Lines 63-98
sub calculate_dropbox_date {
Link Here
|
63 |
return $dropbox_date; |
63 |
return $dropbox_date; |
64 |
} |
64 |
} |
65 |
|
65 |
|
|
|
66 |
|
66 |
=head3 automatic_checkin |
67 |
=head3 automatic_checkin |
67 |
|
68 |
|
68 |
my $automatic_checkins = Koha::Checkouts->automatic_checkin() |
69 |
my $automatic_checkins = Koha::Checkouts->automatic_checkin() |
69 |
|
70 |
|
70 |
Checks in every due issue which itemtype has automatic_checkin enabled. Also if the AutoCheckinAutoFill sys. pref. is enabled, the item is trapped for the next patron. |
71 |
Checks in every due issue which itemtype has automatic_checkin enabled. Also if the AutoCheckinAutoFill system preference is enabled, the item is trapped for the next patron. |
71 |
|
72 |
|
72 |
=cut |
73 |
=cut |
73 |
|
74 |
|
74 |
sub automatic_checkin { |
75 |
sub automatic_checkin { |
75 |
my ($self, $params) = @_; |
76 |
my ( $self, $params ) = @_; |
76 |
|
77 |
|
77 |
my $current_date = dt_from_string; |
78 |
my $current_date = dt_from_string; |
78 |
|
79 |
|
79 |
my $dtf = Koha::Database->new->schema->storage->datetime_parser; |
80 |
my $dtf = Koha::Database->new->schema->storage->datetime_parser; |
80 |
my $due_checkouts = $self->search( |
81 |
my $due_checkouts = $self->search( |
81 |
{ date_due => { '<=' => $dtf->format_datetime($current_date) } }, |
82 |
{ date_due => { '<=' => $dtf->format_datetime($current_date) } }, |
82 |
{ prefetch => 'item'} |
83 |
{ prefetch => 'item' } |
83 |
); |
84 |
); |
84 |
|
85 |
|
85 |
my $autofill_next = C4::Context->preference('AutomaticCheckinAutoFill'); |
86 |
my $autofill_next = C4::Context->preference('AutomaticCheckinAutoFill'); |
86 |
|
87 |
|
87 |
while ( my $checkout = $due_checkouts->next ) { |
88 |
while ( my $checkout = $due_checkouts->next ) { |
88 |
if ( $checkout->item->itemtype->automatic_checkin ) { |
89 |
if ( $checkout->item->itemtype->automatic_checkin ) { |
89 |
my ( undef, $messages) = C4::Circulation::AddReturn($checkout->item->barcode, $checkout->branchcode, undef, dt_from_string($checkout->date_due) ); |
90 |
my ( undef, $messages ) = C4::Circulation::AddReturn( |
90 |
if ( $autofill_next ){ |
91 |
$checkout->item->barcode, $checkout->branchcode, undef, |
91 |
if ( $messages->{ResFound} ){ |
92 |
dt_from_string( $checkout->date_due ) |
|
|
93 |
); |
94 |
if ($autofill_next) { |
95 |
if ( $messages->{ResFound} ) { |
92 |
my $is_transfer = $checkout->branchcode ne $messages->{ResFound}->{branchcode}; |
96 |
my $is_transfer = $checkout->branchcode ne $messages->{ResFound}->{branchcode}; |
93 |
C4::Reserves::ModReserveAffect($checkout->item->itemnumber, $checkout->borrowernumber, $is_transfer, $messages->{ResFound}->{reserve_id}, $checkout->{desk_id}, 0); |
97 |
C4::Reserves::ModReserveAffect( |
94 |
if( $is_transfer ){ |
98 |
$checkout->item->itemnumber, $checkout->borrowernumber, |
95 |
C4::Items::ModItemTransfer($checkout->item->itemnumber,$checkout->branchcode, $messages->{ResFound}->{branchcode},"Reserve"); |
99 |
$is_transfer, $messages->{ResFound}->{reserve_id}, $checkout->{desk_id}, 0 |
|
|
100 |
); |
101 |
if ($is_transfer) { |
102 |
C4::Items::ModItemTransfer( |
103 |
$checkout->item->itemnumber, $checkout->branchcode, |
104 |
$messages->{ResFound}->{branchcode}, "Reserve" |
105 |
); |
96 |
} |
106 |
} |
97 |
} |
107 |
} |
98 |
} |
108 |
} |
Lines 100-105
sub automatic_checkin {
Link Here
|
100 |
} |
110 |
} |
101 |
} |
111 |
} |
102 |
|
112 |
|
|
|
113 |
|
103 |
=head3 type |
114 |
=head3 type |
104 |
|
115 |
|
105 |
=cut |
116 |
=cut |