
<?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 $customer_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">
                    <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 $customer_name; ?>

                        </h3>
                    </div>
                </div>
            </div>
            <div class="m-portlet__body">
                <div class="m-section">
                    <table style="margin-bottom: 30px;">
                        <tr>
                            <td>Loan Amount</td><td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($summary['loan_amount'],0)))); ?></td>
                            <td>Merchant</td><td><?php echo $summary['merchant_name']; ?></td>
                        </tr>
                        <tr>
                            <td>Total EMIs</td><td><?php echo $summary['tenure']; ?></td>
                            <td>Advance EMIs</td><td><?php echo $summary['tenure']-$summary['remaining_emi']; ?></td>
                        </tr>
                        <tr>
                            <td>Quoted rate</td><td><?php echo $summary['quoted_interest']; ?>%</td>
                            <td>Interest Rate</td><td><?php echo round($summary['interest'],2); ?>%</td>
                        </tr>
                        <tr>
                            <td>Subvention</td><td><?php echo $summary['subvention']; ?>%</td>
                            <td>Processing Fee</td><td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($summary['processing_fee'],0)))); ?></td>
                        </tr>
                        <tr>
                            <td>EMI</td><td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($summary['emi'],0)))); ?></td>
                            <td>Advance Due</td><td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($summary['advance_due'],0)))); ?></td>
                        </tr>
                    </table>

                    <?php if(isset($summary['moratoriums']) && count($summary['moratoriums'])): ?>
                        <div class="panel-group" style="margin-bottom: 16px;">
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    <h4 class="panel-title">
                                        <a data-toggle="collapse" href="#moratorium_details">Moratorium Details</a>
                                        <div style="float: right;margin-right: 14px;"><i class="fa fa-angle-down" style="font-size: 24px;"></i></div>
                                    </h4>
                                </div>
                                <div id="moratorium_details" class="panel-collapse collapse">
                                    <div class="panel-body">
                                        <table class="table">
                                            <thead>
                                            <tr>
                                                <th>Moratorium Period</th>
                                                <th>Moratorium Interest Rate</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <?php $__currentLoopData = $summary['moratoriums']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $moratoriumItem): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <tr>
                                                    <td><?php echo $moratoriumItem->emi_date; ?></td>
                                                    <td><?php echo $moratoriumItem->interest_rate; ?>%</td>
                                                </tr>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    <?php endif; ?>

                    <?php if(isset($schedule_new) && isset($schedule_new[0]) && $schedule_new[0]['bpi_interest'] > 0): ?>
                        <div class="panel-group" style="margin-bottom: 16px;">
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                        Pre-EMI Details
                                </div>
                                <div id="pre_emi_details" class="panel-collapse">
                                    <div class="panel-body">
                                        <table class="table">
                                            <tr>
                                                <th>Date</th>
                                                <th>Amount</th>
                                            </tr>
                                            <tr>
                                                <td><?php echo $schedule_new[0]['emi_date']; ?></td>
                                                <td><?php echo $schedule_new[0]['bpi_interest']; ?></td>
                                            </tr>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    <?php endif; ?>


                    <?php if(isset($schedule) && count($schedule) > 0): ?>
                        <table class="table">
                            <thead style="background-color: #999999;color: white">
                            <th>#</th>
                            <th>EMI Date</th>
                            <th>EMIs Amount</th>
                            
                            <th>Principal Outstanding</th>
                            <th>Interest Due</th>
                            <th>Principal Due</th>
                            
                            <th>Bounce Charges</th>
                            <th>Penalty Charges</th>
                            <th>Moratorium Amount</th>
                            <th>Charges Waived off</th>
                            
                            
                            
                            
                            <th>Payment Details<br>(Amount - Payment Date - Mode)</th>
                            <th>Total Amount Due</th>
                            <th>Total Amount Paid</th>
                            <th>Payment Status</th>
                            <th>Foreclosure Amount</th>
                            </thead>
                            <tbody>
                            <?php $x = 1;?>
                            <?php $__currentLoopData = $schedule; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $emis): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <?php  $total_paid = 0; ?>
                                <tr>
                                    <td>
                                        <?php echo $x; ?></td>
                                    <td><?php echo $emis['emi_date']; ?></td>
                                    <?php $emi_amount = $emis['amount'];
                                        if($emis['moratorium_amount']){
                                            $emi_amount -= $emis['moratorium_amount'];
                                        }
                                    ?>
                                    <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($emi_amount,2)))); ?></td>
                                    
                                    <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($emis['principal_outstanding'],2)))); ?></td>
                                    <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($emis['interest'],2)))); ?></td>
                                    <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($emis['principal'],2)))); ?></td>
                                    
                                    <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($emis['bounce_charges'],2)))); ?></td>
                                    <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($emis['delay_penalty'],2)))); ?></td>
                                    <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($emis['moratorium_amount'],2)))); ?></td>
                                    <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($emis['charges_waived'],2)))); ?></td>
                                    
                                    
                                    
                                    
                                    
                                    <td>
                                        <?php if(isset($emis['transaction'])): ?>
                                            <?php $__currentLoopData = $emis['transaction']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $transaction): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <?php $total_paid = $total_paid + $transaction['amount']; ?>
                                                &#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($transaction['amount'],2)))); ?> - <?php echo date('Y-m-d',strtotime($transaction['payment_date'])); ?> - <?php echo $transaction['status']; ?> <br>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        <?php else: ?>
                                        Not Paid
                                        <?php endif; ?>
                                    </td>
                                    <?php $amountdue = ($emis['amount'] + $emis['bounce_charges'] + $emis['delay_penalty']) - $emis['charges_waived'] ?>
                                    <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($amountdue,0)))); ?></td>
                                    <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($total_paid,0)))); ?></td>
                                    <td><?php echo $emis['payment_status']; ?></td>
                                    <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($emis['fore_closure_amount'],0)))); ?></td>

                                </tr>
                                <?php $x++; ?>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </tbody>
                        </table>
                    <?php elseif(isset($schedule_new) && count($schedule_new) > 0): ?>
                        <table class="table">
                            <thead style="background-color: #999999;color: white">
                            <th>#</th>
                            <th>EMI Date</th>
                            <th>EMIs Amount</th>
                            
                            <th>Principal Outstanding</th>
                            <th>Interest Due</th>
                            <th>Principal Due</th>
                            
                            <th>Bounce Charges</th>
                            <th>Penalty Charges</th>
                            <th>Moratorium Amount</th>
                            <th>Charges Waived off</th>
                            
                            
                            
                            
                            <th>Payment Details<br>(Amount - Payment Date - Mode)</th>
                            <th>Total Amount Due</th>
                            <th>Total Amount Paid</th>
                            <th>Payment Status</th>
                            <th>Foreclosure Amount</th>
                            </thead>
                            <tbody>
                            <?php $x = 1;?>
                            <?php $__currentLoopData = $schedule_new; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $emis): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <?php if($emis['emi_amount'] > 0): ?>
                                    <?php  $total_paid = 0; ?>
                                    <tr>
                                        <td>
                                            <?php echo $x; ?></td>
                                        <td><?php echo $emis['emi_date']; ?></td>
                                        <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($emis['emi_amount'],2)))); ?></td>
                                        
                                        <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($emis['principal_outstanding'],2)))); ?></td>
                                        <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($emis['interest_comp'],2)))); ?></td>
                                        <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($emis['principal_comp'],2)))); ?></td>
                                        
                                        <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($emis['bounce_charges'] ?? 0, 2)))); ?></td>
                                        <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($emis['delay_penalty'] ?? 0, 2)))); ?></td>
                                        <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($emis['moratorium_amount'] ?? 0, 2)))); ?></td>
                                        <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($emis['charges_waived'] ?? 0, 2)))); ?></td>
                                        
                                        
                                        
                                        
                                        
                                        <td>Not Paid</td>
                                        <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($amountdue ?? 0, 0)))); ?></td>
                                        <td>&#8377;<?php echo trim(str_replace('.00','',money_format('%!i',round($total_paid ?? 0, 0)))); ?></td>
                                        <td><?php echo isset($emis['payment_status']) ? $emis['payment_status'] : 'pending'; ?></td>
                                        <td>&#8377; <?php echo trim(str_replace('.00','',money_format('%!i',round($emis['foreclosure_amount'])))) ?></td>

                                    </tr>
                                    <?php $x++; ?>
                                <?php endif; ?>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </tbody>
                        </table>
                    <?php else: ?>
                        <b><center>No Data Found</center></b>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </div>
</div>
<?php echo $__env->make("admin.layouts.footer", array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
