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

if ($permission_num==1) {
	 include ("../navigation/production_sidebar.php");
	 include ("../include/date_set.php");
	$date = $_GET['date'];
	$table_name = $_SESSION['db_prefix']."_cutting_bill ";
	$bill_query = "SELECT * FROM $table_name WHERE bill_date BETWEEN '".$start."' AND '".$end."' ";
	$bill_result = execsql($bill_query);
	$bill_num = mysql_num_rows($bill_result);
?>
<!--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": [[ 5, "desc" ]],
					"aoColumns": [
								{"bSortable": false},
                             	{"bSortable": true},
								{"iDataSort": 5},
								{"bSortable": true},
								{"bSortable": true},
								{"bVisible": false}
								 ]
				} );
			} );
		</script> 
</head>

<body>
<div class="main_frame">
  <div class="page_head_frame">
    <label class="label_page_head">Cutting bills</label>
  </div>
  <br />
  <div class="page_middle_frame">
  <form action="cutting_bill_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="218"><?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="39"><label class="label_std">to:</label></td>
        <td width="279"><?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="74">
            <input name="button5" type="submit" class="linkbutton"  id="button5" value="Select" />
          </td>
      </tr>
    </table>
    &nbsp;&nbsp;&nbsp;&nbsp;
  </form>
  </div>
  <br>
  <br>
  <br>
  
  <div class="page_middle_frame">
    <table width="648" id="scroll_table" class="data_display" "  >
      <thead>
        <tr>
          <th width="19" style="border-right:hidden;">&nbsp;</th>
          <th width="78" align="left"  >Job no</th>
          <th width="66" align="left" >Date</th>
          <th width="257" align="left" >Customer</th>
          <th width="175" align="left" >&nbsp;</th>
          <th width="25" align="left" >&nbsp;</th>
        </tr>
      </thead>
      <tbody>
        <?php
$i = 0;
$amount=0;
	while ($i < $bill_num) {
		$b0 = mysql_result($bill_result, $i, "job_no");
		
			$table_name = $_SESSION['db_prefix']."_captured_jobs";
			$cust_id_query = "SELECT cust_id, project_no, project_place, project_description, designer FROM $table_name WHERE job_no = '".$b0."'  ";
			$cust_id_result = mySQL_query($cust_id_query);
			$b1 = mysql_result($cust_id_result, 0, "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);
         $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($bill_result, $i, "bill_date");
		$b3 = mysql_result($bill_result, $i, "bill_id");
		
		
		$b9 = mysql_result($cust_id_result, 0, "project_no");
		$b10 = mysql_result($cust_id_result, 0, "project_place");
		$b11 = mysql_result($cust_id_result, 0, "project_description");
		$b12 = mysql_result($cust_id_result, 0, "designer");
//		
		$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>Designer:</td><td>".$b12."</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;">J</td>
          <td align="left" valign="top" style="padding-left:0px;"><a href="cutting_bill.php?job_no=<?php echo $b0 ?>" onMouseover="ddrivetip('<?php echo $jobTT?>', 300)"; onMouseout="hideddrivetip()" target="_parent"><?php echo $b0 ?></a></td>
          <td><?php echo date("d-m-Y", strtotime($b2)) ?></td>
          <td ><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>&nbsp;</td>
          <td><?php echo $b2 ?></td>
        </tr>
        <?php
    $i++;
		
	}?>
      </tbody>
    </table>
    <br />
  </div>
</div>
</body>


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

<?php } else { 
    $_SESSION['denied_return'] = "store/store_main.php";	?>
<body onLoad="accessdenied(); return false">
</body>
<?php }
?>
