-
Notifications
You must be signed in to change notification settings - Fork 0
/
return_room_occupacy.php
127 lines (106 loc) · 3.97 KB
/
return_room_occupacy.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="form_style.css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<title>return_room_occupacy</title>
<style>
table, td, th {
border: 1px solid black;
border-collapse: collapse;
}
td a {
width: 100%;
display: block;
}
th:first-child {
font-size: 1rem;
text-align: left;
}
th {
font-size: .8rem;
text-align: center;
}
td:first-child {
font-size: .8rem;
}
td, th {
width: 90px !important;
height: 50px !important;
}
.free_room {
background: lightgreen;
}
.occupaed_room {
background: ##dc143c;
text-align: center;
}
</style>
</head>
<body>
<div class="container">
<?php
session_start();
include 'const.php';
// Get data for room id and name/ TODO: need total rooms by type to remove something here!!!!!!!!
// $URL_FOR_CHECK = 'http://127.0.0.1:8080/api/configuration/RoomTypes?token=test1234';
// $curl = curl_init();
// curl_setopt($curl, CURLOPT_URL, $URL_FOR_CHECK);
// curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
// curl_setopt($curl, CURLOPT_HEADER, false);
// $data = curl_exec($curl);
// $data = json_decode($data);
// curl_close($curl);
// Get data for occupaed room by period
date_default_timezone_set('Europe/Sofia');
$datetime = new DateTime();
$array_assoc_search_for_free = array(
3=>[2, 'Апартамент Superior'],
4=>[1, 'Апартамент ВИП'],
6=>[2, 'Студио'],
7=>[1, 'Апартамент RО']
);
$URL_FOR_CHECK = $URL_FOR_CHECK;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $URL_FOR_CHECK);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
$data = curl_exec($curl);
$data = json_decode($data);
curl_close($curl);
echo "<table>";
echo "<tr>";
echo "<th>Дати</th>";
for($i=0;$i<=$HOW_DAY_TO_CHECK;$i++) {
$tomorow = date('d.m.Y', strtotime("now + " . $i ."day"));
echo "<th>$tomorow</th>";
}
echo "</tr>";
foreach($array_assoc_search_for_free as $room=>$room_value) {
echo "<tr>";
echo "<td>$room_value[1]</td>";
for($day=0;$day<=$HOW_DAY_TO_CHECK;$day++) {
$day_to_check = date('Y-m-d', strtotime("now + " . $day ."day"));
$return_in_table = "<td class='free_room'><a href='index.php?income=$day_to_check'><div style='width:1em; height:1em; display:inline-block'></div></a></td>";
for($i=0;$i<sizeof($data);$i++) {
if(
($data[$i]->roomTypeId == $room) &&
(explode('T', $data[$i]->date)[0] == $day_to_check) &&
($data[$i]->count - $array_assoc_search_for_free[$room][0]) == 0
) {
$return_in_table = "<td class='occupaed_room'>X</td>";
}
}
echo $return_in_table;
}
echo "</tr>";
}
echo "</table>";
?>
</div>
</body>
</html>