|
Lines 40-46
use C4::Dates qw/format_date/;
Link Here
|
| 40 |
use C4::Debug; |
40 |
use C4::Debug; |
| 41 |
use C4::Letters; |
41 |
use C4::Letters; |
| 42 |
use C4::Overdues qw(GetFine GetOverdueMessageTransportTypes); |
42 |
use C4::Overdues qw(GetFine GetOverdueMessageTransportTypes); |
| 43 |
use C4::Budgets qw(GetCurrency); |
|
|
| 44 |
|
43 |
|
| 45 |
use Koha::Borrower::Debarments qw(AddUniqueDebarment); |
44 |
use Koha::Borrower::Debarments qw(AddUniqueDebarment); |
| 46 |
use Koha::DateUtils; |
45 |
use Koha::DateUtils; |
|
Lines 812-886
if ( defined $htmlfilename ) {
Link Here
|
| 812 |
|
811 |
|
| 813 |
These methods are internal to the operation of overdue_notices.pl. |
812 |
These methods are internal to the operation of overdue_notices.pl. |
| 814 |
|
813 |
|
| 815 |
=head2 parse_letter |
|
|
| 816 |
|
| 817 |
parses the letter template, replacing the placeholders with data |
| 818 |
specific to this patron, biblio, or item |
| 819 |
|
| 820 |
named parameters: |
| 821 |
letter - required hashref |
| 822 |
borrowernumber - required integer |
| 823 |
substitute - optional hashref of other key/value pairs that should |
| 824 |
be substituted in the letter content |
| 825 |
|
| 826 |
returns the C<letter> hashref, with the content updated to reflect the |
| 827 |
substituted keys and values. |
| 828 |
|
| 829 |
|
| 830 |
=cut |
| 831 |
|
| 832 |
sub parse_letter { |
| 833 |
my $params = shift; |
| 834 |
foreach my $required (qw( letter_code borrowernumber )) { |
| 835 |
return unless ( exists $params->{$required} && $params->{$required} ); |
| 836 |
} |
| 837 |
|
| 838 |
my $substitute = $params->{'substitute'} || {}; |
| 839 |
$substitute->{today} ||= C4::Dates->new()->output("syspref"); |
| 840 |
|
| 841 |
my %tables = ( 'borrowers' => $params->{'borrowernumber'} ); |
| 842 |
if ( my $p = $params->{'branchcode'} ) { |
| 843 |
$tables{'branches'} = $p; |
| 844 |
} |
| 845 |
|
| 846 |
my $currencies = GetCurrency(); |
| 847 |
my $currency_format; |
| 848 |
$currency_format = $currencies->{currency} if defined($currencies); |
| 849 |
|
| 850 |
my @item_tables; |
| 851 |
if ( my $i = $params->{'items'} ) { |
| 852 |
my $item_format = ''; |
| 853 |
foreach my $item (@$i) { |
| 854 |
my $fine = GetFine($item->{'itemnumber'}, $params->{'borrowernumber'}); |
| 855 |
if ( !$item_format and defined $params->{'letter'}->{'content'} ) { |
| 856 |
$params->{'letter'}->{'content'} =~ m/(<item>.*<\/item>)/; |
| 857 |
$item_format = $1; |
| 858 |
} |
| 859 |
|
| 860 |
$item->{'fine'} = currency_format($currency_format, "$fine", FMT_SYMBOL); |
| 861 |
# if active currency isn't correct ISO code fallback to sprintf |
| 862 |
$item->{'fine'} = sprintf('%.2f', $fine) unless $item->{'fine'}; |
| 863 |
|
| 864 |
push @item_tables, { |
| 865 |
'biblio' => $item->{'biblionumber'}, |
| 866 |
'biblioitems' => $item->{'biblionumber'}, |
| 867 |
'items' => $item, |
| 868 |
'issues' => $item->{'itemnumber'}, |
| 869 |
}; |
| 870 |
} |
| 871 |
} |
| 872 |
|
| 873 |
return C4::Letters::GetPreparedLetter ( |
| 874 |
module => 'circulation', |
| 875 |
letter_code => $params->{'letter_code'}, |
| 876 |
branchcode => $params->{'branchcode'}, |
| 877 |
tables => \%tables, |
| 878 |
substitute => $substitute, |
| 879 |
repeat => { item => \@item_tables }, |
| 880 |
message_transport_type => $params->{message_transport_type}, |
| 881 |
); |
| 882 |
} |
| 883 |
|
| 884 |
=head2 prepare_letter_for_printing |
814 |
=head2 prepare_letter_for_printing |
| 885 |
|
815 |
|
| 886 |
returns a string of text appropriate for printing in the event that an |
816 |
returns a string of text appropriate for printing in the event that an |
| 887 |
- |
|
|