<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<?php
include('../include/session.php');
require_once('../include/tc_calendar.php');

$warning_id = $_GET['warning_id'];

$table_name = $_SESSION['db_prefix']."_warnings";
$warning_query = "SELECT  *  FROM $table_name WHERE warning_id = '".$warning_id."' ";
$warning_result = mySQL_query($warning_query);
$warning_num = mysql_num_rows($warning_result);
$w0 = mysql_result($warning_result, 0, "emp_id");
$w1 = mysql_result($warning_result, 0, "warning");
$w2 = mysql_result($warning_result, 0, "offence");
$w3 = mysql_result($warning_result, 0, "warning_date");
$w4 = mysql_result($warning_result, 0, "exp_date");
$w5 = mysql_result($warning_result, 0, "warning_text");
$w6 = mysql_result($warning_result, 0, "issued_by");
$w7 = mysql_result($warning_result, 0, "additional_notes");	
	
$table_name2 = $_SESSION['db_prefix']."_employee";
$employee_query = "SELECT emp_first_name, emp_last_name FROM $table_name2 WHERE emp_id ='".$w0."' ";
$employee_result = mySQL_query($employee_query);
$employee_num = mysql_num_rows($employee_result);	
$a0 = mysql_result($employee_result, 0, "emp_first_name");
$a1 = mysql_result($employee_result, 0, "emp_last_name");

require_once('../include/tc_calendar.php');
$warning_date = strtotime($w3);
$d1 = date("d", $warning_date ) ;
$m1 = date("m", $warning_date ) ;
$y1 = date("Y", $warning_date ) ;

$expiry_date = strtotime($w4);
$d2 = date("d", $expiry_date ) ;
$m2 = date("m", $expiry_date ) ;
$y2 = date("Y", $expiry_date ) ;

$table_name = $_SESSION['db_prefix']."_list_warnings";
    $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_names_discipline";
    $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++;
	}
	}
?>
<script language="javascript" src="../jscript/calendar.js"></script>
<script src="../jscript/nicEdit.js" type="text/javascript"></script>
<script language="JavaScript" src="../jscript/cancel_confirmation.js"  type="text/javascript"></script> 
<script type="text/javascript">
bkLib.onDomLoaded(function() {
	new nicEditor().panelInstance('warning_text');
	//new nicEditor({fullPanel : true}).panelInstance('warning_text');
	//new nicEditor({iconsPath : '../jscript/nicEditorIcons.gif'}).panelInstance('warning_text');
	//new nicEditor({buttonList : ['fontSize','bold','italic','underline','strikeThrough','subscript','superscript','html','image']}).panelInstance('warning_text');
	//new nicEditor({maxHeight : 100}).panelInstance('warning_text');
});
</script>

<body>
<?php
include ("../navigation/header.php");
$page_name = "HR-main";
include ("../navigation/access.php");

if ($permission_num==1) {
	include ("../navigation/hr_sidebar.php");
?>
<div class="main_frame">
  <div class="page_head_frame">
    <table width="809" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><label class="label_page_head">Warning </label><label class="label_page_head_2"><?php echo $a0." ".$a1 ?></label></td>
            </tr>
        </table>
      </div>
        <br />

<br />
<form action="edit_warning_details_save.php" method="POST">
<div class="page_middle_frame">
<div class="page_inside_frame">
<div align="left">Employee details</div>
  <table width="650" id="table_details_display">
    <tr>
      <td width="151" height="25">Employee name:</td>
      <td width="646"><b><?php echo $a0." ". $a1?></b></td>
      </tr>
    </table>
</div>

<div class="page_inside_frame">
<div align="left">Warning</div>
  <table width="650" id="table_details_display">
    <tr>
      <td width="125" height="25">Date</td>
      <td><b>
        <?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, 2020);
		//output the calendar
		$myCalendar->writeScript();
?>
      </b></td>
      </tr>
    <tr>
      <td height="25">Expiry date:</td>
      <td><b>
        <?php 
				  //instantiate class and set properties
		$myCalendar = new tc_calendar("expiry_date", true);
		$myCalendar->setIcon("../images/iconCalendar.gif");
		$myCalendar->setDate($d2, $m2, $y2);
		$myCalendar->setYearInterval(2010, 2020);
		//output the calendar
		$myCalendar->writeScript();
?>
      </b></td>
      </tr>
    <tr>
      <td height="25">Warning type:</td>
      <td><b>
        <select name="warning_select" id="warning_select" class="select200">
          <option value="Verbal warning">Verbal warning</option>
          <option value="Written warning">Written warning</option>
          <option value="Final warning">Final warning</option>
          <option value="<?php echo $w1 ?>" selected="selected"><?php echo $w1 ?></option>
        </select>
      </b></td>
      </tr>
    <tr>
      <td height="25">Offence:</td>
      <td><select name="offence_select" class="select200"  >
        <option value="<?php echo $w2?>" selected="selected"><?php echo $w2?></option>
          <?php
        	for ($j = 0; $j < count($arrId1); $j++) {
    		echo "<option value=" . "\"" . $arrId1[$j] . "\"" . ">" . $arrName1[$j] . "</option>";
	}
?>
        </select>
      </td>
      </tr>
    <tr>
      <td height="25" valign="top">Warning:</td>
      <td valign="top">
        <textarea name="warning_text" cols="70" rows="5" id="warning_text" style="width:550px; min-height:300px;"><?php echo $w5?></textarea>
      </td>
    </tr>
    </table>
</div>

<div class="page_inside_frame">
  <div align="left">Warning given</div>
  <table width="650" id="table_details_display">
    <tr>
      <td width="126" height="25">Warning given by:</td>
      <td width="527"><b>
        <select name="issued_select" class="select150"  >
          <option value="<?php echo $w6?>" selected="selected"><?php echo $w6?></option>
          <?php
        	for ($j = 0; $j < count($arrId2); $j++) {
    		echo "<option value=" . "\"" . $arrId2[$j] . "\"" . ">" . $arrName2[$j] . "</option>";
	}
?>
        </select>
      </b></td>
      </tr>
  </table>
</div>

<div class="page_inside_frame">
Additional notes (not printed on warning):  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<textarea name="additional_notes_text" cols="80" rows="3" class="text_box"><?php echo $w7 ?></textarea>
</div>

<div class="page_inside_frame">
  <table width="645" border="0">
    <tr>
      <td width="20"></td>
      <td width="615" align="right"><input type="hidden" name="warning_id_text" id="warning_id_text" value="<?php echo $warning_id ?>" />
        <input name="button2" type="button" class="imagebutton" id="button2" onclick="cancel_confirmation(3, '../hr_module/hr_main.php?date=0');" value="Close"/>
        <input name="save_button"  id="save_button" type="submit" class="imagebutton" value="Save" onclick="needToConfirm = false; confirmRefresh();" />
        <input name="save_close_button"  id="save_close_button" type="submit" class="imagebutton" value="Save &amp; Close" onclick="needToConfirm = false; confirmRefresh();" /></td>
    </tr>
  </table>
</div>

  
</div>
</form>
</div>
</body>
<?php } else {
$_SESSION['denied_return'] = "hr_module/employee_list.php";	
include ("../navigation/hr_sidebar.php");?>
	<body onload="accessdenied(); return false">
	</body>
<?php }
?>
<?php include ('../navigation/side_bar.php'); ?>

</html>