76 lines
1.7 KiB
PHP
76 lines
1.7 KiB
PHP
<!DOCTYPE html>
|
|
<?php
|
|
|
|
require 'config.inc';
|
|
$pdo = new PDO("mysql:host=$g_db_host;dbname=$g_db_schema;charset=utf8mb4", $g_db_username, $g_db_password);
|
|
$sql = "SELECT p.provid, p.provname, p.target - p.number AS buy, d.ddtext as unit "
|
|
. "FROM provisions AS p LEFT JOIN dropdown AS d ON p.unit=d.ddval AND d.ddid=6 "
|
|
. "WHERE p.target IS NOT NULL AND p.number < p.target "
|
|
. "ORDER BY p.provcat, p.provname";
|
|
$sth = $pdo->query($sql);
|
|
$res = $sth->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
// aktuelle Einkaufsliste laden
|
|
// localStorage.setItem("liste", JSON.stringify(meineListe));
|
|
// let liste = JSON.parse(localStorage.getItem("liste"));
|
|
//$liste = getEinkaufsliste();
|
|
?>
|
|
<html>
|
|
<head>
|
|
<title>Shopping list</title>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<link rel="manifest" href="manifest.json">
|
|
<script src="js/shopping.js" defer></script>
|
|
<script>
|
|
const initialList = <?= json_encode($res, JSON_UNESCAPED_UNICODE) ?>;
|
|
// only activate for production use
|
|
if ('serviceWorker' in navigator) {
|
|
navigator.serviceWorker.register('service-worker.js');
|
|
}
|
|
</script>
|
|
<style>
|
|
body{
|
|
font-family:Arial,sans-serif;
|
|
margin:12px;
|
|
}
|
|
h1{
|
|
text-align:center;
|
|
}
|
|
table{
|
|
width:100%;
|
|
border-collapse:collapse;
|
|
}
|
|
td{
|
|
padding:10px 6px;
|
|
border-bottom:1px solid #ddd;
|
|
font-size:1.1em;
|
|
}
|
|
td:first-child{
|
|
width:40px;
|
|
}
|
|
td:last-child{
|
|
text-align:right;
|
|
width:60px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<h1>YMS Einkaufsliste</h1>
|
|
|
|
<button onclick="location.reload()">Aktualisieren</button>
|
|
|
|
<h2>Offen</h2>
|
|
<div id="shoppingList">
|
|
Loading ...
|
|
</div>
|
|
|
|
<h2>Erledigt</h2>
|
|
<div id="completedList">
|
|
Empty.
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|