From: Iain Patterson Date: Mon, 13 May 2013 09:57:02 +0000 (-0400) Subject: Added get_order_state() and get_order_state_string(). X-Git-Tag: 2013-05-13~7 X-Git-Url: http://git.iain.cx/?p=readifood.git;a=commitdiff_plain;h=7840fb6e5f99fcc6c9b25e05c6f40d73137f6d79 Added get_order_state() and get_order_state_string(). Return an order state with get_order_state(). Return a string representation of an order state with get_order_state_string(). --- diff --git a/lib/functions.php b/lib/functions.php index 8db2720..2b35663 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -257,6 +257,25 @@ 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);