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

(-)a/C4/Letters.pm (+6 lines)
Lines 1566-1571 sub _get_tt_params { Link Here
1566
            plural   => 'old_checkouts',
1566
            plural   => 'old_checkouts',
1567
            fk       => 'itemnumber',
1567
            fk       => 'itemnumber',
1568
        },
1568
        },
1569
        overdues => {
1570
            module   => 'Koha::Checkouts',
1571
            singular => 'overdue',
1572
            plural   => 'overdues',
1573
            fk       => 'itemnumber',
1574
        },
1569
        borrower_modifications => {
1575
        borrower_modifications => {
1570
            module   => 'Koha::Patron::Modifications',
1576
            module   => 'Koha::Patron::Modifications',
1571
            singular => 'patron_modification',
1577
            singular => 'patron_modification',
(-)a/C4/Members.pm (-23 / +35 lines)
Lines 1196-1234 sub IssueSlip { Link Here
1196
             $b->{issuedate} <=> $a->{issuedate} : $s;
1196
             $b->{issuedate} <=> $a->{issuedate} : $s;
1197
    } @issues;
1197
    } @issues;
1198
1198
1199
    my ($letter_code, %repeat);
1199
    my ($letter_code, %repeat, %loops);
1200
    if ( $quickslip ) {
1200
    if ( $quickslip ) {
1201
        $letter_code = 'ISSUEQSLIP';
1201
        $letter_code = 'ISSUEQSLIP';
1202
        %repeat =  (
1202
        my @checkouts = map {
1203
            'checkedout' => [ map {
1204
                'biblio'       => $_,
1203
                'biblio'       => $_,
1205
                'items'        => $_,
1204
                'items'        => $_,
1206
                'biblioitems'  => $_,
1205
                'biblioitems'  => $_,
1207
                'issues'       => $_,
1206
                'issues'       => $_,
1208
            }, grep { $_->{'now'} } @issues ],
1207
            }, grep { $_->{'now'} } @issues;
1208
        %repeat =  (
1209
            checkedout => \@checkouts, # History syntax
1210
        );
1211
        %loops = (
1212
            issues => [ map { $_->{issues}{itemnumber} } @checkouts ], # TT syntax
1209
        );
1213
        );
1210
    }
1214
    }
1211
    else {
1215
    else {
1216
        my @checkouts = map {
1217
            'biblio'        => $_,
1218
              'items'       => $_,
1219
              'biblioitems' => $_,
1220
              'issues'      => $_,
1221
        }, grep { !$_->{'overdue'} } @issues;
1222
        my @overdues = map {
1223
            'biblio'        => $_,
1224
              'items'       => $_,
1225
              'biblioitems' => $_,
1226
              'issues'      => $_,
1227
        }, grep { $_->{'overdue'} } @issues;
1228
        my $news = GetNewsToDisplay( "slip", $branch );
1229
        my @news = map {
1230
            $_->{'timestamp'} = $_->{'newdate'};
1231
            { opac_news => $_ }
1232
        } @$news;
1212
        $letter_code = 'ISSUESLIP';
1233
        $letter_code = 'ISSUESLIP';
1213
        %repeat =  (
1234
        %repeat      = (
1214
            'checkedout' => [ map {
1235
            checkedout => \@checkouts,
1215
                'biblio'       => $_,
1236
            overdue    => \@overdues,
1216
                'items'        => $_,
1237
            news       => \@news,
1217
                'biblioitems'  => $_,
1238
        );
1218
                'issues'       => $_,
1239
        %loops = (
1219
            }, grep { !$_->{'overdue'} } @issues ],
1240
            issues => [ map { $_->{issues}{itemnumber} } @checkouts ],
1220
1241
            overdues   => [ map { $_->{issues}{itemnumber} } @overdues ],
1221
            'overdue' => [ map {
1242
            opac_news => [ map { $_->{opac_news}{idnew} } @news ],
1222
                'biblio'       => $_,
1223
                'items'        => $_,
1224
                'biblioitems'  => $_,
1225
                'issues'       => $_,
1226
            }, grep { $_->{'overdue'} } @issues ],
1227
1228
            'news' => [ map {
1229
                $_->{'timestamp'} = $_->{'newdate'};
1230
                { opac_news => $_ }
1231
            } @{ GetNewsToDisplay("slip",$branch) } ],
1232
        );
1243
        );
1233
    }
1244
    }
1234
1245
Lines 1242-1247 sub IssueSlip { Link Here
1242
            'borrowers'   => $borrowernumber,
1253
            'borrowers'   => $borrowernumber,
1243
        },
1254
        },
