Lines 20-25
use Modern::Perl;
Link Here
|
20 |
use Mojo::Base 'Mojolicious::Controller'; |
20 |
use Mojo::Base 'Mojolicious::Controller'; |
21 |
|
21 |
|
22 |
use Koha::Items; |
22 |
use Koha::Items; |
|
|
23 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
24 |
|
25 |
use C4::Letters qw(GetPreparedLetter); |
23 |
|
26 |
|
24 |
use List::MoreUtils qw( any ); |
27 |
use List::MoreUtils qw( any ); |
25 |
use Try::Tiny qw( catch try ); |
28 |
use Try::Tiny qw( catch try ); |
Lines 273-276
sub remove_from_bundle {
Link Here
|
273 |
); |
276 |
); |
274 |
} |
277 |
} |
275 |
|
278 |
|
|
|
279 |
=head3 print_slip |
280 |
|
281 |
Controller function that handles constructing and returning the contents for a print slip for this item |
282 |
|
283 |
=cut |
284 |
|
285 |
sub print_slip { |
286 |
my $c = shift->openapi->valid_input or return; |
287 |
|
288 |
my $item_id = $c->validation->param('item_id'); |
289 |
my $item = Koha::Items->find( $item_id ); |
290 |
|
291 |
unless ($item) { |
292 |
return $c->render( |
293 |
status => 404, |
294 |
openapi => { error => "Item not found" } |
295 |
); |
296 |
} |
297 |
|
298 |
my $print_slip_id = $c->validation->param('slip_id'); |
299 |
|
300 |
#FIXME: This should come from the session |
301 |
my $user = $c->stash('koha.user'); |
302 |
my $branchcode = $user->branchcode; |
303 |
my $lang = $user->lang; |
304 |
|
305 |
my $slip = C4::Letters::GetPreparedLetter( |
306 |
module => 'circulation', |
307 |
letter_code => $print_slip_id, |
308 |
branchcode => $branchcode, |
309 |
message_transport_type => 'print', |
310 |
#lang => $lang, |
311 |
tables => { |
312 |
items => $item_id |
313 |
} |
314 |
); |
315 |
|
316 |
unless ($slip) { |
317 |
return $c->render( |
318 |
status => 404, |
319 |
openapi => { error => "Slip not found" } |
320 |
); |
321 |
} |
322 |
|
323 |
return $c->render( |
324 |
status => 200, |
325 |
openapi => { |
326 |
timestamp => output_pref( |
327 |
{ dt => dt_from_string(), dateformat => 'rfc3339' } |
328 |
), |
329 |
slip_id => $print_slip_id, |
330 |
content => $slip->{content}, |
331 |
title => $slip->{title} |
332 |
} |
333 |
); |
334 |
} |
335 |
|
276 |
1; |
336 |
1; |