Files
pmgr/views/contacts/edit.ctp
abijah 90604bf672 Doh! That's what happens when you make a seemingly innocuous change right before checkin...
git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629/site@210 97e9348a-65ac-dc4b-aefc-98561f571b83
2009-07-05 15:04:09 +00:00

195 lines
5.4 KiB
PHP

<?php /* -*- mode:PHP -*- */
/**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
* Javascript
*/
?>
<script type="text/javascript"><!--
function addPhone(flash) {
addDiv('phone-id', 'phone', 'phones', flash,
// HTML section
'<DIV>' + // BEGIN phone-div
'<FIELDSET CLASS="phone subset">' + // BEGIN phone-fieldset
'<LEGEND>Phone Number #%{id} (%{remove})</LEGEND>' +
'<DIV ID="phone-%{id}-source-div">' + // BEGIN source-div
'<FIELDSET>' + // BEGIN source-fieldset
//'<LEGEND>Source</LEGEND>' +
'<INPUT TYPE="radio" NAME="data[ContactPhone][%{id}][source]"' +
' ONCLICK="switchPhoneSource(%{id}, '+"'existing'"+')"' +
' CLASS="phone-%{id}-source" ID="phone-%{id}-source-existing"' +
//' VALUE="existing" CHECKED/>' +
' VALUE="existing" />' +
' <LABEL FOR="phone-%{id}-source-existing">Existing</LABEL>' +
' ' +
'<INPUT TYPE="radio" NAME="data[ContactPhone][%{id}][source]"' +
' ONCLICK="switchPhoneSource(%{id}, '+"'new'"+')"' +
' CLASS="phone-%{id}-source" ID="phone-%{id}-source-new"' +
' VALUE="new"/>' +
' <LABEL FOR="phone-%{id}-source-new">New</LABEL>' +
'<div id="phone-%{id}-existing-div"' + // BEGIN existing-div
' STYLE="display:none;">' +
<?php
echo ("'" .
preg_replace
("/\n/", "",
$this->element
('form_table',
array('class' => 'item contact-phone existing',
'field_prefix' => 'ContactPhone.%{id}',
'fields' => array
('id' => array('name' => 'Phone/Ext',
'opts' => array('options' => $contactPhones)),
))))
. "' +");
?>
'</div>' + // END existing-div
'<div id="phone-%{id}-new-div"' + // BEGIN new-div
' STYLE="display:none;">' +
<?php
echo ("'" .
preg_replace
("/\n/", "",
$this->element
('form_table',
array('class' => 'item contact-phone entry',
'field_prefix' => 'ContactPhone.%{id}',
'fields' => array
('type' => array('opts' => array('options' => $phoneTypes)),
'phone' => null,
'ext' => array('name' => "Extension"),
'comment' => null,
))))
. "' +");
?>
'</div>' + // END new-div
'</FIELDSET>' + // END source-fieldset
'</DIV>' + // END source-div
'<div id="phone-%{id}-method-div"' + // BEGIN method-div
<?php
echo ("'" .
preg_replace
("/\n/", "",
$this->element
('form_table',
array('class' => 'item contact-method entry',
'field_prefix' => 'ContactPhone.%{id}.Method',
'fields' => array
('type' => array('opts' => array('options' => $methodTypes)),
'preferences' => array('opts' => array('options' => $methodPreferences)),
'comment' => null,
))))
. "' +");
?>
'</div>' + // END method-div
'</FIELDSET>' + // END phone-fieldset
'</DIV>' // END phone-div
);
}
// Reset the form
function resetForm() {
$('#phones').html('');
$('#phone-id').val(1);
addPhone(false);
}
// Reset the form
function switchPhoneSource(id, source) {
<?php
// REVISIT <AP>: 20090704
// For reasons I don't yet understand, slideUp is NOT working for
// new-div. It works fine for existing-div, and show/hide work
// for both divs. I'll defer figuring this out until later.
?>
if (source == 'new') {
$("#phone-"+id+"-existing-div")
.hide();
//.slideUp();
$("#phone-"+id+"-new-div")
.show();
//.slideDown();
} else {
$("#phone-"+id+"-new-div")
.hide();
//.slideUp();
$("#phone-"+id+"-existing-div")
.show();
//.slideDown();
}
}
$(document).ready(function(){
resetForm();
});
--></script>
<?php
; // alignment
/**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
* Contact Edit
*/
echo '<div class="contact edit">' . "\n";
echo $form->create('Contact') . "\n";
echo $form->input('id') . "\n";
echo($this->element
('form_table',
array('class' => 'item contact detail',
'caption' => 'Edit Contact',
'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,
//'' => null,
//'' => '',
))) . "\n");
?>
<div>
<fieldset CLASS="phone superset">
<legend>Phones</legend>
<input type="hidden" id="phone-id" value="0">
<div id="phones"></div>
<fieldset> <legend>
<a href="#" onClick="addPhone(true); return false;">Add a Phone Number</a>
</legend> </fieldset>
</fieldset>
</div>
<?php
; // Alignment
echo $form->submit('Update') . "\n";
echo $form->submit('Cancel') . "\n";
echo $form->end() . "\n";
echo '</div>' . "\n";