<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php 
include('../include/session.php');


include('../include/period_select_date.php');	 
 
$table_name = $_SESSION['db_prefix']."_mworks_job_components";	 	
$display_query = "SELECT * FROM $table_name WHERE date_produced BETWEEN '".$start."' AND '".$end."' ";
echo '<br>*****'.$display_query;
$display_result = execsql($display_query);
$display_num = mysql_num_rows($display_result); 
?> 

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

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


</head>


<body>
<?php
include ("../navigation/header.php");
include ("../navigation/store_sidebar.php");
$page_name = "Stores-main";
include ("../navigation/access.php");
if ($permission_num==1) {
?>
<div class="main_frame">
<div class="page_head_frame">
  <label class="label_page_head">M-works produced items</label></div>

<div class="page_middle_frame">

<?php
$page='mworks_component_list.php';
$reference_name='';
$reference='';
include('../include/period_select_block.php');
?>
<div class="page_inside_frame">
<script type="text/javascript" language="javascript" src="../jscript/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8">
			$(document).ready(function() {
				$('#scroll_table').dataTable( {
					"sScrollY": "500px",
					"bPaginate": false,
					"bScrollCollapse": true,
					"aaSorting": [[ 1, "desc" ]],
					"aoColumns": [
								{"iDataSort": 1},
								{"bVisible": false},
                              	{"bSortable": true},
                             	{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
                              	{"bSortable": true},
                             	{"bSortable": true},
								{"bSortable": true}					
								 ]
				} );
			} );
		</script>    	
<table width="661" id="scroll_table" class="data_display" >
	<thead>
		<tr>
		  <th width="44" align="center">Date</th>
		  <th width="25" align="center">&nbsp;</th>
		  <th width="191" align="center">Item name</th>
		  <th width="45" align="center">Job card</th>
          <th width="61" align="center" >Quantity<br>
            to produce</th>
		  <th width="63" align="center" >Date <br>
		    produced</th>
		  <th width="65" align="center" >Quantity <br>
		    produced</th>
		  <th width="62" align="center" >Date<br>
		    supplied</th>
		  <th width="65" align="center" >Quantity <br>
		    supplied</th>
		  </tr>
	</thead>
	<tbody>
  <?php
    $b9=0;
	$b4tot='0.00';
	$b5tot='0.00';
	$i = 0;
	while($i < $display_num){
		 $b0 = mysql_result($display_result, $i, "job_card_no");
		 	$table_name = $_SESSION['db_prefix']."_mworks_jobs";
			$date_query = "SELECT entry_date FROM $table_name WHERE job_card_no = '".$b0."' ";
			$date_result = mySQL_query($date_query);
			$b1 = mysql_result($date_result, 0, "entry_date");
		 
			
		$b3 = mysql_result($display_result, $i, "component");
		$b4 = mysql_result($display_result, $i, "quantity"); 
		$b5 = mysql_result($display_result, $i, "job_card_no"); 
		$b6 = mysql_result($display_result, $i, "date_produced"); 
		$b7 = mysql_result($display_result, $i, "produced_quantity"); 
			
			
		//$b8 = mysql_result($displayResult, $i, "reference");
		
				
		 //$itemTT =
//		   "<b>Items on this purchase order:</b><br><table id=table_tool_tip width=300 border=1 ><tr><td>Item</td><td>Quantity</td><td>Price</td></tr>".$line_text."</table><br><b>Click for details</b>";
		
	   
		//$supplierTT =
//		   "<table id=table_tool_tip width=250 ><tr><td  width=75>Name:</td><td width=175>".$b2a."</td></tr><tr><td>Address:</td><td>".$b2b."</td></tr><tr><td></td><td>".$b2c."</td></tr><tr><td>Contact:</td><td>".$b2e."</td></tr><tr><td>Phone:</td><td>".$b2d."</td></tr><tr><td>Cell:</td><td>".$b2f."</td></tr></table><br><b>Click for details</b>";   
//		
		?>
		<tr >
		  <td ><?php echo date("d-m-Y", strtotime($b1 ))?></td>
		  <td ><?php echo $b1 ?>&nbsp;</td>
		  <td align="left"><a href="purchase_order.php?purchase_id=<?php echo $b0?>&message=0" onMouseOver="ddrivetip('', 300)"; onMouseOut="hideddrivetip()"><?php echo $b3?></a></td>
		  <td align="center"><?php echo $b5 ?></td>
			<td align="center"><?php echo $b4 ?></td>
			<td align="center"><?php if ($b6!='') {echo date("d-m-Y", strtotime($b6));}?></td>
			<td align="center"><?php echo $b7 ?></td>
			<td align="center">&nbsp;</td>
			<td align="center">&nbsp;</td>
	      </tr>
		     
		<?php
		$i++; 
	}
	?>
    </tbody>
    <tfoot>
    <tr >
		  <td >&nbsp;</td>
		  <td >&nbsp;</td>
		  <td align="left">&nbsp;</td>
		  <td align="left">&nbsp;</td>
		  <td align="right">&nbsp;</td>
		  <td align="right">&nbsp;</td>
		  <td align="right">&nbsp;</td>
		  <td align="right">&nbsp;</td>
		  <td align="right">&nbsp;</td>
		  </tr>
        </tfoot>
	
</table>
		
</div>	
</div>    
</div>
</body>
<?php } else { 
    $_SESSION['denied_return'] = "store/store_main.php";	?>
<body onLoad="accessdenied(); return false">
</body>
<?php }
?>
<?php include ('../navigation/side_bar.php'); ?>