From 3d46c0c7bb8ce487f85cd0d0233cb7ceffcbbde3 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 20 Dec 2016 22:29:53 +0000 Subject: [PATCH] Bug 14608: Add a page to configure shared statistics This patch set adds: - a reference to Hea at the end of the installation process - a link to the new page from the admin home page - a new page to easily configure shared statistics Signed-off-by: Mark Tompsett Signed-off-by: Chris Cormack Signed-off-by: Marcel de Rooy Signed-off-by: Brendan A Gallagher --- admin/usage_statistics.pl | 58 +++ .../prog/en/modules/admin/usage_statistics.tt | 372 ++++++++++++++++++ 2 files changed, 430 insertions(+) create mode 100755 admin/usage_statistics.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/admin/usage_statistics.tt diff --git a/admin/usage_statistics.pl b/admin/usage_statistics.pl new file mode 100755 index 0000000000..4573321758 --- /dev/null +++ b/admin/usage_statistics.pl @@ -0,0 +1,58 @@ +#!/usr/bin/perl + +# 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 3 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, see . + +use Modern::Perl; + +use CGI qw ( -utf8 ); +use C4::Auth; +use C4::Output; +use Koha::DateUtils qw( dt_from_string output_pref ); + +my $query = new CGI; +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "admin/usage_statistics.tt", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => { parameters => '*' }, + debug => 1, + } +); + +my $op = $query->param('op') || q||; + +if ( $op eq 'update' ) { + my $UsageStats = $query->param('UsageStats'); + my $UsageStatsCountry = $query->param('UsageStatsCountry'); + my $UsageStatsLibraryName = $query->param('UsageStatsLibraryName'); + my $UsageStatsLibraryType = $query->param('UsageStatsLibraryType'); + my $UsageStatsLibraryUrl = $query->param('UsageStatsLibraryUrl'); + C4::Context->set_preference('UsageStats', $UsageStats); + C4::Context->set_preference('UsageStatsCountry', $UsageStatsCountry); + C4::Context->set_preference('UsageStatsLibraryName', $UsageStatsLibraryName); + C4::Context->set_preference('UsageStatsLibraryType', $UsageStatsLibraryType); + C4::Context->set_preference('UsageStatsLibraryUrl', $UsageStatsLibraryUrl); + +} + +if ( C4::Context->preference('UsageStatsLastUpdateTime') ) { + my $dt = DateTime->from_epoch( epoch => C4::Context->preference('UsageStatsLastUpdateTime')); + $template->param(UsageStatsLastUpdateTime => output_pref($dt) ); +} + +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/usage_statistics.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/usage_statistics.tt new file mode 100644 index 0000000000..4b943eabf8 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/usage_statistics.tt @@ -0,0 +1,372 @@ +[% USE Koha %] +[% USE KohaDates %] +[% USE Price %] +[% INCLUDE 'doc-head-open.inc' %] +Koha › Administration › Koha usage statistics +[% INCLUDE 'doc-head-close.inc' %] +[% INCLUDE 'calendar.inc' %] + + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'patrons-admin-search.inc' %] + + + +
+
+
+
+ +[% FOR m IN messages %] +
+ [% SWITCH m.code %] + [% CASE 'error_on_update' %] + An error occurred when updating this patron category. Perhaps it already exists. + [% CASE 'error_on_insert' %] + An error occurred when inserting this patron category. The patron category might already exist. + [% CASE 'error_on_delete' %] + An error occurred when deleting this patron category. Check the logs. + [% CASE 'success_on_update' %] + Patron category updated successfully. + [% CASE 'success_on_insert' %] + Patron category inserted successfully. + [% CASE 'success_on_delete' %] + Patron category deleted successfully. + [% CASE 'already_exists' %] + This patron category already exists. + [% CASE %] + [% m.code %] + [% END %] +
+[% END %] + +[% IF NOT Koha.Preference('UsageStats') %] +
You are not sharing any data with the Koha community
+[% END %] + +
+

Modify the statistics you share with the Koha community

+
+
    +
  1. + Share my Koha usage statistics: + +
  2. +
  3. + Your country: + [% SET UsageStatsCountry = Koha.Preference('UsageStatsCountry') %] + [% SET IsUsageStatsCountryValid = 0 %] + [% IF NOT UsageStatsCountry %] + [% SET IsUsageStatsCountryValid = 1 %] + [% END %] + + [% UNLESS IsUsageStatsCountryValid %] + Note: The value of your system preference 'UsageStatsCountry' is not valid ([% UsageStatsCountry %]). + Please select a valid one. + [% END %] +
  4. +
  5. + Library name: + +
  6. +
  7. + Library type: + [% SET UsageStatsLibraryType = Koha.Preference('UsageStatsLibraryType') %] + +
  8. +
  9. + Library URL: + +
  10. +
  11. + Last update: + [% IF UsageStatsLastUpdateTime %] + [% UsageStatsLastUpdateTime %] + [% ELSE %] + Your data have never been shared + [% END %] +
  12. +
+
+ +
+ + + Cancel +
+
+ +
+
+
+[% INCLUDE 'admin-menu.inc' %] +
+
+[% INCLUDE 'intranet-bottom.inc' %] -- 2.39.5