*/
protected $_contactFields = array();
+ /**
+ * Fields array of fields in the batch profile
+ * (based on the uf_field table data)
+ * (this can't be protected as it is passed into the CRM_Contact_Form_Task_Batch::parseStreetAddress function
+ * (although a future refactoring might hopefully change that so it uses the api & the function is not
+ * required
+ * @var array
+ */
+ public $_fields = array();
/**
* build all the data structures needed to build the 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
$this->_profileId = CRM_Batch_BAO_Batch::getProfileId($this->_batchInfo['type_id']);
}
+ CRM_Core_Resources::singleton()
+ ->addScriptFile('civicrm', 'templates/CRM/Batch/Form/Entry.js')
+ ->addSetting(array('batch' => array('type_id' => $this->_batchInfo['type_id'])))
+ ->addSetting(array('setting' => array('monetaryThousandSeparator' => CRM_Core_Config::singleton()->monetaryThousandSeparator)))
+ ->addSetting(array('setting' => array('monetaryDecimalPoint' => CRM_Core_Config::singleton()->monetaryDecimalPoint)));
+
}
/**
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);
}
$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');
}
}
+ // if contact name is set for a row using autocomplete widget then make sure contact id exists, CRM-13078
+ // I was not able to replicate this on my local but adding this check and hopefully it will fix the issue.
+ if (!empty($params['primary_contact'])) {
+ foreach($params['primary_contact'] as $rowIndex => $contactName) {
+ if (empty($params['primary_contact_select_id'][$rowIndex])) {
+ $errors['primary_contact['.$rowIndex.']'] = ts('Please select a valid contact.');
+ }
+ }
+ }
+
if ($batchTotal != $self->_batchInfo['total']) {
$self->assign('batchAmountMismatch', TRUE);
$errors['_qf_defaults'] = ts('Total for amounts entered below does not match the expected batch total.');
}
// handle soft credit
- if (CRM_Utils_Array::value($key, $params['soft_credit_contact_select_id']) && CRM_Utils_Array::value($key, $params['soft_credit_amount'])) {
+ if (is_array(CRM_Utils_Array::value('soft_credit_contact_select_id', $params)) && CRM_Utils_Array::value($key, $params['soft_credit_contact_select_id']) && CRM_Utils_Array::value($key, $params['soft_credit_amount'])) {
$value['soft_credit'][$key]['contact_id'] = $params['soft_credit_contact_select_id'][$key];
$value['soft_credit'][$key]['amount'] = CRM_Utils_Rule::cleanMoney($params['soft_credit_amount'][$key]);
}
}
}
}
+ return TRUE;
}
/**
$value['contact_id']
);
}
+ /**
+ * Function exists purely for unit testing purposes. If you feel tempted to use this in live code
+ * then it probably means there is some functionality that needs to be moved
+ * out of the form layer
+ * @param unknown_type $params
+ */
+ function testProcessMembership($params) {
+ return $this->processMembership($params);
+ }
}