From 185adc167433133626710edd296555db2d27865c Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Wed, 11 Mar 2020 01:52:27 +0000 Subject: [PATCH] Bug 4461: Manage problem reports on the staff client Test plan: - Update database and upgrade schema files (if you haven't already). Restart memcached - Check your user's permissions and ensure the 'problem_reports' permission is ticked. Confirm the OPACReportProblem syspref is enabled - Log into the OPAC and submit a problem report - Log into the staff client - You should see a box at the bottom of the main page showing your pending problem report - Click the link and confirm it takes you to the new page for managing problem reports - Go to Administration - Confirm you can see a link to 'OPAC problem reports' under the 'Additional parameters' heading - Click 'OPAC problem reports' - Confirm your problem report is showing in the table - Open the OPAC in another tab and submit at least two more problem reports (so you should have at least three in the table after refreshing) - Try the different buttons - selecting multiple problem reports and using the big 'mark viewed', 'mark closed', 'mark new' buttons. Confirm there are no failures and that the number of selected problem reports is correct - select all, clear all, hide viewed, hide closed, hide new, show all - individual 'mark viewed', 'mark closed', 'mark new' buttons for each problem report. Confirm the status shows and the correct button is disabled while others are enabled - Confirm the problem page link works as expected Sponsored-by: Catalyst IT Signed-off-by: Martin Renvoize Signed-off-by: David Nind Signed-off-by: Jonathan Druart Signed-off-by: Martin Renvoize --- admin/problem-reports.pl | 73 ++++++ .../prog/en/modules/admin/problem-reports.tt | 235 ++++++++++++++++++ svc/problem_reports | 68 +++++ 3 files changed, 376 insertions(+) create mode 100755 admin/problem-reports.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/admin/problem-reports.tt create mode 100755 svc/problem_reports diff --git a/admin/problem-reports.pl b/admin/problem-reports.pl new file mode 100755 index 0000000000..659a6e0e2d --- /dev/null +++ b/admin/problem-reports.pl @@ -0,0 +1,73 @@ +#!/usr/bin/perl + +# Copyright 2020 Aleisha Amohia +# +# 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::Context; +use C4::Output; +use C4::Auth; +use Koha::ProblemReports; + +my $query = new CGI; + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "admin/problem-reports.tt", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => { problem_reports => 1 }, + } +); + +my $action; +foreach (qw( viewed closed new )) { + $action = $_ if ( $query->param("mark_selected-$_") ); +} +$action ||= 'none'; + +my @report_ids = $query->multi_param('report_ids'); + +if ( $action eq 'viewed' ) { + foreach my $report_id ( @report_ids ) { + my $report = Koha::ProblemReports->find($report_id); + $report->set({ status => 'V' })->store; + } +} elsif ( $action eq 'closed' ) { + foreach my $report_id ( @report_ids ) { + my $report = Koha::ProblemReports->find($report_id); + $report->set({ status => 'C' })->store; + } + +} elsif ( $action eq 'new' ) { + foreach my $report_id ( @report_ids ) { + my $report = Koha::ProblemReports->find($report_id); + $report->set({ status => 'N' })->store; + } +} + +my $problem_reports = Koha::ProblemReports->search(); +$template->param( + selected_count => scalar(@report_ids), + action => $action, + problem_reports => $problem_reports, +); + +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/problem-reports.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/problem-reports.tt new file mode 100644 index 0000000000..4d6faf0c6f --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/problem-reports.tt @@ -0,0 +1,235 @@ +[% USE raw %] +[% USE Asset %] +[% USE Koha %] +[% USE KohaDates %] +[% SET footerjs = 1 %] +[% INCLUDE 'doc-head-open.inc' %] +Koha › Administration › OPAC problem reports +[% INCLUDE 'doc-head-close.inc' %] + + + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'prefs-admin-search.inc' %] + + +
+
+
+
+ +

OPAC problem reports

+ + + + [% IF ( selected_count ) %] +
+ [% IF ( action == 'viewed' ) %] + [% selected_count | html %] problem report(s) marked as viewed. + [% ELSIF ( action == 'closed' ) %] + [% selected_count | html %] problem report(s) marked as closed. + [% ELSIF ( action == 'new' ) %] + [% selected_count | html %] problem report(s) marked as new. + [% ELSE %] + Failed to change the status of [% selected_count | html %] problem report(s). + [% END %] +
+ [% END %] + + [% IF ( problem_reports.count ) %] +
+
+ + + +
+ +
+ Select all + | Clear all + | Hide viewed + | Hide closed + | Hide new + | Show all +
+ + + + + + + + + + + + + + + [% FOREACH report IN problem_reports %] + + + + + + + + + + [% END %] + +
 MessageProblem pageCreated onSet byStatusActions
+ [% report.title | html %]
+ [% report.content | html %] +
[% report.problempage | html %][% report.created_on | $KohaDates with_hours => 1 %][% INCLUDE 'patron-title.inc' patron => report.patron hide_patron_infos_if_needed=1 %] + [% IF ( report.status == 'V' ) %] + Viewed + [% ELSIF ( report.status == 'C' ) %] + Closed + [% ELSE %] + New + [% END %] + + [% IF ( report.status == 'N' ) %] + + [% ELSIF ( report.status == 'V' ) %] + + [% ELSE %] + + [% END %] +
+ +
+ + [% ELSE %] +
There are currently no problem reports.
+ [% END %] + +
+
+ +
+ +
+ +
+ +[% MACRO jsinclude BLOCK %] + [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %] + [% INCLUDE 'calendar.inc' %] + [% INCLUDE 'datatables.inc' %] + +[% END %] + +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/svc/problem_reports b/svc/problem_reports new file mode 100755 index 0000000000..0641f9794f --- /dev/null +++ b/svc/problem_reports @@ -0,0 +1,68 @@ +#!/usr/bin/perl + +# This file is part of Koha. +# +# Copyright 2020 Aleisha Amohia +# +# 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 JSON qw( to_json ); +use CGI; +use C4::Service; +use C4::Auth qw /check_cookie_auth/; +use C4::Output qw(:DEFAULT :ajax); +use Koha::ProblemReports; + +=head1 NAME + +svc/problem_reports - Web service for managing OPAC problem reports + +=head1 DESCRIPTION + +=cut + +# AJAX requests +my $is_ajax = is_ajax(); +my $query = new CGI; +my ( $auth_status, $sessionID ) = check_cookie_auth( $query->cookie('CGISESSID'), { problem_reports => 1 } ); +if ( $auth_status ne "ok" ) { + exit 0; +} +if ($is_ajax) { + my $report_id = $query->param('report_id'); + my $report = Koha::ProblemReports->find($report_id); + my $action = $query->param('action'); + my $status = 'success'; + if ( $action eq 'viewed' ) { + $report->set({ status => 'V' })->store; + if ( $report->status ne 'V' ) { + $status = 'failure'; + } + } elsif ( $action eq 'closed' ) { + $report->set({ status => 'C' })->store; + if ( $report->status ne 'C' ) { + $status = 'failure'; + } + } elsif ( $action eq 'new' ) { + $report->set({ status => 'N' })->store; + if ( $report->status ne 'N' ) { + $status = 'failure'; + } + } + my $json = to_json ( { status => $status } ); + output_with_http_headers $query, undef, $json, 'js'; + exit; +} -- 2.39.5