<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <base href="<?php echo base_url(); ?>" />
        <title><?php echo $this->config->item('company') ?></title>
        <link rel="stylesheet" rev="stylesheet" href="<?php echo base_url(); ?>css/ospos.css" />
        <link rel="stylesheet" rev="stylesheet" href="<?php echo base_url(); ?>css/ospos_print.css"  media="print"/>
        <script>BASE_URL = '<?php echo site_url(); ?>';</script>

        <script src="<?php echo base_url(); ?>js/jquery-1.2.6.min.js" type="text/javascript" language="javascript" charset="UTF-8"></script> 
<!--        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>-->
        <script src="<?php echo base_url(); ?>js/printThis.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
        <script src="<?php echo base_url(); ?>js/jQuery.print.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
        <script src="<?php echo base_url(); ?>js/jquery.jqprint-0.3.js" type="text/javascript" language="javascript" charset="UTF-8"></script>

<!--         <script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>-->
        <link type="text/css" href="<?php echo base_url(); ?>css/custom.css" rel="stylesheet" />

        <style type="text/css">
            html {
                overflow: auto;
            }
        </style>

    </head>
    <?php
    // $this->load->view("partial/header");

    $current_date_coupon=date("Y-m-d");
    if($current_date_coupon>'2022-05-05'){
    	$coupon_code="";
    }


    if (isset($error_message)) {
    	echo '<h1 style="text-align: center;">' . $error_message . '</h1>';
    	exit;
    }
    include_once(APPPATH.'views/sales/code128.class.php');
    $barcode = new phpCode128($receipt_no, 150, 'c:\windows\fonts\verdana.ttf', 18);
    $barcode->saveBarcode("images/barcode_images/" . $receipt_no . '.png');

    $barHtml= "<div style='float:left;width:100%;'><img style='padding-top: 0px;' src='".LOCAL_PATH."/images/barcode_images/" . $receipt_no . ".png' ></div>";
    $barHtml.= "<div style='float:left;font-size: 13px;background-color: #FFFFFF;line-height:12px;margin:-14px 0px 0 80px;'>".$receipt_no."</div>";

    ?>

    <div id="receipt_wrapper" style="display:none;margin-top:0px;">
    <!--<div id="receipt_wrapper" style="display:none;margin-top:0px;">-->
        <!--<div id="receipt_wrapper">-->
        <div id="receipt-"  style="width: 270px; height: auto; padding: 5px 2px; font-family: times new roman;font-size: 12px;margin-top:-55px;">	
            <div id="receipt_header" style="margin-top:50px; border-bottom:3px double #000000;">
                <div id="company_name" style="width:97%;"><?php echo COMPANYNAME; ?></div>
                <div id="company_address" style="width:97%;"><?php echo nl2br(LOCATION_ADDRESS); ?></div>
                <div id="company_phone" style="width:97%;"><?php echo $this->lang->line('company_phone') ?>&nbsp;<?php echo LOCATION_PHONE; ?></div>
                <div id="company_phone" style="width:97%;padding-top:5px;"><?php echo "Govt. of the People's Republic of Bangladesh, National Board of Revenue Tax Invoice"; ?></div>
                <div id="vat_reg_number" style="width:97%;padding-top:5px;font-weight:bold;"><?php echo "(MUSAK-6.3)";?></div>
                <div id="vat_reg_number" style="width:97%;"><?php echo "[Clauses(c)&(f) of Sub-rule(1) of Rule 40]";?></div>
                <div id="vat_reg_number" style="width:97%;padding-top:5px;font-weight:bold;"><?php echo "BIN&nbsp;" ?>:&nbsp;<?php echo VAT_REG_NO; ?></div>
                <div id="website" style="width:97%;"><?php echo "Web: " . COMPANYWEB; ?></div>
            </div>
            <table id="receipt_items" style="width:97%;">  
            
              <?php if(trim($coupon_code)!=""){ ?> 
                <tr>
                    <td  style='text-align:center;width:100%;font-size: 15px;padding:1px;border:2px double #000000;' colspan="2">GIFT CARD:&nbsp;<font style='font-weight:bold;'><?php echo trim($coupon_code)."</font> | <font style='font-weight:bold;'>".number_format(intval($coupon_value),0,'.',',')." BDT</font>"; ?> </td>
                </tr>
                <?php } ?> 
                <tr>
                    <td  style='text-align:left;width:97%;'>Invoice:<?php echo $receipt_no; ?></td>
                    <td style='text-align:right;width:97%;'>Date:<?php echo date('d/m/Y H:i',strtotime($sale_time)); ?> </td>
                </tr>
                <tr>
                    <td colspan="2" style='text-align:left;width:97%;'><?php echo $this->lang->line('sales_prepared_by') . ": " . $employee; ?></td>
                </tr>
                
               <?php
               if (isset($customer)) {
                            ?>
                            <tr>
                                <td colspan="2" style='text-align:left;width:97%;'><?php echo $this->lang->line('customers_customer_id') . ": " . $customer; ?></td>
                            </tr>
                            <tr>
                                <td colspan="2" style='text-align:left;width:97%;'><?php echo "Customer Card No" . ": " . $customer_card_no; ?></td>
                            </tr>
                            <?php
               }
                        ?>
                        <?php if ($mode == "global") { ?>
                            <tr>
                                <td colspan="2" style='text-align:left;width:97%;'><?php echo $this->lang->line('recieve_location') . ": " . $receive_location; ?></td>
                            </tr>
                        <?php } 
                        ?>

                
            </table>
          
            <?php
            //                        $colspan = 6;
            //                        $colspan2 = 3;
            //                        $colspan3 = 5;
            //                        $colspanTotal = 7;
            ?>
