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

(-)a/C4/Letters.pm (+6 lines)
Lines 1548-1553 sub _get_tt_params { Link Here
1548
            plural   => 'old_checkouts',
1548
            plural   => 'old_checkouts',
1549
            fk       => 'itemnumber',
1549
            fk       => 'itemnumber',
1550
        },
1550
        },
1551
        overdues => {
1552
            module   => 'Koha::Checkouts',
1553
            singular => 'overdue',
1554
            plural   => 'overdues',
1555
            fk       => 'itemnumber',
1556
        },
1551
        borrower_modifications => {
1557
        borrower_modifications => {
1552
            module   => 'Koha::Patron::Modifications',
1558
            module   => 'Koha::Patron::Modifications',
1553
            singular => 'patron_modification',
1559
            singular => 'patron_modification',
(-)a/C4/Members.pm (-23 / +35 lines)
Lines 1232-1270 sub IssueSlip { Link Here
1232
             $b->{issuedate} <=> $a->{issuedate} : $s;
1232
             $b->{issuedate} <=> $a->{issuedate} : $s;
1233
    } @issues;
1233
    } @issues;
1234
1234
1235
    my ($letter_code, %repeat);
1235
    my ($letter_code, %repeat, %loops);
1236
    if ( $quickslip ) {
1236
    if ( $quickslip ) {
1237
        $letter_code = 'ISSUEQSLIP';
1237
        $letter_code = 'ISSUEQSLIP';
1238
        %repeat =  (
1238
        my @checkouts = map {
1239
            'checkedout' => [ map {
1240
                'biblio'       => $_,
1239
                'biblio'       => $_,
1241
                'items'        => $_,
1240
                'items'        => $_,
1242
                'biblioitems'  => $_,
1241
                'biblioitems'  => $_,
1243
                'issues'       => $_,
1242
                'issues'       => $_,
1244
            }, grep { $_->{'now'} } @issues ],
1243
            }, grep { $_->{'now'} } @issues;
1244
        %repeat =  (
1245
            checkedout => \@checkouts, # History syntax
1246
        );
1247
        %loops = (
1248
            issues => [ map { $_->{issues}{itemnumber} } @checkouts ], # TT syntax
1245
        );
1249
        );
1246
    }
1250
    }
1247
    else {
1251
    else {
1252
        my @checkouts = map {
1253
            'biblio'        => $_,
1254
              'items'       => $_,
1255
              'biblioitems' => $_,
1256
              'issues'      => $_,
1257
        }, grep { !$_->{'overdue'} } @issues;
1258
        my @overdues = map {
1259
            'biblio'        => $_,
1260
              'items'       => $_,
1261
              'biblioitems' => $_,
1262
              'issues'      => $_,
1263
        }, grep { $_->{'overdue'} } @issues;
1264
        my $news = GetNewsToDisplay( "slip", $branch );
1265
        my @news = map {
1266
            $_->{'timestamp'} = $_->{'newdate'};
1267
            { opac_news => $_ }
1268
        } @$news;
1248
        $letter_code = 'ISSUESLIP';
1269
        $letter_code = 'ISSUESLIP';
1249
        %repeat =  (
1270
        %repeat      = (
1250
            'checkedout' => [ map {
1271
            checkedout => \@checkouts,
1251
                'biblio'       => $_,
1272
            overdue    => \@overdues,
1252
                'items'        => $_,
1273
            news       => \@news,
1253
                'biblioitems'  => $_,
1274
        );
1254
                'issues'       => $_,
1275
        %loops = (
1255
            }, grep { !$_->{'overdue'} } @issues ],
1276
            issues => [ map { $_->{issues}{itemnumber} } @checkouts ],
1256
1277
            overdues   => [ map { $_->{issues}{itemnumber} } @overdues ],
1257
            'overdue' => [ map {
1278
            opac_news => [ map { $_->{opac_news}{idnew} } @news ],
1258
                'biblio'       => $_,
1259
                'items'        => $_,
1260
                'biblioitems'  => $_,
1261
                'issues'       => $_,
1262
            }, grep { $_->{'overdue'} } @issues ],
1263
1264
            'news' => [ map {
1265
                $_->{'timestamp'} = $_->{'newdate'};
1266
                { opac_news => $_ }
1267
            } @{ GetNewsToDisplay("slip",$branch) } ],
1268
        );
1279
        );
1269
    }
1280
    }
1270
1281
Lines 1277-1282 sub IssueSlip { Link Here
1277
            'borrowers'   => $borrowernumber,
1288
            'borrowers'   => $borrowernumber,
1278
        },
1289
        },
