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