-
Notifications
You must be signed in to change notification settings - Fork 20
/
dashboard.php
413 lines (382 loc) · 15.2 KB
/
dashboard.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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
session_start();
if($_SESSION['status']=='loggedin')
{
?>
<!DOCTYPE html>
<html>
<head>
<title>Letstravel</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.7.1/css/bootstrap-datepicker3.css" rel="stylesheet" id="bootstrap-css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.2.13/dist/semantic.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.2.13/dist/semantic.min.css"/>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,500" rel="stylesheet">
<link rel="shortcut icon" href="images/favicon.png">
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="override.css">
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" type="text/css" href="admin.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<!--navbar-->
<div class="row" id="bar">
<div class="col-sm-10 heading" id="up">Letstravel</div>
<!--<div class="col-sm-2" id="log"><a id="logout" href="logout.php" name="logout_link">Logout</a></div>-->
<div class="col-sm-2" id="log">
<form action="dashboard.php" method="post">
<input type="submit" name="logout_link" value="Logout" id="logout">
</form>
<?php
if(isset($_POST['logout_link']))
{
session_start();
session_destroy();
header("Location: adminlogin.html");
}
?>
</div>
</div>
<!-- create trip Modal -->
<div id="createTripModal" class="modal">
<!-- Modal content -->
<div class="modal-content">
<form action="upload.php" method="POST" enctype="multipart/form-data">
<div style="margin-bottom: 6%;">
<span class="close" id="closeCreateTrip">×</span>
<label><h3 style="font-family: 'Montserrat', sans-serif;">Create trip</h3></label>
</div>
<div class="form-group row">
<label class="col-sm-4">Select Location</label>
<!--<i class="material-icons md-36 col-sm-1">location_on</i>-->
<div class="col-sm-6">
<select name="locs[]" multiple="" class="label ui selection fluid search dropdown" id="tripLocs" onChange="getLocs();">
<option value="">Select Locations</option>
<!--option value="Delhi">Delhi</option>
<option value="Mumbai">Mumbai</option>
<option value="Agra">Agra</option>
<option value="Chennai">Chennai</option>
<option value="Kolkata">Kolkata</option>
<option value="Goa">Goa</option>
<option value="Pune">Pune</option>
<option value="Bangalore">Bangalore</option>-->
<?php
$servername = 'localhost';
$username = 'root';
$password = '';
$db='letstravel';
$conn = mysqli_connect($servername,$username,$password,$db);
if (!$conn)
{
die("Connection failed: " . mysqli_connect_error());
}
$sql5="SELECT Name FROM cities";
$city = mysqli_query($conn,$sql5);
while ($row5=$city->fetch_assoc())
{
echo "<option value='".$row5['Name']."'>".$row5['Name']."</option>";
}
?>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-sm-4">Select Start Location</label>
<!--<i class="material-icons md-36 col-sm-1">location_on</i>-->
<div class="col-sm-6">
<select name="start" class="label ui selection fluid dropdown" id="start">
<option value="" disabled selected>Start Location</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-sm-4">Start Date</label>
<!--<i class="material-icons md-36 col-sm-1">date_range</i>-->
<div class="col-sm-5">
<div class='input-group date' id='datepicker'>
<input type='text' class="form-control" name="startDate" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
<div class="form-group row">
<label class="col-sm-4">End Date</label>
<!--<i class="material-icons md-36 col-sm-1">date_range</i>-->
<div class="col-sm-5">
<div class='input-group date' id='datepicker1'>
<input type='text' class="form-control" name="endDate" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
<div class="form-group row">
<label class="col-sm-4 ">Base Price</label>
<!--<i class="material-icons md-36 col-sm-1">attach_money</i>-->
<div class="col-sm-7">
<div class='input-group' >
<input type='text' class="form-control" placeholder="Base Price" name="basePrice" style="border-radius: 5px;" />
</div>
</div>
</div>
<div class="form-group row">
<label class="col-sm-4">Tour Guide Name</label>
<!--<i class="material-icons md-36 col-sm-1">person</i>-->
<div class="col-sm-7">
<div class='input-group'>
<input type='text' class="form-control" placeholder="Tour Guide Name" name="tgName" style="border-radius: 5px;" />
</div>
</div>
</div>
<div class="form-group row">
<label class="col-sm-4">Tour Guide Contact</label>
<!--<i class="material-icons md-36 col-sm-1">call</i>-->
<div class="col-sm-7">
<div class='input-group'>
<input type='text' class="form-control" placeholder="Tour Guide Contact" name="tgCont" style="border-radius: 5px;"/>
</div>
</div>
</div>
<div class="form-group row">
<label class="col-sm-4">Thumbnail</label>
<div class="col-sm-8">
<div class='input-group'>
<input class="upload" type="file" name="tn-uploaded">
</div>
</div>
</div>
<div class="form-group row">
<label class="col-sm-4 col-form-label">Itinerary</label>
<div class="col-sm-8">
<div class='input-group'>
<input class="upload" type="file" name="it-uploaded">
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="yellowBtn createBtn" name="create">Create Trip</button>
</div>
</form>
</div>
</div>
<!--modal ends-->
<div>
<div class="row mx-auto" id="cardsRow2">
<!--create trip card-->
<a href="#createTripModal" onclick="javascript:openCreateTripModal();">
<div class="col-sm-3">
<div class="createCard">
<div class="top">
<i class="material-icons add">add_circle_outline</i>
</div>
<div class="container">
<h4 class="card-title"><b>CREATE A NEW TRIP</b></h4>
</div>
</div>
</div>
</a>
<?php
$sql="SELECT * FROM trip WHERE Status=1;";
$result = mysqli_query($conn,$sql);
$rows = mysqli_num_rows($result);
for($i=0;$i<$rows;$i++)
{
$tripID = mysqli_fetch_assoc($result);
$sql2='SELECT locations from trip_location where tripId="'.$tripID["TripId"].'"';
$sql3='SELECT locations from trip_location where tripId="'.$tripID["TripId"].'" AND startLoc=1;';
$result2 = mysqli_query($conn,$sql2);
$rows2 = mysqli_num_rows($result2);
$temp = mysqli_fetch_assoc($result2);
$locs = $temp["locations"];
for($j=1;$j<$rows2;$j++)
{
$temp = mysqli_fetch_assoc($result2);
$locs=$locs." - ".$temp["locations"];
}
$result3 = mysqli_query($conn,$sql3);
$start = mysqli_fetch_assoc($result3);
$rows3 = mysqli_num_rows($result3);
$sloc = $start["locations"];
?>
<a href="#TripModal<?php echo $i;?>" onclick="javascript:openModal('<?php echo $i; ?>');" id="viewTripModal<?php echo $i;?>">
<div class="col-sm-3">
<div class="card">
<img class="card-img-top" src="uploads/<?php echo $tripID['Image']; ?>" alt="Avatar" style="width:100%">
<div class="card-body">
<h4 class="card-title"><b><?php echo $locs; ?></b></h4>
<p class="card-text">Starting from <?php echo $sloc; ?></p>
</div>
</div>
</div>
</a>
<!-- Trip Modal-->
<div id="TripModal<?php echo $i; ?>" class="modal">
<!--Modal content -->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"><?php echo $locs; ?></h4>
<button type="button" data-dismiss="modal" aria-label="Close" class="closeBtn">
<span aria-hidden="true" class="close" id="closeTrip<?php echo $i; ?>">×</span>
</button>
</div>
<div class="modal-body" id="carouselimg">
<img class="modal-img" src="uploads/<?php echo $tripID['Image']; ?>">
<div class="modalText">
<label><b>Date:</b><?php echo $tripID['StartDate']; ?> to <?php echo $tripID['EndDate']; ?></label><br>
<a href="uploads/<?php echo $tripID['Itinerary']; ?>" download class="downloadFile">Download itinerary</a><br>
<label><b>Base Price:</b> ₹<?php echo $tripID['BasePrice']; ?></label><br>
<label><b>Tour Guide Name:</b><?php echo $tripID["GuideName"]; ?></label><br>
<label><b>Tour guide Contact:</b><?php echo $tripID["GuideContact"]; ?></label>
</div>
</div>
<div class="modal-footer">
<form action="#" method="POST" enctype="multipart/form-data">
<button type="submit" class="yellowBtn delBtn" value="<?php echo $tripID["TripId"];?>" name="deleteTrip">Delete Trip</button>
<!--<input type="submit" value="<?php //echo $tripID["TripId"];?>" class="yellowBtn delBtn" name="deleteTrip">-->
</form>
</div>
</div>
</div>
<!--modal ends-->
<?php
}
?>
</div>
</div>
<script>
var tripModal;
var modal = document.getElementById('createTripModal');
var span = document.getElementById("closeCreateTrip");
var closeBtn="";
function openCreateTripModal()
{
modal.style.display="block";
}
function openModal(val)
{
tripModal = document.getElementById("TripModal"+val);
tripModal.style.display = "block";
closeBtn=document.getElementById("closeTrip"+val);
closeBtn.onclick=function()
{
tripModal.style.display="none";
}
}
span.onclick = function()
{
modal.style.display = "none";
}
window.onclick = function(event)
{
if (event.target == modal||event.target==tripModal)
{
modal.style.display = "none";
tripModal.style.display="none";
}
}
$(function ()
{
$('#datepicker').datepicker(
{
format: "yyyy/mm/dd",
autoclose: true,
//todayHighlight: true,
showOtherMonths: true,
selectOtherMonths: true,
autoclose: true,
changeMonth: true,
changeYear: true,
orientation: "button"
});
});
$(function ()
{
$('#datepicker1').datepicker(
{
format: "yyyy/mm/dd",
autoclose: true,
//todayHighlight: true,
showOtherMonths: true,
selectOtherMonths: true,
autoclose: true,
changeMonth: true,
changeYear: true,
orientation: "button"
});
});
$(function()
{
$('.label.ui.dropdown').dropdown({
maxSelections: 5
});
});
</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.7.1/js/bootstrap-datepicker.min.js"></script>
<script type="text/javascript" src="js/location.js"></script>
</body>
</html>
<?php
}
else
{
header("location:adminlogin.html");
}
if(isset($_POST['deleteTrip']))
{
$tripDel = $_POST['deleteTrip'];
$sqlx = 'UPDATE trip set Status = 0 where tripId="'.$tripDel.'"';
$resultx = mysqli_query($conn,$sqlx);
if($resultx == True)
{
echo "<script type='text/javascript'>alert('Trip Deleted Successfully'); window.location='dashboard.php'</script>";
$email = "shivanee.j@somaiya.edu"; //replace email
$sqlm="SELECT FirstName FROM user WHERE Email='".$email."'";
$fnamem = mysqli_query($conn,$sqlm);
$nameh = mysqli_fetch_assoc($fnamem);
$namem = $nameh['FirstName'];
$sql12='SELECT locations from trip_location where tripId="'.$tripDel.'"';
$result12 = mysqli_query($conn,$sql12);
$rows12 = mysqli_num_rows($result12);
$temp12 = mysqli_fetch_assoc($result12);
$locs12 = $temp12["locations"];
for($j=1;$j<$rows12;$j++)
{
$temp12 = mysqli_fetch_assoc($result12);
$locs12=$locs12." - ".$temp12["locations"];
}
require("C:/xampp/htdocs/Letstravel/PHPMailer/src/PHPMailer.php");
require("C:/xampp/htdocs/Letstravel/PHPMailer/src/SMTP.php");
require("C:/xampp/htdocs/Letstravel/PHPMailer/src/Exception.php");
$mail = new PHPMailer;
$mail->IsSMTP(); // enable SMTP
//$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->Host = "smtp.gmail.com";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = 'help.letstravel@gmail.com';
$mail->Password = 'help@LT123';
$mail->SetFrom("help.letstravel@gmail.com","Letstravel");
$mail->Subject = "Update On Your Trip With Letstravel";
$mail->Body = "Dear ".$namem.",<br>We regret to inform you that your trip to ".$locs12." was cancelled by our team due to some issues. We are extremely sorry for the inconvenience caused. <br> <br> You will recieve your refund within <b>7 working days</b>. In case of any disrepancy, please write to our team at <i>help@letstravel.com</i>.<br><br>-Best Regards, <br> <i>Team Letstravel</i>";
$mail->AddAddress($email); // Add recipients
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}
}
}
//mysqli_close($conn);
?>