KUJUNTI.ID MINISH3LL
Path : /var/www/html/thb_loan_system/storage/framework/views/
(S)h3ll Cr3at0r :
F!le Upl0ad :

B-Con CMD Config cPanel C-Rdp D-Log Info Jump Mass Ransom Symlink vHost Zone-H

Current File : /var/www/html/thb_loan_system/storage/framework/views/4253716c196149278041dec7eda884701538c1a3.php


<?php $__env->startSection('title'); ?>
    <?php echo e(translate('loan detail')); ?>

<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>
    <?php if($loan->borrower->blacklisted==1): ?>
        <div class="row">
            <div class="col-sm-12">
                <div class="alert bg-danger"><?php echo e(translate('blacklist_notification')); ?></div>
            </div>
        </div>
    <?php endif; ?>
    <div class="row">
        <div class="col-md-12">
            <div class="panel border-left-lg border-left-primary">
                <div class="panel-heading">
                    <h6 class="panel-title"><?php echo e(translate('borrower detail')); ?></h6>

                    <div class="heading-elements">

                    </div>
                </div>
                <div class="panel-body">
                    <div class="row">
                        <div class="col-md-2">
                            <?php if(!empty($loan->borrower->photo)): ?>
                                <a href="<?php echo e(asset('uploads/'.$loan->borrower->photo)); ?>" class="fancybox"> <img
                                        class="img-thumbnail"
                                        src="<?php echo e(asset('uploads/'.$loan->borrower->photo)); ?>"
                                        alt="user image" style="max-height: 150px"/></a>
                            <?php else: ?>
                                <img class="img-thumbnail"
                                     src="<?php echo e(asset('assets/dist/img/user.png')); ?>"
                                     alt="user image" style="max-height: 150px"/>
                            <?php endif; ?>
                        </div>

                        <div class="col-md-3 form-horizontal">
                            <div class="form-group">
                                <label class="control-label col-md-4"><strong><?php echo e(translate('name')); ?>

                                        :</strong></label>
                                <div class="col-md-8" style="padding-top: 9px;">
                                    <span><?php echo e($loan->borrower->title); ?> <?php echo e($loan->borrower->first_name); ?> <?php echo e($loan->borrower->last_name); ?></span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-md-4"><strong><?php echo e(translate('id')); ?>

                                        :</strong></label>
                                <div class="col-md-8" style="padding-top: 9px;">
                                    <span>#<?php echo e($loan->borrower->id); ?></span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-md-4"><strong><?php echo e(translate('gender')); ?>

                                        :</strong></label>
                                <div class="col-md-8" style="padding-top: 9px;">
                                    <?php if($loan->borrower->gender=="Male"): ?>
                                        <span class=""><?php echo e(translate('male')); ?></span>
                                    <?php endif; ?>
                                    <?php if($loan->borrower->gender=="Female"): ?>
                                        <span class=""><?php echo e(translate('female')); ?></span>
                                    <?php endif; ?>
                                </div>
                            </div>

                        </div>
                        <div class="col-md-3 form-horizontal">
                            <div class="form-group">
                                <label class="control-label col-md-4"><strong><?php echo e(translate('age')); ?>

                                        :</strong></label>
                                <div class="col-md-8" style="padding-top: 9px;">
                                    
                                    <span><?php echo e(\Carbon\Carbon::now()->diffInYears($loan->borrower->dob)); ?> <?php echo e(translate('year')); ?></span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-md-4"><strong><?php echo e(translate('phone')); ?>

                                        :</strong></label>
                                <div class="col-md-8" style="padding-top: 9px;">
                                    <span> <a
                                            href="<?php echo e(url('communication/sms/create?borrower_id='.$loan->borrower->id)); ?>"> <?php echo e($loan->borrower->mobile); ?></a></span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-md-4"><strong><?php echo e(translate('email')); ?>

                                        :</strong></label>
                                <div class="col-md-8" style="padding-top: 9px;">
                                    <span>   <a
                                            href="<?php echo e(url('communication/email/create?borrower_id='.$loan->borrower->id)); ?>"><?php echo e($loan->borrower->email); ?></a></span>
                                </div>
                            </div>

                        </div>
                        <div class="col-md-3 form-horizontal">
                            <div class="form-group">
                                <label class="control-label col-md-4"><strong><?php echo e(translate('business')); ?>

                                        :</strong></label>
                                <div class="col-md-8" style="padding-top: 9px;">
                                    <span><?php echo e($loan->borrower->business_name); ?></span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-md-4"><strong><?php echo e(translate('address')); ?>

                                        :</strong></label>
                                <div class="col-md-8" style="padding-top: 9px;">
                                    <span><?php echo e($loan->borrower->address); ?></span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-sm-4"><strong><?php echo e(translate('country')); ?>

                                        :</strong></label>
                                <div class="col-sm-8" style="padding-top: 9px;">
                                    <?php if($loan->borrower->country): ?>
                                        <span><?php echo e($loan->borrower->country->name); ?></span>
                                    <?php endif; ?>
                                </div>
                            </div>

                        </div>
                    </div>
                </div>

                <div class="panel-footer panel-footer-condensed"><a class="heading-elements-toggle"><i
                            class="icon-more"></i></a>
                    <div class="heading-elements">
                        <span class="heading-text"><?php echo e(translate('created_at')); ?>: <span
                                class="text-semibold"><?php echo e($loan->borrower->created_at); ?></span></span>

                        <ul class="list-inline list-inline-condensed heading-text pull-right">
                            <li class="dropdown">
                                <a href="#" class="text-default dropdown-toggle" data-toggle="dropdown"
                                   aria-expanded="false"><i class="icon-menu7"></i> <span class="caret"></span></a>
                                <ul class="dropdown-menu dropdown-menu-right active">
                                    <?php if(Sentinel::hasAccess('loans.create')): ?>
                                        <li class="">
                                            <a href="<?php echo e(url('loan/create?borrower_id='.$loan->borrower_id)); ?>"><?php echo e(translate('add')); ?>

                                                <?php echo e(translate('loan')); ?></a>
                                        </li>
                                    <?php endif; ?>
                                    <?php if(Sentinel::hasAccess('borrowers.update')): ?>
                                        <li class="">
                                            <a href="<?php echo e(url('borrower/'.$loan->borrower_id.'/edit')); ?>"><?php echo e(translate('edit')); ?>

                                                <?php echo e(translate('borrower')); ?></a>
                                        </li>
                                    <?php endif; ?>

                                </ul>
                            </li>

                            <li class="dropdown">
                                <a href="#" class="text-default dropdown-toggle" data-toggle="dropdown"
                                   aria-expanded="false"><?php echo e(translate('borrower statement')); ?>

                                    <span class="caret"></span></a>
                                <ul class="dropdown-menu dropdown-menu-right">
                                    <li>
                                        <a href="<?php echo e(url('loan/'.$loan->borrower_id.'/borrower_statement/print')); ?>"
                                           target="_blank"><i
                                                class="icon-printer"></i> <?php echo e(translate('print statement')); ?>

                                        </a>
                                    </li>
                                    <li>
                                        <a href="<?php echo e(url('loan/'.$loan->borrower_id.'/borrower_statement/pdf')); ?>"
                                           target="_blank"><i
                                                class="icon-file-pdf"></i> <?php echo e(translate('download in pdf')); ?>

                                        </a>
                                    </li>
                                   <!--  <li>
                                        <a href="<?php echo e(url('loan/'.$loan->borrower_id.'/borrower_statement/email')); ?>"
                                        ><i class="icon-envelop"></i> <?php echo e(translate('email statement')); ?>

                                        </a>
                                    </li> -->
                                </ul>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-md-12">
            <!-- Custom Tabs -->
            <div class="panel panel-white">
                <div class="panel-body">
                    <ul class="nav nav-tabs">
                        <?php if($loan->status=="disbursed" || $loan->status=="closed" || $loan->status=="withdrawn" || $loan->status=="written_off" || $loan->status=="rescheduled" ): ?>
                            <li class=""><a href="#transactions" data-toggle="tab"
                                            aria-expanded="true"><?php echo e(translate('transaction')); ?></a></li>
                            <li><a href="#loan_schedule" data-toggle="tab"
                                   aria-expanded="false"><?php echo e(translate('loan')); ?>

                                    <?php echo e(translate('schedule')); ?></a></li>
                            <li class=""><a href="#pending_dues" data-toggle="tab"
                                            aria-expanded="false"><?php echo e(translate('summary')); ?></a>
                            </li>

                        <?php endif; ?>
                        <li class="active"><a href="#loan_terms" data-toggle="tab"
                                              aria-expanded="false"> <?php echo e(translate('detail')); ?></a>
                        </li>

                        <li class=""><a href="#loan_collateral" data-toggle="tab"
                                        aria-expanded="false"><?php echo e(translate('loan collateral')); ?></a>
                        </li>
                        <li class=""><a href="#loan_guarantors" data-toggle="tab"
                                        aria-expanded="false"><?php echo e(translate('loan guarantor')); ?></a>
                        </li>
                        <li class=""><a href="#loan_files" data-toggle="tab"
                                        aria-expanded="false"><?php echo e(translate('loan file')); ?></a>
                        </li>
                        <li class=""><a href="#loan_comments" data-toggle="tab"
                                        aria-expanded="false"><?php echo e(translate('loan comment')); ?></a>
                        </li>

                    </ul>
                    <div class="tab-content">

                        <?php if($loan->status=="disbursed" || $loan->status=="closed" || $loan->status=="withdrawn" || $loan->status=="written_off" || $loan->status=="rescheduled" ): ?>
                            <!-- /.tab-pane -->
                            <div class="tab-pane " id="transactions">
                               

                                <div class="box box-info">
                                    <div class="panel-body">
                                        <div class="row">
                                            <div class="col-sm-12">
                                                <div class="table-responsive">
                                                    <table id="repayments-data-table"
                                                           class="table  table-condensed table-hover">
                                                        <thead>
                                                        <tr>
                                                            <th>
                                                                <?php echo e(translate('id')); ?>

                                                            </th>
                                                            <th>
                                                                <?php echo e(translate('date')); ?>

                                                            </th>
                                                            <th>
                                                                <?php echo e(translate('submitted on')); ?>

                                                            </th>
                                                            <th>
                                                                <?php echo e(translate('type')); ?>

                                                            </th>

                                                            <th>
                                                                <?php echo e(translate('debit')); ?>

                                                            </th>
                                                            <th>
                                                                <?php echo e(translate('credit')); ?>

                                                            </th>
                                                            <th>
                                                                <?php echo e(translate('balance')); ?>

                                                            </th>
                                                            <th>
                                                                <?php echo e(translate('detail')); ?>

                                                            </th>
                                                            <th class="text-center">
                                                                <?php echo e(translate('action')); ?>

                                                            </th>
                                                        </tr>
                                                        </thead>
                                                        <tbody>
                                                            <?php
                                                            $balance = 0;
                                                            ?>
                                                        <?php $__currentLoopData = \App\Models\LoanTransaction::where('loan_id',$loan->id)->whereIn('reversal_type',['user','none'])->get(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                <?php
                                                                $balance = $balance + ($key->debit - $key->credit);
                                                                ?>
                                                            <tr>
                                                                <td><?php echo e($key->id); ?></td>
                                                                <td><?php echo e($key->date); ?></td>
                                                                <td><?php echo e($key->created_at); ?></td>
                                                                <td>
                                                                    <?php if($key->transaction_type=='disbursement'): ?>
                                                                        <?php echo e(translate('disbursement')); ?>

                                                                    <?php endif; ?>
                                                                    <?php if($key->transaction_type=='pay_off'): ?>
                                                                        <?php echo e(translate('pay_off')); ?>

                                                                    <?php endif; ?>

                                                                    <?php if($key->transaction_type=='specified_due_date_fee'): ?>
                                                                        <?php echo e(translate('specified_due_date')); ?>   <?php echo e(translate('fee')); ?>

                                                                    <?php endif; ?>
                                                                    <?php if($key->transaction_type=='installment_fee'): ?>
                                                                        <?php echo e(translate('installment_fee')); ?>

                                                                    <?php endif; ?>
                                                                    <?php if($key->transaction_type=='overdue_installment_fee'): ?>
                                                                        <?php echo e(translate('overdue_installment_fee')); ?>

                                                                    <?php endif; ?>
                                                                    <?php if($key->transaction_type=='loan_rescheduling_fee'): ?>
                                                                        <?php echo e(translate('loan_rescheduling_fee')); ?>

                                                                    <?php endif; ?>
                                                                    <?php if($key->transaction_type=='overdue_maturity'): ?>
                                                                        <?php echo e(translate('overdue_maturity')); ?>

                                                                    <?php endif; ?>
                                                                    <?php if($key->transaction_type=='disbursement_fee'): ?>
                                                                        <?php echo e(translate('disbursement charge')); ?>

                                                                    <?php endif; ?>
                                                                    <?php if($key->transaction_type=='interest'): ?>
                                                                        <?php echo e(translate('interest applied')); ?>

                                                                    <?php endif; ?>
                                                                    <?php if($key->transaction_type=='repayment'): ?>
                                                                        <?php echo e(translate('repayment')); ?>

                                                                    <?php endif; ?>
                                                                    <?php if($key->transaction_type=='penalty'): ?>
                                                                        <?php echo e(translate('penalty')); ?>

                                                                    <?php endif; ?>
                                                                    <?php if($key->transaction_type=='interest_waiver'): ?>
                                                                        <?php echo e(translate('interest waiver')); ?>

                                                                    <?php endif; ?>
                                                                    <?php if($key->transaction_type=='waiver'): ?>
                                                                        <?php echo e(translate('waiver')); ?>

                                                                    <?php endif; ?>
                                                                    <?php if($key->transaction_type=='charge_waiver'): ?>
                                                                        <?php echo e(translate('charge waiver')); ?>

                                                                    <?php endif; ?>
                                                                    <?php if($key->transaction_type=='write_off'): ?>
                                                                        <?php echo e(translate('write_off')); ?>

                                                                    <?php endif; ?>
                                                                    <?php if($key->transaction_type=='write_off_recovery'): ?>
                                                                        <?php echo e(translate('recovery repayment')); ?>

                                                                    <?php endif; ?>
                                                                    <?php if($key->reversed==1): ?>
                                                                        <?php if($key->reversal_type=="user"): ?>
                                                                            <span
                                                                                class="text-danger"><b>(<?php echo e(translate('user reversed')); ?>

                                                                                    )</b></span>
                                                                        <?php endif; ?>
                                                                        <?php if($key->reversal_type=="system"): ?>
                                                                            <span
                                                                                class="text-danger"><b>(<?php echo e(translate('system reversed')); ?>

                                                                                    )</b></span>
                                                                        <?php endif; ?>
                                                                    <?php endif; ?>
                                                                </td>
                                                                <td class="credit"><?php echo e(currency_converter($key->debit)); ?></td>
                                                                <td class="credit"><?php echo e(currency_converter($key->credit)); ?></td>
                                                                <td class="credit"><?php echo e(currency_converter($balance)); ?></td>
                                                                <td class="credit"><?php echo e($key->receipt); ?></td>
                                                                <td class="text-center">
                                                                    <ul class="icons-list">
                                                                        <li class="dropdown">
                                                                            <a href="#" class="dropdown-toggle"
                                                                               data-toggle="dropdown">
                                                                                <i class="icon-menu9"></i>
                                                                            </a>
                                                                            <ul class="dropdown-menu dropdown-menu-right">
                                                                                <li>
                                                                                    <a href="<?php echo e(url('loan/transaction/'.$key->id.'/show')); ?>"><i
                                                                                            class="fa fa-search"></i> <?php echo e(translate('view')); ?>

                                                                                    </a></li>
                                                                                <li>

                                                                                <?php if($key->transaction_type=='repayment' && $key->reversible==1): ?>
                                                                                    <li>
                                                                                        <a href="<?php echo e(url('loan/transaction/'.$key->id.'/print')); ?>"
                                                                                           target="_blank"><i
                                                                                                class="icon-printer"></i> <?php echo e(translate('print')); ?> <?php echo e(translate('receipt')); ?>

                                                                                        </a></li>
                                                                                    <li>
                                                                                        <a href="<?php echo e(url('loan/transaction/'.$key->id.'/pdf')); ?>"
                                                                                           target="_blank"><i
                                                                                                class="icon-file-pdf"></i> <?php echo e(translate('pdf')); ?> <?php echo e(translate('receipt')); ?>

                                                                                        </a></li>
                                                                                    <li>
                                                                                        <a href="<?php echo e(url('loan/repayment/'.$key->id.'/edit')); ?>"><i
                                                                                                class="fa fa-edit"></i> <?php echo e(translate('edit')); ?>

                                                                                        </a></li>
                                                                                    <li>
                                                                                        <a href="<?php echo e(url('loan/repayment/'.$key->id.'/reverse')); ?>"
                                                                                           class="delete"><i
                                                                                                class="fa fa-minus-circle"></i> <?php echo e(translate('reverse')); ?>

                                                                                        </a></li>
                                                                                <?php endif; ?>
                                                                                <?php if($key->transaction_type=='penalty' && $key->reversible==1): ?>
                                                                                    <li>
                                                                                        <a href="<?php echo e(url('loan/transaction/'.$key->id.'/waive')); ?>"
                                                                                           class="delete"><i
                                                                                                class="fa fa-minus-circle"></i> <?php echo e(translate('waive')); ?>

                                                                                        </a></li>
                                                                                <?php endif; ?>
                                                                                <?php if($key->transaction_type=='installment_fee' && $key->reversible==1): ?>
                                                                                    <li>
                                                                                        <a href="<?php echo e(url('loan/transaction/'.$key->id.'/waive')); ?>"
                                                                                           class="delete"><i
                                                                                                class="fa fa-minus-circle"></i> <?php echo e(translate('waive')); ?>

                                                                                        </a></li>
                                                                                <?php endif; ?>
                                                                                <?php if($key->transaction_type=='specified_due_date_fee' && $key->reversible==1): ?>
                                                                                    <li>
                                                                                        <a href="<?php echo e(url('loan/transaction/'.$key->id.'/waive')); ?>"
                                                                                           class="delete"><i
                                                                                                class="fa fa-minus-circle"></i> <?php echo e(translate('waive')); ?>

                                                                                        </a></li>
                                                                                <?php endif; ?>
                                                                            </ul>
                                                                        </li>
                                                                    </ul>
                                                                </td>
                                                            </tr>
                                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                        </tbody>
                                                    </table>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!-- /.tab-pane -->
                            <!-- /.tab-pane -->
                            <div class="tab-pane" id="loan_schedule">
                                <div class="row">
                                    <div class="col-sm-3">
                                        <!--
                                        <div class="input-group-btn">
                                            <button type="button" class="btn btn-info dropdown-toggle m-10"
                                                    data-toggle="dropdown"
                                                    aria-expanded="false"><?php echo e(translate('loan schedule')); ?>

                                        <span class="fa fa-caret-down"></span></button>
                                    <ul class="dropdown-menu" role="menu">
                                        <li>
                                            <a href="<?php echo e(url('loan/'.$loan->id.'/schedule/print')); ?>"
                                                       target="_blank"><?php echo e(translate('print statement')); ?></a>
                                                </li>

                                                <li>
                                                    <a href="<?php echo e(url('loan/'.$loan->id.'/schedule/pdf')); ?>"
                                                       target="_blank"><?php echo e(translate('download in pdf')); ?></a>
                                                </li>

                                                <?php if(Sentinel::hasAccess('communication.create')): ?>
                                            <li>
                                                <a href="<?php echo e(url('loan/'.$loan->id.'/schedule/email')); ?>"
                                                        ><?php echo e(translate('email schedule')); ?></a>
                                                    </li>

                                        <?php endif; ?>

                                        <li>
                                        <a href="<?php echo e(url('loan/'.$loan->id.'/schedule/excel')); ?>"
                                                   target="_blank">Download in Excel</a></li>

                                                <li>
                                                <a href="<?php echo e(url('loan/'.$loan->id.'/schedule/csv')); ?>"
                                                   target="_blank">Download in CSV</a></li>
                                            </ul>
                                        </div>
                                        -->
                                    </div>
                                    <div class="col-sm-9 pull-right">
                                        <div class="btn-group-horizontal">
                                            <a type="button" class="btn btn-info m-10"
                                               href="<?php echo e(url('loan/'.$loan->id.'/schedule/print')); ?>"
                                               target="_blank"><?php echo e(translate('print schedule')); ?></a>

                                        </div>
                                    </div>
                                </div>
                                <div class="box box-success">
                                    <div class="panel-body table-responsive no-padding">
                                        <table class="table table-bordered table-condensed table-hover">
                                            <tbody>
                                            <tr>
                                                <th style="width: 10px">
                                                    <b>#</b>
                                                </th>
                                                <th>
                                                    <b><?php echo e(translate('date')); ?></b>
                                                </th>
                                                <th style="text-align:right;">
                                                    <b><?php echo e(translate('paid by')); ?></b>
                                                </th>
                                                <th>
                                                    <b><?php echo e(translate('description')); ?></b>
                                                </th>
                                                <th style="">
                                                    <b><?php echo e(translate('principal')); ?></b>
                                                </th>
                                                <th style="text-align:right;">
                                                    <b><?php echo e(translate('interest')); ?></b>
                                                </th>
                                                <th style="text-align:right;">
                                                    <b><?php echo e(translate('fee')); ?></b>
                                                </th>
                                                <th style="text-align:right;">
                                                    <b><?php echo e(translate('penalty')); ?></b>
                                                </th>

                                                <th style="text-align:right;">
                                                    <b> <?php echo e(translate('due')); ?></b>
                                                </th>
                                                <th style="text-align:right;">
                                                    <b><?php echo e(translate('paid')); ?></b>
                                                </th>
                                                <th style="text-align:right;">
                                                    <b> <?php echo e(translate('pending due')); ?></b>
                                                </th>
                                                <th style="text-align:right;">
                                                    <b> <?php echo e(translate('principal balance')); ?></b>
                                                </th>
                                                <th>Action</th>
                                            </tr>
                                                <?php
                                                //check for disbursement charges
                                                $disbursement_charges = \App\Models\LoanTransaction::where('loan_id',
                                                    $loan->id)->where('transaction_type',
                                                    'disbursement_fee')->where('reversed', 0)->sum('debit');
                                                ?>
                                            <tr>
                                                <td></td>
                                                <td><?php echo e($loan->release_date); ?></td>
                                                <td></td>
                                                <td><?php echo e(translate('disbursement')); ?></td>
                                                <td></td>
                                                <td></td>
                                                <td style="text-align:right;" class="credit">
                                                    <?php if(!empty($disbursement_charges)): ?>
                                                        <b><?php echo e(currency_converter($disbursement_charges)); ?></b>
                                                    <?php endif; ?>
                                                </td>
                                                <td></td>
                                                <td style="text-align:right;" class="credit">
                                                    <?php if(!empty($disbursement_charges)): ?>
                                                        <b><?php echo e(currency_converter($disbursement_charges)); ?></b>
                                                    <?php endif; ?>
                                                </td>
                                                <td style="text-align:right;" class="credit">
                                                    <?php if(!empty($disbursement_charges)): ?>
                                                        <b><?php echo e(currency_converter($disbursement_charges)); ?></b>
                                                    <?php endif; ?>
                                                </td>
                                                <td></td>
                                                <td style="text-align:right;" class="credit">
                                                    <?php echo e(currency_converter(\App\Models\LoanSchedule::where('loan_id',
                                                    $loan->id)->sum('principal'))); ?>

                                                </td>
                                                <td>

                                                </td>
                                            </tr>
                                                <?php
                                                $timely = 0;
                                                $total_overdue = 0;
                                                $overdue_date = "";
                                                $total_till_now = 0;
                                                $count = 1;
                                                $total_due = 0;
                                                $principal_balance = \App\Models\LoanSchedule::where('loan_id',
                                                    $loan->id)->sum('principal');
                                                $payments = \App\Helpers\GeneralHelper::loan_total_paid($loan->id);
                                                $total_paid = $payments;
                                                $next_payment = [];
                                                $next_payment_amount = "";
                                            foreach ($loan->schedules as $schedule) {
                                                $principal_balance = $principal_balance - $schedule->principal;
                                                $total_due = $total_due + ($schedule->principal + $schedule->interest + $schedule->fees + $schedule->penalty - $schedule->interest_waived);
                                                $paid = 0;
                                                $paid_by = '';
                                                $overdue = 0;
                                                $due = $schedule->principal + $schedule->interest + $schedule->fees + $schedule->penalty - $schedule->interest_waived;
                                                if ($payments > 0) {
                                                    if ($payments > $due) {
                                                        //$paid = $due; //old
                                                        //$payments = $payments - $due; //old
                                                        $paid = \App\Helpers\GeneralHelper::loan_paid($schedule->id);
                                                        //find the corresponding paid by date
                                                        $p_paid = 0;
                                                        foreach (\App\Models\LoanTransaction::where('loan_id',
                                                            $loan->id)->where('transaction_type',
                                                            'repayment')->where('reversed', 0)->orderBy('date',
                                                            'asc')->get() as $key) {
                                                            $p_paid = $p_paid + $key->credit;
                                                            if ((int)$p_paid >= (int)$total_due) {
                                                                $paid_by = $key->date;
                                                                if ($key->date > $schedule->due_date && date("Y-m-d") > $schedule->due_date) {
                                                                    $overdue = 1;
                                                                    $total_overdue = $total_overdue + 1;
                                                                    $overdue_date = '';
                                                                }
                                                                break;
                                                            }
                                                        }
                                                    } else {
                                                        $paid = $payments;
                                                        $payments = 0;
                                                        if (date("Y-m-d") > $schedule->due_date) {
                                                            $overdue = 1;
                                                            $total_overdue = $total_overdue + 1;
                                                            $overdue_date = $schedule->due_date;
                                                        }
                                                        $next_payment[$schedule->due_date] = (($schedule->principal + $schedule->interest + $schedule->fees + $schedule->penalty - $schedule->interest_waived) - $paid);
                                                    }
                                                } else {
                                                    if (date("Y-m-d") > $schedule->due_date) {
                                                        $overdue = 1;
                                                        $total_overdue = $total_overdue + 1;
                                                        $overdue_date = $schedule->due_date;
                                                    }
                                                    $next_payment[$schedule->due_date] = (($schedule->principal + $schedule->interest + $schedule->fees + $schedule->penalty - $schedule->interest_waived));
                                                }
                                                // $outstanding = $due - $paid;
                                                $outstanding = $due > $paid ? $due - $paid : 0;
                                                //check if the schedule has been paid in time


                                                ?>
                                            <tr class="<?php if($overdue==1): ?> danger  <?php endif; ?> <?php if($overdue==0 && $outstanding==0): ?> success  <?php endif; ?>">
                                                <td>
                                                    <?php echo e($count); ?>

                                                </td>
                                                <td>
                                                    <?php echo e($schedule->due_date); ?>

                                                </td>
                                                <td style="">
                                                    <?php if(empty($paid_by) && $overdue==1): ?>
                                                        <?php echo e(translate('overdue')); ?>

                                                    <?php endif; ?>
                                                    <?php if(!empty($paid_by) && $overdue==1): ?>
                                                        <?php echo e($paid_by); ?> <i class="fa fa-minus-circle" data-toggle="tooltip"
                                                                        title=" <?php echo e(translate('late')); ?>"></i>
                                                    <?php endif; ?>                                                    <?php if(!empty($paid_by) && $overdue==0): ?>
                                                        <?php echo e($paid_by); ?> <i class="fa fa-check-circle" data-toggle="tooltip"
                                                                        title=" <?php echo e(translate('timely')); ?>"></i>
                                                    <?php endif; ?>

                                                </td>
                                                <td>
                                                    <?php echo e($schedule->description); ?>

                                                </td>
                                                <td style="text-align:right" class="credit">
                                                    <?php echo e(currency_converter($schedule->principal)); ?>

                                                </td>
                                                <td style="text-align:right" class="credit">
                                                    <?php if($schedule->interest_waived>0): ?>
                                                        <s> <?php echo e(currency_converter($schedule->interest_waived)); ?></s>
                                                    <?php endif; ?>
                                                    <?php if($schedule->pay_off != null): ?>
                                                        <s> <?php echo e(currency_converter($schedule->pay_off)); ?></s>
                                                    <?php endif; ?>
                                                    <?php echo e(currency_converter($schedule->interest)); ?>

                                                </td>
                                                <td style="text-align:right" class="credit">
                                                    <?php echo e(currency_converter($schedule->fees)); ?>

                                                </td>
                                                <td style="text-align:right" class="credit">
                                                    <?php echo e(currency_converter($schedule->penalty)); ?>

                                                </td>
                                                <td style="text-align:right; font-weight:bold" class="credit">
                                                    <?php echo e(currency_converter($due)); ?>

                                                </td>

                                                <td style="text-align:right;" class="credit">
                                                    <?php echo e(currency_converter($paid)); ?>

                                                </td>
                                                <td style="text-align:right;" class="credit">
                                                    <?php echo e(currency_converter($outstanding)); ?>

                                                </td>
                                                <td style="text-align:right;" class="credit">
                                                    <?php echo e(currency_converter($principal_balance)); ?>

                                                </td>

                                                <td class="credit">
                                                    <?php if($schedule->penalty>0 && !empty((int)$outstanding)): ?>
                                                        <a href="#"
                                                           data-toggle="modal"
                                                           data-target="#waivePenalty"
                                                           class="btn btn-info btn-xs waivePenalty"
                                                           style="margin: 5px 0px;"
                                                           onclick="setPenaltyValue(<?php echo e($schedule->penalty); ?>, <?php echo e($schedule->id); ?>)">
                                                            <?php echo e(translate('waive penalty')); ?>

                                                        </a>
                                                    <?php endif; ?>
                                                    <a href="<?php echo e(url('loan/'.$loan->id.'/'.$schedule->id.'/repayment/create')); ?>"
                                                       class="btn btn-info btn-xs <?php if(empty((int)$outstanding) || $loan->status!='disbursed'): ?> disabled <?php endif; ?>"><?php echo e(translate('repayment')); ?></a>
                                                </td>
                                            </tr>
                                                <?php
                                                $count++;
                                            }
                                                ?>
                                            <tr>
                                                <td colspan="3"></td>
                                                <td style="font-weight:bold"><?php echo e(translate('total due')); ?></td>
                                                <td style="text-align:right;" class="credit">
                                                    <?php echo e(currency_converter(\App\Helpers\GeneralHelper::loan_total_principal($loan->id))); ?>

                                                </td>
                                                <td style="text-align:right;" class="credit">
                                                    <?php echo e(currency_converter(\App\Helpers\GeneralHelper::loan_total_interest($loan->id)-\App\Helpers\GeneralHelper::loan_total_interest_waived($loan->id))); ?>

                                                </td>
                                                <td style="text-align:right;" class="credit">
                                                    <?php echo e(currency_converter(\App\Helpers\GeneralHelper::loan_total_fees($loan->id)+$disbursement_charges)); ?>

                                                </td>
                                                <td style="text-align:right;" class="credit">
                                                    <?php echo e(currency_converter(\App\Helpers\GeneralHelper::loan_total_penalty($loan->id))); ?>

                                                </td>
                                                <td style="text-align:right;" class="credit">
                                                    <?php echo e(currency_converter($total_due+$disbursement_charges)); ?>

                                                </td>
                                                <td style="text-align:right;" class="credit">
                                                    <?php echo e(currency_converter($total_paid+$disbursement_charges)); ?>

                                                </td>
                                                <td style="text-align:right;" class="credit">
                                                    <?php echo e(currency_converter(\App\Helpers\GeneralHelper::loan_total_balance($loan->id))); ?>

                                                </td>
                                                <td colspan="2"></td>
                                            </tr>
                                            </tbody>
                                        </table>

                                    </div>
                                </div>
                            </div>
                            <div class="tab-pane" id="pending_dues">
                                <div class="tab_content">
                                        <?php
                                        $loan_due_items = \App\Helpers\GeneralHelper::loan_due_items($loan->id,
                                            $loan->release_date, date("Y-m-d"));
                                        $loan_paid_items = \App\Helpers\GeneralHelper::loan_paid_items($loan->id,
                                            $loan->release_date, date("Y-m-d"));

                                        ?>
                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="row">
                                                <div class="col-md-6"><h6>
                                                        <b><?php echo e(translate('timely repayment')); ?>

                                                            :</b></h6></div>
                                                <div class="col-md-6">
                                                        <?php
                                                        $count = \App\Models\LoanSchedule::where('due_date', '<=',
                                                            date("Y-m-d"))->where('loan_id', $loan->id)->count();
                                                        ?>
                                                    <?php if($count>0): ?>
                                                        <h6><b><?php echo e(round(($count-$total_overdue)/$count)); ?>% </b></h6>
                                                    <?php else: ?>
                                                        <h6><b>0 %</b></h6>
                                                    <?php endif; ?>
                                                </div>
                                            </div>
                                            <div class="row">
                                                <div class="col-md-6"><h6>
                                                        <b><?php echo e(translate('amount in arrears')); ?>

                                                            :</b></h6></div>
                                                <div class="col-md-6" class="credit">
                                                    <?php if(($loan_due_items["principal"]+$loan_due_items["interest"]+$loan_due_items["fees"]+$loan_due_items["penalty"])>($loan_paid_items["principal"]+$loan_paid_items["interest"]+$loan_paid_items["fees"]+$loan_paid_items["penalty"])): ?>
                                                        <h6><b>
                                                                <span
                                                                    class="text-danger"><?php echo e(currency_converter(($loan_due_items["principal"]+$loan_due_items["interest"]+$loan_due_items["fees"]+$loan_due_items["penalty"])-($loan_paid_items["principal"]+$loan_paid_items["interest"]+$loan_paid_items["fees"]+$loan_paid_items["penalty"]))); ?></span></b>
                                                        </h6>
                                                    <?php else: ?>
                                                        <h6><b> <span class="text-danger">0.00</span></b></h6>
                                                    <?php endif; ?>
                                                </div>
                                            </div>
                                            <div class="row">
                                                <div class="col-md-6"><h6>
                                                        <b><?php echo e(translate('day in arrears')); ?>

                                                            :</b></h6></div>
                                                <div class="col-md-6">
                                                    <?php if(!empty($overdue_date)): ?>
                                                            <?php
                                                            $date1 = new DateTime($overdue_date);
                                                            $date2 = new DateTime(date("Y-m-d"));
                                                            ?>
                                                        <h6>
                                                            <b><span
                                                                    class="text-danger"><?php echo e($date2->diff($date1)->format("%a")); ?></span></b>
                                                        </h6>
                                                    <?php else: ?>
                                                        <h6><b> <span class="text-danger">0</span></b></h6>
                                                    <?php endif; ?>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="row">
                                                <div class="col-md-6"><h6>
                                                        <b><?php echo e(translate('last payment')); ?>

                                                            :</b></h6></div>
                                                <div class="col-md-6">
                                                        <?php
                                                        $last_payment = \App\Models\LoanTransaction::where('loan_id',
                                                            $loan->id)->where('transaction_type',
                                                            'repayment')->where('reversed', 0)->orderBy('date',
                                                            'desc')->first();
                                                        ?>
                                                    <?php if(!empty($last_payment)): ?>
                                                        <h6 class="credit"><b><?php echo e(currency_converter($last_payment->credit)); ?>

                                                                on <?php echo e($last_payment->date); ?></b></h6>
                                                    <?php else: ?>
                                                        ----
                                                    <?php endif; ?>
                                                </div>
                                            </div>
                                            <div class="row">
                                                <div class="col-md-6"><h6>
                                                        <b><?php echo e(translate('next payment')); ?>

                                                            :</b></h6></div>
                                                <div class="col-md-6">
                                                        <?php
                                                        $count = \App\Models\LoanSchedule::where('due_date', '<=',
                                                            date("Y-m-d"))->where('loan_id', $loan->id)->count();
                                                        ?>
                                                    <?php $__currentLoopData = $next_payment; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                            <?php
                                                            if ($key > date("Y-m-d")) {
                                                                echo ' <h6><b>' . currency_converter($value) . ' on ' . $key . '</b></h6>';
                                                                break;
                                                            }
                                                            ?>
                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                </div>
                                            </div>
                                            <div class="row">
                                                <div class="col-md-6"><h6>
                                                        <b><?php echo e(translate('last payment expected')); ?>

                                                            :</b></h6></div>
                                                <div class="col-md-6">
                                                    <h6>
                                                        <b><?php echo e(\App\Models\LoanSchedule::where('loan_id', $loan->id)->orderBy('due_date','asc')->get()->last()->due_date??''); ?></b>
                                                    </h6>
                                                </div>
                                            </div>
                                        </div>
                                    </div>


                                    <table class="table table-bordered table-condensed">
                                        <tbody>
                                        <tr class="bg-success">
                                            <th width="200">
                                                <b><?php echo e(translate('item')); ?>

                                                    :</b>
                                            </th>
                                            <th style="text-align:right;">
                                                <b><?php echo e(translate('principal')); ?></b>
                                            </th>
                                            <th style="text-align:right;">
                                                <b><?php echo e(translate('interest')); ?></b>
                                            </th>
                                            <th style="text-align:right;">
                                                <b><?php echo e(translate('fee')); ?></b>
                                            </th>
                                            <th style="text-align:right;">
                                                <b><?php echo e(translate('penalty')); ?></b>
                                            </th>
                                            <th style="text-align:right;">
                                                <b><?php echo e(translate('total')); ?></b>
                                            </th>
                                        </tr>
                                        <tr>
                                            <td class="text-bold bg-danger">
                                                <?php echo e(translate('total due')); ?>

                                            </td>
                                            <td style="text-align:right" class="credit">
                                                <?php echo e(currency_converter(\App\Helpers\GeneralHelper::loan_total_principal($loan->id))); ?>

                                            </td>
                                            <td style="text-align:right" class="credit">
                                                <?php echo e(currency_converter(\App\Helpers\GeneralHelper::loan_total_interest($loan->id))); ?>

                                            </td>
                                            <td style="text-align:right" class="credit">
                                                <?php echo e(currency_converter(\App\Helpers\GeneralHelper::loan_total_fees($loan->id)+$disbursement_charges)); ?>

                                            </td>
                                            <td style="text-align:right" class="credit">
                                                <?php echo e(currency_converter(\App\Helpers\GeneralHelper::loan_total_penalty($loan->id))); ?>

                                            </td>
                                            <td style="text-align:right; font-weight:bold" class="credit">
                                                <?php echo e(currency_converter(\App\Helpers\GeneralHelper::loan_total_due_amount($loan->id)+$disbursement_charges)); ?>

                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="text-bold bg-green">
                                                <?php echo e(translate('total paid')); ?>

                                            </td>
                                            <td style="text-align:right" class="credit">
                                                <?php echo e(currency_converter($loan_paid_items['principal'])); ?>

                                            </td>
                                            <td style="text-align:right" class="credit">
                                                <?php echo e(currency_converter($loan_paid_items['interest'])); ?>

                                            </td>
                                            <td style="text-align:right" class="credit">
                                                <?php echo e(currency_converter($loan_paid_items['fees']+$disbursement_charges)); ?>

                                            </td>
                                            <td style="text-align:right" class="credit">
                                                <?php echo e(currency_converter($loan_paid_items['penalty'])); ?>

                                            </td>
                                            <td style="text-align:right; font-weight:bold" class="credit">
                                                <?php echo e(currency_converter(($loan_paid_items['principal']+$loan_paid_items['interest']+$loan_paid_items['fees']+$loan_paid_items['penalty'])+$disbursement_charges)); ?>

                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="text-bold btn-info">
                                                <?php echo e(translate('balance')); ?>

                                            </td>
                                            <td style="text-align:right" class="credit">
                                                <?php echo e(currency_converter((\App\Helpers\GeneralHelper::loan_total_principal($loan->id)-$loan_paid_items['principal']))); ?>

                                            </td>
                                            <td style="text-align:right" class="credit">
                                                <?php echo e(currency_converter((\App\Helpers\GeneralHelper::loan_total_interest($loan->id)-$loan_paid_items['interest']))); ?>


                                            </td>
                                            <td style="text-align:right" class="credit">
                                                <?php echo e(currency_converter((\App\Helpers\GeneralHelper::loan_total_fees($loan->id)-$loan_paid_items['fees']))); ?>


                                            </td>
                                            <td style="text-align:right" class="credit">
                                                <?php echo e(currency_converter((\App\Helpers\GeneralHelper::loan_total_penalty($loan->id)-$loan_paid_items['penalty']))); ?>


                                            </td>
                                            <td style="text-align:right; font-weight:bold" class="credit">
                                                <?php echo e(currency_converter((\App\Helpers\GeneralHelper::loan_total_due_amount($loan->id)-($loan_paid_items['principal']+$loan_paid_items['interest']+$loan_paid_items['fees']+$loan_paid_items['penalty'])))); ?>


                                            </td>
                                        </tr>

                                        </tbody>
                                    </table>
                                </div>
                            </div>
                            <div class="modal fade" id="waiveInterest">
                                <div class="modal-dialog">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                <span aria-hidden="true">*</span></button>
                                            <h4 class="modal-title"><?php echo e(translate('waive interest')); ?></h4>
                                        </div>
                                        <?php echo Form::open(array('url' => url('loan/'.$loan->id.'/waive_interest'),'method'=>'post')); ?>

                                        <div class="modal-body">
                                            <div class="form-group">
                                                <div class="form-line">
                                                    <?php echo Form::label('date',translate('date'),array('class'=>' control-label')); ?>

                                                    <?php echo Form::text('date',date("Y-m-d"),array('class'=>'form-control date-picker','required'=>'required')); ?>

                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <div class="form-line">
                                                    <?php echo Form::label('amount',translate('amount'),array('class'=>' control-label')); ?>

                                                    <?php echo Form::text('amount',\App\Helpers\GeneralHelper::loan_total_interest($loan->id)-$loan_paid_items['interest'],array('class'=>'form-control touchspin',''=>'','required'=>'required')); ?>

                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <div class="form-line">
                                                    <?php echo Form::label( 'notes',translate('note'),array('class'=>' control-label')); ?>

                                                    <?php echo Form::textarea('notes',null,array('class'=>'form-control','rows'=>'3')); ?>

                                                </div>
                                            </div>
                                        </div>
                                        <div class="modal-footer">
                                            <button type="submit"
                                                    class="btn btn-info"><?php echo e(translate('save')); ?></button>
                                            <button type="button" class="btn default"
                                                    data-dismiss="modal"><?php echo e(translate('close')); ?></button>
                                        </div>
                                        <?php echo Form::close(); ?>

                                    </div>
                                    <!-- /.modal-content -->
                                </div>
                                <!-- /.modal-dialog -->
                            </div>

                            <div class="modal fade" id="waivePenalty">
                                <div class="modal-dialog">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                <span aria-hidden="true">*</span></button>
                                            <h4 class="modal-title"><?php echo e(translate('waive penalty')); ?></h4>
                                        </div>
                                        <?php echo Form::open(array('url' => url('loan/schedule/'.$schedule->id.'/waive_penalty'),'method'=>'post')); ?>

                                        <div class="modal-body">
                                            <p>Are you sure to waive penalty?</p>
                                            <div class="form-group">
                                                <div class="form-line">
                                                    <?php echo Form::label('amount',translate('amount'),array('class'=>' control-label waive_penalty')); ?>

                                                    <?php echo Form::text('amount',$schedule->penalty,array('class'=>'form-control touchspin waivePenaltyAmount',''=>'','required'=>'required')); ?>

                                                    <input type="hidden" name="schedule_id" id="schedule_id" value="<?php echo e($schedule->id); ?>">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="modal-footer">
                                            <button type="submit"
                                                    class="btn btn-info"><?php echo e(translate('save')); ?></button>
                                            <button type="button" class="btn default"
                                                    data-dismiss="modal"><?php echo e(translate('close')); ?></button>
                                        </div>
                                        <?php echo Form::close(); ?>   
                                    </div>
                                    <!-- /.modal-content -->
                                </div>
                                <!-- /.modal-dialog -->
                            </div>

                            <div class="modal fade" id="addCharge">
                                <div class="modal-dialog">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                <span aria-hidden="true">*</span></button>
                                            <h4 class="modal-title"><?php echo e(translate('add charge')); ?></h4>
                                        </div>
                                        <?php echo Form::open(array('url' => url('loan/'.$loan->id.'/add_charge'),'method'=>'post')); ?>

                                        <div class="modal-body">
                                                <?php
                                                $specified_charges = [];
                                                foreach (\App\Models\Charge::where('charge_type',
                                                    'specified_due_date')->where('active',
                                                    1)->get() as $key) {
                                                    $specified_charges[$key->id] = $key->name;
                                                }
                                                ?>
                                            <div class="form-group">
                                                <?php echo Form::label('charge',translate('charge'),array('class'=>' ')); ?>

                                                <?php echo Form::select('charge',$specified_charges,null,array('class'=>' select2','required'=>'required')); ?>

                                            </div>
                                            <div class="form-group">
                                                <?php echo Form::label('date',translate('date'),array('class'=>' control-label')); ?>

                                                <?php echo Form::text('date',date("Y-m-d"),array('class'=>'form-control date-picker','required'=>'required')); ?>

                                            </div>
                                            <div class="form-group">
                                                <?php echo Form::label('amount',translate('amount'),array('class'=>' control-label')); ?>

                                                <?php echo Form::text('amount',null,array('class'=>'form-control touchspin',''=>'','required'=>'required')); ?>

                                            </div>
                                            <div class="form-group">
                                                <?php echo Form::label( 'notes',translate('note'),array('class'=>' control-label')); ?>

                                                <?php echo Form::textarea('notes',null,array('class'=>'form-control','rows'=>'3')); ?>

                                            </div>
                                        </div>
                                        <div class="modal-footer">
                                            <button type="submit"
                                                    class="btn btn-info"><?php echo e(translate('save')); ?></button>
                                            <button type="button" class="btn default"
                                                    data-dismiss="modal"><?php echo e(translate('close')); ?></button>
                                        </div>
                                        <?php echo Form::close(); ?>

                                    </div>
                                    <!-- /.modal-content -->
                                </div>
                                <!-- /.modal-dialog -->
                            </div>
                        <?php endif; ?>
                        <div class="tab-pane active" id="loan_terms">
                            <div class="row">
                                <div class="col-sm-8">
                                    <?php if($loan->status=='pending'): ?>
                                        <div class="col-sm-6">
                                            <?php if(Sentinel::hasAccess('loans.approve')): ?>
                                                <button type="button" class="btn btn-success m-10"
                                                        data-toggle="modal"
                                                        data-target="#approveLoan"><?php echo e(translate('approve')); ?></button>
                                                <button type="button" class="btn btn-danger m-10"
                                                        data-toggle="modal"
                                                        data-target="#declineLoan"><?php echo e(translate('decline')); ?></button>
                                            <?php endif; ?>
                                        </div>
                                    <?php endif; ?>
                                    <?php if($loan->status=='declined'): ?>
                                        <div class="col-sm-6">
                                            <?php if(Sentinel::hasAccess('loans.approve')): ?>
                                                <button type="button" class="btn btn-success m-10"
                                                        data-toggle="modal"
                                                        data-target="#approveLoan"><?php echo e(translate('approve')); ?></button>
                                            <?php endif; ?>
                                        </div>
                                    <?php endif; ?>
                                    <?php if($loan->status=='approved'): ?>
                                        <div class="col-sm-6">
                                            <?php if(Sentinel::hasAccess('loans.disburse')): ?>
                                                <button type="button" class="btn btn-success m-10"
                                                        data-toggle="modal"
                                                        data-target="#disburseLoan"><?php echo e(translate('disburse')); ?></button>
                                                <a type="button" class="btn btn-danger  delete m-10"
                                                   href="<?php echo e(url('loan/'.$loan->id.'/unapprove')); ?>"><?php echo e(translate('undo approval')); ?></a>
                                            <?php endif; ?>
                                        </div>
                                    <?php endif; ?>
                                    <?php if($loan->status=='written_off'): ?>
                                        <div class="col-sm-6">
                                            <?php if(Sentinel::hasAccess('loans.writeoff')): ?>
                                                <a type="button" class="btn btn-danger  delete m-10"
                                                   href="<?php echo e(url('loan/'.$loan->id.'/unwrite_off')); ?>"><?php echo e(translate('undo write_off')); ?></a>
                                            <?php endif; ?>
                                        </div>
                                    <?php endif; ?>
                                    <?php if($loan->status=='withdrawn'): ?>
                                        <div class="col-sm-6">
                                            <?php if(Sentinel::hasAccess('loans.withdraw')): ?>
                                                <a type="button" class="btn btn-danger  delete m-10"
                                                   href="<?php echo e(url('loan/'.$loan->id.'/unwithdraw')); ?>"><?php echo e(translate('undo withdrawal')); ?></a>
                                            <?php endif; ?>
                                        </div>
                                    <?php endif; ?>
                                    <?php if($loan->status=='disbursed'): ?>
                                        <div class="col-sm-3">
                                            <div class="btn-group-horizontal">
                                                <?php if(Sentinel::hasAccess('loans.disburse')): ?>
                                                    <a type="button" class="btn btn-danger delete m-10"
                                                       href="<?php echo e(url('loan/'.$loan->id.'/undisburse')); ?>"
                                                    ><?php echo e(translate('undo disbursement')); ?></a>
                                                <?php endif; ?>
                                            </div>
                                        </div>
                                        <div class="col-sm-3">
                                            <div class="input-group-btn">
                                                <button type="button" class="btn btn-info dropdown-toggle m-10"
                                                        data-toggle="dropdown"
                                                        aria-expanded="false"><?php echo e(translate('more_action')); ?>

                                                    <span class="fa fa-caret-down"></span></button>
                                                <ul class="dropdown-menu" role="menu">
                                                    <?php if(Sentinel::hasAccess('loans.writeoff')): ?>
                                                        <li>
                                                            <a href="#" class=""
                                                               data-toggle="modal"
                                                               data-target="#writeoffLoan"><?php echo e(translate('write_off loan')); ?></a>
                                                        </li>
                                                    <?php endif; ?>
                                                    <?php if(Sentinel::hasAccess('loans.reschedule')): ?>
                                                        <li>
                                                            <a href="#"
                                                               class=""
                                                               data-toggle="modal"
                                                               data-target="#rescheduleLoan"><?php echo e(translate('reschedule loan')); ?></a>
                                                        </li>
                                                    <?php endif; ?>
                                                   <!--  <?php if(Sentinel::hasAccess('loans.update')): ?>
                                                        <li>
                                                            <a href="#" class=""
                                                               data-toggle="modal"
                                                               data-target="#waiveInterest"><?php echo e(translate('waive interest')); ?></a>
                                                        </li>
                                                    <?php endif; ?> -->
                                                    <?php if(Sentinel::hasAccess('loans.update')): ?>
                                                        <li>
                                                            <a href="#" class=""
                                                               data-toggle="modal"
                                                               data-target="#addCharge"><?php echo e(translate('add charge')); ?></a>
                                                        </li>
                                                    <?php endif; ?>
                                                    <?php if($loan->status=="disbursed"): ?>
                                                        <?php if(Sentinel::hasAccess('repayments.create')): ?>
                                                            <li>
                                                                <a href="<?php echo e(url('loan/'.$loan->id.'/pay-off/create')); ?>">
                                                                    <?php echo e(translate('add')); ?>

                                                                    <?php echo e(translate('pay_off')); ?>

                                                                </a>
                                                            </li>
                                                        <?php endif; ?>

                                                    <?php endif; ?>

                                                </ul>
                                            </div>
                                        </div>
                                    <?php endif; ?>

                                    <?php if($loan->status=="disbursed" || $loan->status=="closed" || $loan->status=="withdrawn" || $loan->status=="written_off" || $loan->status=="rescheduled" ): ?>
                                        <!--
                                        <div class="col-sm-3">
                                            <div class="input-group-btn">
                                                <button type="button" class="btn btn-info dropdown-toggle m-10"
                                                        data-toggle="dropdown"
                                                        aria-expanded="false"><?php echo e(translate('loan schedule')); ?>

                                        <span class="fa fa-caret-down"></span></button>
                                    <ul class="dropdown-menu" role="menu">

                                        <li>
                                            <a href="<?php echo e(url('loan/'.$loan->id.'/loan_statement/print')); ?>"
                                                           target="_blank"><?php echo e(translate('print statement')); ?></a>
                                                    </li>

                                                    <li>
                                                        <a href="<?php echo e(url('loan/'.$loan->id.'/loan_statement/pdf')); ?>"
                                                           target="_blank"><?php echo e(translate('download in pdf')); ?></a>
                                                    </li>
                                                    <?php if(Sentinel::hasAccess('communication.create')): ?>
                                            <li>
                                                <a href="<?php echo e(url('loan/'.$loan->id.'/loan_statement/email')); ?>"
                                                            ><?php echo e(translate('email statement')); ?></a>
                                                        </li>

                                        <?php endif; ?>
                                        <li>
                                            <a href="<?php echo e(url('loan/'.$loan->id.'/loan_statement/excel')); ?>"
                                                           target="_blank">Download in Excel</a></li>
                                                    <li>
                                                    <a href="<?php echo e(url('loan/'.$loan->id.'/loan_statement/csv')); ?>"
                                                       target="_blank">Download in CSV</a></li>

                                                </ul>
                                            </div>
                                        </div>-->

                                    <?php endif; ?>


                                    <div class="col-sm-3">
                                        <div class="input-group-btn">
                                            <button type="button" class="btn btn-info dropdown-toggle m-10"
                                                    data-toggle="dropdown"
                                                    aria-expanded="false"><?php echo e(translate('print_contract')); ?>

                                                <span class="fa fa-caret-down"></span></button>
                                            <ul class="dropdown-menu" role="menu">

                                                <!--     <li>
                                                        <a href="<?php echo e(url('loan/'.$loan->id.'/contact-real-estate-mortgage/print')); ?>"
                                                           target="_blank"><?php echo e(translate('print_real_estate_mortgage_contract')); ?> </a>
                                                    </li> -->

                                                <li>
                                                    <a href="<?php echo e(url('loan/'.$loan->id.'/contract-borrow-money/print')); ?>"
                                                       target="_blank"><?php echo e(translate('print_contract_borrow_money')); ?></a>
                                                </li>
                                                <?php
                                                $vehicles = ["Car", "Motor", "car", "motor", "ឡាន", "ម៉ូតូ"];
                                                ?>
                                                <?php if($loan->collateral->first() && in_array($loan->collateral->first()->collateral_type->name, $vehicles)): ?>
                                                    <li>
                                                        <a href="<?php echo e(url('loan/'.$loan->id.'/contract-motor-rental/print')); ?>"
                                                           target="_blank"><?php echo e(translate('print_motor_rental_contract')); ?></a>
                                                    </li>
                                                    <li>
                                                        <a href="<?php echo e(url('loan/'.$loan->id.'/contract-buy-sell-motor/print')); ?>"
                                                           target="_blank"><?php echo e(translate('print_motor_buy_sell_contract')); ?></a>
                                                    </li>
                                                <?php endif; ?>
                                                <li>
                                                    <a href="<?php echo e(url('loan/'.$loan->id.'/print-collateral-receipt/print')); ?>"
                                                       target="_blank"><?php echo e(translate('print_collateral_receipt')); ?></a>
                                                </li>
                                            </ul>
                                        </div>
                                    </div>
                                </div>

                                <div class="col-sm-4 pull-right">
                                    <div class="btn-group-horizontal">

                                        <?php if($loan->status=='pending'||$loan->status=='approved'): ?>
                                            <?php if(Sentinel::hasAccess('loans.update')): ?>
                                                <a type="button" class="btn btn-info m-10"
                                                   href="<?php echo e(url('loan/'.$loan->id.'/edit')); ?>"><?php echo e(translate('edit')); ?>

                                                    <?php echo e(translate('loan')); ?></a>
                                            <?php endif; ?>

                                            <?php if(Sentinel::hasAccess('loans.delete')): ?>

                                                <a type="button" class="btn btn-info m-10 deleteLoan"
                                                   href="<?php echo e(url('loan/'.$loan->id.'/delete')); ?>"><?php echo e(translate('delete')); ?>

                                                    <?php echo e(translate('loan')); ?></a>

                                            <?php endif; ?>
                                        <?php endif; ?>
                                    </div>
                                </div>
                            </div>

                            <div class="panel-body no-padding">
                                <table class="table table-condensed">
                                    <tbody>
                                    <tr>
                                        <td>
                                            <b><?php echo e(translate('loan status')); ?></b>
                                        </td>
                                        <td>
                                            <?php if($loan->maturity_date<date("Y-m-d") && \App\Helpers\GeneralHelper::loan_total_balance($loan->id)>0): ?>
                                                <span class="label label-danger"><?php echo e(translate('past_maturity')); ?></span>
                                            <?php else: ?>
                                                <?php if($loan->status=='pending'): ?>
                                                    <span
                                                        class="label label-warning"><?php echo e(translate('pending approval')); ?></span>
                                                <?php endif; ?>
                                                <?php if($loan->status=='approved'): ?>
                                                    <span
                                                        class="label label-info"><?php echo e(translate('awaiting disbursement')); ?></span>
                                                <?php endif; ?>
                                                <?php if($loan->status=='disbursed'): ?>
                                                    <span class="label label-info"><?php echo e(translate('active')); ?></span>
                                                <?php endif; ?>
                                                <?php if($loan->status=='declined'): ?>
                                                    <span class="label label-danger"><?php echo e(translate('declined')); ?></span>
                                                <?php endif; ?>
                                                <?php if($loan->status=='withdrawn'): ?>
                                                    <span class="label label-danger"><?php echo e(translate('withdrawn')); ?></span>
                                                <?php endif; ?>
                                                <?php if($loan->status=='written_off'): ?>
                                                    <span class="label label-danger"><?php echo e(translate('written_off')); ?></span>
                                                <?php endif; ?>
                                                <?php if($loan->status=='closed'): ?>
                                                    <span class="label label-success"><?php echo e(translate('closed')); ?></span>
                                                <?php endif; ?>
                                                <?php if($loan->status=='pending_reschedule'): ?>
                                                    <span
                                                        class="label label-warning"><?php echo e(translate('pending reschedule')); ?></span>
                                                <?php endif; ?>
                                                <?php if($loan->status=='rescheduled'): ?>
                                                    <span class="label label-info"><?php echo e(translate('rescheduled')); ?></span>
                                                <?php endif; ?>
                                            <?php endif; ?>
                                        </td>
                                    </tr>
                                    <tr>

                                        <td width="200">
                                            <b><?php echo e(translate('loan application id')); ?></b>
                                        </td>
                                        <td><?php echo e($loan->id); ?></td>

                                    </tr>
                                    <tr>
                                        <td>
                                            <b><?php echo e(translate('loan product')); ?></b>
                                        </td>
                                        <td>
                                            <?php if(!empty($loan->loan_product)): ?>
                                                <?php echo e($loan->loan_product->name); ?>

                                            <?php endif; ?>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2"></td>
                                    </tr>
                                    <tr>
                                        <td colspan="2" class="bg-navy disabled color-palette">
                                           <b> <?php echo e(translate('loan term')); ?> </b>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td><b><?php echo e(translate('disbursed_by')); ?></b></td>
                                        <td>
                                            <?php if(!empty($loan->loan_disbursed_by)): ?>
                                                <?php echo e($loan->loan_disbursed_by->name); ?>

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

                                        <td>
                                            <b><?php echo e(translate('principal amount')); ?></b>
                                        </td>
                                        <td class="credit"><?php echo e(currency_converter($loan->principal)); ?></td>

                                    </tr>
                                    <tr>

                                        <td>
                                            <b><?php echo e(translate('loan fee')); ?> (<?php echo e($loanChargesType); ?>)</b>
                                        </td>
                                        <td class="credit">
                                            <!-- if($loanChargesType=='fixed') -->
                                                <?php echo e(currency_converter($loanCharges->amount??0)); ?> 
                                            <!-- else
                                                <?php echo e($loanCharges->amount??0); ?>

                                            endif -->
                                        </td>

                                    </tr>
                                    <tr>
                                        <td>
                                            <b><?php echo e(translate('loan release date')); ?></b>
                                        </td>
                                        <td><?php echo e($loan->release_date); ?></td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <b><?php echo e(translate('loan interest method')); ?></b>
                                        </td>
                                        <td>
                                            <?php if($loan->interest_method=='declining_balance_equal_installments'): ?>
                                                <?php echo e(translate('declining_balance_equal_installments')); ?>

                                            <?php endif; ?>
                                            <?php if($loan->interest_method=='declining_balance_equal_principal'): ?>
                                                <?php echo e(translate('declining_balance_equal_principal')); ?>

                                            <?php endif; ?>
                                            <?php if($loan->interest_method=='interest_only'): ?>
                                                <?php echo e(translate('interest_only')); ?>

                                            <?php endif; ?>
                                            <?php if($loan->interest_method=='flat_rate'): ?>
                                                <?php echo e(translate('flat_rate')); ?>

                                            <?php endif; ?>
                                            <?php if($loan->interest_method=='compound_interest'): ?>
                                                <?php echo e(translate('compound_interest')); ?>

                                            <?php endif; ?>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <b><?php echo e(translate('loan interest')); ?></b>
                                        </td>
                                        <td class="credit"><?php echo e(number_format($loan->interest_rate,2)); ?>%/<?php echo e($loan->interest_period); ?>

                                        </td>
                                    </tr>

                                    <tr>
                                        <td>
                                            <b><?php echo e(translate('loan pay_off')); ?></b>
                                        </td>
                                        <td class="credit"><?php echo e(number_format($loan->pay_off_interest_rate,2)); ?>%
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <b><?php echo e(translate('loan duration')); ?></b>
                                        </td>
                                        <td><?php echo e($loan->loan_duration); ?> <?php echo e($loan->loan_duration_type); ?>s
                                        </td>
                                    </tr>
                                    <tr>
                                        <td><b><?php echo e(translate('repayment_cycle')); ?></b></td>
                                        <td>
                                            <?php if($loan->repayment_cycle=='daily'): ?>
                                                <?php echo e(translate('daily')); ?>

                                            <?php endif; ?>
                                            <?php if($loan->repayment_cycle=='weekly'): ?>
                                                <?php echo e(translate('weekly')); ?>

                                            <?php endif; ?>
                                            <?php if($loan->repayment_cycle=='monthly'): ?>
                                                <?php echo e(translate('monthly')); ?>

                                            <?php endif; ?>
                                            <?php if($loan->repayment_cycle=='bi_monthly'): ?>
                                                <?php echo e(translate('bi_monthly')); ?>

                                            <?php endif; ?>
                                            <?php if($loan->repayment_cycle=='quarterly'): ?>
                                                <?php echo e(translate('quarterly')); ?>

                                            <?php endif; ?>
                                            <?php if($loan->repayment_cycle=='semi_annual'): ?>
                                                <?php echo e(translate('semi_annually')); ?>

                                            <?php endif; ?>
                                            <?php if($loan->repayment_cycle=='annually'): ?>
                                                <?php echo e(translate('annual')); ?>

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

                                    <tr>
                                        <td><b><?php echo e(translate('number')); ?>

                                                of <?php echo e(translate('repayment')); ?></b></td>
                                        <td>
                                            <?php echo e(\App\Models\LoanSchedule::where('loan_id',$loan->id)->where('description',"<>", "Pay Off")->count()); ?>

                                        </td>
                                    </tr>
                                    <tr>
                                        <td><b><?php echo e(translate('decimal_place')); ?></b></td>
                                        <td>
                                            <?php if($loan->decimal_places=='round_off_to_two_decimal'): ?>
                                                <?php echo e(translate('round_off_to_two_decimal')); ?>

                                            <?php endif; ?>
                                            <?php if($loan->decimal_places=='round_off_to_integer'): ?>
                                                <?php echo e(translate('round_off_to_integer')); ?>

                                            <?php endif; ?>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <b><?php echo e(translate('first repayment date')); ?></b>
                                        </td>
                                        <td><?php echo e($loan->first_payment_date); ?></td>
                                    </tr>
                                    <tr>
                                        <td colspan="2"></td>
                                    </tr>

                                    </tbody>
                                </table>
                            </div>

                        </div>
                        <div class="tab-pane" id="loan_collateral">
                            <div class="btn-group-horizontal">
                                <?php if(Sentinel::hasAccess('collateral.create')): ?>
                                    <a type="button" class="btn btn-info m-10"
                                       href="<?php echo e(url('collateral/'.$loan->id.'/create?return_url='.Request::url())); ?>"><?php echo e(translate('add')); ?>

                                        <?php echo e(translate('collateral')); ?></a>
                                <?php endif; ?>
                            </div>
                            <div class="box box-success">
                                <div class="table-responsive">
                                    <table id="data-table" class="table table-striped table-condensed table-hover">
                                        <thead>
                                        <tr>
                                            <th><?php echo e(translate('type')); ?></th>
                                            <th><?php echo e(translate('name')); ?></th>
                                            <th><?php echo e(translate('value')); ?></th>
                                            <th><?php echo e(translate('status')); ?></th>
                                            <th><?php echo e(translate('date')); ?></th>
                                            <th><?php echo e(translate('action')); ?></th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <?php $__currentLoopData = $loan->collateral; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <tr>
                                                <td>
                                                    <?php if(!empty($key->collateral_type)): ?>
                                                        <?php echo e($key->collateral_type->name); ?>

                                                    <?php endif; ?>
                                                </td>
                                                <td><?php echo e($key->name); ?></td>
                                                <td><?php echo e($key->value); ?></td>
                                                <td>
                                                    <?php if($key->status=='deposited_into_branch'): ?>
                                                        <?php echo e(translate('deposited_into_branch')); ?>

                                                    <?php endif; ?>
                                                    <?php if($key->status=='collateral_with_borrower'): ?>
                                                        <?php echo e(translate('collateral_with_borrower')); ?>

                                                    <?php endif; ?>
                                                    <?php if($key->status=='returned_to_borrower'): ?>
                                                        <?php echo e(translate('returned_to_borrower')); ?>

                                                    <?php endif; ?>
                                                    <?php if($key->status=='repossession_initiated'): ?>
                                                        <?php echo e(translate('repossession_initiated')); ?>

                                                    <?php endif; ?>
                                                    <?php if($key->status=='repossessed'): ?>
                                                        <?php echo e(translate('repossessed')); ?>

                                                    <?php endif; ?>
                                                    <?php if($key->status=='sold'): ?>
                                                        <?php echo e(translate('sold')); ?>

                                                    <?php endif; ?>
                                                    <?php if($key->status=='lost'): ?>
                                                        <?php echo e(translate('lost')); ?>

                                                    <?php endif; ?>
                                                </td>
                                                <td><?php echo e($key->date); ?></td>
                                                <td>
                                                    <div class="btn-group">
                                                        <button type="button"
                                                                class="btn btn-info btn-xs dropdown-toggle"
                                                                data-toggle="dropdown" aria-expanded="false">
                                                            <?php echo e(translate('choose')); ?> <span class="caret"></span>
                                                            <span class="sr-only">Toggle Dropdown</span>
                                                        </button>
                                                        <ul class="dropdown-menu" role="menu">
                                                            <?php if(Sentinel::hasAccess('collateral.view')): ?>
                                                                <li><a href="<?php echo e(url('collateral/'.$key->id.'/show')); ?>"><i
                                                                            class="fa fa-search"></i> <?php echo e(translate('view')); ?>

                                                                    </a></li>
                                                            <?php endif; ?>
                                                            <?php if(Sentinel::hasAccess('collateral.update')): ?>
                                                                <li><a href="<?php echo e(url('collateral/'.$key->id.'/edit')); ?>"><i
                                                                            class="fa fa-edit"></i> <?php echo e(translate('edit')); ?>

                                                                    </a></li>
                                                            <?php endif; ?>
                                                            <?php if(Sentinel::hasAccess('collateral.delete')): ?>
                                                                <li>
                                                                    <a href="<?php echo e(url('collateral/'.$key->id.'/delete')); ?>"
                                                                       class="delete"><i
                                                                            class="fa fa-trash"></i> <?php echo e(translate('delete')); ?>

                                                                    </a></li>
                                                            <?php endif; ?>
                                                        </ul>
                                                    </div>
                                                </td>
                                            </tr>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="tab-pane" id="loan_guarantors">
                            <div class="btn-group-horizontal">
                                <?php if(Sentinel::hasAccess('loans.guarantor.create')): ?>
                                    <a type="button" class="btn btn-info m-10" data-toggle="modal"
                                       data-target="#addGuarantor"><?php echo e(translate('add')); ?>

                                        <?php echo e(translate('guarantor')); ?></a>
                                <?php endif; ?>
                            </div>
                            <div class="box box-success">
                                <div class="table-responsive">
                                    <table id="data-table" class="table table-bordered table-condensed table-hover">
                                        <thead>
                                        <tr>
                                            <th><?php echo e(translate('full_name')); ?></th>
                                            <th><?php echo e(translate('business')); ?></th>
                                            <th><?php echo e(translate('unique')); ?>#</th>
                                            <th><?php echo e(translate('mobile')); ?></th>
                                            <th><?php echo e(translate('email')); ?></th>
                                            <th><?php echo e(translate('action')); ?></th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <?php $__currentLoopData = $loan->guarantors; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <?php if(!empty($key->guarantor)): ?>
                                                <tr>
                                                    <td><?php echo e($key->guarantor->first_name); ?> <?php echo e($key->guarantor->last_name); ?></td>
                                                    <td><?php echo e($key->guarantor->business_name); ?></td>
                                                    <td><?php echo e($key->guarantor->unique_number); ?></td>
                                                    <td><?php echo e($key->guarantor->mobile); ?></td>
                                                    <td><?php echo e($key->guarantor->email); ?></td>
                                                    <td>
                                                        <div class="btn-group">
                                                            <button type="button"
                                                                    class="btn btn-info btn-xs dropdown-toggle"
                                                                    data-toggle="dropdown" aria-expanded="false">
                                                                <?php echo e(translate('choose')); ?> <span
                                                                    class="caret"></span>
                                                                <span class="sr-only">Toggle Dropdown</span>
                                                            </button>
                                                            <ul class="dropdown-menu dropdown-menu-right" role="menu">

                                                                <?php if(Sentinel::hasAccess('loans.guarantor.create')): ?>
                                                                    <li>
                                                                        <a href="<?php echo e(url('guarantor/'.$key->guarantor->id.'/show')); ?>"><i
                                                                                class="fa fa-search"></i> <?php echo e(translate('detail')); ?>

                                                                        </a></li>
                                                                <?php endif; ?>
                                                                <?php if(Sentinel::hasAccess('loans.guarantor.delete')): ?>
                                                                    <li>
                                                                        <a href="<?php echo e(url('loan/guarantor/'.$key->guarantor->id.'/remove')); ?>"
                                                                           class="delete"><i
                                                                                class="fa fa-minus"></i> <?php echo e(translate('remove')); ?>

                                                                        </a>
                                                                    </li>
                                                                <?php endif; ?>
                                                                <?php if(Sentinel::hasAccess('loans.guarantor.update')): ?>
                                                                    <li>
                                                                        <a href="<?php echo e(url('guarantor/'.$key->guarantor->id.'/edit')); ?>"><i
                                                                                class="fa fa-edit"></i> <?php echo e(translate('edit')); ?>

                                                                        </a>
                                                                    </li>
                                                                <?php endif; ?>
                                                                <?php if(Sentinel::hasAccess('loans.guarantor.delete')): ?>
                                                                    <li>
                                                                        <a href="<?php echo e(url('guarantor/'.$key->guarantor->id.'/delete')); ?>"
                                                                           class="delete"><i
                                                                                class="fa fa-trash"></i> <?php echo e(translate('delete')); ?>

                                                                        </a>
                                                                    </li>
                                                                <?php endif; ?>
                                                            </ul>
                                                        </div>
                                                    </td>
                                                </tr>
                                            <?php endif; ?>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="tab-pane" id="loan_files">
                            <p>To add new loan files or remove existing files, pls click the <b>Loan Terms</b> tab and
                                then
                                <b>Edit Loan</b>.</p>
                            <ul class="" style="font-size:12px; padding-left:10px">

                                <?php $__currentLoopData = unserialize($loan->files); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <li><a href="<?php echo asset('uploads/'.$value); ?>"
                                           target="_blank"><?php echo $value; ?></a></li>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </ul>
                        </div>
                        <div class="tab-pane" id="loan_comments">
                            <div class="tab_content">
                                <div class="btn-group-horizontal">
                                    <a type="button" class="btn btn-info m-10"
                                       href="<?php echo e(url('loan/'.$loan->id.'/loan_comment/create')); ?>"><?php echo e(translate('add')); ?>

                                        <?php echo e(translate('comment')); ?></a>
                                </div>


                                <div class="panel-footer box-comments">

                                    <?php $__currentLoopData = $loan->comments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $comment): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <div class="media">
                                            <div class="media-left">
                                                <a href="#"><img src="assets/images/placeholder.jpg"
                                                                 class="img-circle img-md" alt=""></a>
                                            </div>

                                            <div class="media-body">
                                                <?php echo $comment->notes; ?>


                                                <div class="media-annotation mt-5">
                                                    <i class="icon-user"></i>
                                                    <?php if(!empty(\App\Models\User::find($comment->user_id))): ?>
                                                        <?php echo e(\App\Models\User::find($comment->user_id)->first_name); ?> <?php echo e(\App\Models\User::find($comment->user_id)->last_name); ?>

                                                    <?php endif; ?>
                                                    <i class="icon-alarm"></i> <?php echo e($comment->created_at); ?>

                                                    <div class="btn-group-horizontal pull-right">
                                                        <a type="button" class="btn bg-info btn-xs text-bold"
                                                           href="<?php echo e(url('loan/'.$loan->id.'/loan_comment/'.$comment->id.'/edit')); ?>"><?php echo e(translate('edit')); ?></a><a
                                                            type="button"
                                                            class="btn btn-danger btn-xs text-bold deleteComment"
                                                            href="<?php echo e(url('loan/'.$loan->id.'/loan_comment/'.$comment->id.'/delete')); ?>"><?php echo e(translate('delete')); ?></a>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </div>
                            </div>
                        </div>
                        <!-- /.tab-pane -->
                    </div>
                    <!-- /.tab-content -->
                </div>
            </div>
            <!-- nav-tabs-custom -->
        </div>
    </div>
    <div class="modal fade" id="approveLoan">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">*</span></button>
                    <h4 class="modal-title"><?php echo e(translate('approve loan')); ?></h4>
                </div>
                <?php echo Form::open(array('url' => url('loan/'.$loan->id.'/approve'),'method'=>'post')); ?>

                <div class="modal-body">
                    <div class="form-group">
                        <div class="form-line">
                            <?php echo Form::label('approved_date',null,array('class'=>' control-label')); ?>

                            <?php echo Form::text('approved_date',date("Y-m-d"),array('class'=>'form-control date-picker','required'=>'required')); ?>

                        </div>
                    </div>
                    <div class="form-group">
                        <div class="form-line">
                            <?php echo Form::label('approved_amount',null,array('class'=>' control-label')); ?>

                            <?php echo Form::text('approved_amount',$loan->principal,array('class'=>'form-control touchspin','required'=>'required')); ?>

                        </div>
                    </div>
                    <div class="form-group">
                        <div class="form-line">
                            <?php echo Form::label( 'Notes',null,array('class'=>' control-label')); ?>

                            <?php echo Form::textarea('approved_notes','',array('class'=>'form-control','rows'=>'3')); ?>

                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-info"><?php echo e(translate('save')); ?></button>
                    <button type="button" class="btn default"
                            data-dismiss="modal"><?php echo e(translate('close')); ?></button>
                </div>
                <?php echo Form::close(); ?>

            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
    <div class="modal fade" id="disburseLoan">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">*</span></button>
                    <h4 class="modal-title"><?php echo e(translate('disburse loan')); ?></h4>
                </div>
                <?php echo Form::open(array('url' => url('loan/'.$loan->id.'/disburse'),'method'=>'post')); ?>

                <div class="modal-body">
                    <div class="form-group">
                        <div class="form-line">
                            <?php echo Form::label('disbursed_date',null,array('class'=>' control-label')); ?>

                            <?php echo Form::text('disbursed_date',$loan->release_date,array('class'=>'form-control date-picker','required'=>'required')); ?>

                        </div>
                    </div>
                    <div class="form-group">
                        <div class="form-line">
                            <?php echo Form::label('first_payment_date',null,array('class'=>' control-label')); ?>

                            <?php echo Form::text('first_payment_date',$loan->first_payment_date,array('class'=>'form-control date-picker',''=>'','required'=>'required')); ?>

                        </div>
                    </div>
                    <div class="form-group">
                        <div class="form-line">
                            <?php echo Form::label('loan_disbursed_by_id',"Disbursed By",array('class'=>' control-label')); ?>

                            <?php echo Form::select('loan_disbursed_by_id',$loan_disbursed_by,null,array('class'=>'form-control','required'=>'required')); ?>

                        </div>
                    </div>
                    <div class="form-group">
                        <div class="form-line">
                            <?php echo Form::label( 'Notes',null,array('class'=>' control-label')); ?>

                            <?php echo Form::textarea('disbursed_notes','',array('class'=>'form-control','rows'=>'3')); ?>

                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-info"><?php echo e(translate('save')); ?></button>
                    <button type="button" class="btn default"
                            data-dismiss="modal"><?php echo e(translate('close')); ?></button>
                </div>
                <?php echo Form::close(); ?>

            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
    <div class="modal fade" id="declineLoan">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">*</span></button>
                    <h4 class="modal-title"><?php echo e(translate('decline loan')); ?></h4>
                </div>
                <?php echo Form::open(array('url' => url('loan/'.$loan->id.'/decline'),'method'=>'post')); ?>

                <div class="modal-body">
                    <div class="form-group">
                        <div class="form-line">
                            <?php echo Form::label('declined_date',null,array('class'=>' control-label')); ?>

                            <?php echo Form::text('declined_date',date("Y-m-d"),array('class'=>'form-control date-picker','required'=>'required')); ?>

                        </div>
                    </div>
                    <div class="form-group">
                        <div class="form-line">
                            <?php echo Form::label( 'Notes',null,array('class'=>' control-label')); ?>

                            <?php echo Form::textarea('declined_notes','',array('class'=>'form-control','rows'=>'3','required'=>'required')); ?>

                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-info"><?php echo e(translate('save')); ?></button>
                    <button type="button" class="btn default"
                            data-dismiss="modal"><?php echo e(translate('close')); ?></button>
                </div>
                <?php echo Form::close(); ?>

            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
    <div class="modal fade" id="writeoffLoan">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">*</span></button>
                    <h4 class="modal-title"><?php echo e(translate('write_off loan')); ?></h4>
                </div>
                <?php echo Form::open(array('url' => url('loan/'.$loan->id.'/write_off'),'method'=>'post')); ?>

                <div class="modal-body">
                    <div class="form-group">
                        <div class="form-line">
                            <?php echo Form::label('written_off_date',translate('date'),array('class'=>' control-label')); ?>

                            <?php echo Form::text('written_off_date',date("Y-m-d"),array('class'=>'form-control date-picker','required'=>'required')); ?>

                        </div>
                    </div>
                    <div class="form-group">
                        <div class="form-line">
                            <?php echo Form::label( 'written_off_notes',translate('note'),array('class'=>' control-label')); ?>

                            <?php echo Form::textarea('written_off_notes','',array('class'=>'form-control','rows'=>'3','required'=>'required')); ?>

                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-info"><?php echo e(translate('save')); ?></button>
                    <button type="button" class="btn default"
                            data-dismiss="modal"><?php echo e(translate('close')); ?></button>
                </div>
                <?php echo Form::close(); ?>

            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
    <div class="modal fade" id="withdrawLoan">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">*</span></button>
                    <h4 class="modal-title"><?php echo e(translate('withdraw loan')); ?></h4>
                </div>
                <?php echo Form::open(array('url' => url('loan/'.$loan->id.'/withdraw'),'method'=>'post')); ?>

                <div class="modal-body">
                    <div class="form-group">
                        <div class="form-line">
                            <?php echo Form::label('withdrawn_date',translate('date'),array('class'=>' control-label')); ?>

                            <?php echo Form::text('withdrawn_date',date("Y-m-d"),array('class'=>'form-control date-picker','required'=>'required')); ?>

                        </div>
                    </div>
                    <div class="form-group">
                        <div class="form-line">
                            <?php echo Form::label( 'withdrawn_notes',translate('note'),array('class'=>' control-label')); ?>

                            <?php echo Form::textarea('withdrawn_notes','',array('class'=>'form-control','rows'=>'3','required'=>'required')); ?>

                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-info"><?php echo e(translate('save')); ?></button>
                    <button type="button" class="btn default"
                            data-dismiss="modal"><?php echo e(translate('close')); ?></button>
                </div>
                <?php echo Form::close(); ?>

            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
    <div class="modal fade" id="withdrawSaving">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">*</span></button>
                    <h4 class="modal-title"><?php echo e(translate('withdraw saving')); ?></h4>
                </div>
                <?php echo Form::open(array('url' =>'','method'=>'post','id'=>'withdrawSavingForm')); ?>

                <div class="modal-body">
                    <div class="form-group">
                        <?php echo Form::label('amount',translate('amount'),array('class'=>'')); ?>

                        <?php echo Form::text('amount',null, array('class' => 'form-control touchspin', 'id'=>'accepted_amount','required'=>'')); ?>

                    </div>
                    <div class="form-group">
                        <?php echo Form::label('date',translate('date'),array('class'=>'')); ?>

                        <?php echo Form::text('date',date("Y-m-d"), array('class' => 'form-control date-picker', 'placeholder'=>'','required'=>'')); ?>

                    </div>
                    <div class="form-group">
                        <?php echo Form::label('time',translate('time'),array('class'=>'')); ?>

                        <?php echo Form::text('time',date("H:i"), array('class' => 'form-control time-picker', 'placeholder'=>'','required'=>'')); ?>

                    </div>
                    <div class="form-group">
                        <?php echo Form::label('notes',translate('note'),array('class'=>'')); ?>

                        <?php echo Form::textarea('notes',null, array('class' => 'form-control', 'placeholder'=>'',)); ?>

                    </div>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-info"><?php echo e(translate('save')); ?></button>
                    <button type="button" class="btn default"
                            data-dismiss="modal"><?php echo e(translate('close')); ?></button>
                </div>
                <?php echo Form::close(); ?>

            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
    <div class="modal fade" id="rescheduleLoan">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">*</span></button>
                    <h4 class="modal-title"><?php echo e(translate('reschedule loan')); ?></h4>
                </div>
                <?php echo Form::open(array('url' => url('loan/'.$loan->id.'/reschedule'),'method'=>'get')); ?>

                <div class="modal-body">
                    <div class="form-group">
                        <div class="form-line">
                            <?php echo Form::label('type',translate('reschedule').' '.translate('on'),array('class'=>' control-label')); ?>

                            <?php echo Form::select('type',['0'=>translate('outstanding_p'),'1'=>translate('outstanding_p_i'),'2'=>translate('outstanding_p_i_f'),'3'=>translate('outstanding_total')],null,array('class'=>'form-control','required'=>'required')); ?>

                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-info"><?php echo e(translate('save')); ?></button>
                    <button type="button" class="btn default"
                            data-dismiss="modal"><?php echo e(translate('close')); ?></button>
                </div>
                <?php echo Form::close(); ?>

            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
    <div class="modal fade" id="addGuarantor">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">*</span></button>
                    <h4 class="modal-title"><?php echo e(translate('add guarantor')); ?></h4>
                </div>
                <?php echo Form::open(array('url' => url('loan/'.$loan->id.'/guarantor/add'),'method'=>'post')); ?>

                <div class="modal-body">
                    <div class="form-group">
                        <div class="form-line">
                            <?php echo Form::label('guarantor_id',translate('guarantor'),array('class'=>' control-label')); ?>

                            <?php echo Form::select('guarantor_id',$guarantors,null,array('class'=>' select2','required'=>'required','placeholder'=>'')); ?>

                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-info"><?php echo e(translate('save')); ?></button>
                    <button type="button" class="btn default"
                            data-dismiss="modal"><?php echo e(translate('close')); ?></button>
                </div>
                <?php echo Form::close(); ?>

            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('footer-scripts'); ?>
    <script>

        $('#repayments-data-table').DataTable({
            dom: '<"datatable-header"fl><"datatable-scroll"t><"datatable-footer"ip>',
            autoWidth: false,
            columnDefs: [{
                orderable: false,
                width: '100px',
                targets: [8]
            }],
            "order": [[1, "asc"]],
            language: {
                "lengthMenu": "<?php echo e(translate('lengthMenu')); ?>",
                "zeroRecords": "<?php echo e(translate('zeroRecords')); ?>",
                "info": "<?php echo e(translate('info')); ?>",
                "infoEmpty": "<?php echo e(translate('infoEmpty')); ?>",
                "search": "<?php echo e(translate('search')); ?>:",
                "infoFiltered": "<?php echo e(translate('infoFiltered')); ?>",
                "paginate": {
                    "first": "<?php echo e(translate('first')); ?>",
                    "last": "<?php echo e(translate('last')); ?>",
                    "next": "<?php echo e(translate('next')); ?>",
                    "previous": "<?php echo e(translate('previous')); ?>"
                }
            },
            drawCallback: function () {
                $('.delete').on('click', function (e) {
                    e.preventDefault();
                    var href = $(this).attr('href');
                    swal({
                        title: 'Are you sure?',
                        text: '',
                        type: 'warning',
                        showCancelButton: true,
                        confirmButtonColor: '#3085d6',
                        cancelButtonColor: '#d33',
                        confirmButtonText: 'Ok',
                        cancelButtonText: 'Cancel'
                    }).then(function () {
                        window.location = href;
                    })
                });
            }
        });
    </script>
    <script>
        $(document).ready(function () {
            $("body").addClass('sidebar-xs');
            $('#withdrawSaving').on('shown.bs.modal', function (e) {
                var id = $(e.relatedTarget).data('id');
                var amount = $(e.relatedTarget).data('amount');
                var url = "<?php echo url('loan/'.$loan->id.'/guarantor'); ?>/" + id + "/withdraw";
                $(e.currentTarget).find("#withdrawSavingForm").attr('action', url);
                $(e.currentTarget).find("#accepted_amount").val(amount);
            });
            $('.deleteLoan').on('click', function (e) {
                e.preventDefault();
                var href = $(this).attr('href');
                swal({
                    title: '<?php echo e(translate('are_you_sure')); ?>',
                    text: '<?php echo e(translate('delete_loan_msg')); ?>',
                    type: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: '<?php echo e(translate('ok')); ?>',
                    cancelButtonText: '<?php echo e(translate('cancel')); ?>'
                }).then(function () {
                    window.location = href;
                })
            });
            $('.deletePayment').on('click', function (e) {
                e.preventDefault();
                var href = $(this).attr('href');
                swal({
                    title: '<?php echo e(translate('are_you_sure')); ?>',
                    text: '<?php echo e(translate('delete_payment_msg')); ?>',
                    type: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: '<?php echo e(translate('ok')); ?>',
                    cancelButtonText: '<?php echo e(translate('cancel')); ?>'
                }).then(function () {
                    window.location = href;
                })
            });
            $('.deleteComment').on('click', function (e) {
                e.preventDefault();
                var href = $(this).attr('href');
                swal({
                    title: '<?php echo e(translate('are_you_sure')); ?>',
                    text: '',
                    type: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: '<?php echo e(translate('ok')); ?>',
                    cancelButtonText: '<?php echo e(translate('cancel')); ?>'
                }).then(function () {
                    window.location = href;
                })
            });
        });

        function setPenaltyValue(value, schedule_id) {
            //var value = parseFloat(value).toFixed;
            $(".waivePenaltyAmount").val(value);
            $('#schedule_id').val(schedule_id);
        }
    </script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /var/www/html/thb_loan_system/resources/views/loan/show.blade.php ENDPATH**/ ?>

© KUJUNTI.ID