|
Line 0
Link Here
|
|
|
1 |
#!/usr/bin/perl |
| 2 |
|
| 3 |
# Copyright 2011 BibLibre SARL |
| 4 |
# This file is part of Koha. |
| 5 |
# |
| 6 |
# Koha is free software; you can redistribute it and/or modify it under the |
| 7 |
# terms of the GNU General Public License as published by the Free Software |
| 8 |
# Foundation; either version 2 of the License, or (at your option) any later |
| 9 |
# version. |
| 10 |
# |
| 11 |
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
| 12 |
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
| 13 |
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU General Public License along |
| 16 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
| 17 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 |
|
| 19 |
=head1 NAME |
| 20 |
|
| 21 |
cancelorder.pl |
| 22 |
|
| 23 |
=head1 DESCRIPTION |
| 24 |
|
| 25 |
Ask confirmation for cancelling an order line |
| 26 |
and add possibility to indicate a reason for cancellation |
| 27 |
(saved in aqorders.notes) |
| 28 |
|
| 29 |
=cut |
| 30 |
|
| 31 |
use Modern::Perl; |
| 32 |
|
| 33 |
use CGI; |
| 34 |
use C4::Auth; |
| 35 |
use C4::Output; |
| 36 |
# FIXME: C4::Search is needed by C4::Items::GetAnalyticsCount, which is called |
| 37 |
# by C4::Acquisition::DelOrder. But C4::Search is not imported by C4::Items. |
| 38 |
# Once this problem is resolved, the following line can be removed. |
| 39 |
# See Bug 7847. |
| 40 |
use C4::Search; |
| 41 |
use C4::Acquisition; |
| 42 |
|
| 43 |
my $input = new CGI; |
| 44 |
my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( { |
| 45 |
template_name => 'acqui/cancelorder.tt', |
| 46 |
query => $input, |
| 47 |
type => 'intranet', |
| 48 |
authnotrequired => 0, |
| 49 |
flagsrequired => { 'acquisition' => 'order_manage' }, |
| 50 |
debug => 1, |
| 51 |
} ); |
| 52 |
|
| 53 |
my $action = $input->param('action'); |
| 54 |
my $ordernumber = $input->param('ordernumber'); |
| 55 |
my $biblionumber = $input->param('biblionumber'); |
| 56 |
my $referrer = $input->param('referrer') || $input->referer; |
| 57 |
my $del_biblio = $input->param('del_biblio') ? 1 : 0; |
| 58 |
|
| 59 |
if($action and $action eq "confirmcancel") { |
| 60 |
my $reason = $input->param('reason'); |
| 61 |
my $error = DelOrder($biblionumber, $ordernumber, $del_biblio, $reason); |
| 62 |
|
| 63 |
if($error) { |
| 64 |
$template->param(error_delitem => 1) if $error->{'delitem'}; |
| 65 |
$template->param(error_delbiblio => 1) if $error->{'delbiblio'}; |
| 66 |
} else { |
| 67 |
$template->param(success_cancelorder => 1); |
| 68 |
} |
| 69 |
$template->param(confirmcancel => 1); |
| 70 |
} |
| 71 |
|
| 72 |
$template->param( |
| 73 |
ordernumber => $ordernumber, |
| 74 |
biblionumber => $biblionumber, |
| 75 |
referrer => $referrer, |
| 76 |
del_biblio => $del_biblio, |
| 77 |
); |
| 78 |
|
| 79 |
output_html_with_http_headers $input, $cookie, $template->output; |