
<script language="javascript" src="../jscript/calendar.js"></script>
<script language="JavaScript">
function toggle(id) {
        var state = document.getElementById(id).style.display;
                document.getElementById(id).style.display = 'block';
				document.form1.sub_cat_group_0.checked=false;
           }
		
	function toggle2(id) {
        var state = document.getElementById(id).style.display;
               document.getElementById(id).style.display = 'none';
			   document.form1.sub_cat_group_0.checked=true;
           }
</script>


<?php
$table_name = $_SESSION['db_prefix']."_presets";
$time_query = "SELECT preset_value FROM $table_name WHERE preset_name = 'clockin1'  ";
$time_result = mySQL_query($time_query);
$hours1 = mysql_result($time_result, 0, "preset_value");

$clockin_hours1 =  floor($hours1/60); 
$clockin_mins1 =   $hours1 % 60; 
if ($clockin_hours1<10) { $clockin_hours1 = 0 . $clockin_hours1; }
if ($clockin_mins1<10) { $clockin_mins1 = 0 . $clockin_mins1; }

$table_name = $_SESSION['db_prefix']."_presets";
$time_query = "SELECT preset_value FROM $table_name WHERE preset_name = 'clockout1'  ";
$time_result = mySQL_query($time_query);
$hours1 = mysql_result($time_result, 0, "preset_value");

$clockout_hours1 =  floor($hours1/60); 
$clockout_mins1 =   $hours1 % 60; 
if ($clockout_hours1<10) { $clockout_hours1 = 0 . $clockout_hours1; }
if ($clockout_mins1<10) { $clockout_mins1 = 0 . $clockout_mins1; }

$table_name = $_SESSION['db_prefix']."_presets";
$time_query = "SELECT preset_value FROM $table_name WHERE preset_name = 'clockin2'  ";
$time_result = mySQL_query($time_query);
$hours2 = mysql_result($time_result, 0, "preset_value");

$clockin_hours2 =  floor($hours2/60); 
$clockin_mins2 =   $hours2 % 60; 
if ($clockin_hours2<10) { $clockin_hours2 = 0 . $clockin_hours2; }
if ($clockin_mins2<10) { $clockin_mins2 = 0 . $clockin_mins2; }

$table_name = $_SESSION['db_prefix']."_presets";
$time_query = "SELECT preset_value FROM $table_name WHERE preset_name = 'clockout2'  ";
$time_result = mySQL_query($time_query);
$hours2 = mysql_result($time_result, 0, "preset_value");

$clockout_hours2 =  floor($hours2/60); 
$clockout_mins2 =   $hours2 % 60; 
if ($clockout_hours2<10) { $clockout_hours2 = 0 . $clockout_hours2; }
if ($clockout_mins2<10) { $clockout_mins2 = 0 . $clockout_mins2; }
?>

<?php include('../include/wait.php') ?>

</head>

<body onLoad="MM_showHideLayers('wait','','hide'); <?php if ($_SESSION['exp'] == 'no' ) { ?> document.getElementById('expat_div').style.visibility='hidden'; <?php } else { ?>document.getElementById('expat_div').style.visibility='visible';<?php }?>" ; onFocus="MM_showHideLayers('wait','','hide');"  >


