@@ -, +, @@ IF message.branchcode == branch OR Koha.Preference('AllowAllMessageDeletion'') --- C4/Members.pm | 44 ------------------- circ/circulation.pl | 26 ++++++++---- .../prog/en/modules/circ/circulation.tt | 49 ++++++++++------------ .../opac-tmpl/bootstrap/en/modules/opac-user.tt | 9 ++-- opac/opac-user.pl | 8 +++- 5 files changed, 53 insertions(+), 83 deletions(-) --- a/C4/Members.pm +++ a/C4/Members.pm @@ -99,8 +99,6 @@ BEGIN { &GetExpiryDate &GetUpcomingMembershipExpires - &GetMessages - &IssueSlip GetBorrowersWithEmail @@ -2188,48 +2186,6 @@ sub ModPrivacy { privacy => $privacy ); } -=head2 GetMessages - - GetMessages( $borrowernumber, $type ); - -$type is message type, B for borrower, or L for Librarian. -Empty type returns all messages of any type. - -Returns all messages for the given borrowernumber - -=cut - -sub GetMessages { - my ( $borrowernumber, $type, $branchcode ) = @_; - - if ( ! $type ) { - $type = '%'; - } - - my $dbh = C4::Context->dbh; - - my $query = "SELECT - branches.branchname, - messages.*, - message_date, - messages.branchcode LIKE '$branchcode' AS can_delete - FROM messages, branches - WHERE borrowernumber = ? - AND message_type LIKE ? - AND messages.branchcode = branches.branchcode - ORDER BY message_date DESC"; - my $sth = $dbh->prepare($query); - $sth->execute( $borrowernumber, $type ) ; - my @results; - - while ( my $data = $sth->fetchrow_hashref ) { - $data->{message_date_formatted} = output_pref( { dt => dt_from_string( $data->{message_date} ), dateonly => 1, dateformat => 'iso' } ); - push @results, $data; - } - return \@results; - -} - =head2 IssueSlip IssueSlip($branchcode, $borrowernumber, $quickslip) --- a/circ/circulation.pl +++ a/circ/circulation.pl @@ -46,6 +46,7 @@ use C4::Members::Attributes qw(GetBorrowerAttributes); use Koha::Borrower::Debarments qw(GetDebarments IsDebarred); use Koha::DateUtils; use Koha::Database; +use Koha::Patron::Messages; use Date::Calc qw( Today @@ -548,11 +549,23 @@ if ( $borrowernumber && $borrower->{'category_type'} eq 'C') { $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1; } -my $lib_messages_loop = GetMessages( $borrowernumber, 'L', $branch ); -if($lib_messages_loop){ $template->param(flagged => 1 ); } +my $librarian_messages = Koha::Patron::Messages->search( + { + borrowernumber => $borrowernumber, + message_type => 'L', + } +); + +my $patron_messages = Koha::Patron::Messages->search( + { + borrowernumber => $borrowernumber, + message_type => 'B', + } +); -my $bor_messages_loop = GetMessages( $borrowernumber, 'B', $branch ); -if($bor_messages_loop){ $template->param(flagged => 1 ); } +if( $librarian_messages->count or $patron_messages->count ) { + $template->param(flagged => 1) +} my $fast_cataloging = 0; if (defined getframeworkinfo('FA')) { @@ -591,9 +604,8 @@ if ($restoreduedatespec || $stickyduedate) { } $template->param( - lib_messages_loop => $lib_messages_loop, - bor_messages_loop => $bor_messages_loop, - all_messages_del => C4::Context->preference('AllowAllMessageDeletion'), + librarian_messages => $librarian_messages, + patron_messages => $patron_messages, findborrower => $findborrower, borrower => $borrower, borrowernumber => $borrowernumber, --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -830,35 +830,30 @@ No patron matched [% message %] [% END %] -
-

Messages:

- -
- [% END %] --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -1,5 +1,6 @@ [% USE Koha %] [% USE KohaDates %] +[% USE Branches %] [% INCLUDE 'doc-head-open.inc' %] [% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Your library home @@ -29,17 +30,17 @@

Messages for you

- [% END # / IF bor_messages %] + [% END %]

Hello, [% INCLUDE 'patron-title.inc' category_type = BORROWER_INFO.category_type firstname = BORROWER_INFO.firstname surname = BORROWER_INFO.surname othernames = BORROWER_INFO.othernames cardnumber = BORROWER_INFO.cardnumber %]

--- a/opac/opac-user.pl +++ a/opac/opac-user.pl @@ -339,9 +339,15 @@ if ( C4::Context->preference('AllowPatronToSetCheckoutsVisibilityForGuarantor' $template->param( relatives => \@relatives ); } +my $patron_messages = Koha::Patron::Messages->search( + { + borrowernumber => $borrowernumber, + message_type => 'B', + } +); $template->param( borrower => $borr, - bor_messages_loop => GetMessages( $borrowernumber, 'B', 'NONE' ), + patron_messages => $patron_messages, patronupdate => $patronupdate, OpacRenewalAllowed => C4::Context->preference("OpacRenewalAllowed"), userview => 1, --