<!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"); 
	 
$display=$_GET['display'];

$table_name = $_SESSION['db_prefix']."_supply_customer";
$display_query = "SELECT supply_id, delivery_date, job_no, cust_id, delivery_note, delivery_address, delivered_by, vehicle_reg, delivery_date, delivery_time, type  FROM $table_name WHERE  delivery_date BETWEEN '".$start."' AND '".$end."' AND type='job' ";

	
$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": [[ 0, "desc" ]],
					"aoColumns": [
								{"bSortable": true},
								{"iDataSort": 2},
								{"bVisible": false},
                             	{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								
								 ]
				} );
			} );
		</script> 

</head>

<body>

<div class="main_frame">
  <div class="page_head_frame">
    <label class="label_page_head">Job deliveries</label>
  </div>
  <br />
  <br />
  <br />
  <br />
  <div class="page_middle_frame">
  <form action="customer_supplied_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="41"><label class="label_std">from:</label></td>
        <td width="239"><?php
		$myCalendar = new tc_calendar("date1", true);
		$myCalendar->setIcon("../images/iconCalendar.gif");
		$myCalendar->setDate($ds, $ms, $ys);
		$myCalendar->setPath("./");
		$myCalendar->setYearInterval(2000, 2030);
	 	$myCalendar->writeScript();?></td>
        <td width="42"><label class="label_std">to:</label></td>
        <td width="291"><?php
		$myCalendar = new tc_calendar("date2", true);
		$myCalendar->setIcon("../images/iconCalendar.gif");
		$myCalendar->setDate($de, $me, $ye);
		$myCalendar->setPath("./");
		$myCalendar->setYearInterval(2000, 2030);
		$myCalendar->writeScript();?>
          <input name="date" type="hidden" id="date" value="1" />
          <input name="cat" type="hidden" id="cat" value="" />
          <input name="display" type="hidden" id="display" value="<?php echo $display ?>" />
          </td>
        <td width="90"><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="115">Delivery note</th>
          <th width="94"><span class="sortable-date-dmy">Date</span></th>
          <th width="23">&nbsp;</th>
          <th width="110">Job no</th>
          <th width="234">Customer</th>
          <th width="58" >&nbsp;</th>
        </tr>
      </thead>
      <tbody>
        <?php
    $b9=0;
	while($i < $display_num){
		
		 $b0 = mysql_result($display_result, $i, "delivery_note");
		 $b1 = mysql_result($display_result, $i, "delivery_date");
		 $b3 = mysql_result($display_result, $i, "job_no");
		 $b4 = mysql_result($display_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 = '".$b4."' ";
		 	$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");
		 $b5 = mysql_result($display_result, $i, "supply_id");
		 $b6 = mysql_result($display_result, $i, "type");
		 
		 	if ($b3!='0') {
		 	$table_name6 = $_SESSION['db_prefix']."_captured_jobs";
			$job_query = "SELECT project_no, project_place, project_description,designer FROM $table_name6 WHERE job_no = '".$b3."' ";
			$job_result = mySQL_query($job_query);
		 	$b9 = mysql_result($job_result, 0, "project_no");
			$b10 = mysql_result($job_result, 0, "project_place");
			$b11 = mysql_result($job_result, 0, "project_description");
			$b12 = mysql_result($job_result, 0, "designer");
			}
						
			$c1 = mysql_result($display_result, $i, "delivery_address");
			$c2 = mysql_result($display_result, $i, "delivered_by");
			$c3 = mysql_result($display_result, $i, "vehicle_reg");
			$c4 = mysql_result($display_result, $i, "delivery_date");
			$c5 = mysql_result($display_result, $i, "delivery_time");
		
		$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>";
		
	if ($b3!='0') {	
		$jobTT ="<table id=table_tool_tip width=300 ><tr><td  width=100>Job no:</td><td width=175>".$b3."</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>";
	}
	else {
	    $jobTT ="Cash sale";
	}
		
		$deliveryTT ="<table id=table_tool_tip width=300 ><tr><td  width=100>Delivery note no:</td><td width=175>".$b0."</td></tr><tr><td valign=top>Delivery address:</td><td>".$c1."</td></tr><tr><td>delivered by::</td><td>".$c2."</td></tr><tr><td>Vehicle reg.:</td><td>".$c3."</td></tr><tr><td>Delivery date::</td><td>".$c4." at ".$c5." hrs</td></tr></table><br><b>Click for details</b>";
		
		?>
        <tr >
          <td ><a href="customer_supplied.php?del_note=<?php echo $b0?>&supply_id=<?php echo $b5?>&pr_option=copy" onMouseover="ddrivetip('<?php echo $deliveryTT ?>', 250)"; onMouseout="hideddrivetip()"><?php echo $b0 ?></a></td>
          <td align="left"><?php echo date("d-m-Y", strtotime($b1 ))?></td>
          <td align="left"><?php echo $b1 ?>&nbsp;</td>
          <td align="left"><a href="../production/captured_job.php?job_no=<?php echo $b3?> " onMouseOver="ddrivetip('<?php echo $jobTT?>', 250)"; onMouseOut="hideddrivetip()"><?php if ($b3!='0') { echo "J".$b3; } else { echo 'Cash sale'; }?></a></td>
          <td align="left"><a href="../sales/customer_details.php?cust_id=<?php echo $b4?> " onMouseOver="ddrivetip('<?php echo $customerTT?>', 250)"; onMouseOut="hideddrivetip()"><?php echo $a2a?></a></td>
          <td align="left"><?php echo $b6 ?>&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'); ?>
