|
Lines 28-33
use Koha::Database;
Link Here
|
| 28 |
use Koha::DateUtils qw( dt_from_string ); |
28 |
use Koha::DateUtils qw( dt_from_string ); |
| 29 |
use Koha::Exceptions::Account; |
29 |
use Koha::Exceptions::Account; |
| 30 |
use Koha::Patron::Debarments; |
30 |
use Koha::Patron::Debarments; |
|
|
31 |
use Koha::Notice::Templates; |
| 31 |
use C4::Letters; |
32 |
use C4::Letters; |
| 32 |
|
33 |
|
| 33 |
use base qw(Koha::Object Koha::Object::Mixin::AdditionalFields); |
34 |
use base qw(Koha::Object Koha::Object::Mixin::AdditionalFields); |
|
Lines 1099-1119
sub store {
Link Here
|
| 1099 |
} |
1100 |
} |
| 1100 |
|
1101 |
|
| 1101 |
#if there is a matching debit description letter, pull that content and render it for the accountline.description |
1102 |
#if there is a matching debit description letter, pull that content and render it for the accountline.description |
| 1102 |
if ( $self->is_debit && !$self->in_storage && !$self->description ) { |
1103 |
if ( $self->is_debit && !$self->in_storage ) { |
| 1103 |
my $debit_type = $self->debit_type; |
1104 |
my $debit_type = $self->debit_type; |
| 1104 |
if ($debit_type) { |
1105 |
if ($debit_type) { |
| 1105 |
my $letter = C4::Letters::GetPreparedLetter( |
1106 |
|
| 1106 |
module => 'debit_description', |
1107 |
# get the patron's prederred lang |
| 1107 |
letter_code => $debit_type->code, |
1108 |
my $patron = $self->patron; |
| 1108 |
tables => { |
1109 |
my $lang = $patron ? $patron->lang : 'default'; |
| 1109 |
borrowers => $self->borrowernumber, |
1110 |
|
| 1110 |
branches => $self->branchcode, |
1111 |
# check to make sure the custom notice exists |
| 1111 |
accountline => $self, |
1112 |
my $notice_exists = Koha::Notice::Templates->search( |
| 1112 |
}, |
1113 |
{ |
| 1113 |
); |
1114 |
module => 'debit_description', |
| 1114 |
|
1115 |
code => $debit_type->code, |
| 1115 |
if ( $letter && $letter->{content} ) { |
1116 |
message_transport_type => 'email', |
| 1116 |
$self->description( $letter->{content} ); |
1117 |
lang => $lang, |
|
|
1118 |
} |
| 1119 |
)->count; |
| 1120 |
|
| 1121 |
if ($notice_exists) { |
| 1122 |
my $letter = C4::Letters::GetPreparedLetter( |
| 1123 |
module => 'debit_description', |
| 1124 |
letter_code => $debit_type->code, |
| 1125 |
message_transport_type => 'email', |
| 1126 |
lang => $lang, |
| 1127 |
tables => { |
| 1128 |
borrowers => $self->borrowernumber, |
| 1129 |
branches => $self->branchcode, |
| 1130 |
}, |
| 1131 |
substitute => { |
| 1132 |
accountline => $self, |
| 1133 |
}, |
| 1134 |
); |
| 1135 |
|
| 1136 |
if ( $letter && $letter->{content} ) { |
| 1137 |
$self->description( $letter->{content} ); |
| 1138 |
} |
| 1117 |
} |
1139 |
} |
| 1118 |
} |
1140 |
} |
| 1119 |
} |
1141 |
} |