From 0ed9f379b560739139cd915d8bada490939919db Mon Sep 17 00:00:00 2001 From: eileenmcnaugton Date: Tue, 15 Mar 2016 22:31:00 +1300 Subject: [PATCH] CRM-18240 Add number of installments & acknowledgement sent to pledge search --- CRM/Contribute/BAO/Query.php | 2 +- CRM/Pledge/BAO/Pledge.php | 2 +- CRM/Pledge/BAO/Query.php | 41 +++++++++++++++++---- CRM/Pledge/Form/Search.php | 7 ++-- templates/CRM/Pledge/Form/Search/Common.tpl | 14 +++++++ 5 files changed, 52 insertions(+), 14 deletions(-) diff --git a/CRM/Contribute/BAO/Query.php b/CRM/Contribute/BAO/Query.php index e86b91fabd..ab35b58a65 100644 --- a/CRM/Contribute/BAO/Query.php +++ b/CRM/Contribute/BAO/Query.php @@ -51,7 +51,7 @@ class CRM_Contribute_BAO_Query { * @return array * Associative array of contribution fields */ - public static function &getFields($checkPermission = TRUE) { + public static function getFields($checkPermission = TRUE) { if (!self::$_contributionFields) { self::$_contributionFields = array(); diff --git a/CRM/Pledge/BAO/Pledge.php b/CRM/Pledge/BAO/Pledge.php index b6835b2385..103585ec38 100644 --- a/CRM/Pledge/BAO/Pledge.php +++ b/CRM/Pledge/BAO/Pledge.php @@ -738,7 +738,7 @@ GROUP BY currency * @return array * array of exportable Fields */ - public static function &exportableFields($checkPermission) { + public static function exportableFields($checkPermission) { if (!self::$_exportableFields) { if (!self::$_exportableFields) { self::$_exportableFields = array(); diff --git a/CRM/Pledge/BAO/Query.php b/CRM/Pledge/BAO/Query.php index 2d890f373d..b4bfd73b66 100644 --- a/CRM/Pledge/BAO/Query.php +++ b/CRM/Pledge/BAO/Query.php @@ -38,17 +38,17 @@ class CRM_Pledge_BAO_Query { * * @return array */ - public static function &getFields($checkPermission = TRUE) { - $fields = CRM_Pledge_BAO_Pledge::exportableFields($checkPermission); - return $fields; + public static function getFields($checkPermission = TRUE) { + return CRM_Pledge_BAO_Pledge::exportableFields($checkPermission); } /** * Build select for Pledge. * - * @param $query + * @param CRM_Contact_BAO_Query $query */ public static function select(&$query) { + $statusId = implode(',', array_keys(CRM_Core_PseudoConstant::accountOptionValues("contribution_status", NULL, " AND v.name IN ('Pending', 'Overdue')"))); if (($query->_mode & CRM_Contact_BAO_Query::MODE_PLEDGE) || !empty($query->_returnProperties['pledge_id'])) { $query->_select['pledge_id'] = 'civicrm_pledge.id as pledge_id'; @@ -272,6 +272,26 @@ class CRM_Pledge_BAO_Query { ); return; + case 'pledge_installments_low': + case 'pledge_installments_high': + // process min/max amount + $query->numberRangeBuilder($values, + 'civicrm_pledge', 'pledge_installments', 'installments', 'Number of Installments' + ); + return; + + case 'pledge_acknowledge_date_is_not_null': + if ($value) { + $op = "IS NOT NULL"; + $query->_qill[$grouping][] = ts('Pledge Acknowledgement Sent'); + } + else { + $op = "IS NULL"; + $query->_qill[$grouping][] = ts('Pledge Acknowledgement Not Sent'); + } + $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_pledge.acknowledge_date", $op); + return; + case 'pledge_payment_status_id': case 'pledge_status_id': if ($name == 'pledge_status_id') { @@ -515,17 +535,22 @@ class CRM_Pledge_BAO_Query { $form->addRule('pledge_amount_high', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money'); $statusValues = CRM_Contribute_PseudoConstant::contributionStatus(); - // Remove status values that are only used for recurring contributions for now (Failed and In Progress). unset($statusValues['4']); - + // unset in progress for payment + unset($statusValues['5']); $form->add('select', 'pledge_status_id', ts('Pledge Status'), $statusValues, FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple') ); - // unset in progress for payment - unset($statusValues['5']); + $form->addYesNo('pledge_acknowledge_date_is_not_null', ts('Acknowledgement sent?'), TRUE); + + $form->add('text', 'pledge_installments_low', ts('From'), array('size' => 8, 'maxlength' => 8)); + $form->addRule('pledge_installments_low', ts('Please enter a number'), 'integer'); + + $form->add('text', 'pledge_installments_high', ts('To'), array('size' => 8, 'maxlength' => 8)); + $form->addRule('pledge_installments_high', ts('Please enter number.'), 'integer'); $form->add('select', 'pledge_payment_status_id', ts('Pledge Payment Status'), $statusValues, diff --git a/CRM/Pledge/Form/Search.php b/CRM/Pledge/Form/Search.php index 4c0facb86e..561aa360f2 100644 --- a/CRM/Pledge/Form/Search.php +++ b/CRM/Pledge/Form/Search.php @@ -67,18 +67,15 @@ class CRM_Pledge_Form_Search extends CRM_Core_Form_Search { */ public function preProcess() { - // set the button names - $this->_searchButtonName = $this->getButtonName('refresh'); $this->_actionButtonName = $this->getButtonName('next', 'action'); $this->_done = FALSE; $this->defaults = array(); - // we allow the controller to set force/reset externally, useful when we are being // driven by the wizard framework - + $this->_reset = CRM_Utils_Request::retrieve('reset', 'Boolean', CRM_Core_DAO::$_nullObject); $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE); $this->_limit = CRM_Utils_Request::retrieve('limit', 'Positive', $this); @@ -302,6 +299,8 @@ class CRM_Pledge_Form_Search extends CRM_Core_Form_Search { * * @param array $fields * Posted values of the form. + * + * @return array|bool */ public static function formRule($fields) { $errors = array(); diff --git a/templates/CRM/Pledge/Form/Search/Common.tpl b/templates/CRM/Pledge/Form/Search/Common.tpl index 119503ef5f..3348db38d1 100644 --- a/templates/CRM/Pledge/Form/Search/Common.tpl +++ b/templates/CRM/Pledge/Form/Search/Common.tpl @@ -88,6 +88,20 @@ {$form.pledge_frequency_unit.html} + + + {ts}Number of Installments{/ts} + {$form.pledge_installments_low.label} {$form.pledge_installments_low.html} +    {$form.pledge_installments_high.label} {$form.pledge_installments_high.html} + + + + + +
{$form.pledge_acknowledge_date_is_not_null.label}   {$form.pledge_acknowledge_date_is_not_null.html} +   + + {* campaign in pledge search *} {include file="CRM/Campaign/Form/addCampaignToComponent.tpl" -- 2.25.1