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

(-)a/C4/SIP/ILS/Patron.pm (-13 / +18 lines)
Lines 152-160 sub new { Link Here
152
    if ( $patron->is_debarred and $patron->debarredcomment ) {
152
    if ( $patron->is_debarred and $patron->debarredcomment ) {
153
        $ilspatron{screen_msg} .= " -- " . $patron->debarredcomment;
153
        $ilspatron{screen_msg} .= " -- " . $patron->debarredcomment;
154
    }
154
    }
155
155
    if ( $circ_blocked ) {
156
    if ( $circ_blocked ) {
156
        $ilspatron{screen_msg} .= " -- " . "Patron has overdues";
157
        $ilspatron{screen_msg} .= " -- " . "Patron has overdues";
157
    }
158
    }
159
158
    for (qw(EXPIRED CHARGES CREDITS GNA LOST NOTES)) {
160
    for (qw(EXPIRED CHARGES CREDITS GNA LOST NOTES)) {
159
        ($flags->{$_}) or next;
161
        ($flags->{$_}) or next;
160
        if ($_ ne 'NOTES' and $flags->{$_}->{message}) {
162
        if ($_ ne 'NOTES' and $flags->{$_}->{message}) {
Lines 166-185 sub new { Link Here
166
            }
168
            }
167
        }
169
        }
168
    }
170
    }
169
    my $patron_messages = Koha::Patron::Messages->search(
171
170
        {
172
    if ( C4::Context->preference('SIP2AddOpacMessagesToScreenMessage') ) {
171
            borrowernumber => $kp->{borrowernumber},
173
        my $patron_messages = Koha::Patron::Messages->search(
172
            message_type => 'B',
174
            {
175
                borrowernumber => $kp->{borrowernumber},
176
                message_type   => 'B',
177
            }
178
        );
179
        my @messages_array;
180
        while ( my $message = $patron_messages->next ) {
181
            my $messagedt      = dt_from_string( $message->message_date, 'iso' );
182
            my $formatted_date = output_pref( { dt => $messagedt, dateonly => 1 } );
183
            push @messages_array, $formatted_date . ": " . $message->message;
184
        }
185
        if (@messages_array) {
186
            $ilspatron{screen_msg} .= " Messages for you: " . join( ' / ', @messages_array );
173
        }
187
        }
174
    );
175
    my @messages_array;
176
    while ( my $message = $patron_messages->next ) {
177
        my $messagedt = dt_from_string( $message->message_date, 'iso' );
178
        my $formatted_date = output_pref({ dt => $messagedt, dateonly => 1});
179
        push @messages_array, $formatted_date . ": " . $message->message;
180
    }
181
    if (@messages_array) {
182
        $ilspatron{screen_msg} .= ". Messages for you: " . join(' / ', @messages_array);
183
    }
188
    }
184
189
185
    # FIXME: populate fine_items recall_items
190
    # FIXME: populate fine_items recall_items
(-)a/installer/data/mysql/atomicupdate/bug_25816.pl (+19 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number  => "25816",
5
    description => "Add OPAC messages in SIP display",
6
    up          => sub {
7
        my ($args) = @_;
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
10
        $dbh->do(
11
            q{
12
            INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
13
            ('SIP2AddOpacMessagesToScreenMessage','0','','If enabled, patron OPAC messages will be included in the SIP2 screen message','YesNo')
14
        }
15
        );
16
17
        say $out "Added new system preference 'SIP2AddOpacMessagesToScreenMessage'";
18
    },
19
};
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 678-683 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
678
('ShowReviewer','full','none|full|first|surname|firstandinitial|username','Choose how a commenter\'s identity is presented alongside comments in the OPAC','Choice'),
678
('ShowReviewer','full','none|full|first|surname|firstandinitial|username','Choose how a commenter\'s identity is presented alongside comments in the OPAC','Choice'),
679
('ShowReviewerPhoto','1','','If ON, photo of reviewer will be shown beside comments in OPAC','YesNo'),
679
('ShowReviewerPhoto','1','','If ON, photo of reviewer will be shown beside comments in OPAC','YesNo'),
680
('SIP2SortBinMapping','',NULL,'Use the following mappings to determine the sort_bin of a returned item. The mapping should be on the form \"branchcode:item field:item field value:sort bin number\", with one mapping per line.','free'),
680
('SIP2SortBinMapping','',NULL,'Use the following mappings to determine the sort_bin of a returned item. The mapping should be on the form \"branchcode:item field:item field value:sort bin number\", with one mapping per line.','free'),
681
('SIP2AddOpacMessagesToScreenMessage','1','','If enabled, patron OPAC messages will be included in the SIP2 screen message','YesNo'),
681
('SkipHoldTrapOnNotForLoanValue','',NULL,'If set, Koha will never trap items for hold with this notforloan value','Integer'),
682
('SkipHoldTrapOnNotForLoanValue','',NULL,'If set, Koha will never trap items for hold with this notforloan value','Integer'),
682
('SlipCSS','',NULL,'Slips CSS url.','free'),
683
('SlipCSS','',NULL,'Slips CSS url.','free'),
683
('SMSSendDriver','','','Sets which SMS::Send driver is used to send SMS messages.','free'),
684
('SMSSendDriver','','','Sets which SMS::Send driver is used to send SMS messages.','free'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+7 lines)
Lines 1355-1360 Circulation: Link Here
1355
                  1: permanent_location
