<?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/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>QIA | RENEWAL NOTICE </title>
<script type="text/javascript" src="js/jquery-1.10.2.js"></script>
<link rel="stylesheet" type="text/css" href="css/allcss.css">

</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" style="width:95%; margin:20px;border-collapse:collapse;font-size:14px;font-family:Arial;">';
echo '<tr><td colspan="2"><img style="vertical-align:top;" src="images/inslogo.png">&nbsp;</img> <span style="font-size:28px;font-weight:bold;font-family:Trebuchet MS;"> &nbsp;&nbsp;QOOLPOINT INSURANCE AGENCY </span> <br> <span style="font-size:14px;font-weight:bold; margin-top:-40px; font-family:Trebuchet MS"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; P.O.Box 82496 - 80100, Mombasa  Tel: 0412228887 / 0722718887 <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Email: insurance@qool-point.co.ke </span><br>REGULATED BY THE INSURANCE REGULATORY AUTHORITY<br></td><tr>';
echo '<tr><td colspan="2">&nbsp;</td></tr>';
echo '<tr align="center"><td colspan="2" style="font-size:24px;font-weight:bold;border: 1px solid #666;"> RENEWAL NOTICE  </br></td></tr>';
echo '<tr><td colspan="2">&nbsp;</td></tr>';
if(isset($_GET['insno'])) {
	$user = $_SESSION['reusername'];
	$db=new MySQLDatabase();
	$db->open_connection();
	$insno = $_GET['insno'];
	$rdate='';		$ndate='';		$agp='';		$renewtxt='';	$inst1='';	$inst2='';	$inst3='';
	$sql = mysqli_query($db->connection, "SELECT * FROM renewals WHERE insno = '$insno';") or die (mysqli_error($db->connection) ); 
	if ($row = mysqli_fetch_array($sql, MYSQLI_ASSOC)){ $rdate = substr($row['rdate'],8,2)."-".substr($row['rdate'],5,2)."-".substr($row['rdate'] ,0,4); 	
										 $ndate = substr($row['ndate'],8,2)."-".substr($row['ndate'],5,2)."-".substr($row['ndate'] ,0,4); 
										 $renewtxt = $row['renewtxt'];
										 $inst1 = $row['inst1'];	$inst2 = $row['inst2'];		$inst3 = $row['inst3'];
										 }
	$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)){
		$ph = $row['cname'].' / '.$row['insurer']; 		$ts= $row['ts'];	$regno= $row['regno'];
		if($row['agpno'] !==''){ $agp = $row['agpno']; }
		else if($row['agpno3'] !==''){ $agp = $row['agpno3']; }
		else if($row['agpno2'] !==''){ $agp = $row['agpno2']; }
		else if($row['agpno1'] !==''){ $agp = $row['agpno1']; }
		echo '<tr><td colspan="2">&nbsp;</td></tr>';
		echo '<tr><td colspan="2">'.$ph.'</td></tr>';
		$expdate = substr($row['expdate'],8,2)."-".substr($row['expdate'],5,2)."-".substr($row['expdate'] ,0,4);
		$idate = substr($row['idate'],8,2)."-".substr($row['idate'],5,2)."-".substr($row['idate'] ,0,4);
		echo '<tr><td colspan="2">'.$row['insaddr'].'</td></tr>';
		echo '<tr><td colspan="2">&nbsp;</td></tr>';
		echo '<tr><td align="left" style="width:400px;">Policy No. : '.$agp.'</td> <td align="right"> Date : '.$ndate.' &nbsp;&nbsp;</td></tr>';
		echo '<tr><td colspan="2">&nbsp;</td></tr>';
		echo '<tr><td colspan="2">'.$renewtxt.'</td></tr>';
		echo '<tr><td colspan="2">&nbsp;</td></tr>';
		echo '<tr><td colspan="2">Insurance period : '.$idate.'&nbsp; - &nbsp;'.$expdate.'</td></tr>';
		echo '<tr><td colspan="2">&nbsp;</td></tr>';
		echo '<tr><td>Renewal Date : '.$rdate.'</td> <td></td></tr>';
		echo '<tr><td colspan="2">&nbsp;</td></tr>';
		echo '<tr style="vertical-align:top;"><td>Full Premium : '.number_format($row['amount'],0).'</td> <td>'.$inst1.'<br>'.$inst2.'<br> '.$inst3.'<br> </td></tr>';
		echo '<tr><td colspan="2">&nbsp;</td></tr>';
		
    }
	//echo '<table style="width:95%; margin:20px;border-collapse:collapse;font-size:14px;font-family:Arial;">';
	//echo '<tr> <td colspan="2" align="left"><br><br><br>Prepared By:&nbsp;'.$user.' - '.$ts.'</td> <td colspan="2" align="right"><br><br><br> </td></tr>';
	//echo '</table>';
	echo '<tr><td colspan="2"> We remain yours faithfully,<td><tr>
		<tr><td colspan="2">&nbsp; </td> </tr>
		<tr><td colspan="2">&nbsp; </td> </tr>
	      <tr><td colspan="2"> For the Managing Director,</td><tr>
	      
	      <tr><td colspan="2"> <b> QOOLPOINT INSURANCE AGENCY</b></td></tr>';
	echo '</table>';
	echo '</div>';
}
?> 

</body></html>

<script type="text/javascript">       
function myprint(){
	var w = window.open('', '', 'width=900,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>
