1
0
mirror of https://github.com/JannikKoester/Tischverwaltung.git synced 2026-01-10 14:50:07 +01:00

mehrfachauswahl

This commit is contained in:
2020-08-19 17:23:59 +03:00
parent 4ed8831781
commit 6600f5f381
4 changed files with 440 additions and 466 deletions

175
index.php
View File

@@ -1,8 +1,8 @@
<!DOCTYPE html> <!DOCTYPE html>
<body> <body>
<?php <?php
if(!file_exists("settings.php")) if (!file_exists("settings.php")) {
{
header("location:install.php"); header("location:install.php");
} }
@@ -10,8 +10,7 @@ if(!file_exists("settings.php"))
if (session_status() == PHP_SESSION_NONE) { if (session_status() == PHP_SESSION_NONE) {
session_start(); session_start();
}else } else {
{
session_destroy(); session_destroy();
session_start(); session_start();
} }
@@ -23,10 +22,8 @@ require 'modal.php';
<?php <?php
if(isset($_GET['result'])) if (isset($_GET['result'])) {
{ if ($_GET['result'] == "gotrecords" || $_GET['result'] == "loggedin") {
if($_GET['result'] == "gotrecords" || $_GET['result'] == "loggedin")
{
$selectedjan = ''; $selectedjan = '';
$selectedfeb = ''; $selectedfeb = '';
$selectedmar = ''; $selectedmar = '';
@@ -40,8 +37,7 @@ require 'modal.php';
$selectednov = ''; $selectednov = '';
$selecteddez = ''; $selecteddez = '';
switch($_SESSION["month_string"]) switch ($_SESSION["month_string"]) {
{
case "Januar": case "Januar":
$selectedjan = 'selected'; $selectedjan = 'selected';
@@ -90,8 +86,6 @@ require 'modal.php';
case "Dezember": case "Dezember":
$selecteddez = 'selected'; $selecteddez = 'selected';
break; break;
} }
@@ -106,7 +100,6 @@ require 'modal.php';
} else { } else {
echo '<option value =' . $i . '>' . $i . '</option>'; echo '<option value =' . $i . '>' . $i . '</option>';
} }
} }
@@ -149,15 +142,9 @@ require 'modal.php';
<button id="refresh" name="getTables" type="submit" class="btnchange"style="display:none;" >Aktualisiere erneut</button> <button id="refresh" name="getTables" type="submit" class="btnchange"style="display:none;" >Aktualisiere erneut</button>
</form> </form>
<h2 style="color:white;font-family:Bitter; text-align:center;">' . $_SESSION["day_string"] . '. ' . $_SESSION["month_string"] . ' ' . $_SESSION["year"] . ' </h2>'; <h2 style="color:white;font-family:Bitter; text-align:center;">' . $_SESSION["day_string"] . '. ' . $_SESSION["month_string"] . ' ' . $_SESSION["year"] . ' </h2>';
} else {
} }
else{ } else {
}
}
else{
echo '<form action="getTables.php" method="post"> echo '<form action="getTables.php" method="post">
<div class="form-group"> <div class="form-group">
<label for="sel1"style="color:white;font-family:Bitter;font-size:24px;">Jahr:</label> <label for="sel1"style="color:white;font-family:Bitter;font-size:24px;">Jahr:</label>
@@ -169,7 +156,6 @@ require 'modal.php';
} else { } else {
echo '<option value =' . $i . '>' . $i . '</option>'; echo '<option value =' . $i . '>' . $i . '</option>';
} }
} }
echo '</select>'; echo '</select>';
@@ -207,8 +193,6 @@ require 'modal.php';
</div> </div>
<button id="refresh" name="getTables" type="submit" class="btnchange style="display:none;"" >Aktualisiere</button> <button id="refresh" name="getTables" type="submit" class="btnchange style="display:none;"" >Aktualisiere</button>
</form>'; </form>';
} }
@@ -224,24 +208,17 @@ require 'modal.php';
<div class="container-fluid" style="background-color:lightgrey;opacity: 0.6;border:solid; width:800px;"> <div class="container-fluid" style="background-color:lightgrey;opacity: 0.6;border:solid; width:800px;">
<div class="right-tables"> <div class="right-tables">
<ul> <li> <ul>
<li>
<div id="table4"> <div id="table4">
<?php <?php
if(isset($_GET['result'])) if (isset($_GET['result'])) {
{ if ($_GET['result'] == "gotrecords") {
if($_GET['result'] == "gotrecords") if ($_SESSION["Tisch4"] == "FREI") {
{
if($_SESSION["Tisch4"] == "FREI")
{
echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModal4" style="color:green; width:120px;">Tisch 4 <br> ist frei.</button>'; echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModal4" style="color:green; width:120px;">Tisch 4 <br> ist frei.</button>';
} else {
}
else
{
echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModal_change4" style="color:red;width:120px;" >Tisch 4 ist belegt durch <br>' . $_SESSION["Tisch4"][4] . '.</button>'; echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModal_change4" style="color:red;width:120px;" >Tisch 4 ist belegt durch <br>' . $_SESSION["Tisch4"][4] . '.</button>';
} }
} }
} }
?> ?>
@@ -252,21 +229,13 @@ require 'modal.php';
<li> <li>
<div id="table3"> <div id="table3">
<?php <?php
if(isset($_GET['result'])) if (isset($_GET['result'])) {
{ if ($_GET['result'] == "gotrecords") {
if($_GET['result'] == "gotrecords") if ($_SESSION["Tisch3"] == "FREI" || $_SESSION["Tisch3"][6] != $_SESSION["year"]) {
{
if($_SESSION["Tisch3"] == "FREI" || $_SESSION["Tisch3"][6] != $_SESSION["year"] )
{
echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModal3" style="color:green;opacity: 1.5;width:120px;">Tisch 3 <br> ist frei.</button>'; echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModal3" style="color:green;opacity: 1.5;width:120px;">Tisch 3 <br> ist frei.</button>';
} else {
}
else
{
echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModal_change3" style="color:red;width:120px;">Tisch 3 ist belegt durch <br>' . $_SESSION["Tisch3"][4] . '.</button>'; echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModal_change3" style="color:red;width:120px;">Tisch 3 ist belegt durch <br>' . $_SESSION["Tisch3"][4] . '.</button>';
} }
} }
} }
?> ?>
@@ -279,21 +248,13 @@ require 'modal.php';
<div id="table2"> <div id="table2">
<?php <?php
if(isset($_GET['result'])) if (isset($_GET['result'])) {
{ if ($_GET['result'] == "gotrecords") {
if($_GET['result'] == "gotrecords") if ($_SESSION["Tisch2"] == "FREI") {
{
if($_SESSION["Tisch2"] == "FREI")
{
echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModal2" style="color:green;">Tisch 2 <br> ist frei.</button>'; echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModal2" style="color:green;">Tisch 2 <br> ist frei.</button>';
} else {
}
else
{
echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModal_change2" style="color:red;">Tisch 2 ist belegt durch <br>' . $_SESSION["Tisch2"][4] . '.</button>'; echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModal_change2" style="color:red;">Tisch 2 ist belegt durch <br>' . $_SESSION["Tisch2"][4] . '.</button>';
} }
} }
} }
?> ?>
@@ -305,21 +266,13 @@ require 'modal.php';
<div id="table1"> <div id="table1">
<?php <?php
if(isset($_GET['result'])) if (isset($_GET['result'])) {
{ if ($_GET['result'] == "gotrecords") {
if($_GET['result'] == "gotrecords") if ($_SESSION["Tisch1"] == "FREI") {
{
if($_SESSION["Tisch1"] == "FREI")
{
echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModal" style="color:green;">Tisch 1 <br> ist frei.</button>'; echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModal" style="color:green;">Tisch 1 <br> ist frei.</button>';
} else {
}
else
{
echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModal_change" style="color:red;">Tisch 1 ist belegt durch <br>' . $_SESSION["Tisch1"][4] . '</button>'; echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModal_change" style="color:red;">Tisch 1 ist belegt durch <br>' . $_SESSION["Tisch1"][4] . '</button>';
} }
} }
} }
?> ?>
@@ -338,21 +291,13 @@ require 'modal.php';
<div id="table5"> <div id="table5">
<?php <?php
if(isset($_GET['result'])) if (isset($_GET['result'])) {
{ if ($_GET['result'] == "gotrecords") {
if($_GET['result'] == "gotrecords") if ($_SESSION["Tisch5"] == "FREI") {
{
if($_SESSION["Tisch5"] == "FREI")
{
echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModal5" style="color:green;">Tisch 5 <br> ist frei.</button>'; echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModal5" style="color:green;">Tisch 5 <br> ist frei.</button>';
} else {
}
else
{
echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModal_change5" style="color:red;">Tisch 5 ist belegt durch <br>' . $_SESSION["Tisch5"][4] . '.</button>'; echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModal_change5" style="color:red;">Tisch 5 ist belegt durch <br>' . $_SESSION["Tisch5"][4] . '.</button>';
} }
} }
} }
?> ?>
@@ -364,21 +309,13 @@ require 'modal.php';
<div id="table6"> <div id="table6">
<?php <?php
if(isset($_GET['result'])) if (isset($_GET['result'])) {
{ if ($_GET['result'] == "gotrecords") {
if($_GET['result'] == "gotrecords") if ($_SESSION["Tisch6"] == "FREI") {
{
if($_SESSION["Tisch6"] == "FREI")
{
echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModal6" style="color:green;">Tisch 6 <br> ist frei.</button>'; echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModal6" style="color:green;">Tisch 6 <br> ist frei.</button>';
} else {
}
else
{
echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModal_change6" style="color:red;">Tisch 6 ist belegt durch <br>' . $_SESSION["Tisch6"][4] . '.</button>'; echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModal_change6" style="color:red;">Tisch 6 ist belegt durch <br>' . $_SESSION["Tisch6"][4] . '.</button>';
} }
} }
} }
?> ?>
@@ -389,21 +326,13 @@ require 'modal.php';
<li> <li>
<div id="park1" style="margin-left:250px;margin-top:-268px;"> <div id="park1" style="margin-left:250px;margin-top:-268px;">
<?php <?php
if(isset($_GET['result'])) if (isset($_GET['result'])) {
{ if ($_GET['result'] == "gotrecords") {
if($_GET['result'] == "gotrecords") if ($_SESSION["Park1"] == "FREI") {
{
if($_SESSION["Park1"] == "FREI")
{
echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModalpark1" style="color:green; height:265px;">Parkplatz 1 <br> ist frei.</button>'; echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModalpark1" style="color:green; height:265px;">Parkplatz 1 <br> ist frei.</button>';
} else {
}
else
{
echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModal_changepark1" style="color:red; height:265px;">Parkplatz 1 ist belegt durch <br>' . $_SESSION["Park1"][4] . '.</button>'; echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModal_changepark1" style="color:red; height:265px;">Parkplatz 1 ist belegt durch <br>' . $_SESSION["Park1"][4] . '.</button>';
} }
} }
} }
?> ?>
@@ -414,21 +343,13 @@ require 'modal.php';
<li> <li>
<div id="park2" style="margin-left:500px;margin-top:-273px;"> <div id="park2" style="margin-left:500px;margin-top:-273px;">
<?php <?php
if(isset($_GET['result'])) if (isset($_GET['result'])) {
{ if ($_GET['result'] == "gotrecords") {
if($_GET['result'] == "gotrecords") if ($_SESSION["Park2"] == "FREI") {
{
if($_SESSION["Park2"] == "FREI")
{
echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModalpark2" style="color:green; height:265px;">Parkplatz 2 <br> ist frei.</button>'; echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModalpark2" style="color:green; height:265px;">Parkplatz 2 <br> ist frei.</button>';
} else {
}
else
{
echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModal_changepark2" style="color:red; height:265px;">Parkplatz 2 ist belegt durch <br>' . $_SESSION["Park2"][4] . '.</button>'; echo '<button id="buttonTable1" type="button" class="btn btn-light" data-toggle="modal" data-target="#myModal_changepark2" style="color:red; height:265px;">Parkplatz 2 ist belegt durch <br>' . $_SESSION["Park2"][4] . '.</button>';
} }
} }
} }
?> ?>
@@ -454,9 +375,9 @@ require 'modal.php';
echo $_SESSION["sucessmessagereplaced"]; echo $_SESSION["sucessmessagereplaced"];
$_SESSION["sucessmessagereplaced"] = ""; $_SESSION["sucessmessagereplaced"] = "";
} }
if(isset( $_SESSION["accnotfound"])){ if (isset($_SESSION["errmsg"])) {
echo $_SESSION["accnotfound"]; echo $_SESSION["errmsg"];
$_SESSION["accnotfound"]=""; $_SESSION["errmsg"] = "";
} }
@@ -491,6 +412,7 @@ require 'modal.php';
border: solid; border: solid;
} }
.left-tables ul li { .left-tables ul li {
list-style-type: none; list-style-type: none;
@@ -504,6 +426,7 @@ require 'modal.php';
border: solid; border: solid;
} }
.right-tables ul li { .right-tables ul li {
list-style-type: none; list-style-type: none;
display: inline-block; display: inline-block;
@@ -524,12 +447,10 @@ require 'modal.php';
height: 50px; height: 50px;
width: 200px; width: 200px;
} }
.btnchange:hover { .btnchange:hover {
background: #269d9d; background: #269d9d;
} }
</style> </style>

