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

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

if ($permission_num==1) {

	 include ("../navigation/sales_sidebar.php");
	 include ("../include/date_set.php");
$date = $_GET['date'];
	
	

	$table_name = $_SESSION['db_prefix']."_captured_cash_sale";
	$job_query = "SELECT * FROM $table_name  WHERE accepted = 'yes' AND authorisation = 'yes' AND (delivered IS  NULL OR delivered = 'no') ";
	$job_result = execsql($job_query);
	$job_num = mysql_num_rows($job_result);

if( $job_num==0) {
	   $message='No sales to deliver.';
	   }
	   else {
		   $message='End of list';
	   }
	
	
	
	?> 
    

<!--style sheets-->
<!--reference to main.css removed-->
<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> 
<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": [
								{"bSortable": true},
                             	{"bSortable": true},
								{"iDataSort": 6},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bVisible": false}
								 ]
				} );
			} );
		</script>

</head>

<body>
<div class="main_frame">
<div class="page_head_frame">
  <label class="label_page_head">Deliver cash sale</label></div><br />
<br /><br />
<br>
<br>


<div class="page_middle_frame">
<label class="label_std">Click on job no to deliver.</label>
<table width="710"  id="scroll_table" class="data_display">
    <thead>
      <tr>
        <th width="15" style="border-right:hidden;">&nbsp;</th>
        <th width="75" align="left"  class="sortable-numeric">Job no</th>
        <th width="59" align="left" class="sortable-date-dmy">Date</th>
        <th width="206" align="left" class="sortable-text">Customer</th>
        <th width="185" align="left" >Value</th>
        <th width="185" align="left" >Sales rep</th>
        <th width="142" align="left">&nbsp;</th>
      </tr>
    </thead>
    <tbody>
    
    <?php
$i = 0;
$amount=0;
	while ($i < $job_num) {
		$b0 = mysql_result($job_result, $i, "job_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);
         $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, "date");
		
		
		$b9 = mysql_result($job_result, $i, "project_no");
		$b10 = mysql_result($job_result, $i, "project_place");
		$b11 = mysql_result($job_result, $i, "project_description");
		$b12 = mysql_result($job_result, $i, "value");
		$b13 = mysql_result($job_result, $i, "sales_rep");
		
		$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>Value:</td><td>".$b12."</td></tr><tr><td>Sales rep:</td><td>".$b13."</td></tr></table><br><b>Click to deliver</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" valign="middle" style="border-right:hidden; padding-right:0px;">J</td>
        <td align="left" valign="middle" style="padding-left:0px;"><a href="../store/deliver_cash_saleWiz0.php?job_no=<?php echo $b0 ?>" onMouseover="ddrivetip('<?php echo $jobTT ?>', 300)"; onMouseout="hideddrivetip()" target="_parent"><?php echo $b0 ?></a></td>
        <td valign="middle"> <?php echo date("d-m-Y", strtotime($b2)) ?></td>
       <td valign="middle" ><a href="customer_details.php?cust_id=<?php echo $b1 ?>" onMouseOver="ddrivetip('<?php echo $customerTT?>', 250)"; onMouseOut="hideddrivetip()"><?php echo $a2a ?></a></td>
        <td valign="middle"><?php echo number_format($b12, 2, '.', ',') ?></td>
        <td valign="middle"><?php echo $b13 ?></td>
        <td valign="middle"><?php echo $b2 ?></td>
       
      </tr> 

    <?php
    $i++;
		
	}?>
	</tbody>
  </table><br>
  <br />
</div>
</div>
<?php include ('../navigation/side_bar.php'); ?>
</body>

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


