forked from ndlibersa/usage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspreadsheet.php
More file actions
192 lines (141 loc) · 6.01 KB
/
spreadsheet.php
File metadata and controls
192 lines (141 loc) · 6.01 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
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
<?php
include_once 'directory.php';
$year = $_GET['year'];
$publisherPlatformID = $_GET['publisherPlatformID'];
$platformID = $_GET['platformID'];
$archiveInd = $_GET['archiveInd'];
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 . "_" . $year;
$excelfile = str_replace (' ','_',$excelfile);
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename='" . $excelfile . "'");
?>
<html>
<head>
</head>
<body>
<h2><?php echo $display_name . " " . $archive . " - " . $year; ?></h2>
<table border='1'>
<tr>
<th> </th>
<th>Publisher</th>
<th>Platform</th>
<th>Print ISSN</th>
<th>Online ISSN</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>
<th>YTD Total</th>
<th>YTD HTML</th>
<th>YTD PDF</th>
</tr>
<?php
//Add a line for totals at top (to mimic counter compliant reports)
$totalArray = array();
$totalArray = $obj->getStatMonthlyTotals($archiveInd, $year);
?>
<tr>
<td><b>Total for all journals</b></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<?php
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>";
//get ytd data if available
$totalArray = array();
$totalArray = $obj->getStatYearlyTotals($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 = '';
echo "<td><b>" . $totalCount . "</b></td>";
echo "<td><b>" . $ytdHTMLCount . "</b></td>";
echo "<td><b>" . $ytdPDFCount . "</b></td>";
$titleStatArray = array();
foreach($obj->getMonthlyStats($archiveInd, $year) as $titleStatArray) {
$title = new Title(new NamedArguments(array('primaryKey' => $titleStatArray['titleID'])));
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>";
//get print issn
echo "<td>" . $title->getPrintISSN() . "</td>";
//get online issn
echo "<td>" . $title->getOnlineISSN() . "</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>";
//get ytd data if available
$totalCount='';
$ytdHTMLCount='';
$ytdPDFCount='';
$titleYearlyStatArray = array();
foreach($title->getYearlyStats($archiveInd, $year, $titleStatArray['publisherPlatformID']) as $titleYearlyStatArray) {
$totalCount = $titleYearlyStatArray['totalCount'];
$ytdHTMLCount = $titleYearlyStatArray['ytdHTMLCount'];
$ytdPDFCount = $titleYearlyStatArray['ytdPDFCount'];
}
echo "<td>" . $totalCount . "</td>";
echo "<td>" . $ytdHTMLCount . "</td>";
echo "<td>" . $ytdPDFCount . "</td>";
echo "</tr>";
}
?>
</tr>
</table>
</body>
</html>