Nowhere near complete, but a quick checkin to the contacts edit view so I can clean up some of the commented code that's getting intrusive.

git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629/site@208 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-05 02:48:23 +00:00
parent 5f82404a4f
commit 6c656b07c3

212
views/contacts/edit.ctp Normal file
View File

@@ -0,0 +1,212 @@
<?php /* -*- mode:PHP -*- */ ?>
<script type="text/javascript"><!--
function addPhone(flash) {
addDiv('phone-id', 'phone', 'phones', flash,
// HTML section
'<FIELDSET CLASS="phone subset">' +
'<LEGEND>Phone Number #%{id} (%{remove})</LEGEND>' +
'<DIV ID="phone-%{id}-source-div">' +
'<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/>' +
' <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>' +
<?php
/* $sources = array(); */
/* foreach(array('Existing', 'New') AS $name) */
/* $sources[preg_replace("/ /", "", strtolower($name))] = $name; */
/* echo "'" . preg_replace("/\n/", "", */
/* $form->radio('ContactPhone.%{id}.source', */
/* $sources, */
/* array('legend' => false, */
/* 'separator'=>' '))) . "' +"; */
?>
'<div id="phone-new">' +
<?php
/* echo "'" . preg_replace("/\n/", "", */
/* $form->input('ContactPhone.%{id}.Method.type', */
/* array('label' => 'Type', */
/* 'options' => $methodTypes, */
/* ))) . "' +"; */
?>
'</div>' +
'<div id="phone-existing"></div>' +
'</FIELDSET>' +
/* foreach ($sources AS $source => $name) { */
/* $div = '<DIV>'; */
/* echo "'" . preg_replace("/\n/", "", */
/* $form->input('ContactPhone.%{id}.source', */
/* array('label' => 'Type', */
/* 'type' => 'radio', */
/* 'options' => $sources, */
/* ))) . "' +"; */
/* $div .= '<INPUT TYPE="radio" NAME="data[ContactPhone][%{id}][source]"'; */
/* $div .= ' ONCLICK="switchPhoneSource(%{id}, \\\''.$source.'\\\')"'; */
/* $div .= ' CLASS="phone-source-%{id}" ID="phone-source-'.$source.'-%{id}"'; */
/* $div .= ' VALUE="'.$name.'" ' . ($name == 'Existing' ? 'CHECKED ' : '') . '/>'; */
/* $div .= ' <LABEL FOR="phone-source-'.$source.'-%{id}">'.$name.'</LABEL>'; */
/* $div .= '</DIV>'; */
/* echo "'$div' +\n"; */
/* } */
'</DIV>' +
//'<DIV ID="phone-method-type-div-%{id}" CLASS="input text required">' +
<?php
echo "'" . preg_replace("/\n/", "",
$form->input('ContactPhone.%{id}.Method.type',
array('label' => 'Type',
'options' => $methodTypes,
))) . "' +";
?>
<?php
echo "'" . preg_replace("/\n/", "",
$form->input('ContactPhone.%{id}.Method.preference',
array('label' => 'Preference',
'options' => $methodPreferences,
))) . "' +";
?>
<?php
echo "'" . preg_replace("/\n/", "",
$form->input('ContactPhone.%{id}.Method.comment',
array('label' => 'Comment',
))) . "' +";
?>
//'</DIV>' +
<?php
/* '<DIV ID="phone-method-comment-div-%{id}" CLASS="input text required">' + */
/* ' <LABEL FOR="phone-method-comment-%{id}">Comment</LABEL>' + */
/* ' <INPUT TYPE="text" SIZE="20"' + */
/* ' NAME="data[ContactPhone][%{id}][Method][comment]"' + */
/* ' ID="phone-method-comment-%{id}" />' + */
/* '</DIV>' + */
/* foreach ($sources AS $source => $name) { */
/* $div = '<DIV'; */
/* $div .= ' ID="phone-%{id}-div"'; */
/* $div .= ' CLASS="phone-source-type-div-%{id}"'; */
/* $div .= ' STYLE="display:none;">'; */
/* $div .= '</DIV>'; */
/* echo "'$div' +\n"; */
/* } */
?>
'</FIELDSET>'
);
}
// Reset the form
function resetForm() {
$('#phones').html('');
$('#phone-id').val(1);
addPhone(false);
}
// Reset the form
function switchPhoneSource(id, source) {
//alert("Switch id:"+id+" source:"+source);
}
$(document).ready(function(){
resetForm();
});
--></script>
<?php
; // alignment
echo '<div class="contact edit">' . "\n";
/**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
* Contact Detail Main Section
*/
echo $form->create('Contact');
echo $form->input('id');
$rows = array();
foreach (array('first_name' => null,
'last_name' => null,
'middle_name' => null,
'display_name' => null,
'company_name' => 'Company',
'id_federal' => 'SSN',
'id_local' => 'ID #',
'id_local_state' => 'ID State',
//'id_local_exp' => 'ID Expires',
'comment' => null,
//'' => null,
//'' => '',
) AS $field => $label) {
if (!isset($label))
$label = implode(' ', array_map('ucfirst', explode('_', $field)));
$opts = array('label' => false);
if ($field === 'id_local_exp')
$opts['empty'] = true;
$rows[] = array($label, $form->input($field, $opts));
}
echo $this->element('table',
array('class' => 'item contact detail',
'caption' => 'Edit Contact',
'rows' => $rows,
'column_class' => array('field', 'value')));
/* echo $form->input('ContactAddress'); */
/* echo $form->input('ContactPhone'); */
/* echo $form->input('ContactEmail'); */
/* echo $form->input('Customer'); */
echo $form->submit('Update') . $form->submit('Cancel');
echo $form->end();
?>
<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 Another Phone</a>
</legend> </fieldset>
</fieldset>
<?php
echo '</div>' . "\n";