<?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>
<?php 

echo '<p><a href="#" id="printnow" class="printnow" onclick="myprint();" style="float:left;">Print</a>
<a href="#" id="closenow" class="closenow" onclick="window.close();">Close</a></p>
<div id="printblk">';
echo '<table id="insf" cellpadding="3px" style="width:90%;margin-left:20px;margin-right:10px;border-collapse:collapse;font-size:11px;font-family:Arial;border: 2px solid #666;">';
echo '<tr><td><img style="vertical-align:top;margin:15px;" src="images/inslogo.png">&nbsp;</img></td> <td colspan="7" style="border: 1px solid #666;"> <span style="font-size:28px;font-weight:bold;font-family:Trebuchet MS">QOOLPOINT INSURANCE AGENCY </span> <br> <span style="font-size:14px;font-weight:bold;font-family:Trebuchet MS"> P.O.Box 82496 - 80100, Mombasa  Tel: 0412228887 / 0722718887 <br> Email: insurance@qool-point.co.ke </span><br> PIN No. A002517691H<br>REGULATED BY THE INSURANCE REGULATORY AUTHORITY<br></td><tr>';

echo '<tr align="center"><td colspan="8" style="font-size:24px;font-weight:bold;border: 1px solid #666;"> RISK NOTE  </td></tr>';

