<?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() {
		$("#date_start").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() {
		$("#date_end").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
$username=$_SESSION['username'];
echo 'Welcome: '.$username;
?>
 <?php
                    $userid=mysql_query("select * from tbl_dir_user where user_name='$username'")or die(mysql_errno());
                    $row2=mysql_fetch_array($userid);
                    $user_id=$row2['user_id'];
					
                ?>
							<a href="cust_FnB_Login.php"><img src="images/logout3.gif" align="right"></a>
							</td>
</tr>
<tr><td>
<!--h2 align="center">STAFF ADMIN PAGE</h2-->
<form action="Cost_General_FnB.php" method="post">
<table align="center" class="gridtable" >
<tr><th>Date start:</th><td><input type="text" name="date_start" id="date_start" >(YYYY-MM-DD)</td></tr>
<tr><th>Date end:</th><td><input type="text" name="date_end" id="date_end">(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(item_total) from tbl_dir_fnb_item
 			   LEFT JOIN tbl_dir_fnb_quotation ON tbl_dir_fnb_quotation.quotation_id=tbl_dir_fnb_item.quotation_id
			   WHERE  tbl_dir_fnb_quotation.quotation_date_from 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_fnb_customer.cust_id,tbl_dir_fnb_customer.cust_name,tbl_dir_fnb_quotation.quotation_id,tbl_dir_fnb_quotation.quotation_status,
                   tbl_dir_fnb_quotation.quotation_date_from,tbl_dir_fnb_item.item_total
                   FROM `tbl_dir_fnb_quotation` 
				   LEFT JOIN tbl_dir_fnb_item
				   ON tbl_dir_fnb_item.quotation_id=tbl_dir_fnb_quotation.quotation_id
				   LEFT JOIN tbl_dir_fnb_customer
				   ON tbl_dir_fnb_quotation.cust_id=tbl_dir_fnb_customer.cust_id
				   WHERE quotation_date_from between '$date_start' AND '$date_end'  order by quotation_date_from,quotation_id asc");
///AND quotation_status='Confirm'
$i=$offset;
		  
echo "<center><span class=style16><table class=tablesorter id=user>";
echo "<thead>";
echo "<a href=QuotationList.php>Quotation List</a>";
echo "<center><table border=1 align=center class=gridtable  >";
echo"<tr align='center' ><th width=60>NO</th><th width=150>Quotation No</th><th width=300>Customer 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'];
	   		  $cust_name = $row['cust_name'];
		   $quotation_id = $row['quotation_id'];
    $quotation_date_from = $row['quotation_date_from'];
		     $item_total = $row['item_total'];
			       $sum += $item_total;
$i++;
					    echo"<tr>";
						echo "<td align=center>".$i."</td>";
						echo "<td align=left >".$row['quotation_id']."</td>";
						echo "<td align=left >".$row['cust_name']."</td>";
						echo "<td align=center >".$row['quotation_date_from']."</td>";
						echo "<td align=center >".$row['item_total']."</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="window.location.href='cust_FnB_view.php'"  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>
