Added descriptive text to the customer entry page, as well as work to associate labels with the inputs and set their class dynamically, to flag missing required fields.
git-svn-id: file:///svn-source/pmgr/branches/pre_0.1_work_20090819@753 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -42,11 +42,12 @@ function customerContactDiv($obj, $values = null, $primary = false) {
|
|||||||
' CLASS="contact-%{id}-source" ' . "\n" .
|
' CLASS="contact-%{id}-source" ' . "\n" .
|
||||||
' ID="contact-%{id}-source-'.$stype.'"' . "\n" .
|
' ID="contact-%{id}-source-'.$stype.'"' . "\n" .
|
||||||
' VALUE="'.$stype.'"' . "\n" .
|
' VALUE="'.$stype.'"' . "\n" .
|
||||||
//' CHECKED' . "\n" .
|
($stype == 'new' ? ' CHECKED' . "\n" : '') .
|
||||||
' />' . "\n" .
|
' />' . "\n" .
|
||||||
' <LABEL FOR="contact-%{id}-source-'.$stype.'">'.$sname.'</LABEL>' . "\n" .
|
' <LABEL FOR="contact-%{id}-source-'.$stype.'">'.$sname.'</LABEL>' . "\n" .
|
||||||
' ';
|
' ';
|
||||||
}
|
}
|
||||||
|
$div .= "<P>(Phone numbers / Addresses can be added later)";
|
||||||
}
|
}
|
||||||
$div .= "\n";
|
$div .= "\n";
|
||||||
|
|
||||||
@@ -75,23 +76,35 @@ function customerContactDiv($obj, $values = null, $primary = false) {
|
|||||||
(
|
(
|
||||||
'Customer.primary_contact_entry' => array
|
'Customer.primary_contact_entry' => array
|
||||||
('name' => 'Primary Contact',
|
('name' => 'Primary Contact',
|
||||||
|
'label_attributes' => array('class' => null),
|
||||||
'no_prefix' => true,
|
'no_prefix' => true,
|
||||||
'opts' => array
|
'opts' => array
|
||||||
('type' => 'radio',
|
('type' => 'radio',
|
||||||
'options' => array('%{id}' => false),
|
'options' => array('%{id}' => false),
|
||||||
'value' => ($primary ? '%{id}' : 'bogus-value-to-suppress-hidden-input'),
|
'value' => ($primary ? '%{id}' : 'bogus-value-to-suppress-hidden-input'),
|
||||||
)),
|
),
|
||||||
|
'after' => ("Check this button if this contact will be the primary" .
|
||||||
|
" contact for this customer (there can be only one primary" .
|
||||||
|
" contact"),
|
||||||
|
),
|
||||||
|
|
||||||
|
|
||||||
'type' => array
|
'type' => array
|
||||||
('opts' => array
|
('label_attributes' => array('class' => 'required'),
|
||||||
|
'opts' => array
|
||||||
('options' => $obj->varstore['contactTypes'],
|
('options' => $obj->varstore['contactTypes'],
|
||||||
'selected' => (isset($values) ? $values['ContactsCustomer']['type'] : null),
|
'selected' => (isset($values) ? $values['ContactsCustomer']['type'] : null),
|
||||||
)),
|
),
|
||||||
|
'after' => "An actual tenant, or just an alternate contact?"
|
||||||
|
),
|
||||||
|
|
||||||
'comment' => array
|
'comment' => array
|
||||||
('opts' => array
|
('label_attributes' => array('class' => 'optional empty'),
|
||||||
|
'opts' => array
|
||||||
('value' => (isset($values) ? $values['ContactsCustomer']['comment'] : null),
|
('value' => (isset($values) ? $values['ContactsCustomer']['comment'] : null),
|
||||||
)),
|
),
|
||||||
|
'after' => "Optional: Comments on the relationship between this customer and this contact."
|
||||||
|
),
|
||||||
|
|
||||||
))) . "\n" .
|
))) . "\n" .
|
||||||
|
|
||||||
@@ -115,22 +128,38 @@ function customerContactTypeDiv($obj, $stype, $values = null) {
|
|||||||
if ($stype === 'existing') {
|
if ($stype === 'existing') {
|
||||||
$fields = array
|
$fields = array
|
||||||
('id' => array('name' => 'Contact',
|
('id' => array('name' => 'Contact',
|
||||||
'opts' => array('options' => $obj->varstore['contacts'])),
|
'label_attributes' => array('class' => 'required empty'),
|
||||||
|
'opts' => array('options' => $obj->varstore['contacts']),
|
||||||
|
'after' => "Select the existing contact."),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
elseif ($stype === 'new') {
|
elseif ($stype === 'new') {
|
||||||
$fields = array
|
$fields = array
|
||||||
('first_name' => true,
|
('last_name' => array('label_attributes' => array('class' => 'required empty'),
|
||||||
'last_name' => true,
|
//'opts' => array('onchange' => 'alert("changed")'),
|
||||||
'middle_name' => true,
|
'after' => "Required."),
|
||||||
'display_name' => true,
|
'first_name' => array('label_attributes' => array('class' => 'recommended empty'),
|
||||||
'company_name' => array('name' => 'Company'),
|
'after' => "Recommended."),
|
||||||
'id_federal' => array('name' => 'SSN'),
|
'middle_name' => array('label_attributes' => array('class' => 'optional empty'),
|
||||||
'id_local' => array('name' => 'ID #'),
|
'after' => "Optional."),
|
||||||
'id_local_state' => array('name' => 'ID State'),
|
'display_name' => array('label_attributes' => array('class' => 'optional empty'),
|
||||||
|
'after' => "Optional: Will default to customer name."),
|
||||||
|
'company_name' => array('name' => 'Company',
|
||||||
|
'label_attributes' => array('class' => 'optional empty'),
|
||||||
|
'after' => "Optional: Company name, if corporate contact."),
|
||||||
|
'id_federal' => array('name' => 'SSN',
|
||||||
|
'label_attributes' => array('class' => 'optional empty'),
|
||||||
|
'after' => "Optional: Social Security Number."),
|
||||||
|
'id_local' => array('name' => 'ID #',
|
||||||
|
'label_attributes' => array('class' => 'recommended empty'),
|
||||||
|
'after' => "Recommended: Driver's license, for example."),
|
||||||
|
'id_local_state' => array('name' => 'ID State',
|
||||||
|
'label_attributes' => array('class' => 'recommended empty'),
|
||||||
|
'after' => "Recommended: State which issued the ID"),
|
||||||
/* 'id_local_exp' => array('name' => 'ID Expiration', */
|
/* 'id_local_exp' => array('name' => 'ID Expiration', */
|
||||||
/* 'opts' => array('empty' => true)), */
|
/* 'opts' => array('empty' => true)), */
|
||||||
'comment' => true,
|
'comment' => array('label_attributes' => array('class' => 'optional empty'),
|
||||||
|
'after' => "Optional: Comments about this contact."),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
elseif ($stype === 'show') {
|
elseif ($stype === 'show') {
|
||||||
@@ -151,14 +180,14 @@ function customerContactTypeDiv($obj, $stype, $values = null) {
|
|||||||
'<div ' . "\n" .
|
'<div ' . "\n" .
|
||||||
' class="contact-%{id}-div"' . "\n" .
|
' class="contact-%{id}-div"' . "\n" .
|
||||||
' id="contact-%{id}-'.$stype.'-div"' . "\n" .
|
' id="contact-%{id}-'.$stype.'-div"' . "\n" .
|
||||||
(isset($values) ? '' : ' STYLE="display:none;"' . "\n") .
|
((isset($values) || $stype == 'new') ? '' : ' STYLE="display:none;"' . "\n") .
|
||||||
'>' . "\n" .
|
'>' . "\n" .
|
||||||
|
|
||||||
$obj->element
|
$obj->element
|
||||||
($element,
|
($element,
|
||||||
array('class' => "item contact {$class}",
|
array('class' => "item contact {$class}",
|
||||||
'field_prefix' => 'Contact.%{id}')
|
'field_prefix' => 'Contact.%{id}')
|
||||||
+ compact('rows', 'fields', 'column_class')) .
|
+ compact('rows', 'fields', 'row_class', 'column_class')) .
|
||||||
|
|
||||||
($stype === 'show'
|
($stype === 'show'
|
||||||
? '<input type="hidden" name="data[Contact][%{id}][id]" value="'.$values['id'].'"/>' . "\n"
|
? '<input type="hidden" name="data[Contact][%{id}][id]" value="'.$values['id'].'"/>' . "\n"
|
||||||
@@ -221,8 +250,28 @@ function customerContactTypeDiv($obj, $stype, $values = null) {
|
|||||||
.slideDown();
|
.slideDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setEmpty(input_elem) {
|
||||||
|
selector = "label[for=" + $(input_elem).attr("id") + "]";
|
||||||
|
//$("#debug").append($(input_elem).attr("id") + ": " + $(input_elem).val() + "<BR>");
|
||||||
|
if ($(input_elem).val() == '')
|
||||||
|
$(selector).addClass('empty');
|
||||||
|
else
|
||||||
|
$(selector).removeClass('empty');
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
resetForm();
|
resetForm();
|
||||||
|
|
||||||
|
// In case refresh is hit with populated fields
|
||||||
|
$(":input").each(function(i,elem){ setEmpty(elem); });
|
||||||
|
|
||||||
|
// keyup doesn't catch cut from menu
|
||||||
|
$(":input").live('keyup', function(){
|
||||||
|
setEmpty(this);
|
||||||
|
});
|
||||||
|
$(":input").live('mouseup', function(){
|
||||||
|
setEmpty(this);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
--></script>
|
--></script>
|
||||||
@@ -247,8 +296,12 @@ echo($this->element
|
|||||||
array('class' => 'item customer detail',
|
array('class' => 'item customer detail',
|
||||||
'caption' => isset($this->data['Customer']) ? 'Edit Customer' : 'New Customer',
|
'caption' => isset($this->data['Customer']) ? 'Edit Customer' : 'New Customer',
|
||||||
'fields' => array
|
'fields' => array
|
||||||
('name' => true,
|
('name' => array('label_attributes' => array('class' => 'optional empty'),
|
||||||
'comment' => true,
|
'after' => ("Optional: If this field is left blank, the" .
|
||||||
|
" customer name will be set to the name of" .
|
||||||
|
" the primary contact, below.")),
|
||||||
|
'comment' => array('label_attributes' => array('class' => 'optional empty'),
|
||||||
|
'after' => 'Optional: Comments about this customer.'),
|
||||||
))) . "\n");
|
))) . "\n");
|
||||||
|
|
||||||
echo $form->submit(isset($this->data['Customer']) ? 'Update' : 'Add New Customer') . "\n";
|
echo $form->submit(isset($this->data['Customer']) ? 'Update' : 'Add New Customer') . "\n";
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ foreach ($fields AS $field => $config) {
|
|||||||
$include_after = true;
|
$include_after = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($column_class))
|
||||||
$column_class = array();
|
$column_class = array();
|
||||||
if ($include_before)
|
if ($include_before)
|
||||||
$column_class[] = 'before';
|
$column_class[] = 'before';
|
||||||
$column_class[] = 'field';
|
$column_class[] = 'field';
|
||||||
@@ -79,7 +79,13 @@ foreach ($fields AS $field => $config) {
|
|||||||
$cells[] = null;
|
$cells[] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($config['opts']['label']))
|
||||||
|
$name = $form->label($field, $config['name'],
|
||||||
|
empty($config['label_attributes'])
|
||||||
|
? null : $config['label_attributes']);
|
||||||
|
else
|
||||||
$name = $config['name'];
|
$name = $config['name'];
|
||||||
|
|
||||||
if (isset($config['with_name_before']))
|
if (isset($config['with_name_before']))
|
||||||
$name = $config['with_name_before'] . $name;
|
$name = $config['with_name_before'] . $name;
|
||||||
elseif (isset($with_name_before))
|
elseif (isset($with_name_before))
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ if (isset($rows) && is_array($rows) && count($rows)) {
|
|||||||
|
|
||||||
foreach ($rows AS $r => &$row) {
|
foreach ($rows AS $r => &$row) {
|
||||||
foreach ($row AS $c => $col) {
|
foreach ($row AS $c => $col) {
|
||||||
$cell_class = implode(" ", array_merge(isset( $row_class[$r]) ? $row_class[$r] : array(),
|
$cell_class = implode(" ", array_merge(empty( $row_class[$r]) ? array() : $row_class[$r],
|
||||||
isset($column_class[$c]) ? $column_class[$c] : array()));
|
empty($column_class[$c]) ? array() : $column_class[$c]));
|
||||||
if ($cell_class)
|
if ($cell_class)
|
||||||
$row[$c] = array($col, array('class' => $cell_class));
|
$row[$c] = array($col, array('class' => $cell_class));
|
||||||
}
|
}
|
||||||
@@ -65,11 +65,11 @@ if (isset($rows) && is_array($rows) && count($rows)) {
|
|||||||
|
|
||||||
// OK, output the table HTML
|
// OK, output the table HTML
|
||||||
echo('<TABLE' .
|
echo('<TABLE' .
|
||||||
(isset($id) ? ' ID="'.$id.'"' : '') .
|
(empty($id) ? '' : ' ID="'.$id.'"') .
|
||||||
(isset($class) ? ' CLASS="'.$class.'"' : '') .
|
(empty($class) ? '' : ' CLASS="'.$class.'"') .
|
||||||
'>' . "\n");
|
'>' . "\n");
|
||||||
|
|
||||||
if (isset($caption))
|
if (!empty($caption))
|
||||||
echo(' <CAPTION>' . $caption . '</CAPTION>' . "\n");
|
echo(' <CAPTION>' . $caption . '</CAPTION>' . "\n");
|
||||||
|
|
||||||
if (isset($headers) && is_array($headers)) {
|
if (isset($headers) && is_array($headers)) {
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ span.fmt-age.delinquent { color: #f00; }
|
|||||||
|
|
||||||
table.item th ,
|
table.item th ,
|
||||||
table.item td { padding: 0.1em 0.4em 0.1em 0.4em; }
|
table.item td { padding: 0.1em 0.4em 0.1em 0.4em; }
|
||||||
table.item td { white-space: nowrap; }
|
table.item td.name { white-space: nowrap; }
|
||||||
/* table.item { border-spacing: 0 0; /\*IE*\/border-collapse: collapse; empty-cells: show } */
|
/* table.item { border-spacing: 0 0; /\*IE*\/border-collapse: collapse; empty-cells: show } */
|
||||||
table.item { border-spacing: 0 0; empty-cells: show }
|
table.item { border-spacing: 0 0; empty-cells: show }
|
||||||
table.item { border:1px solid #ccc;
|
table.item { border:1px solid #ccc;
|
||||||
@@ -122,6 +122,11 @@ div.detail.supporting { clear : both;
|
|||||||
.edit table.detail { width : 80%;
|
.edit table.detail { width : 80%;
|
||||||
float : none;
|
float : none;
|
||||||
}
|
}
|
||||||
|
table.item td { vertical-align: top; }
|
||||||
|
.edit .item td.field .required { color: #33f }
|
||||||
|
.edit .item td.field .recommended { color: #35d }
|
||||||
|
.edit .item td.field .recommended.empty { color: #f5d }
|
||||||
|
.edit .item td.field .required.empty { color: #f33 }
|
||||||
|
|
||||||
|
|
||||||
/************************************************************
|
/************************************************************
|
||||||
|
|||||||
Reference in New Issue
Block a user