|
Lines 23-28
use C4::Auth qw( haspermission );
Link Here
|
| 23 |
use C4::Context; |
23 |
use C4::Context; |
| 24 |
use C4::Circulation; |
24 |
use C4::Circulation; |
| 25 |
use Koha::Checkouts; |
25 |
use Koha::Checkouts; |
|
|
26 |
use Koha::Old::Checkouts; |
| 26 |
|
27 |
|
| 27 |
use Try::Tiny; |
28 |
use Try::Tiny; |
| 28 |
|
29 |
|
|
Lines 42-49
List Koha::Checkout objects
Link Here
|
| 42 |
|
43 |
|
| 43 |
sub list { |
44 |
sub list { |
| 44 |
my $c = shift->openapi->valid_input or return; |
45 |
my $c = shift->openapi->valid_input or return; |
|
|
46 |
my $checked_in = $c->validation->param('checked_in'); |
| 45 |
try { |
47 |
try { |
| 46 |
my $checkouts_set = Koha::Checkouts->new; |
48 |
my $checkouts_set; |
|
|
49 |
if ( $checked_in ) { |
| 50 |
$checkouts_set = Koha::Old::Checkouts->new; |
| 51 |
} else { |
| 52 |
$checkouts_set = Koha::Checkouts->new; |
| 53 |
} |
| 47 |
my $checkouts = $c->objects->search( $checkouts_set, \&_to_model, \&_to_api ); |
54 |
my $checkouts = $c->objects->search( $checkouts_set, \&_to_model, \&_to_api ); |
| 48 |
return $c->render( status => 200, openapi => $checkouts ); |
55 |
return $c->render( status => 200, openapi => $checkouts ); |
| 49 |
} catch { |
56 |
} catch { |
|
Lines 70-76
get one checkout
Link Here
|
| 70 |
sub get { |
77 |
sub get { |
| 71 |
my $c = shift->openapi->valid_input or return; |
78 |
my $c = shift->openapi->valid_input or return; |
| 72 |
|
79 |
|
| 73 |
my $checkout = Koha::Checkouts->find( $c->validation->param('checkout_id') ); |
80 |
my $checkout_id = $c->validation->param('checkout_id'); |
|
|
81 |
my $checkout = Koha::Checkouts->find( $checkout_id ); |
| 82 |
$checkout = Koha::Old::Checkouts->find( $checkout_id ) |
| 83 |
unless ($checkout); |
| 74 |
|
84 |
|
| 75 |
unless ($checkout) { |
85 |
unless ($checkout) { |
| 76 |
return $c->render( |
86 |
return $c->render( |
|
Lines 206-211
our $to_model_mapping = {
Link Here
|
| 206 |
last_renewed_date => 'lastreneweddate', |
216 |
last_renewed_date => 'lastreneweddate', |
| 207 |
checkout_date => 'issuedate', |
217 |
checkout_date => 'issuedate', |
| 208 |
note_date => 'notedate', |
218 |
note_date => 'notedate', |
|
|
219 |
checked_in => undef, |
| 209 |
}; |
220 |
}; |
| 210 |
|
221 |
|
| 211 |
1; |
222 |
1; |