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 under the
12 # terms of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
16 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License along
21 # with Koha; if not, write to the Free Software Foundation, Inc.,
22 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
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.
54 use C4
::Bookseller qw
/GetBookSellerFromId/;
55 use C4
::Acquisition qw
/SearchOrders GetOrder ModOrder/;
56 use C4
::Biblio qw
/GetBiblioData/;
60 my ($template, $loggedinuser, $cookie)
61 = get_template_and_user
({template_name
=> "acqui/uncertainprice.tt",
65 flagsrequired
=> { acquisition
=> 'order_manage' },
69 my $booksellerid = $input->param('booksellerid');
70 my $basketno = $input->param('basketno');
71 my $op = $input->param('op');
72 my $owner = $input->param('owner') || 0 ; # flag to see only "my" orders, or everyone orders
73 my $bookseller = &GetBookSellerFromId
($booksellerid);
75 #show all orders that have uncertain price for the bookseller
76 my $pendingorders = SearchOrders
({
77 booksellerid
=> $booksellerid,
79 basketno
=> $basketno,
84 foreach my $order (@
{$pendingorders}) {
85 if ( $order->{'uncertainprice'} ) {
86 my $bibdata = &GetBiblioData
($order->{'biblionumber'});
87 $order->{'bibisbn'} = $bibdata->{'isbn'};
88 $order->{'bibpublishercode'} = $bibdata->{'publishercode'};
89 $order->{'bibpublicationyear'} = $bibdata->{'publicationyear'};
90 $order->{'bibtitle'} = $bibdata->{'title'};
91 $order->{'bibauthor'} = $bibdata->{'author'};
92 $order->{'surname'} = $order->{'surname'};
93 $order->{'firstname'} = $order->{'firstname'};
94 my $order_as_from_db=GetOrder
($order->{ordernumber
});
95 $order->{'quantity'} = $order_as_from_db->{'quantity'};
96 $order->{'listprice'} = $order_as_from_db->{'listprice'};
97 push(@orders, $order);
100 if ( $op eq 'validate' ) {
101 $template->param( validate
=> 1);
102 my $count = scalar(@orders);
103 for (my $i=0; $i < $count; $i++) {
104 my $order = pop(@orders);
105 my $ordernumber = $order->{ordernumber
};
106 my $order_as_from_db=GetOrder
($order->{ordernumber
});
107 $order->{'listprice'} = $input->param('price'.$ordernumber);
108 $order->{'ecost'}= $input->param('price'.$ordernumber) - (($input->param('price'.$ordernumber) /100) * $bookseller->{'discount'});
109 $order->{'rrp'} = $input->param('price'.$ordernumber);
110 $order->{'quantity'}=$input->param('qty'.$ordernumber);
111 $order->{'uncertainprice'}=$input->param('uncertainprice'.$ordernumber);
116 $template->param( uncertainpriceorders
=> \
@orders,
117 booksellername
=> "".$bookseller->{'name'},
118 booksellerid
=> $bookseller->{'id'},
119 booksellerpostal
=>$bookseller->{'postal'},
120 bookselleraddress1
=> $bookseller->{'address1'},
121 bookselleraddress2
=> $bookseller->{'address2'},
122 bookselleraddress3
=> $bookseller->{'address3'},
123 bookselleraddress4
=> $bookseller->{'address4'},
124 booksellerphone
=>$bookseller->{'phone'},
125 booksellerfax
=> $bookseller->{'fax'},
126 booksellerurl
=> $bookseller->{'url'},
127 booksellercontact
=> $bookseller->{'contact'},
128 booksellercontpos
=> $bookseller->{'contpos'},
129 booksellercontphone
=> $bookseller->{'contphone'},
130 booksellercontaltphone
=> $bookseller->{'contaltphone'},
131 booksellercontfax
=> $bookseller->{'contfax'},
132 booksellercontemail
=> $bookseller->{'contemail'},
133 booksellercontnotes
=> $bookseller->{'contnotes'},
134 booksellernotes
=> $bookseller->{'notes'},
135 basketcount
=> $bookseller->{'basketcount'},
136 subscriptioncount
=> $bookseller->{'subscriptioncount'},
138 scriptname
=> "/cgi-bin/koha/acqui/uncertainprice.pl");
139 output_html_with_http_headers
$input, $cookie, $template->output;