work_list_all.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  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. $group_id = api_get_group_id();
  27. $courseInfo = api_get_course_info();
  28. $sessionId = api_get_session_id();
  29. $htmlHeadXtra[] = api_get_jqgrid_js();
  30. $user_id = api_get_user_id();
  31. if (!empty($group_id)) {
  32. $group_properties = GroupManager::get_group_properties($group_id);
  33. if (api_is_allowed_to_edit(false, true)) {
  34. $show_work = true;
  35. } else {
  36. // you are not a teacher
  37. $show_work = GroupManager::user_has_access(
  38. $user_id,
  39. $group_properties['iid'],
  40. GroupManager::GROUP_TOOL_WORK
  41. );
  42. }
  43. if (!$show_work) {
  44. api_not_allowed();
  45. }
  46. $interbreadcrumb[] = [
  47. 'url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(),
  48. 'name' => get_lang('Groups'),
  49. ];
  50. $interbreadcrumb[] = [
  51. 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(),
  52. 'name' => get_lang('Group area').' '.$group_properties['name'],
  53. ];
  54. }
  55. $interbreadcrumb[] = [
  56. 'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
  57. 'name' => get_lang('Assignments'),
  58. ];
  59. $interbreadcrumb[] = [
  60. 'url' => api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId,
  61. 'name' => $my_folder_data['title'],
  62. ];
  63. $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
  64. $itemId = isset($_REQUEST['item_id']) ? (int) $_REQUEST['item_id'] : null;
  65. switch ($action) {
  66. case 'export_to_doc':
  67. if ($is_allowed_to_edit) {
  68. if (!empty($itemId)) {
  69. $work = get_work_data_by_id($itemId);
  70. if (!empty($work)) {
  71. Export::htmlToOdt($work['description'], $work['title']);
  72. }
  73. }
  74. }
  75. break;
  76. case 'delete':
  77. /* Delete document */
  78. if ($itemId) {
  79. $fileDeleted = deleteWorkItem($itemId, $courseInfo);
  80. if (!$fileDeleted) {
  81. Display::addFlash(
  82. Display::return_message(get_lang('You are not allowed to delete this document'), 'error')
  83. );
  84. } else {
  85. Display::addFlash(
  86. Display::return_message(get_lang('The document has been deleted.'), 'confirmation')
  87. );
  88. }
  89. }
  90. break;
  91. case 'delete_correction':
  92. $result = get_work_user_list(null, null, null, null, $workId);
  93. if ($result) {
  94. foreach ($result as $item) {
  95. $workToDelete = get_work_data_by_id($item['id']);
  96. deleteCorrection($courseInfo, $workToDelete);
  97. }
  98. Display::addFlash(
  99. Display::return_message(get_lang('Deleted'), 'confirmation')
  100. );
  101. }
  102. header('Location: '.api_get_self().'?'.api_get_cidreq().'&id='.$workId);
  103. exit;
  104. break;
  105. case 'make_visible':
  106. /* Visible */
  107. if ($is_allowed_to_edit) {
  108. if (!empty($itemId)) {
  109. if (isset($itemId) && $itemId == 'all') {
  110. } else {
  111. makeVisible($itemId, $courseInfo);
  112. Display::addFlash(
  113. Display::return_message(get_lang('The file is now visible'), 'confirmation')
  114. );
  115. }
  116. }
  117. }
  118. break;
  119. case 'make_invisible':
  120. /* Invisible */
  121. if (!empty($itemId)) {
  122. if (isset($itemId) && $itemId == 'all') {
  123. } else {
  124. makeInvisible($itemId, $courseInfo);
  125. Display::addFlash(
  126. Display::return_message(get_lang('The file is now invisible'), 'confirmation')
  127. );
  128. }
  129. }
  130. break;
  131. case 'export_pdf':
  132. exportAllStudentWorkFromPublication(
  133. $workId,
  134. $courseInfo,
  135. $sessionId,
  136. 'pdf'
  137. );
  138. break;
  139. }
  140. $htmlHeadXtra[] = api_get_jquery_libraries_js(['jquery-upload']);
  141. Display::display_header(null);
  142. $documentsAddedInWork = getAllDocumentsFromWorkToString($workId, $courseInfo);
  143. $actionsLeft = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq().'">'.
  144. Display::return_icon('back.png', get_lang('Back to Assignments list'), '', ICON_SIZE_MEDIUM).'</a>';
  145. if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !$isDrhOfCourse) {
  146. $blockAddDocuments = api_get_configuration_value('block_student_publication_add_documents');
  147. if (!$blockAddDocuments) {
  148. $actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'work/add_document.php?'.api_get_cidreq().'&id='.$workId.'">';
  149. $actionsLeft .= Display::return_icon('new_document.png', get_lang('Add document'), '', ICON_SIZE_MEDIUM).'</a>';
  150. }
  151. $actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'work/add_user.php?'.api_get_cidreq().'&id='.$workId.'">';
  152. $actionsLeft .= Display::return_icon('addworkuser.png', get_lang('Add a user'), '', ICON_SIZE_MEDIUM).'</a>';
  153. $actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId.'&action=export_pdf">';
  154. $actionsLeft .= Display::return_icon('pdf.png', get_lang('Export'), '', ICON_SIZE_MEDIUM).'</a>';
  155. $display_output = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work_missing.php?'.api_get_cidreq().'&amp;id='.$workId.'&amp;list=without">'.
  156. Display::return_icon('exercice_uncheck.png', get_lang('View missing assignments'), '', ICON_SIZE_MEDIUM)."</a>";
  157. $editLink = '<a href="'.api_get_path(WEB_CODE_PATH).'work/edit_work.php?'.api_get_cidreq().'&id='.$workId.'">';
  158. $editLink .= Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM).'</a>';
  159. $blockEdition = api_get_configuration_value('block_student_publication_edition');
  160. if ($blockEdition && !api_is_platform_admin()) {
  161. $editLink = '';
  162. }
  163. $actionsLeft .= $editLink;
  164. $count = get_count_work($workId);
  165. if ($count > 0) {
  166. $display_output .= '<a class="btn-toolbar" href="downloadfolder.inc.php?id='.$workId.'&'.api_get_cidreq().'">'.
  167. Display::return_icon('save_pack.png', get_lang('Download assignments package'), null, ICON_SIZE_MEDIUM).' '.get_lang('Download assignments package').'</a>';
  168. }
  169. $actionsLeft .= $display_output;
  170. $url = api_get_path(WEB_CODE_PATH).'work/upload_corrections.php?'.api_get_cidreq().'&id='.$workId;
  171. $actionsLeft .= '<a class="btn-toolbar" href="'.$url.'">'.
  172. Display::return_icon('upload_package.png', get_lang('Upload corrections package'), '', ICON_SIZE_MEDIUM).' '.get_lang('Upload corrections package').'</a>';
  173. $url = api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId.'&action=delete_correction';
  174. $actionsLeft .= Display::toolbarButton(get_lang('Delete all corrections'), $url, 'remove', 'danger');
  175. }
  176. echo Display::toolbarAction('toolbar-worklist', [$actionsLeft]);
  177. $plagiarismListJqgridColumn = [];
  178. $plagiarismListJqgridLine = [];
  179. $allowAntiPlagiarism = api_get_configuration_value('allow_compilatio_tool');
  180. if ($allowAntiPlagiarism) {
  181. $plagiarismListJqgridColumn = ['Compilatio'];
  182. $plagiarismListJqgridLine = [
  183. [
  184. 'name' => 'compilatio',
  185. 'index' => 'compilatio',
  186. 'width' => '40',
  187. 'align' => 'left',
  188. 'search' => 'false',
  189. 'sortable' => 'false',
  190. ],
  191. ];
  192. }
  193. if (!empty($my_folder_data['title'])) {
  194. echo Display::page_subheader($my_folder_data['title']);
  195. }
  196. if (!empty($my_folder_data['description'])) {
  197. $contentWork = Security::remove_XSS($my_folder_data['description']);
  198. $html = '';
  199. $html .= Display::panel($contentWork, get_lang('Description'));
  200. echo $html;
  201. }
  202. $check_qualification = (int) $my_folder_data['qualification'];
  203. $orderName = api_is_western_name_order() ? 'firstname' : 'lastname';
  204. if (!empty($work_data['enable_qualification']) &&
  205. !empty($check_qualification)
  206. ) {
  207. $type = 'simple';
  208. $columns = [
  209. get_lang('Full name'),
  210. get_lang('Title'),
  211. get_lang('Score'),
  212. get_lang('Date'),
  213. get_lang('Status'),
  214. get_lang('Upload correction'),
  215. ];
  216. $columns = array_merge($columns, $plagiarismListJqgridColumn);
  217. $columns[] = get_lang('Detail');
  218. $column_model = [
  219. [
  220. 'name' => 'fullname',
  221. 'index' => $orderName,
  222. 'width' => '30',
  223. 'align' => 'left',
  224. 'search' => 'true',
  225. ],
  226. [
  227. 'name' => 'title',
  228. 'index' => 'title',
  229. 'width' => '25',
  230. 'align' => 'left',
  231. 'search' => 'false',
  232. 'wrap_cell' => 'true',
  233. ],
  234. [
  235. 'name' => 'qualification',
  236. 'index' => 'qualification',
  237. 'width' => '15',
  238. 'align' => 'center',
  239. 'search' => 'true',
  240. ],
  241. [
  242. 'name' => 'sent_date',
  243. 'index' => 'sent_date',
  244. 'width' => '25',
  245. 'align' => 'left',
  246. 'search' => 'true',
  247. 'wrap_cell' => 'true',
  248. ],
  249. [
  250. 'name' => 'qualificator_id',
  251. 'index' => 'qualificator_id',
  252. 'width' => '20',
  253. 'align' => 'left',
  254. 'search' => 'true',
  255. ],
  256. [
  257. 'name' => 'correction',
  258. 'index' => 'correction',
  259. 'width' => '30',
  260. 'align' => 'left',
  261. 'search' => 'false',
  262. 'sortable' => 'false',
  263. 'title' => 'false',
  264. ],
  265. ];
  266. $column_model = array_merge($column_model, $plagiarismListJqgridLine);
  267. $column_model[] = [
  268. 'name' => 'actions',
  269. 'index' => 'actions',
  270. 'width' => '25',
  271. 'align' => 'left',
  272. 'search' => 'false',
  273. 'sortable' => 'false',
  274. ];
  275. } else {
  276. $type = 'complex';
  277. $columns = [
  278. get_lang('Full name'),
  279. get_lang('Title'),
  280. get_lang('Feedback'),
  281. get_lang('Date'),
  282. get_lang('Upload correction'),
  283. ];
  284. $columns = array_merge($columns, $plagiarismListJqgridColumn);
  285. $columns[] = get_lang('Detail');
  286. $column_model = [
  287. [
  288. 'name' => 'fullname',
  289. 'index' => $orderName,
  290. 'width' => '35',
  291. 'align' => 'left',
  292. 'search' => 'true',
  293. ],
  294. [
  295. 'name' => 'title',
  296. 'index' => 'title',
  297. 'width' => '30',
  298. 'align' => 'left',
  299. 'search' => 'false',
  300. 'wrap_cell' => 'true',
  301. ],
  302. [
  303. 'name' => 'qualification',
  304. 'index' => 'qualification',
  305. 'width' => '20',
  306. 'align' => 'center',
  307. 'search' => 'true',
  308. ],
  309. [
  310. 'name' => 'sent_date',
  311. 'index' => 'sent_date',
  312. 'width' => '30',
  313. 'align' => 'left',
  314. 'search' => 'true',
  315. 'wrap_cell' => 'true',
  316. ],
  317. [
  318. 'name' => 'correction',
  319. 'index' => 'correction',
  320. 'width' => '40',
  321. 'align' => 'left',
  322. 'search' => 'false',
  323. 'sortable' => 'false',
  324. 'title' => 'false',
  325. ],
  326. ];
  327. $column_model = array_merge($column_model, $plagiarismListJqgridLine);
  328. $column_model[] = [
  329. 'name' => 'actions',
  330. 'index' => 'actions',
  331. 'width' => '25',
  332. 'align' => 'left',
  333. 'search' => 'false',
  334. 'sortable' => 'false',
  335. ];
  336. }
  337. $extra_params = [
  338. 'autowidth' => 'true',
  339. 'height' => 'auto',
  340. 'sortname' => $orderName,
  341. 'sortable' => 'false',
  342. 'multiselect' => 'true',
  343. ];
  344. $url = api_get_path(WEB_AJAX_PATH).
  345. 'model.ajax.php?a=get_work_user_list_all&work_id='.$workId.'&type='.$type.'&'.api_get_cidreq();
  346. $workUrl = api_get_path(WEB_AJAX_PATH).'work.ajax.php?'.api_get_cidreq();
  347. $deleteUrl = $workUrl.'&a=delete_student_work';
  348. $showUrl = $workUrl.'&a=show_student_work';
  349. $hideUrl = $workUrl.'&a=hide_student_work';
  350. if ($allowAntiPlagiarism) {
  351. $extra_params['gridComplete'] = 'compilatioInit()';
  352. }
  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('Please select an option')); ?>");
  383. }
  384. },
  385. position:"last"
  386. }).navButtonAdd('#results_pager', {
  387. //caption:"<?php //echo addslashes(get_lang('Set visible'));?>//",
  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('Please select an option')); ?>");
  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. if ($allowAntiPlagiarism) {
  415. echo '<div id="compilation-results"></div>';
  416. echo '<div class="list-work-results">';
  417. $table = '<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. Display::panel($table);
  425. echo '</div>';
  426. $workTable = Database:: get_course_table(TABLE_STUDENT_PUBLICATION);
  427. $courseId = $courseInfo['real_id'];
  428. $formAction['analyseCompilatio'] = [
  429. 'label' => get_lang('Start Compilatio analysis'),
  430. 'data-action' => get_lang('Start Compilatio analysis'),
  431. 'onClick' => "onclick='getMultiCompilatio()'",
  432. ];
  433. $html = '<form 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. $html .= '<div class="btn-toolbar">';
  439. $html .= '<div class="btn-group">';
  440. $html .= '<a class="btn btn-default" href="?'
  441. .'&amp;'."gbox_results".'&amp;'.'selectall=1" onclick="javascript: setCheckbox(true, \''
  442. ."gbox_results".'\'); return false;">'
  443. .get_lang('Select all')
  444. .'</a>';
  445. $html .= '<a class="btn btn-default" href="?'
  446. .'" onclick="javascript: setCheckbox(false, \''
  447. ."gbox_results"
  448. .'\'); return false;">'
  449. .get_lang('UnSelect all')
  450. .'</a> ';
  451. $html .= '</div>';
  452. $html .= '<div class="btn-group">
  453. <button class="btn btn-default" onclick="javascript:return false;">'
  454. .get_lang('Detail')
  455. .'</button>'
  456. .'<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">'
  457. .'<span class="caret"></span>'
  458. .'</button>';
  459. $html .= '<ul class="dropdown-menu">';
  460. foreach ($formAction as $action) {
  461. $html .= '<li>
  462. <a data-action ="'.$action['data-action'].'" href="#" '.$action['onClick'].'>'
  463. .$action['label'].'</a>
  464. </li>';
  465. }
  466. $html .= '</ul>';
  467. $html .= '</div>';
  468. $html .= '</div>';
  469. $html .= '</td></tr></table></form>';
  470. echo $html;
  471. $compTable = Database::get_course_table(TABLE_PLAGIARISM);
  472. $listCompilatioDocId = [];
  473. $compilatioQuery = "SELECT * FROM $compTable WHERE c_id= $courseId";
  474. $compilatioResult = Database::query($compilatioQuery);
  475. while ($compilatioData = Database::fetch_array($compilatioResult)) {
  476. array_push($listCompilatioDocId, $compilatioData['document_id']);
  477. }
  478. $javascriptWorkId = '';
  479. $sql = "SELECT * FROM $workTable WHERE c_id= $courseId AND parent_id= $workId AND active = 1";
  480. $res = Database::query($sql);
  481. while ($data = Database::fetch_array($res)) {
  482. if (in_array($data['id'], $listCompilatioDocId)) {
  483. $javascriptWorkId .= $data['id'].'a';
  484. }
  485. } ?>
  486. <!--
  487. Lets display the javascript AJAX tools for refreshing datas that needed to be refreshed
  488. Only document with state ANALYSE_IN_QUEUE or ANALYSE_PROCESSING need to ask server
  489. for a new state
  490. Hubert Borderiou - Grenoble Universites - avril 2013
  491. -->
  492. <script>
  493. var xhrObject; // the htmlhttprequest object
  494. var analyseComplete = "ANALYSE_COMPLETE";
  495. var analyseProcessing = "ANALYSE_PROCESSING";
  496. var analyseInQueue = "ANALYSE_IN_QUEUE";
  497. var refreshDelaisAfter = 30000;
  498. var allWorkId = "<?php echo $javascriptWorkId; ?>";
  499. var workFolderId = "<?php echo $workId; ?>";
  500. var compilationWebUrl = "<?php echo api_get_path(WEB_CODE_PATH).'plagiarism/compilatio/'; ?>";
  501. var divExisteTimer = null;
  502. var msgWaitJS = '<?php echo Display::return_message(get_lang('Please wait. This could take a while...')); ?>';
  503. var div = document.createElement('div');
  504. var referent = document.getElementById('compilation-results');
  505. var Analyse = '<?php echo get_lang('Analyse'); ?>';
  506. var compiReport = '<?php echo get_lang('See report'); ?>';
  507. var compiNonToAnalyse = '<?php echo Display::return_message(get_lang('Your selection contains no jobs to analyze. Only jobs managed by Compilatio and not already scanned can be sent.'), 'error'); ?>';
  508. var clickTrigger = false;
  509. function compilatioInit() {
  510. if (isWorkFolder()) {
  511. searchAdvancement();
  512. setInterval("searchAdvancement()", refreshDelaisAfter);
  513. if (!clickTrigger) {
  514. clickTrigger = true;
  515. $('.getSingleCompilatio').on('click', function () {
  516. var parts = $(this).parent().attr('id').split('id_avancement');
  517. getSingleCompilatio(parts[1]);
  518. });
  519. }
  520. }
  521. }
  522. // true if we are in a work folder
  523. function isWorkFolder() {
  524. var res = false;
  525. if (workFolderId.match(/[0-9]+/)) {
  526. res = true;
  527. }
  528. return res;
  529. }
  530. // check all compilatio docs
  531. function checkAllCompilatio(action) {
  532. $("input").each(function () {
  533. if ($(this).attr("id")) {
  534. objId = $(this).attr("id");
  535. listObjId = objId.match(/jqg_results_(\d+)/)
  536. if (listObjId.length > 1) {
  537. $(this).prop('checked', action);
  538. }
  539. }
  540. });
  541. }
  542. function getSingleCompilatio(itemId) {
  543. if (div.id == "status_message") {
  544. referent.removeChild(div);
  545. }
  546. div.id = "status_message";
  547. div.className = 'row';
  548. div.innerHTML = '<div class="col-md-6"> <br>' + msgWaitJS + '</div>';
  549. referent.appendChild(div);
  550. $.ajax({
  551. url: compilationWebUrl + "upload.php?<?php echo api_get_cidreq(); ?>&doc=" + itemId,
  552. type: "get",
  553. dataType: "html",
  554. success: function (message) {
  555. allWorkId += itemId + "a";
  556. compilatioInit();
  557. if (message.trim() != "") {
  558. div.id = "status_message";
  559. div.className = 'row';
  560. div.innerHTML = '<div class="col-md-6"> <br>' + message + '</div>';
  561. referent.appendChild(div);
  562. }
  563. }
  564. });
  565. }
  566. function getMultiCompilatio() {
  567. if (div.id == "status_message") {
  568. referent.removeChild(div);
  569. }
  570. div.id = "status_message";
  571. div.className = 'row';
  572. div.innerHTML = '<div class="col-md-6"> <br>' + msgWaitJS + '</div>';
  573. referent.appendChild(div);
  574. multi_compilatio = "";
  575. $("input:checked").each(function () {
  576. if ($(this).attr("id")) {
  577. objId = $(this).attr("id");
  578. listObjId = objId.match(/jqg_results_(\d+)/)
  579. if (listObjId) {
  580. objClick = document.getElementById('id_avancement' + listObjId[1]);
  581. if (objClick) {
  582. objLink = objClick.getElementsByTagName('a');
  583. if (objLink) {
  584. stringLink = [].map.call(objLink, function (node) {
  585. return node.textContent || node.innerText || "";
  586. }).join("");
  587. if (stringLink.trim() == Analyse.trim()) {
  588. if (listObjId && listObjId.length > 1) {
  589. multi_compilatio += listObjId[1] + "a";
  590. }
  591. }
  592. }
  593. }
  594. }
  595. }
  596. });
  597. if ($("#verif")) {
  598. $("#verif").append(multi_compilatio);
  599. }
  600. // run compilatio
  601. if (multi_compilatio != "") {
  602. $.ajax({
  603. url: compilationWebUrl + "upload.php?<?php echo api_get_cidreq(); ?>",
  604. data: {doc: multi_compilatio, type: "multi"}, // on envoie $_GET['id_region'] *// idz
  605. success: function (message) { // idz
  606. allWorkId = multi_compilatio;//idz
  607. compilatioInit();
  608. if (message.trim() != "") {
  609. div.id = "status_message";
  610. div.className = 'row';
  611. div.innerHTML = '<div class="col-md-6"> <br>' + message + '</div>';
  612. referent.appendChild(div);
  613. }
  614. }
  615. });
  616. } else {
  617. // multi_compilatio is empty
  618. div.id = "status_message";
  619. div.className = 'row';
  620. div.innerHTML = '<div class="col-md-6"> <br>' + compiNonToAnalyse + '</div>';
  621. referent.appendChild(div);
  622. }
  623. }
  624. function searchAdvancement(workId) {
  625. $.ajax({
  626. url: compilationWebUrl + "compilatio_ajax.php?<?php echo api_get_cidreq(); ?>&workid=" + allWorkId,
  627. type: "get",
  628. dataType: "html",
  629. error: function () {
  630. showData("<?php echo get_lang('AJAX communication with the Compilatio server impossible. Please retry later.'); ?>");
  631. },
  632. success: function (strData) {
  633. showData(strData);
  634. }
  635. });
  636. }
  637. function deleteIdListeRefresh(id) {
  638. var regexp = eval("/" + id + ":/");
  639. allWorkId = allWorkId.replace(regexp, "");
  640. }
  641. function showData(res) {
  642. var listRes = new Array();
  643. $("#verif").html("");
  644. // parse the answer string
  645. listRes = res.split("|");
  646. for (var i = 0; i < listRes.length; i = i + 3) {
  647. if (listRes[i] != "") {
  648. var workId = listRes[i];
  649. if (i < listRes.length) {
  650. var HTMLcode = listRes[i + 1];
  651. }
  652. if (i < listRes.length + 1) {
  653. var idStatus = listRes[i + 2];
  654. if (idStatus != analyseInQueue && idStatus != analyseProcessing) {
  655. deleteIdListeRefresh(workId);
  656. }
  657. $("#verif").append(workId + ":" + idStatus + "<br/>");
  658. }
  659. $("#" + "id_avancement" + workId).html(HTMLcode);
  660. }
  661. }
  662. }
  663. </script>
  664. <?php
  665. }
  666. Display::display_footer();