From c0aaecf9480d0fc270319f23d9693119bf8afa94 Mon Sep 17 00:00:00 2001 From: Elliott Eggleston Date: Wed, 9 Oct 2019 15:45:55 +0200 Subject: [PATCH] dev/financial#72 Filter contrib status search selects Replacing pseudoConstant calls with BAO buildOptions in 'search' context. This commit is only intended to touch places where we are building a list of options to offer to the user, not places where we are displaying results. In practice this doesn't remove any currently available statuses, but now we can filter our the proposed 'Template' status. --- CRM/Contribute/BAO/ContributionRecur.php | 2 +- CRM/Contribute/BAO/Query.php | 4 ++-- CRM/Report/Form/Contribute/Bookkeeping.php | 4 ++-- CRM/Report/Form/Contribute/Detail.php | 2 +- CRM/Report/Form/Contribute/History.php | 2 +- CRM/Report/Form/Contribute/HouseholdSummary.php | 2 +- CRM/Report/Form/Contribute/Lybunt.php | 2 +- CRM/Report/Form/Contribute/OrganizationSummary.php | 2 +- CRM/Report/Form/Contribute/Recur.php | 2 +- CRM/Report/Form/Contribute/Repeat.php | 2 +- CRM/Report/Form/Contribute/SoftCredit.php | 2 +- CRM/Report/Form/Contribute/Summary.php | 4 ++-- CRM/Report/Form/Contribute/Sybunt.php | 2 +- CRM/Report/Form/Contribute/TopDonor.php | 2 +- CRM/Report/Form/Event/ParticipantListing.php | 2 +- CRM/Report/Form/Member/ContributionDetail.php | 2 +- CRM/Report/Form/Member/Detail.php | 2 +- CRM/Report/Form/Member/Summary.php | 2 +- 18 files changed, 21 insertions(+), 21 deletions(-) diff --git a/CRM/Contribute/BAO/ContributionRecur.php b/CRM/Contribute/BAO/ContributionRecur.php index 7f80887281..38e7cb999a 100644 --- a/CRM/Contribute/BAO/ContributionRecur.php +++ b/CRM/Contribute/BAO/ContributionRecur.php @@ -774,7 +774,7 @@ INNER JOIN civicrm_contribution con ON ( con.id = mp.contribution_id ) // Add field for contribution status $form->addSelect('contribution_recur_contribution_status_id', - ['entity' => 'contribution', 'multiple' => 'multiple', 'context' => 'search', 'options' => CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'label')] + ['entity' => 'contribution', 'multiple' => 'multiple', 'context' => 'search', 'options' => CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'search')] ); $form->addElement('text', 'contribution_recur_processor_id', ts('Processor ID'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionRecur', 'processor_id')); diff --git a/CRM/Contribute/BAO/Query.php b/CRM/Contribute/BAO/Query.php index 8d5e16ee5c..226544fc22 100644 --- a/CRM/Contribute/BAO/Query.php +++ b/CRM/Contribute/BAO/Query.php @@ -923,7 +923,7 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query { } /** - * Add all the elements shared between contribute search and advnaced search. + * Add all the elements shared between contribute search and advanced search. * * @param \CRM_Contribute_Form_Search $form * @@ -976,7 +976,7 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query { ts('Personal Campaign Page'), CRM_Contribute_PseudoConstant::pcPage(), FALSE, ['class' => 'crm-select2', 'multiple' => 'multiple', 'placeholder' => ts('- any -')]); - $statusValues = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'contribution_status_id'); + $statusValues = CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'search'); $form->add('select', 'contribution_status_id', ts('Contribution Status'), $statusValues, FALSE, ['class' => 'crm-select2', 'multiple' => 'multiple'] diff --git a/CRM/Report/Form/Contribute/Bookkeeping.php b/CRM/Report/Form/Contribute/Bookkeeping.php index 014225adf8..230baacfbd 100644 --- a/CRM/Report/Form/Contribute/Bookkeeping.php +++ b/CRM/Report/Form/Contribute/Bookkeeping.php @@ -326,7 +326,7 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form { 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'label'), + 'options' => CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'search'), 'default' => [1], ], ], @@ -386,7 +386,7 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form { 'status_id' => [ 'title' => ts('Financial Transaction Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'label'), + 'options' => CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'search'), 'default' => [1], ], 'card_type_id' => [ diff --git a/CRM/Report/Form/Contribute/Detail.php b/CRM/Report/Form/Contribute/Detail.php index a6117b3808..65f2db9f38 100644 --- a/CRM/Report/Form/Contribute/Detail.php +++ b/CRM/Report/Form/Contribute/Detail.php @@ -236,7 +236,7 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form { 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'label'), + 'options' => CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'search'), 'default' => [1], 'type' => CRM_Utils_Type::T_INT, ], diff --git a/CRM/Report/Form/Contribute/History.php b/CRM/Report/Form/Contribute/History.php index 2f8b2e74b1..6fed16b24f 100644 --- a/CRM/Report/Form/Contribute/History.php +++ b/CRM/Report/Form/Contribute/History.php @@ -248,7 +248,7 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'label'), + 'options' => CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'search'), 'default' => [1], ], 'financial_type_id' => [ diff --git a/CRM/Report/Form/Contribute/HouseholdSummary.php b/CRM/Report/Form/Contribute/HouseholdSummary.php index 8b300a0cbb..2dd9e10566 100644 --- a/CRM/Report/Form/Contribute/HouseholdSummary.php +++ b/CRM/Report/Form/Contribute/HouseholdSummary.php @@ -149,7 +149,7 @@ class CRM_Report_Form_Contribute_HouseholdSummary extends CRM_Report_Form { 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'label'), + 'options' => CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'search'), 'default' => [1], ], 'financial_type_id' => [ diff --git a/CRM/Report/Form/Contribute/Lybunt.php b/CRM/Report/Form/Contribute/Lybunt.php index 15526bd030..078595fd32 100644 --- a/CRM/Report/Form/Contribute/Lybunt.php +++ b/CRM/Report/Form/Contribute/Lybunt.php @@ -226,7 +226,7 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'label'), + 'options' => CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'search'), 'default' => ['1'], ], ], diff --git a/CRM/Report/Form/Contribute/OrganizationSummary.php b/CRM/Report/Form/Contribute/OrganizationSummary.php index 92d98e2521..1de4d57870 100644 --- a/CRM/Report/Form/Contribute/OrganizationSummary.php +++ b/CRM/Report/Form/Contribute/OrganizationSummary.php @@ -159,7 +159,7 @@ class CRM_Report_Form_Contribute_OrganizationSummary extends CRM_Report_Form { 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'label'), + 'options' => CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'search'), 'default' => [1], ], ], diff --git a/CRM/Report/Form/Contribute/Recur.php b/CRM/Report/Form/Contribute/Recur.php index 805c7f5a2b..ac4eae6fd9 100644 --- a/CRM/Report/Form/Contribute/Recur.php +++ b/CRM/Report/Form/Contribute/Recur.php @@ -187,7 +187,7 @@ class CRM_Report_Form_Contribute_Recur extends CRM_Report_Form { 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'label'), + 'options' => CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'search'), 'default' => [5], 'type' => CRM_Utils_Type::T_INT, ], diff --git a/CRM/Report/Form/Contribute/Repeat.php b/CRM/Report/Form/Contribute/Repeat.php index e9540eb103..94338418a7 100644 --- a/CRM/Report/Form/Contribute/Repeat.php +++ b/CRM/Report/Form/Contribute/Repeat.php @@ -242,7 +242,7 @@ class CRM_Report_Form_Contribute_Repeat extends CRM_Report_Form { 'contribution_status_id' => array( 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'label'), + 'options' => CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'search'), 'default' => array('1'), ), ), diff --git a/CRM/Report/Form/Contribute/SoftCredit.php b/CRM/Report/Form/Contribute/SoftCredit.php index 24b1c5a730..a37fdca580 100644 --- a/CRM/Report/Form/Contribute/SoftCredit.php +++ b/CRM/Report/Form/Contribute/SoftCredit.php @@ -252,7 +252,7 @@ class CRM_Report_Form_Contribute_SoftCredit extends CRM_Report_Form { 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'label'), + 'options' => CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'search'), 'default' => [1], ], ], diff --git a/CRM/Report/Form/Contribute/Summary.php b/CRM/Report/Form/Contribute/Summary.php index 2239525f91..735b8c50a8 100644 --- a/CRM/Report/Form/Contribute/Summary.php +++ b/CRM/Report/Form/Contribute/Summary.php @@ -156,7 +156,7 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { 'contribution_status_id' => array( 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'label'), + 'options' => CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'search'), 'default' => array(1), 'type' => CRM_Utils_Type::T_INT, ), @@ -220,7 +220,7 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { 'contribution_status_id' => array( 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'label'), + 'options' => CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'search'), 'default' => array(1), 'type' => CRM_Utils_Type::T_INT, ), diff --git a/CRM/Report/Form/Contribute/Sybunt.php b/CRM/Report/Form/Contribute/Sybunt.php index 98ac7baefc..463d3f9db6 100644 --- a/CRM/Report/Form/Contribute/Sybunt.php +++ b/CRM/Report/Form/Contribute/Sybunt.php @@ -231,7 +231,7 @@ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form { 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'label'), + 'options' => CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'search'), 'default' => ['1'], ], ], diff --git a/CRM/Report/Form/Contribute/TopDonor.php b/CRM/Report/Form/Contribute/TopDonor.php index 093491fdc2..a37280741d 100644 --- a/CRM/Report/Form/Contribute/TopDonor.php +++ b/CRM/Report/Form/Contribute/TopDonor.php @@ -156,7 +156,7 @@ class CRM_Report_Form_Contribute_TopDonor extends CRM_Report_Form { 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'label'), + 'options' => CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'search'), 'default' => [1], ], ], diff --git a/CRM/Report/Form/Event/ParticipantListing.php b/CRM/Report/Form/Event/ParticipantListing.php index a3106d0b7d..063950ae23 100644 --- a/CRM/Report/Form/Event/ParticipantListing.php +++ b/CRM/Report/Form/Event/ParticipantListing.php @@ -353,7 +353,7 @@ class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form { 'contribution_status_id' => array( 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'label'), + 'options' => CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'search'), 'default' => NULL, ), ), diff --git a/CRM/Report/Form/Member/ContributionDetail.php b/CRM/Report/Form/Member/ContributionDetail.php index ae361ba20c..a976715062 100644 --- a/CRM/Report/Form/Member/ContributionDetail.php +++ b/CRM/Report/Form/Member/ContributionDetail.php @@ -221,7 +221,7 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form { 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'label'), + 'options' => CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'search'), 'default' => [1], ], 'total_amount' => ['title' => ts('Contribution Amount')], diff --git a/CRM/Report/Form/Member/Detail.php b/CRM/Report/Form/Member/Detail.php index c9d1effe5d..57820dd6db 100644 --- a/CRM/Report/Form/Member/Detail.php +++ b/CRM/Report/Form/Member/Detail.php @@ -225,7 +225,7 @@ class CRM_Report_Form_Member_Detail extends CRM_Report_Form { 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'label'), + 'options' => CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'search'), 'type' => CRM_Utils_Type::T_INT, ], 'total_amount' => ['title' => ts('Contribution Amount')], diff --git a/CRM/Report/Form/Member/Summary.php b/CRM/Report/Form/Member/Summary.php index 620189b553..2afd8a43f7 100644 --- a/CRM/Report/Form/Member/Summary.php +++ b/CRM/Report/Form/Member/Summary.php @@ -165,7 +165,7 @@ class CRM_Report_Form_Member_Summary extends CRM_Report_Form { 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'label'), + 'options' => CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'search'), ], ], 'grouping' => 'member-fields', -- 2.25.1