Browse Source

Bug 4461: Fix status and borrowernumber fields in problem_reports and more

status varchar(6) with readable statuses
borrowernumber not null default 0
hide form if message successfully sent
fixing hide viewed and hide closed filters
adding recipient column

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
20.05.x
Aleisha Amohia 4 years ago
committed by Martin Renvoize
parent
commit
3509f9cff8
Signed by: martin.renvoize GPG Key ID: 422B469130441A0F
  1. 27
      Koha/Schema/Result/ProblemReport.pm
  2. 6
      admin/problem-reports.pl
  3. 4
      installer/data/mysql/atomicupdate/bug-4461_add-problem-reports-table.perl
  4. 4
      installer/data/mysql/kohastructure.sql
  5. 30
      koha-tmpl/intranet-tmpl/prog/en/modules/admin/problem-reports.tt
  6. 118
      koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reportproblem.tt
  7. 2
      mainpage.pl
  8. 12
      svc/problem_reports

27
Koha/Schema/Result/ProblemReport.pm

@ -46,8 +46,9 @@ __PACKAGE__->table("problem_reports");
=head2 borrowernumber =head2 borrowernumber
data_type: 'integer' data_type: 'integer'
default_value: 0
is_foreign_key: 1 is_foreign_key: 1
is_nullable: 1 is_nullable: 0
=head2 branchcode =head2 branchcode
@ -86,9 +87,9 @@ __PACKAGE__->table("problem_reports");
=head2 status =head2 status
data_type: 'varchar' data_type: 'varchar'
default_value: 'N' default_value: 'NEW'
is_nullable: 0 is_nullable: 0
size: 1 size: 6
=cut =cut
@ -100,7 +101,12 @@ __PACKAGE__->add_columns(
"content", "content",
{ data_type => "varchar", default_value => "", is_nullable => 0, size => 255 }, { data_type => "varchar", default_value => "", is_nullable => 0, size => 255 },
"borrowernumber", "borrowernumber",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, {
data_type => "integer",
default_value => 0,
is_foreign_key => 1,
is_nullable => 0,
},
"branchcode", "branchcode",
{ {
data_type => "varchar", data_type => "varchar",
@ -128,7 +134,7 @@ __PACKAGE__->add_columns(
is_nullable => 0, is_nullable => 0,
}, },
"status", "status",
{ data_type => "varchar", default_value => "N", is_nullable => 0, size => 1 }, { data_type => "varchar", default_value => "NEW", is_nullable => 0, size => 6 },
); );
=head1 PRIMARY KEY =head1 PRIMARY KEY
@ -157,12 +163,7 @@ __PACKAGE__->belongs_to(
"borrowernumber", "borrowernumber",
"Koha::Schema::Result::Borrower", "Koha::Schema::Result::Borrower",
{ borrowernumber => "borrowernumber" }, { borrowernumber => "borrowernumber" },
{ { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
is_deferrable => 1,
join_type => "LEFT",
on_delete => "CASCADE",
on_update => "CASCADE",
},
); );
=head2 branchcode =head2 branchcode
@ -181,8 +182,8 @@ __PACKAGE__->belongs_to(
); );
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-03-11 08:28:15 # Created by DBIx::Class::Schema::Loader v0.07042 @ 2020-03-18 22:36:43
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:qVNVIuurFD6Q6p4YA5Kptg # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:XQn+sJwh4s+EK9vf2gQ7Qw
# You can replace this text with custom code or comments, and it will be preserved on regeneration # You can replace this text with custom code or comments, and it will be preserved on regeneration

6
admin/problem-reports.pl

@ -48,18 +48,18 @@ my @report_ids = $query->multi_param('report_ids');
if ( $action eq 'viewed' ) { if ( $action eq 'viewed' ) {
foreach my $report_id ( @report_ids ) { foreach my $report_id ( @report_ids ) {
my $report = Koha::ProblemReports->find($report_id); my $report = Koha::ProblemReports->find($report_id);
$report->set({ status => 'V' })->store; $report->set({ status => 'Viewed' })->store;
} }
} elsif ( $action eq 'closed' ) { } elsif ( $action eq 'closed' ) {
foreach my $report_id ( @report_ids ) { foreach my $report_id ( @report_ids ) {
my $report = Koha::ProblemReports->find($report_id); my $report = Koha::ProblemReports->find($report_id);
$report->set({ status => 'C' })->store; $report->set({ status => 'Closed' })->store;
} }
} elsif ( $action eq 'new' ) { } elsif ( $action eq 'new' ) {
foreach my $report_id ( @report_ids ) { foreach my $report_id ( @report_ids ) {
my $report = Koha::ProblemReports->find($report_id); my $report = Koha::ProblemReports->find($report_id);
$report->set({ status => 'N' })->store; $report->set({ status => 'New' })->store;
} }
} }

