Bug 6458: Incorrect translation processing - masthead.inc
[koha.git] / acqui / uncertainprice.pl
blob792b8af4dd6d170c8857525f6f303ddd28b9eddf
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 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
14 # version.
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.
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::Input;
50 use C4::Auth;
51 use C4::Output;
52 use CGI;
54 use C4::Bookseller qw/GetBookSellerFromId/;
55 use C4::Acquisition qw/GetPendingOrders GetOrder ModOrder/;
56 use C4::Biblio qw/GetBiblioData/;
58 my $input=new CGI;
60 my ($template, $loggedinuser, $cookie)
61 = get_template_and_user({template_name => "acqui/uncertainprice.tmpl",
62 query => $input,
63 type => "intranet",
64 authnotrequired => 0,
65 flagsrequired => { acquisition => 'order_manage' },
66 debug => 1,
67 });
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 = &GetPendingOrders($booksellerid,0,$owner,$basketno);
77 my @orders;
79 foreach my $order (@{$pendingorders}) {
80 if ( $order->{'uncertainprice'} ) {
81 my $bibdata = &GetBiblioData($order->{'biblionumber'});
82 $order->{'bibisbn'} = $bibdata->{'isbn'};
83 $order->{'bibpublishercode'} = $bibdata->{'publishercode'};
84 $order->{'bibpublicationyear'} = $bibdata->{'publicationyear'};
85 $order->{'bibtitle'} = $bibdata->{'title'};
86 $order->{'bibauthor'} = $bibdata->{'author'};
87 $order->{'surname'} = $order->{'surname'};
88 $order->{'firstname'} = $order->{'firstname'};
89 my $order_as_from_db=GetOrder($order->{ordernumber});
90 $order->{'quantity'} = $order_as_from_db->{'quantity'};
91 $order->{'listprice'} = $order_as_from_db->{'listprice'};
92 push(@orders, $order);
95 if ( $op eq 'validate' ) {
96 $template->param( validate => 1);
97 my $count = scalar(@orders);
98 for (my $i=0; $i < $count; $i++) {
99 my $order = pop(@orders);
100 my $ordernumber = $order->{ordernumber};
101 my $order_as_from_db=GetOrder($order->{ordernumber});
102 $order->{'listprice'} = $input->param('price'.$ordernumber);
103 $order->{'ecost'}= $input->param('price'.$ordernumber) - (($input->param('price'.$ordernumber) /100) * $bookseller->{'discount'});
104 $order->{'rrp'} = $input->param('price'.$ordernumber);
105 $order->{'quantity'}=$input->param('qty'.$ordernumber);
106 $order->{'uncertainprice'}=$input->param('uncertainprice'.$ordernumber);
107 ModOrder($order);
111 $template->param( uncertainpriceorders => \@orders,
112 booksellername => "".$bookseller->{'name'},
113 booksellerid => $bookseller->{'id'},
114 booksellerpostal =>$bookseller->{'postal'},
115 bookselleraddress1 => $bookseller->{'address1'},
116 bookselleraddress2 => $bookseller->{'address2'},
117 bookselleraddress3 => $bookseller->{'address3'},
118 bookselleraddress4 => $bookseller->{'address4'},
119 booksellerphone =>$bookseller->{'phone'},
120 booksellerfax => $bookseller->{'fax'},
121 booksellerurl => $bookseller->{'url'},
122 booksellercontact => $bookseller->{'contact'},
123 booksellercontpos => $bookseller->{'contpos'},
124 booksellercontphone => $bookseller->{'contphone'},
125 booksellercontaltphone => $bookseller->{'contaltphone'},
126 booksellercontfax => $bookseller->{'contfax'},
127 booksellercontemail => $bookseller->{'contemail'},
128 booksellercontnotes => $bookseller->{'contnotes'},
129 booksellernotes => $bookseller->{'notes'},
130 owner => $owner,
131 scriptname => "/cgi-bin/koha/acqui/uncertainprice.pl");
132 output_html_with_http_headers $input, $cookie, $template->output;