index.php 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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. // name of the language file that needs to be included
  10. $language_file = array('admin');
  11. // including files
  12. require_once '../inc/global.inc.php';
  13. require_once 'thematic_controller.php';
  14. // current section
  15. $this_section = SECTION_COURSES;
  16. $current_course_tool = TOOL_COURSE_PROGRESS;
  17. // protect a course script
  18. api_protect_course_script(true);
  19. // defining constants
  20. define('ADD_THEMATIC_PLAN', 6);
  21. // get actions
  22. $actions = array(
  23. 'thematic_details',
  24. 'thematic_list',
  25. 'thematic_add',
  26. 'thematic_edit',
  27. 'thematic_copy',
  28. 'thematic_delete',
  29. 'moveup',
  30. 'movedown',
  31. 'thematic_import_select',
  32. 'thematic_import',
  33. 'thematic_export',
  34. 'thematic_export_pdf',
  35. 'thematic_plan_list',
  36. 'thematic_plan_add',
  37. 'thematic_plan_edit',
  38. 'thematic_plan_delete',
  39. 'thematic_advance_list',
  40. 'thematic_advance_add',
  41. 'thematic_advance_edit',
  42. 'thematic_advance_delete'
  43. );
  44. $action = 'thematic_details';
  45. if (isset($_GET['action']) && in_array($_GET['action'],$actions)) {
  46. $action = $_GET['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['thematic_control'] = $action;
  56. }
  57. // get thematic id
  58. if (isset($_GET['thematic_id'])) {
  59. $thematic_id = intval($_GET['thematic_id']);
  60. }
  61. // get thematic plan description type
  62. if (isset($_GET['description_type'])) {
  63. $description_type = intval($_GET['description_type']);
  64. }
  65. // instance thematic object for using like library here
  66. $thematic = new Thematic();
  67. // thematic controller object
  68. $thematic_controller = new ThematicController();
  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. if ($action == 'thematic_list') {
  158. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('ThematicControl'));
  159. }
  160. if ($action == 'thematic_add') {
  161. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  162. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('NewThematicSection'));
  163. }
  164. if ($action == 'thematic_edit') {
  165. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  166. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('EditThematicSection'));
  167. }
  168. if ($action == 'thematic_details') {
  169. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('ThematicControl'));
  170. }
  171. if ($action == 'thematic_plan_list' || $action == 'thematic_plan_delete') {
  172. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  173. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('ThematicPlan').' ('.$thematic_data['title'].') ');
  174. }
  175. if ($action == 'thematic_plan_add' || $action == 'thematic_plan_edit') {
  176. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  177. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action=thematic_plan_list&thematic_id='.$thematic_id, 'name' => get_lang('ThematicPlan').' ('.$thematic_data['title'].')');
  178. if ($description_type >= ADD_THEMATIC_PLAN) {
  179. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('NewBloc'));
  180. } else {
  181. $interbreadcrumb[] = array ('url' => '#', 'name' => $default_thematic_plan_title[$description_type]);
  182. }
  183. }
  184. if ($action == 'thematic_advance_list' || $action == 'thematic_advance_delete') {
  185. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  186. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('ThematicAdvance').' ('.$thematic_data['title'].')');
  187. }
  188. if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') {
  189. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  190. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action=thematic_advance_list&thematic_id='.$thematic_id, 'name' => get_lang('ThematicAdvance').' ('.$thematic_data['title'].')');
  191. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('NewThematicAdvance'));
  192. }
  193. // Distpacher actions to controller
  194. switch ($action) {
  195. case 'thematic_add':
  196. case 'thematic_edit':
  197. case 'thematic_delete':
  198. case 'thematic_delete_select':
  199. case 'thematic_copy':
  200. case 'thematic_import_select':
  201. case 'thematic_import':
  202. case 'moveup':
  203. case 'movedown':
  204. if (!api_is_allowed_to_edit(null,true)) {
  205. api_not_allowed();
  206. }
  207. case 'thematic_list':
  208. case 'thematic_export':
  209. case 'thematic_export_pdf':
  210. case 'thematic_details':
  211. $thematic_controller->thematic($action);
  212. break;
  213. case 'thematic_plan_add':
  214. case 'thematic_plan_edit':
  215. case 'thematic_plan_delete':
  216. if (!api_is_allowed_to_edit(null,true)) {
  217. api_not_allowed();
  218. }
  219. case 'thematic_plan_list':
  220. $thematic_controller->thematic_plan($action);
  221. break;
  222. case 'thematic_advance_add':
  223. case 'thematic_advance_edit':
  224. case 'thematic_advance_delete':
  225. if (!api_is_allowed_to_edit(null,true)) {
  226. api_not_allowed();
  227. }
  228. case 'thematic_advance_list':
  229. $thematic_controller->thematic_advance($action);
  230. break;
  231. }