*/
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.');
);
// get the price set associated with offline contribution record.
- $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', 'default_contribution_amount', 'id', 'name');
- $this->_priceSet = current(CRM_Price_BAO_Set::getSetDetail($priceSetId));
+ $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', 'default_contribution_amount', 'id', 'name');
+ $this->_priceSet = current(CRM_Price_BAO_PriceSet::getSetDetail($priceSetId));
$fieldID = key($this->_priceSet['fields']);
if (isset($params['field'])) {
$value['price_'.$fieldID] = 1;
$lineItem = array();
- CRM_Price_BAO_Set::processAmount($this->_priceSet['fields'], $value, $lineItem[$priceSetId]);
+ CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'], $value, $lineItem[$priceSetId]);
//unset amount level since we always use quick config price set
unset($value['amount_level']);
);
// get the price set associated with offline memebership
- $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', 'default_membership_type_amount', 'id', 'name');
- $this->_priceSet = $priceSets = current(CRM_Price_BAO_Set::getSetDetail($priceSetId));
+ $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', 'default_membership_type_amount', 'id', 'name');
+ $this->_priceSet = $priceSets = current(CRM_Price_BAO_PriceSet::getSetDetail($priceSetId));
if (isset($params['field'])) {
$customFields = array();
}
// 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]);
}
);
$editedResults = array();
- CRM_Price_BAO_Field::retrieve($editedFieldParams, $editedResults);
+ CRM_Price_BAO_PriceField::retrieve($editedFieldParams, $editedResults);
if (!empty($editedResults)) {
unset($this->_priceSet['fields']);
);
$editedResults = array();
- CRM_Price_BAO_FieldValue::retrieve($editedFieldParams, $editedResults);
+ CRM_Price_BAO_PriceFieldValue::retrieve($editedFieldParams, $editedResults);
$this->_priceSet['fields'][$fid]['options'][$editedResults['id']] = $priceSets['fields'][$fid]['options'][$editedResults['id']];
if (CRM_Utils_Array::value('total_amount', $value)) {
$this->_priceSet['fields'][$fid]['options'][$editedResults['id']]['amount'] = $value['total_amount'];
$value['price_' . $fieldID] = $editedResults['id'];
$lineItem = array();
- CRM_Price_BAO_Set::processAmount($this->_priceSet['fields'],
+ CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'],
$value, $lineItem[$priceSetId]
);
}
}
}
+ 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);
+ }
}