-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathschedules.php
executable file
·140 lines (129 loc) · 4.26 KB
/
schedules.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
<?php
include('manager/bd-access.php');
$access = new DBAccess;
session_start();
$post = $_POST;
if (!isset($_SESSION['source'])){
$_SESSION['source']=$post['source'];
$_SESSION['destination']=$post['destination'];
$_SESSION['date']= $post['date'];
}else{
if (isset($post['source'])){
$_SESSION['source']=$post['source'];
$_SESSION['destination']=$post['destination'];
$_SESSION['date']= $post['date'];
}
}
$source = $_SESSION['source'];
$destination = $_SESSION['destination'];
$date = $_SESSION['date'];
if(date('w', strtotime($date)) == 6 || date('w', strtotime($date)) == 0) {
$query = "SELECT * FROM rutas where origen = '$source' and destino = '$destination' and weekend = 1";
} else {
$query = "SELECT * FROM rutas where origen = '$source' and destino = '$destination' and weekday = 1";
}
$results = $access->select($query);
$date = new DateTime;
$date = $date->format('Y-m-d');
if(isset($_SESSION['loggedin'])){
$login = true;
}else{
$login = false;
}
if($_SESSION['wrongInfo']==true){
$wrongInfo = true;
}else{
$wrongInfo = false;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>NOPM | Autobuses de la Mayab</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" >
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="https://bootswatch.com/yeti/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
</head>
<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="index.php">Autobuses NOPM</a>
</div>
<?php if ($login): ?>
<ul class= "nav navbar-nav navbar-right">
<li>
<a> Se encuentra en una sesion </a>
</li>
<li>
<form class="navbar-form navbar-left" method="POST" action="destroySession.php">
</li>
</ul>
<button type="submit" class="btn btn-default">Cerrar Sesion</button>
</form>
<a href="history.php" role="button" class="btn btn-default">Mostrar Historial</a>
<?php else:?>
<form class="navbar-form navbar-left" method="POST" action="checkOnDB.php">
<div class="form-group">
<input type="email" class="form-control" placeholder="Email" name="username" required>
<input type="password" class="form-control" placeholder="Password" name="password" required>
</div>
<button type="submit" class="btn btn-default">Login</button>
</form>
<?php endif; ?>
</div>
</nav>
<?php if ($wrongInfo):?>
<div class="alert alert-danger">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong>Error!</strong> Email o Password Incorrecto
</div>
<?php endif;
$_SESSION['wrongInfo']=false;
?>
<table class="table table-hover">
<thead>
<tr>
<td>
<p>Ruta</p>
</td>
<td>
<p>Hora</p>
</td>
<td>
<p>Costo</p>
</td>
<td></td>
</tr>
</thead>
<tbody class="table table-hover">
<?php foreach ($results as $result): ?>
<tr>
<td><p><?php echo $result['origen'].' a '.$result['destino']; ?></p></td>
<td><p><?php echo $result['horario']; ?></p></td>
<td><p>$250</p></td>
<td>
<form action="purchase.php" method="POST">
<div class="form-group">
<input type="hidden" name="source" value=<?php echo $result['origen']; ?> >
<input type="hidden" name="destination" value=<?php echo $result['destino']; ?> >
<input type="hidden" name="hour" value=<?php echo $result['horario']; ?> >
<input type="hidden" name="date" value=<?php echo $date; ?> >
<input type="submit" class="btn btn-default" value="Seleccionar">
</div>
</form>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<div class="container">
<form action="index.php">
<input type="submit" class="btn btn-default" value="Cancelar">
</form>
</div>
</body>
</html>