diff --git a/public/main/announcements/announcements.php b/public/main/announcements/announcements.php
index f29b3ef7bf..89786759aa 100644
--- a/public/main/announcements/announcements.php
+++ b/public/main/announcements/announcements.php
@@ -2,6 +2,7 @@
/* For licensing terms, see /license.txt */
+use Chamilo\CoreBundle\Component\Utils\ActionIcon;
use Chamilo\CoreBundle\Entity\AbstractResource;
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CAnnouncement;
@@ -624,6 +625,24 @@ switch ($action) {
$form->addHtml('
');
$form->addDateTimePicker('event_date_start', get_lang('Date start'));
$form->addDateTimePicker('event_date_end', get_lang('Date end'));
+
+ $form->addHtml('
');
+ $form
+ ->addButton(
+ 'add_notification',
+ get_lang('Add reminder'),
+ ActionIcon::ADD_EVENT_REMINDER->value,
+ 'plain'
+ )
+ ->setType('button')
+ ;
+ $form->addHtml('
');
+
+ $htmlHeadXtra[] = ''
+ ;
+
$form->addHtml('
');
}
@@ -646,6 +665,12 @@ switch ($action) {
$data['users'] = $data['users'] ?? [];
$sendToUsersInSession = isset($data['send_to_users_in_session']);
$sendMeCopy = isset($data['send_me_a_copy_by_email']);
+
+ $notificationCount = $data['notification_count'] ?? [];
+ $notificationPeriod = $data['notification_period'] ?? [];
+
+ $reminders = $notificationCount ? array_map(null, $notificationCount, $notificationPeriod) : [];
+
if (isset($id) && $id) {
// there is an Id => the announcement already exists => update mode
$file_comment = $announcementAttachmentIsDisabled ? null : $_POST['file_comment'];
@@ -725,7 +750,8 @@ switch ($action) {
$data['users'],
api_get_course_entity(),
api_get_session_entity(),
- api_get_group_entity()
+ api_get_group_entity(),
+ $reminders
);
}
diff --git a/public/main/inc/lib/agenda.lib.php b/public/main/inc/lib/agenda.lib.php
index 21fee4d446..770ab9a03b 100644
--- a/public/main/inc/lib/agenda.lib.php
+++ b/public/main/inc/lib/agenda.lib.php
@@ -3594,4 +3594,34 @@ class Agenda
return $eventDate->format(DateTime::ISO8601);
}
+
+ public static function getJsForReminders(string $cssSelectorBtnAdd): string
+ {
+ return '
+ var template = \'\' +
+ \'
\' +
+ \'
\' +
+ \'
'.get_lang('Before').'
\' +
+ \'
\' +
+ \'
\';
+
+ $("'.$cssSelectorBtnAdd.'").on("click", function (e) {
+ e.preventDefault();
+
+ $(template).appendTo("#notification_list");
+ $("#notification_list select").selectpicker("refresh");
+ });
+
+ $("#notification_list").on("click", ".delete-notification", function (e) {
+ e.preventDefault();
+
+ $(this).parents(".form-group").remove();
+ });';
+ }
}
diff --git a/src/CourseBundle/Repository/CCalendarEventRepository.php b/src/CourseBundle/Repository/CCalendarEventRepository.php
index 47970cf9f8..59d7ffbd93 100644
--- a/src/CourseBundle/Repository/CCalendarEventRepository.php
+++ b/src/CourseBundle/Repository/CCalendarEventRepository.php
@@ -7,6 +7,7 @@ declare(strict_types=1);
namespace Chamilo\CourseBundle\Repository;
use Chamilo\CoreBundle\Entity\AbstractResource;
+use Chamilo\CoreBundle\Entity\AgendaReminder;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Entity\User;
@@ -31,7 +32,8 @@ final class CCalendarEventRepository extends ResourceRepository
array $users,
Course $course,
?Session $session = null,
- ?CGroup $group = null
+ ?CGroup $group = null,
+ array $remindersInfo = [],
): CCalendarEvent {
$event = (new CCalendarEvent())
->setTitle($announcement->getTitle())
@@ -71,6 +73,16 @@ final class CCalendarEventRepository extends ResourceRepository
}
}
+ foreach ($remindersInfo as $reminderInfo) {
+ $reminder = new AgendaReminder();
+ $reminder->count = (int) $reminderInfo[0];
+ $reminder->period = $reminderInfo[1];
+
+ $reminder->decodeDateInterval();
+
+ $event->addReminder($reminder);
+ }
+
$em->persist($event);
$em->flush();