<?php

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
include('includes/session.inc');
$Title = _('Print Timesheet for GFS');
include('includes/SQL_CommonFunctions.inc');
 
include('includes/newheader.php');
if (isset($_GET['id'])) {
		$_SESSION['id'] = stripslashes($_GET['id']);
	}
	$id = $_SESSION['id'];


$printdate = date("d-m-Y");



		
	

				$SQL = "SELECT  payrun_details.*
								
									
		                            FROM payrun_details 
									INNER JOIN payrun_details_extra
									on payrun_details.payid = payrun_details_extra.payid
									
		                            WHERE payrun_details.id = '" . $id."'
									AND payrun_details_extra.name = 27
									
									
									";

$result=DB_query($SQL);

	
		while ($myrow50=DB_fetch_array($result)){

		
			$SQL1 = "SELECT sum(amount) as totalfixed
								
									
		                            FROM payrun_details_extra 
									
		                            WHERE payid = '" . $myrow50['payid']."'
									
									
									
									";

			$result1=DB_query($SQL1);

	
			while ($myrow501=DB_fetch_array($result1)){
		
		
							$netpay = ($myrow50['totalgross_amount'] + $myrow50['meal_allowance'] + $myrow50['other_allowances_nonfnpf']+ $myrow50['stay_away'] - $myrow50['income_tax_to_withhold'] - $myrow50['employee_fnpf'] -$myrow501['totalfixed']-$myrow50['other_deductions']);
			
			
			
			
		$SQL2 = "UPDATE payrun_details set fixed_deductions = '" . $myrow501['totalfixed']."',
											net_pay = '" . $netpay."'
								
									
		                            WHERE payid = '" . $myrow50['payid']."'
									
									
									
									";

			$result2=DB_query($SQL2);
				
				
				
				
			}
			
			
			

	
	} //end while





//ob_end_clean();
	 //its not an email just print the invoice to PDF
	//	$pdf->OutputD('PaySlip-Period_' . $id. '.pdf');

		

		
			
	
	
				
		
		
		
			    
		
	
//echo 'Quotation Created Successfully'. $jobno.'!';




//echo 'Quotation Created Successfully'. $jobno.'!';
echo '</div>';
echo '</div>';

//include('includes/footer.inc'); 

?>

