Bug 12495 - Include streetnumber in hold alert address
[koha_fer] / acqui / addorderiso2709.pl
index 54c4414..91c0a4c 100755 (executable)
@@ -174,7 +174,7 @@ if ($op eq ""){
         my $c_quantity = shift( @quantities ) || GetMarcQuantity($marcrecord, C4::Context->preference('marcflavour') ) || 1;
         my $c_budget_id = shift( @budgets_id ) || $input->param('all_budget_id') || $budget_id;
         my $c_discount = shift ( @discount);
-        $c_discount = $c_discount / 100 if $c_discount > 100;
+        $c_discount = $c_discount / 100 if $c_discount > 1;
         my $c_sort1 = shift( @sort1 ) || $input->param('all_sort1') || '';
         my $c_sort2 = shift( @sort2 ) || $input->param('all_sort2') || '';
 
@@ -195,6 +195,7 @@ if ($op eq ""){
                 }
             }
             ( $biblionumber, $bibitemnum ) = AddBiblio( $marcrecord, $cgiparams->{'frameworkcode'} || '' );
+            SetImportRecordStatus( $biblio->{'import_record_id'}, 'imported' );
             # 2nd add authorities if applicable
             if (C4::Context->preference("BiblioAddsAuthorities")){
                 my $headings_linked =BiblioAutoLink($marcrecord, $cgiparams->{'frameworkcode'});
@@ -279,6 +280,8 @@ if ($op eq ""){
                 my ( $biblionumber, $bibitemnum, $itemnumber ) = AddItemFromMarc( $record, $biblionumber );
                 NewOrderItem( $itemnumber, $ordernumber );
             }
+        } else {
+            SetImportRecordStatus( $biblio->{'import_record_id'}, 'imported' );
         }
     }
     # go to basket page
@@ -306,41 +309,15 @@ foreach my $r ( @{$budgets_hierarchy} ) {
         b_txt => $r->{budget_name},
         b_sort1_authcat => $r->{'sort1_authcat'},
         b_sort2_authcat => $r->{'sort2_authcat'},
+        b_active => $r->{budget_period_active},
         b_sel => ( $r->{budget_id} == $budget_id ) ? 1 : 0,
       };
 }
-$template->param( budget_loop    => $budget_loop,);
 
-my $CGIsort1;
-if ($budget) {    # its a mod ..
-    if ( defined $budget->{'sort1_authcat'} ) {    # with custom  Asort* planning values
-        $CGIsort1 = GetAuthvalueDropbox(  $budget->{'sort1_authcat'}, $data->{'sort1'} );
-    }
-} elsif ( scalar(@$budgets) ) {
-} elsif ( scalar(@$budgets_hierarchy) ) {
-    $CGIsort1 = GetAuthvalueDropbox( @$budgets_hierarchy[0]->{'sort1_authcat'}, '' );
-}
-# if CGIsort is successfully fetched, the use it
-# else - failback to plain input-field
-if ($CGIsort1) {
-    $template->param( CGIsort1 => $CGIsort1 );
-} else {
-    $template->param( sort1 => $data->{'sort1'} );
-}
+@{$budget_loop} =
+  sort { uc( $a->{b_txt}) cmp uc( $b->{b_txt}) } @{$budget_loop};
 
-my $CGIsort2;
-if ($budget) {
-    if ( defined $budget->{'sort2_authcat'} ) {
-        $CGIsort2 = GetAuthvalueDropbox(  $budget->{'sort2_authcat'}, $data->{'sort2'} );
-    }
-} elsif ( scalar(@$budgets_hierarchy) ) {
-    $CGIsort2 = GetAuthvalueDropbox( @$budgets_hierarchy[0]->{sort2_authcat}, '' );
-}
-if ($CGIsort2) {
-    $template->param( CGIsort2 => $CGIsort2 );
-} else {
-    $template->param( sort2 => $data->{'sort2'} );
-}
+$template->param( budget_loop    => $budget_loop,);
 
 output_html_with_http_headers $input, $cookie, $template->output;
 
@@ -353,11 +330,11 @@ sub import_batches_list {
     foreach my $batch (@$batches) {
         if ( $batch->{'import_status'} =~ /^staged$|^reverted$/ ) {
             # check if there is at least 1 line still staged
-            my $stagedList=GetImportRecordsRange($batch->{'import_batch_id'}, undef, undef, $batch->{import_status});
+            my $stagedList=GetImportRecordsRange($batch->{'import_batch_id'}, undef, undef, $batch->{import_status}, { order_by_direction => 'ASC' });
             if (scalar @$stagedList) {
                 push @list, {
                         import_batch_id => $batch->{'import_batch_id'},
-                        num_biblios => $batch->{'num_biblios'},
+                        num_records => $batch->{'num_records'},
                         num_items => $batch->{'num_items'},
                         staged_date => $batch->{'upload_timestamp'},
                         import_status => $batch->{'import_status'},
@@ -427,12 +404,12 @@ sub import_biblios_list {
 
         push @list, \%cellrecord;
     }
-    my $num_biblios = $batch->{'num_biblios'};
+    my $num_records = $batch->{'num_records'};
     my $overlay_action = GetImportBatchOverlayAction($import_batch_id);
     my $nomatch_action = GetImportBatchNoMatchAction($import_batch_id);
     my $item_action = GetImportBatchItemAction($import_batch_id);
     $template->param(biblio_list => \@list,
-                        num_results => $num_biblios,
+                        num_results => $num_records,
                         import_batch_id => $import_batch_id,
                         "overlay_action_${overlay_action}" => 1,
                         overlay_action => $overlay_action,
@@ -451,9 +428,9 @@ sub batch_info {
                                           comments => $batch->{'comments'},
                                           import_status => $batch->{'import_status'},
                                           upload_timestamp => $batch->{'upload_timestamp'},
-                                          num_biblios => $batch->{'num_biblios'},
-                                          num_items => $batch->{'num_biblios'});
-    if ($batch->{'num_biblios'} > 0) {
+                                          num_records => $batch->{'num_records'},
+                                          num_items => $batch->{'num_items'});
+    if ($batch->{'num_records'} > 0) {
         if ($batch->{'import_status'} eq 'staged' or $batch->{'import_status'} eq 'reverted') {
             $template->param(can_commit => 1);
         }