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

	 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;

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

	 if( window.print()) {
         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;


}

#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['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);

					
?>
 
 <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/viewsales">Add New Sales </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>
						<tr>
						<td colspan="4">
						<center> JOURNAL ENTRY VOUCHER</center>
						</td>
						</tr>
						<tr>
						<td colspan="2">
						<p>
						<?php $description=$configuration[0]['businessname']; if(isset($description)) {echo   $description; }?>
						</p>
						</td>
						<td colspan="2">
<?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'];	

								$profile = $this->usermodel->populateall('smsconfig','id',$companyid);

	
		if(!is_array($profile)) 

 {
	 $this->session->set_flashdata('msg', '<div class="alert alert-danger fade in">
						 <a href="#" class="close" data-dismiss="alert">&times;</a><strong>Error!</strong>Upload photo</div>');
							

    }else {

    
          
  	foreach ($profile as $c): 
$photo= $c->logo;
		 	if($photo!=""){
		 
		 
		
		
	
			
		
		$img=$c->logo;
	
		$img1='uploads/';
	$url = base_url().$img1.$img;

 
 ?>
 <div >
<img class="img-circle" src="<?php echo $url ?>" height="100" width="100" style="border-radius:4px;  ">		 

</div>



	 <?php }else{
		 ?>

				<?php
	 }
		 endforeach; ?>

              <?php }?>
						
						
						
						
						
						
						
						</td>
						
						</tr>
						
						
						
						
								<tr>
							


<td><b> JOURNAL NO </b></td>
	<td><b> JOURNAL REF NO</b></td>

	<td><b>  JOURNAL CREATED</b></td>						
							
<td><b>CURRENCY</b></td>
							</tr>
						
												<tr>
							


<td><?php echo$viewreceipt[0]['id'];?></td>
	<td><?php $invoiceid; if(isset($invoiceid)) {echo   $invoiceid; }?></td>

	<td><?php echo$viewreceipt[0]['entrydate'];?></td>						
							
<td><?php 
					 $currencyid= $viewreceipt[0]['currency'];
						 		$currency= $this->usermodel->populateall('currency','id',$currencyid);

					 if(is_array($currency)) {

   foreach($currency as $currencyrow){
 echo$currencyrow->name; 

}} else {


}	 ?></td>
							</tr>
						
						
						
						
						
						
						
							<tr>
							


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

	<td><b> Debit</b></td>						
							
<td><b>Credit</b></td>
							</tr>
						</thead>
							<?php
					

 $finaltotaldebits=0;
   $finaltotalcredits=0;
 if(!is_array($viewstatement)) 

 {


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



  	foreach ($viewstatement as $row): 

		$finaltotaldebits=$finaltotaldebits+$row->debit;
$finaltotalcredits=$finaltotalcredits+$row->credit; 

             ?>
				            
									
										 
												
											<tr>
											
			
	 <td>
												 
	<?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.';
}
	
?>
												 
	 </td>	
<td><?php echo $row->description ;?><BR></td>
<td><?php echo $row->debit ;?><BR></td>
			<td><?php echo $row->credit ;?><BR></td>
						
										 
											 
											</tr>
										<?php endforeach;} ?>
						
						
          
			  
							
							
							
						
							
							
							
							
							<tr>
							<td>
			Description :<?php echo$viewreceipt[0]['description'];?><BR>
		
				</td>
			<td><h3 style="padding:0; margin:0;">
			TOTAL :
			</h3>
				</td>
			
			<td><h3 style="padding:0; margin:0;">Debit:<?php if(isset($finaltotaldebits)) {echo formatMoney($finaltotaldebits, true); }?></h3></td>
			<td><h3 style="padding:0; margin:0;">Credit:<?php if(isset($finaltotalcredits)) {echo formatMoney($finaltotalcredits, true); }?></h3>
			
			<br>
			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/viewjournalentry";
 }else{
	  //       window.location.href = "../user/paybill";
 
 }
});
</script>	
