<h6 class="foir_formula" style="margin-bottom:15px">FOIR = [(Total EMIs + CF EMI + 2% Credit Card Limit) / (Income<?php if(isset($consumer_applications->purpose) && $consumer_applications->purpose == 24) { echo " + Power Savings";} ?>)] x 100 </h6>
<h6 class="cf_foir_formula" style="margin-bottom:15px">CF FOIR = (CF EMI / (Income<?php if(isset($consumer_applications->purpose) && $consumer_applications->purpose == 24) { echo " + Power Savings";} ?>)) * 100 </h6>
<div  style="overflow: scroll;">
    <div class="btn-group" id="credit_score_both" data-toggle="buttons">
        <label class="btn btn-default btn-on active foir_selection">
            <input type="radio" value="1" checked="checked">Show Applicant FOIR</label>
        <label class="btn btn-default btn-off foir_selection">
            <input type="radio" value="2">Show Co-Applicant FOIR</label>
        <label class="btn btn-default btn-off foir_selection">
            <input type="radio" value="0">Show Both Applicant FOIR</label>
    </div>
    <table class="table show_ratio">
        <tr>
            <td style="color: #4e5858;" colspan="4"><code>Active Credit card limit</code></td>
        </tr>
        <tr>
            <td style="font-weight: 600;">AccountType</td>
            <td style="font-weight: 600;">InstallmentAmount</td>
            <td style="font-weight: 600;">Action</td>
        </tr>
        <?php $amount = 0; ?>
        <?php if(isset($consumer_applications->foir)): ?>
            <?php $__currentLoopData = $consumer_applications->foir; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $foir): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <?php if($foir->cc_loan == 0 && $foir->isOpened == 1): ?>
                    <?php $amount += $foir->InstallmentAmount; ?>
                    <tr class="foir new_foir_details foir_date_row_<?php echo $foir->id; ?>" style="<?php echo ($foir->applicant_type == 2) ? 'display:none;': ''; ?>" data-credit-id="<?php echo $foir->credit_id; ?>" data-is-include="<?php if($foir->applicant_type == 1): ?> 1 <?php else: ?> 0 <?php endif; ?>" data-applicant-type="<?php echo $foir->applicant_type; ?>" data-id="<?php echo $foir->id; ?>" data-type="credit" data-account-type="<?php echo $foir->AccountType; ?>">
                        <td><?php echo $foir->AccountType; ?></td>
                        <td><input type="text" value="<?php echo $foir->InstallmentAmount; ?>" placeholder="Installment Amount" class="form-control <?php if($foir->InstallmentAmount > 0): ?> hide_in_foir <?php endif; ?>" <?php if($foir->InstallmentAmount > 0): ?> readonly <?php endif; ?> name="installment_amount"/></td>
                        <?php if($foir->created_by && \Illuminate\Support\Facades\Session::has('delete_trade_line|-4')): ?>
                            <td class="delete-foir-row" data-id="<?php echo $foir->id; ?>"><i class="fa fa-trash"></i></td>
                        <?php endif; ?>
                    </tr>
                <?php endif; ?>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        <?php endif; ?>
        <tr>
            <td style="font-weight: 600;" class="total_credit_limit">Total Credit Limit</td>
            <td colspan="4"><?php echo $amount; ?></td>
        </tr>
    </table>
    <?php if(\Illuminate\Support\Facades\Session::has('Add_Trade_Line|-16')): ?>
        <div class="btn btn-primary add_more_foir" data-type="credit">Add More</div>
    <?php endif; ?>
    <table class="table km_dhw_sg">
        <tr>
            <td colspan="3"><code>Existing EMI</code></td>
        </tr>
        <tr>
            <td style="font-weight: 600;">AccountType</td>
            <td style="font-weight: 600;">InstallmentAmount</td>
            <td style="font-weight: 600;">Action</td>
        </tr>
        <?php $amount = 0; $is_credit_fair_set = 0; $jointLoans = []; $inc_foir = 1; ?>
        <?php if(isset($consumer_applications->foir)): ?>
            <?php $__currentLoopData = $consumer_applications->foir; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $foir): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <?php if($foir->AccountType == 'Credit Fair EMI'): ?> <?php $is_credit_fair_set = 1; ?> <?php endif; ?>
                <?php if($foir->applicant_type == 2 && $foir->OwnershipType == 'Joint Account' && in_array($foir->AccountType, $jointLoans)){$inc_foir = 0;} ?>
                <?php if($foir->OwnershipType != 'Guarantor' && ($foir->cc_loan == 1 && $foir->isOpened == 1 && ($foir->Balance > 0 || $foir->created_by > 0)) && $inc_foir): ?>
                    <?php $amount += $foir->InstallmentAmount; if($foir->applicant_type == 1){ $jointLoans[] = $foir->AccountType;} ?>
                    <tr class="foir new_foir_details foir_date_row_<?php echo $foir->id; ?>" style="<?php echo ($foir->applicant_type == 2) ? 'display:none;': ''; ?>" data-credit-id="<?php echo $foir->credit_id; ?>" data-is-include="<?php if($foir->applicant_type == 1): ?> 1 <?php else: ?> 0 <?php endif; ?>" data-applicant-type="<?php echo $foir->applicant_type; ?>" data-id="<?php echo $foir->id; ?>" data-type="loan" data-account-type="<?php echo $foir->AccountType; ?>">
                        <td <?php if($foir->AccountType == 'Credit Fair EMI'): ?> class="select_plan_edit_td" <?php endif; ?>> <?php echo $foir->AccountType; ?> <?php if($foir->AccountType == 'Credit Fair EMI'): ?> <span class="select_plan_edit">(Select Other EMI Plan)</span> <?php endif; ?></td>
                        <td><input type="text" value="<?php echo $foir->InstallmentAmount; ?>" placeholder="Installment Amount" class="form-control <?php if($foir->InstallmentAmount > 0): ?> hide_in_foir <?php endif; ?>" <?php if($foir->InstallmentAmount > 0): ?> readonly <?php endif; ?> name="installment_amount"/></td>
                        <?php if($foir->created_by && \Illuminate\Support\Facades\Session::has('delete_trade_line|-4')): ?>
                            <td class="delete-foir-row" data-id="<?php echo $foir->id; ?>"><i class="fa fa-trash"></i></td>
                        <?php endif; ?>
                    </tr>
                <?php endif; ?>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        <?php endif; ?>
        <?php if($is_credit_fair_set == 0): ?>
            <tr class="new_foir_details" data-is-include="1" data-applicant-type="1" data-type="loan" data-account-type="Credit Fair EMI">
                <td class="select_plan_edit_td">Credit Fair EMI  <span class="select_plan_edit">(Select Other EMI Plan)</span></td>
                <td colspan="4"><input type="text" value="" placeholder="Installment Amount" class="form-control hide_in_foir" readonly name="installment_amount"/></td>
            </tr>
        <?php endif; ?>
        <tr class="emi-default-hide">
            <td colspan="5">
                <div class="emi-calculation-summary m-section__content">

                </div>
            </td>
        </tr>
        <tr>
            <td style="font-weight: 600;" class="total_existing_emi">Total Existing EMI</td>
            <td colspan="4"><?php echo $amount; ?></td>
        </tr>
    </table>
    <?php if(\Illuminate\Support\Facades\Session::has('Add_Trade_Line|-16')): ?>
        <div class="btn btn-primary add_more_foir" data-type="loan">Add More</div>
    <?php endif; ?>
    <table class="table">
        <tr>
            <td colspan="3"><code>Guarantor Loans</code></td>
        </tr>
        <tr>
            <td style="font-weight: 600;">Account Type</td>
            <td style="font-weight: 600;">Sanction Amount</td>
        </tr>
        <?php if(isset($consumer_applications->foir)): ?>
            <?php $__currentLoopData = $consumer_applications->foir; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $foir): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <?php if($foir->OwnershipType == 'Guarantor' && ($foir->cc_loan == 1 && $foir->isOpened == 1 && ($foir->Balance > 0 || $foir->created_by > 0))): ?>
                    <tr>
                        <td><?php echo $foir->AccountType; ?></td>
                        <td style="<?php if($foir->PastDueAmount > 0): ?> color:red; <?php endif; ?>"><?php echo $foir->ApprovedAmount; ?> <?php if($foir->PastDueAmount > 0): ?> <span style="font-size: 12px;">(Past Due Amount <?php echo $foir->PastDueAmount; ?>)</span> <?php endif; ?></td>
                    </tr>
                <?php endif; ?>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        <?php endif; ?>
    </table>
    <div class="btn btn-success calculate_foir_btn">Calculate FOIR</div>
</div>
