From 57465e2a09f6e2fb83278532f17b135a1a60338d Mon Sep 17 00:00:00 2001 From: eileen Date: Sun, 4 Aug 2013 21:40:29 +1200 Subject: [PATCH] CRM-13148 minor tidy up - remove smarty from js --- CRM/Batch/Form/Entry.php | 12 +++++++++--- templates/CRM/Batch/Form/Entry.tpl | 20 ++------------------ 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/CRM/Batch/Form/Entry.php b/CRM/Batch/Form/Entry.php index 70d47d2606..48616eda60 100644 --- a/CRM/Batch/Form/Entry.php +++ b/CRM/Batch/Form/Entry.php @@ -100,7 +100,7 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form { $params = array('id' => $this->_batchId); CRM_Batch_BAO_Batch::retrieve($params, $this->_batchInfo); - $this->assign('batchTotal', $this->_batchInfo['total']); + $this->assign('batchTotal', !empty($this->_batchInfo['total']) ? $this->_batchInfo['total'] : NULL); $this->assign('batchType', $this->_batchInfo['type_id']); // get the profile id associted with this batch type @@ -206,7 +206,9 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form { foreach ($this->_fields as $name => $field) { if (in_array($field['field_type'], $contactTypes)) { - $this->_contactFields[$field['name']] = 1; + $fld = explode('-', $field['name']); + $contactReturnProperties[] = $fld[0]; + $contactFieldMap[$fld[0]] = $field['name']; } CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, NULL, FALSE, FALSE, $rowNumber); @@ -217,7 +219,11 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form { } $this->assign('fields', $this->_fields); - $this->assign('contactFields', $this->_contactFields); + CRM_Core_Resources::singleton() + ->addSetting(array('contact' => array( + 'return' => implode(',', $contactReturnProperties), + 'fieldmap' => $contactFieldMap, + ))); // don't set the status message when form is submitted. $buttonName = $this->controller->getButtonName('submit'); diff --git a/templates/CRM/Batch/Form/Entry.tpl b/templates/CRM/Batch/Form/Entry.tpl index 2eecc67b99..ca3a088c6c 100644 --- a/templates/CRM/Batch/Form/Entry.tpl +++ b/templates/CRM/Batch/Form/Entry.tpl @@ -174,28 +174,12 @@ function updateContactInfo(blockNo, prefix) { var contactHiddenElement = 'input[name="' + prefix + 'contact_select_id[' + blockNo + ']"]'; var contactId = cj(contactHiddenElement).val(); - var returnProperties = ''; - var profileFields = new Array(); - {/literal} - {if $contactFields} - {foreach from=$contactFields item=val key=fldName} - var fldName = "{$fldName}"; - {literal} - if (returnProperties) { - returnProperties = returnProperties + ','; - } - var fld = fldName.split('-'); - returnProperties = returnProperties + fld[0]; - profileFields[fld[0]] = fldName; - {/literal} - {/foreach} - {/if} - {literal} + var profileFields = CRM.contact.fieldmap; CRM.api('Contact', 'get', { 'sequential': '1', 'contact_id': contactId, - 'return': returnProperties }, + 'return': CRM.contact.return }, { success: function (data) { cj.each(data.values[0], function (key, value) { // set the values -- 2.25.1