

<script type="text/javascript">

	 $(document).on("click", "#managebtndelete", function()
        {
          var itemid = $(this).data('id');
		  $("#itemid1").val(itemid); 
		  
		  
		   
        });






     $(document).on("click", "#managebtn", function()
        {
			
		     var taskid = $(this).data('id');
		  $("#taskid1").val(taskid);  	
          var taskowner = $(this).data('taskowner');
		  $("#taskowner1").val(taskowner); 
		  
		    var subject = $(this).data('subject');
		   $("#subject1").val(subject); 
		   
		     var comments = $(this).data('comments');
		   $("#comments1").val(comments); 
		 
		     var status = $(this).data('status');
		   $("#status1").val(status);


		     var fromdate = $(this).data('fromdate');
		   $("#fromdate1").val(fromdate); 

		     var todate = $(this).data('todate');
		   $("#todate1").val(todate); 		   
		   
        });
		
		
	   $(document).on("click", "#editbtn", function()
        {
     	
		     var description = $(this).data('description');
		   $("#description1").val(description); 
		 
		     var subject = $(this).data('subject');
		   $("#subject1").val(subject);


		  
        });
		
	  $(document).on("click", "#viewbtn", function()
        {
     	     var taskid = $(this).data('id');
		  $("#taskid2").val(taskid);  	
          var taskowner = $(this).data('taskowner');
		  $("#taskowner2").val(taskowner); 
		  
		    var subject = $(this).data('subject');
		   $("#subject2").val(subject); 
		   
		     var comments = $(this).data('comments');
		   $("#comments2").val(comments); 
		 
		     var status = $(this).data('status');
		   $("#status2").val(status);


		     var fromdate = $(this).data('fromdate');
		   $("#fromdate2").val(fromdate); 

		     var todate = $(this).data('todate');
		   $("#todate2").val(todate); 		
	
		   
 var 	category = $(this).data('category');
		   $("#category2").val(category); 		
 var contact = $(this).data('contact');
		   $("#contact2").val(contact); 		
 var controller = $(this).data('controller');
		   $("#controller2").val(controller); 		
 var priority = $(this).data('priority');
		   $("#priority2").val(priority); 	

 var notification = $(this).data('notification');
		   $("#notification2").val(notification);
		   
		    var repeated = $(this).data('repeated');
		   $("#repeated2").val(repeated);
		   
		   
		  
        });
		
    </script>
 
 <div class="row">
  
   		<a class="btn btn-default" href="<?php echo base_url(); ?>user/salaryhistory"> Go back </a>


   	<div class="col-md-12">
	<?PHP
				$session_data = $this->session->userdata('logged_in');

    $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'];	
 echo $this->session->flashdata('deletemsg'); 

				
					 
	    $addcomplain=$this->usermodel->populatuserpermissionsdataarray('complain','add',$userid);

	 $updatecomplain=$this->usermodel->populatuserpermissionsdataarray('complain','update',$userid);
  $deletecomplain=$this->usermodel->populatuserpermissionsdataarray('complain','delete',$userid);
	 
			    $viewcomplain=$this->usermodel->populatuserpermissionsdataarray('complain','view',$userid);
			    $readallcomplain=$this->usermodel->populatuserpermissionsdataarray('sales','allcompalin',$userid);
				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;
					}
				
	   
								?>	
  

				 
			
			<div class="panel-body">

			
			 <table cellpadding="0" cellspacing="0" border="1"id="sortable" style="width:100%;"  >

             <thead>
			  <?php
			 
			 if(isset($configuration[0]['businessname'])) {
				 ?>
				 
				 	 <tr>
								
								<td colspan="21" >
								<center  >
								
						KENYA REVENUE AUTHORITY<BR>
						INCOME TAX DEPARTMENT<BR>
						INCOME TAX DEDUCTION CARD YEAR <?PHP echo $salaryyear ?><BR>
									</center></td>
								
								
							</tr>
								<tr>
								
								
								<center  >
									<td colspan="10" >
									<B>
					<?php echo"Name: ". $people[0]['firstname']. "  ".$people[0]['surname'] ; ?>.<BR>
						<?php echo"Emp NO: ". $people[0]['number'] ; ?>.<BR>
						<?php echo"ID NO: ". $people[0]['idno'] ; ?>.<BR>

						<?php echo"Email: ". $people[0]['email'] ; ?>.<BR>
						<?php echo"Phone NO: ". $people[0]['phone'] ; ?>.<BR>

						<?php echo"KRA PIN: ". $people[0]['kra'] ; ?>.<BR>

</B>
									</td>
							<td colspan="10" >
					<?php echo $configuration[0]['description'] ; ?>.<BR>

									</td>
								</center>
								
								
							</tr>
							<?php
			 }
							?>
			 
			 
         <tr>
		        <th>Month</th>

   

  

    <th>Basic <br>Salary</th>
			   <th>Other <br>payments</th> 

		 <th>Gross <br>Salary</th> 
		 
		 				   <th>PAYE</th> 
		 				   <th>NSSF</th> 
						   <th>NHF</th> 
						   <th>Advance</th> 
						   <th>Loan</th> 
						   <th>Helb<br>
						   /sacco</th> 
						   <th>Damages</th> 



				   <th>TT Ded</th> 
				   				   <th>Net Salary</th> 


				   <th>Method</th> 
				   <th>Bank Name</th> 
				   <th>Bank Acc</th> 

				   <th>Payment</th> 





                 </tr>
             </thead><tbody>
