From: Iain Patterson Date: Mon, 13 May 2013 08:50:21 +0000 (-0400) Subject: Split get_contact_orders(). X-Git-Tag: 2013-05-13~12 X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=46a6490756496e873962e54db2ad1b68921cd3c8;p=readifood.git Split get_contact_orders(). Added get_beneficiary_orders() and get_requester_orders() to show orders for which a given Contact is a beneficiary or requester. Reworked get_contact_orders() to show orders of either type. --- diff --git a/lib/functions.php b/lib/functions.php index ecaf2ad..8db2720 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -185,13 +185,27 @@ return $order_ids; } - function get_contact_orders($contact, $state_mask = null) { + function get_beneficiary_orders($contact, $state_mask = null) { $q = new OrderQuery; $q->filterByBeneficiaryId($contact->getId()); if ($state_mask) $q->filterById(get_order_ids_by_state($state_mask)); return $q->orderByDate()->find(); } + function get_requester_orders($contact, $state_mask = null) { + $q = new OrderQuery; + $q->filterByRequesterId($contact->getId()); + if ($state_mask) $q->filterById(get_order_ids_by_state($state_mask)); + return $q->orderByDate()->find(); + } + + function get_contact_orders($contact, $state_mask = null) { + $q = new OrderQuery; + $q->filterByBeneficiaryId($contact->getId())->_or()->filterByRequesterId($contact->getId()); + if ($state_mask) $q->filterById(get_order_ids_by_state($state_mask)); + return $q->orderByDate()->find(); + } + function get_user_by_contact_id($id, $verbose = true) { $q = new UserQuery; $user = $q->findOneByContactId($id);