Bug 19166: (follow-up) Add ADJ_REASON auhtorised value category and minor fixes
[koha.git] / acqui / basketgroup.pl
index 9e50484..78514ba 100755 (executable)
@@ -43,8 +43,7 @@ The bookseller who we want to display the baskets (and basketgroups) of.
 
 =cut
 
-use strict;
-use warnings;
+use Modern::Perl;
 use Carp;
 
 use C4::Auth;
@@ -52,11 +51,12 @@ use C4::Output;
 use CGI qw ( -utf8 );
 
 use C4::Acquisition qw/CloseBasketgroup ReOpenBasketgroup GetOrders GetBasketsByBasketgroup GetBasketsByBookseller ModBasketgroup NewBasketgroup DelBasketgroup GetBasketgroups ModBasket GetBasketgroup GetBasket GetBasketGroupAsCSV/;
-use C4::Members qw/GetMember/;
 use Koha::EDI qw/create_edi_order get_edifact_ean/;
 
+use Koha::Biblioitems;
 use Koha::Acquisition::Booksellers;
 use Koha::ItemTypes;
+use Koha::Patrons;
 
 our $input=new CGI;
 
@@ -82,7 +82,6 @@ sub BasketTotal {
             $total = $total + ( $order->{ecost_tax_excluded} * $order->{quantity} );
         }
     }
-    $total .= " " . ($bookseller->invoiceprice // 0);
     return $total;
 }
 
@@ -174,7 +173,7 @@ sub printbasketgrouppdf{
             $ord->{total_tax_included} = $ord->{ecost_tax_included} * $ord->{quantity};
             $ord->{total_tax_excluded} = $ord->{ecost_tax_excluded} * $ord->{quantity};
 
-            my $bib = GetBiblioData($ord->{biblionumber});
+            my $biblioitem = Koha::Biblioitems->search({ biblionumber => $ord->{biblionumber} })->next;
 
             #FIXME DELETE ME
             # 0      1        2        3         4            5         6       7      8        9
@@ -183,7 +182,7 @@ sub printbasketgrouppdf{
             # Editor Number
             my $en;
             my $edition;
-            my $ord->{marcxml} = C4::Biblio::GetXmlBiblio( $ord->{biblionumber} );
+            $ord->{marcxml} = C4::Biblio::GetXmlBiblio( $ord->{biblionumber} );
             my $marcrecord=eval{MARC::Record::new_from_xml( $ord->{marcxml},'UTF-8' )};
             if ($marcrecord){
                 if ( C4::Context->preference("marcflavour") eq 'UNIMARC' ) {
@@ -195,7 +194,11 @@ sub printbasketgrouppdf{
                 }
             }
 
-            $ord->{itemtype} = ( $ord->{itemtype} and $bib->{itemtype} ) ? Koha::ItemTypes->find( $bib->{itemtype} )->description : undef;
+            my $itemtype = ( $ord->{itemtype} and $biblioitem->itemtype )
+                ? Koha::ItemTypes->find( $biblioitem->itemtype )
+                : undef;
+            $ord->{itemtype} = $itemtype ? $itemtype->description : undef;
+
             $ord->{en} = $en ? $en : undef;
             $ord->{edition} = $edition ? $edition : undef;
 
@@ -273,9 +276,9 @@ if ( $op eq "add" ) {
         $template->param( closedbg => 0);
     }
     # determine default billing and delivery places depending on librarian homebranch and existing basketgroup data
-    my $borrower = GetMember( ( 'borrowernumber' => $loggedinuser ) );
-    $billingplace  = $billingplace  || $borrower->{'branchcode'};
-    $deliveryplace = $deliveryplace || $borrower->{'branchcode'};
+    my $patron = Koha::Patrons->find( $loggedinuser ); # FIXME Not needed if billingplace and deliveryplace are set
+    $billingplace  = $billingplace  || $patron->branchcode;
+    $deliveryplace = $deliveryplace || $patron->branchcode;
 
     $template->param( billingplace => $billingplace );
     $template->param( deliveryplace => $deliveryplace );