<head>
<?php 
$page_name = "Maintenance-quotation";
include ("../navigation/access.php");

if ($permission_num==1) {
 
$table_name2 = $_SESSION['db_prefix']."_maintenance_quotations";
$quote_query = "SELECT quote_no, cust_id, request_date, project, project_no, project_area, project_place FROM $table_name2 WHERE status = 'request' ORDER BY quote_no ASC ";
$quote_result = mySQL_query($quote_query);
$quote_num = mysql_num_rows($quote_result);	

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

<!--jscript-->
<script language="JavaScript" src="../jscript/tablesort.js"  type="text/javascript"></script> 


</head>

<?php include('../include/wait.php') ?>

<body onLoad="MM_showHideLayers('wait','','hide')" onFocus="MM_showHideLayers('wait','','hide');">
<div class="wizard_page_middle_frame">
<form id="form1" name="form1" method="get" action="quoteWizbase.php">
  <div class="wizard_frame">
  <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": "500px",
					"bPaginate": false,
					"bScrollCollapse": true,
					"aaSorting": [[ 5, "desc" ]],
					"aoColumns": [
								{"iDataSort": 5},
                              	{"bSortable": true},
                             	{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bVisible": false}
								 ]
				} );
			} );
		</script>
    <label class="label_std">Select quotation request:
    &nbsp;&nbsp;(click on quote number to continue)</label>
  <table width="605" class="data_display" id="scroll_table" ">
    <thead>
    <tr>
      <th width="12" style="border-right-style:hidden;">&nbsp;</th>
      <th width="80"  align="left">Quote no</th>
      <th width="216"  align="left">Customer</th>
      <th width="86"  align="left">Enquiry date:</th>
      <th width="160"  align="left">Project</th>
      <th width="23"  align="left">&nbsp;</th>
    </tr>
    </thead>
    <?php 
	$i=0;
	while ($i<$quote_num) {
		$a1 = mysql_result($quote_result, $i, "quote_no");
		$a2 = mysql_result($quote_result, $i, "cust_id");
			$table_name = $_SESSION['db_prefix']."_customer";
			$customer_query = "SELECT status, account_type, comp_name, name_2, title, bag_box, box_no, postal_place, phone, cell_1  FROM $table_name WHERE cust_id = '".$a2."' ";
			$customer_result = mySQL_query($customer_query);
			$customer_num = mysql_num_rows($customer_result);
			if ($customer_num!=0) {
			$type = mysql_result($customer_result, 0, "account_type");
			if ($type=="corporate") { 
				$a2a = mysql_result($customer_result, 0, "comp_name"); 
			} 
			else {
				$a2a = mysql_result($customer_result, 0, "title")." ".mysql_result($customer_result, 0, "name_2")." ".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, "cell_1");
			$a2g = mysql_result($customer_result, 0, "status");
			$a2h="";
			}
			else {
			$a2a='';
			}
		 $a3 = mysql_result($quote_result, $i, "request_date");	
		 $a4 = mysql_result($quote_result, $i, "project");	
		 
			 
			
		$customerTT = $a2h."<br><label class=tip_text_label>".$a2a."<br>".$a2b." ".$a2c."<br>".$a2d."<br>".$a2e." / ".$a2f."<br>";
	?>	
    <tr>
      <td style="border-right-style:hidden; padding-right:opx;">M</td>
      <td style="padding-left:0px;"><a href="maintenance_quoteWizbase.php?maintenance_no=<?php echo $a1?>&cust_id=<?php echo $a2 ?>&p=2&s=1" onClick="needToConfirm = false; MM_showHideLayers('wait','','show');"><?php echo $a1?></a></td>
      <td><a href="" onMouseover="ddrivetip('<?php echo $customerTT ?>', 150)"; onMouseout="hideddrivetip()"  onClick="needToConfirm = false;" ><?php echo $a2a?></a></td>
      <td><?php echo date("d-m-Y", strtotime($a3)) ?>&nbsp;</td>
      <td><a href="" onMouseover="ddrivetip('<?php echo $customerTT ?>', 150)"; onMouseout="hideddrivetip()"><?php echo $a4?></a></td>
      <td><?php echo $a3 ?></td>
    </tr>
    <?php 
	$i++;
	}
	?>
  </table>
</div>
<br>
<div class="wizard_frame">
<table width="675" height="50" align="center" id="table_button_bar">
          <tr>
            <td width="117">&nbsp;</td>
            <td width="115"><input name="p" type="hidden" id="p" value="1" />
              <input name="error" type="hidden" id="error" value="0" />
            <input name="s" type="hidden" id="s" value="1" /></td>
            <td width="99">&nbsp;</td>
            <td width="125"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onClick="needToConfirm = false; cancel_confirmation(1, '../sales/sales_main.php?date='); " value="Cancel" /></td>
            <td width="110" align="right">&nbsp;</td>
          </tr>
        </table></td>
    </tr>
  </table>
  </div>
 </form>
</div>

</body>  
<?php } else { 
    $_SESSION['denied_return'] = "maintenance/maintenance_main.php?date=";	?>
<body onLoad="needToConfirm = false; accessdenied(); return false">
</body>
<?php }
?>