From ba1dcfda6e75dbf41de5e27550f2828b2d5a08dc Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 6 Jan 2015 13:21:23 -0800 Subject: [PATCH] INFRA-132 - CRM/Price - phpcbf --- CRM/Price/BAO/LineItem.php | 19 ++++++++-------- CRM/Price/BAO/PriceFieldValue.php | 7 +++--- CRM/Price/BAO/PriceSet.php | 22 ++++++++++--------- CRM/Price/Form/Field.php | 36 +++++++++++++++---------------- CRM/Price/Form/Option.php | 5 ++--- CRM/Price/Form/Preview.php | 6 ++++-- CRM/Price/Form/Set.php | 12 ++++++++--- CRM/Price/Page/Field.php | 6 +++--- CRM/Price/Page/Option.php | 9 ++++---- CRM/Price/Page/Set.php | 5 +++-- 10 files changed, 70 insertions(+), 57 deletions(-) diff --git a/CRM/Price/BAO/LineItem.php b/CRM/Price/BAO/LineItem.php index 67fbde540d..1a7f49975d 100644 --- a/CRM/Price/BAO/LineItem.php +++ b/CRM/Price/BAO/LineItem.php @@ -131,7 +131,7 @@ AND li.entity_id = {$entityId} * @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); } /** @@ -154,7 +154,7 @@ AND li.entity_id = {$entityId} * * @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, @@ -212,7 +212,7 @@ AND li.entity_id = {$entityId} ); $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; @@ -272,7 +272,7 @@ AND li.entity_id = {$entityId} * to the price set used for particular event * @param array $values * Reference to the values array(. - this is + this is * lineItem array) * * @return void @@ -420,8 +420,9 @@ AND li.entity_id = {$entityId} * @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 @@ -451,7 +452,7 @@ AND li.entity_id = {$entityId} $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'), @@ -467,7 +468,7 @@ AND li.entity_id = {$entityId} CRM_Core_DAO::executeQuery($query, $params); } - /** + /** * Build line items array. * @param array $params * Form values. @@ -546,10 +547,10 @@ AND li.entity_id = {$entityId} 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; } diff --git a/CRM/Price/BAO/PriceFieldValue.php b/CRM/Price/BAO/PriceFieldValue.php index 0f7ca83eae..8f9f8e92aa 100644 --- a/CRM/Price/BAO/PriceFieldValue.php +++ b/CRM/Price/BAO/PriceFieldValue.php @@ -89,7 +89,8 @@ class CRM_Price_BAO_PriceFieldValue extends CRM_Price_DAO_PriceFieldValue { } if ($id && !empty($params['weight'])) { - if (isset($params['name']))unset($params['name']); + if (isset($params['name'])) { unset($params['name']); + } $oldWeight = NULL; if ($id) { @@ -245,9 +246,9 @@ class CRM_Price_BAO_PriceFieldValue extends CRM_Price_DAO_PriceFieldValue { * * @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 diff --git a/CRM/Price/BAO/PriceSet.php b/CRM/Price/BAO/PriceSet.php index ed7adbb062..d7c974aa40 100644 --- a/CRM/Price/BAO/PriceSet.php +++ b/CRM/Price/BAO/PriceSet.php @@ -387,7 +387,8 @@ WHERE ct.id = cp.financial_type_id AND 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) { @@ -940,14 +941,14 @@ WHERE id = %1"; 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); @@ -1062,7 +1063,7 @@ WHERE id = %1"; // 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); } } } @@ -1110,7 +1111,8 @@ WHERE id = %1"; $title = ts('[Copy id %1]', array(1 => $maxId + 1)); $fieldsFix = array( - 'suffix' => array('title' => ' ' . $title, + 'suffix' => array( + 'title' => ' ' . $title, 'name' => '__Copy_id_' . ($maxId + 1) . '_', ), ); @@ -1309,7 +1311,7 @@ GROUP BY mt.member_of_contact_id"; * * @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 @@ -1328,7 +1330,7 @@ GROUP BY mt.member_of_contact_id"; */ 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 @@ -1352,11 +1354,11 @@ WHERE ps.id = %1 $daoAutoRenew = 0; } if (!empty($autoRenew) && !in_array($daoAutoRenew, $autoRenew)) { - return true; + return TRUE; } $autoRenew[] = $daoAutoRenew; } - return false; + return FALSE; } /** diff --git a/CRM/Price/Form/Field.php b/CRM/Price/Form/Field.php index 69a7338339..5ba917df3c 100644 --- a/CRM/Price/Form/Field.php +++ b/CRM/Price/Form/Field.php @@ -149,7 +149,7 @@ class CRM_Price_Form_Field extends CRM_Core_Form { } $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'); } @@ -196,10 +196,10 @@ class CRM_Price_Form_Field extends CRM_Core_Form { } $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'); } @@ -207,7 +207,7 @@ class CRM_Price_Form_Field extends CRM_Core_Form { $this->add('select', 'financial_type_id', ts('Financial Type'), - array(' '=> ts('- select -')) + $financialType + array(' ' => ts('- select -')) + $financialType ); $this->assign('useForMember', FALSE); @@ -533,21 +533,21 @@ class CRM_Price_Form_Field extends CRM_Core_Form { 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; @@ -614,7 +614,7 @@ class CRM_Price_Form_Field extends CRM_Core_Form { $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), diff --git a/CRM/Price/Form/Option.php b/CRM/Price/Form/Option.php index afa883813b..df05f6e7e6 100644 --- a/CRM/Price/Form/Option.php +++ b/CRM/Price/Form/Option.php @@ -158,7 +158,7 @@ class CRM_Price_Form_Option extends CRM_Core_Form { ) { $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) { @@ -195,7 +195,7 @@ class CRM_Price_Form_Option extends CRM_Core_Form { 'financial_type_id', ts('Financial Type'), array('' => ts('- select -')) + $financialType, - true + TRUE ); //CRM_Core_DAO::getFieldValue( 'CRM_Price_DAO_PriceField', $this->_fid, 'weight', 'id' ); @@ -207,7 +207,6 @@ class CRM_Price_Form_Option extends CRM_Core_Form { array( 'CRM_Core_DAO_OptionValue', $this->_oid, $this->_ogId, 'label' ) ); */ - // value $this->add('text', 'amount', ts('Option Amount'), NULL, TRUE); diff --git a/CRM/Price/Form/Preview.php b/CRM/Price/Form/Preview.php index 934bb003d6..89c202c74e 100644 --- a/CRM/Price/Form/Preview.php +++ b/CRM/Price/Form/Preview.php @@ -69,7 +69,8 @@ class CRM_Price_Form_Preview extends CRM_Core_Form { $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, )); } @@ -79,7 +80,8 @@ class CRM_Price_Form_Preview extends CRM_Core_Form { $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, )); } diff --git a/CRM/Price/Form/Set.php b/CRM/Price/Form/Set.php index 0270dc3ada..4389bc079e 100644 --- a/CRM/Price/Form/Set.php +++ b/CRM/Price/Form/Set.php @@ -70,7 +70,8 @@ class CRM_Price_Form_Set extends CRM_Core_Form { 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); @@ -149,6 +150,7 @@ class CRM_Price_Form_Set extends CRM_Core_Form { } $extends[] = $option; break; + case 'CiviContribute': $option = $this->createElement('checkbox', $compObj->componentID, NULL, ts('Contribution')); if (!empty($priceSetUsedTables)) { @@ -161,6 +163,7 @@ class CRM_Price_Form_Set extends CRM_Core_Form { } $extends[] = $option; break; + case 'CiviMember': $option = $this->createElement('checkbox', $compObj->componentID, NULL, ts('Membership')); if (!empty($priceSetUsedTables)) { @@ -244,7 +247,8 @@ class CRM_Price_Form_Set extends CRM_Core_Form { 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; @@ -267,7 +271,9 @@ class CRM_Price_Form_Set extends CRM_Core_Form { $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); diff --git a/CRM/Price/Page/Field.php b/CRM/Price/Page/Field.php index 4d3bbe61e6..4f9b192cc0 100644 --- a/CRM/Price/Page/Field.php +++ b/CRM/Price/Page/Field.php @@ -64,7 +64,7 @@ class CRM_Price_Page_Field extends CRM_Core_Page { * * @var boolean */ - protected $_isSetReserved = false; + protected $_isSetReserved = FALSE; /** * Get the action links for this page. @@ -131,7 +131,7 @@ class CRM_Price_Page_Field extends CRM_Core_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; @@ -262,7 +262,7 @@ class CRM_Price_Page_Field extends CRM_Core_Page { 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); diff --git a/CRM/Price/Page/Option.php b/CRM/Price/Page/Option.php index 270c338b17..0e538d2206 100644 --- a/CRM/Price/Page/Option.php +++ b/CRM/Price/Page/Option.php @@ -64,7 +64,7 @@ class CRM_Price_Page_Option extends CRM_Core_Page { * * @var boolean */ - protected $_isSetReserved = false; + protected $_isSetReserved = FALSE; /** * The action links that we need to display for the browse screen @@ -130,7 +130,7 @@ class CRM_Price_Page_Option extends CRM_Core_Page { $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; @@ -271,11 +271,12 @@ class CRM_Price_Page_Option extends CRM_Core_Page { 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); diff --git a/CRM/Price/Page/Set.php b/CRM/Price/Page/Set.php index 9a462eb21d..272a42cbc6 100644 --- a/CRM/Price/Page/Set.php +++ b/CRM/Price/Page/Set.php @@ -255,7 +255,8 @@ class CRM_Price_Page_Set extends CRM_Core_Page { 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'), ); @@ -280,7 +281,7 @@ class CRM_Price_Page_Set extends CRM_Core_Page { $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())); -- 2.25.1