1355
                  1: permanent_location
1356
                  0: homebranch
1356
                  0: homebranch
1357
            - for AQ field in SIP protocol.
1357
            - for AQ field in SIP protocol.
1358
        -
1359
            - Use
1360
            - pref: SIP2AddOpacMessagesToScreenMessage
1361
              choices:
1362
                  1: Do
1363
                  0: Don't
1364
            - send OPAC patron messages in the SIP2 screen message field.
1358
1365
1359
    Curbside pickup module:
1366
    Curbside pickup module:
1360
        -
1367
        -
(-)a/t/db_dependent/SIP/Patron.t (-19 / +29 lines)
Lines 407-434 subtest "NoIssuesChargeGuarantorsWithGuarantees tests" => sub { Link Here
407
};
407
};
408
408
409
subtest "Patron messages tests" => sub {
409
subtest "Patron messages tests" => sub {
410
    plan tests => 1;
410
    plan tests => 2;
411
    $schema->storage->txn_begin;
411
    $schema->storage->txn_begin;
412
    my $today = output_pref({ dt => dt_from_string(), dateonly => 1});
412
    my $today         = output_pref( { dt => dt_from_string(), dateonly => 1 } );
413
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
413
    my $patron        = $builder->build_object( { class => 'Koha::Patrons', value => { opacnote => q{} } } );
414
    my $library = $builder->build_object ({ class => 'Koha::Libraries' });
414
    my $library       = $builder->build_object( { class => 'Koha::Libraries' } );
415
    my $new_message_1  = Koha::Patron::Message->new(
415
    my $new_message_1 = Koha::Patron::Message->new(
416
        { borrowernumber => $patron->id,
416
        {
417
          branchcode     => $library->branchcode,
417
            borrowernumber => $patron->id,
418
          message_type   => 'B',
418
            branchcode     => $library->branchcode,
419
          message        => 'my message 1',
419
            message_type   => 'B',
420
        })->store;
420
            message        => 'my message 1',
421
421
        }
422
    my $new_message_2  = Koha::Patron::Message->new(
422
    )->store;
423
        { borrowernumber => $patron->id,
424
          branchcode     => $library->branchcode,
425
          message_type   => 'B',
426
          message        => 'my message 2',
427
        })->store;
428
423
424
    my $new_message_2 = Koha::Patron::Message->new(
425
        {
426
            borrowernumber => $patron->id,
427
            branchcode     => $library->branchcode,
428
            message_type   => 'B',
429
            message        => 'my message 2',
430
        }
431
    )->store;
429
432
433
    t::lib::Mocks::mock_preference( 'SIP2AddOpacMessagesToScreenMessage', 0 );
430
    my $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber );
434
    my $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber );
431
    like( $sip_patron->screen_msg, qr/Messages for you: $today: my message 1 \/ $today: my message 2/,"Screen message includes patron messages");
435
    is( $sip_patron->screen_msg, 'Greetings from Koha. ' );
436
437
    t::lib::Mocks::mock_preference( 'SIP2AddOpacMessagesToScreenMessage', 1 );
438
    $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber );
439
    like(
440
        $sip_patron->screen_msg, qr/Messages for you: $today: my message 1 \/ $today: my message 2/,
441
        "Screen message includes patron messages"
442
    );
432
443
433
    $schema->storage->txn_rollback;
444
    $schema->storage->txn_rollback;
434
};
445
};
435
- 

Return to bug 25816