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

if ($permission_num==1) {
	include ("../navigation/store_sidebar.php");

$supply_id = $_GET['supply_id'];
$pr_option = $_GET['pr_option'];

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

<script type="text/javascript">
function MM_changeProp(objId,x,theProp,theValue) { //v9.0
  var obj = null; with (document){ if (getElementById)
  obj = getElementById(objId); }
  if (obj){
    if (theValue == true || theValue == false)
      eval("obj.style."+theProp+"="+theValue);
    else eval("obj.style."+theProp+"='"+theValue+"'");
  }
}
</script>
</head>
<?php

$table_name = $_SESSION['db_prefix']."_permissions";
$print_permission_query = "SELECT access_id  FROM  $table_name  WHERE access_id ='". $_SESSION['access_id']."' AND page_name = 'Stores-print-copy' ";
$print_permission_result = mySQL_query($print_permission_query);
$print_permission_num = mysql_num_rows($print_permission_result);
if ($print_permission_num==1) {
$print_permission = 'yes';
}
else {
	$print_permission = 'no';
}

$table_name = $_SESSION['db_prefix']."_supply_customer";
$deliver_query = "SELECT * FROM $table_name WHERE supply_id = '".$supply_id."'  ";

$deliver_result = mySQL_query($deliver_query);
$deliver_num = mysql_num_rows($deliver_result);
$a1 = mysql_result($deliver_result, 0, "job_no");
$a2 = mysql_result($deliver_result, 0, "cust_id");
$a3 = mysql_result($deliver_result, 0, "delivery_note");
$a4 = mysql_result($deliver_result, 0, "receipt_no");
$a7 = mysql_result($deliver_result, 0, "delivery_date");


$table_name = $_SESSION['db_prefix']."_supply_customer_lines";
$sundries_query = "SELECT job_no, truss_type, store_item_id, quantity FROM $table_name WHERE supply_id = '".$supply_id."' AND truss_type = 'Cash' ";
$sundries_result = mySQL_query($sundries_query);
$sundries_num = mysql_num_rows($sundries_result);


$table_name2 = $_SESSION['db_prefix']."_customer";
$customer_query = "SELECT * FROM $table_name2 WHERE cust_id ='".$a2."' ";
$customer_result = mySQL_query($customer_query);
$customer_num = mysql_num_rows($customer_result);	
$b1 = mysql_result($customer_result, 0, "account_type");
if ($b1=="corporate") { 
$b0 = mysql_result($customer_result, 0, "comp_name"); 
} 
else {
$b0 = mysql_result($customer_result, 0, "title")." ".mysql_result($customer_result, 0, "name_2")." ".mysql_result($customer_result, 0, "comp_name");
 }
$b2 = mysql_result($customer_result, 0, "bag_box");
$b3 = mysql_result($customer_result, 0, "box_no");
$b4 = mysql_result($customer_result, 0, "postal_place");
$b5 = mysql_result($customer_result, 0, "phone");
$b6 = mysql_result($customer_result, 0, "cell_1");




?>
<!--style sheets-->
<!--reference to main.css removed-->
<link rel="stylesheet" type="text/css" href="../css/tooltip.css" />

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

<body onLoad="MM_changeProp('buttons_non_active','','display','none','DIV')">


<div class="main_frame" style="height:auto; min-height:550px;">
  <table id="tableMain" > <!--begin of tableMain-->
    <tr>
      <td width="830" height="62" valign="top" ><div class="page_head_frame">
        
        <table width="809" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><label class="label_page_head">Cash supply: </label>
              &nbsp;&nbsp;&nbsp;<label class="label_page_head_2"><?php echo $a3; ?><?php if ($a1!='0') { echo "&nbsp;&nbsp;(J".$a1.")";} else { echo "&nbsp;&nbsp;(Cash)"; } ?></label></td>
            </tr>
        </table>
      </div>
        <br />

<br /></td> <!--center of tableMain-->
</tr>
<tr>
<td>
<div class="page_middle_frame">
  <table width="592" id="table_display" >
    <tr>
      <td width="139" align="left" valign="top">Supplied to:</td>
      <td width="203" align="left" valign="top"><?php echo $b0 ?></td>
      <td width="101" align="left" valign="top">Date:</td>
      <td width="129" align="left" valign="top"><?php echo date("d-m-Y", strtotime($a7 )) ?></td>
    </tr>
    <tr>
      <td align="left" valign="top"><?php if ($a1!='0') { ?>
        Supplied for job no:
        <?php } ?></td>
      <td align="left" valign="top"><?php if ($a1!='0') { echo "J".$a1; } ?></td>
      <td align="left" valign="top">Deliver note no:</td>
      <td align="left" valign="top"><?php echo $a3?></td>
    </tr>
    <tr>
      <td colspan="2" align="left" valign="top">&nbsp;</td>
      <td align="left" valign="top">Recipt no:</td>
      <td align="left" valign="top"><?php echo $a4 ?></td>
    </tr>
    <tr>
      <td colspan="4" align="left" valign="top">&nbsp;</td>
    </tr>
  </table><br />
<br />

  <table width="592" id="table_display" >
    <tr>
      <td height="26" colspan="2" align="left" valign="top">Item</td>
      <td width="104" align="left" valign="top">Quantity</td>
      <td width="100" align="left" valign="top">&nbsp;</td>
    </tr>
    <?php
				$i=0;
				$sub_tot=0;
				$a6_total=0;
				 while ($i<$sundries_num){
					 //$a0 = mysql_result($sundries_result, $i, "supply_line_id");
					 $a1 = mysql_result($sundries_result, $i, "store_item_id");
					 $table_name = $_SESSION['db_prefix']."_store_items";
						$item_query = "SELECT item_name FROM $table_name WHERE store_item_id = '".$a1."' ";
						$item_result = mySQL_query($item_query);
						$a1a = mysql_result($item_result, 0, "item_name");
					 $a2 = mysql_result($sundries_result, $i, "quantity");
			
				 ?>
    <tr>
      <td colspan="2" valign="top"><?php echo $a1a ?></td>
      <td valign="top"><?php echo $a2 ?></td>
      <td align="right" valign="top">&nbsp;</td>
    </tr>
    <?php 
			   // $a6_total=$a6_total+$a6;
				$i++;
				 }
				 ?>
    <tr>
      <td colspan="2" align="left" valign="top">&nbsp;</td>
      <td align="left" valign="top">&nbsp;</td>
      <td align="left" valign="top">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" align="left" valign="top">&nbsp;</td>
      <td align="left" valign="top">&nbsp;</td>
      <td align="left" valign="top">&nbsp;</td>
    </tr>
  </table>
  <br>
  </table>
  <!--end of tableMain-->
  <?php 
if ($pr_option=='all') { ?>
  <div align="right">
    <div id="buttons_active" style="display:block;"> <a href="customer_supplied_print_cod.php?supply_id=<?php echo $supply_id?>" target="_blank">
      <input name="del_1_button" type="button" class="imagebutton" id="del_1_button" onClick="MM_changeProp('buttons_active','','display','none','DIV');MM_changeProp('buttons_non_active','','display','block','DIV')"  value="Print for delivery" >
      </a><a href="customer_supplied_print_co.php?supply_id=<?php echo $supply_id?>" target="_blank">
        <input name="col_1_button" type="button" class="imagebutton" id="col_1_button" onClick="MM_changeProp('buttons_active','','display','none','DIV');MM_changeProp('buttons_non_active','','display','block','DIV')"  value="Print for collection" >
      </a><a href="customer_supplied_print_cod.php?supply_id=<?php echo $supply_id?>" target="_blank"></a></div>
    <div id="buttons_non_active" style="display:block;">
      <input name="del_2_button"  id="del_2_button" type="button" class="dis_imagebutton"  value="Print for delivery" >
      <input name="del_2_button"  id="col_2_button" type="button" class="dis_imagebutton"  value="Print for collection" >
    </div>
  </div>
  <div align="right"><a href="customer_supplied_print_co.php?supply_id=<?php echo $supply_id?>" target="_blank"></a></div>
  <?php }
else { ?>
  <div align="right">
    <?php if ($print_permission=='yes') {?>
    <a href="customer_supplied_print_copy.php?supply_id=<?php echo $supply_id ?>" target="_blank">
      <input name="button" type="button" class="imagebutton" id="button" value="Print copy" >
      <?php } else { ?>
      <input name="button" type="button" class="dis_imagebutton" id="button" value="Print copy" >
      <?php } ?>
    </a></div>
  <?php } ?>
  <br />
<br />

  <div class="wizard_frame"></div>
      </td>
           
    </tr>
  </table>
</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td height="220">&nbsp;</td>
</tr>
</table> 
 <!--end of tableMain-->
  
</div>

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

</body>
<?php } else {
$_SESSION['denied_return'] = "sales/sales_main.php";	
include ("../navigation/sales_sidebar.php");?>
	<body onLoad="accessdenied(); return false">
	</body>
<?php }
?>
</html>