@@ -, +, @@ now on called itemtype1) (from now on called itemtype2) in issues table for the item of itemtype2 and only one of the items of --- Koha/Checkouts.pm | 28 +++++++++++++++++++ admin/itemtypes.pl | 3 ++ debian/koha-common.cron.hourly | 1 + .../prog/en/modules/admin/itemtypes.tt | 9 ++++++ misc/cronjobs/automatic_checkin.pl | 27 ++++++++++++++++++ 5 files changed, 68 insertions(+) create mode 100755 misc/cronjobs/automatic_checkin.pl --- a/Koha/Checkouts.pm +++ a/Koha/Checkouts.pm @@ -22,6 +22,7 @@ use Modern::Perl; use Carp; use C4::Context; +use C4::Circulation; use Koha::Checkout; use Koha::Database; use Koha::DateUtils; @@ -62,6 +63,33 @@ sub calculate_dropbox_date { return $dropbox_date; } +=head3 automatic_checkin + +my $automatic_checkins = Koha::Checkouts->automatic_checkin() + +Checks in every due issue which itemtype has automatic_checkin enabled + +=cut + +sub automatic_checkin { + my ($self, $params) = @_; + + my $current_date = dt_from_string; + + my $dtf = Koha::Database->new->schema->storage->datetime_parser; + my $due_checkouts = $self->search( + { date_due => { '<=' => $dtf->format_datetime($current_date) } }, + { prefetch => 'item'} + ); + + while(my $checkout = $due_checkouts->next) { + if($checkout->item->itemtype->automatic_checkin) { + C4::Circulation::AddReturn($checkout->item->barcode, $checkout->branchcode); + } + } + +} + =head3 type =cut --- a/admin/itemtypes.pl +++ a/admin/itemtypes.pl @@ -112,6 +112,7 @@ if ( $op eq 'add_form' ) { my $searchcategory = $input->param('searchcategory'); my $rentalcharge_daily_calendar = $input->param('rentalcharge_daily_calendar') // 0; my $rentalcharge_hourly_calendar = $input->param('rentalcharge_hourly_calendar') // 0; + my $automatic_checkin = $input->param('automatic_checkin') // 0; if ( $itemtype and $is_a_modif ) { # it's a modification $itemtype->description($description); @@ -131,6 +132,7 @@ if ( $op eq 'add_form' ) { $itemtype->searchcategory($searchcategory); $itemtype->rentalcharge_daily_calendar($rentalcharge_daily_calendar); $itemtype->rentalcharge_hourly_calendar($rentalcharge_hourly_calendar); + $itemtype->automatic_checkin($automatic_checkin); eval { $itemtype->store; @@ -163,6 +165,7 @@ if ( $op eq 'add_form' ) { searchcategory => $searchcategory, rentalcharge_daily_calendar => $rentalcharge_daily_calendar, rentalcharge_hourly_calendar => $rentalcharge_hourly_calendar, + automatic_checkin => $automatic_checkin, } ); eval { --- a/debian/koha-common.cron.hourly +++ a/debian/koha-common.cron.hourly @@ -17,3 +17,4 @@ koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/holds/build_holds_queue.pl +koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/automatic_checkin.pl --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt @@ -339,6 +339,15 @@ Item types administration Select 'All libraries' if all libraries use this item type. Otherwise, select the specific libraries that use this item type. +
  • + + [% IF itemtype.automatic_checkin %] + + [% ELSE %] + + [% END %] + If checked, items will be checked in automatically after a period of time. Useful for materials where you really don't care for fisical return, like museum passes, etc. +
  • --- a/misc/cronjobs/automatic_checkin.pl +++ a/misc/cronjobs/automatic_checkin.pl @@ -0,0 +1,27 @@ +#!/usr/bin/perl + +# This file is part of Koha. +# +# Copyright (C) 2020 Theke Solutions +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use Koha::Checkouts; +use Koha::Script -cron; +use C4::Log; + +cronlogaction(); + +Koha::Checkouts->automatic_checkin; --