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

(-)a/Koha/Checkouts.pm (+28 lines)
Lines 22-27 use Modern::Perl; Link Here
22
use Carp;
22
use Carp;
23
23
24
use C4::Context;
24
use C4::Context;
25
use C4::Circulation;
25
use Koha::Checkout;
26
use Koha::Checkout;
26
use Koha::Database;
27
use Koha::Database;
27
use Koha::DateUtils;
28
use Koha::DateUtils;
Lines 62-67 sub calculate_dropbox_date { Link Here
62
    return $dropbox_date;
63
    return $dropbox_date;
63
}
64
}
64
65
66
=head3 automatic_checkin
67
68
my $automatic_checkins = Koha::Checkouts->automatic_checkin()
69
70
Checks in every due issue which itemtype has automatic_checkin enabled
71
72
=cut
73
74
sub automatic_checkin {
75
    my ($self, $params) = @_;
76
77
    my $current_date = dt_from_string;
78
79
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
80
    my $due_checkouts = $self->search(
81
        { date_due => { '<=' => $dtf->format_datetime($current_date) } },
82
        { prefetch => 'item'}
83
    );
84
85
    while(my $checkout = $due_checkouts->next) {
86
        if($checkout->item->itemtype->automatic_checkin) {
87
            C4::Circulation::AddReturn($checkout->item->barcode, $checkout->branchcode);
88
        }
89
    }
90
91
}
92
65
=head3 type
93
=head3 type
66
94
67
=cut
95
=cut
(-)a/admin/itemtypes.pl (+3 lines)
Lines 112-117 if ( $op eq 'add_form' ) { Link Here
112
    my $searchcategory = $input->param('searchcategory');
112
    my $searchcategory = $input->param('searchcategory');
113
    my $rentalcharge_daily_calendar  = $input->param('rentalcharge_daily_calendar') // 0;
113
    my $rentalcharge_daily_calendar  = $input->param('rentalcharge_daily_calendar') // 0;
114
    my $rentalcharge_hourly_calendar = $input->param('rentalcharge_hourly_calendar') // 0;
114
    my $rentalcharge_hourly_calendar = $input->param('rentalcharge_hourly_calendar') // 0;
115
    my $automatic_checkin = $input->param('automatic_checkin') // 0;
115
116
116
    if ( $itemtype and $is_a_modif ) {    # it's a modification
117
    if ( $itemtype and $is_a_modif ) {    # it's a modification
117
        $itemtype->description($description);
118
        $itemtype->description($description);
Lines 131-136 if ( $op eq 'add_form' ) { Link Here
131
        $itemtype->searchcategory($searchcategory);
132
        $itemtype->searchcategory($searchcategory);
132
        $itemtype->rentalcharge_daily_calendar($rentalcharge_daily_calendar);
133
        $itemtype->rentalcharge_daily_calendar($rentalcharge_daily_calendar);
133
        $itemtype->rentalcharge_hourly_calendar($rentalcharge_hourly_calendar);
134
        $itemtype->rentalcharge_hourly_calendar($rentalcharge_hourly_calendar);
135
        $itemtype->automatic_checkin($automatic_checkin);
134
136
135
        eval {
137
        eval {
136
          $itemtype->store;
138
          $itemtype->store;
Lines 163-168 if ( $op eq 'add_form' ) { Link Here
163
                searchcategory      => $searchcategory,
165
                searchcategory      => $searchcategory,
164
                rentalcharge_daily_calendar  => $rentalcharge_daily_calendar,
166
                rentalcharge_daily_calendar  => $rentalcharge_daily_calendar,
165
                rentalcharge_hourly_calendar => $rentalcharge_hourly_calendar,
167
                rentalcharge_hourly_calendar => $rentalcharge_hourly_calendar,
168
                automatic_checkin   => $automatic_checkin,
166
            }
169
            }
167
        );
170
        );
168
        eval {
171
        eval {
(-)a/debian/koha-common.cron.hourly (+1 lines)
Lines 17-19 Link Here
17
17
18
18
19
koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/holds/build_holds_queue.pl
19
koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/holds/build_holds_queue.pl
20
koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/automatic_checkin.pl
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt (+9 lines)
Lines 340-345 Item types administration Link Here
340
                    <span class="hint">Select 'All libraries' if all libraries use this item type. Otherwise, select the specific libraries that use this item type.</span>
340
                    <span class="hint">Select 'All libraries' if all libraries use this item type. Otherwise, select the specific libraries that use this item type.</span>
341
                </li>
341
                </li>
342
                <li>
342
                <li>
343
                    <label for="automatic_checkin">Automatic checkin: </label>
344
                        [% IF itemtype.automatic_checkin %]
345
                            <input type="checkbox" id="automatic_checkin" name="automatic_checkin" checked="checked" value="1" />
346
                        [% ELSE %]
347
                            <input type="checkbox" id="automatic_checkin" name="automatic_checkin" value="1" />
348
                        [% END %]
349
                        <span class="hint">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.</span>
350
                </li>
351
                <li>
343
                    <label for="summary">Summary: </label>
352
                    <label for="summary">Summary: </label>
344
                   <textarea id="summary" name="summary" cols="55" rows="5">[% itemtype.summary | html %]</textarea>
353
                   <textarea id="summary" name="summary" cols="55" rows="5">[% itemtype.summary | html %]</textarea>
345
                    <p>Enter a summary that will overwrite the default one in search results lists. Example, for a website itemtype : </p>
354
                    <p>Enter a summary that will overwrite the default one in search results lists. Example, for a website itemtype : </p>
(-)a/misc/cronjobs/automatic_checkin.pl (-1 / +27 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Copyright (C) 2020  Theke Solutions
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
use Koha::Checkouts;
22
use Koha::Script -cron;
23
use C4::Log;
24
25
cronlogaction();
26
27
Koha::Checkouts->automatic_checkin;

Return to bug 23207