X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;ds=inline;f=lib%2Fdelivery.php;h=9cdd3385e0ed814ea1a2d789923db78c1b2e386f;hb=refs%2Ftags%2Flive-2013-12-12;hp=dddf2a229b393e8349903a4affdb453d9690cb23;hpb=5f50c624101d671ec4147b3ad974c15178c6ebe5;p=readifood.git diff --git a/lib/delivery.php b/lib/delivery.php index dddf2a2..9cdd338 100644 --- a/lib/delivery.php +++ b/lib/delivery.php @@ -1,19 +1,33 @@ filterByDate(time('Y-m-d'))->find(); + $orders = $q->filterByDate($then)->find(); if (count($orders)) { foreach ($orders as $order) $order_ids[] = $order->getId(); } - else echo "
No deliveries today.
\n"; + else echo "No deliveries for $date.
\n"; return $order_ids; } + /* Find orders scheduled for delivery today. */ + function get_orders_for_today() { + return get_orders_for_date(date('Y-m-d'), time()); + } + /* Find drivers with deliveries today. */ function get_drivers_by_order_id($order_ids) { $driver_ids = array(); @@ -53,7 +67,7 @@ return $order_ids; } - function show_driver_forms($driver_ids) { + function show_driver_forms($driver_ids, $date = null) { global $module; if (! count($driver_ids)) return; @@ -65,13 +79,16 @@ return; } - echo "Drivers with deliveries scheduled:"; + echo "
Drivers with deliveries scheduled on ";
+ if ($date) echo $date;
+ else echo date('Y-m-d', time());
+ echo ":";
foreach ($contacts as $contact) {
- printf("
\n%s", urlencode($contact->getDisplayname()), $contact->getId(), htmlspecialchars($contact->getDisplayname()));
+ printf("
\n%s", ($date) ? "date/$date/" : "", urlencode($contact->getDisplayname()), $contact->getId(), htmlspecialchars($contact->getDisplayname()));
}
}
- function show_driver_schedule($driver_name = null, $driver_id = null) {
+ function show_driver_schedule($driver_name = null, $driver_id = null, $date = null) {
if (isset($driver_id)) $contact = get_contact_by_id($driver_id);
else if (isset($driver_name)) $contact = get_contact_by_name($driver_name);
if (! $contact) {
@@ -79,24 +96,61 @@
return;
}
- echo "
Order of " . get_order_parcel_string($order) . " for " . htmlspecialchars($contact->getDisplayname()) . " in " . htmlspecialchars(get_area_displayname($area)) . ".
\n"; $hub = get_hub_by_id($order->getHubId(), false); if ($hub) { echo "Deliver to hub " . htmlspecialchars($hub->getName()) . ""; $address = get_hub_address($hub); + $phone = $hub->getTelephone1(); + if ($phone) $phones[] = $phone; + $phone = $hub->getTelephone2(); + if ($phone) $phones[] = $phone; } else { echo "
Deliver direct to beneficiary";
$address = get_contact_address($contact);
+ $phone = $contact->getTelephone1();
+ if ($phone) $phones[] = $phone;
+ $phone = $contact->getTelephone2();
+ if ($phone) $phones[] = $phone;
}
$area = get_address_area($address);
@@ -105,18 +159,49 @@
echo "\n
" . htmlspecialchars($address->getLine());
echo "\n
" . htmlspecialchars($city->getName());
echo "\n
" . htmlspecialchars($address->getPostcode());
+ if (count($phones)) echo "\n
Telephone " . implode(" or ", $phones) . "";
echo "
Notes:\n"; + echo htmlspecialchars($notes); + echo "
\n"; + } + + echo "