-
Notifications
You must be signed in to change notification settings - Fork 1
/
admin-edit-room.php
160 lines (153 loc) · 5.67 KB
/
admin-edit-room.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?php
session_start();
if (!isset($_SESSION['is_admin'])) {
exit(header("Location:index.php"));
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php
$page_title = "Edit Room";
include "partials/header.php";
?>
</head>
<body>
<?php
$header_active_link = "about";
include "partials/navbar.php";
include "partials/notifications.php";
include "partials/db_connect.php";
?>
<div class="container">
<div class="row">
<div class="col-xs-12">
<h2 class="text-center">Edit Room</h2>
</div>
</div>
<?php
openDatabaseConnection();
$roomid = $_POST["roomid"];
$sql_room_data = "SELECT * FROM Room WHERE id=$roomid";
$result_room_data = mysqli_query($link, $sql_room_data);
if($result_room_data->num_rows > 0) {
while ($row_room_data = mysqli_fetch_assoc($result_room_data)) {
$fQuery = "SELECT feature FROM roomfeatures WHERE roomid=$roomid";
$fResult = mysqli_query($link, $fQuery);
$features = array();
while($featureArr = mysqli_fetch_assoc($fResult))
$features[] = $featureArr["feature"];
?>
<div class="row">
<div class="col-xs-12">
<form id="editRoomForm" action="api/admin/room.php" method="POST">
<input type="hidden" name="operation" value="edit">
<input type="hidden" name="roomid" value="<?=$roomid ?>">
<div class="row form-group">
<div class="col-xs-12 col-md-3">
<label for="roomName">Room Name</label>
<input type="text" class="form-control" id="roomName" name="room_name" placeholder="Room Name" autofocus="true" value="<?=$row_room_data["name"] ?>" required>
<div class="info"></div>
</div>
</div>
<div class="row form-group">
<div class="col-xs-12 col-md-3">
<label for="imagesInput">Select files to upload:</label>
<input type="file" id="imagesInput" name="files[]" multiple="multiple">
<p class="help-block"><span class="label label-info">Note:</span> Please, Select the only images (.jpg, .jpeg, .png, .gif) to upload with the size of 100KB only.</p>
</div>
</div>
<div class="row form-group">
<div class="col-xs-12 col-md-3">
<p>Check photos to keep: </p>
<?php
$path = "./img/".$row_room_data["img"];
$files = array_diff(scandir($path), array('.', '..', '.DS_Store'));
$counter = 1;
foreach($files as $key => $value) {
?>
<div class="checkbox">
<label>
<img src="<?=$path."/".$value ?>" width="100" height="100">
<input type="checkbox" id="img<?=$counter ?>" name="fileList[]" value="<?=$value ?>"> <?=$value ?>
</label>
</div>
<?php
$counter++;
}
?>
<input name="counterForOriginalFiles" type="hidden" value="<?=($counter-1) ?>">
</div>
</div>
<div class="row form-group">
<div class="col-xs-12 col-md-3">
<label for="price">Price/Night in Dollars($)</label>
<input type="number" class="form-control" id="price" name="price" placeholder="Price" value="<?=$row_room_data["price"] ?>" required>
<div class="info"></div>
</div>
</div>
<div class="row form-group">
<div class="col-xs-12 col-md-3">
<label for="numbeds">Number of Beds</label>
<input type="number" class="form-control" id="numbeds" name="numbeds" placeholder="Beds" value="<?=$row_room_data["numbeds"] ?>" required>
<div class="info"></div>
</div>
</div>
<div class="row form-group">
<div class="col-xs-12 col-md-3">
<label for="bedsize">Bed Size</label>
<select id="bedsize" name="bedsize" class="form-control" value="<?=$row_room_data["bedsize"] ?>">
<option value="Queen">Queen</option>
<option value="King">King</option>
<option value="Full">Full</option>
</select>
<div class="info"></div>
</div>
</div>
<div class="row form-group">
<div class="col-xs-12 col-md-3">
<label for="maxoccupants">Maximum Occupants</label>
<input type="number" class="form-control" id="maxoccupants" name="maxoccupants" placeholder="Max" value="<?=$row_room_data["maxoccupants"] ?>" required>
<div class="info"></div>
</div>
</div>
<div class="row form-group">
<div class="col-xs-12 col-md-3">
<input type="checkbox" id="wifi" name="wifi" <?php if(in_array("wifi", $features)) echo 'checked'; ?>/>
<label for="wifi">Wireless internet</label>
<br />
<input type="checkbox" id="tv" name="tv" <?php if(in_array("tv", $features)) echo 'checked'; ?>/>
<label for="tv">Premium TV channels</label>
<br />
<p>Smoking options:</p>
<input type="radio" name="smoking" value="nosmoking" <?php if(in_array("nosmoking", $features)) echo 'checked'; ?>/>
<label for="smoking">Non-smoking</label>
<br />
<input type="radio" name="smoking" value="smoking" <?php if(in_array("smoking", $features)) echo 'checked'; ?>/>
<label for="smoking">Smoking</label>
<br />
</div>
</div>
<div class="row form-group">
<div class="col-xs-12 col-md-3">
<label for="description">Description</label>
<textarea name="description" id="description" rows="8" class="form-control" required><?=$row_room_data["description"] ?></textarea>
<div class="info"></div>
</div>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</div>
<?php
}
}
closeDatabaseConnection();
?>
</div>
<?php
include "partials/footer.php";
?>
<script src="js/adminEditRoom.js"></script>
</body>
</html>