CRM-13148 minor tidy up - remove smarty from js
authoreileen <eileen@fuzion.co.nz>
Sun, 4 Aug 2013 09:40:29 +0000 (21:40 +1200)
committereileen <eileen@fuzion.co.nz>
Sun, 4 Aug 2013 23:32:34 +0000 (11:32 +1200)
CRM/Batch/Form/Entry.php
templates/CRM/Batch/Form/Entry.tpl

index 70d47d2606b7b220abbbc23998d78c689f6ec076..48616eda607c3c417861641c041c1b9ae3c2424d 100644 (file)
@@ -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');
index 2eecc67b990be11af115208984cf7ad942966bad..ca3a088c6c55e9f5b20fc11818f94834bc1a6d72 100644 (file)
@@ -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