if ($mapping->entity == 'civicrm_participant') {
$tokenEntity = 'event';
- $tokenFields = array('event_type', 'title', 'event_id', 'start_date', 'end_date', 'summary', 'description', 'location', 'info_url', 'registration_url', 'fee_amount', 'contact_email', 'contact_phone');
+ $tokenFields = array('event_type', 'title', 'event_id', 'start_date', 'end_date', 'summary', 'description', 'location', 'info_url', 'registration_url', 'fee_amount', 'contact_email', 'contact_phone', 'balance');
$extraSelect = ', ov.label as event_type, ev.title, ev.id as event_id, ev.start_date, ev.end_date, ev.summary, ev.description, address.street_address, address.city, address.state_province_id, address.postal_code, email.email as contact_email, phone.phone as contact_phone ';
$extraJoin = "
elseif (in_array($field, array('start_date','end_date','join_date','activity_date_time'))) {
$entityTokenParams["{$tokenEntity}." . $field] = CRM_Utils_Date::customFormat($dao->$field);
}
+ elseif ($field == 'balance') {
+ $info = CRM_Contribute_BAO_Contribution::getPaymentInfo($dao->entityID, 'event');
+ $entityTokenParams["{$tokenEntity}." . $field] = CRM_Utils_Array::value('balance', $info);
+ }
else {
$entityTokenParams["{$tokenEntity}." . $field] = $dao->$field;
}
}
}
- static function buildRecipientContacts($mappingID, $now) {
+ static function buildRecipientContacts($mappingID, $now, $params = array()) {
$actionSchedule = new CRM_Core_DAO_ActionSchedule();
$actionSchedule->mapping_id = $mappingID;
$actionSchedule->is_active = 1;
+ if(!empty($params)) {
+ _civicrm_api3_dao_set_filter($actionSchedule, $params, FALSE, 'ActionSchedule');
+ }
$actionSchedule->find();
while ($actionSchedule->fetch()) {
elseif ($actionSchedule->repetition_frequency_unit == 'week') {
$hrs = 24 * $actionSchedule->repetition_frequency_interval * 7;
}
+ elseif ($actionSchedule->repetition_frequency_unit == 'month') {
+ $hrs = "24*(DATEDIFF(DATE_ADD(latest_log_time, INTERVAL 1 MONTH ), latest_log_time))";
+ }
+ elseif ($actionSchedule->repetition_frequency_unit == 'year') {
+ $hrs = "24*(DATEDIFF(DATE_ADD(latest_log_time, INTERVAL 1 YEAR ), latest_log_time))";
+ }
else {
$hrs = $actionSchedule->repetition_frequency_interval;
}
return NULL;
}
- static function processQueue($now = NULL) {
+ static function processQueue($now = NULL, $params = array()) {
$now = $now ? CRM_Utils_Time::setTime($now) : CRM_Utils_Time::getTime();
$mappings = self::getMapping();
foreach ($mappings as $mappingID => $mapping) {
- self::buildRecipientContacts($mappingID, $now);
+ self::buildRecipientContacts($mappingID, $now, $params);
self::sendMailings($mappingID, $now);
}