-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathauction.php
240 lines (212 loc) · 8.85 KB
/
auction.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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
<?php
include 'admin/configuration.php';
session_start();
if (!isset($_GET["id"])) {
include("404.php");
die;
}
?>
<!DOCTYPE html>
<html>
<head lang="en">
<?php
$Page_Title = "Δημοπρασία";
include 'head.php';
?>
<style>
.bidnumber {
font-size: 80px !important;
color: white !important;
text-shadow: -2px 0 orange, 0 2px orange, 2px 0 orange, 0 -2px orange !important;
text-align: center;
}
.bidheader {
text-align: center;
}
</style>
<script src="js/bid_scripts.js"></script>
</head>
<body onload="initFuncIntervals(<?php echo $_GET["id"] ?>)">
<?php
include 'header.php';
?>
<?php
try {
// SQL query to fetch
$con = db_connect();
$auctionDetailsStmt = "";
// <editor-fold defaultstate="collapsed" desc="Prepare and run statement">
// <editor-fold defaultstate="collapsed" desc="Error checking">
$auctionDetails = $con->prepare("
SELECT auction.Closed, auction.ID as auctionID, hotel.ID as hotelID, hotel.Name as hotelName, auction.Name as auctionName, auction.Description, PeopleCount, Closed, Bid_Price, Buy_Price, Hotel, Images, End_Date, Highest_Bidder, Tel
FROM auction, hotel WHERE hotel.ID=auction.Hotel AND auction.ID=?");
if (!$auctionDetails) {
throw new Exception("\nPrepared '" . $auctionDetailsStmt . "' statement failed. \nDetails: " . mysqli_error($con));
}
// </editor-fold>
$auctionDetails->bind_param('i', $_GET["id"]);
// <editor-fold defaultstate="collapsed" desc="Error checking">
if (!$auctionDetails->execute()) {
error_reporting("Execute error: \"" . $auctionDetailsStmt . "\"" . "\n");
error_reporting("Execute failed: (" . $auctionDetails->errno . ") " . $auctionDetails->error . "\"" . "\n");
throw new Exception("Statement failed to execute");
}
// </editor-fold>
$resulauctionDetails = $auctionDetails->get_result();
if (mysqli_num_rows($resulauctionDetails) != 1) {
throw new Exception("Wrong number of results");
}
// </editor-fold>
$auctionDetailsRow = mysqli_fetch_array($resulauctionDetails);
//$_SESSION["CurrentViewingAuctionBidPrice"]=$auctionDetailsRow["Bid_Price"];
} catch (Exception $e) {
error_reporting("##Error at " . __FILE__ . "\"\nDetails: " . $e->getMessage() . "\"" . "\n");
echo $e->getMessage() . "\n";
$errormessage = "<div class=\"col offset-s1 s10\">
<p class=\"col s12\">Κάτι πήγε στραβά </p></div>";
echo $errormessage;
}
$hotelGrade = $con->prepare("
SELECT avg(auction.GradeOfHotel) as Grade
FROM hotel, auction WHERE hotel.ID=? and auction.Hotel=hotel.id");
$hotelGrade->bind_param('i', $auctionDetailsRow["hotelID"]);
$hotelGrade->execute();
$resulthotelGrade = $hotelGrade->get_result();
$resultRowhotelGrade = mysqli_fetch_array($resulthotelGrade);
?>
<div class="parallax-container">
<div class="parallax"><img
src="<?php
$sql = $con->prepare("SELECT Images FROM auction WHERE ID=?");
$sql->bind_param('s', $_GET["id"]);
$sql->execute();
$result = $sql->get_result();
$resultRow = mysqli_fetch_array($result);
$split = explode(";", $resultRow["Images"]);
echo $split[0];
?>">
</div>
</div>
<div class="container">
<div class="section no-pad-bot" style="margin-top: -5%;">
<div class="row">
<div class="col offset-l2 l8 s12 white z-depth-3">
<div class="col l12 m8 s12">
<h4 class="grey-text darken-2 light"><?php echo $auctionDetailsRow["auctionName"]; ?></h4>
<p class="grey-text darken-3"><?php echo $auctionDetailsRow["Description"]; ?></p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col s12 m12 l4">
<ul class="collection">
<li class="collection-item avatar">
<i class="mdi-action-accessibility circle blue"></i>
<span class="title truncate">Αριθμός ατόμων</span>
<p>
<?php echo $auctionDetailsRow["PeopleCount"]; ?>
</p>
</li>
<li class="collection-item avatar">
<i class="mdi-communication-messenger circle orange"></i>
<span class="title truncate">Πληροφορίες ξενοδοχείου</span>
<p><a href="hotel.php?id=<?php echo $auctionDetailsRow["hotelID"]; ?>">
<?php echo $auctionDetailsRow["hotelName"]; ?>
</a>
</p>
</li>
<li class="collection-item avatar">
<i class="mdi-communication-phone circle green"></i>
<span class="title">Τηλέφωνο επικοινωνίας</span>
<p>
<?php echo $auctionDetailsRow["Tel"]; ?>
</p>
</li>
<li class="collection-item">
<?php
$starsNum = floor($resultRowhotelGrade["Grade"]);
for ($l = 0; $l < $starsNum; $l++) {
echo "<i class=\"mdi-action-star-rate circle amber accent-3\"></i>";
}
for ($l = 0; $l < 5 - $starsNum; $l++) {
echo "<i class=\"mdi-action-star-rate circle gray\"></i>";
}
?>
</li>
</ul>
</div>
<div class="col s12 m12 l8 center-align">
<div class="col s12 m6 l6 z-depth-1" style="padding: 10px; height: 200px;">
<h5 class="grey-text bidheader truncate">ΤΡΕΧΟΥΣΑ ΤΙΜΗ</h5>
<p class="bidnumber" id="parAuctionHighestBid">
<?php
if ($auctionDetailsRow["Highest_Bidder"] == null) {
echo $auctionDetailsRow["Bid_Price"];
}
?></p>
</div>
<?php
if (isRole("user") && $auctionDetailsRow["Closed"] == 0) {
?>
<div class="col s12 m6 l6 z-depth-1" style="padding: 10px; height: 200px;">
<h5 class="grey-text bidheader truncate">ΠΛΕΙΟΔΟΤΗΣΑΤΕ</h5>
<p class="bidnumber" id="LastUserBid"><?php
if ($auctionDetailsRow["Highest_Bidder"] != null) {
//include "bid/last_user_bid.php";
}
?></p>
</div>
<form id="auctionBidForm" method="Get">
<div class="col s12 m6 l6 z-depth-1" style="padding: 10px; height: 200px;">
<a class="btn waves-effect waves-light" onclick="userBid(<?php echo $_GET["id"]; ?>)"
name="action">Πλειοδοτησε
</a>
<input id="auctionUserBid" class="validate bidnumber" style="height: 90px; margin-top: 45px"
placeholder="" size="90" name="bid_value" type="text">
<input name="auctionID" style="display: none" value="<?php echo $_GET["id"]; ?>">
</div>
</form>
<?php
if ($auctionDetailsRow["Buy_Price"] != 0) {
?>
<form id="auctionBuyForm" method="Get">
<div class="col s12 m6 z-depth-1" style="padding: 10px; height: 190px;">
<a class="btn waves-effect waves-light" name="action"
onclick="auctionBuyNow(<?php echo $_GET["id"]; ?>)">Αγορασε τωρα</a>
<p class="bidnumber" id="BuyNowValue">
<?php echo $auctionDetailsRow["Buy_Price"]; ?>
</p>
</div>
<?php
}
?>
</form>
<?php
}
?>
</div>
</div>
<!--Slider-->
<?php
if (count($split) > 1) {
?>
<div class="slider col s8 offset-s2">
<ul class="slides">
<?php
for ($n = 0; $n < count($split); $n++) {
echo "<li><img src=\"$split[$n]\"></li>>";
}
?>
</ul>
</div>
<?php
}
?>
<!--Slider End-->
</div>
<?php
include 'footer.php';
?>
</body>
</html>