<!DOCTYPE html>

<html lang="en" class="no-js">

<!-- start: HEAD -->

<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?php

header("Expires: Tue, 01 Jan 2000 00:00:00 GMT");

header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");

header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");

header("Cache-Control: post-check=0, pre-check=0", false);

header("Pragma: no-cache");

?>
<title>
<?php

if (isset($sub_menu_name))

    echo strtoupper($sub_menu_name . ' - ');

?>
STOCK MANAGEMENT SYSTEM</title>

<!-- start: META -->



<!--[if IE]><meta http-equiv='X-UA-Compatible' content="IE=edge,IE=9,IE=8,chrome=1" /><![endif]-->

<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="description" />
<meta name="author" />

<!--<link rel="stylesheet" href="<?php echo asset_url();?>plugins/bootstrap/css/bootstrap.min.css">
-->

</head>
<div style="top:5px;" class="panel-tools open">
  <button style="display:none" data-toggle="dropdown" class="btn btn-blue dropdown-toggle" onClick="window.print()"><i class="fa fa-print"></i></button>
</div>
<style type="text/css">

th {
	text-align: center !important;
}
.report_view_th {
	color: #000 !important;
	text-align: center !important;
}
body {
	background-color: #fff !important;
	font-size: 11px;
	font-family: "verdana";
	/*, Times, serif; */
	/* font-family:verdana; */
	 /* BPmono helvetica;  verdana*/
    letter-spacing: 0.5px;
   
     margin-right:10px;
     margin-top:40px;
     color:#000 !important;
}
p {
	margin: 0;
}
.print-table td, th {
	padding: 0px;
	vertical-align: top !important;
}
thead {
	display: table-header-group;
}
tfoot {
	display: table-footer-group;
}
</style>
<style type="text/css" media="print">
.print-table {
	width: 100%;
}
.td_border_bottom_1 {
	border-bottom: 1px solid #666 !important;
}
.td_border_bottom_2 {
	border-bottom: 4px double #666 !important;
}
.td_border_top_1 {
	border-top: 1px double #666 !important;
}
.pagebreak {
	page-break-before: always;
}

 @page {
size: auto;   /* auto is the initial value */
margin: 0;  /* this affects the margin in the printer settings */
}

.row {
  padding-left: 20px;
  padding-right: 15px;
}
</style>
<!--  onLoad="window.print(),window.close()" -->
<?php 
$close_text='';
if($this->session->userdata('ss_warehouse_id')==8){
    
   $close_text='';
}else{
    
    
}

