<?
/*
Copyright (C)2004 Jeff Holman, Downhill Battle, et al
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
session_name("postal");
session_start();
require("inventory.inc.php");
// Read initial inventory into session
if (!$_SESSION['init']) {
$_SESSION['items'] = $types;
$_SESSION['pricing'] = $pricing;
$_SESSION['shipping'] = $shipping;
$_SESSION['init'] = 1;
}
// "Add to order" form for items w/o options
function quantityBox($code, $pricing, $text="Quantity and Price") {
?>
<form method="post" target="orderbar" action="order.php#new">
<b><? echo $text; ?></b><br />
<?
if (sizeof($pricing[$code]) > 1) {
?>
<select id="<? echo "$code-quantitysel"; ?>" name="quantity" onChange="if (document.getElementById('<? echo "$code-quantitysel"; ?>').value == 'o') { document.getElementById('<? echo "$code-quantitybox"; ?>').value = ''; document.getElementById('<? echo "$code-quantitybox"; ?>').disabled = false; } else { document.getElementById('<? echo "$code-quantitybox"; ?>').value = document.getElementById('<? echo "$code-quantitysel"; ?>').value; document.getElementById('<? echo "$code-quantitybox"; ?>').disabled = true; }">
<!-- <option>-- Select quantity --</option> -->
<?
foreach(array_keys($pricing[$code]) as $quantityType) {
?>
<option value="<? echo $quantityType; ?>">
<? echo $quantityType; ?> for $<? echo $pricing[$code][$quantityType]; ?>
</option>
<?
}
?>
<option value="o">Other</option>
</select>
<?
} else {
?>
<input type="hidden" name="quantity" id="<? echo "$code-quantitysel"; ?>" value="o">
<?
}
?>
<input type="text" name="quantitybox" id="<? echo "$code-quantitybox"; ?>" size="5" disabled />
<input type="hidden" name="code" value="<? echo $code ?>" />
<input type="image" src="cart-images/add-to-order.gif" name="add" value="1" alt="Add to Order" />
</form>
<script language="JavaScript">
if (document.getElementById('<? echo "$code-quantitysel"; ?>').value == 'o') { document.getElementById('<? echo "$code-quantitybox"; ?>').value = ''; document.getElementById('<? echo "$code-quantitybox"; ?>').disabled = false; } else { document.getElementById('<? echo "$code-quantitybox"; ?>').value = document.getElementById('<? echo "$code-quantitysel"; ?>').value; document.getElementById('<? echo "$code-quantitybox"; ?>').disabled = true; }
</script>
<?
}
// "Add to order" form for items w/ options
function optionBox($code, $options, $text="Quantity:") {
?>
<form method="post" target="orderbar" action="order.php#new">
<b><? echo $text ?></b><br />
<input type="text" name="quantity" id="quantity" size="5" value="1" />
<?
foreach(array_keys($options[$code]) as $optionName) {
?>
<select name="<? echo $optionName; ?>">
<option>-- Select <? echo $optionName; ?> --</option>
<?
foreach(array_keys($options[$code][$optionName]) as $optionCode) {
?>
<option value="<? echo $optionCode; ?>">
<? echo $options[$code][$optionName][$optionCode] ?>
</option>
<?
}
?>
</select>
<?
}
?>
<input type="hidden" name="code" value="<? echo $code ?>" />
<input type="image" src="cart-images/add-to-order.gif" name="add" value="1" />
</form>
<?
}
?>