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

if ($permission_num==1) {
require_once ('../include/tc_calendar.php');	
$start = strtotime($_SESSION['delivery_date']);
$d = date("d", $start );
$m = date("m", $start );
$y = date("Y", $start );

$table_name = $_SESSION['db_prefix']."_list_drivers";
$vehiclesQuery = "SELECT item_id, item_name FROM $table_name  ORDER BY item_name ASC";
	$vehiclesResult = execsql($vehiclesQuery);
	$vehiclesNum = mysql_num_rows($vehiclesResult);
	$w = 0;
	$arrId1 = array ();
	$arrName1 = array ();
	while ($w < $vehiclesNum) {
		$arrId1[$w] = mysql_result($vehiclesResult, $w, "item_name");
		$arrName1[$w] = mysql_result($vehiclesResult, $w, "item_name");
		$w++;
	}

$table_name = $_SESSION['db_prefix']."_list_vehicles";
$vehiclesQuery = "SELECT item_id, item_name FROM $table_name  ORDER BY item_name ASC";
	$vehiclesResult = execsql($vehiclesQuery);
	$vehiclesNum = mysql_num_rows($vehiclesResult);
	$w = 0;
	$arrId2 = array ();
	$arrName2 = array ();
	while ($w < $vehiclesNum) {
		$arrId2[$w] = mysql_result($vehiclesResult, $w, "item_name");
		$arrName2[$w] = mysql_result($vehiclesResult, $w, "item_name");
		$w++;
	}


$table_name = $_SESSION['db_prefix']."_captured_jobs";
		$job_query = "SELECT *  FROM $table_name WHERE job_no = '".$_SESSION['job_no']."' ";
		$job_result = mySQL_query($job_query);
		$_SESSION['cust_id']=mysql_result($job_result, 0, "cust_id");
		$quote_note=mysql_result($job_result, 0, "quote_note");
		$_SESSION['delivery_address'] = mysql_result($job_result, 0, "project_no").' '.mysql_result($job_result, 0, "project_place");
		
$job_no = $_SESSION['job_no'];
$quote='no';
$table_name = $_SESSION['db_prefix']."_captured_jobs";
$job_query = "SELECT * FROM $table_name WHERE job_no = '".$job_no."' ";
$job_result = mySQL_query($job_query);
$cust_id = mysql_result($job_result, 0, "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") { 
				$_SESSION['name'] = mysql_result($customer_result, 0, "comp_name"); 
			} 
			else {
				$_SESSION['name'] = mysql_result($customer_result, 0, "title")." ".mysql_result($customer_result, 0, "name_2")." ".mysql_result($customer_result, 0, "comp_name");
 			}

		 
?>
<!--style sheets-->

<!--jscript-->
<script language="javascript" src="../jscript/calendar.js"></script>
<script language="JavaScript" src="../jscript/gen_validatorv4.js"  type="text/javascript" xml:space="preserve"></script>
<script language="JavaScript" src="../jscript/numbers_only.js"  type="text/javascript"></script>  
<script language="JavaScript" src="../jscript/capitalize_textbox.js"  type="text/javascript"></script>  

</head>



<?php include('../include/wait.php') ?>
<body onLoad="MM_showHideLayers('wait','','hide'); " onFocus="MM_showHideLayers('wait','','hide'); " >

<div class="page_middle_frame">
<form id="form1" name="form1" method="get" action="deliverJobWizbase.php">
  
<div class="wizard_frame">
<?php 
		include ('../include/customer_block.php');
		echo '<br>';
		include ('../include/job_block.php')
		?>
</div>
<div class="wizard_frame">
  <table width="672" id="table_display_wizard2">
    <tr>
      <td width="123" valign="middle">&nbsp;</td>
      <td colspan="3" valign="middle">&nbsp;</td>
    </tr>
    <tr>
      <td height="30" valign="middle"><label class="label_std">Delivery address:</label></td>
      <td colspan="3" valign="middle"><input name="delivery_address_text" type="text" class="text300" id="delivery_address_text" value="<?php echo $_SESSION['delivery_address']?>" onBlur="capitalize(this)">
        <label class="star">*</label></td>
    </tr>
    <tr>
      <td height="30" valign="middle"><label class="label_std">Delivered by:</label></td>
      <td width="271" valign="middle"><select name="driver_select" id="driver_select" class="select160">
        <option value="<?php echo $_SESSION['driver']?>" selected="selected" ><selected="selected"><?php echo $_SESSION['driver']?></option>
        <?php 
    	for ($w = 0; $w < count($arrId1); $w++) {
		echo "<option value=\"".$arrId1[$w] . "\"" . ">" . $arrName1[$w] . "</option>";	
	    }
     ?>
      </select>
        <label class="star">*</label></td>
      <td width="86" valign="middle"><label class="label_std">Vehicle reg.:</label></td>
      <td width="172" valign="middle"><select name="vehicle_select" id="vehicle_select" class="select120">
        <option value="<?php echo $_SESSION['vehicle']?>" selected="selected" ><selected="selected"><?php echo $_SESSION['vehicle']?></option>
        <?php 
    	for ($w = 0; $w < count($arrId2); $w++) {
		echo "<option value=\"".$arrId2[$w] . "\"" . ">" . $arrName2[$w] . "</option>";	
	    }
     ?>
      </select>
        <label class="star">*</label></td>
    </tr>
    <tr>
      <td height="30" valign="middle"><label class="label_std">Delivery date:</label></td>
      <td valign="middle"><?php

		$myCalendar = new tc_calendar("receive_date", true);
		$myCalendar->setIcon("../images/iconCalendar.gif");
		$myCalendar->setDate($d, $m, $y);
		$myCalendar->setPath("./");
		$myCalendar->setYearInterval(2014, 2090);
		//$myCalendar->dateAllow('2009-02-20', "", false);
		$myCalendar->writeScript();
?></td>
      <td valign="middle"><label class="label_std">Delivery time:</label></td>
      <td valign="middle"><select name="hour_select" class="select50" id="hour_select">
        <option value="<?php echo $_SESSION['hour']?>" selected="selected" ><selected="selected"><?php echo $_SESSION['hour']?></option>
        <?php 
		$i=0;
		while ($i<24) { ?>
           <option value="<?php if ($i<10) {echo '0'.$i;} else { echo $i; } ?>"><?php if ($i<10) {echo '0'.$i;} else { echo $i; } ?></option>
           <?php 
		   $i++;
		}
		?>
        
        <option> </option>
      </select>
        <label class="label_std">hrs
          <select name="min_select" class="select50" id="min_select">
            <option value="<?php echo $_SESSION['min']?>" selected="selected" ><selected="selected"><?php echo $_SESSION['min']?></option>
            <?php 
		$i=0;
		while ($i<60) { ?>
           <option value="<?php if ($i<10) {echo '0'.$i;} else { echo $i; } ?>"><?php if ($i<10) {echo '0'.$i;} else { echo $i; } ?></option>
           <?php 
		   $i++;
		}
		?>
            <option> </option>
          </select>
          min
        </label><label class="star">*</label></td>
    </tr>
  </table>
</div> 
<div class="button_bar_frame">
<table 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" />
            <input name="all" type="hidden" id="all" value="none" /></td>
            <td width="99">&nbsp;</td>
            <td width="125"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onClick="needToConfirm = false; cancel_confirmation(1, '../store/store_main.php');" value="Cancel"  tabindex="-1"/></td>
            <td width="110" align="right"><input type="submit" name="next_button" class="imagebutton" value="Next" onClick="needToConfirm = false; MM_showHideLayers('wait','','show');" /></td>
          </tr>
        </table>
        </div>
         </form>
 </div>
 <!--form validation-->
<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form1");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("delivery_address_text","req","Please enter a delivery address.");
  frmvalidator.addValidation("driver_select","req","Please select driver.");
  frmvalidator.addValidation("vehicle_select","req","Please select vehicle registration.");
  frmvalidator.addValidation("hour_select","req","Please select delivery time hour.");
  frmvalidator.addValidation("min_select","req","Please select delivery time minutes.");
</script>

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