<?php 
   include ('../include/formValidations.php');
   
   require_once ('classes/tc_calendar.php');
   $start = strtotime($_SESSION['PurchaseDate']);
$d = date("d", $start );
$m = date("m", $start );
$y = date("Y", $start );
   
   $repQuery = "SELECT repId, first_name, last_name FROM nam_rad_representatives  ORDER BY last_name ASC";
	$repResult = execsql($repQuery);
	$repNum = mysql_num_rows($repResult);
	$r = 0;
	$arr2Id = array ();
	$arr2Name = array ();
	while ($r < $repNum) {
		$arr2Id[$r] = mysql_result($repResult, $r, "repId");
		$arr2Name[$r] = mysql_result($repResult, $r, "first_name")." ".mysql_result($repResult, $r, "last_name");
		$r++;
	}
	
    $dropDownQuery = "SELECT account_no, name FROM nam_rad_tocotex  ORDER BY name ASC";
	$dropDownResult = execsql($dropDownQuery);
	$num = mysql_num_rows($dropDownResult);
	$q = 0;
	$arrId = array ();
	$arrName = array ();
	while ($q < $num) {
		$arrId[$q] = mysql_result($dropDownResult, $q, "account_no");
		$arrName[$q] = mysql_result($dropDownResult, $q, "name");
		$q++;
	}	
   
?>
<script type="text/javascript" src="../css/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="../css/wizard.css" />
<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='vehicleList.php'
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.";
  }
function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}
</script>
<form id="feedbackform" method="get"  >
  <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="left">Tocotex Company: </label>&nbsp;&nbsp;
          <select name="companySelect" id="companySelect"  class="wizard3">
            <option value="<?php echo $_SESSION['CompanyNo'] ?>" selected="selected"><?php echo $_SESSION['CompanyName']?></option>
            <?php
    	for ($i = 0; $i < count($arrId); $i++) 
		  {
			echo "<option value=".$arrId[$i]. ">" . $arrName[$i] . "</option>";	
	    }
     ?>
          </select>
      
          <label class="star">*</label>
      </p>
        <p class="wizard">
          <label class="left">Usual driver:&nbsp;&nbsp;&nbsp;</label>&nbsp;
          <select name="driverSelect" id="driverSelect"  class="wizard3">
            <option value="<?php echo $_SESSION['DriverNo'] ?>"><?php echo $_SESSION['DriverName']?></option>
            <?php
    	for ($i = 0; $i < count($arr2Id); $i++) {
			echo "<option value=".$arr2Id[$i]. ">" . $arr2Name[$i] . "</option>";	
	    }
     ?>
          </select>
        
          <label class="star">*</label>
        </p>
        <p class="wizard">
          <label class="std">Date of purchase:</label>
 &nbsp;&nbsp;&nbsp;
 <?php

		$myCalendar = new tc_calendar("PurchaseDate", true);
		$myCalendar->setIcon("../img/iconCalendar.gif");
		$myCalendar->setDate($d, $m, $y);
		$myCalendar->setPath("./");
		$myCalendar->setYearInterval(1995, 2020);
		//$myCalendar->dateAllow('2009-02-20', "", false);
		$myCalendar->writeScript();
?>
        </p>
        <p class="wizard">
          <label class="std">License expiry: (end of)&nbsp;&nbsp;&nbsp;&nbsp;</label>
          <select name="licenseSelect" id="licenseSelect" class="wizard2">
            <option value="January">January</option>
            <option value="February">February</option>
            <option value="March">March</option>
            <option value="April">April</option>
            <option value="May">May</option>
            <option value="June">June</option>
            <option value="July">July</option>
            <option value="August">August</option>
            <option value="September">September</option>
            <option value="october">October</option>
            <option value="November">November</option>
            <option value="December">December</option>
            <option value="<?php echo $_SESSION['License']?>" selected="selected"><?php echo $_SESSION['License']?></option>
          </select>
          &nbsp;&nbsp;&nbsp;&nbsp;</label>
        </p>
        <p class="wizard">
          <label class="std">notes:<br />
          &nbsp;&nbsp;&nbsp;<textarea name="notesText" id="notesText" cols="45" rows="3" class="wizard1"><?php echo $_SESSION['Notes'] ?></textarea></label>
        </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">&nbsp;</td>
            <td width="125"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onclick="needToConfirm = false; confirmRefresh();" 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("companySelect","req","Please select owner company.");
  frmvalidator.addValidation("driverSelect","req","Please select driver.");
  
</script>
