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

(-)a/C4/Auth.pm (+1 lines)
Lines 467-472 sub get_template_and_user { Link Here
467
            UseKohaPlugins                                                             => C4::Context->preference('UseKohaPlugins'),
467
            UseKohaPlugins                                                             => C4::Context->preference('UseKohaPlugins'),
468
            UseCourseReserves                                                          => C4::Context->preference("UseCourseReserves"),
468
            UseCourseReserves                                                          => C4::Context->preference("UseCourseReserves"),
469
            useDischarge                                                               => C4::Context->preference('useDischarge'),
469
            useDischarge                                                               => C4::Context->preference('useDischarge'),
470
            DashBoardDisplayed                                                         => C4::Context->preference('DashBoardDisplayed'),
470
        );
471
        );
471
    }
472
    }
472
    else {
473
    else {
(-)a/C4/DashBoard.pm (+338 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
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__
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 137-142 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
137
('DisplayLibraryFacets',  'holding',  'home|holding|both',  'Defines which library facets to display.',  'Choice'),
137
('DisplayLibraryFacets',  'holding',  'home|holding|both',  'Defines which library facets to display.',  'Choice'),
138
('DisplayMultiPlaceHold','1','','Display the ability to place multiple holds or not','YesNo'),
138
('DisplayMultiPlaceHold','1','','Display the ability to place multiple holds or not','YesNo'),
139
('DisplayOPACiconsXSLT','1','','If ON, displays the format, audience, and material type icons in XSLT MARC21 results and detail pages in the OPAC.','YesNo'),
139
('DisplayOPACiconsXSLT','1','','If ON, displays the format, audience, and material type icons in XSLT MARC21 results and detail pages in the OPAC.','YesNo'),
140
('DashBoardDisplayed','1','','Display Dashboard on main page','YesNo'),
140
('dontmerge','1',NULL,'If ON, modifying an authority record will not update all associated bibliographic records immediately, ask your system administrator to enable the merge_authorities.pl cron job','YesNo'),
141
('dontmerge','1',NULL,'If ON, modifying an authority record will not update all associated bibliographic records immediately, ask your system administrator to enable the merge_authorities.pl cron job','YesNo'),
141
('DumpTemplateVarsIntranet',  '0', NULL ,  'If enabled, dump all Template Toolkit variable to a comment in the html source for the staff intranet.',  'YesNo'),
142
('DumpTemplateVarsIntranet',  '0', NULL ,  'If enabled, dump all Template Toolkit variable to a comment in the html source for the staff intranet.',  'YesNo'),
142
('DumpTemplateVarsOpac',  '0', NULL ,  'If enabled, dump all Template Toolkit variable to a comment in the html source for the opac.',  'YesNo'),
143
('DumpTemplateVarsOpac',  '0', NULL ,  'If enabled, dump all Template Toolkit variable to a comment in the html source for the opac.',  'YesNo'),
(-)a/installer/data/mysql/updatedatabase.pl (+7 lines)
Lines 13926-13931 if( CheckVersion( $DBversion ) ) { Link Here
13926
    print "Upgrade to $DBversion done (Bug 16034 - Integration with OverDrive Patron API)\n";
13926
    print "Upgrade to $DBversion done (Bug 16034 - Integration with OverDrive Patron API)\n";
13927
}
13927
}
13928
13928
13929
$DBversion = "XXX";
13930
if( CheckVersion( $DBversion ) ) {
13931
    $dbh->do("INSERT IGNORE INTO `systempreferences` (variable,value,explanation,options,type) VALUES('DashBoardDisplayed','1','','Display Dashboard on main page','YesNo')");
13932
    print "Upgrade to $DBversion done. Added Dashboard Syspref \n";
13933
    SetVersion ($DBversion);
13934
}
13935
13929
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
13936
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
13930
# SEE bug 13068
13937
# SEE bug 13068
13931
# if there is anything in the atomicupdate, read and execute it.
13938
# if there is anything in the atomicupdate, read and execute it.
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref (+8 lines)
Lines 402-404 Administration: Link Here
402
              choices:
402
              choices:
403
                Zebra: Zebra
403
                Zebra: Zebra
404
                Elasticsearch: Elasticsearch
404
                Elasticsearch: Elasticsearch
405
    Dashboard:
406
        -
407
            - pref: DashBoardDisplayed
408
              default: 0
409
              choices:
410
                  yes: Show
411
                  no: "Don't Show"
412
            - switch on Dashboard on main page.
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt (-1 / +112 lines)
Lines 195-201 Link Here
195
            [% END %]
195
            [% END %]
196
        </div><!-- /koha-news -->
196
        </div><!-- /koha-news -->
197
    [% END %]
197
    [% END %]
198
    </div>
198
199
<!-- Dashboard, if on -->
200
[% IF DashBoardDisplayed %]
201
[% UNLESS nofile %]
202
<fieldset class="rows">
203
<legend>Koha Library Dashboard</legend>
204
    <table style="border:0px;" id="dashboard">
205
     <tr style="border-bottom: 0px;border-left: 0px;">
206
     <td style="border-left: 0px;border-bottom: 0px;">
207
	<table id="overview" width="400">
208
           <tr>
209
               <th>Overview</th>
210
              <th>System</th>
211
                <th>My Library</th>
212
            </tr>
213
          <tr align="left">
214
              <td align="left">Number of Biblios
215
             </td>
216
          <td>[% number_of_biblios %]</td>
217
               <td style="background-color:#E8E8E8"></td>
218
         </tr>
219
          <tr>
220
               <td>Biblios added in last 7 days</td>
221
          <td>[% biblios_7days %]</td>
222
           <td style="background-color:#E8E8E8"></td>
223
         </tr>
224
          <tr>
225
               <td>Number of Items</td>
226
               <td>[% items_system %]</td>
227
            <td>[% items_library %]</td>
228
       </tr>
229
          <tr>
230
               <td>Number of items added in last 7 days</td>
231
          <td> [% items_7days_system %]</td>
232
             <td>[% items_7days_system %]</td>
233
          </tr>
234
          <tr>
235
               <td>Registered Borrowers</td>
236
          <td>[% borrowers_system %]</td>
237
                <td>[% borrowers_library %]</td>
238
           </tr>
239
          <tr>
240
               <td>Expired Borrowers</td>
241
             <td>[% expired_borrowers_system %]</td>
242
                <td>[% expired_borrowers_library %]</td>
243
           </tr>
244
          <tr>
245
           <td>&nbsp;</td>
246
        <td></td>
247
      <td></td>
248
      </tr>
249
250
     </table>
251
       Last updated: [% last_updated %]
252
       </td>
253
  <td style="border-bottom: 0px;border-left: 0px;">
254
	
255
    <table id="circulation" width="400">
256
       <tr>
257
               <th>Circulation</th>
258
           <th>System</th>
259
                <th>My Library</th>
260
            </tr>
261
          <tr align="left">
262
              <td align="left">Items on Loan
263
         </td>
264
          <td>[% issues_system %]</td>
265
           <td>[% issues_library %]</td>
266
      </tr>
267
          <tr>
268
               <td>Loan History</td>
269
          <td>[% loan_history_system %]</td>
270
             <td>[% loan_history_library %]</td>
271
        </tr>
272
          <tr>
273
               <td>Items Overdue</td>
274
         <td>[% overdues_system %]</td>
275
         <td>[% overdues_library %]</td>
276
            </tr>
277
          <tr>
278
               <td>Overdue within 7 days</td>
279
         <td>[% overdues_7days_system %]</td>
280
           <td>[% overdues_7days_library %]</td>
281
      </tr>
282
          <tr>
283
               <td>Overdue 8-14 days</td>
284
             <td>[% overdues_14days_system %]</td>
285
          <td>[% overdues_14days_library %]</td>
286
     </tr>
287
           <tr>
288
              <td>Overdue 15-21 days</td>
289
            <td>[% overdues_21days_system %]</td>
290
          <td>[% overdues_21days_library %]</td>
291
     </tr>
292
           <tr>
293
              <td>Very Overdue Items</td>
294
            <td>[% very_overdue_system %]</td>
295
             <td>[% very_overdue_library %]</td>
296
        </tr>
297
      </table>
298
       </td>
299
    </tr>
300
    </table>
301
</fieldset>
302
</div>
303
</div>
304
</div>
305
[% END %]
306
[% END %]
307
[% IF nofile %]
308
<b>[% nofile %]</b>
309
[% END %]
199
</div>
310
</div>
200
311
201
[% MACRO jsinclude BLOCK %]
312
[% MACRO jsinclude BLOCK %]
(-)a/mainpage.pl (+176 lines)
Lines 91-94 unless ($loggedinuser) { Link Here
91
    $template->param(adminWarning => 1);
91
    $template->param(adminWarning => 1);
92
}
92
}
93
93
94
# Dashboard (If on in SysPref)
95
my $nofile = "Dashboard is set to \"ON\". However there is no XML file to read. Have you run it at least once?";
96
if ( C4::Context->preference('DashBoardDisplayed') )
97
    {
98
    my $koha_conf = $ENV{'KOHA_CONF'};
99
    my ($base,$file) = $koha_conf =~ m|^(.*[/\\])([^/\\]+?)$|;
100
    my $xml_read = "dashboard_xml.out";
101
    my $xml_file = "$base"."$xml_read";
102
if (-e $xml_file) {
103
    my $xml = new XML::Simple;
104
    my $dash = $xml->XMLin($xml_file);
105
    my $login_branch_name = $template->{VARS}{LoginBranchcode};
106
    my $number_of_biblios;
107
    my $biblios_7days;
108
    my $items_7days_system;
109
    my $items_7days_library;
110
    my $borrowers_system;
111
    my $expired_borrowers_library;
112
    my $expired_borrowers_system;
113
    my $loan_history_system;
114
    my $loan_history_library;
115
    my $overdues_library;
116
    my $overdues_system;
117
    my $overdues_7days_library;
118
    my $overdues_7days_system;
119
    my $overdues_14days_library;
120
    my $overdues_14days_system;
121
    my $overdues_21days_library;
122
    my $overdues_21days_system;
123
    my $very_overdue_library;
124
    my $very_overdue_system;
125
    my $borrowers_library;
126
    my $issues_library;
127
    my $issues_system;
128
    my $items_library;
129
    my $items_system;
130
    my $last_updated;
131
132
            $number_of_biblios          = $dash->{biblios}->{NumberOfBiblios};
133
            $biblios_7days              = $dash->{biblio_7days}->{NumberOfBiblio7Days};
134
            $items_7days_system         = $dash->{items_7days_system}->{NumberOfItems7Days};
135
            $borrowers_system           = $dash->{number_of_borrowers_system}->{NumberofBorrowersSystem};
136
            $loan_history_system        = $dash->{loan_history_system}->{NumberOfLoans};
137
            $items_system               = $dash->{items_system}->{NumberOfItemsSystem};
138
            $expired_borrowers_system   = $dash->{expired_borrowers_system}->{ExpiredBorrowers};
139
            $issues_system              = $dash->{issues_system}->{NumberOfIssuesSystem};
140
            $overdues_system            = $dash->{overdues_system}->{NumberOfOverdues};
141
            $overdues_7days_system      = $dash->{overdues_7days_system}->{NumberOfOverdues};
142
            $overdues_14days_system     = $dash->{overdues_14days_system}->{NumberOfOverdues14Days};
143
            $overdues_21days_system     = $dash->{overdues_21days_system}->{NumberOfOverdues21Days};
144
            $very_overdue_system        = $dash->{very_overdue_system}->{Overdues};
145
            $last_updated               = $dash->{last_updated}->{UpdatedTime};
146
147
# Looping for "logged in branch" dependant data
148
            foreach my $numissl(@{$dash->{issues_library}})
149
                {
150
                    if($numissl->{BranchCode} eq $login_branch_name)
151
                        {
152
                          $issues_library = $numissl->{NumberOfIssues}
153
                        }
154
                }
155
            foreach my $numitm(@{$dash->{items_library}})
156
                {
157
                    if($numitm->{BranchCode} eq $login_branch_name)
158
                        {
159
                            $items_library = $numitm->{NumberOfItems}
160
                        }
161
                 }
162
            foreach my $numbor(@{$dash->{borrowers_library}})
163
                {
164
                    if($numbor->{BranchCode} eq $login_branch_name)
165
                        {
166
                            $borrowers_library = $numbor->{NumberOfBorrowers}
167
                        }
168
                 }
169
            foreach my $numex(@{$dash->{expired_borrowers_library}})
170
                {
171
                    if($numex->{BranchCode} eq $login_branch_name)
172
                        {
173
                            $expired_borrowers_library = $numex->{ExpiredBorrowers}
174
                        }
175
                 }
176
177
            foreach my $numitm7(@{$dash->{items_7days_library}})
178
                {
179
                    if($numitm7->{BranchCode} eq $login_branch_name)
180
                        {
181
                            $items_7days_library = $numitm7->{NumberOfItems7DaysLibrary}
182
                        }
183
                 }
184
185
            foreach my $oldiss(@{$dash->{loan_history_library}})
186
                {
187
                    if($oldiss->{BranchCode} eq $login_branch_name)
188
                        {
189
                            $loan_history_library = $oldiss->{NumberOfLoans}
190
                        }
191
                 }
192
193
            foreach my $ovdlib(@{$dash->{overdues_library}})
194
                {
195
                    if($ovdlib->{BranchCode} eq $login_branch_name)
196
                        {
197
                            $overdues_library = $ovdlib->{NumberOfOverdues}
198
                        }
199
                 }
200
201
            foreach my $ovd7day(@{$dash->{overdues_7days_library}})
202
                {
203
                    if($ovd7day->{BranchCode} eq $login_branch_name)
204
                        {
205
                            $overdues_7days_library = $ovd7day->{NumberOfOverdues7Days}
206
                        }
207
                 }
208
209
            foreach my $ovd14day(@{$dash->{overdues_14days_library}})
210
                {
211
                    if($ovd14day->{BranchCode} eq $login_branch_name)
212
                        {
213
                            $overdues_14days_library = $ovd14day->{NumberOfOverdues14Days}
214
                        }
215
                 }
216
217
            foreach my $ovd21day(@{$dash->{overdues_21days_library}})
218
                {
219
                    if($ovd21day->{BranchCode} eq $login_branch_name)
220
                        {
221
                            $overdues_21days_library = $ovd21day->{NumberOfOverdues21Days}
222
                        }
223
                 }
224
225
            foreach my $vryod(@{$dash->{very_overdue_library}})
226
                {
227
                    if($vryod->{BranchCode} eq $login_branch_name)
228
                        {
229
                            $very_overdue_library = $vryod->{NumberOfVeryOverdue}
230
                        }
231
                 }
232
233
        $template->param('number_of_biblios'            => $number_of_biblios,
234
                         'biblios_7days'                => $biblios_7days,
235
                         'items_7days_system'           => $items_7days_system,
236
                         'items_7days_library'          => $items_7days_library,
237
                         'borrowers_system'             => $borrowers_system,
238
                         'expired_borrowers_library'    => $expired_borrowers_library,
239
                         'expired_borrowers_system'     => $expired_borrowers_system,
240
                         'overdues_library'             => $overdues_library,
241
                         'overdues_system'              => $overdues_system,
242
                         'overdues_7days_library'       => $overdues_7days_library,
243
                         'overdues_7days_system'        => $overdues_7days_system,
244
                         'overdues_14days_library'      => $overdues_14days_library,
245
                         'overdues_14days_system'       => $overdues_14days_system,
246
                         'overdues_21days_library'      => $overdues_21days_library,
247
                         'overdues_21days_system'       => $overdues_21days_system,
248
                         'very_overdue_library'         => $very_overdue_library,
249
                         'very_overdue_system'          => $very_overdue_system,
250
                         'loan_history_system'          => $loan_history_system,
251
                         'loan_history_library'         => $loan_history_library,
252
                         'issues_library'               => $issues_library,
253
                         'issues_system'                => $issues_system,
254
                         'items_library'                => $items_library,
255
                         'items_system'                 => $items_system,
256
                         'borrowers_library'            => $borrowers_library,
257
                         'last_updated'                 => $last_updated
258
259
        );
260
}
261
262
elsif(!-e $xml_file) {
263
 $template->param('nofile' => $nofile,);
264
        }
265
266
}
267
268
# Dashboard end
269
94
output_html_with_http_headers $query, $cookie, $template->output;
270
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