work_list_all.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. require_once __DIR__.'/../inc/global.inc.php';
  4. $current_course_tool = TOOL_STUDENTPUBLICATION;
  5. api_protect_course_script(true);
  6. // Including necessary files
  7. require_once 'work.lib.php';
  8. $this_section = SECTION_COURSES;
  9. $workId = isset($_GET['id']) ? (int) $_GET['id'] : null;
  10. $is_allowed_to_edit = api_is_allowed_to_edit() || api_is_coach();
  11. if (empty($workId)) {
  12. api_not_allowed(true);
  13. }
  14. $my_folder_data = get_work_data_by_id($workId);
  15. if (empty($my_folder_data)) {
  16. api_not_allowed(true);
  17. }
  18. $work_data = get_work_assignment_by_id($workId);
  19. $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
  20. api_get_user_id(),
  21. api_get_course_info()
  22. );
  23. if (!($is_allowed_to_edit || $isDrhOfCourse)) {
  24. api_not_allowed(true);
  25. }
  26. $tool_name = get_lang('StudentPublications');
  27. $group_id = api_get_group_id();
  28. $courseInfo = api_get_course_info();
  29. $courseCode = $courseInfo['code'];
  30. $sessionId = api_get_session_id();
  31. $htmlHeadXtra[] = api_get_jqgrid_js();
  32. $user_id = api_get_user_id();
  33. if (!empty($group_id)) {
  34. $group_properties = GroupManager::get_group_properties($group_id);
  35. $show_work = false;
  36. if (api_is_allowed_to_edit(false, true)) {
  37. $show_work = true;
  38. } else {
  39. // you are not a teacher
  40. $show_work = GroupManager::user_has_access(
  41. $user_id,
  42. $group_properties['iid'],
  43. GroupManager::GROUP_TOOL_WORK
  44. );
  45. }
  46. if (!$show_work) {
  47. api_not_allowed();
  48. }
  49. $interbreadcrumb[] = [
  50. 'url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(),
  51. 'name' => get_lang('Groups'),
  52. ];
  53. $interbreadcrumb[] = [
  54. 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(),
  55. 'name' => get_lang('GroupSpace').' '.$group_properties['name'],
  56. ];
  57. }
  58. $interbreadcrumb[] = [
  59. 'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
  60. 'name' => get_lang('StudentPublications'),
  61. ];
  62. $interbreadcrumb[] = [
  63. 'url' => api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId,
  64. 'name' => $my_folder_data['title'],
  65. ];
  66. $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
  67. $itemId = isset($_REQUEST['item_id']) ? (int) $_REQUEST['item_id'] : null;
  68. switch ($action) {
  69. case 'export_to_doc':
  70. if ($is_allowed_to_edit) {
  71. if (!empty($itemId)) {
  72. $work = get_work_data_by_id($itemId);
  73. if (!empty($work)) {
  74. Export::htmlToOdt($work['description'], $work['title']);
  75. }
  76. }
  77. }
  78. break;
  79. case 'delete':
  80. /* Delete document */
  81. if ($itemId) {
  82. $fileDeleted = deleteWorkItem($itemId, $courseInfo);
  83. if (!$fileDeleted) {
  84. Display::addFlash(
  85. Display::return_message(get_lang('YouAreNotAllowedToDeleteThisDocument'), 'error')
  86. );
  87. } else {
  88. Display::addFlash(
  89. Display::return_message(get_lang('TheDocumentHasBeenDeleted'), 'confirmation')
  90. );
  91. }
  92. }
  93. break;
  94. case 'delete_correction':
  95. $result = get_work_user_list(null, null, null, null, $workId);
  96. if ($result) {
  97. foreach ($result as $item) {
  98. $workToDelete = get_work_data_by_id($item['id']);
  99. deleteCorrection($courseInfo, $workToDelete);
  100. }
  101. Display::addFlash(
  102. Display::return_message(get_lang('Deleted'), 'confirmation')
  103. );
  104. }
  105. header('Location: '.api_get_self().'?'.api_get_cidreq().'&id='.$workId);
  106. exit;
  107. break;
  108. case 'make_visible':
  109. /* Visible */
  110. if ($is_allowed_to_edit) {
  111. if (!empty($itemId)) {
  112. if (isset($itemId) && $itemId == 'all') {
  113. } else {
  114. makeVisible($itemId, $courseInfo);
  115. Display::addFlash(
  116. Display::return_message(get_lang('FileVisible'), 'confirmation')
  117. );
  118. }
  119. }
  120. }
  121. break;
  122. case 'make_invisible':
  123. /* Invisible */
  124. if (!empty($itemId)) {
  125. if (isset($itemId) && $itemId == 'all') {
  126. } else {
  127. makeInvisible($itemId, $courseInfo);
  128. Display::addFlash(
  129. Display::return_message(get_lang('FileInvisible'), 'confirmation')
  130. );
  131. }
  132. }
  133. break;
  134. case 'export_pdf':
  135. exportAllStudentWorkFromPublication(
  136. $workId,
  137. $courseInfo,
  138. $sessionId,
  139. 'pdf'
  140. );
  141. break;
  142. }
  143. $htmlHeadXtra[] = api_get_jquery_libraries_js(['jquery-upload']);
  144. Display::display_header(null);
  145. $documentsAddedInWork = getAllDocumentsFromWorkToString($workId, $courseInfo);
  146. $actionsLeft = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq().'">'.
  147. Display::return_icon('back.png', get_lang('BackToWorksList'), '', ICON_SIZE_MEDIUM).'</a>';
  148. if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !$isDrhOfCourse) {
  149. $blockAddDocuments = api_get_configuration_value('block_student_publication_add_documents');
  150. if (!$blockAddDocuments) {
  151. $actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'work/add_document.php?'.api_get_cidreq().'&id='.$workId.'">';
  152. $actionsLeft .= Display::return_icon('new_document.png', get_lang('AddDocument'), '', ICON_SIZE_MEDIUM).'</a>';
  153. }
  154. $actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'work/add_user.php?'.api_get_cidreq().'&id='.$workId.'">';
  155. $actionsLeft .= Display::return_icon('addworkuser.png', get_lang('AddUsers'), '', ICON_SIZE_MEDIUM).'</a>';
  156. $actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId.'&action=export_pdf">';
  157. $actionsLeft .= Display::return_icon('pdf.png', get_lang('Export'), '', ICON_SIZE_MEDIUM).'</a>';
  158. $display_output = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work_missing.php?'.api_get_cidreq().'&amp;id='.$workId.'&amp;list=without">'.
  159. Display::return_icon('exercice_uncheck.png', get_lang('ViewUsersWithoutTask'), '', ICON_SIZE_MEDIUM)."</a>";
  160. $editLink = '<a href="'.api_get_path(WEB_CODE_PATH).'work/edit_work.php?'.api_get_cidreq().'&id='.$workId.'">';
  161. $editLink .= Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM).'</a>';
  162. $blockEdition = api_get_configuration_value('block_student_publication_edition');
  163. if ($blockEdition && !api_is_platform_admin()) {
  164. $editLink = '';
  165. }
  166. $actionsLeft .= $editLink;
  167. $count = get_count_work($workId);
  168. if ($count > 0) {
  169. $display_output .= '<a class="btn-toolbar" href="downloadfolder.inc.php?id='.$workId.'&'.api_get_cidreq().'">'.
  170. Display::return_icon('save_pack.png', get_lang('DownloadTasksPackage'), null, ICON_SIZE_MEDIUM).' '.get_lang('DownloadTasksPackage').'</a>';
  171. }
  172. $actionsLeft .= $display_output;
  173. $url = api_get_path(WEB_CODE_PATH).'work/upload_corrections.php?'.api_get_cidreq().'&id='.$workId;
  174. $actionsLeft .= '<a class="btn-toolbar" href="'.$url.'">'.
  175. Display::return_icon('upload_package.png', get_lang('UploadCorrectionsPackage'), '', ICON_SIZE_MEDIUM).' '.get_lang('UploadCorrectionsPackage').'</a>';
  176. $url = api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId.'&action=delete_correction';
  177. $actionsLeft .= Display::toolbarButton(get_lang('DeleteCorrections'), $url, 'remove', 'danger');
  178. }
  179. echo Display::toolbarAction('toolbar-worklist', [$actionsLeft]);
  180. $plagiarismListJqgridColumn = [];
  181. $plagiarismListJqgridLine = [];
  182. if (api_get_configuration_value('allow_compilatio_tool')) {
  183. require_once api_get_path(SYS_CODE_PATH).'/plagiarism/compilatio/config.php';
  184. $plagiarismListJqgridColumn = ['Compilatio'];
  185. $plagiarismListJqgridLine = [
  186. [
  187. 'name'=>'compilatio',
  188. 'index'=>'compilatio',
  189. 'width'=>'40',
  190. 'align'=>'left',
  191. 'search' => 'false',
  192. 'sortable'=>'false'
  193. ]
  194. ];
  195. }
  196. if (!empty($my_folder_data['title'])) {
  197. echo Display::page_subheader($my_folder_data['title']);
  198. }
  199. if (!empty($my_folder_data['description'])) {
  200. $contentWork = Security::remove_XSS($my_folder_data['description']);
  201. $html = '';
  202. $html .= Display::panel($contentWork, get_lang('Description'));
  203. echo $html;
  204. }
  205. $check_qualification = (int) $my_folder_data['qualification'];
  206. $orderName = api_is_western_name_order() ? 'firstname' : 'lastname';
  207. if (!empty($work_data['enable_qualification']) &&
  208. !empty($check_qualification)
  209. ) {
  210. $type = 'simple';
  211. $columns = [
  212. get_lang('FullUserName'),
  213. get_lang('Title'),
  214. get_lang('Score'),
  215. get_lang('Date'),
  216. get_lang('Status'),
  217. get_lang('UploadCorrection'),
  218. ];
  219. $columns = array_merge($columns, $plagiarismListJqgridColumn);
  220. $columns[] = get_lang('Actions');
  221. $column_model = [
  222. [
  223. 'name' => 'fullname',
  224. 'index' => $orderName,
  225. 'width' => '30',
  226. 'align' => 'left',
  227. 'search' => 'true',
  228. ],
  229. [
  230. 'name' => 'title',
  231. 'index' => 'title',
  232. 'width' => '25',
  233. 'align' => 'left',
  234. 'search' => 'false',
  235. 'wrap_cell' => 'true',
  236. ],
  237. [
  238. 'name' => 'qualification',
  239. 'index' => 'qualification',
  240. 'width' => '15',
  241. 'align' => 'center',
  242. 'search' => 'true',
  243. ],
  244. [
  245. 'name' => 'sent_date',
  246. 'index' => 'sent_date',
  247. 'width' => '25',
  248. 'align' => 'left',
  249. 'search' => 'true',
  250. 'wrap_cell' => 'true',
  251. ],
  252. [
  253. 'name' => 'qualificator_id',
  254. 'index' => 'qualificator_id',
  255. 'width' => '20',
  256. 'align' => 'left',
  257. 'search' => 'true',
  258. ],
  259. [
  260. 'name' => 'correction',
  261. 'index' => 'correction',
  262. 'width' => '30',
  263. 'align' => 'left',
  264. 'search' => 'false',
  265. 'sortable' => 'false',
  266. 'title' => 'false',
  267. ],
  268. ];
  269. $column_model = array_merge($column_model, $plagiarismListJqgridLine);
  270. $column_model[] = [
  271. 'name' => 'actions',
  272. 'index' => 'actions',
  273. 'width' => '25',
  274. 'align' => 'left',
  275. 'search' => 'false',
  276. 'sortable' => 'false',
  277. ];
  278. } else {
  279. $type = 'complex';
  280. $columns = [
  281. get_lang('FullUserName'),
  282. get_lang('Title'),
  283. get_lang('Feedback'),
  284. get_lang('Date'),
  285. get_lang('UploadCorrection'),
  286. ];
  287. $columns = array_merge($columns, $plagiarismListJqgridColumn);
  288. $columns[] = get_lang('Actions');
  289. $column_model = [
  290. [
  291. 'name' => 'fullname',
  292. 'index' => $orderName,
  293. 'width' => '35',
  294. 'align' => 'left',
  295. 'search' => 'true',
  296. ],
  297. [
  298. 'name' => 'title',
  299. 'index' => 'title',
  300. 'width' => '30',
  301. 'align' => 'left',
  302. 'search' => 'false',
  303. 'wrap_cell' => 'true',
  304. ],
  305. [
  306. 'name' => 'qualification',
  307. 'index' => 'qualification',
  308. 'width' => '20',
  309. 'align' => 'center',
  310. 'search' => 'true',
  311. ],
  312. [
  313. 'name' => 'sent_date',
  314. 'index' => 'sent_date',
  315. 'width' => '30',
  316. 'align' => 'left',
  317. 'search' => 'true',
  318. 'wrap_cell' => 'true',
  319. ],
  320. [
  321. 'name' => 'correction',
  322. 'index' => 'correction',
  323. 'width' => '40',
  324. 'align' => 'left',
  325. 'search' => 'false',
  326. 'sortable' => 'false',
  327. 'title' => 'false',
  328. ],
  329. ];
  330. $column_model = array_merge($column_model, $plagiarismListJqgridLine);
  331. $column_model[] = [
  332. 'name' => 'actions',
  333. 'index' => 'actions',
  334. 'width' => '25',
  335. 'align' => 'left',
  336. 'search' => 'false',
  337. 'sortable' => 'false',
  338. ];
  339. }
  340. $extra_params = [
  341. 'autowidth' => 'true',
  342. 'height' => 'auto',
  343. 'sortname' => $orderName,
  344. 'sortable' => 'false',
  345. 'multiselect' => 'true',
  346. ];
  347. $url = api_get_path(WEB_AJAX_PATH).
  348. 'model.ajax.php?a=get_work_user_list_all&work_id='.$workId.'&type='.$type.'&'.api_get_cidreq();
  349. $workUrl = api_get_path(WEB_AJAX_PATH).'work.ajax.php?'.api_get_cidreq();
  350. $deleteUrl = $workUrl.'&a=delete_student_work';
  351. $showUrl = $workUrl.'&a=show_student_work';
  352. $hideUrl = $workUrl.'&a=hide_student_work';
  353. ?>
  354. <script>
  355. $(function() {
  356. <?php
  357. echo Display::grid_js('results', $url, $columns, $column_model, $extra_params);
  358. ?>
  359. $("#results").jqGrid(
  360. "navGrid",
  361. "#results_pager",
  362. { edit: false, add: false, search: false, del: true },
  363. { height:280, reloadAfterSubmit:false }, // edit options
  364. { height:280, reloadAfterSubmit:false }, // add options
  365. { reloadAfterSubmit:false, url: "<?php echo $deleteUrl; ?>" }, // del options
  366. { width:500 } // search options
  367. ).navButtonAdd('#results_pager', {
  368. caption:"<i class=\"fa fa-eye\" ></i>",
  369. buttonicon:"ui-icon-blank",
  370. onClickButton: function(a) {
  371. var userIdList = $("#results").jqGrid('getGridParam', 'selarrrow');
  372. if (userIdList.length) {
  373. $.ajax({
  374. type: "POST",
  375. url: "<?php echo $showUrl; ?>&item_list=" + userIdList,
  376. dataType: "json",
  377. success: function(data) {
  378. $('#results').trigger('reloadGrid');
  379. }
  380. });
  381. } else {
  382. alert("<?php echo addslashes(get_lang('SelectAnOption')); ?>");
  383. }
  384. },
  385. position:"last"
  386. }).navButtonAdd('#results_pager', {
  387. //caption:"<?php //echo addslashes(get_lang('SetVisible'));?>//",
  388. caption:"<i class=\"fa fa-eye-slash\" ></i>",
  389. buttonicon:"ui-icon-blank",
  390. onClickButton: function(a) {
  391. var userIdList = $("#results").jqGrid('getGridParam', 'selarrrow');
  392. if (userIdList.length) {
  393. $.ajax({
  394. type: "POST",
  395. url: "<?php echo $hideUrl; ?>&item_list=" + userIdList,
  396. dataType: "json",
  397. success: function(data) {
  398. $('#results').trigger('reloadGrid');
  399. }
  400. });
  401. } else {
  402. alert("<?php echo addslashes(get_lang('SelectAnOption')); ?>");
  403. }
  404. },
  405. position:"last"
  406. });
  407. });
  408. </script>
  409. <?php
  410. echo $documentsAddedInWork;
  411. $tableWork = Display::grid_html('results');
  412. echo workGetExtraFieldData($workId);
  413. echo Display::panel($tableWork);
  414. echo '<div class="list-work-results">';
  415. echo '<div class="panel panel-default">';
  416. echo '<div class="panel-body">';
  417. echo '<table style="display:none; width:100%" class="files data_table">
  418. <tr>
  419. <th>'.get_lang('FileName').'</th>
  420. <th>'.get_lang('Size').'</th>
  421. <th>'.get_lang('Status').'</th>
  422. </tr>
  423. </table>';
  424. echo '</div></div></div>';
  425. if (api_get_configuration_value('allow_compilatio_tool')) {
  426. $workTable = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
  427. $courseId = $courseInfo['real_id'];
  428. $form_action['analyseCompilatio'] = [
  429. 'label' => get_lang('compilatioStartAnalysis'),
  430. 'data-action' => get_lang('compilatioStartAnalysis'),
  431. 'onClick' => "onclick='getMultiCompilatio()'",
  432. ];
  433. $html = '<form id ="mes_actions" class="form-search" method="post" name="form_actions">';
  434. $html .= '<input type="hidden" name="action">';
  435. $html .= '<table style="width:100%;">';
  436. $html .= '<tr>';
  437. $html .= '<td>';
  438. if (count($form_action) > 0) {
  439. $html .= '<div class="btn-toolbar">';
  440. $html .= '<div class="btn-group">';
  441. $html .= '<a class="btn btn-default" href="?'
  442. . '&amp;'
  443. . "gbox_results"
  444. . '&amp;'
  445. . 'selectall=1" onclick="javascript: setCheckbox(true, \''
  446. . "gbox_results". '\'); return false;">'
  447. . get_lang('SelectAll')
  448. . '</a>';
  449. $html .= '<a class="btn btn-default" href="?'
  450. . '" onclick="javascript: setCheckbox(false, \''
  451. . "gbox_results"
  452. . '\'); return false;">'
  453. . get_lang('UnSelectAll')
  454. . '</a> ';
  455. $html .= '</div>';
  456. $html .= '<div class="btn-group">
  457. <button class="btn btn-default" onclick="javascript:return false;">'
  458. . get_lang('Actions')
  459. . '</button>'
  460. . '<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">'
  461. . '<span class="caret"></span>'
  462. . '</button>';
  463. $html .= '<ul class="dropdown-menu">';
  464. /*ORIGINAL*/
  465. // foreach ($form_action as $action => & $label) {
  466. // $html .= '<li><a data-action ="' . $action . '" href="#" onclick="javascript:action_click(this, \'' . "gbox_results" . '\');">' . $label . '</a></li>';
  467. // }
  468. /*fin original*/
  469. foreach ($form_action as $action ) {
  470. $html .= '<li>
  471. <a data-action ="'.$action['data-action'].'" href="#" '.$action['onClick'].'>'
  472. .$action['label'].'</a>
  473. </li>';
  474. }
  475. $html .= '</ul>';
  476. $html .= '</div>';//btn-group
  477. $html .= '</div>'; //toolbar
  478. $html .= '</td></tr></table></form>';
  479. }
  480. echo $html;
  481. $compTable = Database::get_course_table(TABLE_PLAGIARISM);
  482. $listCompilatioDocId = [];
  483. $compilatioQuery = "SELECT * FROM $compTable WHERE c_id= $courseId";
  484. $compilatioResult = Database::query($compilatioQuery);
  485. while ($compilatioData = Database::fetch_array($compilatioResult)) {
  486. array_push($listCompilatioDocId, $compilatioData['document_id']);
  487. }
  488. $javascriptWorkId = '';
  489. $sql = "SELECT * FROM $workTable WHERE c_id= $courseId AND parent_id= $workId AND active = 1";
  490. $res = Database::query($sql);
  491. while ($data = Database::fetch_array($res)) {
  492. if (in_array($data['id'], $listCompilatioDocId)) {
  493. $javascriptWorkId .= $data['id'].'a';
  494. }
  495. }
  496. }
  497. Display::display_footer();
  498. ?>
  499. <!--
  500. Lets display the javascript AJAX tools for refreshing datas that needed to be refreshed
  501. Only document with state ANALYSE_IN_QUEUE or ANALYSE_PROCESSING need to ask server
  502. for a new state
  503. Hubert Borderiou - Grenoble Universites - avril 2013
  504. -->
  505. <script>
  506. var xhrObject; // the htmlhttprequest object
  507. var analyseComplete = "ANALYSE_COMPLETE";
  508. var analyseProcessing = "ANALYSE_PROCESSING";
  509. var analyseInQueue = "ANALYSE_IN_QUEUE";
  510. var refreshDelaisAfter = 30000;
  511. var allWorkId = "<?php echo $javascriptWorkId?>";
  512. var workFolderId = "<?php echo $workId; ?>";
  513. var compilationWebUrl = "<?php echo api_get_path(WEB_CODE_PATH) . 'plagiarism/compilatio/' ?>";
  514. var divExisteTimer = null;
  515. var msgWaitJS = '<?php echo Display::display_confirmation_message(get_lang('PleaseWaitThisCouldTakeAWhile')); ?>';
  516. var div = document.createElement('div');
  517. var referent = document.getElementById('toolbar-worklist');
  518. var Analyse = '<?php echo get_lang('compilatioAnalyse'); ?>';
  519. var compiReport = '<?php echo get_lang('compilatioSeeReport'); ?>';
  520. var compiNonToAnalyse = '<?php echo Display::display_error_message(get_lang('compilatioNonToAnalyse')); ?>';
  521. var clickTrigger = false;
  522. function compilatioInit() {
  523. if (isWorkFolder()) {
  524. searchAdvancement();
  525. setInterval("searchAdvancement()", refreshDelaisAfter);
  526. if(!clickTrigger) {
  527. clickTrigger = true;
  528. $('.getSingleCompilatio').on('click', function () {
  529. var parts = $(this).parent().attr('id').split('id_avancement');
  530. getSingleCompilatio(parts[1]);
  531. });
  532. }
  533. }
  534. }
  535. // true if we are in a work folder
  536. function isWorkFolder() {
  537. var res = false;
  538. if (workFolderId.match(/[0-9]+/)) {
  539. res = true;
  540. }
  541. return res;
  542. }
  543. // check all compilatio docs
  544. function checkAllCompilatio(action) {
  545. $("input").each(function() {
  546. if ($(this).attr("id")) {
  547. objId = $(this).attr("id");
  548. listObjId = objId.match(/jqg_results_(\d+)/)
  549. if (listObjId.length > 1) {
  550. $(this).prop('checked', action);
  551. }
  552. }
  553. });
  554. }
  555. function getSingleCompilatio(itemId) {
  556. if (div.id == "status_message") {
  557. referent.removeChild(div);
  558. }
  559. div.id = "status_message";
  560. div.className = 'row';
  561. div.innerHTML = '<div class="col-md-6"> <br>' + msgWaitJS + '</div>';
  562. referent.appendChild(div);
  563. $.ajax({
  564. url: compilationWebUrl + "upload.php?doc="+itemId,
  565. type: "get",
  566. dataType: "html",
  567. success: function(message) {
  568. allWorkId += itemId+"a";
  569. compilatioInit();
  570. if (message.trim() != ""){
  571. div.id = "status_message";
  572. div.className = 'row';
  573. div.innerHTML = '<div class="col-md-6"> <br>'+message+'</div>';
  574. referent.appendChild(div);
  575. }
  576. }
  577. });
  578. }
  579. function getMultiCompilatio() {
  580. if (div.id == "status_message") {
  581. referent.removeChild(div);
  582. }
  583. div.id = "status_message";
  584. div.className = 'row';
  585. div.innerHTML = '<div class="col-md-6"> <br>' + msgWaitJS + '</div>';
  586. referent.appendChild(div);
  587. multi_compilatio = "";
  588. $("input:checked").each(function() {
  589. if ($(this).attr("id")) {
  590. objId = $(this).attr("id");
  591. listObjId = objId.match(/jqg_results_(\d+)/)
  592. if(listObjId){
  593. objClick = document.getElementById('id_avancement'+listObjId[1]);
  594. if (objClick){
  595. objLink = objClick.getElementsByTagName('a');
  596. if (objLink){
  597. stringLink = [].map.call( objLink, function(node){
  598. return node.textContent || node.innerText || "";
  599. }).join("");
  600. if(stringLink.trim() == Analyse.trim()){
  601. if (listObjId && listObjId.length > 1) {
  602. multi_compilatio += listObjId[1]+"a";
  603. }
  604. }
  605. }
  606. }
  607. }
  608. }
  609. });
  610. if ($("#verif")) {
  611. $("#verif").append(multi_compilatio);
  612. }
  613. // run compilatio
  614. if (multi_compilatio != "") {
  615. $.ajax({
  616. url: compilationWebUrl + "upload.php",
  617. data: { doc: multi_compilatio, type: "multi"}, // on envoie $_GET['id_region'] *// idz
  618. success: function(message) { // idz
  619. allWorkId = multi_compilatio;//idz
  620. compilatioInit();
  621. if (message.trim() != ""){
  622. div.id = "status_message";
  623. div.className = 'row';
  624. div.innerHTML = '<div class="col-md-6"> <br>'+message+'</div>';
  625. referent.appendChild(div);
  626. }
  627. }
  628. });
  629. } else {
  630. //multi_compilatio is empty
  631. div.id = "status_message";
  632. div.className = 'row';
  633. div.innerHTML = '<div class="col-md-6"> <br>' + compiNonToAnalyse + '</div>';
  634. referent.appendChild(div);
  635. }
  636. }
  637. function searchAdvancement(workId) {
  638. $.ajax({
  639. url: compilationWebUrl + "compilatio_ajax.php?workid=" + allWorkId,
  640. type: "get",
  641. dataType: "html",
  642. error: function(){
  643. showData("<?php echo get_lang('compilatioComunicationAjaxImpossible');?>");
  644. },
  645. success: function( strData ){
  646. showData( strData );
  647. }
  648. });
  649. }
  650. function deleteIdListeRefresh(id) {
  651. var regexp = eval("/"+id+":/");
  652. allWorkId = allWorkId.replace(regexp, "");
  653. }
  654. function showData(res) {
  655. var listRes = new Array();
  656. // for debugging
  657. $("#verif").html("");
  658. // parse the answer string
  659. listRes = res.split("|");
  660. for (var i=0; i < listRes.length; i=i+3) {
  661. if (listRes[i] != "") {
  662. var workId = listRes[i];
  663. if (i < listRes.length) {
  664. var HTMLcode = listRes[i+1];
  665. }
  666. if (i < listRes.length + 1) {
  667. var idStatus = listRes[i+2];
  668. if (idStatus != analyseInQueue && idStatus != analyseProcessing) {
  669. deleteIdListeRefresh(workId);
  670. }
  671. $("#verif").append(workId+":"+idStatus+"<br/>");
  672. }
  673. $("#"+"id_avancement"+workId).html(HTMLcode);
  674. }
  675. }
  676. }
  677. </script>