diff --git a/main/calendar/agenda.php b/main/calendar/agenda.php index 1ef34a6783..2b00e9b54b 100755 --- a/main/calendar/agenda.php +++ b/main/calendar/agenda.php @@ -172,6 +172,8 @@ if ($allowToEdit) { $endDate = $values['date_range_end']; $notificationCount = $_REQUEST['notification_count'] ?? []; $notificationPeriod = $_REQUEST['notification_period'] ?? []; + $careerId = $_REQUEST['career_id'] ?? 0; + $promotionId = $_REQUEST['promotion_id'] ?? 0; $reminders = $notificationCount ? array_map(null, $notificationCount, $notificationPeriod) : []; @@ -190,7 +192,9 @@ if ($allowToEdit) { '', $values['invitees'] ?? [], $values['collective'] ?? false, - $reminders + $reminders, + (int) $careerId, + (int) $promotionId ); if (!empty($values['repeat']) && !empty($eventId)) { @@ -248,6 +252,8 @@ if ($allowToEdit) { $comment = $values['comment'] ?? ''; $notificationCount = $_REQUEST['notification_count'] ?? []; $notificationPeriod = $_REQUEST['notification_period'] ?? []; + $careerId = $_REQUEST['career_id'] ?? 0; + $promotionId = $_REQUEST['promotion_id'] ?? 0; $reminders = $notificationCount ? array_map(null, $notificationCount, $notificationPeriod) : []; @@ -299,7 +305,9 @@ if ($allowToEdit) { 0, $values['invitees'] ?? [], $values['collective'] ?? false, - $reminders + $reminders, + (int) $careerId, + (int) $promotionId ); if (!empty($values['repeat']) && !empty($eventId)) { diff --git a/main/calendar/agenda_js.php b/main/calendar/agenda_js.php index 8956ce60c1..000b212f07 100755 --- a/main/calendar/agenda_js.php +++ b/main/calendar/agenda_js.php @@ -300,6 +300,11 @@ if (api_get_configuration_value('agenda_reminders')) { $form->addHtml('
'); } +if (api_get_configuration_value('allow_careers_in_global_agenda') && 'admin' === $agenda->type) { + Career::addCareerFieldsToForm($form); + $form->addHtml('
'); +} + $form->addHtml(''); diff --git a/main/inc/ajax/agenda.ajax.php b/main/inc/ajax/agenda.ajax.php index 7c1663b709..c3af39a165 100755 --- a/main/inc/ajax/agenda.ajax.php +++ b/main/inc/ajax/agenda.ajax.php @@ -49,6 +49,8 @@ switch ($action) { $isCollective = isset($_REQUEST['collective']); $notificationCount = $_REQUEST['notification_count'] ?? []; $notificationPeriod = $_REQUEST['notification_period'] ?? []; + $careerId = $_REQUEST['career_id'] ?? 0; + $promotionId = $_REQUEST['promotion_id'] ?? 0; $reminders = $notificationCount ? array_map(null, $notificationCount, $notificationPeriod) : []; @@ -67,7 +69,9 @@ switch ($action) { '', $inviteesList, $isCollective, - $reminders + $reminders, + (int) $careerId, + (int) $promotionId ); echo $eventId; diff --git a/main/inc/lib/agenda.lib.php b/main/inc/lib/agenda.lib.php index 61b8ba77d9..309c1d31c9 100644 --- a/main/inc/lib/agenda.lib.php +++ b/main/inc/lib/agenda.lib.php @@ -252,7 +252,9 @@ class Agenda $color = '', array $inviteesList = [], bool $isCollective = false, - array $reminders = [] + array $reminders = [], + int $careerId = 0, + int $promotionId = 0 ) { $start = api_get_utc_datetime($start); $end = api_get_utc_datetime($end); @@ -446,6 +448,11 @@ class Agenda 'access_url_id' => api_get_current_access_url_id(), ]; + if (api_get_configuration_value('allow_careers_in_global_agenda')) { + $attributes['career_id'] = $careerId; + $attributes['promotion_id'] = $promotionId; + } + $id = Database::insert( $this->tbl_global_agenda, $attributes @@ -856,7 +863,9 @@ class Agenda $authorId = 0, array $inviteesList = [], bool $isCollective = false, - array $remindersList = [] + array $remindersList = [], + int $careerId = 0, + int $promotionId = 0 ) { $id = (int) $id; $start = api_get_utc_datetime($start); @@ -1165,6 +1174,11 @@ class Agenda 'all_day' => $allDay, ]; + if (api_get_configuration_value('allow_careers_in_global_agenda')) { + $attributes['career_id'] = $careerId; + $attributes['promotion_id'] = $promotionId; + } + if ($updateContent) { $attributes['content'] = $content; } @@ -2385,6 +2399,32 @@ class Agenda $event['has_children'] = 0; $event['description'] = $row['content']; + if (api_get_configuration_value('allow_careers_in_global_agenda')) { + $event['career'] = null; + $event['promotion'] = null; + + if (!empty($row['career_id'])) { + $careerInfo = (new Career())->get($row['career_id']); + + unset($careerInfo['status'], $careerInfo['created_at'], $careerInfo['updated_at']); + + $event['career'] = $careerInfo; + } + + if (!empty($row['promotion_id'])) { + $promotionInfo = (new Promotion())->get($row['promotion_id']); + + unset( + $promotionInfo['career_id'], + $promotionInfo['status'], + $promotionInfo['created_at'], + $promotionInfo['updated_at'] + ); + + $event['promotion'] = $promotionInfo; + } + } + $my_events[] = $event; $this->events[] = $event; } @@ -2876,6 +2916,11 @@ class Agenda $form->addHtml('
'); } + if (api_get_configuration_value('allow_careers_in_global_agenda') && 'admin' === $this->type) { + Career::addCareerFieldsToForm($form); + $form->addHtml('
'); + } + if ($id) { $form->addButtonUpdate(get_lang('ModifyEvent')); } else { diff --git a/main/inc/lib/career.lib.php b/main/inc/lib/career.lib.php index 559ed0b618..07ae6913e4 100755 --- a/main/inc/lib/career.lib.php +++ b/main/inc/lib/career.lib.php @@ -1456,8 +1456,6 @@ class Career extends Model var $txtPromotion = $("#promotion_id"); $("#career_id").on("change", function () { - $("#promotion").show(); - var id = this.value; $txtPromotion.empty().append($("