uploadExcel.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. <?php
  2. include($_SERVER['DOCUMENT_ROOT']."/Authorization/script/php/permission/check_right.php");
  3. if (!isset($_FILES['excel']['error'])) {
  4. //header("Location: /DataBase/Upload.php");
  5. }
  6. if (0 < $_FILES['excel']['error']) {
  7. echo 'Error: ' . $_FILES['excel']['error'] . '<br>';
  8. } else {
  9. $filepath = 'uploads/' . $_FILES['excel']['name'];
  10. move_uploaded_file($_FILES['excel']['tmp_name'], $filepath);
  11. $project_id = $_POST['projectId'];
  12. $project_name = $_POST['projectName'];
  13. $category_id = $_POST['category'];
  14. $file = $_FILES['excel']['name'];
  15. }
  16. ?>
  17. <!doctype html>
  18. <html class="fixed">
  19. <head>
  20. <!-- Basic -->
  21. <meta charset="UTF-8">
  22. <title>設計資料庫匯入工具</title>
  23. <meta name="keywords" content="HTML5 Admin Template" />
  24. <meta name="description" content="JSOFT Admin - Responsive HTML5 Template">
  25. <meta name="author" content="JSOFT.net">
  26. <script src="/DataBase/assets/vendor/jquery/jquery.js"></script>
  27. <!-- Mobile Metas -->
  28. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  29. <!-- Web Fonts -->
  30. <link href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800|Shadows+Into+Light" rel="stylesheet" type="text/css">
  31. <!-- jstree CSS -->
  32. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.4/themes/default/style.min.css">
  33. <!-- Vendor CSS -->
  34. <link rel="stylesheet" href="/DataBase/assets/vendor/bootstrap/css/bootstrap.css" />
  35. <link rel="stylesheet" href="/DataBase/assets/vendor/font-awesome/css/font-awesome.css" />
  36. <link rel="stylesheet" href="/DataBase/assets/vendor/magnific-popup/magnific-popup.css" />
  37. <link rel="stylesheet" href="/DataBase/assets/vendor/bootstrap-datepicker/css/datepicker3.css" />
  38. <link rel="stylesheet" href="/DataBase/assets/vendor/pnotify/pnotify.custom.css" />
  39. <!-- Specific Page Vendor CSS -->
  40. <link rel="stylesheet" href="/DataBase/assets/vendor/jquery-ui/css/ui-lightness/jquery-ui-1.10.4.custom.css" />
  41. <link rel="stylesheet" href="/DataBase/assets/vendor/bootstrap-multiselect/bootstrap-multiselect.css" />
  42. <link rel="stylesheet" href="/DataBase/assets/vendor/morris/morris.css" />
  43. <link rel="stylesheet" href="/DataBase/assets/vendor/bootstrap-fileupload/bootstrap-fileupload.min.css" />
  44. <!-- Theme CSS -->
  45. <link rel="stylesheet" href="/DataBase/assets/stylesheets/theme.css" />
  46. <!-- Skin CSS -->
  47. <link rel="stylesheet" href="/DataBase/assets/stylesheets/skins/default.css" />
  48. <!-- Theme Custom CSS -->
  49. <link rel="stylesheet" href="/DataBase/assets/stylesheets/theme-custom.css">
  50. <!-- Head Libs -->
  51. <script src="/DataBase/assets/vendor/modernizr/modernizr.js"></script>
  52. <!-- chart.js -->
  53. <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
  54. <!-- DataTable -->
  55. <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.25/css/jquery.dataTables.css">
  56. <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.js"></script>
  57. <!-- Icon -->
  58. <link rel="shortcut icon" href="/DataBase/assets/images/favicon.ico" />
  59. <link href="https://js.arcgis.com/4.21/esri/themes/light/main.css" rel="stylesheet">
  60. <link href="/DataBase/CustomCSS/main.css" rel="stylesheet">
  61. <script src="/DataBase/script/js/bootstrap.js"></script>
  62. <script src="/DataBase/script/js/pdfobject.min.js"></script>
  63. <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.4/jstree.min.js"></script>
  64. <script src="https://js.arcgis.com/4.21/"></script>
  65. <style>
  66. body {
  67. color: #000;
  68. }
  69. .row {
  70. margin-top: -15px;
  71. }
  72. .page-header>ul {
  73. list-style: none;
  74. padding: 0;
  75. margin: 0;
  76. }
  77. .page-header>ul>li {
  78. display: inline-block;
  79. font-size: 25px;
  80. color: #FFFFFF;
  81. }
  82. .page-header>ul>li.right {
  83. float: right;
  84. padding-right: 10px;
  85. }
  86. .input-search {
  87. margin-top: 8px;
  88. }
  89. .page-header li>label {
  90. margin-top: 13px;
  91. border-bottom: 4px solid #0088cc;
  92. height: 41px;
  93. padding-left: 40px;
  94. }
  95. .sidebar-left {
  96. box-shadow: 0 0 0;
  97. }
  98. .jstree-default .jstree-icon {
  99. color: #ffe693;
  100. }
  101. .jqsfield {
  102. color: white;
  103. font: 10px arial, san serif;
  104. text-align: left;
  105. }
  106. .jstree-anchor {
  107. width: 250px;
  108. text-overflow: ellipsis;
  109. overflow: hidden;
  110. white-space: nowrap;
  111. }
  112. .jstree-anchor,
  113. .jstree-anchor:link,
  114. .jstree-anchor:visited,
  115. .jstree-anchor:hover,
  116. .jstree-anchor:active {
  117. color: #abb4be;
  118. }
  119. td,
  120. th {
  121. text-align: center;
  122. }
  123. #tablepage匯入資訊>thead>tr>th {
  124. width: 25%;
  125. }
  126. #tableform>thead>tr>th {
  127. width: 50%;
  128. }
  129. .nav-main {
  130. padding: 15px;
  131. }
  132. .node-hidden {
  133. display: none;
  134. }
  135. html.fixed .page-header {
  136. left: 0px;
  137. }
  138. html.fixed .content-body {
  139. margin-left: 0px;
  140. }
  141. .sidebar-left {
  142. width: 0px;
  143. }
  144. #viewDiv {
  145. height: 100%;
  146. width: 100%;
  147. }
  148. #zoom {
  149. margin-bottom: 5px;
  150. }
  151. #actions {
  152. padding: 5px;
  153. }
  154. .container {
  155. height: 50%;
  156. width: 100%;
  157. }
  158. #createSlideDiv {
  159. background-color: white;
  160. opacity: 0.9;
  161. color: black;
  162. padding: 6px;
  163. }
  164. #slidesDiv {
  165. background-color: white;
  166. opacity: 0.9;
  167. color: black;
  168. padding: 10px;
  169. visibility: hidden;
  170. bottom: 20px;
  171. overflow-y: auto;
  172. text-align: center;
  173. height: 260px;
  174. }
  175. #slidesDiv .slide {
  176. /* Show cursor as pointer when on a slide */
  177. cursor: pointer;
  178. margin-bottom: 6px;
  179. }
  180. #slidesDiv .slide .title {
  181. /* Center the title text */
  182. text-align: center;
  183. }
  184. /* Draw active slide with a nice border around the thumbnail */
  185. #slidesDiv .slide.active img {
  186. box-shadow: 0px 0px 12px black;
  187. border-style: solid;
  188. border-width: thin;
  189. border-color: black;
  190. }
  191. .pdfobject-container {
  192. height: 730px;
  193. }
  194. #topbar {
  195. background: #fff;
  196. padding: 10px;
  197. }
  198. /* uploadExcel */
  199. td>label {
  200. width: 8em;
  201. text-align: left;
  202. padding-right: 0.5em;
  203. /* display: inline-block; */
  204. }
  205. .excel {
  206. font-family: Arial, Helvetica, sans-serif;
  207. border-collapse: collapse;
  208. width: 100%;
  209. }
  210. .nav-tabs>li.active>a,
  211. .nav-tabs>li.active>a:focus,
  212. .nav-tabs>li.active>a:hover {
  213. border: 1px solid #000;
  214. }
  215. .excel td,
  216. .excel th {
  217. border: 1px solid #aaa;
  218. padding: 8px;
  219. }
  220. .excel tr:nth-child(even) {
  221. background-color: #f2f2f2;
  222. }
  223. .excel tr:hover {
  224. background-color: #ddd;
  225. }
  226. .excel th {
  227. padding-top: 12px;
  228. padding-bottom: 12px;
  229. text-align: center;
  230. background-color: #004B7C;
  231. color: white;
  232. }
  233. table.dataTable tbody tr td.NullClass {
  234. background-color: #ed9c28;
  235. }
  236. table.dataTable tbody tr td.ErrorClass {
  237. background-color: #d2322d;
  238. }
  239. .submit {
  240. display: inline-block;
  241. margin-left: auto;
  242. margin-right: auto;
  243. width: 20%;
  244. background-color: #004B7C;
  245. border: none;
  246. color: white;
  247. padding: 15px 32px;
  248. text-align: center;
  249. text-decoration: none;
  250. font-size: 16px;
  251. margin: 10px;
  252. }
  253. .delete {
  254. background-color: red;
  255. border: none;
  256. color: white;
  257. padding: 5px 32px;
  258. text-align: center;
  259. text-decoration: none;
  260. display: inline-block;
  261. font-size: 16px;
  262. }
  263. .center {
  264. text-align: center;
  265. }
  266. .nav-tabs.nav-justified li.active a.error.text-center,
  267. a.error.text-center:hover {
  268. border-bottom-color: transparent;
  269. border-top: 3px solid #d2322d;
  270. box-shadow: none;
  271. color: #d2322d;
  272. }
  273. a.error.text-center,
  274. i.error,
  275. td.error {
  276. color: #d2322d;
  277. }
  278. .nav-tabs.nav-justified li.active a.warning.text-center,
  279. a.warning.text-center:hover {
  280. border-bottom-color: transparent;
  281. border-top: 3px solid #ed9c28;
  282. box-shadow: none;
  283. color: #ed9c28;
  284. }
  285. a.warning.text-center,
  286. i.warning,
  287. td.warning {
  288. color: #ed9c28;
  289. }
  290. .nav-tabs.nav-justified li.active a.info.text-center,
  291. a.info.text-center:hover {
  292. border-bottom-color: transparent;
  293. border-top: 3px solid #0088cc;
  294. box-shadow: none;
  295. color: #0088cc;
  296. }
  297. a.info.text-center,
  298. i.info {
  299. color: #0088cc;
  300. }
  301. .nav-tabs.nav-justified li.active a.success.text-center,
  302. a.success.text-center:hover {
  303. border-bottom-color: transparent;
  304. border-top: 3px solid #4a934a;
  305. box-shadow: none;
  306. color: #4a934a;
  307. }
  308. a.success.text-center,
  309. i.success {
  310. color: #4a934a;
  311. }
  312. .dataTables_wrapper .dataTables_filter label {
  313. width: initial;
  314. }
  315. .dataTables_wrapper .dataTables_filter input {
  316. width: initial;
  317. }
  318. </style>
  319. </head>
  320. <body>
  321. <section class="body">
  322. <!-- start: header -->
  323. <header class="header">
  324. <div class="logo-container">
  325. <div class="banner-txt">設計資料庫匯入工具</div>
  326. <div class="visible-xs toggle-sidebar-left" data-toggle-class="sidebar-left-opened" data-target="html" data-fire-event="sidebar-left-opened">
  327. <i class="fa fa-bars" aria-label="Toggle sidebar"></i>
  328. </div>
  329. </div>
  330. <!-- start: search & user box -->
  331. <div class="header-right">
  332. <span class="separator"></span>
  333. <ul class="notifications">
  334. <li>
  335. <a href="/DataBase/Upload.php" class="notification-icon" data-toggle="tooltip" title="匯入工具" data-placement="bottom">
  336. <i class="fa fa-upload"></i>
  337. </a>
  338. <a href="/Front-Page/home.php" class="notification-icon" data-toggle="tooltip" title="綜合登入入口" data-placement="bottom">
  339. <i class="fa fa-home"></i>
  340. </a>
  341. </li>
  342. </ul>
  343. <span class="separator"></span>
  344. <div id="userbox" class="userbox">
  345. <a href="#" data-toggle="dropdown">
  346. <figure class="profile-picture"> <img src="/DataBase/assets/images/!logged-user.jpg" alt="Joseph Doe" class="img-circle" data-lock-picture="/DataBase/assets/images/!logged-user.jpg" /> </figure>
  347. <div class="profile-info" data-lock-name="John Doe" data-lock-email="johndoe@JSOFT.com"> <span class="name"><?php echo $_SESSION['name'] ?></span> <span class="role"><?php echo($groupName);?></span> </div> <i class="fa custom-caret"></i>
  348. </a>
  349. <div class="dropdown-menu">
  350. <ul class="list-unstyled">
  351. <li class="divider"></li>
  352. <li> <a role="menuitem" tabindex="-1" href="/DataBase/script/php/Logout.php"><i class="fa fa-power-off"></i> Logout</a> </li>
  353. </ul>
  354. </div>
  355. </div>
  356. </div>
  357. <!-- end: search & user box -->
  358. </header>
  359. <!-- end: header -->
  360. <div class="inner-wrapper">
  361. <!-- start: sidebar -->
  362. <section role="main" class="content-body">
  363. <header class="page-header">
  364. <ul>
  365. <li>
  366. <label id="header"></label>
  367. </li>
  368. </ul>
  369. </header>
  370. <div class="row">
  371. <div class="col-md-4 col-md-offset-8">
  372. 圖示顏色含意: <i class="fa fa-info-circle info">匯入確認頁面</i> <i class="fa fa-check-circle success">此頁面資料正確</i> <i class="fa fa-exclamation-circle warning">此頁面資料有空</i> <i class="fa fa-times-circle error">此頁面檔案路徑有誤</i>
  373. </div>
  374. <div class="col-md-12">
  375. <div class="tabs">
  376. <ul class="nav nav-tabs nav-justified" id="tabs">
  377. </ul>
  378. <div class="tab-content" id="tab-content">
  379. </div>
  380. </div>
  381. </div>
  382. </div>
  383. </div>
  384. </section>
  385. </div>
  386. </section>
  387. <script type="text/javascript">
  388. var val = [];
  389. var error;
  390. var tables;
  391. var searchTables = [];
  392. var tableIndex;
  393. var confirmMsg = "確定要匯入嗎?";
  394. var statusList = {
  395. "error": false,
  396. "warning": false
  397. };
  398. const statusDetail = {
  399. "error": "錯誤:檔案路徑有誤,請再次檢查檔案路徑是否正確。",
  400. "warning": "警告:有資料尚未填寫。"
  401. }
  402. const icons = {
  403. 'info': 'fa fa-info-circle',
  404. 'success': 'fa fa-check-circle',
  405. 'error': 'fa fa-times-circle',
  406. 'warning': 'fa fa-exclamation-circle',
  407. };
  408. var ErrorClass = function(settings, searchData, index, rowData) {
  409. var $td = searchTables[tableIndex].row(index).nodes().to$().find('td.ErrorClass');
  410. return $td.length;
  411. }
  412. var NullClass = function(settings, searchData, index, rowData) {
  413. var $td = searchTables[tableIndex].row(index).nodes().to$().find('td.NullClass');
  414. return $td.length;
  415. }
  416. var BothClasses = function(settings, searchData, index, rowData) {
  417. var $td = searchTables[tableIndex].row(index).nodes().to$().find('td.NullClass,td.ErrorClass');
  418. return $td.length;
  419. }
  420. $(document).ready(function() {
  421. const queryString = window.location.search;
  422. const urlParams = new URLSearchParams(queryString);
  423. var file = '<?= $file ?>';
  424. var categoryId = '<?= $category_id ?>';
  425. var projectId = '<?= $project_id ?>';
  426. var projectName = '<?= $project_name ?>';
  427. getExcel(file, projectId, projectName, categoryId);
  428. $('#form').submit(function() {
  429. var c = confirm(confirmMsg);
  430. return c;
  431. });
  432. });
  433. function getExcel(file, projectId, projectName, categoryId) {
  434. $.ajax({
  435. url: "./getExcel.php",
  436. data: {
  437. file: file,
  438. projectId: projectId,
  439. categoryId: categoryId,
  440. projectName:projectName,
  441. },
  442. async: false,
  443. contentType: "application/json",
  444. dataType: "json",
  445. type: "GET",
  446. })
  447. .success(function(response) {
  448. tables = response.table;
  449. var info = response.info;
  450. var statuses = response.statuses;
  451. errors = response.errorLists;
  452. var projectInfo = tables["匯入資訊"];
  453. $("#header").append(projectInfo[1][0] + "-" + projectInfo[1][1]); // 16019-促進民間參與高雄市鳳山溪污水處理廠放流水回收再利用案之興建、移轉、營運
  454. for (var tab in tables) {
  455. let status = statuses[tab];
  456. let active = '';
  457. if (tab == "匯入資訊") {
  458. active = 'class="active"';
  459. }
  460. if (statusList[status] != undefined & !statusList[status]) {
  461. statusList[status] = true;
  462. confirmMsg += "\n" + statusDetail[status];
  463. }
  464. console.log(status);
  465. let icon = icons[status];
  466. $('#tabs').append(`<li ${active}><a href="#page${tab}" data-toggle="tab" class="text-center ${status}"><i class="${icon}"></i> ${tab}</a></li>`);
  467. $("#tab-content").append(`<div id="page${tab}" class="tab-pane fade"></div>`);
  468. appendTable(tables[tab], `page${tab}`);
  469. }
  470. $(`#page匯入資訊`).append("<form id='form' method='post' action='./insertExcel.php'></form>");
  471. appendTable(info, "form");
  472. // TODO: add confirm message
  473. $("#form").append(`<div class='center'><input class='submit' type='submit' value='開始匯入'><button type='button' class='submit' onClick=\"location.href='/DataBase/Upload.php'\" >重新選擇檔案</button></div>`);
  474. $("#form").append(`<input id='projectId' name='projectId' type='hidden' value='${projectId}'><input id='projectName' name='projectName' type='hidden' value='${projectName}'><input id='file' name='file' type='hidden' value='${file}'><input id='categoryId' name='categoryId' style='display:none;' value='${categoryId}'>`);
  475. })
  476. .error(function(error) {
  477. console.log(error);
  478. })
  479. .complete(function() {
  480. $('#page匯入資訊').addClass('in active')
  481. let i = 1;
  482. for (var tab in tables) {
  483. if (tab != "匯入資訊" && tab != "注意事項") {
  484. var errorList = [];
  485. if (errors[tab] != "" & errors[tab] != undefined) {
  486. errorList = errors[tab].split(',');
  487. errorList.shift();
  488. }
  489. searchTables[tab] = $('#tablepage' + tab).DataTable({
  490. dom: '<"#toolbar' + tab + '">lfrtip',
  491. "language": {
  492. "processing": "處理中...",
  493. "loadingRecords": "載入中...",
  494. "lengthMenu": "顯示 _MENU_ 項資料",
  495. "zeroRecords": "沒有符合的結果或是沒有資料",
  496. "info": "顯示第 _START_ 至 _END_ 項資料,共 _TOTAL_ 項",
  497. "infoEmpty": "顯示第 0 至 0 項資料,共 0 項",
  498. "infoFiltered": "(從 _MAX_ 項資料中過濾)",
  499. "infoPostFix": "",
  500. "search": "搜尋:",
  501. "paginate": {
  502. "first": '<i class="fa fa-step-backward"></i>',
  503. "previous": '<i class="fa fa-backward"></i>',
  504. "next": '<i class="fa fa-forward"></i>',
  505. "last": '<i class="fa fa-step-forward"></i>'
  506. },
  507. "aria": {
  508. "sortAscending": ": 升冪排列",
  509. "sortDescending": ": 降冪排列"
  510. }
  511. },
  512. "columnDefs": [{
  513. "targets": -1,
  514. "createdCell": function(td, cellData, rowData, row, col) {
  515. if (errorList.length > 0) {
  516. for (i = 0; i < errorList.length; i++) {
  517. if (errorList[i] == row) {
  518. $(td).addClass('ErrorClass');
  519. }
  520. }
  521. }
  522. }
  523. }, {
  524. "targets": '_all',
  525. "createdCell": function(td, cellData, rowData, row, col) {
  526. if (cellData == "null") {
  527. $(td).addClass('NullClass');
  528. }
  529. }
  530. }],
  531. });
  532. i++;
  533. $('#toolbar' + tab).html(`<input name="check${tab}" id="errCheck${tab}" value="error" type="radio" >僅顯示錯誤檔案路徑</input>
  534. <input name="check${tab}" id="nullCheck${tab}" value="null" type="radio" >僅顯示未填入的資料</input>
  535. <input name="check${tab}" id="nullCheck${tab}" value="both" type="radio" >顯示所有異常資料</input>
  536. <input name="check${tab}" id="nullCheck${tab}" value="all" type="radio" checked="checked">顯示所有資料</input>`);
  537. /*$(`input[name='check${tab}']`).on("click", function() {
  538. $.fn.dataTable.ext.search.pop();
  539. if ($(this).val() == "error") {
  540. $.fn.dataTable.ext.search.push(ErrorClass);
  541. } else if ($(this).val() == "null") {
  542. $.fn.dataTable.ext.search.push(NullClass);
  543. } else if ($(this).val() == "both") {
  544. $.fn.dataTable.ext.search.push(BothClasses);
  545. } else {
  546. $.fn.dataTable.ext.search.pop();
  547. }
  548. console.log(tab);
  549. searchTables["3_設計圖"].draw();
  550. });*/
  551. if (document.querySelector(`input[name="check${tab}"]`)) {
  552. document.querySelectorAll(`input[name="check${tab}"]`).forEach((elem) => {
  553. elem.addEventListener("change", function(event) {
  554. var item = event.target.value;
  555. tableIndex = event.target.parentElement.id.split('bar')[1];
  556. $.fn.dataTable.ext.search.pop();
  557. if (item == "error") {
  558. $.fn.dataTable.ext.search.push(ErrorClass);
  559. } else if (item == "null") {
  560. $.fn.dataTable.ext.search.push(NullClass);
  561. } else if (item == "both") {
  562. $.fn.dataTable.ext.search.push(BothClasses);
  563. } else {
  564. $.fn.dataTable.ext.search.pop();
  565. }
  566. console.log(tableIndex);
  567. searchTables[tableIndex].draw();
  568. });
  569. });
  570. }
  571. }
  572. }
  573. });
  574. }
  575. function appendTable(data, id) {
  576. let i = 0;
  577. table = `<table id='table${id}' class='excel'><thead>`;
  578. for (var tab in data) {
  579. table += "<tr>";
  580. for (j = 0; j < data[tab].length; j++) {
  581. if (i == 0)
  582. table += `<th>${data[tab][j]}</th>` //style="width:33%;"
  583. else
  584. table += `<td>${data[tab][j]}</td>`
  585. }
  586. table += "</tr>";
  587. if (i == 0) {
  588. table += "</thead><tbody>";
  589. }
  590. i++;
  591. }
  592. table += "</tbody></table>";
  593. $('#' + id).append(table);
  594. }
  595. </script>
  596. </body>
  597. </html>