
            <div class="row profile">
                <div class="col-md-12">
                    
                    <h4>Payment Details</h4>
                    <hr>
                    <div class="row">
                        <div class="col-md-offset-1 col-md-10">
                            <table class="table table-hover table-bordered table-striped">
                                <tr>
                                    <td>
                                        <strong>Payment Number</strong>
                                    </td>
                                    <td>
                                        <?php echo $payment_details->id; ?>
                                    </td>
                                    <td>
                                        <strong>Date</strong>
                                    </td>
                                    <td>
                                        <?php echo date("d-m-Y", strtotime($payment_details->date)); ?>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <strong>Customer Name</strong>
                                    </td>
                                    <td>
                                        <a href="<?php echo base_url().'view_customer?customer_id='.$payment_details->customer_id; ?>"><?php echo $payment_details->customer_name; ?></a>
                                    </td>
                                    <td>
                                        <strong>Contact Number</strong>
                                    </td>
                                    <td>
                                        <?php echo $payment_details->contact_number; ?>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <strong>Payment Method</strong>
                                    </td>
                                    <td>
                                        <?php echo $payment_details->payment_method; ?>
                                    </td>
                                    <td>
                                        <strong>Amount</strong>
                                    </td>
                                    <td>
                                        <?php 
                                        if($payment_details->payment_method != 'Gold'){
                                            echo 'Rs. '.number_format($payment_details->amount,2,'.',',');
                                        }else {
                                            echo $payment_details->amount.' g';
                                        }
                                        ?>
                                    </td>
                                </tr>
                                <?php if($payment_details->payment_method == 'Cheque'){ ?>
                                <tr>
                                    <td>
                                        <strong>Cheque Issued Bank Name</strong>
                                    </td>
                                    <td>
                                        <?php 
                                        $cheque_account_details = $this->admin_db->get_bank_by_id($payment_details->bank_id);
                                        echo $cheque_account_details->bank_name; 
                                        ?>
                                    </td>
                                    <td>
                                        <strong>Cheque Number</strong>
                                    </td>
                                    <td>
                                        <?php echo $payment_details->cheque_number; ?>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <strong>Cheque Deposit Date</strong>
                                    </td>
                                    <td>
                                        <?php echo $payment_details->cheque_deposit_date; ?>
                                    </td>
                                    <td>
                                        <strong>Cheque Status</strong>
                                    </td>
                                    <td>
                                        <?php
                                            if($payment_details->status == 1){
                                                echo '<span class="label label-success">Deposited</span>';
                                            }elseif($payment_details->status == 2){
                                                echo '<span class="label label-warning">Pending</span>';
                                            }elseif($payment_details->status == 3){
                                                echo '<span class="label label-danger">Returned</span>';
                                            }elseif($payment_details->status == 4){
                                                echo '<span class="label label-danger">Cancelled</span>';
                                            }
                                        ?>
                                    </td>
                                </tr>
                                <?php } ?>

                                <?php if($payment_details->payment_method == 'Bank Deposit'){ ?>
                                <tr>
                                    <td>
                                        <strong>Deposited To Bank Name</strong>
                                    </td>
                                    <td>
                                        <?php 
                                        $bank_account_details = $this->admin_db->get_account_details_by_id($payment_details->account_id);
                                        echo $bank_account_details->bank_name; 
                                        ?>
                                    </td>
                                    <td>
                                        <strong>Deposited To Account Number</strong>
                                    </td>
                                    <td>
                                        <?php echo $bank_account_details->account_number; ?>
                                    </td>
                                </tr>
                                <?php } ?>
                            </table>
                        </div>
                    </div>
                    <?php if($payment_items){ ?>
                        <h4>Payment Items</h4>
                        <hr>
                        <div class="row">
                            <div class="col-md-offset-1 col-md-10">
                                <table class="table table-hover table-bordered table-striped">
                                    <thead>
                                        <td>
                                            <strong>#</strong>
                                        </td>
                                        <td>
                                            <strong>Sale Number</strong>
                                        </td>
                                        <td>
                                            <strong>Amount</strong>
                                        </td>
                                    </thead>
                                    <tbody>
                                    <?php  
                                    $total_payment_amount = 0;
                                    foreach($payment_items as $payment_item) { ?>
                                        <tr>
                                            <td>
                                                <?php echo $payment_item['id']; ?>
                                            </td>
                                            <td>
                                                <a href="<?php echo base_url().'view_sale?sale_id='.$payment_item['sale_id']; ?>"><?php echo $payment_item['sale_id']; ?></a>
                                            </td>
                                            <td>
                                                <?php 
                                                $total_payment_amount += $payment_item['paid_amount'];
                                                if($payment_details->payment_method != 'Gold'){
                                                    echo 'Rs. '.number_format($payment_item['paid_amount'],2,'.',',');
                                                }else {
                                                    echo number_format($payment_item['paid_amount'],3,'.',',').' g';
                                                }
                                                ?>
                                            </td>
                                        </tr>
                                    <?php } ?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        
                        <?php
                        $over_payment = 0;
                        $over_payment = $payment_details->amount - $total_payment_amount;
                        
                        if($over_payment > 0){ ?>
                            
                        <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 Payment Amount</strong>
                                        </td>
                                        <td>
                                            <strong>
                                            <?php
                                            if($payment_details->payment_method != 'Gold'){ 
                                                echo 'Rs. '.number_format($payment_details->amount,2,'.',','); 
                                            } else {
                                                echo number_format($payment_details->amount,3,'.',',').' g';
                                            } ?>
                                            </strong>
                                        </td>
                                        <td>
                                            <strong>Total Bill Paid Amount</strong>
                                        </td>
                                        <td>
                                            <strong>
                                            <?php
                                            if($payment_details->payment_method != 'Gold'){ 
                                                echo 'Rs. '.number_format($total_payment_amount,2,'.',','); 
                                            } else {
                                                echo number_format($total_payment_amount,3,'.',',').' g';
                                            } ?>
                                            </strong>
                                        </td>
                                        <td>
                                            <strong>Over Paid Amount</strong>
                                        </td>
                                        <td>
                                            <strong>
                                            <?php
                                            if($payment_details->payment_method != 'Gold'){ 
                                                echo 'Rs. '.number_format($over_payment,2,'.',','); 
                                            } else {
                                                echo number_format($over_payment,3,'.',',').' g';
                                            } ?>
                                            </strong>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                    <?php }} ?>
                </div> 
            </div>
            <!-- END DASHBOARD STATS -->
        </div>
    </div>
    <!-- END CONTENT -->
</div>
<!-- END CONTAINER -->
