	    <?php header('Refresh: 5'); ?>
		
				
<script type="text/javascript">

<?php
if($pendingorder !=false){

?>
$(window).load(function()
{
	 if( window.print()) {
		 <?php 
		 
		 
			
						   							$paymentdata=array(		
			
			
				'printed'=>1,
		
						   
					  	);	

		 $this->usermodel->updatedata($paymentdata,'sms_in','id',$invoiceid)


		?>
         window.location.href = "../printmpesa";
 }else{
 
 }
});

<?php
}

?>
</script>	

	<?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.7em; }
#myalltitle { font-size: 2em; }
    @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'); 
		 
		    
$session_data = $this->session->userdata('logged_in');


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

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

   $myuser=$this->usermodel->geteuser($userid);
   $firstname=$myuser[0]['firstname'];
    $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);

					
?>
 
 <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 Sales</span>
						 
							<div class="print-hide"  >
<form name="print" method="post" action="">
 
 <div class="row">

 

   	<div class="col-md-6">

	
  			  <a class="btn btn-primary" id="next-btn" href="<?php echo base_url(); ?>pendingorder">Check Pending</a>
</div>
   	<div class="col-md-6">
<input type="submit" id="print"  accesskey="p" class="btn btn-primary"  name="print"onclick="printDiv('printableArea')" value="print receipt!" />
</form></div></div>
							</div> 
						 
						 

				
            	</div>
            </div>
				<div class="table-responsive">
			<div id="printableArea" style="width:100%;margin:0" >
<table    width="100%" >
						<thead>
						<tr>
								
		<td colspan="6"><center><b>
       	<center>		<span id="extratitle"> MPESA  RECEIPTS	</span>		</center>			

								</b></center></td>
								
								
							</tr>
							<tr>
								
								<td colspan="6"><center>
								
								
										<?php $bussinessname=$configuration[0]['businessname']; if(isset($bussinessname)) {
										echo   $bussinessname;
										}?>

								</center></td>
								
								
							</tr>
									<tr>
																<td ><b  id="mytitle">RECEIPT NO:<?php  echo$viewreceipt[0]['id'];?><b></td>

						
								
								<td ><b  id="mytitle">AMOUNT:<?php  echo$viewreceipt[0]['amount'];?><b></td>
				
								
								
								
							</tr>
							<tr>
								
									<td colspan="6" id="mytitle"><h4 style="padding:0; margin:0"><b> DATE: <?php  $myypostedtime= $viewreceipt[0]['sent_dt']; echo date("d/m/Y", strtotime($myypostedtime));    echo ";  TIME:" ;?> <?php echo date("H:i:a", strtotime($myypostedtime)) ;?>
									</h4></td>
								
							</tr>
						
							
							
							</table>
								

							
								<div class="invoice-box">
													<table border="1" class="height2" height="100%" id="mytitle" style="width:100%;">

							
							<tr >
							<td  id="mytitle"><b>AMOUNT</b></td>
	 <td  id="mytitle" ><b>CODE</B> </td>	
			 <td  id="mytitle"><b>NAME </b> </td>				
	
							</tr>
									
										 
												
				<tr   valign="top">
											
	


		<td  id="mytitle"><b><?php echo $viewreceipt[0]['amount']; ?></b></td>
	<td  id="mytitle"><b><?php echo $viewreceipt[0]['code']; ?></b></td>
	
	<td  id="mytitle"><b><?php echo $viewreceipt[0]['firstname']." ".$viewreceipt[0]['lastname']; ?></b></td>
						
									
											</tr>
									

    
		
			  
			  
				
								
								<tr>
							
								
								<td colspan="4"> 

								
								
							<span class="pull-left">
															
							Name:-----------------------------								Signature:----------------------
											</span>

							
							
							</td>
							
							</tr>
							
							

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






















