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