<?php
session_start();

if($_SESSION['dbName']==""){
	header("location:../index.php");
}

function salarygrid($staffcode, $connection){
	echo "<table border='0' cellpadding='3' cellspacing='0' align='left' valign='center' width='590px'>
		<col width='40px'>
		<col width='150px'>
		<col width='120px'>
		<col width='120px'>
		<col width='120px'>
		<col width='40px'>";
		
	$querysal = "select AUTO_INC, Description, date_format(date_value,'%d-%m-%Y'),date_format(Todate,'%d-%m-%Y'), Amount from staff_salary where EmployeeID = '$staffcode' ";
	$ressal = mysql_query ($querysal, $connection);
	$i=0;
	while($rwsal = mysql_fetch_array($ressal)){
		$salary_id			= $rwsal[0];
		$sal_desc[$i] 		= $rwsal[1];
		$sal_startdate[$i] 	= $rwsal[2];
		$sal_enddate[$i] 	= $rwsal[3];
		$sal_amount[$i] 	= $rwsal[4];
		
		echo"<tr>
			<td><input type='button' id='imgSubmit[0]' onclick=\"deleteSalary('$salary_id','$staffcode');\" title='Submit Record' style='width:20px; height:20px; vertical-align:bottom; cursor:pointer; outline:none; border:0px; background-image:url(img/undo-1.png)'></td>
			<td align='center'><input type='text' name='sal_desc[$i]' id='sal_desc[$i]' value='$sal_desc[$i]' style='width:145px;'></td>
			<td align='center'><input type='text' name='sal_startdate$i' id='sal_startdate[$i]' value='$sal_startdate[$i]' style='width:90px;'>
						<a href='#' onclick=\"displayCalendar(document.form.sal_startdate$i,'dd-mm-yyyy',this); return false;\" name='anchor1' id='anchor1'>
						<img src='./img/cal.gif' border='0' align='center'></a></td>
			<td align='center'><input type='text' name='sal_enddate$i' id='sal_enddate[$i]' value='$sal_enddate[$i]' style='width:90px;'>
						<a href='#' onclick=\"displayCalendar(document.form.sal_enddate$i,'dd-mm-yyyy',this); return false;\" name='anchor1' id='anchor1'>
						<img src='./img/cal.gif' border='0' align='center'></a></td>
			<td align='center'><input type='text' name='sal_amount[$i]' id='sal_amount[$i]' value='$sal_amount[$i]' style='width:115px;'></td>
			<td><input type='button' id='imgSubmit[0]' onclick=\"submitSalary('$i', '$salary_id','$staffcode');\" title='Submit Record' style='width:20px; height:20px; vertical-align:bottom; cursor:pointer; outline:none; border:0px; background-image:url(img/confirm-1.png)'></td>		
			</tr>";
		
		$i++;
	}
	
	echo"<tr>
			<td></td>
			<td align='center'><input type='text' name='sal_desc[$i]' id='sal_desc[$i]' value='$sal_desc[$i]' style='width:145px;'></td>
			<td align='center'><input type='text' name='sal_startdate$i' id='sal_startdate[$i]' value='$sal_startdate[$i]' style='width:90px;'>
						<a href='#' onclick=\"displayCalendar(document.form.sal_startdate$i,'dd-mm-yyyy',this); return false;\" name='anchor1' id='anchor1'>
						<img src='./img/cal.gif' border='0' align='center'></a></td>
			<td align='center'><input type='text' name='sal_enddate$i' id='sal_enddate[$i]' value='$sal_enddate[$i]' style='width:90px;'>
						<a href='#' onclick=\"displayCalendar(document.form.sal_enddate$i,'dd-mm-yyyy',this); return false;\" name='anchor1' id='anchor1'>
						<img src='./img/cal.gif' border='0' align='center'></a></td>
			<td align='center'><input type='text' name='sal_amount[$i]' id='sal_amount[$i]' value='$sal_amount[$i]' style='width:115px;'></td>
			<td><input type='button' id='imgSubmit[0]' onclick=\"submitSalary('$i', '','$staffcode');\" title='Submit Record' style='width:20px; height:20px; vertical-align:bottom; cursor:pointer; outline:none; border:0px; background-image:url(img/confirm-1.png)'></td>		
			</tr>";
	echo "</table>";	
	
}

?>