diff --git a/main/course_progress/index.php b/main/course_progress/index.php index cff739d53d..ca98339131 100755 --- a/main/course_progress/index.php +++ b/main/course_progress/index.php @@ -98,6 +98,32 @@ function datetime_by_attendance(selected_value) { } $(document).ready(function() { + $(".thematic_advance_actions, .thematic_tools ").hide(); + + + $(".thematic_content").mouseover(function() { + var id = parseInt(this.id.split("_")[3]); + $("#thematic_id_content_"+id ).show(); + }); + + $(".thematic_content").mouseleave(function() { + var id = parseInt(this.id.split("_")[3]); + $("#thematic_id_content_"+id ).hide(); + }); + + + + $(".thematic_advance_content").mouseover(function() { + var id = parseInt(this.id.split("_")[4]); + $("#thematic_advance_tools_"+id ).show(); + }); + + $(".thematic_advance_content").mouseleave(function() { + var id = parseInt(this.id.split("_")[4]); + $("#thematic_advance_tools_"+id ).hide(); + }); + + //Second col $(".thematic_plan_opener").live("click", function() { var url = this.href; @@ -118,14 +144,29 @@ $(document).ready(function() { modal: true, buttons: { '.addslashes(get_lang('Save')).' : function() { - var serialize_form_content = $("#thematic_plan_add").serialize(); + var serialize_form_content = $("#thematic_plan_add").serialize(); + + //Getting FCK content + var oEditor = FCKeditorAPI.GetInstance("description[1]"); + content_1= oEditor.GetXHTML(true) ; + var oEditor = FCKeditorAPI.GetInstance("description[2]"); + content_2= oEditor.GetXHTML(true) ; + var oEditor = FCKeditorAPI.GetInstance("description[3]"); + content_3= oEditor.GetXHTML(true) ; + var oEditor = FCKeditorAPI.GetInstance("description[4]"); + content_4= oEditor.GetXHTML(true) ; + var oEditor = FCKeditorAPI.GetInstance("description[5]"); + content_5= oEditor.GetXHTML(true) ; + var oEditor = FCKeditorAPI.GetInstance("description[6]"); + content_6= oEditor.GetXHTML(true) ; + $.ajax({ type: "POST", url: "'.api_get_path(WEB_AJAX_PATH).'thematic.ajax.php?a=save_thematic_plan", - data: serialize_form_content, + data: "desc[1]="+content_1+"&"+"desc[2]="+content_2+"&"+"desc[3]="+content_3+"&"+"desc[4]="+content_4+"&"+"desc[5]="+content_5+"&"+"desc[6]="+content_6+"&"+serialize_form_content, success: function(data) { var thematic_id = $("input[name=\"thematic_id\"]").val(); - $("#thematic_plan_"+thematic_id ).html(data); + $("#thematic_plan_"+thematic_id).html(data); } }); dialog.dialog("close"); @@ -137,6 +178,57 @@ $(document).ready(function() { //prevent the browser to follow the link return false; }); + + // Third col + + $(".thematic_advanced_opener, .thematic_advanced_add_opener").live("click", function() { + var url = this.href; + var my_class = this.className; + var dialog = $("#dialog"); + if ($("#dialog").length == 0) { + dialog = $(\'
\').appendTo(\'body\'); + } + + // load remote content + dialog.load( + url, + {}, + function(responseText, textStatus, XMLHttpRequest) { + + dialog.dialog({ + width: 720, + height: 550, + modal: true, + buttons: { + '.addslashes(get_lang('Save')).' : function() { + var serialize_form_content = $("#thematic_advance").serialize(); + + //Getting FCK content + var oEditor = FCKeditorAPI.GetInstance("content"); + content = oEditor.GetXHTML(true) ; + $.ajax({ + type: "POST", + url: "'.api_get_path(WEB_AJAX_PATH).'thematic.ajax.php?a=save_thematic_advance", + data: "real_content=" + content + "&" +serialize_form_content, + success: function(data) { + var thematic_advance_id = $("input[name=\"thematic_advance_id\"]").val(); + $("#thematic_advance_"+thematic_advance_id).html(data); + + //Only refresh if the parent is to add + if (my_class == "thematic_advanced_add_opener") { + location.reload(true); + } + } + }); + dialog.dialog("close"); + } + } + }); + } + ); + //prevent the browser to follow the link + return false; + }); }); diff --git a/main/course_progress/layout_headerless.php b/main/course_progress/layout_no_header.php similarity index 100% rename from main/course_progress/layout_headerless.php rename to main/course_progress/layout_no_header.php diff --git a/main/course_progress/thematic.php b/main/course_progress/thematic.php index 70b3cf0beb..7b71487436 100755 --- a/main/course_progress/thematic.php +++ b/main/course_progress/thematic.php @@ -74,7 +74,6 @@ if ($action == 'thematic_list') { echo ''; echo ''; - foreach ($thematic_data as $thematic) { $my_thematic_id = $thematic['id']; @@ -116,54 +115,67 @@ if ($action == 'thematic_list') { $actions_first_col .= ''.Display::return_icon('delete.png',get_lang('Delete'),'',22).''; } } + + $actions_first_col = Display::div($actions_first_col, array('id'=>'thematic_id_content_'.$thematic['id'], 'class'=>'thematic_tools')); + $actions_first_col = Display::div($actions_first_col, array('style'=>'height:20px')); - echo Display::tag('td', Display::tag('h2', Security::remove_XSS($thematic['title'], STUDENT).$session_star).Security::remove_XSS($thematic['content'], STUDENT).$actions_first_col); + echo Display::tag('td', Display::tag('h2', Security::remove_XSS($thematic['title'], STUDENT).$session_star).Security::remove_XSS($thematic['content'], STUDENT).$actions_first_col, array('id'=>'thematic_td_content_'.$thematic['id'], 'class'=>'thematic_content')); - // display thematic plan data - echo ''; - // display thematic advance data - echo '
'.get_lang('Thematic').''.get_lang('ThematicPlan').''.get_lang('ThematicAdvance').'
'; + // Display 2nd column - thematic plan data + + echo ''; + //if (api_is_allowed_to_edit(null, true) && api_get_session_id() == $thematic['session_id']) { if (api_is_allowed_to_edit(null, true)) { echo '
'. - Display::return_icon('edit.png', get_lang('EditThematicPlan'), array('style'=>'vertical-align:middle'),22).'

'; - } - - echo $thematic_plan_div[$thematic['id']]; + Display::return_icon('edit.png', get_lang('EditThematicPlan'), array('style'=>'vertical-align:middle'),32).'
'; + } + if (empty($thematic_plan_div[$thematic['id']])) { + echo Display::div('', array('id' => "thematic_plan_".$thematic['id'])); + } else { + echo $thematic_plan_div[$thematic['id']]; + } + echo '
'; + // Display 3rd column - thematic advance data + echo ''; + //if (api_is_allowed_to_edit(null, true) && api_get_session_id() == $thematic['session_id']) { if (api_is_allowed_to_edit(null, true)) { - echo '
'.Display::return_icon('edit.png',get_lang('EditThematicAdvance'),array('style'=>'vertical-align:middle'),22).'

'; - } + //echo '
'.Display::return_icon('edit.png',get_lang('EditThematicAdvance'),array('style'=>'vertical-align:middle'),22).'

'; + echo '
'.Display::return_icon('add.png',get_lang('NewThematicAdvance'),'','32').'
'; + } //if (api_is_allowed_to_edit(null, true) && api_get_session_id() == $thematic['session_id']) { if (!empty($thematic_advance_data[$thematic['id']])) { echo ''; foreach ($thematic_advance_data[$thematic['id']] as $thematic_advance) { + $thematic_advance['start_date'] = api_get_local_time($thematic_advance['start_date']); $thematic_advance['start_date'] = api_format_date($thematic_advance['start_date'], DATE_TIME_FORMAT_LONG); echo ''; - echo ''; //if (api_is_allowed_to_edit(null, true) && api_get_session_id() == $thematic['session_id']) { - if (api_is_allowed_to_edit(null, true)) { - + if (api_is_allowed_to_edit(null, true)) { if (empty($thematic_id)) { - $checked = ''; - + $checked = ''; if ($last_done_thematic_advance == $thematic_advance['id']) { $checked = 'checked'; } @@ -176,8 +188,7 @@ if ($action == 'thematic_list') { echo ''; - } else { - + } else { if ($thematic_advance['done_advance'] == 1) { echo ''; } else { @@ -192,10 +203,8 @@ if ($action == 'thematic_list') { echo '
'.get_lang('ThereIsNoAThematicAdvance').'
'; } echo ''; - echo ''; + echo ''; } //End for - - echo '
'; + echo ''; + + + $edit_link = ''.Display::return_icon('edit.png',get_lang('EditThematicAdvance'),array(),22).''; + $edit_link .= ''.Display::return_icon('delete.png',get_lang('Delete'),'',22).''; + + + $thematic_advance_item = isset($thematic_advance_div[$thematic['id']][$thematic_advance['id']]) ? $thematic_advance_div[$thematic['id']][$thematic_advance['id']] : null; + echo Display::div($thematic_advance_item, array('id'=>'thematic_advance_'.$thematic_advance['id'])); + + //Links + echo Display::div(Display::div($edit_link , array('id'=>'thematic_advance_tools_'.$thematic_advance['id'], 'class'=>'thematic_advance_actions')), array('style'=>'height:20px;')); - $session_star = ''; - if (api_is_allowed_to_edit(null, true)) { - if ($thematic_advance['session_id'] !=0) { - $session_star = api_get_session_image(api_get_session_id(), $user_info['status']); - } - } - echo '
'.$thematic_advance['start_date'].$session_star.'
'; - echo '
'.Security::remove_XSS($thematic_advance['content'], STUDENT).'
'; - echo '
'.get_lang('DurationInHours').' : '.$thematic_advance['duration'].'
'; + echo '
'; echo ''; echo '
'.get_lang('Done').'
'; } else { echo '
'.get_lang('ThereIsNoAThematicSection').'
'; @@ -217,7 +226,7 @@ if ($action == 'thematic_list') { } $form->add_textfield('title', get_lang('Title'), true, array('size'=>'50')); - $form->add_html_editor('content', get_lang('Content'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '250')); + $form->add_html_editor('content', get_lang('Content'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '80%', 'Height' => '150')); $form->addElement('html','
'); $form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"'); diff --git a/main/course_progress/thematic_advance.php b/main/course_progress/thematic_advance.php index 99cfcf8b70..d44bfd000e 100755 --- a/main/course_progress/thematic_advance.php +++ b/main/course_progress/thematic_advance.php @@ -72,11 +72,11 @@ if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') { $form->add_textfield('duration_in_hours', get_lang('DurationInHours'), false, array('size'=>'3')); - $form->add_html_editor('content', get_lang('Content'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '150')); + $form->add_html_editor('content', get_lang('Content'), false, false, array('ToolbarStartExpanded'=>'false', 'ToolbarSet' => 'TrainingDescription', 'Width' => '80%', 'Height' => '150')); //$form->addElement('textarea', 'content', get_lang('Content')); $form->addElement('html','
'); - $form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"'); + //$form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"'); $default['start_date_type'] = 1; $default['custom_start_date'] = date('d-F-Y H:i',api_strtotime(api_get_local_time())); @@ -115,12 +115,7 @@ if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') { $form->display(); } else if ($action == 'thematic_advance_list') { - - if (api_is_allowed_to_edit(null, true)) { - echo ''; - } + // thematic advance list $table = new SortableTable('thematic_advance_list', array('Thematic', 'get_number_of_thematic_advances'), array('Thematic', 'get_thematic_advance_data')); diff --git a/main/course_progress/thematic_controller.php b/main/course_progress/thematic_controller.php index be4d509d0e..45044d8394 100755 --- a/main/course_progress/thematic_controller.php +++ b/main/course_progress/thematic_controller.php @@ -150,6 +150,8 @@ class ThematicController $data['thematic_plan_div'] = $thematic->get_thematic_plan_div($thematic_plan_data); + $data['thematic_advance_div'] = $thematic->get_thematic_advance_div($thematic_advance_data); + $data['thematic_plan_data'] = $thematic_plan_data; $data['thematic_advance_data'] = $thematic_advance_data; @@ -213,12 +215,8 @@ class ThematicController $this->view->set_template('thematic_plan'); $this->view->render(); } - } else if($_POST['action'] == 'thematic_plan_list') { - - - - } - } + } + } if ($action == 'thematic_plan_list') { @@ -255,7 +253,7 @@ class ThematicController //render to the view $this->view->set_data($data); - $this->view->set_layout('layout_headerless'); + $this->view->set_layout('layout_no_header'); $this->view->set_template('thematic_plan'); $this->view->render(); exit; @@ -279,64 +277,7 @@ class ThematicController foreach ($attendance_list as $attendance_id => $attendance_data) { $attendance_select[$attendance_id] = $attendance_data['name']; } - - if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") { - if (isset($_POST['action']) && ($_POST['action'] == 'thematic_advance_add' || $_POST['action'] == 'thematic_advance_edit')) { - if (($_POST['start_date_type'] == 1 && empty($_POST['start_date_by_attendance'])) || (!empty($_POST['duration_in_hours']) && !is_numeric($_POST['duration_in_hours'])) ) { - - if ($_POST['start_date_type'] == 1 && empty($_POST['start_date_by_attendance'])) { - $start_date_error = true; - $data['start_date_error'] = $start_date_error; - } - - if (!empty($_POST['duration_in_hours']) && !is_numeric($_POST['duration_in_hours'])) { - $duration_error = true; - $data['duration_error'] = $duration_error; - } - - $data['action'] = $_POST['action']; - $data['thematic_id'] = $_POST['thematic_id']; - $data['attendance_select'] = $attendance_select; - if (isset($_POST['thematic_advance_id'])) { - $data['thematic_advance_id'] = $_POST['thematic_advance_id']; - $thematic_advance_data = $thematic->get_thematic_advance_list($_POST['thematic_advance_id']); - $data['thematic_advance_data'] = $thematic_advance_data; - } - // render to the view - $this->view->set_data($data); - $this->view->set_layout('layout'); - $this->view->set_template('thematic_advance'); - $this->view->render(); - } else { - if ($_POST['thematic_advance_token'] == $_SESSION['thematic_advance_token'] && api_is_allowed_to_edit(null, true)) { - $thematic_advance_id = $_POST['thematic_advance_id']; - $thematic_id = $_POST['thematic_id']; - $content = $_POST['content']; - $duration = $_POST['duration_in_hours']; - if (isset($_POST['start_date_type']) && $_POST['start_date_type'] == 2) { - $start_date = $thematic->build_datetime_from_array($_POST['custom_start_date']); - $attendance_id = 0; - } else { - $start_date = $_POST['start_date_by_attendance']; - $attendance_id = $_POST['attendance_select']; - } - $thematic->set_thematic_advance_attributes($thematic_advance_id, $thematic_id, $attendance_id, $content, $start_date, $duration); - $affected_rows = $thematic->thematic_advance_save(); - if ($affected_rows) { - // get last done thematic advance before move thematic list - $last_done_thematic_advance = $thematic->get_last_done_thematic_advance(); - // update done advances with de current thematic list - if (!empty($last_done_thematic_advance)) { - $update_done_advances = $thematic->update_done_thematic_advances($last_done_thematic_advance); - } - } - unset($_SESSION['thematic_advance_token']); - $action = 'thematic_advance_list'; - } - } - } - } - + $thematic_id = intval($_GET['thematic_id']); $thematic_advance_id = intval($_GET['thematic_advance_id']); $thematic_advance_data = array(); @@ -345,7 +286,9 @@ class ThematicController if (api_is_allowed_to_edit(null, true)) { $affected_rows = $thematic->thematic_advance_destroy($thematic_advance_id); } - $action = 'thematic_advance_list'; + $action = 'thematic_list'; + header('Location: index.php'); + exit; } else { $thematic_advance_data = $thematic->get_thematic_advance_list($thematic_advance_id); } @@ -373,7 +316,7 @@ class ThematicController // render to the view $this->view->set_data($data); - $this->view->set_layout('layout'); + $this->view->set_layout('layout_no_header'); $this->view->set_template('thematic_advance'); $this->view->render(); } diff --git a/main/course_progress/thematic_plan.php b/main/course_progress/thematic_plan.php index 868a5fa2b6..bb38f153d9 100755 --- a/main/course_progress/thematic_plan.php +++ b/main/course_progress/thematic_plan.php @@ -48,40 +48,28 @@ if ($action == 'thematic_plan_list') { $form->addElement('hidden', 'action', $action); $form->addElement('hidden', 'thematic_plan_token', $token); $form->addElement('hidden', 'thematic_id', $thematic_id); - - //var_dump($default_thematic_plan_title); - //var_dump($thematic_simple_list); foreach ($default_thematic_plan_title as $id => $title) { - //foreach ($thematic_simple_list as $id) { - //$title = $default_thematic_plan_title[$id]; $form->addElement('hidden', 'description_type['.$id.']', $id); $form->add_textfield('title['.$id.']', get_lang('Title'), true, array('size'=>'50')); - //$form->add_html_editor('description['.$id.']', get_lang('Description'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '200')); - - $form->addElement('textarea', 'description['.$id.']', get_lang('Description')); - - $form->addElement('html','
'); - + $form->add_html_editor('description['.$id.']', get_lang('Description'), false, false, array('ToolbarStartExpanded'=>'false', 'ToolbarSet' => 'TrainingDescription', 'Width' => '80%', 'Height' => '150')); + //$form->addElement('textarea', 'description['.$id.']', get_lang('Description')); + $form->addElement('html','
'); if (!empty($thematic_simple_list) && in_array($id, $thematic_simple_list)) { - $thematic_plan = $new_thematic_plan_data[$id]; - + $thematic_plan = $new_thematic_plan_data[$id]; // set default values $default['title['.$id.']'] = $thematic_plan['title']; $default['description['.$id.']'] = $thematic_plan['description']; $thematic_plan = null; - } else { $thematic_plan = null; $default['title['.$id.']'] = $title; $default['description['.$id.']']= ''; - } - + } $form->setDefaults($default); } //$form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"'); - $form->display(); - + $form->display(); } else if ($action == 'thematic_plan_add' || $action == 'thematic_plan_edit') { if ($description_type >= ADD_THEMATIC_PLAN) { @@ -108,7 +96,7 @@ if ($action == 'thematic_plan_list') { } $form->add_textfield('title', get_lang('Title'), true, array('size'=>'50')); - $form->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '200')); + $form->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '80%', 'Height' => '150')); $form->addElement('html','
'); $form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"'); diff --git a/main/css/base.css b/main/css/base.css index 843b4aee90..68c136f218 100644 --- a/main/css/base.css +++ b/main/css/base.css @@ -2238,4 +2238,12 @@ div.admin_section h4 { .question-list-description-block { margin-bottom:10px !important; margin-top: -6px !important; +} + +.thematic_advance_content { + padding:10px; +} + +.thematic_advance_actions { + width:100px; } \ No newline at end of file diff --git a/main/img/icons/32/add.png b/main/img/icons/32/add.png new file mode 100644 index 0000000000..e4fe053a5b Binary files /dev/null and b/main/img/icons/32/add.png differ diff --git a/main/inc/ajax/thematic.ajax.php b/main/inc/ajax/thematic.ajax.php index d4d42cc46d..92617e0bf9 100755 --- a/main/inc/ajax/thematic.ajax.php +++ b/main/inc/ajax/thematic.ajax.php @@ -12,11 +12,12 @@ api_protect_course_script(true); $action = $_GET['a']; -switch ($action) { +switch ($action) { case 'save_thematic_plan': $thematic = new Thematic(); $title_list = $_REQUEST['title']; - $description_list = $_REQUEST['description']; + $description_list = $_REQUEST['desc']; + //$description_list = $_REQUEST['description']; $description_type = $_REQUEST['description_type']; if (api_is_allowed_to_edit(null, true)) { for($i=1;$iget_thematic_advance_list($_REQUEST['thematic_advance_id']); + $data['thematic_advance_data'] = $thematic_advance_data; + } + } else { + if ($_REQUEST['thematic_advance_token'] == $_SESSION['thematic_advance_token'] && api_is_allowed_to_edit(null, true)) { + $thematic_advance_id = $_REQUEST['thematic_advance_id']; + $thematic_id = $_REQUEST['thematic_id']; + $content = $_REQUEST['real_content']; + $duration = $_REQUEST['duration_in_hours']; + if (isset($_REQUEST['start_date_type']) && $_REQUEST['start_date_type'] == 2) { + $start_date = $thematic->build_datetime_from_array($_REQUEST['custom_start_date']); + $attendance_id = 0; + } else { + $start_date = $_REQUEST['start_date_by_attendance']; + $attendance_id = $_REQUEST['attendance_select']; + } + $thematic->set_thematic_advance_attributes($thematic_advance_id, $thematic_id, $attendance_id, $content, $start_date, $duration); + $affected_rows = $thematic->thematic_advance_save(); + if ($affected_rows) { + // get last done thematic advance before move thematic list + $last_done_thematic_advance = $thematic->get_last_done_thematic_advance(); + // update done advances with de current thematic list + if (!empty($last_done_thematic_advance)) { + $update_done_advances = $thematic->update_done_thematic_advances($last_done_thematic_advance); + } + } + } + } + $thematic_advance_data = $thematic->get_thematic_advance_list(null, null, true); + $return = $thematic->get_thematic_advance_div($thematic_advance_data); + + echo $return[$_REQUEST['thematic_id']][$_REQUEST['thematic_advance_id']]; + break; + case 'get_datetime_by_attendance': $attendance_id = intval($_POST['attendance_id']); diff --git a/main/inc/lib/thematic.lib.php b/main/inc/lib/thematic.lib.php index 92fc61d4c0..cfcedd9b96 100755 --- a/main/inc/lib/thematic.lib.php +++ b/main/inc/lib/thematic.lib.php @@ -466,9 +466,32 @@ class Thematic } return $data; } - + + + public function get_thematic_advance_div($data) { + $return_array = array(); + + foreach ($data as $thematic_id => $thematic_advance_data) { + foreach ($thematic_advance_data as $key => $thematic_advance) { + + $session_star = ''; + if (api_is_allowed_to_edit(null, true)) { + if ($thematic_advance['session_id'] !=0) { + $session_star = api_get_session_image(api_get_session_id(), $user_info['status']); + } + } + + $thematic_advance_item = '
'.$thematic_advance['start_date'].$session_star.'
'; +// $thematic_advance_item .= '
'.get_lang('DurationInHours').' : '.$thematic_advance['duration'].'
'; + $thematic_advance_item .= '
'.$thematic_advance['duration'].' '.get_lang('HourShort').'
'; + $thematic_advance_item .= '
'.Security::remove_XSS($thematic_advance['content'], STUDENT).'
'; + $return_array[$thematic_id][$thematic_advance['id']] = $thematic_advance_item; + } + } + return $return_array; + } - public function get_thematic_plan_div($data, $id = false) { + public function get_thematic_plan_div($data) { $final_return = array(); foreach ($data as $thematic_id => $thematic_plan_data) {