}
function show_contact_form($contact = null, $new = false) {
- global $contact_roles;
+ global $contact_roles, $parcel_sizes, $parcel_contents;
if (! $contact) $contact = new Contact;
echo " </select></td>\n";
echo "</tr>\n";
+ /* Parcel type. */
+ echo "<tr>\n";
+ echo " <td>Family unit</td>\n";
+ echo " <td><select name=\"parcel_size\">\n";
+ $mask = 1 << (count($parcel_sizes) + 1);
+ for ($i = 0; $i < count($parcel_sizes); $i++) {
+ option("parcel_size", $i << 1, $parcel_sizes[$i], $contact->getParcel() % $mask);
+ }
+ echo "</select></td>\n";
+ echo "</tr>\n";
+
+ /* Parcel contents. */
+ echo "<tr>\n";
+ echo " <td>Dietary requirements</td>\n";
+ echo " <td>";
+ for ($i = count($parcel_sizes); $i < count($parcel_contents); $i++) {
+ if (1 << $i == $GLOBALS['PARCEL_TOILETRY']) continue;
+ echo " <input type=\"checkbox\" name=\"parcel_$i\"";
+ if ($contact->getParcel() & (1 << $i)) echo " checked";
+ echo ">$parcel_contents[$i]\n";
+ }
+ echo "</td>\n";
+ echo "</tr>\n";
+
/* Notes. */
echo "<tr>\n";
echo " <td>Notes</td>\n";
}
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++) {
$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);
$contact->setTelephone1($telephone1);
$contact->setTelephone2($telephone2);
$contact->setEmail($email);
+ $contact->setParcel($parcel);
$contact->setNotes($notes);
$contact->setAddressId($address->getId());
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);
<column name="telephone1" type="varchar" size="32" required="true"/>
<column name="telephone2" type="varchar" size="32" required="true"/>
<column name="email" type="varchar" size="64" required="true"/>
+ <column name="parcel" type="integer"/>
<column name="notes" type="longvarchar" lazyLoad="true"/>
<foreign-key foreignTable="Address" phpName="Address" refPhpName="Contact">
<reference local="address_id" foreign="id"/>