@php($statuses = Modules\Contracts\Models\ContractStatus::class)
<div>
    <div class="fs-5 bg-light p-0 m-0 border border-1 rounded-4 py-3 p-2 p-md-0">
        <table class="table table-striped table-hover">
            <thead>
                <tr class="d-none d-lg-table-row" scope="col">
                    <th>Клиент
                    <th>ЖК
                    <th>Площадь
                    <th>Сумма
			<!--	<th>Вознаграждение		-->
                    <!--<th>Статус-->
                    <th>
                </tr>
            </thead>
            <tbody class="">
                @foreach ($contracts as $contract)
                    <tr class="d-flex d-lg-table-row flex-column flex-md-row my-4 my-lg-0" scope="row">
                        <td class="align-middle d-flex flex-row d-lg-table-cell">
                            <div class="d-block d-md-none me-2">
                                <div class="border  rounded-pill "
                                    style="width: 1.5rem; height:1.5rem;background-color:{{ $statuses::getHtmlColor($contract->status) }}">
                                </div>
                            </div>
                            <div class="w-100">
                                @php($clients = $contract->deal->clients)
                                @foreach ($clients as $client)
                                    <div>{{ $client->name }}</div>
                                @endforeach
                            </div>
                        </td>
                        <td class="d-block d-lg-none d-flex flex-row">
                            <div class="w-100">
                                <span class="d-block d-md-none fs-6 text-secondary">Жилой комплекс</span>
                                {{ $contract->deal->complex->name }}
                            </div>
                            <div class="d-flex flex-column d-md-none">
                                <span class="d-block d-md-none fs-6 text-secondary">Площадь</span>
                                <div>
                                    {{ $contract->square }} <span class="d-inline d-lg-none"> м<sup>2</sup></span>
                                </div>
                            </div>
                        </td>
                        <td class="align-middle d-none d-lg-table-cell">
                            {{ $contract->deal->complex->name }}
                        </td>
                        <td class="align-middle d-none d-lg-table-cell">
                            {{ $contract->square }}
                        </td>
                        <td class="align-middle d-none d-lg-table-cell">
                            <?php
                            $price = ($contract->price) ? Number::forHumans($contract->price, 2) : '';
                            $price = str_replace('million', 'млн', $price);
                            $price = str_replace('thousand', 'тыс', $price);
                            $price = ($price) ? $price . ' &#8381' : '';
                            $price = str_replace(' ', '&nbsp;', $price);
                            ?>
                            {!! $price !!}
                        </td>
				            <!--	<td class="align-middle d-none d-lg-table-cell">	-->
                            <?php
                			$contract->reward = GetAgentPaymentForContract($contract);
                            //$contract->reward = $contract->reward ? $contract->reward : 0;
                            $reward = Number::forHumans($contract->reward, precision: 2);
                            $reward = str_replace('million', 'млн', $reward);
                            $reward = str_replace('thousand', 'тыс', $reward);
                            $reward = $reward . ' &#8381';
                            $reward = str_replace(' ', '&nbsp;', $reward);
                			?>
				
                            @if ($contract->status == 'TREATY')
				<!--			<span class="fw-bold">{!! $reward !!}</span>		-->
				 	
                            @else
				<!--			<span style="text-decoration:underline;text-decoration-style: dotted;cursor:pointer"
                                    title='Вознаграждение будет зафиксировано при изменении статуса на "Выплачено"'>
                                    {!! $reward !!}
                                </span>	--> 	
							@endif
                 
				<!--	</td>	-->
                  
                        <td class="d-block d-lg-none d-flex flex-row">
                            <div class="w-100">
                                <span class="d-block d-md-none fs-6 text-secondary">Стоимость</span>
                                {!! $price !!}
                            </div>
				<!--
						<div class="d-flex flex-column">
                                <span class="d-block d-md-none fs-6 text-secondary">Вознаграждение</span>
                                <div>
                                    {!! $reward !!}
                                </div>
                            </div>
				-->
                        </td>
                        <td class="align-middle d-none d-md-table-cell">
                            <div class="py-1 px-3 border rounded rounded-5 text-center"
                                style="background-color:{{ $statuses::getHtmlColor($contract->status) }}">
                                {{ $statuses::getName($contract->status) }}
                            </div>
                        </td>
                        <td class="align-middle ">
                            <div class="d-block d-md-none text-end fs-6">
                                <a class="icon-link icon-link-hover" style="--bs-link-hover-color-rgb: 25, 135, 84;"
                                    href="{{ route('contract', ['contract' => $contract->id]) }}">
                                    Детали
                                    <svg xmlns="http://www.w3.org/2000/svg" class="bi" viewBox="0 0 16 16"
                                        aria-hidden="true">
                                        <path
                                            d="M1 8a.5.5 0 0 1 .5-.5h11.793l-3.147-3.146a.5.5 0 0 1 .708-.708l4 4a.5.5 0 0 1 0 .708l-4 4a.5.5 0 0 1-.708-.708L13.293 8.5H1.5A.5.5 0 0 1 1 8z" />
                                    </svg>
                                </a>
                            </div>
                            <div class="dropdown d-none d-md-block" style="">
                                <button class="btn btn-light" type="button" id="dropdownMenuButton"
                                    data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                    <i class="bi bi-three-dots-vertical"></i>
                                </button>
                                <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
                                    <a class="dropdown-item"
                                        href="{{ route('contract', ['contract' => $contract->id]) }}">Детали</a>
                                    <form method="post"
                                        action="{{ route('contract.delete', ['contract' => $contract]) }}">
                                        @csrf
                                        <button class="dropdown-item disabled" type="submit">Удалить</button>
                                    </form>
                                </div>
                            </div>
                        </td>
                    </tr>
                @endforeach
            </tbody>
        </table>
    </div>
</div>
