+
+ /* Get orders. */
+ $order_ids = array();
+ /* XXX: Order 51 changed to state delivered in May then updated in June. */
+ $dbh = Propel::getConnection();
+ $sth = $dbh->prepare("select * from OrderState o where updated=(select min(updated) from OrderState where order_id=o.order_id and state & " . $GLOBALS['STATE_DELIVERED'] . ") and updated between '$from' and '$to'");
+ $sth->execute();
+ $order_states = OrderStatePeer::populateObjects($sth);
+ foreach ($order_states as $order_state) $order_ids[] = $order_state->getOrderId();
+ $q = new OrderQuery;
+ $q->filterById($order_ids);
+
+ if (! count($order_ids)) {
+ echo "<p>No results!</p>\n";
+ return;
+ }
+
+ show_requester_report($order_ids);