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