<?php
if ($_POST['area_name']) {
+ set_last_selected("city_id", $_POST['city_id']);
$id = add_area($_POST['area_name'], $_POST['city_id']);
if ($id !== false) {
echo "<p>Added area.</p>\n";
}
}
else if ($_POST['city_id']) {
- /* XXX: city_id is actually a string $city_name/$city_id */
- header(sprintf("Location: http%s://%s/%s/in/city/%s", ($_SERVER['HTTPS']) ? "s" : "", $_SERVER['HTTP_HOST'], $module, $_POST['city_id']));
+ set_last_selected("city_id", $_POST['city_id']);
+ $city_id = $_POST['city_id'];
+ $city = get_city_by_id($city_id);
+ header(sprintf("Location: http%s://%s/%s/in/city/%s/%d", ($_SERVER['HTTPS']) ? "s" : "", $_SERVER['HTTP_HOST'], $module, $city->getName(), $city_id));
exit;
}
else if ($_POST['update_area']) {
update_area_delivery_days($parameters[0]);
}
- function show_areas($offset, $per_page, $city_name = null, $city_id = null) {
+ function show_areas($city_name = null, $city_id = null) {
+ list($first_page, $per_page) = pagination();
if (isset($city_name) || isset($city_id)) {
if (isset($city_id)) $city = get_city_by_id($city_id);
else if ($city_name) $city = get_city_by_name($city_name);
if ($city) {
echo "<p>Areas in " . $city->getLink(get_city_displayname($city)) . ":";
$q = new AreaQuery;
- $areas = $q->filterByCityId($city_id)->find();
+ $areas = $q->filterByCityId($city_id)->orderByName()->orderById()->paginate($first_page, $per_page);
if (count($areas)) {
foreach ($areas as $area) {
echo " " . $area->getDeleteLink();
}
}
+ show_pagination($areas);
}
else echo " none";
echo "</p>\n";
echo "<p>Show areas in\n";
echo "<select name=\"city_id\">\n";
foreach ($candidates as $city) {
- option("city_id", sprintf("%s/%s", $city->getName(), $city->getId()), get_city_displayname($city));
+ option("city_id", $city->getId(), get_city_displayname($city));
}
echo "</select>\n";
echo "<input type=\"submit\" value=\"Show\">\n";
echo "Delivery days:";
if (check_admin(1)) {
for ($i = 0; $i < count($week); $i++) {
- echo " <input type=\"checkbox\" name=\"day_$i\"";
+ echo " <input type=\"checkbox\" id=\"day_$i\" name=\"day_$i\"";
if ($days & (1 << $i)) echo " checked";
- echo ">$week[$i]\n";
+ echo "><label for=\"day_$i\">$week[$i]</label>\n";
}
}
else {
if ($parameters[0] == "in") {
if ($parameters[1] == "city") {
$city_id = $parameters[3];
- show_areas(0, 10, $parameters[2], $city_id);
+ show_areas($parameters[2], $city_id);
show_new_area_form($city_id);
}
}