varstore = compact('contactTypes', 'contacts'); //pr($this->data); /********************************************************************** ********************************************************************** ********************************************************************** ********************************************************************** * Javascript */ function customerContactDiv($obj, $values = null, $primary = false) { $div = // BEGIN type-div '
' . "\n" . // BEGIN type-fieldset '
' . "\n" . 'Contact #%{id} (%{remove})' . "\n" . // BEGIN source-div '
' . "\n" . // BEGIN source-fieldset '
' . "\n" . //'Source' . "\n" . '' ; if (!isset($values)) { foreach (array('Existing', 'New') AS $sname) { $stype = strtolower($sname); $div .= '' . "\n" . ' ' . "\n" . ' '; } $div .= "

(Phone numbers / Addresses can be added later)"; } $div .= "\n"; if (isset($values)) { $div .= customerContactTypeDiv($obj, 'show', $values); } else { $div .= customerContactTypeDiv($obj, 'existing'); $div .= customerContactTypeDiv($obj, 'new'); } $div .= // END source-fieldset '

' . "\n" . // END source-div '
' . "\n" . // BEGIN contact-div '
element ('form_table', array('class' => "item contact entry", 'field_prefix' => 'Contact.%{id}.ContactsCustomer', 'fields' => array ( 'Customer.primary_contact_entry' => array ('name' => 'Primary Contact', 'label_attributes' => array('class' => null), 'no_prefix' => true, 'opts' => array ('type' => 'radio', 'options' => array('%{id}' => false), 'value' => ($primary ? '%{id}' : 'bogus-value-to-suppress-hidden-input'), ), 'after' => ("Check this button if this contact will be the primary" . " contact for this customer (there can be only one primary" . " contact"), ), 'type' => array ('label_attributes' => array('class' => 'required'), 'opts' => array ('options' => $obj->varstore['contactTypes'], 'selected' => (isset($values) ? $values['ContactsCustomer']['type'] : null), ), 'after' => "An actual tenant, or just an alternate contact?" ), 'comment' => array ('label_attributes' => array('class' => 'optional empty'), 'opts' => array ('value' => (isset($values) ? $values['ContactsCustomer']['comment'] : null), ), 'after' => "Optional: Comments on the relationship between this customer and this contact." ), ))) . "\n" . // END contact-div '
' . "\n" . // END type-fieldset '
' . "\n" . // END type-div '
' ; return $div; } function customerContactTypeDiv($obj, $stype, $values = null) { $element = 'form_table'; $class = $stype; if ($stype === 'existing') { $fields = array ('id' => array('name' => 'Contact', 'label_attributes' => array('class' => 'required empty'), 'opts' => array('options' => $obj->varstore['contacts']), 'after' => "Select the existing contact."), ); } elseif ($stype === 'new') { $fields = array ('last_name' => array('label_attributes' => array('class' => 'recommended empty'), 'after' => "Recommended."), 'first_name' => array('label_attributes' => array('class' => 'recommended empty'), 'after' => "Recommended."), 'middle_name' => array('label_attributes' => array('class' => 'optional empty'), 'after' => "Optional."), 'company_name' => array('name' => 'Company', 'label_attributes' => array('class' => 'optional empty'), 'after' => "Optional: Company name, if corporate contact."), 'display_name' => array('label_attributes' => array('class' => 'optional empty'), 'after' => "Optional with first/last name; Required otherwise."), 'id_federal' => array('name' => 'SSN', 'label_attributes' => array('class' => 'optional empty'), 'after' => "Optional: Social Security Number."), 'id_local' => array('name' => 'ID #', 'label_attributes' => array('class' => 'recommended empty'), 'after' => "Recommended: Driver's license, for example."), 'id_local_state' => array('name' => 'ID State', 'label_attributes' => array('class' => 'recommended empty'), 'after' => "Recommended: State which issued the ID."), /* 'id_local_exp' => array('name' => 'ID Expiration', */ /* 'opts' => array('empty' => true)), */ 'comment' => array('label_attributes' => array('class' => 'optional empty'), 'after' => "Optional: Comments about this contact."), ); } elseif ($stype === 'show') { $element = 'table'; $class = 'detail'; $column_class = array('field', 'value'); $rows = array(array('First Name', $values['first_name']), array('Last Name', $values['last_name']), array('Company', $values['company_name']), array('Comment', $values['comment'])); } else { die("\n\nInvalid stype ($stype)\n\n"); } return // BEGIN sourcetype-div '' . "\n" . ''; } ?> ' . "\n"; echo $form->create('Customer', array('action' => 'edit')) . "\n"; echo $form->input('id') . "\n"; echo($this->element ('form_table', array('class' => 'item customer detail', 'caption' => isset($this->data['Customer']) ? 'Edit Customer' : 'New Customer', 'fields' => array ('name' => array('label_attributes' => array('class' => 'optional empty'), 'after' => ("Optional: If this field is left blank, the" . " customer name will be set to the name of" . " the primary contact, below.")), 'comment' => array('label_attributes' => array('class' => 'optional empty'), 'after' => 'Optional: Comments about this customer.'), ))) . "\n"); echo $form->submit(isset($this->data['Customer']) ? 'Update' : 'Add New Customer') . "\n"; ?>
Contacts
Add a Contact
input("movein.Unit.id", array('type' => 'hidden', 'value' => $movein['Unit']['id'])) . "\n"; echo $form->submit(isset($this->data['Customer']) ? 'Update' : 'Add New Customer') . "\n"; echo $form->submit('Cancel', array('name' => 'cancel')) . "\n"; echo $form->end() . "\n"; echo '' . "\n";