X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=acqui%2Funcertainprice.pl;h=4a559e3691fad7ed4f07bd657f70c19d1f68eb97;hb=702ca8e9a341ea8350bb69596be5ce8c29596b45;hp=f50a1b74c22f2845b2ca11f9e6e7543e0c173055;hpb=8ad2c7d7acc3cb0033426bd78928214a22ad9dd1;p=koha.git diff --git a/acqui/uncertainprice.pl b/acqui/uncertainprice.pl index f50a1b74c2..4a559e3691 100755 --- a/acqui/uncertainprice.pl +++ b/acqui/uncertainprice.pl @@ -8,18 +8,18 @@ # # This file is part of Koha. # -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. # -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . =head1 NAME @@ -43,22 +43,22 @@ The bookseller who we want to display the orders of. =cut -use strict; -use warnings; +use Modern::Perl; -use C4::Input; use C4::Auth; use C4::Output; -use CGI; +use CGI qw ( -utf8 ); -use C4::Bookseller qw/GetBookSellerFromId/; -use C4::Acquisition qw/GetPendingOrders GetOrder ModOrder/; +use C4::Acquisition qw/SearchOrders GetOrder ModOrder/; use C4::Biblio qw/GetBiblioData/; +use Koha::Acquisition::Booksellers; +use Koha::Acquisition::Baskets; + my $input=new CGI; my ($template, $loggedinuser, $cookie) - = get_template_and_user({template_name => "acqui/uncertainprice.tmpl", + = get_template_and_user({template_name => "acqui/uncertainprice.tt", query => $input, type => "intranet", authnotrequired => 0, @@ -70,28 +70,19 @@ my $booksellerid = $input->param('booksellerid'); my $basketno = $input->param('basketno'); my $op = $input->param('op'); my $owner = $input->param('owner') || 0 ; # flag to see only "my" orders, or everyone orders -my $bookseller = &GetBookSellerFromId($booksellerid); +my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid ); + +$template->param( basket => scalar Koha::Acquisition::Baskets->find($basketno) ); #show all orders that have uncertain price for the bookseller -my $pendingorders = &GetPendingOrders($booksellerid,0,$owner,$basketno); -my @orders; - -foreach my $order (@{$pendingorders}) { - if ( $order->{'uncertainprice'} ) { - my $bibdata = &GetBiblioData($order->{'biblionumber'}); - $order->{'bibisbn'} = $bibdata->{'isbn'}; - $order->{'bibpublishercode'} = $bibdata->{'publishercode'}; - $order->{'bibpublicationyear'} = $bibdata->{'publicationyear'}; - $order->{'bibtitle'} = $bibdata->{'title'}; - $order->{'bibauthor'} = $bibdata->{'author'}; - $order->{'surname'} = $order->{'surname'}; - $order->{'firstname'} = $order->{'firstname'}; - my $order_as_from_db=GetOrder($order->{ordernumber}); - $order->{'quantity'} = $order_as_from_db->{'quantity'}; - $order->{'listprice'} = $order_as_from_db->{'listprice'}; - push(@orders, $order); - } -} +my $pendingorders = SearchOrders({ + booksellerid => $booksellerid, + owner => $owner, + basketno => $basketno, + pending => 1, +}); +my @orders = grep { $_->{'uncertainprice'} } @$pendingorders; + if ( $op eq 'validate' ) { $template->param( validate => 1); my $count = scalar(@orders); @@ -100,7 +91,7 @@ if ( $op eq 'validate' ) { my $ordernumber = $order->{ordernumber}; my $order_as_from_db=GetOrder($order->{ordernumber}); $order->{'listprice'} = $input->param('price'.$ordernumber); - $order->{'ecost'}= $input->param('price'.$ordernumber) - (($input->param('price'.$ordernumber) /100) * $bookseller->{'discount'}); + $order->{'ecost'}= $input->param('price'.$ordernumber) - (($input->param('price'.$ordernumber) /100) * $bookseller->discount); $order->{'rrp'} = $input->param('price'.$ordernumber); $order->{'quantity'}=$input->param('qty'.$ordernumber); $order->{'uncertainprice'}=$input->param('uncertainprice'.$ordernumber); @@ -109,24 +100,21 @@ if ( $op eq 'validate' ) { } $template->param( uncertainpriceorders => \@orders, - booksellername => "".$bookseller->{'name'}, - booksellerid => $bookseller->{'id'}, - booksellerpostal =>$bookseller->{'postal'}, - bookselleraddress1 => $bookseller->{'address1'}, - bookselleraddress2 => $bookseller->{'address2'}, - bookselleraddress3 => $bookseller->{'address3'}, - bookselleraddress4 => $bookseller->{'address4'}, - booksellerphone =>$bookseller->{'phone'}, - booksellerfax => $bookseller->{'fax'}, - booksellerurl => $bookseller->{'url'}, - booksellercontact => $bookseller->{'contact'}, - booksellercontpos => $bookseller->{'contpos'}, - booksellercontphone => $bookseller->{'contphone'}, - booksellercontaltphone => $bookseller->{'contaltphone'}, - booksellercontfax => $bookseller->{'contfax'}, - booksellercontemail => $bookseller->{'contemail'}, - booksellercontnotes => $bookseller->{'contnotes'}, - booksellernotes => $bookseller->{'notes'}, + booksellername => "".$bookseller->name, + booksellerid => $bookseller->id, + booksellerpostal =>$bookseller->postal, + bookselleraddress1 => $bookseller->address1, + bookselleraddress2 => $bookseller->address2, + bookselleraddress3 => $bookseller->address3, + bookselleraddress4 => $bookseller->address4, + booksellerphone =>$bookseller->phone, + booksellerfax => $bookseller->fax, + booksellerurl => $bookseller->url, + booksellernotes => $bookseller->notes, + basketcount => $bookseller->baskets->count, + subscriptioncount => $bookseller->subscriptions->count, + active => $bookseller->active, owner => $owner, scriptname => "/cgi-bin/koha/acqui/uncertainprice.pl"); +$template->{'VARS'}->{'contacts'} = $bookseller->contacts; output_html_with_http_headers $input, $cookie, $template->output;