<head>
<?php
$e=$_GET['e'];

require_once ('../include/tc_calendar.php');

if ($_SESSION['order_date']=='2000-01-01') { $_SESSION['order_date'] = date('Y-m-d');}
$ord_date = strtotime($_SESSION['order_date']);
$d1 = date("d", $ord_date );
$m1 = date("m", $ord_date );
$y1 = date("Y", $ord_date );



if ($_SESSION['delivery_date']=='2000-01-01') { $_SESSION['delivery_date'] = date('Y-m-d');}
$require_date = strtotime($_SESSION['delivery_date']);
$d2 = date("d", $require_date );
$m2 = date("m", $require_date );
$y2 = date("Y", $require_date );
	
$table_name = $_SESSION['db_prefix']."_list_places";
    $position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
	$arrId3 = array ();
	$arrName3 = array ();
	$position_result = execsql($position_query);
	if ($position_result!="") {
	$position_num = mysql_num_rows($position_result);
	$b = 0;
	while ($b < $position_num) {
		$arrId3[$b] = mysql_result($position_result, $b, "item_name");
		$arrName3[$b] = mysql_result($position_result, $b, "item_name");
		$b++;
	}
	}

$table_name = $_SESSION['db_prefix']."_permissions";
$permission_query = "SELECT access_id  FROM  $table_name  WHERE access_id ='". $_SESSION['access_id']."' AND page_name = 'Sales-discount' ";
$permission_result = mySQL_query($permission_query);
$permission_num = mysql_num_rows($permission_result);
if ($permission_num>0) { 
		$discount_limit = 'no'; 
}
else {
	$discount_limit = 'yes'; 
}
?>
<!--jscript-->
<script language="JavaScript" src="../jscript/gen_validatorv4.js"  type="text/javascript" xml:space="preserve"></script>
<script language="javascript" src="../jscript/calendar.js"></script>
<script language="JavaScript" src="../jscript/capitalize_textbox.js"  type="text/javascript"></script> 
<script language="JavaScript" src="../jscript/lower_case.js"  type="text/javascript"></script>
<script language="JavaScript" src="../jscript/show_hide_layers.js"  type="text/javascript"></script>
<script language="JavaScript" src="../jscript/go_to_url.js"  type="text/javascript"></script>   
</head>
<?php include('../include/wait.php') ?>

<body onLoad="
MM_showHideLayers('wait','','hide');
<?php if ($_SESSION['deliver_collect']=='') {?> document.getElementById('deliver_entry').hidden=false; document.getElementById('collect_entry').hidden=true; <?php } ?> 
<?php if ($_SESSION['deliver_collect']=='deliver') {?> document.getElementById('deliver_entry').hidden=false; document.getElementById('collect_entry').hidden=true; <?php } ?>
<?php if ($_SESSION['deliver_collect']=='collect') {?> document.getElementById('deliver_entry').hidden=true; document.getElementById('collect_entry').hidden=false; <?php } ?>
<?php if ($e==1) { ?> alertMessage(1, '', 'The order number entered is already used.<br>Please use another number.'); <?php } ?>
<?php if ($_SESSION['tba_deliver']=='del_date') {?>document.getElementById('date_div').hidden=false; <?php } else { ?>document.getElementById('date_div').hidden=true;<?php } ?>
"




onFocus="MM_showHideLayers('wait','','hide');"  onBlur="MM_showHideLayers('wait','','hide');">
<div class="page_middle_frame">
<form id="form1" method="get" action="newOrderWizbase.php">

    <div class="wizard_frame">
      <table width="600" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="131" height="36">
    <input type="hidden" name="val_check" id="val_check" value="yes">
&nbsp;    Order no:&nbsp;
    <label class="star">*</label>
    &nbsp;&nbsp;<br>
    </td>
    <td width="200"><input name="order_no_text" type="text" value="<?php echo $_SESSION['order_no'] ?>" onKeyUp="ToUpper(this)" autocomplete="off"></td>
    <td width="269"><label>
      <input type="radio" name="deliver_group" value="deliver" id="deliver_group_0" onClick="if (document.getElementById('deliver_group_0').checked='true') {document.getElementById('deliver_entry').hidden=false; document.getElementById('collect_entry').hidden=true; document.getElementById('deliver_project_no_text').value=''; document.getElementById('deliver_project_place_select').selectedIndex=0; }" <?php if ($_SESSION['deliver_collect']=='deliver') {?> checked <?php } ?> >
      Deliver</label>
      <label>
        <input type="radio" name="deliver_group" value="collect" id="deliver_group_1" onClick="if (document.getElementById('deliver_group_1').checked='true') { document.getElementById('deliver_entry').hidden=true;  document.getElementById('deliver_project_no_text').value='--'; document.getElementById('deliver_project_place_select').selectedIndex=1;  }"  <?php if ($_SESSION['deliver_collect']=='collect') {?> checked <?php } ?> >
        Collect</label>
      &nbsp;&nbsp;
      <label class="star">*</label></td>
  </tr>
  <tr>
    <td>Order date:</td>
    <td colspan="2"><?php

		$myCalendar = new tc_calendar("order_date", true);
		$myCalendar->setIcon("../images/iconCalendar.gif");
		$myCalendar->setDate($d1, $m1, $y1);
		$myCalendar->setPath("./");
		$myCalendar->setYearInterval(2015, 2090);
		//$myCalendar->dateAllow('2009-02-20', "", false);
		$myCalendar->writeScript();
