
<head>
<script language="javascript" src="../jscript/calendar.js"></script>
<script language="JavaScript" src="../jscript/gen_validatorv4.js"  type="text/javascript" xml:space="preserve"></script>

<?php
	if($_SESSION['p']==1) {
		    $_SESSION['first_name'] = $_GET['first_name_text'];
		    $_SESSION['last_name'] = $_GET['last_name_text'];
	}
	$table_name = $_SESSION['db_prefix']."_employee";
	$query = "SELECT emp_id 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'] = $_GET['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 ) ;


   include ('../include/formValidations.php');
   
    $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++;
	}
	}
?>

<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;
           }
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
</script>

</head>

<body >
<div class="wizard_page_middle_frame">  
<form id="form1" method="get" action="employeeWizbase.php">
    <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(1950, 2000);
		//output the calendar
		$myCalendar->writeScript();
?></td>
                  <td width="114">Gender: <label class="star">*</label> </td>
                  <td width="129"><span class="wizard">
                    <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>
                  </span></td>
                  </tr>
                <tr>
                  <td class="step">Id number:&nbsp;&nbsp;<label class="star">*</label></td>
                  <td><span class="wizard">
                    <input name="id_number_text" type="text" class="text200" id="id_number_text" value="<?php echo $_SESSION['rate'] ?>"  onkeyup="ToUpper(this)"/>
                  </span></td>
                  <td><span class="step">&nbsp;Marital status:</span></td>
                  <td><span class="wizard">
                    <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>
                  </span></td>
                </tr>
              </table>
            </div><br /><br /><br />



            <div class="wizard_frame">
              <table width="629" id="table_display_wizard">
                <tr>
                  <td width="93">Pay period:
                    <label class="star">*</label></td>
                  <td width="96"><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"><span class="wizard">Rate/Salary: <label class="star">*</label></span></td>
                  <td colspan="2"><span class="wizard">
                    <input name="rate_text" type="text" class="text100" id="rate_text" value="<?php echo $_SESSION['rate'] ?>" style="text-align:right" onKeyPress="return isNumberKey(event)"/>
                  </span></td>
                  <td width="81">Pay unit:&nbsp;&nbsp;<label class="star">*</label></td>
                  <td width="86"><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>
                </tr>
                <tr>
                  <td>Department:</td>
                  <td colspan="2"><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 colspan="3" align="right">Time keeping:&nbsp;<label class="star">*</label></td>
                  <td><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>
                </tr>
                <tr>
                  <td><span class="wizard">Position: <label class="star">*</label></span></td>
                  <td><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 colspan="2" align="right">Employment date:&nbsp;&nbsp;<label class="star">*</label></td>
                  <td colspan="3"><?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(1970, 2020);
		//output the calendar
		$myCalendar->writeScript();
?></td>
                  </tr>
                </table>
            </div>
<div class="wizard_spacer_frame" style="height:60px;"></div>
            <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" />
                  </span></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; " /></td>
                </tr>
            </table></div>
            
</form>
</div>
<!--form validation-->
  <script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form1");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("gender_select","req","Please select gender.");
  frmvalidator.addValidation("id_number_text","req","Please enter the id number.");
  frmvalidator.addValidation("position_select","req","Please select position.");
  frmvalidator.addValidation("rate_text","req","Please enter rate or salary.");
  frmvalidator.addValidation("pay_unit_select","req","Please select pay unit.");
  frmvalidator.addValidation("pay_period_select","req","Please select pay period.");
  frmvalidator.addValidation("time_keeping_select","req","Please select time keeping include.");
  
  frmvalidator.addValidation("id_number_text","req","Please enter id_number.");
  </script>

<?php
	}
	?>
</div>	
    </body>