<!--jscript-->
<script language="javascript" src="../jscript/calendar.js"></script>
<?php
$today = date("Y-m-d");  
require_once('../include/tc_calendar.php');
$warning_date = strtotime($_SESSION['warning_date']);
$d1 = date("d", $warning_date ) ;
$m1 = date("m", $warning_date ) ;
$y1 = date("Y", $warning_date ) ;

$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++;
  }
}
   
?>
</head>

<?php include('../include/wait.php') ?>
<body onLoad="MM_showHideLayers('wait','','hide')" onFocus="MM_showHideLayers('wait','','hide');">


<div class="wizard_page_middle_frame">
  <form id="feedbackform" method="get" action="warningWizbase.php">
    <div class="wizard_frame">
        <table width="613" height="84" id="table_display_wizard">
                <tr>
                  <td height="45" valign="middle">Select employee:&nbsp;&nbsp;<label class="star">*</label></td>
                  <td valign="middle"><select name="employee_select" id="employee_select" class="select200" >
                    <option value="<?php echo $_SESSION['emp_id']?>" ><?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>
                <tr>
                  <td width="253" height="45" valign="middle"><label class="label_std">Date of warning:</label>
&nbsp;&nbsp;
<label class="star">*</label></td>
                  <td width="348" valign="middle"><?php 
          //instantiate class and set properties
    $myCalendar = new tc_calendar("warning_date", true);
    $myCalendar->setIcon("../images/iconCalendar.gif");
    $myCalendar->setDate($d1, $m1, $y1);
    $myCalendar->setYearInterval(2010, 2099);
    //output the calendar
    $myCalendar->writeScript();
?></td>
                  </tr>
              </table>
            </div>
    <div class="wizard_spacer_frame" style="height:95px;"></div>
            <div class="wizard_frame">
              <table width="640" height="50" align="center" id="table_button_bar">
                <tr>
                  <td width="117"><input type="button" name="lastprev_button" class="imagebutton" value="Prev" onClick="needToConfirm = false; MM_goToURL('parent','warningWizbase.php?s=&p=1');return document.MM_returnValue; MM_showHideLayers('wait','','show');" /></td>
                  <td width="115">&nbsp;</td>
                  <td width="99">
                    <input name="p" type="hidden" id="p" value="1" />
                    <input name="s" type="hidden" id="s" value="1" />
                  </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'); MM_showHideLayers('wait','','show');" 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>
</div>
<!--form validation-->
  <script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("feedbackform");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("employee_select","req","Please select an employee.");
  
  </script>
