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

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

Return to bug 17967