@@ -, +, @@ --- C4/Auth.pm | 1 + C4/DashBoard.pm | 338 +++++++++++++++++++++ installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 7 + .../prog/en/modules/admin/preferences/admin.pref | 8 + .../intranet-tmpl/prog/en/modules/intranet-main.tt | 113 ++++++- mainpage.pl | 176 +++++++++++ misc/migration_tools/dashboard_xml.pl | 82 +++++ 8 files changed, 725 insertions(+), 1 deletion(-) create mode 100755 C4/DashBoard.pm create mode 100644 misc/migration_tools/dashboard_xml.pl --- a/C4/Auth.pm +++ a/C4/Auth.pm @@ -467,6 +467,7 @@ sub get_template_and_user { UseKohaPlugins => C4::Context->preference('UseKohaPlugins'), UseCourseReserves => C4::Context->preference("UseCourseReserves"), useDischarge => C4::Context->preference('useDischarge'), + DashBoardDisplayed => C4::Context->preference('DashBoardDisplayed'), ); } else { --- a/C4/DashBoard.pm +++ a/C4/DashBoard.pm @@ -0,0 +1,338 @@ +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 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__ --- a/installer/data/mysql/sysprefs.sql +++ a/installer/data/mysql/sysprefs.sql @@ -137,6 +137,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('DisplayLibraryFacets', 'holding', 'home|holding|both', 'Defines which library facets to display.', 'Choice'), ('DisplayMultiPlaceHold','1','','Display the ability to place multiple holds or not','YesNo'), ('DisplayOPACiconsXSLT','1','','If ON, displays the format, audience, and material type icons in XSLT MARC21 results and detail pages in the OPAC.','YesNo'), +('DashBoardDisplayed','1','','Display Dashboard on main page','YesNo'), ('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'), ('DumpTemplateVarsIntranet', '0', NULL , 'If enabled, dump all Template Toolkit variable to a comment in the html source for the staff intranet.', 'YesNo'), ('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 +++ a/installer/data/mysql/updatedatabase.pl @@ -13926,6 +13926,13 @@ if( CheckVersion( $DBversion ) ) { print "Upgrade to $DBversion done (Bug 16034 - Integration with OverDrive Patron API)\n"; } +$DBversion = "XXX"; +if( CheckVersion( $DBversion ) ) { + $dbh->do("INSERT IGNORE 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); +} + # DEVELOPER PROCESS, search for anything to execute in the db_update directory # SEE bug 13068 # if there is anything in the atomicupdate, read and execute it. --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref @@ -402,3 +402,11 @@ Administration: choices: Zebra: Zebra Elasticsearch: Elasticsearch + Dashboard: + - + - pref: DashBoardDisplayed + default: 0 + choices: + yes: Show + no: "Don't Show" + - switch on Dashboard on main page. --- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt @@ -195,7 +195,118 @@ [% END %] [% END %] - + + +[% IF DashBoardDisplayed %] +[% UNLESS nofile %] +
+Koha Library Dashboard + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OverviewSystemMy Library
Number of Biblios + [% number_of_biblios %]
Biblios added in last 7 days[% biblios_7days %]
Number of Items[% items_system %][% items_library %]
Number of items added in last 7 days [% items_7days_system %][% items_7days_system %]
Registered Borrowers[% borrowers_system %][% borrowers_library %]
Expired Borrowers[% expired_borrowers_system %][% expired_borrowers_library %]
 
+ Last updated: [% last_updated %] +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CirculationSystemMy Library
Items on Loan + [% issues_system %][% issues_library %]
Loan History[% loan_history_system %][% loan_history_library %]
Items Overdue[% overdues_system %][% overdues_library %]
Overdue within 7 days[% overdues_7days_system %][% overdues_7days_library %]
Overdue 8-14 days[% overdues_14days_system %][% overdues_14days_library %]
Overdue 15-21 days[% overdues_21days_system %][% overdues_21days_library %]
Very Overdue Items[% very_overdue_system %][% very_overdue_library %]
+
+
+ + + +[% END %] +[% END %] +[% IF nofile %] +[% nofile %] +[% END %] [% MACRO jsinclude BLOCK %] --- a/mainpage.pl +++ a/mainpage.pl @@ -91,4 +91,180 @@ unless ($loggedinuser) { $template->param(adminWarning => 1); } +# 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; --- a/misc/migration_tools/dashboard_xml.pl +++ a/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 => '', + AttrIndent => 1, + NoAttr => 1, + RootName => 'dashboard', + KeepRoot => 1 + ); --