*/
public function buildQuickForm( ) {
parent::buildQuickForm( );
- $dataURL = CRM_Utils_System::url('civicrm/ajax/rest',
- 'className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=contact&org=1', FALSE, NULL, FALSE);
- $this->assign('dataURL', $dataURL);
if ($this->_action & CRM_Core_Action::DELETE) {
return;
$this->add('text', 'description', ts('Description'), $attributes['description']);
$this->add('text', 'accounting_code', ts('Accounting Code'), $attributes['accounting_code']);
$elementAccounting = $this->add('text', 'account_type_code', ts('Account Type Code'), $attributes['account_type_code']);
- $this->add('text', 'contact_name', ts('Owner'), $attributes['name']);
- $this->add('hidden', 'contact_id', '', array('id' => 'contact_id'));
+ $this->addEntityRef('contact_id', ts('Owner'), array('api' => array('params' => array('contact_type' => 'Organization')), 'create' => TRUE));
$this->add('text', 'tax_rate', ts('Tax Rate'), $attributes['tax_rate']);
$this->add('checkbox', 'is_deductible', ts('Tax-Deductible?'));
$elementActive = $this->add('checkbox', 'is_active', ts('Enabled?'));
$defaults = parent::setDefaultValues();
if ($this->_action & CRM_Core_Action::ADD) {
$defaults['contact_id'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Domain', CRM_Core_Config::domainID(), 'contact_id');
- $defaults['contact_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $defaults['contact_id'], 'sort_name');
}
return $defaults;
}
}
}
}
-
-
<td class="html-adjust">{$form.description.html}</td>
</tr>
<tr class="crm-contribution-form-block-organisation_name">
- <td class="label">{$form.contact_name.label} {help id="id-financial-owner" file="CRM/Contact/Form/Contact.hlp"}</td>
- <td class="html-adjust">{$form.contact_name.html|crmReplace:class:twenty}<br />
+ <td class="label">{$form.contact_id.label} {help id="id-financial-owner" file="CRM/Contact/Form/Contact.hlp"}</td>
+ <td class="html-adjust">{$form.contact_id.html}<br />
<span class="description">{ts}Use this field to indicate the organization that owns this account.{/ts}</span>
</td>
</tr>
{/if}
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="botttom"}</div>
</div>
-
-{literal}
-<script type="text/javascript">
-var dataUrl = "{/literal}{$dataURL}{literal}";
-cj('#contact_name').autocomplete( dataUrl, {
- width : 250,
- selectFirst : false,
- matchCase : true,
- matchContains: true,
- max: {/literal}{crmSetting name="search_autocomplete_count" group="Search Preferences"}{literal}
-}).result( function(event, data, formatted) {
- ( parseInt( data[1] ) ) ? cj( "#contact_id" ).val( data[1] ) : cj( "#contact_id" ).val('');
-});
-
-// remove current account owner id when current owner removed.
-cj("form").submit(function() {
- if (!cj('#contact_name').val()) cj( "#contact_id" ).val('');
-});
-
-//current employer default setting
-var employerId = "{/literal}{$organisationId}{literal}";
-if ( employerId ) {
- var dataUrl = "{/literal}{crmURL p='civicrm/ajax/rest' h=0 q="className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=contact&org=1&id=" }{literal}" + employerId ;
- cj.ajax({
- url : dataUrl,
- async : false,
- success : function(html){
- //fixme for showing address in div
- htmlText = html.split( '|' , 2);
- cj('input#contact_name').val(htmlText[0]);
- cj('input#contact_id').val(htmlText[1]);
- }
- });
-}
-
-cj("input#contact_name").click( function( ) {
- cj("input#contact_id").val('');
-});
-</script>
-{/literal}