<div class="row">
    <div class="col-md-12">
        <table class="table table-bordered table-hover">
            <thead>
            <tr>
                <th> TT</th>
                <th> Tên</th>
                <th> Đơn giá</th>
                <th style="width: 12%">Chỉ số đầu</th>
                <th style="width: 12%">Chỉ số cuối</th>
                <th style="width: 12%"> Số lượng</th>
                <th style="width: 12%"> Thành tiền</th>
                {{--<th width="25%"> Ghi chú</th>--}}
            </tr>
            </thead>
            <tbody>
            @foreach($details as $detail)
                <tr>
                    <input type="hidden" name="id[]" value="{{ $detail->id }}"/>
                    <td> {{ $loop->index + 1 }}</td>
                    <td> {{ $detail->name }}</td>
                    <td> @if($detail->is_electric || $detail->is_water) Biến
                        động @else {{ number_format($detail->value, 0, '.', '.') }} @endif</td>
                    <td> {{  $detail->start_index }}</td>
                    <td> {{  $detail->end_index }}</td>
                    <td> {{  $detail->qty_text_2 }}</td>
                    <td> {{ number_format(!empty($detail->sum_amount) ? $detail->sum_amount: $detail->amount, 0, '.', '.') }}</td>
                    {{--<td> <textarea name="note[]" class="form-control form-detail">{{ $detail->note }}</textarea></td>--}}


                </tr>
            @endforeach
            <tr>
                <td colspan="6"><b>Tổng</b></td>
                <td>{{  number_format($sum, 0, '.', '.') }}</td>

            </tr>
            @if(!empty($moneyInfoItem->discount))
                <tr>
                    <td colspan="6"><b>Giảm giá</b></td>
                    <td>{{  number_format($moneyInfoItem->discount, 0, '.', '.') }}</td>

                </tr>
                <tr>
                    <td colspan="6"><b>Tổng sau giảm giá</b></td>
                    <td>{{  number_format($sum - $moneyInfoItem->discount, 0, '.', '.') }}</td>

                </tr>
            @endif


            <tr>
                <td colspan="6"><b>Đã thanh toán</b></td>
                <td>{{  number_format($pay, 0, '.', '.') }}</td>

            </tr>
            <tr>
                <td colspan="6"><b>Còn lại</b></td>
                <td>{{  number_format($sum - $moneyInfoItem->discount-$pay, 0, '.', '.') }}</td>

            </tr>
            <tr>

            </tr>
            </tbody>
        </table>
    </div>
    @if($sum - $moneyInfoItem->discount-$pay > 0)
        @if(auth('backend')->user()->can('add-payment'))
            <div class="col-md-12">
                <button class="btn green-jungle btn-paid" data-money-info="{{ $moneyInfoItem->id }}">Thanh toán</button>
            </div>
            <div class="col-md-12 form-paid" id="form-paid-{{ $moneyInfoItem->id }}" style="margin-top: 15px;">

            </div>
        @endif
    @endif
</div>
