
	<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/viewexpenses";
    }

	 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>

  <style type="text/css">
  
  

    #printable { display: none; }
#print{  	


    background-repeat: no-repeat;
	font-size;20px;
  
    width:100%; height:50px;


}

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

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


}
    @media print
    {
    	#non-printable { display: none; }
    	#printableArea { display: block; font-size:18; width:100%; }
    }
    </style>
<?PHP

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




$data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
	 
	 $data['branchid'] = $session_data['branchid'];
	 $branchid = $data['branchid'];





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

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

   $myuser=$this->usermodel->geteuser($userid);
   $myname=$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);
												 $countbranch=$this->usermodel->countbranches($companyid);
												 	$profile = $this->usermodel->populateallarray('smsconfig','id',$companyid);

$hscode=$profile[0]['hscode'];
									$photo=$profile[0]['logo'];
									$img=$profile[0]['logo'];
											$receiptlogo=$profile[0]['receiptlogo'];

					
?>
 
 <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(); ?>user/viewexpenses">Go back to expenses </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%" >
						<table  class="table table-bordered" border="0" width="100%">
						<thead>
					
						<?php
//if(($receiptlogo=="yes") ||($receiptlogo=="yesbranch")) {
?>
								<tr>
								

					<td COLSPAN="6">
					<center>


			<?php
			
$img1='uploads/';
	//$url = base_url().$img1.$img;
	
	if($receiptlogo=="yesbranch") {
					 $allbranches= $this->usermodel->populateallarray('branch','id',$branchid);
					$branchlogo=$allbranches[0]['logo']; 
											
				
					$url = base_url().$img1.$branchlogo;

			}else{
									$url = base_url().$img1.$img;


			}


	
if($photo!=""){
	
	?>
	
 <div>
<img class="img-circle" src="<?php echo $url ?>" height="150" width="200" style="border-radius:4px;margin:0px  ">		 

</div>
<?php
 
 }
 ?>
		
						</center>	
						</td>
					
				
				</TR>
					<?php
//}

						?>
					<TR>	
									
								<td colspan="6"><center>
								
								<span id="mytitle"><b>EXPENSE VOUCHER </br></b>	</span>	
								
								
										<?php 
										 if( $countbranch > 1){
										 $mybranches= $this->usermodel->populateallarray('branch','id',$branchid);
										$branchdescription=$mybranches[0]['description']; if(isset($branchdescription)) {
											
											//
											echo   strtoupper($branchdescription); }


										}else{
									$bussinessname=$configuration[0]['businessname']; if(isset($bussinessname)) {echo   $bussinessname; }
 
											 
										 }
										?>
										
											<?php $mypin= $configuration[0]['address']; 
if(	 $mypin!=""){
?>
			 <?php echo"<b> COMPANY PIN : &nbsp;&nbsp;&nbsp;&nbsp;        ". $mypin."</b>"; ?>

 
<?php
};			 
				 

?>
	

								</center></td>
								
								
							</tr>
									
						
						
						
						
						
						
						
						
						
						
						
						
						
						
						
						
						
						
						
						
						
						<tr>
						
						<td>
						<H3>PAYMENT TO:</H3>
							<p>
<?php 
						
						
						
						$customer=$viewexpenses[0]['supplier'];
							$mysupplier=$this->usermodel->populateallarray('people','id', $customer);
						$alldetais="";
														
														
					
					
						 
						 if($mysupplier[0]['company']!=""){
							 $alldetais.= $mysupplier[0]['company']."<br>";
						 }
						  if($mysupplier[0]['firstname']!=""){
							 $alldetais.= $mysupplier[0]['firstname']." ". $mysupplier[0]['surname']."<br>";
						 }
						  if($mysupplier[0]['idno']!=""){
							 $alldetais.= $mysupplier[0]['idno']."<br>";
						 }
						    if($mysupplier[0]['idnumber']!=""){
							 $alldetais.= $mysupplier[0]['idnumber']."<br>";
						 }
						  if($mysupplier[0]['phone']!=""){
							 $alldetais.= $mysupplier[0]['phone']."<br>";
						 } if($mysupplier[0]['email']!=""){
							 $alldetais.= $mysupplier[0]['email']."<br>";
						 }
						  if($mysupplier[0]['website']!=""){
							// $alldetais= $mysupplier[0]['website']."<br>";
						 }
						  if($mysupplier[0]['zip']!=""){
							// $alldetais.= $mysupplier[0]['zip']."<br>";
						 }
						   if($mysupplier[0]['code']!=""){
							 $alldetais.= $mysupplier[0]['code']."<br>";
						 }
						 
						  if($mysupplier[0]['city']!=""){
							 $alldetais.= $mysupplier[0]['city']."<br>";
						 }
						
						  if($mysupplier[0]['comments']!=""){
							 $alldetais.= $mysupplier[0]['comments']."<br>";
						 }
						 
						
						 	
													echo "<br>".$alldetais;	
						
						
						
						
						
						
						
						
						
						
							 
						 
							?>						
							</p>

						</td>
						<td colspan="2">
					
						<H3>
						EXPENSE NO:<?php echo$viewexpenses[0]['id'];?><BR>

						 DATE CREATED:<?php echo$viewexpenses[0]['dateposted'];?><BR>

						REF NO:<?php $invoiceid; if(isset($invoiceid)) {echo   $invoiceid; }?><BR></H3>
						
						
						
						
						
						
						</td>
						
						
						
						
						
							</tr>
								
						
							<tr>
							


