X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;ds=inline;f=lib%2Forder.php;h=6c752117214d2405ae53c5c531b887e00a645e2b;hb=refs%2Ftags%2Flive-2014-03-13;hp=e9aaedad511d203c35dd04910997cc7aac1d7cd4;hpb=c5fb790a7fa53100d2c3373603c82812265c7a6a;p=readifood.git diff --git a/lib/order.php b/lib/order.php index e9aaeda..6c75211 100644 --- a/lib/order.php +++ b/lib/order.php @@ -28,13 +28,13 @@ else if ($_POST['show_in_area']) { $q = new AreaQuery; $area = $q->findOneById($_POST['area_id']); - header(sprintf("Location: http%s://%s/%s/in/area/%s/%d%s", ($_SERVER['HTTPS']) ? "s" : "", $_SERVER['HTTP_HOST'], $module, urlencode($area->getName()), $_POST['area_id'], get_order_state_uri(get_order_state_mask()))); + header(sprintf("Location: http%s://%s/%s/in/area/%s/%d%s", ($_SERVER['HTTPS']) ? "s" : "", $_SERVER['HTTP_HOST'], $module, urlencode($area->getName()), $_POST['area_id'], get_order_state_query_uri(get_order_state_mask()))); exit; } else if ($_POST['show_in_city']) { $q = new CityQuery; $city = $q->findOneById($_POST['city_id']); - header(sprintf("Location: http%s://%s/%s/in/city/%s/%d%s", ($_SERVER['HTTPS']) ? "s" : "", $_SERVER['HTTP_HOST'], $module, urlencode($city->getName()), $_POST['city_id'], get_order_state_uri(get_order_state_mask()))); + header(sprintf("Location: http%s://%s/%s/in/city/%s/%d%s", ($_SERVER['HTTPS']) ? "s" : "", $_SERVER['HTTP_HOST'], $module, urlencode($city->getName()), $_POST['city_id'], get_order_state_query_uri(get_order_state_mask()))); exit; } @@ -111,9 +111,9 @@ echo "
Restrict to order states:\n"; for ($i = 0; $i < count($states); $i++) { - echo " $states[$i]\n"; + echo ">\n"; } echo "
\n"; } @@ -139,7 +139,7 @@ return $mask; } - function get_order_state_string($mask) { + function get_order_state_query_string($mask) { global $states; $selected = array(); @@ -151,13 +151,13 @@ return implode("+", $selected); } - function get_order_state_uri($mask) { + function get_order_state_query_uri($mask) { global $all_states; if (is_null($mask)) return ""; if ($mask == $all_states) return ""; - return "/state/" . get_order_state_string($mask); + return "/state/" . get_order_state_query_string($mask); } function show_order_areas_form($city_id = null) { @@ -167,9 +167,16 @@ return; } + $candidates = array(); + foreach ($areas as $area) { + if (! count(get_area_contacts($area->getId()))) continue; + $candidates[] = $area; + } + if (! count($candidates)) return; + echo "Show orders in area\n"; echo "\n"; @@ -185,9 +192,16 @@ return; } + $candidates = array(); + foreach ($cities as $city) { + if (! count(get_city_contacts($city->getId()))) continue; + $candidates[] = $city; + } + if (! count($candidates)) return; + echo "
Show orders in city\n"; echo "\n"; @@ -206,8 +220,7 @@ global $states, $parcel_sizes, $parcel_contents; if ($order) { - $q = new OrderStateQuery; - $order_state = $q->filterByOrderId($order->getId())->orderByUpdated('desc')->limit(1)->findOne(); + $order_state = get_order_state($order); if ($order_state) { $state = $order_state->getState(); $driver_id = $order_state->getDriverId(); @@ -215,7 +228,6 @@ } else $order = new Order; - /* Date. */ echo "
You must confirm deletion of order $id: " . $order->getDeleteLink(true) . "
\n"; + } + function delete_order($id = null) { if (! check_admin(1, "delete an order")) return; @@ -532,6 +562,7 @@ if (! count($order_states)) return; echo "\n"; foreach ($order_states as $order_state) { $date = $order_state->getUpdated(); @@ -543,19 +574,11 @@ if ($driver_id) $driver = get_contact_by_id($driver_id); else $driver = null; - /* XXX */ - $state = $order_state->getState(); - for ($i = 0; $i < count($states); $i++) { - if ((1 << $i) == $state) { - $state = $states[$i]; - break; - } - } - #$state = $states[$order_state->getState()]; - echo "
$username changed order to state $state"; + echo "$username changed order to state " . get_order_state_string($order_state) . ""; if ($driver) echo " for driver " . $driver->getDisplayname(); - echo " on $date.
\n"; + echo " on $date.