<script>
    $(document).ready(function (){
        $('#policy-issued-jvs').dataTable();
    });
    var f = document.getElementsByClassName("fr");
    for (var i = 0; i < f.length; i++) {
        f[i].innerHTML = (i+1)+".";
    }
</script>
<style>
    #policy-issued-jvs tr:nth-child(even) {
        background-color: #f2f2f2;
    }
    #policy-issued-jvs th, td {
        text-align: left;
        padding: 5px;
    }
    #policy-issued-jvs tr:hover {background-color: #99a6fd;}
</style>
<table id="policy-issued-jvs" style="width: 100%; border-collapse: collapse">
    <thead>
    <tr style="background-color: #a1b5d3">
        <th>No</th>
        <th>Debited Account.</th>
        <th>Credited Account</th>
        <th>JV Amount</th>
        <th>JV Narration</th>
        <th>1st Approved By</th>
        <th>1st Approved At</th>
        <th>2nd Approved By</th>
        <th>2nd Approved At</th>
        <th>Created By</th>
        <th>View File</th>
    </tr>
    </thead>
    @foreach($jvs as $jv)
        <tr class="docs-row">
            <td class="fr"></td>
            <td><b class="error">DN{!! $jv->acc_dr !!}</b></td>
            <td><b class="success">DN{!! $jv->acc_cr !!}</b></td>
            <td><b>{!! number_format($jv->amount,2) !!}</b></td>
            <td><b class="error">{!! $jv->nar !!}</b></td>
            <td>
                @if($jv->first_approved == 1)
                    @if($jv->firstApprover)
                        {!! $jv->firstApprover->firstName." ".$jv->firstApprover->lastName !!}
                    @endif
                @else
                    -
                @endif
            </td>
            <td>
                @if($jv->first_approved == 1)
                    {!! date('d/m/Y', strtotime($jv->first_approved_at)) !!}
                @else
                    -
                @endif
            </td>
            <td>
                @if($jv->second_approved == 1)
                    @if($jv->secondApprover)
                        {!! $jv->secondApprover->firstName." ".$jv->secondApprover->lastName !!}
                    @endif
                @else
                    -
                @endif
            </td>
            <td>
                @if($jv->second_approved == 1)
                    {!! date('d/m/Y', strtotime($jv->second_approved_at)) !!}
                @else
                    -
                @endif
            </td>
            <td>
                @if($jv->user)
                    {!! $jv->user->firstName." ".$jv->user->lastName !!}
                @endif
            </td>
            <td style="width: 50px">
                <i class="fa fa-eye error" style="font-size: 14px; cursor: pointer"></i>
            </td>
        </tr>
    @endforeach
    <tfoot>
    <tr style="background-color: #a1b5d3">
        <th>No</th>
        <th>Debited Account.</th>
        <th>Credited Account</th>
        <th>JV Amount</th>
        <th>JV Narration</th>
        <th>1st Approved By</th>
        <th>1st Approved At</th>
        <th>2nd Approved By</th>
        <th>2nd Approved At</th>
        <th>Created By</th>
        <th>View File</th>
    </tr>
    </tfoot>
</table>
