
            <div class="row profile">
                <div class="col-md-12">
                    
                    <div id="response_msg"></div>

                    <div id="view_payment_history" class="modal fade" tabindex="-1" aria-hidden="true">
                        <div class="modal-dialog modal-lg">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                                    <h4 class="modal-title">Payment History</h4>
                                </div>
                                <div class="modal-body">
                                    <table class="table table-bordered">
                                        <thead>
                                            <th style="width: 10%">
                                                Date
                                            </th>
                                            <th style="width: 16%">
                                                Payment Method
                                            </th>
                                            <th>
                                                Bank
                                            </th>
                                            <th>
                                                Chq. num / Acc. num
                                            </th>
                                            <th style="width: 13%">
                                                Deposit Date
                                            </th>
                                            <th style="width: 13%">
                                                Chq Status
                                            </th>
                                            <?php if($sale_details->sale_type == 'Gold Sale'){ ?>
                                                <th style="width: 15%">
                                                    Paid Amount In Gold
                                                </th>
                                            <?php } ?>
                                            <th style="width: 15%">
                                                Paid Amount In Cash
                                            </th>
                                        </thead>
                                        <tbody>
                                            <?php 
                                            $total_paid_amount_gold = 0;
                                            $total_paid_amount_cash = 0;
                                            foreach($payment_items as $payment_item){ 
                                            if($payment_item['payment_status'] == 2){
                                                $pulse_effect = "style='background-color: #ffe492;'";
                                            }elseif($payment_item['payment_status'] == 3 || $payment_item['payment_status'] == 4){
                                                $pulse_effect = "style='background-color: #ef888c;'";
                                            }else{
                                                $pulse_effect = "";
                                            }    
                                            ?>
                                            <tr <?php echo $pulse_effect; ?>>
                                                <td>
                                                    <?php echo date("d-m-Y", strtotime($payment_item['date'])); ?>
                                                </td>
                                                <td>
                                                    <?php echo $payment_item['payment_method']; ?>
                                                </td>
                                                <td>
                                                    <?php 
                                                    if($payment_item['payment_method'] == 'Cheque'){
                                                        echo $payment_item['bank_name'];
                                                    }elseif($payment_item['payment_method'] == 'Bank Deposit'){
                                                        $bank_details = $this->admin_db->get_bank_by_id($payment_item['bank_id']);
                                                        echo $bank_details->bank_name;
                                                    }
                                                    ?>
                                                </td>
                                                <td>
                                                    <?php 
                                                    if($payment_item['payment_method'] == 'Cheque'){
                                                        echo $payment_item['cheque_number'];
                                                    }elseif($payment_item['payment_method'] == 'Bank Deposit'){
                                                        echo $payment_item['account_number'];
                                                    }
                                                    ?>
                                                </td>
                                                <td>
                                                    <?php 
                                                    if($payment_item['payment_method'] == 'Cheque'){
                                                        echo date("d-m-Y", strtotime($payment_item['cheque_deposit_date']));
                                                    }
                                                    ?>
                                                </td>
                                                <td>
                                                    <?php 
                                                    if($payment_item['payment_method'] == 'Cheque'){
                                                        if($payment_item['payment_status'] == 1){
                                                            echo '<span class="label label-success">Deposited</span>';
                                                        }else if($payment_item['payment_status'] == 2){
                                                            echo '<span class="label label-warning">Pending</span>';
                                                        }else if($payment_item['payment_status'] == 3){
                                                            echo '<span class="label label-danger">Rejected</span>';
                                                        }else if($payment_item['payment_status'] == 4){
                                                            echo '<span class="label label-danger">Cancelled</span>';
                                                        }
                                                    }
                                                    ?>
                                                </td>
                                                <?php if($payment_item['payment_type'] == 'Normal'){ ?>
                                                    <td style="text-align: right;">
                                                        <?php
                                                        if($payment_item['payment_status'] == 1){
                                                            $total_paid_amount_gold += $payment_item['paid_amount'];
                                                        }
                                                        if($payment_item['payment_method'] != 'Gold'){
                                                            $total_paid_amount_cash += $payment_item['paid_amount'];
                                                            echo 'Rs. '.number_format($payment_item['paid_amount'],2,'.',','); 
                                                        }else{
                                                            echo number_format($payment_item['fixing_gold'],3,'.',',').' g';
                                                        }
                                                        ?>
                                                    </td>
                                                    <?php if($sale_details->sale_type == 'Gold Sale'){ ?>
                                                        <td></td>
                                                    <?php } ?> 
                                                <?php } ?> 
                                                <?php if($sale_details->sale_type == 'Gold Sale' && $payment_item['payment_type'] == 'Fixing'){ 
                                                    $total_paid_amount_gold += $payment_item['fixing_gold']; ?>
                                                    <td style="text-align: right;"><?php echo number_format($payment_item['fixing_gold'],3,'.',',').' g'; ?> </td>
                                                    <td style="text-align: right;">
                                                        <?php
                                                        if($payment_item['payment_status'] == 1){
                                                            $total_paid_amount_cash += $payment_item['paid_amount'];
                                                        }
                                                        if($payment_item['payment_method'] != 'Gold'){
                                                            echo 'Rs. '.number_format($payment_item['paid_amount'],2,'.',','); 
                                                        }else{
                                                            echo number_format($payment_item['fixing_gold'],3,'.',',').' g';
                                                        }
                                                        ?>
                                                    </td>
                                                <?php } ?>
                                            </tr>
                                            <?php } ?>
                                            <tr>
                                                <th colspan="6">
                                                    Total Amount
                                                </th>
                                                <?php if($sale_details->sale_type == 'Gold Sale'){ ?>
                                                    <th style="text-align: right;">
                                                        <?php echo number_format($total_paid_amount_gold,3,'.',',').' g'; ?>
                                                    </th>
                                                <?php } ?>
                                                <th style="text-align: right;">
                                                    <?php if($payment_item['payment_method'] != 'Gold'){ 
                                                        echo 'Rs. '.number_format($total_paid_amount_cash,2,'.',','); 
                                                    }else{
                                                        echo 'Rs. '.number_format($total_paid_amount_cash,2,'.',','); 
                                                    }
                                                    ?>
                                                </th>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                    
