	    <?php header('Refresh: 5'); ?>
	<?PHP

 $session_data = $this->session->userdata('logged_in');

   
 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];

 $data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
		 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
	 $data['branchid'] = $session_data['branchid'];
	 $branchid = $data['branchid'];		
													  $logoutaction=$this->usermodel->populatuserpermissionsdataarray('sales','Logout',$userid);
 $smsconfig = $this->usermodel->populateallarray('smsconfig','id',$companyid);
		 	 	
  $receipt=$smsconfig[0]['receipt'];	
								?>	
					  		<input type="hidden" name="printing" id="printing"  value="<?php echo set_value('printing',$logoutaction); ?>" class="form-control"  placeholder="Enter printing">


	<script>
	var util = { };

document.addEventListener('keydown', function(e){

    var key = util.key[e.which];
    if( key ){
        e.preventDefault();
    }

   if( key === 'F5' ){        
  return  printDiv('printableArea');
    }
  if( key === 'F6' ){        
  window.location.href = "../user/viewsales";
    }

	 if( key === 'enter' ){        
return true;
    }
	
   
	
	
})


  
util.key = { 
  9: "tab",
  //13: "enter",
  16: "shift",
  12: "alt",
  27: "esc",
  33: "rePag",
  34: "avPag",
  35: "end",
  36: "home",
  37: "left",
  38: "up",
  39: "right",
  40: "down",
  112: "F1",
  113: "F2",
  114: "F3",
  115: "F4",
  116: "F5",
  117: "F6",
  112: "F7",
  119: "F8",
  120: "F9",
  121: "F10",
  122: "F11",
  123: "F12"
}
 

	</script>
<script>
	function printDiv(divName) {
     var printContents = document.getElementById(divName).innerHTML;
     var originalContents = document.body.innerHTML;
  var printing = document.getElementById('printing');

     document.body.innerHTML = printContents.fontsize(16);
     window.print();

	 if( window.print()) {
		 if(printing=true){
			 
			  window.location.href = "../user/logout";

		 }else{
			         window.location.href = "../user/viewsales";
 		alert(" printing...........");

		 }
    }else {

	
		      return      window.location.href = "../user/viewsales";

		    // document.body.innerHTML = originalContents;

	}
}
	</script>
  <style type="text/css">
  
  

    #printable { display: none; }
#print{  	


    background-repeat: no-repeat;
	font-size;20px;

    width:100%; height:50px;



}
#extratitle { font-size: 2em; }
.doted{
    border: dotted 3px #000000;
}
table { border-collapse: collapse; }
td { padding: 5px; }
tr { border-bottom:1px dashed #494949; }


table{
    border-collapse:collapse;/*This property collapses borders together*/
}

#sale{  	
background-image:url(images/add.png) ;

    background-repeat: no-repeat;
  
    width:100px; height:50px;


}
#alltitle{ font-size: 2.2em; }
	#mytitle { font-size: 1.5em; }
#myalltitle { font-size: 3em; }
    @media print
    {
		
    	#non-printable { display: none; }
    	#printableArea { display: block; font-size:18; width:100%; }
		  margin:0; 
		#receipt{
	font-style: normal;font-size: 2em;
	
	padding:0px;
	
}
    }
    </style>
<?PHP

 echo $this->session->flashdata('imagemsg1'); 
		 

    $postedtime = date('Y-m-d');
		$currenttime = date('h:i:sa');
 		$dateposted =  ($postedtime)." ".$currenttime ;	

function formatMoney($number, $fractional=false) {
						if ($fractional) {
							$number = sprintf('%.2f', $number);
						}
						while (true) {
							$replaced = preg_replace('/(-?\d+)(\d\d\d)/', '$1,$2', $number);
							if ($replaced != $number) {
								$number = $replaced;
							} else {
								break;
							}
						}
						return $number;
					}	

 //$displaycode=$this->usermodel->populatuserpermissionsdataarray('config','productcode',$userid);
 /// $displaydiscount=$this->usermodel->populatuserpermissionsdataarray('sales','discount',$userid);
$displaycode=false;
$displaydiscount=false;
					
?>
 
 <div class="row">

 

   	<div class="col-md-12">
	
  
		<div class="panel panel-default" data-collapsed="0">
        	<div class="panel-heading" id="non-printable">
            	<div class="panel-title" id="redcolor" >
            		<i class="entypo-plus-circled"></i>
						 <span class="pull-right"> View Pending Orders</span>
						 
						   			  <a class="btn btn-primary" id="next-btn" href="<?php echo base_url(); ?>displayorders">Check Pending Orders</a>

										 <center><b style="font-size:15px"> ORDER DISPLAY SCREEN</b>  <center>

            </div>
				<div class="table-responsive">
			<div id="printableArea" style="width:100%;margin:0" >
