diff --git a/CRM/Pledge/BAO/Query.php b/CRM/Pledge/BAO/Query.php index 1b3779060efd..733e26abda30 100644 --- a/CRM/Pledge/BAO/Query.php +++ b/CRM/Pledge/BAO/Query.php @@ -82,6 +82,12 @@ public static function select(&$query) { $query->_tables['civicrm_pledge'] = $query->_whereTables['civicrm_pledge'] = 1; } + if (!empty($query->_returnProperties['pledge_end_date'])) { + $query->_select['pledge_end_date'] = 'civicrm_pledge.end_date as pledge_end_date'; + $query->_element['pledge_end_date'] = 1; + $query->_tables['civicrm_pledge'] = $query->_whereTables['civicrm_pledge'] = 1; + } + if (!empty($query->_returnProperties['pledge_start_date'])) { $query->_select['pledge_start_date'] = 'civicrm_pledge.start_date as pledge_start_date'; $query->_element['pledge_start_date'] = 1; @@ -531,11 +537,27 @@ public static function extraReturnProperties($mode) { public static function getSearchFieldMetadata() { $fields = [ 'pledge_status_id', + 'pledge_start_date', + 'pledge_end_date', + 'pledge_create_date', ]; $metadata = civicrm_api3('Pledge', 'getfields', [])['values']; return array_intersect_key($metadata, array_flip($fields)); } + /** + * Get the metadata for fields to be included on the grant search form. + * + * @throws \CiviCRM_API3_Exception + */ + public static function getPledgePaymentSearchFieldMetadata() { + $fields = [ + 'pledge_payment_scheduled_date', + ]; + $metadata = civicrm_api3('PledgePayment', 'getfields', [])['values']; + return array_intersect_key($metadata, array_flip($fields)); + } + /** * Build the search for for pledges. * @@ -547,13 +569,8 @@ public static function getSearchFieldMetadata() { public static function buildSearchForm(&$form) { // pledge related dates $form->addSearchFieldMetadata(['Pledge' => self::getSearchFieldMetadata()]); + $form->addSearchFieldMetadata(['PledgePayment' => self::getPledgePaymentSearchFieldMetadata()]); $form->addFormFieldsFromMetadata(); - CRM_Core_Form_Date::buildDateRange($form, 'pledge_start_date', 1, '_low', '_high', ts('From'), FALSE); - CRM_Core_Form_Date::buildDateRange($form, 'pledge_end_date', 1, '_low', '_high', ts('From'), FALSE); - CRM_Core_Form_Date::buildDateRange($form, 'pledge_create_date', 1, '_low', '_high', ts('From'), FALSE); - - // pledge payment related dates - CRM_Core_Form_Date::buildDateRange($form, 'pledge_payment_date', 1, '_low', '_high', ts('From'), FALSE); $form->addYesNo('pledge_test', ts('Pledge is a Test?'), TRUE); $form->add('text', 'pledge_amount_low', ts('From'), ['size' => 8, 'maxlength' => 8]); diff --git a/CRM/Pledge/DAO/Pledge.php b/CRM/Pledge/DAO/Pledge.php index fe6abc9014b7..baddf50a8683 100644 --- a/CRM/Pledge/DAO/Pledge.php +++ b/CRM/Pledge/DAO/Pledge.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Pledge/Pledge.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:5e5bb725caa46ae10f0c5d039a03c675) + * (GenCodeChecksum:238d9af98168511a7e6694e3d30e533d) */ /** @@ -420,7 +420,7 @@ public static function &fields() { 'type' => 'Text', ], ], - 'start_date' => [ + 'pledge_start_date' => [ 'name' => 'start_date', 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME, 'title' => ts('Pledge Start Date'), @@ -431,6 +431,7 @@ public static function &fields() { 'entity' => 'Pledge', 'bao' => 'CRM_Pledge_BAO_Pledge', 'localizable' => 0, + 'unique_title' => ts('Payments Start Date'), 'html' => [ 'type' => 'Select Date', ], @@ -491,7 +492,7 @@ public static function &fields() { 'type' => 'Select Date', ], ], - 'end_date' => [ + 'pledge_end_date' => [ 'name' => 'end_date', 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME, 'title' => ts('Pledge End Date'), @@ -501,6 +502,7 @@ public static function &fields() { 'entity' => 'Pledge', 'bao' => 'CRM_Pledge_BAO_Pledge', 'localizable' => 0, + 'unique_title' => ts('Payments Ended Date'), 'html' => [ 'type' => 'Select Date', ], diff --git a/CRM/Pledge/DAO/PledgePayment.php b/CRM/Pledge/DAO/PledgePayment.php index 5e1da56ae5f8..879a6fa973d2 100644 --- a/CRM/Pledge/DAO/PledgePayment.php +++ b/CRM/Pledge/DAO/PledgePayment.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Pledge/PledgePayment.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:7dfb4f8000b79fa8b1abab1de3712fc1) + * (GenCodeChecksum:563e2926d00b9fe0c4919bfd9a0a05e7) */ /** @@ -236,6 +236,7 @@ public static function &fields() { 'entity' => 'PledgePayment', 'bao' => 'CRM_Pledge_BAO_PledgePayment', 'localizable' => 0, + 'unique_title' => ts('Payment Scheduled'), 'html' => [ 'type' => 'Select Date', 'formatType' => 'activityDate', diff --git a/CRM/Pledge/Form/Search.php b/CRM/Pledge/Form/Search.php index ecf8f503e464..0e8b05ccc81d 100644 --- a/CRM/Pledge/Form/Search.php +++ b/CRM/Pledge/Form/Search.php @@ -321,19 +321,6 @@ public function addRules() { $this->addFormRule(['CRM_Pledge_Form_Search', 'formRule']); } - /** - * Set the default form values. - * - * - * @return array - * the default array reference - */ - public function setDefaultValues() { - $defaults = []; - $defaults = $this->_formValues; - return $defaults; - } - public function fixFormValues() { if (!$this->_force) { return; diff --git a/CRM/Upgrade/Incremental/php/FiveEighteen.php b/CRM/Upgrade/Incremental/php/FiveEighteen.php index 54af4a96574c..e475d3b060a1 100644 --- a/CRM/Upgrade/Incremental/php/FiveEighteen.php +++ b/CRM/Upgrade/Incremental/php/FiveEighteen.php @@ -82,6 +82,19 @@ public function upgrade_5_18_alpha1($rev) { $this->addTask('Remove Foreign Key from civicrm_dashboard on domain_id if exists', 'removeDomainIDFK'); $this->addTask('Remove Index on domain_id that might have been randomly added in the same format as FK', 'dropIndex', 'civicrm_dashboard', 'FK_civicrm_dashboard_domain_id'); $this->addTask('Re-Create Foreign key between civicrm_dashboard and civicrm_domain correctly', 'recreateDashboardFK'); + $this->addTask('Update smart groups to rename filters on pledge_payment_date to pledge_payment_scheduled_date', 'updateSmartGroups', [ + 'renameField' => [ + ['old' => 'pledge_payment_date', 'new' => 'pledge_payment_scheduled_date'], + ], + ]); + $this->addTask('Update smart groups where jcalendar fields have been converted to datepicker', 'updateSmartGroups', [ + 'datepickerConversion' => [ + 'pledge_payment_scheduled_date', + 'pledge_create_date', + 'pledge_end_date', + 'pledge_start_date', + ], + ]); } public static function removeDomainIDFK() { diff --git a/templates/CRM/Pledge/Form/Search/Common.tpl b/templates/CRM/Pledge/Form/Search/Common.tpl index dbd5cc6d6ced..9168c503b347 100644 --- a/templates/CRM/Pledge/Form/Search/Common.tpl +++ b/templates/CRM/Pledge/Form/Search/Common.tpl @@ -25,7 +25,7 @@ *}