3 # Copyright 2021 Aleisha Amohia <aleisha@catalyst.net.nz>
5 # This file is part of Koha.
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.
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.
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>.
26 Modify just the estimated delivery date of an individual order when
34 use C4::Auth qw( get_template_and_user );
35 use C4::Output qw( output_html_with_http_headers );
36 use C4::Acquisition qw( GetOrder GetBasket ModOrder );
38 use Koha::Acquisition::Booksellers;
39 use Koha::DateUtils qw( dt_from_string );
42 my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( {
43 template_name => 'acqui/moddeliverydate.tt',
46 flagsrequired => { 'acquisition' => 'order_manage' },
49 my $op = $input->param('op');
50 my $ordernumber = $input->param('ordernumber');
51 my $referrer = $input->param('referrer') || $input->referer();
52 my $order = GetOrder($ordernumber);
53 my $basket = GetBasket($order->{basketno});
54 my $bookseller = Koha::Acquisition::Booksellers->find( $basket->{booksellerid} );
56 if($op and $op eq 'save') {
57 my $estimated_delivery_date = $input->param('estimated_delivery_date');
58 $order->{'estimated_delivery_date'} = $estimated_delivery_date ? dt_from_string( $estimated_delivery_date ) : undef;
60 print $input->redirect($referrer);
64 estimated_delivery_date => $order->{'estimated_delivery_date'}
69 $template->param($op => 1);
73 basketname => $basket->{'basketname'},
74 basketno => $order->{basketno},
75 booksellerid => $bookseller->id,
76 booksellername => $bookseller->name,
77 ordernumber => $ordernumber,
78 referrer => $referrer,
82 output_html_with_http_headers $input, $cookie, $template->output;