index.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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. * @package chamilo.course_progress
  7. */
  8. // name of the language file that needs to be included
  9. $language_file = array ('course_description', 'pedaSuggest', 'userInfo', 'admin');
  10. // including files
  11. require_once '../inc/global.inc.php';
  12. require_once api_get_path(LIBRARY_PATH).'attendance.lib.php';
  13. require_once api_get_path(LIBRARY_PATH).'thematic.lib.php';
  14. require_once api_get_path(LIBRARY_PATH).'app_view.php';
  15. //require_once 'attendance_controller.php';
  16. require_once 'thematic_controller.php';
  17. require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
  18. require_once api_get_path(LIBRARY_PATH).'course.lib.php';
  19. require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
  20. require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
  21. //require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
  22. // current section
  23. $this_section = SECTION_COURSES;
  24. // protect a course script
  25. api_protect_course_script(true);
  26. // defining constants
  27. define('ADD_THEMATIC_PLAN', 6);
  28. // get actions
  29. $actions = array('thematic_details', 'thematic_list', 'thematic_add', 'thematic_edit', 'thematic_copy', 'thematic_delete', 'moveup', 'movedown',
  30. 'thematic_plan_list', 'thematic_plan_add', 'thematic_plan_edit', 'thematic_plan_delete',
  31. 'thematic_advance_list', 'thematic_advance_add', 'thematic_advance_edit', 'thematic_advance_delete');
  32. $action = 'thematic_details';
  33. if (isset($_GET['action']) && in_array($_GET['action'],$actions)) {
  34. $action = $_GET['action'];
  35. }
  36. if (isset($_POST['action']) && $_POST['action'] == 'thematic_delete_select') {
  37. $action = 'thematic_delete_select';
  38. }
  39. if (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'true') {
  40. $action = 'thematic_details';
  41. }
  42. if ($action == 'thematic_details' || $action == 'thematic_list') {
  43. $_SESSION['thematic_control'] = $action;
  44. }
  45. // get thematic id
  46. if (isset($_GET['thematic_id'])) {
  47. $thematic_id = intval($_GET['thematic_id']);
  48. }
  49. // get thematic plan description type
  50. if (isset($_GET['description_type'])) {
  51. $description_type = intval($_GET['description_type']);
  52. }
  53. // instance thematic object for using like library here
  54. $thematic = new Thematic();
  55. // thematic controller object
  56. $thematic_controller = new ThematicController();
  57. if (!empty($thematic_id)) {
  58. // thematic data by id
  59. $thematic_data = $thematic->get_thematic_list($thematic_id);
  60. }
  61. // get default thematic plan title
  62. $default_thematic_plan_title = $thematic->get_default_thematic_plan_title();
  63. //jquery thickbox already called from main/inc/header.inc.php
  64. $htmlHeadXtra[] = '<script language="javascript">
  65. function datetime_by_attendance(selected_value) {
  66. $.ajax({
  67. contentType: "application/x-www-form-urlencoded",
  68. beforeSend: function(objeto) {},
  69. type: "POST",
  70. url: "'.api_get_path(WEB_AJAX_PATH).'thematic.ajax.php?a=get_datetime_by_attendance",
  71. data: "attendance_id="+selected_value+"&thematic_advance_id='.$thematic_id.'",
  72. success: function(datos) {
  73. $("#div_datetime_attendance").html(datos);
  74. }
  75. });
  76. }
  77. function update_done_thematic_advance(selected_value) {
  78. $.ajax({
  79. contentType: "application/x-www-form-urlencoded",
  80. beforeSend: function(objeto) {},
  81. type: "GET",
  82. url: "'.api_get_path(WEB_AJAX_PATH).'thematic.ajax.php?a=update_done_thematic_advance&thematic_advance_id="+selected_value,
  83. data: "thematic_advance_id="+selected_value,
  84. success: function(datos) {
  85. $("#div_result").html(datos);
  86. }
  87. });
  88. // clean all radios
  89. for (var i=0; i<$("input[@name=\'done_thematic\']").length;i++) {
  90. var id_radio_thematic = $("input[@name=\'done_thematic\']").get(i).id;
  91. $("#td_"+id_radio_thematic).css({"background-color":"#FFF"});
  92. }
  93. // set background to previous radios
  94. for (var i=0; i<$("input[@name=\'done_thematic\']").length;i++) {
  95. var id_radio_thematic = $("input[@name=\'done_thematic\']").get(i).id;
  96. $("#td_"+id_radio_thematic).css({"background-color":"#E5EDF9"});
  97. if ($("input[@name=\'done_thematic\']").get(i).value == selected_value) {
  98. break;
  99. }
  100. }
  101. }
  102. function check_per_attendance(obj) {
  103. if (obj.checked) {
  104. document.getElementById(\'div_datetime_by_attendance\').style.display=\'block\';
  105. document.getElementById(\'div_custom_datetime\').style.display=\'none\';
  106. } else {
  107. document.getElementById(\'div_datetime_by_attendance\').style.display=\'none\';
  108. document.getElementById(\'div_custom_datetime\').style.display=\'block\';
  109. }
  110. }
  111. function check_per_custom_date(obj) {
  112. if (obj.checked) {
  113. document.getElementById(\'div_custom_datetime\').style.display=\'block\';
  114. document.getElementById(\'div_datetime_by_attendance\').style.display=\'none\';
  115. } else {
  116. document.getElementById(\'div_custom_datetime\').style.display=\'none\';
  117. document.getElementById(\'div_datetime_by_attendance\').style.display=\'block\';
  118. }
  119. }
  120. </script>';
  121. // interbreadcrumbs
  122. //$interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action=thematic_details'.$param_gradebook.$student_param, 'name' => get_lang('ToolAttendance'));
  123. //if ($action == 'attendance_add') {
  124. //$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('CreateANewAttendance'));
  125. //}
  126. if ($action == 'thematic_list') {
  127. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('ThematicControl'));
  128. }
  129. if ($action == 'thematic_add') {
  130. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  131. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('NewThematicSection'));
  132. }
  133. if ($action == 'thematic_edit') {
  134. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  135. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('EditThematicSection'));
  136. }
  137. if ($action == 'thematic_details') {
  138. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('ThematicControl'));
  139. }
  140. if ($action == 'thematic_plan_list' || $action == 'thematic_plan_delete') {
  141. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  142. $interbreadcrumb[] = array ('url' => '#', 'name' => $thematic_data['title'].':'.get_lang('ThematicPlan'));
  143. }
  144. if ($action == 'thematic_plan_add' || $action == 'thematic_plan_edit') {
  145. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  146. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action=thematic_plan_list&thematic_id='.$thematic_id, 'name' => $thematic_data['title'].':'.get_lang('ThematicPlan'));
  147. if ($description_type >= ADD_THEMATIC_PLAN) {
  148. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('NewBloc'));
  149. } else {
  150. $interbreadcrumb[] = array ('url' => '#', 'name' => $default_thematic_plan_title[$description_type]);
  151. }
  152. }
  153. if ($action == 'thematic_advance_list' || $action == 'thematic_advance_delete') {
  154. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  155. $interbreadcrumb[] = array ('url' => '#', 'name' => $thematic_data['title'].':'.get_lang('ThematicAdvance'));
  156. }
  157. if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') {
  158. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
  159. $interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action=thematic_advance_list&thematic_id='.$thematic_id, 'name' => $thematic_data['title'].':'.get_lang('ThematicAdvance'));
  160. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('NewThematicAdvance'));
  161. }
  162. // distpacher actions to controller
  163. switch ($action) {
  164. case 'thematic_add' :
  165. case 'thematic_edit' :
  166. case 'thematic_delete' :
  167. case 'thematic_delete_select' :
  168. case 'thematic_copy' :
  169. case 'moveup' :
  170. case 'movedown' :
  171. if (!api_is_allowed_to_edit(null,true)) {
  172. api_not_allowed();
  173. }
  174. case 'thematic_list' :
  175. case 'thematic_details' :
  176. $thematic_controller->thematic($action);
  177. break;
  178. case 'thematic_plan_add' :
  179. case 'thematic_plan_edit' :
  180. case 'thematic_plan_delete' :
  181. if (!api_is_allowed_to_edit(null,true)) {
  182. api_not_allowed();
  183. }
  184. case 'thematic_plan_list' :
  185. $thematic_controller->thematic_plan($action);
  186. break;
  187. case 'thematic_advance_add' :
  188. case 'thematic_advance_edit' :
  189. case 'thematic_advance_delete' :
  190. if (!api_is_allowed_to_edit(null,true)) {
  191. api_not_allowed();
  192. }
  193. case 'thematic_advance_list' :
  194. $thematic_controller->thematic_advance($action);
  195. break;
  196. }