Lines 15-20
package Koha::REST::V1::Checkout;
Link Here
|
15 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
15 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
16 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
16 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
17 |
|
17 |
|
|
|
18 |
use strict; |
19 |
use warnings; |
20 |
|
18 |
use Modern::Perl; |
21 |
use Modern::Perl; |
19 |
|
22 |
|
20 |
use Mojo::Base 'Mojolicious::Controller'; |
23 |
use Mojo::Base 'Mojolicious::Controller'; |
Lines 22-27
use Mojo::Base 'Mojolicious::Controller';
Link Here
|
22 |
use C4::Auth qw( haspermission ); |
25 |
use C4::Auth qw( haspermission ); |
23 |
use C4::Circulation; |
26 |
use C4::Circulation; |
24 |
use Koha::Issues; |
27 |
use Koha::Issues; |
|
|
28 |
use Koha::OldIssues; |
25 |
|
29 |
|
26 |
sub list { |
30 |
sub list { |
27 |
my ($c, $args, $cb) = @_; |
31 |
my ($c, $args, $cb) = @_; |
Lines 94-97
sub renew {
Link Here
|
94 |
return $c->$cb($checkout->unblessed, 200); |
98 |
return $c->$cb($checkout->unblessed, 200); |
95 |
} |
99 |
} |
96 |
|
100 |
|
|
|
101 |
sub listhistory { |
102 |
my ($c, $args, $cb) = @_; |
103 |
|
104 |
my $user = $c->stash('koha.user'); |
105 |
unless ($user && haspermission($user->userid, { circulate => "circulate_remaining_permissions" })) { |
106 |
return $c->$cb({error => "You don't have the required permission"}, 403); |
107 |
} |
108 |
|
109 |
my $borrowernumber = $c->param('borrowernumber'); |
110 |
|
111 |
my $checkouts; |
112 |
|
113 |
if ($borrowernumber) { |
114 |
|
115 |
$checkouts = Koha::OldIssues->search({ |
116 |
borrowernumber => $borrowernumber |
117 |
})->unblessed; |
118 |
|
119 |
} else { |
120 |
|
121 |
# Retrieve all the issues in the history, but only the issue_id due to possible perfomance issues |
122 |
$checkouts = Koha::OldIssues->search({}, { |
123 |
columns => [qw/issue_id/], |
124 |
})->unblessed; |
125 |
|
126 |
} |
127 |
|
128 |
$c->$cb($checkouts, 200); |
129 |
} |
130 |
|
131 |
sub gethistory { |
132 |
my ($c, $args, $cb) = @_; |
133 |
|
134 |
my $user = $c->stash('koha.user'); |
135 |
unless ($user && haspermission($user->userid, { circulate => "circulate_remaining_permissions" })) { |
136 |
return $c->$cb({error => "You don't have the required permission"}, 403); |
137 |
} |
138 |
|
139 |
my $checkout_id = $args->{checkout_id}; |
140 |
my $checkout = Koha::OldIssues->find($checkout_id); |
141 |
|
142 |
if (!$checkout) { |
143 |
return $c->$cb({ |
144 |
error => "Checkout doesn't exist" |
145 |
}, 404); |
146 |
} |
147 |
|
148 |
return $c->$cb($checkout->unblessed, 200); |
149 |
} |
150 |
|
97 |
1; |
151 |
1; |