/
partneractivity.php
153 lines (110 loc) · 3.82 KB
/
partneractivity.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
<?php include 'session.php'; ?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
//include_once 'RotationUser.php';
include 'functions.php';
include 'checkloggedin.php';
include 'header.php';
?>
</head>
<body>
<div class="bg">
<?php
include 'navback.php';
$month = date('n');
$year = date('Y');
if(isset($_GET['month'])){
$month = $_GET['month'];
}
if(isset($_GET['year'])){
$year = $_GET['year'];
}
?>
<div class="container">
<?php
showPartnerActivity($month, $year);
?>
</div>
<?php
function checkFirstMonth(){
include 'connection.php';
$query = "SELECT * FROM partner_team_month_score ORDER BY -month DESC LIMIT 1";
$result = mysqli_query($link, $query);
if (!$result) {
printf("Error: %s\n", mysqli_error($link));
exit();
}
$row = mysqli_fetch_array($result);
return $row['month'];
}
function showPartnerActivity($month, $year){
include 'connection.php';
$teams = array("Blue", "Green", "Red", "Yellow");
echo '<h1>Partner Activity For '.monthText($month).'</h1>';
echo '<h6>This report shows how many checks, questions, observations each Partner has undertaken, listed in reverse order.</h6>';
// get array with employee number and activity
$countquery = "SELECT employee,COUNT(*) as count FROM partner_team_month_score
WHERE MONTH = ".$month." AND YEAR = 2018
GROUP BY employee ORDER BY count ASC";
$countresult = mysqli_query($link, $countquery);
while($data = mysqli_fetch_assoc($countresult)){
$activityCount[$data['employee']] = $data['count'];
}
foreach ($teams as $team) {
echo '<h4>'.$team.'</h4>';
echo '<div class="row">';
$query = "SELECT
e.employee,
e.firstname,
e.surname,
(SELECT
COUNT(*)
FROM partner_team_month_score s
WHERE s.employee = e.employee
AND s.year = ".$year."
AND s.month = ".$month.")
AS ScoreCount
FROM partners e
WHERE e.active = 1
AND e.team = '".$team."'
AND e.level = 10
ORDER BY ScoreCount ASC";
$result = mysqli_query($link, $query);
if (!$result) {
printf("Error: %s\n", mysqli_error($link));
exit();
}
while($row = mysqli_fetch_array($result)){
showPartnerAndCount($row['employee'],$row['ScoreCount']);
}
echo '</div>';
}
echo '<br>';
echo '<h6>Change Month</h6>';
// links for other months here
// ** TO DO ** I need a way of it passing one year to the next
$first = checkFirstMonth();
$current = date("n");
echo '<div class="row">';
for ($x = $current; $x >= $first; $x--) {
// only show if it's not the month current being shown
if($x != $month){
echo '<div class="col-sm-4">';
echo '<div class="lightGreenBox click">';
echo '<a href="partneractivity.php?month='.$x.'">'.monthText($x).'</a>';
echo '</div>';
echo '</div>';
}
}
echo '</div>';
}
include ('footer.php');
?>
</div>
</body>
</html>