X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=acqui%2Ftransferorder.pl;h=6eeafdb12ecb69e6e58c56273b2511f1507ab7f1;hb=0bd1f30c8c4f151eaed1a6e1e56a8c78d28c0b4b;hp=27c450955a486faf258fd74e248b8dc655be86e8;hpb=12f62ba1dbefda7ccdaafdc69c168e6658c84468;p=koha.git diff --git a/acqui/transferorder.pl b/acqui/transferorder.pl index 27c450955a..6eeafdb12e 100755 --- a/acqui/transferorder.pl +++ b/acqui/transferorder.pl @@ -6,39 +6,34 @@ # # 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., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see use Modern::Perl; -use CGI; +use CGI qw ( -utf8 ); use C4::Auth; use C4::Output; use C4::Context; use C4::Acquisition; -use C4::Bookseller qw/GetBookSellerFromId GetBookSeller/; -use C4::Members; -use C4::Dates qw/format_date_in_iso/; -use Date::Calc qw/Today/; +use Koha::Acquisition::Booksellers; my $input = new CGI; my ( $template, $loggedinuser, $cookie ) = get_template_and_user( - { template_name => "acqui/transferorder.tmpl", + { template_name => "acqui/transferorder.tt", query => $input, type => "intranet", - authnotrequired => 1, flagsrequired => { acquisition => 'order_manage' }, - debug => 1, } ); @@ -52,48 +47,49 @@ my $op = $input->param('op'); my $query = $input->param('query'); my $order = GetOrder($ordernumber); +my $basketfromname = ''; if($order) { my $basket = GetBasket($order->{basketno}); + $basketfromname = $basket->{basketname}; $bookselleridfrom = $basket->{booksellerid} if $basket; } -my $booksellerfrom = GetBookSellerFromId($bookselleridfrom); +my $booksellerfrom = Koha::Acquisition::Booksellers->find( $bookselleridfrom ); my $booksellerfromname; if($booksellerfrom){ - $booksellerfromname = $booksellerfrom->{name}; + $booksellerfromname = $booksellerfrom->name; } -my $booksellerto = GetBookSellerFromId($bookselleridto); +my $booksellerto = Koha::Acquisition::Booksellers->find( $bookselleridto ); my $booksellertoname; if($booksellerto){ - $booksellertoname = $booksellerto->{name}; + $booksellertoname = $booksellerto->name; } + if( $basketno && $ordernumber) { # Transfer order and exit my $order = GetOrder( $ordernumber ); my $basket = GetBasket($order->{basketno}); - my $booksellerfrom = GetBookSellerFromId($basket->{booksellerid}); - my $bookselleridfrom = $booksellerfrom->{id}; + my $booksellerfrom = Koha::Acquisition::Booksellers->find( $basket->{booksellerid} ); + my $bookselleridfrom = $booksellerfrom->id; TransferOrder($ordernumber, $basketno); - my $referrer = $input->param('referrer'); - print $input->redirect($referrer); - exit; + $template->param(transferred => 1) } elsif ( $bookselleridto && $ordernumber) { # Show open baskets for this bookseller my $order = GetOrder( $ordernumber ); my $basketfrom = GetBasket( $order->{basketno} ); - my $booksellerfrom = GetBookSellerFromId( $basketfrom->{booksellerid} ); - $booksellerfromname = $booksellerfrom->{name}; + my $booksellerfrom = Koha::Acquisition::Booksellers->find( $basketfrom->{booksellerid} ); + $booksellerfromname = $booksellerfrom->name; my $baskets = GetBasketsByBookseller( $bookselleridto ); my $basketscount = scalar @$baskets; my @basketsloop = (); for( my $i = 0 ; $i < $basketscount ; $i++ ){ my %line; %line = %{ $baskets->[$i] }; - my $createdby = GetMember(borrowernumber => $line{authorisedby}); - $line{createdby} = "$createdby->{surname}, $createdby->{firstname}"; + my $createdby = Koha::Patrons->find( $line{authorisedby} ); + $line{createdby} = $createdby ? $createdby->surname . ', ' . $createdby->firstname : ''; push @basketsloop, \%line unless $line{closedate}; } $template->param( @@ -103,7 +99,10 @@ if( $basketno && $ordernumber) { ); } elsif ( $bookselleridfrom && !defined $ordernumber) { # Show pending orders - my $pendingorders = GetPendingOrders($bookselleridfrom); + my $pendingorders = SearchOrders({ + booksellerid => $bookselleridfrom, + pending => 1, + }); my $orderscount = scalar @$pendingorders; my @ordersloop = (); for( my $i = 0 ; $i < $orderscount ; $i++ ){ @@ -118,16 +117,14 @@ if( $basketno && $ordernumber) { # Search for booksellers to transfer from/to $op = '' unless $op; if( $op eq "do_search" ) { - my @booksellers = GetBookSeller($query); + my @booksellers = Koha::Acquisition::Booksellers->search( + { name => { -like => "%$query%" } }, + { order_by => { -asc => 'name' } } ); $template->param( query => $query, do_search => 1, booksellersloop => \@booksellers, ); - } else { - $template->param( - search_form => 1, - ); } } @@ -138,7 +135,7 @@ $template->param( booksellertoname => $booksellertoname, ordernumber => $ordernumber, basketno => $basketno, - referrer => $input->param('referrer') + basketfromname => $basketfromname, ); output_html_with_http_headers $input, $cookie, $template->output;