1279
        repeat => \%repeat,
1290
        repeat => \%repeat,
1291
        loops => \%loops,
1280
    );
1292
    );
1281
}
1293
}
1282
1294
(-)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 => 5;
321
    plan tests => 6;
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 348-353 subtest 'regression tests' => sub { Link Here
348
            itemcallnumber   => 'itemcallnumber2',
348
            itemcallnumber   => 'itemcallnumber2',
349
        }
349
        }
350
    )->store->unblessed;
350
    )->store->unblessed;
351
    my $biblio3 = Koha::Biblio->new({title => 'Test Biblio 3'})->store->unblessed;
352
    my $biblioitem3 = Koha::Biblioitem->new({biblionumber => $biblio3->{biblionumber}})->store()->unblessed;
353
    my $item3 = Koha::Item->new(
354
        {
355
            biblionumber     => $biblio3->{biblionumber},
356
            biblioitemnumber => $biblioitem3->{biblioitemnumber},
357
            barcode          => 'another_t_barcode_3',
358
            homebranch       => $library->{branchcode},
359
            holdingbranch    => $library->{branchcode},
360
            itype            => 'BK',
361
            itemcallnumber   => 'itemcallnumber3',
362
        }
363
    )->store->unblessed;
351
364
352
    C4::Context->_new_userenv('xxx');
365
    C4::Context->_new_userenv('xxx');
353
    C4::Context->set_userenv(0,0,0,'firstname','surname', $library->{branchcode}, 'Midway Public Library', '', '', '');
366
    C4::Context->set_userenv(0,0,0,'firstname','surname', $library->{branchcode}, 'Midway Public Library', '', '', '');
Lines 613-618 EOF Link Here
613
        is( $tt_letter_for_item1->{content}, $letter_for_item1->{content}, );
626
        is( $tt_letter_for_item1->{content}, $letter_for_item1->{content}, );
614
        is( $tt_letter_for_item2->{content}, $letter_for_item2->{content}, );
627
        is( $tt_letter_for_item2->{content}, $letter_for_item2->{content}, );
615
    };
628
    };