<!--                    <div id="sale_discount" 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">Add Discount to this Sale</h4>
                                </div>
                                <form id="apply_24k_sale_discount" class="form-horizontal" method="post">
                                    <div class="modal-body">
                                        <div class="alert alert-danger hidden" id="discount_alert_error"></div>
                                        <div class="scroller" style="height:190px" data-always-visible="1" data-rail-visible1="1">
                                            <input type="hidden" name="sale_id" value="<?php echo $sale_details->id ?>"/>
                                            <input type="hidden" name="customer_id" value="<?php echo $sale_details->customer_id ?>"/>
                                            <input type="hidden" value="<?php echo $sale_details->sale_type ?>" name="sale_type" />
                                            <div class="row">
                                                <div class="col-md-12">
                                                    <div class="form-body">
                                                        <div class="form-group">
                                                            <label class="control-label col-md-4">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="discount_date" value="<?php echo date('d-m-Y') ?>"/>
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="control-label col-md-4">Balance Amount</label>
                                                            <div class="col-md-3">
                                                                <div class="control-label pull-left"><?php echo 'Rs. '.number_format($sale_details->balance_amount,2,'.',','); ?></div>
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="control-label col-md-4">Discount Amount</label>
                                                            <div class="col-md-3">
                                                                <div class="input-group input-small">
                                                                    <span class="input-group-addon">
                                                                        Rs. 
                                                                    </span>
                                                                    <input class="form-control input-small" type="number" id="discount_amount" name="discount_amount"/>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="control-label col-md-4">Amount to be paid</label>
                                                            <div class="col-md-3">
                                                                <?php $balance_amount = 'Rs. '.number_format($sale_details->balance_amount,2,'.',','); ?>
                                                                <div class="control-label pull-left" id="div_dis_amount_to_be_paid" style="color: #2d823a"><?php echo $balance_amount; ?></div>
                                                            </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" id="div_discount_submit_button">Submit</button>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>-->
                    
                    <div class="modal fade" id="delete_sale" 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">Delete This Sale!</h4>
                                </div>
                                <div class="modal-body">
                                    Are you sure to delete this sale?
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn red" data-dismiss="modal" onclick="window.location.href='<?php echo base_url().'delete_24k_sale?id=' . $sale_details->id . '\&status=6'; ?>'">Delete</button>
                                    <button type="button" class="btn default" data-dismiss="modal">Cancel</button>
                                </div>
                            </div>
                            <!-- /.modal-content -->
                        </div>
                        <!-- /.modal-dialog -->
                    </div>
                    <!-- /.modal -->
                    
                    <!--BEGIN TABS-->
                    <div class="tabbable tabbable-custom tabbable-full-width">
                        <ul class="nav nav-tabs">
                            <li class="active">
                                <a href="#tab_1_1" data-toggle="tab"> Sales Invoice </a>
                            </li>
                            <?php if($sale_details->total_amount > 0 && $sale_details->sale_status != 6) {?>
                                <?php if($sale_details->sale_status != 1 && $sale_details->sale_status != 5) {?>
                                <li>
                                    <a href="#tab_1_2" data-toggle="tab"> Receipt </a>
                                </li>
                                <?php } ?>
                            <?php } ?>
                            <?php if($this->session->userdata('user_type_id') == 1 && $sale_details->sale_status == 4){ ?>
                                <div class="pull-right">
                                    <a class="btn default btn-sm green"  data-toggle="modal" href="<?php echo base_url().'change_this_approval_status?id='.$approval_details->id.'&type=24K Sale&status=Approved'; ?>"> Approve</a>
                                    <a class="btn default btn-sm red"  data-toggle="modal" href="<?php echo base_url().'change_this_approval_status?id='.$approval_details->id.'&type=24K Sale&status=Rejected'; ?>"> Reject</a>
                                    <a class="btn default btn-sm red"  data-toggle="modal" href="#delete_sale"> Delete Sale</a>
                                    <a class="btn default btn-sm purple-stripe" href="<?php echo base_url().'print_sale?sale_id='.$sale_details->id; ?>"> Print Sale</a>
                                </div>
                            <?php } ?>
                            <?php if($sale_details->sale_status != 4 && $sale_details->sale_status != 6){ ?>
                                <div class="pull-right">
                                    <a class="btn default btn-sm red"  data-toggle="modal" href="#delete_sale"> Delete Sale</a>
                                    <?php if($sale_details->sale_category == 'Normal'){ ?>
                                        <a class="btn default btn-sm purple-stripe" href="<?php echo base_url().'print_sale?sale_id='.$sale_details->id; ?>"> Print Sale</a>
                                    <?php } ?>
                                </div>
                            <?php }elseif($sale_details->sale_status == 5 && $sale_details->sale_category == 'Normal'){ ?>
                                <div class="pull-right">
                                    <a class="btn default btn-sm purple-stripe" href="<?php echo base_url().'print_sale?sale_id='.$sale_details->id; ?>"> Print Sale</a>
                                </div>
                            <?php } ?>
                        </ul>

                        <div class="tab-content">
                            <div class="tab-pane active" id="tab_1_1">
                                <div class="row">
                                    <div class="col-md-12">
                                        <?php if($payment_items){ ?>
                                            <div class="pull-right">
                                                <a class="btn default green-stripe"  data-toggle="modal" href="#view_payment_history"> View Payment History</a>
                                            </div>
                                        <?php } ?>
                                        <h4>Sale 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">
                                                    <tr>
                                                        <td>
                                                            <strong>Invoice Number</strong>
                                                        </td>
                                                        <td>
                                                            <?php echo $sale_details->invoice_num; ?>
                                                        </td>
                                                        <td>
                                                            <strong>Date</strong>
                                                        </td>
                                                        <td>
                                                            <?php echo date("d-m-Y", strtotime($sale_details->date)); ?>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            <strong>Customer Name</strong>
                                                        </td>
                                                        <td>
                                                            <a href="<?php echo base_url().'view_customer?customer_id='.$sale_details->customer_id; ?>"><?php echo $sale_details->customer_name; ?></a>
                                                        </td>
                                                        <td>
                                                            <strong>Contact Number</strong>
                                                        </td>
                                                        <td>
                                                            <?php echo $sale_details->contact_number; ?>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            <strong>Sale Type</strong>
                                                        </td>
                                                        <td>
                                                            <?php echo $sale_details->sale_type; ?>
                                                        </td>
                                                        <td>
                                                            <strong>Customer Status</strong>
                                                        </td>
                                                        <td>
                                                            <?php
                                                            if($sale_details->customer_status == 1){
                                                                echo '<span class="label label-success">Active</span>';
                                                            }else if($sale_details->customer_status == 2){
                                                                echo '<span class="label label-warning">Inactive</span>';
                                                            }else if($sale_details->customer_status == 3){
                                                                echo '<span class="label label-danger">Deleted</span>';
                                                            }else if($sale_details->customer_status == 4){
                                                                echo '<span class="label label-info">Hold-On</span>';
                                                            }
                                                            ?>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            <strong>Sale Status</strong>
                                                        </td>
                                                        <td>
                                                            <?php
                                                            if($sale_details->sale_status == 1){
                                                                echo '<span class="label label-success">Payment Completed</span>';
                                                            }else if($sale_details->sale_status == 2){
                                                                echo '<span class="label label-warning">Payment Incomplete</span>';
                                                            }else if($sale_details->sale_status == 3){
                                                                echo '<span class="label label-danger">Payment Pending</span>';
                                                            }else if($sale_details->sale_status == 4){
                                                                echo '<span class="label label-info">Pending Approval</span>';
                                                            }else if($sale_details->sale_status == 5){
                                                                echo '<span class="label label-danger">Rejected</span>';
                                                            }else if($sale_details->sale_status == 6){
                                                                echo '<span class="label label-danger">Deleted</span>';
                                                            }
                                                            ?>
                                                        </td>
                                                        <td>
                                                            <strong>Total Amount</strong>
                                                        </td>
                                                        <td>
                                                            <?php echo 'Rs. '.number_format($sale_details->total_amount,2,'.',','); ?>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td><strong>24K Rate</strong></td>
                                                        <td colspan="3">
                                                            <?php echo 'Rs. '.number_format($sale_details->k_rate,2,'.',','); ?>
                                                        </td>
                                                    </tr>
                                                    <?php if($sale_details->sale_category == 'Old Debts'){ ?>
                                                    <tr>
                                                        <td><strong>Previous Debt</strong></td>
                                                        <td>
                                                            <strong>Description</strong>
                                                        </td>
                                                        <td colspan="2">
                                                            <?php echo $sale_details->description; ?>
                                                        </td>
                                                    </tr>
                                                    <?php } ?>
                                                </table>
                                            </div>
                                            <!--end col-md-8-->
                                        </div>
                                        <!--end row-->
                                        
                                        <h4>Account Details</h4>
                                        <hr>
                                      
                                        <div class="row">
                                            <div class="col-md-12">
                                                <table class="table table-hover table-bordered table-striped" style="font-size: initial;">
                                                    <tr>
                                                        <td>
                                                            <strong>Total Amount</strong>
                                                        </td>
                                                        <td>
                                                            <strong><?php echo 'Rs. '.number_format($sale_details->total_amount,2,'.',','); ?></strong>
                                                        </td>
                                                        <?php if($sale_details->discount != ''){ ?>
                                                        <td>
                                                            <strong>Discounted Amount</strong>
                                                        </td>
                                                        <td>
                                                            <strong><?php echo 'Rs. '.number_format($sale_details->discount,2,'.',','); ?></strong>
                                                        </td>
                                                        <?php } ?>
                                                        <td>
                                                            <strong>Total Paid Amount</strong>
                                                        </td>
                                                        <td>
                                                            <strong><?php echo 'Rs. '.number_format($sale_details->total_amount - ($sale_details->balance_amount + $sale_details->discount),2,'.',','); ?></strong>
                                                        </td>
                                                        <td>
                                                            <strong>Total Balance</strong>
                                                        </td>
                                                        <?php 
                                                            $balance_amount = $sale_details->balance_amount;
                                                            if($balance_amount > 0){
                                                                $col_colour = 'background-color: #ff000085;';
                                                            }else{
                                                                $col_colour = 'background-color: #03ff007d;';
                                                            }
                                                        ?>
                                                        <td style="<?php echo $col_colour; ?>">
                                                            <strong><?php echo 'Rs. '.number_format($balance_amount,2,'.',','); ?></strong>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </div>
                                        </div>
                                        
                                        <?php if($sale_items){ ?>
                                        <h4>Sale Items</h4>
                                        <hr>
                                        <table class="table table-striped table-bordered table-hover" id="">
                                            <thead>
                                                <tr>
                                                    <th style=""><strong>Item Name</strong></th>
                                                    <th style=""><strong>Description</strong></th>
                                                    <th style=""><strong>Sales in Grams (g) - 24K</strong></th>
                                                    <th style=""><strong>Amount</strong></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                $total_amount = 0;
                                                $total_grams = 0;

                                                foreach($sale_items as $sale_item) { ?>                                                        
                                                <tr>
                                                    <td><?php echo $sale_item['item_name']; ?></td>
                                                    <td><?php echo $sale_item['description']; ?></td>
                                                    <td><?php $total_grams += $sale_item['sales_grams']; echo number_format($sale_item['sales_grams'],3,'.',','). ' g'; ?></td>
                                                    <td><?php $total_amount += $sale_item['amount']; echo 'Rs. '.number_format($sale_item['amount'],2,'.',','); ?></td>
                                                </tr> 
                                                <?php }?> 
                                                <tr>
                                                    <th colspan="2">Total</th>
                                                    <th><?php echo number_format($total_grams,3,'.',','). ' g'; ?></th>
                                                    <th><?php echo 'Rs. '.number_format($total_amount,2,'.',','); ?></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">
                                                <div class="alert alert-info hidden" id="alert_info"></div>
                                                <div class="alert alert-danger hidden" id="alert_error"></div>
							
                                                <!-- BEGIN FORM-->
                                                <form id="make_24k_normal_payment" class="form-horizontal" method="POST" enctype="multipart/form-data">
                                                    <input type="hidden" name="sale_id" value="<?php echo $sale_details->id ?>"/>
                                                    <input type="hidden" name="customer_id" value="<?php echo $sale_details->customer_id ?>"/>
                                                    <input type="hidden" name="sale_type" value="<?php echo $sale_details->sale_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-large 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">Sale Type</label>
                                                            <div class="col-md-3">
                                                                <div class="control-label pull-left"><?php echo $sale_details->sale_type; ?></div>
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="control-label col-md-3">24K Rate</label>
                                                            <div class="col-md-3">
                                                                <div class="control-label pull-left"><?php echo 'Rs. '.number_format($sale_details->k_rate,2,'.',','); ?></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 input-large" name="payment_method" id="payment_method">
                                                                        <option value="Cash">Cash</option>
                                                                        <?php if($sale_details->over_paid_cash > 0){ ?>
                                                                            <option value="Over Paid Cash">Over Paid Cash</option>
                                                                        <?php } ?>
                                                                        <option value="Cheque">Cheque</option>
                                                                        <option value="Bank Deposit">Bank Deposit</option>
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div id="div_over_paid_gold_details" class="hidden">
                                                            <div class="form-group">
                                                                <label class="control-label col-md-3">Over Paid Gold</label>
                                                                <div class="col-md-3">
                                                                    <div class="control-label pull-left"><?php echo number_format($sale_details->over_paid_gold,3,'.',',').' g'; ?></div>
                                                                    <input type="hidden" id="over_paid_gold" value="<?php echo $sale_details->over_paid_gold; ?>">
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div id="div_over_paid_cash_details" class="hidden">
                                                            <div class="form-group">
                                                                <label class="control-label col-md-3">Over Paid Cash</label>
                                                                <div class="col-md-3">
                                                                    <div class="control-label pull-left"><?php echo 'Rs. '.number_format($sale_details->over_paid_cash,2,'.',','); ?></div>
                                                                    <input type="hidden" id="over_paid_gold" value="<?php echo $sale_details->over_paid_cash; ?>">
                                                                </div>
                                                            </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-large 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 input-large" 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-large 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-large select2me" name="deposit_bank_account" id="deposit_bank_account">
                                                                    <?php
                                                                        $accounts = $this->admin_db->get_dxb_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($sale_details->sale_category == 'Normal'){ ?>
                                                        
                                                        <h4>Sale Items</h4>
                                                        <hr>
                                                        <table class="table table-striped table-bordered table-hover" id="">
                                                            <thead>
                                                                <tr>
                                                                    <th style=""><strong>Item Name</strong></th>
                                                                    <th style=""><strong>Description</strong></th>
                                                                    <th style=""><strong>Sales in Grams (g) - 24K</strong></th>
                                                                    <th style=""><strong>Amount</strong></th>
                                                                </tr>
                                                            </thead>
                                                            <tbody>
                                                                <?php 
                                                                $total_amount = 0;

                                                                foreach($sale_items as $sale_item) { ?>                                                        
                                                                <tr>
                                                                    <td><?php echo $sale_item['item_name']; ?></td>
                                                                    <td><?php echo $sale_item['description']; ?></td>
                                                                    <td><?php echo number_format($sale_item['sales_grams'],3,'.',','). ' g'; ?></td>
                                                                    <td><?php $total_amount += $sale_item['amount']; echo 'Rs. '.number_format($sale_item['amount'],2,'.',','); ?></td>
                                                                </tr> 
                                                                <?php }?> 
                                                                <tr>
                                                                    <th colspan="2">Total</th>
                                                                    <th><?php echo 'Rs. '.number_format($total_amount,2,'.',','); ?></th>
                                                                </tr> 
                                                                <?php if($sale_details->discount != ''){ ?>
                                                                <tr>
                                                                    <th colspan="2">Discounted Amount</th>
                                                                    <th><?php echo 'Rs. '.number_format($sale_details->discount,2,'.',','); ?></th>
                                                                </tr>
                                                                <?php }?>
                                                                <?php 
                                                                if($sale_details->status == 2){ 
                                                                    $paid_amount = $total_amount - ($sale_details->balance_amount + $sale_details->discount);
                                                                    $total_amount = $sale_details->balance_amount;
                                                                ?>
                                                                    <tr>
                                                                        <th colspan="5">Paid Amount</th>
                                                                        <th><?php echo 'Rs. '.number_format($paid_amount,2,'.',','); ?></th>
                                                                    </tr> 
                                                                    <tr>
                                                                        <th colspan="5">Balance Amount</th>
                                                                        <th><?php echo 'Rs. '.number_format($total_amount,2,'.',','); ?></th>
                                                                    </tr> 
                                                                <?php } else{
                                                                    $paid_amount = $total_amount - ($sale_details->balance_amount + $sale_details->discount);
                                                                    $total_amount = $sale_details->balance_amount;
                                                                } ?>
                                                            </tbody>
                                                        </table> 
                                                        
                                                        <?php }else{
                                                            $total_amount = $sale_details->balance_amount;
                                                        } ?>
                                                        
                                                        <div class="invoice">
                                                            <div class="row">
                                                                <div class="col-xs-4"> </div>
                                                                <div class="col-xs-8 invoice-block" align="right">
                                                                    <ul class="list-unstyled amounts" style="font-size: 20px">
                                                                        <li>
                                                                            <?php $total_amount_display = 'Rs. '.number_format($total_amount,2,'.',','); ?>
                                                                            <input type="hidden" value="<?php echo $sale_details->sale_type ?>" id="sale_type" />
                                                                            
                                                                            <strong>Amount to be Paid : </strong><div><?php echo $total_amount_display; ?></div>
                                                                            <input type="hidden" name="payment_total" value="<?php echo $total_amount ?>" id="payment_total" />
                                                                        </li>
                                                                        <li>
                                                                            <strong>Payment Amount : </strong>
                                                                            <div class="input-group input-small">
                                                                                <?php if($sale_details->sale_type == 'Credit Sale'){ ?>
                                                                                    <span class="input-group-addon">
                                                                                        Rs.
                                                                                    </span>
                                                                                <?php } ?>
                                                                                <input type="number" name="payment_amount" class="form-control input-small" value="" id="24k_sale_payment_amount" />
                                                                                <?php if($sale_details->sale_type == 'Gold Sale'){ ?>
                                                                                    <span class="input-group-addon">
                                                                                        g
                                                                                    </span>
                                                                                <?php } ?>
                                                                            </div>
                                                                        </li>
                                                                        <li>
                                                                            <strong>Balance Amount : </strong><div id="div_balance_total" style="color: #ff0000"><?php echo $total_amount_display; ?></div>
                                                                            <input type="hidden" name="balance_total" value="<?php echo $sale_details->total_amount ?>" id="balance_total" />
                                                                        </li>
                                                                    </ul>
                                                                    <br/>
                                                                    
<!--                                                                    <button type="button" class="btn btn-lg hidden-print margin-bottom-5" data-toggle="modal" href="#sale_discount">
                                                                        Apply Discount
                                                                    </button>-->
                                                                    <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 -->
