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

(-)a/C4/Overdues.pm (+3 lines)
Lines 1028-1033 sub parse_overdues_letter { Link Here
1028
        letter_code => $params->{'letter_code'},
1028
        letter_code => $params->{'letter_code'},
1029
        branchcode => $params->{'branchcode'},
1029
        branchcode => $params->{'branchcode'},
1030
        tables => \%tables,
1030
        tables => \%tables,
1031
        loops => {
1032
            overdues => [ map { $_->{items}->{itemnumber} } @item_tables ],
1033
        },
1031
        substitute => $substitute,
1034
        substitute => $substitute,
1032
        repeat => { item => \@item_tables },
1035
        repeat => { item => \@item_tables },
1033
        message_transport_type => $params->{message_transport_type},
1036
        message_transport_type => $params->{message_transport_type},
(-)a/t/db_dependent/Letters/TemplateToolkit.t (-2 / +137 lines)
Lines 286-292 $prepared_letter = GetPreparedLetter( Link Here
286
is( $prepared_letter->{content}, $modification->id(), 'Patron modification object used correctly' );
286
is( $prepared_letter->{content}, $modification->id(), 'Patron modification object used correctly' );
287
287
288
subtest 'regression tests' => sub {
288
subtest 'regression tests' => sub {
289
    plan tests => 6;
289
    plan tests => 7;
290
290
291
    my $library = $builder->build( { source => 'Branch' } );
291
    my $library = $builder->build( { source => 'Branch' } );
292
    my $patron  = $builder->build( { source => 'Borrower' } );
292
    my $patron  = $builder->build( { source => 'Borrower' } );
Lines 716-722 EOF Link Here
716
716
717
        is( $first_tt_slip->{content}, $first_slip->{content}, );
717
        is( $first_tt_slip->{content}, $first_slip->{content}, );
718
        is( $second_tt_slip->{content}, $second_slip->{content}, );
718
        is( $second_tt_slip->{content}, $second_slip->{content}, );
719
720
        # Cleanup
721
        AddReturn( $item1->{barcode} );
722
        AddReturn( $item2->{barcode} );
723
        AddReturn( $item3->{barcode} );
719
    };
724
    };
725
726
    subtest 'ODUE|items.content|item' => sub {
727
        plan tests => 1;
728
729
        my $code = 'ODUE';
730
731
        my $branchcode = $library->{branchcode};
732
733
        # historic syntax
734
        # FIXME items.fine does not work with TT notices
735
        # See bug 17976
736
        # <item> should contain Fine: <<items.fine>></item>
737
        my $template = <<EOF;
738
Dear <<borrowers.firstname>> <<borrowers.surname>>,
739
740
According to our current records, you have items that are overdue.Your library does not charge late fines, but please return or renew them at the branch below as soon as possible.
741
742
<<branches.branchname>>
743
<<branches.branchaddress1>>
744
<<branches.branchaddress2>> <<branches.branchaddress3>>
745
Phone: <<branches.branchphone>>
746
Fax: <<branches.branchfax>>
747
Email: <<branches.branchemail>>
748
749
If you have registered a password with the library, and you have a renewal available, you may renew online. If an item becomes more than 30 days overdue, you will be unable to use your library card until the item is returned.
750
751
The following item(s) is/are currently overdue:
752
753
<item>"<<biblio.title>>" by <<biblio.author>>, <<items.itemcallnumber>>, Barcode: <<items.barcode>></item>
754
755
<<items.content>>
756
757
Thank-you for your prompt attention to this matter.
758
759
<<branches.branchname>> Staff
760
EOF
761
762
        reset_template( { template => $template, code => $code, module => 'circulation' } );
763
764
        my $yesterday = dt_from_string->subtract( days => 1 );
765
        my $two_days_ago = dt_from_string->subtract( days => 2 );
766
        my $issue1 = C4::Circulation::AddIssue( $patron, $item1->{barcode} ); # Add a first checkout
767
        my $issue2 = C4::Circulation::AddIssue( $patron, $item2->{barcode}, $yesterday ); # Add an first overdue
768
        my $issue3 = C4::Circulation::AddIssue( $patron, $item3->{barcode}, $two_days_ago ); # Add an second overdue
769
        $issue1 = Koha::Checkout->_new_from_dbic( $issue1 )->unblessed; # ->unblessed should be enough but AddIssue does not return a Koha::Checkout object
770
        $issue2 = Koha::Checkout->_new_from_dbic( $issue2 )->unblessed;
771
        $issue3 = Koha::Checkout->_new_from_dbic( $issue3 )->unblessed;
772
773
        # For items.content
774
        my @item_fields = qw( date_due title barcode author itemnumber );
775
        my $items_content = C4::Letters::get_item_content( { %$item1, %$biblio1, %$issue1 }, @item_fields );
776
          $items_content .= C4::Letters::get_item_content( { %$item2, %$biblio2, %$issue2 }, @item_fields );
777
          $items_content .= C4::Letters::get_item_content( { %$item3, %$biblio3, %$issue3 }, @item_fields );
778
779
        my @items = ( $item1, $item2, $item3 );
780
        my $letter = C4::Overdues::parse_overdues_letter(
781
            {
782
                letter_code => $code,
783
                borrowernumber => $patron->{borrowernumber},
784
                branchcode  => $library->{branchcode},
785
                items       => \@items,
786
                substitute  => {
787
                    bib                    => $library->{branchname},
788
                    'items.content'        => $items_content,
789
                    count                  => scalar( @items ),
790
                    message_transport_type => 'email',
791
                }
792
            }
793
        );
794
795
        # Cleanup
796
        AddReturn( $item1->{barcode} );
797
        AddReturn( $item2->{barcode} );
798
        AddReturn( $item3->{barcode} );
799
800
801
        # historic syntax
802
        my $tt_template = <<EOF;
803
Dear [% borrower.firstname %] [% borrower.surname %],
804
805
According to our current records, you have items that are overdue.Your library does not charge late fines, but please return or renew them at the branch below as soon as possible.
806
807
[% branch.branchname %]
808
[% branch.branchaddress1 %]
809
[% branch.branchaddress2 %] [% branch.branchaddress3 %]
810
Phone: [% branch.branchphone %]
811
Fax: [% branch.branchfax %]
812
Email: [% branch.branchemail %]
813
814
If you have registered a password with the library, and you have a renewal available, you may renew online. If an item becomes more than 30 days overdue, you will be unable to use your library card until the item is returned.
815
816
The following item(s) is/are currently overdue:
817
818
[% FOREACH overdue IN overdues %]
819
[%~ SET item = overdue.item ~%]
820
"[% item.biblio.title %]" by [% item.biblio.author %], [% item.itemcallnumber %], Barcode: [% item.barcode %]
821
[% END %]
822
[% FOREACH overdue IN overdues %]
823
[%~ SET item = overdue.item ~%]
824
[% overdue.date_due | \$KohaDates %]\t[% item.biblio.title %]\t[% item.barcode %]\t[% item.biblio.author %]\t[% item.itemnumber %]
825
[% END %]
826
827
Thank-you for your prompt attention to this matter.
828
829
[% branch.branchname %] Staff
830
EOF
831
832
        reset_template( { template => $tt_template, code => $code, module => 'circulation' } );
833
834
        C4::Circulation::AddIssue( $patron, $item1->{barcode} ); # Add a first checkout
835
        C4::Circulation::AddIssue( $patron, $item2->{barcode}, $yesterday ); # Add an first overdue
836
        C4::Circulation::AddIssue( $patron, $item3->{barcode}, $two_days_ago ); # Add an second overdue
837
838
        my $tt_letter = C4::Overdues::parse_overdues_letter(
839
            {
840
                letter_code => $code,
841
                borrowernumber => $patron->{borrowernumber},
842
                branchcode  => $library->{branchcode},
843
                items       => \@items,
844
                substitute  => {
845
                    bib                    => $library->{branchname},
846
                    'items.content'        => $items_content,
847
                    count                  => scalar( @items ),
848
                    message_transport_type => 'email',
849
                }
850
            }
851
        );
852
853
        is( $tt_letter->{content}, $letter->{content}, );
854
    };
855
720
};
856
};
721
857
722
subtest 'loops' => sub {
858
subtest 'loops' => sub {
723
- 

Return to bug 17967