if(isset($_GET['insno'])) {
	$user = $_SESSION['reusername'];
	$db=new MySQLDatabase();
	$db->open_connection();
	$insno = $_GET['insno'];	
	$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)){
		$idate = substr($row['idate'],8,2)."-".substr($row['idate'],5,2)."-".substr($row['idate'] ,0,4);
		$expdate = substr($row['expdate'],8,2)."-".substr($row['expdate'],5,2)."-".substr($row['expdate'] ,0,4);
		$agpno = '';	$cname = $row['cname'];
		if(($row['agpno'] !== NULL) || (!empty($row['agpno']))) { $agpno = $row['agpno']; }
		elseif(($row['agpno3']  !== NULL) || (!empty($row['agpno3']))) { $agpno = $row['agpno3']; }
		elseif(($row['agpno2']  !== NULL) || (!empty($row['agpno']))) { $agpno = $row['agpno2']; }
		elseif(($row['agpno1'] !== NULL) || (!empty($row['agpno']))) { $agpno = $row['agpno1']; }
		if( $cname === "RETAIL CUSTOMERS") { $iname = strtoupper($row['insurer']); }
		else { $iname = strtoupper($row['cname']).' / '.strtoupper($row['insurer']); }
		$idno = $row['idno'];   $pinno = $row['pinno'];
		echo '<tr><td style="border: 1px solid #666;">INSURED</td> <td colspan="5">'.$iname.'</td>';  
		echo '<td colspan="2" style="border: 1px solid #666;">BOOKING NO.'.$row['insno'].'</td></tr>';
		echo '<tr><td colspan="2" style="border: 1px solid #666;">Policy No. : &nbsp; '.$agpno.'</td> <td colspan="2" style="border: 1px solid #666;"> PHONE No. &nbsp;'.$row['instel'].'</td> <td colspan="2" style="border: 1px solid #666;">ID No.'.$idno.'</td> <td colspan="3" style="border: 1px solid #666;">PIN No.'.$pinno.' </td></tr>';
		echo '<tr><td colspan="4" style="border: 1px solid #666;">CLASS :&nbsp; '.$row['icat'].'</td> <td colspan="4" style="border: 1px solid #666;"> SCOPE : &nbsp;'.$row['isco'].'</td></tr>';
		echo '<tr><td colspan="4" style="border: 1px solid #666;">COVER FROM &nbsp; '.$idate.'</td> <td colspan="4" style="border: 1px solid #666;"> COVER TO &nbsp;'.$expdate.'</td></tr>';
		echo '<tr><td style="border: 1px solid #666;">REG. NO. </td> <td style="border: 1px solid #666;"> MAKE/MODEL </td> <td style="border: 1px solid #666;"> BODY </td> <td style="border: 1px solid #666;"> Y.O.M </td> <td style="border: 1px solid #666;"> RATING </td> <td style="border: 1px solid #666;"> CHASIS </td> <td style="border: 1px solid #666;"> ENGINE </td><td style="border: 1px solid #666;"> COLOUR </td></tr>';
		echo '<tr><td style="border: 1px solid #666;">'.$row['regno'].'</td> <td style="border: 1px solid #666;">'.$row['vehmod'].'</td> <td style="border: 1px solid #666;">'.$row['vbody'].'</td> <td style="border: 1px solid #666;">'.$row['yom'].'</td> <td style="border: 1px solid #666;">'.$row['rating'].'</td> <td style="border: 1px solid #666;">'.$row['chasis'].'</td> <td style="border: 1px solid #666;">'.$row['engno'].'</td><td style="border: 1px solid #666;">'.$row['vcolor'].'</td></tr>';
		echo '<tr><td style="border: 1px solid #666;">DRIVERS</td> <td colspan="7" style="border: 1px solid #666;">The insured or any person authorised by the insured and having a valid driving license</td></tr>';
		echo '<tr><td>USE OF VEHICLE</td> <td colspan="7" style="border: 1px solid #666;">'.$row['useofveh1'].'<br>'.$row['useofveh2'].'</td></tr>';
		echo '<tr><td></td> <td colspan="3" style="border: 1px solid #666;">COVERS INCLUDE</td> <td colspan="4" style="border: 1px solid #666;">SUBJECT TO</td>';
		echo '<tr><td style="border: 1px solid #666;"></td> <td colspan="3">'.$row['covers1'].' <br>'.$row['covers2'].'<br>'.$row['covers3'].'<br>'.$row['covers4'].'<br>'.$row['covers5'].'<br>'.$row['covers6'].'<br>'.$row['covers7'].'<br>'.$row['covers8'].'</td>  
					<td colspan="4" style="border: 1px solid #666;">'.$row['subj1'].' <br>'.$row['subj2'].'<br>'.$row['subj3'].'<br>'.$row['subj4'].'<br>'.$row['subj5'].'<br>'.$row['subj6'].'<br>'.$row['subj7'].'<br>'.$row['subj8'].'</td></tr>';
		echo '<tr><td style="font-weight:bold;border: 1px solid #666;">SUMMARY OF COVER</td> <td colspan="7" style="border: 1px solid #666;">'.$row['sumcov1'].'<br>'.$row['sumcov2'].'<br>'.$row['sumcov3'].'</td> </tr>';
		echo '<tr><td style="font-weight:bold;border: 1px solid #666;">EXCESSES APPLICABLE</td> <td colspan="7" style="border: 1px solid #666;">'.$row['excess1'].'<br>'.$row['excess2'].'<br>'.$row['excess3'].'<br>'.$row['excess4'].'<br>'.$row['excess5'].'<br>'.$row['excess6'].'<br>'.$row['excess7'].'<br>'.$row['excess8'].'</td> </tr>';
		echo '<tr><td colspan="3" style="border: 1px solid #666;"><table><tr><td>Sum Insured :</td> <td align="right">'.number_format($row['inam'],0).'</td></tr>
																		<tr><td> Basic Premium :</td> <td align="right">'.number_format($row['insprem'],0).'</td></tr>
																		<tr><td> Levy :</td> <td align="right">'.number_format($row['clevy'],0).'</td></tr>
																		<tr><td> Stamp Duty :</td> <td align="right">'.number_format($row['csduty'],0).'</td></tr>
																		<tr><td colspan="2"><hr></td></tr>
																		<tr><td> Total Premium :</td> <td align="right">'.number_format($row['amount'],0).'</td></tr> 
																		<tr><td colspan="2"><hr></td></tr>';
																		if($row['inst1'] !=='0') { echo '<tr><td>1st Installment :</td> <td align="right">'.number_format($row['inst1'],0).'</td></tr>
																		<tr><td>2nd Installment :</td> <td align="right">'.number_format($row['inst2'],0).'</td></tr>
																		<tr><td>3rd Installment :</td> <td align="right">'.number_format($row['inst3'],0).'</td></tr>'; }
																	echo '</table> </td> 
				<td colspan="3" style="border: 1px solid #666;"><u>LIMITS OF LIABILITY </u><br>'.$row['liab1a'].'<br>'.$row['liab2a'].'<br>'.$row['liab3a'].'<br>'.$row['liab4a'].'<br>'.$row['liab5a'].'<br>'.$row['liab6a'].'<br>'.$row['liab7a'].'<br>'.$row['liab8a'].'<br>'.$row['liab9a'].'<br>'.$row['liab10a'].'</td> 
				<td colspan="2" style="border: 1px solid #666;"><br>'.$row['liab1b'].'<br>'.$row['liab2b'].'<br>'.$row['liab3b'].'<br>'.$row['liab4b'].'<br>'.$row['liab5b'].'<br>'.$row['liab6b'].'<br>'.$row['liab7b'].'<br>'.$row['liab8b'].'<br>'.$row['liab9b'].'<br>'.$row['liab10b'].'</td></tr>';
		echo '<tr><td colspan="8" style="border: 1px solid #666;">This summary of your policy is issued for quick reference and if the cover shown does not meet your requirements, please return immediately for alteration</td></tr>';
		echo '<tr><td colspan="8" style="border: 1px solid #666;">INSURER : &nbsp;'.getsupplier($row['supp']).'</td> </tr>';
		echo '<tr><td colspan="8" style="border: 1px solid #666;padding-right:20px;text-align:right;"><br><br>Approved By : &nbsp;___________________&nbsp;&nbsp; Date : &nbsp;'.$idate.'</td> </tr>';
		echo '<tr><td colspan="8">Printed By : '.$user.'&nbsp; ON &nbsp; '.date('d-m-Y').'</td>  </tr>';
		echo '</table>';
    }
	
}
echo '</div>';
?> 

</body></html>

<script type="text/javascript">       
function myprint(){
	var w = window.open('', '', 'width=800,height=600,resizeable,scrollbars');
	 w.document.write($("#printblk").html());
	 w.document.write('<link rel="stylesheet" type="text/css" href="css/allcss.css">');
	 w.document.close(); 										// needed for chrome and safari
	 javascript:w.print();
	 w.close();
};	
</script>
