#
# 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 <http://www.gnu.org/licenses>
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,
}
);
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);
# 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(
);
} 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++ ){
# 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,
- );
}
}
booksellertoname => $booksellertoname,
ordernumber => $ordernumber,
basketno => $basketno,
+ basketfromname => $basketfromname,
);
output_html_with_http_headers $input, $cookie, $template->output;