

<?php
   if($_SESSION['p']==1) {
		    $_SESSION['name'] = $_GET['name_text'];
			$_SESSION['first_name'] = $_GET['first_name_text'];
	}
	
	$query = "SELECT last_name, first_name FROM rad_representatives WHERE  last_name = '". $_SESSION['name']."' AND first_name = '". $_SESSION['first_name']."' " ;
	$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="repWizbase.php?s=0&p=1 ";
        -->
     </script>

<?php	
       }
    else{


   include ('../include/formValidations.php')
?>


<?php
$dropDownQuery = "SELECT  name FROM 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, "name");
		$arrName[$q] = mysql_result($dropDownResult, $q, "name");
		$q++;
	}

   $table_name = "rad_list_designation";
    $position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
	$arrId1 = array ();
	$arrName1 = array ();
	$position_result = execsql($position_query);
	if ($position_result!="") {
	$position_num = mysql_num_rows($position_result);
	$b = 0;
	while ($b < $position_num) {
		$arrId1[$b] = mysql_result($position_result, $b, "item_name");
		$arrName1[$b] = mysql_result($position_result, $b, "item_name");
		$b++;
	}
	}


?>

<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='repList.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.";
  }
</script>



<form id="feedbackform" method="GET" onsubmit="mysubmit();return false" action="repWizbase.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">For which company: </label>
              &nbsp;&nbsp;&nbsp;
              <select name="companySelect" id="companySelect"  class="wizard3">
                <option value="<?php echo $_SESSION['company'] ?>"><?php echo $_SESSION['company']?></option>
                <?php
    	for ($i = 0; $i < count($arrId); $i++) {
		//echo "<option value=" . "\"" . $arrId[$i] . "\"" . ">" . $arrName[$i] . "</option>";
		//foreach($arrId as $key=>$value){
			echo "<option value=".$arrId[$i]. ">" . $arrName[$i] . "</option>";	
	    }
     ?>
              </select>
            
              <label class="star">*</label>
            </p>
              <p class="wizard"><label class="std">Designation:</label> 
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              <span class="star">
              <select name="designationText" class="wizard1"  >
                <option value="<?php echo $_SESSION['designation'] ?>" selected="selected"><?php echo $_SESSION['designation'] ?></option>
                <?php
        	for ($j = 0; $j < count($arrId1); $j++) {
    		echo "<option value=" . "\"" . $arrId1[$j] . "\"" . ">" . $arrName1[$j] . "</option>";
	}
?>
              </select>
              </span>
              <label class="star">*</label>
              </p>
              <p class="wizard"><label class="std">Cell number:</label>
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              <input type="text" name="cellText" id="cellText" class="wizard1" value ="<?php echo $_SESSION['cell'] ?>"/>
              
              <label class="star">*</label>
              </p>
              <p class="wizard"><label class="std">ID number:</label>
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              <input type="text" name="idNoText" id="idNoText"  class="wizard1" value="<?php echo $_SESSION['idNo'] ?>"/>
              </p>
              &nbsp;</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="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>

<!--form validation-->
  <script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("feedbackform");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("companySelect","req","Please select company.");
  frmvalidator.addValidation("designationText","req","Please select designation.");
  frmvalidator.addValidation("cellText","req","Please enter cell number.");
  </script>

 <?php
	}
	?>