Bug 10120: (QA followup) avoid raising warnings on upgrade
[koha.git] / acqui / uncertainprice.pl
bloba90c75f41eb3eba0cc7de829da17931d9dff93e1
1 #!/usr/bin/perl
3 #script to show a list of orders with uncertain prices for a bookseller
4 #the script also allows to edit the prices and uncheck the uncertainprice property of them
5 #written by john.soros@biblibre.com 01/10/2008
7 # Copyright 2008-2009 BibLibre SARL
9 # This file is part of Koha.
11 # Koha is free software; you can redistribute it and/or modify it
12 # under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 3 of the License, or
14 # (at your option) any later version.
16 # Koha is distributed in the hope that it will be useful, but
17 # WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with Koha; if not, see <http://www.gnu.org/licenses>.
25 =head1 NAME
27 uncertainprice.pl
29 =head1 DESCRIPTION
31 This script displays all the orders with uncertain prices for a given bookseller, it also lets the user modify the unitprice and uncertainprice properties of the order
33 =head1 CGI PARAMETERS
35 =over 4
37 =item $booksellerid
39 The bookseller who we want to display the orders of.
41 =back
43 =cut
46 use strict;
47 use warnings;
49 use C4::Auth;
50 use C4::Output;
51 use CGI qw ( -utf8 );
53 use C4::Bookseller::Contact;
54 use C4::Acquisition qw/SearchOrders GetOrder ModOrder/;
55 use C4::Biblio qw/GetBiblioData/;
57 use Koha::Acquisition::Bookseller;
59 my $input=new CGI;
61 my ($template, $loggedinuser, $cookie)
62 = get_template_and_user({template_name => "acqui/uncertainprice.tt",
63 query => $input,
64 type => "intranet",
65 authnotrequired => 0,
66 flagsrequired => { acquisition => 'order_manage' },
67 debug => 1,
68 });
70 my $booksellerid = $input->param('booksellerid');
71 my $basketno = $input->param('basketno');
72 my $op = $input->param('op');
73 my $owner = $input->param('owner') || 0 ; # flag to see only "my" orders, or everyone orders
74 my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
76 #show all orders that have uncertain price for the bookseller
77 my $pendingorders = SearchOrders({
78 booksellerid => $booksellerid,
79 owner => $owner,
80 basketno => $basketno,
81 pending => 1,
82 });
83 my @orders;
85 foreach my $order (@{$pendingorders}) {
86 if ( $order->{'uncertainprice'} ) {
87 my $bibdata = &GetBiblioData($order->{'biblionumber'});
88 $order->{'bibisbn'} = $bibdata->{'isbn'};
89 $order->{'bibpublishercode'} = $bibdata->{'publishercode'};
90 $order->{'bibpublicationyear'} = $bibdata->{'publicationyear'};
91 $order->{'bibtitle'} = $bibdata->{'title'};
92 $order->{'bibauthor'} = $bibdata->{'author'};
93 $order->{'surname'} = $order->{'surname'};
94 $order->{'firstname'} = $order->{'firstname'};
95 my $order_as_from_db=GetOrder($order->{ordernumber});
96 $order->{'quantity'} = $order_as_from_db->{'quantity'};
97 $order->{'listprice'} = $order_as_from_db->{'listprice'};
98 push(@orders, $order);
101 if ( $op eq 'validate' ) {
102 $template->param( validate => 1);
103 my $count = scalar(@orders);
104 for (my $i=0; $i < $count; $i++) {
105 my $order = pop(@orders);
106 my $ordernumber = $order->{ordernumber};
107 my $order_as_from_db=GetOrder($order->{ordernumber});
108 $order->{'listprice'} = $input->param('price'.$ordernumber);
109 $order->{'ecost'}= $input->param('price'.$ordernumber) - (($input->param('price'.$ordernumber) /100) * $bookseller->{'discount'});
110 $order->{'rrp'} = $input->param('price'.$ordernumber);
111 $order->{'quantity'}=$input->param('qty'.$ordernumber);
112 $order->{'uncertainprice'}=$input->param('uncertainprice'.$ordernumber);
113 ModOrder($order);
117 $template->param( uncertainpriceorders => \@orders,
118 booksellername => "".$bookseller->{'name'},
119 booksellerid => $bookseller->{'id'},
120 booksellerpostal =>$bookseller->{'postal'},
121 bookselleraddress1 => $bookseller->{'address1'},
122 bookselleraddress2 => $bookseller->{'address2'},
123 bookselleraddress3 => $bookseller->{'address3'},
124 bookselleraddress4 => $bookseller->{'address4'},
125 booksellerphone =>$bookseller->{'phone'},
126 booksellerfax => $bookseller->{'fax'},
127 booksellerurl => $bookseller->{'url'},
128 booksellernotes => $bookseller->{'notes'},
129 basketcount => $bookseller->{'basketcount'},
130 subscriptioncount => $bookseller->{'subscriptioncount'},
131 active => $bookseller->{active},
132 owner => $owner,
133 scriptname => "/cgi-bin/koha/acqui/uncertainprice.pl");
134 $template->{'VARS'}->{'contacts'} = $bookseller->{'contacts'};
135 output_html_with_http_headers $input, $cookie, $template->output;