$query['casContactTableAlias'] = NULL;
// $schedule->start_action_date is user-supplied data. validate.
- if (!array_key_exists($schedule->start_action_date, $this->getDateFields())) {
+ if (empty($schedule->absolute_date) && !array_key_exists($schedule->start_action_date, $this->getDateFields())) {
throw new CRM_Core_Exception("Invalid date field");
}
- $query['casDateField'] = $schedule->start_action_date;
+ $query['casDateField'] = $schedule->start_action_date ?? '';
+ if (empty($query['casDateField']) && $schedule->absolute_date) {
+ $query['casDateField'] = "'" . CRM_Utils_Type::escape($schedule->absolute_date, 'String') . "'";
+ }
// build where clause
if (!empty($selectedValues)) {
$query['casContactTableAlias'] = NULL;
// $schedule->start_action_date is user-supplied data. validate.
- if (!array_key_exists($schedule->start_action_date, $this->getDateFields())) {
+ if (empty($schedule->absolute_date) && !array_key_exists($schedule->start_action_date, $this->getDateFields())) {
throw new CRM_Core_Exception("Invalid date field");
}
- $query['casDateField'] = $schedule->start_action_date;
-
+ $query['casDateField'] = $schedule->start_action_date ?? '';
+ if (empty($query['casDateField']) && $schedule->absolute_date) {
+ $query['casDateField'] = "'" . CRM_Utils_Type::escape($schedule->absolute_date, 'String') . "'";
+ }
// build where clause
if (!empty($selectedValues)) {
$query->where("e.financial_type_id IN (@selectedValues)")
],
];
+ $cs[] = [
+ '2015-02-02 00:00:00',
+ 'addAliceDues addBobDonation scheduleForDonationWithAbsoluteDate useHelloFirstName',
+ [
+ [
+ 'time' => '2015-02-02 00:00:00',
+ 'to' => ['bob@example.org'],
+ 'subject' => '/Hello, Bob.*via subject/',
+ ],
+ ],
+ ];
+
$cs[] = [
'2015-02-03 00:00:00',
'addAliceDues addBobDonation scheduleForSoftCreditor startWeekAfter useHelloFirstName',
$this->schedule->entity_status = CRM_Utils_Array::implodePadded(NULL);
}
+ /**
+ * Schedule message delivery for contribution with an absolute date.
+ */
+ public function scheduleForDonationWithAbsoluteDate(): void {
+ $this->schedule->mapping_id = 'contribtype';
+ $this->schedule->absolute_date = date('Y-m-d', strtotime($this->targetDate));
+ $this->schedule->entity_value = CRM_Utils_Array::implodePadded([2]);
+ $this->schedule->entity_status = CRM_Utils_Array::implodePadded(NULL);
+ }
+
/**
* Schedule message delivery for any contribution, regardless of type.
*/