<?php

session_start();
header("Content-type: text/html; charset=".$_SESSION['encodingmode']);
if($_SESSION['dbName']==""){
header("location:../index.php");
}

include("config.inc.php");
include("staf_function.php");

$connection = mysql_connect($config['dbServer'],$config['dbUser'],$config['dbPass']) or die("Could not connect to DB");
mysql_select_db($_SESSION['dbName'],$connection) or die("Could not find DB");

if(	$_SESSION['encodingmode'] == 'utf8' || $_SESSION['encodingmode'] == 'utf-8'){
	mysql_query("SET NAMES 'utf8'"); 
	mysql_query('SET CHARACTER SET utf8'); 
	mysql_set_charset('utf8', $connection);
}


$querylog="SELECT ifnull(ShowBankInfo,0) as ShowBankInfo, ifnull(ShowInsuranceInfo,0) as ShowInsuranceInfo, ifnull(ShowSalaryInfo,0) as ShowSalaryInfo from ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['useraccount']."' 	and Upper(Login_Schema) = Upper('".$_SESSION['dbName']."')	";
$resultlog=mysql_query($querylog,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($resultlog)){
	extract($rows);
}


class tabs {
	var $name;
	var $tabs;
	var $active;
	var $current;
function start($name){
		if (empty($this->active)){ $this->active = $name; }
		$this->current = $name;
		ob_start();
	}
	function end(){
		$this->tabs[$this->current] = ob_get_contents();
		ob_end_clean();
	}
	function run(){
	
		if (count($this->tabs) > 0){
			echo "<DIV CLASS='tabs'>\n";
			$jsClear = "";
			foreach($this->tabs as $tabname => $tabcontent){
				$tabid = "tab_".$this->name."_$tabname";
				$contentid = "tabcontent_".$this->name."_$tabname";
				$jsClear .= "\tdocument.getElementById('$tabid').className = 'tab_inactive';\n";
				$jsClear .= "\tdocument.getElementById('$contentid').style.display = 'none';\n";
			}
			echo "<script type=\"text/javascript\">\n";
			echo "function tab_".$this->name."(id,fieldname){\n";
			
			
			
			echo "$jsClear";
			echo "\tdocument.getElementById('tab_".$this->name."_'+id).className = 'tab_active';\n";
			echo "\tdocument.getElementById('tabcontent_".$this->name."_'+id).style.display = '';\n";
			echo"	
				//alert(fieldname);
				if(fieldname!='' && fieldname!=undefined)
					
					document.items[fieldname].focus();
				";
			echo "}\n";
			echo "</script>\n";
			foreach($this->tabs as $tabname => $tabcontent){
				$tabid = "tab_".$this->name."_$tabname";
				$contentid = "tabcontent_".$this->name."_$tabname";
				echo "<DIV CLASS='";
				if ($this->active == $tabname){ echo "tab_active"; }else{ echo "tab_inactive"; }
				echo "' ID='$tabid' ";
				echo "onClick=\"tab_".$this->name."('$tabname');\">$tabname</DIV>\n";
			}
			echo "<DIV STYLE='float: center; clear:both;'></DIV>\n";
			foreach($this->tabs as $tabname => $tabcontent){
				$contentid = "tabcontent_".$this->name."_$tabname";
				echo "<DIV ID = '$contentid' CLASS='tab_content' STYLE='display: ";
				if ($this->active == $tabname){ echo "block"; }else{ echo "none"; }
				echo ";'>$tabcontent</DIV>\n";
			}
			echo "</DIV>\n";
			echo "<DIV STYLE='clear: both;'></DIV>\n";
		}}
}	

if ($famPackage == '') $famPackage = 0;
print <<<HERE

<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<link rel="stylesheet" type="text/css" media="all" href="css-v2/style.css">
<LINK REL="stylesheet" TYPE="text/css" MEDIA="all" HREF="css/tabs.css">
<title>Add staff</title>

