Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- require("databaseconnection.php");
- if (isset($_SESSION['admin'])) {
- $SQL = "select isAdmin from users where login = '".$_SESSION['loggedlogin']."';";
- $baza = new Database();
- $baza->connect();
- if($dane = $baza->query($SQL)){
- if($dane->num_rows == 0){
- }else{
- while($row = $dane->fetch_assoc()){
- if($row['isAdmin']<1){
- header("location: index.php");
- }else{
- $status = $row['isAdmin'];
- }
- }
- }
- }else{
- header("location: index.php");
- }
- }
- require("HourModel.php");
- $placeName = "Kort I";
- $connection = new Database();
- if(isset($_GET['date'])){
- $checkDate = $_GET['date'];
- }else{
- $checkDate = date("Y-m-d");
- }
- //echo("&date = ".date("Y-m-d"));
- $connection->connect();
- $sql = "Select * from objects order by name;";
- $dataQuery = $connection->query($sql);
- $tommorow = date('Y-m-d', strtotime("+1 days",strtotime($checkDate)));
- $yesterday = date('Y-m-d', strtotime("-1 days",strtotime($checkDate)));
- echo('
- <head>
- <meta charset="utf-8" />
- <link rel="stylesheet" type="text/css" href="css/bootstrap-theme.min.css" />
- <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
- <link rel="stylesheet" type="text/css" href="style.css" />
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
- <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
- <style>
- .tab{
- display:inline-block;
- }
- </style>
- </head>
- ');
- echo("<button class='btn orange wielkosc6' onclick='location.reload();'>Odśwież</button>");
- echo("<h1>Sprawdzam dzien:".$checkDate."</h1>");
- echo("<b><h3><div style='display:inline-block; margin-right: 7px;' onclick='before();'> <- </div>");
- echo("<div style='display:inline-block;' onclick='after();'> -> </div></h3></b>");
- if($dataQuery->num_rows<1){
- exit();
- }
- echo("
- <script>
- function after(){
- window.location.replace('/tabela.php?date=".$tommorow."');
- }
- function before(){
- window.location.replace('/tabela.php?date=".$yesterday."');
- }
- </script>
- ");
- echo("<div class='row'>");
- echo("<div class='center-block alert alert-primary ' style='margin-top:60px;' >");
- while($r = $dataQuery->fetch_assoc()){
- $placeName = $r['name'];
- $placeAddress = $r['address'];
- $placeId = $r['object_id'];
- $category = $r['category'];
- $testModel = getTestHourModel();
- echo("<div class='center-block marginek3 marginek4'>");
- echo("<div class=' row ' style='width: 200px; display: inline-block; margin:15px;'>");
- echo("<h2>".$placeName."</h2>");
- $actualDate = date("Y-m-d");
- $actualHour = date("H");
- foreach($testModel as $model){
- $arr = array($placeName,$placeAddress,$model->fromHour,$model->toHour,$checkDate,$placeId);
- $json = json_encode($arr);
- $jsondecoded = json_decode($json);
- $dw = date( "w", strtotime($_GET['date']));
- if(checkHourIsReserved($placeId,$jsondecoded[2],$checkDate)){
- echo("<div class='blue wolne marginek5' style='border: 1px solid white; margin: 0 0 0 0;font-weight: bold;text-align: center; '>".$jsondecoded[2].":00 - ".$jsondecoded[3].":00<br>".' WOLNE </div>');
- }else{
- $SQL = "select * from staticReservations where dayOfWeek=".$dw." and hour_from=".$jsondecoded[2]." and object_id=".$placeId.";";
- if($datax = $connection->query($SQL)){
- while($roww = $datax->fetch_assoc()){
- echo("<div class='zajete marginek5' style='border: 1px solid white; font-weight: bold;text-align: center; background-color: rgba(224,0,0,0.4);'>".$jsondecoded[2].":00 - ".$jsondecoded[3].":00<br><b>".' ('.$roww['teamName'].')</b></div>');
- }
- }
- $SQL = "select * from unregister_reservations where hour_from = ".$jsondecoded[2]." AND DATE = '".$checkDate."' and object_id=".$placeId." ;";
- if($datax = $connection->query($SQL)){
- while($roww = $datax->fetch_assoc()){
- echo("<div class='zajete marginek5' style='border: 1px solid white; font-weight: bold;text-align: center; background-color: rgba(224,0,0,0.4);'>".$jsondecoded[2].":00 - ".$jsondecoded[3].":00<br>".' ('.$roww['nickname'].') - niezarej</div>');
- }
- }
- $SQL = "SELECT *
- FROM
- reservation_details
- INNER JOIN
- reservations ON reservation_details.hour_from = ".$jsondecoded[2]."
- AND DATE =
- '".$checkDate."'
- AND
- reservation_details.detail_id = reservations.detail_id
- INNER JOIN
- users ON users.user_id = reservations.client_id
- LIMIT 1;";
- if($data = $connection->query($SQL)){
- if($data->num_rows==1){
- while($row = $data->fetch_assoc()){
- echo("<div class='zajete marginek5' style='border: 1px solid white; font-weight: bold;text-align: center; background-color: rgba(224,0,0,0.4);'>".$jsondecoded[2].":00 - ".$jsondecoded[3].":00 <br>".' ('.$row['login'].')'.$row['name'].' '.$row['surname'].' </div>');
- // echo($SQL);
- }
- }
- }
- }
- }
- echo("</div>");
- echo("</div>");
- }
- echo("</div></div>");
- function checkHourIsReserved($objectId,$hourFrom,$data){
- $SQL = 'SELECT * FROM reservation_details where object_id = '.$objectId.' AND hour_From = '.$hourFrom.' AND date = "'.$data.'";';
- $connection = new Database();
- $connection->connect();
- $dataQueryy = $connection->query($SQL);
- if($dataQueryy->num_rows>0){
- return false;
- }else{
- $SQL = 'SELECT * FROM unregister_reservations where object_id = '.$objectId.' AND hour_From = '.$hourFrom.' AND date = "'.$data.'";';
- $dataQueryy = $connection->query($SQL);
- if($dataQueryy->num_rows>0){
- return false;
- }
- else{
- $dw = date( "w", strtotime($data));
- $SQL = "select * from staticReservations where dayOfWeek=".$dw." and hour_from=".$hourFrom." and object_id=".$objectId.";";
- $dataQueryy = $connection->query($SQL);
- if($dataQueryy->num_rows>0){
- return false;
- }else{
- $SQL = "";
- return true;
- }
- }
- }
- }
- function getTestHourModel(){
- $hourModel = array();
- for($i = 7 ;$i<22;$i++){
- $hourModel[] = new HourModel($i,$i+1);
- }
- return $hourModel;
- }
- echo(' <script src="https://code.jquery.com/jquery-3.1.1.slim.min.js"
- integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous">
- </script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js"
- integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous">
- </script>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"
- integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous">
- </script>');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement