<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<link href="../css/main.css" rel="stylesheet" type="text/css" />
<?php
include ("../navigation/header.php");
$page_name = "AD-tracking";
include ("../navigation/access.php");
include('../include/period_select_date.php');	

if ($permission_num==1) {
	include ("../navigation/admin_sidebar.php");
?>
<?php

	
$table_name2 = $_SESSION['db_prefix']."_tracking_store";
$tracking_query = "SELECT * FROM $table_name2 WHERE entry_date >= '".$start."' AND entry_date <= ('".$end."'+ INTERVAL 1 DAY) ORDER BY action_id DESC ";
$tracking_result = mySQL_query($tracking_query);
$tracking_num = mysql_num_rows($tracking_result);


?>
<!--style sheets-->
<link rel="stylesheet" type="text/css" href="../css/scroll_table.css" />

<!--jscript-->
<script language="javascript" src="../jscript/calendar.js"></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": [
								{"iDataSort": 5},
                              	{"bSortable": true},
                             	{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bVisible": false}
								 ]
				} );
			} );
		</script>
</head>

<body>


<div class="main_frame">
<div class="page_head_frame">
        
        <table width="825" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="523"><label class="label_page_head">Stores tracking</label></td>
            <td width="287">&nbsp;</td>
          </tr>
        </table>
  </div>
        <br />
<br />

<div class="page_middle_frame">	
<?php
$page='tracking_stores.php';
$reference_name='';
$reference='';
$reference_name_2='';
$reference_2='';
$reference_name_3='';
$reference_3='';
include('../include/period_select_block_small.php');
?>
</div>


<div class="page_middle_frame">
<table width="683" id="scroll_table" class="data_display"  >
  <thead>
  <tr>
    <th>date</th>
    <th >time</th>
    <th>user</th>
    <th>action</th>
    <th width="371" >details</th>
    <th width="55" >&nbsp;</th>
    </tr>
    </thead>
<?php 

$i=0;

