Bugzilla – Attachment 10058 Details for
Bug 6828
Add admin dashboard for staff users
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 6828 - Add basic Dashboard for staff users.
Bug-6828ENH---Add-basic-Dashboard-for-staff-users.patch (text/plain), 33.56 KB, created by
Jared Camins-Esakov
on 2012-06-10 03:02:14 UTC
(
hide
)
Description:
Bug 6828 - Add basic Dashboard for staff users.
Filename:
MIME Type:
Creator:
Jared Camins-Esakov
Created:
2012-06-10 03:02:14 UTC
Size:
33.56 KB
patch
obsolete
>From 341db58ff8a95ae35bf6c8d6c6d0227d27fbbc8c Mon Sep 17 00:00:00 2001 >From: Barry Cannon <barry@oslo.ie> >Date: Thu, 24 Nov 2011 11:58:30 +0000 >Subject: [PATCH] Bug 6828[ENH] - Add basic Dashboard for staff users. >Content-Type: text/plain; charset="UTF-8" > >This enhancement adds the option of switching on/off a Dashboard >on the Staff users mainpage. The information displayed is specific >to the users logged in branch but will also show a system wide >overview. Its visibility is controlled by a new SysPref. > >This first revision takes its data from an XML file which needs to >be populated on a cronjob. >The file to run is in misc/migration_tools/dashboard_xml.pl. The usual Koha >env will need to be set for the user running the script. >--- > C4/Auth.pm | 1 + > C4/DashBoard.pm | 339 ++++++++++++++++++++ > installer/data/mysql/sysprefs.sql | 1 + > installer/data/mysql/updatedatabase.pl | 8 + > .../prog/en/modules/admin/preferences/admin.pref | 8 + > .../intranet-tmpl/prog/en/modules/intranet-main.tt | 114 +++++++- > mainpage.pl | 176 ++++++++++ > misc/migration_tools/dashboard_xml.pl | 82 +++++ > 8 files changed, 727 insertions(+), 2 deletions(-) > create mode 100755 C4/DashBoard.pm > create mode 100644 misc/migration_tools/dashboard_xml.pl > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index ffee1bb..e1389e3 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -363,6 +363,7 @@ sub get_template_and_user { > LocalCoverImages => C4::Context->preference('LocalCoverImages'), > OPACLocalCoverImages => C4::Context->preference('OPACLocalCoverImages'), > AllowMultipleCovers => C4::Context->preference('AllowMultipleCovers'), >+ DashBoardDisplayed => C4::Context->preference('DashBoardDisplayed') > ); > } > else { >diff --git a/C4/DashBoard.pm b/C4/DashBoard.pm >new file mode 100755 >index 0000000..2491ad1 >--- /dev/null >+++ b/C4/DashBoard.pm >@@ -0,0 +1,339 @@ >+package C4::DashBoard; >+ >+# Copyright 2000-2002 Katipo Communications >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+# >+ >+use strict; >+use warnings; >+use C4::Context; >+use C4::Dates qw(format_date); >+ >+use vars qw($VERSION @ISA @EXPORT); >+ >+BEGIN { >+ $VERSION = 3.01; >+ @ISA = qw(Exporter); >+ @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 >+ &number_of_overdues_library_xml &number_of_biblios_7days_xml &number_of_items_7days_system_xml &number_of_overdues_7days_library_xml >+ &number_of_borrowers_system_xml &number_of_items_system_xml &number_of_items_7days_library_xml &number_of_overdues_system_xml >+ &number_of_overdues_14days_library_xml &number_of_overdues_21days_library_xml &number_of_veryoverdue_library_xml &expired_borrowers_library_xml >+ &expired_borrowers_system_xml &number_of_issues_system_xml &number_of_loan_history_library_xml &number_of_overdues_7days_system_xml >+ &number_of_overdues_14days_system_xml &number_of_overdues_21days_system_xml &number_of_veryoverdue_system_xml &last_update_xml >+ ); >+} >+ >+ >+sub number_of_items_library_xml { >+ my $dbh = C4::Context->dbh; >+ my $items = $dbh->selectall_arrayref ('select branches.branchcode as BranchCode, IFNULL(SubTotal.items,0) as NumberOfItems >+ from branches >+ left join >+ (select homebranch, count(*) as Items >+ from items >+ group by homebranch) SubTotal >+ on branches.branchcode=SubTotal.homebranch',{ Columns => {} }); >+ $dbh->disconnect(); >+ return $items; >+ >+} >+ >+sub number_of_items_system_xml { >+ my $dbh = C4::Context->dbh; >+ my $items_system = $dbh->selectall_arrayref('select count(*) as NumberOfItemsSystem from items', {Columns => {} }); >+ $dbh->disconnect; >+ return $items_system; >+ >+} >+ >+sub number_of_borrowers_library_xml { >+ my $dbh = C4::Context->dbh; >+ my $borrowers = $dbh->selectall_arrayref ('select branches.branchcode as BranchCode, IFNULL(SubTotal.Borrowers,0) as NumberOfBorrowers >+ from branches >+ left join >+ (select branchcode, count(*) as Borrowers >+ from borrowers >+ group by branchcode) SubTotal >+ on branches.branchcode=SubTotal.branchcode',{ Columns => {} }); >+ $dbh->disconnect; >+ return $borrowers; >+ >+} >+ >+sub number_of_borrowers_system_xml { >+ my $dbh = C4::Context->dbh; >+ my $number_of_borrowers_system = $dbh->selectall_arrayref('select count(*) as NumberofBorrowersSystem >+ from borrowers',{ Columns => {} } ); >+ $dbh->disconnect; >+ return $number_of_borrowers_system; >+ >+} >+ >+sub number_of_issues_library_xml { >+ my $dbh = C4::Context->dbh; >+ my $issues_library = $dbh->selectall_arrayref('select branches.branchcode as BranchCode, IFNULL(SubTotal.issues,0) as NumberOfIssues >+ from branches >+ left join >+ (select branchcode, count(*) as Issues >+ from issues >+ group by branchcode) SubTotal >+ on branches.branchcode=SubTotal.branchcode',{ Columns => {} }); >+ $dbh->disconnect(); >+ return $issues_library; >+ >+} >+ >+sub number_of_issues_system_xml { >+ my $dbh = C4::Context->dbh; >+ my $issues_system = $dbh->selectall_arrayref('select count(*) as NumberOfIssuesSystem >+ from issues',{Columns => {}}); >+ $dbh->disconnect; >+ return $issues_system; >+ >+} >+ >+sub number_of_biblios_xml { >+ my $dbh = C4::Context->dbh; >+ my $biblios = $dbh->selectall_arrayref('select count(*) as NumberOfBiblios from biblio',{ Columns => {} } ); >+ $dbh->disconnect; >+ return $biblios; >+ >+} >+ >+sub number_of_loan_history_system_xml { >+ my $dbh = C4::Context->dbh; >+ my $loan_history = $dbh->selectall_arrayref('select count(*) as NumberOfLoans from old_issues', { Columns => {} }); >+ $dbh->disconnect; >+ return $loan_history; >+ >+} >+ >+sub number_of_loan_history_library_xml { >+ my $dbh = C4::Context->dbh; >+ my $loan_history_library = $dbh->selectall_arrayref('select branches.branchcode as BranchCode, IFNULL(SubTotal.oldissues,0) as NumberOfLoans >+ from branches >+ left join >+ (select branchcode, count(*) as OldIssues >+ from old_issues >+ group by branchcode) SubTotal >+ on branches.branchcode=SubTotal.branchcode', {Columns => {}} ); >+ $dbh->disconnect; >+ return $loan_history_library; >+ >+} >+ >+sub number_of_overdues_library_xml { >+ my $dbh = C4::Context->dbh; >+ my $overdues_library = $dbh->selectall_arrayref('select branches.branchcode as BranchCode, IFNULL(SubTotal.Overdues,0) as NumberOfOverdues >+ from branches >+ left join >+ (select branchcode, count(*) as Overdues >+ from issues >+ where date_due < date(now()) >+ group by branchcode) SubTotal >+ on branches.branchcode=SubTotal.branchcode', {Columns => {} }); >+ $dbh->disconnect; >+ return $overdues_library; >+ >+} >+ >+sub number_of_overdues_system_xml { >+ my $dbh = C4::Context->dbh; >+ my $overdues_system = $dbh->selectall_arrayref('select count(*) as NumberOfOverdues >+ from issues >+ where date_due < date(now())',{Columns => {}} ); >+ $dbh->disconnect; >+ return $overdues_system; >+ >+} >+ >+sub number_of_overdues_7days_library_xml { >+ my $dbh = C4::Context->dbh; >+ my $overdues_library_7days = $dbh->selectall_arrayref('select branches.branchcode as BranchCode, IFNULL(SubTotal.Overdues,0) as NumberOfOverdues7Days >+ from branches >+ left join >+ (select branchcode, count(*) as Overdues >+ from issues >+ where date_due between DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND DATE_SUB(CURDATE(), INTERVAL 1 DAY) >+ group by branchcode) SubTotal >+ on branches.branchcode=SubTotal.branchcode', {Columns => {} }); >+ $dbh->disconnect; >+ return $overdues_library_7days; >+ >+} >+ >+sub number_of_overdues_7days_system_xml { >+ my $dbh = C4::Context->dbh; >+ my $overdues_7days_system = $dbh->selectall_arrayref('select count(*) as NumberOfOverdues >+ from issues >+ where date_due >+ between DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND DATE_SUB(CURDATE(), INTERVAL 1 DAY)', {Columns => {}} ); >+ return $overdues_7days_system; >+ >+} >+ >+sub number_of_overdues_14days_library_xml { >+ my $dbh = C4::Context->dbh; >+ my $overdues_14days = $dbh->selectall_arrayref('select branches.branchcode as BranchCode, IFNULL(SubTotal.Overdues,0) as NumberOfOverdues14Days >+ from branches >+ left join >+ (select branchcode, count(*) as Overdues >+ from issues >+ where date_due >+ between DATE_SUB(CURDATE(), INTERVAL 14 DAY) AND DATE_SUB(CURDATE(), INTERVAL 8 DAY) >+ group by branchcode) SubTotal >+ on branches.branchcode=SubTotal.branchcode', {Columns => {} }); >+ $dbh->disconnect; >+ return $overdues_14days; >+ >+} >+ >+sub number_of_overdues_14days_system_xml { >+ my $dbh = C4::Context->dbh; >+ my $overdues_14days_system = $dbh->selectall_arrayref('select count(*) as NumberOfOverdues14Days >+ from issues >+ where date_due >+ between DATE_SUB(CURDATE(), INTERVAL 14 DAY) AND DATE_SUB(CURDATE(), INTERVAL 8 DAY)', {Columns => {}} ); >+ $dbh->disconnect; >+ return $overdues_14days_system; >+ >+} >+ >+sub number_of_overdues_21days_library_xml { >+ my $dbh = C4::Context->dbh; >+ my $overdues_21days_library = $dbh->selectall_arrayref('select branches.branchcode as BranchCode, IFNULL(SubTotal.Overdues,0) as NumberOfOverdues21Days >+ from branches >+ left join >+ (select branchcode, count(*) as Overdues >+ from issues >+ where date_due between DATE_SUB(CURDATE(), INTERVAL 21 DAY) AND DATE_SUB(CURDATE(), INTERVAL 15 DAY) >+ group by branchcode) SubTotal >+ on branches.branchcode=SubTotal.branchcode', {Columns => {} }); >+ $dbh->disconnect; >+ return $overdues_21days_library; >+ >+} >+ >+sub number_of_overdues_21days_system_xml { >+ my $dbh = C4::Context->dbh; >+ my $overdues_21days_system = $dbh->selectall_arrayref('select count(*) as NumberOfOverdues21Days >+ from issues >+ where date_due between DATE_SUB(CURDATE(), INTERVAL 21 DAY) AND DATE_SUB(CURDATE(), INTERVAL 15 DAY)' >+ , {Columns => {} }); >+ return $overdues_21days_system; >+ >+} >+ >+sub number_of_veryoverdue_library_xml { >+ my $dbh = C4::Context->dbh; >+ my $very_overdue_library = $dbh->selectall_arrayref('select branches.branchcode as BranchCode, IFNULL(SubTotal.Overdues,0) as NumberOfVeryOverdue >+ from branches >+ left join >+ (select branchcode, count(*) as Overdues >+ from issues >+ where date_due < DATE_SUB(CURDATE(), INTERVAL 22 DAY) >+ group by branchcode) SubTotal >+ on branches.branchcode=SubTotal.branchcode', {Columns => {} }); >+ $dbh->disconnect; >+ return $very_overdue_library; >+ >+} >+ >+sub number_of_veryoverdue_system_xml { >+ my $dbh = C4::Context->dbh; >+ my $very_overdue_system = $dbh->selectall_arrayref('select count(*) as Overdues >+ from issues >+ where date_due < DATE_SUB(CURDATE(), INTERVAL 22 DAY)' ,{Columns => {} }); >+ $dbh->disconnect; >+ return $very_overdue_system; >+ >+} >+ >+ >+sub number_of_biblios_7days_xml { >+ my $dbh = C4::Context->dbh; >+ my $biblio_7days = $dbh->selectall_arrayref('SELECT count(*) as NumberOfBiblio7Days >+ FROM biblio >+ WHERE datecreated >+ between DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND CURDATE()', {Columns => {} } ); >+ $dbh->disconnect; >+ return $biblio_7days; >+ >+} >+ >+sub number_of_items_7days_system_xml { >+ my $dbh = C4::Context->dbh; >+ my $items_7days_system = $dbh->selectall_arrayref('SELECT count(*) as NumberOfItems7Days >+ FROM items >+ WHERE dateaccessioned >+ between DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND CURDATE()',{Columns =>{} } ); >+ $dbh->disconnect; >+ return $items_7days_system; >+ >+} >+ >+sub number_of_items_7days_library_xml { >+ my $dbh = C4::Context->dbh; >+ my $items_7days_library = $dbh->selectall_arrayref('select branches.branchcode as BranchCode, IFNULL(SubTotal.items,0) as NumberOfItems7DaysLibrary >+ from branches >+ left join >+ (select homebranch, count(*) as Items >+ from items >+ where dateaccessioned > DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND CURDATE() >+ group by homebranch) SubTotal >+ on branches.branchcode=SubTotal.homebranch', {Columns => {} }); >+ $dbh->disconnect; >+ return $items_7days_library; >+ >+} >+ >+sub expired_borrowers_library_xml { >+ my $dbh = C4::Context->dbh; >+ my $expired_borrowers_library = $dbh->selectall_arrayref('select branches.branchcode as BranchCode, IFNULL(SubTotal.ExpiredBorrowers,0) as ExpiredBorrowers >+ from branches >+ left join >+ (select branchcode, count(*) as ExpiredBorrowers >+ from borrowers >+ where dateexpiry < date(now()) >+ group by branchcode) SubTotal >+ on branches.branchcode=SubTotal.branchcode;',{Columns => {} } ); >+ $dbh->disconnect; >+ return $expired_borrowers_library; >+ >+} >+ >+sub expired_borrowers_system_xml { >+ my $dbh = C4::Context->dbh; >+ my $expired_borrowers_system = $dbh->selectall_arrayref('select count(*) as ExpiredBorrowers >+ from borrowers >+ where dateexpiry < date(now())', {Columns => {} }); >+ $dbh->disconnect; >+ return $expired_borrowers_system; >+ >+} >+ >+sub last_update_xml { >+ my $dbh = C4::Context->dbh; >+ my $updated = $dbh->selectall_arrayref('SELECT DATE_FORMAT(now(), "%W %M %D %Y %T") as UpdatedTime', >+ {Columns => {} }); >+ $dbh->disconnect; >+ return $updated; >+ >+} >+ >+1; >+__END__ >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 241348a..205bed5 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -13,6 +13,7 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES > INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AnonSuggestions',0,'Set to enable Anonymous suggestions to AnonymousPatron borrowernumber',NULL,'YesNo'); > 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,''); > INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('Babeltheque',0,'Turn ON Babeltheque content - See babeltheque.com to subscribe to this service','','YesNo'); >+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('DashBoardDisplayed','1','','Display Dashboard on main page','YesNo'); > > INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('authoritysep','--','Used to separate a list of authorities in a display. Usually --',10,'free'); > 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'); >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 9cd4b14..618240e 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -5336,6 +5336,14 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = "3.09.00.XXX"; >+if (C4::Context->preference("Version") < TransformToNum($DBversion)) { >+ $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('DashBoardDisplayed','1','','Display Dashboard on main page','YesNo')"); >+ print "Upgrade to $DBversion done. Added Dashboard Syspref \n"; >+ SetVersion ($DBversion); >+} >+ >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref >index 08eb954..187c0df 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref >@@ -104,3 +104,11 @@ Administration: > Common Name: the Common Name > emailAddress: the emailAddress > - field for SSL client certificate authentication >+ Dashboard: >+ - >+ - pref: DashBoardDisplayed >+ default: 0 >+ choices: >+ yes: Show >+ no: "Don't Show" >+ - switch on Dashboard on main page. >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt >index 492dca4..affb547 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt >@@ -154,8 +154,118 @@ > [% END %] > </div><!-- /koha-news --> > [% END %] >- </div> >- </div> >+ >+<!-- Dashboard, if on --> >+[% IF DashBoardDisplayed %] >+[% UNLESS nofile %] >+<fieldset class="rows"> >+<legend>Koha Library Dashboard</legend> >+ <table style="border:0px;" id="dashboard"> >+ <tr style="border-bottom: 0px;border-left: 0px;"> >+ <td style="border-left: 0px;border-bottom: 0px;"> >+ <table id="overview" width="400"> >+ <tr> >+ <th>Overview</th> >+ <th>System</th> >+ <th>My Library</th> >+ </tr> >+ <tr align="left"> >+ <td align="left">Number of Biblios >+ </td> >+ <td>[% number_of_biblios %]</td> >+ <td style="background-color:#E8E8E8"></td> >+ </tr> >+ <tr> >+ <td>Biblios added in last 7 days</td> >+ <td>[% biblios_7days %]</td> >+ <td style="background-color:#E8E8E8"></td> >+ </tr> >+ <tr> >+ <td>Number of Items</td> >+ <td>[% items_system %]</td> >+ <td>[% items_library %]</td> >+ </tr> >+ <tr> >+ <td>Number of items added in last 7 days</td> >+ <td> [% items_7days_system %]</td> >+ <td>[% items_7days_system %]</td> >+ </tr> >+ <tr> >+ <td>Registered Borrowers</td> >+ <td>[% borrowers_system %]</td> >+ <td>[% borrowers_library %]</td> >+ </tr> >+ <tr> >+ <td>Expired Borrowers</td> >+ <td>[% expired_borrowers_system %]</td> >+ <td>[% expired_borrowers_library %]</td> >+ </tr> >+ <tr> >+ <td> </td> >+ <td></td> >+ <td></td> >+ </tr> >+ >+ </table> >+ Last updated: [% last_updated %] >+ </td> >+ <td style="border-bottom: 0px;border-left: 0px;"> >+ >+ <table id="circulation" width="400"> >+ <tr> >+ <th>Circulation</th> >+ <th>System</th> >+ <th>My Library</th> >+ </tr> >+ <tr align="left"> >+ <td align="left">Items on Loan >+ </td> >+ <td>[% issues_system %]</td> >+ <td>[% issues_library %]</td> >+ </tr> >+ <tr> >+ <td>Loan History</td> >+ <td>[% loan_history_system %]</td> >+ <td>[% loan_history_library %]</td> >+ </tr> >+ <tr> >+ <td>Items Overdue</td> >+ <td>[% overdues_system %]</td> >+ <td>[% overdues_library %]</td> >+ </tr> >+ <tr> >+ <td>Overdue within 7 days</td> >+ <td>[% overdues_7days_system %]</td> >+ <td>[% overdues_7days_library %]</td> >+ </tr> >+ <tr> >+ <td>Overdue 8-14 days</td> >+ <td>[% overdues_14days_system %]</td> >+ <td>[% overdues_14days_library %]</td> >+ </tr> >+ <tr> >+ <td>Overdue 15-21 days</td> >+ <td>[% overdues_21days_system %]</td> >+ <td>[% overdues_21days_library %]</td> >+ </tr> >+ <tr> >+ <td>Very Overdue Items</td> >+ <td>[% very_overdue_system %]</td> >+ <td>[% very_overdue_library %]</td> >+ </tr> >+ </table> >+ </td> >+ </tr> >+ </table> >+</fieldset> >+</div> >+</div> >+</div> >+[% END %] >+[% END %] >+[% IF nofile %] >+<b>[% nofile %]</b> >+[% END %] > </div> > > <!-- the main div is closed in intranet-bottom.inc --> >diff --git a/mainpage.pl b/mainpage.pl >index f834985..5644542 100755 >--- a/mainpage.pl >+++ b/mainpage.pl >@@ -60,4 +60,180 @@ $template->param( > pendingsuggestions => $pendingsuggestions > ); > >+# Dashboard (If on in SysPref) >+my $nofile = "Dashboard is set to \"ON\". However there is no XML file to read. Have you run it at least once?"; >+if ( C4::Context->preference('DashBoardDisplayed') ) >+ { >+ my $koha_conf = $ENV{'KOHA_CONF'}; >+ my ($base,$file) = $koha_conf =~ m|^(.*[/\\])([^/\\]+?)$|; >+ my $xml_read = "dashboard_xml.out"; >+ my $xml_file = "$base"."$xml_read"; >+if (-e $xml_file) { >+ my $xml = new XML::Simple; >+ my $dash = $xml->XMLin($xml_file); >+ my $login_branch_name = $template->{VARS}{LoginBranchcode}; >+ my $number_of_biblios; >+ my $biblios_7days; >+ my $items_7days_system; >+ my $items_7days_library; >+ my $borrowers_system; >+ my $expired_borrowers_library; >+ my $expired_borrowers_system; >+ my $loan_history_system; >+ my $loan_history_library; >+ my $overdues_library; >+ my $overdues_system; >+ my $overdues_7days_library; >+ my $overdues_7days_system; >+ my $overdues_14days_library; >+ my $overdues_14days_system; >+ my $overdues_21days_library; >+ my $overdues_21days_system; >+ my $very_overdue_library; >+ my $very_overdue_system; >+ my $borrowers_library; >+ my $issues_library; >+ my $issues_system; >+ my $items_library; >+ my $items_system; >+ my $last_updated; >+ >+ $number_of_biblios = $dash->{biblios}->{NumberOfBiblios}; >+ $biblios_7days = $dash->{biblio_7days}->{NumberOfBiblio7Days}; >+ $items_7days_system = $dash->{items_7days_system}->{NumberOfItems7Days}; >+ $borrowers_system = $dash->{number_of_borrowers_system}->{NumberofBorrowersSystem}; >+ $loan_history_system = $dash->{loan_history_system}->{NumberOfLoans}; >+ $items_system = $dash->{items_system}->{NumberOfItemsSystem}; >+ $expired_borrowers_system = $dash->{expired_borrowers_system}->{ExpiredBorrowers}; >+ $issues_system = $dash->{issues_system}->{NumberOfIssuesSystem}; >+ $overdues_system = $dash->{overdues_system}->{NumberOfOverdues}; >+ $overdues_7days_system = $dash->{overdues_7days_system}->{NumberOfOverdues}; >+ $overdues_14days_system = $dash->{overdues_14days_system}->{NumberOfOverdues14Days}; >+ $overdues_21days_system = $dash->{overdues_21days_system}->{NumberOfOverdues21Days}; >+ $very_overdue_system = $dash->{very_overdue_system}->{Overdues}; >+ $last_updated = $dash->{last_updated}->{UpdatedTime}; >+ >+# Looping for "logged in branch" dependant data >+ foreach my $numissl(@{$dash->{issues_library}}) >+ { >+ if($numissl->{BranchCode} eq $login_branch_name) >+ { >+ $issues_library = $numissl->{NumberOfIssues} >+ } >+ } >+ foreach my $numitm(@{$dash->{items_library}}) >+ { >+ if($numitm->{BranchCode} eq $login_branch_name) >+ { >+ $items_library = $numitm->{NumberOfItems} >+ } >+ } >+ foreach my $numbor(@{$dash->{borrowers_library}}) >+ { >+ if($numbor->{BranchCode} eq $login_branch_name) >+ { >+ $borrowers_library = $numbor->{NumberOfBorrowers} >+ } >+ } >+ foreach my $numex(@{$dash->{expired_borrowers_library}}) >+ { >+ if($numex->{BranchCode} eq $login_branch_name) >+ { >+ $expired_borrowers_library = $numex->{ExpiredBorrowers} >+ } >+ } >+ >+ foreach my $numitm7(@{$dash->{items_7days_library}}) >+ { >+ if($numitm7->{BranchCode} eq $login_branch_name) >+ { >+ $items_7days_library = $numitm7->{NumberOfItems7DaysLibrary} >+ } >+ } >+ >+ foreach my $oldiss(@{$dash->{loan_history_library}}) >+ { >+ if($oldiss->{BranchCode} eq $login_branch_name) >+ { >+ $loan_history_library = $oldiss->{NumberOfLoans} >+ } >+ } >+ >+ foreach my $ovdlib(@{$dash->{overdues_library}}) >+ { >+ if($ovdlib->{BranchCode} eq $login_branch_name) >+ { >+ $overdues_library = $ovdlib->{NumberOfOverdues} >+ } >+ } >+ >+ foreach my $ovd7day(@{$dash->{overdues_7days_library}}) >+ { >+ if($ovd7day->{BranchCode} eq $login_branch_name) >+ { >+ $overdues_7days_library = $ovd7day->{NumberOfOverdues7Days} >+ } >+ } >+ >+ foreach my $ovd14day(@{$dash->{overdues_14days_library}}) >+ { >+ if($ovd14day->{BranchCode} eq $login_branch_name) >+ { >+ $overdues_14days_library = $ovd14day->{NumberOfOverdues14Days} >+ } >+ } >+ >+ foreach my $ovd21day(@{$dash->{overdues_21days_library}}) >+ { >+ if($ovd21day->{BranchCode} eq $login_branch_name) >+ { >+ $overdues_21days_library = $ovd21day->{NumberOfOverdues21Days} >+ } >+ } >+ >+ foreach my $vryod(@{$dash->{very_overdue_library}}) >+ { >+ if($vryod->{BranchCode} eq $login_branch_name) >+ { >+ $very_overdue_library = $vryod->{NumberOfVeryOverdue} >+ } >+ } >+ >+ $template->param('number_of_biblios' => $number_of_biblios, >+ 'biblios_7days' => $biblios_7days, >+ 'items_7days_system' => $items_7days_system, >+ 'items_7days_library' => $items_7days_library, >+ 'borrowers_system' => $borrowers_system, >+ 'expired_borrowers_library' => $expired_borrowers_library, >+ 'expired_borrowers_system' => $expired_borrowers_system, >+ 'overdues_library' => $overdues_library, >+ 'overdues_system' => $overdues_system, >+ 'overdues_7days_library' => $overdues_7days_library, >+ 'overdues_7days_system' => $overdues_7days_system, >+ 'overdues_14days_library' => $overdues_14days_library, >+ 'overdues_14days_system' => $overdues_14days_system, >+ 'overdues_21days_library' => $overdues_21days_library, >+ 'overdues_21days_system' => $overdues_21days_system, >+ 'very_overdue_library' => $very_overdue_library, >+ 'very_overdue_system' => $very_overdue_system, >+ 'loan_history_system' => $loan_history_system, >+ 'loan_history_library' => $loan_history_library, >+ 'issues_library' => $issues_library, >+ 'issues_system' => $issues_system, >+ 'items_library' => $items_library, >+ 'items_system' => $items_system, >+ 'borrowers_library' => $borrowers_library, >+ 'last_updated' => $last_updated >+ >+ ); >+} >+ >+elsif(!-e $xml_file) { >+ $template->param('nofile' => $nofile,); >+ } >+ >+} >+ >+# Dashboard end >+ > output_html_with_http_headers $query, $cookie, $template->output; >diff --git a/misc/migration_tools/dashboard_xml.pl b/misc/migration_tools/dashboard_xml.pl >new file mode 100644 >index 0000000..64e0a9a >--- /dev/null >+++ b/misc/migration_tools/dashboard_xml.pl >@@ -0,0 +1,82 @@ >+#!/usr/bin/perl >+use strict; >+use warnings; >+use XML::Simple; >+use C4::Context; >+use C4::DashBoard; >+ >+# This script should be run on a cron at specific intervals >+# It will generate XML with the results of the queries below >+# This can then be parsed and displayed on the Dashboard page. >+# The Syspref for Dashboard will need to be enabled too. >+ >+# Using the KOHA_CONF variable to get the base directory. >+# The generated XML file will go there >+my $koha_conf = $ENV{'KOHA_CONF'}; >+my ($base,$file) = $koha_conf =~ m|^(.*[/\\])([^/\\]+?)$|; >+my $out_file = 'dashboard_xml.out'; >+my $path = "$base"."$out_file"; >+ >+my $items_library = number_of_items_library_xml; >+my $items_system = number_of_items_system_xml; >+my $borrowers_system = number_of_borrowers_system_xml; >+my $borrowers_library = number_of_borrowers_library_xml; >+my $issues_library = number_of_issues_library_xml; >+my $issues_system = number_of_issues_system_xml; >+my $biblios = number_of_biblios_xml; >+my $loan_history_system = number_of_loan_history_system_xml; >+my $loan_history_library = number_of_loan_history_library_xml; >+my $overdues_library = number_of_overdues_library_xml; >+my $overdues_system = number_of_overdues_system_xml; >+my $biblio_7days = number_of_biblios_7days_xml; >+my $items_7days_system = number_of_items_7days_system_xml; >+my $items_7days_library = number_of_items_7days_library_xml; >+my $overdues_7days_library = number_of_overdues_7days_library_xml; >+my $overdues_7days_system = number_of_overdues_7days_system_xml; >+my $overdues_14days_library = number_of_overdues_14days_library_xml; >+my $overdues_14days_system = number_of_overdues_14days_system_xml; >+my $overdues_21days_library = number_of_overdues_21days_library_xml; >+my $overdues_21days_system = number_of_overdues_21days_system_xml; >+my $very_overdue_library = number_of_veryoverdue_library_xml; >+my $very_overdue_system = number_of_veryoverdue_system_xml; >+my $expired_borrowers_library = expired_borrowers_library_xml; >+my $expired_borrowers_system = expired_borrowers_system_xml; >+my $last_updated = last_update_xml; >+ >+ >+open my $xml_file, '>:encoding(UTF-8)', $path or die "open($path): $!"; >+ XMLout( { >+ items_library => $items_library, >+ items_system => $items_system, >+ borrowers_library => $borrowers_library, >+ issues_library => $issues_library, >+ issues_system => $issues_system, >+ biblios => $biblios, >+ loan_history_system => $loan_history_system, >+ loan_history_library => $loan_history_library, >+ overdues_library => $overdues_library, >+ overdues_system => $overdues_system, >+ biblio_7days => $biblio_7days, >+ items_7days_system => $items_7days_system, >+ items_7days_library => $items_7days_library, >+ overdues_7days_library => $overdues_7days_library, >+ overdues_7days_system => $overdues_7days_system, >+ overdues_14days_library => $overdues_14days_library, >+ overdues_14days_system => $overdues_14days_system, >+ overdues_21days_library => $overdues_21days_library, >+ overdues_21days_system => $overdues_21days_system, >+ very_overdue_library => $very_overdue_library, >+ very_overdue_system => $very_overdue_system, >+ expired_borrowers_library => $expired_borrowers_library, >+ expired_borrowers_system => $expired_borrowers_system, >+ number_of_borrowers_system => $borrowers_system, >+ last_updated => $last_updated >+ }, >+ >+ Outputfile => $xml_file, >+ XMLDecl => '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>', >+ AttrIndent => 1, >+ NoAttr => 1, >+ RootName => 'dashboard', >+ KeepRoot => 1 >+ ); >\ No newline at end of file >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 6828
:
5249
|
6317
|
6389
|
10058
|
10059
|
10217
|
10218
|
60692
|
60693