index.php 8.9 KB

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