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