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

(-)a/C4/SIP/Sip.pm (-1 / +13 lines)
Lines 12-17 use Sys::Syslog qw(syslog); Link Here
12
use POSIX qw(strftime);
12
use POSIX qw(strftime);
13
use Socket qw(:crlf);
13
use Socket qw(:crlf);
14
use IO::Handle;
14
use IO::Handle;
15
use List::Util qw(first);
15
16
16
use C4::SIP::Sip::Constants qw(SIP_DATETIME FID_SCREEN_MSG);
17
use C4::SIP::Sip::Constants qw(SIP_DATETIME FID_SCREEN_MSG);
17
use C4::SIP::Sip::Checksum qw(checksum);
18
use C4::SIP::Sip::Checksum qw(checksum);
Lines 57-63 sub timestamp { Link Here
57
#    return constructed field value
58
#    return constructed field value
58
#
59
#
59
sub add_field {
60
sub add_field {
60
    my ($field_id, $value) = @_;
61
    my ($field_id, $value, $server) = @_;
62
63
    if ( my $hide_fields = $server->{account}->{hide_fields} ) {
64
        my @fields = split( ',', $hide_fields );
65
        return q{} if first { $_ eq $field_id } @fields;
66
    }
67
61
    my ($i, $ent);
68
    my ($i, $ent);
62
69
63
    if (!defined($value)) {
70
    if (!defined($value)) {
Lines 87-92 sub add_field { Link Here
87
sub maybe_add {
94
sub maybe_add {
88
    my ($fid, $value, $server) = @_;
95
    my ($fid, $value, $server) = @_;
89
96
97
    if ( my $hide_fields = $server->{account}->{hide_fields} ) {
98
        my @fields = split( ',', $hide_fields );
99
        return q{} if first { $_ eq $fid } @fields;
100
    }
101
90
    if ( $fid eq FID_SCREEN_MSG && $server->{account}->{screen_msg_regex} ) {
102
    if ( $fid eq FID_SCREEN_MSG && $server->{account}->{screen_msg_regex} ) {
91
        foreach my $regex (
103
        foreach my $regex (
92
            ref $server->{account}->{screen_msg_regex} eq "ARRAY"
104
            ref $server->{account}->{screen_msg_regex} eq "ARRAY"
(-)a/C4/SIP/Sip/MsgType.pm (-156 / +157 lines)
Lines 422-449 sub build_patron_status { Link Here
422
422
423
        $resp .= patron_status_string($patron);
423
        $resp .= patron_status_string($patron);
424
        $resp .= $lang . timestamp();
424
        $resp .= $lang . timestamp();
425
        $resp .= add_field( FID_PERSONAL_NAME, $patron->name( $server->{account}->{ae_field_template} ) );
425
        $resp .= add_field( FID_PERSONAL_NAME, $patron->name( $server->{account}->{ae_field_template} ), $server );
426
426
427
        # while the patron ID we got from the SC is valid, let's
427
        # while the patron ID we got from the SC is valid, let's
428
        # use the one returned from the ILS, just in case...
428
        # use the one returned from the ILS, just in case...
429
        $resp .= add_field( FID_PATRON_ID, $patron->id );
429
        $resp .= add_field( FID_PATRON_ID, $patron->id, $server );
430
430
431
        if ( $protocol_version >= 2 ) {
431
        if ( $protocol_version >= 2 ) {
432
            $resp .= add_field( FID_VALID_PATRON, 'Y' );
432
            $resp .= add_field( FID_VALID_PATRON, 'Y', $server );
433
433
434
            # Patron password is a required field.
434
            # Patron password is a required field.
435
            $resp .= add_field( FID_VALID_PATRON_PWD, sipbool($password_rc) );
435
            $resp .= add_field( FID_VALID_PATRON_PWD, sipbool($password_rc), $server );
436
            $resp .= maybe_add( FID_CURRENCY, $patron->currency );
436
            $resp .= maybe_add( FID_CURRENCY, $patron->currency, $server );
437
            $resp .= maybe_add( FID_FEE_AMT,  $patron->fee_amount );
437
            $resp .= maybe_add( FID_FEE_AMT,  $patron->fee_amount, $server );
438
        }
438
        }
439
439
440
        my $msg = $patron->screen_msg;
440
        my $msg = $patron->screen_msg;
441
        $msg .= ' -- '. INVALID_PW if $patron_pwd && !$password_rc;
441
        $msg .= ' -- '. INVALID_PW if $patron_pwd && !$password_rc;
442
        $resp .= maybe_add( FID_SCREEN_MSG, $msg, $server );
442
        $resp .= maybe_add( FID_SCREEN_MSG, $msg, $server, $server );
443
443
444
        $resp .= maybe_add( FID_SCREEN_MSG, $patron->{branchcode}, $server )
444
        $resp .= maybe_add( FID_SCREEN_MSG, $patron->{branchcode}, $server )
445
          if ( $server->{account}->{send_patron_home_library_in_af} );
445
          if ( $server->{account}->{send_patron_home_library_in_af} );
446
        $resp .= maybe_add( FID_PRINT_LINE, $patron->print_line );
446
        $resp .= maybe_add( FID_PRINT_LINE, $patron->print_line, $server );
447
447
448
        $resp .= $patron->build_patron_attributes_string( $server );
448
        $resp .= $patron->build_patron_attributes_string( $server );
449
449
Lines 453-471 sub build_patron_status { Link Here
453
453
454
        # no personal name, and is invalid (if we're using 2.00)
454
        # no personal name, and is invalid (if we're using 2.00)
455
        $resp .= 'YYYY' . ( ' ' x 10 ) . $lang . timestamp();
455
        $resp .= 'YYYY' . ( ' ' x 10 ) . $lang . timestamp();
456
        $resp .= add_field( FID_PERSONAL_NAME, '' );
456
        $resp .= add_field( FID_PERSONAL_NAME, '', $server );
457
457
458
        # the patron ID is invalid, but it's a required field, so
458
        # the patron ID is invalid, but it's a required field, so
459
        # just echo it back
459
        # just echo it back
460
        $resp .= add_field( FID_PATRON_ID, $fields->{ (FID_PATRON_ID) } );
460
        $resp .= add_field( FID_PATRON_ID, $fields->{ (FID_PATRON_ID) }, $server );
461
461
462
        ( $protocol_version >= 2 )
462
        ( $protocol_version >= 2 )
463
          and $resp .= add_field( FID_VALID_PATRON, 'N' );
463
          and $resp .= add_field( FID_VALID_PATRON, 'N', $server );
464
464
465
        $resp .= maybe_add( FID_SCREEN_MSG, INVALID_CARD, $server );
465
        $resp .= maybe_add( FID_SCREEN_MSG, INVALID_CARD, $server, $server );
466
    }
466
    }
467
467
468
    $resp .= add_field( FID_INST_ID, $fields->{ (FID_INST_ID) } );
468
    $resp .= add_field( FID_INST_ID, $fields->{ (FID_INST_ID) }, $server );
469
    return $resp;
469
    return $resp;
470
}
470
}
471
471
Lines 537-561 sub handle_checkout { Link Here
537
        $resp .= timestamp;
537
        $resp .= timestamp;
538
538
539
        # Now for the variable fields
539
        # Now for the variable fields
540
        $resp .= add_field( FID_INST_ID,   $inst );
540
        $resp .= add_field( FID_INST_ID,   $inst, $server );
541
        $resp .= add_field( FID_PATRON_ID, $patron_id );
541
        $resp .= add_field( FID_PATRON_ID, $patron_id, $server );
542
        $resp .= add_field( FID_ITEM_ID,   $item_id );
542
        $resp .= add_field( FID_ITEM_ID,   $item_id, $server );
543
        $resp .= add_field( FID_TITLE_ID,  $item->title_id );
543
        $resp .= add_field( FID_TITLE_ID,  $item->title_id, $server );
544
        if ( $item->due_date ) {
544
        if ( $item->due_date ) {
545
            $resp .= add_field( FID_DUE_DATE, timestamp( $item->due_date ) );
545
            $resp .= add_field( FID_DUE_DATE, timestamp( $item->due_date ), $server );
546
        } else {
546
        } else {
547
            $resp .= add_field( FID_DUE_DATE, q{} );
547
            $resp .= add_field( FID_DUE_DATE, q{}, $server );
548
        }
548
        }
549
549
550
        $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server );
550
        $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server, $server );
551
        $resp .= maybe_add( FID_PRINT_LINE, $status->print_line );
551
        $resp .= maybe_add( FID_PRINT_LINE, $status->print_line, $server );
552
552
553
        if ( $protocol_version >= 2 ) {
553
        if ( $protocol_version >= 2 ) {
554
            if ( $ils->supports('security inhibit') ) {
554
            if ( $ils->supports('security inhibit') ) {
555
                $resp .= add_field( FID_SECURITY_INHIBIT, $status->security_inhibit );
555
                $resp .= add_field( FID_SECURITY_INHIBIT, $status->security_inhibit, $server );
556
            }
556
            }
557
            $resp .= maybe_add( FID_MEDIA_TYPE, $item->sip_media_type );
557
            $resp .= maybe_add( FID_MEDIA_TYPE, $item->sip_media_type, $server );
558
            $resp .= maybe_add( FID_ITEM_PROPS, $item->sip_item_properties );
558
            $resp .= maybe_add( FID_ITEM_PROPS, $item->sip_item_properties, $server );
559
559
560
        }
560
        }
561
    }
561
    }
Lines 566-595 sub handle_checkout { Link Here
566
        # Checkout Response: not ok, no renewal, don't know mag. media,
566
        # Checkout Response: not ok, no renewal, don't know mag. media,
567
        # no desensitize
567
        # no desensitize
568
        $resp = sprintf( "120NUN%s", timestamp );
568
        $resp = sprintf( "120NUN%s", timestamp );
569
        $resp .= add_field( FID_INST_ID,   $inst );
569
        $resp .= add_field( FID_INST_ID,   $inst, $server );
570
        $resp .= add_field( FID_PATRON_ID, $patron_id );
570
        $resp .= add_field( FID_PATRON_ID, $patron_id, $server );
571
        $resp .= add_field( FID_ITEM_ID,   $item_id );
571
        $resp .= add_field( FID_ITEM_ID,   $item_id, $server );
572
572
573
        # If the item is valid, provide the title, otherwise
573
        # If the item is valid, provide the title, otherwise
574
        # leave it blank
574
        # leave it blank
575
        $resp .= add_field( FID_TITLE_ID, $item ? $item->title_id : '' );
575
        $resp .= add_field( FID_TITLE_ID, $item ? $item->title_id : '', $server );
576
576
577
        # Due date is required.  Since it didn't get checked out,
577
        # Due date is required.  Since it didn't get checked out,
578
        # it's not due, so leave the date blank
578
        # it's not due, so leave the date blank
579
        $resp .= add_field( FID_DUE_DATE, '' );
579
        $resp .= add_field( FID_DUE_DATE, '', $server );
580
580
581
        $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server );
581
        $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server, $server );
582
        $resp .= maybe_add( FID_PRINT_LINE, $status->print_line );
582
        $resp .= maybe_add( FID_PRINT_LINE, $status->print_line, $server );
583
583
584
        if ( $protocol_version >= 2 ) {
584
        if ( $protocol_version >= 2 ) {
585
585
586
            # Is the patron ID valid?
586
            # Is the patron ID valid?
587
            $resp .= add_field( FID_VALID_PATRON, sipbool($patron) );
587
            $resp .= add_field( FID_VALID_PATRON, sipbool($patron), $server );
588
588
589
            if ( $patron && exists( $fields->{FID_PATRON_PWD} ) ) {
589
            if ( $patron && exists( $fields->{FID_PATRON_PWD} ) ) {
590
590
591
                # Password provided, so we can tell if it was valid or not
591
                # Password provided, so we can tell if it was valid or not
592
                $resp .= add_field( FID_VALID_PATRON_PWD, sipbool( $patron->check_password( $fields->{ (FID_PATRON_PWD) } ) ) );
592
                $resp .= add_field( FID_VALID_PATRON_PWD, sipbool( $patron->check_password( $fields->{ (FID_PATRON_PWD) } ) ), $server );
593
            }
593
            }
594
        }
594
        }
595
    }
595
    }
Lines 598-607 sub handle_checkout { Link Here
598
598
599
        # Financials : return irrespective of ok status
599
        # Financials : return irrespective of ok status
600
        if ( $status->fee_amount ) {
600
        if ( $status->fee_amount ) {
601
            $resp .= add_field( FID_FEE_AMT, $status->fee_amount );
601
            $resp .= add_field( FID_FEE_AMT, $status->fee_amount, $server );
602
            $resp .= maybe_add( FID_CURRENCY,       $status->sip_currency );
602
            $resp .= maybe_add( FID_CURRENCY,       $status->sip_currency, $server );
603
            $resp .= maybe_add( FID_FEE_TYPE,       $status->sip_fee_type );
603
            $resp .= maybe_add( FID_FEE_TYPE,       $status->sip_fee_type, $server );
604
            $resp .= maybe_add( FID_TRANSACTION_ID, $status->transaction_id );
604
            $resp .= maybe_add( FID_TRANSACTION_ID, $status->transaction_id, $server );
605
        }
605
        }
606
    }
606
    }
607
607
Lines 655-681 sub handle_checkin { Link Here
655
655
656
    $resp .= $status->alert ? 'Y' : 'N';
656
    $resp .= $status->alert ? 'Y' : 'N';
657
    $resp .= timestamp;
657
    $resp .= timestamp;
658
    $resp .= add_field( FID_INST_ID, $inst_id );
658
    $resp .= add_field( FID_INST_ID, $inst_id, $server );
659
    $resp .= add_field( FID_ITEM_ID, $item_id );
659
    $resp .= add_field( FID_ITEM_ID, $item_id, $server );
660
660
661
    if ($item) {
661
    if ($item) {
662
        $resp .= add_field( FID_PERM_LOCN, $item->permanent_location );
662
        $resp .= add_field( FID_PERM_LOCN, $item->permanent_location, $server );
663
        $resp .= maybe_add( FID_TITLE_ID, $item->title_id );
663
        $resp .= maybe_add( FID_TITLE_ID, $item->title_id, $server );
664
    }
664
    }
665
665
666
    if ( $protocol_version >= 2 ) {
666
    if ( $protocol_version >= 2 ) {
667
        $resp .= maybe_add( FID_SORT_BIN, $status->sort_bin );
667
        $resp .= maybe_add( FID_SORT_BIN, $status->sort_bin, $server );
668
        if ($patron) {
668
        if ($patron) {
669
            $resp .= add_field( FID_PATRON_ID, $patron->id );
669
            $resp .= add_field( FID_PATRON_ID, $patron->id, $server );
670
        }
670
        }
671
        if ($item) {
671
        if ($item) {
672
            $resp .= maybe_add( FID_MEDIA_TYPE,           $item->sip_media_type );
672
$resp .= maybe_add( FID_MEDIA_TYPE,           $item->sip_media_type,      $server );
673
            $resp .= maybe_add( FID_ITEM_PROPS,           $item->sip_item_properties );
673
$resp .= maybe_add( FID_ITEM_PROPS,           $item->sip_item_properties, $server );
674
            $resp .= maybe_add( FID_COLLECTION_CODE,      $item->collection_code );
674
$resp .= maybe_add( FID_COLLECTION_CODE,      $item->collection_code,     $server );
675
            $resp .= maybe_add( FID_CALL_NUMBER,          $item->call_number );
675
$resp .= maybe_add( FID_CALL_NUMBER,          $item->call_number,         $server );
676
            $resp .= add_field( FID_DESTINATION_LOCATION, $item->destination_loc ) if ( $item->destination_loc || $server->{account}->{ct_always_send} );
676
$resp .= maybe_add( FID_HOLD_PATRON_ID,       $item->hold_patron_bcode,   $server );
677
            $resp .= maybe_add( FID_HOLD_PATRON_ID,       $item->hold_patron_bcode );
677
$resp .= add_field( FID_DESTINATION_LOCATION, $item->destination_loc,     $server ) if ( $item->destination_loc || $server->{account}->{ct_always_send} );
678
            $resp .= maybe_add( FID_HOLD_PATRON_NAME,     $item->hold_patron_name( $server->{account}->{da_field_template} ) );
678
$resp .= maybe_add( FID_HOLD_PATRON_NAME,     $item->hold_patron_name( $server->{account}->{da_field_template} ), $server );
679
679
            if ( $status->hold and $status->hold->{branchcode} ne $item->destination_loc ) {
680
            if ( $status->hold and $status->hold->{branchcode} ne $item->destination_loc ) {
680
                warn 'SIP hold mismatch: $status->hold->{branchcode}=' . $status->hold->{branchcode} . '; $item->destination_loc=' . $item->destination_loc;
681
                warn 'SIP hold mismatch: $status->hold->{branchcode}=' . $status->hold->{branchcode} . '; $item->destination_loc=' . $item->destination_loc;
681
682
Lines 685-696 sub handle_checkin { Link Here
685
    }
686
    }
686
687
687
    if ( $status->alert && $status->alert_type ) {
688
    if ( $status->alert && $status->alert_type ) {
688
        $resp .= maybe_add( FID_ALERT_TYPE, $status->alert_type );
689
        $resp .= maybe_add( FID_ALERT_TYPE, $status->alert_type, $server );
689
    } elsif ( $server->{account}->{cv_send_00_on_success} ) {
690
    } elsif ( $server->{account}->{cv_send_00_on_success} ) {
690
        $resp .= add_field( FID_ALERT_TYPE, '00' );
691
        $resp .= add_field( FID_ALERT_TYPE, '00', $server );
691
    }
692
    }
692
    $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server );
693
    $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server );
693
    $resp .= maybe_add( FID_PRINT_LINE, $status->print_line );
694
    $resp .= maybe_add( FID_PRINT_LINE, $status->print_line, $server );
694
695
695
    $self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
696
    $self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
696
697
Lines 915-921 sub summary_info { Link Here
915
916
916
    syslog( "LOG_DEBUG", "summary_info: list = (%s)", join( ", ", @{$itemlist} ) );
917
    syslog( "LOG_DEBUG", "summary_info: list = (%s)", join( ", ", @{$itemlist} ) );
917
    foreach my $i ( @{$itemlist} ) {
918
    foreach my $i ( @{$itemlist} ) {
918
        $resp .= add_field( $fid, $i->{barcode} );
919
        $resp .= add_field( $fid, $i->{barcode}, $server );
919
    }
920
    }
920
921
921
    return $resp;
922
    return $resp;
Lines 952-970 sub handle_patron_info { Link Here
952
        $resp .= add_count( 'patron_info/recall_items',  scalar @{ $patron->recall_items } );
953
        $resp .= add_count( 'patron_info/recall_items',  scalar @{ $patron->recall_items } );
953
        $resp .= add_count( 'patron_info/unavail_holds', scalar @{ $patron->unavail_holds } );
954
        $resp .= add_count( 'patron_info/unavail_holds', scalar @{ $patron->unavail_holds } );
954
955
955
        $resp .= add_field( FID_INST_ID, ( $ils->institution_id || 'SIP2' ) );
956
        $resp .= add_field( FID_INST_ID, ( $ils->institution_id || 'SIP2' ), $server );
956
957
957
        # while the patron ID we got from the SC is valid, let's
958
        # while the patron ID we got from the SC is valid, let's
958
        # use the one returned from the ILS, just in case...
959
        # use the one returned from the ILS, just in case...
959
        $resp .= add_field( FID_PATRON_ID,     $patron->id );
960
        $resp .= add_field( FID_PATRON_ID,     $patron->id, $server );
960
        $resp .= add_field( FID_PERSONAL_NAME, $patron->name( $server->{account}->{ae_field_template} ) );
961
        $resp .= add_field( FID_PERSONAL_NAME, $patron->name( $server->{account}->{ae_field_template} ), $server );
961
962
962
        # TODO: add code for the fields
963
        # TODO: add code for the fields
963
        #   hold items limit
964
        #   hold items limit
964
        #   overdue items limit
965
        #   overdue items limit
965
        #   charged items limit
966
        #   charged items limit
966
967
967
        $resp .= add_field( FID_VALID_PATRON, 'Y' );
968
        $resp .= add_field( FID_VALID_PATRON, 'Y', $server );
968
        my $password_rc;
969
        my $password_rc;
969
        if ( defined($patron_pwd) ) {
970
        if ( defined($patron_pwd) ) {
970
971
Lines 974-985 sub handle_patron_info { Link Here
974
            } else {
975
            } else {
975
                $password_rc = $patron->check_password($patron_pwd);
976
                $password_rc = $patron->check_password($patron_pwd);
976
            }
977
            }
977
            $resp .= add_field( FID_VALID_PATRON_PWD, sipbool( $password_rc ) );
978
            $resp .= add_field( FID_VALID_PATRON_PWD, sipbool( $password_rc ), $server );
978
        }
979
        }
979
980
980
        $resp .= maybe_add( FID_CURRENCY, $patron->currency );
981
        $resp .= maybe_add( FID_CURRENCY, $patron->currency, $server );
981
        $resp .= maybe_add( FID_FEE_AMT,  $patron->fee_amount );
982
        $resp .= maybe_add( FID_FEE_AMT,  $patron->fee_amount, $server );
982
        $resp .= add_field( FID_FEE_LMT, $patron->fee_limit );
983
        $resp .= add_field( FID_FEE_LMT, $patron->fee_limit, $server );
983
984
984
        # TODO: zero or more item details for 2.0 can go here:
985
        # TODO: zero or more item details for 2.0 can go here:
985
        #          hold_items
986
        #          hold_items
Lines 990-1016 sub handle_patron_info { Link Here
990
991
991
        $resp .= summary_info( $ils, $patron, $summary, $start, $end, $server );
992
        $resp .= summary_info( $ils, $patron, $summary, $start, $end, $server );
992
993
993
        $resp .= maybe_add( FID_HOME_ADDR,  $patron->address );
994
        $resp .= maybe_add( FID_HOME_ADDR,  $patron->address, $server );
994
        $resp .= maybe_add( FID_EMAIL,      $patron->email_addr );
995
        $resp .= maybe_add( FID_EMAIL,      $patron->email_addr, $server );
995
        $resp .= maybe_add( FID_HOME_PHONE, $patron->home_phone );
996
        $resp .= maybe_add( FID_HOME_PHONE, $patron->home_phone, $server );
996
997
997
        # SIP 2.0 extensions used by Envisionware
998
        # SIP 2.0 extensions used by Envisionware
998
        # Other terminals will ignore unrecognized fields (unrecognized field identifiers)
999
        # Other terminals will ignore unrecognized fields (unrecognized field identifiers)
999
        $resp .= maybe_add( FID_PATRON_BIRTHDATE, $patron->birthdate );
1000
        $resp .= maybe_add( FID_PATRON_BIRTHDATE, $patron->birthdate, $server );
1000
        $resp .= maybe_add( FID_PATRON_CLASS,     $patron->ptype );
1001
        $resp .= maybe_add( FID_PATRON_CLASS,     $patron->ptype, $server );
1001
1002
1002
        # Custom protocol extension to report patron internet privileges
1003
        # Custom protocol extension to report patron internet privileges
1003
        $resp .= maybe_add( FID_INET_PROFILE, $patron->inet_privileges );
1004
        $resp .= maybe_add( FID_INET_PROFILE, $patron->inet_privileges, $server );
1004
1005
1005
        my $msg = $patron->screen_msg;
1006
        my $msg = $patron->screen_msg;
1006
        if( defined( $patron_pwd ) && !$password_rc ) {
1007
        if( defined( $patron_pwd ) && !$password_rc ) {
1007
            $msg .= ' -- ' . INVALID_PW;
1008
            $msg .= ' -- ' . INVALID_PW;
1008
        }
1009
        }
1009
        $resp .= maybe_add( FID_SCREEN_MSG, $msg, $server );
1010
        $resp .= maybe_add( FID_SCREEN_MSG, $msg, $server, $server );
1010
        if ( $server->{account}->{send_patron_home_library_in_af} ) {
1011
        if ( $server->{account}->{send_patron_home_library_in_af} ) {
1011
            $resp .= maybe_add( FID_SCREEN_MSG, $patron->{branchcode}, $server);
1012
            $resp .= maybe_add( FID_SCREEN_MSG, $patron->{branchcode}, $server);
1012
        }
1013
        }
1013
        $resp .= maybe_add( FID_PRINT_LINE, $patron->print_line );
1014
        $resp .= maybe_add( FID_PRINT_LINE, $patron->print_line, $server );
1014
1015
1015
        $resp .= $patron->build_patron_attributes_string( $server );
1016
        $resp .= $patron->build_patron_attributes_string( $server );
1016
    } else {
1017
    } else {
Lines 1021-1036 sub handle_patron_info { Link Here
1021
        $resp .= 'YYYY' . ( ' ' x 10 ) . $lang . timestamp();
1022
        $resp .= 'YYYY' . ( ' ' x 10 ) . $lang . timestamp();
1022
        $resp .= '0000' x 6;
1023
        $resp .= '0000' x 6;
1023
1024
1024
        $resp .= add_field( FID_INST_ID, ( $ils->institution_id || 'SIP2' ) );
1025
        $resp .= add_field( FID_INST_ID, ( $ils->institution_id || 'SIP2' ), $server );
1025
1026
1026
        # patron ID is invalid, but field is required, so just echo it back
1027
        # patron ID is invalid, but field is required, so just echo it back
1027
        $resp .= add_field( FID_PATRON_ID, $fields->{ (FID_PATRON_ID) } );
1028
        $resp .= add_field( FID_PATRON_ID, $fields->{ (FID_PATRON_ID) }, $server );
1028
        $resp .= add_field( FID_PERSONAL_NAME, '' );
1029
        $resp .= add_field( FID_PERSONAL_NAME, '', $server );
1029
1030
1030
        if ( $protocol_version >= 2 ) {
1031
        if ( $protocol_version >= 2 ) {
1031
            $resp .= add_field( FID_VALID_PATRON, 'N' );
1032
            $resp .= add_field( FID_VALID_PATRON, 'N', $server );
1032
        }
1033
        }
1033
        $resp .= maybe_add( FID_SCREEN_MSG, INVALID_CARD, $server );
1034
        $resp .= maybe_add( FID_SCREEN_MSG, INVALID_CARD, $server, $server );
1034
    }
1035
    }
1035
1036
1036
    $self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
1037
    $self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
Lines 1054-1064 sub handle_end_patron_session { Link Here
1054
    $resp .= $status ? 'Y' : 'N';
1055
    $resp .= $status ? 'Y' : 'N';
1055
    $resp .= timestamp();
1056
    $resp .= timestamp();
1056
1057
1057
    $resp .= add_field( FID_INST_ID, $server->{ils}->institution );
1058
    $resp .= add_field( FID_INST_ID, $server->{ils}->institution, $server );
1058
    $resp .= add_field( FID_PATRON_ID, $fields->{ (FID_PATRON_ID) } );
1059
    $resp .= add_field( FID_PATRON_ID, $fields->{ (FID_PATRON_ID) }, $server );
1059
1060
1060
    $resp .= maybe_add( FID_SCREEN_MSG, $screen_msg, $server );
1061
    $resp .= maybe_add( FID_SCREEN_MSG, $screen_msg, $server, $server );
1061
    $resp .= maybe_add( FID_PRINT_LINE, $print_line );
1062
    $resp .= maybe_add( FID_PRINT_LINE, $print_line, $server );
1062
1063
1063
    $self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
1064
    $self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
1064
1065
Lines 1092-1102 sub handle_fee_paid { Link Here
1092
    $status = $ils->pay_fee( $patron_id, $patron_pwd, $fee_amt, $fee_type, $pay_type, $fee_id, $trans_id, $currency, $is_writeoff, $disallow_overpayment );
1093
    $status = $ils->pay_fee( $patron_id, $patron_pwd, $fee_amt, $fee_type, $pay_type, $fee_id, $trans_id, $currency, $is_writeoff, $disallow_overpayment );
1093
1094
1094
    $resp .= ( $status->ok ? 'Y' : 'N' ) . timestamp;
1095
    $resp .= ( $status->ok ? 'Y' : 'N' ) . timestamp;
1095
    $resp .= add_field( FID_INST_ID,   $inst_id );
1096
    $resp .= add_field( FID_INST_ID,   $inst_id, $server );
1096
    $resp .= add_field( FID_PATRON_ID, $patron_id );
1097
    $resp .= add_field( FID_PATRON_ID, $patron_id, $server );
1097
    $resp .= maybe_add( FID_TRANSACTION_ID, $status->transaction_id );
1098
    $resp .= maybe_add( FID_TRANSACTION_ID, $status->transaction_id, $server );
1098
    $resp .= maybe_add( FID_SCREEN_MSG,     $status->screen_msg, $server );
1099
    $resp .= maybe_add( FID_SCREEN_MSG,     $status->screen_msg, $server, $server );
1099
    $resp .= maybe_add( FID_PRINT_LINE,     $status->print_line );
1100
    $resp .= maybe_add( FID_PRINT_LINE,     $status->print_line, $server );
1100
1101
1101
    $self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
1102
    $self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
1102
1103
Lines 1126-1135 sub handle_item_information { Link Here
1126
        $resp .= timestamp;
1127
        $resp .= timestamp;
1127
1128
1128
        # Just echo back the invalid item id
1129
        # Just echo back the invalid item id
1129
        $resp .= add_field( FID_ITEM_ID, $fields->{ (FID_ITEM_ID) } );
1130
        $resp .= add_field( FID_ITEM_ID, $fields->{ (FID_ITEM_ID) }, $server );
1130
1131
1131
        # title id is required, but we don't have one
1132
        # title id is required, but we don't have one
1132
        $resp .= add_field( FID_TITLE_ID, '' );
1133
        $resp .= add_field( FID_TITLE_ID, '', $server );
1133
    } else {
1134
    } else {
1134
1135
1135
        # Valid Item ID, send the good stuff
1136
        # Valid Item ID, send the good stuff
Lines 1138-1172 sub handle_item_information { Link Here
1138
        $resp .= $item->sip_fee_type;
1139
        $resp .= $item->sip_fee_type;
1139
        $resp .= timestamp;
1140
        $resp .= timestamp;
1140
1141
1141
        $resp .= add_field( FID_ITEM_ID,  $item->id );
1142
        $resp .= add_field( FID_ITEM_ID,  $item->id, $server );
1142
        $resp .= add_field( FID_TITLE_ID, $item->title_id );
1143
        $resp .= add_field( FID_TITLE_ID, $item->title_id, $server );
1143
1144
1144
        $resp .= maybe_add( FID_MEDIA_TYPE,   $item->sip_media_type );
1145
        $resp .= maybe_add( FID_MEDIA_TYPE,   $item->sip_media_type, $server );
1145
        $resp .= maybe_add( FID_PERM_LOCN,    $item->permanent_location );
1146
        $resp .= maybe_add( FID_PERM_LOCN,    $item->permanent_location, $server );
1146
        $resp .= maybe_add( FID_CURRENT_LOCN, $item->current_location );
1147
        $resp .= maybe_add( FID_CURRENT_LOCN, $item->current_location, $server );
1147
        $resp .= maybe_add( FID_ITEM_PROPS,   $item->sip_item_properties );
1148
        $resp .= maybe_add( FID_ITEM_PROPS,   $item->sip_item_properties, $server );
1148
1149
1149
        if ( ( $i = $item->fee ) != 0 ) {
1150
        if ( ( $i = $item->fee ) != 0 ) {
1150
            $resp .= add_field( FID_CURRENCY, $item->fee_currency );
1151
            $resp .= add_field( FID_CURRENCY, $item->fee_currency, $server );
1151
            $resp .= add_field( FID_FEE_AMT,  $i );
1152
            $resp .= add_field( FID_FEE_AMT,  $i, $server );
1152
        }
1153
        }
1153
        $resp .= maybe_add( FID_OWNER, $item->owner );
1154
        $resp .= maybe_add( FID_OWNER, $item->owner, $server );
1154
1155
1155
        if ( ( $i = scalar @{ $item->hold_queue } ) > 0 ) {
1156
        if ( ( $i = scalar @{ $item->hold_queue } ) > 0 ) {
1156
            $resp .= add_field( FID_HOLD_QUEUE_LEN, $i );
1157
            $resp .= add_field( FID_HOLD_QUEUE_LEN, $i, $server );
1157
        }
1158
        }
1158
        if ( $item->due_date ) {
1159
        if ( $item->due_date ) {
1159
            $resp .= add_field( FID_DUE_DATE, timestamp( $item->due_date ) );
1160
            $resp .= add_field( FID_DUE_DATE, timestamp( $item->due_date ), $server );
1160
        }
1161
        }
1161
        if ( ( $i = $item->recall_date ) != 0 ) {
1162
        if ( ( $i = $item->recall_date ) != 0 ) {
1162
            $resp .= add_field( FID_RECALL_DATE, timestamp($i) );
1163
            $resp .= add_field( FID_RECALL_DATE, timestamp($i), $server );
1163
        }
1164
        }
1164
        if ( ( $i = $item->hold_pickup_date ) != 0 ) {
1165
        if ( ( $i = $item->hold_pickup_date ) != 0 ) {
1165
            $resp .= add_field( FID_HOLD_PICKUP_DATE, timestamp($i) );
1166
            $resp .= add_field( FID_HOLD_PICKUP_DATE, timestamp($i), $server );
1166
        }
1167
        }
1167
1168
1168
        $resp .= maybe_add( FID_SCREEN_MSG, $item->screen_msg, $server );
1169
        $resp .= maybe_add( FID_SCREEN_MSG, $item->screen_msg, $server, $server );
1169
        $resp .= maybe_add( FID_PRINT_LINE, $item->print_line );
1170
        $resp .= maybe_add( FID_PRINT_LINE, $item->print_line, $server );
1170
    }
1171
    }
1171
1172
1172
    $self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
1173
    $self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
Lines 1201-1207 sub handle_item_status_update { Link Here
1201
        # Invalid Item ID
1202
        # Invalid Item ID
1202
        $resp .= '0';
1203
        $resp .= '0';
1203
        $resp .= timestamp;
1204
        $resp .= timestamp;
1204
        $resp .= add_field( FID_ITEM_ID, $item_id );
1205
        $resp .= add_field( FID_ITEM_ID, $item_id, $server );
1205
    } else {
1206
    } else {
1206
1207
1207
        # Valid Item ID
1208
        # Valid Item ID
Lines 1211-1223 sub handle_item_status_update { Link Here
1211
        $resp .= $status->ok ? '1' : '0';
1212
        $resp .= $status->ok ? '1' : '0';
1212
        $resp .= timestamp;
1213
        $resp .= timestamp;
1213
1214
1214
        $resp .= add_field( FID_ITEM_ID,  $item->id );
1215
        $resp .= add_field( FID_ITEM_ID,  $item->id, $server );
1215
        $resp .= add_field( FID_TITLE_ID, $item->title_id );
1216
        $resp .= add_field( FID_TITLE_ID, $item->title_id, $server );
1216
        $resp .= maybe_add( FID_ITEM_PROPS, $item->sip_item_properties );
1217
        $resp .= maybe_add( FID_ITEM_PROPS, $item->sip_item_properties, $server );
1217
    }
1218
    }
1218
1219
1219
    $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server );
1220
    $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server, $server );
1220
    $resp .= maybe_add( FID_PRINT_LINE, $status->print_line );
1221
    $resp .= maybe_add( FID_PRINT_LINE, $status->print_line, $server );
1221
1222
1222
    $self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
1223
    $self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
1223
1224
Lines 1244-1253 sub handle_patron_enable { Link Here
1244
1245
1245
        # Invalid patron ID
1246
        # Invalid patron ID
1246
        $resp .= 'YYYY' . ( ' ' x 10 ) . '000' . timestamp();
1247
        $resp .= 'YYYY' . ( ' ' x 10 ) . '000' . timestamp();
1247
        $resp .= add_field( FID_PATRON_ID,        $patron_id );
1248
        $resp .= add_field( FID_PATRON_ID,        $patron_id, $server );
1248
        $resp .= add_field( FID_PERSONAL_NAME,    '' );
1249
        $resp .= add_field( FID_PERSONAL_NAME,    '', $server );
1249
        $resp .= add_field( FID_VALID_PATRON,     'N' );
1250
        $resp .= add_field( FID_VALID_PATRON,     'N', $server );
1250
        $resp .= add_field( FID_VALID_PATRON_PWD, 'N' );
1251
        $resp .= add_field( FID_VALID_PATRON_PWD, 'N', $server );
1251
    } else {
1252
    } else {
1252
1253
1253
        # valid patron
1254
        # valid patron
Lines 1259-1275 sub handle_patron_enable { Link Here
1259
        $resp .= patron_status_string($patron);
1260
        $resp .= patron_status_string($patron);
1260
        $resp .= $patron->language . timestamp();
1261
        $resp .= $patron->language . timestamp();
1261
1262
1262
        $resp .= add_field( FID_PATRON_ID,     $patron->id );
1263
        $resp .= add_field( FID_PATRON_ID,     $patron->id, $server );
1263
        $resp .= add_field( FID_PERSONAL_NAME, $patron->name( $server->{account}->{ae_field_template} ) );
1264
        $resp .= add_field( FID_PERSONAL_NAME, $patron->name( $server->{account}->{ae_field_template} ), $server );
1264
        if ( defined($patron_pwd) ) {
1265
        if ( defined($patron_pwd) ) {
1265
            $resp .= add_field( FID_VALID_PATRON_PWD, sipbool( $patron->check_password($patron_pwd) ) );
1266
            $resp .= add_field( FID_VALID_PATRON_PWD, sipbool( $patron->check_password($patron_pwd) ), $server );
1266
        }
1267
        }
1267
        $resp .= add_field( FID_VALID_PATRON, 'Y' );
1268
        $resp .= add_field( FID_VALID_PATRON, 'Y', $server );
1268
        $resp .= maybe_add( FID_SCREEN_MSG, $patron->screen_msg, $server );
1269
        $resp .= maybe_add( FID_SCREEN_MSG, $patron->screen_msg, $server, $server );
1269
        $resp .= maybe_add( FID_PRINT_LINE, $patron->print_line );
1270
        $resp .= maybe_add( FID_PRINT_LINE, $patron->print_line, $server );
1270
    }
1271
    }
1271
1272
1272
    $resp .= add_field( FID_INST_ID, $ils->institution );
1273
    $resp .= add_field( FID_INST_ID, $ils->institution, $server );
1273
1274
1274
    $self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
1275
    $self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
1275
1276
Lines 1316-1338 sub handle_hold { Link Here
1316
    $resp .= timestamp;
1317
    $resp .= timestamp;
1317
1318
1318
    if ( $status->ok ) {
1319
    if ( $status->ok ) {
1319
        $resp .= add_field( FID_PATRON_ID, $status->patron->id );
1320
        $resp .= add_field( FID_PATRON_ID, $status->patron->id, $server );
1320
1321
1321
        ( $status->expiration_date )
1322
        ( $status->expiration_date )
1322
          and $resp .= maybe_add( FID_EXPIRATION, timestamp( $status->expiration_date ) );
1323
          and $resp .= maybe_add( FID_EXPIRATION, timestamp( $status->expiration_date ), $server );
1323
        $resp .= maybe_add( FID_QUEUE_POS,   $status->queue_position );
1324
        $resp .= maybe_add( FID_QUEUE_POS,   $status->queue_position, $server );
1324
        $resp .= maybe_add( FID_PICKUP_LOCN, $status->pickup_location );
1325
        $resp .= maybe_add( FID_PICKUP_LOCN, $status->pickup_location, $server );
1325
        $resp .= maybe_add( FID_ITEM_ID,     $status->item->id );
1326
        $resp .= maybe_add( FID_ITEM_ID,     $status->item->id, $server );
1326
        $resp .= maybe_add( FID_TITLE_ID,    $status->item->title_id );
1327
        $resp .= maybe_add( FID_TITLE_ID,    $status->item->title_id, $server );
1327
    } else {
1328
    } else {
1328
1329
1329
        # Not ok.  still need required fields
1330
        # Not ok.  still need required fields
1330
        $resp .= add_field( FID_PATRON_ID, $patron_id );
1331
        $resp .= add_field( FID_PATRON_ID, $patron_id, $server );
1331
    }
1332
    }
1332
1333
1333
    $resp .= add_field( FID_INST_ID, $ils->institution );
1334
    $resp .= add_field( FID_INST_ID, $ils->institution, $server );
1334
    $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server );
1335
    $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server, $server );
1335
    $resp .= maybe_add( FID_PRINT_LINE, $status->print_line );
1336
    $resp .= maybe_add( FID_PRINT_LINE, $status->print_line, $server );
1336
1337
1337
    $self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
1338
    $self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
1338
1339
Lines 1379-1397 sub handle_renew { Link Here
1379
        }
1380
        }
1380
        $resp .= sipbool( $status->desensitize );
1381
        $resp .= sipbool( $status->desensitize );
1381
        $resp .= timestamp;
1382
        $resp .= timestamp;
1382
        $resp .= add_field( FID_PATRON_ID, $patron->id );
1383
        $resp .= add_field( FID_PATRON_ID, $patron->id, $server );
1383
        $resp .= add_field( FID_ITEM_ID, $item->id );
1384
        $resp .= add_field( FID_ITEM_ID, $item->id, $server );
1384
        $resp .= add_field( FID_TITLE_ID, $item->title_id );
1385
        $resp .= add_field( FID_TITLE_ID, $item->title_id, $server );
1385
        if ( $item->due_date ) {
1386
        if ( $item->due_date ) {
1386
            $resp .= add_field( FID_DUE_DATE, timestamp( $item->due_date ) );
1387
            $resp .= add_field( FID_DUE_DATE, timestamp( $item->due_date ), $server );
1387
        } else {
1388
        } else {
1388
            $resp .= add_field( FID_DUE_DATE, q{} );
1389
            $resp .= add_field( FID_DUE_DATE, q{}, $server );
1389
        }
1390
        }
1390
        if ( $ils->supports('security inhibit') ) {
1391
        if ( $ils->supports('security inhibit') ) {
1391
            $resp .= add_field( FID_SECURITY_INHIBIT, $status->security_inhibit );
1392
            $resp .= add_field( FID_SECURITY_INHIBIT, $status->security_inhibit, $server );
1392
        }
1393
        }
1393
        $resp .= add_field( FID_MEDIA_TYPE, $item->sip_media_type );
1394
        $resp .= add_field( FID_MEDIA_TYPE, $item->sip_media_type, $server );
1394
        $resp .= maybe_add( FID_ITEM_PROPS, $item->sip_item_properties );
1395
        $resp .= maybe_add( FID_ITEM_PROPS, $item->sip_item_properties, $server );
1395
    } else {
1396
    } else {
1396
1397
1397
        # renew failed for some reason
1398
        # renew failed for some reason
Lines 1402-1423 sub handle_renew { Link Here
1402
        # If we found the patron or the item, the return the ILS
1403
        # If we found the patron or the item, the return the ILS
1403
        # information, otherwise echo back the information we received
1404
        # information, otherwise echo back the information we received
1404
        # from the terminal
1405
        # from the terminal
1405
        $resp .= add_field( FID_PATRON_ID, $patron ? $patron->id     : $patron_id );
1406
        $resp .= add_field( FID_PATRON_ID, $patron ? $patron->id     : $patron_id, $server );
1406
        $resp .= add_field( FID_ITEM_ID,   $item   ? $item->id       : $item_id );
1407
        $resp .= add_field( FID_ITEM_ID,   $item   ? $item->id       : $item_id, $server );
1407
        $resp .= add_field( FID_TITLE_ID,  $item   ? $item->title_id : $title_id );
1408
        $resp .= add_field( FID_TITLE_ID,  $item   ? $item->title_id : $title_id, $server );
1408
        $resp .= add_field( FID_DUE_DATE,  '' );
1409
        $resp .= add_field( FID_DUE_DATE,  '', $server );
1409
    }
1410
    }
1410
1411
1411
    if ( $status->fee_amount ) {
1412
    if ( $status->fee_amount ) {
1412
        $resp .= add_field( FID_FEE_AMT, $status->fee_amount );
1413
        $resp .= add_field( FID_FEE_AMT, $status->fee_amount, $server );
1413
        $resp .= maybe_add( FID_CURRENCY,       $status->sip_currency );
1414
        $resp .= maybe_add( FID_CURRENCY,       $status->sip_currency, $server );
1414
        $resp .= maybe_add( FID_FEE_TYPE,       $status->sip_fee_type );
1415
        $resp .= maybe_add( FID_FEE_TYPE,       $status->sip_fee_type, $server );
1415
        $resp .= maybe_add( FID_TRANSACTION_ID, $status->transaction_id );
1416
        $resp .= maybe_add( FID_TRANSACTION_ID, $status->transaction_id, $server );
1416
    }
1417
    }
1417
1418
1418
    $resp .= add_field( FID_INST_ID, $ils->institution );
1419
    $resp .= add_field( FID_INST_ID, $ils->institution, $server );
1419
    $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server );
1420
    $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server, $server );
1420
    $resp .= maybe_add( FID_PRINT_LINE, $status->print_line );
1421
    $resp .= maybe_add( FID_PRINT_LINE, $status->print_line, $server );
1421
1422
1422
    $self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
1423
    $self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
1423
1424
Lines 1462-1474 sub handle_renew_all { Link Here
1462
    }
1463
    }
1463
1464
1464
    $resp .= timestamp;
1465
    $resp .= timestamp;
1465
    $resp .= add_field( FID_INST_ID, $ils->institution );
1466
    $resp .= add_field( FID_INST_ID, $ils->institution, $server );
1466
1467
1467
    $resp .= join( '', map( add_field( FID_RENEWED_ITEMS,   $_ ), @renewed ) );
1468
    $resp .= join( '', map( add_field( FID_RENEWED_ITEMS,   $_ ), @renewed ), $server );
1468
    $resp .= join( '', map( add_field( FID_UNRENEWED_ITEMS, $_ ), @unrenewed ) );
1469
    $resp .= join( '', map( add_field( FID_UNRENEWED_ITEMS, $_ ), @unrenewed ), $server );
1469
1470
1470
    $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server );
1471
    $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server, $server );