while ($i<$tracking_num) {
    $b0  =  mysql_result($tracking_result, $i, "action_id");
	$b1 =  mysql_result($tracking_result, $i, "entry_date");
	$b2 =  mysql_result($tracking_result, $i, "user_name");
	$b3 =  mysql_result($tracking_result, $i, "action");
	$d1 = mysql_result($tracking_result, $i, "details_1");
	$d2 = mysql_result($tracking_result, $i, "details_2");
	$d3 = mysql_result($tracking_result, $i, "details_3");
	$d4 = mysql_result($tracking_result, $i, "details_4");
	
	
	
	$action='';
	$details='';
	switch ($b3) {
    case 10:
        $action = 'New store item';
		$table_name = $_SESSION['db_prefix']."_store_items";
		$item_query = "SELECT item_name FROM $table_name WHERE store_item_id = '".$d1."' ";
		$item_result = mySQL_query($item_query);
		$item_name = mysql_result($item_result, 0, "item_name");
		$details = '<a href=../store/store_item_display.php?store_item_id='.$d1.'><b>'.$item_name.'</b></a>';
        break;
    case 11:
        $action = 'Receive stock';
		$table_name = $_SESSION['db_prefix']."_store_items";
		$item_query = "SELECT item_name FROM $table_name WHERE store_item_id = '".$d1."' ";
		$item_result = mySQL_query($item_query);
		$item_name = mysql_result($item_result, 0, "item_name");
		
		$table_name = $_SESSION['db_prefix']."_suppliers";
		$sup_name_query = "SELECT account_name FROM $table_name WHERE supplier_id = '".$d2."' ";
		$sup_name_result = mySQL_query($sup_name_query);
		$sup_name = mysql_result($sup_name_result, 0, "account_name");
		
		$details = '<a href=../store/store_item_display.php?store_item_id='.$d1.'><b>'.$item_name.'</b></a> from <a href=../store/supplier_details.php?supplier_id='.$d2.'><b>'.$sup_name.'</b></a> on receive no: <a href=../store/receive_note.php?receive_id='.$d3.'><b>'.$d3.'</b></a>';
        break;
    case 12:
        $action = 'Tiles/accessories from production';
		
		$table_name = $_SESSION['db_prefix']."_production_plan";
		$item_query = "SELECT mix_design_name FROM $table_name WHERE production_no = '".$d2."'  ";
		$item_result = mySQL_query($item_query);
		$item = mysql_result($item_result, 0, "mix_design_name");
				
		$details = $d4.' '.$item.' received from production no: <a href="../production/production_plan.php?production_no='.$d2.'"><b>'.$d2.'</b></a>.';
        break;
	case 13:
        $action = 'Deliver tiles & acc';
				$table_name2 = $_SESSION['db_prefix']."_customer";
				$customer_query = "SELECT account_type, title, name_2, comp_name FROM $table_name2 WHERE cust_id ='".$d4."' ";
				$customer_result = mySQL_query($customer_query);
				$customer_num = mysql_num_rows($customer_result);
				if ($customer_num>0) {	
				$cust_name = mysql_result($customer_result, 0, "comp_name"); 
				}
				else {
				$cust_name = '';
				}
				
		$details = 'Tiles & acc delivered on delivery note: <a href=../store/tile_deliver_display.php?delivery_no='.$d1.'><b>'.$d1.'</b></a> on order <a href=../store/order.php?order_no='.$d3.'><b>'.$d2.'</b></a> of <a href=../store/account_details.php?cust_id='.$d4.'><b>'.$cust_name.'</b></a>.';
        break;
	case 14:
        $action = 'Supply direct materials';
		$table_name = $_SESSION['db_prefix']."_store_items";
		$item_query = "SELECT item_name, unit FROM $table_name WHERE store_item_id = '".$d1."' ";
		$item_result = mySQL_query($item_query);
		$item_name = mysql_result($item_result, 0, "item_name");
		$item_unit = mysql_result($item_result, 0, "unit");
		
		
		$table_name = $_SESSION['db_prefix']."_captured_jobs";
		$table_name2 = $_SESSION['db_prefix']."_customer";
		$cust_name_query = "SELECT $table_name.cust_id, comp_name FROM $table_name, $table_name2 WHERE job_no= '".$d4."' AND $table_name.cust_id=$table_name2.cust_id ";
		$cust_name_result = mySQL_query($cust_name_query);
		$cust_id = mysql_result($cust_name_result, 0, "cust_id");
		$cust_name = mysql_result($cust_name_result, 0, "comp_name");
		
		$details = $d2.' '.$item_unit.' <a href=../store/store_item_display.php?store_item_id='.$d1.'>'.$item_name.'</a> for <a href=../production/captured_job.php?job_no='.$d4.'>'.$d4.'</a> of: <a href=../sales/customer_details.php?cust_id='.$cust_id.'>'.$cust_name.'</a>';
        break;
	case 15:
        $action = 'Supply department';
		
		$table_name = $_SESSION['db_prefix']."_store_items";
		$item_query = "SELECT item_name FROM $table_name WHERE store_item_id = '".$d1."' ";
		$item_result = mySQL_query($item_query);
		$item_name = mysql_result($item_result, 0, "item_name");
		$details = '<a href=../store/store_item_display.php?store_item_id='.$d1.'><b>'.$item_name.'</b></a> to '.$d2.' on delvery no <a href=../store/department_supply.php?dep_supply_no='.$d4.'><b>'.$d4.'</b></a>, issued to '.$d3.'.';
		
        break;
	case 16:
        $action = 'Supply employee';
		
		$table_name = $_SESSION['db_prefix']."_store_items";
		$item_query = "SELECT item_name FROM $table_name WHERE store_item_id = '".$d1."' ";
		$item_result = mySQL_query($item_query);
		$item_name = mysql_result($item_result, 0, "item_name");
		
		$table_name2 = $_SESSION['db_prefix']."_employee";
		$employee_query = "SELECT emp_first_name, emp_last_name FROM $table_name2 WHERE emp_id ='".$d2."' ";
		$employee_result = mySQL_query($employee_query);
		$employee_num = mysql_num_rows($employee_result);	
		$emp_name = mysql_result($employee_result, 0, "emp_first_name").' '.mysql_result($employee_result, 0, "emp_last_name"); 
		
		$details = '<a href=../store/store_item_display.php?store_item_id='.$d1.'><b>'.$item_name.'</b></a> to <a href=../hr_module/employee_details.php?emp_id='.$d2.'><b>'.$emp_name.'</b></a> on delvery no <a href=../store/employee_supply.php?emp_supply_no='.$d3.'><b>'.$d3.'</b></a>';
		break;
		
	case 17:
        $action = 'Return from employee';
		
		$table_name = $_SESSION['db_prefix']."_store_items";
		$item_query = "SELECT item_name FROM $table_name WHERE store_item_id = '".$d1."' ";
		$item_result = mySQL_query($item_query);
		$item_name = mysql_result($item_result, 0, "item_name");
		
		$table_name2 = $_SESSION['db_prefix']."_employee";
		$employee_query = "SELECT emp_first_name, emp_last_name FROM $table_name2 WHERE emp_id ='".$d2."' ";
		$employee_result = mySQL_query($employee_query);
		$employee_num = mysql_num_rows($employee_result);	
		$emp_name = mysql_result($employee_result, 0, "emp_first_name").' '.mysql_result($employee_result, 0, "emp_last_name"); 
		
		$details = '<a href=../store/store_item_display.php?store_item_id='.$d1.'><b>'.$item_name.'</b></a> to <a href=../hr_module/employee_details.php?emp_id='.$d2.'><b>'.$emp_name.'</b></a> on delvery no <a href=../store/employee_supply.php?emp_supply_no='.$d3.'><b>'.$d3.'</b></a>';
		break;	
		
	case 18:
	    $action = 'New vehicle';
        $table_name = $_SESSION['db_prefix']."_vehicle";
		$vehicle_query = "SELECT vehicle_id, registration_no, make, model FROM $table_name WHERE registration_no = '".$d2."' ";
		$vehicle_result = mySQL_query($vehicle_query);
		$vehicle_id = mysql_result($vehicle_result, 0, "vehicle_id");
		$vehicle = mysql_result($vehicle_result, 0, "registration_no").' '.mysql_result($vehicle_result, 0, "make").' '.mysql_result($vehicle_result, 0, "model");
		$TT = "'Click here for details on ".$vehicle."'";
        $details='New vehicle: <b><a href="../store/vehicle_details.php?vehicle_id='.$vehicle_id.'" onMouseover="ddrivetip('.$TT.', 250)"; onMouseout="hideddrivetip()">'.$vehicle.'</a></b> ';
        break;
		
	case 19:
	    $action = 'Edit vehicle';
        $table_name = $_SESSION['db_prefix']."_vehicle";
		$vehicle_query = "SELECT registration_no, make, model FROM $table_name WHERE vehicle_id = '".$d1."' ";
		$vehicle_result = mySQL_query($vehicle_query);
		$vehicle = mysql_result($vehicle_result, 0, "registration_no").' '.mysql_result($vehicle_result, 0, "make").' '.mysql_result($vehicle_result, 0, "model");
		$TT = "'Click here for details on ".$vehicle."'";
        $details= $d4.' for: <b><a href="../store/vehicle_details.php?vehicle_id='.$d1.'" onMouseover="ddrivetip('.$TT.', 250)"; onMouseout="hideddrivetip()">'.$vehicle.'</a></b> edited from: '.$d2.' to: '.$d3;
        break;		
	
		
	case 20:
        $action = 'New supplier';
		
		$table_name = $_SESSION['db_prefix']."_suppliers";
		$sup_name_query = "SELECT account_name FROM $table_name WHERE supplier_id = '".$d2."' ";
		$sup_name_result = mySQL_query($sup_name_query);
		$sup_name = mysql_result($sup_name_result, 0, "account_name");
		$details = '<a href=../store/supplier_details.php?supplier_id='.$d2.'><b>'.$sup_name.'</b></a>';
		
		
        break;
	case 21:
        $action = 'Stock count';
		$table_name = $_SESSION['db_prefix']."_store_items";
		$item_query = "SELECT item_name FROM $table_name WHERE store_item_id = '".$d1."' ";
		$item_result = mySQL_query($item_query);
		$item_name = mysql_result($item_result, 0, "item_name");
		$details = '<a href=../store/store_item_display.php?store_item_id='.$d1.'><b>'.$item_name.'</b></a>, old value: <b>'.$d2.'</b> counted value: <b>'.$d3.'</b>';
		break;
		
	case 22:
        $action = 'Supply company';
		
		$table_name = $_SESSION['db_prefix']."_store_items";
		$item_query = "SELECT item_name FROM $table_name WHERE store_item_id = '".$d1."' ";
		$item_result = mySQL_query($item_query);
		$item_name = mysql_result($item_result, 0, "item_name");
		$details = '<a href=../store/store_item_display.php?store_item_id='.$d1.'><b>'.$item_name.'</b></a> to '.$d2.' on delvery no <a href=../store/company_supply.php?dep_supply_no='.$d4.'><b>'.$d4.'</b></a>, issued to '.$d3.'.';
		
        break;	
	
	case 23:
        $action = 'Edit supplier';
		$table_name = $_SESSION['db_prefix']."_suppliers";
		$name_query = "SELECT account_name FROM $table_name WHERE supplier_id = '".$d1."' ";
		$name_result = mySQL_query($name_query);
		$name = mysql_result($name_result, 0, "account_name");
		$details = '<b>'.$d4.'</b> for <b><a href=../store/supplier_details.php?supplier_id='.$d1.'>'.$name.'</a></b> changed from <b>'.$d2.'</b> to <b>'.$d3.'</b>';
		break;
	case 24:
        $action = 'Edit store item';
		//if (($d4=='Price') OR ($d4=='Purchase price')) {
//			$d2='P'.number_format($d2, 2, '.', ',');
//			$d3=number_format($d3, 2, '.', ',');
//		}
		
		$table_name = $_SESSION['db_prefix']."_store_items";
		$item_query = "SELECT item_name FROM $table_name WHERE store_item_id = '".$d1."' ";
		$item_result = mySQL_query($item_query);
		$item_name = mysql_result($item_result, 0, "item_name");
		
		
		$details = '<b>'.$d4.'</b> for <b><a href=../store/store_item_display.php?store_item_id='.$d1.'>'.$item_name.'</a></b> changed from <b>'.$d2.'</b> to <b>'.$d3.'</b>';
		break;
	case 25:
        $action = 'Stock adjustment';
		$table_name = $_SESSION['db_prefix']."_store_items";
		$item_query = "SELECT item_name FROM $table_name WHERE store_item_id = '".$d1."' ";
		$item_result = mySQL_query($item_query);
		$item_name = mysql_result($item_result, 0, "item_name");
		$details = '<a href=../store/store_item_display.php?store_item_id='.$d1.'><b>'.$item_name.'</b></a>, old value: <b>'.$d2.'</b> counted value: <b>'.$d3.'</b>';
		break;		
	case 26:
        $action = 'Return pallets';
		
		$table_name = $_SESSION['db_prefix']."_tile_orders";
		$cust_id_query = "SELECT cust_id FROM $table_name WHERE order_no = '".$d2."' ";
		$cust_id_result = mySQL_query($cust_id_query);
		$cust_id = mysql_result($cust_id_result, 0, "cust_id");
		
		$table_name2 = $_SESSION['db_prefix']."_customer";
		$customer_query = "SELECT account_type, title, name_2, comp_name FROM $table_name2 WHERE cust_id ='".$cust_id."' ";
		$customer_result = mySQL_query($customer_query);
		$customer_num = mysql_num_rows($customer_result);	
		$account_type = mysql_result($customer_result, 0, "account_type");
		if ($account_type=="corporate") { 
				$cust_name = mysql_result($customer_result, 0, "comp_name"); 
			} 
		else {
				$cust_name = mysql_result($customer_result, 0, "title")." ".mysql_result($customer_result, 0, "name_2")." ".mysql_result($customer_result, 0, "comp_name");
 			}
		
		$details = '<b>'.$d3.' pallets returned on delivery no <a href=../store/tile_deliver_display.php?delivery_no='.$d1.'>'.$d1.'</a> from <a href=../sales/customer_details.php?cust_id='.$cust_id.'>'.$cust_name.'</a>, order no:	<a href=../sales/tile_order_display.php?order_no='.$d2.'</a> <b>'.$d2.'</b>';
		
        break;
		
		case 27:
        $action = 'Return on order';
		
		$table_name = $_SESSION['db_prefix']."_order_return";
		$order_query = "SELECT cust_id FROM $table_name WHERE order_return_no = '".$d1."' ";
		$order_result = mySQL_query($order_query);
		$order_num = mysql_num_rows($order_result);
		$cust_id = mysql_result($order_result, 0, "cust_id");
		
		$table_name2 = $_SESSION['db_prefix']."_customer";
		$customer_query = "SELECT * FROM $table_name2 WHERE cust_id ='".$cust_id."' ";
		$customer_result = mySQL_query($customer_query);
		$customer_num = mysql_num_rows($customer_result);	
		$a1 = mysql_result($customer_result, 0, "account_type");
		$cust_name = mysql_result($customer_result, 0, "comp_name"); 
				
		
		$details = 'Return <b><a href=../store/order_return.php?order_return_no='.$d1.'&order_no='.$d2.'>'.$d1.'</b></a> on order <b><a href=../orders/order.php?order_no='.$d2.'>'.$d2.'</a></b> for <a href=../orders/account_details.php?cust_id='.$cust_id.'><b>'.$cust_name.'</b></a>.';
		break;
		
		case 28:
        $action = 'Edit depallet count';
				
		$table_name = $_SESSION['db_prefix']."_production_plan";
		$date_query = "SELECT production_date, mix_design_name FROM $table_name WHERE production_no = '".$d1."' ";
		$date_result = mySQL_query($date_query);
		$production_date = mysql_result($date_result, 0, "production_date");
		$mix_design_name = mysql_result($date_result, 0, "mix_design_name");
		
								
		$details = 'Depallet count on <b>'.$mix_design_name.'</b> production on <a href=../production/day_production_display.php?production_no='.$d1.'><b>'.date("d-m-Y", strtotime($production_date)).'</b></a>, counted on '.date("d-m-Y", strtotime($d2)).' changed from <b>'.$d3.'</b> to <b>'.$d4.'</b>.';
        break;	
		
		case 29:
        $action = 'Edit stock count';
		$details = '<b>'.$d4.'</b> for <b>'.$d1.'</a></b> changed from <b>'.$d2.'</b> to <b>'.$d3.'</b>';
		break;	
		
		case 30:
	    $action = 'Fuel';
        $table_name = $_SESSION['db_prefix']."_vehicle";
		$vehicle_query = "SELECT registration_no, make, model FROM $table_name WHERE vehicle_id = '".$d1."' ";
		$vehicle_result = mySQL_query($vehicle_query);
		$vehicle = mysql_result($vehicle_result, 0, "registration_no").' '.mysql_result($vehicle_result, 0, "make").' '.mysql_result($vehicle_result, 0, "model");
		$TT = "'Click here for details on ".$vehicle."'";
        $details= $d3.'ltr for: <b><a href="../store/vehicle_details.php?vehicle_id='.$d1.'" onMouseover="ddrivetip('.$TT.', 250)"; onMouseout="hideddrivetip()">'.$vehicle.'</a></b> on: '.date("d-m-Y", strtotime($d2)).' on: '.$d4.'km';
        break;	
		
		case 31:
	    $action = 'Edit fuel receipt';
        $table_name = $_SESSION['db_prefix']."_vehicle";
		$TT = "'Click here for receipt details'";
        $details= '<b>'.$d4.'</b> on fuel receipt: <b><a href="../store/fuel_rec_display.php?fuel_id='.$d1.'" onMouseover="ddrivetip('.$TT.', 250)"; onMouseout="hideddrivetip()">'.$d1.'</a></b> changed from: <b>'.$d2.'</b> to <b>'.$d3.'</b>';
        break;	
		
		case 32:
	    $action = 'Edit received note';
		
		$table_name = $_SESSION['db_prefix']."_receive_store";
		$receive_query = "SELECT supplier_id FROM $table_name WHERE receive_id = '".$d1."' ";
		$receive_result = mySQL_query($receive_query);
		$supplier_id = mysql_result($receive_result, 0, "supplier_id");
		
		$table_name = $_SESSION['db_prefix']."_store_items";
		$unit_query = "SELECT item_name, unit FROM $table_name WHERE store_item_id = '".$d2."' ";
		$unit_result = mySQL_query($unit_query);
		$item_name = mysql_result($unit_result, 0, "item_name");
		$unit = mysql_result($unit_result, 0, "unit");
		
		$table_name2 = $_SESSION['db_prefix']."_suppliers";
		$account_name_query = "SELECT account_name FROM $table_name2 WHERE supplier_id ='".$supplier_id."' ";
		$account_name_result = mySQL_query($account_name_query);
		$account_name_num = mysql_num_rows($account_name_result);	
		$account_name = mysql_result($account_name_result, 0, "account_name"); 
		        
        $details= '<b>'.$d4.' '.$unit.'</b> <b><a href="../store/store_item_display.php?store_item_id='.$d2.'">'.$item_name.'</a></b> was added on receive note: <b><a href="../store/receive_note.php?receive_id='.$d1.'">'.$d1.'</a></b>, supplier: <b><a href="../store/supplier_details.php?supplier_id='.$supplier_id.'">'.$account_name.'</b></a>.';
        break;	
		
		case 33:
	    $action = 'Edit received note';
		
		$table_name = $_SESSION['db_prefix']."_receive_store";
		$receive_query = "SELECT supplier_id FROM $table_name WHERE receive_id = '".$d1."' ";
		$receive_result = mySQL_query($receive_query);
		$supplier_id = mysql_result($receive_result, 0, "supplier_id");
		
		$table_name = $_SESSION['db_prefix']."_store_items";
		$unit_query = "SELECT item_name, unit FROM $table_name WHERE store_item_id = '".$d4."' ";
		$unit_result = mySQL_query($unit_query);
		$item_name = mysql_result($unit_result, 0, "item_name");
		$unit = mysql_result($unit_result, 0, "unit");
		
		$table_name2 = $_SESSION['db_prefix']."_suppliers";
		$account_name_query = "SELECT account_name FROM $table_name2 WHERE supplier_id ='".$supplier_id."' ";
		$account_name_result = mySQL_query($account_name_query);
		$account_name_num = mysql_num_rows($account_name_result);	
		$account_name = mysql_result($account_name_result, 0, "account_name"); 
		        
        $details= 'Quantity for <b><a href="../store/store_item_display.php?store_item_id='.$d4.'">'.$item_name.'</a></b> on receive note <b><a href="../store/receive_note.php?receive_id='.$d1.'">'.$d1.'</a></b> was changed from <b>'.$d2.' '.$unit.'</b> to <b>'.$d3.' '.$unit.'</b> supplier: <b><a href="../store/supplier_details.php?supplier_id='.$supplier_id.'">'.$account_name.'</b></a>.';
        break;	
		
		case 34:
	    $action = 'Edit received note';
		
		$table_name = $_SESSION['db_prefix']."_receive_store";
		$receive_query = "SELECT supplier_id FROM $table_name WHERE receive_id = '".$d1."' ";
		$receive_result = mySQL_query($receive_query);
		$supplier_id = mysql_result($receive_result, 0, "supplier_id");
		
		$table_name = $_SESSION['db_prefix']."_store_items";
		$unit_query = "SELECT item_name, unit FROM $table_name WHERE store_item_id = '".$d4."' ";
		$unit_result = mySQL_query($unit_query);
		$item_name = mysql_result($unit_result, 0, "item_name");
		$unit = mysql_result($unit_result, 0, "unit");
		
		$table_name2 = $_SESSION['db_prefix']."_suppliers";
		$account_name_query = "SELECT account_name FROM $table_name2 WHERE supplier_id ='".$supplier_id."' ";
		$account_name_result = mySQL_query($account_name_query);
		$account_name_num = mysql_num_rows($account_name_result);	
		$account_name = mysql_result($account_name_result, 0, "account_name"); 
		        
        $details= 'Unit price for <b><a href="../store/store_item_display.php?store_item_id='.$d4.'">'.$item_name.'</a></b> on receive note <b><a href="../store/receive_note.php?receive_id='.$d1.'">'.$d1.'</a></b> was changed from <b>P'.$d2.' </b> to <b>P'.$d3.' </b> supplier: <b><a href="../store/supplier_details.php?supplier_id='.$supplier_id.'">'.$account_name.'</b></a>.';
        break;	
		
		case 35:
		$action = 'Edit received note';
		
		$table_name = $_SESSION['db_prefix']."_receive_store";
		$receive_query = "SELECT supplier_id FROM $table_name WHERE receive_id = '".$d1."' ";
		$receive_result = mySQL_query($receive_query);
		$supplier_id = mysql_result($receive_result, 0, "supplier_id");
					
		$table_name2 = $_SESSION['db_prefix']."_suppliers";
		$account_name_query = "SELECT account_name FROM $table_name2 WHERE supplier_id ='".$supplier_id."' ";
		$account_name_result = mySQL_query($account_name_query);
		$account_name_num = mysql_num_rows($account_name_result);	
		$account_name = mysql_result($account_name_result, 0, "account_name"); 
		        
        $details= 'Receive date on receive note <b><a href="../store/receive_note.php?receive_id='.$d1.'">'.$d1.'</a></b> was changed from <b>'.date("d-m-Y", strtotime($d2)).'</b> to <b>'.date("d-m-Y", strtotime($d3)).'</b> supplier: <b><a href="../store/supplier_details.php?supplier_id='.$supplier_id.'">'.$account_name.'</b></a>.';
        break;
		
		case 36:
        $action = 'Supply vehicle';
		
		$table_name = $_SESSION['db_prefix']."_store_items";
		$item_query = "SELECT item_name FROM $table_name WHERE store_item_id = '".$d1."' ";
		$item_result = mySQL_query($item_query);
		$item_name = mysql_result($item_result, 0, "item_name");
		
		$table_name2 = $_SESSION['db_prefix']."_vehicle";
		$vehicle_query = "SELECT registration_no, make, model FROM $table_name2 WHERE vehicle_id ='".$d2."' ";
		$vehicle_result = mySQL_query($vehicle_query);
		$vehicle_num = mysql_num_rows($vehicle_result);	
		$veh_name = mysql_result($vehicle_result, 0, "make").' '.mysql_result($vehicle_result, 0, "model").' '.mysql_result($vehicle_result, 0, "registration_no"); 
		
		$details = '<a href=../store/store_item_display.php?store_item_id='.$d1.'><b>'.$item_name.'</b></a> to <a href=../store/vehicles_details.php?vehicle_id='.$d2.'><b>'.$veh_name.'</b></a> on delvery no <a href=../store/vehicle_supply.php?veh_supply_no='.$d3.'><b>'.$d3.'</b></a>';
		break;	
		
		case 37:
        $action = 'Supply machine';
		
		$table_name = $_SESSION['db_prefix']."_store_items";
		$item_query = "SELECT item_name FROM $table_name WHERE store_item_id = '".$d1."' ";
		$item_result = mySQL_query($item_query);
		$item_name = mysql_result($item_result, 0, "item_name");
		
		$table_name2 = $_SESSION['db_prefix']."_machinery";
		$machinery_query = "SELECT machine_id, machine_name FROM $table_name2 WHERE machine_id ='".$d2."' ";
		$machinery_result = mySQL_query($machinery_query);
		$machinery_num = mysql_num_rows($machinery_result);	
		$mach_name = mysql_result($machinery_result, 0, "machine_name"); 
		
		
		$details = '<a href=../store/store_item_display.php?store_item_id='.$d1.'><b>'.$item_name.'</b></a> to <a href=../store/machine_details.php?machine_id='.$d2.'><b>'.$mach_name.'</b></a> on delvery no <a href=../store/vehicle_supply.php?veh_supply_no='.$d3.'><b>'.$d3.'</b></a>';
		break;
		
		case 38:
	    $action = 'New machinery';
        $table_name = $_SESSION['db_prefix']."_machinery";
		$machine_query = "SELECT machine_id, machine_name, make, model FROM $table_name WHERE machine_name = '".$d2."' ";
		$machine_result = mySQL_query($machine_query);
		$machine_id = mysql_result($machine_result, 0, "machine_id");
		$machine = mysql_result($machine_result, 0, "make").' '.mysql_result($machine_result, 0, "model");
		$TT = "'Click here for details on ".$machine."'";
        $details='New machinery: <b><a href="../store/machine_details.php?machine_id='.$machine_id.'" onMouseover="ddrivetip('.$TT.', 250)"; onMouseout="hideddrivetip()">'.$machine.'</a></b> ';
        break;
		
		case 39:
	    $action = 'Edit machinery';
        $table_name = $_SESSION['db_prefix']."_machinery";
		$machine_query = "SELECT machine_name, make, model FROM $table_name WHERE machine_id = '".$d1."' ";
		$machine_result = mySQL_query($machine_query);
		$machine = mysql_result($machine_result, 0, "machine_name").' '.mysql_result($machine_result, 0, "make").' '.mysql_result($machine_result, 0, "model");
		$TT = "'Click here for details on ".$machine."'";
        $details= $d4.' for: <b><a href="../store/machine_details.php?vehicle_id='.$d1.'" onMouseover="ddrivetip('.$TT.', 250)"; onMouseout="hideddrivetip()">'.$machine.'</a></b> edited from: '.$d2.' to: '.$d3;
        break;
		
		
		case 40:
        $action = 'Return pallets';
				
		$table_name2 = $_SESSION['db_prefix']."_customer";
		$customer_query = "SELECT account_type, title, name_2, comp_name FROM $table_name2 WHERE cust_id ='".$d2."' ";
		$customer_result = mySQL_query($customer_query);
		$customer_num = mysql_num_rows($customer_result);	
		$account_type = mysql_result($customer_result, 0, "account_type");
		if ($account_type=="corporate") { 
				$cust_name = mysql_result($customer_result, 0, "comp_name"); 
			} 
		else {
				$cust_name = mysql_result($customer_result, 0, "title")." ".mysql_result($customer_result, 0, "name_2")." ".mysql_result($customer_result, 0, "comp_name");
 			}
		
		$details = '<b>'.$d3.'</b> pallets returned from <b><a href=../store/account_details.php?cust_id='.$d2.'>'.$cust_name.'</a></b>, return reference:<a href=../store/return_pallets_display.php?entry_reference='.$d1.'</a> <b>'.$d1.'</b>';
		
        break;	
}
	
	?>
  
  
  <tr>
    <td width="54" align="left"><?php echo date("d-m-Y", strtotime($b1 )) ?></td>
    <td width="38" align="left"><?php echo date("H:i", strtotime($b1 ))  ?></td>
    <td width="50" align="left"><?php echo $b2 ?></td>
    <td width="87" align="left"><?php echo $action ?></td>
    <td align="left"><?php echo $details ?></td>
    <td align="left"><?php echo $b1 ?></td>
    </tr>
  <?php
  $i++;
}
?>

</table>

</div>

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