<html>
<head>
<title>Daily Bookstore - Cashier System</title>
<!--include css file-->
<link href="cashierprint.css" rel="stylesheet" type="text/css"/>
<link href="bookstaffprint.css" rel="stylesheet" type="text/css" media="print, projection" />
</head>
<body>
<?php

if($_POST["Back"] == "Back")
{
	echo "<script language='javascript'>window.location='cashiermain.php'</script>"; 
}

include("connect.php");
$billNo = $_GET['billNo'];
$point = $_GET['point'];

	$result = mysql_query("SELECT * FROM receipt WHERE receiptNo = '$billNo'");
	$row = mysql_fetch_array($result);
	
	$result2 = mysql_query("SELECT * FROM receiptitem WHERE receiptNo = '$billNo'");
	$num_results = mysql_num_rows($result2);
	
echo "<form name='billform' method='post'>";
echo "<table border='0' cellspacing='0' cellpadding='5' bordercolor='black' width='30%' align=''>";
echo "<tr>";
echo "<td colspan='4' align='center'>Daily BookStore</td>";
echo "</tr>";

echo "<tr>";
echo "<td colspan='4' align='center'>---------------------------------</td>";
echo "</tr>";

$times = date("H:m:s");

echo "<tr>";
echo "<td colspan='2'>".$row["receiptDate"]." $times</td>";
echo "<td width='25%'>Cashier: </td>";
echo "<td width='25%'>".$row["cashierName"]."</td>";
echo "</tr>";

if($row["memberLname"]!=""){
echo "<tr>";
echo "<td width='15%'>Member: </td>";
echo "<td align='left'>".$row["memberLname"]."</td>";

	$result3 = mysql_query("SELECT memberpoint FROM membership WHERE memberLname = '$row[memberLname]'");
	$row3 = mysql_fetch_array($result3);
	
echo "<td>Point: </td>";
echo "<td>".$row3["memberpoint"]."</td>";
echo "</tr>";
}

echo "<tr>";
echo "<td colspan='4' align='center'>---------------------------------</td>";
echo "</tr>";

echo "</table>";

echo "<table border='0' cellspacing='0' cellpadding='5' bordercolor='black' width='30%' align=''>";

echo "<tr>";
echo "<td>Q</td>";
echo "<td>ISBN</td>";
echo "<td>Description</td>";
echo "<td>Price</td>";
echo "</tr>";

for ($i=0; $i <$num_results; $i++)
{
	$row2 = mysql_fetch_array($result2);
	echo "<tr>";
	echo "<td>".$row2['receiptQuantity']."</td>";
	echo "<td><input type='hidden' name='receiptItem".$i."' value='$row2[receiptItem]'>".$row2['receiptItem']."</td>";
	
	$ISBN = $row2['receiptItem'];
	$p = $row2['receiptPrice'];
	$q = $row2['receiptQuantity'];
	$subtotal = $p*$q;
	$total = $total + $subtotal;
	$totalq = $totalq+$q;
	
	$result5 = mysql_query("SELECT itemName FROM item WHERE ISBN = '$ISBN'");
	$row5 = mysql_fetch_array($result5);
	
	include_once("functioncut.php");
	
	echo "<td>";
	echo cutstr($row5['itemName'],30);
	echo "</td>";
	echo "<td align='right'>";
	printf("%10.2f",$subtotal);
	echo "</td>";
	echo "</tr>";
}

echo "<tr>";
	echo "<td colspan='4'><br/></td>";
echo "</tr>";

echo "<tr>";
	echo "<td colspan='3' align='left'>Total:</td>";
	echo "<td align='right'>";
	printf("%10.2f",$total);
	echo "</td>";
echo "</tr>";

echo "<tr>";
	echo "<td colspan='3' align='left'>Payment:</td>";
	echo "<td align='right'>";
	printf("%10.2f",$row['receiptCash']);
	echo "</td>";
echo "</tr>";

echo "<tr>";
	echo "<td colspan='3' align='left'>Change Due:</td>";
	echo "<td align='right'>";
	printf("%10.2f",($row['receiptCash'] - $total));
	echo "</td>";
echo "</tr>";

echo "<tr>";
	echo "<td colspan='5' align='center'>";
	echo "-----------THANK YOU-----------<br/>Please Come Again<br/><br/>DAILY BOOKSTORE SDN BHD";
	echo "</td>";
echo "</tr>";

echo "<tr>";
	echo "<td colspan='5' align='center'>
	<input type='button' value='Print' onClick='window.print()'/>
	<input type='submit' name='Back' value='Back'>";
	echo "</td>";
echo "</tr>";
echo "</table>";
echo "</form>";
?>
</body>
</html>