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

$page_name = "Stores-main";
include ("../navigation/access.php");

if ($permission_num==1) {

	 include ("../navigation/store_sidebar.php");
     include ("../include/date_set.php"); 
	
	 
	$table_name = $_SESSION['db_prefix']."_cutting_supplies";	 	
	$display_query = "SELECT cutting_supply_id, date, job_no FROM $table_name WHERE date BETWEEN '".$start."' AND '".$end."'  GROUP BY job_no ";
	
		$display_result = execsql($display_query);
		$i = 0;
		$display_num = mysql_num_rows($display_result);
		
		
		if ($display_num==0) {
		  $message="No records to show"; 
		   }
		else  {
		  $message="End of list";
		  }
 
		?>
        
<!--style sheets-->
<link rel="stylesheet" type="text/css" href="../css/tooltip.css" />
<link rel="stylesheet" type="text/css" href="../css/scroll_table.css" />

<!--jscript-->
<script language="JavaScript" src="../jscript/tooltip.js"  type="text/javascript"></script>
<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}
								 ]
				} );
			} );
		</script> 


</head>

<body>

<div class="main_frame">
  <div class="page_head_frame">
    <label class="label_page_head">Timber supplied</label>
  </div>
  <br />
  <br />
  <br />
  <br />
  <div class="page_middle_frame">
  <form action="timber_supply_list.php" method="get" name="dateform" class="today" id="dateform">
    <table width="650" border="0" align="left" cellpadding="0" cellspacing="0" id="table_calendar">
      <tr>
        <td width="40"><label class="label_std">from:</label></td>
        <td width="249"><?php
		$myCalendar = new tc_calendar("date1", true);
		$myCalendar->setIcon("../images/iconCalendar.gif");
		$myCalendar->setDate($ds, $ms, $ys);
		$myCalendar->setPath("./");
		$myCalendar->setYearInterval(2014, 2090);
	 	$myCalendar->writeScript();?></td>
        <td width="23"><label class="label_std">to:</label></td>
        <td width="265"><?php
		$myCalendar = new tc_calendar("date2", true);
		$myCalendar->setIcon("../images/iconCalendar.gif");
		$myCalendar->setDate($de, $me, $ye);
		$myCalendar->setPath("./");
		$myCalendar->setYearInterval(2014, 2090);
		$myCalendar->writeScript();?>
          <input name="date" type="hidden" id="date" value="1" /></td>
        <td width="73"><label>
            <input name="button5" type="submit" class="linkbutton"  id="button5" value="Select" />
          </label></td>
      </tr>
    </table>
    &nbsp;&nbsp;&nbsp;&nbsp;
  </form>
  </div>
  <br />
  <div class="page_middle_frame">
    <table width="662" id="scroll_table" class="data_display"  >
      <thead>
        <tr>
          <th width="97">Date</th>
          <th width="32">&nbsp;</th>
          <th width="164">Job no</th>
          <th width="152" >Customer</th>
          <th width="88" >&nbsp;</th>
          <th width="101" >&nbsp;</th>
        </tr>
      </thead>
      <tbody>
        <?php
    $b9=0;
	while($i < $display_num){
		 $b0 = mysql_result($display_result, $i, "job_no");
		 $b1 = mysql_result($display_result, $i, "date");
		 
		 			$table_name = $_SESSION['db_prefix']."_captured_jobs";
					$customer_query = "SELECT cust_id FROM $table_name WHERE job_no = '".$b0."'  ";
					$customer_result = mySQL_query($customer_query);
					$cust_id = mysql_result($customer_result, 0, "cust_id");
					
					$table_name2 = $_SESSION['db_prefix']."_customer";
					$name_query = "SELECT comp_name FROM $table_name2 WHERE cust_id = '".$cust_id."'  ";
					$name_result = mySQL_query($name_query);
					$b2 = mysql_result($name_result, 0, "comp_name");
					
					$b3 = mysql_result($display_result, $i, "cutting_supply_id");
					
		  
		
		?>
        <tr >
          <td ><?php echo date("d-m-Y", strtotime($b1 ))?></td>
          <td ><?php echo $b1 ?>&nbsp;</td>
          <td align="left"><a href="timber_supply.php?job_no=<?php echo $b0 ?> " onMouseOver="ddrivetip('', 300)"; onMouseOut="hideddrivetip()"><?php echo 'J'.$b0?></a></td>
          <td align="left"><a href="../sales/customer_details.php?cust_id=<?php echo $cust_id ?>" onMouseOver="ddrivetip('', 200)"; onMouseOut="hideddrivetip()"><?php echo $b2?></a></td>
          <td align="right">&nbsp;</td>
          <td align="right">&nbsp;</td>
        </tr>
        <?php
		$i++;
		  
	}
	
	?>
      </tbody>
      <tfoot>
      </tfoot>
    </table>
    <div align="left">
      <label class="label_end">
        <?php  echo $message ?>
      </label>
    </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'); ?>
