
            <div class="row profile">
                <div class="col-md-12">
                    
                    <div id="response_msg"></div>
                                
                    <div id="submit_this_cheque" class="modal fade" tabindex="-1" aria-hidden="true">
                        <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                                    <h4 class="modal-title">Submit This Cheque</h4>
                                </div>
                                <form id="submit_cheque_action" class="form-horizontal" method="post">
                                    <input type="hidden" name="cheque_id" value="<?php echo $cheque_details->id; ?>">
                                    <input type="hidden" name="cheque_type" value="<?php echo $cheque_details->cheque_type; ?>">
                                    <input type="hidden" name="payment_id" value="<?php echo $cheque_details->payment_id; ?>">
                                    <input type="hidden" name="customer_id" value="<?php echo $cheque_details->customer_id; ?>">
                                    <input type="hidden" name="cheque_amount" value="<?php echo $cheque_details->cheque_amount; ?>">
                                    <input type="hidden" name="cheque_number" value="<?php echo $cheque_details->cheque_number; ?>">
                                    <div class="modal-body">
                                        <div id="response_msg_modal"></div>
                                        <div class="scroller" style="height:300px" data-always-visible="1" data-rail-visible1="1">
                                            <div class="row">
                                                <div class="col-md-12">
                                                    <div class="form-body">
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">Bank Name</label>
                                                            <div class="col-md-9">
                                                                <div class="control-label pull-left">
                                                                    <?php 
                                                                        $bank_details = $this->admin_db->get_bank_by_id($cheque_details->bank_id);
                                                                        echo $bank_details->bank_name; 
                                                                    ?>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">Cheque Number</label>
                                                            <div class="col-md-9">
                                                                <div class="control-label pull-left">
                                                                    <?php echo $cheque_details->cheque_number; ?>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">Cheque Amount</label>
                                                            <div class="col-md-9">
                                                                <div class="control-label pull-left">
                                                                    <?php echo 'Rs. '.number_format($cheque_details->cheque_amount,2,'.',','); ?>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">Deposit Date</label>
                                                            <div class="col-md-9">
                                                                <div class="control-label pull-left">
                                                                    <?php echo date("d-m-Y", strtotime($cheque_details->deposit_date)); ?>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="row form-group">
                                                            <label class="col-md-3 control-label pull-left">Cheque Action</label>
                                                            <div class="col-md-6">
                                                                <select class="form-control input-large" name="submit_action" id="submit_action">
                                                                    <option value="Bank Deposited">Bank Deposited</option>
                                                                    <option value="Cashed">Cashed</option>
                                                                    <option value="Cheque Returned">Cheque Returned</option>
                                                                    <option value="Cheque Cancelled">Cheque Cancelled</option>
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="row form-group" id="div_chq_submit_bank_account">
                                                            <label class="col-md-3 control-label pull-left">Bank Account</label>
                                                            <div class="col-md-6">
                                                                <select class="form-control input-large select2me" name="bank_account" id="bank_account">
                                                                    <?php
                                                                        if($cheque_details->cheque_type == 'Box Sale'){
                                                                            $accounts = $this->admin_db->get_box_bank_accounts_for_receipts();
                                                                        }elseif($cheque_details->cheque_type == 'Sale'){
                                                                            $accounts = $this->admin_db->get_dxb_bank_accounts_for_receipts();
                                                                        }else{
                                                                            $accounts = $this->admin_db->get_bank_accounts_for_receipts();
                                                                        }
                                                                        
                                                                        foreach ($accounts as $account) {
                                                                            $sel = '';
                                                                    ?>

                                                                    <option value="<?php echo $account['id']; ?>" <?php echo $sel; ?>><?php echo $account['account_name'].' - '.$account['account_number'].' - '.$account['bank_name']; ?></option>

                                                                    <?php } ?>
                                                                </select>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" data-dismiss="modal" class="btn default">Close</button>
                                        <button type="submit" class="btn green">Save changes</button>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>

                    <div class="modal fade" id="success_modal" tabindex="-1" role="basic" aria-hidden="true">
                        <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                                    <h4 class="modal-title">Success!</h4>
                                </div>
                                <div class="modal-body">
                                    Cheque Submitted Successfully
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn green" data-dismiss="modal" onclick="window.location.reload()">Ok</button>
                                </div>
                            </div>
                            <!-- /.modal-content -->
                        </div>
                        <!-- /.modal-dialog -->
                    </div>
                    <!-- /.modal -->
                    
                    <!--BEGIN TABS-->
                    <div class="tabbable tabbable-custom tabbable-full-width">
                        
                        <div class="tab-content">
                            <div class="tab-pane active" id="tab_1_1">
                                <div class="row">
                                    <div class="col-md-12">
                                        <?php if($cheque_details->status == 'Pending' && $cheque_details->deposit_date <= date('Y-m-d')){ ?>
                                            <div class="pull-right">
                                                <a class="btn default yellow-stripe"  data-toggle="modal" href="#submit_this_cheque"> Submit This Cheque</a>
                                            </div>
                                        <?php } ?>
                                        <h4>Cheque Details</h4>
                                        <hr>
                                        <div class="row">
                                            <div class="col-md-offset-1 col-md-10">
                                                <table class="table table-hover table-bordered table-striped" align="center">
                                                    <?php if($cheque_details->customer_id != null){ ?>
                                                        <tr>
                                                            <td>
                                                                <strong>Customer Name</strong>
                                                            </td>
                                                            <td>
                                                                <?php echo $customer_details->customer_name; ?>
                                                            </td>
                                                            <td>
                                                                <strong>Contact Number</strong>
                                                            </td>
                                                            <td>
                                                                <?php echo $customer_details->contact_number; ?>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td>
                                                                <strong>Customer Type</strong>
                                                            </td>
                                                            <td>
                                                                <?php echo $customer_details->customer_type; ?>
                                                            </td>
                                                            <td>
                                                                <strong>Customer Status</strong>
                                                            </td>
                                                            <td>
                                                                <?php
                                                                if($customer_details->status == 1){
                                                                    echo '<span class="label label-success">Active</span>';
                                                                }else if($customer_details->status == 2){
                                                                    echo '<span class="label label-warning">Inactive</span>';
                                                                }else if($customer_details->status == 3){
                                                                    echo '<span class="label label-danger">Deleted</span>';
                                                                }else if($customer_details->status == 4){
                                                                    echo '<span class="label label-info">Hold-On</span>';
                                                                }
                                                                ?>
                                                            </td>
                                                        </tr>
                                                    <?php } ?>
                                                    <tr>
                                                        <td>
                                                            <strong>Cheque Number</strong>
                                                        </td>
                                                        <td>
                                                            <?php echo $cheque_details->cheque_number; ?>
                                                        </td>
                                                        <td>
                                                            <strong>Bank Name</strong>
                                                        </td>
                                                        <td>
                                                            <?php 
                                                                $bank_details = $this->admin_db->get_bank_by_id($cheque_details->bank_id);
                                                                echo $bank_details->bank_name; 
                                                            ?>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            <strong>Cheque Amount</strong>
                                                        </td>
                                                        <td>
                                                            <?php echo 'Rs. '.number_format($cheque_details->cheque_amount,2,'.',','); ?>
                                                        </td>
                                                        <td>
                                                            <strong>Cheque Deposit Date</strong>
                                                        </td>
                                                        <td>
                                                            <?php echo date("d-m-Y", strtotime($cheque_details->deposit_date)); ?>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            <strong>Cheque Status</strong>
                                                        </td>
                                                        <td>
                                                            <?php
                                                                if($cheque_details->status == 'Deposited'){
                                                                    echo '<span class="label label-success">Deposited</span>';
                                                                }elseif($cheque_details->status == 'Pending'){
                                                                    echo '<span class="label label-warning">Pending</span>';
                                                                }elseif($cheque_details->status == 'Returned'){
                                                                    echo '<span class="label label-danger">Returned</span>';
                                                                }elseif($cheque_details->status == 'Cancelled'){
                                                                    echo '<span class="label label-danger">Cancelled</span>';
                                                                }
                                                            ?>
                                                        </td>
                                                        <td></td>
                                                        <td></td>
                                                    </tr>
                                                </table>
                                            </div>
                                            <!--end col-md-8-->
                                        </div>
                                        <!--end row-->
                                        
                                        <?php if(($cheque_details->cheque_type == 'Sale') && $sale_details){ ?>
                                        <h4>Sale Details</h4>
                                        <hr>
                                        
                                        <?php if($payment_details->payment_type == 'Normal'){ ?>
                                            <table class="table table-striped table-bordered table-hover">
                                                <thead>
                                                    <tr>
                                                        <th style="width: 12%;"><strong>Invoice Number</strong></th>
                                                        <th><strong>Sales Date</strong></th>
                                                        <th><strong>24K Rate</strong></th>
                                                        <th><strong>Payment Status</strong></th>
                                                        <th><strong>Total Amount</strong></th>
                                                        <th><strong>Paid Amount</strong></th>
                                                        <th><strong>Action</strong></th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <?php 
                                                    $total_amount = 0;
                                                    $paid_amount = 0;

                                                    foreach($sale_details as $sale_detail) { ?>                                                        
                                                    <tr>
                                                        <td><?php echo $sale_detail['invoice_num']; ?></td>
                                                        <td><?php echo date("d-m-Y", strtotime($sale_detail['date'])); ?></td>
                                                        <td><?php // echo 'Rs. '.number_format($sale_detail['24k_rate'],2,'.',','); ?></td>
                                                        <td><?php 
                                                            if($sale_detail['status'] == 2){
                                                                echo '<span class="label label-warning">Payment Incomplete</span>';
                                                            }else if($sale_detail['status'] == 3){
                                                                echo '<span class="label label-danger">Payment Pending</span>';
                                                            }
                                                            ?>
                                                        </td>
                                                        <td><?php $total_amount += $sale_detail['total_amount']; echo 'Rs. '.number_format($sale_detail['total_amount'],2,'.',','); ?></td>
                                                        <td><?php $paid_amount += $sale_detail['paid_amount']; echo 'Rs. '.number_format($sale_detail['paid_amount'],2,'.',','); ?></td>
                                                        <td><a data-toggle="tooltip" title="View Sale" class="btn default btn-xs blue-stripe" href="<?php echo base_url().'view_sale?sale_id='.$sale_detail['sale_id'];?>" target="_blank"> View </a></td>
                                                    </tr> 
                                                    <?php }?> 
                                                    <tr>
                                                        <th colspan="4">Total</th>
                                                        <th><?php echo 'Rs. '.number_format($total_amount,2,'.',','); ?></th>
                                                        <th><?php echo 'Rs. '.number_format($paid_amount,2,'.',','); ?></th>
                                                        <th></th>
                                                    </tr>  
                                                </tbody>
                                            </table>  
                                        <?php }else if($payment_details->payment_type == 'Fixing'){ ?>
                                            <table class="table table-striped table-bordered table-hover">
                                                <thead>
                                                    <tr>
                                                        <th style="width: 5%;"><strong>#</strong></th>
                                                        <th style="width: 10%;"><strong>Sales Date</strong></th>
                                                        <th><strong>Payment Status</strong></th>
                                                        <th><strong>Total Amount</strong></th>
                                                        <th><strong>Paid Amount in Gold</strong></th>
                                                        <th><strong>Paid Amount in Cash</strong></th>
                                                        <th><strong>Action</strong></th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <?php 
                                                    $total_amount = 0;
                                                    $paid_amount_in_gold = 0;
                                                    $paid_amount_in_cash = 0;

                                                    foreach($sale_details as $sale_detail) { ?>                                                        
                                                    <tr>
                                                        <td><?php echo $sale_detail['invoice_num']; ?></td>
                                                        <td><?php echo date("d-m-Y", strtotime($sale_detail['date'])); ?></td>
                                                        <td><?php 
                                                            if($sale_detail['status'] == 2){
                                                                echo '<span class="label label-warning">Payment Incomplete</span>';
                                                            }else if($sale_detail['status'] == 3){
                                                                echo '<span class="label label-danger">Payment Pending</span>';
                                                            }
                                                            ?>
                                                        </td>
                                                        <td><?php $total_amount += $sale_detail['total_amount']; echo number_format($sale_detail['total_amount'],3,'.',',').' g'; ?></td>
                                                        <td><?php $paid_amount_in_gold += $sale_detail['paid_amount_in_gold']; echo number_format($sale_detail['paid_amount_in_gold'],3,'.',',').' g'; ?></td>
                                                        <td><?php $paid_amount_in_cash += $sale_detail['paid_amount_in_cash']; echo 'Rs. '.number_format($sale_detail['paid_amount_in_cash'],2,'.',','); ?></td>
                                                        <td><a data-toggle="tooltip" title="View Sale" class="btn default btn-xs blue-stripe" href="<?php echo base_url().'view_sale?sale_id='.$sale_detail['sale_id'];?>" target="_blank"> View </a></td>
                                                    </tr> 
                                                    <?php }?> 
                                                    <tr>
                                                        <th colspan="3">Total</th>
                                                        <th><?php echo number_format($total_amount,3,'.',',').' g'; ?></th>
                                                        <th><?php echo number_format($paid_amount_in_gold,3,'.',',').' g'; ?></th>
                                                        <th><?php echo 'Rs. '.number_format($paid_amount_in_cash,2,'.',','); ?></th>
                                                        <th></th>
                                                    </tr>  
                                                </tbody>
                                            </table>
                                        <?php }} ?>
                                        
                                        <?php if(($cheque_details->cheque_type == 'Box Sale') && $sale_details){ ?>
                                        <h4>Sale Details</h4>
                                        <hr>
                                        
                                        <?php if($payment_details->payment_type == 'Normal'){ ?>
                                            <table class="table table-striped table-bordered table-hover">
                                                <thead>
                                                    <tr>
                                                        <th style="width: 12%;"><strong>Invoice Number</strong></th>
                                                        <th><strong>Sales Date</strong></th>
                                                        <th><strong>24K Rate</strong></th>
                                                        <th><strong>Payment Status</strong></th>
                                                        <th><strong>Total Amount</strong></th>
                                                        <th><strong>Paid Amount</strong></th>
                                                        <th><strong>Action</strong></th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <?php 
                                                    $total_amount = 0;
                                                    $paid_amount = 0;

                                                    foreach($sale_details as $sale_detail) { ?>                                                        
                                                    <tr>
                                                        <td><?php echo $sale_detail['box_sale_id']; ?></td>
                                                        <td><?php echo date("d-m-Y", strtotime($sale_detail['date'])); ?></td>
                                                        <td><?php // echo 'Rs. '.number_format($sale_detail['24k_rate'],2,'.',','); ?></td>
                                                        <td><?php 
                                                            if($sale_detail['status'] == 2){
                                                                echo '<span class="label label-warning">Payment Incomplete</span>';
                                                            }else if($sale_detail['status'] == 3){
                                                                echo '<span class="label label-danger">Payment Pending</span>';
                                                            }
                                                            ?>
                                                        </td>
                                                        <td><?php $total_amount += $sale_detail['total_amount']; echo 'Rs. '.number_format($sale_detail['total_amount'],2,'.',','); ?></td>
                                                        <td><?php $paid_amount += $sale_detail['paid_amount']; echo 'Rs. '.number_format($sale_detail['paid_amount'],2,'.',','); ?></td>
                                                        <td><a data-toggle="tooltip" title="View Sale" class="btn default btn-xs blue-stripe" href="<?php echo base_url().'view_box_sale?box_sale_id='.$sale_detail['box_sale_id'];?>" target="_blank"> View </a></td>
                                                    </tr> 
                                                    <?php }?> 
                                                    <tr>
                                                        <th colspan="4">Total</th>
                                                        <th><?php echo 'Rs. '.number_format($total_amount,2,'.',','); ?></th>
                                                        <th><?php echo 'Rs. '.number_format($paid_amount,2,'.',','); ?></th>
                                                        <th></th>
                                                    </tr>  
                                                </tbody>
                                            </table>  
                                        <?php }else if($payment_details->payment_type == 'Fixing'){ ?>
                                            <table class="table table-striped table-bordered table-hover">
                                                <thead>
                                                    <tr>
                                                        <th style="width: 5%;"><strong>#</strong></th>
                                                        <th style="width: 10%;"><strong>Sales Date</strong></th>
                                                        <th><strong>Payment Status</strong></th>
                                                        <th><strong>Total Amount</strong></th>
                                                        <th><strong>Paid Amount in Gold</strong></th>
                                                        <th><strong>Paid Amount in Cash</strong></th>
                                                        <th><strong>Action</strong></th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <?php 
                                                    $total_amount = 0;
                                                    $paid_amount_in_gold = 0;
                                                    $paid_amount_in_cash = 0;

                                                    foreach($sale_details as $sale_detail) { ?>                                                        
                                                    <tr>
                                                        <td><?php echo $sale_detail['id']; ?></td>
                                                        <td><?php echo date("d-m-Y", strtotime($sale_detail['date'])); ?></td>
                                                        <td><?php 
                                                            if($sale_detail['status'] == 2){
                                                                echo '<span class="label label-warning">Payment Incomplete</span>';
                                                            }else if($sale_detail['status'] == 3){
                                                                echo '<span class="label label-danger">Payment Pending</span>';
                                                            }
                                                            ?>
                                                        </td>
                                                        <td><?php $total_amount += $sale_detail['total_amount']; echo number_format($sale_detail['total_amount'],3,'.',',').' g'; ?></td>
                                                        <td><?php $paid_amount_in_gold += $sale_detail['paid_amount_in_gold']; echo number_format($sale_detail['paid_amount_in_gold'],3,'.',',').' g'; ?></td>
                                                        <td><?php $paid_amount_in_cash += $sale_detail['paid_amount_in_cash']; echo 'Rs. '.number_format($sale_detail['paid_amount_in_cash'],2,'.',','); ?></td>
                                                        <td><a data-toggle="tooltip" title="View Sale" class="btn default btn-xs blue-stripe" href="<?php echo base_url().'view_box_sale?box_sale_id='.$sale_detail['sale_id'];?>" target="_blank"> View </a></td>
                                                    </tr> 
                                                    <?php }?> 
                                                    <tr>
                                                        <th colspan="3">Total</th>
                                                        <th><?php echo number_format($total_amount,3,'.',',').' g'; ?></th>
                                                        <th><?php echo number_format($paid_amount_in_gold,3,'.',',').' g'; ?></th>
                                                        <th><?php echo 'Rs. '.number_format($paid_amount_in_cash,2,'.',','); ?></th>
                                                        <th></th>
                                                    </tr>  
                                                </tbody>
                                            </table>
                                        <?php }} ?>
                                    </div>
                                </div>
                            </div>
                            <!--tab_1_2-->
                            <div class="tab-pane" id="tab_1_2">
                                <div class="row profile-account">
                                    <div class="col-md-12">
                                        <div class="portlet box grey-cascade">
                                            <div class="portlet-title">
                                                <div class="caption">
                                                    <i class="fa fa-money"></i>Make Payment
                                                </div>
                                            </div>
                                            <div class="portlet-body form">
                                                <!-- BEGIN FORM-->
                                                <form id="make_debtor_payment" class="form-horizontal" method="POST" enctype="multipart/form-data">
                                                    <input type="hidden" name="customer_id" value="<?php echo $customer_details->id ?>"/>
                                                    <input type="hidden" name="debtor_type" value="<?php echo $debtor_type ?>"/>
                                                    <div class="form-body">
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">Date</label>
                                                            <div class="col-md-3">
                                                                <input class="form-control form-control-inline input-medium date-picker" size="16" type="text" data-date-format=dd-mm-yyyy name="invoice_date" value="<?php echo date('d-m-Y') ?>"/>
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">Debtor Type</label>
                                                            <div class="col-md-3">
                                                                <div class="control-label pull-left">
                                                                    <?php 
                                                                    if($debtor_type == 'credit'){
                                                                        echo 'Credit Debtor';
                                                                    }elseif($debtor_type == 'gold'){
                                                                        echo 'Gold Debtor';
                                                                    }
                                                                    ?>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">Payment Method</label>
                                                            <div class="col-md-3">
                                                                <select class="form-control" name="payment_method" id="payment_method">
                                                                    <?php if($debtor_type == 'credit'){ ?>
                                                                        <option value="Cash">Cash</option>
                                                                        <option value="Cheque">Cheque</option>
                                                                        <option value="Bank Deposit">Bank Deposit</option>
                                                                    <?php }elseif($debtor_type == 'gold'){?>
                                                                        <option value="Gold">Gold</option>
                                                                    <?php }?>
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div id="div_cheque_details" class="hidden">
                                                            <div class="form-group">
                                                                <label class="control-label col-md-3">Bank Name</label>
                                                                <div class="col-md-3">
                                                                    <select class="form-control input-medium select2me" name="cheq_bank" id="cheq_bank">
                                                                    <?php
                                                                        $banks = $this->admin_db->get_banks_for_receipts();
                                                                        foreach ($banks as $bank) {
                                                                            $sel = '';
                                                                    ?>

                                                                    <option value="<?php echo $bank['id']; ?>" <?php echo $sel; ?>><?php echo $bank['bank_name']; ?></option>

                                                                    <?php } ?>
                                                                    </select>
                                                                </div>
                                                            </div>
                                                            <div class="form-group">
                                                                <label class="control-label col-md-3">Cheque Number</label>
                                                                <div class="col-md-3">
                                                                    <input class="form-control" type="number" name="cheq_cheque_number" id="cheq_cheque_number"/>
                                                                </div>
                                                            </div>
                                                            <div class="form-group">
                                                                <label class="control-label col-md-3">Deposit Date</label>
                                                                <div class="col-md-3">
                                                                    <input class="form-control form-control-inline input-medium date-picker" size="16" type="text" data-date-format=dd-mm-yyyy name="cheq_deposit_date" value="<?php echo date('d-m-Y') ?>"/>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div id="div_deposit_details" class="hidden">
                                                            <div class="form-group">
                                                                <label class="control-label col-md-3">Bank Account</label>
                                                                <div class="col-md-3">
                                                                    <select class="form-control input-medium select2me" name="deposit_bank_account" id="deposit_bank_account">
                                                                    <?php
                                                                        $accounts = $this->admin_db->get_bank_accounts_for_receipts();
                                                                        foreach ($accounts as $account) {
                                                                            $sel = '';
                                                                    ?>

                                                                    <option value="<?php echo $account['id']; ?>" <?php echo $sel; ?>><?php echo $account['account_name'].' - '.$account['account_number'].' - '.$account['bank_name']; ?></option>

                                                                    <?php } ?>
                                                                    </select>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        
                                                        <?php if($debtor_type == 'credit'){ ?>
                                                        
                                                        <h4>Credit Sale Details</h4>
                                                        <hr>
                                                            <table class="table table-striped table-bordered table-hover">
                                                                <thead>
                                                                    <tr>
                                                                        <th><strong>#</strong></th>
                                                                        <th><strong>Sales Date</strong></th>
                                                                        <th><strong>24K Rate</strong></th>
                                                                        <th><strong>Payment Status</strong></th>
                                                                        <th><strong>Total Amount</strong></th>
                                                                        <th><strong>Amount to be Paid</strong></th>
                                                                        <th><strong>Payment Amount</strong></th>
                                                                        <th><strong>Balance Amount</strong></th>
                                                                        <th><strong>Action</strong></th>
                                                                    </tr>
                                                                </thead>
                                                                <tbody>
                                                                    <?php 
                                                                    $total_amount = 0;
                                                                    $balance_amount = 0;
                                                                    $x = 0;
                                                                    foreach($sale_details as $sale_detail) { ?>                                                        
                                                                    <tr>
                                                                        <td><?php echo $sale_detail['id']; ?></td>
                                                                        <td><?php echo date("d-m-Y", strtotime($sale_detail['date'])); ?></td>
                                                                        <td><?php echo 'Rs. '.number_format($sale_detail['24k_rate'],2,'.',','); ?></td>
                                                                        <td><?php 
                                                                            if($sale_detail['status'] == 2){
                                                                                echo '<span class="label label-warning">Payment Incomplete</span>';
                                                                            }else if($sale_detail['status'] == 3){
                                                                                echo '<span class="label label-danger">Payment Pending</span>';
                                                                            }
                                                                            ?>
                                                                        </td>
                                                                        <td><?php $total_amount += $sale_detail['total_amount']; echo 'Rs. '.number_format($sale_detail['total_amount'],2,'.',','); ?></td>
                                                                        <td><?php $balance_amount += $sale_detail['balance_amount']; echo 'Rs. '.number_format($sale_detail['balance_amount'],2,'.',','); ?></td>
                                                                        <td><input type="number" class="form-control input-small debtor_payment_amount" id="debtor_payment_amount<?php echo $sale_detail['id']; ?>" item-id="<?php echo $sale_detail['id']; ?>" bal-amount="<?php echo $sale_detail['balance_amount']; ?>" name="debtor_payment_amount[<?php echo $x; ?>]"></td>
                                                                        <td id="div_debtor_bal_amount<?php echo $sale_detail['id']; ?>" style="color: #2d823a"><?php echo 'Rs. '.number_format($sale_detail['balance_amount'],2,'.',','); ?></td>
                                                                        <td class="hidden">
                                                                            <input type="number" class="form-control input-small debtor_balance_amount" id="debtor_balance_amount<?php echo $sale_detail['id']; ?>" name="debtor_balance_amount[<?php echo $x; ?>]">
                                                                            <input type="number" class="form-control input-small" value="<?php echo $sale_detail['id']; ?>" name="sale_ids[<?php echo $x; ?>]">
                                                                        </td>
                                                                        <td><a data-toggle="tooltip" title="View Sale" class="btn default btn-xs blue-stripe" href="<?php echo base_url().'view_sale?sale_id='.$sale_detail['id'];?>" target="_blank"> View</a></td>
                                                                    </tr> 
                                                                    <?php $x++; }?> 
                                                                    <tr>
                                                                        <th colspan="4">Total</th>
                                                                        <th><?php echo 'Rs. '.number_format($total_amount,2,'.',','); ?></th>
                                                                        <th>
                                                                            <input type="hidden" class="form-control input-small" id="tot_amount_to_be_paid" value="<?php echo $balance_amount; ?>" name="tot_amount_to_be_paid">
                                                                            <?php echo 'Rs. '.number_format($balance_amount,2,'.',','); ?>
                                                                        </th>
                                                                        <th id="debtor_total_paid">Rs. 0.00</th>
                                                                        <input type="text" class="form-control input-small" id="tot_payment_amount" value="0.00" name="tot_payment_amount">
                                                                        <th id="debtor_total_balance_amount">Rs. 0.00</th>
                                                                        <th></th>
                                                                    </tr>  
                                                                </tbody>
                                                            </table>                                            
                                                        <?php }else if($debtor_type == 'gold'){ ?>
                                                        
                                                        <h4>Gold Sale Details</h4>
                                                        <hr>
                                                            <table class="table table-striped table-bordered table-hover" id="">
                                                                <thead>
                                                                    <tr>
                                                                        <th><strong>#</strong></th>
                                                                        <th><strong>Sales Date</strong></th>
                                                                        <th><strong>Payment Status</strong></th>
                                                                        <th><strong>Total Gold</strong></th>
                                                                        <th><strong>Gold to be Paid</strong></th>
                                                                        <th><strong>Payment Gold</strong></th>
                                                                        <th><strong>Balance Gold</strong></th>
                                                                        <th><strong>Action</strong></th>
                                                                    </tr>
                                                                </thead>
                                                                <tbody>
                                                                    <?php 
                                                                    $total_amount = 0;
                                                                    $balance_amount = 0;
                                                                    $x = 0;
                                                                    foreach($sale_details as $sale_detail) { ?>                                                        
                                                                    <tr>
                                                                        <td><?php echo $sale_detail['id']; ?></td>
                                                                        <td><?php echo date("d-m-Y", strtotime($sale_detail['date'])); ?></td>
                                                                        <td><?php 
                                                                            if($sale_detail['status'] == 2){
                                                                                echo '<span class="label label-warning">Payment Incomplete</span>';
                                                                            }else if($sale_detail['status'] == 3){
                                                                                echo '<span class="label label-danger">Payment Pending</span>';
                                                                            }
                                                                            ?>
                                                                        </td>
                                                                        <td><?php $total_amount += $sale_detail['total_amount']; echo $sale_detail['total_amount'].' g'; ?></td>
                                                                        <td><?php $balance_amount += $sale_detail['balance_amount']; echo $sale_detail['balance_amount'].' g'; ?></td>
                                                                        <td><input type="number" class="form-control input-small debtor_payment_amount_gold" id="debtor_payment_amount_gold<?php echo $sale_detail['id']; ?>" item-id="<?php echo $sale_detail['id']; ?>" bal-amount="<?php echo $sale_detail['balance_amount']; ?>" name="debtor_payment_amount[<?php echo $x; ?>]"></td>
                                                                        <td id="div_debtor_bal_amount_gold<?php echo $sale_detail['id']; ?>" style="color: #2d823a"><?php echo $sale_detail['balance_amount'].' g'; ?></td>
                                                                        <td class="hidden">
                                                                            <input type="number" class="form-control input-small debtor_balance_amount_gold" id="debtor_balance_amount_gold<?php echo $sale_detail['id']; ?>" name="debtor_balance_amount[<?php echo $x; ?>]">
                                                                            <input type="number" class="form-control input-small" value="<?php echo $sale_detail['id']; ?>" name="sale_ids[<?php echo $x; ?>]">
                                                                        </td>
                                                                        <td><a data-toggle="tooltip" title="View Sale" class="btn default btn-xs blue-stripe" href="<?php echo base_url().'view_sale?sale_id='.$sale_detail['id'];?>" target="_blank"> View</a></td>
                                                                    </tr> 
                                                                    <?php $x++; }?> 
                                                                    <tr>
                                                                        <th colspan="3">Total</th>
                                                                        <th><?php echo $total_amount.' g'; ?></th>
                                                                        <th>
                                                                            <input type="hidden" class="form-control input-small" id="tot_amount_to_be_paid_gold" value="<?php echo $balance_amount; ?>" name="tot_amount_to_be_paid">
                                                                            <?php echo $balance_amount.' g'; ?>
                                                                        </th>
                                                                        <th id="debtor_total_paid_gold">0 g</th>
                                                                        <input type="text" class="form-control input-small" id="tot_payment_amount_gold" value="0" name="tot_payment_amount">
                                                                        <th id="debtor_total_balance_amount_gold">0 g</th>
                                                                        <th></th>
                                                                    </tr>  
                                                                </tbody>
                                                            </table>
                                                        <?php } ?>
                                                        
                                                        
                                                        

                                                        <div class="invoice">
                                                            <div class="row">
                                                                <div class="col-xs-4"> </div>
                                                                <div class="col-xs-8 invoice-block" align="right">
                                                                    <button type="submit" class="btn btn-lg green hidden-print margin-bottom-5" id="div_submit_button">
                                                                    Submit Payment <i class="fa fa-check"></i>
                                                                    </button>

                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </form>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!--end tab-pane-->
                        </div>
                    </div>
                    <!--END TABS-->
                </div> 
            </div>
            <!-- END DASHBOARD STATS -->
        </div>
    </div>
    <!-- END CONTENT -->
</div>
<!-- END CONTAINER -->
