File "regist.php"
Full path: /www/ichimill/4/regist.php
File size: 10.49 KiB (10743 bytes)
MIME-type: text/html
Charset: utf-8
<html lang="ja">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<title>登録GPSデータ一覧</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css" />
<!-- Leaflet JavaScriptファイルの読み込み -->
<script src="https://unpkg.com/leaflet/dist/leaflet.js"></script>
<link rel="stylesheet" type="text/css" href="common.css">
</head>
<main>
<div class="container-fluid">
<!-- page header -->
<div class="row mb-2">
<div class="col-12">
<div class="title p-2 border rounded text-center"><FONT SIZE='5'>登録GPSデータ一覧</FONT></div>
</div>
</div>
<?php
// EXTRACT($_GET);
// $id = $_GET['id'];
//$fs = fopen("test.txt","a");
//fwrite($fs,$id ."\n");
//print_r($_POST);
$path = explode("/" ,getcwd());
$ct = count($path) -1;
$id =$path[$ct];
//===============================================
// CommonUtilities
// 備考 :
// 更新 : 2012/11/29 KMK-Teraoka
//===============================================
$DATA_TABLE = "gps.rtk_data_regist" .$id;
$HOST = "localhost";
$DB = "ichimill";
$USER = "postgres";
$PASS = "postgres";
$conn = pg_connect("
host = ". $HOST. "
dbname = ". $DB. "
user = ". $USER. "
password= ". $PASS. "
");
//登録データの削除
if($_POST['del'])
{
// print $_POST['no'] ."<BR>";
$sql_del = "UPDATE " .$DATA_TABLE ." SET del_flag='true' WHERE no = " .$_POST['no'];
$res_del = pg_query($conn, $sql_del) or die("SQL ERROR!!<br />"."No" .$_POST['no'] ."の削除に失敗しました");
print "<FONT COLOR='red'>No" .$_POST['no'] ."を削除しました</FONT>";
}
//日付毎表示
//プルダウン用
$sql2 = "SELECT distinct (to_char(gps_date,'YYYY-MM-DD')) AS date_ FROM " .$DATA_TABLE ." where del_flag='false' order by date_";
$res2 = pg_query($conn, $sql2) or die("SQL ERROR!!<br />". $sql2.pg_last_error());
$ct2 = pg_num_rows($res2);
if($_POST['date'])
{
$date_st = date("Y-m-d H:i:s",$_POST['date']);
$date_end = date("Y-m-d H:i:s",$_POST['date'] + 86400);
$where_date = " AND gps_date >= '" .$date_st ."' AND gps_date < '" .$date_end ."'";
$date_ = $_POST['date'];
}
else if($ct2)
{
$row2 = pg_fetch_array($res2,$ct2-1);
$date_unix = strtotime($row2[0]);
$date_st = date("Y-m-d H:i:s",$date_unix);
$date_end = date("Y-m-d H:i:s",$date_unix + 86400);
$where_date = " AND gps_date >= '" .$date_st ."' AND gps_date < '" .$date_end ."'";
$date_ = $date_unix;
}
// print_r($_POST);
$sql = "SELECT * FROM " .$DATA_TABLE ." WHERE del_flag = 'false'" .$where_date ." order by gps_date";
$res = pg_query($conn, $sql) or die("SQL ERROR!!<br />". $sql.pg_last_error());
$ct = pg_num_rows($res);
$device_list = array("lc5590","lc2473","lc2389","lc2733","lc1949","lc2355");
$idd = $id -1;
//表示切替処理
if($_POST['view_set'])
{
$view_no = ($_POST['view_no'] == 1) ? 2:1;
}
else
{
$view_no = (!$_POST['view_no']) ? 1:$_POST['view_no'];
}
$view = ($view_no == 1) ? "平面直角" :"緯度経度";
print "<TABLE BORDER='0' width='100%'>";
print "<TR>";
print "<TD>";
print "<form style='display:inline' action='regist.php' method='post'>";
print "<INPUT TYPE='submit' name='set' VALUE='更 新' style='width:80px;height:20px'>";
print " 端末ID名:" .$device_list[$idd];
if($date_) print "<INPUT TYPE='hidden' name='date' VALUE='" .$date_."' >";
print "<INPUT TYPE='hidden' name='view_no' VALUE='" .$view_no ."' >";
print "</form>";
print "</TD>";
print "<TD>";
print "<div align='right'><input type='button' onclick='window.close();' value='閉じる' ALIGN='right'></div>";
print "</TD>";
print "</TR>";
print "<TR>";
print "<TD>";
print "<form style='display:inline' action='regist.php' method='post'>";
print "<INPUT TYPE='submit' name='view_set' VALUE='" .$view ."' style='width:80px;height:20px'>";
if($date_) print "<INPUT TYPE='hidden' name='date' VALUE='" .$date_."' >";
print "<INPUT TYPE='hidden' name='view_no' VALUE='" .$view_no ."' >";
print "</form>";
print "</TD>";
print "<TD>";
print " ";
print "</TD>";
print "</TR>";
print "</TABLE BORDER>";
print "<div id='map'></div>";
print "<script>";
// マップ作成
print "var map = L.map('map',{";
print "center:[51.505, -0.09],zoom:5";
print "});";
// OpenStreetMapのタイルを設定
print "L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {";
print "maxZoom: 30,";
print "}).addTo(map);";
// GNSS位置情報を取得してピンを表示する関数
print "function showPosition(lat_in,lon_in,alt_in,x_in,y_in,z_in,position_type_in,remarks_in,name_in,no,viwe_) {";
print "var point_no = no;";
print "var lat = lat_in;";
print "var lon = lon_in;";
print "var alt = alt_in;";
print "var position_type = position_type_in;";
print "var remarks = remarks_in;";
print "var name = name_in;";
print "var marker = L.marker([lat, lon]).addTo(map);";
print "map.setView([lat, lon], 14);";
print "if(viwe_==1){";
print "marker.bindPopup(\"[\" + point_no + \"]\" + name + \"<br />X: \" + x_in + \"<br>Y: \" + y_in + \"<br>標高: \" + z_in + \"<br>測位状況: \" + position_type + \"<br>備考: \" + remarks).openPopup();";
print "}else{";
print "marker.bindPopup(\"[\" + point_no + \"]\" + name + \"<br />緯度: \" + lat + \"<br>経度: \" + lon + \"<br>楕円体高: \" + alt + \"<br>測位状況: \" + position_type + \"<br>備考: \" + remarks).openPopup();";
print "}";
print "}";
print "</script>";
if($ct)
{
//CSV保存時のパス
$OutputDirectory = "/www/ichimill/" .$id ."/regist_csv";
$OutputFileName[0] = date("Ymd",$date_);
$OutputFileName[1] = date("Ymd",$date_) ."_1.csv";
$OutputFileName[2] = date("Ymd",$date_) ."_2.csv";
$OutputFileName[3] = date("Ymd",$date_) ."_3.csv";
$OutputPath[1] = $OutputDirectory ."/" .$OutputFileName[1];
$OutputPath[2] = $OutputDirectory ."/" .$OutputFileName[2];
$OutputPath[3] = $OutputDirectory ."/" .$OutputFileName[3];
file_put_contents($OutputPath[1] ,mb_convert_encoding("端末ID,GPS日時,X,Y,標高,測位状況,登録地点名,備考" ."\n" , "sjis","utf-8"));
file_put_contents($OutputPath[2] ,mb_convert_encoding("端末ID,GPS日時,緯度,経度,楕円体高,測位状況,登録地点名,備考" ."\n" , "sjis","utf-8"));
file_put_contents($OutputPath[3] ,mb_convert_encoding("端末ID,GPS日時,緯度,経度,楕円体高,X,Y,標高,測位状況,登録地点名,備考" ."\n" , "sjis","utf-8"));
$chmod[1] = chmod($OutputPath[1], 0777);
$chmod[2] = chmod($OutputPath[2], 0777);
$chmod[3] = chmod($OutputPath[3], 0777);
//初期データ
$offset_file = "/www/ichimill/" .$id ."/offset.txt";
$timeset_file = "/www/ichimill/" .$id ."/timeset.txt";
$basegps_file = "/www/ichimill/" .$id ."/gps_base.txt";
print "<TABLE BORDER='1' class='table_sticky'>";
print "<TR ALIGN='Center'>";
print "<TD>" ."No" ."</TD><TD>" ."GPS日時" ."</TD><TD>" ."削除" ."</TD>";
print "</TR>";
$row2 = array();
$date = array();
print "<form style='display:inline' action='regist.php' method='post'>";
for($j = 0;$j < $ct2;$j++)
{
$row2 = pg_fetch_array($res2,$j);
$date[] = $row2[0];
}
Pulldown_create(100 ,$date,$date_);
print " ";
print "<INPUT TYPE='submit' name='date_set' VALUE='表示'>";
print "<INPUT TYPE='hidden' name='view_no' VALUE='" .$view_no ."' >";
print " ";
print "</form>";
print "<form style='display:inline' action='../download.php' method='post'>";
// print "<form style='display:inline' action='regist.php' method='post'>";
print "<INPUT TYPE='submit' name='csv' VALUE='CSV出力'>";
print "<INPUT TYPE='radio' name='csv_type' Checked VALUE='1'>平面直角";
print " ";
print "<INPUT TYPE='radio' name='csv_type' VALUE='2'>緯度経度";
print " ";
print "<INPUT TYPE='radio' name='csv_type' VALUE='3'>全て";
print " ";
print "<INPUT TYPE='hidden' name='s' VALUE='" .$OutputDirectory ."' >";
print "<INPUT TYPE='hidden' name='f' VALUE='" .$OutputFileName[0] ."' >";
print "</form>";
for($i = 0;$i < $ct ;$i++)
{
$row = pg_fetch_array($res,$i);
print "<TR>";
print "<TD>";
print $row[8];
print "</TD>";
print "<TD>";
print $row[0];
print "</TD>";
print "<TD>";
print "<form style='display:inline' action='regist.php' method='post'>";
print "<INPUT TYPE='submit' name='del' VALUE='削除'>";
print "<INPUT TYPE='hidden' name='no' VALUE='" .$row[8]."' >";
if($date_) print "<INPUT TYPE='hidden' name='date' VALUE='" .$date_."'>";
print "<INPUT TYPE='hidden' name='view_no' VALUE='" .$view_no ."' >";
print "</form>";
print "</TD>";
print "</TR>";
//CSV出力処理
file_put_contents($OutputPath[1] ,mb_convert_encoding($device_list[$idd] ."," .$row['gps_date'] ."," .$row['x'] ."," .$row['y'] ."," .$row['elevation'] ."," .$row['position_type_name'] ."," .$row['file_name'] ."," .$row['remarks'] ."\n", "sjis","utf-8") , FILE_APPEND);
file_put_contents($OutputPath[2] ,mb_convert_encoding($device_list[$idd] ."," .$row['gps_date'] ."," .$row['latitude'] ."," .$row['longitude'] ."," .$row['gps_altitude'] ."," .$row['position_type_name'] ."," .$row['file_name'] ."," .$row['remarks'] ."\n", "sjis","utf-8") , FILE_APPEND);
file_put_contents($OutputPath[3] ,mb_convert_encoding($device_list[$idd] ."," .$row['gps_date'] ."," .$row['latitude'] ."," .$row['longitude'] ."," .$row['gps_altitude'] .",".$row['x'] ."," .$row['y'] ."," .$row['elevation'] ."," .$row['position_type_name'] ."," .$row['file_name'] ."," .$row['remarks'] ."\n", "sjis","utf-8") , FILE_APPEND);
$row = pg_fetch_array($res,$i);
$lat = $row['latitude'];
$lon = $row['longitude'];
$alt = $row['gps_altitude'];
$x = $row['x'];
$y = $row['y'];
$z = $row['elevation'];
$position_type = $row['position_type_name'];
$remarks = ($row['remarks']) ? $row['remarks']:"---";
$name = ($row['file_name']) ? $row['file_name']:"---";
$no = $row['no'];
echo "<script>showPosition($lat,$lon,$alt,$x,$y,$z,'$position_type','$remarks','$name',$no,$view_no);</script>";
}
print "</TABLE>";
}
else
{
print "登録データはありません";
}
function Pulldown_create($width ,$data_,$selected)
{
$value_ct = count($data_);
print "<select name='date' style='width:" .$width ."px;'>";
for($j= 0 ;$j < $value_ct;$j++)
{
$unix = strtotime($data_[$j]);
$sel = ($selected== $unix) ? "selected" : "";
print "<option value='" .$unix ."' " .$sel ." >" .$data_[$j] ."</option>";
}
print "</select>";
}
?>