<table id="receipt_items" style="width:97%;">
                <thead>
                    <tr>
                        <th style="width:10%;text-align:left"><?php echo "Product"; ?></th>
                        <th style="width:17%;"><?php echo $this->lang->line('common_price'); ?></th>
                        <th style="width:16%;text-align:center;"><?php echo $this->lang->line('sales_quantity'); ?></th>
                        <th style="width:16%;text-align:center;"><?php echo $this->lang->line('sales_discount'); ?></th>
                        <th style="width:17%;text-align:right;"><?php echo $this->lang->line('sales_total'); ?></th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td colspan="5" style='border-top:3px double #000000;'></td>
                    </tr>

                    <?php
                    $totalQty = 0;
                    $subTotal = 0;
                    $totaldiscount = 0;

                    $no_exchage=0;


                    $included_vat_sub_total_amount=0;
                    $exclued_vat_sub_total_amount=0;

                    $included_vat_sub_total_qty=0;
                    $exclued_vat_sub_total_qty=0;
                    $exclued_vat_sub_total_vat_amount=0;

                    $subtotal_product_discount = 0;
                    $subtotal_real_product_discount = 0;

                    foreach (array_reverse($cart, true) as $line => $item) {
                    	//$vatStr = isset($item_tax[$item['item_id']]) ? '*' : '';
                    	if($no_exchage==0){
                    		if($item['quantity']<=0){
                    			$no_exchage=1;
                    		}elseif(intval($item['discount'])>0){
                    			$no_exchage=1;
                    		}
                    	}


                    	if($item['lot_no']>=211100){
                    		$subtotal_product_discount+=round((round($item['price_with_vat'])* $item['discount'] / 100))*$item['quantity'];

                    	}else{
                    		$vat_amount=((round($item['price'])*$item['vat_rate'])/100);
                    		$price_with_vat=round(round($item['price'])+((round($item['price'])*$item['vat_rate'])/100));
                    		$subtotal_product_discount+=round((round($price_with_vat)* $item['discount'] / 100))*$item['quantity'];
                    	}

                    	$vatStr = '';
                    	$totalQty = $totalQty + $item['quantity'];
                    	$subTotal = $subTotal + round(($item['quantity'] * $item['price']));
                    	$discount = round((($item['discount'] / 100) * $item['price'])) * $item['quantity'];
                    	$totaldiscount = $totaldiscount + $discount;


                    	///////////////////////////////////////////////////////////////////////////
                    	$show_price=0;
                    	$show_total_amount=0;

                    	if($item['lot_no']>=211100){
                    		$show_price=round(round($item['price'])+((round($item['price'])*$item['vat_rate'])/100));
                    		$show_total_amount=$show_price*$item['quantity'];
                    		$included_vat_sub_total_amount+=$show_total_amount;
                    		$included_vat_sub_total_qty+=$item['quantity'];

                    	}else{
                    		$show_price=round($item['price']);
                    		$show_total_amount=$show_price*$item['quantity'];
                    		$exclued_vat_sub_total_amount+=$show_total_amount;
                    		$exclued_vat_sub_total_qty+=$item['quantity'];
                    		$exclued_vat_sub_total_vat_amount+=((round($item['price'])*$item['vat_rate'])/100)*$item['quantity'];
                    	}



                        ?>
                        <tr>
                            <td style='padding-top:5px;'><?php echo $item['item_number']; ?></td>
                            <td style='text-align:right;padding-top:5px;'><?php echo number_format(round($show_price), 2); ?></td>
                            <td style='text-align:center;padding-top:5px;'><?php echo $item['quantity']; ?></td>
                            <td style='text-align:center;padding-top:5px;'><?php echo $item['discount']; ?></td>
                            <td style='text-align:right;padding-top:5px;'><?php echo number_format(round($show_total_amount), 2); ?></td>
                        </tr>
                        <tr>
                        <?php
                        $cat_pos=0;
                        $cat_pos = strpos($item['name'], "</br>");

                        if(intval($cat_pos)){
                        	$cat_pos=$cat_pos+5;
                        }if($item['lot_no']>=211100){
                        ?>
                            <td colspan="5" style='text-align:left;border-bottom:1px dashed #000000;padding-bottom:7px'><?php echo $vatStr . str_replace("</br>"," - ",substr($item['name'],$cat_pos))." @".$item['lot_no']; ?></td>
                        <?php }else{?>
                        	<td colspan="5" style='text-align:left;border-bottom:1px dashed #000000;padding-bottom:7px'><?php echo $vatStr . str_replace("</br>"," - ",substr($item['name'],$cat_pos))." @".$item['lot_no']." **"; ?></td>
                            <?php }?>
                            </tr>
                        <?php
                    }



                    ?>
                    <?php 
                    $has_both=0;
                    if($included_vat_sub_total_amount!=0 AND $exclued_vat_sub_total_amount!=0){
                    	$has_both=1;
                    }

                    ?>
                    <?php if($included_vat_sub_total_amount!=0){?>
                    
                    
                    <?php if($has_both==1){?>
                    <tr>
                        <td colspan="2" style='text-align:right;border-top:3px double #000000;border-bottom:1px dashed #000000;'><?php echo "Incl.VAT Qty"; ?>:</td>
                        <td style='text-align:center;border-top:3px double #000000;border-bottom:1px dashed #000000;'><?php echo $included_vat_sub_total_qty; ?></td>
                        <td colspan="1" style='text-align:right;border-top:3px double #000000;border-bottom:1px dashed #000000;'><?php echo "Sub Total"; ?>:</td>
                        <td style='text-align:right;border-top:3px double #000000;border-bottom:1px dashed #000000;'><?php echo number_format(round($included_vat_sub_total_amount), 2); ?></td>
                    </tr>
                    
                    <?php }else{?>
                     <tr>
                        <td colspan="2" style='text-align:right;border-top:3px double #000000;'><?php echo $this->lang->line('sales_qty_total'); ?></td>
                        <td style='text-align:center;border-top:3px double #000000;'><?php echo $included_vat_sub_total_qty; ?></td>
                        <td colspan="1" style='text-align:right;border-top:3px double #000000;'><?php echo "Sub Total"; ?>:</td>
                        <td style='text-align:right;border-top:3px double #000000;'><?php echo number_format(round($included_vat_sub_total_amount), 2); ?></td>
                    </tr>
                    
                    <?php }?>
                    <?php
                    }

                    ?>
                    <?php if($exclued_vat_sub_total_amount!=0){?>
                    
                    <?php if($has_both==1){?>
                    <tr>
                        <td colspan="2" style='text-align:right;border-top:1px dashed #000000;border-bottom:1px solid #000000;'><?php echo "VATable Qty"; ?>:</td>
                        <td style='text-align:center;border-top:1px dashed #000000;border-bottom:1px solid #000000;'><?php echo $exclued_vat_sub_total_qty; ?></td>
                        <td colspan="1" style='text-align:right;border-top:1px dashed #000000;border-bottom:1px solid #000000;'><?php echo "Sub Total"; ?>:</td>
                        <td style='text-align:right;border-top:1px dashed #000000;border-bottom:1px solid #000000;'><?php echo number_format(round($exclued_vat_sub_total_amount), 2); ?></td>
                    </tr>
                    
                    <?php }else{?>
                     <tr>
                        <td colspan="2" style='text-align:right;border-top:3px double #000000;'><?php echo $this->lang->line('sales_qty_total'); ?>:</td>
                        <td style='text-align:center;border-top:3px double #000000;'><?php echo $exclued_vat_sub_total_qty; ?></td>
                        <td colspan="1" style='text-align:right;border-top:3px double #000000;'><?php echo "Sub Total"; ?>:</td>
                        <td style='text-align:right;border-top:3px double #000000;'><?php echo number_format(round($exclued_vat_sub_total_amount),2); ?></td>
                    </tr>
                    
                    <?php }?>
                    <?php
                    }
                    ?>
                     <?php if($has_both==1){?>
                     <tr>
                        <td colspan="2" style='text-align:right;border-top:1px solid #000000;'><?php echo $this->lang->line('sales_qty_total'); ?>:</td>
                        <td style='text-align:center;border-top:1px solid #000000;'><?php echo ($exclued_vat_sub_total_qty+$included_vat_sub_total_qty); ?></td>
                        <td colspan="1" style='text-align:right;border-top:1px solid #000000;'><?php echo "Sub Total"; ?>:</td>
                        <td style='text-align:right;border-top:1px solid #000000;'><?php echo number_format((round($included_vat_sub_total_amount)+round($exclued_vat_sub_total_amount)),2); ?></td>
                    </tr>
                    <?php } ?>
                    
                    <?php
                    if($no_exchage==1 OR $customer_card_no=="BOGO" OR $customer_card_no=="B2GO"){
                    	//$no_exchage_font='<font style="font-weight:bold;font-size:14px;border-top: 3px solid #000000;border-bottom: 0px solid #000000;">NO EXCHANGE</font></br><font style="font-weight:bold;font-size:14px;border-top: 0px solid #000000;border-bottom: 3px solid #000000;">OR NO REFUND</font>';
                    	$no_exchage_font='&nbsp;';
                    }else{
                    	$current_date_check=date("Y-m-d");
                    	if($current_date_check>='2022-01-15' AND $current_date_check<='2022-01-31'){
                    		$no_exchage_font='<font style="font-weight:bold;font-size:14px;border-top: 3px solid #000000;border-bottom: 0px solid #000000;">NO EXCHANGE</font></br><font style="font-weight:bold;font-size:14px;border-top: 0px solid #000000;border-bottom: 3px solid #000000;">OR NO REFUND</font>';
                    		
                    	}else{
                    		$no_exchage_font='&nbsp;';
                    	}

                    }

                    if($no_exchage==1 OR $customer_card_no=="BOGO" OR $customer_card_no=="B2GO"){
                    	if(($exclued_vat_sub_total_qty+$included_vat_sub_total_qty)==0){
                    		?>
                    		<tr>
                        <td colspan="2" style='text-align:right;border-top:1px solid #000000;'><?php echo $this->lang->line('sales_qty_total'); ?>:</td>
                        <td style='text-align:center;border-top:1px solid #000000;'><?php echo ($exclued_vat_sub_total_qty+$included_vat_sub_total_qty); ?></td>
                        <td colspan="1" style='text-align:right;border-top:1px solid #000000;'><?php echo "Sub Total"; ?>:</td>
                        <td style='text-align:right;border-top:1px solid #000000;'><?php echo number_format((round($included_vat_sub_total_amount)+round($exclued_vat_sub_total_amount)),2); ?></td>
                    </tr>
                    		<?php
                    	}

                    }

                    if($exclued_vat_sub_total_vat_amount!=0){ ?>
                    <tr>
                        <td colspan="4" style='text-align:right;'><?php echo "VAT On VATable Sub Total (".number_format(round($exclued_vat_sub_total_amount),0).")"; ?>:</td>
                         <td style='text-align:right;'><?php echo number_format($exclued_vat_sub_total_vat_amount, 2); ?></td>
                    </tr>
                    <?php
                    $adjectment = round($exclued_vat_sub_total_vat_amount)-($exclued_vat_sub_total_vat_amount);
                        ?>
                    <tr>
                        <td colspan="4" style="text-align:right;">Adjustment(+/-):</td>
                        
                        <?php if($adjectment>0){?>
                        <td style="text-align:right;">+<?php echo number_format($adjectment, 2); ?></td>
                        <?php }else{?>
                         <td style="text-align:right;"><?php echo number_format($adjectment, 2); ?></td>
                        <?php }?>
                        
                    </tr>
                    	
                   <?php }else{ ?>
                    <tr>
                        <td colspan="4" style='text-align:right;'><?php echo "VAT" ?>:</td>
                         <td style='text-align:right;'><?php echo number_format(0, 2); ?></td>
                    </tr>
                    <?php
                    $adjectment = 0;
                        ?>
                    <tr>
                        <td colspan="4" style="text-align:right;">Adjustment(+/-):</td>
                       
                        <?php if($adjectment>0){?>
                        <td style="text-align:right;">+<?php echo number_format($adjectment, 2); ?></td>
                        <?php }else{?>
                         <td style="text-align:right;"><?php echo number_format($adjectment, 2); ?></td>
                        <?php }?>
                    </tr>
                    
                    <?php 
                   }
                   $grand_total_show=round(round($exclued_vat_sub_total_vat_amount)+round($included_vat_sub_total_amount)+round($exclued_vat_sub_total_amount));
                    ?>
                    
                    <tr>
                        <td colspan="4" style='text-align:right;border-top:1px solid #000000;border-bottom:1px solid #000000;'><?php echo "Total:"; ?></td>
                        <td style='text-align:right;border-top:1px solid #000000;border-bottom:1px solid #000000;'><?php echo number_format(round($grand_total_show), 2); ?></td>
                    </tr>

                    <?php
                    $totaldiscount=$subtotal_product_discount;
                    ?>
                    
                    <?php
                    if($totaldiscount>0){
                    ?>
                    <tr>
                        
                        <td colspan="4" style='text-align:right;'><?php echo "Product Discount" ?>:</td>
                        <td style='text-align:right'><?php echo "-".number_format(round($totaldiscount), 2); ?></td>
                    </tr> 
                    <?php
                    }else{
                    ?>
                    <tr>
                        <td colspan="4" style='text-align:right;'><?php echo "Product Discount" ?>:</td>
                        <td style='text-align:right'><?php echo number_format(round(0, 2), 2); ?></td>
                    </tr> 
                    <?php
                    }
                    ?>
                    
                    <?php if ($this->session->userdata['customer'] != -1) { ?>
                        
                        <?php 	if(POINT_CARD_ACTIVE==1){ ?>
                        <?php
                        if($purchase_discount_amount>0){
                        ?>
                        <tr>
                           <?php if($customer_card_no=="BOGO" OR $customer_card_no=="B2GO"){?>
                            <td colspan="4" style="text-align:right;"><b><?php echo $customer_card_no;?></b> Discount:</td>
                            <?php }else{?>
                            <td colspan="4" style="text-align:right;">Card Discount:</td>
                            <?php }?>
                            <td style="text-align:right;"><?php echo "-" . number_format(round($purchase_discount_amount), 2); ?></td>
                        </tr>
                        <?php }else{?>
                        <tr>
                            <td colspan="4" style="text-align:right;">Card Discount:</td>
                            <td style="text-align:right;"><?php echo number_format(round($purchase_discount_amount), 2); ?></td>
                        </tr>
                    <?php }
                        }
                    }

                    if(intval($coupon_card_discout)>0){ ?>
                    	
                    	<tr>
                            <td colspan="4" style="text-align:right;">Previous Gift Dis:</td>
                            <td style="text-align:right;"><?php echo  "-" .number_format(intval($coupon_card_discout), 2); ?></td>
                        </tr>
                   <?php 
                   $purchase_discount_amount+=intval($coupon_card_discout);
                    }




                    ?>
                    <?php if ($this->session->userdata['customer'] != -1) { ?>
                        
                       <?php if($cart_point_cost>0){?>
                    
                        <tr>
                            <td colspan="4" style="text-align:right;">Use Points:</td>
                            <td style="text-align:right;"><?php echo "-" . number_format(round($cart_point_cost), 2); ?></td>
                        </tr> 
                        <?php
                       }
                        ?>
                        <?php } ?>
                 
                    
                    <?php if($final_due>0){?>
                    <tr>
                        <td colspan="4" style="text-align:right;">Previous Due(+):</td>
                        <td style="text-align:right;"><?php echo number_format(round($final_due), 2); ?></td>
                    </tr>
                    <?php }?>
                    
                    <?php if($final_due<0){?>
                    <tr>
                        <td colspan="4" style="text-align:right;">Advance Payment(-):</td>
                        <td style="text-align:right;"><?php echo number_format(round($final_due), 2); ?></td>
                    </tr>
                    <?php }?>
                    
                    <?php 

                    $grand_total_show-=(round($totaldiscount)+round($purchase_discount_amount)+round($cart_point_cost)+round($final_due));

                    ?>
                    
                    <tr>
                        <td colspan="4" style='text-align:right;border-top:3px double #000000;border-bottom:3px double #000000;'><?php echo "Grand Total:"; ?></td>
                        <td style='text-align:right;border-top:3px double #000000;border-bottom:3px double #000000;'><?php echo number_format(round($grand_total_show), 2); ?></td>
                    </tr>

                    <?php
                    $this_trans_due = 0;
                    $other_paid = 0;

                    foreach ($payments as $payment_id => $payment) {
                    	if ($payment['payment_type'] != 'User Point') {

                    		if ($payment['payment_type'] == "Due") {
                    			$this_trans_due = $this_trans_due + $payment['payment_amount'];
                    		} else {
                    			$other_paid = $other_paid + $payment['payment_amount'];
                    		}
                    		$splitpayment = explode(':', $payment['payment_type']);
                            ?>
                            <tr>
                                <?php if ($payment['payment_type'] == "Due") { ?>
                                    <td style="text-align:left;"><?php echo "This Invoice:"; ?></td>

                                    <?php if ($payment['payment_amount'] < 0) { ?>
                                        <td colspan="4" style="text-align:left;"><?php echo "Advance:"; ?> </td>
                                    <?php } else { ?>
                                        <td colspan="4" style="text-align:right;"><?php
                                        echo $splitpayment[0];
                                            ?> </td>
                                    <?php } ?>
                                    <td colspan="4" style="text-align:right"><?php echo number_format($payment['payment_amount'], 2, '.', ','); ?>  </td>
                                <?php } else { 

                                	$payment_type_show=$splitpayment[0];
                                	$card_no_show="";

                                	if($payment_type_show=="Credit Card" OR $payment_type_show=="AMEX Card" OR $payment_type_show=="Debit Card"){
                                		if(trim($payment['card_no'])){
                                			$card_no_show="";
                                			if(strlen(trim($payment['card_no']))>4){
                                				$first_part=substr(trim($payment['card_no']),0,-4);
                                				$card_no_show.=str_pad(substr($first_part,0,4),4,"*",STR_PAD_RIGHT);
                                			}
                                			$card_no_show.="***";
                                			$card_no_show.=str_pad(substr(trim($payment['card_no']),-4),4,"*",STR_PAD_LEFT);
                                		}elseif(trim($payment['card_no_credit'])){
                                			$card_no_show="";
                                			if(strlen(trim($payment['card_no_credit']))>4){
                                				$first_part=substr(trim($payment['card_no_credit']),0,-4);
                                				$card_no_show.=str_pad(substr($first_part,0,4),4,"*",STR_PAD_RIGHT);
                                			}
                                			$card_no_show.="***";
                                			$card_no_show.=str_pad(substr(trim($payment['card_no_credit']),-4),4,"*",STR_PAD_LEFT);
                                		}
                                	}
                                	
                                	

                                	if($splitpayment[0]=="Purchase Discount"){
                                		$payment_type_show="Sales Discount";
                                	}elseif($splitpayment[0]=="Purchase Bonus"){
                                		$payment_type_show="Special Sales Discount";
                                	}
                                	if(trim($card_no_show)){
                                	?>
                                	<td colspan="4" style="text-align:right;"><p><?php echo $this->lang->line('sales_payment') . ' (' . $payment_type_show. '):'; ?></p><p><?php echo 'Card No: ' .$card_no_show . ''; ?></p></td>
                                    <td style="text-align:right;"><?php echo number_format($payment['payment_amount'], 2, '.', ','); ?>  </td>
                                	<?php }else{ ?>
                                	<td colspan="4" style="text-align:right;"><?php echo $this->lang->line('sales_payment') . ' (' . $payment_type_show . '):'; ?></td>
                                    <td style="text-align:right;"><?php echo number_format($payment['payment_amount'], 2, '.', ','); ?>  </td>
                                	<?php }?>
                                    
                                <?php } ?>


                            </tr>
                            <?php
                    	}
                    }
                    ?>


                    <tr>
                            <td colspan="4" style='text-align:right;'><?php echo $this->lang->line('sales_change_due'); ?>:</td>
                            <?php
                            if ($previous_due <= 0) {
                            	echo"<td style='text-align:right'>0.00</td>";
                            } else {
                            	echo"<td style='text-align:right'>" . number_format(round($get_payments_total) - round($grand_total_show), 2) . "</td>";
                            }
                            ?>
                        </tr>
                  
                </tbody>
            </table>

            <!--	<div id="sale_return_policy">
            <?php // echo nl2br($this->config->item('return_policy'));        ?>
                    </div>-->
            <?php if($exclued_vat_sub_total_qty!=0){?>
             <div id='foot' style="text-align:center;width:97%;border-top:1px solid #000000;border-bottom:1px solid #000000;margin-bottom:3px;">
                <p>** VAT is not included with the product price. So, you have to pay additionally as VAT.</p>
            </div>
            <?php }?>
            
            <?php
            if($customer_card_no=="FLAT_40P" OR $customer_card_no=="27P_FLAT_DIS"){
            	 $no_exchage=1;
            }

            if($no_exchage==1 OR $customer_card_no=="BOGO" OR $customer_card_no=="B2GO"){?>
                        
            <div id='foot' style="text-align:center;width:97%;font-size:16px;margin-top:3px;">
                <?php if(trim($coupon_code)!=""){ ?> 
            <p style="text-align:center;text-decoration: underline;margin-top:5px;"><b>GIFT CARD TERMS & CONDITIONS</b></p>
            <p style="text-align:justify;margin-top:1px;">1. This invoice will be treated as a gift card and you must show this invoice at future purchases if you want to avail this gift card.</p>
            <p style="text-align:justify;margin-top:1px;">2. This gift card distribution campaign will continue upto <b>Eid-ul-fitr-2022 </b> and will be valid from the date of issue till <b>30/06/2022</b>. You can be used for subsequent purchases at <b>Grameen Check(<?php echo ucwords(LOCATION_NAME);?>)</b> outlet.</p>
            <p style="text-align:justify;margin-top:1px;">3. This gift card is non-refundable and cannot be exchanged for cash in part or full and is valid for a single transaction only.</p>
            <p style="text-align:justify;margin-top:1px;">4. Strictly no extension of the expiry date from the date of issue will be allowed.</p>
            <p style="text-align:justify;margin-top:1px;">5. The management retains the right to reject any voucher that has been tampered with or found in any way unacceptable.</p>
            <?php }?>
                <p style="padding-top:3px;padding-bottom:3px;"><font style="font-weight:bold;font-size:14px;border-top: 3px solid #000000;border-bottom: 3px solid #000000;">NO EXCHANGE OR NO REFUND</font></p>
                <p><b>Thank You for Shopping.</b></p>
                <p><?php echo $barHtml;?></p>
            </div>
            <?php }else{?>
            
            <?php
            $current_date_check=date("Y-m-d");
            if($current_date_check>='2022-01-15' AND $current_date_check<='2022-01-31'){?>
            	 <div id='foot' style="text-align:center;width:97%;font-size:16px;margin-top:3px;">
            	 <?php if(trim($coupon_code)!=""){ ?> 
            <p style="text-align:center;text-decoration: underline;margin-top:5px;"><b>GIFT CARD TERMS & CONDITIONS</b></p>
            <p style="text-align:justify;margin-top:1px;">1. This invoice will be treated as a gift card and you must show this invoice at future purchases if you want to avail this gift card.</p>
            <p style="text-align:justify;margin-top:1px;">2. This gift card distribution campaign will continue upto <b>Eid-ul-fitr-2022 </b> and will be valid from the date of issue till <b>30/06/2022</b>. You can be used for subsequent purchases at <b>Grameen Check(<?php echo ucwords(LOCATION_NAME);?>)</b> outlet.</p>
            <p style="text-align:justify;margin-top:1px;">3. This gift card is non-refundable and cannot be exchanged for cash in part or full and is valid for a single transaction only.</p>
            <p style="text-align:justify;margin-top:1px;">4. Strictly no extension of the expiry date from the date of issue will be allowed.</p>
            <p style="text-align:justify;margin-top:1px;">5. The management retains the right to reject any voucher that has been tampered with or found in any way unacceptable.</p>
            <?php }?>
                <p><b>Thank You for Shopping.</b></p>
                <p><?php echo $barHtml;?></p>
            </div>
            <?php }else{?>
            	<div id='foot' style="text-align:center;width:97%;">
                 <p>Exchange not allowed without this receipt and price tag. Items exchange may be made within 7 days from <b>Grameen Check(<?php echo ucwords(LOCATION_NAME);?>)</b> outlet. An item may be exchanged only once. Any kind of discounted product, undergarments and accessories cannot be exchanged or returned. No cash refund is applicable.</p>
                <?php if(trim($coupon_code)!=""){ ?> 
            <p style="text-align:center;text-decoration: underline;margin-top:5px;"><b>GIFT CARD TERMS & CONDITIONS</b></p>
            <p style="text-align:justify;margin-top:1px;">1. This invoice will be treated as a gift card and you must show this invoice at future purchases if you want to avail this gift card.</p>
            <p style="text-align:justify;margin-top:1px;">2. This gift card distribution campaign will continue upto <b>Eid-ul-fitr-2022 </b> and will be valid from the date of issue till <b>30/06/2022</b>. You can be used for subsequent purchases at <b>Grameen Check(<?php echo ucwords(LOCATION_NAME);?>)</b> outlet.</p>
            <p style="text-align:justify;margin-top:1px;">3. This gift card is non-refundable and cannot be exchanged for cash in part or full and is valid for a single transaction only.</p>
            <p style="text-align:justify;margin-top:1px;">4. Strictly no extension of the expiry date from the date of issue will be allowed.</p>
            <p style="text-align:justify;margin-top:1px;">5. The management retains the right to reject any voucher that has been tampered with or found in any way unacceptable.</p>
            <?php }?>
                 <p><b>Thank You for Shopping.</b></p>
                <p><?php echo $barHtml;?></p>
            </div>
            <?php }?>
            
            <?php }?>
          
        </div>
    </div>
    <?php //exit(); ?>
    <?php
    // if ($this->Appconfig->get('print_after_sale'))
    //{
    ?>

    <script type="text/javascript">


    $(document).ready(function () {

    	//$("#receipt_wrapper").hide();

    	$("#receipt_wrapper").printThis({
    		debug: false,
    		printContainer: false,
    		pageTitle: "",
    		removeInline: false
    	});
    });
    </script>