<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<!--jscript-->
<script language="JavaScript" src="../jscript/gen_validatorv4.js"  type="text/javascript" xml:space="preserve"></script>
<?php
if ($_SESSION['first_choice']=="capturing") {
$table_name = $_SESSION['db_prefix']."_captured_jobs";
$jobQuery = "SELECT job_no, cust_id FROM $table_name WHERE compiled = 'yes' AND cutting_bill IS NULL  AND  authorisation IS NULL ORDER BY job_no DESC";
$jobResult = execsql($jobQuery);
$jobNum = mysql_num_rows($jobResult);
	$w = 0;
	$arrId4 = array ();
	$arrName4 = array ();
	while ($w < $jobNum) {
		$cust_id = mysql_result($jobResult, $w, "cust_id");
		$table_name = $_SESSION['db_prefix']."_customer";
		$name_query = "SELECT comp_name FROM $table_name WHERE cust_id = '".$cust_id."' ";
		$name_result = mySQL_query($name_query);
		$name = mysql_result($name_result, 0, "comp_name");
		$arrId4[$w] = mysql_result($jobResult, $w, 'job_no');
		$arrName4[$w] = "J".mysql_result($jobResult, $w, 'job_no')."&nbsp;&nbsp;&nbsp;".$name;
		$w++;
	}
}

if ($_SESSION['first_choice']=="cutting") {
$table_name = $_SESSION['db_prefix']."_captured_jobs";
$jobQuery = "SELECT job_no, cust_id FROM $table_name WHERE cutting_bill = 'yes' AND supplied IS NULL ORDER BY job_no DESC";
$jobResult = execsql($jobQuery);
$jobNum = mysql_num_rows($jobResult);
	$w = 0;
	$arrId4 = array ();
	$arrName4 = array ();
	while ($w < $jobNum) {
		$cust_id = mysql_result($jobResult, $w, "cust_id");
		$table_name = $_SESSION['db_prefix']."_customer";
		$name_query = "SELECT comp_name FROM $table_name WHERE cust_id = '".$cust_id."' ";
		$name_result = mySQL_query($name_query);
		$name = mysql_result($name_result, 0, "comp_name");
		$arrId4[$w] = mysql_result($jobResult, $w, 'job_no');
		$arrName4[$w] = "J".mysql_result($jobResult, $w, 'job_no')."&nbsp;&nbsp;&nbsp;".$name;
		$w++;
	}
}

if ($_SESSION['first_choice']=="authorisation") {
$table_name = $_SESSION['db_prefix']."_captured_jobs";
$jobQuery = "SELECT job_no, cust_id FROM $table_name WHERE authorisation = 'yes' AND delivered IS NULL ORDER BY job_no DESC";
$jobResult = execsql($jobQuery);
$jobNum = mysql_num_rows($jobResult);
	$w = 0;
	$arrId4 = array ();
	$arrName4 = array ();
	while ($w < $jobNum) {
		$cust_id = mysql_result($jobResult, $w, "cust_id");
		$table_name = $_SESSION['db_prefix']."_customer";
		$name_query = "SELECT comp_name FROM $table_name WHERE cust_id = '".$cust_id."' ";
		$name_result = mySQL_query($name_query);
		$name = mysql_result($name_result, 0, "comp_name");
		$arrId4[$w] = mysql_result($jobResult, $w, 'job_no');
		$arrName4[$w] = "J".mysql_result($jobResult, $w, 'job_no')."&nbsp;&nbsp;&nbsp;".$name;
		$w++;
	}
}

if (($_SESSION['first_choice']=="job") OR ($_SESSION['first_choice']=="job_details") ) {
$table_name = $_SESSION['db_prefix']."_captured_jobs";
$jobQuery = "SELECT job_no, cust_id FROM $table_name WHERE captured='yes' ORDER BY job_no DESC";
$jobResult = execsql($jobQuery);
$jobNum = mysql_num_rows($jobResult);
	$w = 0;
	$arrId4 = array ();
	$arrName4 = array ();
	while ($w < $jobNum) {
		$cust_id = mysql_result($jobResult, $w, "cust_id");
		$table_name = $_SESSION['db_prefix']."_customer";
		$name_query = "SELECT comp_name FROM $table_name WHERE cust_id = '".$cust_id."' ";
		$name_result = mySQL_query($name_query);
		$name = mysql_result($name_result, 0, "comp_name");
		$arrId4[$w] = mysql_result($jobResult, $w, 'job_no');
		$arrName4[$w] = "J".mysql_result($jobResult, $w, 'job_no')."&nbsp;&nbsp;&nbsp;".$name;
		$w++;
	}
}

?>
</head>

<body>
<form name="form1" id="form1" method="get" action="edit_selectWizbase.php">
  <table id="tableMain" width="595">
    <tr>
      <td><table width=595 border="0" align="center" cellpadding="10" cellspacing="0" bordercolor="#0066FF" border-collapse="collapse">
          <tr>
            <td width="525" height="90" valign="top" ><table id="tableMain2" width="595">
                <!--begin of tableMain-->
                <tr>
                  <td><!--center of tableMain-->
                    
                    <table width=595 border="0" align="center" cellpadding="10" cellspacing="0" bordercolor="#0066FF" border-collapse="collapse">
                      <tr>
                        <td width="525" height="90" valign="top" ><div class="wizard_frame">
                            <label class="label_std"> Select job to edit: &nbsp;&nbsp;</label>
                            <select name="job_no_select" id="job_no_select" class="selectbox300" autofocus >
                              <option value=" " selected="selected" >&nbsp;</option>
                              <?php
    	for ($j = 0; $j < count($arrId4); $j++) {
		echo "<option value=" . "\"" . $arrId4[$j] . "\"" . ">" . $arrName4[$j] . "</option>";
		}
     ?>
                            </select>
                          </div>
                          <br />
                          <br />
                          <br /></td>
                        <!--center of tableMain--> 
                      </tr>
                      <tr>
                        <td><!--center of tableMain-->
                          
                          <table width="675" height="50" align="center" id="table_button_bar">
                            <tr>
                              <td width="117"><input type="button" name="lastprev_button" class="imagebutton" value="Prev" onclick="needToConfirm = false; MM_goToURL('parent','edit_selectWizbase.php?s=&amp;p=1'); return document.MM_returnValue" MM_showHideLayers('wait','','show');   tabindex="2"/></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" /></td>
                              <td width="125" align="right"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onclick="needToConfirm = false; cancel_confirmation(1, '../production/production_main.php');" value="Cancel" /></td>
                              <td width="110" align="right"><input type="submit" name="next_button" class="imagebutton" value="Next" onclick="needToConfirm = false; MM_showHideLayers('wait','','show');" /></td>
                            </tr>
                          </table></td>
                      </tr>
                    </table></td>
                </tr>
              </table></td>
          </tr>
        </table>
  </table>
  <!--end of tableMain-->
</form>
<!--form validation--> 
<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form1");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("job_no_select","req","Please select a job no.");
</script>

</body>