<script type="text/javascript" language="javascript">
function searchforstaff()
		{
    win = window.open('Form_StaffSearch.php', 'Form_staffSearch', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=750,height=550,top=100,left=100');		
				
}

function submitInfo(staff_code){
	if(staff_code == '')
		actionmode = 'insert';
	else if(staff_code != '')
		actionmode = 'edit';
	document.form.action = "staff_action.php?actionmode="+actionmode+"&staffcode="+staff_code;
	document.form.submit();
}

function clearPage(){
	var x = document.form;
	x.allowance2.value			= '';
	x.staffcode.value			= '';
	x.firstname.value			= '';
	x.lastname.value 			= '';
	x.fathername.value 			= '';
	x.phone1.value				= '';
	x.phone2.value 				= '';
	x.emailadress.value 		= '';
	x.nationality.value 		= '';
	x.curentpos.value 			= '';
	x.passportnumber.value 		= '';
	x.birthdate.value 			= '';
	x.religions.value 			= '';
	x.gender.value 				= '';
	x.bloodgroup.value 			= '';
	if (x.inssurancenumber)
	x.inssurancenumber.value 	= '';
	if (x.inssurancedate)
	x.inssurancedate.value 		= '';
	if (x.inssuranceexpire)
	x.inssuranceexpire.value 	= '';
	x.passportdate.value 		= '';
	x.passportexpire.value 		= '';
	x.cardnumber.value 			= '';
	x.carddate.value 			= '';
	x.cardexpire.value 			= '';
	x.birthplace.value 			= '';
	x.visanumber.value 			= '';
	x.visadate.value 			= '';
	x.visaexpire.value 			= '';
	if (x.bankacc)
	x.bankacc.value 			= '';
	if (x.bankname)
	x.bankname.value 			= '';
	x.quotaname.value 			= '';
	x.marialstatus.value 		= '';
	x.totalchildren.value 		= '';
	if (x.salaryamount)
	x.salaryamount.value 		= '';
	x.leavedays.value 			= '';
	x.visatype.value 			= '';
	x.tempnumber.value 			= '';
	x.tempdate.value 			= '';
	x.tempexpire.value 			= '';
	x.resigned.value 			= '';
	x.resigndate.value 			= '';
	x.project.value 			= '';
	x.quotaexpire.value 		= '';
	if (x.iban)
	x.iban.value 				= '';
	if (x.sortcode)
	x.sortcode.value 			= '';
	x.company.value 			= '';
	x.fullname.value 			= '';
	if (x.bankbranch)
	x.bankbranch.value 			= '';
	if (x.allowance)
	x.allowance.value 			= '';
	if (x.accname)
	x.accname.value 			= '';
	x.aliennumber.value 		= '';
	x.aliendate.value 			= '';
	x.alienexpire.value 		= '';
	x.resignreason.value	   	= '';
	x.employedate.value			= '';
	x.famPackage.value			= '';
	ClearTicket();
	
}

function showlistProject(str){
	vProjectCode = encodeURIComponent(document.getElementById('project_code').value);
	window.open('List_SorProject.php?frm=31&item='+str+'&PProject_Code='+vProjectCode,'mywindow','width=850,height=550,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}
function setReturned(){
	if(document.getElementById("staff_returned").checked)
		document.getElementById("staff_returned").value=1;
	else document.getElementById("staff_returned").value=0;
}
function submitticket(ticket_id, staffcode){
	var x = document.form;
	if(x.staffcode.value == ''){
	  alert("Staff Code is Empty!")
	  return 0;
	} else {	
		if(ticket_id == '') mode = 'insertticket';
		else mode = 'updateticket';
		x.action='staff_action.php?mode='+mode+'&ticket_id='+ticket_id+'&staffcode='+staffcode+'&vTabFocus=Ticket';
		x.submit();
	}
	
}
function UpdateTicket(ticketid){
	document.form.ticket_id.value = ticketid;
	document.form.vTabFocus.value = 'Ticket';
	document.form.submit();
}
function DeleteTicket(ticketid, staffcode){
	
	document.form.action='staff_action.php?mode=deleteticket&ticket_id='+ticketid+'&staffcode='+staffcode+'&vTabFocus=Ticket';
	document.form.submit();
}
function ClearTicket(){
	var x = document.form;
	x.ticket_id.value='';
	x.vTabFocus.value='';
	x.staff_returned.value='';
	x.DepDate.value='';
	x.DepTime.value='';
	x.ArrivalDate.value='';
	x.Arrival_time.value='';
	x.Com_DepDate.value='';
	x.Com_depTime.value='';
	x.Com_ArrivalDate.value='';
	x.Com_ArrivalTime.value='';
	x.Airline_name.value='';
	x.project_code.value='';
	x.action = 'staff.php';
	x.submit();
}

function UploadImg(staffcode,vform){
	if(staffcode == '') staffcode = document.form.staffcode.value;
	if (staffcode == ''){
		alert('Staff Code Cannot Be Empty!');
		return 0;
	} else {
		win = window.open('UploadImages.php?vform='+vform+'&sc='+staffcode, 'Upload', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=990,height=600,top=60,left=100');		
		win.creator = self;
		win.focus();	
	}
}
function showlistProject(str){

	vProjectCode = encodeURIComponent(document.getElementById('project').value);
	window.open('List_SorProject.php?frm='+str+'&item=&PProject_Code='+vProjectCode,'mywindow','width=850,height=550,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}

function submitSalary (index, salary_id, staffcode){
	if(salary_id == '')
		var actionmode='insertsalary';
	else var actionmode='updatesalary';
	
	var v1 = 'sal_desc['+index+']';
	var v2 = 'sal_startdate['+index+']';
	var v3 = 'sal_enddate['+index+']';
	var v4 = 'sal_amount['+index+']';
	
	var sal_desc 		= encodeURIComponent(document.getElementById(v1).value);
	var sal_startdate 	= document.getElementById(v2).value;
	var sal_enddate 	= document.getElementById(v3).value;
	var sal_amount	 	= document.getElementById(v4).value;
	
	if(staffcode == ''){
		alert("Save Staff Code First!");
		return 0;
	} else if(sal_desc == ''){
		alert("Salary Description is Empty!");
		return 0;
	} else {
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			var data = xmlhttp.responseText.split("[BRK]");
			document.getElementById('salarygrid').innerHTML=data[1];
		}
	  }

  
	xmlhttp.open("GET","staff_action.php?mainmode=&actionmode="+actionmode+"&sal_desc="+sal_desc+"&sal_startdate="+sal_startdate+"&sal_enddate="+sal_enddate+"&sal_amount="+sal_amount
			+"&salary_id="+salary_id+"&staffcode="+staffcode,true);
	xmlhttp.send();
}
}

function deleteSalary(salary_id, staffcode){
if (confirm ( "Do you want to Delete this Salary?")){
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			var data = xmlhttp.responseText.split("[BRK]");
			document.getElementById('salarygrid').innerHTML=data[1];
		}
	  }

  
	xmlhttp.open("GET","staff_action.php?mainmode=&actionmode=deleteSalary&salary_id="+salary_id+"&staffcode="+staffcode,true);
	xmlhttp.send();
	}
}

function setChk(fieldid){
	if (document.getElementById(fieldid).checked)
		document.getElementById(fieldid).value = 1;
	else 
		document.getElementById(fieldid).value = 0;
}
</script>

<script type="text/javascript" src="dropdown.js"></script>

<style type="text/css">

body,td,th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 11px;
}
body {
	margin-top: 2px;
	margin-left: 1px;
}
a:link {
	text-decoration: none;
	color: #0000FF;
}
a:visited {
	text-decoration: none;
	color: #0000FF;
}
a:hover {
	text-decoration: none;
	color: #0000FF;
}
a:active {
	text-decoration: none;
	color: #0000FF;
}
.style11 {color: #999999; font-weight: bold; }
.style12 {
	font-size: 9px;
	color: #999999;
	font-weight: bold;
}
.style15 {color: #5151FF; font-size: 10px;}
.style16 {
	font-size: 16px;
	color: #FF0000;
	font-weight: bold;
	font-family: "Times New Roman", Times, serif;
}
.style17 {font-size: 9px}
.style25 {color: #999999; font-weight: bold; font-size: 10px; }
.style26 {color: #FF0000}
.style27 {color: #999999 ;font-size: 10px;}
.style28 {color: #FFFFFF ;font-size: 10px;}

</style>

<link type="text/css" rel="stylesheet" href="dhtmlgoodies_calendar.css?random=20051112" media="screen"></LINK>
<SCRIPT type="text/javascript" src="dhtmlgoodies_calendar.js?random=20060118"></script>

</head>
<body >

HERE;

	$staffcode			= $_POST['staffcode']; if($staffcode == '') $staffcode = $_GET['staffcode'];
	$firstname 			= $_POST['firstname'];
	$lastname 			= $_POST['lastname'];
	$fathername 		= $_POST['fathername'];
	$phone1 			= $_POST['phone1'];
	$phone2 			= $_POST['phone2'];
	$emailadress 		= $_POST['emailadress'];
	$nationality 		= $_POST['nationality'];
	$curentpos 			= $_POST['curentpos'];
	$passportnumber 	= $_POST['passportnumber'];
	$birthdate 			= $_POST['birthdate'];
	$religions 			= $_POST['religions'];
	$gender 			= $_POST['gender'];
	$bloodgroup 		= $_POST['bloodgroup'];
	$Staff_picture 		= $_POST['Staff_picture'];
	$inssurancenumber 	= $_POST['inssurancenumber'];
	$inssurancedate 	= $_POST['inssurancedate'];
	$inssuranceexpire 	= $_POST['inssuranceexpire'];
	$passportdate 		= $_POST['passportdate'];
	$passportexpire 	= $_POST['passportexpire'];
	$cardnumber 		= $_POST['cardnumber'];
	$carddate 			= $_POST['carddate'];
	$cardexpire 		= $_POST['cardexpire'];
	$birthplace 		= $_POST['birthplace'];
	$visanumber 		= $_POST['visanumber'];
	$visadate 			= $_POST['visadate'];
	$visaexpire 		= $_POST['visaexpire'];
	$bankacc 			= $_POST['bankacc'];
	$bankname 			= $_POST['bankname'];
	$quotaname 			= $_POST['quotaname'];
	$marialstatus 		= $_POST['marialstatus'];
	$totalchildren 		= $_POST['totalchildren'];
	$salaryamount 		= $_POST['salaryamount'];
	$leavedays 			= $_POST['leavedays'];
	$visatype 			= $_POST['visatype'];
	$tempnumber 		= $_POST['tempnumber'];
	$tempdate 			= $_POST['tempdate'];
	$tempexpire 		= $_POST['tempexpire'];
	$resigned 			= $_POST['resigned'];
	$resigndate 		= $_POST['resigndate'];
	$project 			= $_POST['project'];
	$quotaexpire 		= $_POST['quotaexpire'];
	$iban 				= $_POST['iban'];
	$sortcode 			= $_POST['sortcode'];
	$company 			= $_POST['company'];
	$fullname 			= $_POST['fullname'];
	$bankbranch 		= $_POST['bankbranch'];
	$allowance 			= $_POST['allowance'];
	$allowance2			= $_POST['allowance2'];
	$accname 			= $_POST['accname'];
	$aliennumber 		= $_POST['aliennumber'];
	$aliendate 			= $_POST['aliendate'];
	$alienexpire 		= $_POST['alienexpire'];
	$resignreason		= $_POST['resignreason'];
	
if($employedate == '') $employedate = date("d-m-Y");
if($birthdate == '') $birthdate = date("d-m-Y");


echo "<form enctype='multipart/form-data' method='post' name='form'>

<input type='hidden' name='staff_code' id='staff_code' value='$staff_code'>";
echo "<input type='hidden' name='vTabFocus' id='vTabFocus' value='$vTabFocus'>";
echo"<table cellpadding='0' cellspacing='0' border='0'  align='center' class='layout-width'>";
include_once("header.php");
echo" <tr><td  valign='top'>";

include_once("sidemenu.php");
echo"  </td></tr>";


echo" <tr style='height:26px;'>
		<td  valign='top' id='content-top'>
			<table border='0' cellpadding='0' cellspacing='0' style='table-layout:fixed; height:26px;' class='layout-width'>
			<tr style='height:26px;'>
				<td style='width:38px; height:26px;'>&nbsp;</td>
				<td valign='middle' style='width:300px; height:26px;'><span class='title'>Staff</span></td>
				<td class='message' valign='middle' style='height:26px;'>".htmlspecialchars($message, ENT_QUOTES)."</td>
			</tr></table>
		</td>
	  </tr>";

	 
	
echo"<tr><td  height='18'  valign='top' id='content-top2'>";	
echo"</td></tr>";

 
echo"<tr><td align=left  id='content-body'>";


	echo"<table border=0 align=left width=800> <tr  height='35'>";
	echo"<td align=left>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button type='button'  onclick=\"clearPage();\" title='Clear' ><span><span>Clear</span></span></button>" ;
	echo"<button type='button' name='btnEdit' id='btnEdit' value='Save' onclick=\"submitInfo('$staffcode');\" /><span><span>Save</span></span></button>";
	echo"<button name='btnSearch' type='button' id='btnSearch' value='Search' onclick='searchforstaff();' title='Search Vehicle' ";
    echo " /><span><span>Search</span></span></button>";
	echo"</td>";
	echo"  </tr></table></td></tr>";
	 
echo"<tr><td align=center id='content-body'>";
$tabs = new tabs("Staff");	
$tabs->start("Main Page");
echo"<table border=0 align='left' valign='top' ><tr><td width='50px'></td><td>";

$querysetup="select grid_color1,grid_color2,DecimalBase, DecimalBase1, DecimalBase2, base1, base2, maxperpage from setup";
$resultsetup=mysql_query($querysetup,$connection) or die(mysql_error());
if($result=mysql_fetch_array($resultsetup)){
	$grid_color1=$result[0];
	$grid_color2=$result[1];}
			
	echo "<table border='0' cellpadding='3' cellspacing='0' align='left' valign='center' width='1040px'>
		<col width='100px'>
		<col width='160px'>
		<col width='100px'>
		<col width='160px'>
		<col width='100px'>
		<col width='160px'>
		<col width='100px'>
		<col width='160px'>";

if($staffcode != ''){
$housestaff="select Staff_code, Staff_firstName, Staff_lastName, Staff_fatherName, Staff_phone1, Staff_phone2, Staff_email, 
			Staff_nationality, Staff_Jobtitle, Staff_PassportNb, date_format(Staff_Dob,'%d-%m-%Y') as Staff_Dob, Staff_religion, date_format(Staff_beginingDate,'%d-%m-%Y') as Staff_beginingDate, Staff_gender, 
			Staff_bloodgrp,	Staff_picture, Staff_InsNb, date_format(Staff_Insissuedate,'%d-%m-%Y') as Staff_Insissuedate, date_format(Staff_InsExpDate,'%d-%m-%Y') as Staff_InsExpDate, 
			date_format(Staff_passIssueDate,'%d-%m-%Y') as Staff_passIssueDate, 
			date_format(Staff_PassExpDate,'%d-%m-%Y') as Staff_PassExpDate, Staff_Rpnb, date_format(Staff_Rpissuedate,'%d-%m-%Y') as Staff_Rpissuedate, date_format(Staff_rpexpdate,'%d-%m-%Y') as Staff_rpexpdate, 
			Staff_placeofbirth, Staff_visaNo, date_format(Staff_visaIssueDate,'%d-%m-%Y') as Staff_visaIssueDate,
			date_format(Staff_visaExpDate,'%d-%m-%Y') as Staff_visaExpDate, Staff_bankAcc, Staff_bankName, Staff_quota, Staff_MaritalStatus, Staff_totalChildren, Staff_salary, Staff_leaveDays, 
			Staff_visatype, staff_TempNo, date_format(staff_TempIssueDate,'%d-%m-%Y') as staff_TempIssueDate,date_format( staff_TempExpDate,'%d-%m-%Y') as staff_TempExpDate, staff_Resigned, 
			date_format(staff_ResignedDate,'%d-%m-%Y') as staff_ResignedDate, project_code, 
			date_format(Staff_quotaExpired,'%d-%m-%Y') as Staff_quotaExpired, staff_IBAN, staff_SortCode, Staff_company, Staff_fullName, Staff_bankbranch, Staff_localallowance,
			Staff_accname, Staff_AllienNo, date_format(Staff_AllienFrom,'%d-%m-%Y') as Staff_AllienFrom, date_format(Staff_AllienTo,'%d-%m-%Y') as Staff_AllienTo,Staff_defaulAll, Staff_remark,
			ifnull(staff_familyPackage,0) as staff_familyPackage
			from staff where staff_code='$staffcode'";
		
$queryres=mysql_query($housestaff, $connection);

while($rows=mysql_fetch_array($queryres)){
		extract($rows);
	
	$staffcode			= $Staff_code;
	$firstname 			= $Staff_firstName;
	$lastname 			= $Staff_lastName;
	$fathername 		= $Staff_fatherName;
	$phone1 			= $Staff_phone1;
	$phone2 			= $Staff_phone2;
	$emailadress 		= $Staff_email;
	$nationality 		= $Staff_nationality;	
	$curentpos 			= $Staff_Jobtitle;
	$passportnumber 	= $Staff_PassportNb;
	$birthdate 			= $Staff_Dob;
	$religions 			= $Staff_religion;
	$employedate	 	= $Staff_beginingDate;
	$gender 			= $Staff_gender;
	$bloodgroup 		= $Staff_bloodgrp;
	$Staff_picture 		= $Staff_picture;
	$inssurancenumber 	= $Staff_InsNb;
	$inssurancedate 	= $Staff_Insissuedate;
	$inssuranceexpire 	= $Staff_InsExpDate;
	$passportdate 		= $Staff_passIssueDate;
	$passportexpire 	= $Staff_PassExpDate;
	$cardnumber 		= $Staff_Rpnb;
	$carddate 			= $Staff_Rpissuedate;
	$cardexpire 		= $Staff_rpexpdate;
	$birthplace 		= $Staff_placeofbirth;
	$visanumber 		= $Staff_visaNo;
	$visadate 			= $Staff_visaIssueDate;
	$visaexpire 		= $Staff_visaExpDate;
	$bankacc 			= $Staff_bankAcc;
	$bankname 			= $Staff_bankName;
	$quotaname 			= $Staff_quota;
	$marialstatus 		= $Staff_MaritalStatus; 
	$totalchildren 		= $Staff_totalChildren;
	$salaryamount 		= $Staff_salary;
	$leavedays 			= $Staff_leaveDays;
	$visatype 			= $Staff_visatype;
	$tempnumber 		= $staff_TempNo;
	$tempdate 			= $staff_TempIssueDate;
	$tempexpire 		= $staff_TempExpDate;
	$resigned 			= $staff_Resigned;
	$resigndate 		= $staff_ResignedDate;
	$project 			= $project_code;
	$quotaexpire 		= $Staff_quotaExpired;
	$iban 				= $staff_IBAN;
	$sortcode 			= $staff_SortCode;
	$company 			= $Staff_company; 
	$fullname 			= $Staff_fullName;
	$bankbranch 		= $Staff_bankbranch;
	$allowance 			= $Staff_localallowance;
	$accname 			= $Staff_accname;
	$aliennumber 		= $Staff_AllienNo;
	$aliendate 			= $Staff_AllienFrom;
	$alienexpire 		= $Staff_AllienTo;	
	$allowance2			= $Staff_defaulAll;
	$resignreason 		= $Staff_remark;
	$famPackage			= $staff_familyPackage;
}
}


$color1='#94E9E0';
if( $rowres[0]!=''){
	$read='readonly';
	$Color22 ="style='background-color:".$grid_color2."'";
		$color ="style='background-color:".$color1."'";
}
//echo "<tr height='30px'></tr>";
	echo "	<tr>
			<td ><span class='style1'>Staff code</span></td>
			<td><input type='text' name='staffcode' id='staffcode' value='$staffcode' style='width: 145px;' $read $color></td>
			<td><span class='style1'> nationality</span></td>
			<td>
			<select name='nationality'  id='nationality' style='width: 145px;' >";
			$nationalityquery="select nationality_code,nationality_name from nationality order by nationality_name";
			$resnationality=mysql_query($nationalityquery, $connection) or die(mysql_error('555'));
			while($row=mysql_fetch_array($resnationality)){
			echo "	<option value='$row[1]' ";
			if ($row[1]==$nationality) echo "selected";
			echo ">$row[1]</option>";
	}
		echo "	
		</select>
		</td>";
		echo "<td colspan='2' align='right' align=''><input type='file' name='image' style='width:200px;'>";
			echo "</td>
		<td  colspan='2' rowspan='4' align='right'><img src='photos/$staffcode/$Staff_picture' width='120px' height='100px'>";
		
		echo" </td>";
		echo "	</tr>
		<tr>
			<td><span class='style1'>First name</span></td>
			<td><input type='text' name='firstname' id='firstname' value='$firstname' style='width: 145px;'></td>
			
			<td><span class='style1'>relegions</span></td>
			<td>
				<select name='religions' id='religions' style='width: 145px;'>";
				$religionquery="select religion_code,religion_name from religion order by religion_name";
			$resreligion=mysql_query($religionquery, $connection) or die(mysql_error());
			while($religionresult=mysql_fetch_row($resreligion)){
			echo "	<option value='$religionresult[1]'";
			if ($religionresult[1]==$religions) echo "selected";
			echo ">$religionresult[1]</option>";
	}
			echo "	
				</select>
			</td><td></td><td></td><td></td><td></td>
		</tr>
		<tr>
			<td><span class='style1'>Last Name</span></td>
			<td><input type='text' name='lastname' id='lastname' value='$lastname' style='width: 145px;'></td>
			<td><span class='style1'>Employement Date</span></td>
			<td><input type='text' name='employedate' id='employedate' value='$employedate' style='width: 90px;'> 
			<a HREF='#' onClick=\"displayCalendar(document.form.employedate,'dd-mm-yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\" >";

 echo"<image src='./img/cal.gif' border=0 align=center ></image></a></td>
			<td align='left'><span class='style1'>Project</span></td>
			<td><input type='text' name='project' id='project' value='$project' style='width: 130px;'>
			<label><span class='style1'><img src='img/scroll-down-1.png' title=' Select Project ' id='assetsaccountnoimg' width='20' height='20' border='0' onMouseOver=\"style.cursor='pointer'\" onClick=\"showlistProject('37');\"  />
			</span></label></td>
			<td></td><td></td>
	</tr>
	<tr>
		<td><span class='style1'>Father Name</span></td>
		<td><input type='text' name='fathername' id='fathername'  value='$fathername' style='width: 145px;'></td>
		<td><span class='style1'>Full Name</span></td>
		<td colspan='3'><input type='text' name='fullname' id='fullname' style='width: 145px;' value='$fullname'></td>	
		<td></td><td></td>
	</tr>
	<tr>
		<td><span class='style1'>Email Adress</span></td>
		<td><input type='text' name='emailadress' id='emailadress' value='$emailadress' style='width: 145px;'></td>
		<td><span class='style1'>company</span></td>
		<td ><select name='company' id='company'  style='width: 145px;'>";
			
			$querycompany="SELECT Company_code, Company_name FROM STAFF_COMPANY order by Company_name";
			$rescompanyname=mysql_query($querycompany, $connection) or die(mysql_error());
			while($companyresult=mysql_fetch_array($rescompanyname)){
				echo "<option value='$companyresult[0]'";
				if ($companyresult[0]==$company) echo "selected";
				echo ">$companyresult[1]</option>";
				
			}
			
	echo"		</select></td>
			<td align='left'><span class='style1'>Leave Days</span></td>		
			<td ><input type='text' name='leavedays' id='leavedays' style='width: 145px;' value='$leavedays'></td>			
			<td align='right' ><span class='style1'>Blood Grp </span></td>
			<td><input type='text' name='bloodgroup' id='bloodgroup' value='$bloodgroup' style='width: 145px;'></td>			
		</tr>
		<tr>
			<td><span class='style1'>Place of Birth</span></td>
			<td><input type='text' name='birthplace' id='birthplace' value='$birthplace' style='width: 145px;'></td>
			<td><span class='style1'>Date of Birth</span></td>
			<td ><input type='text' name='birthdate' id='birthdate' size='8' value='$birthdate' style='width: 90px;'> <a HREF='#' onClick=\"displayCalendar(document.form.birthdate,'dd-mm-yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\" >";

 



 echo"<image src='./img/cal.gif' border=0 align=center ></image></a></td>
			<td align='left'><span class='style1'>Gender(M-F)</span></td>
			<td><select name='gender'  id='gender' style='width: 145px;'>
			<option value='M'"; 
				if ($companyresult[1]==$rowres[47]) echo " selected ";
			if ('M'==$gender) echo " selected " ;
			echo ">Male</option>
			<option value='F' "; 
			if ('F'==$gender)
				echo " selected " ;
			echo ">Female</option>
			
			</select></td>			
			<td align='right' ><span class='style1'>Total Children</span></td><td><input type='text' name='totalchildren' id='totalchildren' style='width: 145px;' value='$totalchildren'></td>			
		</tr>
		<tr>
			<td><span class='style1'>Foreign Phone No</span></td>
			<td><input type='text' name='phone1' id='phone1' value='$phone1' style='width: 145px;'></td>
			<td><span class='style1'>Local Phone No</span></td>
			<td ><input type='text' name='phone2' id='phone2' value='$phone2' style='width: 145px;'></td>
			
			<td align='left'><span class='style1'>Marial Status (M/S/D/W)</span></td>
			<td ><select name='marialstatus'  id='marialstatus' style='width: 145px;'>
			<option value='M'"; if ('M'==$marialstatus) echo"selected";
			echo ">Married</option>
			<option value='S'"; if ('S'==$marialstatus) echo"selected";
			echo ">Single</option>
			<option value='D'"; if ('D'==$marialstatus) echo"selected";
			echo ">Divorced</option>
			<option value='W'"; if ('W'==$marialstatus) echo"selected";
			echo ">Widowed</option>
			
			</select>
			</td>
			<td align='right'><span class='style1'>allowance</span></td>
			<td ><input type='text' name='allowance2' id='allowance2' value='$allowance2' style='width: 145px;'></td>
			
		</tr>
	
		
		<tr>
			<td><span class='style1'>Quota Position</span></td>
			<td>
			<select name='quotaname' id='quotaname' style='width: 145px;'>
			<option value=''></option>";
			if($quotaname) $quotaquery="select quota_id,quota_code,quota_name from quota order by quota_name ;";
			else $quotaquery="select quota_code,quota_name from quota where ifnull(quota_used,0) = 0 order by quota_name;";
			$quota=mysql_query($quotaquery, $connection) or die(mysql_error());
			while($quotaresult=mysql_fetch_array($quota)){
			echo "<option value='$quotaresult[0]'";
			if($quotaresult[0]==$quotaname)echo "selected";
			echo ">$quotaresult[2]</option>";
			}
			echo "</select>
			</td>
			<td><span class='style1'>Current Position</span></td>
			<td ><select name='curentpos' id='curentpos' style='width: 145px;'>";
			$selectjob ="select Job_code, Job_description from jobs";
				$job=mysql_query($selectjob, $connection) or die(mysql_error());
			while($jobaresult=mysql_fetch_row($job)){
				echo "<option value='$jobaresult[1]' ".($jobaresult[1] == $curentpos?'selected':'')." >";
				echo " $jobaresult[1]</option>";
			}
	 echo"	<td align='left'><span class='style1'>Quota Pos Expired</span></td>
			<td ><input type='text' name='quotaexpire' id='quotaexpire' value='$quotaexpire' style='width: 90px;'>
			<a HREF='#' onClick=\"displayCalendar(document.form.quotaexpire,'dd-mm-yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\" >
			<image src='./img/cal.gif' border=0 align=center ></image></a></td>
		<td><span class='style1'>Attach CV</span></td><td><img src='./img/view_file.png' height='20px' width='20px' title='View Image' onclick=\"UploadImg('$staffcode', 'CV')\"></td>	
			
		</tr>
		<tr>
			<td><span class='style1'>Resignation Date </span></td>
			<td><input type='text' name='resigndate' id='resigndate' value='$resigndate' style='width: 90px;'> <a HREF='#' onClick=\"displayCalendar(document.form.resigndate,'dd-mm-yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\" >";
echo"<image src='./img/cal.gif' border=0 align=center ></image></a></td>
		<td><span class='style1'>Resignation Reason</span></td>
		<td ><input type='text' name='resignreason' id='resignreason' value='$resignreason' style='width: 145px;'></td>
		<td><span class='style1'><input type='checkbox' name='resigned' id='resigned' value='$resigned' ".($resigned == 1?"checked":" ")." onclick=\"setChk(this.id);\">Resigned</span></td>		
		<td><span class='style1'><input type='checkbox' name='famPackage' id='famPackage' value='$famPackage' ".($famPackage == 1?"checked":" ")." onclick=\"setChk(this.id);\">Family Package</span></td><td></td><td></td>
	</tr>";
echo "<tr height='20px'></tr>";

echo "	<tr><td colspan='4'><fieldset><legend><span class='style1'>Passport Information</span></legend><table border='0' width='420px'>
	<col width=100>
	<col width=120>
	<col width=100>
	<col width=120>
	<tr><td><span class='style1'>Passport N</span></td>
		<td colspan='3'><div style='float:left;'><input type='text' name='passportnumber' style='width:140px;' id='passportnumber' value='$passportnumber'></div> 
		<div style='float:right;'><img src='./img/view_file.png' height='20px' width='20px' title='View Image' onclick=\"UploadImg('$staffcode', 'Passport')\"></div>
		</td>
	</tr>
	<tr>
		<td><span class='style1'>issue Date </span></td>";
echo "<td ><input type='text' name='passportdate' style='width:90px;' id='passportdate' value='$passportdate'> 
	<a HREF='#' onClick=\"displayCalendar(document.form.passportdate,'dd-mm-yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\" >";

echo"<image src='./img/cal.gif' border=0 align=center ></image></a</td></td>
	<td><span class='style1'>Expiry Date</span></td>
	<td ><input type='text' name='passportexpire' style='width:90px;' id='passportexpire' value='$passportexpire'> 
	<a HREF='#' onClick=\"displayCalendar(document.form.passportexpire,'dd-mm-yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\" >";
 echo"<image src='./img/cal.gif' border=0 align=center ></image></a></td></tr>
		</table>
		 </fieldset>";
		//echo "<td></td>";
echo "</td>";
if($ShowInsuranceInfo == 1){
echo "<td colspan='4'> <fieldset><legend><span class='style1'>inssurance</span></legend><table border='0' width='420px'>
	<col width=100>
	<col width=120>
	<col width=100>
	<col width=120>
			
<tr><td><span class='style1'>inssurance N</span></td>
	<td colspan='3'><div style='float:left;'><input type='text' name='inssurancenumber'  id='inssurancenumber' style='width:140px;' value='$inssurancenumber'> </div>
	<div style='float:right;'><img src='./img/view_file.png' height='20px' width='20px' title='View Image' onclick=\"UploadImg('$staffcode', 'inssurance');\"></div>
	</td>
	
</tr>
<tr>
	<td><span class='style1'>Issue Date</span></td>";
			
echo "	<td ><input type='text' name='inssurancedate' style='width:90px;' id='inssurancedate' value='$inssurancedate'> 
		<a HREF='#' onClick=\"displayCalendar(document.form.inssurancedate,'dd-mm-yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\" >";

echo"<image src='./img/cal.gif' border=0 align=center ></image></a></td></td>
	<td><span class='style1'>Expiry Date</span></td>
	<td ><input type='text' name='inssuranceexpire' style='width:90px;'  id='inssuranceexpire'value='$inssuranceexpire'>
	<a HREF='#' onClick=\"displayCalendar(document.form.inssuranceexpire,'dd-mm-yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\" >";

echo"<image src='./img/cal.gif' border=0 align=center ></image></a></td></tr></table></fieldset>
</td>";
} else echo "<td colspan='4'></td>";
echo"</tr>";

echo "<tr><td colspan='4'><fieldset><legend><span class='style1'>Cerpac Information</legend><table  border='0' width='520px'>
	<col width=120>
	<col width=140>
	<col width=120>
	<col width=140>
		
	<tr><td><span class='style1'>Card N</span></td>
	<td colspan='3'><div style='float:left;'><input type='text' name='cardnumber' style='width:140px;' id='cardnumber'value='$cardnumber'></div>
	<div style='float:right;'><img src='./img/view_file.png' height='20px' width='20px' title='View Image' onclick=\"UploadImg('$staffcode', 'CerpacInfo');\"></div>
	</td>
	</tr><tr>
	<td><span class='style1'>issue Date</span></td>";
			
echo "
<td ><input type='text' name='carddate'  style='width:90px;'  id='carddate'value='$carddate'>
<a HREF='#' onClick=\"displayCalendar(document.form.carddate,'dd-mm-yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\" >";

echo"<image src='./img/cal.gif' border=0 align=center ></image></a></td>
		<td><span class='style1'>Expiry Date</span></td>
		<td ><input type='text' name='cardexpire' style='width:90px;' id='cardexpire' value='$cardexpire'> <a HREF='#' onClick=\"displayCalendar(document.form.cardexpire,'dd-mm-yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\" >";
echo"<image src='./img/cal.gif' border=0 align=center ></image></a></td></tr>
		</table>
		</fieldset>
</td>";
//echo "<td></td>";	

echo "<td colspan='4'><fieldset><legend><span class='style1'>temporary card Information</span></legend><table  border='0' width='520px'>
	<col width=120>
	<col width=140>
	<col width=120>
	<col width=140>			
	<tr><td><span class='style1'>temporary number N</span></td>
	<td colspan='3'><div style='float:left;'><input type='text' name='tempnumber' style='width:140px;' id='tempnumber' value='$tempnumber'></div>
	<div style='float:right;'><img src='./img/view_file.png' height='20px' width='20px' title='View Image' onclick=\"UploadImg('$staffcode', 'TempCard');\"></div></td>
	</tr><tr>
	<td><span class='style1'>issue Date</span></td>";
		
echo "<td ><input type='text' name='tempdate' style='width:90px;' id='tempdate' value='$tempdate'>
<a HREF='#' onClick=\"displayCalendar(document.form.tempdate,'dd-mm-yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\" >";

echo"<image src='./img/cal.gif' border=0 align=center ></image></a></td>
	<td><span class='style1'>Expiry Date</span></td>
	<td ><input type='text' name='tempexpire' style='width:90px;' id='tempexpire' value='$tempexpire'>
	
	<a HREF='#' onClick=\"displayCalendar(document.form.tempexpire,'dd-mm-yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\" >";
echo"<image src='./img/cal.gif' border=0 align=center ></image></a></td></tr>
		</table></fieldset></td></tr>";

echo "<tr><td colspan='4'><fieldset><legend><span class='style1'>Visa Information</span></legend><table border='0' width='520px'>
	<col width=120>
	<col width=140>
	<col width=120>
	<col width=140>	
			
<tr><td><span class='style1'>visa N</span></td>
	<td ><input type='text' name='visanumber' style='width:140px;' id='visanumber' value='$visanumber'>
	</td>";

echo"<td><span class='style1'>Type</span></td>
	<td><div style='float:left;'><select name='visatype' id='visatype' style='width:90px;' value='$visatype'>
		<option value='' ".($visatype==''?'selected':'')."></option>
		<option value='Single' ".($visatype=='Single'?'selected':'').">Single</option>
		<option value='Multiple' ".($visatype=='Multiple'?'selected':'').">Multiple</option>
		</select></div>
		<div style='float:right;'><img src='./img/view_file.png' height='20px' width='20px' title='View Image' onclick=\"UploadImg('$staffcode', 'VisaInfo');\"></div>
	</td>
</tr>";
		
echo "<tr>
	<td><span class='style1'>issue Date</span></td>
	<td ><input type='text' name='visadate' style='width:90px;' id='visadate' value='$visadate'> <a HREF='#' onClick=\"displayCalendar(document.form.visadate,'dd-mm-yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\" >";

 echo"<image src='./img/cal.gif' border=0 align=center ></image></a></td>
	<td><span class='style1'>Expiry Date</span></td>
	<td ><input type='text' name='visaexpire' style='width:90px;'  id='visaexpire' value='$visaexpire'>
	 <a HREF='#' onClick=\"displayCalendar(document.form.visaexpire,'dd-mm-yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\" >";
echo"<image src='./img/cal.gif' border=0 align=center ></image></a></td></tr>
		</table></fieldset></td>";
	
echo "<td colspan='4'> <fieldset><legend><span class='style1'>Alien</span></legend><table border='0' width='520px'>
	<col width=120>
	<col width=140>
	<col width=120>
	<col width=140>	
			
<tr><td><span class='style1'>Alien Card Number N</span></td>
	<td colspan='3'><div style='float:left;'><input type='text' name='aliennumber' style='width:140px;' id='aliennumber' value='$aliennumber'></div>
	<div style='float:right;'><img src='./img/view_file.png' height='20px' width='20px' title='View Image' onclick=\"UploadImg('$staffcode', 'Alien');\"></div></td>
</tr><tr>
<td><span class='style1'>issue Date</span></td>";

echo "<td ><input type='text' name='aliendate' style='width:90px;' id='aliendate' value='$aliendate'> 
 <a HREF='#' onClick=\"displayCalendar(document.form.aliendate,'dd-mm-yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\" >";

echo"<image src='./img/cal.gif' border=0 align=center ></image></a></td>
	<td><span class='style1'>Expiry Date</span></td>
	<td ><input type='text' name='alienexpire' style='width:90px;' id='alienexpire' value='$alienexpire'> 
	<a HREF='#' onClick=\"displayCalendar(document.form.alienexpire,'dd-mm-yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\" >";

echo"<image src='./img/cal.gif' border=0 align=center ></image></a></td></tr></table></fieldset></td></tr>";
echo "<tr height='30px' ></tr>";
echo"	</table>";


	
print <<< HERE
       </td>
      </tr>
	  </table>
HERE;

$tabs->end();
$tabs->start("Ticket");
echo "<input type='hidden' name='ticket_id' id='ticket_id' value='$ticket_id'>";
echo"<table border=0 align='left' valign='top' ><tr><td width='50px'></td><td>";
echo "<div id='insertTicket'>";
insertTicket($ticket_id, $staffcode,$firstname,$connection);		

echo "</div>";	
echo "</td></tr>";

echo "<tr><td width='50px'></td><td>";

echo "<table border='0' cellpadding='0' cellspacing='0' align='left' valign='center' width='1065px'>
		<col width='25px'><col width='25px'>
		<col width='120px'><col width='125px'><col width='90px'><col width='90px'><col width='90px'><col width='90px'>
		<col width='90px'><col width='90px'><col width='90px'><col width='90px'><col width='40px'>";
echo "<tr height='20px'><td colspan='11'></td></tr>";
echo "<tr>".
		"<td></td><td></td>".
		"<td></td><td></td>".
		"<td colspan='4' align='center'><span style='font-size: 14px;font-weight: bold;'>Leaving</span></td>".
		"<td colspan='4'align='center'><span style='font-size: 14px;font-weight: bold;'>Coming</span></td>".
		"<td></td>".
	 "</tr>";	
echo "<tr height='10px'><td colspan='13'></td></tr>";	 
echo "<tr>".
		"<td></td><td></td>".
		"<td><b>Airline Name</b></td><td><b>Project</b></td>".
		"<td><b>Departure Date</b></td><td><b>Departure Time</b></td>".
		"<td><b>Arrival Date</b></td><td><b>Arrival Time</b></td>".
		"<td><b>Departure Date</b></td><td><b>Departure Time</b></td>".
		"<td><b>Arrival Date</b></td><td><b>Arrival Time</b></td>".
		"<td><b>Returned</td>".
	 "</tr>";
echo "<tr height='10px'><td colspan='13'><hr></td></tr>";
echo "</table></td></tr>";

echo "<tr><td width='50px'></td><td>";
echo "<div id='gridTicket' style='overflow-y:scroll;height:450px;'>";
gridTicket($ticket_id, $staffcode,$connection);		

echo "</div>";	
echo "</td></tr>";
echo "</table>";
$tabs->end();

if($ShowBankInfo == 1){
$tabs->start("Bank Info");
	echo "<table border='0' cellpadding='3' cellspacing='0' align='left' valign='center' width='1040px'>
		<col width='100px'>
		<col width='160px'>
		<col width='100px'>
		<col width='160px'>
		<col width='100px'>
		<col width='160px'>
		<col width='120px'>
		<col width='160px'>";
	echo"<tr>
			<td><span class='style1'>Bank Acc</span></td>
			<td><input type='text' name='bankacc' id='bankacc' value='$bankacc' style='width: 145px;'></td>
			<td><span class='style1'>Bank Name</span></td>
			<td ><select name='bankname' id='bankname' style='width: 145px;' >
			<option value=''></option>";
			
			$bankquery="select bank_id,bank_name from banks";
			$banknameres=mysql_query($bankquery, $connection) or die(mysql_error());
			while($bankresult=mysql_fetch_array($banknameres)){
			echo "<option value='$bankresult[0]'";
			if($bankresult[0]==$bankname)echo "selected";
			echo ">$bankresult[1]</option>";
			}
			echo "</select></td>
			<td align='left'><span class='style1'>Branch</span></td>		
			<td ><input type='text' name='bankbranch' id='bankbranch' value='$bankbranch' style='width: 145px;'></td>			
			<td align='right'><span class='style1'>Paid allowance</span></td>
			<td ><input type='text' name='allowance' id='allowance' value='$allowance' style='width: 145px;'></td>
			
		</tr>";
	echo"<tr>
			<td> <span class='style1'>Acc Holder Name</span></td>
			<td><input type='text' name='accname' id='accname' value='$accname' style='width: 145px;'></td>
			<td align='left'><span class='style1'>IBAN</span></td>
			<td ><input type='text' name='iban' id='iban' value='$iban' style='width: 145px;'></td>
			<td align='left'><span class='style1'> Sort Code </span></td>		
			<td ><input type='text' name='sortcode' id='sortcode' value='$sortcode' style='width: 145px;'></td>			
			<td align='right'><span class='style1'>Salary Amount</span></td>
			<td ><input type='text' name='salaryamount' id='salaryamount' value='$salaryamount' style='width: 145px;'></td>
			
			
		</tr>";
	echo "</table>";	
$tabs->end();	
}

if($ShowSalaryInfo == 1){
$tabs->start("Salary Info");
	
	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'>";
	echo"<tr>
			<td></td>
			<td align='center'><span class='style1'>Salary Desc.</span></td>
			<td align='center'><span class='style1'>Start Date</span></td>
			<td align='center'><span class='style1'>End Date</span></td>
			<td align='center'><span class='style1'>Salary Amount</span></td>
			<td></td>		
			</tr>";
	echo "<tr><td colspan='6'><hr></td></tr>";
	echo "<tr><td colspan='6'>";
	echo "<div id='salarygrid' style='height:350px;overflow-x:hidden; overflow-y:scroll;'>";
	salarygrid($staffcode, $connection);
	echo "</div>";
	echo "</td></tr></table>";
$tabs->end();	
}
$tabs->run();
echo"</td></tr>";


print <<< HERE
      
    <tr height='30'><td align='center' id='content-bottom' ></td></tr>
	  </table>
HERE;


if($vTabFocus!=''){
	echo'<script type="text/javascript" language="javascript">';
	echo"tab_('$vTabFocus','');";
	echo'</script>';	
}

print <<<HERE
</form>
</body>

HERE;

function insertTicket($ticket_id, $staffcode,$firstname,$connection){
	$staff_returned = 0;
	echo "<table border='0' cellpadding='0' cellspacing='0' align='left' valign='center' width='1015px'>
		<col width='120px'><col width='130px'><col width='5px'>
		<col width='120px'><col width='130px'><col width='5px'>
		<col width='120px'><col width='130px'><col width='5px'>
		<col width='120px'><col width='130px'>";
	echo"<tr height='30px'><td colspan='11'><button type='button' name='btnEdit' id='btnEdit' value='Save' onclick=\"submitticket('$ticket_id','$staffcode');\" /><span><span>Submit</span></span></button>
	<button type='button' name='btnClear' id='btnClear' value='Clear' onclick=\"ClearTicket();\" /><span><span>Clear</span></span></button></td></tr>";	
	if($ticket_id !=''){
		$query = "select Staff_code,staff_name, date_format(DepDate,'%d-%m-%Y'), DepTime, date_format(ArrivalDate,'%d-%m-%Y'), Arrival_time, date_format(Com_DepDate,'%d-%m-%Y'), 
				Com_depTime, date_format(Com_ArrivalDate,'%d-%m-%Y'), Com_ArrivalTime, Airline_name, project_code, ifnull(staff_returned ,0), staff_destination
				from staff_ticket 
				where autoincrement = $ticket_id;";
		$res = mysql_query($query,$connection);
		$row = mysql_fetch_row($res);
		$staffcode    	 = $row[0];
		$firstname    	 = $row[1];
		$DepDate   	  	 = $row[2];
		$DepTime 	  	 = $row[3];
		$ArrivalDate  	 = $row[4];
		$Arrival_time 	 = $row[5];
		$Com_DepDate	 = $row[6];
		$Com_depTime 	 = $row[7];
		$Com_ArrivalDate = $row[8];
		$Com_ArrivalTime = $row[9];
		$Airline_name    = $row[10];
		$project_code    = $row[11];
		$staff_returned  = $row[12];
		$staff_dest		 = $row[13]; 
	}	
	echo "<tr><td><span class='style1'>Staff Code</span></td><td>$staffcode</td>".
			"<td></td>".
			"<td><span class='style1'>Staff Name</span></td><td>$firstname</td>".
			"<td></td>".	
			"<td><span class='style1'>Staff Returned</span></td><td><input type='checkbox' name='staff_returned' id='staff_returned' value='$staff_returned' 
			onclick = \"setReturned();\" ".($staff_returned==1?'selected':'')." ></td>".
		 "</tr>";	
	echo "<tr height='10px'><td colspan='5'></td></tr>";
	echo "<tr height='20px'><td><span class='style1'>Airline Name</span></td><td colspan='4'><input type='text' name='Airline_name' id='Airline_name' value='".htmlentities($Airline_name,ENT_QUOTES)."' style='width:355px;' ></td>".
			"<td></td>".
			"<td><span class='style1'>Project Code</span></td><td colspan='3'><input type='text' name='project_code' id='project_code' value='$project_code' style='width:200px;' >
			<img src='img/btnopen.jpg' title='Select Project' id='lstProjectCodeH' width='15' height='20' border='0' onmouseover=\"style.cursor='hand'\" onclick=\"showlistProject(1);\" style='cursor: pointer;'></td>".
			"<td></td>".
		"</tr>";
	echo "<tr height='20px'><td><span class='style1'>Destination</span></td><td colspan='4'><input type='text' name='staff_dest' id='staff_dest' value='".htmlentities($staff_dest,ENT_QUOTES)."' style='width:355px;' ></td>".
			"<td></td>".
			"<td></td><td colspan='3'></td>".
			"<td></td>".
		"</tr>";		
	echo "<tr height='15px'><td colspan='5'></td></tr>";
	echo "	<tr><td colspan='5'><fieldset><legend><span class='style1'>Leaving</span></legend><table border='0'><col width='120px'><col width='130px'><col width='5px'>
		<col width='120px'><col width='130px'>";
	echo "<tr height='20px'><td><span class='style1'>Departure Date</span></td><td><input type='text' name='DepDate' id='DepDate' value='$DepDate' style='width: 90px;' readonly> 
			<a HREF='#' onClick=\"displayCalendar(document.form.DepDate,'dd-mm-yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\" ><image src='./img/cal.gif' border=0 align=center ></image></a></td>".
			"<td></td>".
			"<td><span class='style1'>Departure Time</span></td><td><input type='time' name='DepTime' id='DepTime' value='$DepTime' style='width:100px;'></td>".
		"</tr>";	
			
	echo "<tr height='20px'><td><span class='style1'>Arrival Date</span></td><td><input type='text' name='ArrivalDate' id='ArrivalDate' value='$ArrivalDate' style='width: 90px;' readonly> 
			<a HREF='#' onClick=\"displayCalendar(document.form.ArrivalDate,'dd-mm-yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\" ><image src='./img/cal.gif' border=0 align=center ></image></a></td>".
			"<td></td>".
			"<td><span class='style1'>Arrival Time</span></td><td><input type='time' name='Arrival_time' id='Arrival_time' value='$Arrival_time' style='width: 100px;'></td>".
		 "</tr>";	
	echo "</table></fieldset></td>";
	
	echo "<td></td>";
	
	echo "<td colspan='5'><fieldset><legend><span class='style1'>Coming</span></legend><table border='0' ><col width='120px'><col width='130px'><col width='5px'>
		<col width='120px'><col width='130px'>";
	echo "<tr height='20px'><td><span class='style1'>Departure Date</span></td><td><input type='text' name='Com_DepDate' id='Com_DepDate' value='$Com_DepDate' style='width: 90px;' readonly> 
			<a HREF='#' onClick=\"displayCalendar(document.form.Com_DepDate,'dd-mm-yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\" ><image src='./img/cal.gif' border=0 align=center ></image></a></td>".
			"<td></td>".
			"<td><span class='style1'>Departure Time</span></td><td><input type='time' name='Com_depTime' id='Com_depTime' value='$Com_depTime' style='width: 100px;'></td>".
		"</tr>";
	echo "<tr height='20px'><td><span class='style1'>Arrival Date</span></td><td><input type='text' name='Com_ArrivalDate' id='Com_ArrivalDate' value='$Com_ArrivalDate' style='width: 90px;' readonly> 
			<a HREF='#' onClick=\"displayCalendar(document.form.Com_ArrivalDate,'dd-mm-yyyy',this); return false;\" NAME=\"anchor1\" ID=\"anchor1\" ><image src='./img/cal.gif' border=0 align=center ></image></a></td>".
			"<td></td>".
			"<td><span class='style1'>Arrival Time</span></td><td><input type='time' name='Com_ArrivalTime' id='Com_ArrivalTime' value='$Com_ArrivalTime' style='width: 100px;'></td>".
		 "</tr>";
	echo "</table></fieldset></td></tr>";
	
	
	echo "</table>";	
}

function gridTicket($ticket_id, $staffcode,$connection){
	echo "<table border='0' cellpadding='0' cellspacing='0' align='left' valign='center' width='1065px'>
		<col width='25px'><col width='25px'>
		<col width='120px'><col width='125px'><col width='90px'><col width='90px'><col width='90px'><col width='90px'>
		<col width='90px'><col width='90px'><col width='90px'><col width='90px'><col width='40px'>";
	echo "<tr height='20px'><td colspan='13'></td></tr>";
	$queryall ="select Airline_name, project_code, date_format(DepDate,'%d-%m-%Y'), DepTime, date_format(ArrivalDate,'%d-%m-%Y'), Arrival_time, date_format(Com_DepDate,'%d-%m-%Y'), 
				Com_depTime, date_format(Com_ArrivalDate,'%d-%m-%Y'), Com_ArrivalTime,  if(ifnull(staff_returned ,0) = 0,'&#x2717;' ,'&#10004;' ), autoincrement
				from staff_ticket where staff_code = '$staffcode' ";
	$resall = mysql_query($queryall,$connection);
	$ct=0;
	while($rowall = mysql_fetch_row($resall)){
		if($ct%2) $bgcolor = "background-color: #E6E6E6;";
		else $bgcolor = "background-color: #F7F7F7;";
		
		if($ticket_id == $rowall[11]) $bgcolor = "background-color: #1e87a5;color: #fff;";
	echo "<tr style='$bgcolor'>".
			"<td><img src='img/edit.png' onMouseOver=\"style.cursor='hand'\" onclick=\"UpdateTicket('$rowall[11]');\" title='Edit Ticket'  style=\"width: 20px; height: 20px; \"></td>
			<td><img src='img/delete.png' onMouseOver=\"style.cursor='hand'\" onclick=\"DeleteTicket('$rowall[11]', '$staffcode');\" title='Delete Ticket' style=\"width: 20px; height: 20px; \"></td>".
			"<td>$rowall[0]</td><td>$rowall[1]</td>".
			"<td>$rowall[2]</td><td>$rowall[3]</td>".
			"<td>$rowall[4]</td><td>$rowall[5]</td>".
			"<td>$rowall[6]</td><td>$rowall[7]</td>".
			"<td>$rowall[8]</td><td>$rowall[9]</td>".
			"<td>$rowall[10]</td>".
		 "</tr>";
	}
	
	echo "</table>";	
}
?>