View File

@@ -5,36 +5,36 @@ require 'settings.php';
if(isset($_POST['reservierenBtnTisch1'])){ if(isset($_POST['reservierenBtnTisch1'])){
$month = $_SESSION["month"]; $month = $_SESSION["month"];
$day = $_SESSION["day"]; $daystart=intval($_POST['daystart']);
$dayend = intval($_POST['dayend']);
$name = $_POST['reservierterName']; $name = $_POST['reservierterName'];
$year = $_SESSION["year"]; $year = $_SESSION["year"];
$table = 1; $table = 1;
$sql = "INSERT INTO calenderplanner (year, month, day,reserviert,reserviertvon,tisch)
VALUES ('$year', '$month', '$day', '1', '$name', '$table')";
if ($conn->query($sql) === TRUE) { if($daystart > $dayend)
echo "New record created successfully"; {
$_SESSION["errmsg"] = '<div class="alert alert-danger">
Fehler! Der Starttag lag über dem Endtag.</div>';
header("location:index.php?result=gotrecords");
}
else{
for ($daystart; $daystart <= $dayend ; $daystart++) {
$sql = "INSERT INTO calenderplanner (year, month, day,reserviert,reserviertvon,tisch)
VALUES ('$year', '$month', '$daystart', '1', '$name', '$table')";
$conn->query($sql);
}
$_SESSION["sucessmessage"] = '<div class="alert alert-success"> $_SESSION["sucessmessage"] = '<div class="alert alert-success">
Du hast den Tisch erfolgreich reserviert.</div>'; Du hast den Tisch erfolgreich reserviert.</div>';
$sql = "SELECT * FROM calenderplanner WHERE month='$month' AND day='$day'AND year='$year' AND tisch='1'"; header("location:index.php");
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
//echo $row['uniqueid'].$row['year'].$row['month'].$row['day'].$row['reserviert'].$row['reserviertvon'].$row['tisch']."<br>" ;
$_SESSION["Tisch1"] = array($row['uniqueid'],$row['month'],$row['day'],$row['reserviert'],$row['reserviertvon'],$row['tisch'],$row['year']);
//echo $_SESSION["Tisch3"][6];
}
}
header("location:index.php?result=gotrecords");
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
} }
} }
else if(isset($_POST['reservierenBtnTisch2'])){ else if(isset($_POST['reservierenBtnTisch2'])){
$month = $_SESSION["month"]; $month = $_SESSION["month"];
$day = $_SESSION["day"]; $day = $_SESSION["day"];

View File

@@ -1,13 +1,31 @@
<script>
function ValidInputs(){
var e = document.getElementById("daystart");
var daystart = e.options[e.selectedIndex].value;
var b = document.getElementById("dayend");
var dayend = b.options[b.selectedIndex].value;
if(daystart > dayend)
{
document.getElementById("reservierenbutton").disabled = true;
alert("Starttag liegt nach dem Endtag");
}
else{
document.getElementById("reservierenbutton").disabled = false;
}
//alert(daystart +" " + dayend);
}
</script>
<?php <?php
if (session_status() == PHP_SESSION_NONE) { if (session_status() == PHP_SESSION_NONE) {
session_start(); session_start();
}else }else
{ {
}
function selected()
{
} }
?> ?>
<!-- Modals für erstes belegen--> <!-- Modals für erstes belegen-->
@@ -21,7 +39,7 @@ function selected()
<!-- Modal Header --> <!-- Modal Header -->
<div class="modal-header"> <div class="modal-header">
<h4 class="modal-title">Tisch 1</h4> <h4 class="modal-title">Tisch 1 neu</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button> <button type="button" class="close" data-dismiss="modal">&times;</button>
</div> </div>
@@ -31,7 +49,38 @@ function selected()
<h2>Geben Sie Ihren Namen ein:</h2> <h2>Geben Sie Ihren Namen ein:</h2>
<label for="lname">Name:</label> <label for="lname">Name:</label>
<input type="text" id="lname" name="reservierterName"required><br><br> <input type="text" id="lname" name="reservierterName"required><br><br>
<input class="btn btn-primary" type="submit" value="Reservieren" name="reservierenBtnTisch1" >
<?php
echo '<h3>Reservieren von</h3>';
echo '<select class="form-control" name="daystart" id="daystart" onchange="ValidInputs()">';
for ($i=1; $i <32 ; $i++) {
$month = $_SESSION['month_string'];
if ($i == 1) {
echo "<option value='$i' selected>$i. $month</option>";
} else {
echo "<option value ='$i'> $i. $month</option>";
}
}
echo '</select>';
echo '<h3>bis</h3>';
echo '<select class="form-control" name="dayend" id="dayend" onchange="ValidInputs()">';
for ($i=1; $i <32 ; $i++) {
$month = $_SESSION['month_string'];
if ($i == 1) {
echo "<option value='$i' selected>$i. $month</option>";
} else {
echo "<option value ='$i'> $i. $month</option>";
}
}
echo '</select>';
?>
<br>
<input class="btn btn-primary" type="submit" id="reservierenbutton"value="Reservieren" name="reservierenBtnTisch1" >
</form> </form>
</div> </div>

View File

@@ -14,6 +14,10 @@
$("#refresh").click(); $("#refresh").click();
} }
function ValidInputs(){
//var daystart = $( "#daystart:selected" ).text();
alert("daystart");
}
</script> </script>