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>.
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
39 The bookseller who we want to display the orders of.
48 use C4::Auth qw( get_template_and_user );
49 use C4::Output qw( output_html_with_http_headers );
52 use C4::Acquisition qw( SearchOrders GetOrder ModOrder );
54 use Koha::Acquisition::Booksellers;
55 use Koha::Acquisition::Baskets;
59 my ($template, $loggedinuser, $cookie)
60 = get_template_and_user({template_name => "acqui/uncertainprice.tt",
63 flagsrequired => { acquisition => 'order_manage' },
66 my $booksellerid = $input->param('booksellerid');
67 my $basketno = $input->param('basketno');
68 my $op = $input->param('op');
69 my $owner = $input->param('owner') || 0 ; # flag to see only "my" orders, or everyone orders
70 my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
72 $template->param( basket => Koha::Acquisition::Baskets->find($basketno) );
74 #show all orders that have uncertain price for the bookseller
75 my $pendingorders = SearchOrders({
76 booksellerid => $booksellerid,
78 basketno => $basketno,
81 my @orders = grep { $_->{'uncertainprice'} } @$pendingorders;
83 if ( $op eq 'validate' ) {
84 $template->param( validate => 1);
85 my $count = scalar(@orders);
86 for (my $i=0; $i < $count; $i++) {
87 my $order = pop(@orders);
88 my $ordernumber = $order->{ordernumber};
89 next unless ($input->param('qty'.$ordernumber));
90 my $order_as_from_db=GetOrder($order->{ordernumber});
91 $order->{'listprice'} = $input->param('price'.$ordernumber);
92 $order->{'ecost'}= $input->param('price'.$ordernumber) - (($input->param('price'.$ordernumber) /100) * $bookseller->discount);
93 $order->{'rrp'} = $input->param('price'.$ordernumber);
94 $order->{'quantity'}=$input->param('qty'.$ordernumber);
95 $order->{'uncertainprice'}=$input->param('uncertainprice'.$ordernumber);
100 $template->param( uncertainpriceorders => \@orders,
101 booksellername => "".$bookseller->name,
102 booksellerid => $bookseller->id,
103 booksellerpostal =>$bookseller->postal,
104 bookselleraddress1 => $bookseller->address1,
105 bookselleraddress2 => $bookseller->address2,
106 bookselleraddress3 => $bookseller->address3,
107 bookselleraddress4 => $bookseller->address4,
108 booksellerphone =>$bookseller->phone,
109 booksellernotes => $bookseller->notes,
110 basketcount => $bookseller->baskets->count,
111 subscriptioncount => $bookseller->subscriptions->count,
112 active => $bookseller->active,
114 scriptname => "/cgi-bin/koha/acqui/uncertainprice.pl");
115 $template->{'VARS'}->{'contacts'} = $bookseller->contacts;
116 output_html_with_http_headers $input, $cookie, $template->output;