<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<?php
include('../include/session.php');
require_once('../include/tc_calendar.php');

$edit_date = date("Y-m-d");
$edit_date = strtotime($edit_date);
$d = date("d", $edit_date ) ;
$m = date("m", $edit_date ) ;
$y = date("Y", $edit_date ) ;

$page = $_GET['page'];
	
if ($page=='quote') {
$reference='edit_maintenance_quotation.php?edit=0&stock_error=0&quote_no=';	
$page_name_this='Edit maintenance';
$table_name = $_SESSION['db_prefix']."_maintenance_quotations";
$quoteQuery = "SELECT quote_id, quote_no, project, cust_id  FROM $table_name WHERE status = 'quoted' ORDER BY quote_no DESC";
$quoteResult = execsql($quoteQuery);
$quoteNum = mysql_num_rows($quoteResult);
	$w = 0;
	$arrId4 = array ();
	$arrName4 = array ();
	while ($w < $quoteNum) {
		$cust_id = mysql_result($quoteResult, $w, "cust_id"); 
		$table_name2 = $_SESSION['db_prefix']."_customer";
		$customer_query = "SELECT * FROM $table_name2 WHERE cust_id ='".$cust_id."' ";
		$customer_result = mySQL_query($customer_query);
		$customer_num = mysql_num_rows($customer_result);	
		$a1 = mysql_result($customer_result, 0, "account_type");
			if ($a1=="corporate") { 
				$cust_name = mysql_result($customer_result, 0, "comp_name"); 
			} 
			else {
				$cust_name = mysql_result($customer_result, 0, "title")." ".mysql_result($customer_result, 0, "name_2")." ".mysql_result($customer_result, 0, "comp_name");
 			}
		
		
		
		$arrId4[$w] = mysql_result($quoteResult, $w, 'quote_no');
		$arrName4[$w] = mysql_result($quoteResult, $w, 'quote_no').' '.$cust_name.' ('.mysql_result($quoteResult, $w, 'project').')';
		$w++;
	}
}


?>
</head>

<body>
<?php
include ("../navigation/header.php");
$page_name = "Maintenance-edit quote";
include ("../navigation/access.php");
if ($permission_num==1) {
	include ("../navigation/maintenance_sidebar.php");
?>
<div class="main_frame">
<div class="page_head_frame">
        <table width="630" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="385"><label class="label_page_head">Select to edit</label></td>
            <td align="right">&nbsp;</td>
          </tr>
        </table>
      </div>

<div class="page_middle_frame"><br />

<?php 
if ($page=='quote') { ?>
<div class="page_inside_frame">
  <label class="label_std" style="font-size:16px;"><?php echo $page_name_this?></label>
  <br />
  <br />
  <form action="" method="get">
  
    <label class="label_std"> Select <?php echo $page_name_this?> to edit : &nbsp;&nbsp;</label>
    <select name="vehicle_select" autofocus class="selectbox400" id="vehicle_select" onchange="window.location.href= this.form.vehicle_select.options[this.form.vehicle_select.selectedIndex].value"> 
      <option value=" " selected="selected" >&nbsp;</option>
      <?php
    	for ($j = 0; $j < count($arrId4); $j++) {
			echo "<option value=".$reference.$arrId4[$j].">".$arrName4[$j]."</option>";	
		}
     ?>
    </select>
  
  </form>
  <br />
  <br />
<br />
<br />
<br />
</div>
<?php } ?>


<?php 
if ($page=='fuel') { 
?>
<div class="page_inside_frame">
  <label class="label_std" style="font-size:16px;"><?php echo $page_name_this ?></label>
  <br />
  <br />
  <form action="" method="get">
  
    <label class="label_std"> Select <?php echo $page_name_this ?> to edit : &nbsp;&nbsp;</label>
    <select name="fuel_id_select" autofocus class="selectbox300" id="fuel_id_select" onchange="window.location.href= this.form.fuel_id_select.options[this.form.fuel_id_select.selectedIndex].value"> 
      <option value=" " selected="selected" >&nbsp;</option>
      <?php
    	for ($j = 0; $j < count($arrId2); $j++) {
			echo "<option value=".$reference.$arrId2[$j].">".$arrName2[$j]."</option>";	
		}
     ?>
    </select>
  
  </form>
  <br />
  <br />
<br />
<br />
<br />
</div>
<?php } ?>

    
</div>
</div>
<?php include ('../navigation/side_bar.php'); ?>

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


</html>