jQuery 3.6.1.
[readifood.git] / lib / delivery.php
index 3b45558..574094a 100644 (file)
 
     $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 "<h4>$count orders</h4>";
+      echo "<p class=\"noprint\">Drag delivery details to reorder the schedule.</p>\n";
+      echo "<div class=\"sortable\">\n";
+    }
+          else echo "<h4>1 order</h4>";
+
     foreach ($orders as $order) {
       $contact = get_contact_by_id($order->getBeneficiaryId());
       if (! $contact) continue;
 
+      echo "<div class=\"delivery\">";
+
       $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";
       }
       $area = get_address_area($address);
 
-      echo " in " . htmlspecialchars($area->getName()) . " at:<br>";
+      echo " in " . htmlspecialchars($area->getName()) . " at:";
       $city = get_area_city($area);
-      echo "\n<br>" . htmlspecialchars($address->getLine());
-      echo "\n<br>" . htmlspecialchars($city->getName());
-      echo "\n<br>" . htmlspecialchars($address->getPostcode());
-      if (count($phones)) echo "\n<br><br>Telephone <strong>" . implode(" or ", $phones) . "</strong>";
+      echo "\n" . htmlspecialchars($address->getLine());
+      echo ",\n" . htmlspecialchars($address->getPostcode());
+      if (count($phones)) echo ";\nTelephone <strong>" . implode(" or ", $phones) . "</strong>";
       echo "</p>\n";
 
       $notes = $order->getNotes();
         echo "</p>\n";
       }
 
-      echo "<hr>\n\n";
+      echo "<hr>\n";
+      echo "</div>\n\n";
     }
+
+    if ($count > 1) echo "</div>\n";
   }
 
   function show_delivery_date_form($date = null) {