

<?php
   if($_SESSION['p']==1) {
		    $_SESSION['orderNo'] = $_GET['order_no_text'];
	}
	
	$query = "SELECT orderNo FROM orders WHERE  orderNo = '". $_SESSION['orderNo']."' " ;
	$result = mySQL_query($query) or die ("Error in query:   $query . * ". mySQL_error());
	$num = mysql_num_rows($result);
	
	if ($num!=0) { 
	$_SESSION['error']=1;
	$_SESSION['p']=1;
	
	?>
    <script language="javascript" type="text/javascript">
        <!--
		needToConfirm = false;
	 window.location="orderWizbase.php?s=0&p=1 ";
        -->
     </script>
     
    
<?php	
       }
    else{


   include ('../include/formValidations.php');
   require_once ('classes/tc_calendar.php');
   $start = strtotime($_SESSION['DeliveryDate']);
	
	$d = date("d", $start );
	$m = date("m", $start );
	$y = date("Y", $start );
	
	
	$table_name = "rad_list_places";
    $position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
	$arrId2 = array ();
	$arrName2 = array ();
	$position_result = execsql($position_query);
	if ($position_result!="") {
	$position_num = mysql_num_rows($position_result);
	$b = 0;
	while ($b < $position_num) {
		$arrId2[$b] = mysql_result($position_result, $b, "item_name");
		$arrName2[$b] = mysql_result($position_result, $b, "item_name");
		$b++;
	}
	}


$suppliersQuery = "SELECT CompanyName,  CustNo FROM customer WHERE active=" . 1 ." ORDER BY CompanyName ASC";
	$suppliersResult = execsql($suppliersQuery);
	$suppliersNum = mysql_num_rows($suppliersResult);
	$w = 0;
	$arrId = array ();
	$arrName = array ();
	while ($w < $suppliersNum) {
		$arrId[$w] = mysql_result($suppliersResult, $w, "CustNo");
		$arrName[$w] = mysql_result($suppliersResult, $w, "CompanyName");
		$w++;
	}



$_SESSION['error']=0;
//place select box
$place = file('../include/places.txt');
$options = '';
foreach ($place as $place) {
    $options .= '<option value="'.$place.'">'.$place.'</option>';
}
$place_select = '<select name="PlaceText" class="wizard1"> <option selected="selected">'. $_SESSION['PlaceText'].'</option> '.$options.'</select>';  

?>

<script language="JavaScript" src="gen_validatorv4.js"  type="text/javascript" xml:space="preserve"></script>  <!--form validation-->
<script type="text/javascript" src="../css/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="../css/wizard.css" />
<script language="javascript" type="text/javascript" >
<!--
function confirmRefresh() {
var okToRefresh = confirm("Do you really want to cancel this entry?");
var url='showAllProducts.php?cat=Tiles and Accessories&productSelect=All&colorSelect=All'
if (okToRefresh)
	{
			window.location=url;
	}
}
// -->
</script>
<script language="JavaScript">
var needToConfirm = true;
  window.onbeforeunload = confirmExit;
   function confirmExit()
  {
    if (needToConfirm)
      return "You did not finish the wizard./nIf you leave now your data will not be saved.";
  }
</script>


<?php echo $_SESSION['CustNo'] ?>
<form id="feedbackform" method="GET" onsubmit="mysubmit();return false" action="orderWizbase.php">
    <table width=595 border="0" align="center" cellpadding="10" cellspacing="0" bordercolor="#0066FF" border-collapse="collapse">
          <tr>
            <td width="525" ><p class="wizard">
            <label class="std">Order for:&nbsp;&nbsp;&nbsp;: &nbsp;&nbsp;
              <select name="CustText" id="CustText" class="wizard3" >
                <option value="<?php echo $_SESSION['CustNo']?>" ><?php echo $_SESSION['CustomerName']?></option>
                <?php
    	for ($i = 0; $i < count($arrId); $i++) {
		echo "<option value=" . "\"" . $arrId[$i] . "\"" . ">" . $arrName[$i] . "</option>";
		$_SESSION['CustomerName'] = $arrName[$i];
		//foreach($arrId as $key=>$value){
			//echo "<option value=\"delivery.php?productId=".$arrId[$i]."&cat=$cat&formEnabled2=1&date=$date" . "\"" . ">" . $arrName[$i] . "</option>";	
	    }
     ?>
              </select>
              &nbsp;</label>
            <label class="star">*</label>
              </p>
              <p class="wizard">
                <label class="std">Delivery to:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
                <input name="deliver_to_text" type="text" id="deliver_to_text" class="wizard0" onblur="capitalize(this)" value="<?php echo $_SESSION['DeliverTo'] ?>"  />
                <label class="std"><br />
                  &nbsp;Address:</label>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <input name="address_text" type="text" id="address_text" class="wizard0" onblur="capitalize(this)" value="<?php echo $_SESSION['AddressText'] ?>"  />
  <label class="star">*</label>
  <label class="right">&nbsp;&nbsp;&nbsp;<br />
    &nbsp;City:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
  <select name="PlaceText" class="wizard1"  >
    <option value="<?php echo $_SESSION['PlaceText'] ?>" selected="selected"><?php echo $_SESSION['PlaceText'] ?></option>
    <?php
        	for ($j = 0; $j < count($arrId2); $j++) {
    		echo "<option value=" . "\"" . $arrId2[$j] . "\"" . ">" . $arrName2[$j] . "</option>";
	}
?>
  </select>
  <label class="star">*</label>
              </p>
              <br />
              <p class="wizard">
                <label class="std">Contact number:&nbsp;&nbsp;&nbsp;&nbsp;</label>
                <input class="wizard1" name="CellText" id="cell number" type="text" value="<?php echo $_SESSION['CellText'] ?>" onkeypress="return numbersonly(this, event)"/>
              </p>
              <p class="wizard">
                <label class="std">
                  <input type="radio" name="del_col_group" value="D" id="del_col_group_0" <?php if ($_SESSION['delCol']=='D') {echo 'checked=checked';} ?> />
                  deliver</label>
                <label class="std">
<input type="radio" name="del_col_group" value="C" id="del_col_group_1" <?php if ($_SESSION['delCol']=='C') {echo 'checked=checked';} ?>/>
collect</label>
                <label class="std">&nbsp; </label>
                <label class="star">*</label>
                </p>
                <p class="wizard">
                  <label class="std">
                date for delivery or collect:</label>
                &nbsp;&nbsp;&nbsp;<label class="star">*</label>
                <input type="radio" name="delivery_group" value="tba" id="delivery_group_1"  <?php if ($_SESSION['DelDate']=='tba') {echo 'checked=checked';} ?> />
               <label class="std">tba&nbsp;&nbsp;&nbsp;&nbsp;</label>
                
                  <input type="radio" name="delivery_group" value="date" id="delivery_group_0" <?php if ($_SESSION['DelDate']=='date') {echo 'checked=checked';} ?>/>
                <?php

		$myCalendar = new tc_calendar("DeliveryDate", true);
		$myCalendar->setIcon("../img/iconCalendar.gif");
		$myCalendar->setDate($d, $m, $y);
		$myCalendar->setPath("./");
		$myCalendar->setYearInterval(2010, 2030);
		$myCalendar->writeScript();
?>
           
                
                
              </p></td>
            
          </tr>
          <tr>
            <td>
              <table width="590" height="50" align="center" id="tableButtonBar">
                <tr>
                  <td width="117"><input type="submit" name="prev_button" id="prev_button" class="imagebutton" value="Prev" onclick=" needToConfirm = false; " /></td>
                  <td width="115"><span class="wizard">
                    <input name="p" type="hidden" id="p" value="2" />
                    <input name="s" type="hidden" id="s" value="2" />
                  </span></td>
                  <td width="99">&nbsp;</td>
                  <td width="125"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onclick="javascript:confirmRefresh(); needToConfirm = false;" value="Cancel" /></td>
                  <td width="110" align="left"><input type="submit" name="next_button" class="imagebutton" value="Next" onclick="needToConfirm = false; " /></td>
                </tr>
              </table></td>
          </tr>
        </table>
  </table>
  
</form>

<!--form validation-->
  <script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("feedbackform");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("CustText","req","Please select a customer.");
  frmvalidator.addValidation("address_text","req","Please enter a delivery address.");
  //frmvalidator.addValidation("PlaceText","req","Please select a city.");
  frmvalidator.addValidation("del_col_group","selone","Please select delivery or collection.");
  frmvalidator.addValidation("delivery_group","selone","Please select date.");
  </script>

 <?php
	}
	?>