<?php session_start();?>
<?php require_once('open_connection.php');?>
<!--link href='blue/style.css' rel='stylesheet' type='text/css' /-->
<link href='css/imagetable.css' rel='stylesheet' type='text/css' />
<link href="css/gridtable.css" rel="stylesheet" type="text/css" />

<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
	<script src="//code.jquery.com/jquery-1.10.2.js"></script>
	<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
	<link rel="stylesheet" href="/resources/demos/style.css">
	<script>
	$(function() {
		$("#invoice_date").datepicker({ dateFormat: 'yy-mm-dd' });
		$( "#format" ).change(function() {
		 var minValue = $(this).val();
		  minValue = $.datepicker.parseDate("yy-mm-dd", minValue);
            minValue.setDate(minValue.getDate()+1);
			$( "#invoice_date").datepicker( "option", "dateFormat", $( this ).val() );
		});
	});
	$(function() {
		$("#invoice_date2").datepicker({ dateFormat: 'yy-mm-dd' });
		$( "#format" ).change(function() {
		 var minValue = $(this).val();
		  minValue = $.datepicker.parseDate("yy-mm-dd", minValue);
            minValue.setDate(minValue.getDate()+1);
			$( "#invoice_date").datepicker( "option", "dateFormat", $( this ).val() );
		});
	});
	</script><!---date-->  
			<script language="JavaScript">
			function printPage() {
				if(document.all) {
					document.all.divButtons.style.visibility = 'hidden';
					window.print();
					document.all.divButtons.style.visibility = 'visible';
					} else {
					document.getElementById('divButtons').style.visibility = 'hidden';
					window.print();
					document.getElementById('divButtons').style.visibility = 'visible';
							}
				}
		</script><!---print-->

<!DOCTYPE html>
<html>
<head>
      <title>PICCSB e-Directory System</title>

</head>
<body bgcolor="#333333"> 
<table width="100%" border="0" align="center">
<tr>
<td width="15%" bgcolor="#333333">&nbsp;</td>
<td width="70%" align="center" bgcolor="#FFFFFF" > 

<table width="100%" border="0" align="center">

<!-- row for header picc 1 -->
<tr>  
     <th width="100%" colspan="4"><img src="images/header-cox.jpg" width="100%" height="30%"></th>
</tr>

<!-- row for header picc 2 -->
<tr>
     <th width="100%" colspan="4"><img src="images/eoffice-cox.jpg" width="100%" height="40%"></th>
</tr>
<!-- calling frame -->	
<tr>
    <td colspan="1" width="10%" align="center"><?php include("header.php");?></td>
	
</tr>
<tr>

<td colspan="3" width="90%" align="center" >
<tr><td>&nbsp;</td></tr>
<tr><td align="left">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							<?php
								echo 'Welcome: ' . $_SESSION['username'];
								?>
							<a href="vendor_AdminSection_login.php"><img src="images/logout3.gif" align="right"></a>

							</td>
</tr>
<tr><td>
<!--h2 align="center">STAFF ADMIN PAGE</h2-->

<form action="cost_fnb.php" method="post">
<table align="center" class="gridtable" >
<tr><th>Date start:</th><td><input type="text" name="date_start" id="invoice_date" >(YYYY-MM-DD)</td></tr>
<tr><th>Date end:</th><td><input type="text" name="date_end" id="invoice_date2">(YYYY-MM-DD)</td></tr>
</table><div align="center"><input type="submit" class="myButton"  value="SEARCH"/></div>
</form>
<br>

<!--hr /-->
<div align="right">
<form method="post">
 <?php $total="SELECT SUM(invoice_amount) from tbl_dir_fnb_invoice
			   WHERE  tbl_dir_fnb_invoice.invoice_date between '$date_start' AND  '$date_end' ";
								 ?>
<?php 
$date_start=$_POST['date_start'];
  $date_end=$_POST['date_end'];

$rowsPerPage =20; 
				$pageNum = $_REQUEST['page']; 
				if(empty($pageNum))
						{
					$offset =0;
					$pageNum=1;
						}
				else
						{
					$offset = ($pageNum - 1) * $rowsPerPage;
						}

$cost=mysql_query("select tbl_dir_evendor.vendor_id ,tbl_dir_evendor.vendor_name ,tbl_dir_fnb_invoice.invoice_ref_id, tbl_dir_fnb_invoice.invoice_date, 					                   tbl_dir_fnb_invoice.invoice_amount 
                   from tbl_dir_evendor 
				   left join tbl_dir_fnb_invoice on tbl_dir_evendor.vendor_id=tbl_dir_fnb_invoice.vendor_id 
				   WHERE invoice_date between '$date_start' AND '$date_end' order by invoice_date,invoice_ref_id asc");

$i=$offset;
		  
echo "<center><span class=style16><table class=tablesorter id=user>";
echo "<thead>";
echo "<center><table border=1 align=center class=gridtable  >";
echo"<tr align='center' ><th width=60>NO</th><th width=150>INVOICE REF.NO</th><th width=300>COMPANY NAME</th><th width=100>DATE</th><th width=100>AMOUNT</th></tr>";
echo "</thead>";
echo "<tbody>";	 
while($row=mysql_fetch_array($cost))
{
 			  $vendor_id = $row['vendor_id'];
	   		$vendor_name = $row['vendor_name'];
		 $invoice_ref_id = $row['invoice_ref_id'];
		   $invoice_date = $row['invoice_date'];
		 $invoice_amount = $row['invoice_amount'];
			       $sum += $invoice_amount;


$i++;
					echo"<tr>";
						echo "<td align=center>".$i."</td>";
						echo "<td align=left >".$row['invoice_ref_id']."</td>";
						echo "<td align=left >".$row['vendor_name']."</td>";
						echo "<td align=center >".$row['invoice_date']."</td>";
						echo "<td align=center >".$row['invoice_amount']."</td>";
							echo "<tr>";	
				}	
				echo"<tr>";
				    echo "<td colspan=4 align= right>"."Total "."</td>";
					echo "<td colspan=1 align=left>"."RM ".$sum."</td>";
		     		echo"</tr>";
					echo "</table>";
?>

</form>
  <tr><td>
   <div id="divButtons" name="divButtons" align="center">
<input type="button" value = "Print this page" onClick="printPage()" style="font:bold 11px verdana;color:#FF0000;background-color:#FFFFFF;"> &nbsp;
<input type="button" value = "Back" onClick="history.go(-1);return true;" style="font:bold 11px verdana;color:#FF0000;background-color:#FFFFFF;">
  </td></tr>
  
  </div>
  </td></tr>
<!-- row for footer -->	
<tr>
	<th align="center" colspan="4">
	<?php include('footer.php');?>
		
	</th>
</tr>

<!--- end for ruang kerja 80% -->
</table>

</td>

<td width="20%" bgcolor="#333333">&nbsp;</td>

</tr>

<!--- end for ruang kerja 100% -->
</table>

</body>
</html>
