<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<?php
include ("../navigation/header.php");
$page_name = "Production-main";
include ("../navigation/access.php");
?>

<link href="../css/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../jscript/jquery.1.4.2.js"></script>
</head>
<?php
if ($permission_num==1) {
	include ("../navigation/production_sidebar.php");

$page = $_GET['page'];
	
if ($page=='captured_quote') {
$reference='captured_edit.php?save_message=0&';	
$page_name='Captured Quote';
$page_heading='Edit captured quote';
$table_name = $_SESSION['db_prefix']."_captured_jobs";
$jobQuery = "SELECT job_no, cust_id FROM $table_name WHERE compiled = '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++;
	}
}

if ($page=='cutting_bill') {
$reference='cutting_bill_edit.php?';
$page_name='Cutting Bill';
$page_heading='Edit cutting bill';
$table_name = $_SESSION['db_prefix']."_captured_jobs";
$jobQuery = "SELECT job_no, cust_id FROM $table_name WHERE cutting_bill = '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++;
	}
}

if ($page=='authorisation') {
$reference='authorisation_edit.php?';
$page_name='Authorisation';
$page_heading='Edit authorisation';
$table_name = $_SESSION['db_prefix']."_captured_jobs";
$jobQuery = "SELECT job_no, cust_id FROM $table_name WHERE authorisation = '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++;
	}
}


if (($page=='details')) {
$reference='job_details_edit.php?';
$page_name='details';
$page_heading='Edit 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++;
	}
}

if (($page=='completion')) {
$reference='job_status_edit.php?';
$page_name='completion';
$page_heading='Set job completion';
$table_name = $_SESSION['db_prefix']."_captured_jobs";
$jobQuery = "SELECT job_no, cust_id FROM $table_name WHERE captured = 'yes' AND delivered IS NULL OR delivered = 'no' ORDER BY job_no DESC";
//$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++;
	}
}

?>
<body>

<div class="main_frame">
<table width="630" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="52" colspan="4" align="left" valign="top"><div class="page_head_frame">
        <table width="630" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="385"><label class="label_page_head">Select job </label></td>
            <td align="right">&nbsp;</td>
          </tr>
        </table>
      </div>
       <br />
<br /><br />
<br />
<br />
<br />

<div class="page_middle_frame"><br />
  <label class="label_std" style="font-size:16px;"><?php echo $page_heading; ?></label>
  <br />
  <br />
  <form action="" method="get">
  <div class="wizard_frame">
    <?php if($page_name=='completion') { echo 'Select job to set complete:'; } else { echo 'Select job to edit:'; } ?>&nbsp;
    <select name="job_no_select" autofocus="autofocus" class="selectbox300" id="job_no_select" onchange="window.location.href= this.form.job_no_select.options[this.form.job_no_select.selectedIndex].value; "> 
      <option value=" " selected="selected" >&nbsp;</option>
      <?php
    	for ($j = 0; $j < count($arrId4); $j++) {
			echo "<option value=".$reference."job_no=".$arrId4[$j]."&screen=0&edit=0&sub_category=>".$arrName4[$j]."</option>";	
		}
     ?>
    </select>
  </div>
  </form>
  <br />
  <br />
<br />
<br />
<br />

</div>
    </td>
    </tr>
    </table>
</div>

<?php include ('../navigation/side_bar.php'); ?>


<?php } else {
    $_SESSION['denied_return'] = "production/production_main.php";	
    include ("../navigation/production_sidebar.php");?>
    <?php include ('../navigation/side_bar.php'); ?>
	<body onLoad="accessdenied(); return false">	
	</body>
<?php }
?>
</html>
</body>