-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsquads.php
More file actions
131 lines (110 loc) · 5.15 KB
/
Copy pathsquads.php
File metadata and controls
131 lines (110 loc) · 5.15 KB
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
<?php
session_start();
require 'inc/connection.inc.php';
require 'inc/security.inc.php';
if (!isset($_SESSION['username'])) {
header('location: ' . $domain . '/message.php?id=badaccess');
die();
}
if(!squadViewAccess($connection,$currentUser,$memberValidation)) {
header( 'Location:' . $domain . 'message.php?id=badaccess' );
exit;
}
?>
<!DOCTYPE html>
<html lang="en-GB">
<head>
<?php include 'inc/meta.inc.php';?>
<title>Squads | Bucksburn Amateur Swimming Club</title>
<link href='https://fonts.googleapis.com/css?family=Bree+Serif' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Hind' rel='stylesheet' type='text/css'>
<link href="css/site.min.css" rel="stylesheet"/>
</head>
<body>
<?php include 'inc/header.inc.php'; ?>
<br>
<div class="row" id="content">
<div class="row-12 columns">
<ul class="breadcrumbs">
<li><a href="index.php" role="link">Home</a></li>
<li class="current">Squads</li>
</ul>
<h2>Squads</h2>
<?php
if (isset($_SESSION['delete'])) {
echo '<p class="alert-box success radius centre">Squad deleted successfully!</p>';
unset($_SESSION['delete']);
}
?>
<table class="large-12 medium-12 small-12 columns">
<tr>
<th>Squad Name</th>
<th>Squad Description</th>
<th>Coach</th>
<th>Number of Members</th>
<?php
if(squadFullAccess($connection,$currentUser,$memberValidation))
{
echo '<th>View Details</th>';
echo '<th>TimeSheets</th>';
}
?>
</tr>
<?php
require 'obj/squads.obj.php';
require_once 'obj/members.obj.php';
$conn = dbConnect();
$squadItem = new Squads();
$member = new Members();
if (!empty($_GET["txtSquad"])) {
$pSquad = "%" . strtolower($_GET["txtSquad"]) . "%";
} else {
$pSquad = "";
}
if (!empty($_GET["txtDescription"])) {
$pDescription = "%" . strtolower($_GET["txtDescription"]) . "%";
} else {
$pDescription = "";
}
if (!empty($_GET["sltCoach"])) {
$pCoach = "%" . strtolower($_GET["sltCoach"]) . "%";
} else {
$pCoach = "";
}
$squadsList = $squadItem->listAllSquadsWithParam($conn, $pSquad, $pDescription, $pCoach);
foreach ($squadsList as $squad) {
$squadItem->setID($squad["id"]);
$squadItem->getAllDetails($conn);
$member->setUsername($squadItem->getCoach());
//set hyperlink to point to member search with squadID parameter
$squadCoachLink = "members/view.php?u=" . $squadItem->getCoach();
$squadCountLink = "members.php?squadID=" . $squadItem->getID();
$squadViewLink = "squads/view.php?id=" . $squadItem->getID();
$squadTimeSheetLink = "squads/timesheet.php?squadID=" . $squadItem->getID();
echo "<tr>";
//If user has full access then display links
if(squadFullAccess($connection,$currentUser,$memberValidation)) {
echo '<td data-th="Squad">' . $squadItem->getSquad() . '</td>';
echo '<td data-th="Description">' . $squadItem->getDescription() . '</td>';
echo '<td data-th="Coach"><a href="'.$squadCoachLink.'">' . $member->getFullNameByUsername($conn) . '</a></td>';
echo '<td data-th="No. of Members"><a href="'.$squadCountLink.'">' . $squad["COUNT(*)"] . '</a></td>';
echo '<td class="none"><a href="' . $squadViewLink . '">View Details</a></td>';
echo '<td class="none"><a href="' . $squadTimeSheetLink . '">Squad Timesheet</a></td>';
}
else //otherwise display data only
{
echo '<td data-th="Squad">' . $squadItem->getSquad() . '</td>';
echo '<td data-th="Description">' . $squadItem->getDescription() . '</td>';
echo '<td data-th="Coach"> '. $member->getFullNameByUsername($conn) . '</td>';
echo '<td data-th="No. of Members">'.$squad["COUNT(*)"].'</td>';
}
echo "</tr>";
}
dbClose($conn);
?>
</table>
</div>
</div>
<?php include 'inc/footer.inc.php';?>
</body>
</html>