|
Lines 14-19
use Koha::DateUtils qw( dt_from_string output_pref );
Link Here
|
| 14 |
use Koha::Patrons; |
14 |
use Koha::Patrons; |
| 15 |
use Koha::Patron::Debarments qw( AddDebarment ); |
15 |
use Koha::Patron::Debarments qw( AddDebarment ); |
| 16 |
|
16 |
|
|
|
17 |
=head1 NAME |
| 18 |
|
| 19 |
Koha::Patron::Discharge - Koha Discharge object class |
| 20 |
|
| 21 |
=head1 API |
| 22 |
|
| 23 |
=head2 Class Methods |
| 24 |
|
| 25 |
=cut |
| 26 |
|
| 27 |
=head3 count |
| 28 |
|
| 29 |
Koha::Patron:Discharge->count; |
| 30 |
|
| 31 |
Return the number of discharges corresponding to the asked criteria |
| 32 |
|
| 33 |
=cut |
| 34 |
|
| 17 |
sub count { |
35 |
sub count { |
| 18 |
my ($params) = @_; |
36 |
my ($params) = @_; |
| 19 |
my $values = {}; |
37 |
my $values = {}; |
|
Lines 31-36
sub count {
Link Here
|
| 31 |
return search_limited($values)->count; |
49 |
return search_limited($values)->count; |
| 32 |
} |
50 |
} |
| 33 |
|
51 |
|
|
|
52 |
=head3 can_be_discharged |
| 53 |
|
| 54 |
my $can_be_discharged = Koha::Patron:Discharge->can_be_discharged({borrowernumber => $borrowernumber}); |
| 55 |
|
| 56 |
Return true if the borrower can be discharged |
| 57 |
|
| 58 |
=cut |
| 59 |
|
| 34 |
sub can_be_discharged { |
60 |
sub can_be_discharged { |
| 35 |
my ($params) = @_; |
61 |
my ($params) = @_; |
| 36 |
return unless $params->{borrowernumber}; |
62 |
return unless $params->{borrowernumber}; |
|
Lines 56-61
sub can_be_discharged {
Link Here
|
| 56 |
return ( $can_be_discharged, $problems ); |
82 |
return ( $can_be_discharged, $problems ); |
| 57 |
} |
83 |
} |
| 58 |
|
84 |
|
|
|
85 |
=head3 is_discharged |
| 86 |
|
| 87 |
my $is_discharged = Koha::Patron:Discharge->is_discharged({borrowernumber => $borrowernumber}); |
| 88 |
|
| 89 |
Return true if the borrower is discharged |
| 90 |
|
| 91 |
=cut |
| 92 |
|
| 59 |
sub is_discharged { |
93 |
sub is_discharged { |
| 60 |
my ($params) = @_; |
94 |
my ($params) = @_; |
| 61 |
return unless $params->{borrowernumber}; |
95 |
return unless $params->{borrowernumber}; |
|
Lines 71-76
sub is_discharged {
Link Here
|
| 71 |
} |
105 |
} |
| 72 |
} |
106 |
} |
| 73 |
|
107 |
|
|
|
108 |
=head3 request |
| 109 |
|
| 110 |
my $request = Koha::Patron:Discharge->request({borrowernumber => $borrowernumber}); |
| 111 |
|
| 112 |
Place a discharge request on a given borrower after checking the borrower has the right to be discharged. |
| 113 |
|
| 114 |
=cut |
| 115 |
|
| 74 |
sub request { |
116 |
sub request { |
| 75 |
my ($params) = @_; |
117 |
my ($params) = @_; |
| 76 |
my $borrowernumber = $params->{borrowernumber}; |
118 |
my $borrowernumber = $params->{borrowernumber}; |
|
Lines 87-92
sub request {
Link Here
|
| 87 |
); |
129 |
); |
| 88 |
} |
130 |
} |
| 89 |
|
131 |
|
|
|
132 |
=head3 discharge |
| 133 |
|
| 134 |
my $request = Koha::Patron:Discharge->discharge({borrowernumber => $borrowernumber}); |
| 135 |
|
| 136 |
Place a discharge request on a given borrower, if a discharge was requested, update the status to discharged and place a suspension on the user. |
| 137 |
|
| 138 |
=cut |
| 139 |
|
| 90 |
sub discharge { |
140 |
sub discharge { |
| 91 |
my ($params) = @_; |
141 |
my ($params) = @_; |
| 92 |
my $borrowernumber = $params->{borrowernumber}; |
142 |
my $borrowernumber = $params->{borrowernumber}; |
|
Lines 124-129
sub discharge {
Link Here
|
| 124 |
} |
174 |
} |
| 125 |
} |
175 |
} |
| 126 |
|
176 |
|
|
|
177 |
=head3 generate_as_pdf |
| 178 |
|
| 179 |
my $request = Koha::Patron:Discharge->generate_as_pdf({borrowernumber => $borrowernumber}); |
| 180 |
|
| 181 |
Create a pdf from an existing discharge associated to the borrowernumber. |
| 182 |
|
| 183 |
=cut |
| 184 |
|
| 127 |
sub generate_as_pdf { |
185 |
sub generate_as_pdf { |
| 128 |
my ($params) = @_; |
186 |
my ($params) = @_; |
| 129 |
return unless $params->{borrowernumber}; |
187 |
return unless $params->{borrowernumber}; |
|
Lines 175-180
sub generate_as_pdf {
Link Here
|
| 175 |
return $pdf_path; |
233 |
return $pdf_path; |
| 176 |
} |
234 |
} |
| 177 |
|
235 |
|
|
|
236 |
=head3 get_pendings |
| 237 |
|
| 238 |
my $rs = Koha::Patron:Discharge->get_pendings({ |
| 239 |
borrowernumber => $borrowernumber |
| 240 |
branchcode => $branchcode |
| 241 |
}); |
| 242 |
|
| 243 |
Get all pending discharges associated to a borrowernumber and/or a given branch |
| 244 |
|
| 245 |
=cut |
| 246 |
|
| 178 |
sub get_pendings { |
247 |
sub get_pendings { |
| 179 |
my ($params) = @_; |
248 |
my ($params) = @_; |
| 180 |
my $branchcode = $params->{branchcode}; |
249 |
my $branchcode = $params->{branchcode}; |
|
Lines 190-195
sub get_pendings {
Link Here
|
| 190 |
return search_limited($cond); |
259 |
return search_limited($cond); |
| 191 |
} |
260 |
} |
| 192 |
|
261 |
|
|
|
262 |
=head3 get_validated |
| 263 |
|
| 264 |
my $rs = Koha::Patron:Discharge->get_validated({ |
| 265 |
borrowernumber => $borrowernumber |
| 266 |
branchcode => $branchcode |
| 267 |
}); |
| 268 |
|
| 269 |
Get all validated discharges associated to a borrowernumber and/or a given branch |
| 270 |
|
| 271 |
=cut |
| 272 |
|
| 193 |
sub get_validated { |
273 |
sub get_validated { |
| 194 |
my ($params) = @_; |
274 |
my ($params) = @_; |
| 195 |
my $branchcode = $params->{branchcode}; |
275 |
my $branchcode = $params->{branchcode}; |
|
Lines 205-210
sub get_validated {
Link Here
|
| 205 |
} |
285 |
} |
| 206 |
|
286 |
|
| 207 |
# TODO This module should be based on Koha::Object[s] |
287 |
# TODO This module should be based on Koha::Object[s] |
|
|
288 |
|
| 289 |
=head3 search_limited |
| 290 |
|
| 291 |
my $rs = Koha::Patron:Discharge->search_limited({ |
| 292 |
borrower.branchcode => $branchcode |
| 293 |
}, |
| 294 |
$attributes); |
| 295 |
|
| 296 |
Search all discharges that can be seen by the user and fitting the given conditions |
| 297 |
|
| 298 |
=cut |
| 299 |
|
| 208 |
sub search_limited { |
300 |
sub search_limited { |
| 209 |
my ( $params, $attributes ) = @_; |
301 |
my ( $params, $attributes ) = @_; |
| 210 |
my $userenv = C4::Context->userenv; |
302 |
my $userenv = C4::Context->userenv; |
| 211 |
- |
|
|