Use form() and end_form() where appropriate.
Use standout and noprint classes to emphasise forms and to hide those
which don't show any information.
Ensure that all appropriate forms are shown once. Not never; not twice.
return;
}
- echo "<form method=\"POST\" action=\"" . $_SCRIPT['REQUEST_URI'] . "\">\n";
+ form("noprint standout");
echo "<p>Show areas in\n";
echo "<select name=\"city_id\">\n";
foreach ($cities as $city) {
}
echo "</select>\n";
echo "<input type=\"submit\" value=\"Show\">\n";
- echo "</form>\n";
+ end_form();
}
function show_new_area_form($city_id = null) {
return;
}
- echo "<form method=\"POST\" action=\"" . $_SERVER['REQUEST_URI'] . "\">\n";
+ form("noprint standout");
echo "<p>Add a new area <input name=\"area_name\">\n";
echo "in <select name=\"city_id\">\n";
}
echo "</select>\n";
echo "<input type=\"submit\" value=\"Add\">\n";
- echo "</form>\n";
+ end_form();
}
function add_area($name, $city_id) {
$area = get_area_by_name($name);
if (! $area) return;
- echo "<form method=\"POST\" action=\"" . $_SERVER['REQUEST_URI'] . "\">\n";
+ form();
echo "<p>Area: <span class=\"strong\">" . $area->getName() . "</span>";
$n = $area->getName();
$i = $area->getId();
echo "<input type=\"submit\" name=\"update_area\" value=\"Update\">\n";
}
echo "</p>\n";
- echo "</form>\n";
+ end_form();
}
/* /area/in/Cambridge/1 */
function show_new_city_form() {
if (! check_admin(1)) return;
- echo "<form method=\"POST\" action=\"" . $_SERVER['REQUEST_URI'] . "\">\n";
+ form("noprint standout");
echo "<p>Add a new city <input name=\"city_name\">\n";
echo "with postcode prefix <input name=\"city_postcode_area\" size=4 maxlength=4>\n";
echo "<input type=\"submit\" value=\"Add\"></p>\n";
}
}
else if (isset($name)) show_city($name, $id);
- else {
- show_cities(0, 10);
- show_new_city_form();
- }
+ else show_cities(0, 10);
+
+ if (count($parameters)) echo "<p class=\"noprint standout\">Show all <a href=\"/city\">cities</a></p>\n";
+ show_new_city_form();
# XXX: Format URL in branch case...
if (count($parameters))
return;
}
- echo "<form method=\"POST\" action=\"" . $_SERVER['REQUEST_URI'] . "\">\n";
echo "<p>Show contacts in area\n";
echo "<select name=\"area_id\">\n";
foreach ($areas as $area) {
}
echo "</select>\n";
echo "<input type=\"submit\" value=\"Show\">\n";
- echo "</form>\n";
}
function show_contact_cities_form($city_id = null) {
return;
}
- echo "<form method=\"POST\" action=\"" . $_SERVER['REQUEST_URI'] . "\">\n";
echo "<p>Show contacts in city\n";
echo "<select name=\"city_id\">\n";
foreach ($cities as $city) {
}
echo "</select>\n";
echo "<input type=\"submit\" value=\"Show\">\n";
- echo "</form>\n";
}
function show_contact_search_form() {
- echo "<form method=\"POST\" action=\"" . $_SERVER['REQUEST_URI'] . "\">\n";
echo "<p>Search for contacts:";
input("search_contact");
echo "<input type=\"submit\" value=\"Search\">\n";
- echo "</form>\n";
}
function show_contact_forms($city_id) {
+ form("noprint standout");
show_contact_areas_form($city_id);
show_contact_cities_form($city_id);
show_contact_search_form();
+ end_form();
}
function show_contact_role_form($role) {
return;
}
- echo "<form method=\"POST\" action=\"" . $_SERVER['REQUEST_URI'] . "\">\n";
+ form("noprint");
echo "<p>Add a new contact:</p>\n";
echo "<table>\n";
echo " <td colspan=2>"; submit("add_contact", "Add"); echo "</td></tr>\n";
echo "</tr>\n";
echo "</table>\n";
- echo "</form>\n";
+ end_form();
}
function show_add_new_contact_form() {
return;
}
- echo "<form method=\"POST\" action=\"" . $_SERVER['REQUEST_URI'] . "\">\n";
+ form("noprint standout");
echo "<p>Add a new contact in <select name=\"city_id\">\n";
foreach ($cities as $city) {
option("city_id", $city->getId(), get_city_displayname($city));
echo "</select>";
submit("show_add_contact", "Proceed");
echo "</p>\n";
- echo "</form>\n";
+ end_form();
}
function update_contact(&$contact, $area_id, $new = false) {
else $contact = get_contact_by_name($name);
if (! $contact) return;
- echo "<form method=\"POST\" action=\"" . $_SERVER['REQUEST_URI'] . "\">\n";
+ form();
show_contact_summary($contact, true);
echo ": ";
echo "\n</p>";
}
echo "</table>\n";
- echo "</form>\n";
+ end_form();
}
/* /contact/in/area/Cambridge/1 */
show_city_contacts(0, 10, $parameters[2], $city_id);
break;
}
-
- show_add_new_contact_form($city_id);
}
else if ($parameters[0] == "search") {
search_contacts(0, 10, $parameters[1]);
}
}
else if (isset($name)) show_contact($name, $id);
- else {
- /* XXX: Shown after adding. */
- show_contact_forms($city_id);
- show_add_new_contact_form($city_id);
- }
- if (count($parameters)) {
- show_contact_forms($city_id);
- }
+ show_contact_forms($city_id);
+ show_add_new_contact_form($city_id);
?>
return;
}
- echo "<form method=\"POST\" action=\"" . $_SERVER['REQUEST_URI'] . "\">\n";
echo "<p>Show donations in area\n";
echo "<select name=\"area_id\">\n";
foreach ($areas as $area) {
}
echo "</select>\n";
echo "<input type=\"submit\" value=\"Show\">\n";
- echo "</form>\n";
}
function show_donation_cities_form($city_id = null) {
return;
}
- echo "<form method=\"POST\" action=\"" . $_SERVER['REQUEST_URI'] . "\">\n";
echo "<p>Show donations in city\n";
echo "<select name=\"city_id\">\n";
foreach ($cities as $city) {
}
echo "</select>\n";
echo "<input type=\"submit\" value=\"Show\">\n";
- echo "</form>\n";
}
function show_donation_forms($city_id) {
+ form("noprint standout");
show_donation_areas_form($city_id);
show_donation_cities_form($city_id);
+ end_form();
}
function show_donation_form($donation = null, $area_id = null) {
return;
}
- echo "<form method=\"POST\" action=\"" . $_SERVER['REQUEST_URI'] . "\">\n";
+ form();
echo "<p>Record a donation:</p>\n";
echo "<table>\n";
echo " <td colspan=2>"; submit("add_donation", "Record"); echo "</td></tr>\n";
echo "</tr>\n";
echo "</table>\n";
- echo "</form>\n";
+ end_form();
}
function show_add_new_donation_form() {
return;
}
- echo "<form method=\"POST\" action=\"" . $_SERVER['REQUEST_URI'] . "\">\n";
+ form("noprint standout");
echo "<p>Record a donation in <select name=\"area_id\">\n";
foreach ($areas as $area) {
option("area_id", $area->getId(), get_area_displayname($area));
echo "</select>";
submit("show_add_donation", "Proceed");
echo "</p>\n";
- echo "</form>\n";
+ end_form();
}
function update_donation(&$donation, $new = false) {
if (isset($id)) $donation = get_donation_by_id($id);
if (! $donation) return;
- echo "<form method=\"POST\" action=\"" . $_SERVER['REQUEST_URI'] . "\">\n";
+ form();
echo "<p>Donation <span class=\"strong\">" . $donation->getId() . "</span>";
if (check_admin(1)) {
echo " " . $donation->getDeleteLink();
}
echo "</table>\n";
- echo "</form>\n";
+ end_form();
}
if (count($parameters)) {
}
}
else if (isset($id)) show_donation($id);
- else {
- /* XXX: Shown after adding. */
- show_donation_forms($city_id);
- show_add_new_donation_form($city_id);
- }
-
- if (count($parameters)) {
- show_donation_forms($city_id);
- }
+ show_donation_forms($city_id);
+ show_add_new_donation_form($city_id);
?>
return;
}
- echo "<form method=\"POST\" action=\"" . $_SERVER['REQUEST_URI'] . "\">\n";
echo "<p>Show hubs in area\n";
echo "<select name=\"area_id\">\n";
foreach ($areas as $area) {
}
echo "</select>\n";
echo "<input type=\"submit\" value=\"Show\">\n";
- echo "</form>\n";
}
function show_hub_cities_form($city_id = null) {
return;
}
- echo "<form method=\"POST\" action=\"" . $_SERVER['REQUEST_URI'] . "\">\n";
echo "<p>Show hubs in city\n";
echo "<select name=\"city_id\">\n";
foreach ($cities as $city) {
}
echo "</select>\n";
echo "<input type=\"submit\" value=\"Show\">\n";
- echo "</form>\n";
}
function show_hub_forms($city_id) {
+ form("noprint standout");
show_hub_areas_form($city_id);
show_hub_cities_form($city_id);
+ end_form();
}
function show_hub_role_form($role) {
return;
}
- echo "<form method=\"POST\" action=\"" . $_SERVER['REQUEST_URI'] . "\">\n";
+ form("noprint");
echo "<p>Add a new hub:</p>\n";
echo "<table>\n";
echo " <td colspan=2>"; submit("add_hub", "Add"); echo "</td></tr>\n";
echo "</tr>\n";
echo "</table>\n";
- echo "</form>\n";
+ end_form();
}
function show_add_new_hub_form() {
return;
}
- echo "<form method=\"POST\" action=\"" . $_SERVER['REQUEST_URI'] . "\">\n";
+ form("noprint standout");
echo "<p>Add a new hub in <select name=\"city_id\">\n";
foreach ($cities as $city) {
option("city_id", $city->getId(), get_city_displayname($city));
echo "</select>";
submit("show_add_hub", "Proceed");
echo "</p>\n";
- echo "</form>\n";
+ end_form();
}
function update_hub(&$hub, $area_id, $new = false) {
else $hub = get_hub_by_name($name);
if (! $hub) return;
- echo "<form method=\"POST\" action=\"" . $_SERVER['REQUEST_URI'] . "\">\n";
+ form();
show_hub_summary($hub, true);
echo ": ";
echo "\n</p>";
}
echo "</table>\n";
- echo "</form>\n";
+ end_form();
}
/* /hub/in/area/Cambridge/1 */
show_city_hubs(0, 10, $parameters[2], $city_id);
break;
}
-
- show_new_hub_form($city_id);
}
}
list($name, $id, $args) = parse_parameters($parameters);
}
}
else if (isset($name)) show_hub($name, $id);
- else {
- /* XXX: Shown after adding. */
- show_hub_forms($city_id);
- show_add_new_hub_form($city_id);
- }
- if (count($parameters)) {
- show_hub_forms($city_id);
- }
+ show_hub_forms($city_id);
+ show_add_new_hub_form($city_id);
?>
$orders = $q->orderByDate()->find();
if (count($orders)) {
foreach ($orders as $order) {
- echo "<br>\nOrder " . $order->getStrongLink($order->getId()) . ": " . get_order_displayname($order);
- if (check_admin(1)) {
- echo " " . $order->getDeleteLink();
- }
-
- /* XXX: Should pull from query. */
- $q = new ContactQuery;
- $contact = $q->findOneById($order->getBeneficiaryId());
- if ($contact) {
- echo " for " . $contact->getLink();
- $area = get_contact_area($contact);
- if ($area) echo " in " . $area->getLink();
- }
-
- if ($order->getHubId()) {
- $q = new HubQuery;
- $hub = $q->findOneById($order->getHubId());
- if ($hub) echo " to hub " . $hub->getLink();
- $area = get_hub_area($hub);
- if ($area) echo " in " . $area->getLink();
- }
+ echo "<br>\n" . get_order_summary($order) . "<br>\n";
}
}
else echo " none";
}
function show_order_forms($city_id, $state_mask) {
- echo "<form method=\"POST\" action=\"" . $_SERVER['REQUEST_URI'] . "\">\n";
+ form("noprint standout");
show_order_state_form($state_mask);
show_order_areas_form($city_id);
show_order_cities_form($city_id);
- echo "</form>\n";
+ end_form();
}
function show_order_form($order = null, $area_id = null) {
return;
}
- echo "<form method=\"POST\" action=\"" . $_SERVER['REQUEST_URI'] . "\">\n";
+ form("noprint");
echo "<p>Place an order:</p>\n";
echo "<table>\n";
echo " <td colspan=2>"; submit("add_order", "Order"); echo "</td></tr>\n";
echo "</tr>\n";
echo "</table>\n";
- echo "</form>\n";
+ end_form();
}
function show_contact_order_form($contact) {
$order = new Order;
$order->setBeneficiaryId($contact->getId());
- echo "<form method=\"POST\" action=\"" . $_SERVER['REQUEST_URI'] . "\">\n";
+ form("standout");
echo "<p>Placing order for " . $contact->getStrongLink() . ".";
$parcel = $contact->getParcel();
if ($parcel) {
echo " <td colspan=2>"; submit("add_order", "Order"); echo "</td></tr>\n";
echo "</tr>\n";
echo "</table>\n";
- echo "</form>\n";
+ end_form();
}
function show_add_new_order_form() {
return;
}
- echo "<form method=\"POST\" action=\"" . $_SERVER['REQUEST_URI'] . "\">\n";
+ form("noprint standout");
echo "<p>Place an order in <select name=\"area_id\">\n";
foreach ($areas as $area) {
option("area_id", $area->getId(), get_area_displayname($area));
echo "</select>";
submit("show_add_order", "Proceed");
echo "</p>\n";
- echo "</form>\n";
+ end_form();
}
function update_order(&$order, $new = false) {
if (isset($id)) $order = get_order_by_id($id);
if (! $order) return;
- echo "<form method=\"POST\" action=\"" . $_SERVER['REQUEST_URI'] . "\">\n";
+ form();
echo "<p>Order: <span class=\"strong\">" . $order->getId() . "</span>";
if (check_admin(1)) {
echo " " . $order->getDeleteLink();
}
echo "</table>\n";
- echo "</form>\n";
+ end_form();
show_order_history($order->getId());
}
}
else if (isset($id)) show_order($id);
else if ($state_mask) show_orders(0, 10, null, null, $state_mask);
- else {
- /* XXX: Shown after adding. */
- show_order_forms($city_id, $state_mask);
- show_add_new_order_form($city_id);
- }
- if (count($parameters)) {
- show_order_forms($city_id, $state_mask);
- }
+ show_order_forms($city_id, $state_mask);
+ show_add_new_order_form($city_id);
?>