From 3509f9cff86da2faea2ccc53ecdd0fdee70366c5 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Wed, 18 Mar 2020 22:50:50 +0000 Subject: [PATCH] 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 Signed-off-by: Jonathan Druart Signed-off-by: Martin Renvoize --- Koha/Schema/Result/ProblemReport.pm | 27 ++-- admin/problem-reports.pl | 6 +- .../bug-4461_add-problem-reports-table.perl | 4 +- installer/data/mysql/kohastructure.sql | 4 +- .../prog/en/modules/admin/problem-reports.tt | 30 ++--- .../en/modules/opac-reportproblem.tt | 118 +++++++++--------- mainpage.pl | 2 +- svc/problem_reports | 12 +- 8 files changed, 97 insertions(+), 106 deletions(-) diff --git a/Koha/Schema/Result/ProblemReport.pm b/Koha/Schema/Result/ProblemReport.pm index a55ad1ece6..f2655b5a7d 100644 --- a/Koha/Schema/Result/ProblemReport.pm +++ b/Koha/Schema/Result/ProblemReport.pm @@ -46,8 +46,9 @@ __PACKAGE__->table("problem_reports"); =head2 borrowernumber data_type: 'integer' + default_value: 0 is_foreign_key: 1 - is_nullable: 1 + is_nullable: 0 =head2 branchcode @@ -86,9 +87,9 @@ __PACKAGE__->table("problem_reports"); =head2 status data_type: 'varchar' - default_value: 'N' + default_value: 'NEW' is_nullable: 0 - size: 1 + size: 6 =cut @@ -100,7 +101,12 @@ __PACKAGE__->add_columns( "content", { data_type => "varchar", default_value => "", is_nullable => 0, size => 255 }, "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", { data_type => "varchar", @@ -128,7 +134,7 @@ __PACKAGE__->add_columns( is_nullable => 0, }, "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 @@ -157,12 +163,7 @@ __PACKAGE__->belongs_to( "borrowernumber", "Koha::Schema::Result::Borrower", { borrowernumber => "borrowernumber" }, - { - is_deferrable => 1, - join_type => "LEFT", - on_delete => "CASCADE", - on_update => "CASCADE", - }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, ); =head2 branchcode @@ -181,8 +182,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-03-11 08:28:15 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:qVNVIuurFD6Q6p4YA5Kptg +# Created by DBIx::Class::Schema::Loader v0.07042 @ 2020-03-18 22:36:43 +# 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 diff --git a/admin/problem-reports.pl b/admin/problem-reports.pl index 659a6e0e2d..70b97276c2 100755 --- a/admin/problem-reports.pl +++ b/admin/problem-reports.pl @@ -48,18 +48,18 @@ 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; + $report->set({ status => 'Viewed' })->store; } } elsif ( $action eq 'closed' ) { foreach my $report_id ( @report_ids ) { my $report = Koha::ProblemReports->find($report_id); - $report->set({ status => 'C' })->store; + $report->set({ status => 'Closed' })->store; } } elsif ( $action eq 'new' ) { foreach my $report_id ( @report_ids ) { my $report = Koha::ProblemReports->find($report_id); - $report->set({ status => 'N' })->store; + $report->set({ status => 'New' })->store; } } diff --git a/installer/data/mysql/atomicupdate/bug-4461_add-problem-reports-table.perl b/installer/data/mysql/atomicupdate/bug-4461_add-problem-reports-table.perl index 11cee3aa67..02dcb49281 100644 --- a/installer/data/mysql/atomicupdate/bug-4461_add-problem-reports-table.perl +++ b/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 title varchar(40) NOT NULL default '', -- report subject line 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 username varchar(75) default NULL, -- OPAC username 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 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), 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 diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 38c2ee55ce..2b7371fd52 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/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 `title` varchar(40) NOT NULL default '', -- report subject line `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 `username` varchar(75) default NULL, -- OPAC username `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 `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`), 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 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 index 4d6faf0c6f..ceb0f6c440 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/problem-reports.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/problem-reports.tt @@ -64,6 +64,7 @@   Message Problem page + Sent to Created on Set by Status @@ -79,21 +80,14 @@ [% report.content | html %] [% report.problempage | html %] + [% report.recipient %] [% 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 %] - + [% report.status | html %] - [% IF ( report.status == 'N' ) %] + [% IF ( report.status == 'New' ) %] - [% ELSIF ( report.status == 'V' ) %] + [% ELSIF ( report.status == 'Viewed' ) %] [% ELSE %] @@ -151,16 +145,18 @@ $(".marknew").prop("disabled", true); }); + + $(".HideViewed").on("click", function(){ - $(".statusV").parent().hide(); + $(".statusViewed").parent().hide(); }); $(".HideClosed").on("click", function(){ - $(".statusC").parent().hide(); + $(".statusClosed").parent().hide(); }); $(".HideNew").on("click", function(){ - $(".statusN").parent().hide(); + $(".statusNew").parent().hide(); }); $(".ShowAll").on("click", function(){ @@ -201,19 +197,19 @@ if (data.status == 'success'){ if ( $action == '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(".new").prop("disabled", false); $(event.target).prop("disabled", true); } else if ( $action == '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(".viewed").prop("disabled", false); $(event.target).prop("disabled", true); } else { $("#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(".new").prop("disabled", false); $(event.target).prop("disabled", true); diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reportproblem.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reportproblem.tt index 3b5ffe30f8..b866967a90 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reportproblem.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reportproblem.tt @@ -27,71 +27,65 @@ [% END %]

Report a problem

- [% FOR m IN messages %] -
- [% SWITCH m.code %] - [% CASE 'success_on_send' %] - [% IF recipient == 'admin' %] - Your problem report has been sent to the Koha administrator. - [% ELSE %] - Your problem report has been sent to the library. + [% IF messages %] + [% FOR m IN messages %] +
+ [% SWITCH m.code %] + [% CASE 'success_on_send' %] + [% IF recipient == 'admin' %] + Your problem report has been sent to the Koha administrator. + [% 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 %] - [% CASE 'error_on_send' %][#% We really should avoid reaching this! %] - Something wrong happened when sending the report. Please contact your library. - [% END %] -
- [% END %] +
+ [% END %] + [% ELSE %] - [% IF success_on_send %] -
- [% IF recipient == 'admin' %] - Your problem report has been sent to the Koha administrator. - [% ELSE %] - Your problem report has been sent to the library. - [% END %] -
- [% END %] +
+
+ +
+
    +
  1. + + [% IF library.branchemail %] + + [% ELSE %] + Koha administrator + [% END %] +
  2. +
  3. + + + [% problempage | html %] +
  4. +
  5. + + + [% username | html %] +
  6. + + +
  7. +
  8. + + +
  9. +
+
+
+ +
+
+
-
-
- -
-
    -
  1. - - [% IF library.branchemail %] - - [% ELSE %] - Koha administrator - [% END %] -
  2. -
  3. - - - [% problempage | html %] -
  4. -
  5. - - - [% username | html %] -
  6. - - -
  7. -
  8. - - -
  9. -
-
-
- -
-
-
+ [% END %] diff --git a/mainpage.pl b/mainpage.pl index 75072b1073..ff234f6baa 100755 --- a/mainpage.pl +++ b/mainpage.pl @@ -75,7 +75,7 @@ my $pending_article_requests = Koha::ArticleRequests->search_limited( $branch ? ( 'me.branchcode' => $branch ) : (), } )->count; -my $pending_problem_reports = Koha::ProblemReports->search({ status => 'N' }); +my $pending_problem_reports = Koha::ProblemReports->search({ status => 'New' }); $template->param( pendingcomments => $pendingcomments, diff --git a/svc/problem_reports b/svc/problem_reports index 0641f9794f..9fedc92ebe 100755 --- a/svc/problem_reports +++ b/svc/problem_reports @@ -47,18 +47,18 @@ if ($is_ajax) { my $action = $query->param('action'); my $status = 'success'; if ( $action eq 'viewed' ) { - $report->set({ status => 'V' })->store; - if ( $report->status ne 'V' ) { + $report->set({ status => 'Viewed' })->store; + if ( $report->status ne 'Viewed' ) { $status = 'failure'; } } elsif ( $action eq 'closed' ) { - $report->set({ status => 'C' })->store; - if ( $report->status ne 'C' ) { + $report->set({ status => 'Closed' })->store; + if ( $report->status ne 'Closed' ) { $status = 'failure'; } } elsif ( $action eq 'new' ) { - $report->set({ status => 'N' })->store; - if ( $report->status ne 'N' ) { + $report->set({ status => 'New' })->store; + if ( $report->status ne 'New' ) { $status = 'failure'; } } -- 2.39.5