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

(-)a/C4/Overdues.pm (+3 lines)
Lines 1035-1040 sub parse_overdues_letter { Link Here
1035
        letter_code => $params->{'letter_code'},
1035
        letter_code => $params->{'letter_code'},
1036
        branchcode => $params->{'branchcode'},
1036
        branchcode => $params->{'branchcode'},
1037
        tables => \%tables,
1037
        tables => \%tables,
1038
        loops => {
1039
            overdues => [ map { $_->{items}->{itemnumber} } @item_tables ],
1040
        },
1038
        substitute => $substitute,
1041
        substitute => $substitute,
1039
        repeat => { item => \@item_tables },
1042
        repeat => { item => \@item_tables },
1040
        message_transport_type => $params->{message_transport_type},
1043
        message_transport_type => $params->{message_transport_type},
(-)a/t/db_dependent/Letters/TemplateToolkit.t (-2 / +137 lines)
Lines 318-324 subtest 'loops' => sub { Link Here
318
};
318
};
319
319
320
subtest 'regression tests' => sub {
320
subtest 'regression tests' => sub {
321
    plan tests => 6;
321
    plan tests => 7;
322
322
323
    my $library = $builder->build( { source => 'Branch' } );
323
    my $library = $builder->build( { source => 'Branch' } );
324
    my $patron  = $builder->build( { source => 'Borrower' } );
324
    my $patron  = $builder->build( { source => 'Borrower' } );
Lines 748-754 EOF Link Here
748
748
749
        is( $first_tt_slip->{content}, $first_slip->{content}, );
749
        is( $first_tt_slip->{content}, $first_slip->{content}, );
750
        is( $second_tt_slip->{content}, $second_slip->{content}, );
750
        is( $second_tt_slip->{content}, $second_slip->{content}, );
751
752
        # Cleanup
753
        AddReturn( $item1->{barcode} );
754
        AddReturn( $item2->{barcode} );
755
        AddReturn( $item3->{barcode} );
751
    };
756
    };
757
758
    subtest 'ODUE|items.content|item' => sub {
759
        plan tests => 1;
760
761
        my $code = 'ODUE';
762
763
        my $branchcode = $library->{branchcode};
764
765
        # historic syntax
766
        # FIXME items.fine does not work with TT notices
767
        # See bug 17976
768
        # <item> should contain Fine: <<items.fine>></item>
769
        my $template = <<EOF;
770
Dear <<borrowers.firstname>> <<borrowers.surname>>,
771
772
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.
773
774
<<branches.branchname>>
775
<<branches.branchaddress1>>
776
<<branches.branchaddress2>> <<branches.branchaddress3>>
777
Phone: <<branches.branchphone>>
778
Fax: <<branches.branchfax>>
779
Email: <<branches.branchemail>>
780
781
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.
782
783
The following item(s) is/are currently overdue:
784
785
<item>"<<biblio.title>>" by <<biblio.author>>, <<items.itemcallnumber>>, Barcode: <<items.barcode>></item>
786
787
<<items.content>>
788
789
Thank-you for your prompt attention to this matter.
790
791
<<branches.branchname>> Staff
792
EOF
793
794
        reset_template( { template => $template, code => $code, module => 'circulation' } );
795
796
        my $yesterday = dt_from_string->subtract( days => 1 );
797
        my $two_days_ago = dt_from_string->subtract( days => 2 );
798
        my $issue1 = C4::Circulation::AddIssue( $patron, $item1->{barcode} ); # Add a first checkout
799
        my $issue2 = C4::Circulation::AddIssue( $patron, $item2->{barcode}, $yesterday ); # Add an first overdue
800
        my $issue3 = C4::Circulation::AddIssue( $patron, $item3->{barcode}, $two_days_ago ); # Add an second overdue
801
        $issue1 = Koha::Checkout->_new_from_dbic( $issue1 )->unblessed; # ->unblessed should be enough but AddIssue does not return a Koha::Checkout object
802
        $issue2 = Koha::Checkout->_new_from_dbic( $issue2 )->unblessed;
803
        $issue3 = Koha::Checkout->_new_from_dbic( $issue3 )->unblessed;
804
805
        # For items.content
806
        my @item_fields = qw( date_due title barcode author itemnumber );
807
        my $items_content = C4::Letters::get_item_content( { %$item1, %$biblio1, %$issue1 }, @item_fields );
808
          $items_content .= C4::Letters::get_item_content( { %$item2, %$biblio2, %$issue2 }, @item_fields );
809
          $items_content .= C4::Letters::get_item_content( { %$item3, %$biblio3, %$issue3 }, @item_fields );
810
811
        my @items = ( $item1, $item2, $item3 );
812
        my $letter = C4::Overdues::parse_overdues_letter(
813
            {
814
                letter_code => $code,
815
                borrowernumber => $patron->{borrowernumber},
816
                branchcode  => $library->{branchcode},
817
                items       => \@items,
818
                substitute  => {
819
                    bib                    => $library->{branchname},
820
                    'items.content'        => $items_content,
821
                    count                  => scalar( @items ),
822
                    message_transport_type => 'email',
823
                }
824
            }
825
        );
826
827
        # Cleanup
828
        AddReturn( $item1->{barcode} );
829
        AddReturn( $item2->{barcode} );
830
        AddReturn( $item3->{barcode} );
831
832
833
        # historic syntax
834
        my $tt_template = <<EOF;
835
Dear [% borrower.firstname %] [% borrower.surname %],
836
837
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.
838
839
[% branch.branchname %]
840
[% branch.branchaddress1 %]
841
[% branch.branchaddress2 %] [% branch.branchaddress3 %]
842
Phone: [% branch.branchphone %]
843
Fax: [% branch.branchfax %]
844
Email: [% branch.branchemail %]
845
846
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.
847
848
The following item(s) is/are currently overdue:
849
850
[% FOREACH overdue IN overdues %]
851
[%~ SET item = overdue.item ~%]
852
"[% item.biblio.title %]" by [% item.biblio.author %], [% item.itemcallnumber %], Barcode: [% item.barcode %]
853
[% END %]
854
[% FOREACH overdue IN overdues %]
855
[%~ SET item = overdue.item ~%]
856
[% overdue.date_due | \$KohaDates %]\t[% item.biblio.title %]\t[% item.barcode %]\t[% item.biblio.author %]\t[% item.itemnumber %]
857
[% END %]
858
859
Thank-you for your prompt attention to this matter.
860
861
[% branch.branchname %] Staff
862
EOF
863
864
        reset_template( { template => $tt_template, code => $code, module => 'circulation' } );
865
866
        C4::Circulation::AddIssue( $patron, $item1->{barcode} ); # Add a first checkout
867
        C4::Circulation::AddIssue( $patron, $item2->{barcode}, $yesterday ); # Add an first overdue
868
        C4::Circulation::AddIssue( $patron, $item3->{barcode}, $two_days_ago ); # Add an second overdue
869
870
        my $tt_letter = C4::Overdues::parse_overdues_letter(
871
            {
872
                letter_code => $code,
873
                borrowernumber => $patron->{borrowernumber},
874
                branchcode  => $library->{branchcode},
875
                items       => \@items,
876
                substitute  => {
877
                    bib                    => $library->{branchname},
878
                    'items.content'        => $items_content,
879
                    count                  => scalar( @items ),
880
                    message_transport_type => 'email',
881
                }
882
            }
883
        );
884
885
        is( $tt_letter->{content}, $letter->{content}, );
886
    };
887
752
};
888
};
753
889
754
sub reset_template {
890
sub reset_template {
755
- 

Return to bug 17967