return $order;
}
+ function get_order_ids_by_state($state_mask) {
+ $order_ids = array();
+ $dbh = Propel::getConnection();
+ $sth = $dbh->prepare("select * from OrderState o where updated=(select max(updated) from OrderState where order_id=o.order_id) and state & $state_mask");
+ $sth->execute();
+ $order_states = OrderStatePeer::populateObjects($sth);
+ foreach ($order_states as $order_state) $order_ids[] = $order_state->getOrderId();
+ return $order_ids;
+ }
+
function get_user_by_contact_id($id, $verbose = true) {
$q = new UserQuery;
$user = $q->findOneByContactId($id);
function show_orders($offset, $per_page, $requester_ids = null, $beneficiary_ids = null, $state_mask = null) {
/* XXX: Use Propel methods. */
- if (isset($state_mask)) {
- $order_ids = array();
- $dbh = Propel::getConnection();
- $sth = $dbh->prepare("select * from OrderState o where updated=(select max(updated) from OrderState where order_id=o.order_id) and state & $state_mask");
- $sth->execute();
- $order_states = OrderStatePeer::populateObjects($sth);
- foreach ($order_states as $order_state) $order_ids[] = $order_state->getOrderId();
- }
+ if (isset($state_mask)) $order_ids = get_order_ids_by_state($state_mask);
$q = new OrderQuery;
if (isset($requester_ids)) $q->filterByRequesterId($requester_ids);
if (isset($beneficiary_ids)) $q->filterByBeneficiaryId($beneficiary_ids);