<?php $__env->startSection('title', 'Company Payments Reports'); ?>


<?php $__env->startSection('internal-js'); ?>
    <script>
        $(document).ready(function () {
            $('#insurers1').DataTable( {
                dom: 'lBfrtip',
                buttons: [
                    { extend: 'excel', className: 'download-buttons'},
                ]
            } );
            $('#insurer-list').select2();
            $('#status-list').select2();
            $('#currency-list').select2();
            $('#type-list').select2();
            $('#receipt-type-list').select2();

            $('#receipt-type-list').on('change', function (){
                let type = $(this).val();

                if(type == 'premium'){
                    $('#clients-div').show();
                    $('#insurers-div').hide();
                }else if(type == 'commission'){
                    $('#clients-div').hide();
                    $('#insurers-div').show();
                }else{
                    $('#clients-div').hide();
                    $('#insurers-div').hide();
                }

            });

            $('#client-name').on('input paste', function (){
                let name = $(this).val();
                if(name != ""){
                    $.ajax({
                        method: 'GET',
                        url: '/search-client-by-name/'+name,
                        data: name,
                        success: function (res){
                            if(res != ""){
                                $('#client-search-results').show();
                                $('#client-search-results').html(res);
                            }else{
                                $('#client-search-results').hide();
                            }
                        }
                    });
                }

            });


            $('#date-from').on('change', function (){
                $('#date-to').attr('required', true);
            });
            $('#date-to').on('change', function (){
                $('#date-from').attr('required', true);
            });
        });
    </script>
<?php $__env->stopSection(); ?>


<?php $__env->startSection('internal-css'); ?>
    <style>
        #insurers1 tr:nth-child(even) {
            background-color: #f2f2f2;
        }
        #insurers1 th, td {
            text-align: left;
            padding: 5px;
        }
        #insurers1 tr:hover {background-color: #d8d9e1;}
    </style>

<?php $__env->stopSection(); ?>


