<?php 
$end_employ_date = date('Y-m-d', strtotime(date("Y-m-d", strtotime($today))." -60 day"));
$premature_end_date = date('Y-m-d', strtotime(date("Y-m-d", strtotime($today))." -60 day"));
$table_name = $_SESSION['db_prefix']."_permissions";
$view_query = "SELECT access_id  FROM  $table_name  WHERE access_id ='". $_SESSION['access_id']."' AND page_name = 'HR-management' ";
$view_result = mySQL_query($view_query);
$view_num = mysql_num_rows($view_result);
if ($view_num!=0) {
	$management_view='yes';
}
else { 
$management_view='no';
}


$table_name = $_SESSION['db_prefix']."_employee";
$employeeQuery = "SELECT emp_id, emp_first_name, emp_last_name FROM $table_name WHERE end_employ_date > '".$today."' AND premature_end_date > '".$today."' AND emp_group='E'  ORDER BY emp_first_name ASC";
$employeeResult = execsql($employeeQuery);
$employeeNum = mysql_num_rows($employeeResult);
	$w = 0;
	$arrId4 = array ();
	$arrName4 = array ();
	while ($w < $employeeNum) {
		$arrId4[$w] = mysql_result($employeeResult, $w, 'emp_id');
		$arrName4[$w] = mysql_result($employeeResult, $w, 'emp_first_name').' '.mysql_result($employeeResult, $w, 'emp_last_name');
		$w++;
	}

if ($management_view=='yes') {
$table_name = $_SESSION['db_prefix']."_employee";
$employeeQuery = "SELECT emp_id, emp_first_name, emp_last_name FROM $table_name WHERE end_employ_date > '".$today."' AND premature_end_date > '".$today."' AND emp_group='M'  ORDER BY emp_first_name ASC";
$employeeResult = execsql($employeeQuery);
$employeeNum = mysql_num_rows($employeeResult);
	$w = 0;
	$arrId5 = array ();
	$arrName5 = array ();
	while ($w < $employeeNum) {
		$arrId5[$w] = mysql_result($employeeResult, $w, 'emp_id');
		$arrName5[$w] = mysql_result($employeeResult, $w, 'emp_first_name').' '.mysql_result($employeeResult, $w, 'emp_last_name');
		$w++;
	}
}
?>
<link href="../css/wait.css" rel="stylesheet" type="text/css"> 
</head>


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


<?php 
$page_name = "HR-pettycash";
include ("../navigation/access.php");
if ($permission_num==1) {
	?>
<body onLoad="MM_showHideLayers('wait','','hide')" onFocus="MM_showHideLayers('wait','','hide');">    
<div class="wizard_page_middle_frame">
<form id="form1" name="form1" method="get" action="pettycashReturnWizbase.php">
  <div class="wizard_frame">
     <table width="600"  id="table_display_wizard">
       <tr>
         <td width="241">
         
         <label class="label_std">
         Select to receive petty cash from:&nbsp;&nbsp;</label>
         <label class="star">*</label></td>
         <td width="347"><select name="employee_select" id="employee_select" class="select200" >
           <option value="<?php echo $_SESSION['emp_id']?>" selected="selected"><?php echo $_SESSION['employee_name']?></option>
             	<?php
    			for ($i = 0; $i < count($arrId4); $i++) {
				echo "<option value=" . "\"" . $arrId4[$i] . "\"" . ">" . $arrName4[$i] . "</option>";
			    }
     			?>
                <?php
    			for ($i = 0; $i < count($arrId5); $i++) {
				echo "<option value=" . "\"" . $arrId5[$i] . "\"" . ">" . $arrName5[$i] . "</option>";
			    }
     			?>
         </select>
           </td>
       </tr>
     </table>
     </div> 
     <div class="wizard_spacer_frame" style="height:200px;"></div>
     <div class="wizard_frame">
     <table width="675" height="50" align="center" id="table_button_bar">
          <tr>
            <td width="117">&nbsp;</td>
            <td width="115">&nbsp;</td>
            <td width="99"><span class="wizard">
              <input name="p" type="hidden" id="p" value="1" />
              <input name="error" type="hidden" id="error" value="0" />
              <input name="s" type="hidden" id="s" value="1" />
            </span></td>
            <td width="125"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onClick="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>
 </form>
<!--form validation-->
<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form1");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("employee_select","req","- employee name.");
</script>
  
</div>  
<?php } else { 
    $_SESSION['denied_return'] = "hr_module/hr_main.php?date=";	?>
	<body onLoad="needToConfirm = false; accessdenied(); return false">
</body>
<?php }
?>