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

(-)a/C4/Auth.pm (+1 lines)
Lines 363-368 sub get_template_and_user { Link Here
363
            LocalCoverImages            => C4::Context->preference('LocalCoverImages'),
363
            LocalCoverImages            => C4::Context->preference('LocalCoverImages'),
364
            OPACLocalCoverImages        => C4::Context->preference('OPACLocalCoverImages'),
364
            OPACLocalCoverImages        => C4::Context->preference('OPACLocalCoverImages'),
365
            AllowMultipleCovers         => C4::Context->preference('AllowMultipleCovers'),
365
            AllowMultipleCovers         => C4::Context->preference('AllowMultipleCovers'),
366
            DashBoardDisplayed          => C4::Context->preference('DashBoardDisplayed')
366
        );
367
        );
367
    }
368
    }
368
    else {
369
    else {
(-)a/C4/DashBoard.pm (+339 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__
(-)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 (+7 lines)
Lines 5369-5374 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
5369
    SetVersion($DBversion);
5369
    SetVersion($DBversion);
5370
}
5370
}
5371
5371
5372
$DBversion = "3.09.00.XXX";
5373
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5374
    $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('DashBoardDisplayed','1','','Display Dashboard on main page','YesNo')");
5375
    print "Upgrade to $DBversion done. Added Dashboard Syspref \n";
5376
    SetVersion ($DBversion);
5377
}
5378
5372
5379
5373
=head1 FUNCTIONS
5380
=head1 FUNCTIONS
5374
5381
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref (+8 lines)
Lines 104-106 Administration: Link Here
104
                  Common Name: the Common Name
104
                  Common Name: the Common Name
105
                  emailAddress: the emailAddress
105
                  emailAddress: the emailAddress
106
            - field for SSL client certificate authentication
106
            - field for SSL client certificate authentication
107
    Dashboard:
108
        -
109
            - pref: DashBoardDisplayed
110
              default: 0
111
              choices:
112
                  yes: Show
113
                  no: "Don't Show"
114
            - switch on Dashboard on main page.
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt (-2 / +112 lines)
Lines 154-161 Link Here
154
            [% END %]
154
            [% END %]
155
        </div><!-- /koha-news -->
155
        </div><!-- /koha-news -->
156
    [% END %]
156
    [% END %]
157
    </div>
157
158
    </div>
158
<!-- Dashboard, if on -->
159
[% IF DashBoardDisplayed %]
160
[% UNLESS nofile %]
161
<fieldset class="rows">
162
<legend>Koha Library Dashboard</legend>
163
    <table style="border:0px;" id="dashboard">
164
     <tr style="border-bottom: 0px;border-left: 0px;">
165
     <td style="border-left: 0px;border-bottom: 0px;">
166
	<table id="overview" width="400">
167
           <tr>
168
               <th>Overview</th>
169
              <th>System</th>
170
                <th>My Library</th>
171
            </tr>
172
          <tr align="left">
173
              <td align="left">Number of Biblios
174
             </td>
175
          <td>[% number_of_biblios %]</td>
176
               <td style="background-color:#E8E8E8"></td>
177
         </tr>
178
          <tr>
179
               <td>Biblios added in last 7 days</td>
180
          <td>[% biblios_7days %]</td>
181
           <td style="background-color:#E8E8E8"></td>
182
         </tr>
183
          <tr>
184
               <td>Number of Items</td>
185
               <td>[% items_system %]</td>
186
            <td>[% items_library %]</td>
187
       </tr>
188
          <tr>
189
               <td>Number of items added in last 7 days</td>
190
          <td> [% items_7days_system %]</td>
191
             <td>[% items_7days_system %]</td>
192
          </tr>
193
          <tr>
194
               <td>Registered Borrowers</td>
195
          <td>[% borrowers_system %]</td>
196
                <td>[% borrowers_library %]</td>
197
           </tr>
198
          <tr>
199
               <td>Expired Borrowers</td>
200
             <td>[% expired_borrowers_system %]</td>
201
                <td>[% expired_borrowers_library %]</td>
202
           </tr>
203
          <tr>
204
           <td>&nbsp;</td>
205
        <td></td>
206
      <td></td>
207
      </tr>
208
209
     </table>
210
       Last updated: [% last_updated %]
211
       </td>
212
  <td style="border-bottom: 0px;border-left: 0px;">
213
	
214
    <table id="circulation" width="400">
215
       <tr>
216
               <th>Circulation</th>
217
           <th>System</th>
218
                <th>My Library</th>
219
            </tr>
220
          <tr align="left">
221
              <td align="left">Items on Loan
222
         </td>
223
          <td>[% issues_system %]</td>
224
           <td>[% issues_library %]</td>
225
      </tr>
226
          <tr>
227
               <td>Loan History</td>
228
          <td>[% loan_history_system %]</td>
