Fix driver display in order form.
authorIain Patterson <me@iain.cx>
Wed, 10 Apr 2013 21:39:37 +0000 (17:39 -0400)
committerIain Patterson <me@iain.cx>
Wed, 10 Apr 2013 21:39:37 +0000 (17:39 -0400)
Drivers were being correctly recorded but not always correctly displayed
when viewing existing orders.

lib/order.php

index 12a34aa..a392f6e 100644 (file)
     if ($order) {
       $q = new OrderStateQuery;
       $order_state = $q->filterByOrderId($order->getId())->orderByUpdated('desc')->limit(1)->findOne();
-      if ($order_state) $state = $order_state->getState();
+      if ($order_state) {
+        $state = $order_state->getState();
+        $driver_id = $order_state->getDriverId();
+      }
     }
     else $order = new Order;
 
 
       $driver_id = $order_state->getDriverId();
       if ($driver_id) $driver = get_contact_by_id($driver_id);
+      else $driver = null;
 
       /* XXX */
       $state = $order_state->getState();