varstore = compact('contactTypes', 'contacts');
//pr($this->data);
/**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
* Javascript
*/
function customerContactDiv($obj, $values = null, $primary = false) {
$div =
// BEGIN type-div
'
' . "\n" .
// BEGIN type-fieldset
'
' . "\n" .
// END type-fieldset
'' . "\n" .
// END type-div
''
;
return $div;
}
function customerContactTypeDiv($obj, $stype, $values = null) {
$element = 'form_table';
if ($stype === 'existing') {
$fields = array
('id' => array('name' => 'Contact',
'opts' => array('options' => $obj->varstore['contacts'])),
);
}
elseif ($stype === 'new') {
$fields = array
('first_name' => null,
'last_name' => null,
'middle_name' => null,
'display_name' => null,
'company_name' => array('name' => 'Company'),
'id_federal' => array('name' => 'SSN'),
'id_local' => array('name' => 'ID #'),
'id_local_state' => array('name' => 'ID State'),
/* 'id_local_exp' => array('name' => 'ID Expiration', */
/* 'opts' => array('empty' => true)), */
'comment' => null,
);
}
elseif ($stype === 'show') {
$element = 'table';
$column_class = array('field', 'value');
$rows = array(array('First Name', $values['first_name']),
//array('Middle Name', $values['middle_name']),
array('Last Name', $values['last_name']),
array('Company', $values['company_name']),
//array('SSN', $values['id_federal']),
/* array('ID', ($values['id_local'] */
/* . ($values['id_local'] */
/* ? " - ".$values['id_local_state'] */
/* : ""))), */
array('Comment', $values['comment']));
}
else {
die("\n\nInvalid stype ($stype)\n\n");
}
return
// BEGIN sourcetype-div
'' . "\n" .
$obj->element
($element,
array('class' => "item contact {$stype}",
'field_prefix' => 'Contact.%{id}')
+ compact('rows', 'fields', 'column_class')) .
($stype === 'show'
? '' . "\n"
: '') .
// END 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' => $this->data ? 'Edit Customer' : 'New Customer',
'fields' => array
('name' => null,
'comment' => null,
))) . "\n");
echo $form->submit('Update') . "\n";
?>
submit('Update') . "\n";
echo $form->submit('Cancel', array('name' => 'cancel')) . "\n";
echo $form->end() . "\n";
echo '' . "\n";