View | Details | Raw Unified | Return to bug 6828
Collapse All | Expand All

(-)a/C4/Auth.pm (-1 / +2 lines)
Lines 389-395 sub get_template_and_user { Link Here
389
            virtualshelves              => C4::Context->preference("virtualshelves"),
389
            virtualshelves              => C4::Context->preference("virtualshelves"),
390
            StaffSerialIssueDisplayCount => C4::Context->preference("StaffSerialIssueDisplayCount"),
390
            StaffSerialIssueDisplayCount => C4::Context->preference("StaffSerialIssueDisplayCount"),
391
            NoZebra                     => C4::Context->preference('NoZebra'),
391
            NoZebra                     => C4::Context->preference('NoZebra'),
392
		EasyAnalyticalRecords => C4::Context->preference('EasyAnalyticalRecords'),
392
            EasyAnalyticalRecords => C4::Context->preference('EasyAnalyticalRecords'),
393
	    DashBoardDisplayed          => C4::Context->preference('DashBoardDisplayed')
393
        );
394
        );
394
    }
395
    }
395
    else {
396
    else {
(-)a/C4/DashBoard.pm (+341 lines)
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
use C4::Dates qw(format_date);
25
26
use vars qw($VERSION @ISA @EXPORT);
27
28
BEGIN { 
29
	$VERSION = 3.01;	
30
	@ISA = qw(Exporter);
31
	@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 
32
                     &number_of_overdues_library_xml &number_of_biblios_7days_xml &number_of_items_7days_system_xml &number_of_overdues_7days_library_xml
33
                     &number_of_borrowers_system_xml &number_of_items_system_xml &number_of_items_7days_library_xml &number_of_overdues_system_xml
34
                     &number_of_overdues_14days_library_xml &number_of_overdues_21days_library_xml &number_of_veryoverdue_library_xml &expired_borrowers_library_xml
35
                     &expired_borrowers_system_xml &number_of_issues_system_xml &number_of_loan_history_library_xml &number_of_overdues_7days_system_xml
36
                     &number_of_overdues_14days_system_xml &number_of_overdues_21days_system_xml &number_of_veryoverdue_system_xml &last_update_xml
37
               );
38
}
39
40
41
sub number_of_items_library_xml {
42
    my $dbh = C4::Context->dbh;
43
    my $items = $dbh->selectall_arrayref ('select branches.branchcode as BranchCode, IFNULL(SubTotal.items,0) as NumberOfItems
44
    from branches
45
    left join
46
    (select homebranch, count(*) as Items
47
    from items
48
    group by homebranch) SubTotal
49
    on branches.branchcode=SubTotal.homebranch',{ Columns => {} });
50
    $dbh->disconnect();
51
    return $items;
52
    
53
}
54
55
sub number_of_items_system_xml {
56
    my $dbh = C4::Context->dbh;
57
    my $items_system = $dbh->selectall_arrayref('select count(*) as NumberOfItemsSystem from items', {Columns => {} });
58
    $dbh->disconnect;
59
    return $items_system;
60
    
61
}
62
63
sub number_of_borrowers_library_xml {
64
    my $dbh = C4::Context->dbh;
65
    my $borrowers = $dbh->selectall_arrayref ('select branches.branchcode as BranchCode, IFNULL(SubTotal.Borrowers,0) as NumberOfBorrowers
66
    from branches
67
    left join
68
    (select branchcode, count(*) as Borrowers
69
    from borrowers
70
    group by branchcode) SubTotal
71
    on branches.branchcode=SubTotal.branchcode',{ Columns => {} });
72
    $dbh->disconnect;
73
    return $borrowers;
74
75
}
76
77
sub number_of_borrowers_system_xml {
78
    my $dbh = C4::Context->dbh;
79
    my $number_of_borrowers_system = $dbh->selectall_arrayref('select count(*) as NumberofBorrowersSystem
80
    from borrowers',{ Columns => {} } );
81
    $dbh->disconnect;
82
    return $number_of_borrowers_system;
83
84
}
85
86
sub number_of_issues_library_xml {
87
    my $dbh = C4::Context->dbh;
88
    my $issues_library = $dbh->selectall_arrayref('select branches.branchcode as BranchCode, IFNULL(SubTotal.issues,0) as NumberOfIssues
89
    from branches
90
    left join
91
    (select branchcode, count(*) as Issues
92
    from issues
93
    group by branchcode) SubTotal
94
    on branches.branchcode=SubTotal.branchcode',{ Columns => {} });
95
    $dbh->disconnect();
96
    return $issues_library;
97
   
98
}   
99
100
sub number_of_issues_system_xml {
101
    my $dbh = C4::Context->dbh;
102
    my $issues_system = $dbh->selectall_arrayref('select count(*) as NumberOfIssuesSystem
103
    from issues',{Columns => {}});
104
    $dbh->disconnect;
105
    return $issues_system;
106
    
107
}
108
109
sub number_of_biblios_xml {
110
    my $dbh = C4::Context->dbh;
111
    my $biblios = $dbh->selectall_arrayref('select count(*) as NumberOfBiblios from biblio',{ Columns => {} } );
112
    $dbh->disconnect;
113
    return $biblios;
114
    
115
}
116
117
sub number_of_loan_history_system_xml {
118
    my $dbh = C4::Context->dbh;
119
    my $loan_history = $dbh->selectall_arrayref('select count(*) as NumberOfLoans from old_issues', { Columns => {} });
120
    $dbh->disconnect;
121
    return $loan_history;
122
123
}
124
125
sub number_of_loan_history_library_xml {
126
    my $dbh = C4::Context->dbh;
127
    my $loan_history_library = $dbh->selectall_arrayref('select branches.branchcode as BranchCode, IFNULL(SubTotal.oldissues,0) as NumberOfLoans 
128
    from branches 
129
    left join
130
    (select branchcode, count(*) as OldIssues
131
    from old_issues
132
    group by branchcode) SubTotal     
133
    on branches.branchcode=SubTotal.branchcode', {Columns => {}} );
134
    $dbh->disconnect;
135
    return $loan_history_library;
136
    
137
}
138
139
sub number_of_overdues_library_xml {
140
    my $dbh = C4::Context->dbh;
141
    my $overdues_library = $dbh->selectall_arrayref('select branches.branchcode as BranchCode, IFNULL(SubTotal.Overdues,0) as NumberOfOverdues
142
    from branches
143
    left join
144
    (select branchcode, count(*) as Overdues
145
    from issues
146
    where date_due < date(now()) 
147
    group by branchcode) SubTotal
148
    on branches.branchcode=SubTotal.branchcode', {Columns => {} });
149
    $dbh->disconnect;
150
    return $overdues_library;
151
    
152
}
153
154
sub number_of_overdues_system_xml {
155
    my $dbh = C4::Context->dbh;
156
    my $overdues_system = $dbh->selectall_arrayref('select count(*) as NumberOfOverdues
157
    from issues
158
    where date_due < date(now())',{Columns => {}} );
159
    $dbh->disconnect;
160
    return $overdues_system;
161
    
162
}
163
164
sub number_of_overdues_7days_library_xml {
165
    my $dbh = C4::Context->dbh;
166
    my $overdues_library_7days = $dbh->selectall_arrayref('select branches.branchcode as BranchCode, IFNULL(SubTotal.Overdues,0) as NumberOfOverdues7Days
167
    from branches
168
    left join
169
    (select branchcode, count(*) as Overdues
170
    from issues
171
    where date_due between DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND DATE_SUB(CURDATE(), INTERVAL 1 DAY)  
172
    group by branchcode) SubTotal
173
    on branches.branchcode=SubTotal.branchcode', {Columns => {} });
174
    $dbh->disconnect;
175
    return $overdues_library_7days;
176
    
177
}
178
179
sub number_of_overdues_7days_system_xml {
180
    my $dbh = C4::Context->dbh;
181
    my $overdues_7days_system = $dbh->selectall_arrayref('select count(*) as NumberOfOverdues
182
    from issues
183
    where date_due 
184
    between DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND DATE_SUB(CURDATE(), INTERVAL 1 DAY)', {Columns => {}} );
185
    return $overdues_7days_system;
186
    
187
}
188
189
sub number_of_overdues_14days_library_xml {
190
    my $dbh = C4::Context->dbh;
191
    my $overdues_14days = $dbh->selectall_arrayref('select branches.branchcode as BranchCode, IFNULL(SubTotal.Overdues,0) as NumberOfOverdues14Days
192
    from branches
193
    left join
194
    (select branchcode, count(*) as Overdues
195
    from issues
196
    where date_due 
197
    between DATE_SUB(CURDATE(), INTERVAL 14 DAY) AND DATE_SUB(CURDATE(), INTERVAL 8 DAY)
198
    group by branchcode) SubTotal
199
    on branches.branchcode=SubTotal.branchcode', {Columns => {} });
200
    $dbh->disconnect;
201
    return $overdues_14days;
202
    
203
}
204
205
sub number_of_overdues_14days_system_xml {
206
    my $dbh = C4::Context->dbh;
207
    my $overdues_14days_system = $dbh->selectall_arrayref('select count(*) as NumberOfOverdues14Days
208
    from issues
209
    where date_due 
210
    between DATE_SUB(CURDATE(), INTERVAL 14 DAY) AND DATE_SUB(CURDATE(), INTERVAL 8 DAY)', {Columns => {}} );
211
    $dbh->disconnect;
212
    return $overdues_14days_system;
213
214
}
215
216
sub number_of_overdues_21days_library_xml {
217
    my $dbh = C4::Context->dbh;
218
    my $overdues_21days_library = $dbh->selectall_arrayref('select branches.branchcode as BranchCode, IFNULL(SubTotal.Overdues,0) as NumberOfOverdues21Days
219
    from branches
220
    left join
221
    (select branchcode, count(*) as Overdues
222
    from issues
223
    where date_due between DATE_SUB(CURDATE(), INTERVAL 21 DAY) AND DATE_SUB(CURDATE(), INTERVAL 15 DAY)
224
    group by branchcode) SubTotal
225
    on branches.branchcode=SubTotal.branchcode', {Columns => {} });
226
    $dbh->disconnect;
227
    return $overdues_21days_library;
228
    
229
}
230
231
sub number_of_overdues_21days_system_xml {
232
    my $dbh = C4::Context->dbh;
233
    my $overdues_21days_system = $dbh->selectall_arrayref('select count(*) as NumberOfOverdues21Days
234
    from issues
235
    where date_due between DATE_SUB(CURDATE(), INTERVAL 21 DAY) AND DATE_SUB(CURDATE(), INTERVAL 15 DAY)'
236
    , {Columns => {} });
237
    return $overdues_21days_system;
238
    
239
}
240
241
sub number_of_veryoverdue_library_xml {
242
    my $dbh = C4::Context->dbh;
243
    my $very_overdue_library = $dbh->selectall_arrayref('select branches.branchcode as BranchCode, IFNULL(SubTotal.Overdues,0) as NumberOfVeryOverdue
244
    from branches
245
    left join
246
    (select branchcode, count(*) as Overdues
247
    from issues
248
    where date_due < DATE_SUB(CURDATE(), INTERVAL 22 DAY)
249
    group by branchcode) SubTotal
250
    on branches.branchcode=SubTotal.branchcode', {Columns => {} });
251
    $dbh->disconnect;
252
    return $very_overdue_library;
253
    
254
}
255
256
sub number_of_veryoverdue_system_xml {
257
    my $dbh = C4::Context->dbh;
258
    my $very_overdue_system = $dbh->selectall_arrayref('select count(*) as Overdues
259
    from issues
260
    where date_due < DATE_SUB(CURDATE(), INTERVAL 22 DAY)' ,{Columns => {} });
261
    $dbh->disconnect;
262
    return $very_overdue_system;
263
    
264
}
265
266
267
sub number_of_biblios_7days_xml {
268
    my $dbh = C4::Context->dbh;
269
    my $biblio_7days = $dbh->selectall_arrayref('SELECT count(*) as NumberOfBiblio7Days 
270
    FROM biblio
271
    WHERE datecreated 
272
    between DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND CURDATE()', {Columns => {} } );
273
    $dbh->disconnect;
274
    return $biblio_7days; 
275
    
276
}
277
278
sub number_of_items_7days_system_xml {
279
    my $dbh = C4::Context->dbh;
280
    my $items_7days_system = $dbh->selectall_arrayref('SELECT count(*) as NumberOfItems7Days 
281
    FROM items 
282
    WHERE dateaccessioned
283
    between DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND CURDATE()',{Columns =>{} } );
284
    $dbh->disconnect;
285
    return $items_7days_system;
286
287
}
288
289
sub number_of_items_7days_library_xml {
290
    my $dbh = C4::Context->dbh;
291
    my $items_7days_library = $dbh->selectall_arrayref('select branches.branchcode as BranchCode, IFNULL(SubTotal.items,0) as NumberOfItems7DaysLibrary
292
    from branches
293
    left join
294
    (select homebranch, count(*) as Items
295
    from items
296
    where dateaccessioned > DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND CURDATE()
297
    group by homebranch) SubTotal
298
    on branches.branchcode=SubTotal.homebranch', {Columns => {} });
299
    $dbh->disconnect;
300
    return $items_7days_library;
301
302
}
303
304
sub expired_borrowers_library_xml {
305
    my $dbh = C4::Context->dbh;
306
    my $expired_borrowers_library = $dbh->selectall_arrayref('select branches.branchcode as BranchCode, IFNULL(SubTotal.ExpiredBorrowers,0) as ExpiredBorrowers
307
    from branches
308
    left join
309
    (select branchcode, count(*) as ExpiredBorrowers
310
    from borrowers
311
    where dateexpiry < date(now())
312
    group by branchcode) SubTotal
313
    on branches.branchcode=SubTotal.branchcode;',{Columns => {} } );
314
    $dbh->disconnect;
315
    return $expired_borrowers_library;
316
    
317
}
318
319
sub expired_borrowers_system_xml {
320
    my $dbh = C4::Context->dbh;
321
    my $expired_borrowers_system = $dbh->selectall_arrayref('select count(*) as ExpiredBorrowers
322
    from borrowers 
323
    where dateexpiry < date(now())', {Columns => {} });
324
    $dbh->disconnect;
325
    return $expired_borrowers_system;
326
    
327
}
328
329
sub last_update_xml {
330
    my $dbh = C4::Context->dbh;
331
    my $updated = $dbh->selectall_arrayref('SELECT DATE_FORMAT(now(), "%W %M %D %Y %T") as UpdatedTime',
332
    {Columns => {} });
333
    $dbh->disconnect;
334
    return $updated;
335
    
336
}
337
338
1;
339
__END__
340
341
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 13-18 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES Link Here
13
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AnonSuggestions',0,'Set to enable Anonymous suggestions to AnonymousPatron borrowernumber',NULL,'YesNo');
13
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AnonSuggestions',0,'Set to enable Anonymous suggestions to AnonymousPatron borrowernumber',NULL,'YesNo');
14
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AnonymousPatron', '0', 'Set the identifier (borrowernumber) of the anonymous patron. Used for Suggestion and reading history privacy',NULL,'');
14
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AnonymousPatron', '0', 'Set the identifier (borrowernumber) of the anonymous patron. Used for Suggestion and reading history privacy',NULL,'');
15
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('Babeltheque',0,'Turn ON Babeltheque content  - See babeltheque.com to subscribe to this service','','YesNo');
15
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('Babeltheque',0,'Turn ON Babeltheque content  - See babeltheque.com to subscribe to this service','','YesNo');
16
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('DashBoardDisplayed','1','','Display Dashboard on main page','YesNo');
16
17
17
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('authoritysep','--','Used to separate a list of authorities in a display. Usually --',10,'free');
18
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('authoritysep','--','Used to separate a list of authorities in a display. Usually --',10,'free');
18
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('autoBarcode','OFF','Used to autogenerate a barcode: incremental will be of the form 1, 2, 3; annual of the form 2007-0001, 2007-0002; hbyymmincr of the form HB08010001 where HB=Home Branch','incremental|annual|hbyymmincr|OFF','Choice');
19
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('autoBarcode','OFF','Used to autogenerate a barcode: incremental will be of the form 1, 2, 3; annual of the form 2007-0001, 2007-0002; hbyymmincr of the form HB08010001 where HB=Home Branch','incremental|annual|hbyymmincr|OFF','Choice');
(-)a/installer/data/mysql/updatedatabase.pl (+8 lines)
Lines 4550-4555 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
4550
    SetVersion ($DBversion);
4550
    SetVersion ($DBversion);
4551
}
4551
}
4552
4552
4553
$DBversion = "3.06.00.XXX";
4554
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
4555
    $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('DashBoardDisplayed','1','','Display Dashboard on main page','YesNo')");
4556
    print "Upgrade to $DBversion done. Added Dashboard Syspref \n";
4557
    SetVersion ($DBversion);
4558
}
4559
4560
4553
=head1 FUNCTIONS
4561
=head1 FUNCTIONS
4554
4562
4555
=head2 DropAllForeignKeys($table)
4563
=head2 DropAllForeignKeys($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref (+8 lines)
Lines 95-97 Administration: Link Here
95
        -
95
        -
96
            - The CAS Authentication Server can be found at
96
            - The CAS Authentication Server can be found at
97
            - pref: casServerUrl           
97
            - pref: casServerUrl           
98
    Dashboard:
99
        -
100
            - pref: DashBoardDisplayed
101
              default: 0
102
              choices:
103
                  yes: Show
104
                  no: "Don't Show"
105
            - Switch on Dashboard on main page.
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt (+111 lines)
Lines 117-122 Link Here
117
		</div><!-- /koha-news -->
117
		</div><!-- /koha-news -->
118
	</div>
118
	</div>
119
[% END %]
119
[% END %]
120
121
<!-- Dashboard, if on -->
122
[% IF DashBoardDisplayed %]
123
[% UNLESS nofile %]
124
<fieldset class="rows">
125
<legend>Koha Library Dashboard</legend>
126
    <table style="border:0px;" id="dashboard">
127
     <tr style="border-bottom: 0px;border-left: 0px;">
128
     <td style="border-left: 0px;border-bottom: 0px;"> 
129
    	<table id="overview" width="400">
130
	    <tr>
131
		<th>Overview</th>
132
		<th>System</th>
133
		<th>My Library</th>
134
		</tr>
135
		<tr align="left">
136
		<td align="left">Number of Biblios
137
		</td>
138
		<td>[% number_of_biblios %]</td>
139
		<td style="background-color:#E8E8E8"></td>
140
	    </tr>
141
	    <tr>
142
		<td>Biblios added in last 7 days</td>
143
		<td>[% biblios_7days %]</td>
144
		<td style="background-color:#E8E8E8"></td>
145
	    </tr>
146
	    <tr>
147
		<td>Number of Items</td>
148
		<td>[% items_system %]</td>
149
		<td>[% items_library %]</td>
150
	    </tr>
151
	    <tr>
152
		<td>Number of items added in last 7 days</td>
153
		<td> [% items_7days_system %]</td>
154
		<td>[% items_7days_system %]</td>
155
	    </tr>
156
	    <tr>
157
		<td>Registered Borrowers</td>
158
		<td>[% borrowers_system %]</td>
159
		<td>[% borrowers_library %]</td>
160
	    </tr>
161
	    <tr>
162
		<td>Expired Borrowers</td>
163
		<td>[% expired_borrowers_system %]</td>
164
		<td>[% expired_borrowers_library %]</td>
165
	    </tr>
166
	    <tr>
167
	    <td>&nbsp;</td>
168
	    <td></td>
169
	    <td></td>
170
	    </tr>
171
	    
172
	</table>
173
	Last updated: [% last_updated %]
174
	</td>
175
	<td style="border-bottom: 0px;border-left: 0px;">
120
	
176
	
177
	<table id="circulation" width="400">
178
	    <tr>
179
		<th>Circulation</th>
180
		<th>System</th>
181
		<th>My Library</th>
182
		</tr>
183
		<tr align="left">
184
		<td align="left">Items on Loan
185
		</td>
186
		<td>[% issues_system %]</td>
187
		<td>[% issues_library %]</td>
188
	    </tr>
189
	    <tr>
190
		<td>Loan History</td>
191
		<td>[% loan_history_system %]</td>
192
		<td>[% loan_history_library %]</td>
193
	    </tr>
194
	    <tr>
195
		<td>Items Overdue</td>
196
		<td>[% overdues_system %]</td>
197
		<td>[% overdues_library %]</td>
198
	    </tr>
199
	    <tr>
200
		<td>Overdue within 7 days</td>
201
		<td>[% overdues_7days_system %]</td>
202
		<td>[% overdues_7days_library %]</td>
203
	    </tr>
204
	    <tr>
205
		<td>Overdue 8-14 days</td>
206
		<td>[% overdues_14days_system %]</td>
207
		<td>[% overdues_14days_library %]</td>
208
	    </tr>
209
	     <tr>
210
		<td>Overdue 15-21 days</td>
211
		<td>[% overdues_21days_system %]</td>
212
		<td>[% overdues_21days_library %]</td>
213
	    </tr>
214
	     <tr>
215
		<td>Very Overdue Items</td>
216
		<td>[% very_overdue_system %]</td>
217
		<td>[% very_overdue_library %]</td>
218
	    </tr>
219
	</table>
220
	</td>
221
    </tr>
222
    </table>
223
</fieldset>
224
</div>
225
</div>
226
</div>
227
[% END %]
228
[% END %]
229
[% IF nofile %]
230
<b>[% nofile %]</b>
231
[% END %]
121
</div>
232
</div>
122
[% INCLUDE 'intranet-bottom.inc' %]
233
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/mainpage.pl (+176 lines)
Lines 67-70 $template->param( Link Here
67
    koha_news_count => $koha_news_count
67
    koha_news_count => $koha_news_count
68
);
68
);
69
69
70
# Dashboard (If on in SysPref)
71
my $nofile = "Dashboard is set to \"ON\". However there is no XML file to read. Have you run it at least once?";
72
unless ( C4::Context->preference('DashBoardDisplayed') == 0 )
73
    {
74
    my $koha_conf = $ENV{'KOHA_CONF'};
75
    my ($base,$file) = $koha_conf =~ m|^(.*[/\\])([^/\\]+?)$|;
76
    my $xml_read = "dashboard_xml.out";
77
    my $xml_file = "$base"."$xml_read";
78
if (-e $xml_file) {
79
    my $xml = new XML::Simple;
80
    my $dash = $xml->XMLin($xml_file);
81
    my $login_branch_name = $template->{VARS}{LoginBranchcode};
82
    my $number_of_biblios;
83
    my $biblios_7days;
84
    my $items_7days_system;
85
    my $items_7days_library;
86
    my $borrowers_system;
87
    my $expired_borrowers_library;
88
    my $expired_borrowers_system;
89
    my $loan_history_system;
90
    my $loan_history_library;
91
    my $overdues_library;
92
    my $overdues_system;
93
    my $overdues_7days_library;
94
    my $overdues_7days_system;
95
    my $overdues_14days_library;
96
    my $overdues_14days_system;
97
    my $overdues_21days_library;
98
    my $overdues_21days_system;
99
    my $very_overdue_library;
100
    my $very_overdue_system;
101
    my $borrowers_library;
102
    my $issues_library;
103
    my $issues_system;
104
    my $items_library;
105
    my $items_system;
106
    my $last_updated;
107
    
108
            $number_of_biblios          = $dash->{biblios}->{NumberOfBiblios};
109
            $biblios_7days              = $dash->{biblio_7days}->{NumberOfBiblio7Days};
110
            $items_7days_system         = $dash->{items_7days_system}->{NumberOfItems7Days};
111
            $borrowers_system           = $dash->{number_of_borrowers_system}->{NumberofBorrowersSystem};
112
            $loan_history_system        = $dash->{loan_history_system}->{NumberOfLoans};
113
            $items_system               = $dash->{items_system}->{NumberOfItemsSystem};
114
            $expired_borrowers_system   = $dash->{expired_borrowers_system}->{ExpiredBorrowers};
115
            $issues_system              = $dash->{issues_system}->{NumberOfIssuesSystem};
116
            $overdues_system            = $dash->{overdues_system}->{NumberOfOverdues};
117
            $overdues_7days_system      = $dash->{overdues_7days_system}->{NumberOfOverdues};
118
            $overdues_14days_system     = $dash->{overdues_14days_system}->{NumberOfOverdues14Days};
119
            $overdues_21days_system     = $dash->{overdues_21days_system}->{NumberOfOverdues21Days};
120
            $very_overdue_system        = $dash->{very_overdue_system}->{Overdues};
121
            $last_updated               = $dash->{last_updated}->{UpdatedTime};
122
123
# Looping for "logged in branch" dependant data           
124
            foreach my $numissl(@{$dash->{issues_library}})
125
                {
126
                    if($numissl->{BranchCode} eq $login_branch_name)
127
                        {
128
                          $issues_library = $numissl->{NumberOfIssues}
129
                        }
130
                }
131
            foreach my $numitm(@{$dash->{items_library}})
132
                {
133
                    if($numitm->{BranchCode} eq $login_branch_name)
134
                        {
135
                            $items_library = $numitm->{NumberOfItems}
136
                        }
137
                 }
138
            foreach my $numbor(@{$dash->{borrowers_library}})
139
                {
140
                    if($numbor->{BranchCode} eq $login_branch_name)
141
                        {
142
                            $borrowers_library = $numbor->{NumberOfBorrowers}
143
                        }
144
                 }
145
            foreach my $numex(@{$dash->{expired_borrowers_library}})
146
                {
147
                    if($numex->{BranchCode} eq $login_branch_name)
148
                        {
149
                            $expired_borrowers_library = $numex->{ExpiredBorrowers}
150
                        }
151
                 }
152
                 
153
            foreach my $numitm7(@{$dash->{items_7days_library}})
154
                {
155
                    if($numitm7->{BranchCode} eq $login_branch_name)
156
                        {
157
                            $items_7days_library = $numitm7->{NumberOfItems7DaysLibrary}
158
                        }
159
                 }
160
            
161
            foreach my $oldiss(@{$dash->{loan_history_library}})
162
                {
163
                    if($oldiss->{BranchCode} eq $login_branch_name)
164
                        {
165
                            $loan_history_library = $oldiss->{NumberOfLoans}
166
                        }
167
                 }
168
            
169
            foreach my $ovdlib(@{$dash->{overdues_library}})
170
                {
171
                    if($ovdlib->{BranchCode} eq $login_branch_name)
172
                        {
173
                            $overdues_library = $ovdlib->{NumberOfOverdues}
174
                        }
175
                 }
176
            
177
            foreach my $ovd7day(@{$dash->{overdues_7days_library}})
178
                {
179
                    if($ovd7day->{BranchCode} eq $login_branch_name)
180
                        {
181
                            $overdues_7days_library = $ovd7day->{NumberOfOverdues7Days}
182
                        }
183
                 }
184
            
185
            foreach my $ovd14day(@{$dash->{overdues_14days_library}})
186
                {
187
                    if($ovd14day->{BranchCode} eq $login_branch_name)
188
                        {
189
                            $overdues_14days_library = $ovd14day->{NumberOfOverdues14Days}
190
                        }
191
                 }
192
            
193
            foreach my $ovd21day(@{$dash->{overdues_21days_library}})
194
                {
195
                    if($ovd21day->{BranchCode} eq $login_branch_name)
196
                        {
197
                            $overdues_21days_library = $ovd21day->{NumberOfOverdues21Days}
198
                        }
199
                 }
200
            
201
            foreach my $vryod(@{$dash->{very_overdue_library}})
202
                {
203
                    if($vryod->{BranchCode} eq $login_branch_name)
204
                        {
205
                            $very_overdue_library = $vryod->{NumberOfVeryOverdue}
206
                        }
207
                 }
208
            
209
        $template->param('number_of_biblios'            => $number_of_biblios,
210
                         'biblios_7days'                => $biblios_7days,
211
                         'items_7days_system'           => $items_7days_system,
212
                         'items_7days_library'          => $items_7days_library,
213
                         'borrowers_system'             => $borrowers_system,
214
                         'expired_borrowers_library'    => $expired_borrowers_library,
215
                         'expired_borrowers_system'     => $expired_borrowers_system,
216
                         'overdues_library'             => $overdues_library,
217
                         'overdues_system'              => $overdues_system,
218
                         'overdues_7days_library'       => $overdues_7days_library,
219
                         'overdues_7days_system'        => $overdues_7days_system,
220
                         'overdues_14days_library'      => $overdues_14days_library,
221
                         'overdues_14days_system'       => $overdues_14days_system,
222
                         'overdues_21days_library'      => $overdues_21days_library,
223
                         'overdues_21days_system'       => $overdues_21days_system,
224
                         'very_overdue_library'         => $very_overdue_library,
225
                         'very_overdue_system'          => $very_overdue_system,
226
                         'loan_history_system'          => $loan_history_system,
227
                         'loan_history_library'         => $loan_history_library,
228
                         'issues_library'               => $issues_library,
229
                         'issues_system'                => $issues_system,
230
                         'items_library'                => $items_library,
231
                         'items_system'                 => $items_system,
232
                         'borrowers_library'            => $borrowers_library,
233
                         'last_updated'                 => $last_updated
234
			                    
235
        );
236
}
237
238
elsif(!-e $xml_file) {
239
	$template->param('nofile' => $nofile,);
240
	}
241
242
}
243
244
# Dashboard end
245
70
output_html_with_http_headers $query, $cookie, $template->output;
246
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/misc/migration_tools/dashboard_xml.pl (-1 / +82 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
use strict;
3
use warnings;
4
use XML::Simple;
5
use C4::Context;
6
use C4::DashBoard;
7
8
# This script should be run on a cron at specific intervals
9
# It will generate XML with the results of the queries below
10
# This can then be parsed and displayed on the Dashboard page.
11
# The Syspref for Dashboard will need to be enabled too.
12
13
# Using the KOHA_CONF variable to get the base directory.
14
# The generated XML file will go there
15
my $koha_conf = $ENV{'KOHA_CONF'};
16
my ($base,$file) = $koha_conf =~ m|^(.*[/\\])([^/\\]+?)$|;
17
my $out_file = 'dashboard_xml.out';
18
my $path = "$base"."$out_file";
19
20
my $items_library               = number_of_items_library_xml;
21
my $items_system                = number_of_items_system_xml;
22
my $borrowers_system            = number_of_borrowers_system_xml;
23
my $borrowers_library           = number_of_borrowers_library_xml;
24
my $issues_library              = number_of_issues_library_xml;
25
my $issues_system               = number_of_issues_system_xml;
26
my $biblios                     = number_of_biblios_xml;
27
my $loan_history_system         = number_of_loan_history_system_xml;
28
my $loan_history_library        = number_of_loan_history_library_xml;
29
my $overdues_library            = number_of_overdues_library_xml;
30
my $overdues_system             = number_of_overdues_system_xml;
31
my $biblio_7days                = number_of_biblios_7days_xml;
32
my $items_7days_system          = number_of_items_7days_system_xml;
33
my $items_7days_library         = number_of_items_7days_library_xml;
34
my $overdues_7days_library      = number_of_overdues_7days_library_xml;
35
my $overdues_7days_system       = number_of_overdues_7days_system_xml;
36
my $overdues_14days_library     = number_of_overdues_14days_library_xml;
37
my $overdues_14days_system      = number_of_overdues_14days_system_xml;
38
my $overdues_21days_library     = number_of_overdues_21days_library_xml;
39
my $overdues_21days_system      = number_of_overdues_21days_system_xml;
40
my $very_overdue_library        = number_of_veryoverdue_library_xml;
41
my $very_overdue_system         = number_of_veryoverdue_system_xml;
42
my $expired_borrowers_library   = expired_borrowers_library_xml;
43
my $expired_borrowers_system    = expired_borrowers_system_xml;
44
my $last_updated                = last_update_xml;
45
46
47
open my $xml_file, '>:encoding(UTF-8)', $path or die "open($path): $!";
48
        XMLout(   {  
49
                    items_library               => $items_library, 
50
                    items_system                => $items_system,    
51
		    borrowers_library           => $borrowers_library,
52
                    issues_library              => $issues_library,
53
                    issues_system               => $issues_system,
54
                    biblios                     => $biblios,
55
                    loan_history_system         => $loan_history_system,
56
                    loan_history_library        => $loan_history_library,
57
                    overdues_library            => $overdues_library,
58
                    overdues_system             => $overdues_system,
59
                    biblio_7days                => $biblio_7days,
60
                    items_7days_system          => $items_7days_system,
61
                    items_7days_library         => $items_7days_library,
62
                    overdues_7days_library      => $overdues_7days_library,
63
                    overdues_7days_system       => $overdues_7days_system,
64
                    overdues_14days_library     => $overdues_14days_library,
65
                    overdues_14days_system      => $overdues_14days_system,
66
                    overdues_21days_library     => $overdues_21days_library,
67
                    overdues_21days_system      => $overdues_21days_system,
68
                    very_overdue_library        => $very_overdue_library,
69
                    very_overdue_system         => $very_overdue_system,
70
                    expired_borrowers_library   => $expired_borrowers_library,
71
                    expired_borrowers_system    => $expired_borrowers_system,
72
                    number_of_borrowers_system  => $borrowers_system,
73
                    last_updated                => $last_updated
74
                  },
75
               
76
                    Outputfile  => $xml_file,
77
                    XMLDecl     => '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',
78
                    AttrIndent  => 1,
79
                    NoAttr      => 1,
80
                    RootName    => 'dashboard',
81
                    KeepRoot    => 1
82
                  );

Return to bug 6828