From ebc6a50f528c82e58b8e65424c607fdfd520daf3 Mon Sep 17 00:00:00 2001 From: Jannik Date: Thu, 20 Aug 2020 16:22:59 +0300 Subject: [PATCH] . --- assets/css/Header-Dark.css | 2 +- functions.php | 63 +++++++++++++++++++++++++++++++------- required/header.php | 3 ++ 3 files changed, 56 insertions(+), 12 deletions(-) diff --git a/assets/css/Header-Dark.css b/assets/css/Header-Dark.css index f002796..60fd9bc 100644 --- a/assets/css/Header-Dark.css +++ b/assets/css/Header-Dark.css @@ -1,6 +1,6 @@ body { - background: url(../../assets/img/mountain_bg.jpg) blue; + background: url(../../assets/img/mountain_bg.jpg) grey; height:100%; padding-bottom: 80px; background-repeat:no-repeat; diff --git a/functions.php b/functions.php index 2c22970..54910e3 100644 --- a/functions.php +++ b/functions.php @@ -3,7 +3,7 @@ require 'settings.php'; class Funcs { - public static function InsertDatas($conn, $ds, $de, $n,$tisch,$tnum) + public static function InsertDatas($conn, $ds, $de, $n, $tisch, $tnum) { $day = $_SESSION["day"]; $month = $_SESSION["month"]; @@ -12,28 +12,69 @@ class Funcs $dayend = $de; $name = $n; - + $besetzt = array(); $table = $tisch; for ($daystart; $daystart <= $dayend; $daystart++) { - $sql = "INSERT INTO calenderplanner (year, month, day,reserviert,reserviertvon,tisch) - VALUES ('$year', '$month', '$daystart', '1', '$name', '$table')"; + $sql = "SELECT * FROM calenderplanner WHERE month='$month' AND day='$daystart'AND year='$year' AND tisch='$table'"; + $result = $conn->query($sql); + + if ($result->num_rows > 0) { + + while ($row = $result->fetch_assoc()) { + $besetzt[$row['day']] = $row['reserviertvon']; + //array_push($besetzt[$row['day'] = $row['reserviertvon']]); + } + } + else{ + $sql = "INSERT INTO calenderplanner (year, month, day,reserviert,reserviertvon,tisch) + VALUES ('$year', '$month', '$daystart', '1', '$name', '$table')"; $conn->query($sql); + } + + } $sql = "SELECT * FROM calenderplanner WHERE month='$month' AND day='$day'AND year='$year' AND tisch='$table'"; $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']."
" ; $_SESSION[$tnum] = array($row['uniqueid'], $row['month'], $row['day'], $row['reserviert'], $row['reserviertvon'], $row['tisch'], $row['year']); - //echo $_SESSION["Tisch3"][6]; } - $_SESSION["sucessmessage"] = '
-Du hast den Tisch erfolgreich reserviert.
'; - header("location:index.php?result=gotrecords"); } - } + + if(empty($besetzt)) { + + $_SESSION["sucessmessage"] = '
+ Du hast den/die Tisch/e erfolgreich reserviert.
'; + + header("location:index.php?result=gotrecords"); + } + else + { + $_SESSION["sucessmessage"] = '
+ + Folgende Tische sind schon belegt von:
+ '; + + foreach ($besetzt as $key => $value) + { + + $_SESSION["sucessmessage"].= "Tag ".$key." belegt von: ".$value."
"; + } + + $_SESSION["sucessmessage"].='

'; + $_SESSION["sucessmessage"].='
+ + Die freien Tische wurden belegt!
+

'; + + header("location:index.php?result=gotrecords"); + } + + + + } + } diff --git a/required/header.php b/required/header.php index 6f61b56..df1a216 100644 --- a/required/header.php +++ b/required/header.php @@ -14,6 +14,9 @@ $("#refresh").click(); } + $(function () { + $('[data-toggle="popover"]').popover() + })