27 protected \ILIAS\BookingManager\InternalRepoService
$repo;
35 $this->
lng = $DIC->language();
38 $this->repo = $DIC->bookingManager()
45 return "book_notification";
53 return $lng->
txt(
"book_notification");
61 return $lng->
txt(
"book_notification_info");
66 return CronJobScheduleType::SCHEDULE_TYPE_DAILY;
95 $result->setStatus($status);
104 $access = $DIC->bookingManager()->internal()->domain()->access();
108 $log->debug(
"start");
119 $next_day_ts = mktime(0, 0, 0, date(
'n'), (
int) date(
'j') + 1);
120 $log->debug(
"next day ts: " . $next_day_ts);
121 $last_reminder_to_ts = $p[
"last_remind_ts"];
124 $log->debug(
"last_reminder ts: " . $last_reminder_to_ts);
125 $from_ts = max($next_day_ts, $last_reminder_to_ts);
126 $log->debug(
"from ts: " . $from_ts);
127 $to_ts = mktime(0, 0, 0, date(
'n'), (
int) date(
'j') + $p[
"reminder_day"] + 1);
136 $log->debug(
"pool id: " 137 . $p[
"booking_pool_id"]
140 . date(
"Y-m-d, H:i:s", $from_ts)
141 .
" to " . date(
"Y-m-d, H:i:s", $to_ts));
144 if ($to_ts > $from_ts) {
145 $repo = $this->repo->reservation();
146 $res = $repo->getListByDate(
true, null, [
149 ], [$p[
"booking_pool_id"]]);
152 $log->debug(
"reservations: " . count(
$res));
158 $log->debug(
"users: " . count($user_ids));
163 $log->debug(
"check notification of user id: " . $r[
"user_id"]);
164 if (in_array($r[
"user_id"], $user_ids)) {
165 if ($access->canRetrieveNotificationsForOwnReservationsByObjId(
166 (
int) $p[
"booking_pool_id"],
169 $log->debug(
"got read");
170 $notifications[$r[
"user_id"]][
"personal"][$r[
"pool_id"]][] =
$r;
175 foreach ($user_ids as $uid) {
176 $log->debug(
"check write for user id: " . $uid .
", pool: " . $p[
"booking_pool_id"]);
178 if ($access->canRetrieveNotificationsForAllReservationsByObjId(
179 (
int) $p[
"booking_pool_id"],
182 $log->debug(
"got write");
183 $notifications[$uid][
"admin"][$r[
"pool_id"]][] =
$r;
193 return count($notifications);
199 foreach ($notifications as $uid => $n) {
205 if (is_array($n[
"personal"] ?? null)) {
206 $txt .=
"\n" . $lng->
txt(
"book_your_reservations") .
"\n";
207 $txt .=
"-----------------------------------------\n";
208 foreach ($n[
"personal"] as $obj_id => $reservs) {
210 foreach ($reservs as
$r) {
211 $txt .=
"- " . $r[
"title"] .
" (" . $r[
"counter"] .
"), " .
218 if (is_array($n[
"admin"] ?? null)) {
219 $txt .=
"\n" . $lng->
txt(
"book_reservation_overview") .
"\n";
220 $txt .=
"-----------------------------------------\n";
221 foreach ($n[
"admin"] as $obj_id => $reservs) {
223 foreach ($reservs as
$r) {
224 $txt .=
"- " . $r[
"title"] .
" (" . $r[
"counter"] .
"), " . $r[
"user_name"] .
", " .
227 if ($r[
"message"] !=
"") {
228 $txt .=
" " . $lng->
txt(
"book_message") .
229 ": " . $r[
"message"];
234 $ntf->setLangModules(array(
"book"));
235 $ntf->setSubjectLangId(
"book_booking_reminders");
236 $ntf->setIntroductionLangId(
"book_rem_intro");
237 $ntf->addAdditionalInfo(
"",
$txt);
238 $ntf->setReasonLangId(
"book_rem_reason");
239 $this->book_log->debug(
"send Mail: " . $uid);
240 $ntf->sendMailAndReturnRecipients([$uid]);
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ilObjUser $user=null,)
static getLogger(string $a_component_id)
Get component logger.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
getUserLanguage()
Return language of user.
loadLanguageModule(string $a_module)
Load language module.
static getPoolsWithReminders()
Get pools with reminders.
static getNotificationsForObject(int $type, int $id, ?int $page_id=null, bool $ignore_threshold=false)
Get all users/recipients for given object.
static writeLastReminderTimestamp(int $a_obj_id, int $a_ts)
getDefaultScheduleValue()
static _lookupTitle(int $obj_id)
final const STATUS_NO_ACTION
Cron for booking manager notification.
ILIAS BookingManager InternalRepoService $repo
sendMails(array $notifications)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...