-
Notifications
You must be signed in to change notification settings - Fork 11
/
spreadsheet.php
executable file
·238 lines (196 loc) · 8.31 KB
/
spreadsheet.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<?php
include_once 'directory.php';
$year = $_GET['year'];
$publisherPlatformID = $_GET['publisherPlatformID'];
$platformID = $_GET['platformID'];
$archiveInd = $_GET['archiveInd'];
$resourceType = $_GET['resourceType'];
if ($archiveInd == '1') {
$archive='Archive';
}else{
$archive='';
}
//determine config settings for outlier usage
$config = new Configuration();
$outlier = array();
$outlier[0]['color']='';
if ($config->settings->useOutliers == "Y"){
$outliers = new Outlier();
$outlierArray = array();
foreach($outliers->allAsArray as $outlierArray) {
$outlier[$outlierArray['outlierID']]['color'] = $outlierArray['color'];
}
}
if ($publisherPlatformID){
$obj = new PublisherPlatform(new NamedArguments(array('primaryKey' => $publisherPlatformID)));
}else if ($platformID){
$obj = new Platform(new NamedArguments(array('primaryKey' => $platformID)));
}
$display_name = $obj->reportDisplayName;
$excelfile = $display_name . "_" . $resourceType . "_" . $year;
$excelfile = str_replace (' ','_',$excelfile) . '.xls';
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=" . $excelfile);
?>
<html>
<head>
</head>
<body>
<h2> <?php echo $display_name . " " . $resourceType . " " . $archive . " - " . $year; ?> </h2>
<table border='1'>
<tr>
<th> </th>
<th>Publisher</th>
<th>Platform</th>
<?php if ($resourceType == "Journal"){ ?>
<th>DOI</th>
<th>Proprietary ID</th>
<th>Print ISSN</th>
<th>Online ISSN</th>
<th>YTD Total</th>
<th>YTD HTML</th>
<th>YTD PDF</th>
<th>Jan-<?php echo $year; ?></th>
<th>Feb-<?php echo $year; ?></th>
<th>Mar-<?php echo $year; ?></th>
<th>Apr-<?php echo $year; ?></th>
<th>May-<?php echo $year; ?></th>
<th>Jun-<?php echo $year; ?></th>
<th>Jul-<?php echo $year; ?></th>
<th>Aug-<?php echo $year; ?></th>
<th>Sep-<?php echo $year; ?></th>
<th>Oct-<?php echo $year; ?></th>
<th>Nov-<?php echo $year; ?></th>
<th>Dec-<?php echo $year; ?></th>
<?php } else if ($resourceType == "Book") {?>
<th>DOI</th>
<th>Proprietary ID</th>
<th>ISBN</th>
<th>ISSN</th>
<th>YTD Total</th>
<th>Jan-<?php echo $year; ?></th>
<th>Feb-<?php echo $year; ?></th>
<th>Mar-<?php echo $year; ?></th>
<th>Apr-<?php echo $year; ?></th>
<th>May-<?php echo $year; ?></th>
<th>Jun-<?php echo $year; ?></th>
<th>Jul-<?php echo $year; ?></th>
<th>Aug-<?php echo $year; ?></th>
<th>Sep-<?php echo $year; ?></th>
<th>Oct-<?php echo $year; ?></th>
<th>Nov-<?php echo $year; ?></th>
<th>Dec-<?php echo $year; ?></th>
<?php } else if ($resourceType == "Database") {?>
<th>User Activity</th>
<th>YTD Total</th>
<th>Jan-<?php echo $year; ?></th>
<th>Feb-<?php echo $year; ?></th>
<th>Mar-<?php echo $year; ?></th>
<th>Apr-<?php echo $year; ?></th>
<th>May-<?php echo $year; ?></th>
<th>Jun-<?php echo $year; ?></th>
<th>Jul-<?php echo $year; ?></th>
<th>Aug-<?php echo $year; ?></th>
<th>Sep-<?php echo $year; ?></th>
<th>Oct-<?php echo $year; ?></th>
<th>Nov-<?php echo $year; ?></th>
<th>Dec-<?php echo $year; ?></th>
<?php
}
echo "</tr>";
//Add a line for totals at top (to mimic counter compliant reports)
echo "<tr>";
if ($resourceType == 'Journal'){
echo "<td colspan = '7'><b>Total for all Journals</b></td>";
}else if ($resourceType == 'Book'){
echo "<td colspan = '7'><b>Total for all Books</b></td>";
}else if ($resourceType == 'Database'){
echo "<td colspan = '4'><b>Total for all Databases</b></td>";
}
//get ytd data if available
$totalArray = array();
$totalArray = $obj->getStatYearlyTotals($resourceType, $archiveInd, $year);
if (isset($totalArray['totalCount'])) $totalCount = $totalArray['totalCount']; else $totalCount = '';
if (isset($totalArray['ytdHTMLCount'])) $ytdHTMLCount = $totalArray['ytdHTMLCount']; else $ytdHTMLCount = '';
if (isset($totalArray['ytdPDFCount'])) $ytdPDFCount = $totalArray['ytdPDFCount']; else $ytdPDFCount = '';
if ($resourceType == 'Journal'){
echo "<td><b>" . $totalCount . "</b></td>";
echo "<td><b>" . $ytdHTMLCount . "</b></td>";
echo "<td><b>" . $ytdPDFCount . "</b></td>";
}else if (strpos($resourceType,'Book') == "1"){
echo "<td><b>" . $totalCount . "</b></td>";
}else{
echo "<td><b>" . $totalCount . "</b></td>";
}
$totalArray = array();
$totalArray = $obj->getStatMonthlyTotals($resourceType, $archiveInd, $year);
echo "<td><b>" . $totalArray['january'] . "</b></td>";
echo "<td><b>" . $totalArray['february'] . "</b></td>";
echo "<td><b>" . $totalArray['march'] . "</b></td>";
echo "<td><b>" . $totalArray['april'] . "</b></td>";
echo "<td><b>" . $totalArray['may'] . "</b></td>";
echo "<td><b>" . $totalArray['june'] . "</b></td>";
echo "<td><b>" . $totalArray['july'] . "</b></td>";
echo "<td><b>" . $totalArray['august'] . "</b></td>";
echo "<td><b>" . $totalArray['september'] . "</b></td>";
echo "<td><b>" . $totalArray['october'] . "</b></td>";
echo "<td><b>" . $totalArray['november'] . "</b></td>";
echo "<td><b>" . $totalArray['december'] . "</b></td>";
$titleStatArray = array();
foreach($obj->getMonthlyStats($resourceType, $archiveInd, $year) as $titleStatArray) {
$title = new Title(new NamedArguments(array('primaryKey' => $titleStatArray['titleID'])));
//get ytd data if available
$totalCount='';
$ytdHTMLCount='';
$ytdPDFCount='';
$titleYearlyStatArray = array();
foreach($title->getYearlyStats($archiveInd, $year, $titleStatArray['publisherPlatformID'], $titleStatArray['activityType']) as $titleYearlyStatArray) {
$totalCount = $titleYearlyStatArray['totalCount'];
$ytdHTMLCount = $titleYearlyStatArray['ytdHTMLCount'];
$ytdPDFCount = $titleYearlyStatArray['ytdPDFCount'];
}
if ($titleStatArray['mergeInd'] == "1") {
echo "<tr bgcolor='lightgrey'>";
}else{
echo "<tr>";
}
echo "<td>" . $titleStatArray['Title'] . "</td>";
echo "<td>" . $titleStatArray['Publisher'] . "</td>";
echo "<td>" . $titleStatArray['Platform'] . "</td>";
if ($resourceType == 'Journal'){
echo "<td>" . $title->getIdentifier('DOI') . "</td>";
echo "<td>" . $title->getIdentifier('Proprietary Identifier') . "</td>";
echo "<td>" . $title->getIdentifier('ISSN') . "</td>";
echo "<td>" . $title->getIdentifier('eISSN') . "</td>";
echo "<td>" . $totalCount . "</td>";
echo "<td>" . $ytdHTMLCount . "</td>";
echo "<td>" . $ytdPDFCount . "</td>";
}else if ($resourceType == 'Book'){
echo "<td>" . $title->getIdentifier('DOI') . "</td>";
echo "<td>" . $title->getIdentifier('Proprietary Identifier') . "</td>";
echo "<td>" . $title->getIdentifier('ISBN') . "</td>";
echo "<td>" . $title->getIdentifier('ISSN') . "</td>";
echo "<td>" . $totalCount . "</td>";
}else if ($resourceType == 'Database'){
echo "<td>" . $titleStatArray['activityType'] . "</td>";
echo "<td>" . $totalCount . "</td>";
}
echo "<td bgcolor='" . $outlier[$titleStatArray['january_outlier']]['color'] . "'>" . $titleStatArray['january'] . "</td>";
echo "<td bgcolor='" . $outlier[$titleStatArray['february_outlier']]['color'] . "'>" . $titleStatArray['february'] . "</td>";
echo "<td bgcolor='" . $outlier[$titleStatArray['march_outlier']]['color'] . "'>" . $titleStatArray['march'] . "</td>";
echo "<td bgcolor='" . $outlier[$titleStatArray['april_outlier']]['color'] . "'>" . $titleStatArray['april'] . "</td>";
echo "<td bgcolor='" . $outlier[$titleStatArray['may_outlier']]['color'] . "'>" . $titleStatArray['may'] . "</td>";
echo "<td bgcolor='" . $outlier[$titleStatArray['june_outlier']]['color'] . "'>" . $titleStatArray['june'] . "</td>";
echo "<td bgcolor='" . $outlier[$titleStatArray['july_outlier']]['color'] . "'>" . $titleStatArray['july'] . "</td>";
echo "<td bgcolor='" . $outlier[$titleStatArray['august_outlier']]['color'] . "'>" . $titleStatArray['august'] . "</td>";
echo "<td bgcolor='" . $outlier[$titleStatArray['september_outlier']]['color'] . "'>" . $titleStatArray['september'] . "</td>";
echo "<td bgcolor='" . $outlier[$titleStatArray['october_outlier']]['color'] . "'>" . $titleStatArray['october'] . "</td>";
echo "<td bgcolor='" . $outlier[$titleStatArray['november_outlier']]['color'] . "'>" . $titleStatArray['november'] . "</td>";
echo "<td bgcolor='" . $outlier[$titleStatArray['december_outlier']]['color'] . "'>" . $titleStatArray['december'] . "</td>";
echo "</tr>";
}
?>
</tr>
</table>
</body>
</html>