Bug 4461: Fix status and borrowernumber fields in problem_reports and more
authorAleisha Amohia <aleishaamohia@hotmail.com>
Wed, 18 Mar 2020 22:50:50 +0000 (22:50 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 6 Apr 2020 10:18:59 +0000 (11:18 +0100)
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>

Koha/Schema/Result/ProblemReport.pm
admin/problem-reports.pl
installer/data/mysql/atomicupdate/bug-4461_add-problem-reports-table.perl
installer/data/mysql/kohastructure.sql
koha-tmpl/intranet-tmpl/prog/en/modules/admin/problem-reports.tt
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reportproblem.tt
mainpage.pl
svc/problem_reports

index a55ad1e..f2655b5 100644 (file)
@@ -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
index 659a6e0..70b9727 100755 (executable)
@@ -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;
     }
 }
 
index 11cee3a..02dcb49 100644 (file)
@@ -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
index 38c2ee5..2b7371f 100644 (file)
@@ -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
index 4d6faf0..ceb0f6c 100644 (file)
@@ -64,6 +64,7 @@
                                 <th class="NoSort">&nbsp;</th>
                                 <th class="anti-the">Message</th>
                                 <th>Problem page</th>
+                                <th>Sent to</th>
                                 <th class="title-string">Created on</th>
                                 <th>Set by</th>
                                 <th>Status</th>
                                         [% report.content | html %]
                                     </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>[% INCLUDE 'patron-title.inc' patron => report.patron hide_patron_infos_if_needed=1 %]</td>
-                                    <td class="status[% report.status | html %]" name="status">
-                                        [% 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="status[% report.status | html %]" name="status"><span id="status_[% report.reportid | html %]">[% report.status | html %]</span></td>
                                     <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>
-                                        [% 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>
                                         [% 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>
                 $(".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(){
                     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);
index 3b5ffe3..b866967 100644 (file)
                 [% END %]
                 <h1>Report a problem</h1>
 
-                [% FOR m IN messages %]
-                    <div class="alert alert-[% m.type | html %]">
-                        [% 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 %]
+                        <div class="alert alert-[% m.type | html %]">
+                            [% 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 %]
-                    </div>
-                [% END %]
+                        </div>
+                    [% END %]
+                [% ELSE %]
 
-                [% IF success_on_send %]
-                    <div class="alert alert-info">
-                        [% IF recipient == 'admin' %]
-                            Your problem report has been sent to the Koha administrator.
-                        [% ELSE %]
-                            Your problem report has been sent to the library.
-                        [% END %]
-                    </div>
-                [% END %]
+                    <div id="reportproblem" class="maincontent toptabs">
+                        <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 id="reportproblem" class="maincontent toptabs">
-                    <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 -->
+                [% END %]
 
                 </div> <!-- / .span10/12 -->
             </div> <!-- / .row-fluid -->
index 75072b1..ff234f6 100755 (executable)
@@ -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,
index 0641f97..9fedc92 100755 (executable)
@@ -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';
         }
     }