* @return array
*/
public static function getLineItemsByContributionID($contributionID) {
- return self::getLineItems($contributionID,'contribution', NULL, TRUE, TRUE, " WHERE contribution_id = " . (int) $contributionID);
+ return self::getLineItems($contributionID, 'contribution', NULL, TRUE, TRUE, " WHERE contribution_id = " . (int) $contributionID);
}
/**
*
* @return array of line items
*/
- public static function getLineItems($entityId, $entity = 'participant', $isQuick = NULL , $isQtyZero = TRUE, $relatedEntity = FALSE, $overrideWhereClause = '') {
+ public static function getLineItems($entityId, $entity = 'participant', $isQuick = NULL, $isQtyZero = TRUE, $relatedEntity = FALSE, $overrideWhereClause = '') {
$whereClause = $fromClause = NULL;
$selectClause = "
SELECT li.id,
);
$getTaxDetails = FALSE;
- $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME,'contribution_invoice_settings');
+ $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
if ($overrideWhereClause) {
$whereClause = $overrideWhereClause;
* to the price set used for particular event
* @param array $values
* Reference to the values array(.
- this is
+ this is
* lineItem array)
*
* @return void
* @param array $otherParams
*/
public static function syncLineItems($entityId, $entityTable = 'civicrm_contribution', $amount, $otherParams = NULL) {
- if (!$entityId || CRM_Utils_System::isNull($amount))
+ if (!$entityId || CRM_Utils_System::isNull($amount)) {
return;
+ }
$from = " civicrm_line_item li
LEFT JOIN civicrm_price_field pf ON pf.id = li.price_field_id
$set .= " ,li.label = %4,
li.price_field_value_id = cpfv.id ";
$where .= " AND cpse.entity_table = 'civicrm_event' AND cpse.entity_id = %5 ";
- $amount = empty($amount) ? 0: $amount;
+ $amount = empty($amount) ? 0 : $amount;
$params += array(
4 => array($otherParams['fee_label'], 'String'),
5 => array($otherParams['event_id'], 'String'),
CRM_Core_DAO::executeQuery($query, $params);
}
- /**
+ /**
* Build line items array.
* @param array $params
* Form values.
return;
}
if ($lineItemId['html_type'] == 'Text') {
- $tax = $lineItemId['tax_amount']/($lineItemId['unit_price'] * $lineItemId['qty'])*100;
+ $tax = $lineItemId['tax_amount'] / ($lineItemId['unit_price'] * $lineItemId['qty']) * 100;
}
else {
- $tax = ($lineItemId['tax_amount']/$lineItemId['unit_price']) * 100;
+ $tax = ($lineItemId['tax_amount'] / $lineItemId['unit_price']) * 100;
}
return $tax;
}
}
if ($id && !empty($params['weight'])) {
- if (isset($params['name']))unset($params['name']);
+ if (isset($params['name'])) { unset($params['name']);
+ }
$oldWeight = NULL;
if ($id) {
*
* @param int $entityId
* Id.
- * @param String $entityTable
+ * @param string $entityTableEntity table.
* Entity table.
- * @param String $financialTypeID
+ * @param string $financialTypeIDFinancial type id.
* Financial type id.
*
* @static
if ($isQuickConfig) {
$sql .= ' AND ps.is_quick_config = 0 ';
}
- $params = array(1 => array($entityTable, 'String'),
+ $params = array(
+ 1 => array($entityTable, 'String'),
2 => array($entityId, 'Integer'),
);
if ($usedFor) {
CRM_Utils_Hook::buildAmount($component, $form, $feeBlock);
// CRM-14492 Admin price fields should show up on event registration if user has 'administer CiviCRM' permissions
- $adminFieldVisible = false;
+ $adminFieldVisible = FALSE;
if (CRM_Core_Permission::check('administer CiviCRM')) {
- $adminFieldVisible = true;
+ $adminFieldVisible = TRUE;
}
foreach ($feeBlock as $id => $field) {
if (CRM_Utils_Array::value('visibility', $field) == 'public' ||
- (CRM_Utils_Array::value('visibility', $field) == 'admin' && $adminFieldVisible == true) ||
+ (CRM_Utils_Array::value('visibility', $field) == 'admin' && $adminFieldVisible == TRUE) ||
!$validFieldsOnly
) {
$options = CRM_Utils_Array::value('options', $field);
// past price sets discounts are made inaccessible by this as the discount_id is set to NULL
// on the participant record
if (CRM_Price_BAO_PriceSet::removeFrom('civicrm_' . $entityName, $entity->id)) {
- CRM_Core_BAO_Discount::del($entity->id,'civicrm_' . $entityName);
+ CRM_Core_BAO_Discount::del($entity->id, 'civicrm_' . $entityName);
}
}
}
$title = ts('[Copy id %1]', array(1 => $maxId + 1));
$fieldsFix = array(
- 'suffix' => array('title' => ' ' . $title,
+ 'suffix' => array(
+ 'title' => ' ' . $title,
'name' => '__Copy_id_' . ($maxId + 1) . '_',
),
);
*
* @param int $id
* Id of the database record.
- * @param boolean $isQuickConfig
+ * @param bool $isQuickConfigValue we want to set the is_quick_config field.
* Value we want to set the is_quick_config field.
*
* @return Object DAO object on sucess, null otherwise
*/
public static function checkMembershipPriceSet($id) {
$query =
-"
+ "
SELECT pfv.id, pfv.price_field_id, pfv.name, pfv.membership_type_id, pf.html_type, mt.auto_renew
FROM civicrm_price_field_value pfv
LEFT JOIN civicrm_price_field pf ON pf.id = pfv.price_field_id
$daoAutoRenew = 0;
}
if (!empty($autoRenew) && !in_array($daoAutoRenew, $autoRenew)) {
- return true;
+ return TRUE;
}
$autoRenew[] = $daoAutoRenew;
}
- return false;
+ return FALSE;
}
/**
}
$enabledComponents = CRM_Core_Component::getEnabledComponents();
$eventComponentId = NULL;
- if (array_key_exists('CiviEvent',$enabledComponents)) {
+ if (array_key_exists('CiviEvent', $enabledComponents)) {
$eventComponentId = CRM_Core_Component::getComponentID('CiviEvent');
}
}
$enabledComponents = CRM_Core_Component::getEnabledComponents();
$eventComponentId = $memberComponentId = NULL;
- if (array_key_exists('CiviEvent',$enabledComponents)) {
+ if (array_key_exists('CiviEvent', $enabledComponents)) {
$eventComponentId = CRM_Core_Component::getComponentID('CiviEvent');
}
- if (array_key_exists('CiviMember',$enabledComponents)) {
+ if (array_key_exists('CiviMember', $enabledComponents)) {
$memberComponentId = CRM_Core_Component::getComponentID('CiviMember');
}
$this->add('select', 'financial_type_id',
ts('Financial Type'),
- array(' '=> ts('- select -')) + $financialType
+ array(' ' => ts('- select -')) + $financialType
);
$this->assign('useForMember', FALSE);
if (!empty($memTypesIDS)) {
// check for checkboxes allowing user to select multiple memberships from same membership organization
if ($fields['html_type'] == 'CheckBox') {
- $foundDuplicate = FALSE;
- $orgIds = array();
- foreach ($memTypesIDS as $key => $val) {
- $org = CRM_Member_BAO_MembershipType::getMembershipTypeOrganization($val);
- if (in_array($org[$val], $orgIds)) {
- $foundDuplicate = TRUE;
- break;
- }
- $orgIds[$val] = $org[$val];
+ $foundDuplicate = FALSE;
+ $orgIds = array();
+ foreach ($memTypesIDS as $key => $val) {
+ $org = CRM_Member_BAO_MembershipType::getMembershipTypeOrganization($val);
+ if (in_array($org[$val], $orgIds)) {
+ $foundDuplicate = TRUE;
+ break;
+ }
+ $orgIds[$val] = $org[$val];
+ }
+ if ($foundDuplicate) {
+ $errors['_qf_default'] = ts('You have selected multiple memberships for the same organization or entity. Please review your selections and choose only one membership per entity.');
+ }
}
- if ($foundDuplicate) {
- $errors['_qf_default'] = ts('You have selected multiple memberships for the same organization or entity. Please review your selections and choose only one membership per entity.');
- }
- }
// CRM-10390 - Only one price field in a set can include auto-renew membership options
$foundAutorenew = FALSE;
$params['is_display_amounts'] = CRM_Utils_Array::value('is_display_amounts', $params, FALSE);
$params['is_required'] = CRM_Utils_Array::value('is_required', $params, FALSE);
$params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
- $params['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $params, false);
+ $params['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $params, FALSE);
if (isset($params['active_on'])) {
$params['active_on'] = CRM_Utils_Date::processDate($params['active_on'],
CRM_Utils_Array::value('active_on_time', $params),
) {
$this->_sid = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $this->_fid, 'price_set_id', 'id');
}
- $this->isEvent = False;
+ $this->isEvent = FALSE;
$extendComponentId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_sid, 'extends', 'id');
$this->assign('showMember', FALSE);
if ($memberComponentId == $extendComponentId) {
'financial_type_id',
ts('Financial Type'),
array('' => ts('- select -')) + $financialType,
- true
+ TRUE
);
//CRM_Core_DAO::getFieldValue( 'CRM_Price_DAO_PriceField', $this->_fid, 'weight', 'id' );
array( 'CRM_Core_DAO_OptionValue', $this->_oid, $this->_ogId, 'label' ) );
*/
-
// value
$this->add('text', 'amount', ts('Option Amount'), NULL, TRUE);
$this->_groupTree[$groupId]['fields'][$fieldId] = $groupTree[$groupId]['fields'][$fieldId];
$this->assign('preview_type', 'field');
$url = CRM_Utils_System::url('civicrm/admin/price/field', "reset=1&action=browse&sid={$groupId}");
- $breadCrumb = array(array('title' => ts('Price Set Fields'),
+ $breadCrumb = array(array(
+ 'title' => ts('Price Set Fields'),
'url' => $url,
));
}
$this->assign('preview_type', 'group');
$this->assign('setTitle', CRM_Price_BAO_PriceSet::getTitle($groupId));
$url = CRM_Utils_System::url('civicrm/admin/price', 'reset=1');
- $breadCrumb = array(array('title' => ts('Price Sets'),
+ $breadCrumb = array(array(
+ 'title' => ts('Price Sets'),
'url' => $url,
));
}
CRM_Utils_System::setTitle($title);
$url = CRM_Utils_System::url('civicrm/admin/price', 'reset=1');
- $breadCrumb = array(array('title' => ts('Price Sets'),
+ $breadCrumb = array(array(
+ 'title' => ts('Price Sets'),
'url' => $url,
));
CRM_Utils_System::appendBreadCrumb($breadCrumb);
}
$extends[] = $option;
break;
+
case 'CiviContribute':
$option = $this->createElement('checkbox', $compObj->componentID, NULL, ts('Contribution'));
if (!empty($priceSetUsedTables)) {
}
$extends[] = $option;
break;
+
case 'CiviMember':
$option = $this->createElement('checkbox', $compObj->componentID, NULL, ts('Membership'));
if (!empty($priceSetUsedTables)) {
CRM_Price_BAO_PriceSet::retrieve($params, $defaults);
$extends = explode(CRM_Core_DAO::VALUE_SEPARATOR, $defaults['extends']);
unset($defaults['extends']);
- foreach ($extends as $compId) $defaults['extends'][$compId] = 1;
+ foreach ($extends as $compId) { $defaults['extends'][$compId] = 1;
+ }
}
return $defaults;
$compIds = array();
$extends = CRM_Utils_Array::value('extends', $params);
if (is_array($extends)) {
- foreach ($extends as $compId => $selected) if ($selected) { $compIds[] = $compId; }
+ foreach ($extends as $compId => $selected) { if ($selected) { $compIds[] = $compId;
+ }
+ }
}
$params['extends'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $compIds);
*
* @var boolean
*/
- protected $_isSetReserved = false;
+ protected $_isSetReserved = FALSE;
/**
* Get the action links for this page.
$priceFieldBAO->find();
// display taxTerm for priceFields
- $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME,'contribution_invoice_settings');
+ $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
$taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings);
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
$getTaxDetails = FALSE;
if ($this->_sid) {
$usedBy = CRM_Price_BAO_PriceSet::getUsedBy($this->_sid);
$this->assign('usedBy', $usedBy);
- $this->_isSetReserved= CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_sid, 'is_reserved');
+ $this->_isSetReserved = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_sid, 'is_reserved');
$this->assign('isReserved', $this->_isSetReserved);
CRM_Price_BAO_PriceSet::checkPermission($this->_sid);
*
* @var boolean
*/
- protected $_isSetReserved = false;
+ protected $_isSetReserved = FALSE;
/**
* The action links that we need to display for the browse screen
$financialType = CRM_Contribute_PseudoConstant::financialType();
$taxRate = CRM_Core_PseudoConstant::getTaxRates();
// display taxTerm for priceFields
- $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME,'contribution_invoice_settings');
+ $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
$taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings);
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
$getTaxDetails = FALSE;
if ($this->_sid) {
CRM_Price_BAO_PriceSet::checkPermission($this->_sid);
- $this->_isSetReserved= CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_sid, 'is_reserved');
+ $this->_isSetReserved = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_sid, 'is_reserved');
$this->assign('isReserved', $this->_isSetReserved);
}
//as url contain $sid so append breadcrumb dynamically.
- $breadcrumb = array(array('title' => ts('Price Fields'),
+ $breadcrumb = array(array(
+ 'title' => ts('Price Fields'),
'url' => CRM_Utils_System::url('civicrm/admin/price/field', 'reset=1&sid=' . $this->_sid),
));
CRM_Utils_System::appendBreadCrumb($breadcrumb);
public function browse($action = NULL) {
// get all price sets
$priceSet = array();
- $comps = array('CiviEvent' => ts('Event'),
+ $comps = array(
+ 'CiviEvent' => ts('Event'),
'CiviContribute' => ts('Contribution'),
'CiviMember' => ts('Membership'),
);
$extends[] = $comps[CRM_Core_Component::getComponentName($compId)];
}
}
- $priceSet[$dao->id]['extends'] = implode(', ', $extends);
+ $priceSet[$dao->id]['extends'] = implode(', ', $extends);
// form all action links
$action = array_sum(array_keys($this->actionLinks()));