1471
    $resp .= maybe_add( FID_PRINT_LINE, $status->print_line );
1472
    $resp .= maybe_add( FID_PRINT_LINE, $status->print_line, $server );
1472
1473
1473
    $self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
1474
    $self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
1474
1475
Lines 1539-1545 sub send_acs_status { Link Here
1539
    }
1540
    }
1540
1541
1541
    # Institution ID
1542
    # Institution ID
1542
    $msg .= add_field( FID_INST_ID, $account->{institution} );
1543
    $msg .= add_field( FID_INST_ID, $account->{institution}, $server );
1543
1544
1544
    if ( $protocol_version >= 2 ) {
1545
    if ( $protocol_version >= 2 ) {
1545
1546
Lines 1556-1565 sub send_acs_status { Link Here
1556
        if ( length($supported_msgs) < 16 ) {
1557
        if ( length($supported_msgs) < 16 ) {
1557
            syslog( "LOG_ERR", 'send_acs_status: supported messages "%s" too short', $supported_msgs );
1558
            syslog( "LOG_ERR", 'send_acs_status: supported messages "%s" too short', $supported_msgs );
1558
        }
1559
        }
1559
        $msg .= add_field( FID_SUPPORTED_MSGS, $supported_msgs );
1560
        $msg .= add_field( FID_SUPPORTED_MSGS, $supported_msgs, $server );
1560
    }
1561
    }
1561
1562
1562
    $msg .= maybe_add( FID_SCREEN_MSG, $screen_msg, $server );
1563
    $msg .= maybe_add( FID_SCREEN_MSG, $screen_msg, $server, $server );
1563
1564
1564
    if (   defined( $account->{print_width} )
1565
    if (   defined( $account->{print_width} )
1565
        && defined($print_line)
1566
        && defined($print_line)
Lines 1568-1574 sub send_acs_status { Link Here
1568
        $print_line = substr( $print_line, 0, $account->{print_width} );
1569
        $print_line = substr( $print_line, 0, $account->{print_width} );
1569
    }
1570
    }
1570
1571
1571
    $msg .= maybe_add( FID_PRINT_LINE, $print_line );
1572
    $msg .= maybe_add( FID_PRINT_LINE, $print_line, $server );
1572
1573
1573
    # Do we want to tell the terminal its location?
1574
    # Do we want to tell the terminal its location?
1574
1575
(-)a/etc/SIPconfig.xml (-1 / +2 lines)
Lines 55-61 Link Here
55
             ct_always_send="1"
55
             ct_always_send="1"
56
             ae_field_template="[% patron.surname %][% IF patron.firstname %], [% patron.firstname %][% END %]"
56
             ae_field_template="[% patron.surname %][% IF patron.firstname %], [% patron.firstname %][% END %]"
57
             da_field_template="[% patron.surname %][% IF patron.firstname %], [% patron.firstname %][% END %]"
57
             da_field_template="[% patron.surname %][% IF patron.firstname %], [% patron.firstname %][% END %]"
58
             av_field_template="[% accountline.description %] [% accountline.amountoutstanding | format('%.2f') %]" >
58
             av_field_template="[% accountline.description %] [% accountline.amountoutstanding | format('%.2f') %]"
59
             hide_fields="BD,BE,BF,PB" />
59
          <screen_msg_regex find="Greetings from Koha." replace="Welcome to your library!" />
60
          <screen_msg_regex find="Greetings from Koha." replace="Welcome to your library!" />
60
          <screen_msg_regex find="Invalid patron barcode." replace="Barcode not found, are you sure this is your library card?" />
61
          <screen_msg_regex find="Invalid patron barcode." replace="Barcode not found, are you sure this is your library card?" />
61
          <patron_attribute field="XY" code="CODE" />
62
          <patron_attribute field="XY" code="CODE" />
(-)a/t/db_dependent/SIP/Message.t (-2 / +11 lines)
Lines 58-64 subtest 'Testing Patron Status Request V2' => sub { Link Here
58
subtest 'Testing Patron Info Request V2' => sub {
58
subtest 'Testing Patron Info Request V2' => sub {
59
    my $schema = Koha::Database->new->schema;
59
    my $schema = Koha::Database->new->schema;
60
    $schema->storage->txn_begin;
60
    $schema->storage->txn_begin;
61
    plan tests => 20;
61
    plan tests => 24;
62
    $C4::SIP::Sip::protocol_version = 2;
62
    $C4::SIP::Sip::protocol_version = 2;
63
    test_request_patron_info_v2();
63
    test_request_patron_info_v2();
64
    $schema->storage->txn_rollback;
64
    $schema->storage->txn_rollback;
Lines 252-257 sub test_request_patron_info_v2 { Link Here
252
    $respcode = substr( $response, 0, 2 );
252
    $respcode = substr( $response, 0, 2 );
253
    check_field( $respcode, $response, FID_PERSONAL_NAME, 'X' . $patron2->{surname} . 'Y', 'Check customized patron name' );
253
    check_field( $respcode, $response, FID_PERSONAL_NAME, 'X' . $patron2->{surname} . 'Y', 'Check customized patron name' );
254
254
255
    undef $response;
256
    $server->{account}->{hide_fields} = "BD,BE,BF,PB";
257
    $msg->handle_patron_info( $server );
258
    $respcode = substr( $response, 0, 2 );
259
    check_field( $respcode, $response, FID_HOME_ADDR, undef, 'Home address successfully stripped from response' );
260
    check_field( $respcode, $response, FID_EMAIL, undef, 'Email address successfully stripped from response' );
261
    check_field( $respcode, $response, FID_HOME_PHONE, undef, 'Home phone successfully stripped from response' );
262
    check_field( $respcode, $response, FID_PATRON_BIRTHDATE, undef, 'Date of birth successfully stripped from response' );
263
    $server->{account}->{hide_fields} = "";
264
255
    # Check empty password and verify CQ again
265
    # Check empty password and verify CQ again
256
    $siprequest = PATRON_INFO. 'engYYYYMMDDZZZZHHMMSS'.'Y         '.
266
    $siprequest = PATRON_INFO. 'engYYYYMMDDZZZZHHMMSS'.'Y         '.
257
        FID_INST_ID. $branchcode. '|'.
267
        FID_INST_ID. $branchcode. '|'.
258
- 

Return to bug 20292