?></td>
    </tr>
      </table>
</div>
            
<div class="wizard_frame">
                <table width="656" border="0">
                  <tr>
                    <td valign="middle" >&nbsp;Contact:&nbsp;<label class="star">*</label></td>
                    <td valign="middle"><input type="text" name="deliver_contact_text" id="deliver_contact_text" class="text200" onBlur="capitalize(this)" value="<?php echo $_SESSION['deliver_contact']?>"></td>
                    <td valign="middle">Phone:&nbsp;<label class="star">*</label></td>
                    <td valign="middle"><input type="text" name="deliver_phone_text" id="deliver_phone_text" class="text200" onKeyPress="return numbersonly(this, event)" value="<?php echo $_SESSION['deliver_phone']?>"></td>
                  </tr>
                  </table>
                <div id="deliver_entry" >
                <table width="656" border="0">
                  <tr>
                    <td width="127" valign="middle" ><label class="label_std">Project or plot no:&nbsp;&nbsp;</label>
                     <label class="star">*</label></td>
                    <td width="242" valign="middle"><input name="deliver_project_no_text" type="text" class="text200" id="deliver_project_no_text" onKeyUp="ToLower(this)" onBlur="capitalize(this)" value="<?php echo $_SESSION['project_no']?>"  autocomplete="off"></td>
                    <td width="55" valign="middle"><label class="label_std">Place: 
                    </label>
                    <label class="star">*</label></td>
                    <td width="214" valign="middle"><select name="deliver_project_place_select" id="deliver_project_place_select" class="select120" tabindex="4" >
                        <option value="<?php echo $_SESSION['project_place']?>" selected><?php echo $_SESSION['project_place']?></option>
                        <?php
        	for ($j = 0; $j < count($arrId3); $j++) {
    		echo "<option value=" . "\"" . $arrId3[$j] . "\"" . ">" . $arrName3[$j] . "</option>";
	}
?>
                      </select></td>
                  </tr>
               </table>  
                 </div> 
               <table width="656" border="0">
                  <tr>
                    <td width="127" valign="top"><label class="label_std">Additional info:</label></td>
                    <td width="519" colspan="3"><textarea name="additional_info_text" cols="70" rows="3" class="text_box" id="textarea" tabindex="5" ><?php echo $_SESSION['additional_info']?></textarea></td>
                  </tr>
                  <tr>
                    <td><label class="label_std">Delivery date:</label></td>
                    <td colspan="3">
                      <label>
                        <input type="radio" name="del_date_group" value="tba" id="del_date_group_0"  onClick="document.getElementById('date_div').hidden=true;" <?php if ($_SESSION['tba_deliver']=='tba') { ?> checked <?php } ?>>
                        t.b.a</label>
                      
                      <label>
                        <input type="radio" name="del_date_group" value="del_date" id="del_date_group_1" onClick="document.getElementById('date_div').hidden=false; " <?php if ($_SESSION['tba_deliver']=='del_date') { ?> checked <?php }  ?> >
                        delivery date</label>
                    <div id="date_div" hidden="true;"><?php
		$myCalendar = new tc_calendar("delivery_date", true);
		$myCalendar->setIcon("../images/iconCalendar.gif");
		$myCalendar->setDate($d2, $m2, $y2);
		$myCalendar->setPath("./");
		$myCalendar->setYearInterval(2015, 2090);
		$myCalendar->writeScript();
?></div></td>
                  </tr>
                </table>
              </div>
              
              <br>
                        
              <table  id="table_button_bar">
                <tr>
                  <td width="117"><input type="button" name="lastprev_button" class="imagebutton" value="Prev" onClick="needToConfirm = false;MM_showHideLayers('wait','','show');MM_goToURL('parent','newOrderWizbase.php?s=&amp;p=1');return document.MM_returnValue" tabindex="9" /></td>
                  <td width="115">&nbsp;</td>
                  <td width="99"><input name="p" type="hidden" id="p" value="2" />
                    <input name="s" type="hidden" id="s" value="2" />
                    </span></td>
                  <td width="125" align="right"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onClick="needToConfirm = false; cancel_confirmation(1, '../store/store_main.php?date='); " value="Cancel" tabindex="10"/></td>
                  <td width="110" align="right"><input type="submit" name="next_button" class="imagebutton" value="Next" onClick="needToConfirm = false;  MM_showHideLayers('wait','','show');" tabindex="8"/></td>
                </tr>
              </table>
 
  
</form>
</div>
<!--form validation--> 
<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var val_check = document.getElementById('val_check').value;
  var frmvalidator  = new Validator("form1");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("deliver_group","selone","- deliver or collect.");
  frmvalidator.addValidation("order_no_text","req","- order reference.");
  frmvalidator.addValidation("deliver_contact_text","req","- contact.");
  frmvalidator.addValidation("deliver_phone_text","req","- contact phone no.");
  frmvalidator.addValidation("deliver_project_no_text","req","- project/plot no.");
  frmvalidator.addValidation("deliver_project_place_select","req","- project place.");
  frmvalidator.addValidation("del_date_group","selone","- delivery date.");
   
</script>
</body>
