Implemented ability to add a customer, and fixed the problem with flagging of the primary contact.

git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629@220 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-06 03:01:28 +00:00
parent 09cb297dc7
commit 3e60f8d45e
4 changed files with 49 additions and 11 deletions

View File

@@ -15,7 +15,7 @@ $this->varstore = compact('contactTypes', 'contacts');
* Javascript
*/
function customerContactDiv($obj, $values = null) {
function customerContactDiv($obj, $values = null, $primary = false) {
$div =
// BEGIN type-div
@@ -67,12 +67,31 @@ function customerContactDiv($obj, $values = null) {
// BEGIN contact-div
'<div id="contact-%{id}-contact-div"' . "\n" .
/* '<INPUT TYPE="radio" ' . "\n" . */
/* ' NAME="data[Customer][primary_contact_entry]"' . "\n" . */
/* ' CLASS="contact-primary" ' . "\n" . */
/* ' ID="contact-primary-%{id}"' . "\n" . */
/* ' VALUE="%{id}"' . "\n" . */
/* //($primary ? ' CHECKED' . "\n" : "(\$(#contact-entry-id).val() == 1 ? ' CHECKED' : '')") . */
/* ($primary ? ' CHECKED' . "\n" : '' ) . */
/* ' />' . "\n" . */
/* ' <LABEL FOR="contact-primary-%{id}">Primary Contact</LABEL>' . "\n" . */
$obj->element
('form_table',
array('class' => "item contact entry",
'field_prefix' => 'Contact.%{id}.ContactsCustomer',
'fields' => array
(
'Customer.primary_contact_entry' => array
('name' => 'Primary Contact',
'no_prefix' => true,
'opts' => array
('type' => 'radio',
'options' => array('%{id}' => false),
'value' => ($primary ? '%{id}' : 'bogus-value-to-suppress-hidden-input'),
)),
'type' => array
('opts' => array
('options' => $obj->varstore['contactTypes'],
@@ -171,9 +190,10 @@ function customerContactTypeDiv($obj, $stype, $values = null) {
function addContact(flash) {
addDiv('contact-entry-id', 'contact', 'contacts', flash, <?php
echo FormatHelper::phpVarToJavascript(customerContactDiv($this),
null,
' ');
echo FormatHelper::phpVarToJavascript
(customerContactDiv($this),
null,
' ');
?>
);
}
@@ -185,14 +205,26 @@ function customerContactTypeDiv($obj, $stype, $values = null) {
<?php foreach ($this->data['Contact'] AS $contact): ?>
addDiv('contact-entry-id', 'contact', 'contacts', false, <?php
echo FormatHelper::phpVarToJavascript(customerContactDiv($this,
$contact
),
null,
' ');
echo FormatHelper::phpVarToJavascript
(customerContactDiv($this,
$contact,
$contact['id'] == $this->data['Customer']['primary_contact_id']
),
null,
' ');
?>
);
<?php endforeach; ?>
if ($("#contact-entry-id").val() == 1) {
addDiv('contact-entry-id', 'contact', 'contacts', false, <?php
echo FormatHelper::phpVarToJavascript
(customerContactDiv($this, null, true),
null,
' ');
?>
);
}
}
function switchContactSource(id, source) {