<?php session_start();?>

<?php
	if($_SESSION ["role"]=="Evaluator")
	{
		$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
/* 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']);
$idvac = mysqli_real_escape_string ($link, $_POST['idvac']);
$vacctype = mysqli_real_escape_string ($link, $_POST['vacctype']);
$Assess = mysqli_real_escape_string($link, $_POST['Assess']);
$datesubmit = mysqli_real_escape_string($link, $_POST['datesubmit']);
$Q1 = mysqli_real_escape_string($link, $_POST['Q1']);
$Q1comment = mysqli_real_escape_string($link, $_POST['Q1comment']);
$Q1AI = mysqli_real_escape_string($link, $_POST['Q1AI']);
$Q2 = mysqli_real_escape_string($link, $_POST['Q2']);
$Q2comment = mysqli_real_escape_string($link, $_POST['Q2comment']);
$Q2AI = mysqli_real_escape_string($link, $_POST['Q2AI']);
$Q3 = mysqli_real_escape_string($link, $_POST['Q3']);
$Q3comment = mysqli_real_escape_string($link, $_POST['Q3comment']);
$Q3AI = mysqli_real_escape_string($link, $_POST['Q3AI']);
$Q4 = mysqli_real_escape_string($link, $_POST['Q4']);
$Q4comment = mysqli_real_escape_string($link, $_POST['Q4comment']);
$Q4AI = mysqli_real_escape_string($link, $_POST['Q4AI']);
$Q5 = mysqli_real_escape_string($link, $_POST['Q5']);
$Q5comment = mysqli_real_escape_string($link, $_POST['Q5comment']);
$Q5AI = mysqli_real_escape_string($link, $_POST['Q5AI']);
$Q6 = mysqli_real_escape_string($link, $_POST['Q6']);
$Q6comment = mysqli_real_escape_string($link, $_POST['Q6comment']);
$Q6AI = mysqli_real_escape_string($link, $_POST['Q6AI']);
$Q7 = mysqli_real_escape_string($link, $_POST['Q7']);
$Q7comment = mysqli_real_escape_string($link, $_POST['Q7comment']);
$Q7AI = mysqli_real_escape_string($link, $_POST['Q7AI']);
$Q8 = mysqli_real_escape_string($link, $_POST['Q8']);
$Q8comment = mysqli_real_escape_string($link, $_POST['Q8comment']);
$Q8AI = mysqli_real_escape_string($link, $_POST['Q8AI']);
$Q9 = mysqli_real_escape_string($link, $_POST['Q9']);
$Q9comment = mysqli_real_escape_string($link, $_POST['Q9comment']);
$Q9AI = mysqli_real_escape_string($link, $_POST['Q9AI']);
$Q10 = mysqli_real_escape_string($link, $_POST['Q10']);
$Q10comment = mysqli_real_escape_string($link, $_POST['Q10comment']);
$Q10AI = mysqli_real_escape_string($link, $_POST['Q10AI']);
$Q11 = mysqli_real_escape_string($link, $_POST['Q11']);
$Q11comment = mysqli_real_escape_string($link, $_POST['Q11comment']);
$Q11AI = mysqli_real_escape_string($link, $_POST['Q11AI']);
$Q12 = mysqli_real_escape_string($link, $_POST['Q12']);
$Q12comment = mysqli_real_escape_string($link, $_POST['Q12comment']);
$Q12AI = mysqli_real_escape_string($link, $_POST['Q12AI']);
$Q13 = mysqli_real_escape_string($link, $_POST['Q13']);
$Q13comment = mysqli_real_escape_string($link, $_POST['Q13comment']);
$Q13AI = mysqli_real_escape_string($link, $_POST['Q13AI']);
$Q14 = mysqli_real_escape_string($link, $_POST['Q14']);
$Q14comment = mysqli_real_escape_string($link, $_POST['Q14comment']);
$Q14AI = mysqli_real_escape_string($link, $_POST['Q14AI']);
$Q15 = mysqli_real_escape_string($link, $_POST['Q15']);
$Q15comment = mysqli_real_escape_string($link, $_POST['Q15comment']);
$Q15AI = mysqli_real_escape_string($link, $_POST['Q15AI']);
$Q16 = mysqli_real_escape_string($link, $_POST['Q16']);
$Q16comment = mysqli_real_escape_string($link, $_POST['Q16comment']);
$Q16AI = mysqli_real_escape_string($link, $_POST['Q16AI']);
$Q17 = mysqli_real_escape_string($link, $_POST['Q17']);
$Q17comment = mysqli_real_escape_string($link, $_POST['Q17comment']);
$Q17AI = mysqli_real_escape_string($link, $_POST['Q17AI']);
$Q18 = mysqli_real_escape_string($link, $_POST['Q18']);
$Q18comment = mysqli_real_escape_string($link, $_POST['Q18comment']);
$Q18AI = mysqli_real_escape_string($link, $_POST['Q18AI']);
$Q19 = mysqli_real_escape_string($link, $_POST['Q19']);
$Q19comment = mysqli_real_escape_string($link, $_POST['Q19comment']);
$Q19AI = mysqli_real_escape_string($link, $_POST['Q19AI']);
$Q20 = mysqli_real_escape_string($link, $_POST['Q20']);
$Q20comment = mysqli_real_escape_string($link, $_POST['Q20comment']);
$Q20AI = mysqli_real_escape_string($link, $_POST['Q20AI']);
$Q21 = mysqli_real_escape_string($link, $_POST['Q21']);
$Q21comment = mysqli_real_escape_string($link, $_POST['Q21comment']);
$Q21AI = mysqli_real_escape_string($link, $_POST['Q21AI']);
$Q22 = mysqli_real_escape_string($link, $_POST['Q22']);
$Q22comment = mysqli_real_escape_string($link, $_POST['Q22comment']);
$Q22AI = mysqli_real_escape_string($link, $_POST['Q22AI']);
$Q23 = mysqli_real_escape_string($link, $_POST['Q23']);
$Q23comment = mysqli_real_escape_string($link, $_POST['Q23comment']);
$Q23AI = mysqli_real_escape_string($link, $_POST['Q23AI']);
$Q24 = mysqli_real_escape_string($link, $_POST['Q24']);
$Q24comment = mysqli_real_escape_string($link, $_POST['Q24comment']);
$Q24AI = mysqli_real_escape_string($link, $_POST['Q24AI']);
$Q25 = mysqli_real_escape_string($link, $_POST['Q25']);
$Q25comment = mysqli_real_escape_string($link, $_POST['Q25comment']);
$Q25AI = mysqli_real_escape_string($link, $_POST['Q25AI']);
$Q26 = mysqli_real_escape_string($link, $_POST['Q26']);
$Q26comment = mysqli_real_escape_string($link, $_POST['Q26comment']);
$Q26AI = mysqli_real_escape_string($link, $_POST['Q26AI']);
$Q27 = mysqli_real_escape_string($link, $_POST['Q27']);
$Q27comment = mysqli_real_escape_string($link, $_POST['Q27comment']);
$Q27AI = mysqli_real_escape_string($link, $_POST['Q27AI']);
$Q28 = mysqli_real_escape_string($link, $_POST['Q28']);
$Q28comment = mysqli_real_escape_string($link, $_POST['Q28comment']);
$Q28AI = mysqli_real_escape_string($link, $_POST['Q28AI']);
$Q29 = mysqli_real_escape_string($link, $_POST['Q29']);
$Q29comment = mysqli_real_escape_string($link, $_POST['Q29comment']);
$Q29AI = mysqli_real_escape_string($link, $_POST['Q29AI']);
$Q30 = mysqli_real_escape_string($link, $_POST['Q30']);
$Q30comment = mysqli_real_escape_string($link, $_POST['Q30comment']);
$Q30AI = mysqli_real_escape_string($link, $_POST['Q30AI']);
$Q31 = mysqli_real_escape_string($link, $_POST['Q31']);
$Q31comment = mysqli_real_escape_string($link, $_POST['Q31comment']);
$Q31AI = mysqli_real_escape_string($link, $_POST['Q31AI']);
$Q32 = mysqli_real_escape_string($link, $_POST['Q32']);
$Q32comment = mysqli_real_escape_string($link, $_POST['Q32comment']);
$Q32AI = mysqli_real_escape_string($link, $_POST['Q32AI']);
$Q33 = mysqli_real_escape_string($link, $_POST['Q33']);
$Q33comment = mysqli_real_escape_string($link, $_POST['Q33comment']);
$Q33AI = mysqli_real_escape_string($link, $_POST['Q33AI']);
$Q34 = mysqli_real_escape_string($link, $_POST['Q34']);
$Q34comment = mysqli_real_escape_string($link, $_POST['Q34comment']);
$Q34AI = mysqli_real_escape_string($link, $_POST['Q34AI']);
$Q35 = mysqli_real_escape_string($link, $_POST['Q35']);
$Q35comment = mysqli_real_escape_string($link, $_POST['Q35comment']);
$Q35AI = mysqli_real_escape_string($link, $_POST['Q35AI']);
$Q36 = mysqli_real_escape_string($link, $_POST['Q36']);
$Q36comment = mysqli_real_escape_string($link, $_POST['Q36comment']);
$Q36AI = mysqli_real_escape_string($link, $_POST['Q36AI']);
$Q37 = mysqli_real_escape_string($link, $_POST['Q37']);
$Q37comment = mysqli_real_escape_string($link, $_POST['Q37comment']);
$Q37AI = mysqli_real_escape_string($link, $_POST['Q37AI']);
$Q38 = mysqli_real_escape_string($link, $_POST['Q38']);
$Q38comment = mysqli_real_escape_string($link, $_POST['Q38comment']);
$Q38AI = mysqli_real_escape_string($link, $_POST['Q38AI']);
$Q39 = mysqli_real_escape_string($link, $_POST['Q39']);
$Q39comment = mysqli_real_escape_string($link, $_POST['Q39comment']);
$Q39AI = mysqli_real_escape_string($link, $_POST['Q39AI']);
$Q40 = mysqli_real_escape_string($link, $_POST['Q40']);
$Q40comment = mysqli_real_escape_string($link, $_POST['Q40comment']);
$Q40AI = mysqli_real_escape_string($link, $_POST['Q40AI']);
$Q41 = mysqli_real_escape_string($link, $_POST['Q41']);
$Q41comment = mysqli_real_escape_string($link, $_POST['Q41comment']);
$Q41AI = mysqli_real_escape_string($link, $_POST['Q41AI']);
$refQ1 = mysqli_real_escape_string($link, $_POST['refQ1']);
$refQ2 = mysqli_real_escape_string($link, $_POST['refQ2']);
$refQ3 = mysqli_real_escape_string($link, $_POST['refQ3']);
$refQ4 = mysqli_real_escape_string($link, $_POST['refQ4']);
$refQ5 = mysqli_real_escape_string($link, $_POST['refQ5']);
$refQ6 = mysqli_real_escape_string($link, $_POST['refQ6']);
$refQ7 = mysqli_real_escape_string($link, $_POST['refQ7']);
$refQ8 = mysqli_real_escape_string($link, $_POST['refQ8']);
$refQ9 = mysqli_real_escape_string($link, $_POST['refQ9']);
$refQ10 = mysqli_real_escape_string($link, $_POST['refQ10']);
$refQ11 = mysqli_real_escape_string($link, $_POST['refQ11']);
$refQ12 = mysqli_real_escape_string($link, $_POST['refQ12']);
$refQ13 = mysqli_real_escape_string($link, $_POST['refQ13']);
$refQ14 = mysqli_real_escape_string($link, $_POST['refQ14']);
$refQ15 = mysqli_real_escape_string($link, $_POST['refQ15']);
$refQ16 = mysqli_real_escape_string($link, $_POST['refQ16']);
$refQ17 = mysqli_real_escape_string($link, $_POST['refQ17']);
$refQ18 = mysqli_real_escape_string($link, $_POST['refQ18']);
$refQ19 = mysqli_real_escape_string($link, $_POST['refQ19']);
$refQ20 = mysqli_real_escape_string($link, $_POST['refQ20']);
$refQ21 = mysqli_real_escape_string($link, $_POST['refQ21']);
$refQ22 = mysqli_real_escape_string($link, $_POST['refQ22']);
$refQ23 = mysqli_real_escape_string($link, $_POST['refQ23']);
$refQ24 = mysqli_real_escape_string($link, $_POST['refQ24']);
$refQ25 = mysqli_real_escape_string($link, $_POST['refQ25']);
$refQ26 = mysqli_real_escape_string($link, $_POST['refQ26']);
$refQ27 = mysqli_real_escape_string($link, $_POST['refQ27']);
$refQ28 = mysqli_real_escape_string($link, $_POST['refQ28']);
$refQ29 = mysqli_real_escape_string($link, $_POST['refQ29']);
$refQ30 = mysqli_real_escape_string($link, $_POST['refQ30']);
$refQ31 = mysqli_real_escape_string($link, $_POST['refQ31']);
$refQ32 = mysqli_real_escape_string($link, $_POST['refQ32']);
$refQ33 = mysqli_real_escape_string($link, $_POST['refQ33']);
$refQ34 = mysqli_real_escape_string($link, $_POST['refQ34']);
$refQ35 = mysqli_real_escape_string($link, $_POST['refQ35']);
$refQ36 = mysqli_real_escape_string($link, $_POST['refQ36']);
$refQ37 = mysqli_real_escape_string($link, $_POST['refQ37']);
$refQ38 = mysqli_real_escape_string($link, $_POST['refQ38']);
$refQ39 = mysqli_real_escape_string($link, $_POST['refQ39']);
$refQ40 = mysqli_real_escape_string($link, $_POST['refQ40']);
$refQ41 = mysqli_real_escape_string($link, $_POST['refQ41']);
$gencomm = mysqli_real_escape_string($link, $_POST['gencomm']);
$recomm = mysqli_real_escape_string($link, $_POST['recomm']);

//Q1


// attempt insert query execution
$sql = "UPDATE dossierform SET idvac = '$idvac', Assess = '$Assess',datesubmit = '$datesubmit',Q1 = '$Q1',Q1comment = '$Q1comment',Q1AI = '$Q1AI',Q2 = '$Q2', Q2comment = '$Q2comment',Q2AI = '$Q2AI',Q3 = '$Q3',Q3comment = '$Q3comment',Q3AI = '$Q3AI',Q4 = '$Q4',Q4comment = '$Q4comment',Q4AI = '$Q4AI',Q5 = '$Q5',Q5comment = '$Q5comment',Q5AI = '$Q5AI',Q6 = '$Q6',Q6comment = '$Q6comment',Q6AI = '$Q6AI',Q7 = '$Q7',Q7comment = '$Q7comment',Q7AI = '$Q7AI',Q8 = '$Q8',Q8comment = '$Q8comment',Q8AI = '$Q8AI',Q9 = '$Q9',Q9comment = '$Q9comment',Q9AI = '$Q9AI',Q10 = '$Q10',Q10comment = '$Q10comment',Q10AI = '$Q10AI',Q11 = '$Q11',Q11comment = '$Q11comment',Q11AI = '$Q11AI',Q12 = '$Q12',Q12comment = '$Q12comment',Q12AI = '$Q12AI',Q13 = '$Q13',Q13comment = '$Q13comment',Q13AI = '$Q13AI',Q14 = '$Q14',Q14comment = '$Q14comment',Q14AI = '$Q14AI',Q15 = '$Q15',Q15comment = '$Q15comment',Q15AI = '$Q15AI',Q16 = '$Q16',Q16comment = '$Q16comment',Q16AI = '$Q16AI',Q17 = '$Q17',Q17comment = '$Q17comment',Q17AI = '$Q17AI',Q18 = '$Q18',Q18comment = '$Q18comment',Q18AI = '$Q18AI',Q19 = '$Q19',Q19comment = '$Q19comment',Q19AI = '$Q19AI',Q20 = '$Q20',Q20comment = '$Q20comment',Q20AI = '$Q20AI',Q21 = '$Q21',Q21comment = '$Q21comment',Q21AI = '$Q21AI',Q22 = '$Q22',Q22comment = '$Q22comment',Q22AI = '$Q22AI',Q23 = '$Q23',Q23comment = '$Q23comment',Q23AI = '$Q23AI',Q24 = '$Q24',Q24comment = '$Q24comment',Q24AI = '$Q24AI',Q25 = '$Q25',Q25comment = '$Q25comment',Q25AI = '$Q25AI',Q26 = '$Q26',Q26comment = '$Q26comment',Q26AI = '$Q26AI',Q27 = '$Q27',Q27comment = '$Q27comment',Q27AI = '$Q27AI',Q28 = '$Q28',Q28comment = '$Q28comment',Q28AI = '$Q28AI',Q29 = '$Q29',Q29comment = '$Q29comment',Q29AI = '$Q29AI',Q30 = '$Q30',Q30comment = '$Q30comment',Q30AI = '$Q30AI',Q31 = '$Q31',Q31comment = '$Q31comment',Q31AI = '$Q31AI',Q32 = '$Q32',Q32comment = '$Q32comment',Q32AI = '$Q32AI',Q33 = '$Q33',Q33comment = '$Q33comment',Q33AI = '$Q33AI',Q34 = '$Q34',Q34comment = '$Q34comment',Q34AI = '$Q34AI',Q35 = '$Q35',Q35comment = '$Q35comment',Q35AI = '$Q35AI',Q36 = '$Q36',Q36comment = '$Q36comment',Q36AI = '$Q36AI',Q37 = '$Q37',Q37comment = '$Q37comment',Q37AI = '$Q37AI',Q38 = '$Q38',Q38comment = '$Q38comment',Q38AI = '$Q38AI',Q39 = '$Q39',Q39comment = '$Q39comment',Q39AI = '$Q39AI',Q40 = '$Q40',Q40comment = '$Q40comment',Q40AI = '$Q40AI',Q41 = '$Q41',Q41comment = '$Q41comment',Q41AI = '$Q41AI',refQ1 = '$refQ1',refQ2 = '$refQ2',refQ3 = '$refQ3',refQ4 = '$refQ4',refQ5 = '$refQ5',refQ6 = '$refQ6',refQ7 = '$refQ7',refQ8 = '$refQ8',refQ9 = '$refQ9',refQ10 = '$refQ10',refQ11 = '$refQ11',refQ12 = '$refQ12',refQ13 = '$refQ13',refQ14 = '$refQ14',refQ15 = '$refQ15',refQ16 = '$refQ16',refQ17 = '$refQ17',refQ18 = '$refQ18',refQ19 = '$refQ19',refQ20 = '$refQ20',refQ21 = '$refQ21',refQ22 = '$refQ22',refQ23 = '$refQ23',refQ24 = '$refQ24',refQ25 = '$refQ25',refQ26 = '$refQ26',refQ27 = '$refQ27',refQ28 = '$refQ28',refQ29 = '$refQ29',refQ30 = '$refQ30',refQ31 = '$refQ31',refQ32 = '$refQ32',refQ33 = '$refQ33',refQ34 = '$refQ34',refQ35 = '$refQ35',refQ36 = '$refQ36',refQ37 = '$refQ37',refQ38 = '$refQ38',refQ39 = '$refQ39',refQ40 = '$refQ40',refQ41 = '$refQ41',gencomm = '$gencomm',recomm = '$recomm' WHERE idvac='$idvac' AND Assess='$Assess'";
 

	

if ($vacctype==Recombinant) {

//$campurA == $Q1a;
$campurA = ($Q1 + $Q2 + $Q3)/18*100;
$campurB = ($Q4 + $Q5 + $Q6)/18*100;
$campurC = ($Q7 + $Q8 + $Q9)/18*100;
$campurD = ($Q10)/6*100;
$campurE = ($Q11 + $Q12 + $Q13 + $Q14 + $Q15 + $Q16 + $Q17 + $Q18 + $Q19)/54*100;
$campurF = ($Q20 + $Q21 + $Q22 + $Q23 + $Q24 + $Q25 + $Q26 + $Q27)/48*100;
$campurG = ($Q28 + $Q29 + $Q30 + $Q31 + $Q32 + $Q33 + $Q34 + $Q35 + $Q36)/54*100;
$campurH = ($Q37 + $Q38 + $Q39 + $Q40 + $Q41)/30*100;
//$campurB = ($Q4 + $Q5 + $Q6)*100;
}

else if ($vacctype==Killed){
//$campurA == $Q1a;
$campurA = ($Q1 + $Q2 + $Q3)/18*100;
$campurB = ($Q4 + $Q5 + $Q6)/18*100;
$campurC = ($Q7 + $Q8 + $Q9)/18*100;
$campurD = ($Q10)/6*100;
$campurE = ($Q12 + $Q13 + $Q14 + $Q15 + $Q16 + $Q17 + $Q18 + $Q19)/48*100;
$campurF = ($Q20 + $Q21 + $Q22 + $Q23 + $Q24 + $Q25 + $Q26 + $Q27)/48*100;
$campurG = ($Q29 + $Q30 + $Q31 + $Q32 + $Q33 + $Q34 + $Q35)/42*100;
$campurH = ($Q37 + $Q38 + $Q39 + $Q40 + $Q41)/30*100;
//$campurB = ($Q4 + $Q5 + $Q6)*100;
}

else if ($vacctype==Live){
//$campurA == $Q1a;
$campurA = ($Q1 + $Q2 + $Q3)/18*100;
$campurB = ($Q4 + $Q5 + $Q6)/18*100;
$campurC = ($Q7 + $Q8 + $Q9)/18*100;
$campurD = ($Q10)/6*100;
$campurE = ($Q11 + $Q12 + $Q13 + $Q14 + $Q15 + $Q16 + $Q17 + $Q18 + $Q19)/54*100;
$campurF = ($Q20 + $Q22 + $Q23 + $Q25 + $Q26 + $Q27)/36*100;
$campurG = ($Q28 + $Q30 + $Q31 + $Q32 + $Q33 + $Q34 + $Q35 + $Q36)/48*100;
$campurH = ($Q37 + $Q38 + $Q39 + $Q40 + $Q41)/30*100;
//$campurB = ($Q4 + $Q5 + $Q6)*100;
}

$sql2= "UPDATE IGNORE dossierform SET sumA='$campurA', sumB='$campurB',sumC='$campurC',sumD='$campurD',sumE='$campurE',sumF='$campurF',sumG='$campurG',sumH='$campurH' WHERE idvac='$idvac' AND Assess='$Assess'";
//$sql3= "UPDATE IGNORE dossierform SET sumB = '$campurB' WHERE idvac='$idvac' AND Assess='$Assess'";
mysqli_query($link, $sql);
mysqli_query($link, $sql2);
//mysqli_query($link, $sql3);
header('location: dossierform.php?idvac='.$idvac.'');
mysqli_close($link);
?>
