
            <div class="row profile">
                <div class="col-md-12">
                    
                    <div id="response_msg"></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 Purchase!</h4>
                                </div>
                                <div class="modal-body">
                                    Are you sure to delete this purchase?
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn red" data-dismiss="modal" onclick="window.location.href='<?php echo base_url().'delete_sale?id=' . $purchase_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">
                        <div class="pull-right">
                            <?php if($purchase_details->status != 3 && $purchase_details->status != 4){ ?>
                                <a class="btn default btn-sm red"  data-toggle="modal" href="#delete_sale"> Delete Sale</a>
                            <?php } ?>
                            <?php if(($this->session->userdata('user_type_id') == 1 || $this->session->userdata('user_type_id') == 3) && $purchase_details->status == 2){ ?>
                                <a class="btn default btn-sm green"  data-toggle="modal" href="<?php echo base_url().'change_this_approval_status?id='.$approval_details->id.'&type=Dxb Purchase&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=Dxb Purchase&status=Rejected'; ?>"> Reject</a>
                            <?php } ?>
                        </div>
                        <ul class="nav nav-tabs">
                            <li class="active">
                                <a href="#tab_1_1" data-toggle="tab"> Purchases Invoice </a>
                            </li>
                            <?php if($purchase_details->payment_status != 1) {?>
                                <li>
                                    <a href="#tab_1_2" data-toggle="tab"> Receipt </a>
                                </li>
                            <?php } ?>
                        </ul>

                        <div class="tab-content">
                            <div class="tab-pane active" id="tab_1_1">
                                <div class="row">
                                    <div class="col-md-12">
                                        <h4>Purchase 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 $purchase_details->invoice_num; ?>
                                                        </td>
                                                        <td>
                                                            <strong>Date</strong>
                                                        </td>
                                                        <td>
                                                            <?php echo date("d-m-Y", strtotime($purchase_details->date)); ?>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            <strong>Carrier Name</strong>
                                                        </td>
                                                        <td>
                                                            <a href="<?php echo base_url().'view_carrier?carrier_id='.$purchase_details->carrier_id; ?>"><?php echo $purchase_details->carrier_name; ?></a>
                                                        </td>
                                                        <td>
                                                            <strong>Contact Number</strong>
                                                        </td>
                                                        <td>
                                                            <?php echo $purchase_details->contact_number; ?>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            <strong>Purchase Status</strong>
                                                        </td>
                                                        <td>
                                                            <?php
                                                            if($purchase_details->status == 1){
                                                                echo '<span class="label label-success">Approved</span>';
                                                            }else if($purchase_details->status == 2){
                                                                echo '<span class="label label-info">Pending Approval</span>';
                                                            }else if($purchase_details->status == 3){
                                                                echo '<span class="label label-danger">Rejected</span>';
                                                            }else if($purchase_details->status == 4){
                                                                echo '<span class="label label-danger">Deleted</span>';
                                                            }
                                                            ?>
                                                        </td>
                                                        <td>
                                                            <strong>Payment Status</strong>
                                                        </td>
                                                        <td>
                                                            <?php
                                                            if($purchase_details->payment_status == 1){
                                                                echo '<span class="label label-success">Payment Completed</span>';
                                                            }else if($purchase_details->payment_status == 2){
                                                                echo '<span class="label label-warning">Payment Incompleted</span>';
                                                            }else if($purchase_details->payment_status == 3){
                                                                echo '<span class="label label-danger">Payment Pending</span>';
                                                            }
                                                            ?>
                                                        </td>
                                                    </tr>
                                                    <td rowspan="7">
                                                        <strong>Total Amounts</strong>
                                                    </td>
                                                    <tr>
                                                        <th><strong>Quantity - 22K</strong></th>
                                                        <th><strong>Carrier Charges Rate</strong></th>
                                                        <th><strong>Amount</strong></th>
                                                    </tr>
                                                    <tr>
                                                        <td><?php echo ($purchase_details->quantity_1)?(number_format($purchase_details->quantity_1,3,'.',',').' g'):('-'); ?></td>
                                                        <td><?php echo ($purchase_details->rate_1)?('Rs. '.number_format($purchase_details->rate_1,2,'.',',')):('-'); ?></td>
                                                        <td><?php echo ($purchase_details->amount_1)?('Rs. '.number_format($purchase_details->amount_1,2,'.',',')):('-'); ?></td>
                                                    </tr>
                                                    <tr>
                                                        <td><?php echo ($purchase_details->quantity_2)?(number_format($purchase_details->quantity_2,3,'.',',').' g'):('-'); ?></td>
                                                        <td><?php echo ($purchase_details->rate_2)?('Rs. '.number_format($purchase_details->rate_2,2,'.',',')):('-'); ?></td>
                                                        <td><?php echo ($purchase_details->amount_2)?('Rs. '.number_format($purchase_details->amount_2,2,'.',',')):('-'); ?></td>
                                                    </tr>
                                                    <tr>
                                                        <td><?php echo ($purchase_details->quantity_3)?(number_format($purchase_details->quantity_3,3,'.',',').' g'):('-'); ?></td>
                                                        <td><?php echo ($purchase_details->rate_3)?('Rs. '.number_format($purchase_details->rate_3,2,'.',',')):('-'); ?></td>
                                                        <td><?php echo ($purchase_details->amount_3)?('Rs. '.number_format($purchase_details->amount_3,2,'.',',')):('-'); ?></td>
                                                    </tr>
                                                    <tr>
                                                        <td><?php echo ($purchase_details->quantity_4)?(number_format($purchase_details->quantity_4,3,'.',',').' g'):('-'); ?></td>
                                                        <td><?php echo ($purchase_details->rate_4)?('Rs. '.number_format($purchase_details->rate_4,2,'.',',')):('-'); ?></td>
                                                        <td><?php echo ($purchase_details->amount_4)?('Rs. '.number_format($purchase_details->amount_4,2,'.',',')):('-'); ?></td>
                                                    </tr>
                                                    <tr>
                                                        <td><?php echo ($purchase_details->quantity_5)?(number_format($purchase_details->quantity_5,3,'.',',').' g'):('-'); ?></td>
                                                        <td><?php echo ($purchase_details->rate_5)?('Rs. '.number_format($purchase_details->rate_5,2,'.',',')):('-'); ?></td>
                                                        <td><?php echo ($purchase_details->amount_5)?('Rs. '.number_format($purchase_details->amount_5,2,'.',',')):('-'); ?></td>
                                                    </tr>
                                                </table>
                                            </div>
                                            <!--end col-md-8-->
                                        </div>
                                        <!--end row-->
                                        <h4>Carrier Charges Accounts</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($purchase_details->total_amount,2,'.',','); ?></strong>
                                                        </td>
                                                        <td>
                                                            <strong>Total Paid Amount</strong>
                                                        </td>
                                                        <td>
                                                            <strong><?php echo 'Rs. '.number_format($purchase_details->paid_amount,2,'.',','); ?></strong>
                                                        </td>
                                                        <td>
                                                            <strong>Total Balance</strong>
                                                        </td>
                                                        <?php 
                                                            $balance_amount = $purchase_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>
                                        
                                        <h4>Purchased Suppliers' Details</h4>
                                        <hr>
                                        <?php if($purchase_suppliers){ ?>
                                        <div class="row">
                                            <div class="col-md-12">
                                                <table class="table table-striped table-bordered table-hover" id="">
                                                    <thead>
                                                        <tr>
                                                            <th style=""><strong>Supplier_name</strong></th>
                                                            <th style=""><strong>Invoice Number</strong></th>
                                                            <th style=""><strong>Invoice Weight</strong></th>
                                                            <th style=""><strong>Actual Weight</strong></th>
                                                            <th style=""><strong>Received Weight</strong></th>
                                                            <th style=""><strong>Pending Weight</strong></th>
                                                            <th style=""><strong>Status</strong></th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                        <?php 
                                                        $tot_invoice_weight = 0;
                                                        $tot_actual_weight = 0;
                                                        $tot_received_weight = 0;
                                                        $tot_pending_weight = 0;
                                                        
                                                        foreach ($purchase_suppliers as $purchase_supplier) { ?>                                                        
                                                        <tr>
                                                            <td><?php echo $purchase_supplier['supplier_name']; ?></td>
                                                            <td><?php echo $purchase_supplier['invoice_num']; ?></td>
                                                            <td><?php $tot_invoice_weight += $purchase_supplier['invoice_weight']; echo number_format($purchase_supplier['invoice_weight'],3,'.',','). ' g'; ?></td>
                                                            <td><?php $tot_actual_weight += $purchase_supplier['actual_weight']; echo number_format($purchase_supplier['actual_weight'],3,'.',','). ' g'; ?></td>
                                                            <td><?php $tot_received_weight += $purchase_supplier['received_weight']; echo number_format($purchase_supplier['received_weight'],3,'.',','). ' g'; ?></td>
                                                            <td><?php $tot_pending_weight += $purchase_supplier['pending_weight']; echo number_format($purchase_supplier['pending_weight'],3,'.',','). ' g'; ?></td>
                                                            <td>
                                                                <?php
                                                                if($purchase_supplier['status'] == 1){
                                                                    echo '<span class="label label-success">Completed</span>';
                                                                }else if($purchase_supplier['status'] == 2){
                                                                    echo '<span class="label label-warning">Incompleted</span>';
                                                                }
                                                                ?>
                                                            </td>
                                                        </tr>
                                                        <?php }?> 
                                                    <tr>
                                                        <th colspan="2">Total</th>
                                                        <th><?php echo number_format($tot_invoice_weight,3,'.',','). ' g'; ?></th>
                                                        <th><?php echo number_format($tot_actual_weight,3,'.',','). ' g'; ?></th>
                                                        <th><?php echo number_format($tot_received_weight,3,'.',','). ' g'; ?></th>
                                                        <th><?php echo number_format($tot_pending_weight,3,'.',','). ' g'; ?></th>
                                                        <th></th>
                                                    </tr>  
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>
                                        <?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 Carrier Charges 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_carrier_charges_payment" class="form-horizontal" method="POST" enctype="multipart/form-data">
                                                    <input type="hidden" name="purchase_id" value="<?php echo $purchase_details->id ?>"/>
                                                    <input type="hidden" name="carrier_id" value="<?php echo $purchase_details->carrier_id ?>"/>
                                                    <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">Carrier Charges</label>
                                                            <div class="col-md-3">
                                                                <div class="control-label pull-left"><?php echo 'Rs. '.number_format($purchase_details->total_amount,2,'.',','); ?></div>
                                                                <input type="hidden" id="carrier_charges" value="<?php echo $purchase_details->total_amount ; ?>">
                                                            </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_expense">
                                                                    <option value="Cash">Cash</option>
                                                                    <option value="Cheque">Cheque</option>
                                                                    <option value="Bank Transfer">Bank Transfer</option>
                                                                    <option value="Bank Deposit">Bank Deposit</option>
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div id="div_cheque_details_expense" class="hidden">
                                                            <div class="form-group">
                                                                <label class="control-label col-md-3">From Bank Account</label>
                                                                <div class="col-md-3">
                                                                    <select class="form-control input-large select2me" name="cheq_bank_account" id="cheq_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 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_bank_details_expense" class="hidden">
                                                            <div id="div_bank_tranfer_expense" class="hidden">
                                                                <div class="form-group">
                                                                    <label class="control-label col-md-3">From Account Number</label>
                                                                    <div class="col-md-3">
                                                                        <select class="form-control input-large select2me" name="transfer_bank_account" id="transfer_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>
                                                            <div class="form-group">
                                                                <label class="control-label col-md-3">To Bank Name</label>
                                                                <div class="col-md-3">
                                                                    <select class="form-control input-large select2me" name="bank_bank_name" id="bank_bank_name">
                                                                    <?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">To Bank Account Number</label>
                                                                <div class="col-md-3">
                                                                    <input class="form-control input-large" type="number" name="bank_account_number" id="bank_account_number"/>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        
                                                        <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>                                                                            
                                                                            <strong>Amount to be Paid : </strong><div><?php echo 'Rs. '.number_format($purchase_details->balance_amount,2,'.',','); ?></div>
                                                                            <input type="hidden" name="payment_total" value="<?php echo $purchase_details->balance_amount ?>" id="carrier_payment_total" />
                                                                        </li>
                                                                        <li>
                                                                            <strong>Payment Amount : </strong>
                                                                            <div class="input-group input-small">
                                                                                <span class="input-group-addon">
                                                                                    Rs.
                                                                                </span>
                                                                                <input type="number" name="payment_amount" class="form-control input-small" value="" id="carrier_payment_amount" />
                                                                            </div>
                                                                        </li>
                                                                        <li>
                                                                            <strong>Balance Amount : </strong><div id="div_carrier_balance_total" style="color: #ff0000"><?php echo 'Rs. '.number_format($purchase_details->balance_amount,2,'.',','); ?></div>
                                                                            <input type="hidden" name="balance_total" value="<?php echo $purchase_details->balance_amount ?>" id="carrier_balance_total" />
                                                                        </li>
                                                                    </ul>
                                                                    <br/>
                                                                    
                                                                    <button type="submit" class="btn btn-lg green hidden-print margin-bottom-5" id="div_purchase_submit_button">
                                                                    Submit Payment <i class="fa fa-check"></i>
                                                                    </button>

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