<?php
	if($_SESSION['p']==1) {
		    $_SESSION['first_name'] = $_POST['first_name_text'];
		    $_SESSION['last_name'] = $_POST['last_name_text'];
	}
	$table_name = $_SESSION['db_prefix']."_employee";
	$query = "SELECT emp_last_name FROM $table_name WHERE emp_first_name = '". $_SESSION['first_name']."' AND emp_last_name = '". $_SESSION['last_name']."'" ;

	$result = mySQL_query($query) or die ("Error in query:   $query . * ". mySQL_error());
	$num = mysql_num_rows($result);
	if ($num!=0)
	{ 
	$_SESSION['error']=1;
	$_SESSION['p']=1;
	
	?>
    <script language="javascript" type="text/javascript">
        <!--
	 needToConfirm = false;
	 window.location="employeeWizbase.php?s=0&p=1";
        -->
     </script>
<?php
	}

	if($_SESSION['p']==1) {
		    $_SESSION['emp_no'] = $_POST['emp_no_text'];
	}
	$table_name = $_SESSION['db_prefix']."_employee";
	$query = "SELECT emp_id FROM $table_name WHERE emp_no = '". $_SESSION['emp_no']."' " ;

	$result = mySQL_query($query) or die ("Error in query:   $query . * ". mySQL_error());
	$num = mysql_num_rows($result);
	if ($num!=0)
	{ 
	$_SESSION['error']=2;
	$_SESSION['p']=1;
	
	?>
    <script language="javascript" type="text/javascript">
        <!--
		needToConfirm = false;
	 window.location="employeeWizbase.php?s=0&p=1";
        -->
     </script>
          
     
<?php
	}
    else{
//$_SESSION['error']=0;	
require_once('../include/tc_calendar.php');
$birth_date = strtotime($_SESSION['birth_date']);
$d1 = date("d", $birth_date ) ;
$m1 = date("m", $birth_date ) ;
$y1 = date("Y", $birth_date ) ;


$employ_date = strtotime($_SESSION['employ_date']);
$d2 = date("d", $employ_date ) ;
$m2 = date("m", $employ_date ) ;
$y2 = date("Y", $employ_date ) ;

$expiry_date = strtotime($_SESSION['expiry_date']);
$d4 = date("d", $expiry_date ) ;
$m4 = date("m", $expiry_date ) ;
$y4 = date("Y", $expiry_date ) ;


$permit_date = strtotime($_SESSION['permit_date']);
$d3 = date("d", $permit_date ) ;
$m3 = date("m", $permit_date ) ;
$y3 = date("Y", $permit_date ) ;

    $table_name = $_SESSION['db_prefix']."_list_positions";
    $position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
	$arrId2 = array ();
	$arrName2 = array ();
	$position_result = execsql($position_query);
	if ($position_result!="") {
	$position_num = mysql_num_rows($position_result);
	$b = 0;
	while ($b < $position_num) {
		$arrId2[$b] = mysql_result($position_result, $b, "item_name");
		$arrName2[$b] = mysql_result($position_result, $b, "item_name");
		$b++;
	}
	}
	
	$table_name = $_SESSION['db_prefix']."_list_department";
    $position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
	$arrId1 = array ();
	$arrName1 = array ();
	$position_result = execsql($position_query);
	if ($position_result!="") {
	$position_num = mysql_num_rows($position_result);
	$b = 0;
	while ($b < $position_num) {
		$arrId1[$b] = mysql_result($position_result, $b, "item_name");
		$arrName1[$b] = mysql_result($position_result, $b, "item_name");
		$b++;
	}
	}
	
	$table_name = $_SESSION['db_prefix']."_list_salary_scale";
    $position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
	$arrId3 = array ();
	$arrName3 = array ();
	$position_result = execsql($position_query);
	if ($position_result!="") {
	$position_num = mysql_num_rows($position_result);
	$b = 0;
	while ($b < $position_num) {
		$arrId3[$b] = mysql_result($position_result, $b, "item_name");
		$arrName3[$b] = mysql_result($position_result, $b, "item_name");
		$b++;
	}
	}
	
	$table_name = $_SESSION['db_prefix']."_list_nationality";
    $position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
	$arrId4 = array ();
	$arrName4 = array ();
	$position_result = execsql($position_query);
	if ($position_result!="") {
	$position_num = mysql_num_rows($position_result);
	$b = 0;
	while ($b < $position_num) {
		$arrId4[$b] = mysql_result($position_result, $b, "item_name");
		$arrName4[$b] = mysql_result($position_result, $b, "item_name");
		$b++;
	}
	}
?>

<div class="page_middle_frame">  
<form id="form1" method="POST" action="employeeWizbase.php?p=2&s=2">
  <table id="tableMain" width="595">
    <!--begin of tableMain-->
    <tr>
      <td><!--center of tableMain-->
        <table width=595 border="0" align="center" cellpadding="10" cellspacing="0" bordercolor="#0066FF" border-collapse="collapse">
          <tr>
            <td width="525" valign="top" ><div class="wizard_frame">
              <table width="630" id="table_display_wizard">
                <tr>
                  <td width="103"><label class="label_std">Date of birth:</label>
&nbsp;&nbsp;
<label class="star">*</label></td>
                  <td width="264"><?php 
				  //instantiate class and set properties
		$myCalendar = new tc_calendar("birth_date", true);
		$myCalendar->setIcon("../images/iconCalendar.gif");
		$myCalendar->setDate($d1, $m1, $y1);
		$myCalendar->setYearInterval(1960, 2030);
		//output the calendar
		$myCalendar->writeScript();
?></td>
                  <td width="114">Gender: <label class="star">*</label> </td>
                  <td width="129">
                    <select name="gender_select" class="select120" id="gender_select">
                      <option value="female">female</option>
                      <option value="male">male</option>
                      <option value="<?php echo $_SESSION['gender'] ?>" selected="selected"><?php echo $_SESSION['gender'] ?></option>
                    </select>
                  </td>
                  </tr>
                <tr>
                  <td class="step">Id number:&nbsp;&nbsp;<label class="star">*</label></td>
                  <td>
                    <input name="id_number_text" type="text" class="text200" id="id_number_text"  onkeyup="ToUpper(this)" value="<?php echo $_SESSION['id_number'] ?>" maxlength="25"/>
                  </td>
                  <td>Marital status</td>
                  <td>
                    <select name="marital_status_select" class="select120" id="marital_status_select">
                      <option value="single">single</option>
                      <option value="married">married</option>
                      <option value="divorced">divorded</option>
                      <option value="seperated">seperated</option>
                      <option value="<?php echo $_SESSION['marital_status'] ?>" selected="selected"><?php echo $_SESSION['marital_status'] ?></option>
                    </select>
                  </td>
                </tr>
                <tr>
                  <td class="step">Nationality:</td>
                  <td><select name="nationality_select" class="select120"  >
                    <option value="<?php echo $_SESSION['nationality'] ?>" selected="selected"><?php echo $_SESSION['nationality'] ?></option>
                    <?php
        	for ($j = 0; $j < count($arrId4); $j++) {
    		echo "<option value=" . "\"" . $arrId4[$j] . "\"" . ">" . $arrName4[$j] . "</option>";
	}
?>
                  </select></td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
              </table>
            </div><br /><br /><br />



            <div class="wizard_frame">
              <table width="651" id="table_display_wizard">
                <tr>
                  <td width="107">Pay period:
                    <label class="star">*</label></td>
                  <td colspan="2"><select name="pay_period_select" class="select80" id="pay_period_select">
                    <option value="month">month</option>
                    <option value="hour">hour</option>
                    <option value="<?php echo $_SESSION['pay_period'] ?>" selected><?php echo $_SESSION['pay_period'] ?></option>
                  </select></td>
                  <td width="101">Pay unit:&nbsp;&nbsp;
                    <label class="star">*</label></td>
                  <td width="101"><select name="pay_unit_select" class="select80" id="pay_unit_select">
                    <option value="month">month</option>
                    <option value="hour">hour</option>
                    <option value="<?php echo $_SESSION['pay_unit'] ?>" selected><?php echo $_SESSION['pay_unit'] ?></option>
                  </select></td>
                  <td width="86">&nbsp;</td>
                  <td width="97">&nbsp;</td>
                </tr>
                <tr>
                  <td>Salary scale:&nbsp;</td>
                  <td colspan="2"><select name="scale_select" class="select80"  >
                    <option value="<?php echo $_SESSION['scale'] ?>" selected="selected"><?php echo $_SESSION['scale'] ?></option>
                    <?php
        	for ($j = 0; $j < count($arrId3); $j++) {
    		echo "<option value=" . "\"" . $arrId3[$j] . "\"" . ">" . $arrName3[$j] . "</option>";
	}
?>
                  </select></td>
                  <td>Rate/Salary:
                    <label class="star">*</label></td>
                  <td align="left"><input name="rate_text" type="text" class="text60" id="rate_text" style="text-align:right" onChange=" this.value = this.value.replace (/(\...).*/, '$1')" onKeyPress="return isNumberKey(event)" value="<?php echo $_SESSION['rate'] ?>" size="15" maxlength="9"/></td>
                  <td align="left">Leave days: 
                    <label class="star">*</label></td>
                  <td><label for="leave_select"></label>
                    <select name="leave_select" id="leave_select" class="select80">
                      <option value="1.00">1.00 (12)</option>
                      <option value="1.25">1.25 (15)</option>
                      <option value="1.5">1.50 (18)</option>
                      <option value="1.67">1.67 (20)</option>
                      <option value="1.84">1.84 (22)</option>
                      <option value="2.00">2.00 (24)</option>
                      <option value="<?php echo $_SESSION['leave_days']?>" selected="selected"><?php echo $_SESSION['leave_days']?></option>
                    </select></td>
                </tr>
                <tr>
                  <td>Time keeping:&nbsp;
                    <label class="star">*</label></td>
                  <td width="116"><select name="time_keeping_select" class="select80" id="time_keeping_select">
                    <option value="yes">yes</option>
                    <option value="no">no</option>
                    <option value="<?php echo $_SESSION['time_keeping'] ?>" selected><?php echo $_SESSION['time_keeping'] ?></option>
                    </select></td>
                  <td width="11"><label class="star">*</label></td>
                  <td colspan="4">                    <p>
                    
                    <input type="radio" name="time_zone" value="1" id="time_zone_0" <?php if ($_SESSION['time_zone']==1) { ?> checked="checked" <?php } ?>>
                    time zone 1 (currently set to: <?php echo $clockin_hours1.':'.$clockin_mins1.' hr to '.$clockout_hours1.':'.$clockout_mins1.' hr' ?><br>
                    <input type="radio" name="time_zone" value="2" id="time_zone_1" <?php if ($_SESSION['time_zone']==2) { ?> checked="checked" <?php } ?>>
                    time zone 2 (currently set to: <?php echo $clockin_hours2.':'.$clockin_mins2.' hr to '.$clockout_hours2.':'.$clockout_mins2.' hr' ?><br>
                    <input type="radio" name="time_zone" value="3" id="time_zone_1" <?php if ($_SESSION['time_zone']==3) { ?> checked="checked" <?php } ?>>
                    time zone 3 (not specified)
                    </td>
                </tr>
                </table>
            </div>
            <div class="wizard_frame">
              <table width="651" id="table_display_wizard">
                <tr>
                  <td width="126">Department:&nbsp;<label class="star">*</label></td>
                  <td width="135"><select name="department_select" class="select120"  >
                    <option value="<?php echo $_SESSION['department'] ?>" selected="selected"><?php echo $_SESSION['department'] ?></option>
                    <?php
        	for ($j = 0; $j < count($arrId1); $j++) {
    		echo "<option value=" . "\"" . $arrId1[$j] . "\"" . ">" . $arrName1[$j] . "</option>";
	}
?>
                    </select></td>
                  <td width="123">Position:
                    <label class="star">*</label>
                    </td>
                  <td width="83" align="left"><select name="position_select" class="select120"  >
                    <option value="<?php echo $_SESSION['position'] ?>" selected="selected"><?php echo $_SESSION['position'] ?></option>
                    <?php
        	for ($j = 0; $j < count($arrId2); $j++) {
    		echo "<option value=" . "\"" . $arrId2[$j] . "\"" . ">" . $arrName2[$j] . "</option>";
	}
?>
                    </select></td>
                  <td width="90">&nbsp;</td>
                </tr>
                <tr>
                  <td>Employment date:&nbsp;&nbsp;
                    <label class="star">*</label></td>
                  <td colspan="4"><?php 
				  //instantiate class and set properties
		$myCalendar = new tc_calendar("employ_date", true);
		$myCalendar->setIcon("../images/iconCalendar.gif");
		$myCalendar->setDate($d2, $m2, $y2);
		$myCalendar->setYearInterval(2014, 2090);
		//output the calendar
		$myCalendar->writeScript();
?></td>
                  </tr>
                <tr>
                  <td>Contract expiry date:</td>
                  <td colspan="4"><?php 
				  //instantiate class and set properties
		$myCalendar = new tc_calendar("expiry_date", true);
		$myCalendar->setIcon("../images/iconCalendar.gif");
		$myCalendar->setDate($d4, $m4, $y4);
		$myCalendar->setYearInterval(2014, 2090);
		//output the calendar
		$myCalendar->writeScript();
?> &nbsp;&nbsp;&nbsp;<img src="../images/info_green.png" width="16" height="16">&nbsp;if undefined leave date on 01 January 2030</td>
                  </tr>
              </table>
            </div>
            <br />
<div class="wizard_frame">
<input type="checkbox" name="exp_checkbox" id="exp_checkbox" <?php if ($_SESSION['exp'] == 'yes' ) { ?> checked="checked" <?php } ?>  onClick="if (document.getElementById('exp_checkbox').checked) {document.getElementById('expat_div').style.visibility='visible';} else {document.getElementById('expat_div').style.visibility='hidden';}" >
        <label class="label_std">Expatriate</label>
        <div id='expat_div'>
  <table width="651" id="table_display_wizard" >
    <tr>
      <td width="317" >Work permit no:&nbsp;&nbsp;&nbsp;
<input name="permit_text" type="text" class="text200" id="permit_text" onKeyUp="ToUpper(this)" maxlength="20"  value="<?php echo $_SESSION['permit'] ?>"/></td>
      <td width="86">Expiry date:</td>
      <td width="232"><?php 
				  //instantiate class and set properties
		$myCalendar = new tc_calendar("permit_date", true);
		$myCalendar->setIcon("../images/iconCalendar.gif");
		$myCalendar->setDate($d3, $m3, $y3);
		$myCalendar->setYearInterval(2014, 2090);
		//output the calendar
		$myCalendar->writeScript();
?></td>
    </tr>
  </table>
  </div>
   </div>
<br />
</td>
            <!--center of tableMain-->
          </tr>
          <tr>
            <td><!--center of tableMain-->
            <div class="wizard_frame">
              <table width="660" height="50" align="left" cellpadding="20"  id="table_button_bar">
                <tr>
                  <td width="117"><input type="button" name="lastprev_button" class="imagebutton" value="Prev" onClick="needToConfirm = false;MM_goToURL('parent','employeeWizbase.php?s=&amp;p=1');return document.MM_returnValue" /></td>
                  <td width="115">&nbsp;</td>
                  <td width="99">
                    <input name="p" type="hidden" id="p" value="2" />
                    <input name="s" type="hidden" id="s" value="2" />
                  </td>
                  <td width="125" align="right"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onClick="needToConfirm = false; cancel_confirmation(1, '../hr_module/hr_main.php?date=0');" value="Cancel" /></td>
                  <td width="110" align="right"><input type="submit" name="next_button" class="imagebutton" value="Next" onClick="
                  needToConfirm = false; MM_showHideLayers('wait','','show');" /></td>
                </tr>
            </table></div>
            </td>
          </tr>
        </table>
        
  </table>
  <!--end of tableMain-->
</form>
<!--form validation-->
<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form1");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("gender_select","req","- gender.");
  frmvalidator.addValidation("id_number_text","req","- id number.");
  frmvalidator.addValidation("pay_period_select","req","- pay period.");
  frmvalidator.addValidation("rate_text","req","- rate or salary.");
  frmvalidator.addValidation("pay_unit_select","req","- pay unit.");
  frmvalidator.addValidation("leave_select","req","- leave days.");
  frmvalidator.addValidation("time_keeping_select","req","- select time keeping include.");
  frmvalidator.addValidation("time_zone","selone","- select time zone.");
  frmvalidator.addValidation("department_select","req","- department.");
  frmvalidator.addValidation("position_select","req","- position.");
</script>

<?php
	}
	?>
</div>	
  