1244
        repeat => \%repeat,
1255
        repeat => \%repeat,
1256
        loops => \%loops,
1245
    );
1257
    );
1246
}
1258
}
1247
1259
(-)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 => 5;
289
    plan tests => 6;
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 316-321 subtest 'regression tests' => sub { Link Here
316
            itemcallnumber   => 'itemcallnumber2',
316
            itemcallnumber   => 'itemcallnumber2',
317
        }
317
        }
318
    )->store->unblessed;
318
    )->store->unblessed;
319
    my $biblio3 = Koha::Biblio->new({title => 'Test Biblio 3'})->store->unblessed;
320
    my $biblioitem3 = Koha::Biblioitem->new({biblionumber => $biblio3->{biblionumber}})->store()->unblessed;
321
    my $item3 = Koha::Item->new(
322
        {
323
            biblionumber     => $biblio3->{biblionumber},
324
            biblioitemnumber => $biblioitem3->{biblioitemnumber},
325
            barcode          => 'another_t_barcode_3',
326
            homebranch       => $library->{branchcode},
327
            holdingbranch    => $library->{branchcode},
328
            itype            => 'BK',
329
            itemcallnumber   => 'itemcallnumber3',
330
        }
331
    )->store->unblessed;
319
332
320
    C4::Context->_new_userenv('xxx');
333
    C4::Context->_new_userenv('xxx');
321
    C4::Context->set_userenv(0,0,0,'firstname','surname', $library->{branchcode}, 'Midway Public Library', '', '', '');
334
    C4::Context->set_userenv(0,0,0,'firstname','surname', $library->{branchcode}, 'Midway Public Library', '', '', '');
Lines 582-587 EOF Link Here
582
        is( $tt_letter_for_item1->{content}, $letter_for_item1->{content}, );
595
        is( $tt_letter_for_item1->{content}, $letter_for_item1->{content}, );
583
        is( $tt_letter_for_item2->{content}, $letter_for_item2->{content}, );
596
        is( $tt_letter_for_item2->{content}, $letter_for_item2->{content}, );
584
    };
597
    };
