<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>
<?php
session_start();
require_once 'includes/database.php';
require_once 'includes/funcs.php';

if (isset($_GET['dacc'])) {
    $dno = $_GET['dno'];
    $dacc = $_GET['dacc'];
	$bacc = $_GET['bacc'];
    $am = $_GET['am'];
    $pd = $_GET['pd'];
    $pmode = $_GET['pm'];
	$rmks = $_GET['rmks'];
    $ts = date("d-m-Y H:i:s");
	$user = $_SESSION['reusername'];	
}else {	   $dno = $_GET['dno']; 
	$db=new MySQLDatabase();
	$db->open_connection();
	$query = "SELECT * FROM dexptrans WHERE dexpno =  '$dno'";
    $result = mysqli_query($db->connection, $query) or die(mysqli_error($db->connection) );
    while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
	//	$dno = $row['dexpno'];
		$dacc = $row['expacc'];
		$bacc = $row['bacc'];
		$am = $row['amount'];
		$pd = $row['ddate'];
		$pmode = $row['pmode'].' - '.$row['chqno'];
		$rmks = $row['rmks'];
		$ts = $row['ts'];
		$user = $row['us'];
	}
}
$pd = substr($pd,8,2)."-".substr($pd,5,2)."-".substr($pd,0,4); 	
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>';
echo '<div id="printblk">';	
echo '<table class="printable" style="width:980px;border: solid 2px black;font-family:Trebuchet MS, Arial;font-size:14px;margin-right:10px;"><div id="printheader">
		<tr><td colspan="3"><center><span class="invoice">EXPENSE VOUCHER</span></center></td></tr>
		<tr><td align"left" colspan="3"> </td></tr>
           </div>';       
echo '<tr><td colspan="3"></td></tr>'; echo '<tr><td colspan="3"></td></tr>';		   
echo '<tr><td colpan="2"><span id="invoiceno">Expense Voucher No. &nbsp;'.$dno.'</span></td><td></td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Date &nbsp;'.$pd.'</td></tr>';
echo '<tr><td colspan="3"><br/><td></tr>';
echo '<tr><td colspan="2" style="border: 1px solid #666;"><b>Expense Account: &nbsp;</b>'.$dacc.'</b></td><td></td></tr><br/>';
echo '<tr><td colspan="3">Being Payment For:</td></tr>';

echo '<tr><td colspan="3"></td></tr>';
echo '<tr><td colspan="3">'.$rmks.'</td></tr>';

echo '<tr><td colspan="6"><hr/></td></tr>';	
echo '<tr><td align="right" colspan="6">Total Amount:&nbsp;&nbsp;'.number_format($am,0).'</td></tr>';


	  
echo '<tr><td style="width:350px"><b></td><td style="width:250px"></td><td style="width:300px"><b><br></td></tr>';
echo '<tr><td colspan="3"></td></tr>';
echo '<tr><td colspan="2">Mode:&nbsp;'.$pmode.' - '.$bacc.'</td><td align="left">Prepared By:&nbsp;'.$user.' - '.$ts.'</td></tr>';
echo '<tr><td align="right" colspan="3">&nbsp;&nbsp;</td></tr>';
echo '<tr><td colspan="2"></td><td align="left">Authorised By:____________</td></tr>';
echo '<tr><td colspan="3"></td></tr>'; 	echo '<tr><td colspan="3"></td></tr>';
echo '<tr><td colspan="2"></td><td align="left">Collected By:____________</td></tr>';
echo '<tr><td colspan="2">Total Kshs:&nbsp; '.convert_number_to_words($am).' Only </td></tr>';
echo '<tr><td colspan="3"></td></tr>';
echo '<tr><td align="right" colspan="3"></td></tr></table>';

?>
<script type="text/javascript">
function myprint(){
	$("#printblk").printArea();
};	
</script>
