Lines 153-187
sub store {
Link Here
|
153 |
|
153 |
|
154 |
my $is_modification = $self->in_storage; |
154 |
my $is_modification = $self->in_storage; |
155 |
my $old_booking = $self->get_from_storage; |
155 |
my $old_booking = $self->get_from_storage; |
156 |
if ( $self = |
156 |
|
157 |
$self->SUPER::store |
157 |
if ( $self = $self->SUPER::store ) { |
158 |
and $is_modification |
|
|
159 |
and any { $old_booking->$_ ne $self->$_ } qw(pickup_library_id start_date end_date) ) |
160 |
{ |
161 |
my $patron = $self->patron; |
158 |
my $patron = $self->patron; |
162 |
my $pickup_library = $self->pickup_library; |
159 |
my $pickup_library = $self->pickup_library; |
163 |
my $branch = C4::Context->userenv->{'branch'}; |
160 |
my $branch = C4::Context->userenv->{'branch'}; |
164 |
|
161 |
|
165 |
my $letter = C4::Letters::GetPreparedLetter( |
162 |
if ( $is_modification |
166 |
module => 'bookings', |
163 |
and any { $old_booking->$_ ne $self->$_ } qw(pickup_library_id start_date end_date) ) |
167 |
letter_code => 'BOOKING_MODIFICATION', |
164 |
{ |
168 |
message_transport_type => 'email', |
165 |
my $letter = C4::Letters::GetPreparedLetter( |
169 |
branchcode => $branch, |
166 |
module => 'bookings', |
170 |
lang => $patron->lang, |
167 |
letter_code => 'BOOKING_MODIFICATION', |
171 |
objects => { |
168 |
message_transport_type => 'email', |
172 |
old_booking => $old_booking, |
169 |
branchcode => $branch, |
173 |
booking => $self |
170 |
lang => $patron->lang, |
174 |
}, |
171 |
objects => { |
175 |
); |
172 |
old_booking => $old_booking, |
|
|
173 |
booking => $self |
174 |
}, |
175 |
); |
176 |
|
176 |
|
177 |
if ($letter) { |
177 |
if ($letter) { |
178 |
C4::Letters::EnqueueLetter( |
178 |
C4::Letters::EnqueueLetter( |
179 |
{ |
179 |
{ |
180 |
letter => $letter, |
180 |
letter => $letter, |
181 |
borrowernumber => $patron->borrowernumber, |
181 |
borrowernumber => $patron->borrowernumber, |
182 |
message_transport_type => 'email', |
182 |
message_transport_type => 'email', |
183 |
} |
183 |
} |
|
|
184 |
); |
185 |
} |
186 |
} elsif ( !$is_modification ) { |
187 |
my $letter = C4::Letters::GetPreparedLetter( |
188 |
module => 'bookings', |
189 |
letter_code => 'BOOKING_CONFIRMATION', |
190 |
message_transport_type => 'email', |
191 |
branchcode => $branch, |
192 |
lang => $patron->lang, |
193 |
objects => { booking => $self }, |
184 |
); |
194 |
); |
|
|
195 |
|
196 |
if ($letter) { |
197 |
C4::Letters::EnqueueLetter( |
198 |
{ |
199 |
letter => $letter, |
200 |
borrowernumber => $patron->borrowernumber, |
201 |
message_transport_type => 'email', |
202 |
} |
203 |
); |
204 |
} |
185 |
} |
205 |
} |
186 |
} |
206 |
} |
187 |
} |
207 |
} |