X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;ds=sidebyside;f=lib%2Farea.php;h=fbf739d0aae041bdb9c478dff41044b3167c476e;hb=44602fdbde624186066be0f824e97c822679bc01;hp=8872a43308975cd3746d48931e909b5a2bd4f35c;hpb=56f5e034aebe1b00dbd1cc976fd165d03420c632;p=readifood.git diff --git a/lib/area.php b/lib/area.php index 8872a43..fbf739d 100644 --- a/lib/area.php +++ b/lib/area.php @@ -1,6 +1,7 @@ Added area.
\n"; @@ -8,22 +9,25 @@ } } 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 "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) { @@ -37,6 +41,7 @@ echo " " . $area->getDeleteLink(); } } + show_pagination($areas); } else echo " none"; echo "
\n"; @@ -64,7 +69,7 @@ echo "Show areas in\n"; echo "\n"; echo "\n"; @@ -131,9 +136,9 @@ echo "Delivery days:"; if (check_admin(1)) { for ($i = 0; $i < count($week); $i++) { - echo " $week[$i]\n"; + echo ">\n"; } } else { @@ -242,7 +247,7 @@ 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); } }