229
             <td>[% loan_history_library %]</td>
230
        </tr>
231
          <tr>
232
               <td>Items Overdue</td>
233
         <td>[% overdues_system %]</td>
234
         <td>[% overdues_library %]</td>
235
            </tr>
236
          <tr>
237
               <td>Overdue within 7 days</td>
238
         <td>[% overdues_7days_system %]</td>
239
           <td>[% overdues_7days_library %]</td>
240
      </tr>
241
          <tr>
242
               <td>Overdue 8-14 days</td>
243
             <td>[% overdues_14days_system %]</td>
244
          <td>[% overdues_14days_library %]</td>
245
     </tr>
246
           <tr>
247
              <td>Overdue 15-21 days</td>
248
            <td>[% overdues_21days_system %]</td>
249
          <td>[% overdues_21days_library %]</td>
250
     </tr>
251
           <tr>
252
              <td>Very Overdue Items</td>
253
            <td>[% very_overdue_system %]</td>
254
             <td>[% very_overdue_library %]</td>
255
        </tr>
256
      </table>
257
       </td>
258
    </tr>
259
    </table>
260
</fieldset>
261
</div>
262
</div>
263
</div>
264
[% END %]
265
[% END %]
266
[% IF nofile %]
267
<b>[% nofile %]</b>
268
[% END %]
159
</div>
269
</div>
160
270
161
<!-- the main div is closed in intranet-bottom.inc -->
271
<!-- the main div is closed in intranet-bottom.inc -->
(-)a/mainpage.pl (+176 lines)
Lines 60-63 $template->param( Link Here
60
    pendingsuggestions => $pendingsuggestions
60
    pendingsuggestions => $pendingsuggestions
61
);
61
);
62
62
63
# Dashboard (If on in SysPref)
64
my $nofile = "Dashboard is set to \"ON\". However there is no XML file to read. Have you run it at least once?";
65
if ( C4::Context->preference('DashBoardDisplayed') )
66
    {
67
    my $koha_conf = $ENV{'KOHA_CONF'};
68
    my ($base,$file) = $koha_conf =~ m|^(.*[/\\])([^/\\]+?)$|;
69
    my $xml_read = "dashboard_xml.out";
70
    my $xml_file = "$base"."$xml_read";
71
if (-e $xml_file) {
72
    my $xml = new XML::Simple;
73
    my $dash = $xml->XMLin($xml_file);
74
    my $login_branch_name = $template->{VARS}{LoginBranchcode};
75
    my $number_of_biblios;
76
    my $biblios_7days;
77
    my $items_7days_system;
78
    my $items_7days_library;
79
    my $borrowers_system;
80
    my $expired_borrowers_library;
81
    my $expired_borrowers_system;
82
    my $loan_history_system;
83
    my $loan_history_library;
84
    my $overdues_library;
85
    my $overdues_system;
86
    my $overdues_7days_library;
87
    my $overdues_7days_system;
88
    my $overdues_14days_library;
89
    my $overdues_14days_system;
90
    my $overdues_21days_library;
91
    my $overdues_21days_system;
92
    my $very_overdue_library;
93
    my $very_overdue_system;
94
    my $borrowers_library;
95
    my $issues_library;
96
    my $issues_system;
97
    my $items_library;
98
    my $items_system;
99
    my $last_updated;
100
101
            $number_of_biblios          = $dash->{biblios}->{NumberOfBiblios};
102
            $biblios_7days              = $dash->{biblio_7days}->{NumberOfBiblio7Days};
103
            $items_7days_system         = $dash->{items_7days_system}->{NumberOfItems7Days};
104
            $borrowers_system           = $dash->{number_of_borrowers_system}->{NumberofBorrowersSystem};
105
            $loan_history_system        = $dash->{loan_history_system}->{NumberOfLoans};
106
            $items_system               = $dash->{items_system}->{NumberOfItemsSystem};
107
            $expired_borrowers_system   = $dash->{expired_borrowers_system}->{ExpiredBorrowers};
108
            $issues_system              = $dash->{issues_system}->{NumberOfIssuesSystem};
109
            $overdues_system            = $dash->{overdues_system}->{NumberOfOverdues};
110
            $overdues_7days_system      = $dash->{overdues_7days_system}->{NumberOfOverdues};
111
            $overdues_14days_system     = $dash->{overdues_14days_system}->{NumberOfOverdues14Days};
112
            $overdues_21days_system     = $dash->{overdues_21days_system}->{NumberOfOverdues21Days};
113
            $very_overdue_system        = $dash->{very_overdue_system}->{Overdues};
114
            $last_updated               = $dash->{last_updated}->{UpdatedTime};
115
116
# Looping for "logged in branch" dependant data
117
            foreach my $numissl(@{$dash->{issues_library}})
118
                {
119
                    if($numissl->{BranchCode} eq $login_branch_name)
120
                        {
121
                          $issues_library = $numissl->{NumberOfIssues}
122
                        }
123
                }
124
            foreach my $numitm(@{$dash->{items_library}})
125
                {
126
                    if($numitm->{BranchCode} eq $login_branch_name)
127
                        {
128
                            $items_library = $numitm->{NumberOfItems}
129
                        }
130
                 }
131
            foreach my $numbor(@{$dash->{borrowers_library}})
132
                {
133
                    if($numbor->{BranchCode} eq $login_branch_name)
134
                        {
135
                            $borrowers_library = $numbor->{NumberOfBorrowers}
136
                        }
137
                 }
138
            foreach my $numex(@{$dash->{expired_borrowers_library}})
139
                {
140
                    if($numex->{BranchCode} eq $login_branch_name)
141
                        {
142
                            $expired_borrowers_library = $numex->{ExpiredBorrowers}
143
                        }
144
                 }
145
146
            foreach my $numitm7(@{$dash->{items_7days_library}})
147
                {
148
                    if($numitm7->{BranchCode} eq $login_branch_name)
149
                        {
150
                            $items_7days_library = $numitm7->{NumberOfItems7DaysLibrary}
151
                        }
152
                 }
153
154
            foreach my $oldiss(@{$dash->{loan_history_library}})
155
                {
156
                    if($oldiss->{BranchCode} eq $login_branch_name)
157
                        {
158
                            $loan_history_library = $oldiss->{NumberOfLoans}
159
                        }
160
                 }
161
162
            foreach my $ovdlib(@{$dash->{overdues_library}})
163
                {
164
                    if($ovdlib->{BranchCode} eq $login_branch_name)
165
                        {
166
                            $overdues_library = $ovdlib->{NumberOfOverdues}
167
                        }
168
                 }
169
170
            foreach my $ovd7day(@{$dash->{overdues_7days_library}})
171
                {
172
                    if($ovd7day->{BranchCode} eq $login_branch_name)
173
                        {
174
                            $overdues_7days_library = $ovd7day->{NumberOfOverdues7Days}
175
                        }
176
                 }
177
178
            foreach my $ovd14day(@{$dash->{overdues_14days_library}})
179
                {
180
                    if($ovd14day->{BranchCode} eq $login_branch_name)
181
                        {
182
                            $overdues_14days_library = $ovd14day->{NumberOfOverdues14Days}
183
                        }
184
                 }
185
186
            foreach my $ovd21day(@{$dash->{overdues_21days_library}})
187
                {
188
                    if($ovd21day->{BranchCode} eq $login_branch_name)
189
                        {
190
                            $overdues_21days_library = $ovd21day->{NumberOfOverdues21Days}
191
                        }
192
                 }
193
194
            foreach my $vryod(@{$dash->{very_overdue_library}})
195
                {
196
                    if($vryod->{BranchCode} eq $login_branch_name)
197
                        {
198
                            $very_overdue_library = $vryod->{NumberOfVeryOverdue}
199
                        }
200
                 }
201
202
        $template->param('number_of_biblios'            => $number_of_biblios,
203
                         'biblios_7days'                => $biblios_7days,
204
                         'items_7days_system'           => $items_7days_system,
205
                         'items_7days_library'          => $items_7days_library,
206
                         'borrowers_system'             => $borrowers_system,
207
                         'expired_borrowers_library'    => $expired_borrowers_library,
208
                         'expired_borrowers_system'     => $expired_borrowers_system,
209
                         'overdues_library'             => $overdues_library,
210
                         'overdues_system'              => $overdues_system,
211
                         'overdues_7days_library'       => $overdues_7days_library,
212
                         'overdues_7days_system'        => $overdues_7days_system,
213
                         'overdues_14days_library'      => $overdues_14days_library,
214
                         'overdues_14days_system'       => $overdues_14days_system,
215
                         'overdues_21days_library'      => $overdues_21days_library,
216
                         'overdues_21days_system'       => $overdues_21days_system,
217
                         'very_overdue_library'         => $very_overdue_library,
218
                         'very_overdue_system'          => $very_overdue_system,
219
                         'loan_history_system'          => $loan_history_system,
220
                         'loan_history_library'         => $loan_history_library,
221
                         'issues_library'               => $issues_library,
222
                         'issues_system'                => $issues_system,
223
                         'items_library'                => $items_library,
224
                         'items_system'                 => $items_system,
225
                         'borrowers_library'            => $borrowers_library,
226
                         'last_updated'                 => $last_updated
227
228
        );
229
}
230
231
elsif(!-e $xml_file) {
232
 $template->param('nofile' => $nofile,);
233
        }
234
235
}
236
237
# Dashboard end
238
63
output_html_with_http_headers $query, $cookie, $template->output;
239
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