<table    width="100%" >


						
						<?php

 if(is_array($orders)) 

 {
	 	foreach ($orders as $row){
$salesid=$row->invoice;

$myid=$row->id;
 $viewsales = $this->usermodel->populatealldatanoarraythree('sales_order','status <>', "returned", "maincategory",$maincategory,'invoice',$row->invoice);

?>
 
 
 
 
 
 <?php
 
 if(is_array($viewsales)) 

 {
	?>


 						<thead>
 
 	<tr style="background:gray">
						


	<td colspan="2" id="mytitle"><b>Item Name;     Order NO. <?PHP echo $row->id; ?>.  Time. <?PHP echo date("H:s d/m/Y", strtotime($row->dateposted)); ?> , Ordered BY:<?php
							$mysupplier=$this->usermodel->populateallarray('people','id', $row->userid);
						$myname=$mysupplier[0]['firstname'];
							echo strtoupper($myname);
						?>  
						
				                              <a  id="more" class="btn btn-info" href="<?php echo base_url();?>user/serveorder?randomitemidentifier=<?php   {echo  $myid;}  ?>&salesid=<?php   {echo  $salesid;}  ?>&branch=<?php   {echo  $branch;}  ?> &categoryno=<?php   {echo  $maincategory;}  ?>"> Served </a>
				
						
						
						
						
						
						
						</td>

 <td id="mytitle"><b>Qty</b></td>
				
							</tr>
						</thead>


<?php	
	
	
 $totalcost=0;
  $totalvatcost=0;
  $totalexemptedcost=0;
   $totaltax=0;
      $total=0;
  $totalqty=0;
  	foreach ($viewsales as $c){ 
 $total=$c->qty *$c->sprice;
		$totalcost= $totalcost+$total;
 $totalqty=$totalqty+$c->qty;

		 

             ?>
				                    <tbody>
									
										 
												
											<tr>
											
											<?php 
if($displaycode==true){
	 ?>
									<td><b><?php echo $c->code ; ?></b></td>

													    <td id="text"> <b><?php ; 
	 $receiptdescription=$configuration[0]['receiptdescription'];
   $customer=$c->code;
   if($customer!=""){
	  
      $productname = $this->usermodel->geteproductbyid($customer);
	  $finalmessage="";
       $message=strtoupper($c->address);
	   
	   if($message==""){
		   $finalmessage="";
	   }else{
		   		   $finalmessage=" -".$message;

	   }
		   

     echo$name=strtoupper($productname[0]['name'])." ".$finalmessage;


	 if($receiptdescription=="yes"){ echo"-".$description=strtoupper($productname[0]['description'])." ".$finalmessage;;}

	
   }else{
	    echo "No Product";  
   }
  
  
  ?></b></td>
	 	<?php
		}else{?>
	
	
													    <td  colspan="2" id="mytitle"><b><?php ; 
	 $receiptdescription=$configuration[0]['receiptdescription'];
   $customer=$c->code;
   if($customer!=""){
	   $message=strtoupper($c->address);
	   
	   if($message==""){
		   $finalmessage="";
	   }else{
		   		   $finalmessage=" -".$message;

	   }
		   


      $productname = $this->usermodel->geteproductbyid($customer);
  
     echo$name=strtoupper($productname[0]['name'])." ".$finalmessage;; 
	 
	 if($receiptdescription=="yes"){ echo"-".$description=strtoupper($productname[0]['description'])." ".$finalmessage;;}

	
   }else{
	    echo "No Product";  
   }
  
  
  ?></b></td>
 <?php
 }
 ?>
										<td id="mytitle"><b><?php echo $c->qty ; ?></b></td>
										
								
											
											</tr>
										<?php 
										
	}
	?>
	
	
	<tr>
								<td colspan="1" id="mytitle"><b>TOTAL QUANTITY:</b>
								<B>
	<?php 
	
								if(isset($totalqty)) {echo   formatMoney($totalqty, true); }
								
								?>
								</B>
								</td>
							
							</tr>
						<tr><td colspan="6"></br> </td>  </tr>
						
						<?php
						
										} ?>

          
				

						
							
					
 
<?php
}


}


?>					
											
</H3> </td></tr>

							

							
				
									</tbody>
									
									
					</table>
		
					
					
					
					
				</div>
			</div>
			</div>
		</div>
  
  </div>
 </div>
 </div> 
			
			
		
		






















