Lines 172-205
sub checkout {
Link Here
|
172 |
} |
172 |
} |
173 |
|
173 |
|
174 |
sub checkin { |
174 |
sub checkin { |
175 |
my ($self, $item_id, $trans_date, $return_date, |
175 |
my ( $self, $item_id, $trans_date, $return_date, $current_loc, $item_props, $cancel, $checked_in_ok ) = @_; |
176 |
$current_loc, $item_props, $cancel) = @_; |
176 |
my ( $patron, $item, $circ ); |
177 |
my ($patron, $item, $circ); |
|
|
178 |
|
177 |
|
179 |
$circ = new ILS::Transaction::Checkin; |
178 |
$circ = new ILS::Transaction::Checkin; |
|
|
179 |
|
180 |
# BEGIN TRANSACTION |
180 |
# BEGIN TRANSACTION |
181 |
$circ->item($item = new ILS::Item $item_id); |
181 |
$circ->item( $item = new ILS::Item $item_id); |
182 |
|
182 |
|
183 |
if ($item) { |
183 |
if ($item) { |
184 |
$circ->do_checkin($current_loc, $return_date); |
184 |
$circ->do_checkin( $current_loc, $return_date ); |
185 |
} else { |
185 |
} |
|
|
186 |
else { |
186 |
$circ->alert(1); |
187 |
$circ->alert(1); |
187 |
$circ->alert_type(99); |
188 |
$circ->alert_type(99); |
188 |
$circ->screen_msg('Invalid Item'); |
189 |
$circ->screen_msg('Invalid Item'); |
189 |
} |
190 |
} |
190 |
# It's ok to check it in if it exists, and if it was checked out |
191 |
|
191 |
$circ->ok($item && $item->{patron}); |
192 |
# It's ok to check it in if it exists, and if it was checked out |
192 |
|
193 |
# or it was not checked out but the checked_in_ok flag was set |
193 |
if (!defined($item->{patron})) { |
194 |
$circ->ok( ( $checked_in_ok && $item ) || ( $item && $item->{patron} ) ); |
194 |
$circ->screen_msg("Item not checked out"); |
195 |
|
195 |
} else { |
196 |
if ( !defined( $item->{patron} ) ) { |
196 |
if ($circ->ok) { |
197 |
$circ->screen_msg("Item not checked out") unless $checked_in_ok; |
197 |
$circ->patron($patron = new ILS::Patron $item->{patron}); |
198 |
} |
198 |
delete $item->{patron}; |
199 |
else { |
199 |
delete $item->{due_date}; |
200 |
if ( $circ->ok ) { |
200 |
$patron->{items} = [ grep {$_ ne $item_id} @{$patron->{items}} ]; |
201 |
$circ->patron( $patron = new ILS::Patron $item->{patron} ); |
201 |
} |
202 |
delete $item->{patron}; |
202 |
} |
203 |
delete $item->{due_date}; |
|
|
204 |
$patron->{items} = [ grep { $_ ne $item_id } @{ $patron->{items} } ]; |
205 |
} |
206 |
} |
207 |
|
203 |
# END TRANSACTION |
208 |
# END TRANSACTION |
204 |
|
209 |
|
205 |
return $circ; |
210 |
return $circ; |