|
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 |
- |
|
|