Allow reordering the delivery list.
[readifood.git] / lib / order.php
index d48f214..6c75211 100644 (file)
 
     echo "<p>Restrict to order states:\n";
     for ($i = 0; $i < count($states); $i++) {
-      echo " <input type=\"checkbox\" name=\"state_$i\"";
+      echo " <input type=\"checkbox\" id=\"state_$i\" name=\"state_$i\"";
       if ($state_mask & (1 << $i)) echo " checked";
-      echo ">$states[$i]\n";
+      echo "><label for=\"state_$i\">$states[$i]</label>\n";
     }
     echo "</p>\n";
   }
     echo "  <td>Parcel contents</td>\n";
     echo "  <td>";
     for ($i = count($parcel_sizes); $i < count($parcel_contents); $i++) {
-      echo "  <input type=\"checkbox\" name=\"parcel_$i\"";
+      echo "  <input type=\"checkbox\" id=\"parcel_$i\" name=\"parcel_$i\"";
       if ($order->getParcel() & (1 << $i)) echo " checked";
-      echo ">$parcel_contents[$i]\n";
+      echo "><label for=\"parcel_$i\">$parcel_contents[$i]</label>\n";
     }
     echo "</td>\n";
     echo "</tr>\n";
       echo "  <td>State</td>\n";
       echo "  <td><select name=\"state\">\n";
       for ($i = 0; $i < count($states); $i++) {
-        option("state", $i << 1, ucfirst($states[$i]), $state);
+        option("state", 1 << $i, ucfirst($states[$i]), $state);
       }
       echo "</select></td>\n";
       echo "</tr>\n";
     return $order->getId();
   }
 
+  function confirm_delete_order($id = null) {
+    if (! check_admin(1, "delete an order")) return;
+
+    if (isset($id)) $order = get_order_by_id($id);
+    if (! $order) return false;
+
+    echo "<h3>Confirm deletion</h3>\n";
+    echo "<p>You must confirm deletion of order $id: " . $order->getDeleteLink(true) . "</p>\n";
+  }
+
   function delete_order($id = null) {
     if (! check_admin(1, "delete an order")) return;
 
   if (count($args)) {
     switch ($args[0]) {
       case "delete":
+        confirm_delete_order($id);
+      break;
+
+      case "confirmdelete":
         delete_order($id);
       break;
     }