index.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. /**
  5. * Template (front controller in MVC pattern) used for distpaching to the controllers depend on the current action
  6. * @author Christian Fasanando <christian1827@gmail.com>
  7. * @author Julio Montoya <gugli100@gmail.com> Bugfixes session support
  8. * @package chamilo.course_progress
  9. */
  10. require_once 'thematic_controller.php';
  11. // current section
  12. $this_section = SECTION_COURSES;
  13. $current_course_tool = TOOL_COURSE_PROGRESS;
  14. // protect a course script
  15. api_protect_course_script(true);
  16. // get actions
  17. $actions = array(
  18. 'thematic_details',
  19. 'thematic_list',
  20. 'thematic_add',
  21. 'thematic_edit',
  22. 'thematic_copy',
  23. 'thematic_delete',
  24. 'moveup',
  25. 'movedown',
  26. 'thematic_import_select',
  27. 'thematic_import',
  28. 'thematic_export',
  29. 'thematic_export_pdf',
  30. 'thematic_plan_list',
  31. 'thematic_plan_add',
  32. 'thematic_plan_edit',
  33. 'thematic_plan_delete',
  34. 'thematic_advance_list',
  35. 'thematic_advance_add',
  36. 'thematic_advance_edit',
  37. 'thematic_advance_delete'
  38. );
  39. $action = 'thematic_details';
  40. if (isset($_REQUEST['action']) && in_array($_REQUEST['action'], $actions)) {
  41. $action = $_REQUEST['action'];
  42. }
  43. if (isset($_POST['action']) && $_POST['action'] == 'thematic_delete_select') {
  44. $action = 'thematic_delete_select';
  45. }
  46. if (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'true') {
  47. $action = 'thematic_details';
  48. }
  49. if ($action == 'thematic_details' || $action == 'thematic_list') {
  50. Session::write('thematic_control', $action);
  51. }
  52. // get thematic id
  53. $thematic_id = isset($_GET['thematic_id']) ? (int) $_GET['thematic_id'] : 0;
  54. // get thematic plan description type
  55. $description_type = isset($_GET['description_type']) ? (int) $_GET['description_type'] : 0;
  56. // instance thematic object for using like library here
  57. $thematic = new Thematic();
  58. // thematic controller object
  59. $thematic_controller = new ThematicController();
  60. $thematic_data = [];
  61. if (!empty($thematic_id)) {
  62. // thematic data by id
  63. $thematic_data = $thematic->get_thematic_list($thematic_id);
  64. }
  65. // get default thematic plan title
  66. $default_thematic_plan_title = $thematic->get_default_thematic_plan_title();
  67. // Only when I see the 3 columns. Avoids double or triple click binding for onclick event
  68. $htmlHeadXtra[] = '<script>
  69. $(document).ready(function() {
  70. $(".thematic_advance_actions, .thematic_tools ").hide();
  71. $(".thematic_content").mouseover(function() {
  72. var id = parseInt(this.id.split("_")[3]);
  73. $("#thematic_id_content_"+id ).show();
  74. });
  75. $(".thematic_content").mouseleave(function() {
  76. var id = parseInt(this.id.split("_")[3]);
  77. $("#thematic_id_content_"+id ).hide();
  78. });
  79. $(".thematic_advance_content").mouseover(function() {
  80. var id = parseInt(this.id.split("_")[4]);
  81. $("#thematic_advance_tools_"+id ).show();
  82. });
  83. $(".thematic_advance_content").mouseleave(function() {
  84. var id = parseInt(this.id.split("_")[4]);
  85. $("#thematic_advance_tools_"+id ).hide();
  86. });
  87. });
  88. </script>';
  89. $htmlHeadXtra[] = '<script>
  90. function datetime_by_attendance(attendance_id, thematic_advance_id) {
  91. $.ajax({
  92. contentType: "application/x-www-form-urlencoded",
  93. beforeSend: function(objeto) {},
  94. type: "GET",
  95. url: "'.api_get_path(WEB_AJAX_PATH).'thematic.ajax.php?a=get_datetime_by_attendance",
  96. data: "attendance_id="+attendance_id+"&thematic_advance_id="+thematic_advance_id,
  97. success: function(data) {
  98. $("#div_datetime_attendance").html(data);
  99. if (thematic_advance_id == 0) {
  100. $("#start_date_select_calendar").val($("#start_date_select_calendar option:first").val());
  101. }
  102. }
  103. });
  104. }
  105. function update_done_thematic_advance(selected_value) {
  106. $.ajax({
  107. contentType: "application/x-www-form-urlencoded",
  108. beforeSend: function(objeto) {},
  109. type: "GET",
  110. url: "'.api_get_path(WEB_AJAX_PATH).'thematic.ajax.php?a=update_done_thematic_advance",
  111. data: "thematic_advance_id="+selected_value,
  112. success: function(data) {
  113. $("#div_result").html(data);
  114. }
  115. });
  116. // clean all radios
  117. for (var i=0; i< $(".done_thematic").length;i++) {
  118. var id_radio_thematic = $(".done_thematic").get(i).id;
  119. $("#td_"+id_radio_thematic).css({"background-color":"#FFF"});
  120. }
  121. // set background to previous radios
  122. for (var i=0; i < $(".done_thematic").length;i++) {
  123. var id_radio_thematic = $(".done_thematic").get(i).id;
  124. $("#td_"+id_radio_thematic).css({"background-color":"#E5EDF9"});
  125. if ($(".done_thematic").get(i).value == selected_value) {
  126. break;
  127. }
  128. }
  129. }
  130. function check_per_attendance(obj) {
  131. if (obj.checked) {
  132. $("#div_datetime_by_attendance").show();
  133. $("#div_custom_datetime").hide();
  134. } else {
  135. $("#div_datetime_by_attendance").hide();
  136. $("#div_custom_datetime").show();
  137. }
  138. }
  139. function check_per_custom_date(obj) {
  140. if (obj.checked) {
  141. $("#div_custom_datetime").show();
  142. $("#div_datetime_by_attendance").hide();
  143. } else {
  144. $("#div_custom_datetime").hide();
  145. $("#div_datetime_by_attendance").show();
  146. }
  147. }
  148. </script>';
  149. $thematicAction = Session::read('thematic_control');
  150. if ($action == 'thematic_list') {
  151. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('ThematicControl'));
  152. }
  153. if ($action == 'thematic_add') {
  154. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$thematicAction, 'name' => get_lang('ThematicControl'));
  155. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('NewThematicSection'));
  156. }
  157. if ($action == 'thematic_edit') {
  158. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$thematicAction, 'name' => get_lang('ThematicControl'));
  159. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('EditThematicSection'));
  160. }
  161. if ($action == 'thematic_details') {
  162. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('ThematicControl'));
  163. }
  164. if ($action == 'thematic_plan_list' || $action == 'thematic_plan_delete') {
  165. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$thematicAction, 'name' => get_lang('ThematicControl'));
  166. if (!empty($thematic_data)) {
  167. $interbreadcrumb[] = array(
  168. 'url' => '#',
  169. 'name' => get_lang('ThematicPlan').' ('.$thematic_data['title'].') '
  170. );
  171. }
  172. }
  173. if ($action == 'thematic_plan_add' || $action == 'thematic_plan_edit') {
  174. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$thematicAction, 'name' => get_lang('ThematicControl'));
  175. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action=thematic_plan_list&thematic_id='.$thematic_id, 'name' => get_lang('ThematicPlan').' ('.$thematic_data['title'].')');
  176. if ($description_type >= ADD_THEMATIC_PLAN) {
  177. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('NewBloc'));
  178. } else {
  179. $interbreadcrumb[] = array ('url' => '#', 'name' => $default_thematic_plan_title[$description_type]);
  180. }
  181. }
  182. if ($action == 'thematic_advance_list' || $action == 'thematic_advance_delete') {
  183. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$thematicAction, 'name' => get_lang('ThematicControl'));
  184. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('ThematicAdvance').' ('.$thematic_data['title'].')');
  185. }
  186. if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') {
  187. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$thematicAction, 'name' => get_lang('ThematicControl'));
  188. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action=thematic_advance_list&thematic_id='.$thematic_id, 'name' => get_lang('ThematicAdvance').' ('.$thematic_data['title'].')');
  189. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('NewThematicAdvance'));
  190. }
  191. // Distpacher actions to controller
  192. switch ($action) {
  193. case 'thematic_add':
  194. case 'thematic_edit':
  195. case 'thematic_delete':
  196. case 'thematic_delete_select':
  197. case 'thematic_copy':
  198. case 'thematic_import_select':
  199. case 'thematic_import':
  200. case 'moveup':
  201. case 'movedown':
  202. if (!api_is_allowed_to_edit(null,true)) {
  203. api_not_allowed();
  204. }
  205. case 'thematic_list':
  206. case 'thematic_export':
  207. case 'thematic_export_pdf':
  208. case 'thematic_details':
  209. $thematic_controller->thematic($action);
  210. break;
  211. case 'thematic_plan_add':
  212. case 'thematic_plan_edit':
  213. case 'thematic_plan_delete':
  214. if (!api_is_allowed_to_edit(null,true)) {
  215. api_not_allowed();
  216. }
  217. case 'thematic_plan_list':
  218. $thematic_controller->thematic_plan($action);
  219. break;
  220. case 'thematic_advance_add':
  221. case 'thematic_advance_edit':
  222. case 'thematic_advance_delete':
  223. if (!api_is_allowed_to_edit(null,true)) {
  224. api_not_allowed();
  225. }
  226. case 'thematic_advance_list':
  227. $thematic_controller->thematic_advance($action);
  228. break;
  229. }