@if(count($plcy->CreditNotes) > 0)
    <table id="debitNotes" style="width: 100%; border-collapse: collapse">
        <thead>
        <tr style="background-color: #a1b5d3">
            <th>No</th>
            <th>CN Number</th>
            <th>Type</th>
            <th>Total Credit Amount</th>
            <th>Date Done</th>
            <th>User</th>
            <th>Status</th>
        </tr>
        </thead>
        <tbody>

        @foreach($plcy->CreditNotes as $row)
            <tr>
                <td class="cr"></td>
                <td><a href="{{url('credit-note/'.$row->cr_id.'/finance?type=summary')}}" class="inner" style="color: red; font-weight: bold" target="_blank" >
                        @if($row->cr_id < 100000)
                            CN{{sprintf("%06d", $row->cr_id)}}
                        @else
                            CN{{$row->cr_id}}
                        @endif
                    </a></td>
                <td>
                    @if($row->creditType($row->end_type) != null)
                        {{$row->creditType($row->end_type)}}
                    @else
                        -
                    @endif

                </td>
                <td style="font-weight: bold">
                    @if($row->total_premium != null)
                        {{number_format($row->total_premium,2)}}
                    @else
                        0
                    @endif
                </td>
                <td>
                    @if($row->created_at != null)
                        {{date('d-m-Y', strtotime($row->created_at))}}
                    @else
                        -
                    @endif
                </td>
                <td>
                    @if($row->user != null)
                        {{$row->user->firstName." ".$row->user->lastName}}
                    @else
                        -
                    @endif
                </td>
                <td>
                    @if($row->first_confirmed != 0)
                        <span class="success"><i><b>Authorized</b></i> <i class="fa fa-check" aria-hidden="true"></i></span>
                    @else
                        <span class="error"><i><b>Unauthorized!</b></i></span>
                    @endif
                </td>
            </tr>
        @endforeach

        </tbody>
        <tfoot>
        <tr style="background-color: #a1b5d3">
            <th>No</th>
            <th>CN Number</th>
            <th>Type</th>
            <th>Total Credit Amount</th>
            <th>Date Done</th>
            <th>User</th>
            <th>Status</th>
        </tr>

        </tfoot>
    </table>
@endif
