<?php
session_start();
if (!isset($_SESSION['reusername'])) { echo 'Sorry You Dont Have permissions to View this Page!'; exit();}
require_once 'includes/database.php';
require_once 'includes/display.php';
require_once 'includes/funcs.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>QPL | Risk Note </title>
<script type="text/javascript" src="js/jquery-1.10.2.js"></script>
<script type="text/javascript" language="javascript" src="js/jquery.dataTables.js"></script>
<link rel="stylesheet" type="text/css" href="css/jquery.dataTables.css">
<link rel="stylesheet" type="text/css" href="css/allcss.css">
<style>
html, body {margin:0; padding:0; height:100%; width:100%; min-width:100%; min-height:100%; overflow:scroll;z-index: 100;}  
#insform {
text-align: left;
width:90%;
background: #AAFFD4;
margin: 5px; padding-left:5px; padding-right:5px;
border: 1px solid #666; 
font-family:"Tahoma", Arial, Helvetica, sans-serif;
font-size:12px;
text-wrap: none;
}
</style>

</head>
<body>



<p align="center" style="font-size:24px;font-weight:bold;"> RISK NOTE DETAILS &nbsp;&nbsp; Booking No. <?php if(isset($_POST['btnaddins'])) { $insno = $_POST['insno']; } else { $insno = $_GET['insno']; } echo $insno; ?> </p>
<form id="insform" method="post" onkeypress="return event.keyCode!=13" enctype="multipart/form-data" action="risknote.php" >
<?php 
if(isset($_POST['btnaddins'])) {
	$insno = $_POST['insno'];
	$useofveh1 = $_POST['useofveh1'];
	$useofveh2 = $_POST['useofveh2'];
	$covers1 = $_POST['covers1'];
	$covers2 = $_POST['covers2'];	
	$covers3 = $_POST['covers3'];	
	$covers4 = $_POST['covers4'];
	$covers5 = $_POST['covers5'];	
	$covers6 = $_POST['covers6'];	
	$covers7 = $_POST['covers7'];	
	$covers8 = $_POST['covers8'];
	$subj1 = $_POST['subj1'];	
	$subj2 = $_POST['subj2'];	
	$subj3 = $_POST['subj3'];	
	$subj4 = $_POST['subj4'];
	$subj5 = $_POST['subj5'];	
	$subj6 = $_POST['subj6'];	
	$subj7 = $_POST['subj7'];	
	$subj8 = $_POST['subj8'];
	$sumcov1 = $_POST['sumcov1'];	
	$sumcov2 = $_POST['sumcov2'];	
	$sumcov3 = $_POST['sumcov3'];
	$excess1 = $_POST['excess1'];	
	$excess2 = $_POST['excess2'];	
	$excess3 = $_POST['excess3'];	
	$excess4 = $_POST['excess4'];
	$excess5 = $_POST['excess5'];	
	$excess6 = $_POST['excess6'];	
	$excess7 = $_POST['excess7'];	
	$excess8 = $_POST['excess8'];
	$liab1a = $_POST['liab1a'];	
	$liab2a = $_POST['liab2a'];	
	$liab3a = $_POST['liab3a'];	
	$liab4a = $_POST['liab4a'];	
	$liab5a = $_POST['liab5a'];
	$liab6a = $_POST['liab6a'];	
	$liab7a = $_POST['liab7a'];	
	$liab8a = $_POST['liab8a']; 	
	$liab9a = $_POST['liab9a'];	
	$liab10a = $_POST['liab10a'];
	$liab1b = $_POST['liab1b'];	
	$liab2b = $_POST['liab2b'];	
	$liab3b = $_POST['liab3b'];	
	$liab4b = $_POST['liab4b'];	
	$liab5b = $_POST['liab5b'];
	$liab6b = $_POST['liab6b'];	
	$liab7b = $_POST['liab7b'];	
	$liab8b = $_POST['liab8b']; 	
	$liab9b = $_POST['liab9b'];	
	$liab10b = $_POST['liab10b'];
	$db=new MySQLDatabase();
	$db->open_connection();
	$qry = "UPDATE insrecs SET useofveh1 ='".$useofveh1."', useofveh2 ='".$useofveh2."', covers1='".$covers1."', covers2='".$covers2."', covers3='".$covers3."', covers4='".$covers4."', covers5='".$covers5."', covers6='".$covers6."', covers7='".$covers7."', covers8='".$covers8."', subj1='".$subj1."', subj2='".$subj2."', subj3='".$subj3."', subj4='".$subj4."', subj5='".$subj5."', subj6='".$subj6."', subj7='".$subj7."', subj8='".$subj8."', 
			excess1='".$excess1."', excess2='".$excess2."', excess3='".$excess3."', excess4='".$excess4."', excess5='".$excess5."', excess6='".$excess6."', excess7='".$excess7."', excess8='".$excess8."', sumcov1='".$sumcov1."', sumcov2='".$sumcov2."', sumcov3='".$sumcov3."',
			liab1a='".$liab1a."', liab2a='".$liab2a."', liab3a='".$liab3a."', liab4a='".$liab4a."', liab5a='".$liab5a."', liab6a='".$liab6a."', liab7a='".$liab7a."', liab8a='".$liab8a."', liab9a='".$liab9a."', liab10a='".$liab10a."', liab1b='".$liab1b."', liab2b='".$liab2b."', liab3b='".$liab3b."', liab4b='".$liab4b."', liab5b='".$liab5b."', liab6b='".$liab6b."', liab7b='".$liab7b."', liab8b='".$liab8b."', liab9b='".$liab9b."', liab10b='".$liab10b."' WHERE insno='".$insno."';";
	$sql = mysqli_query($db->connection, $qry) or die (mysqli_error($db->connection) );
	echo '<script>window.close();</script>';
}