$close_text=',window.close()';
$print_text='window.print()';
if($this->session->userdata('ss_user_id')==1){
	$close_text='';
	$print_text='';
}
$close_text='';
?>
<body onLoad="<?php echo $print_text;?> <?php echo $close_text;?>">
<div class="print_area print" style="width:100%;">
  <div class="row">
    <div class="col-xs-12" style="text-align:center">
      <center>
        <div style="display:none; border:solid 3px; border-radius:50px; width:13%; padding:15px; line-height:1"><span style="font-size:31px;font-weight:bold">SO</span> <span style="font-size:14px;font-weight:bold">Yummy</span></div>
      </center>
      <!-- <img src="<?php echo asset_url(); ?>images/logo_s.png" style="margin-top: 1px;width: 80%;"> -->
      
      <H2 style="font-size:14px; margin-bottom:0px; font-weight: bold; margin-top: 1px; line-height: 0.9; font-family: ; margin-bottom: 5px; letter-spacing: 0.1px;"> <?php //if($warehouse_details['id']==1) echo "&nbsp;&nbsp;&nbsp;";?>
      
      <?php 
      if($warehouse_details['id']==21)
      echo "OPSEL PHONES & GADGETS";
      else
      echo $warehouse_details['name']; ?>
      
      </H2> 
      
      
      <?php if($warehouse_details['name_2']){?>
      <p style="font-size:27px; margin-bottom:0px; font-weight: bold; margin-top: 0px; line-height: 0.8;"><?php echo $warehouse_details['name_2']; ?></p>
      <?php } ?>
      <!-- 
      <p class="text-center" style="font-weight:bold; font-size:17px;">Mobile Phone & Accessories</p> -->
      <p style="font-size:"><?php echo $warehouse_details['address']; ?></p>
      <?php if($warehouse_details['email']) //echo $warehouse_details['email']."<br>"; ?>
      <?php if($warehouse_details['phone']) echo "<span style=\"font-size:\">  ".$warehouse_details['phone']."</span><br>"; ?>
      
      <p style="padding:3px; font-weight:bold;">INVOICE</p>
      
    <!-- <p style="font-size:15px">INVOICE<P/>-->
     <div style="height:2px; border-bottom: 1px dashed black;"></div>
     
    
    </div>
    
    <!--col-xs-12--> 
    
  </div>
  <div class="row">
    <div class="col-xs-12" style="margin-left:0px;">
      <div class="" style="margin-left:0px; padding-left:0;">
        <p style="font-size:11px;margin: 0px 35px 0px 0px;">Inv. No &nbsp;&nbsp;&nbsp;&nbsp;: <?php echo $sale_details['sale_reference_no']; ?></p>
        <p style="font-size:11px;margin: 0px 35px 0px 0px;">Date &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : <?php echo site_date_time($sale_details['sale_datetime']); //date("Y-m-d", strtotime($sale_details['sale_datetime'])); ?></p>
        <div style="height:5px">&nbsp; </div>
        <p style="font-size:11px;margin: 0px 35px 0px 0px;">Customer &nbsp;  : <?php echo $customer_details['cus_name']; ?></p>
       
        <?php 

            if($customer_details['cus_id'] != 1){ 

    //        	  if($customer_details['cus_address']){ echo "<p>Address: ".$customer_details['cus_address']."</p>"; }

                  if($customer_details['cus_phone']){ echo "<p style=\"font-size:12px;margin-bottom:-2px;\">Phone: ".$customer_details['cus_phone']."</p>"; }

            }

        ?>
        
        <p style="font-size:px;margin: 0px 35px 0px 0px;">Rep. &nbsp;  &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;: 
		<?php 
		$ref_id = new User_Model();
	 	 $data['user_details']=$ref_id->get_user_info($sale_details['rep_id']);
		 if(isset($data['user_details']['user_first_name']))
		 {
		echo $data['user_details']['user_first_name'];
		 }
		//echo $this->session->userdata('ss_user_first_name'); ?></p>
      </div>
      <!-- 
      <div class="col-xs-3 pull-right">
        <p style="font-size:13px; margin-bottom:-4px;">Us: <?php echo $this->session->userdata('ss_user_first_name'); ?></p>
        
        
      </div>
      -->
    </div>
  </div>
  <div class="print-start">
    <?php //print_r($sale_details);?>
    <div class="row col-md-12">
    <div style="height:2px; border-bottom: 1px dashed black;"></div>
      <div class="col-xs-12">
        <table class="print-table" width="100%">
          <thead style="border-bottom:dashed 2px;border-top:dashed 2px">
            <tr class="report_view_th">
              
              <td style="width:85%">Item</td>
              <td style="width:5%">Qty</td>
              <td style="width:10%">Price</td>
             <!--  <th style="width:10%">Dis.</th> -->
              <?php /*?><th class="col-xs-1"><br/>Discount</th> <?php */?>
              <td align="center" style="width:10%"> Amount</td>
            </tr>
          </thead>
          <tbody>
            <?php 
 $sale_mod=new Sales_Model();
 $tmpcount=0;
  $tot_qty=0;

 $gtotal  =0;

  foreach ($sale_item_list as $row)

 {

	 $gtotal += $row['gross_total'];

	 $tmpcount++;
	 $tot_qty=$tot_qty+intval( $row['quantity']);

 ?>
            <tr>
              
              <td style="" colspan="4"><?php echo $row['product_name'] ?>
               <?php 
 $sn_list=$sale_mod->get_sales_serial_by_id($sale_details['sale_id'],$row['id']);
 if($row['w_id']){
  $w_des=$sale_mod->get_warranty_types_des_by_id($row['w_id']);
//print_r($w_des);
echo "<br/> ".$w_des['w_name'];
}

if(!empty($sn_list)){ 
echo " <br/>IEMI/Seri No: ";
foreach ($sn_list as $sn) { 
echo "$sn->sis_number, ";
}
}

if($row['product_w']) echo " / Warranty: ".$row['product_w']. " Months";
?>
              
              </td>
              
            </tr>
            
            <tr>
                <td></td>
                <td><?php echo intval( $row['quantity']); ?></td>
                <td><?php 
                
               // if($row['unit_price']!=0.00) 
               // echo $row['unit_price']-$row['discount_val']; 
               
               echo $row['gross_total']/$row['quantity'];
                
                if($row['unit_price']==0.00) {
                    if($row['discount_val']<0)
                    {
                   // echo $row['discount_val']*-1; 
                    }
                }
                
                ?></td>
             <!--    <td>&nbsp
             <?php
             
           //  echo $row['discount_val'];
             ?></td> -->
                <td align='right'><?php echo number_format($row['gross_total'], 2, '.', ','); ?></td>
            </tr>
            <?php }?>
            
             <?php 
 $tmpcount_rtn=0;
  // $sale_mod=new Sales_Model();
  foreach ($sale_rtn_item_list as $row_rtn)
 {
	// print_r
	 $tmpcount_rtn++;
 ?> 
 
 <tr>
              
              <td style="" colspan="4"><?php echo $row_rtn['product_name'] ?>  (Returned)
               <?php 
 $sn_list=$sale_mod->get_sales_return_serial_by_id($sale_rtn_details['sl_rtn_id'],$row_rtn['id']);
 
if(!empty($sn_list)){ 
echo " <br/>IEMI/Seri No: ";
foreach ($sn_list as $sn) { 
echo "($sn->sris_number) , ";
}
}

?>
              
              </td>
              
            </tr>
            
            <tr>
                <td></td>
                <td><?php echo intval( $row_rtn['quantity']); ?></td>
                <td><?php echo $row_rtn['unit_price']; ?></td>
             <!--    <td>&nbsp<?php echo $row_rtn['discount'] ?></td> -->
                <td align='right'><?php echo number_format($row_rtn['gross_total'], 2, '.', ','); ?></td>
            </tr>
 
 <?php } ?>
 
 <?php 
                if($sale_details['remarks']!=''){
                ?>
                <tr>
                    
                <td colspan="3">
                
                <?php
                echo "<br/> Remark : ".$sale_details['remarks'];
                
                ?></td>
                 
                 </tr>
                <?php 
                }
                ?>
 
 
            
            <tr>
            <td style="border-top:1px dashed #000" colspan="2" align="left">
                Num. of Items: <?php echo $tmpcount;?>
                
                </td>
            <td colspan="4" style="border-top:1px dashed #000">Total Qty : &nbsp;&nbsp;&nbsp; <?php echo $tot_qty;?></td>
            
            </tr>
            <tr style="border-top:dashed 2px;">
              <td style="text-align:right;  border-bottom:1px dashed #000;" colspan="2">SubTotal &nbsp;</td>
               <td style="text-align:left;  border-bottom:1px dashed #000;"></td>
              <td style="text-align:right; padding-right:0px; border-bottom:1px dashed #000;"><?php echo number_format($gtotal, 2, '.', ',') ?></td>
            </tr>
            

            <?php if ($sale_details['sale_inv_discount_amount'])
			{ ?>
            <tr>
              <td style="text-align:left; font-weight:;" colspan="2"> Discount &nbsp;</td>
              <td style="text-align:left;"></td>
              <td style="text-align:right; padding-right:0px; border-bottom:solid 0px #000000"><?php echo number_format($sale_details['sale_inv_discount_amount'], 2, '.', ',') ?></td>
            </tr>
            <?php }?>
            
            <?php 
			$sls_rtn_total_paid=0;
			if(isset($sale_rtn_details['sls_rtn_total_paid'])){
				$sls_rtn_total_paid=$sale_rtn_details['sls_rtn_total_paid'];
			}
			
			if(isset($sale_rtn_details['sl_rtn_reference_no'])){?>
             <tr style="border-top:dashed 2px;">
              <td style="text-align:left;" colspan="2">Returned Amount ( Ref. No. <?php echo $sale_rtn_details['sl_rtn_reference_no'];?>)</td>
               <td style="text-align:left;">:</td>
              <td style="text-align:right; padding-right:0px;"><?php echo number_format(($sls_rtn_total_paid), 2, '.', ',') ?></td>
            </tr>
            <?php } ?>
            <tr>
              <td style="text-align:right; font-weight:; font-size:14px" colspan="2">Net Total &nbsp;</td>
              <td style="text-align:left;"></td>
              <td style="text-align:right; font-size:16px; font-weight:; border-bottom:0px double #000;"><?php echo number_format($sale_details['sale_total']-$sls_rtn_total_paid, 2, '.', ',') ?>
            </tr>
            
            <?php
            //print_r($sale_payments_list);
             foreach ($sale_payments_list as $row){
//	$tot_advnc_paid+=$row->sale_pymnt_amount;

if($row->sale_pymnt_amount!='0.00')
            {
            
            ?>
            
            <tr>
              <td style="text-align:right; font-weight:; font-size:14px" colspan="2">Paid (<?php echo $row->sale_pymnt_paying_by ?>) &nbsp;</td>
              <td style="text-align:left;"></td>
              <td style="text-align:right; font-size:16px; font-weight:; border-bottom:0px double #000;"><?php echo number_format($row->sale_pymnt_amount, 2, '.', ',') ?>
            </tr>
            
            <?php }  } ?>
            <tr>
              <td style="text-align:right; font-weight:; font-size:14px" colspan="2">Total Paid &nbsp;</td>
              <td style="text-align:left;"></td>
              <td style="text-align:right; font-size:16px; font-weight:; border-bottom:0px double #000;"><?php echo number_format($sale_details['sale_total']-$sls_rtn_total_paid, 2, '.', ',') ?>
            </tr>
            <!-- 
             <tr>
              <td style="text-align:right; font-weight:; font-size:14px" colspan="2">Change &nbsp;</td>
              <td style="text-align:left;"></td>
              <td style="text-align:right; font-size:16px; font-weight:; border-bottom:0px double #000;">0.00</td>
            </tr>
            -->
            <!-- 
            <tr>
              <td style="text-align:left; font-weight:; font-size:14px" colspan="3">Card &nbsp;</td>
              <td style="text-align:left;">:</td>
              <td style="text-align:right; font-size:16px; font-weight:; border-bottom:0px double #000;">0.00
            </tr> -->
            <?php 
            { ?>
            <?php 

			if(isset($sale_payments_list[0]))

		{ ?>
            
            <?php } ?>
            
            
            
            <?php

if(isset($sale_payments_list[0])) 

if( floatval($sale_payments_list[0]->sale_pymnt_given_amount) > 0 ){

?>
            <tr>
              <td style="font-size:16px;text-align:right; font-weight:bold" colspan="3">Balance Amount</td>
              <td style="text-align:right; font-weight:bold; border-bottom:4px double #000;"><p style="font-size:16px">
                  <?php 

if($sale_payments_list[0]->sale_pymnt_given_amount)

echo number_format($sale_payments_list[0]->sale_pymnt_given_amount-$sale_details['sale_total'], 2, '.', ',');

else echo number_format(0, 2, '.', ',');

			}?>
                  &nbsp;&nbsp; </p></td>
            </tr>
            <?php } ?>
          </tbody>
        </table>
        
        <div style="height:2px; border-bottom: 1px dashed black;"></div>
         <?php 
    $rep_name='';
