From e7862268051db4ebdc89d4514b62910da133d19c Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Thu, 18 Apr 2013 12:10:25 -0400 Subject: [PATCH] Record contacts' preferred parcel type. Specify family unit and dietary requirements for a contact by reusing parcel flags. --- lib/contact.php | 33 +++++++++++++++++++++++++++++++-- lib/functions.php | 5 +++++ propel/schema.xml | 1 + 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/lib/contact.php b/lib/contact.php index ef8c335..8ba1fcd 100644 --- a/lib/contact.php +++ b/lib/contact.php @@ -177,7 +177,7 @@ } function show_contact_form($contact = null, $new = false) { - global $contact_roles; + global $contact_roles, $parcel_sizes, $parcel_contents; if (! $contact) $contact = new Contact; @@ -262,6 +262,30 @@ echo " \n"; echo "\n"; + /* Parcel type. */ + echo "\n"; + echo " Family unit\n"; + echo " \n"; + echo "\n"; + + /* Parcel contents. */ + echo "\n"; + echo " Dietary requirements\n"; + echo " "; + for ($i = count($parcel_sizes); $i < count($parcel_contents); $i++) { + if (1 << $i == $GLOBALS['PARCEL_TOILETRY']) continue; + echo " getParcel() & (1 << $i)) echo " checked"; + echo ">$parcel_contents[$i]\n"; + } + echo "\n"; + echo "\n"; + /* Notes. */ echo "\n"; echo " Notes\n"; @@ -313,7 +337,7 @@ } function update_contact(&$contact, $area_id, $new = false) { - global $contact_roles; + global $contact_roles, $parcel_sizes, $parcel_contents; $role = 0; for ($i = 0; $i < count($contact_roles); $i++) { @@ -371,6 +395,10 @@ $telephone1 = $_POST['telephone1']; $telephone2 = $_POST['telephone2']; $email = $_POST['email']; + $parcel = $_POST['parcel_size']; + for ($i = count($parcel_sizes); $i < count($parcel_contents); $i++) { + if ($_POST['parcel_' . $i] == "on") $parcel |= (1 << $i); + } $notes = $_POST['notes']; $contact->setRole($role); @@ -381,6 +409,7 @@ $contact->setTelephone1($telephone1); $contact->setTelephone2($telephone2); $contact->setEmail($email); + $contact->setParcel($parcel); $contact->setNotes($notes); $contact->setAddressId($address->getId()); diff --git a/lib/functions.php b/lib/functions.php index 3727a65..20fdd7b 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -246,6 +246,11 @@ return get_area_city($area); } + /* Parcel strings are the same so this can work. */ + function get_contact_parcel_string($contact) { + return get_order_parcel_string($contact); + } + /* Hub and Contact are similar enough that this can work. */ function get_hub_address($hub) { return get_contact_address($hub); diff --git a/propel/schema.xml b/propel/schema.xml index 1f423dd..7d7e6c0 100644 --- a/propel/schema.xml +++ b/propel/schema.xml @@ -62,6 +62,7 @@ + -- 2.7.4