/**
* Variable is set if price set is used for membership.
+ * @var bool
*/
protected $_useForMember;
$this->_sid = CRM_Utils_Request::retrieve('sid', 'Positive', $this, FALSE, NULL, 'REQUEST');
$this->_fid = CRM_Utils_Request::retrieve('fid', 'Positive', $this, FALSE, NULL, 'REQUEST');
$url = CRM_Utils_System::url('civicrm/admin/price/field', "reset=1&action=browse&sid={$this->_sid}");
- $breadCrumb = array(array('title' => ts('Price Set Fields'), 'url' => $url));
+ $breadCrumb = [['title' => ts('Price Set Fields'), 'url' => $url]];
- $this->_extendComponentId = array();
+ $this->_extendComponentId = [];
$extendComponentId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_sid, 'extends', 'id');
if ($extendComponentId) {
$this->_extendComponentId = explode(CRM_Core_DAO::VALUE_SEPARATOR, $extendComponentId);
* array of default values
*/
public function setDefaultValues() {
- $defaults = array();
+ $defaults = [];
// is it an edit operation ?
if (isset($this->_fid)) {
- $params = array('id' => $this->_fid);
+ $params = ['id' => $this->_fid];
$this->assign('fid', $this->_fid);
CRM_Price_BAO_PriceField::retrieve($params, $defaults);
$this->_sid = $defaults['price_set_id'];
// if text, retrieve price
if ($defaults['html_type'] == 'Text') {
$isActive = $defaults['is_active'];
- $valueParams = array('price_field_id' => $this->_fid);
+ $valueParams = ['price_field_id' => $this->_fid];
CRM_Price_BAO_PriceFieldValue::retrieve($valueParams, $defaults);
}
if ($this->_action & CRM_Core_Action::ADD) {
- $fieldValues = array('price_set_id' => $this->_sid);
+ $fieldValues = ['price_set_id' => $this->_sid];
$defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Price_DAO_PriceField', $fieldValues);
$defaults['options_per_line'] = 1;
$defaults['is_display_amounts'] = 1;
$this->add('select', 'financial_type_id',
ts('Financial Type'),
- array(' ' => ts('- select -')) + $financialType
+ [' ' => ts('- select -')] + $financialType
);
$this->assign('useForMember', FALSE);
'select',
'option_financial_type_id[' . $i . ']',
ts('Financial Type'),
- array('' => ts('- select -')) + $financialType
+ ['' => ts('- select -')] + $financialType
);
if (in_array($eventComponentId, $this->_extendComponentId)) {
// count
}
elseif (in_array($memberComponentId, $this->_extendComponentId)) {
$membershipTypes = CRM_Member_PseudoConstant::membershipType();
- $js = array('onchange' => "calculateRowValues( $i );");
+ $js = ['onchange' => "calculateRowValues( $i );"];
$this->add('select', 'membership_type_id[' . $i . ']', ts('Membership Type'),
- array('' => ' ') + $membershipTypes, FALSE, $js
+ ['' => ' '] + $membershipTypes, FALSE, $js
);
$this->add('text', 'membership_num_terms[' . $i . ']', ts('Number of Terms'), CRM_Utils_Array::value('membership_num_terms', $attributes));
}
// weight
- $this->add('text', 'option_weight[' . $i . ']', ts('Order'), $attributes['weight']);
+ $this->add('number', 'option_weight[' . $i . ']', ts('Order'), $attributes['weight']);
// is active ?
$this->add('checkbox', 'option_status[' . $i . ']', ts('Active?'));
$this->add('checkbox', 'is_display_amounts', ts('Display Amount?'));
// weight
- $this->add('text', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Price_DAO_PriceField', 'weight'), TRUE);
+ $this->add('number', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Price_DAO_PriceField', 'weight'), TRUE);
$this->addRule('weight', ts('is a numeric field'), 'numeric');
// checkbox / radio options per line
CRM_Core_DAO::getAttribute('CRM_Price_DAO_PriceField', 'help_post')
);
- $this->add('datepicker', 'active_on', ts('Active On'), [], FALSE, array('time' => TRUE));
+ $this->add('datepicker', 'active_on', ts('Active On'), [], FALSE, ['time' => TRUE]);
// expire_on
- $this->add('datepicker', 'expire_on', ts('Expire On'), [], FALSE, array('time' => TRUE));
+ $this->add('datepicker', 'expire_on', ts('Expire On'), [], FALSE, ['time' => TRUE]);
// is required ?
$this->add('checkbox', 'is_required', ts('Required?'));
$this->add('checkbox', 'is_active', ts('Active?'));
// add buttons
- $this->addButtons(array(
- array(
+ $this->addButtons([
+ [
'type' => 'next',
'name' => ts('Save'),
'isDefault' => TRUE,
- ),
- array(
+ ],
+ [
'type' => 'next',
'name' => ts('Save and New'),
'subName' => 'new',
- ),
- array(
+ ],
+ [
'type' => 'cancel',
'name' => ts('Cancel'),
- ),
- ));
+ ],
+ ]);
// is public?
$this->add('select', 'visibility_id', ts('Visibility'), CRM_Core_PseudoConstant::visibility());
// add a form rule to check default value
- $this->addFormRule(array('CRM_Price_Form_Field', 'formRule'), $this);
+ $this->addFormRule(['CRM_Price_Form_Field', 'formRule'], $this);
// if view mode pls freeze it with the done button.
if ($this->_action & CRM_Core_Action::VIEW) {
$this->addElement('button',
'done',
ts('Done'),
- array('onclick' => "location.href='$url'")
+ ['onclick' => "location.href='$url'"]
);
}
}
public static function formRule($fields, $files, $form) {
// all option fields are of type "money"
- $errors = array();
+ $errors = [];
/** Check the option values entered
* Appropriate values are required for the selected datatype
}
if ((is_numeric(CRM_Utils_Array::value('count', $fields)) &&
- CRM_Utils_Array::value('count', $fields) == 0
+ empty($fields['count'])
) &&
(CRM_Utils_Array::value('html_type', $fields) == 'Text')
) {
$publicOptionCount = $_flagOption = $_rowError = 0;
$_showHide = new CRM_Core_ShowHideBlocks('', '');
- $visibilityOptions = CRM_Price_BAO_PriceFieldValue::buildOptions('visibility_id', NULL, array('labelColumn' => 'name'));
+ $visibilityOptions = CRM_Price_BAO_PriceFieldValue::buildOptions('visibility_id', NULL, ['labelColumn' => 'name']);
for ($index = 1; $index <= self::NUM_OPTION; $index++) {
// check for checkboxes allowing user to select multiple memberships from same membership organization
if ($fields['html_type'] == 'CheckBox') {
$foundDuplicate = FALSE;
- $orgIds = array();
+ $orgIds = [];
foreach ($memTypesIDS as $key => $val) {
$org = CRM_Member_BAO_MembershipType::getMembershipTypeOrganization($val);
if (in_array($org[$val], $orgIds)) {
}
if (empty($fields['option_name'])) {
- $fields['option_amount'] = array();
+ $fields['option_amount'] = [];
}
if (empty($fields['option_label'])) {
- $fields['option_label'] = array();
+ $fields['option_label'] = [];
}
}
$params['price_set_id'] = $this->_sid;
if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) {
- $fieldValues = array('price_set_id' => $this->_sid);
+ $fieldValues = ['price_set_id' => $this->_sid];
$oldWeight = NULL;
if ($this->_fid) {
$oldWeight = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $this->_fid, 'weight', 'id');
$params['is_enter_qty'] = 1;
// modify params values as per the option group and option
// value
- $params['option_amount'] = array(1 => $params['price']);
- $params['option_label'] = array(1 => $params['label']);
- $params['option_count'] = array(1 => $params['count']);
- $params['option_max_value'] = array(1 => CRM_Utils_Array::value('max_value', $params));
+ $params['option_amount'] = [1 => $params['price']];
+ $params['option_label'] = [1 => $params['label']];
+ $params['option_count'] = [1 => $params['count']];
+ $params['option_max_value'] = [1 => CRM_Utils_Array::value('max_value', $params)];
//$params['option_description'] = array( 1 => $params['description'] );
- $params['option_weight'] = array(1 => $params['weight']);
- $params['option_financial_type_id'] = array(1 => $params['financial_type_id']);
- $params['option_visibility_id'] = array(1 => CRM_Utils_Array::value('visibility_id', $params));
+ $params['option_weight'] = [1 => $params['weight']];
+ $params['option_financial_type_id'] = [1 => $params['financial_type_id']];
+ $params['option_visibility_id'] = [1 => CRM_Utils_Array::value('visibility_id', $params)];
}
if ($this->_fid) {
$priceField = CRM_Price_BAO_PriceField::create($params);
if (!is_a($priceField, 'CRM_Core_Error')) {
- CRM_Core_Session::setStatus(ts('Price Field \'%1\' has been saved.', array(1 => $priceField->label)), ts('Saved'), 'success');
+ CRM_Core_Session::setStatus(ts('Price Field \'%1\' has been saved.', [1 => $priceField->label]), ts('Saved'), 'success');
}
$buttonName = $this->controller->getButtonName();
$session = CRM_Core_Session::singleton();