X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;ds=sidebyside;f=lib%2Forder.php;h=95d96bb859e0db9a908779aafd3b5fe9aae8a6a8;hb=46a6490756496e873962e54db2ad1b68921cd3c8;hp=69026bfcde75668b5c0bc52ac4bdb1a9e5bf172b;hpb=48175505d7f95be28b778fbca3826e34ba505cde;p=readifood.git
diff --git a/lib/order.php b/lib/order.php
index 69026bf..95d96bb 100644
--- a/lib/order.php
+++ b/lib/order.php
@@ -50,27 +50,7 @@
$orders = $q->orderByDate()->find();
if (count($orders)) {
foreach ($orders as $order) {
- echo "
\nOrder " . $order->getStrongLink($order->getId()) . ": " . get_order_displayname($order);
- if (check_admin(1)) {
- echo " " . $order->getDeleteLink();
- }
-
- /* XXX: Should pull from query. */
- $q = new ContactQuery;
- $contact = $q->findOneById($order->getBeneficiaryId());
- if ($contact) {
- echo " for " . $contact->getLink();
- $area = get_contact_area($contact);
- if ($area) echo " in " . $area->getLink();
- }
-
- if ($order->getHubId()) {
- $q = new HubQuery;
- $hub = $q->findOneById($order->getHubId());
- if ($hub) echo " to hub " . $hub->getLink();
- $area = get_hub_area($hub);
- if ($area) echo " in " . $area->getLink();
- }
+ echo "
\n" . get_order_summary($order) . "
\n";
}
}
else echo " none";
@@ -215,11 +195,11 @@
}
function show_order_forms($city_id, $state_mask) {
- echo "
\n";
+ end_form();
}
function show_order_form($order = null, $area_id = null) {
@@ -259,7 +239,10 @@
foreach ($contacts as $contact) {
option("requester_id", $contact->getId(), $contact->getDisplayname(), $order->getRequesterId());
}
- echo "\n";
+ echo "";
+ $contact = get_contact_by_id($order->getRequesterId(), false);
+ if ($contact) echo " " . get_small_link($contact->getDisplayname(), $contact->getURL());
+ echo "\n";
echo "\n";
/* Beneficiary. */
@@ -277,7 +260,10 @@
option("beneficiary_id", $contact->getId(), $contact->getDisplayname(), $order->getBeneficiaryId());
}
}
- echo "\n";
+ echo "";
+ $contact = get_contact_by_id($order->getBeneficiaryId(), false);
+ if ($contact) echo " " . get_small_link($contact->getDisplayname(), $contact->getURL());
+ echo "\n";
echo "\n";
/* Hub. */
@@ -289,7 +275,10 @@
foreach ($hubs as $hub) {
option("hub_id", $hub->getId(), $hub->getDisplayname(), $order->getHubId());
}
- echo "\n";
+ echo "";
+ $hub = get_hub_by_id($order->getHubId(), false);
+ if ($hub) echo " " . get_small_link($hub->getDisplayname(), $hub->getURL());
+ echo "\n";
echo "\n";
/* Parcel type. */
@@ -325,7 +314,10 @@
foreach ($contacts as $contact) {
option("driver_id", $contact->getId(), $contact->getDisplayname(), $driver_id);
}
- echo "\n";
+ echo "";
+ $contact = get_contact_by_id($driver_id, false);
+ if ($contact) echo " " . get_small_link($contact->getDisplayname(), $contact->getURL());
+ echo "\n";
}
else echo " No drivers! | \n";
echo "\n";
@@ -352,7 +344,7 @@
return;
}
- echo "\n";
+ end_form();
}
function show_contact_order_form($contact) {
@@ -377,7 +369,7 @@
$order = new Order;
$order->setBeneficiaryId($contact->getId());
- echo "\n";
+ end_form();
}
function show_add_new_order_form() {
@@ -406,7 +398,7 @@
return;
}
- echo "\n";
+ end_form();
}
function update_order(&$order, $new = false) {
@@ -540,6 +532,7 @@
if (! count($order_states)) return;
echo "Order history
\n";
+ echo "\n";
foreach ($order_states as $order_state) {
$date = $order_state->getUpdated();
@@ -560,17 +553,18 @@
}
}
#$state = $states[$order_state->getState()];
- echo "
$username changed order to state $state";
+ echo "$username changed order to state $state";
if ($driver) echo " for driver " . $driver->getDisplayname();
- echo " on $date.
\n";
+ echo " on $date.
\n";
}
+ echo "\n";
}
function show_order(&$id = null) {
if (isset($id)) $order = get_order_by_id($id);
if (! $order) return;
- echo "\n";
+ end_form();
show_order_history($order->getId());
}
@@ -670,15 +664,9 @@
}
else if (isset($id)) show_order($id);
else if ($state_mask) show_orders(0, 10, null, null, $state_mask);
- else {
- /* XXX: Shown after adding. */
- show_order_forms($city_id, $state_mask);
- show_add_new_order_form($city_id);
- }
- if (count($parameters)) {
- show_order_forms($city_id, $state_mask);
- }
+ show_order_forms($city_id, $state_mask);
+ show_add_new_order_form($city_id);
?>