<?php

 if(!is_array($viewemployee)) 

 {


   echo "<tr  style='margin-bottom:0px;margin-top:0px;' '>";
      echo "<td colspan='18'>";
    
       echo '<div class="alert alert-warning text-center">There no records found..</div>';
    echo "</td>";
   echo "</tr>";
    }else {
?>
    
             <?php
$i=0;			 
  $ttpay=0;
$ttsalary=0;
$ttdeductions=0;
$ttgrosssalary=0;
$ttbonus=0;
 $ttnetsalry=0;
 $PAYE=0; 
		 				   $NSSF=0; 
						   $NHF=0; 
						   $Advance=0; 
						   $Loan=0; 
						   $sacco=0; 
						   $Damages=0; 
  	foreach ($viewemployee as $c): 

		 

             ?>



             <tr>
                
            <?php 
$id=$c->id;
$i++;	

?>

       <td><?php echo $c->slarymonth ; ?></td>         

 

	  

	  
	  
	  
	  
	  <td><?php echo $c->mysalary ; ?></td>
	  	  <td><?php echo $c->pay ; ?></td>

	  						  		  	  <td><?php echo $c->gross ; ?></td>
 <th>
 <?php 
 		$payeconfig = $this->usermodel->populatealldatanorraythree('employeepayments','salaryid', $c->salaryid ,'code',"8",'companyid', $companyid);
	echo$mypaye=$payeconfig[0]['amount'];
	$PAYE=$PAYE+$mypaye;
	
	
 ?>
 
 </th> 
		 				   <th>
						    <?php 
 		$nssfconfig = $this->usermodel->populatealldatanorraythree('employeepayments','salaryid', $c->salaryid ,'code',"9",'companyid', $companyid);
	echo$myNSSF=$nssfconfig[0]['amount'];
	$NSSF=$NSSF+$myNSSF;
	
	
 ?>
 
						   
						   </th> 
						   <th>
						   
						     <?php 
 		$nhifconfig = $this->usermodel->populatealldatanorraythree('employeepayments','salaryid', $c->salaryid ,'code',"10",'companyid', $companyid);
	echo$myNHF=$nhifconfig[0]['amount'];
	$NHF=$NHF+$myNHF;
	
 ?>
						   </th> 
						   <th>
						    <?php 
 		$advanceconfig = $this->usermodel->populatealldatanorraythree('employeepayments','salaryid', $c->salaryid ,'code',"11",'companyid', $companyid);
	echo$myAdvance=$advanceconfig[0]['amount'];
	$Advance=$Advance+$myAdvance;
	
 ?>
						   </th> 
						   <th>
						    <?php 
 		$loanconfig = $this->usermodel->populatealldatanorraythree('employeepayments','salaryid', $c->salaryid ,'code',"12",'companyid', $companyid);
	echo$myLoan=$loanconfig[0]['amount'];
	
	$Loan=$Loan+$myLoan;
	
 ?>
						   
						   </th> 
						   <th>
						    <?php 
 		$saccosconfig = $this->usermodel->populatealldatanorraythree('employeepayments','salaryid', $c->salaryid ,'code',"16",'companyid', $companyid);
	echo$mysacco=$saccosconfig[0]['amount'];
	
	$sacco=$sacco+$mysacco;
 ?>
						   
						   
						   </th> 
						   <th>
						   <?php 
 		$damegesconfig = $this->usermodel->populatealldatanorraythree('employeepayments','salaryid', $c->salaryid ,'code',"14",'companyid', $companyid);
	echo$myDamages=$damegesconfig[0]['amount'];
	$Damages=$Damages+$myDamages; 

 ?>
						   
						   
						   </th>
	  	  <td><?php echo $c->deductions ; ?>
		  	<?php  $c->bonus ; 
			  
$ttsalary=$ttsalary+$c->mysalary;
$ttdeductions=$ttdeductions+$c->deductions;
$ttpay=$ttpay+$c->pay;
$ttgrosssalary=$ttgrosssalary+$c->gross;
$ttbonus=$ttbonus+$c->bonus;
		$ttnetsalry=$ttnetsalry+$c->netsalry;	  
			  
			  ?></td>
		
			  
			  		  	  <td><?php echo $c->netsalry ; ?></td>

						  

 <td><?php 
 	$methodename = $this->usermodel->populateallarray('paymentmethodes','id',$c->method);
		echo $methodename[0]["name"];
 
 ?></td>
  <td><?php echo $c->bankname ; ?></td>
   <td><?php echo $c->bankaccount ; ?></td>
     	  <td><?php echo $c->slarymonth ; ?></td>
  
             </tr>

	<?php endforeach;} ?>

            		<tr border="1" background="green">
									<td><center><b>Expected  Amount:
		<?php if(isset($total)) {echo formatMoney($total, true);  }?><b></center></td>

		<td>  <b><?php if(isset($ttsalary)) {echo formatMoney($ttsalary, true);  }?><b></td>
						
			<td>  <b><?php if(isset($ttpay)) {echo formatMoney($ttpay, true);  }?><b></td>

						<td>  <b><?php if(isset($ttgrosssalary)) {echo formatMoney($ttgrosssalary, true);  }?><b></td>
<td>  <b><?php if(isset($PAYE)) {echo formatMoney($PAYE, true);  }?><b></td>
						<td>  <b><?php if(isset($NSSF)) {echo formatMoney($NSSF, true);  }?><b></td>
						<td>  <b><?php if(isset($NHF)) {echo formatMoney($NHF, true);  }?><b></td>
						<td>  <b><?php if(isset($Advance)) {echo formatMoney($Advance, true);  }?><b></td>
						<td>  <b><?php if(isset($Loan)) {echo formatMoney($Loan, true);  }?><b></td>
						<td>  <b><?php if(isset($sacco)) {echo formatMoney($sacco, true);  }?><b></td>
						<td>  <b><?php if(isset($Damages)) {echo formatMoney($Damages, true);  }?><b></td>

			

			
			
			
			<td>  <b><?php if(isset($ttdeductions)) {echo formatMoney($ttdeductions, true);  }?><b></td>

	<td>  <b><?php if(isset($ttnetsalry)) {echo formatMoney($ttnetsalry, true);  }?><b></td>

	
	<td id="non-printable"  colspan="6"></td>
</tr>

       <tbody> </table>
	
									
				

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

 
</div>










	
					
  </div>
			
			
			
		
		
  

 
</div>


















