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.
$q = new OrderQuery;
$orders = $q->filterById(get_driver_schedule_by_order_id($contact->getId(), $order_ids))->find();
$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 "<div class=\"sortable\">\n";
+ echo "<p class=\"noprint\">Drag delivery details to reorder the schedule.</p>\n";
+ }
+
foreach ($orders as $order) {
$contact = get_contact_by_id($order->getBeneficiaryId());
if (! $contact) continue;
foreach ($orders as $order) {
$contact = get_contact_by_id($order->getBeneficiaryId());
if (! $contact) continue;
$phones = array();
$area = get_contact_area($contact);
echo "<p>Order of <em>" . get_order_parcel_string($order) . "</em> for <strong>" . htmlspecialchars($contact->getDisplayname()) . "</strong> in " . htmlspecialchars(get_area_displayname($area)) . ".</p>\n";
$phones = array();
$area = get_contact_area($contact);
echo "<p>Order of <em>" . get_order_parcel_string($order) . "</em> for <strong>" . htmlspecialchars($contact->getDisplayname()) . "</strong> in " . htmlspecialchars(get_area_displayname($area)) . ".</p>\n";
+ echo "<hr>\n";
+ echo "</span>\n\n";
+
+ if ($count > 1) echo "</div>\n";
}
function show_delivery_date_form($date = null) {
}
function show_delivery_date_form($date = null) {
echo "<script src=\"$http://code.jquery.com/ui/1.10.3/jquery-ui.js\"></script>\n";
?>
<script src="/jquery.autosize.js"></script>
echo "<script src=\"$http://code.jquery.com/ui/1.10.3/jquery-ui.js\"></script>\n";
?>
<script src="/jquery.autosize.js"></script>
+<script src="/jquery.sortable.js"></script>
--- /dev/null
+$(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();
+});
height: 375px;
background: #eeeeee;
}
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;
+}
+