3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
21 use C4::Auth qw( get_template_and_user );
22 use C4::Output qw( output_html_with_http_headers );
24 use Koha::CurbsidePickupPolicies;
28 my $op = $input->param('op') || 'list';
31 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
33 template_name => "admin/curbside_pickup.tt",
36 flagsrequired => { parameters => 'manage_curbside_pickups' },
40 my $libraries = Koha::Libraries->search( {}, { order_by => ['branchname'] } );
41 if ( $op eq 'save' ) {
42 foreach my $library ( $libraries->as_list ) {
43 my $branchcode = $library->branchcode;
46 branchcode => $branchcode,
47 enabled => scalar $input->param("enable-$branchcode") || 0,
48 enable_waiting_holds_only => scalar $input->param("enable-waiting-holds-only-$branchcode") || 0,
49 pickup_interval => scalar $input->param("interval-$branchcode"),
50 patrons_per_interval => scalar $input->param("max-per-interval-$branchcode"),
51 patron_scheduled_pickup => scalar $input->param("patron-scheduled-$branchcode") || 0,
55 Koha::CurbsidePickupPolicies->find_or_create( { branchcode => $branchcode } );
56 $policy->update($params);
58 $policy->opening_slots->delete;
59 my @pickup_slots = $input->multi_param("pickup-slot-" . $branchcode);
60 for my $pickup_slot ( @pickup_slots ) {
61 $policy->add_opening_slot($pickup_slot);
67 if ( $op eq 'list' ) {
70 map { $_->branchcode => $_ }
71 Koha::CurbsidePickupPolicies->search->as_list
73 libraries => $libraries,
78 messages => \@messages,
82 output_html_with_http_headers $input, $cookie, $template->output;