<?php 

 require_once ('classes/tc_calendar.php');
$start = strtotime($_SESSION['DeliveryDateText']); 
$d = date("d", $start );
$m = date("m", $start);
$y = date("Y", $start);

  include ('../include/formValidations.php');
  
  $table_name = "nam_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++;
	}
	}
?>
<link rel="stylesheet" href="../css/dhtmlwindow.css" type="text/css" />
<script type="text/javascript" src="../css/dhtmlwindow.js">
</script>


<script type="text/javascript" src="../css/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="../css/wizard.css" />
<link rel="stylesheet" href="../css/modal.css" type="text/css" />
<script type="text/javascript" src="../css/modal.js"></script>
<script language="JavaScript" src="gen_validatorv4.js"  type="text/javascript" xml:space="preserve"></script>
<!--form validation-->
<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 type="text/javascript">
function addproduct(){
//Open a modal window with an iframe page inside, and assign the result to a global variable called "addproductwindow"
addproductwindow=dhtmlmodal.open('EmailBox', 'iframe', 'selectProduct.php', 'Select a product', 'width=300px,height=150px,center=1,resize=0,scrolling=0')
needToConfirm = false;
addproductwindow.onclose=function(){
	needToConfirm = false;
var theform=this.contentDoc.forms[0] //Access first form inside iframe for demo purposes
var theemail=this.contentDoc.getElementById("emailfield") //Access form field with id="emailfield"
if (theemail.value.indexOf("@")==-1){ //crude check for invalid email
//alert("Please enter a valid email address")

return false //cancel closing of modal window
}
else{ //else if this is a valid email
document.getElementById("youremail").innerHTML=theemail.value //Assign the email to a span on the page

return true //allow closing of window
}
}
}

</script>

<script type="text/javascript">
function removeproduct(){
//Open a modal window with an iframe page inside, and assign the result to a global variable called "addproductwindow"
removeproductwindow=dhtmlmodal.open('EmailBox', 'iframe', 'removeProduct.php', 'Remove this product', 'width=300px,height=300px,center=1,resize=0,scrolling=0')
needToConfirm = false;
removeproductwindow.onclose=function(){
var theform=this.contentDoc.forms[0] //Access first form inside iframe for demo purposes
var theemail=this.contentDoc.getElementById("emailfield") //Access form field with id="emailfield"
if (theemail.value.indexOf("@")==-1){ //crude check for invalid email
//alert("Please enter a valid email address")

return false //cancel closing of modal window
}
else{ //else if this is a valid email
document.getElementById("youremail").innerHTML=theemail.value //Assign the email to a span on the page

return true //allow closing of window
}
}
}

</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.";
  }
function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}
</script>

<body onUnload="needToConfirm = false;">

<form id="feedbackform" method="get" action="outWizbase.php" >
  <table width=595 border="0" align="center" cellpadding="10" cellspacing="0" bordercolor="#0066FF" border-collapse="collapse">
    <tr>
      <td width="525" valign="top" >
      <p class="wizard">
  <label class="left">Delivery date: </label> 
  
  <?php

		$myCalendar = new tc_calendar("DeliveryDateText", true);
		$myCalendar->setIcon("../img/iconCalendar.gif");
		$myCalendar->setDate($d, $m, $y);
		$myCalendar->setPath("./");
		$myCalendar->setYearInterval(2010, 2020);
		$myCalendar->writeScript();
?>
&nbsp;&nbsp;&nbsp;Deliver or collect:&nbsp;&nbsp;<span class="std">
<select name="delCol_select" class="wizard1" id="delCol_select"  >
  <option value="C">Collect</option>
  <option value="D">Deliver</option>
  <option value="<?php echo $_SESSION['delColText'] ?>" selected>
  <?php if ($_SESSION['delColText']=="C") {echo "Collect";} if ($_SESSION['delColText']=="D") {echo "Deliver";}?>
  </option>
</select>
</span></p>
      <p class="wizard">
  <label class="left">Delivery place:</label><br />
  <label class="left">Address: </label>  <input type="text" class="wizard0" name="DeliverText2" id="DeliverText2" value="<?php echo $_SESSION['DeliverText2']?>" onBlur="capitalize(this)" onKeyUp="ToLower(this)" onfocus = "this.select();"/><br>

  <label class="left">Place:</label>
  <select name="DeliverText3" class="wizard1"  >
    <option value="<?php echo $_SESSION['DeliverText3'] ?>" selected="selected"><?php echo $_SESSION['DeliverText3'] ?></option>
    <?php
        	for ($j = 0; $j < count($arrId2); $j++) {
    		echo "<option value=" . "\"" . $arrId2[$j] . "\"" . ">" . $arrName2[$j] . "</option>";
	}
?>
  </select>
<br>
      <label class="left">Contact:</label> 
      <input type="text" class="wizard1" name="contactText" id="contactText" value="<?php echo $_SESSION['contactText'] ?> " onfocus = "this.select();" onKeyPress="return numbersonly(this, event)"/>
      </p>
  <p class="wizard">
<label class="left">Transporter:</label>  <input type="text" class="wizard1" name="TransporterText" id="TransporterText" value="<?php echo $_SESSION['TransporterText'] ?>" onBlur="capitalize(this)" onKeyUp="ToLower(this)"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<label class="right">Reg.No:</label>&nbsp;&nbsp;&nbsp;  <input type="text" class="wizard1" name="RegNoText" id="RegNoText" onKeyUp="ToUpper(this)" value="<?php echo $_SESSION['RegNoText']?>"/>
</p>
<p class="wizard">
          <label class="std">Enter additional information here:</label>
          <br />
          <textarea class="wizard1" name="RemarksText" id="remarks"  style="width:500px;height:50px"  ><?php echo $_SESSION['RemarksText'] ?></textarea>
          <br />
        </p>
  </td>
    </tr>
    <tr>
      <td><table width="590" height="50" align="center" id="tableButtonBar">
          <tr>
            <td width="117"><input type="submit" name="prev_button" class="imagebutton" value="Prev" onClick="needToConfirm = false; " /></td>
            <td width="115"><span class="wizard">
              <input name="s" type="hidden" id="s" value="3" />
              <input name="p" type="hidden" id="p" value="3" />
            </span></td>
            <td width="99"><span class="wizard"></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>
<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("feedbackform");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("PalletsText","req","Please enter number of pallets with this order.\nIf no pallets are on order, enter 0.");
  
</script>
</body>