if(!empty($sale_details['rep_id'])){
$objasd = new User_Model();

$rep_details=$this->User_Model->get_user_info($sale_details['rep_id']);
$rep_name=$rep_details['user_first_name'];
}

?>

       <!-- <p style="font-size:15px"> <br/> Sales Person : <?php echo $rep_name?>-->
        
        
        </p>
        <p style="text-align:center; font-size:; padding-top:5px; padding-bottom:5px;">
           <!--  All Cheques to be drawn in favour <br/> * Opsel Phones & Gadgets * <br/> -->
        All Electrical items have 06 Months Warranty. No warranty for physical and liquid damages.
       
       
        </p>
        
        <table width="100%">
            <tr>
                <td align="center"><br/> 
                ----------------<br/>Customer</td>
                <td></td>
                <td align="center">
                    <br/> 
                 ----------------<br/>
                Authorized by</td>
            </tr>
        </table>
        
        
        
        <div style="text-align:center ;">
        ** Authorised Dealer For ** <br/>
Samsung, Nokia, Oppo, Huawei, Mi <!-- , Micromax, Etel, Lava, Vivo -->
        </div>
        
        <div style="height:2px; border-bottom: 1px dashed black;"></div>
        <p align="center" style="font-weight:; font-size:; font-style:; font-family:">
        THANK YOU COME AGAIN</p>
            <div style="height:2px; border-bottom: 1px dashed black;"></div>
        <?php //if( floatval($sale_payments_list[0]->sale_pymnt_given_amount) > 0 ) echo '2'; else echo '1'; ?>
      </div>
    </div>
  </div>
</div>
<!--
<div class="pagebreak"> - </div>
-->



<!--print-start-->

</body>
<!-- <script src="<?php echo asset_url(); ?>plugins/jQuery-lib/2.0.3/jquery.min.js"></script>-->
<script type="text/javascript">
jQuery(document).ready(function() {
    
    setTimeout(
  function() 
  {
    //do something special
  }, 2000);
	//alert();
//window.close();
				// $("#modal_ajax_sales_payment_btn").trigger("click");
				//fbs_click('<?php //echo $sale_id ?>')
				//Main.init();
				//TableData.init();
				//UIModals.init();

			});
			
			</script>
