
            <div class="row profile">
                <div class="col-md-12">
                    
                    <div id="response_msg"></div>
                    
                    <div class="pull-right">
                        <a class="btn btn-sm default green-stripe" href="<?php echo base_url().'view_sale?sale_id='.$returned_sale_details->sale_id; ?>"> View Sale</a>
                        <a class="btn btn-sm default purple-stripe" href="<?php echo base_url().'print_returned_sale?return_sale_id='.$returned_sale_details->id; ?>"> Print Return Sale</a>
                        <?php if(($this->session->userdata('user_type_id') == 1 || $this->session->userdata('user_type_id') == 3) && $returned_sale_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=Return Dxb 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=Return Dxb Sale&status=Rejected'; ?>"> Reject</a>
                        <?php } ?>
                    </div>
                    
                    <h4>Returned 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>Sale Invoice Number</strong>
                                    </td>
                                    <td>
                                        <a href="<?php echo base_url().'view_sale?sale_id='.$returned_sale_details->sale_id; ?>"><?php echo $returned_sale_details->sale_invoice_num; ?></a>
                                    </td>
                                    <td>
                                        <strong>Customer Name</strong>
                                    </td>
                                    <td>
                                        <a href="<?php echo base_url().'view_customer?customer_id='.$returned_sale_details->customer_id; ?>"><?php echo $returned_sale_details->customer_name; ?></a>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <strong>Returned Invoice Number</strong>
                                    </td>
                                    <td>
                                        <?php echo $returned_sale_details->invoice_num; ?>
                                    </td>
                                    <td>
                                        <strong>Returned Sale Date</strong>
                                    </td>
                                    <td>
                                        <?php echo date("d-m-Y", strtotime($returned_sale_details->date)); ?>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <strong>Total Amount</strong>
                                    </td>
                                    <td>
                                        <?php 

                                        if($returned_sale_details->sale_type == 'Credit Sale'){
                                            echo 'Rs. '.number_format($returned_sale_details->amount,2,'.',',');
                                        }else if($returned_sale_details->sale_type == 'Gold Sale'){
                                            echo number_format($returned_sale_details->amount,3,'.',',').' g';
                                        }
                                        ?>
                                    </td>
                                    <td>
                                        <strong>Sale Type</strong>
                                    </td>
                                    <td>
                                        <?php echo $returned_sale_details->sale_type; ?>
                                    </td>
                                </tr>
                                <?php if($returned_sale_details->sale_type == 'Credit Sale'){ ?>
                                <tr>
                                    <td>
                                        <strong>24K Rate</strong>
                                    </td>
                                    <td>
                                        <?php echo 'Rs. '.number_format($returned_sale_details->k_rate,2,'.',','); ?>
                                    </td>
                                    <td></td>
                                    <td></td>
                                </tr>
                                <?php } ?>
                                <tr>
                                    <td>
                                        <strong>Return Note</strong>
                                    </td>
                                    <td colspan="3">
                                        <?php echo $returned_sale_details->description; ?>
                                    </td>
                                </tr>
                            </table>
                        </div>
                        <!--end col-md-8-->
                    </div>
                    <!--end row-->

                    <?php if($returned_sale_items){ ?>
                    <h4>Returned Sale Items</h4>
                    <hr>
                    <?php if($returned_sale_details->sale_type == 'Credit Sale'){ ?>
                        <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>Selling Percentage</strong></th>
                                    <th style=""><strong>Selling Rate</strong></th>
                                    <th style=""><strong>Sales in Grams (g) - 22K</strong></th>
                                    <th style=""><strong>Amount</strong></th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php 
                                $returned_sale_total_amount = 0;

                                foreach($returned_sale_items as $returned_sale_item) { ?>                                                        
                                <tr>
                                    <td><?php echo $returned_sale_item['item_name']; ?></td>
                                    <td><?php echo $returned_sale_item['description']; ?></td>
                                    <td><?php echo $returned_sale_item['selling_percentage'].' %'; ?></td>
                                    <td><?php echo 'Rs. '.number_format($returned_sale_item['selling_rate'],2,'.',','); ?></td>
                                    <td><?php echo number_format($returned_sale_item['sales_grams'],3,'.',','). ' g'; ?></td>
                                    <td><?php $returned_sale_total_amount += $returned_sale_item['amount']; echo 'Rs. '.number_format($returned_sale_item['amount'],2,'.',','); ?></td>
                                </tr> 
                                <?php }?> 
                                <tr>
                                    <th colspan="5">Total</th>
                                    <th><?php echo 'Rs. '.number_format($returned_sale_total_amount,2,'.',','); ?></th>
                                </tr>  
                            </tbody>
                        </table>                                            
                    <?php }else if($returned_sale_details->sale_type == 'Gold Sale'){ ?>
                        <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>Selling Percentage</strong></th>
                                    <th style=""><strong>Sales in Grams (g) - 22K</strong></th>
                                    <th style=""><strong>Amount</strong></th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php 
                                $returned_sale_total_amount = 0;

                                foreach ($returned_sale_items as $returned_sale_item) { ?>                                                        
                                <tr>
                                    <td><?php echo $returned_sale_item['item_name']; ?></td>
                                    <td><?php echo $returned_sale_item['description']; ?></td>
                                    <td><?php echo $returned_sale_item['selling_percentage'].' %'; ?></td>
                                    <td><?php echo number_format($returned_sale_item['sales_grams'],3,'.',','). ' g'; ?></td>
                                    <td><?php $returned_sale_total_amount += $returned_sale_item['amount']; echo number_format($returned_sale_item['amount'],3,'.',','). ' g'; ?></td>
                                </tr>
                                <?php }?> 
                                <tr>
                                    <th colspan="4">Total</th>
                                    <th><?php echo number_format($returned_sale_total_amount,3,'.',','). ' g'; ?></th>
                                </tr>
                            </tbody>
                        </table>
                    <?php } ?>
                    <?php } ?>
                </div> 
            </div>
            <!-- END DASHBOARD STATS -->
        </div>
    </div>
    <!-- END CONTENT -->
</div>
<!-- END CONTAINER -->
