<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<link href="../css/main.css" rel="stylesheet" type="text/css" />
<?php
include('../include/session.php');
	$table_name = $_SESSION['db_prefix']."_mworks_jobs";
	$job_query = "SELECT * FROM $table_name WHERE captured='yes' AND completed IS NULL ORDER BY job_card_no DESC";
	$job_result = execsql($job_query);
	$job_num = mysql_num_rows($job_result);
?>

<!--style sheets-->
<link rel="stylesheet" type="text/css" href="../css/tooltip.css" />

<!--jscript-->
<script type="text/javascript" src="../jscript/tablesort.js"></script>
<script language="JavaScript" src="../jscript/tooltip.js"  type="text/javascript"></script> 
</head>

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

if ($permission_num==1) {
	include ("../navigation/production_sidebar.php");
?>

<div class="main_frame" style="height:auto;">
<div class="page_head_frame">
 <table width="800" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><label class="label_page_head">Production M-works 
              </label></td>
            <td width="171" align="right">&nbsp;</td>
          </tr>
        </table>
      </div>
       
  <div class="scroll_frame_long" style="height:450px; width:700px;">
  <div align="right">
    <label class="label_end"><img src="../images/round_green.png" width="8" height="8" />: completed&nbsp;&nbsp;<img src="../images/round_orange.png" width="8" height="8" />: in progress&nbsp;&nbsp;<img src="../images/round_red.png" width="8" height="8" />:pending&nbsp;&nbsp;<img src="../images/M_only.png" width="8" height="8">: M-works only</label>
  </div>
  <table width="680" id="table_list" class="sortable-onload-1r rowstyle-alt no-arrow "  >
    <thead>
      <tr>
        <th width="29" style="border-right:hidden;">&nbsp;</th>
        <th width="35" align="left"  class="sortable-numeric">Job card</th>
        <th width="65" align="left" class="sortable-date-dmy">Delivery Date</th>
        <th width="139" align="left" class="sortable-text">Customer</th>
        <th width="66" align="center" >Compile<br />
          order</th>
        <th width="55" align="center" >Store<br />
          supply</th>
        <th width="75" align="center" >Production</th>
        <th width="52" align="center" >Deliver</th>
        <th width="54" align="center" >Invoice</th>
        <th width="66" align="center">Complete</th>
      </tr>
    </thead>
    <tbody>
      <?php
$i = 0;
$amount=0;
	while ($i < $job_num) {
		$b0 = mysql_result($job_result, $i, "job_card_no");
		$b1 = mysql_result($job_result, $i, "cust_id");
		 $table_name3 = $_SESSION['db_prefix']."_customer";
         $customer_query = "SELECT comp_name, status, bag_box, box_no, postal_place, phone, contact_1 FROM $table_name3 WHERE cust_id = '".$b1."' ";
		 $customer_result = mySQL_query($customer_query);
		 $customer_num = mysql_num_rows($customer_result);
		 if ($customer_num!=0) {
         $a2a = mysql_result($customer_result, 0, "comp_name");
		 $a2b = mysql_result($customer_result, 0, "bag_box");
		 $a2c = mysql_result($customer_result, 0, "box_no");
		 $a2d = mysql_result($customer_result, 0, "postal_place");
		 $a2e = mysql_result($customer_result, 0, "phone");
		 $a2f = mysql_result($customer_result, 0, "contact_1");
		 $a3 = mysql_result($customer_result, 0, "status");
		 }
		$b2 = mysql_result($job_result, $i, "del_date");
		if ($b2!='') {$b2a=date("d-m-Y", strtotime($b2));
		}
		else {
			$b2a='';
		}
		
		$table_name = $_SESSION['db_prefix']."_compiled_jobs";
		$project_query = "SELECT project_no, project_place, project_description, mworks FROM $table_name WHERE job_card_no = '".$b0."'  ";
				
		$project_result = mySQL_query($project_query);
		$b9 = mysql_result($project_result, 0, "project_no");
		$b10 = mysql_result($project_result, 0, "project_place");
		$b11 = mysql_result($project_result, 0, "project_description");
		$mworks = mysql_result($project_result, 0, "mworks");
		
		$b13 = mysql_result($job_result, $i, "value");
		$b20 = mysql_result($job_result, $i, "compiled");
		$b21 = mysql_result($job_result, $i, "supplied");
		$b22 = mysql_result($job_result, $i, "production");
		$b23 = mysql_result($job_result, $i, "invoiced");
		$b24 = mysql_result($job_result, $i, "completed");
		$b25 = mysql_result($job_result, $i, "delivered");
		
				
		$jobTT ="<table id=table_tool_tip width=300 ><tr><td  width=100>Job no:</td><td width=175>".$b0."</td></tr><tr><td valign=top>Project no /place:</td><td>".$b9."&nbsp;".$b10."</td></tr><tr><td>Project description:</td><td>".$b11."</td></tr><tr><td>Job value:</td><td>P ".number_format($b13, 2, '.', ',')."</td></tr><tr><td>Delivery date:</td><td>".$b2a."</td></tr></table><br><b>Click for details</b>";

		$customerTT ="<table id=table_tool_tip width=250 ><tr><td  width=75>Company:</td><td width=175>".$a2a."</td></tr><tr><td>Address:</td><td>".$a2b."&nbsp;".$a2c."<br>".$a2d."</td></tr><tr><td>Phone:</td><td>".$a2e."</td></tr><tr><td>Contact:</td><td>".$a2f."</td></tr></table><br><b>Click for details</b>";
?>
      <tr class="alt">
        <td align="right" style="border-right:hidden; padding-right:0px;"><?php if ($mworks=='only') {?>
          <img src="../images/M_only.png" width="8" height="8">          <?php } ?></td>
        <td align="left" style="padding-left:0px;"><a href="m_job_card.php?job_card_no=<?php echo $b0?>" onmouseover="ddrivetip('<?php echo $jobTT?>', 300)"; onmouseout="hideddrivetip()" target="_parent"><?php echo $b0?></a></td>
        <td><?php  if ($b2!='') {echo date("d-m-Y", strtotime($b2));}?></td>
        <td align="left" ><a href="../sales/customer_details.php?cust_id=<?php echo $b1?>" onmouseover="ddrivetip('<?php echo $customerTT?>', 250)"; onmouseout="hideddrivetip()"><?php echo $a2a?></a></td>
        
        <td align="center">
          <?php if ($b20=='yes') {?>
          <a href="m_job_card.php?job_card_no=<?php echo $b0?>" onmouseover="ddrivetip('Click to view order', 150)"; onmouseout="hideddrivetip()">
          <img src="../images/round_green.png" width="12" height="12"></a>
          <?php }
		else{ ?>
          <a href="m_compileJobWiz0.php?job_card_no=<?php echo $b0?>" onmouseover="ddrivetip('Click to compile order', 150)"; onmouseout="hideddrivetip()"><img src="../images/round_red.png" width="12" height="12"></a>
          <?php } ?>
        </td>
        <td align="center"><?php 
		if ($b20=='yes') {
		if ($b21=='yes') {?>
          <a href="m_job_card.php?job_card_no=<?php echo $b0?>" onmouseover="ddrivetip('Job card supplied', 100)"; onmouseout="hideddrivetip()"><img src="../images/round_green.png" width="12" height="12"></a>
          <?php }
		else { 
		if ($b21=='part') {?>
          <a href="../store/m_supplyJobWiz0.php?job_card_no=<?php echo $b0?>" onmouseover="ddrivetip('Partly supplied, click to supply job card balance', 140)"; onmouseout="hideddrivetip()"><img src="../images/round_orange.png" width="12" height="12"></a>
          <?php }
		else { ?>
          <a href="../store/m_supplyJobWiz0.php?job_card_no=<?php echo $b0?>" onmouseover="ddrivetip('Click to supply order', 110)"; onmouseout="hideddrivetip()"><img src="../images/round_red.png" width="12" height="12"></a>
          <?php }
		}
		}
		?></td>
        <td align="center">
          <?php 
		  if ($b21!='') {
		  if ($b22=='yes') {?>
          <a href="m_job_card.php?job_card_no=<?php echo $b0?>" onmouseover="ddrivetip('M-works job produced', 150)"; onmouseout="hideddrivetip()"><img src="../images/round_green.png" alt="" width="12" height="12"></a>
          <?php }?>
          <?php if ($b22=='part') {?> 
          <a href="producedJobWiz0.php?job_card_no=<?php echo $b0?>" onmouseover="ddrivetip('M-works job partly produced. Click to enter new production', 150)"; onmouseout="hideddrivetip()"><img src="../images/round_orange.png" alt="" width="12" height="12"></a>
          <?php } ?>
		  <?php if ($b22=='') {?> 
          <a href="producedJobWiz0.php?job_card_no=<?php echo $b0?>" onmouseover="ddrivetip('Click to produce', 150)"; onmouseout="hideddrivetip()"><img src="../images/round_red.png" alt="" width="12" height="12"></a>
          <?php } ?>
		  <?php }?>
        </td>
        <td align="center"><?php 
		  if ($b22!='') {
		  
		  if ($b25=='yes') {?>
          <a href="m_job_card.php?job_card_no=<?php echo $b0?>" onmouseover="ddrivetip('M-works job delivered', 150)"; onmouseout="hideddrivetip()"><img src="../images/round_green.png" alt="" width="12" height="12"></a>
          <?php }?>
          <?php if ($b25=='part') {?>
          <a href="deliverJobWiz0.php?job_card_no=<?php echo $b0?>" onmouseover="ddrivetip('M-works job partly delivered. Click to enter new production', 150)"; onmouseout="hideddrivetip()"><img src="../images/round_orange.png" alt="" width="12" height="12"></a>
          <?php } ?>
          <?php if ($b25=='') {?>
          <a href="deliverJobWiz0.php?job_card_no=<?php echo $b0?>" onmouseover="ddrivetip('Click to deliver', 150)"; onmouseout="hideddrivetip()"><img src="../images/round_red.png" alt="" width="12" height="12"></a>
          <?php } ?>
          <?php }
		  ?></td>
        <td align="center"><?php 
		
		  if ($b25!='') {
		  if ($b23=='yes') {?>
          <a href="../orders/invoice_report_list.php?date=" onmouseover="ddrivetip('M-works job invoiced', 150)"; onmouseout="hideddrivetip()"><img src="../images/round_green.png" alt="" width="12" height="12"></a>
          <?php }
		else{ ?>
          <a href="m_invoiceJobWiz0.php?job_card_no=<?php echo $b0?>" onmouseover="ddrivetip('Click to invoice M-works job', 150)"; onmouseout="hideddrivetip()"><img src="../images/round_red.png" alt="" width="12" height="12"></a>
          <?php } 
		  }
		
		
		?></td>
        <td align="center">
		<?php
		
		  if ($b23=='yes') {
		  if ($b24=='yes') {?>
          <a href="producedJobWiz0.php?job_card_no=<?php echo $b0?>" onmouseover="ddrivetip('M-works job completed', 150)"; onmouseout="hideddrivetip()"><img src="../images/round_green.png" alt="" width="12" height="12"></a>
          <?php }
		else{ ?>
          <a href="m_completeJobWiz0.php?job_card_no=<?php echo $b0?>" onmouseover="ddrivetip('Click to complete job', 150)"; onmouseout="hideddrivetip()"><img src="../images/round_red.png" alt="" width="12" height="12"></a>
          <?php }
		  }
		?></td>
      </tr>
      <?php
    $i++;
		
	}?>
    </tbody>
  </table>
  </div>
  
</div>
</body>



<?php } else {
$_SESSION['denied_return'] = $_SESSION['location'];	
include ("../navigation/production_sidebar.php");?>
	<body onload="accessdenied(); return false">
	</body>
<?php }
?>

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