* @param CRM_Contact_BAO_Query $query
*/
public static function whereClauseSingle(&$values, &$query) {
+ if ($query->buildDateRangeQuery($values)) {
+ // @todo - move this to Contact_Query in or near the call to
+ // $this->buildRelativeDateQuery($values);
+ return;
+ }
list($name, $op, $value, $grouping) = $values;
switch ($name) {
case 'member_join_date_low':
case 'member_join_date_high':
+ Civi::log()->warning(
+ 'member_join_date field is deprecated please use membership_join_date field instead',
+ ['civi.tag' => 'deprecated']
+ );
+ $fldName = str_replace(['_low', '_high'], '', $name);
$query->dateQueryBuilder($values,
- 'civicrm_membership', 'member_join_date', 'join_date',
+ 'civicrm_membership', $fldName, 'join_date',
'Member Since'
);
return;
case 'membership_start_date':
case 'member_start_date_low':
case 'member_start_date_high':
+ Civi::log()->warning(
+ 'member_start_date field is deprecated please use membership_start_date field instead',
+ ['civi.tag' => 'deprecated']
+ );
$fldName = str_replace(['_low', '_high'], '', $name);
$query->dateQueryBuilder($values,
'civicrm_membership', $fldName, 'start_date',
case 'membership_end_date':
case 'member_end_date_low':
case 'member_end_date_high':
+ Civi::log()->warning(
+ 'member_end_date field is deprecated please use membership_end_date field instead',
+ ['civi.tag' => 'deprecated']
+ );
$fldName = str_replace(['_low', '_high'], '', $name);
$query->dateQueryBuilder($values,
'civicrm_membership', $fldName, 'end_date',
$query->_qill[$grouping][] = $value ? ts("Membership Status Is Overriden") : ts("Membership Status Is NOT Overriden");
$query->_tables['civicrm_membership'] = $query->_whereTables['civicrm_membership'] = 1;
return;
+
}
}
return $properties;
}
+ /**
+ * Get the metadata for fields to be included on the grant search form.
+ *
+ * @throws \CiviCRM_API3_Exception
+ */
+ public static function getSearchFieldMetadata() {
+ $fields = [
+ 'membership_join_date',
+ 'membership_start_date',
+ 'membership_end_date',
+ ];
+ $metadata = civicrm_api3('Membership', 'getfields', [])['values'];
+ return array_intersect_key($metadata, array_flip($fields));
+ }
+
/**
* Build the search form.
*
* @param CRM_Core_Form $form
*/
public static function buildSearchForm(&$form) {
+ $form->addSearchFieldMetadata(['Membership' => self::getSearchFieldMetadata()]);
+ $form->addFormFieldsFromMetadata();
$membershipStatus = CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'label', FALSE, FALSE);
$form->add('select', 'membership_status_id', ts('Membership Status'), $membershipStatus, FALSE, [
'id' => 'membership_status_id',
$form->addElement('text', 'member_source', ts('Source'));
$form->add('number', 'membership_id', ts('Membership ID'), ['class' => 'four', 'min' => 1]);
- CRM_Core_Form_Date::buildDateRange($form, 'member_join_date', 1, '_low', '_high', ts('From'), FALSE);
- $form->addElement('hidden', 'member_join_date_range_error');
-
- CRM_Core_Form_Date::buildDateRange($form, 'member_start_date', 1, '_low', '_high', ts('From'), FALSE);
- $form->addElement('hidden', 'member_start_date_range_error');
-
- CRM_Core_Form_Date::buildDateRange($form, 'member_end_date', 1, '_low', '_high', ts('From'), FALSE);
- $form->addElement('hidden', 'member_end_date_range_error');
-
- $form->addFormRule(['CRM_Member_BAO_Query', 'formRule'], $form);
-
$form->addYesNo('membership_is_current_member', ts('Current Member?'), TRUE);
$form->addYesNo('member_is_primary', ts('Primary Member?'), TRUE);
$form->addYesNo('member_pay_later', ts('Pay Later?'), TRUE);
}
}
- /**
- * Custom form rules.
- *
- * @param array $fields
- * @param array $files
- * @param CRM_Core_Form $form
- *
- * @return bool|array
- */
- public static function formRule($fields, $files, $form) {
- $errors = [];
-
- if ((empty($fields['member_join_date_low']) || empty($fields['member_join_date_high'])) && (empty($fields['member_start_date_low']) || empty($fields['member_start_date_high'])) && (empty($fields['member_end_date_low']) || empty($fields['member_end_date_high']))) {
- return TRUE;
- }
-
- CRM_Utils_Rule::validDateRange($fields, 'member_join_date', $errors, ts('Member Since'));
- CRM_Utils_Rule::validDateRange($fields, 'member_start_date', $errors, ts('Start Date'));
- CRM_Utils_Rule::validDateRange($fields, 'member_end_date', $errors, ts('End Date'));
-
- return empty($errors) ? TRUE : $errors;
- }
-
}
$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'],
+ ['old' => 'pledge_payment_date_relative', 'new' => 'pledge_payment_scheduled_date_relative'],
+ ['old' => 'pledge_payment_date_high', 'new' => 'pledge_payment_scheduled_date_high'],
+ ['old' => 'pledge_payment_date_low', 'new' => 'pledge_payment_scheduled_date_low'],
+ ['old' => 'member_join_date_relative', 'new' => 'membership_join_date_relative'],
+ ['old' => 'member_join_date_high', 'new' => 'membership_join_date_high'],
+ ['old' => 'member_join_date_low', 'new' => 'membership_join_date_low'],
+ ['old' => 'member_start_date_relative', 'new' => 'membership_start_date_relative'],
+ ['old' => 'member_start_date_high', 'new' => 'membership_start_date_high'],
+ ['old' => 'member_start_date_low', 'new' => 'membership_start_date_low'],
+ ['old' => 'member_end_date_relative', 'new' => 'membership_end_date_relative'],
+ ['old' => 'member_end_date_high', 'new' => 'membership_end_date_high'],
+ ['old' => 'member_end_date_low', 'new' => 'membership_end_date_low'],
],
]);
$this->addTask('Update smart groups where jcalendar fields have been converted to datepicker', 'updateSmartGroups', [
'pledge_create_date',
'pledge_end_date',
'pledge_start_date',
+ 'membership_join_date',
+ 'membership_end_date',
+ 'membership_start_date',
],
]);
$this->addTask('Update civicrm_mapping_field and civicrm_uf_field for change in join_date name', 'updateJoinDateMappingUF');
</tr>
<tr>
- <td>
- {$form.member_source.label}
- <br />{$form.member_source.html}
- <p>
- {$form.member_test.label} {help id="is-test" file="CRM/Contact/Form/Search/Advanced"} {$form.member_test.html}
- </p>
+ <td>{$form.member_source.label}<br />
+ {$form.member_source.html}
</td>
<td>
- <p>
- {$form.membership_is_current_member.label}
+ {$form.membership_is_current_member.label}<br />
{$form.membership_is_current_member.html}
- </p>
- <p>
- {$form.member_is_primary.label}
- {help id="id-member_is_primary" file="CRM/Member/Form/Search.hlp"}
- {$form.member_is_primary.html}
- </p>
- <p>
- {$form.member_pay_later.label} {$form.member_pay_later.html}
- </p>
- <p>
- {if $form.member_auto_renew}
- <label>{$form.member_auto_renew.label}</label>
- {help id="id-member_auto_renew" file="CRM/Member/Form/Search.hlp"}
- <br/>
- {$form.member_auto_renew.html}
- {/if}
- </p>
- <p>
- {$form.member_is_override.label}
- {help id="id-member_is_override" file="CRM/Member/Form/Search.hlp"}
- {$form.member_is_override.html}
- </p>
</td>
</tr>
-
+<tr>
+ <td>{$form.member_test.label} {help id="is-test" file="CRM/Contact/Form/Search/Advanced"} {$form.member_test.html}
+ </td>
+ <td>
+ {$form.member_is_primary.label} {help id="id-member_is_primary" file="CRM/Member/Form/Search.hlp"} {$form.member_is_primary.html}
+ </td>
+</tr>
<tr><td><label>{$form.membership_id.label}</label> {$form.membership_id.html}</td>
+ <td>{$form.member_pay_later.label} {$form.member_pay_later.html}</td>
</tr>
-
-<tr><td><label>{ts}Member Since{/ts}</label></td></tr>
<tr>
-{include file="CRM/Core/DateRange.tpl" fieldName="member_join_date" from='_low' to='_high'}
+ <td>
+ {if $form.member_auto_renew}
+ <label>{$form.member_auto_renew.label}</label>
+ {help id="id-member_auto_renew" file="CRM/Member/Form/Search.hlp"}
+ <br/>
+ {$form.member_auto_renew.html}
+ {/if}
+ </td>
+ <td>{$form.member_is_override.label}{help id="id-member_is_override" file="CRM/Member/Form/Search.hlp"}{$form.member_is_override.html}</td>
</tr>
-
-<tr><td><label>{ts}Start Date{/ts}</label></td></tr>
<tr>
-{include file="CRM/Core/DateRange.tpl" fieldName="member_start_date" from='_low' to='_high'}
+ {include file="CRM/Core/DatePickerRangeWrapper.tpl" fieldName="membership_join_date" colspan='2'}
+</tr>
+<tr>
+ {include file="CRM/Core/DatePickerRangeWrapper.tpl" fieldName="membership_start_date" colspan='2'}
</tr>
-
-<tr><td><label>{ts}End Date{/ts}</label></td></tr>
<tr>
-{include file="CRM/Core/DateRange.tpl" fieldName="member_end_date" from='_low' to='_high'}
+ {include file="CRM/Core/DatePickerRangeWrapper.tpl" fieldName="membership_end_date" colspan='2'}
</tr>
{* campaign in membership search *}