|
Lines 126-173
sub offline_ok {
Link Here
|
| 126 |
# the response. |
126 |
# the response. |
| 127 |
# |
127 |
# |
| 128 |
sub checkout { |
128 |
sub checkout { |
| 129 |
my ($self, $patron_id, $item_id, $sc_renew, $fee_ack) = @_; |
129 |
my ( $self, $patron_id, $item_id, $sc_renew, $fee_ack ) = @_; |
| 130 |
my ($patron, $item, $circ); |
130 |
my ( $patron, $item, $circ ); |
| 131 |
|
131 |
|
| 132 |
$circ = C4::SIP::ILS::Transaction::Checkout->new(); |
132 |
$circ = C4::SIP::ILS::Transaction::Checkout->new(); |
|
|
133 |
|
| 133 |
# BEGIN TRANSACTION |
134 |
# BEGIN TRANSACTION |
| 134 |
$circ->patron($patron = C4::SIP::ILS::Patron->new( $patron_id)); |
135 |
$circ->patron( $patron = C4::SIP::ILS::Patron->new($patron_id) ); |
| 135 |
$circ->item($item = C4::SIP::ILS::Item->new( $item_id)); |
136 |
$circ->item( $item = C4::SIP::ILS::Item->new($item_id) ); |
| 136 |
if ($fee_ack) { |
137 |
if ($fee_ack) { |
| 137 |
$circ->fee_ack($fee_ack); |
138 |
$circ->fee_ack($fee_ack); |
| 138 |
} |
139 |
} |
| 139 |
|
140 |
|
| 140 |
if (!$patron) { |
141 |
if ( !$patron ) { |
| 141 |
$circ->screen_msg("Invalid Patron"); |
142 |
$circ->screen_msg("Invalid Patron"); |
| 142 |
} elsif (!$patron->charge_ok) { |
143 |
} |
| 143 |
$circ->screen_msg("Patron Blocked"); |
144 |
elsif ( !$patron->charge_ok ) { |
| 144 |
} elsif (!$item) { |
145 |
$circ->screen_msg("Patron Blocked"); |
| 145 |
$circ->screen_msg("Invalid Item"); |
146 |
} |
| 146 |
# holds checked inside do_checkout |
147 |
elsif ( !$item ) { |
| 147 |
# } elsif ($item->hold_queue && @{$item->hold_queue} && ! $item->barcode_is_borrowernumber($patron_id, $item->hold_queue->[0]->{borrowernumber})) { |
148 |
$circ->screen_msg("Invalid Item"); |
| 148 |
# $circ->screen_msg("Item on Hold for Another User"); |
|
|
| 149 |
} elsif ($item->{patron} && !_ci_cardnumber_cmp($item->{patron},$patron_id)) { |
| 150 |
$circ->screen_msg("Item checked out to another patron"); |
| 151 |
} else { |
| 152 |
$circ->do_checkout(); |
| 153 |
if ($circ->ok){ |
| 154 |
$debug and warn "circ is ok"; |
| 155 |
# If the item is already associated with this patron, then |
| 156 |
# we're renewing it. |
| 157 |
$circ->renew_ok($item->{patron} && _ci_cardnumber_cmp($item->{patron}, $patron_id)); |
| 158 |
|
| 159 |
$item->{patron} = $patron_id; |
| 160 |
$item->{due_date} = $circ->{due}; |
| 161 |
push(@{$patron->{items}}, $item_id); |
| 162 |
$circ->desensitize(!$item->magnetic_media); |
| 163 |
|
| 164 |
syslog("LOG_DEBUG", "ILS::Checkout: patron %s has checked out %s", |
| 165 |
$patron_id, join(', ', @{$patron->{items}})); |
| 166 |
} |
| 167 |
else { |
| 168 |
syslog("LOG_ERR", "ILS::Checkout Issue failed"); |
| 169 |
} |
| 170 |
} |
149 |
} |
|
|
150 |
elsif ( $item->{patron} |
| 151 |
&& !_ci_cardnumber_cmp( $item->{patron}, $patron_id ) ) |
| 152 |
{ |
| 153 |
$circ->screen_msg("Item checked out to another patron"); |
| 154 |
} |
| 155 |
else { |
| 156 |
$circ->do_checkout(); |
| 157 |
if ( $circ->ok ) { |
| 158 |
$debug and warn "circ is ok"; |
| 159 |
|
| 160 |
# If the item is already associated with this patron, then |
| 161 |
# we're renewing it. |
| 162 |
$circ->renew_ok( $item->{patron} |
| 163 |
&& _ci_cardnumber_cmp( $item->{patron}, $patron_id ) ); |
| 164 |
|
| 165 |
$item->{patron} = $patron_id; |
| 166 |
$item->{due_date} = $circ->{due}; |
| 167 |
push( @{ $patron->{items} }, $item_id ); |
| 168 |
$circ->desensitize( !$item->magnetic_media ); |
| 169 |
|
| 170 |
syslog( |
| 171 |
"LOG_DEBUG", "ILS::Checkout: patron %s has checked out %s", |
| 172 |
$patron_id, join( ', ', @{ $patron->{items} } ) |
| 173 |
); |
| 174 |
} |
| 175 |
else { |
| 176 |
syslog( "LOG_ERR", "ILS::Checkout Issue failed" ); |
| 177 |
} |
| 178 |
} |
| 179 |
|
| 171 |
# END TRANSACTION |
180 |
# END TRANSACTION |
| 172 |
|
181 |
|
| 173 |
return $circ; |
182 |
return $circ; |
| 174 |
- |
|
|