/
viewBus.php
139 lines (127 loc) · 6.35 KB
/
viewBus.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
<?php
/**
* Created by IntelliJ IDEA.
* User: rorypb
*/
require_once 'connection.php'; //for connection to db
require_once 'garageTableGateway.php'; //connecting to garage tbal
require_once 'busTableGateway.php'; //connection to bus tbale
if (!isset($_GET['id'])) { //oif the id is not one from the db
die("Halt"); //die
}
$id = $_GET['id']; //get the id from the databae
$connection = Connection::getInstance(); //connect to the db
$garageGateway = new garageTableGateway($connection); //connect to the garage table
$busGateway = new busTableGateway($connection); //connect to the bus table
$garages = $garageGateway->getGarageByGarageId($id); //garage table get garageby id
$buses = $busGateway->getBusByID($id); //bus table get bus by id
//used in conjunction to view the garage that hioues that bus
//$row = $statement->fetch(PDO::FETCH_ASSOC);
//if (!$row) {
// die("Unable to get Bus By ID");
//}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>View Bus by Id</title>
<!--all styles and scripts will be contained in these php scripts-->
<?php require 'utilities/styles.php'; ?>
<?php require 'utilities/scripts.php'; ?>
</head>
<body>
<div class="container-fluid">
<div class="row">
<?php require 'utilities/header.php'; ?>
</div>
<div class="row page-header home_content">
<h2>View Bus Details</h2>
<table class="table rpb-table">
<tbody>
<?php
$bus = $buses->fetch(PDO::FETCH_ASSOC);
echo '<tr>';
echo '<th>Bus ID</th>'
. '<td>' . $bus['busID'] . '</td>';
echo '</tr>';
echo '<tr>';
echo '<th>Registration Number</th>'
. '<td>' . $bus['regNum'] . '</td>';
echo '</tr>';
echo '<tr>';
echo '<th>Bus Make</th>'
. '<td>' . $bus['busMake'] . '</td>';
echo '</tr>';
echo '<th>Bus Model</th>'
. '<td>' . $bus['busModel'] . '</td>';
echo '</tr>';
echo '<th>Engine Size</th>'
. '<td>' . $bus['engineSize'] . '</td>';
echo '</tr>';
echo '<th>Date Purchase</th>'
. '<td>' . $bus['dateBought'] . '</td>';
echo '</tr>';
echo '</tr>';
echo '<th>Date Next Service</th>'
. '<td>' . $bus['dateNextService'] . '</td>';
echo '</tr>';
echo '<th>Garage ID</th>'
. '<td>' . $bus['garageID'] . '</td>';
echo '</tr>';
echo '<td>'
. '<a href="editbusform.php?id=' . $bus['busID'] . '"><img src="icons/edit.png" height="40px" width="40px" style="margin: 3px;" /></a>'
. '<a class="deletebtn" href="deletebus.php?id=' . $bus['busID'] . '"><img class="" src="icons/delete.png" height="40px" width="40px" style="margin: 3px;" /></a>'
?>
</tbody>
</table>
<div class="">
<h3>Bus Assigned to Selected Garage = <?php echo $bus['busID']; ?></h3>
<?php if ($garages->rowCount() !== 0) { ?>
<table class="table table-height rpb-table">
<thead>
<tr>
<th>Garage Address</th>
<th>Phone Number</th>
<th>Manager Name</th>
<th>Garage Name</th>
<th>Garage Id</th>
<th>Service Date</th>
<th>Manager Email</th>
<th>Garage URL</th>
<th>Over Night</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
$row = $garages->fetch(PDO::FETCH_ASSOC);
while ($row) {
echo '<tr>';
echo '<td>' . $row['garageAddress'] . '</td>';
echo '<td>' . $row['phoneNo'] . '</td>';
echo '<td>' . $row['managerName'] . '</td>';
echo '<td>' . $row['nameofGarage'] . '</td>';
echo '<td>' . $row['garageID'] . '</td>';
echo '<td>' . $row['dateService'] . '</td>';
echo '<td>' . $row['managerEmail'] . '</td>';
echo '<td>' . $row['garageURL'] . '</td>';
echo '<td>' . $row['overNight'] . '</td>';
echo '<td>'
. '<a href="viewGarage.php?id=' . $row['garageID'] . '"><img src="icons/view.png" height="30px" width="30px" style="margin: 3px;" /></a> '
. '<a href="editgarageform.php?id=' . $row['garageID'] . '"><img src="icons/edit.png" height="30px" width="30px" style="margin: 3px;" /></a>'
. '<a class="deleteGarage" href="deletegarage.php?id=' . $row['garageID'] . '"><img class="" src="icons/delete.png" height="30px" width="30px" style="margin: 3px;" /></a> '
. '</td>';
echo '</tr>';
$row = $garages->fetch(PDO::FETCH_ASSOC);
}
}
?>
</tbody>
</table>
</div>
</div>
</div>
<?php require 'utilities/footer.php'; ?>
</body>
</html>