<?php $__env->startSection('headers'); ?>
    <?php echo $__env->make('headers.finance-header', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<?php $__env->stopSection(); ?>


<?php $__env->startSection('heading', 'Company Payments Report'); ?>
<?php $__env->startSection('done-by', ''); ?>


<?php $__env->startSection('content'); ?>

    <div class="inputDivider" style="margin-top: 10px; text-align: left; background-color: lightcyan">
        <?php echo Form::open(['action'=>['Payments\PaymentController@showPayments'], 'method'=>'POST', 'id'=>'filter-payments', 'class'=>'fields-small']); ?>

        <div class="guestDetails_input_right">
            <div class="guestDetails_inputLabel">
                &nbsp;
            </div>
            <div class="guestDetails_input_right">
                <button type="submit" name="search" style="cursor: pointer"><i class="fa fa-search" aria-hidden="true"></i></button>
            </div>
        </div>
        <div class="guestDetails_input_right">
            <div class="guestDetails_inputLabel">
                Date Added To:<span class="error">*</span>
            </div>
            <div class="guestDetails_input_right">
                <?php echo Form::date('to', $search['to'] ?? null, ['id'=>'date-to','style'=>'cursor:pointer', 'class'=>'input-text-height']); ?>

            </div>
        </div>
        <div class="guestDetails_input_right">
            <div class="guestDetails_inputLabel">
                Date Added From:<span class="error">*</span>
            </div>
            <div class="guestDetails_input_right">
                <?php echo Form::date('from',  $search['from'] ?? null, ['id'=>'date-from','style'=>'cursor:pointer', 'class'=>'input-text-height']); ?>

            </div>
        </div>
        <div class="guestDetails_input_right">
            <div class="guestDetails_inputLabel">
                Payment Voucher No:<span class="error">*</span>
            </div>
            <div class="guestDetails_input_right">
                <?php echo Form::text('payment-no', '', ['size'=>10,'class'=>'input-text-height', 'id'=>'receipt-no','autocomplete'=>'off']); ?>

            </div>
        </div>
        <div class="guestDetails_input_right">
            <div class="guestDetails_inputLabel">
                Currency:<span class="error">*</span>
            </div>
            <div class="guestDetails_input_right">
                <select name="currency" id="currency-list" style="width: 100px">
                    <option value="all">ALL</option>
                    <?php $__currentLoopData = $currencies; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($row->id); ?>"><?php echo strtoupper($row->abbr); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>
        </div>
        <div class="guestDetails_input_right">
            <div class="guestDetails_inputLabel">
                Payment Status:<span class="error">*</span>
            </div>
            <div class="guestDetails_input_right">
                <select name="payment-status" id="type-list" style="width: 120px">
                    <option value="all" >ALL</option>
                    <option value="reversed">REVERSED</option>
                    <option value="allocated">FULLY ALLOCATED</option>
                    <option value="pending">PENDING ALLOCATION</option>
                </select>
            </div>
        </div>
        <div class="guestDetails_input_right">
            <div class="guestDetails_inputLabel">
                Payment Type:<span class="error">*</span>
            </div>
            <div class="guestDetails_input_right">
                <select name="payment-type" id="receipt-type-list" style="width: 120px">
                    <option value="all" >ALL</option>
                    <option value="bill-payment">BILL PAYMENT</option>
                    <option value="bank-transfer">BANK TRANSFER</option>
                    <option value="payroll">PAYROLL</option>
                </select>
            </div>
        </div>
        <div class="guestDetails_inputDividerNone" style="height: 0"></div>
        <?php echo Form::close(); ?>

    </div>

    <?php if($payments != null): ?>
        <div class="guestDetails_inputDivider"></div>
        <!--View and Setup your Insurers-->
        <div>
            <!--Export Links/Buttons-->
            <span onclick="this.parentElement.style.display='none'" class="topright" style="margin-left: 20px">&times</span>
            <table id="insurers1" style="width: 100%; border-collapse: collapse; ">
                <thead>
                <tr style="background-color: #a1b5d3">
                    <th>No</th>
                    <th>PV No.</th>
                    <th>PV Type</th>
                    <th>Paid From</th>
                    <th>GL Account</th>
                    <th>Paid To</th>
                    <th>Mode</th>
                    <th>REF</th>
                    <th>Narration</th>
                    <th>Amount</th>
                    <th>Currency</th>
                    <th>Exchange rate</th>
                    <th>Status</th>
                    <th>Date Paid</th>
                    <th>Date of Payment</th>
                    <th>User</th>
                    <th></th>
                </tr>
                </thead>
                <tbody>
                <?php if($payments != null || session('payments')): ?>
                    <?php $__currentLoopData = $payments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $pv): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td class="ar"></td>
                            <td><a href="<?php echo e(url('payment/'.$pv->stamp.'/finance?type=summary')); ?>" class="inner"><b class="error">PV<?php echo e($pv->pv_id); ?></b></a></td>
                            <td><?php echo e($pv->type); ?></td>
                            <td>
                                <b>
                                    <?php if($pv->account != null): ?>
                                        <?php echo strtoupper($pv->account->acc_name); ?>

                                    <?php endif; ?>
                                </b>
                            </td>
                            <td>
                                <b>
                                    <?php if($pv->glAccount != null): ?>
                                        <?php echo strtoupper($pv->glAccount->acc_name); ?>

                                    <?php endif; ?>
                                </b>
                            </td>
                            <td>
                                <?php if($pv->type == 'refund-premium'): ?>
                                    <?php if($pv->client != null): ?>
                                        <?php echo strtoupper($pv->client->nms); ?>

                                    <?php endif; ?>
                                <?php elseif($pv->type == 'remit-premium'): ?>
                                    <?php if($pv->insurer != null): ?>
                                        <?php echo strtoupper($pv->insurer->nm); ?>

                                    <?php endif; ?>
                                <?php endif; ?>
                            </td>

                            <td>
                                <?php if($pv->modeOfPayment != null): ?>
                                    <?php echo $pv->modeOfPayment->name; ?>

                                    <?php if($pv->subModeOfPayment != null): ?>
                                        - <?php echo $pv->subModeOfPayment->name; ?>

                                    <?php endif; ?>
                                <?php endif; ?>
                            </td>
                            <td><?php echo $pv->ref; ?></td>
                            <td><?php echo $pv->nar; ?></td>
                            <td><b><?php echo number_format($pv->amount,2); ?></b></td>
                            <td>
                                <?php if($pv->currencyDetails != null): ?>
                                    <b class="error"><?php echo $pv->currencyDetails->abbr; ?></b>
                                <?php endif; ?>
                            </td>
                            <td><?php echo number_format($pv->conversion_rate,2); ?></td>
                            <td><?php echo $pv->pv_status; ?></td>
                            <td><?php echo e(date('d/m/Y', strtotime($pv->pv_date))); ?></td>
                            <td><?php echo e(date('d/m/Y', strtotime($pv->created_at))); ?></td>
                            <td>
                                <?php if($pv->user != null): ?>
                                    <?php echo $pv->user->firstName[0].". ".$pv->user->lastName; ?>

                                <?php endif; ?>
                            </td>
                            <td><a href="<?php echo e(url('payment-pdf/'.$pv->stamp.'/AddWatermark')); ?>" class="inner" target="_blank"><i class="fa fa-print error" style="font-size: 16px"></i></a></td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                <?php endif; ?>
                </tbody>
                <tfoot>
                <tr style="background-color: #a1b5d3">
                    <th>No</th>
                    <th>PV No.</th>
                    <th>PV Type</th>
                    <th>Paid From</th>
                    <th>GL Account</th>
                    <th>Paid To</th>
                    <th>Mode</th>
                    <th>REF</th>
                    <th>Narration</th>
                    <th>Amount</th>
                    <th>Currency</th>
                    <th>Exchange rate</th>
                    <th>Status</th>
                    <th>Date Paid</th>
                    <th>Date of Payment</th>
                    <th>User</th>
                    <th></th>
                </tr>
                </tfoot>
            </table>

        </div>
    <?php endif; ?>

<?php $__env->stopSection(); ?>


<?php $__env->startSection('modal_heading'); ?>
    <h1>Company Payments</h1>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('modal_title'); ?>
    <h3><u>Dashboard Functionalities</u></h3>
    <b>
        <ol>
            <li>View all Types of Payments for the Company</li>
            <li>Filter through available Payments to Generate Reports</li>
            <li>Export Payments Report</li>

        </ol>
    </b>
<?php $__env->stopSection(); ?>




<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\finewood\resources\views/payments/payments.blade.php ENDPATH**/ ?>