<?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">
                    EMIs
                </h3>
            </div>

        </div>
    </div>
<?php setlocale(LC_MONETARY, 'en_IN.UTF-8'); ?>
<!-- END: Subheader -->
    <div class="m-content">
        <?php if(Session::has('success')): ?>
            <div class="alert alert-success alert-dismissible fade show" role="alert">
                <button type="button" class="close" data-dismiss="alert" aria-label="Close"></button>
                <?php echo e(Session::get('success')); ?>

            </div>
        <?php endif; ?>
        <?php if(Session::has('error')): ?>
            <div class="alert alert-danger alert-dismissible fade show" role="alert">
                <button type="button" class="close" data-dismiss="alert" aria-label="Close"></button>
                <?php echo e(Session::get('error')); ?>

            </div>
        <?php endif; ?>
        <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">
                            EMIs
                        </h3>
                    </div>
                </div>
            </div>
            <div class="m-portlet__body">
                <div class="m-section">
                    <div class="m-section__content">
                        <div class="col-md-12">
                            <form id="merchant_offer" class="form-horizontal" method="POST">
                                <input name="_token" value="<?php echo e(csrf_token()); ?>" type="hidden">
                                <input name="search" value="search" type="hidden">
                                <input name="source" value="source" type="hidden">
                                <div class="row" style="padding-bottom: 10px;margin-left: -32px;padding-top: 10px;">
                                    <div class="col-md-3">
                                        <input type="text" name="from_date" id="fl_from_date" class="form-control" placeholder="From Date" value="<?php echo e(Request::old('from_date', $from_date)); ?>" autocomplete="off"/>
                                    </div>
                                    <div class="col-md-3">
                                        <select class="form-control" name="merchant_id" id="merchant_id">
                                            <option value="">Select Merchant</option>
                                            <?php $__currentLoopData = $merchants; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index=>$merchant): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option data-index="<?php echo $index; ?>" value="<?php echo $merchant->id; ?>" <?php if(isset($merchant_id) && $merchant_id == $merchant->id): ?> selected="selected" <?php endif; ?>><?php echo $merchant->merchant_name; ?></option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </select>
                                    </div>
                                    <div class="col-md-3">
                                        <select class="form-control" name="category_id" id="category_id">
                                            <option value="">Select Category</option>
                                        </select>
                                    </div>
                                    <div class="col-md-3">
                                        <select class="form-control" name="lender_id" id="lender_id">
                                            <option value="">Select Lender</option>
                                            <?php $__currentLoopData = $lenders; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $lender): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option data-index="<?php echo $index; ?>" value="<?php echo $lender->id; ?>" <?php if(isset($lender_id) && $lender_id == $lender->id): ?> selected="selected" <?php endif; ?>><?php echo $lender->name; ?></option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </select>
                                    </div>
                                    <div class="col-md-3">
                                        <input type="text" name="keyword" value="" class="form-control" id="keyword" placeholder="Search By Name, Email, Phone"/>
                                    </div>

                                    <div class="col-md-3 calculate-for-emi">
                                        <input type="submit" class="btn btn-accent" value="Get EMIs"  style="margin-right: 20px;"/>
                                        <div class="btn btn-primary" onclick="return window.location = '/admin/emis';">Clear Filter</div>
                                    </div>
                                </div>
                            </form>
                        </div>

                        <div class="emi-dues-summary m-section__content">
                            <?php if(isset($emis) && count($emis) > 0): ?>
                                <div style="margin-bottom: 11px;font-size: 15px;font-weight: 800;">Total EMIs: <?php echo $applications->total() ?? count($emis); ?> <a href="?export=true&<?php echo http_build_query($_POST);?>" style="color: white;text-decoration: none;"><span class="pull-right col-md-1 form-control btn btn-primary">Export</span></a><a href="?paymentfile=true&<?php echo http_build_query($_POST);?>" style="color: white;text-decoration: none;"><span class="pull-right col-md-1 form-control btn btn-primary">Payment File</span></a><a href="?ovderdue=true&<?php echo http_build_query($_POST);?>" style="color: white;text-decoration: none;"><span class="pull-right col-md-1 form-control btn btn-primary">Over Due File</span></a></div>
                                <table class="table">
                                    <thead style="background-color: #999999;color: white">
                                    <th>#</th>
                                    <th>Name</th>
                                    <th>Merchant</th>
                                    <th>Lender</th>
                                    <th style="display: none;">Email</th>
                                    <th style="display: none;">Phone</th>
                                    <th style="display: none;">Amount</th>
                                    <th style="display: none;">Nach Status</th>
                                    <th>Application</th>
                                    </thead>
                                    <tbody>
                                    <?php $total_amount = 0;
                                    $i= 1?>
                                    <?php $__currentLoopData = $emis; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $emi): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <tr>
                                            <td><?php echo $i; ?></td>
                                            <td>
                                                <?php if($emi['is_error']): ?>
                                                    <i class="fa fa-exclamation-triangle" aria-hidden="true" style="margin-right: 6px;color: red;" title="<?php if($emi['is_error'] == 1): ?> Bank Details Missing <?php elseif($emi['is_error']): ?> ProForma Missing <?php endif; ?>"></i>
                                                <?php endif; ?>
                                                <?php echo $emi['name']; ?></td>
                                            <td><?php echo $emi['merchant_name']; ?></td>
                                            <td><?php echo $emi['lender_name']; ?></td>
                                            <td style="display: none"><?php echo $emi['email'] ?? ''; ?></td>
                                            <td style="display: none"><?php echo $emi['phone'] ?? ''; ?></td>
                                            <td style="display: none">&#8377;<?php echo isset($emi['emi_amount']) ? str_replace('.00','',money_format('%!i', $emi['emi_amount'])) : '0'; ?></td>
                                            <td style="display: none"><?php echo $emi['nach_status'] ?? ''; ?></td>
                                            <td><a class="btn btn-primary" href="/admin/consumer-applications/edit/<?php echo $emi['id']; ?>" target="_blank">Go To Application</a></td>
                                        </tr>
                                        <?php $total_amount += $emi['emi_amount'] ?? 0;
                                        $i++;?>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    <tr style="display: none;background-color: #999999;color: white">
                                        <td colspan="7" style="text-align: center"><strong>Total EMI Amount</strong></td>
                                        <td><strong>&#8377;<?php echo str_replace('.00','',money_format('%!i',$total_amount)); ?></strong></td>
                                    </tr>
                                    </tbody>
                                </table>
                            <?php else: ?>
                                <b><center>No Data Found</center></b>
                            <?php endif; ?>
                        </div>
                        <div>
                            <?php echo $applications->appends(\Request::except('page', '_token'))->render(); ?>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php echo $__env->make("admin.layouts.footer", array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
