<?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" />
			<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="auto"></th>
</tr>

<!-- row for header picc 2 -->
<tr>
     <th width="100%" colspan="4"><img src="images/eoffice-cox.jpg" width="100%" height="auto"></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="QuotationListRamadhan.php" method="post">

<?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_rquotation.quotation_id,tbl_dir_fnb_rquotation.quotation_status,
                   tbl_dir_fnb_rquotation.quotation_date_from, tbl_dir_fnb_rquotation.quotation_date_to,
				   tbl_dir_fnb_rquotation.quotation_remarks, tbl_dir_fnb_rquotation.quotation_status,tbl_dir_fnb_ritem.item_total
                   FROM `tbl_dir_fnb_rquotation` 
				   LEFT JOIN tbl_dir_fnb_ritem
				   ON tbl_dir_fnb_ritem.quotation_id=tbl_dir_fnb_rquotation.quotation_id
				   LEFT JOIN tbl_dir_fnb_customer
				   ON tbl_dir_fnb_rquotation.cust_id=tbl_dir_fnb_customer.cust_id
				   order by  tbl_dir_fnb_rquotation.quotation_id,quotation_id asc LIMIT $offset, $rowsPerPage");

$i=$offset;
		  
echo "<center><span class=style16><table class=tablesorter id=user>";
echo "<thead>";
echo "<a href=QuotationListRamadhan.php>Quotation List</a>";
echo "<center><table border=1 align=center class=gridtable  >";
echo"<tr align='center' ><th width=60>NO</th><th width=200>Date</th><th width=50>Quotation No</th><th width=300>Customer Name</th>
     <th width=50>Status</th><th width=60>Amount (RM)</th><th width=200>Remarks</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'];
	$quotation_date_from = $row['quotation_date_to'];
		     $item_total = $row['item_total'];
			       $sum += $item_total;
$i++;
					    echo"<tr>";
						echo "<td align=center>".$i."</td>";
						echo "<td align=center >".$row['quotation_date_from']."&nbsp;to&nbsp;".$row['quotation_date_to']."</td>";
						echo "<td align=left >".$row['quotation_id']."</td>";
						echo "<td align=left >".$row['cust_name']."</td>";
						echo "<td align=left >".$row['quotation_status']."</td>";
						echo "<td align=center >".$row['item_total']."</td>";
						echo "<td align=left >".$row['quotation_remarks']."</td>";
						echo "<tr>";	
				}	
				    /*echo"<tr>";
				    echo "<td colspan=5 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;">
 <div align="right"> <span class="style16"  >
 
    <?php
				//$query1 = "SELECT COUNT(cust_id) AS numrows FROM tbl_dir_fnb_customer
				$query1 = "SELECT COUNT(tbl_dir_fnb_customer.cust_id) AS numrows, tbl_dir_fnb_customer.cust_name, tbl_dir_fnb_rquotation.quotation_id, 
				                  tbl_dir_fnb_rquotation.quotation_status, tbl_dir_fnb_rquotation.quotation_date_from, tbl_dir_fnb_rquotation.quotation_date_to,   
								  tbl_dir_fnb_rquotation.quotation_remarks, tbl_dir_fnb_rquotation.quotation_status, tbl_dir_fnb_ritem.item_total
                           FROM `tbl_dir_fnb_rquotation`
                           LEFT JOIN tbl_dir_fnb_ritem ON tbl_dir_fnb_ritem.quotation_id = tbl_dir_fnb_rquotation.quotation_id
                           LEFT JOIN tbl_dir_fnb_customer ON tbl_dir_fnb_rquotation.cust_id = tbl_dir_fnb_customer.cust_id
                           ORDER BY tbl_dir_fnb_rquotation.quotation_id, quotation_id ASC ";
			   
				$result1 = mysql_query($query1) or die('Error, query failed');
				$row1 = mysql_fetch_array($result1, MYSQL_ASSOC);
				$numrows = $row1['numrows'];
				$maxPage = ceil($numrows/$rowsPerPage);
				// print the link to access each page
				$self = $_SERVER['PHP_SELF'];
				$nav = '';
				for($page = 1; $page <= $maxPage; $page++){
				if ($page == $pageNum){
				$nav .= " $page ";}
				else{
				$nav .= " <a href=\"$self?page=$page\">$page</a> ";
					}
				}
				if ($pageNum > 1)
				{
					$page = $pageNum - 1;
					$color="#FFFFFF";
					$prev = " <a href=\"$self?page=$page\">[Previous]</a> ";
					$first = " <a href=\"$self?page=1\">[First]</a> ";
				}
					else{
					$prev = ' ';
					$first = ' ';
				}
					if ($pageNum < $maxPage)
				{
						$page = $pageNum + 1;
						$next = " <a href=\"$self?page=$page\">[Next]</a> ";
						$last = " <a href=\"$self?page=$maxPage\">[Last]</a> ";
				}
					else{
					$next = ' ';
					$last = ' ';
				}
		echo  $first . $prev . $nav . $next . $last;?>
  </span></div> </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>
