index.php 9.0 KB

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