/
viewGarage.php
137 lines (129 loc) · 6.54 KB
/
viewGarage.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
<?php
/**
* Created by IntelliJ IDEA.
* User: rorypb
* Date: 01/12/2015
* Time: 12:17 PM
*/
require_once 'connection.php'; //connect to db
require_once 'garageTableGateway.php'; //connect to garagetable
require_once 'busTableGateway.php'; //connect to bus tbale
//if (!isset($_GET['id'])) {
// die("Halt");
//}
$id = $_GET['id']; //id has to be valid
$connection = Connection::getInstance(); //conenct to the db
$garageGateway = new garageTableGateway($connection); //for conenction to garage table
$busGateway = new busTableGateway($connection); //for connection to bus table
$garages = $garageGateway->getGarageById($id); //get garagebyid form garages
$bus = $busGateway->getBusByGarageId($id); //get busbygarageid from bus
//the garage selected will show all buses that is stored by that garage
//$row = $statement->fetch(PDO::FETCH_ASSOC);
//if (!$row) {
// die("Unable to get Garage By ID");
//}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>View Garage 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">
<?php require 'utilities/header.php'; ?>
<div class="row col-lg-12">
<h2>View Garage Details</h2>
<div class="row page-header">
<table class="table rpb-table">
<tbody>
<?php
$garage = $garages->fetch(PDO::FETCH_ASSOC);
echo '<tr>';
echo '<th>Address</th>'
. '<td>' . $garage['garageAddress'] . '</td>';
echo '</tr>';
echo '<tr>';
echo '<th>Phone</th>'
. '<td>' . $garage['phoneNo'] . '</td>';
echo '</tr>';
echo '<tr>';
echo '<th>Manager Name</th>'
. '<td>' . $garage['managerName'] . '</td>';
echo '</tr>';
echo '<th>Garage Name</th>'
. '<td>' . $garage['nameofGarage'] . '</td>';
echo '</tr>';
echo '<th>Garage Id</th>'
. '<td>' . $garage['garageID'] . '</td>';
echo '</tr>';
echo '<th>Date of Next Service</th>'
. '<td>' . $garage['dateService'] . '</td>';
echo '</tr>';
echo '<th>Manager Email</th>'
. '<td>' . $garage['managerEmail'] . '</td>';
echo '</tr>';
echo '<th>Garage URL</th>'
. '<td>' . $garage['garageURL'] . '</td>';
echo '</tr>';
echo '<th>Overnight</th>'
. '<td>' . $garage['overNight'] . '</td>';
echo '</tr>';
echo '<td>'
. '<a href="editgarageform.php?id=' . $row['garageID'] . '"><img src="icons/edit.png" height="30px" width="30px" style="margin: 3px;" /></a>'
. '<a class="deletebtn" href="deletegarage.php?id=' . $row['garageID'] . '"><img class="" src="icons/delete.png" height="30px" width="30px" style="margin: 3px;" /></a>'
?>
</tbody>
</table>
<div class="col-lg-10 col-lg-offset-1">
<h3>Buses Assigned to <?php echo $garage['nameofGarage']; ?></h3>
<?php if ($bus->rowCount() !== 0) { ?>
<table class="table table-height rpb-table">
<thead>
<tr>
<th>Bus ID</th>
<th>Registration</th>
<th>Make</th>
<th>Model</th>
<th>Engine Size</th>
<th>Garage Id</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
$row = $bus->fetch(PDO::FETCH_ASSOC);
while ($row) {
echo '<tr>';
echo '<td>' . $row['busID'] . '</td>';
echo '<td>' . $row['regNum'] . '</td>';
echo '<td>' . $row['busMake'] . '</td>';
echo '<td>' . $row['busModel'] . '</td>';
echo '<td>' . $row['engineSize'] . '</td>';
echo '<td>' . $row['garageID'] . '</td>';
echo '<td>'
. '<a href="viewBus.php?id=' . $row['busID'] . '"><img src="icons/view.png" height="30px" width="30px" style="margin: 3px;" /></a> '
. '<a href="editBusForm.php?id=' . $row['busID'] . '"><img src="icons/edit.png" height="30px" width="30px" style="margin: 3px;" /></a>'
. '<a class="deleteBus" href="deleteBus.php?id=' . $row['busID'] . '"><img class="" src="icons/delete.png" height="30px" width="30px" style="margin: 3px;" /></a> '
. '</td>';
echo '</tr>';
$row = $bus->fetch(PDO::FETCH_ASSOC);
}
?>
</tbody>
</table>
</div>
</div>
<?php } else { ?>
<p>There are no buses being stored in this garage.</p>
<?php } ?>
</div>
</div>
<div class="row">
<?php require 'utilities/footer.php'; ?>
</div>
</body>
</html>