}
function show_order_form($order = null, $area_id = null) {
- global $states;
+ global $states, $parcel_sizes, $parcel_contents;
if ($order) {
$q = new OrderStateQuery;
echo " <td>"; input("quantity", sprintf("%0.2f", $order->getQuantity() / 1000)); echo "</td>\n";
echo "</tr>\n";
+ /* Parcel type. */
+ echo "<tr>\n";
+ echo " <td>Parcel size</td>\n";
+ echo " <td><select name=\"parcel_size\">\n";
+ $mask = 1 << (count($parcel_sizes) + 1);
+ for ($i = 0; $i < count($parcel_sizes); $i++) {
+ option("parcel_size", $i << 1, $parcel_sizes[$i], $order->getParcel() % $mask);
+ }
+ echo "</select></td>\n";
+ echo "</tr>\n";
+
+ /* Parcel contents. */
+ echo "<tr>\n";
+ echo " <td>Parcel contents</td>\n";
+ echo " <td>";
+ for ($i = count($parcel_sizes); $i < count($parcel_contents); $i++) {
+ echo " <input type=\"checkbox\" name=\"parcel_$i\"";
+ if ($order->getParcel() & (1 << $i)) echo " checked";
+ echo ">$parcel_contents[$i]\n";
+ }
+ echo "</td>\n";
+ echo "</tr>\n";
+
/* Driver. */
echo "<tr>\n";
echo " <td>Driver</td>\n";
}
function update_order(&$order, $new = false) {
- global $user_id;
+ global $user_id, $parcel_sizes, $parcel_contents;
#$date = ymd_to_iso8601("date");
$date = $_POST['date'];
if (! $driver_id) $driver_id = null;
$state = $_POST['state'];
if (! $state) $state = $GLOBALS['STATE_PLACED'];
+ $parcel = $_POST['parcel_size'];
+ for ($i = count($parcel_sizes); $i < count($parcel_contents); $i++) {
+ if ($_POST['parcel_' . $i] == "on") $parcel |= (1 << $i);
+ }
if ($date) {
list($y, $m, $d) = explode('-', $date);
$order->setBeneficiaryId($beneficiary_id);
$order->setHubId($hub_id);
$order->setQuantity($quantity * 1000);
+ $order->setParcel($parcel);
/* XXX: begin/commit */
try {