Bug 18991: Fix cleanup in t/db_dependent/Log.t
[koha.git] / acqui / cancelorder.pl
bloba0b7597d44bf81ba6fd06d9bce32834ba459ef13
1 #!/usr/bin/perl
3 # Copyright 2014 BibLibre
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>.
20 =head1 NAME
22 cancelorder.pl
24 =head1 DESCRIPTION
26 Ask confirmation for cancelling an order line
27 and add possibility to indicate a reason for cancellation
28 (saved in aqorders.notes)
30 =cut
32 use Modern::Perl;
34 use CGI;
35 use C4::Auth;
36 use C4::Output;
37 use C4::Acquisition;
39 my $input = new CGI;
40 my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( {
41 template_name => 'acqui/cancelorder.tt',
42 query => $input,
43 type => 'intranet',
44 authnotrequired => 0,
45 flagsrequired => { 'acquisition' => 'order_manage' },
46 debug => 1,
47 } );
49 my $action = $input->param('action');
50 my $ordernumber = $input->param('ordernumber');
51 my $biblionumber = $input->param('biblionumber');
52 my $referrer = $input->param('referrer') || $input->referer;
53 my $del_biblio = $input->param('del_biblio') ? 1 : 0;
55 if($action and $action eq "confirmcancel") {
56 my $reason = $input->param('reason');
57 my $error = DelOrder($biblionumber, $ordernumber, $del_biblio, $reason);
59 if($error) {
60 $template->param(error_delitem => 1) if $error->{'delitem'};
61 $template->param(error_delbiblio => 1) if $error->{'delbiblio'};
62 } else {
63 $template->param(success_cancelorder => 1);
65 $template->param(confirmcancel => 1);
68 $template->param(
69 ordernumber => $ordernumber,
70 biblionumber => $biblionumber,
71 referrer => $referrer,
72 del_biblio => $del_biblio,
75 output_html_with_http_headers $input, $cookie, $template->output;