Bug 32829: Fix cataloguing/value_builder/unimarc_field_115b.pl
[srvgit] / cataloguing / moveitem.pl
index 49641f4..ec59c25 100755 (executable)
 use Modern::Perl;
 
 use CGI qw ( -utf8 );
-use C4::Auth;
-use C4::Output;
-use C4::Biblio;
-use C4::Items;
-use C4::Context;
-use C4::Koha;
-use C4::ClassSource;
-use C4::Acquisition qw/GetOrderFromItemnumber ModOrder GetOrder/;
+use C4::Auth qw( get_template_and_user );
+use C4::Output qw( output_html_with_http_headers );
 
 use Koha::Biblios;
-
-use Date::Calc qw(Today);
-
-use MARC::File::XML;
-
 use Koha::Items;
 
 my $query = CGI->new;
@@ -52,16 +41,12 @@ my ($template, $loggedinuser, $cookie) = get_template_and_user(
         template_name   => "cataloguing/moveitem.tt",
         query           => $query,
         type            => "intranet",
-        authnotrequired => 0,
         flagsrequired   => { editcatalogue => 'edit_items' },
-        debug           => 1,
     }
 );
 
-
-
 my $biblio = Koha::Biblios->find( $biblionumber );
-$template->param(bibliotitle => $biblio->title);
+$template->param(biblio => $biblio);
 $template->param(biblionumber => $biblionumber);
 
 # If we already have the barcode of the item to move and the biblionumber to move the item to
@@ -74,10 +59,14 @@ if ( $barcode && $biblionumber ) {
 
         $itemnumber = $item->itemnumber;
         my $frombiblionumber = $item->biblionumber;
+        my $to_biblio = Koha::Biblios->find($biblionumber);
 
-        my $moveresult = MoveItemFromBiblio( $itemnumber, $frombiblionumber, $biblionumber );
+        my $moveresult = $item->move_to_biblio($to_biblio);
         if ($moveresult) {
-            $template->param( success => 1 );
+            $template->param(
+                success => 1,
+                from_biblio => Koha::Biblios->find($frombiblionumber),
+            );
         }
         else {
             $template->param(
@@ -105,5 +94,4 @@ else {
     if ( !$biblionumber ) { $template->param( missingbiblionumber => 1 ); }
 }
 
-
 output_html_with_http_headers $query, $cookie, $template->output;