629
630
    subtest 'ISSUESLIP|checkedout|repeat' => sub {
631
        plan tests => 2;
632
633
        my $code = 'ISSUESLIP';
634
635
        my $branchcode = $library->{branchcode};
636
637
        Koha::News->delete;
638
        my $news_item = Koha::NewsItem->new({ branchcode => $branchcode, title => "A wonderful news", content => "This is the wonderful news." })->store;
639
640
        # historic syntax
641
        my $template = <<EOF;
642
<h3><<branches.branchname>></h3>
643
Checked out to <<borrowers.title>> <<borrowers.firstname>> <<borrowers.initials>> <<borrowers.surname>> <br />
644
(<<borrowers.cardnumber>>) <br />
645
646
<<today>><br />
647
648
<h4>Checked Out</h4>
649
<checkedout>
650
<p>
651
<<biblio.title>> <br />
652
Barcode: <<items.barcode>><br />
653
Date due: <<issues.date_due | dateonly>><br />
654
</p>
655
</checkedout>
656
657
<h4>Overdues</h4>
658
<overdue>
659
<p>
660
<<biblio.title>> <br />
661
Barcode: <<items.barcode>><br />
662
Date due: <<issues.date_due | dateonly>><br />
663
</p>
664
</overdue>
665
666
<hr>
667
668
<h4 style="text-align: center; font-style:italic;">News</h4>
669
<news>
670
<div class="newsitem">
671
<h5 style="margin-bottom: 1px; margin-top: 1px"><b><<opac_news.title>></b></h5>
672
<p style="margin-bottom: 1px; margin-top: 1px"><<opac_news.content>></p>
673
<p class="newsfooter" style="font-size: 8pt; font-style:italic; margin-bottom: 1px; margin-top: 1px">Posted on <<opac_news.timestamp>></p>
674
<hr />
675
</div>
676
</news>
677
EOF
678
679
        reset_template( { template => $template, code => $code, module => 'circulation' } );
680
681
        C4::Circulation::AddIssue( $patron, $item1->{barcode} ); # Add a first checkout
682
        my $first_slip = C4::Members::IssueSlip( $branchcode, $patron->{borrowernumber} );
683
684
        C4::Circulation::AddIssue( $patron, $item2->{barcode} ); # Add a second checkout
685
        my $yesterday = dt_from_string->subtract( days => 1 );
686
        C4::Circulation::AddIssue( $patron, $item3->{barcode}, $yesterday ); # Add an overdue
687
        my $second_slip = C4::Members::IssueSlip( $branchcode, $patron->{borrowernumber} );
688
689
        # Cleanup
690
        AddReturn( $item1->{barcode} );
691
        AddReturn( $item2->{barcode} );
692
        AddReturn( $item3->{barcode} );
693
694
        # TT syntax
695
        my $tt_template = <<EOF;
696
<h3>[% branch.branchname %]</h3>
697
Checked out to [% borrower.title %] [% borrower.firstname %] [% borrower.initials %] [% borrower.surname %] <br />
698
([% borrower.cardnumber %]) <br />
699
700
[% today | \$KohaDates with_hours => 1 %]<br />
701
702
<h4>Checked Out</h4>
703
[% FOREACH checkout IN checkouts %]
704
[%~ SET item = checkout.item %]
705
[%~ SET biblio = checkout.item.biblio %]
706
<p>
707
[% biblio.title %] <br />
708
Barcode: [% item.barcode %]<br />
709
Date due: [% checkout.date_due | \$KohaDates %]<br />
710
</p>
711
[% END %]
712
713
<h4>Overdues</h4>
714
[% FOREACH overdue IN overdues %]
715
[%~ SET item = overdue.item %]
716
[%~ SET biblio = overdue.item.biblio %]
717
<p>
718
[% biblio.title %] <br />
719
Barcode: [% item.barcode %]<br />
720
Date due: [% overdue.date_due | \$KohaDates %]<br />
721
</p>
722
[% END %]
723
724
<hr>
725
726
<h4 style="text-align: center; font-style:italic;">News</h4>
727
[% FOREACH n IN news %]
728
<div class="newsitem">
729
<h5 style="margin-bottom: 1px; margin-top: 1px"><b>[% n.title %]</b></h5>
730
<p style="margin-bottom: 1px; margin-top: 1px">[% n.content %]</p>
731
<p class="newsfooter" style="font-size: 8pt; font-style:italic; margin-bottom: 1px; margin-top: 1px">Posted on [% n.timestamp | \$KohaDates %]</p>
732
<hr />
733
</div>
734
[% END %]
735
EOF
736
737
        reset_template( { template => $tt_template, code => $code, module => 'circulation' } );
738
739
        C4::Circulation::AddIssue( $patron, $item1->{barcode} ); # Add a first checkout
740
        my $first_tt_slip = C4::Members::IssueSlip( $branchcode, $patron->{borrowernumber} );
741
742
        C4::Circulation::AddIssue( $patron, $item2->{barcode} ); # Add a second checkout
743
        C4::Circulation::AddIssue( $patron, $item3->{barcode}, $yesterday ); # Add an overdue
744
        my $second_tt_slip = C4::Members::IssueSlip( $branchcode, $patron->{borrowernumber} );
745
746
        # There is too many line breaks generated by the historic syntax
747
        $second_slip->{content} =~ s|</p>\n\n\n<p>|</p>\n\n<p>|s;
748
749
        is( $first_tt_slip->{content}, $first_slip->{content}, );
750
        is( $second_tt_slip->{content}, $second_slip->{content}, );
751
    };
616
};
752
};
617
753
618
sub reset_template {
754
sub reset_template {
619
- 

Return to bug 17966