manto07m %!s(int64=3) %!d(string=hai) anos
pai
achega
71b5ab1171

+ 13 - 1
R03/Index.php

@@ -87,6 +87,18 @@ include($_SERVER['DOCUMENT_ROOT'] . "/Authorization/script/php/permission/check_
 								<div class="panel-body">
 									<div class="tab-content">
 										<div id="popular" class="chart chart-unity tab-pane active">
+											<!-- <div class="input-daterange input-group" data-plugin-datepicker="">
+												<span class="input-group-addon">
+													<i class="fa fa-calendar"></i>
+												</span>
+												<input type="text" class="form-control" name="start" autocomplete="off">
+												<span class="input-group-addon">to</span>
+												<input type="text" class="form-control" name="end" autocomplete="off">
+											</div> -->
+											<div id="legend" style="margin: auto; width: 50%; display:none;">
+												<img src="/BIM-Monitor/assets/images/legend.png" />
+											</div>
+
 											<canvas id="myChart" height="100%"></canvas>
 										</div>
 										<div id="recent" class="tab-pane">
@@ -239,7 +251,7 @@ include($_SERVER['DOCUMENT_ROOT'] . "/Authorization/script/php/permission/check_
 				console.log(error);
 			});
 		}
-		if(right < 2){
+		if (right < 2) {
 			$("#upload-btn").hide();
 		}
 	</script>

BIN=BIN
assets/images/legend.png


+ 12 - 0
script/js/r03.js

@@ -66,6 +66,13 @@ function LoadPage() {
 
     var option = window.localStorage.getItem("option");
     $('#' + window.localStorage.getItem("option")).removeClass('hidden').removeAttr('disabled');
+    if(option == "SIS" || option == "SID"){
+        $("#legend").show();
+    }else{
+        $("#legend").hide();
+    }
+
+        
 
     document.getElementById("monitorSelect2").innerHTML = "選擇觀測儀器";
 
@@ -442,6 +449,11 @@ function displayChart(monitor, label, unit, charts) {
                 datasets: datasets
             },
             options: {
+                plugins: {
+                    legend: {
+                        display: false
+                    },
+                },
                 spanGaps: true,
                 maintainAspectRatio: false,
                 responsive: true,

+ 17 - 8
script/php/read_excel.php

@@ -1,5 +1,5 @@
 <?php
-include($_SERVER['DOCUMENT_ROOT']."/Authorization/script/php/permission/check_right.php");
+include($_SERVER['DOCUMENT_ROOT'] . "/Authorization/script/php/permission/check_right.php");
 include("./API/equipment.php");
 include("./connect_sql.php");
 require '../../assets/vendor/autoload.php';
@@ -36,7 +36,7 @@ if (isset($_FILES["excel"])) {
     $date_value = $header->getCell('J2')->getValue();
     $timestamp = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($date_value);
     $date = date('Y/m/d', $timestamp);
-
+    $equipment_name = "";
     for ($s = 0; $s < $sheetCount; $s++) {
         $data = array();
         $sheet = $spreadsheet->getSheet($s);
@@ -54,24 +54,28 @@ if (isset($_FILES["excel"])) {
             $endR = $equipment_data[$index_key]["endR"] !== 0 ? $equipment_data[$index_key]["endR"] : $column['row'];   //結尾列數 若為0則總列數
             for ($i = $startR; $i <= $endR; $i++) {
                 $skip = false;
+                $first = true;
                 $row = array();
                 $col_count = 0;
                 array_push($row, $date);
                 if (str_contains($sheetName, "SIS") || str_contains($sheetName, "SID")) {   //若為SIS取出儀器名稱
-                    if(str_contains($sheetName,"區")){
+                    if (str_contains($sheetName, "區")) {
                         $equipment_name = explode("區", $sheetName)[1];
                     }
-                    if(str_contains($sheetName,"(")){
+                    if (str_contains($sheetName, "(")) {
                         $temp = explode("(", $sheetName);
-                        $equipment_name = $temp[0].$temp[1];
+                        $equipment_name = $temp[0] . $temp[1];
                     }
-                    
+
                     $equipment_name = str_replace(" ", "", $equipment_name);
                     $col_count++;
                     array_push($row, $equipment_name);
                 }
                 for ($j = $startC; $j <= $endC; $j++) {
                     if ($skipC != $j) {
+                        if($first){
+                            $first = false;
+                        }
                         $col_count++;
                         $key = $j . $i;
                         $value = $sheet->getCell($key)->getCalculatedValue();
@@ -90,7 +94,12 @@ if (isset($_FILES["excel"])) {
                 if (!$skip) {
                     array_push($data, $row);
                     $row_merge = str_repeat(", ?", $col_count);
-                    $sql = "INSERT INTO [{$type}_Data] VALUES (? {$row_merge});";
+                    $sql = "BEGIN
+                                IF NOT EXISTS (SELECT [date] FROM [{$type}_Data] WHERE [date] = '{$date}' AND [EquipmentID] = '')
+                                BEGIN
+                                    INSERT INTO [{$type}_Data] VALUES (? {$row_merge})
+                                END
+                            END";
                     $stmt = sqlsrv_query($conn, $sql, $row);
                     if ($stmt === false) {
                         if (($errors = sqlsrv_errors()) != null) {
@@ -130,7 +139,7 @@ if (isset($_FILES["excel"])) {
         }
     }
     header("Location: ../../Upload.php?status=success");
-}else{
+} else {
     header("Location: ../../Upload.php?status=failed");
 }
 

BIN=BIN
script/php/uploads/1110808-580C-(車站區)_unmerge.xls