From: Iain Patterson Date: Thu, 12 Dec 2013 18:15:05 +0000 (-0500) Subject: Allow reordering the delivery list. X-Git-Tag: 2013-12-12^0 X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=f181270af10ecded4b40d9ad3f838216835eb5f4;hp=-c;p=readifood.git Allow reordering the delivery list. Delivery details are retrieved from the database in an undefined order. They can now be dragged and dropped to reorder into a schedule which is more convenient for a driver to read. --- f181270af10ecded4b40d9ad3f838216835eb5f4 diff --git a/lib/delivery.php b/lib/delivery.php index 3b45558..9cdd338 100644 --- a/lib/delivery.php +++ b/lib/delivery.php @@ -109,10 +109,29 @@ $q = new OrderQuery; $orders = $q->filterById(get_driver_schedule_by_order_id($contact->getId(), $order_ids))->find(); + + /* + Only allow drag and drop if there's more than one order otherwise IE will + mess up the CSS. + */ + $count = count($orders); + if ($count) { + foreach ($orders as $order) { + if (! get_contact_by_id($order->getBeneficiaryId())) $count--; + } + } + + if ($count > 1) { + echo "
\n"; + echo "

Drag delivery details to reorder the schedule.

\n"; + } + foreach ($orders as $order) { $contact = get_contact_by_id($order->getBeneficiaryId()); if (! $contact) continue; + echo "\n"; + $phones = array(); $area = get_contact_area($contact); echo "

Order of " . get_order_parcel_string($order) . " for " . htmlspecialchars($contact->getDisplayname()) . " in " . htmlspecialchars(get_area_displayname($area)) . ".

\n"; @@ -150,8 +169,11 @@ echo "

\n"; } - echo "
\n\n"; + echo "
\n"; + echo "
\n\n"; } + + if ($count > 1) echo "
\n"; } function show_delivery_date_form($date = null) { diff --git a/lib/header.php b/lib/header.php index e8b89da..1451a04 100644 --- a/lib/header.php +++ b/lib/header.php @@ -7,6 +7,7 @@ echo "\n"; ?> + diff --git a/www/jquery.sortable.js b/www/jquery.sortable.js new file mode 100644 index 0000000..3e59fe6 --- /dev/null +++ b/www/jquery.sortable.js @@ -0,0 +1,11 @@ +$(function() { + $(".sortable").sortable({ + axis: "y", + containment: "parent", + placeholder: "sortplaceholder", + forcePlaceholderSize: true, + start: function( event, ui ) { ui.item.addClass('sortdragging'); }, + stop: function( event, ui ) { ui.item.removeClass('sortdragging'); }, + }); + $(".sortable").disableSelection(); +}); diff --git a/www/style.css b/www/style.css index 79f7f55..96c3cda 100644 --- a/www/style.css +++ b/www/style.css @@ -108,3 +108,27 @@ table.report > * > tr > td { height: 375px; background: #eeeeee; } + +.sortdragging { + border-color: black; + border-width: 1px; + border-style: solid; + border-radius: 0.5em; + padding-bottom: 1em; + background: #eeeeee; +} + +span.sortdragging hr { + display: none; +} + +.sortplaceholder { + border-color: black; + border-width: 1px; + border-style: dotted; + border-radius: 0.5em; + background: #ffffee; + height: 2em; + position: absolute; +} +