<!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" />
<link rel="stylesheet" href="css/allcss.css" type="text/css" />

<script type="text/javascript" src="js/jquery.tools.min.js"></script>
<script type="text/javascript" src="js/jquery.PrintArea.js"></script>

</head>
<body>
<?php
require_once 'includes/database.php';
require_once 'includes/funcs.php';
date_default_timezone_set('Africa/Nairobi'); 			//time
if (isset($_GET['i'])){
    $insno =  $_GET['insno'];	$i =  intval($_GET['i']);
	$db=new MySQLDatabase();
	$db->open_connection();
    $query="SELECT * FROM insrecs WHERE insno = '$insno'"; 
    $sql = mysqli_query($db->connection, $query) or die(mysqli_error($db->connection) ); 
    if ($row = mysqli_fetch_array($sql, MYSQLI_ASSOC)){
            if($i===0){ $agp = $row['agpno']; }
			else if($i===1){ $agp = $row['agpno1']; }
			else if($i===2){ $agp = $row['agpno2']; }
			else if($i===3){ $agp = $row['agpno3']; }
            $ts = $row['ts'];
			$idate = substr($row['idate'],8,2)."-".substr($row['idate'],5,2)."-".substr($row['idate'] ,0,4); 
			$regno = $row['regno'];		
			$ph = $row['cname'].' / '.$row['insurer'];
			$insco = getsupplier($row['supp']);	
            $expdate = substr($row['expdate'],8,2)."-".substr($row['expdate'],5,2)."-".substr($row['expdate'] ,0,4); 
    }
	$db->close_connection();	

	
echo '<div id="inv">';	
echo '<table id="ttt" style="border-collapse:collapse; width:1020px; font-family:Tahoma, Arial;font-size:12px; margin-left:10px; position:fixed;">'; 	
echo '<th style="width:340px;line-height:0px;"> &nbsp; </th> <th style="width:340px;line-height:2px;">&nbsp;</th> <th style="width:340px;line-height:2px;">&nbsp; </th>';	   
echo '<tr><td style="padding-left:-20px;">'.$ph.' </td> <td style="padding-left:30px;"> '.$ph.' </td> <td> </td></tr>';

echo '<tr><td style="padding-left:-20px;text-align:top;"> '.$agp.' </td> <td style="padding-left:20px;text-align:top;"> '.$agp.' </td> <td style="padding-left:80px;text-align:top;"> '.$agp.'</td></tr>';
echo '<tr><td style="padding-left:20px;"> '.$idate.'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.date("g:iA").' </td> <td style="padding-left:50px;"> '.$idate.'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.date("g:iA").' </td> 
<td style="padding-left:70px;"> '.$idate.'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.date("g:iA").'</td></tr>';
echo '<tr><td style="padding-left:30px;font-size:16px; font-weight:bold;"> '.$expdate.' </td> <td style="padding-left:50px;font-size:16px; font-weight:bold;"> '.$expdate.' </td> <td style="padding-left:100px;font-size:16px; font-weight:bold;"> '.$expdate.'</td></tr>';
echo '<tr><td style="padding-left:30px;font-size:16px;"> '.$regno.'</td> <td style="padding-left:50px;font-size:16px;">'.$regno.'</td> <td style="padding-left:110px;font-size:16px;">'.$regno.'</td></tr>';
echo '<tr><td > &nbsp;  </td> <td style="padding-left:30px;"> &nbsp;  </td> <td style="padding-left:30px;">&nbsp;  </td></tr>';
echo '<tr><td style="padding-left:-20px;"> '.$insco.' </td> <td style="padding-left:50px;"> '.$insco.' </td> <td style="padding-left:60px;"> '.$insco.' </td></tr>';

echo'</table></div>';

echo '<p><a href="#" id="printnow" class="printnow" onclick="myprint();" style="float:left;">Print</a>';
echo '<a href="#" id="closenow" class="closenow" onclick="window.close();">Close</a></p>';
}
?>
</body>

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