index.php 8.9 KB

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