4
installer/data/mysql/atomicupdate/bug-4461_add-problem-reports-table.perl

@ -6,13 +6,13 @@ if( CheckVersion( $DBversion ) ) {
reportid int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha reportid int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
title varchar(40) NOT NULL default '', -- report subject line title varchar(40) NOT NULL default '', -- report subject line
content varchar(255) NOT NULL default '', -- report message content content varchar(255) NOT NULL default '', -- report message content
borrowernumber int(11) default NULL, -- the user who created the problem report borrowernumber int(11) NOT NULL default 0, -- the user who created the problem report
branchcode varchar(10) NOT NULL default '', -- borrower's branch branchcode varchar(10) NOT NULL default '', -- borrower's branch
username varchar(75) default NULL, -- OPAC username username varchar(75) default NULL, -- OPAC username
problempage varchar(255) default NULL, -- page the user triggered the problem report form from problempage varchar(255) default NULL, -- page the user triggered the problem report form from
recipient enum('admin','library') NOT NULL default 'library', -- the 'to-address' of the problem report recipient enum('admin','library') NOT NULL default 'library', -- the 'to-address' of the problem report
created_on timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of report submission created_on timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of report submission
status varchar(1) NOT NULL default 'N', -- status of the report. N=new, V=viewed, C=closed status varchar(6) NOT NULL default 'New', -- status of the report. New, Viewed, Closed
PRIMARY KEY (reportid), PRIMARY KEY (reportid),
CONSTRAINT problem_reports_ibfk1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT problem_reports_ibfk1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT problem_reports_ibfk2 FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE CONSTRAINT problem_reports_ibfk2 FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE

4
installer/data/mysql/kohastructure.sql

@ -4445,13 +4445,13 @@ CREATE TABLE `problem_reports` (
`reportid` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha `reportid` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
`title` varchar(40) NOT NULL default '', -- report subject line `title` varchar(40) NOT NULL default '', -- report subject line
`content` varchar(255) NOT NULL default '', -- report message content `content` varchar(255) NOT NULL default '', -- report message content
`borrowernumber` int(11) default NULL, -- the user who created the problem report `borrowernumber` int(11) NOT NULL default 0, -- the user who created the problem report
`branchcode` varchar(10) NOT NULL default '', -- borrower's branch `branchcode` varchar(10) NOT NULL default '', -- borrower's branch
`username` varchar(75) default NULL, -- OPAC username `username` varchar(75) default NULL, -- OPAC username
`problempage` varchar(255) default NULL, -- page the user triggered the problem report form from `problempage` varchar(255) default NULL, -- page the user triggered the problem report form from
`recipient` enum('admin','library') NOT NULL default 'library', -- the 'to-address' of the problem report `recipient` enum('admin','library') NOT NULL default 'library', -- the 'to-address' of the problem report
`created_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of report submission `created_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of report submission
`status` varchar(1) NOT NULL default 'N', -- status of the report. N=new, V=viewed, C=closed `status` varchar(6) NOT NULL default 'New', -- status of the report. New, Viewed, Closed
PRIMARY KEY (`reportid`), PRIMARY KEY (`reportid`),
CONSTRAINT `problem_reports_ibfk1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `problem_reports_ibfk1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `problem_reports_ibfk2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE CONSTRAINT `problem_reports_ibfk2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE

30
koha-tmpl/intranet-tmpl/prog/en/modules/admin/problem-reports.tt

@ -64,6 +64,7 @@
<th class="NoSort">&nbsp;</th> <th class="NoSort">&nbsp;</th>
<th class="anti-the">Message</th> <th class="anti-the">Message</th>
<th>Problem page</th> <th>Problem page</th>
<th>Sent to</th>
<th class="title-string">Created on</th> <th class="title-string">Created on</th>
<th>Set by</th> <th>Set by</th>
<th>Status</th> <th>Status</th>
@ -79,21 +80,14 @@
[% report.content | html %] [% report.content | html %]
</td> </td>
<td><a href="[% report.problempage | uri %]">[% report.problempage | html %]</a></td> <td><a href="[% report.problempage | uri %]">[% report.problempage | html %]</a></td>
<td>[% report.recipient %]</td>
<td><span title="[% report.created_on | html %]">[% report.created_on | $KohaDates with_hours => 1 %]</span></td> <td><span title="[% report.created_on | html %]">[% report.created_on | $KohaDates with_hours => 1 %]</span></td>
<td>[% INCLUDE 'patron-title.inc' patron => report.patron hide_patron_infos_if_needed=1 %]</td> <td>[% INCLUDE 'patron-title.inc' patron => report.patron hide_patron_infos_if_needed=1 %]</td>
<td class="status[% report.status | html %]" name="status"> <td class="status[% report.status | html %]" name="status"><span id="status_[% report.reportid | html %]">[% report.status | html %]</span></td>
[% IF ( report.status == 'V' ) %]
<span id="status_[% report.reportid | html %]">Viewed</span>
[% ELSIF ( report.status == 'C' ) %]
<span id="status_[% report.reportid | html %]">Closed</span>
[% ELSE %]
<span id="status_[% report.reportid | html %]">New</span>
[% END %]
</td>
<td class="actions"> <td class="actions">
[% IF ( report.status == 'N' ) %] [% IF ( report.status == 'New' ) %]
<button name="viewed" data-report_id="[% report.reportid | html %]" class="viewed btn btn-default btn-xs"><i class="fa fa-eye"></i> Mark viewed</button> <button name="closed" data-report_id="[% report.reportid | html %]" class="closed btn btn-default btn-xs"><i class="fa fa-times-circle"></i> Mark closed</button> <button name="new" disabled="disabled" data-report_id="[% report.reportid | html %]" class="new btn btn-default btn-xs"><i class="fa fa-star"></i> Mark new</button> <button name="viewed" data-report_id="[% report.reportid | html %]" class="viewed btn btn-default btn-xs"><i class="fa fa-eye"></i> Mark viewed</button> <button name="closed" data-report_id="[% report.reportid | html %]" class="closed btn btn-default btn-xs"><i class="fa fa-times-circle"></i> Mark closed</button> <button name="new" disabled="disabled" data-report_id="[% report.reportid | html %]" class="new btn btn-default btn-xs"><i class="fa fa-star"></i> Mark new</button>
[% ELSIF ( report.status == 'V' ) %] [% ELSIF ( report.status == 'Viewed' ) %]
<button name="viewed" disabled="disabled" data-report_id="[% report.reportid | html %]" class="viewed btn btn-default btn-xs"><i class="fa fa-eye"></i> Mark viewed</button> <button name="closed" data-report_id="[% report.reportid | html %]" class="closed btn btn-default btn-xs"><i class="fa fa-times-circle"></i> Mark closed</button> <button name="new" data-report_id="[% report.reportid | html %]" class="new btn btn-default btn-xs"><i class="fa fa-star"></i> Mark new</button> <button name="viewed" disabled="disabled" data-report_id="[% report.reportid | html %]" class="viewed btn btn-default btn-xs"><i class="fa fa-eye"></i> Mark viewed</button> <button name="closed" data-report_id="[% report.reportid | html %]" class="closed btn btn-default btn-xs"><i class="fa fa-times-circle"></i> Mark closed</button> <button name="new" data-report_id="[% report.reportid | html %]" class="new btn btn-default btn-xs"><i class="fa fa-star"></i> Mark new</button>
[% ELSE %] [% ELSE %]
<button name="viewed" data-report_id="[% report.reportid | html %]" class="viewed btn btn-default btn-xs"><i class="fa fa-eye"></i> Mark viewed</button> <button name="closed" disabled="disabled" data-report_id="[% report.reportid | html %]" class="closed btn btn-default btn-xs"><i class="fa fa-times-circle"></i> Mark closed</button> <button name="new" data-report_id="[% report.reportid | html %]" class="new btn btn-default btn-xs"><i class="fa fa-star"></i> Mark new</button> <button name="viewed" data-report_id="[% report.reportid | html %]" class="viewed btn btn-default btn-xs"><i class="fa fa-eye"></i> Mark viewed</button> <button name="closed" disabled="disabled" data-report_id="[% report.reportid | html %]" class="closed btn btn-default btn-xs"><i class="fa fa-times-circle"></i> Mark closed</button> <button name="new" data-report_id="[% report.reportid | html %]" class="new btn btn-default btn-xs"><i class="fa fa-star"></i> Mark new</button>
@ -151,16 +145,18 @@
$(".marknew").prop("disabled", true); $(".marknew").prop("disabled", true);
}); });
$(".HideViewed").on("click", function(){ $(".HideViewed").on("click", function(){
$(".statusV").parent().hide(); $(".statusViewed").parent().hide();
}); });
$(".HideClosed").on("click", function(){ $(".HideClosed").on("click", function(){
$(".statusC").parent().hide(); $(".statusClosed").parent().hide();
}); });
$(".HideNew").on("click", function(){ $(".HideNew").on("click", function(){
$(".statusN").parent().hide(); $(".statusNew").parent().hide();
}); });
$(".ShowAll").on("click", function(){ $(".ShowAll").on("click", function(){
@ -201,19 +197,19 @@
if (data.status == 'success'){ if (data.status == 'success'){
if ( $action == 'viewed' ){ if ( $action == 'viewed' ){
$("#status_" + $report_id).text(_("Viewed")); $("#status_" + $report_id).text(_("Viewed"));
$(event.target).parent().siblings("status").removeClass().addClass("statusV"); $(event.target).parent().siblings("[name='status']").removeClass().addClass("statusViewed");
$(event.target).siblings(".closed").prop("disabled", false); $(event.target).siblings(".closed").prop("disabled", false);
$(event.target).siblings(".new").prop("disabled", false); $(event.target).siblings(".new").prop("disabled", false);
$(event.target).prop("disabled", true); $(event.target).prop("disabled", true);
} else if ( $action == 'new' ){ } else if ( $action == 'new' ){
$("#status_" + $report_id).text(_("New")); $("#status_" + $report_id).text(_("New"));
$(event.target).parent().siblings("status").removeClass().addClass("statusN"); $(event.target).parent().siblings("[name='status']").removeClass().addClass("statusNew");
$(event.target).siblings(".closed").prop("disabled", false); $(event.target).siblings(".closed").prop("disabled", false);
$(event.target).siblings(".viewed").prop("disabled", false); $(event.target).siblings(".viewed").prop("disabled", false);
$(event.target).prop("disabled", true); $(event.target).prop("disabled", true);
} else { } else {
$("#status_" + $report_id).text(_("Closed")); $("#status_" + $report_id).text(_("Closed"));
$(event.target).parent().siblings("status").removeClass().addClass("statusC"); $(event.target).parent().siblings("[name='status']").removeClass().addClass("statusClosed");
$(event.target).siblings(".viewed").prop("disabled", false); $(event.target).siblings(".viewed").prop("disabled", false);
$(event.target).siblings(".new").prop("disabled", false); $(event.target).siblings(".new").prop("disabled", false);
$(event.target).prop("disabled", true); $(event.target).prop("disabled", true);

118
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reportproblem.tt

@ -27,71 +27,65 @@
[% END %] [% END %]
<h1>Report a problem</h1> <h1>Report a problem</h1>
[% FOR m IN messages %] [% IF messages %]
<div class="alert alert-[% m.type | html %]"> [% FOR m IN messages %]
[% SWITCH m.code %] <div class="alert alert-[% m.type | html %]">
[% CASE 'success_on_send' %] [% SWITCH m.code %]
[% IF recipient == 'admin' %] [% CASE 'success_on_send' %]
Your problem report has been sent to the Koha administrator. [% IF recipient == 'admin' %]
[% ELSE %] Your problem report has been sent to the Koha administrator.
Your problem report has been sent to the library. [% ELSE %]
Your problem report has been sent to the library.
[% END %]
[% CASE 'error_on_send' %][#% We really should avoid reaching this! %]
Something wrong happened when sending the report. Please contact your library.
[% END %] [% END %]
[% CASE 'error_on_send' %][#% We really should avoid reaching this! %] </div>
Something wrong happened when sending the report. Please contact your library. [% END %]
[% END %] [% ELSE %]
</div>
[% END %]
[% IF success_on_send %] <div id="reportproblem" class="maincontent toptabs">
<div class="alert alert-info"> <form name="reportlibform" action="/cgi-bin/koha/opac-reportproblem.pl" method="post">
[% IF recipient == 'admin' %] <input type="hidden" name="op" value="addreport">
Your problem report has been sent to the Koha administrator. <fieldset class="rows">
[% ELSE %] <ol>
Your problem report has been sent to the library. <li>
[% END %] <label for="recipient">Send problem report to: </label>
</div> [% IF library.branchemail %]
[% END %] <select name="recipient" id="recipient">
<option value="library">A librarian</option>
<option value="admin">Koha administrator</option>
</select>
[% ELSE %]
<span>Koha administrator</span>
[% END %]
</li>
<li>
<label for="problempage">Problem found on page: </label>
<input type="hidden" name="problempage" id="problempage" value="[% problempage | html %]">
[% problempage | html %]
</li>
<li>
<label for="user">Username: </label>
<input type="hidden" name="user" id="user" value="[% username | html %]" class="span3">
[% username | html %]
<li>
<label for="subject">Subject: </label>
<input type="text" name="subject" id="subject" value="[% subject | html %]" class="span3">
</li>
<li>
<label for="message">Message: </label>
<textarea name="message" id="message" rows="7" cols="60"></textarea>
</li>
</ol>
</fieldset>
<fieldset class="action">
<input type="submit" value="Submit" class="btn">
</fieldset>
</form>
</div> <!-- / #reportproblem -->
<div id="reportproblem" class="maincontent toptabs"> [% END %]
<form name="reportlibform" action="/cgi-bin/koha/opac-reportproblem.pl" method="post">
<input type="hidden" name="op" value="addreport">
<fieldset class="rows">
<ol>
<li>
<label for="recipient">Send problem report to: </label>
[% IF library.branchemail %]
<select name="recipient" id="recipient">
<option value="library">A librarian</option>
<option value="admin">Koha administrator</option>
</select>
[% ELSE %]
<span>Koha administrator</span>
[% END %]
</li>
<li>
<label for="problempage">Problem found on page: </label>
<input type="hidden" name="problempage" id="problempage" value="[% problempage | html %]">
[% problempage | html %]
</li>
<li>
<label for="user">Username: </label>
<input type="hidden" name="user" id="user" value="[% username | html %]" class="span3">
[% username | html %]
<li>
<label for="subject">Subject: </label>
<input type="text" name="subject" id="subject" value="[% subject | html %]" class="span3">
</li>
<li>
<label for="message">Message: </label>
<textarea name="message" id="message" rows="7" cols="60"></textarea>
</li>
</ol>
</fieldset>
<fieldset class="action">
<input type="submit" value="Submit" class="btn">
</fieldset>
</form>
</div> <!-- / #reportproblem -->
</div> <!-- / .span10/12 --> </div> <!-- / .span10/12 -->
</div> <!-- / .row-fluid --> </div> <!-- / .row-fluid -->

2
mainpage.pl

@ -75,7 +75,7 @@ my $pending_article_requests = Koha::ArticleRequests->search_limited(
$branch ? ( 'me.branchcode' => $branch ) : (), $branch ? ( 'me.branchcode' => $branch ) : (),
} }
)->count; )->count;
my $pending_problem_reports = Koha::ProblemReports->search({ status => 'N' }); my $pending_problem_reports = Koha::ProblemReports->search({ status => 'New' });
$template->param( $template->param(
pendingcomments => $pendingcomments, pendingcomments => $pendingcomments,

12
svc/problem_reports

@ -47,18 +47,18 @@ if ($is_ajax) {
my $action = $query->param('action'); my $action = $query->param('action');
my $status = 'success'; my $status = 'success';
if ( $action eq 'viewed' ) { if ( $action eq 'viewed' ) {
$report->set({ status => 'V' })->store; $report->set({ status => 'Viewed' })->store;
if ( $report->status ne 'V' ) { if ( $report->status ne 'Viewed' ) {
$status = 'failure'; $status = 'failure';
} }
} elsif ( $action eq 'closed' ) { } elsif ( $action eq 'closed' ) {
$report->set({ status => 'C' })->store; $report->set({ status => 'Closed' })->store;
if ( $report->status ne 'C' ) { if ( $report->status ne 'Closed' ) {
$status = 'failure'; $status = 'failure';
} }
} elsif ( $action eq 'new' ) { } elsif ( $action eq 'new' ) {
$report->set({ status => 'N' })->store; $report->set({ status => 'New' })->store;
if ( $report->status ne 'N' ) { if ( $report->status ne 'New' ) {
$status = 'failure'; $status = 'failure';
} }
} }

Loading…
Cancel
Save