Bug 19801: Display messages on user details page as well as on check out page
authorLiz Rea <liz@catalyst.net.nz>
Wed, 13 Dec 2017 02:14:58 +0000 (15:14 +1300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 8 Feb 2018 20:01:14 +0000 (17:01 -0300)
To test:

Look up a borrower, add a message (internal or opac)
Click the Details tab for that borrower
Messages should be displayed above the user information [is this the right place? it could go below]
adding messages on this page should make them immediately available
deleting messages on this page should delete them immediately and bring you back to the detail page.

Basically, make sure messages work from both the Check out and detail pages and that there are no typos.

Messages should work the same as they always have from the Check Out page.

sponsored-by: Catalyst IT
Signed-off-by: Simon Pouchol <simon.pouchol@biblibre.com>

Signed-off-by: Marjorie Vila <marjorie.barry-vila@collecto.ca>
Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com>

Bug 19801 - Fixes for QA

- Fixes indentation
- changes messages to patron_messages (even though it's not like that on the circulation page.)

Signed-off-by: Marjorie Vila <marjorie.barry-vila@collecto.ca>
Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com>

circ/del_message.pl
koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
members/moremember.pl

index ccce661..8dfa3d4 100755 (executable)
@@ -43,5 +43,10 @@ my $message_id     = $input->param('message_id');
 my $message = Koha::Patron::Messages->find($message_id);
 $message->delete if $message;
 
-print $input->redirect(
-    "/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
+if ( $input->param('from') eq  "moremember" ) {
+    print $input->redirect(
+        "/cgi-bin/koha/members/moremember.pl?borrowernumber=$borrowernumber");
+} else {
+    print $input->redirect(
+        "/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
+}
index 6277abd..cee748a 100644 (file)
@@ -41,6 +41,7 @@ var relatives_borrowernumbers = new Array();
 [% END %]
 
 var MSG_EXPORT_SELECT_CHECKOUTS = _("You must select checkout(s) to export");
+var MSG_CONFIRM_DELETE_MESSAGE = _("Are you sure you want to delete this message? This cannot be undone.");
 
 columns_settings = [% ColumnsSettings.GetColumns( 'members', 'moremember', 'issues-table', 'json' ) %]
 
@@ -190,6 +191,31 @@ function validate1(date) {
       </ul>
     </div>
     [% END %]
+    <div id="messages" class="circmessage">
+        <h4>Messages:</h4>
+        <ul>
+            [% FOREACH patron_message IN patron_messages %]
+                <li>
+                    [% IF(patron_message.message_type == "L") %]
+                        <span class="circ-hlt">
+                    [% ELSE %]
+                        <span>
+                    [% END %]
+                        [% patron_message.message_date | $KohaDates %]
+                        [% Branches.GetName( patron_message.branchcode ) %]
+                        [% IF patron_message.manager_id %]
+                            ( <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron_message.manager_id %]">[% patron_message.get_column('manager_firstname') %] [% patron_message.get_column('manager_surname') %]</a> )
+                        [% END %]
+                        <i>"[% patron_message.message | html %]"</i>
+                    </span>
+                    [% IF patron_message.branchcode == branchcode OR Koha.Preference('AllowAllMessageDeletion') %]
+                        <a class="btn btn-link btn-sm" href="/cgi-bin/koha/circ/del_message.pl?message_id=[% patron_message.message_id %]&amp;borrowernumber=[% patron_message.borrowernumber %]&amp;from=moremember" onclick="return confirm(MSG_CONFIRM_DELETE_MESSAGE);"><i class="fa fa-trash"></i> Delete</a>
+                    [% END %]
+                </li>
+            [% END %]
+        </ul>
+        <a id="addnewmessageLabel" href="#add_message_form" class="btn btn-link btn-sm" data-toggle="modal"><i class="fa fa-plus"></i> Add a new message</a>
+    </div>
 
     [% IF ( flagged ) %]
     <div id="circmessages" class="circmessage attention">
@@ -217,7 +243,6 @@ function validate1(date) {
         </ul>
     </div>
     [% END %]
-
 <h3>[% UNLESS ( I ) %]
    [% title | html %] [% firstname | html %] [% END %] [% surname | html %] ([% cardnumber | html %])</h3>
  <div class="yui-u first">
@@ -500,7 +525,6 @@ function validate1(date) {
 
 </div>
 </div>
-
 <div id="finesholdsissues" class="toptabs">
     <ul>
         <li><a href="#checkouts">[% issuecount %] Checkout(s)</a></li>
index faae4d7..1bf4d22 100755 (executable)
@@ -54,6 +54,7 @@ use Koha::AuthorisedValues;
 use Koha::CsvProfiles;
 use Koha::Patron::Debarments qw(GetDebarments);
 use Koha::Patron::Images;
+use Koha::Patron::Messages;
 use Module::Load;
 if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
     load Koha::NorwegianPatronDB, qw( NLGetSyncDataFromBorrowernumber );
@@ -331,6 +332,18 @@ if ( C4::Context->preference("ExportCircHistory") ) {
     $template->param(csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc' }) ]);
 }
 
+my $patron_messages = Koha::Patron::Messages->search(
+    {
+        'me.borrowernumber' => $borrowernumber,
+    },
+    {
+        join => 'manager',
+        '+select' => ['manager.surname', 'manager.firstname' ],
+        '+as' => ['manager_surname', 'manager_firstname'],
+    }
+);
+
+
 # Display the language description instead of the code
 # Note that this is certainly wrong
 my ( $subtag, $region ) = split '-', $patron->lang;
@@ -359,6 +372,7 @@ $template->param(
     PatronsPerPage => C4::Context->preference("PatronsPerPage") || 20,
     relatives_issues_count => $relatives_issues_count,
     relatives_borrowernumbers => \@relatives,
+    patron_messages       => $patron_messages,
 );
 
 output_html_with_http_headers $input, $cookie, $template->output;