
<?php echo $__env->make('admin.layouts.header', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<?php echo $__env->make('admin.layouts.sidebar', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<style>
    .hidden{
        display: none;
    }
    .font-weight{
        font-weight: 600;
    }
    table{
        width: 100%;
        font-family: Arial;
    }
    .emi-form > thead > tr > th{
        font-weight: 600 !important;
    }
    .payable-amt{
        border-top-style: solid;
        border-bottom-style: solid;
    }
    .interest_rate{
        text-transform: capitalize;
    }
    .datepicker tbody tr > td[class='day']{
        border-color: #34b9c3;
        color: black;
        border-style: dashed;
        border-width: 1px;
    }
    .panel-group{
        padding-top: 18px;
    }
    .panel-default{
        padding-bottom: 4px;
    }
    .panel-collapse{
        background-color: #ffffff;
        padding: 10px;
        border: 1px solid #dedada;
    }
    h4.panel-title > a{
        font-size: 14px;
        color: #5f5a5a !important;
    }
    .panel-heading {
        background-color: #f1f1f1;
        border: 1px solid #e0dfe0;
        padding-left: 10px;
        padding-top: 6px;
        cursor: pointer;
    }
</style>
<div class="m-grid__item m-grid__item--fluid m-wrapper">
    <!-- BEGIN: Subheader -->
    <div class="m-subheader ">
        <div class="d-flex align-items-center">
            <div class="mr-auto">
                <h3 class="m-subheader__title m-subheader__title--separator">
                    Loan Schedule -  <?php echo ucwords($summary->name) ?? '-' ?>
                </h3>
            </div>

        </div>
    </div>
<?php setlocale(LC_MONETARY, 'en_IN.UTF-8'); ?>
    <!-- END: Subheader -->
    <div class="m-content">
        <div class="m-portlet m-portlet--mobile">
            <div class="m-portlet__head">
                <div class="m-portlet__head-caption" style="position:relative;">
                    <div class="m-portlet__head-title">
                        <span class="m-portlet__head-icon">
                            <i class="fa fa-calendar"></i>
                        </span>
                        <h3 class="m-portlet__head-text">
                            Loan Schedule -  <?php echo ucwords($summary->name) ?? '-' ?>
                        </h3>
                    </div>
                    <div class="pull-right btn btn-primary" style="position: absolute;right: 0px;top: 19px;"><a style="color: white;" target="_blank" href="/admin/payment/start_v1/<?php echo $summary->id; ?>">Go To Payment Page</a></div>
                </div>
            </div>
            <div class="m-portlet__body">
                <div class="m-section">
                    <div style="padding-top: 20px;color: #0b0b0b;font-weight: bolder">Loan Summary</div>
                    <hr/>
                    <table style="margin-bottom: 30px;">
                        <tr>
                            <td>Loan Amount</td><td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($approved_amount,0)))); ?></td>
                            <td>Merchant</td><td><?php echo $summary->merchant->merchant_name; ?></td>
                        </tr>
                        <tr>
                            <td>Total EMIs</td><td><?php echo $summary->emi->tenure; ?></td>
                            <td>Advance EMIs</td><td><?php echo $summary->emi->tenure - $summary->emi->remaining_emi; ?></td>
                        </tr>
                        <tr>
                            <td>Subvention</td><td><?php echo $summary->emi->subvention; ?>%</td>
                            <td>Processing Fee</td><td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($summary->emi->processing_fee,0)))); ?></td>
                        </tr>
                        <tr>
                            <td>EMI</td><td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($schedule[0]->emi_amount ?? 0,0)))); ?></td>
                            <td>BPI Interest</td><td>&#8377;<?php echo isset($schedule[0]->bpi_interest) ? $schedule[0]->bpi_interest : 0; ?></td>
                        </tr>
                        <tr>
                            <td>Morat Interest</td><td>&#8377;<?php echo isset($schedule[0]->morat_interest) ? $schedule[0]->morat_interest : 0; ?></td>
                        </tr>
                    </table>

                    <?php if(!isset($schedule_summary)): ?>
                        <?php if(isset($schedule)): ?>
                            <table class="table">
                                <tr>
                                    <td>Installment Number</td>
                                    <td>EMI Date</td>
                                    <td>Due Date</td>
                                    <td>Interest</td>
                                    <td>Principal</td>
                                    <td>EMI Amount</td>
                                    <td>Total Payable</td>
                                    <td>Principal Outstanding</td>
                                    <td>Foreclosure Amount</td>
                                </tr>
                                <?php $__currentLoopData = $schedule; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $scheduleItem): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                        <td><?php echo $scheduleItem->installment_number; ?></td>
                                        <td><?php echo $scheduleItem->emi_date; ?></td>
                                        <td><?php echo $scheduleItem->due_date; ?></td>
                                        <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($scheduleItem->interest_comp ?? 0, 0)))); ?></td>
                                        <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($scheduleItem->principal_comp ?? 0, 0)))); ?></td>
                                        <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($scheduleItem->emi_amount ?? 0, 0)))); ?></td>
                                        <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($scheduleItem->total_payable ?? 0, 0)))); ?></td>
                                        <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($scheduleItem->principal_outstanding ?? 0, 0)))); ?></td>
                                        <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($scheduleItem->foreclosure_amount ?? 0, 0)))); ?></td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </table>
                        <?php else: ?>
                            <b><center>No Data Found</center></b>
                        <?php endif; ?>
                    <?php else: ?>
                        <?php if(isset($schedule_summary)): ?>
                            <?php $todayDate = \Carbon\Carbon::now()->timestamp;

                            ?>
                            <table>
                                <tr><td>Pre-EMI Due</td><td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($schedule_summary['message']['Pre-EMI due'])))); ?></td><td>Principal Due</td><td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($schedule_summary['message']['Principal due'])))); ?></td></tr>
                                <tr><td>Interest due</td><td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($schedule_summary['message']['Interest due'])))); ?></td><td>Moratorium due</td><td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($schedule_summary['message']['Moratorium due'])))); ?></td></tr>
                                <tr><td>Bounce charges due</td><td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($schedule_summary['message']['Bounce charges due'])))); ?></td><td>Penal charges due</td><td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($schedule_summary['message']['Penal charges due'])))); ?></td></tr>
                                <tr><td>PF due</td><td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($schedule_summary['message']['PF due'])))); ?></td><td>Advance due</td><td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($schedule_summary['message']['Advance due'])))); ?></td></tr>
                                <tr><td>Interest Outstanding</td><td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($schedule_summary['message']['Interest Outstanding'])))); ?></td></tr>
                            </table>
                            <table class="table" style="margin-top: 30px;">
                                <tr>
                                    <td>EMI Date</td>
                                    <?php if($schedule_summary['data'][0]['pre_emi_amount'] > 0): ?>
                                    <td>Pre-EMI Amount</td>
                                    <?php endif; ?>
                                    <td>Interest Due</td>
                                    <td>Principal Due</td>
                                    <td>EMI Amount</td>
                                    <td>Bounce Charges</td>
                                    <td>Delay Penalty</td>
                                    <td>Charges Waived</td>
                                    <td>Total Amount Paid</td>
                                    <td>Total Amount Due</td>
                                    <td>Opening POS</td>
                                    <td>Closing POS</td>
                                    <td>Foreclosure Amount</td>
                                </tr>
                                <?php $__currentLoopData = $schedule_summary['data']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $scheduleItem): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <?php if($scheduleItem['emi_amount']): ?>
                                        <?php $_emi_date = \Carbon\Carbon::parse($scheduleItem['emi_date'])->timestamp; ?>
                                    <tr>
                                        <td><div style="position: relative;">
                                                <?php if($scheduleItem['total_amount_due'] == 0): ?>
                                                    <span style="position: absolute;left: -25px;"><i style="color: green;" class="fa fa-check-circle" aria-hidden="true"></i></span>
                                                <?php elseif($_emi_date < $todayDate && $scheduleItem['total_amount_due']): ?>
                                                    <span style="position: absolute;left: -25px;"><i style="color: red;" class="fa fa-times-circle-o" aria-hidden="true"></i></span>
                                                <?php else: ?>
                                                    <span style="position: absolute;left: -25px;"><i style="color: yellow;" class="fa fa-circle" aria-hidden="true"></i></span>
                                                <?php endif; ?>

                                            </div> <?php echo $scheduleItem['emi_date']; ?></td>
                                        <?php if($schedule_summary['data'][0]['pre_emi_amount']): ?>
                                        <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($scheduleItem['pre_emi_amount'] ?? 0, 0)))); ?> <?php if($scheduleItem['pre_emi_paid']): ?> <div>Pre-EMI Paid: <?php echo $scheduleItem['pre_emi_paid']; ?><?php endif; ?></div></td>
                                        <?php endif; ?>
                                        <td style="<?php if($_emi_date < $todayDate && $scheduleItem['interest_paid'] != $scheduleItem['interest_due']): ?> color:red; <?php endif; ?>">&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($scheduleItem['interest_due'] ?? 0, 0)))); ?> <?php if($scheduleItem['interest_paid']): ?> <div>Interest Paid: &#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($scheduleItem['interest_paid'])))); ?><?php endif; ?></div></td>
                                        <td style="<?php if($_emi_date < $todayDate && $scheduleItem['principal_paid'] != $scheduleItem['principal_due']): ?> color:red; <?php endif; ?>">&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($scheduleItem['principal_due'] ?? 0, 0)))); ?> <?php if($scheduleItem['principal_paid']): ?> <div>Principal Paid: &#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($scheduleItem['principal_paid'])))); ?><?php endif; ?></div></td>
                                        <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($scheduleItem['emi_amount'] ?? 0, 0)))); ?></td>
                                        <td style="<?php if($scheduleItem['bounce_paid'] != $scheduleItem['bounce_charges']): ?> color:red; <?php endif; ?>">&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($scheduleItem['bounce_charges'] ?? 0, 0)))); ?> <?php if($scheduleItem['bounce_paid']): ?> <div>Bounce Charges Paid: <?php echo $scheduleItem['bounce_paid']; ?><?php endif; ?></div></td>
                                        <td style="<?php if($scheduleItem['penal_paid'] != $scheduleItem['delay_penalty']): ?> color:red; <?php endif; ?>">&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($scheduleItem['delay_penalty'] ?? 0, 0)))); ?> <?php if($scheduleItem['penal_paid']): ?> <div>Delay Penalty Paid: <?php echo $scheduleItem['penal_paid']; ?><?php endif; ?></div></td>
                                        <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($scheduleItem['charges_waived'] ?? 0, 0)))); ?></td>
                                        <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($scheduleItem['total_amount_paid'] ?? 0, 0)))); ?>

                                        <?php if($scheduleItem['payment_details']): ?><div style="color: green;">(Payment Received: <?php echo $scheduleItem['payment_details']; ?>)</div><?php endif; ?>
                                        </td>
                                        <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($scheduleItem['total_amount_due'] ?? 0, 0)))); ?></td>
                                        <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($scheduleItem['opening_pos'] ?? 0, 0)))); ?></td>
                                        <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($scheduleItem['closing_pos'] ?? 0, 0)))); ?></td>
                                        <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($scheduleItem['foreclosure_amount'] ?? 0, 0)))); ?></td>
                                    </tr>
                                    <?php endif; ?>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </table>
                        <?php else: ?>
                            <b><center>No Data Found</center></b>
                        <?php endif; ?>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </div>
</div>
<?php echo $__env->make("admin.layouts.footer", array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
