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


<!--reference to main.css removed-->
<?php
include('../include/session.php');
?>

<?php
$emp_supply_id=$_GET['emp_supply_id'];

$table_name = $_SESSION['db_prefix']."_employee_supply";
$emp_supply_query = "SELECT *  FROM $table_name WHERE  emp_supply_id = '".$emp_supply_id."' ";
$emp_supply_result = mySQL_query($emp_supply_query);
$b0 = mysql_result($emp_supply_result, 0, "issue_date");
$b2 = mysql_result($emp_supply_result, 0, "emp_id");
$b6 = mysql_result($emp_supply_result, 0, "issued_by");
$b7 = mysql_result($emp_supply_result, 0, "authorised_by");
    
   $table_name = $_SESSION['db_prefix']."_employee_supply_lines";
   $line_query = "SELECT *  FROM $table_name WHERE  emp_supply_id = '".$emp_supply_id."' ";
   $line_result = mySQL_query($line_query);
   $line_num = mysql_num_rows($line_result);

  
$table_name2 = $_SESSION['db_prefix']."_employee";
$employee_query = "SELECT emp_first_name, emp_last_name FROM $table_name2 WHERE emp_id ='".$b2."' ";
$employee_result = mySQL_query($employee_query);
$employee_num = mysql_num_rows($employee_result);  

$a0 = mysql_result($employee_result, 0, "emp_first_name");
$a1 = mysql_result($employee_result, 0, "emp_last_name");


$employeeTT =
       "<table id=table_tool_tip width=300 ><tr><td  width=75>Name:</td><td width=175>".$a0." ".$a1."</td></tr></table><br><b>Click for details</b>";   

?>
<!--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
include ("../navigation/header.php");
$page_name = "Stores-main";
include ("../navigation/access.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 $a0.' '.$a1 ?></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"><?php echo $a0.' '.$a1 ?></td>
              <td align="left" valign="top">&nbsp;</td>
              <td align="left" valign="top">&nbsp;</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">&nbsp;</td>
              <td width="185" align="left" valign="top">&nbsp;</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
        $i=0;
        $sub_tot=0;
        $a6_total=0;
         while ($i<$line_num){
           $a0 = mysql_result($line_result, $i, "emp_supply_line_id");
           $a1 = mysql_result($line_result, $i, "store_item_id");
           $table_name = $_SESSION['db_prefix']."_store_items";
            $item_query = "SELECT * FROM $table_name WHERE store_item_id = '".$a1."' ";
           
            $item_result = mySQL_query($item_query);
            $a1a = mysql_result($item_result, 0, "item_name");
            $a3a = mysql_result($item_result, 0, "unit");
            $a4 = mysql_result($item_result, 0, "subCategory");
           $a2 = mysql_result($line_result, $i, "quantity");
           $a3 = mysql_result($line_result, $i, "price");
          $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;
        $i++;
         }
         ?>
            <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="employee_supply_print.php?emp_supply_id=<?php echo $emp_supply_id ?>" 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>