<?php session_start();?>

<?php
	if($_SESSION ["role"]=="Administrator")
	{
		$role = $_SESSION["role"];
		$email = $_SESSION["email"];
		// header('location:form.php');
	}
	else
	{
		header('location:index.php?expired session please login back');
		// $userName = $_SESSION["userName"]; $userRole = $_SESSION["userRole"];
		}
?>
<?

require ("_common/global.php");
require ("_common/conn.php");
//require ("_common/function.php");
require ("_common/check_session.php");
?>
<?php
$idvac =$_REQUEST['idvac'];
$email =$_SESSION['email'];
/* Attempt MySQL server connection. Assuming you are running MySQL
server with default setting (user 'root' with no password) */
$link = mysqli_connect("localhost", "dvsvigov_vacc", "DVSvacdos123", "dvsvigov_vacdos");
 
// Check connection
if($link === false){
    die("ERROR: Could not connect. " . mysqli_connect_error());
}
// Escape user inputs for security
// $fName = mysqli_real_escape_string($link, $_POST['fName']);
//$tradename = mysqli_real_escape_string ($link, $_POST['tradename']);
//$manufacturername = mysqli_real_escape_string($link, $_POST['manufacturername']);
//$locagentadd = mysqli_real_escape_string($link, $_POST['locagentadd']);
//$loacagentphone = mysqli_real_escape_string($link, $_POST['loacagentphone']);
//$plantaff = mysqli_real_escape_string($link, $_POST['plantaff']);
//$mainplant = mysqli_real_escape_string($link, $_POST['mainplant']);
//$vacctype = mysqli_real_escape_string($link, $_POST['vacctype']);

	$AssessA = $_POST['AssessA'] ;
	$AssessB = $_POST['AssessB'] ;
	$AssessC = $_POST['AssessC'] ;
	$assignby = $_POST['assignby'] ;
	$idvac = $_POST['idvac'] ;	
	$dateassign = $_POST['dateassign'] ;	
	
	$tradename = $_POST['tradename'] ;
	$manufacturername = $_POST['manufacturername'] ;
	$plantaff = $_POST['plantaff'] ;
	$mainplant = $_POST['mainplant'] ;
	$vacctype = $_POST['vacctype'] ;
	//$statusassign = $_POST['statusassign'] ;
	
// attempt insert query execution
$sql = "UPDATE vacc SET AssessA='$AssessA', AssessB='$AssessB', AssessC='$AssessC', assignby='$assignby', dateassign='$dateassign' WHERE idvac = '$idvac'";
$sql2 = "INSERT IGNORE INTO dossierform (idvac, Assess, AssessNo, tradename, manufacturername, plantaff, mainplant, vacctype) VALUES ('$idvac', '$AssessA', 'A', '$tradename', '$manufacturername', '$plantaff', '$mainplant', '$vacctype')";
$sql3 = "INSERT IGNORE INTO dossierform (idvac, Assess, AssessNo, tradename, manufacturername, plantaff, mainplant, vacctype) VALUES ('$idvac', '$AssessB', 'B', '$tradename', '$manufacturername', '$plantaff', '$mainplant', '$vacctype')";
$sql4 = "INSERT IGNORE INTO dossierform (idvac, Assess, AssessNo, tradename, manufacturername, plantaff, mainplant, vacctype) VALUES ('$idvac', '$AssessC', 'C', '$tradename', '$manufacturername', '$plantaff', '$mainplant', '$vacctype')";
$sql5 = "UPDATE dossierform SET statusform='Draft' WHERE idvac='$idvac'";
$sql6 = "UPDATE vacc SET statusassign='Yes' WHERE idvac='$idvac'";
mysqli_query($link, $sql);
mysqli_query($link, $sql2);
mysqli_query($link, $sql3);
mysqli_query($link, $sql4);
mysqli_query($link, $sql5);
mysqli_query($link, $sql6);
header('location: assignevaluator.php');
mysqli_close($link);
?>
