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 1136-1174 sub IssueSlip { Link Here
1136
             $b->{issuedate} <=> $a->{issuedate} : $s;
1136
             $b->{issuedate} <=> $a->{issuedate} : $s;
1137
    } @issues;
1137
    } @issues;
1138
1138
1139
    my ($letter_code, %repeat);
1139
    my ($letter_code, %repeat, %loops);
1140
    if ( $quickslip ) {
1140
    if ( $quickslip ) {
1141
        $letter_code = 'ISSUEQSLIP';
1141
        $letter_code = 'ISSUEQSLIP';
1142
        %repeat =  (
1142
        my @checkouts = map {
1143
            'checkedout' => [ map {
1144
                'biblio'       => $_,
1143
                'biblio'       => $_,
1145
                'items'        => $_,
1144
                'items'        => $_,
1146
                'biblioitems'  => $_,
1145
                'biblioitems'  => $_,
1147
                'issues'       => $_,
1146
                'issues'       => $_,
1148
            }, grep { $_->{'now'} } @issues ],
1147
            }, grep { $_->{'now'} } @issues;
1148
        %repeat =  (
1149
            checkedout => \@checkouts, # History syntax
1150
        );
1151
        %loops = (
1152
            issues => [ map { $_->{issues}{itemnumber} } @checkouts ], # TT syntax
1149
        );
1153
        );
1150
    }
1154
    }
1151
    else {
1155
    else {
1156
        my @checkouts = map {
1157
            'biblio'        => $_,
1158
              'items'       => $_,
1159
              'biblioitems' => $_,
1160
              'issues'      => $_,
1161
        }, grep { !$_->{'overdue'} } @issues;
1162
        my @overdues = map {
1163
            'biblio'        => $_,
1164
              'items'       => $_,
1165
              'biblioitems' => $_,
1166
              'issues'      => $_,
1167
        }, grep { $_->{'overdue'} } @issues;
1168
        my $news = GetNewsToDisplay( "slip", $branch );
1169
        my @news = map {
1170
            $_->{'timestamp'} = $_->{'newdate'};
1171
            { opac_news => $_ }
1172
        } @$news;
1152
        $letter_code = 'ISSUESLIP';
1173
        $letter_code = 'ISSUESLIP';
1153
        %repeat =  (
1174
        %repeat      = (
1154
            'checkedout' => [ map {
1175
            checkedout => \@checkouts,
1155
                'biblio'       => $_,
1176
            overdue    => \@overdues,
1156
                'items'        => $_,
1177
            news       => \@news,
1157
                'biblioitems'  => $_,
1178
        );
1158
                'issues'       => $_,
1179
        %loops = (
1159
            }, grep { !$_->{'overdue'} } @issues ],
1180
            issues => [ map { $_->{issues}{itemnumber} } @checkouts ],
1160
1181
            overdues   => [ map { $_->{issues}{itemnumber} } @overdues ],
1161
            'overdue' => [ map {
1182
            opac_news => [ map { $_->{opac_news}{idnew} } @news ],
1162
                'biblio'       => $_,
1163
                'items'        => $_,
1164
                'biblioitems'  => $_,
1165
                'issues'       => $_,
1166
            }, grep { $_->{'overdue'} } @issues ],
1167
1168
            'news' => [ map {
1169
                $_->{'timestamp'} = $_->{'newdate'};
1170
                { opac_news => $_ }
1171
            } @{ GetNewsToDisplay("slip",$branch) } ],
1172
        );
1183
        );
1173
    }
1184
    }
1174
1185
Lines 1182-1187 sub IssueSlip { Link Here
1182
            'borrowers'   => $borrowernumber,
1193
            'borrowers'   => $borrowernumber,
1183
        },
1194
        },
1184
        repeat => \%repeat,
1195
        repeat => \%repeat,
1196
        loops => \%loops,
1185
    );
1197
    );
1186
}
1198
}
1187
1199
(-)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