598
599
    subtest 'ISSUESLIP|checkedout|repeat' => sub {
600
        plan tests => 2;
601
602
        my $code = 'ISSUESLIP';
603
604
        my $branchcode = $library->{branchcode};
605
606
        Koha::News->delete;
607
        my $news_item = Koha::NewsItem->new({ branchcode => $branchcode, title => "A wonderful news", content => "This is the wonderful news." })->store;
608
609
        # historic syntax
610
        my $template = <<EOF;
611
<h3><<branches.branchname>></h3>
612
Checked out to <<borrowers.title>> <<borrowers.firstname>> <<borrowers.initials>> <<borrowers.surname>> <br />
613
(<<borrowers.cardnumber>>) <br />
614
615
<<today>><br />
616
617
<h4>Checked Out</h4>
618
<checkedout>
619
<p>
620
<<biblio.title>> <br />
621
Barcode: <<items.barcode>><br />
622
Date due: <<issues.date_due | dateonly>><br />
623
</p>
624
</checkedout>
625
626
<h4>Overdues</h4>
627
<overdue>
628
<p>
629
<<biblio.title>> <br />
630
Barcode: <<items.barcode>><br />
631
Date due: <<issues.date_due | dateonly>><br />
632
</p>
633
</overdue>
634
635
<hr>
636
637
<h4 style="text-align: center; font-style:italic;">News</h4>
638
<news>
639
<div class="newsitem">
640
<h5 style="margin-bottom: 1px; margin-top: 1px"><b><<opac_news.title>></b></h5>
641
<p style="margin-bottom: 1px; margin-top: 1px"><<opac_news.content>></p>
642
<p class="newsfooter" style="font-size: 8pt; font-style:italic; margin-bottom: 1px; margin-top: 1px">Posted on <<opac_news.timestamp>></p>
643
<hr />
644
</div>
645
</news>
646
EOF
647
648
        reset_template( { template => $template, code => $code, module => 'circulation' } );
649
650
        C4::Circulation::AddIssue( $patron, $item1->{barcode} ); # Add a first checkout
651
        my $first_slip = C4::Members::IssueSlip( $branchcode, $patron->{borrowernumber} );
652
653
        C4::Circulation::AddIssue( $patron, $item2->{barcode} ); # Add a second checkout
654
        my $yesterday = dt_from_string->subtract( days => 1 );
655
        C4::Circulation::AddIssue( $patron, $item3->{barcode}, $yesterday ); # Add an overdue
656
        my $second_slip = C4::Members::IssueSlip( $branchcode, $patron->{borrowernumber} );
657
658
        # Cleanup
659
        AddReturn( $item1->{barcode} );
660
        AddReturn( $item2->{barcode} );
661
        AddReturn( $item3->{barcode} );
662
663
        # TT syntax
664
        my $tt_template = <<EOF;
665
<h3>[% branch.branchname %]</h3>
666
Checked out to [% borrower.title %] [% borrower.firstname %] [% borrower.initials %] [% borrower.surname %] <br />
667
([% borrower.cardnumber %]) <br />
668
669
[% today | \$KohaDates with_hours => 1 %]<br />
670
671
<h4>Checked Out</h4>
672
[% FOREACH checkout IN checkouts %]
673
[%~ SET item = checkout.item %]
674
[%~ SET biblio = checkout.item.biblio %]
675
<p>
676
[% biblio.title %] <br />
677
Barcode: [% item.barcode %]<br />
678
Date due: [% checkout.date_due | \$KohaDates %]<br />
679
</p>
680
[% END %]
681
682
<h4>Overdues</h4>
683
[% FOREACH overdue IN overdues %]
684
[%~ SET item = overdue.item %]
685
[%~ SET biblio = overdue.item.biblio %]
686
<p>
687
[% biblio.title %] <br />
688
Barcode: [% item.barcode %]<br />
689
Date due: [% overdue.date_due | \$KohaDates %]<br />
690
</p>
691
[% END %]
692
693
<hr>
694
695
<h4 style="text-align: center; font-style:italic;">News</h4>
696
[% FOREACH n IN news %]
697
<div class="newsitem">
698
<h5 style="margin-bottom: 1px; margin-top: 1px"><b>[% n.title %]</b></h5>
699
<p style="margin-bottom: 1px; margin-top: 1px">[% n.content %]</p>
700
<p class="newsfooter" style="font-size: 8pt; font-style:italic; margin-bottom: 1px; margin-top: 1px">Posted on [% n.timestamp | \$KohaDates %]</p>
701
<hr />
702
</div>
703
[% END %]
704
EOF
705
706
        reset_template( { template => $tt_template, code => $code, module => 'circulation' } );
707
708
        C4::Circulation::AddIssue( $patron, $item1->{barcode} ); # Add a first checkout
709
        my $first_tt_slip = C4::Members::IssueSlip( $branchcode, $patron->{borrowernumber} );
710
711
        C4::Circulation::AddIssue( $patron, $item2->{barcode} ); # Add a second checkout
712
        C4::Circulation::AddIssue( $patron, $item3->{barcode}, $yesterday ); # Add an overdue
713
        my $second_tt_slip = C4::Members::IssueSlip( $branchcode, $patron->{borrowernumber} );
714
715
        # There is too many line breaks generated by the historic syntax
716
        $second_slip->{content} =~ s|</p>\n\n\n<p>|</p>\n\n<p>|s;
717
718
        is( $first_tt_slip->{content}, $first_slip->{content}, );
719
        is( $second_tt_slip->{content}, $second_slip->{content}, );
720
    };
585
};
721
};
586
722
587
subtest 'loops' => sub {
723
subtest 'loops' => sub {
588
- 

Return to bug 17966