This is the page that is sending the command from the form button at the bottom.
<?php
//ordering.php page2
//Start the session
session_start();
var_dump($_REQUEST['command']);
if(isset($_REQUEST['command']) && $_REQUEST['command'] == 'clear'){
unset($_SESSION['cart']);
header("location:product_page.php");
exit();
}
?>
<!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" xml:lang="en">
<script type="text/javascript">
function getOrderTotal() {
var icost = document.product_form.unitCost1.value;
var iqty = document.product_form.qty1.value;
var recurrency = '^[0-9]{1,5}\.[0-9]{2}$';
var reitems = '^([1-9])([0-9]{0,2})$';
if(!icost.match(recurrency)) {
alert('Please provide an item cost in 0.00 format!');
}
else if(!iqty.match(reitems)) {
alert('Please provide a quantity of 1 to 999!');
}
else {
var itotal = (icost * iqty);
itotal *= 100;
itotal = Math.ceil(itotal);
itotal /= 100;
if(itotal.toFixed) {
itotal = itotal.toFixed(2);
}
document.getElementById('totalCost1').value = itotal;
}
}
</script>
<head>
<title>Order Form</title>
<script language="javascript">
function clear_order(){
if(confirm('This will empty your shopping cart, continue?')){
document.subtm_order.command.value='clear';
document.subtm_order.submit();
}
}
</script>
</head>
<body style="background: #336699; margin-top: 8px; margin-left: 8px;">
<h1 align="center">Order Form</h1>
<?php
date_default_timezone_set('America/Los_Angeles');
$ord_date=date('M j, Y H:i');
//If we have previously initiated a session in order_product.php, the shopping cart is
//defined as an associative array, $_SESSION['cart'].
//We first need to check if the $_SESSION['cart'] variable has been defined, as it
//won't be if the user has come straight to this page.
//Top of the order form information
echo '<div align="center"><form name="subtm_order" method="post">
<table border="0" id="requestor_info" summary="Table holds SubTM Ordered Parts information">
<tbody>
<thead><tr><th>Requesting Facility<br>
<input name="facility" type="text" id="facility" value="SubTM Bangor" size="11" readonly="readonly"></th>
<th>Requester Name<br>
<input name="lname" type="text" id="lname" style="text-align: center" size="10" value="'.$_SESSION['SESS_MEMBER_LNAME'].'"></th>
<th>Today\'s Date<br>
<input align="center" type="text" name="ord_date"
value="'.$ord_date.'" readonly="readonly" size="14"></th></tr>
</thead>
</tbody>
</table>';
//We also need to check if there are currently any items in the shopping cart.
if (!isset($_SESSION['cart']) || (count($_SESSION['cart']) == 0)) {
echo '<p>Your order form is woefully empty!</p>';
} else {
echo '<table border="1" cellpadding="5px" cellspacing="1px" style="font-family:Veranda, Geneva, sans-serif; font-size:11px; background-color:#E1E1E1">
<tr bgcolor=\"#FFFFFF\" style=\"font-weight:bold\">
<th>Row</th>
<th>Unit Cost</th>
<th>Qty</th>
<th><div title="bx, ea, ft, etc.">Unit</div></th>
<th>Description</th>
<th>Part Number</th>
<th><div title="AC-1, AC-2, COAET, etc.">Location where <br>item is used</div></th>
<th>Rack or<br>Machine Info</th>
<th>Function performed<br>by Hardware</th>
<th>Total Cost</th>
<th>Sources / Links <br>Please paste below</th></tr>';
$total = 0;
$i=1;
//We iterate over all the items in $_SESSION['cart'].
//Each item represents a "row," or a single product to buy, in the shopping cart.
foreach($_SESSION['cart'] as $item) {
//Recall that the format of the $item associative array is the same as the one
//defined in add.php, since the array has simply been passed to this page
//via the $_SESSION variable.
echo "<tr bgcolor=\"#FFFFFF\" style=\"font-weight:bold\">
<td>$i</td>
<td>\${$item['unitCost']}</td>
<td>{$item['ord_qty']}</td>
<td>{$item['unit']}</td>
<td>{$item['desc']}</td>
<td>{$item['partNo']}</td>
<td>{$item['location']}</td>
<td>{$item['rackUnit']}</td>
<td>{$item['hdwrFunct']}</td>
<td>$".number_format(($item['unitCost'] * $item['ord_qty']),2)."</td>
<td>{$item['supplierUrl']}</td>
</tr>";
$i++;
$total += ($item['unitCost'] * $item['ord_qty']);
};
}
?>
<tr><td colspan="3"><b><strong>Grand total: </strong>$<?php echo number_format($total,2)?></b></td>
<td colspan="8" align="right">
<input type="button" value="CLEAR Order" onclick="clear_order()">
<input type="button" value="Order more" onclick="window.location='product_page.php'">
<input type="button" value="Place Order" onclick="window.location='submit_order.php'"></td></tr>
</table></form></div>
<!-- <hr /> -->
</body>
</html>