elseif(isset($_GET['insno'])) {
	$user = $_SESSION['reusername'];
	$db=new MySQLDatabase();
	$db->open_connection();
	$sql = mysqli_query($db->connection, "SELECT * FROM insrecs WHERE insno = '$insno';") or die (mysqli_error($db->connection) );
	if ($row = mysqli_fetch_array($sql, MYSQLI_ASSOC)){ if(($row['covers1'] === '') || empty($row['covers1']) ) { $sql = mysqli_query($db->connection, "SELECT * FROM risknote;") or die (mysqli_error($db->connection) );}
					     else { $sql = mysqli_query($db->connection, "SELECT * FROM insrecs WHERE insno = '$insno';") or die (mysqli_error($db->connection) ); }
	}

	if ($row = mysqli_fetch_array($sql, MYSQLI_ASSOC)){
		echo '<table id="insf" style="width:90%;margin-left:20px;border: 1px solid #666;">';
		echo '<tr style="font-weight:bold;"><td>Use of Vehicle</td> <td><input type="text" id="useofveh1" name="useofveh1" value="'.$row['useofveh1'].'" size="40"/></td> <td><input type="text" id="useofveh2" name="useofveh2" value="'.$row['useofveh2'].'" size="40"/></td></tr>';
		echo '<tr style="font-weight:bold;"><td> </td> <td>Cover Includes</td> <td>Subject To</td></tr>';
		echo '<tr><td></td> <td><input type="text" id="covers1" name="covers1" value="'.$row['covers1'].'" size="40"/></td>  <td><input type="text" id="subj1" name="subj1" value="'.$row['subj1'].'" size="40"/></td></tr>';
		echo '<tr><td></td> <td><input type="text" id="covers2" name="covers2" value="'.$row['covers2'].'" size="40"/></td>  <td><input type="text" id="subj2" name="subj2" value="'.$row['subj2'].'" size="40"/></td></tr>';
		echo '<tr><td></td> <td><input type="text" id="covers3" name="covers3" value="'.$row['covers3'].'" size="40"/></td>  <td><input type="text" id="subj3" name="subj3" value="'.$row['subj3'].'" size="40"/></td></tr>';
		echo '<tr><td></td> <td><input type="text" id="covers4" name="covers4" value="'.$row['covers4'].'" size="40"/></td>  <td><input type="text" id="subj4" name="subj4" value="'.$row['subj4'].'" size="40"/></td></tr>';
		echo '<tr><td></td> <td><input type="text" id="covers5" name="covers5" value="'.$row['covers5'].'" size="40"/></td>  <td><input type="text" id="subj5" name="subj5" value="'.$row['subj5'].'" size="40"/></td></tr>';
		echo '<tr><td></td> <td><input type="text" id="covers6" name="covers6" value="'.$row['covers6'].'" size="40"/></td>  <td><input type="text" id="subj6" name="subj6" value="'.$row['subj6'].'" size="40"/></td></tr>';
		echo '<tr><td></td> <td><input type="text" id="covers7" name="covers7" value="'.$row['covers7'].'" size="40"/></td>  <td><input type="text" id="subj7" name="subj7" value="'.$row['subj7'].'" size="40"/></td></tr>';
		echo '<tr><td></td> <td><input type="text" id="covers8" name="covers8" value="'.$row['covers8'].'" size="40"/></td>  <td><input type="text" id="subj8" name="subj8" value="'.$row['subj8'].'" size="40"/></td></tr>';
		echo '<tr><td style="font-weight:bold;">Summary of Cover</td> <td colspan="2"><input type="text" id="sumcov1" name="sumcov1" value="'.$row['sumcov1'].'" size="70"/></td> </tr>';
		echo '<tr><td></td> <td colspan="2"><input type="text" id="sumcov2" name="sumcov2" value="'.$row['sumcov2'].'" size="70"/></td> </tr>';
		echo '<tr><td></td> <td colspan="2"><input type="text" id="sumcov3" name="sumcov3" value="'.$row['sumcov3'].'" size="70"/></td> </tr>';
		echo '<tr><td style="font-weight:bold;">Excess Applicable</td> <td colspan="2"><input type="text" id="excess1" name="excess1" value="'.$row['excess1'].'" size="70"/></td> </tr>';
		echo '<tr><td></td> <td colspan="2"><input type="text" id="excess2" name="excess2" value="'.$row['excess2'].'" size="70"/></td> </tr>';
		echo '<tr><td></td> <td colspan="2"><input type="text" id="excess3" name="excess3" value="'.$row['excess3'].'" size="70"/></td> </tr>';
		echo '<tr><td></td> <td colspan="2"><input type="text" id="excess4" name="excess4" value="'.$row['excess4'].'" size="70"/></td> </tr>';
		echo '<tr><td></td> <td colspan="2"><input type="text" id="excess5" name="excess5" value="'.$row['excess5'].'" size="70"/></td> </tr>';
		echo '<tr><td></td> <td colspan="2"><input type="text" id="excess6" name="excess6" value="'.$row['excess6'].'" size="70"/></td> </tr>';
		echo '<tr><td></td> <td colspan="2"><input type="text" id="excess7" name="excess7" value="'.$row['excess7'].'" size="70"/></td> </tr>';
		echo '<tr><td></td> <td colspan="2"><input type="text" id="excess8" name="excess8" value="'.$row['excess8'].'" size="70"/></td> </tr>';
		echo '<tr><td style="font-weight:bold;">Limits of Liability</td> <td><input type="text" id="liab1a" name="liab1a" value="'.$row['liab1a'].'" size="30"/></td> <td><input type="text" id="liab1b" name="liab1b" value="'.$row['liab1b'].'" size="30"/></td> </tr>';
		echo '<tr><td></td> <td><input type="text" id="liab2a" name="liab2a" value="'.$row['liab2a'].'" size="30"/></td> <td><input type="text" id="liab2b" name="liab2b" value="'.$row['liab2b'].'" size="30"/></td> </tr>';
		echo '<tr><td></td> <td><input type="text" id="liab3a" name="liab3a" value="'.$row['liab3a'].'" size="30"/></td> <td><input type="text" id="liab3b" name="liab3b" value="'.$row['liab3b'].'" size="30"/></td> </tr>';
		echo '<tr><td></td> <td><input type="text" id="liab4a" name="liab4a" value="'.$row['liab4a'].'" size="30"/></td> <td><input type="text" id="liab4b" name="liab4b" value="'.$row['liab4b'].'" size="30"/></td> </tr>';
		echo '<tr><td></td> <td><input type="text" id="liab5a" name="liab5a" value="'.$row['liab5a'].'" size="30"/></td> <td><input type="text" id="liab5b" name="liab5b" value="'.$row['liab5b'].'" size="30"/></td> </tr>';
		echo '<tr><td></td> <td><input type="text" id="liab6a" name="liab6a" value="'.$row['liab6a'].'" size="30"/></td> <td><input type="text" id="liab6b" name="liab6b" value="'.$row['liab6b'].'" size="30"/></td> </tr>';
		echo '<tr><td></td> <td><input type="text" id="liab7a" name="liab7a" value="'.$row['liab7a'].'" size="30"/></td> <td><input type="text" id="liab7b" name="liab7b" value="'.$row['liab7b'].'" size="30"/></td> </tr>';
		echo '<tr><td></td> <td><input type="text" id="liab8a" name="liab8a" value="'.$row['liab8a'].'" size="30"/></td> <td><input type="text" id="liab8b" name="liab8b" value="'.$row['liab8b'].'" size="30"/></td> </tr>';
		echo '<tr><td></td> <td><input type="text" id="liab9a" name="liab9a" value="'.$row['liab9a'].'" size="30"/></td> <td><input type="text" id="liab9b" name="liab9b" value="'.$row['liab9b'].'" size="30"/></td> </tr>';
		echo '<tr><td></td> <td><input type="text" id="liab10a" name="liab10a" value="'.$row['liab10a'].'" size="30"/></td> <td><input type="text" id="liab10b" name="liab10b" value="'.$row['liab10b'].'" size="30"/> <input type="hidden" id="insno" name="insno" value="'.$insno.'"/></td> </tr>';
		echo '</table>';
    }
	echo '<p align="center"><input type="submit" class="text ui-widget-content ui-corner-all" style="width:160px;font-weight:bold;"  id="btnaddins" name="btnaddins" value="Save Risks"/></p>';
}
?> 

</form>

</body></html>

<script type="text/javascript">       

</script>
