Line 0
Link Here
|
|
|
1 |
package C4::DashBoard; |
2 |
|
3 |
# Copyright 2000-2002 Katipo Communications |
4 |
# |
5 |
# This file is part of Koha. |
6 |
# |
7 |
# Koha is free software; you can redistribute it and/or modify it under the |
8 |
# terms of the GNU General Public License as published by the Free Software |
9 |
# Foundation; either version 2 of the License, or (at your option) any later |
10 |
# version. |
11 |
# |
12 |
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
13 |
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
14 |
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
15 |
# |
16 |
# You should have received a copy of the GNU General Public License along |
17 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
18 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 |
# |
20 |
|
21 |
use strict; |
22 |
use warnings; |
23 |
use C4::Context; |
24 |
|
25 |
use vars qw($VERSION @ISA @EXPORT); |
26 |
|
27 |
BEGIN { |
28 |
$VERSION = 3.01; |
29 |
@ISA = qw(Exporter); |
30 |
@EXPORT = qw(&number_of_items_library_xml &number_of_borrowers_library_xml &number_of_issues_library_xml &number_of_biblios_xml &number_of_loan_history_system_xml |
31 |
&number_of_overdues_library_xml &number_of_biblios_7days_xml &number_of_items_7days_system_xml &number_of_overdues_7days_library_xml |
32 |
&number_of_borrowers_system_xml &number_of_items_system_xml &number_of_items_7days_library_xml &number_of_overdues_system_xml |
33 |
&number_of_overdues_14days_library_xml &number_of_overdues_21days_library_xml &number_of_veryoverdue_library_xml &expired_borrowers_library_xml |
34 |
&expired_borrowers_system_xml &number_of_issues_system_xml &number_of_loan_history_library_xml &number_of_overdues_7days_system_xml |
35 |
&number_of_overdues_14days_system_xml &number_of_overdues_21days_system_xml &number_of_veryoverdue_system_xml &last_update_xml |
36 |
); |
37 |
} |
38 |
|
39 |
|
40 |
sub number_of_items_library_xml { |
41 |
my $dbh = C4::Context->dbh; |
42 |
my $items = $dbh->selectall_arrayref ('select branches.branchcode as BranchCode, IFNULL(SubTotal.items,0) as NumberOfItems |
43 |
from branches |
44 |
left join |
45 |
(select homebranch, count(*) as Items |
46 |
from items |
47 |
group by homebranch) SubTotal |
48 |
on branches.branchcode=SubTotal.homebranch',{ Columns => {} }); |
49 |
$dbh->disconnect(); |
50 |
return $items; |
51 |
|
52 |
} |
53 |
|
54 |
sub number_of_items_system_xml { |
55 |
my $dbh = C4::Context->dbh; |
56 |
my $items_system = $dbh->selectall_arrayref('select count(*) as NumberOfItemsSystem from items', {Columns => {} }); |
57 |
$dbh->disconnect; |
58 |
return $items_system; |
59 |
|
60 |
} |
61 |
|
62 |
sub number_of_borrowers_library_xml { |
63 |
my $dbh = C4::Context->dbh; |
64 |
my $borrowers = $dbh->selectall_arrayref ('select branches.branchcode as BranchCode, IFNULL(SubTotal.Borrowers,0) as NumberOfBorrowers |
65 |
from branches |
66 |
left join |
67 |
(select branchcode, count(*) as Borrowers |
68 |
from borrowers |
69 |
group by branchcode) SubTotal |
70 |
on branches.branchcode=SubTotal.branchcode',{ Columns => {} }); |
71 |
$dbh->disconnect; |
72 |
return $borrowers; |
73 |
|
74 |
} |
75 |
|
76 |
sub number_of_borrowers_system_xml { |
77 |
my $dbh = C4::Context->dbh; |
78 |
my $number_of_borrowers_system = $dbh->selectall_arrayref('select count(*) as NumberofBorrowersSystem |
79 |
from borrowers',{ Columns => {} } ); |
80 |
$dbh->disconnect; |
81 |
return $number_of_borrowers_system; |
82 |
|
83 |
} |
84 |
|
85 |
sub number_of_issues_library_xml { |
86 |
my $dbh = C4::Context->dbh; |
87 |
my $issues_library = $dbh->selectall_arrayref('select branches.branchcode as BranchCode, IFNULL(SubTotal.issues,0) as NumberOfIssues |
88 |
from branches |
89 |
left join |
90 |
(select branchcode, count(*) as Issues |
91 |
from issues |
92 |
group by branchcode) SubTotal |
93 |
on branches.branchcode=SubTotal.branchcode',{ Columns => {} }); |
94 |
$dbh->disconnect(); |
95 |
return $issues_library; |
96 |
|
97 |
} |
98 |
|
99 |
sub number_of_issues_system_xml { |
100 |
my $dbh = C4::Context->dbh; |
101 |
my $issues_system = $dbh->selectall_arrayref('select count(*) as NumberOfIssuesSystem |
102 |
from issues',{Columns => {}}); |
103 |
$dbh->disconnect; |
104 |
return $issues_system; |
105 |
|
106 |
} |
107 |
|
108 |
sub number_of_biblios_xml { |
109 |
my $dbh = C4::Context->dbh; |
110 |
my $biblios = $dbh->selectall_arrayref('select count(*) as NumberOfBiblios from biblio',{ Columns => {} } ); |
111 |
$dbh->disconnect; |
112 |
return $biblios; |
113 |
|
114 |
} |
115 |
|
116 |
sub number_of_loan_history_system_xml { |
117 |
my $dbh = C4::Context->dbh; |
118 |
my $loan_history = $dbh->selectall_arrayref('select count(*) as NumberOfLoans from old_issues', { Columns => {} }); |
119 |
$dbh->disconnect; |
120 |
return $loan_history; |
121 |
|
122 |
} |
123 |
|
124 |
sub number_of_loan_history_library_xml { |
125 |
my $dbh = C4::Context->dbh; |
126 |
my $loan_history_library = $dbh->selectall_arrayref('select branches.branchcode as BranchCode, IFNULL(SubTotal.oldissues,0) as NumberOfLoans |
127 |
from branches |
128 |
left join |
129 |
(select branchcode, count(*) as OldIssues |
130 |
from old_issues |
131 |
group by branchcode) SubTotal |
132 |
on branches.branchcode=SubTotal.branchcode', {Columns => {}} ); |
133 |
$dbh->disconnect; |
134 |
return $loan_history_library; |
135 |
|
136 |
} |
137 |
|
138 |
sub number_of_overdues_library_xml { |
139 |
my $dbh = C4::Context->dbh; |
140 |
my $overdues_library = $dbh->selectall_arrayref('select branches.branchcode as BranchCode, IFNULL(SubTotal.Overdues,0) as NumberOfOverdues |
141 |
from branches |
142 |
left join |
143 |
(select branchcode, count(*) as Overdues |
144 |
from issues |
145 |
where date_due < date(now()) |
146 |
group by branchcode) SubTotal |
147 |
on branches.branchcode=SubTotal.branchcode', {Columns => {} }); |
148 |
$dbh->disconnect; |
149 |
return $overdues_library; |
150 |
|
151 |
} |
152 |
|
153 |
sub number_of_overdues_system_xml { |
154 |
my $dbh = C4::Context->dbh; |
155 |
my $overdues_system = $dbh->selectall_arrayref('select count(*) as NumberOfOverdues |
156 |
from issues |
157 |
where date_due < date(now())',{Columns => {}} ); |
158 |
$dbh->disconnect; |
159 |
return $overdues_system; |
160 |
|
161 |
} |
162 |
|
163 |
sub number_of_overdues_7days_library_xml { |
164 |
my $dbh = C4::Context->dbh; |
165 |
my $overdues_library_7days = $dbh->selectall_arrayref('select branches.branchcode as BranchCode, IFNULL(SubTotal.Overdues,0) as NumberOfOverdues7Days |
166 |
from branches |
167 |
left join |
168 |
(select branchcode, count(*) as Overdues |
169 |
from issues |
170 |
where date_due between DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND DATE_SUB(CURDATE(), INTERVAL 1 DAY) |
171 |
group by branchcode) SubTotal |
172 |
on branches.branchcode=SubTotal.branchcode', {Columns => {} }); |
173 |
$dbh->disconnect; |
174 |
return $overdues_library_7days; |
175 |
|
176 |
} |
177 |
|
178 |
sub number_of_overdues_7days_system_xml { |
179 |
my $dbh = C4::Context->dbh; |
180 |
my $overdues_7days_system = $dbh->selectall_arrayref('select count(*) as NumberOfOverdues |
181 |
from issues |
182 |
where date_due |
183 |
between DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND DATE_SUB(CURDATE(), INTERVAL 1 DAY)', {Columns => {}} ); |
184 |
return $overdues_7days_system; |
185 |
|
186 |
} |
187 |
|
188 |
sub number_of_overdues_14days_library_xml { |
189 |
my $dbh = C4::Context->dbh; |
190 |
my $overdues_14days = $dbh->selectall_arrayref('select branches.branchcode as BranchCode, IFNULL(SubTotal.Overdues,0) as NumberOfOverdues14Days |
191 |
from branches |
192 |
left join |
193 |
(select branchcode, count(*) as Overdues |
194 |
from issues |
195 |
where date_due |
196 |
between DATE_SUB(CURDATE(), INTERVAL 14 DAY) AND DATE_SUB(CURDATE(), INTERVAL 8 DAY) |
197 |
group by branchcode) SubTotal |
198 |
on branches.branchcode=SubTotal.branchcode', {Columns => {} }); |
199 |
$dbh->disconnect; |
200 |
return $overdues_14days; |
201 |
|
202 |
} |
203 |
|
204 |
sub number_of_overdues_14days_system_xml { |
205 |
my $dbh = C4::Context->dbh; |
206 |
my $overdues_14days_system = $dbh->selectall_arrayref('select count(*) as NumberOfOverdues14Days |
207 |
from issues |
208 |
where date_due |
209 |
between DATE_SUB(CURDATE(), INTERVAL 14 DAY) AND DATE_SUB(CURDATE(), INTERVAL 8 DAY)', {Columns => {}} ); |
210 |
$dbh->disconnect; |
211 |
return $overdues_14days_system; |
212 |
|
213 |
} |
214 |
|
215 |
sub number_of_overdues_21days_library_xml { |
216 |
my $dbh = C4::Context->dbh; |
217 |
my $overdues_21days_library = $dbh->selectall_arrayref('select branches.branchcode as BranchCode, IFNULL(SubTotal.Overdues,0) as NumberOfOverdues21Days |
218 |
from branches |
219 |
left join |
220 |
(select branchcode, count(*) as Overdues |
221 |
from issues |
222 |
where date_due between DATE_SUB(CURDATE(), INTERVAL 21 DAY) AND DATE_SUB(CURDATE(), INTERVAL 15 DAY) |
223 |
group by branchcode) SubTotal |
224 |
on branches.branchcode=SubTotal.branchcode', {Columns => {} }); |
225 |
$dbh->disconnect; |
226 |
return $overdues_21days_library; |
227 |
|
228 |
} |
229 |
|
230 |
sub number_of_overdues_21days_system_xml { |
231 |
my $dbh = C4::Context->dbh; |
232 |
my $overdues_21days_system = $dbh->selectall_arrayref('select count(*) as NumberOfOverdues21Days |
233 |
from issues |
234 |
where date_due between DATE_SUB(CURDATE(), INTERVAL 21 DAY) AND DATE_SUB(CURDATE(), INTERVAL 15 DAY)' |
235 |
, {Columns => {} }); |
236 |
return $overdues_21days_system; |
237 |
|
238 |
} |
239 |
|
240 |
sub number_of_veryoverdue_library_xml { |
241 |
my $dbh = C4::Context->dbh; |
242 |
my $very_overdue_library = $dbh->selectall_arrayref('select branches.branchcode as BranchCode, IFNULL(SubTotal.Overdues,0) as NumberOfVeryOverdue |
243 |
from branches |
244 |
left join |
245 |
(select branchcode, count(*) as Overdues |
246 |
from issues |
247 |
where date_due < DATE_SUB(CURDATE(), INTERVAL 22 DAY) |
248 |
group by branchcode) SubTotal |
249 |
on branches.branchcode=SubTotal.branchcode', {Columns => {} }); |
250 |
$dbh->disconnect; |
251 |
return $very_overdue_library; |
252 |
|
253 |
} |
254 |
|
255 |
sub number_of_veryoverdue_system_xml { |
256 |
my $dbh = C4::Context->dbh; |
257 |
my $very_overdue_system = $dbh->selectall_arrayref('select count(*) as Overdues |
258 |
from issues |
259 |
where date_due < DATE_SUB(CURDATE(), INTERVAL 22 DAY)' ,{Columns => {} }); |
260 |
$dbh->disconnect; |
261 |
return $very_overdue_system; |
262 |
|
263 |
} |
264 |
|
265 |
|
266 |
sub number_of_biblios_7days_xml { |
267 |
my $dbh = C4::Context->dbh; |
268 |
my $biblio_7days = $dbh->selectall_arrayref('SELECT count(*) as NumberOfBiblio7Days |
269 |
FROM biblio |
270 |
WHERE datecreated |
271 |
between DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND CURDATE()', {Columns => {} } ); |
272 |
$dbh->disconnect; |
273 |
return $biblio_7days; |
274 |
|
275 |
} |
276 |
|
277 |
sub number_of_items_7days_system_xml { |
278 |
my $dbh = C4::Context->dbh; |
279 |
my $items_7days_system = $dbh->selectall_arrayref('SELECT count(*) as NumberOfItems7Days |
280 |
FROM items |
281 |
WHERE dateaccessioned |
282 |
between DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND CURDATE()',{Columns =>{} } ); |
283 |
$dbh->disconnect; |
284 |
return $items_7days_system; |
285 |
|
286 |
} |
287 |
|
288 |
sub number_of_items_7days_library_xml { |
289 |
my $dbh = C4::Context->dbh; |
290 |
my $items_7days_library = $dbh->selectall_arrayref('select branches.branchcode as BranchCode, IFNULL(SubTotal.items,0) as NumberOfItems7DaysLibrary |
291 |
from branches |
292 |
left join |
293 |
(select homebranch, count(*) as Items |
294 |
from items |
295 |
where dateaccessioned > DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND CURDATE() |
296 |
group by homebranch) SubTotal |
297 |
on branches.branchcode=SubTotal.homebranch', {Columns => {} }); |
298 |
$dbh->disconnect; |
299 |
return $items_7days_library; |
300 |
|
301 |
} |
302 |
|
303 |
sub expired_borrowers_library_xml { |
304 |
my $dbh = C4::Context->dbh; |
305 |
my $expired_borrowers_library = $dbh->selectall_arrayref('select branches.branchcode as BranchCode, IFNULL(SubTotal.ExpiredBorrowers,0) as ExpiredBorrowers |
306 |
from branches |
307 |
left join |
308 |
(select branchcode, count(*) as ExpiredBorrowers |
309 |
from borrowers |
310 |
where dateexpiry < date(now()) |
311 |
group by branchcode) SubTotal |
312 |
on branches.branchcode=SubTotal.branchcode;',{Columns => {} } ); |
313 |
$dbh->disconnect; |
314 |
return $expired_borrowers_library; |
315 |
|
316 |
} |
317 |
|
318 |
sub expired_borrowers_system_xml { |
319 |
my $dbh = C4::Context->dbh; |
320 |
my $expired_borrowers_system = $dbh->selectall_arrayref('select count(*) as ExpiredBorrowers |
321 |
from borrowers |
322 |
where dateexpiry < date(now())', {Columns => {} }); |
323 |
$dbh->disconnect; |
324 |
return $expired_borrowers_system; |
325 |
|
326 |
} |
327 |
|
328 |
sub last_update_xml { |
329 |
my $dbh = C4::Context->dbh; |
330 |
my $updated = $dbh->selectall_arrayref('SELECT DATE_FORMAT(now(), "%W %M %D %Y %T") as UpdatedTime', |
331 |
{Columns => {} }); |
332 |
$dbh->disconnect; |
333 |
return $updated; |
334 |
|
335 |
} |
336 |
|
337 |
1; |
338 |
__END__ |