First shot at an actual working form to enter contact information. It only handles phone numbers at the moment, and it does NOT handle existing ones. It's a decent start though, and worth checking in. Next I'll have to handle existing phone numbers, and then addresses and emails. Of course, after that, I'll have to actually save everything to the database.
git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629@209 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -47,13 +47,15 @@ class AppModel extends Model {
|
|||||||
*
|
*
|
||||||
* Gets the enum values for MySQL 4 and 5 to use in selectTag()
|
* Gets the enum values for MySQL 4 and 5 to use in selectTag()
|
||||||
*/
|
*/
|
||||||
function getEnumValues($columnName=null, $respectDefault=false)
|
function getEnumValues($columnName=null, $tableName=null)
|
||||||
{
|
{
|
||||||
if ($columnName==null) { return array(); } //no field specified
|
if ($columnName==null) { return array(); } //no field specified
|
||||||
|
|
||||||
//Get the name of the table
|
if (!isset($tableName)) {
|
||||||
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
//Get the name of the table
|
||||||
$tableName = $db->fullTableName($this, false);
|
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
||||||
|
$tableName = $db->fullTableName($this, false);
|
||||||
|
}
|
||||||
|
|
||||||
//Get the values for the specified column (database and version specific, needs testing)
|
//Get the values for the specified column (database and version specific, needs testing)
|
||||||
$result = $this->query("SHOW COLUMNS FROM {$tableName} LIKE '{$columnName}'");
|
$result = $this->query("SHOW COLUMNS FROM {$tableName} LIKE '{$columnName}'");
|
||||||
|
|||||||
@@ -46,6 +46,11 @@ class ContactsController extends AppController {
|
|||||||
return $order;
|
return $order;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function jqGridRecordLinks(&$params, &$model, &$records, $links) {
|
||||||
|
$links['Contact'] = array('id');
|
||||||
|
return parent::jqGridRecordLinks($params, $model, $records, $links);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
@@ -72,8 +77,69 @@ class ContactsController extends AppController {
|
|||||||
'conditions' => array('Contact.id' => $id),
|
'conditions' => array('Contact.id' => $id),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// Set up dynamic menu items
|
||||||
|
$this->sidemenu_links[] =
|
||||||
|
array('name' => 'Operations', 'header' => true);
|
||||||
|
|
||||||
|
$this->sidemenu_links[] =
|
||||||
|
array('name' => 'Edit',
|
||||||
|
'url' => array('action' => 'edit',
|
||||||
|
$id));
|
||||||
|
|
||||||
// Prepare to render.
|
// Prepare to render.
|
||||||
$title = $contact['Contact']['display_name'];
|
$title = $contact['Contact']['display_name'];
|
||||||
$this->set(compact('contact', 'title'));
|
$this->set(compact('contact', 'title'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
* action: edit
|
||||||
|
*/
|
||||||
|
|
||||||
|
function edit($id = null) {
|
||||||
|
if (isset($this->data)) {
|
||||||
|
pr($this->data);
|
||||||
|
$this->autoRender = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$id) {
|
||||||
|
$this->Session->setFlash(__('Invalid Item.', true));
|
||||||
|
$this->redirect(array('action'=>'index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->data = $this->Contact->find
|
||||||
|
('first', array
|
||||||
|
('contain' => array
|
||||||
|
(// Models
|
||||||
|
'ContactPhone',
|
||||||
|
'ContactEmail',
|
||||||
|
'ContactAddress',
|
||||||
|
'Customer'),
|
||||||
|
|
||||||
|
'conditions' => array('Contact.id' => $id),
|
||||||
|
));
|
||||||
|
|
||||||
|
$phone_types = array_flip($this->Contact->ContactPhone->getEnumValues('type'));
|
||||||
|
unset($phone_types[0]);
|
||||||
|
$this->set(compact('phone_types'));
|
||||||
|
|
||||||
|
$method_types = array_flip($this->Contact->getEnumValues('type', 'pmgr_contacts_methods'));
|
||||||
|
unset($method_types[0]);
|
||||||
|
$this->set(compact('method_types'));
|
||||||
|
|
||||||
|
$method_preferences = array_flip($this->Contact->getEnumValues('preference', 'pmgr_contacts_methods'));
|
||||||
|
unset($method_preferences[0]);
|
||||||
|
$this->set(compact('method_preferences'));
|
||||||
|
|
||||||
|
$contact_phones = $this->Contact->ContactPhone->phoneList();
|
||||||
|
$this->set(compact('contact_phones'));
|
||||||
|
|
||||||
|
// Prepare to render.
|
||||||
|
//pr($this->data);
|
||||||
|
$title = $this->data['Contact']['display_name'] . " : Edit";
|
||||||
|
$this->set(compact('title'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
class ContactPhone extends AppModel {
|
class ContactPhone extends AppModel {
|
||||||
|
|
||||||
var $name = 'ContactPhone';
|
|
||||||
var $validate = array(
|
var $validate = array(
|
||||||
'id' => array('numeric'),
|
'id' => array('numeric'),
|
||||||
//'type' => array('inlist'),
|
//'type' => array('inlist'),
|
||||||
@@ -20,5 +19,21 @@ class ContactPhone extends AppModel {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
function phoneList() {
|
||||||
|
$results = $this->find('all',
|
||||||
|
array('contain' => false,
|
||||||
|
'fields' => array('id', 'phone', 'ext'),
|
||||||
|
'order' => array('phone', 'ext')));
|
||||||
|
|
||||||
|
App::Import('Helper', 'Format');
|
||||||
|
$list = array();
|
||||||
|
foreach ($results as $key => $val) {
|
||||||
|
$list[$val['ContactPhone']['id']]
|
||||||
|
= FormatHelper::phone($val['ContactPhone']['phone'],
|
||||||
|
$val['ContactPhone']['ext']);
|
||||||
|
}
|
||||||
|
return $list;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,21 +1,30 @@
|
|||||||
<?php /* -*- mode:PHP -*- */ ?>
|
<?php /* -*- mode:PHP -*- */ ?>
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
**********************************************************************
|
||||||
|
**********************************************************************
|
||||||
|
**********************************************************************
|
||||||
|
* Javascript
|
||||||
|
*/
|
||||||
|
|
||||||
<script type="text/javascript"><!--
|
<script type="text/javascript"><!--
|
||||||
|
|
||||||
function addPhone(flash) {
|
function addPhone(flash) {
|
||||||
addDiv('phone-id', 'phone', 'phones', flash,
|
addDiv('phone-id', 'phone', 'phones', flash,
|
||||||
// HTML section
|
// HTML section
|
||||||
'<FIELDSET CLASS="phone subset">' +
|
'<DIV>' + // BEGIN phone-div
|
||||||
|
'<FIELDSET CLASS="phone subset">' + // BEGIN phone-fieldset
|
||||||
'<LEGEND>Phone Number #%{id} (%{remove})</LEGEND>' +
|
'<LEGEND>Phone Number #%{id} (%{remove})</LEGEND>' +
|
||||||
|
|
||||||
'<DIV ID="phone-%{id}-source-div">' +
|
'<DIV ID="phone-%{id}-source-div">' + // BEGIN source-div
|
||||||
'<FIELDSET>' +
|
'<FIELDSET>' + // BEGIN source-fieldset
|
||||||
//'<LEGEND>Source</LEGEND>' +
|
//'<LEGEND>Source</LEGEND>' +
|
||||||
|
|
||||||
'<INPUT TYPE="radio" NAME="data[ContactPhone][%{id}][source]"' +
|
'<INPUT TYPE="radio" NAME="data[ContactPhone][%{id}][source]"' +
|
||||||
' ONCLICK="switchPhoneSource(%{id}, '+"'existing'"+')"' +
|
' ONCLICK="switchPhoneSource(%{id}, '+"'existing'"+')"' +
|
||||||
' CLASS="phone-%{id}-source" ID="phone-%{id}-source-existing"' +
|
' CLASS="phone-%{id}-source" ID="phone-%{id}-source-existing"' +
|
||||||
' VALUE="existing" CHECKED/>' +
|
//' VALUE="existing" CHECKED/>' +
|
||||||
|
' VALUE="existing" />' +
|
||||||
' <LABEL FOR="phone-%{id}-source-existing">Existing</LABEL>' +
|
' <LABEL FOR="phone-%{id}-source-existing">Existing</LABEL>' +
|
||||||
' ' +
|
' ' +
|
||||||
'<INPUT TYPE="radio" NAME="data[ContactPhone][%{id}][source]"' +
|
'<INPUT TYPE="radio" NAME="data[ContactPhone][%{id}][source]"' +
|
||||||
@@ -24,99 +33,67 @@
|
|||||||
' VALUE="new"/>' +
|
' VALUE="new"/>' +
|
||||||
' <LABEL FOR="phone-%{id}-source-new">New</LABEL>' +
|
' <LABEL FOR="phone-%{id}-source-new">New</LABEL>' +
|
||||||
|
|
||||||
|
'<div id="phone-%{id}-existing-div"' + // BEGIN existing-div
|
||||||
|
' STYLE="display:none;">' +
|
||||||
<?php
|
<?php
|
||||||
/* $sources = array(); */
|
echo ("'" .
|
||||||
/* foreach(array('Existing', 'New') AS $name) */
|
preg_replace
|
||||||
/* $sources[preg_replace("/ /", "", strtolower($name))] = $name; */
|
("/\n/", "",
|
||||||
|
$this->element
|
||||||
/* echo "'" . preg_replace("/\n/", "", */
|
('form_table',
|
||||||
/* $form->radio('ContactPhone.%{id}.source', */
|
array('class' => 'item contact-phone existing',
|
||||||
/* $sources, */
|
'field_prefix' => 'ContactPhone.%{id}',
|
||||||
/* array('legend' => false, */
|
'fields' => array
|
||||||
/* 'separator'=>' '))) . "' +"; */
|
('id' => array('name' => 'Phone/Ext',
|
||||||
|
'opts' => array('options' => $contactPhones)),
|
||||||
|
))))
|
||||||
|
. "' +");
|
||||||
?>
|
?>
|
||||||
|
'</div>' + // END existing-div
|
||||||
|
|
||||||
'<div id="phone-new">' +
|
'<div id="phone-%{id}-new-div"' + // BEGIN new-div
|
||||||
|
' STYLE="display:none;">' +
|
||||||
<?php
|
<?php
|
||||||
/* echo "'" . preg_replace("/\n/", "", */
|
echo ("'" .
|
||||||
/* $form->input('ContactPhone.%{id}.Method.type', */
|
preg_replace
|
||||||
/* array('label' => 'Type', */
|
("/\n/", "",
|
||||||
/* 'options' => $methodTypes, */
|
$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>' +
|
'</div>' + // END new-div
|
||||||
'<div id="phone-existing"></div>' +
|
|
||||||
|
|
||||||
'</FIELDSET>' +
|
'</FIELDSET>' + // END source-fieldset
|
||||||
|
'</DIV>' + // END source-div
|
||||||
|
|
||||||
|
'<div id="phone-%{id}-method-div"' + // BEGIN method-div
|
||||||
/* 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
|
<?php
|
||||||
echo "'" . preg_replace("/\n/", "",
|
echo ("'" .
|
||||||
$form->input('ContactPhone.%{id}.Method.type',
|
preg_replace
|
||||||
array('label' => 'Type',
|
("/\n/", "",
|
||||||
'options' => $methodTypes,
|
$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
|
||||||
|
|
||||||
<?php
|
'</FIELDSET>' + // END phone-fieldset
|
||||||
echo "'" . preg_replace("/\n/", "",
|
'</DIV>' // END phone-div
|
||||||
$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>'
|
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -129,8 +106,29 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reset the form
|
// Reset the form
|
||||||
function switchPhoneSource(id, source) {
|
function switchPhoneSource(id, source) {
|
||||||
//alert("Switch id:"+id+" source:"+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(){
|
$(document).ready(function(){
|
||||||
@@ -142,71 +140,54 @@
|
|||||||
<?php
|
<?php
|
||||||
; // alignment
|
; // alignment
|
||||||
|
|
||||||
echo '<div class="contact edit">' . "\n";
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
* Contact Detail Main Section
|
* Contact Edit
|
||||||
*/
|
*/
|
||||||
|
|
||||||
echo $form->create('Contact');
|
echo '<div class="contact edit">' . "\n";
|
||||||
echo $form->input('id');
|
|
||||||
|
|
||||||
$rows = array();
|
echo $form->create('Contact') . "\n";
|
||||||
foreach (array('first_name' => null,
|
echo $form->input('id') . "\n";
|
||||||
'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();
|
|
||||||
|
|
||||||
|
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">
|
<fieldset CLASS="phone superset">
|
||||||
<legend>Phones</legend>
|
<legend>Phones</legend>
|
||||||
<input type="hidden" id="phone-id" value="0">
|
<input type="hidden" id="phone-id" value="0">
|
||||||
<div id="phones"></div>
|
<div id="phones"></div>
|
||||||
<fieldset> <legend>
|
<fieldset> <legend>
|
||||||
<a href="#" onClick="addPhone(true); return false;">Add Another Phone</a>
|
<a href="#" onClick="addPhone(true); return false;">Add a Phone Number</a>
|
||||||
</legend> </fieldset>
|
</legend> </fieldset>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
; // Alignment
|
||||||
|
|
||||||
|
echo $form->submit('Update') . "\n";
|
||||||
|
echo $form->submit('Cancel') . "\n";
|
||||||
|
echo $form->end() . "\n";
|
||||||
echo '</div>' . "\n";
|
echo '</div>' . "\n";
|
||||||
|
|||||||
31
site/views/elements/form_table.ctp
Normal file
31
site/views/elements/form_table.ctp
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php /* -*- mode:PHP -*- */
|
||||||
|
|
||||||
|
/* form_table.ctp */
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* @filesource
|
||||||
|
* @copyright Copyright 2009, Abijah Perkins
|
||||||
|
* @package pmgr
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
$rows = array();
|
||||||
|
foreach ($fields AS $field => $config) {
|
||||||
|
if (!isset($config['name']))
|
||||||
|
$config['name'] = implode(' ', array_map('ucfirst', explode('_', $field)));
|
||||||
|
if (!isset($config['opts']))
|
||||||
|
$config['opts'] = null;
|
||||||
|
|
||||||
|
if (isset($field_prefix))
|
||||||
|
$field = $field_prefix . '.' . $field;
|
||||||
|
|
||||||
|
$config['opts']['label'] = false;
|
||||||
|
$rows[] = array($config['name'],
|
||||||
|
$form->input($field, $config['opts']));
|
||||||
|
}
|
||||||
|
|
||||||
|
echo $this->element('table',
|
||||||
|
compact('class', 'caption', 'headers',
|
||||||
|
'rows', 'row_class', 'suppress_alternate_rows') +
|
||||||
|
array('column_class' => array('field', 'value'),
|
||||||
|
));
|
||||||
@@ -50,17 +50,20 @@ class FormatHelper extends AppHelper {
|
|||||||
return self::$time->nice($datetime);
|
return self::$time->nice($datetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
function phone($phone) {
|
function phone($phone, $ext = null) {
|
||||||
if (!isset($phone))
|
if (!isset($phone))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
$phone = preg_replace("/\D/", "", $phone);
|
$phone = preg_replace("/\D/", "", $phone);
|
||||||
if(strlen($phone) == 7)
|
if(strlen($phone) == 7)
|
||||||
return preg_replace("/(\d{3})(\d{4})/", "$1-$2", $phone);
|
$phone = preg_replace("/(\d{3})(\d{4})/", "$1-$2", $phone);
|
||||||
elseif(strlen($phone) == 10)
|
elseif(strlen($phone) == 10)
|
||||||
return preg_replace("/(\d{3})(\d{3})(\d{4})/", "$1-$2-$3", $phone);
|
$phone = preg_replace("/(\d{3})(\d{3})(\d{4})/", "$1-$2-$3", $phone);
|
||||||
else
|
|
||||||
return $phone;
|
if ($ext)
|
||||||
|
$phone .= ' x' . $ext;
|
||||||
|
|
||||||
|
return $phone;
|
||||||
}
|
}
|
||||||
|
|
||||||
function comment($comment) {
|
function comment($comment) {
|
||||||
|
|||||||
Reference in New Issue
Block a user