<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
include ("../navigation/header.php");
$page_name = "Sales-main";
include ("../navigation/access.php");

if ($permission_num==1) {
	include ("../navigation/sales_sidebar.php");

require_once("../include/tc_calendar.php");
	    
	$date = mysql_real_escape_string($_GET['date']);
		
	if ($date==1) {
	$start = mysql_real_escape_string($_GET['date1']);
    $end = mysql_real_escape_string($_GET['date2']);
	}
	else {
	
	$de=31;
	if (date("m")==2) {$de=28;}
	if ( (date("m")==4) OR (date("m")==6) OR (date("m")==9) OR (date("m")==11) ) {$de=30;}
	
	$start = date("Y-m-01");
	$end = date("Y-m-".$de);
	}
			
	if ($date!=1) {
	   $ds = "1"; }
	   else {
		$ds = date("d", strtotime($start) );
	   }
	$ms = date("m", strtotime($start) );
	$ys = date("Y", strtotime($start) );
	
	
	$de = date("d", strtotime($end) );
	$me = date("m", strtotime($end) );
	$ye = date("Y", strtotime($end) );	

	
$table_name2 = $_SESSION['db_prefix']."_quotations";
$quotation_query = "SELECT quote_no, cust_id, type, request_date, company_contact, contact_phone, quote_type, project_no, seller, designer, value, result FROM $table_name2 WHERE status = 'request' ORDER BY quote_no ASC ";
$quotation_result = mySQL_query($quotation_query);
$quotation_num = mysql_num_rows($quotation_result);	

?>
<!--style sheets-->
<link rel="stylesheet" type="text/css" href="../css/tooltip.css" />
<link rel="stylesheet" type="text/css" href="../css/scroll_table.css" />

<!--jscript-->
<script language="javascript" src="../jscript/calendar.js"></script>
<script language="JavaScript" src="../jscript/tooltip.js"  type="text/javascript"></script> 
<script type="text/javascript" language="javascript" src="../jscript/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8">
			$(document).ready(function() {
				$('#scroll_table').dataTable( {
					"sScrollY": "485px",
					"bPaginate": false,
					"bScrollCollapse": true,
					"aaSorting": [[ 1, "desc" ]],
					"aoColumns": [
								{"bSortable": true},
                             	{"bSortable": true},
								{"iDataSort": 8},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bVisible": false}
								 ]
				} );
			} );
		</script>

</head>
<body>

<div class="main_frame">
  <div class="page_head_frame">
          <table width="809" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="385"><label class="label_page_head">Enquiries</label></td>
              <td width="253">&nbsp;</td>
              <td width="171" align="right">&nbsp;</td>
            </tr>
          </table>
</div>
        <br />
        <br />
        <br />
        <div><br />
        <div class="page_middle_frame">
        <div><img src="../images/round_blue.png" width="8" height="8" />=project&nbsp;&nbsp;<img src="../images/round_purple.png" width="8" height="8" />=cash sale</div>
        <table width="678"  id="scroll_table" class="data_display" >
           
           <thead>
            <tr>
              <th width="18" style="border-right:hidden" >&nbsp;</th>
              <th width="57" >Number</th>
              <th >Enq-Date</th>
              <th >Project no</th>
              <th >Name</th>
              <th >Contact</th>
              <th >Designer</th>
              <th >Sales<br />
                person</th>
              <th >&nbsp;</th>
            </tr>
          </thead>
            <?php 
$i=0;
$a7tot=0;
while ($i<$quotation_num) {
	$a1 = mysql_result($quotation_result, $i, "quote_no");
	
	     $a2 = mysql_result($quotation_result, $i, "cust_id");
		 
		 if ($a2!='0') {
	     $table_name3 = $_SESSION['db_prefix']."_customer";
         $customer_query = "SELECT comp_name, status, bag_box, box_no, postal_place, phone, contact_1 FROM $table_name3 WHERE cust_id = '".$a2."' ";
		 
         $customer_result = mySQL_query($customer_query);
         $a2a = mysql_result($customer_result, 0, "comp_name");
		 $a2b = mysql_result($customer_result, 0, "bag_box");
		 $a2c = mysql_result($customer_result, 0, "box_no");
		 $a2d = mysql_result($customer_result, 0, "postal_place");
		 $a2e = mysql_result($customer_result, 0, "phone");
		 $a2f = mysql_result($customer_result, 0, "contact_1");
		 $a3 = mysql_result($customer_result, 0, "status");
		 } 
		 else {
			 $a2a='';
		 }
		 
		
	$a5 = mysql_result($quotation_result, $i, "request_date");
	$a7 = mysql_result($quotation_result, $i, "designer");
	$a8 = mysql_result($quotation_result, $i, "seller");
	$a9 = mysql_result($quotation_result, $i, "company_contact");
	$a10 = mysql_result($quotation_result, $i, "contact_phone");
	$a11 = mysql_result($quotation_result, $i, "result");
	$a12 = mysql_result($quotation_result, $i, "project_no");
	$a14 = mysql_result($quotation_result, $i, "quote_type");
	
	$quoteTT = "Click for details";
	
	$customerTT ="<table id=table_tool_tip width=250 ><tr><td  width=75>Company:</td><td width=175>".$a2a."</td></tr><tr><td>Address:</td><td>".$a2b."&nbsp;".$a2c."<br>".$a2d."</td></tr><tr><td>Phone:</td><td>".$a2e."</td></tr><tr><td>Contact:</td><td>".$a2f."</td></tr></table><br><b>Click for details</b>";
	?>
            <tr>
              <td style="border-right:hidden; padding-right:0px;" align="right">
              <?php if ($a14=='Project') { ?><img src="../images/round_blue.png" width="8" height="8" /><?php } ?>
              <?php if ($a14=='Cash sale') { ?><img src="../images/round_purple.png" width="8" height="8" /><?php } ?>
              Q</td>
              <td  style="padding-left:0px;" align="left"><a href="quotation_request.php?quote_no=<?php echo $a1 ?> " onmouseover="ddrivetip('<?php echo $quoteTT?>', 250)"; onmouseout="hideddrivetip()"><?php echo $a1 ?></a></td>
              <td width="70" align="left"><?php echo date("d-m-Y", strtotime($a5))?></td>
              <td width="98" align="left"><?php echo $a12 ?>&nbsp;</td>
              <td width="94" align="left"><a href="customer_details.php?cust_id=<?php echo $a2 ?>" onmouseover="ddrivetip('<?php echo $customerTT?>', 250)"; onmouseout="hideddrivetip()"><?php echo $a2a ?></a></td>
              <td width="88" align="left"><?php echo $a9."<br>".$a10 ?>&nbsp;</td>
              <td width="80" align="left"><?php echo $a7 ?></td>
              <td width="69" align="left"><?php echo $a8 ?>&nbsp;</td>
              <td width="64" align="left"><?php echo $a5?></td>
            </tr>
            <?php
  $i++;
}
?>
            <tfoot>
              <tr>
                <td colspan="9"; height="5px;">&nbsp;</td>
              
              </tr>
            </tfoot>
          </table>
          
        </div>
</div>  
  
</div>
<?php include ('../navigation/side_bar.php'); ?>
</body>
<?php } else {
$_SESSION['denied_return'] = "sales/sales_main.php";	
include ("../navigation/sales_sidebar.php");?>
<body onload="accessdenied(); return false">
</body>
<?php }
?>
</html>