View | Details | Raw Unified | Return to bug 17397
Collapse All | Expand All

(-)a/Koha/Patron/Message.pm (+3 lines)
Lines 49-54 sub store { Link Here
49
              and $self->message_type
49
              and $self->message_type
50
              and $self->branchcode;
50
              and $self->branchcode;
51
51
52
    my $userenv = C4::Context->userenv;
53
    $self->manager_id($userenv ? $userenv->{number} : 0);
54
52
    C4::Log::logaction( "MEMBERS", "ADDCIRCMESSAGE", $self->borrowernumber, $self->message )
55
    C4::Log::logaction( "MEMBERS", "ADDCIRCMESSAGE", $self->borrowernumber, $self->message )
53
        if C4::Context->preference("BorrowersLog");
56
        if C4::Context->preference("BorrowersLog");
54
57
(-)a/circ/circulation.pl (-11 / +23 lines)
Lines 564-583 if ( $borrowernumber && $borrower->{'category_type'} eq 'C') { Link Here
564
    $template->param( 'catcode' => $patron_categories->next )  if $patron_categories->count == 1;
564
    $template->param( 'catcode' => $patron_categories->next )  if $patron_categories->count == 1;
565
}
565
}
566
566
567
my $librarian_messages = Koha::Patron::Messages->search(
567
my $all_messages = Koha::Patron::Messages->search(
568
    {
568
    {
569
        borrowernumber => $borrowernumber,
569
        'me.borrowernumber' => $borrowernumber,
570
        message_type => 'L',
570
    },
571
    }
572
);
573
574
my $patron_messages = Koha::Patron::Messages->search(
575
    {
571
    {
576
        borrowernumber => $borrowernumber,
572
       join => 'manager',
577
        message_type => 'B',
573
       '+select' => ['manager.surname', 'manager.firstname' ],
574
       '+as' => ['manager_surname', 'manager_firstname'],
578
    }
575
    }
579
);
576
);
580
577
578
my @messages;
579
while ( my $content = $all_messages->next ) {
580
    my $this_item;
581
582
    $this_item->{borrowernumber} = $content->borrowernumber;
583
    $this_item->{message_id}     = $content->message_id;
584
    $this_item->{branchcode}     = $content->branchcode;
585
    $this_item->{message_type}   = $content->message_type;
586
    $this_item->{message_date}   = $content->message_date;
587
    $this_item->{message}        = $content->message;
588
    $this_item->{manager_id}     = $content->manager_id;
589
    $this_item->{name}           = $content->_result->get_column('manager_firstname') . ' ' . $content->_result->get_column('manager_surname');
590
591
    push @messages, $this_item;
592
}
593
581
my $fast_cataloging = 0;
594
my $fast_cataloging = 0;
582
if (defined getframeworkinfo('FA')) {
595
if (defined getframeworkinfo('FA')) {
583
    $fast_cataloging = 1 
596
    $fast_cataloging = 1 
Lines 626-633 if ($restoreduedatespec || $stickyduedate) { Link Here
626
}
639
}
627
640
628
$template->param(
641
$template->param(
629
    librarian_messages => $librarian_messages,
642
    messages           => \@messages,
630
    patron_messages   => $patron_messages,
631
    borrower          => $borrower,
643
    borrower          => $borrower,
632
    borrowernumber    => $borrowernumber,
644
    borrowernumber    => $borrowernumber,
633
    categoryname      => $borrower->{'description'},
645
    categoryname      => $borrower->{'description'},
(-)a/installer/data/mysql/atomicupdate/bug_17397.sql (+3 lines)
Line 0 Link Here
1
ALTER TABLE `messages`
2
ADD `manager_id` int(11) NULL,
3
ADD FOREIGN KEY (`manager_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL;
(-)a/installer/data/mysql/kohastructure.sql (-1 / +3 lines)
Lines 2670-2676 CREATE TABLE `messages` ( -- circulation messages left via the patron's check ou Link Here
2670
  `message_type` varchar(1) NOT NULL, -- whether the message is for the librarians (L) or the patron (B)
2670
  `message_type` varchar(1) NOT NULL, -- whether the message is for the librarians (L) or the patron (B)
2671
  `message` text NOT NULL, -- the text of the message
2671
  `message` text NOT NULL, -- the text of the message
2672
  `message_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- the date and time the message was written
2672
  `message_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- the date and time the message was written
2673
  PRIMARY KEY (`message_id`)
2673
  `manager_id` int(11) default NULL, -- creator of message
2674
  PRIMARY KEY (`message_id`),
2675
  CONSTRAINT `messages_ibfk_1` FOREIGN KEY (`manager_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL
2674
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2676
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2675
2677
2676
--
2678
--
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-9 / +7 lines)
Lines 850-860 No patron matched <span class="ex">[% message | html %]</span> Link Here
850
    <div id="messages" class="circmessage">
850
    <div id="messages" class="circmessage">
851
        <h4>Messages:</h4>
851
        <h4>Messages:</h4>
852
        <ul>
852
        <ul>
853
            [% FOREACH message IN librarian_messages %]
853
            [% FOREACH message IN messages %]
854
                <li>
854
                <li>
855
                    <span class="circ-hlt">
855
                    [% IF(message.message_type == "L") %]
856
                        <span class="circ-hlt">
857
                    [% ELSE %]
858
                        <span>
859
                    [% END %]>
856
                        [% message.message_date | $KohaDates %]
860
                        [% message.message_date | $KohaDates %]
857
                        [% Branches.GetName( message.branchcode ) %]
861
                        [% Branches.GetName( message.branchcode ) %]
862
                        ( <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% message.manager_id %]">[% message.name %]</a> )
858
                        <i>"[% message.message %]"</i>
863
                        <i>"[% message.message %]"</i>
859
                    </span>
864
                    </span>
860
                    [% IF message.branchcode == branch OR Koha.Preference('AllowAllMessageDeletion') %]
865
                    [% IF message.branchcode == branch OR Koha.Preference('AllowAllMessageDeletion') %]
Lines 862-873 No patron matched <span class="ex">[% message | html %]</span> Link Here
862
                    [% END %]
867
                    [% END %]
863
                </li>
868
                </li>
864
            [% END %]
869
            [% END %]
865
            [% FOREACH message IN patron_messages %]
866
                <li><span class="">[% message.message_date | $KohaDates %] [% Branches.GetName( message.branchcode )%] <i>"[% message.message %]"</i></span>
867
                [% IF message.branchcode == branch OR Koha.Preference('AllowAllMessageDeletion') %]
868
                    [<a href="/cgi-bin/koha/circ/del_message.pl?message_id=[% message.message_id %]&amp;borrowernumber=[% message.borrowernumber %]"><i class="fa fa-trash"></i> Delete</a>]
869
                [% END %]</li>
870
            [% END %]
871
        </ul>
870
        </ul>
872
        <a id="addnewmessageLabel" href="#add_message_form" data-toggle="modal"><i class="fa fa-plus"></i> Add a new message</a>
871
        <a id="addnewmessageLabel" href="#add_message_form" data-toggle="modal"><i class="fa fa-plus"></i> Add a new message</a>
873
    </div>
872
    </div>
874
- 

Return to bug 17397