View | Details | Raw Unified | Return to bug 13411
Collapse All | Expand All

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

Return to bug 13411