<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>


<!--reference to main.css removed-->

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



$dep_supply_no=$_GET['dep_supply_no'];

$table_name = $_SESSION['db_prefix']."_department_supply";
$dep_supply_query = "SELECT *  FROM $table_name WHERE  dep_supply_no = '".$dep_supply_no."' ";
$dep_supply_result = $con->query($dep_supply_query);
$row = mysqli_fetch_assoc($dep_supply_result);
$b0 = $row["issue_date"];
$b2 = $row["department"];
$b6 = $row["issued_by"];
$b7 = $row["authorised_by"];
$b8 = $row["supplied_to"];
	  
	 $table_name = $_SESSION['db_prefix']."_department_supply_lines";
	 $line_query = "SELECT *  FROM $table_name WHERE  dep_supply_no = '".$dep_supply_no."' ";
	 $line_result = $con->query($line_query);
	 
?>
<!--style sheets-->
<link rel="stylesheet" type="text/css" href="../css/tooltip.css" />

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

</head>

<body>
<?php


if ($permission_num==1) {
	include ("../navigation/store_sidebar.php");
?>
<div class="main_frame">
  <div class="page_head_frame">
          <table width="809" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td><label class="label_page_head">Supplied to :</label>
                &nbsp;&nbsp;&nbsp;
                <label class="label_page_head_2"> <?php echo $b2 ?></label></td>
            </tr>
          </table>
          </div>
          <div class="page_middle_frame">
        <div class="page_inside_frame">
          <table width="620" id="table_display" >
            <tr>
              <td align="left" valign="top">Supplied to:</td>
              <td align="left" valign="top"><span class="label_page_head_2"><?php echo $b2 ?></span></td>
              <td align="left" valign="top">Issued to:</td>
              <td align="left" valign="top"><?php echo $b8 ?></td>
            </tr>
            <tr>
              <td width="114" align="left" valign="top">Date:</td>
              <td width="155" align="left" valign="top"><?php echo date("d-m-Y", strtotime($b0 )) ?></td>
              <td width="146" align="left" valign="top">Supply no:</td>
              <td width="185" align="left" valign="top"><?php echo $dep_supply_no ?></td>
            </tr>
            <tr>
              <td align="left" valign="top">Issued by:</td>
              <td align="left" valign="top"><?php echo $b6 ?></td>
              <td align="left" valign="top">Authorised by:</td>
              <td align="left" valign="top"><?php echo $b7 ?></td>
            </tr>
            <tr>
              <td colspan="4" align="left" valign="top">&nbsp;</td>
            </tr>
          </table>
        </div>
        <div class="page_inside_frame">
          <table width="620" id="table_display" >
            <tr>
              <td width="211" height="26" align="left" valign="top">Item</td>
              <td width="116" align="left" valign="top">Group</td>
              <td width="51" align="left" valign="top">Quantity</td>
              <td width="106" align="left" valign="top">Unit price</td>
              <td width="112" align="left" valign="top">Total</td>
            </tr>
            <?php
				
				$sub_tot=0;
				$a6_total=0;
				while($row = $line_result->fetch_assoc()) {
					$a0 = $row["dep_supply_line_id"];
					$a1 = $row["store_item_id"];
					$a2 = $row["quantity"];
					$a3 = $row["price"];
					
					 $table_name = $_SESSION['db_prefix']."_store_items";
						$item_query = "SELECT item_name, subCategory, unit FROM $table_name WHERE store_item_id = '".$a1."' ";
						$item_result = $con->query($item_query);
						$row = mysqli_fetch_assoc($item_result);
						$a1a = $row["item_name"];
						$a3a = $row["unit"];
						$a4 = $row["subCategory"];
											 
					$a5=$a2*$a3;
					$a6_total=$a6_total+$a5;
					 
				 ?>
            <tr>
              <td valign="top"><?php echo $a1a ?></td>
              <td valign="top"><?php echo $a4 ?></td>
              <td valign="top"><?php echo $a2 ?></td>
              <td align="right" valign="top"><div align="right"><?php echo $a3." /".$a3a ?></div></td>
              <td align="right" valign="top"><div align="right"><?php echo number_format($a5, 2, '.', ',')?></div></td>
            </tr>
            <?php 
			   // $a6_total=$a6_total+$a6;
			
				 }
				 ?>
            <tr>
              <td colspan="4" align="left" valign="top">&nbsp;</td>
              <td align="left" valign="top"></td>
            </tr>
            <tr>
              <td colspan="4" align="left" valign="top"><div align="right">Total:</div></td>
              <td align="left" valign="top"><div align="right"><?php echo number_format($a6_total, 2, '.', ',') ?></div></td>
            </tr>
          </table>
          <br>
          <br>
     
</div>
<div class="page_inside_frame">
<a href="department_supply_print.php?dep_supply_no=<?php echo $dep_supply_no ?>" target="_blank"><input name="print_button" type="button" class="imagebutton" value="Print issue " /></a>
</div>
</div>  
</div>
<?php include ('../navigation/side_bar.php'); ?>


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