<?php
require_once('configuration/config.php');

function display_details($id) {
	$id = $id;
	$details = mysql_query("SELECT * FROM transaction LEFT JOIN status ON status.statusId = transaction.status 
							LEFT JOIN customer ON customer.customer_id = transaction.customer_id
							LEFT JOIN employees ON employees.emp_id = transaction.acct_id
							LEFT JOIN items ON items.itemNo = transaction.itemNo
							WHERE transaction.id = '$id'") or die(mysql_error());
	$display = mysql_fetch_array($details);
?>
	<table>
	<tr><td>ID </td><td><?php echo $display['id']; ?></td></tr>
	<tr><td>Transaction Name </td><td><?php echo $display['transaction_name']; ?></td></tr>
	<tr><td>Date </td><td><?php echo $display['date']; ?></td></tr>
	<tr><td>Status </td><td><?php echo $display['statuslabel']; ?></td></tr>
	<tr><td>Customer </td><td><?php echo $display['last_name'].", ".$display['first_name']; ?></td></tr>
	<tr><td>Employee </td><td><?php echo $display['emp_name']; ?></td></tr>
	<tr><td>Item </td><td><?php echo $display['itemName']; ?></td></tr>
	<tr><td>Quantity </td><td><?php echo $display['ship_qty']; ?></td></tr>
	<tr><td>Address </td><td><?php echo $display['address']; ?></td></tr>
	</table>
<?php }
	function updateStatus($id, $status, $location, $comment){
	$insert = mysql_query("INSERT INTO comment (transaction_id, status, current_location, comment) VALUES ('$id', '$status', '$location', '$comment')");
	$update = mysql_query("UPDATE transaction SET status = '$status' WHERE id = '$id'") or die(mysql_error());
	return "Success";
	}
	
	function optionStatus(){
	$status = mysql_query("SELECT * FROM status") or die(mysql_error());
			echo "<option>------Update Status--------</option>";
		WHILE($statusLabel = mysql_fetch_array($status)){
			echo "<option value='".$statusLabel['statusId']."'>".$statusLabel['statuslabel']."</option>";
		}
	}
?>