Got the existing contact phone numbers to populate correctly. I've chosen to disallow editing of these numbers, since a) it's tricky to do this in place, and b) it will be too confusing at the moment to handle this on a separate page, and c) I don't want to implement a modal ajax box at the moment, and d) doing so would probably be a user error liability, since folks would choose to edit a shared number instead of adding a new one when the situation would warrant the latter.
git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629/site@212 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -124,14 +124,18 @@ class ContactsController extends AppController {
|
||||
|
||||
$phone_types = array_flip($this->Contact->ContactPhone->getEnumValues('type'));
|
||||
unset($phone_types[0]);
|
||||
//$phone_types = array_combine($phone_types, array_map('ucfirst', array_map('strtolower', $phone_types)));
|
||||
$phone_types = array_combine($phone_types, $phone_types);
|
||||
$this->set(compact('phone_types'));
|
||||
|
||||
$method_types = array_flip($this->Contact->getEnumValues('type', 'pmgr_contacts_methods'));
|
||||
unset($method_types[0]);
|
||||
$method_types = array_combine($method_types, $method_types);
|
||||
$this->set(compact('method_types'));
|
||||
|
||||
$method_preferences = array_flip($this->Contact->getEnumValues('preference', 'pmgr_contacts_methods'));
|
||||
unset($method_preferences[0]);
|
||||
$method_preferences = array_combine($method_preferences, $method_preferences);
|
||||
$this->set(compact('method_preferences'));
|
||||
|
||||
$contact_phones = $this->Contact->ContactPhone->phoneList();
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
$this->varstore = compact('methodTypes', 'methodPreferences',
|
||||
'contactPhones', 'phoneTypes');
|
||||
|
||||
//pr($this->data);
|
||||
/**********************************************************************
|
||||
**********************************************************************
|
||||
**********************************************************************
|
||||
@@ -48,9 +49,10 @@ function contactMethodDiv($obj, $type, $legend, $values = null) {
|
||||
' ';
|
||||
}
|
||||
}
|
||||
$div .= "\n";
|
||||
|
||||
if (isset($values)) {
|
||||
$div .= contactMethodTypeDiv($obj, $type, 'edit', $values);
|
||||
$div .= contactMethodTypeDiv($obj, $type, 'show', $values);
|
||||
}
|
||||
else {
|
||||
$div .= contactMethodTypeDiv($obj, $type, 'existing');
|
||||
@@ -71,9 +73,24 @@ function contactMethodDiv($obj, $type, $legend, $values = null) {
|
||||
array('class' => "item contact-{$type} entry",
|
||||
'field_prefix' => 'Contact'.ucfirst($type).'.%{id}.Method',
|
||||
'fields' => array
|
||||
('type' => array('opts' => array('options' => $obj->varstore['methodTypes'])),
|
||||
'preferences' => array('opts' => array('options' => $obj->varstore['methodPreferences'])),
|
||||
'comment' => null,
|
||||
|
||||
('type' => array
|
||||
('opts' => array
|
||||
('options' => $obj->varstore['methodTypes'],
|
||||
'selected' => (isset($values) ? $values['ContactsMethod']['type'] : null),
|
||||
)),
|
||||
|
||||
'preferences' => array
|
||||
('opts' => array
|
||||
('options' => $obj->varstore['methodPreferences'],
|
||||
'selected' => (isset($values) ? $values['ContactsMethod']['preference'] : null),
|
||||
)),
|
||||
|
||||
'comment' => array
|
||||
('opts' => array
|
||||
('value' => (isset($values) ? $values['ContactsMethod']['comment'] : null),
|
||||
)),
|
||||
|
||||
))) . "\n" .
|
||||
|
||||
// END method-div
|
||||
@@ -90,6 +107,8 @@ function contactMethodDiv($obj, $type, $legend, $values = null) {
|
||||
|
||||
function contactMethodTypeDiv($obj, $type, $stype, $values = null) {
|
||||
|
||||
$element = 'form_table';
|
||||
|
||||
if ($type === 'phone') {
|
||||
if ($stype === 'existing') {
|
||||
$fields = array
|
||||
@@ -97,14 +116,24 @@ function contactMethodTypeDiv($obj, $type, $stype, $values = null) {
|
||||
'opts' => array('options' => $obj->varstore['contactPhones'])),
|
||||
);
|
||||
}
|
||||
elseif ($stype === 'new' || $stype === 'edit') {
|
||||
elseif ($stype === 'new') {
|
||||
$fields = array
|
||||
('type' => array('opts' => array('options' => $obj->varstore['phoneTypes'])),
|
||||
'phone' => null, //array('opts' => array('value' => )),
|
||||
'phone' => null,
|
||||
'ext' => array('name' => "Extension"),
|
||||
'comment' => null,
|
||||
);
|
||||
}
|
||||
elseif ($stype === 'show') {
|
||||
$element = 'table';
|
||||
$column_class = array('field', 'value');
|
||||
$rows = array
|
||||
(array('Type', $values['type']),
|
||||
array('Phone', $values['phone']),
|
||||
array('Extension', $values['ext']),
|
||||
array('Comment', $values['comment']),
|
||||
);
|
||||
}
|
||||
else {
|
||||
die("Invalid stype ($stype)");
|
||||
}
|
||||
@@ -119,13 +148,18 @@ function contactMethodTypeDiv($obj, $type, $stype, $values = null) {
|
||||
'<div ' . "\n" .
|
||||
' class="'.$type.'-%{id}-div"' . "\n" .
|
||||
' id="'.$type.'-%{id}-'.$stype.'-div"' . "\n" .
|
||||
' STYLE="display:none;">' . "\n" .
|
||||
(isset($values) ? '' : ' STYLE="display:none;"' . "\n") .
|
||||
'>' . "\n" .
|
||||
|
||||
$obj->element
|
||||
('form_table',
|
||||
($element,
|
||||
array('class' => "item contact-{$type} {$stype}",
|
||||
'field_prefix' => 'Contact'.ucfirst($type).'.%{id}',
|
||||
'fields' => $fields)) . "\n" .
|
||||
'field_prefix' => 'Contact'.ucfirst($type).'.%{id}')
|
||||
+ compact('rows', 'fields', 'column_class')) .
|
||||
|
||||
($stype === 'show'
|
||||
? '<input type="hidden" name="data[Contact'.ucfirst($type).'][%{id}][id]" value="'.$values['id'].'"/>' . "\n"
|
||||
: '') .
|
||||
|
||||
// END sourcetype-div
|
||||
'</div>' . "\n" .
|
||||
@@ -154,13 +188,18 @@ function contactMethodTypeDiv($obj, $type, $stype, $values = null) {
|
||||
$('#phones').html('');
|
||||
$('#phone-entry-id').val(1);
|
||||
|
||||
/* <?php foreach ($this->data['ContactPhone'] AS $phone): ?> */
|
||||
/* addPhone(true); */
|
||||
/* var id=$("#phone-entry-id").val(); */
|
||||
/* $("#ContactPhone."+id+".phone').val(1); */
|
||||
/* $('ContactPhone.%{id}', */
|
||||
|
||||
/* <?php endforeach; ?> */
|
||||
<?php foreach ($this->data['ContactPhone'] AS $phone): ?>
|
||||
addDiv('phone-entry-id', 'phone', 'phones', false, <?php
|
||||
echo FormatHelper::phpVarToJavascript(contactMethodDiv($this,
|
||||
'phone',
|
||||
'Phone Number',
|
||||
$phone
|
||||
),
|
||||
null,
|
||||
' ');
|
||||
?>
|
||||
);
|
||||
<?php endforeach; ?>
|
||||
|
||||
}
|
||||
|
||||
@@ -216,7 +255,7 @@ echo($this->element
|
||||
|
||||
<div CLASS="dynamic-set">
|
||||
<fieldset CLASS="phone superset">
|
||||
<legend>Phones</legend>
|
||||
<legend>Phone Numbers</legend>
|
||||
<input type="hidden" id="phone-entry-id" value="0">
|
||||
<div id="phones"></div>
|
||||
<fieldset> <legend>
|
||||
|
||||
Reference in New Issue
Block a user