index.php 9.8 KB

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