|
|
@@ -145,7 +145,7 @@ if (0 < $_FILES['excel']['error']) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- #tablepage0>thead>tr>th {
|
|
|
+ #tablepage匯入資訊>thead>tr>th {
|
|
|
width: 25%;
|
|
|
}
|
|
|
|
|
|
@@ -286,6 +286,10 @@ if (0 < $_FILES['excel']['error']) {
|
|
|
background-color: #ed9c28;
|
|
|
}
|
|
|
|
|
|
+ table.dataTable tbody tr td.ErrorClass {
|
|
|
+ background-color: #d2322d;
|
|
|
+ }
|
|
|
+
|
|
|
.submit {
|
|
|
display: inline-block;
|
|
|
margin-left: auto;
|
|
|
@@ -448,11 +452,6 @@ if (0 < $_FILES['excel']['error']) {
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
</div>
|
|
|
</section>
|
|
|
</div>
|
|
|
@@ -466,6 +465,16 @@ if (0 < $_FILES['excel']['error']) {
|
|
|
<script type="text/javascript">
|
|
|
var error;
|
|
|
var tables;
|
|
|
+ var test;
|
|
|
+ var confirmMsg = "確定要匯入嗎?";
|
|
|
+ var statusList = {
|
|
|
+ "error": false,
|
|
|
+ "warning": false
|
|
|
+ };
|
|
|
+ const statusDetail = {
|
|
|
+ "error": "錯誤:檔案路徑有誤,請再次檢查檔案路徑是否正確。",
|
|
|
+ "warning": "警告:有資料尚未填寫。"
|
|
|
+ }
|
|
|
const icons = {
|
|
|
'info': 'fa fa-info-circle',
|
|
|
'success': 'fa fa-check-circle',
|
|
|
@@ -482,6 +491,11 @@ if (0 < $_FILES['excel']['error']) {
|
|
|
var projectName = '<?= $project_name ?>';
|
|
|
getExcel(file, projectId, projectName, categoryId);
|
|
|
|
|
|
+ $('#form').submit(function() {
|
|
|
+ var c = confirm(confirmMsg);
|
|
|
+ return c;
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
|
|
|
function getExcel(file, projectId, projectName, categoryId) {
|
|
|
@@ -506,21 +520,28 @@ if (0 < $_FILES['excel']['error']) {
|
|
|
var projectInfo = tables["匯入資訊"];
|
|
|
$("#header").append(projectInfo[1][0] + "-" + projectInfo[1][1]); // 16019-促進民間參與高雄市鳳山溪污水處理廠放流水回收再利用案之興建、移轉、營運
|
|
|
|
|
|
- let i = 0;
|
|
|
- console.log(errors);
|
|
|
for (var tab in tables) {
|
|
|
- let status = statuses[i];
|
|
|
+ let status = statuses[tab];
|
|
|
let active = '';
|
|
|
- if (i == 0) {
|
|
|
+ if (tab == "匯入資訊") {
|
|
|
active = 'class="active"';
|
|
|
}
|
|
|
+ //(statusList[status] != undefined) && (statusList[status] = true);
|
|
|
+ if (statusList[status] != undefined & !statusList[status]) {
|
|
|
+ statusList[status] = true;
|
|
|
+ confirmMsg += "\n"+statusDetail[status];
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log(status);
|
|
|
let icon = icons[status];
|
|
|
- $('#tabs').append(`<li ${active}><a href="#page${i}" data-toggle="tab" class="text-center ${status}"><i class="${icon}"></i> ${tab}</a></li>`);
|
|
|
- $("#tab-content").append(`<div id="page${i}" class="tab-pane fade"></div>`);
|
|
|
- appendTable(tables[tab], `page${i}`);
|
|
|
- i++;
|
|
|
+ $('#tabs').append(`<li ${active}><a href="#page${tab}" data-toggle="tab" class="text-center ${status}"><i class="${icon}"></i> ${tab}</a></li>`);
|
|
|
+ $("#tab-content").append(`<div id="page${tab}" class="tab-pane fade"></div>`);
|
|
|
+ appendTable(tables[tab], `page${tab}`);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
- $(`#page${0}`).append("<form id='form' method='post' action='./insertExcel.php'></form>");
|
|
|
+ $(`#page匯入資訊`).append("<form id='form' method='post' action='./insertExcel.php'></form>");
|
|
|
appendTable(info, "form");
|
|
|
// TODO: add confirm message
|
|
|
$("#form").append(`<div class='center'><input class='submit' type='submit' value='開始匯入'><button type='button' class='submit' onClick=\"location.href='/DataBase/upload.html'\" >重新選擇檔案</button></div>`);
|
|
|
@@ -530,75 +551,74 @@ if (0 < $_FILES['excel']['error']) {
|
|
|
console.log(error);
|
|
|
})
|
|
|
.complete(function() {
|
|
|
- $('#page0').addClass('in active')
|
|
|
+ $('#page匯入資訊').addClass('in active')
|
|
|
let i = 1;
|
|
|
-
|
|
|
+
|
|
|
for (var tab in tables) {
|
|
|
- var errorList = [];
|
|
|
-
|
|
|
- if (errors[tab] != "" && errors[tab] != undefined) {
|
|
|
- errorList = errors[tab].split(',');
|
|
|
- errorList.shift();
|
|
|
- }
|
|
|
+ if (tab != "匯入資訊" && tab != "注意事項") {
|
|
|
|
|
|
- /*$('#tablepage'+i).dataTable({
|
|
|
- "createdRow": function(row, data, dataIndex) {
|
|
|
- for (j = 0; j < data.length; j++) {
|
|
|
- if (data[j] == `null`) {
|
|
|
- $(row).addClass('NullClass');
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+ var errorList = [];
|
|
|
+
|
|
|
+ if (errors[tab] != "" & errors[tab] != undefined) {
|
|
|
+ errorList = errors[tab].split(',');
|
|
|
+ errorList.shift();
|
|
|
}
|
|
|
- });*/
|
|
|
- $('#tablepage' + i).dataTable({
|
|
|
- "language": {
|
|
|
- "processing": "處理中...",
|
|
|
- "loadingRecords": "載入中...",
|
|
|
- "lengthMenu": "顯示 _MENU_ 項結果",
|
|
|
- "zeroRecords": "沒有符合的結果或是沒有資料",
|
|
|
- "info": "顯示第 _START_ 至 _END_ 項結果,共 _TOTAL_ 項",
|
|
|
- "infoEmpty": "顯示第 0 至 0 項結果,共 0 項",
|
|
|
- "infoFiltered": "(從 _MAX_ 項結果中過濾)",
|
|
|
- "infoPostFix": "",
|
|
|
- "search": "搜尋:",
|
|
|
- "paginate": {
|
|
|
- "first": '<i class="fa fa-step-backward"></i>',
|
|
|
- "previous": '<i class="fa fa-backward"></i>',
|
|
|
- "next": '<i class="fa fa-forward"></i>',
|
|
|
- "last": '<i class="fa fa-step-forward"></i>'
|
|
|
- },
|
|
|
- "aria": {
|
|
|
- "sortAscending": ": 升冪排列",
|
|
|
- "sortDescending": ": 降冪排列"
|
|
|
+
|
|
|
+ /*$('#tablepage'+i).dataTable({
|
|
|
+ "createdRow": function(row, data, dataIndex) {
|
|
|
+ for (j = 0; j < data.length; j++) {
|
|
|
+ if (data[j] == `null`) {
|
|
|
+ $(row).addClass('NullClass');
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- },
|
|
|
- "columnDefs": [{
|
|
|
- "targets": -1,
|
|
|
- "createdCell": function(td, cellData, rowData, row, col) {
|
|
|
-
|
|
|
- if(cellData == "03-厭氧儲氣槽結構計算書"){
|
|
|
- console.log("row:" + row + " col: " + col)
|
|
|
+ });*/
|
|
|
+ $('#tablepage' + tab).dataTable({
|
|
|
+ "language": {
|
|
|
+ "processing": "處理中...",
|
|
|
+ "loadingRecords": "載入中...",
|
|
|
+ "lengthMenu": "顯示 _MENU_ 項資料",
|
|
|
+ "zeroRecords": "沒有符合的結果或是沒有資料",
|
|
|
+ "info": "顯示第 _START_ 至 _END_ 項資料,共 _TOTAL_ 項",
|
|
|
+ "infoEmpty": "顯示第 0 至 0 項資料,共 0 項",
|
|
|
+ "infoFiltered": "(從 _MAX_ 項資料中過濾)",
|
|
|
+ "infoPostFix": "",
|
|
|
+ "search": "搜尋:",
|
|
|
+ "paginate": {
|
|
|
+ "first": '<i class="fa fa-step-backward"></i>',
|
|
|
+ "previous": '<i class="fa fa-backward"></i>',
|
|
|
+ "next": '<i class="fa fa-forward"></i>',
|
|
|
+ "last": '<i class="fa fa-step-forward"></i>'
|
|
|
+ },
|
|
|
+ "aria": {
|
|
|
+ "sortAscending": ": 升冪排列",
|
|
|
+ "sortDescending": ": 降冪排列"
|
|
|
}
|
|
|
- if(errorList.length > 0 ){
|
|
|
- for(var error in errorList){
|
|
|
- if(error == row){
|
|
|
- console.log(cellData)
|
|
|
- $(td).addClass('NullClass');
|
|
|
+ },
|
|
|
+ "columnDefs": [{
|
|
|
+ "targets": -1,
|
|
|
+ "createdCell": function(td, cellData, rowData, row, col) {
|
|
|
+ if (errorList.length > 0) {
|
|
|
+ for (i = 0; i < errorList.length; i++) {
|
|
|
+ if (errorList[i] == row) {
|
|
|
+ $(td).addClass('ErrorClass');
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
- }
|
|
|
- },{
|
|
|
- "targets": '_all',
|
|
|
- "createdCell": function(td, cellData, rowData, row, col) {
|
|
|
- if (cellData == "null") {
|
|
|
- $(td).addClass('NullClass');
|
|
|
+ }, {
|
|
|
+ "targets": '_all',
|
|
|
+ "createdCell": function(td, cellData, rowData, row, col) {
|
|
|
+ if (cellData == "null") {
|
|
|
+ $(td).addClass('NullClass');
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- }],
|
|
|
- });
|
|
|
- i++;
|
|
|
+ }],
|
|
|
+ });
|
|
|
+ i++;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|