*/
// protect a course script
api_protect_course_script(true);
if (!$is_locked_attendance || api_is_platform_admin()) {
echo '
');
} else {
$form->addElement('html', '
');
}
$a_repeat_type = [
'daily' => get_lang('Daily'),
'weekly' => get_lang('Weekly'),
'monthlyByDate' => get_lang('Monthly, by date'),
];
$form->addElement('select', 'repeat_type', get_lang('Repeat type'), $a_repeat_type);
$form->addElement(
'date_picker',
'end_date_time',
get_lang('Repeat end date'),
['form_name' => 'attendance_calendar_add']
);
$defaults['end_date_time'] = date('Y-m-d');
$form->addElement('html', '
');
$defaults['repeat_type'] = 'weekly';
$form->addSelect('groups', get_lang('Group'), $groupIdList);
$form->addButtonCreate(get_lang('Save'));
$form->setDefaults($defaults);
$form->display();
} else {
// Calendar list
$groupList = GroupManager::get_group_list();
$groupIdList = ['--'];
foreach ($groupList as $group) {
$groupIdList[$group['id']] = $group['name'];
}
echo Display::page_subheader(get_lang('Calendar list of attendances'));
echo '
';
if (!empty($attendance_calendar)) {
foreach ($attendance_calendar as $calendar) {
echo '- ';
if ((isset($action) && $action === 'calendar_edit') &&
(isset($calendar_id) && $calendar_id == $calendar['id'])
) {
// calendar edit form
echo '
';
$form = new FormValidator(
'attendance_calendar_edit',
'POST',
'index.php?action=calendar_edit&attendance_id='.$attendance_id.'&calendar_id='.$calendar_id.'&'.api_get_cidreq(),
''
);
$form->addDateTimePicker(
'date_time',
[get_lang('Date')],
['form_name' => 'attendance_calendar_edit'],
5
);
$defaults['date_time'] = $calendar['date_time'];
$form->addButtonSave(get_lang('Save'));
$form->addButtonCancel(get_lang('Cancel'), 'cancel');
$form->setDefaults($defaults);
$form->display();
echo '
';
} else {
echo Display::return_icon(
'lp_calendar_event.png',
get_lang('Date DateTime time'),
null,
ICON_SIZE_MEDIUM
).' '.
substr(
$calendar['date_time'],
0,
strlen($calendar['date_time']) - 3
).
' ';
if (isset($calendar['groups']) && !empty($calendar['groups'])) {
foreach ($calendar['groups'] as $group) {
echo ' '.Display::label($groupIdList[$group['group_id']]);
}
}
if (!$is_locked_attendance || api_is_platform_admin()) {
if (api_is_allowed_to_edit()) {
echo '';
}
}
}
echo ' ';
}
} else {
echo Display::return_message(get_lang('There is no date/time registered yet'), 'warning');
}
echo '
';
}