<td><b>Item Name/ Account</b></td>
	<td><b>Description</b></td>

							
							
<td><b>Total Amount</b></td>
							</tr>
						</thead>
							<?php
					
 $totalcost=0;
  $totalvatcost=0;
  $totalexemptedcost=0;
    $mytotalcost=0;
 if(!is_array($viewstatement)) 

 {


   echo "<tr  style='margin-bottom:0px;margin-top:0px;' '>";
      echo "<td colspan='5'>";
    
    echo "</td>";
   echo "</tr>";
    }else {


   $totaltax=0;
  	foreach ($viewstatement as $row): 

		 

             ?>
				            
									
										 
												
											<tr>
											
			
	 <td>
		<b>										 
	<?php 
					// $branch="";
					 $myaccount=$row->account;

					 $account= $this->usermodel->populateall('glaccounts','number',$myaccount);



if(is_array($account)) {

   foreach($account as $accountrow){

   echo $accountrow->accountname;
 
 
}} else {
    echo 'No Name.';
}
	
?>
		</b>										 
	 </td>	

<td><b><?php echo $row->description ;?></b><BR></td>
									
										 
											 	 <td><b><?php echo $row->amount ; 
												 $mytotalcost=$mytotalcost+$row->amount ;
												
												 
												

												 ?></b></td>
											</tr>
										<?php endforeach;} ?>
						<?php
					

 if(!is_array($viewsales)) 

 {


   echo "<tr  style='margin-bottom:0px;margin-top:0px;' '>";
      echo "<td colspan='5'>";
    
    echo "</td>";
   echo "</tr>";
    }else {
 $totalcost=0;
  $totalvatcost=0;
  $totalexemptedcost=0;
   $totaltax=0;
  	foreach ($viewsales as $c): 

		 

             ?>
				                    <tbody>
									
										 
												
											<tr>
											
			
	
													    <td><?php ; 
	 $receiptdescription=$configuration[0]['receiptdescription'];
   $customer=$c->code;
   if($customer!=""){
	  
      $productname = $this->usermodel->geteproductbyid($customer);
  
     echo$name=$productname[0]['name']; if($receiptdescription=="yes"){ echo"-".$description=$productname[0]['description'];}

	
   }else{
	    echo "No Product";  
   }
  
  
  ?></td>

<td><?php echo $c->description ;?><BR></td>
									
										 
											 	 <td><?php echo $c->amount ; 
												 $totalcost=$totalcost+$c->amount; ;
												
												 ?></td>
											</tr>
										<?php endforeach;} ?>

          
			  
							
							
							
						
							
							
							
							
								<tr>
									<td   colspan="2">Memo/Note: <br>
								<?php echo$viewexpenses[0]['description'];
								?>
								
								
								
								</td>
								
								<td colspan="2"> 

								
								
							<H3 class="pull-left">Total Money Spent:
															<?php  if(isset($totalcost)) {echo   formatMoney($totalcost+$mytotalcost, true); }else{ echo formatMoney($mytotalcost, true);}?></br>
															
											</H3>

							
							
							</td>
							
							</tr>
							<tr>
<td colspan="3"	>
</br>
Authorized by: Name:-------------------------------------------------------------------------------------------</br></br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Signature:-------------------------------------------------------------------------------------


						</td>
									
							</tr>
							
							
				
									</tbody>
									
									
					</table>
	
					
					
					
					
				</div>
			</div>
			</div>
		</div>
  
  </div>
 </div>
 </div> 
			
			
		
			<script type="text/javascript">


$(window).load(function()
{
	 if( window.print()) {
         window.location.href = "../user/allinvoices";
 }else{
	  //       window.location.href = "../user/allinvoices";
 
 }
});
</script>	


















