Thematic: Fix Editing Thematic advance dates is not working properly - refs BT#19229

pull/4028/head
Christian 4 years ago
parent 5737d79604
commit 0f0cdaffeb
  1. 17
      main/course_progress/thematic_advance.php

@ -61,8 +61,8 @@ if ($action === 'thematic_advance_add' || $action === 'thematic_advance_edit') {
);
$form->addGroup($radios, null, get_lang('StartDateOptions'));
if (isset($thematic_advance_data['attendance_id']) &&
$thematic_advance_data['attendance_id'] == 0) {
if (empty($thematic_advance_data['attendance_id'])
) {
$form->addElement('html', '<div id="div_custom_datetime" style="display:block">');
} else {
$form->addElement('html', '<div id="div_custom_datetime" style="display:none">');
@ -71,8 +71,7 @@ if ($action === 'thematic_advance_add' || $action === 'thematic_advance_edit') {
$form->addElement('DateTimePicker', 'custom_start_date', get_lang('StartDate'));
$form->addElement('html', '</div>');
if (isset($thematic_advance_data['attendance_id']) &&
$thematic_advance_data['attendance_id'] == 0
if (empty($thematic_advance_data['attendance_id'])
) {
$form->addElement('html', '<div id="div_datetime_by_attendance" style="display:none">');
} else {
@ -157,16 +156,17 @@ if ($action === 'thematic_advance_add' || $action === 'thematic_advance_edit') {
}
}
$default['start_date_type'] = 1;
$default['start_date_type'] = 2;
$default['custom_start_date'] = date('Y-m-d H:i:s', api_strtotime(api_get_local_time()));
$default['duration_in_hours'] = 1;
if (!empty($thematic_advance_data)) {
// set default values
if ('thematic_advance_edit' == $action) {
$default['content'] = isset($thematic_advance_data['content']) ? $thematic_advance_data['content'] : null;
$default['duration_in_hours'] = isset($thematic_advance_data['duration']) ? $thematic_advance_data['duration'] : 1;
if (empty($thematic_advance_data['attendance_id'])) {
$default['start_date_type'] = 1;
$default['start_date_type'] = 2;
$default['custom_start_date'] = null;
if (isset($thematic_advance_data['start_date'])) {
$default['custom_start_date'] = date(
@ -182,6 +182,11 @@ if ($action === 'thematic_advance_add' || $action === 'thematic_advance_edit') {
$default['attendance_select'] = $thematic_advance_data['attendance_id'];
}
} else {
$default['start_date_type'] = 2;
$default['custom_start_date'] = date('Y-m-d H:i:s', api_strtotime(api_get_local_time()));
$default['duration_in_hours'] = 1;
}
}
$form->setDefaults($default);

Loading…
Cancel
Save