myticket.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This script is the Tickets plugin main entry point
  5. * @package chamilo.plugin.ticket
  6. */
  7. $language_file = array('admin');
  8. $cidReset = true;
  9. //needed in order to load the plugin lang variables
  10. $course_plugin = 'ticket';
  11. require_once '../config.php';
  12. $plugin = TicketPlugin::create();
  13. $tool_name = $plugin->get_lang('LastEdit');
  14. api_block_anonymous_users();
  15. $libPath = api_get_path(LIBRARY_PATH);
  16. $webLibPath = api_get_path(WEB_LIBRARY_PATH);
  17. $htmlHeadXtra[] = '<script type="text/javascript">
  18. function load_history_ticket (div_course,ticket_id) {
  19. $.ajax({
  20. contentType: "application/x-www-form-urlencoded",
  21. beforeSend: function(object) {
  22. $("div#"+div_course).html("<img src=\'' . $webLibPath . 'javascript/indicator.gif\' />"); },
  23. type: "POST",
  24. url: "ticket_assign_log.php",
  25. data: "ticket_id="+ticket_id,
  26. success: function(data) {
  27. $("div#div_"+ticket_id).html(data);
  28. $("div#div_"+ticket_id).attr("class","blackboard_show");
  29. $("div#div_"+ticket_id).attr("style","");
  30. }
  31. });
  32. }
  33. function clear_course_list (div_course) {
  34. $("div#"+div_course).html("&nbsp;");
  35. $("div#"+div_course).hide("");
  36. }
  37. $(function() {
  38. $( "#keyword_start_date_start" ).datepicker({ dateFormat: ' . "'dd/mm/yy'" . ' });
  39. $( "#keyword_start_date_end" ).datepicker({ dateFormat: ' . "'dd/mm/yy'" . ' });
  40. });
  41. $(document).ready(function() {
  42. $("#advanced_search_form").css("display","none");
  43. });
  44. function display_advanced_search_form () {
  45. if ($("#advanced_search_form").css("display") == "none") {
  46. $("#advanced_search_form").css("display","block");
  47. $("#img_plus_and_minus").html(\'&nbsp;' . Display::return_icon('div_hide.gif', get_lang('Hide'), array('style' => 'vertical-align:middle')) . '&nbsp;' . get_lang('AdvancedSearch') . '\');
  48. } else {
  49. $("#advanced_search_form").css("display","none");
  50. $("#img_plus_and_minus").html(\'&nbsp;' . Display::return_icon('div_show.gif', get_lang('Show'), array('style' => 'vertical-align:middle')) . '&nbsp;' . get_lang('AdvancedSearch') . '\');
  51. }
  52. }
  53. </script>
  54. <style>
  55. .label2 {
  56. float: left;
  57. text-align: left;
  58. width: 75px;
  59. }
  60. .label3 {
  61. margin-left: 20px;
  62. float: left;
  63. text-align: left;
  64. margin-top: 10px;
  65. width: 95px;
  66. }
  67. .label4 {
  68. float: left;
  69. text-align: left;
  70. margin-top: 10px;
  71. width: 75px;
  72. }
  73. .formw2 {
  74. float: left;
  75. margin-left: 4px;
  76. margin-top: 5px;
  77. }
  78. .blackboard_show {
  79. float: left;
  80. position: absolute;
  81. border: 1px solid black;
  82. width: 350px;
  83. background-color: white;
  84. z-index: 99;
  85. padding: 3px;
  86. display: inline;
  87. }
  88. .blackboard_hide {
  89. display: none;
  90. }
  91. .advanced-parameters {
  92. margin-top: 5px;
  93. }
  94. .remove-margin-top {
  95. margin-top: 0px;
  96. }
  97. .select-margin-top {
  98. margin-top: -5px;
  99. }
  100. .input-width {
  101. width: 170px;
  102. }
  103. .fleft {
  104. float: left;
  105. }
  106. </style>';
  107. $this_section = 'tickets';
  108. unset($_SESSION['this_section']);
  109. $table = new SortableTable(
  110. 'Tickets',
  111. array('TicketManager', 'get_total_tickets_by_user_id'),
  112. array('TicketManager', 'get_tickets_by_user_id'),
  113. 2,
  114. 20,
  115. 'DESC'
  116. );
  117. if ($table->per_page == 0) {
  118. $table->per_page = 20;
  119. }
  120. if (isset($_GET['action'])) {
  121. global $table;
  122. $action = $_GET['action'];
  123. switch ($action) {
  124. case 'assign':
  125. if ($isAdmin && isset($_GET['ticket_id']))
  126. TicketManager::assign_ticket_user($_GET['ticket_id'], $user_id);
  127. break;
  128. case 'unassign':
  129. if ($isAdmin && isset($_GET['ticket_id']))
  130. TicketManager::assign_ticket_user($_GET['ticket_id'], 0);
  131. break;
  132. case 'alert':
  133. if (!$isAdmin && isset($_GET['ticket_id']))
  134. TicketManager::send_alert($_GET['ticket_id'], $user_id);
  135. break;
  136. case 'export':
  137. $data = array(
  138. array(
  139. $plugin->get_lang('TicketNum'),
  140. $plugin->get_lang('Date'),
  141. $plugin->get_lang('DateLastEdition'),
  142. $plugin->get_lang('Category'),
  143. $plugin->get_lang('User'),
  144. $plugin->get_lang('Program'),
  145. $plugin->get_lang('Responsible'),
  146. $plugin->get_lang('Status'),
  147. $plugin->get_lang('Description')
  148. )
  149. );
  150. $datos = $table->get_clean_html();
  151. foreach ($datos as $ticket) {
  152. $ticket[0] = substr(strip_tags($ticket[0]), 0, 12);
  153. $ticket_rem = array(
  154. utf8_decode(strip_tags($ticket[0])),
  155. utf8_decode(api_html_entity_decode($ticket[1])),
  156. utf8_decode(strip_tags($ticket[2])),
  157. utf8_decode(strip_tags($ticket[3])),
  158. utf8_decode(strip_tags($ticket[4])),
  159. utf8_decode(strip_tags($ticket[5])),
  160. utf8_decode(strip_tags($ticket[6])),
  161. utf8_decode(strip_tags($ticket[7])),
  162. utf8_decode(strip_tags(str_replace('&nbsp;', ' ', $ticket[9])))
  163. );
  164. $data[] = $ticket_rem;
  165. }
  166. Export::export_table_xls($data, $plugin->get_lang('Tickets'));
  167. exit;
  168. break;
  169. case 'close_tickets':
  170. TicketManager::close_old_tickets();
  171. break;
  172. default:
  173. break;
  174. }
  175. }
  176. //$nameTools = api_xml_http_response_encode($plugin->get_lang('MyTickets'));
  177. $user_id = api_get_user_id();
  178. $isAdmin = api_is_platform_admin();
  179. Display::display_header($plugin->get_lang('MyTickets'));
  180. if ($isAdmin) {
  181. $get_parameter = '&keyword=' . Security::remove_XSS($_GET['keyword']) . '&keyword_status=' . Security::remove_XSS($_GET['keyword_status']) . '&keyword_category=' .Security::remove_XSS($_GET['keyword_category']). '&keyword_request_user=' . Security::remove_XSS($_GET['keyword_request_user']);
  182. $get_parameter .= '&keyword_admin=' . Security::remove_XSS($_GET['keyword_admin']) . '&keyword_start_date=' . Security::remove_XSS($_GET['keyword_start_date']) . '&keyword_unread=' . Security::remove_XSS($_GET['keyword_unread']);
  183. $get_parameter2 = '&Tickets_per_page=' . Security::remove_XSS($_GET['Tickets_per_page']) . '&Tickets_column=' . Security::remove_XSS($_GET['Tickets_column']);
  184. if (isset($_GET['submit_advanced'])) {
  185. $get_parameter .= "&submit_advanced=";
  186. }
  187. if (isset($_GET['submit_simple'])) {
  188. $get_parameter .= "&submit_simple=";
  189. }
  190. //select categories
  191. $select_types .= '<select class="chzn-select" name = "keyword_category" id="keyword_category" ">';
  192. $select_types .= '<option value="">---' . get_lang('Select') . '---</option>';
  193. $types = TicketManager::get_all_tickets_categories();
  194. foreach ($types as $type) {
  195. $select_types.= "<option value = '" . $type['category_id'] . "'>" . $type['name'] . "</option>";
  196. }
  197. $select_types .= "</select>";
  198. //select admins
  199. $select_admins .= '<select class ="chzn-select" name = "keyword_admin" id="keyword_admin" ">';
  200. $select_admins .= '<option value="">---' . get_lang('Select') . '---</option>';
  201. $select_admins .= '<option value = "0">' . $plugin->get_lang('Unassigned') . '</option>';
  202. $admins = UserManager::get_user_list_like(array("status" => "1"), array("username"), true);
  203. foreach ($admins as $admin) {
  204. $select_admins.= "<option value = '" . $admin['user_id'] . "'>" . $admin['lastname'] . " ," . $admin['firstname'] . "</option>";
  205. }
  206. $select_admins .= "</select>";
  207. //select status
  208. $select_status .= '<select class ="chzn-select" name = "keyword_status" id="keyword_status" >';
  209. $select_status .= '<option value="">---' . get_lang('Select') . '---</option>';
  210. $status = TicketManager::get_all_tickets_status();
  211. foreach ($status as $stat) {
  212. $select_status.= "<option value = '" . $stat['status_id'] . "'>" . $stat['name'] . "</option>";
  213. }
  214. $select_status .= "</select>";
  215. //select priority
  216. $select_priority .= '<select name = "keyword_priority" id="keyword_priority" >';
  217. $select_priority .= '<option value="">' . get_lang('All') . '</option>';
  218. $select_priority .= '<option value="NRM">' . $plugin->get_lang('PriorityNormal') . '</option>';
  219. $select_priority .= '<option value="HGH">' . $plugin->get_lang('PriorityHigh') . '</option>';
  220. $select_priority .= '<option value="LOW">' . $plugin->get_lang('PriorityLow') . '</option>';
  221. $select_priority .= "</select>";
  222. //select unread
  223. $select_unread = '<select name = "keyword_unread" id="keyword_unread" >';
  224. $select_unread .= '<option value="">' . get_lang('All') . '</option>';
  225. $select_unread .= '<option value="yes">' . $plugin->get_lang('Unread') . '</option>';
  226. $select_unread .= '<option value="no">' . $plugin->get_lang('Read') . '</option>';
  227. $select_unread .= "</select>";
  228. // Create a search-box
  229. $form = new FormValidator('search_simple', 'get', '', '', null, false);
  230. $renderer = & $form->defaultRenderer();
  231. $renderer->setCustomElementTemplate('<span>{element}</span> ');
  232. $form->addElement('text', 'keyword', get_lang('keyword'), 'size="25"');
  233. $form->addElement('style_submit_button', 'submit_simple', get_lang('Search'), 'class="search"');
  234. $form->addElement('static', 'search_advanced_link', null,
  235. '<a href="javascript://" class = "advanced-parameters" onclick="display_advanced_search_form();">'
  236. . '<span id="img_plus_and_minus">&nbsp;'
  237. . Display::return_icon('div_show.gif', get_lang('Show')) . ' '
  238. . get_lang('AdvancedSearch') . '</span></a>');
  239. echo '<div class="actions" >';
  240. if (api_is_platform_admin()) {
  241. echo '<span class="fleft">' .
  242. '<a href="' . api_get_path(WEB_PLUGIN_PATH) . 'ticket/src/new_ticket.php">' .
  243. Display::return_icon('add.png', $plugin->get_lang('TckNew'), '', '32') . '</a>' .
  244. '<a href="' . api_get_self() . '?action=export' . $get_parameter . $get_parameter2 . '">' .
  245. Display::return_icon('export_excel.png', get_lang('Export'), '', '32') . '</a>' .
  246. '</span>';
  247. }
  248. $form->display();
  249. echo '</div>';
  250. echo '<form action="' . api_get_self() . '" method="get" name="advanced_search" id="advanced_search" display:"none">
  251. <div id="advanced_search_form" style="display: block;">
  252. <div>
  253. <div class="form_header">' . get_lang('AdvancedSearch') . '</div>
  254. </div>
  255. <table >
  256. <tbody>
  257. <tr>
  258. <td>
  259. <div>
  260. <div class="label2">' . get_lang('Category') . ': </div>
  261. <div class="formw2" style="margin-top: -5px;">' . $select_types . '</div>
  262. </div>
  263. </td>
  264. <td>
  265. <div>
  266. <div class="label3">' . get_lang('User') . ': </div>
  267. <div class="formw2"><input class="input-width" id="keyword_request_user" name="keyword_request_user" type="text"></div>
  268. </div>
  269. </td>
  270. <td>
  271. <div>
  272. <div class="label3">' . $plugin->get_lang('RegisterDate') . ': </div>
  273. <div class="formw2"><input class="input-width" id="keyword_start_date_start" name="keyword_start_date_start" type="text"></div>
  274. </div>
  275. </td>
  276. <td>
  277. <div>
  278. <div class="label3"><input type="checkbox" name="keyword_dates" value="1">' . $plugin->get_lang('Untill') . '</div>
  279. <div class="formw2"><input class="input-width" id="keyword_start_date_end" name="keyword_start_date_end" type="text"></div>
  280. </div>
  281. </td>
  282. </tr>
  283. <tr >
  284. <td>
  285. <div>
  286. <div class="label2">' . $plugin->get_lang('AssignedTo') . ': </div>
  287. <div class="formw2 select-margin-top">' . $select_admins . '</div>
  288. </div>
  289. </td>
  290. <td>
  291. <div>
  292. <div class="label3 remove-margin-top">' . get_lang('Status') . ':</div>
  293. <div class="formw2 select-margin-top">' . $select_status . '</div>
  294. </div>
  295. </td>
  296. <td>
  297. <div>
  298. <div>
  299. <div class="label3">' . $plugin->get_lang('Priority') . ': </div>
  300. <div class="formw2">' . $select_priority . '</div>
  301. </div>
  302. </td>
  303. <td>
  304. <div>
  305. <div>
  306. <div class="label3">' . get_lang('Status') . ': </div>
  307. <div class="formw2">' . $select_unread . '</div>
  308. </div>
  309. </td>
  310. </tr>
  311. <tr>
  312. <td>
  313. <div >
  314. <div class="label4">' . get_lang('Course') . ': </div>
  315. <div class="formw2">
  316. <input id="keyword_course" style="width: 170px;" name="keyword_course" type="text"></div>
  317. </div>
  318. </td>
  319. <td colspan= "3">
  320. <div>
  321. <button name="submit_advanced" type="submit">' . get_lang('AdvancedSearch') . '</button>
  322. </div>
  323. </td>
  324. </tr>
  325. </tbody>
  326. </table>
  327. </div>
  328. <input name="_qf__advanced_search" type="hidden" value="">
  329. <div class="clear">&nbsp;</div>
  330. </form>';
  331. } else {
  332. if ($plugin->get('allow_student_add') == 'true') {
  333. echo '<div class="actions" >';
  334. echo '<span style="float:right;">' .
  335. '<a href="' . api_get_path(WEB_PLUGIN_PATH) . 'ticket/src/new_ticket.php">' .
  336. Display::return_icon('add.png', $plugin->get_lang('TckNew'), '', '32') .
  337. '</a>' .
  338. '</span>';
  339. echo '<span style="float:right;">' .
  340. '</span>';
  341. echo '</div>';
  342. }
  343. }
  344. if ($isAdmin) {
  345. $table->set_header(0, $plugin->get_lang('TicketNum'), true);
  346. $table->set_header(1, $plugin->get_lang('Date'), true);
  347. $table->set_header(2, $plugin->get_lang('DateLastEdition'), true);
  348. $table->set_header(3, $plugin->get_lang('Category'), true);
  349. $table->set_header(4, $plugin->get_lang('User'), true);
  350. $table->set_header(5, $plugin->get_lang('Responsible'), true);
  351. $table->set_header(6, $plugin->get_lang('Status'), true);
  352. $table->set_header(7, $plugin->get_lang('Message'), true);
  353. $table->set_header(8, get_lang('Actions'), true);
  354. $table->set_header(9, get_lang('Description'), true, array("style" => "width:200px"));
  355. } else {
  356. echo '<center><h1>' . $plugin->get_lang('MyTickets') . '</h1></center>';
  357. echo '<center><p>' . $plugin->get_lang('MsgWelcome') . '</p></center>';
  358. if (isset($_GET['message'])) {
  359. Display::display_confirmation_message($plugin->get_lang('TckSuccessSave'));
  360. }
  361. $table->set_header(0, $plugin->get_lang('TicketNum'), true);
  362. $table->set_header(1, $plugin->get_lang('Date'), true);
  363. $table->set_header(2, $plugin->get_lang('DateLastEdition'), true);
  364. $table->set_header(3, $plugin->get_lang('Category'));
  365. $table->set_header(4, $plugin->get_lang('Status'), false);
  366. $table->set_header(5, get_lang('Actions'), false);
  367. }
  368. $table->display();
  369. Display::display_footer();