melder/admin/print_html.php

129 lines
5.2 KiB
PHP
Raw Permalink Normal View History

2024-02-16 15:35:01 +01:00
<?php
session_start();
$strLoginName=(isset($_SESSION['user'])) ? $_SESSION['user'] : "" ;
$boolLogin = (!empty($strLoginName));
if (!$boolLogin) {
header("Location: login.php");
}
2024-02-21 14:31:28 +01:00
$strDistrict=$_SESSION['district'];
2024-02-21 19:42:20 +01:00
if (isset($_SESSION['superadmin'])) {
$boolSuperAdmin = $_SESSION['superadmin']==true;
} else {
$boolSuperAdmin=false;
}
2024-02-16 15:35:01 +01:00
include("../config.php");
2024-02-21 10:29:10 +01:00
$sqlDistrict = ($boolSuperAdmin) ? "1" : "l.district='$strDistrict'";
2024-02-16 15:35:01 +01:00
2024-02-22 10:33:50 +01:00
2024-02-16 15:35:01 +01:00
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="../css/bootstrap.min.css" />
<link rel="stylesheet" href="../css/font-awesome.min.css">
<link rel="stylesheet" href="../css/leaflet.css" />
<link rel="stylesheet" href="../css/leaflet.awesome-markers.css" />
<script src="../js/jquery.min.js"></script>
<script src="../js/leaflet.js"></script>
<script src="../js/leaflet.awesome-markers.js"></script>
<title>Eintragsliste</title>
<style>
.tdmap { height:350px; width:300px;}
</style>
</head>
<body>
<div class="container-fluid">
<table class="table table-bordered table-striped">
<thead>
2024-02-22 10:33:50 +01:00
<tr><th>id</th>
<th>Username</th>
2024-02-16 15:35:01 +01:00
<?= ($boolUserinfo) ? "<th>Alter</th><th>Transport</th>" : ""; ?>
<th>Topic</th>
<th>Beschreibung</th>
<?= ($boolRating) ? "<th><i class=\"fa fa-thumbs-up\"></i></th><th><i class=\"fa fa-thumbs-down\"></i></th>" : "" ?>
<th>Kommentare</th>
<th>Mangel</th>
<th>Bild</th>
<th>Adresse</th>
<th>Karte</th>
</thead>
<tbody>
<?php
$strScript="";
2024-02-21 10:29:10 +01:00
$strSQL="SELECT l.id as lid,l.*,adr.*
FROM location l LEFT JOIN address adr ON l.id=adr.loc_id
WHERE $sqlDistrict
ORDER BY city,postcode,suburb,hamlet,road ASC";
2024-02-16 15:35:01 +01:00
$result = $db->query($strSQL);
2024-02-17 08:42:54 +01:00
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
2024-02-16 15:35:01 +01:00
$id = $row['lid'];
$numDatum= strtotime($row['created_at']);
$strDatum= date("d.m.Y",$numDatum);
echo "<tr>";
echo "<td>".$id."</td>";
echo "<td>". stripslashes($row['username']) ."<br><br>". $strDatum . "</td>";
echo ($boolUserinfo) ? "<td>".$row['age']."</td><td>".$row['transport']."</td>" : "";
echo "<td>".$arrIcon[$row['topic']]." ".$arrTopic[$row['topic']]."</td>";
echo "<td>" . stripslashes(nl2br($row['description'])) . "</td>";
echo ($boolRating) ? "<td>".$row['thumb_ups']."</td><td>".$row['thumb_downs']."</td>" : "";
echo "<td>";
$strSQL = "SELECT id,username,comment,created_at FROM comment WHERE loc_id=".$id;
$comments = $db->query($strSQL);
2024-02-17 08:42:54 +01:00
while ($comment = $comments->fetch(PDO::FETCH_ASSOC)) {
2024-02-16 15:35:01 +01:00
echo "<div class='comment'>";
echo "<em>".$comment['username']." schrieb am ";
$numDatum = strtotime($comment['created_at']);
$strDatum = date("d.m.Y",$numDatum);
echo $strDatum."</em><br>";
echo nl2br($comment['comment']);
echo "</div>";
}
echo "</td>";
$strDefect = (isset($row['defect']) && $row['defect']>0) ? $arrDefect[$row['defect']] : "";
echo "<td>".$strDefect."</td>\n";
echo "<td>";
$strSQL = "SELECT id,filename FROM files WHERE loc_id=".$id;
$files=$db->query($strSQL);
2024-02-17 08:42:54 +01:00
if ($file=$files->fetch(PDO::FETCH_ASSOC)) {
2024-02-16 15:35:01 +01:00
echo "<img src='../images/".$file['filename']."' style='width:200px'>";
}
echo "</td>";
echo "<td>".$row['road']." ".$row['house_number']."<br>".$row['neighbourhood']."<br>"
.$row['hamlet']."<br>".$row['suburb']."<br>".$row['postcode']." ".$row['city']."</td>";
//echo "<td>".round($row['lat'],5)." ".round($row['lng'],5)."</td>";
echo "<td><div class='tdmap' id='map_".$id."'></div></td>\n";
echo "</tr>\n";
$strScript.="var mymap_".$id." = L.map(map_".$id.").setView([".$row['lat'].", ".$row['lng']."], 16);\n";
$strScript.="L.tileLayer(url, {maxZoom: 18,minZoom:12,attribution: attribution,id: 'mapbox/streets-v11',tileSize: 512,zoomOffset: -1}).addTo(mymap_".$id.")\n";
$strScript.="L.marker([".$row['lat'].", ".$row['lng']."], { icon: infoMarker } ).addTo(mymap_".$id.")\n\n";
}
?>
</tbody>
</table>
<a class="btn btn-primary" href="../index.php?ref=1">zurück</a>
</div>
</body>
2024-02-22 10:33:50 +01:00
2024-02-16 15:35:01 +01:00
<script>
$( document ).ready(function() {
2024-02-18 19:46:30 +01:00
var url = 'https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=<?=$mapbox_key?>';
2024-02-16 15:35:01 +01:00
var attribution = 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
'<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>';
var infoMarker = L.AwesomeMarkers.icon({icon: 'info', prefix: 'fa', markerColor: 'orange'});
<?= $strScript ?>
});
</script>
</html>