[Patches] [PATCH] Bug 6828 - Add Admin Dashboard for staff users.

koha-patchbot at kohaaloha.com koha-patchbot at kohaaloha.com
Thu Nov 17 03:05:02 NZDT 2011


From: Barry Cannon <barry at oslo.ie>
Date: Wed, 16 Nov 2011 13:51:06 +0000
Subject: [PATCH] Bug 6828 - Add Admin Dashboard for staff users.
 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.
Content-Type: text/plain; charset="utf-8"

---
 C4/Auth.pm                                         |    3 +-
 C4/DashBoard.pm                                    |  341 ++++++++++++++++++++
 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 |  111 +++++++
 mainpage.pl                                        |  176 ++++++++++
 7 files changed, 647 insertions(+), 1 deletions(-)
 create mode 100755 C4/DashBoard.pm

diff --git a/C4/Auth.pm b/C4/Auth.pm
index e360e10..4f418c7 100755
--- a/C4/Auth.pm
+++ b/C4/Auth.pm
@@ -389,7 +389,8 @@ sub get_template_and_user {
             virtualshelves              => C4::Context->preference("virtualshelves"),
             StaffSerialIssueDisplayCount => C4::Context->preference("StaffSerialIssueDisplayCount"),
             NoZebra                     => C4::Context->preference('NoZebra'),
-		EasyAnalyticalRecords => C4::Context->preference('EasyAnalyticalRecords'),
+            EasyAnalyticalRecords => C4::Context->preference('EasyAnalyticalRecords'),
+	    DashBoardDisplayed          => C4::Context->preference('DashBoardDisplayed')
         );
     }
     else {
diff --git a/C4/DashBoard.pm b/C4/DashBoard.pm
new file mode 100755
index 0000000..2270aba
--- /dev/null
+++ b/C4/DashBoard.pm
@@ -0,0 +1,341 @@
+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 ae2c1cb..da36014 100755
--- 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 815a71d..915c7ee 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -4550,6 +4550,14 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     SetVersion ($DBversion);
 }
 
+$DBversion = "3.06.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 DropAllForeignKeys($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 f026c7e..551ace9 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
@@ -95,3 +95,11 @@ Administration:
         -
             - The CAS Authentication Server can be found at
             - pref: casServerUrl           
+    Dashboard:
+        -
+            - pref: DashBoardDisplayed
+              default: 1
+              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 0a2b20c..ea4c6a6 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt
@@ -117,6 +117,117 @@
 		</div><!-- /koha-news -->
 	</div>
 [% END %]
+
+<!-- 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>
 [% INCLUDE 'intranet-bottom.inc' %]
diff --git a/mainpage.pl b/mainpage.pl
index 25ee475..62d3fee 100755
--- a/mainpage.pl
+++ b/mainpage.pl
@@ -67,4 +67,180 @@ $template->param(
     koha_news_count => $koha_news_count
 );
 
+# 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?";
+unless ( C4::Context->preference('DashBoardDisplayed') == 0 )
+    {
+    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;
-- 
1.7.2.5




More information about the Patches mailing list