X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;ds=sidebyside;f=lib%2Ffunctions.php;h=73ea46443743007dd483b8a2d5d80bc6dd888516;hb=refs%2Ftags%2Fuat-2013-07-10;hp=8db2720fbcc1758ff1133fca5b59ece7faf8b533;hpb=46a6490756496e873962e54db2ad1b68921cd3c8;p=readifood.git
diff --git a/lib/functions.php b/lib/functions.php
index 8db2720..73ea464 100644
--- a/lib/functions.php
+++ b/lib/functions.php
@@ -257,8 +257,30 @@
return sprintf("%s on %s", get_order_parcel_string($order), $order->getDate());
}
+ function get_order_state_string($order_state = null) {
+ global $states;
+
+ if (is_null($order_state)) return null;
+
+ for ($i = 0; $i < count($states); $i++) {
+ if ($order_state->getState() & (1 << $i)) {
+ return $states[$i];
+ }
+ }
+
+ return "unknown";
+ }
+
+ function get_order_state($order) {
+ $q = new OrderStateQuery();
+ return $q->filterByOrderId($order->getId())->orderByUpdated('desc')->findOne();
+ }
+
function get_order_summary($order) {
- $ret = "Order " . $order->getStrongLink($order->getId()) . ": " . get_order_displayname($order);
+ $ret = "Order ";
+ $order_state = get_order_state($order);
+ if ($order_state) $ret = "" . ucfirst(get_order_state_string($order_state)) . " order ";
+ $ret .= $order->getStrongLink($order->getId()) . ": " . get_order_displayname($order);
if (check_admin(1)) $ret .= " " . $order->getDeleteLink();
@@ -295,6 +317,13 @@
return $q->findOneById($address->getAreaId());
}
+ function get_address_map_link($address) {
+ $postcode = trim($address->getPostcode());
+ if ($postcode) {
+ return " " . get_small_link("Map", "http://maps.google.co.uk/maps?q=" . urlencode($postcode));
+ }
+ }
+
function get_contact_address($contact) {
$q = new AddressQuery;
return $q->findOneById($contact->getAddressId());