<?php
include("../include/session.php");
if(!$session->isRadstoneReceptionUser() && !$session->isAdmin()){
	header("Location: ../HR/employeeMenu.php");
}else{
$empId = mysql_real_escape_string($_POST['empId']);
$vioType = mysql_real_escape_string($_POST['vioType']);
$vioDetails = mysql_real_escape_string($_POST['vioDetails']);
$vioDate = isset($_REQUEST["date1"]) ? $_REQUEST["date1"] : "";
$warnings = mysql_real_escape_string($_POST['warnings']);

if($warnings == "firstWarning"){
	$warning = "Verbal Warning";
}elseif($warnings == "writtenWarning"){
	$warning = "Written Warning";
}elseif($warnings == "finalWarning"){
	$warning = "Final Warning";	
}else{
	$warning = "Comment";
}

include("../include/db.php");
$query = "INSERT INTO nam_minorviolations (empId, vioType, vioDetails, vioDate, warning) VALUES ('".$empId."', '".$vioType."', '".$vioDetails."','".$vioDate."', '$warning')";
execsql($query);

if($warnings != ""){
	$q = "UPDATE nam_employees SET $warnings = 'YES' WHERE empId = '$empId'";
	execsql($q);
}
$return = mysql_real_escape_string($_POST['submitok']);
if ($return == "Save and New") {
				$cat = mysql_real_escape_string($_POST['cat']);
				header("Location: addMinorVio.php?date=$vioDate");
			} else {
				header("Location: searchAndDisplayE.php?id=$empId&type=discipline");
			}
}
?>
