Bug 2400 [10/18]: fixing pod syntax in C4/ImportBatch.pm
[koha_fer] / cataloguing / additem.pl
index b806a0a..f8780c2 100755 (executable)
@@ -96,8 +96,10 @@ if ($op eq "additem") {
     my @indicator = $input->param('indicator');
     my $xml = TransformHtmlToXml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag, 'ITEM');
         my $record=MARC::Record::new_from_xml($xml, 'UTF-8');
-    # if autoBarcode is ON, calculate barcode...
-    if (C4::Context->preference('autoBarcode')) {
+    # if autoBarcode is set to 'incremental', calculate barcode...
+       # NOTE: This code is subject to change in 3.2 with the implemenation of ajax based autobarcode code
+       # NOTE: 'incremental' is the ONLY autoBarcode option available to those not using javascript
+    if (C4::Context->preference('autoBarcode') eq 'incremental') {
         my ($tagfield,$tagsubfield) = &GetMarcFromKohaField("items.barcode",$frameworkcode);
         unless ($record->field($tagfield)->subfield($tagsubfield)) {
             my $sth_barcode = $dbh->prepare("select max(abs(barcode)) from items");
@@ -133,7 +135,7 @@ if ($op eq "additem") {
 } elsif ($op eq "delitem") {
 #-------------------------------------------------------------------------------
     # check that there is no issue on this item before deletion.
-    my $sth=$dbh->prepare("select * from issues i where i.returndate is null and i.itemnumber=?");
+    my $sth=$dbh->prepare("select * from issues i where i.itemnumber=?");
     $sth->execute($itemnumber);
     my $onloan=$sth->fetchrow;
        $sth->finish();
@@ -142,7 +144,7 @@ if ($op eq "additem") {
                $nextop="additem";
     } else {
                # check it doesnt have a waiting reserve
-               $sth=$dbh->prepare("SELECT * FROM reserves WHERE found = 'w' AND cancellationdate IS NULL AND itemnumber = ?");
+               $sth=$dbh->prepare("SELECT * FROM reserves WHERE found = 'W' AND itemnumber = ?");
                $sth->execute($itemnumber);
                my $reserve=$sth->fetchrow;
                if ($reserve){
@@ -207,9 +209,12 @@ foreach my $field (@fields) {
                 && $subf[$i][0] ne $itemtagsubfield));
 
         $witness{$subf[$i][0]} = $tagslib->{$field->tag()}->{$subf[$i][0]}->{lib} if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab}  eq 10);
+               if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab}  eq 10) {
+               $this_row{$subf[$i][0]}=GetAuthorisedValueDesc( $field->tag(),
+                        $subf[$i][0], $subf[$i][1], '', $tagslib) 
+                                               || $subf[$i][1];
+               }
 
-        $this_row{$subf[$i][0]} =$subf[$i][1] if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab}  eq 10);
-        
         if (($field->tag eq $branchtagfield) && ($subf[$i][$0] eq $branchtagsubfield) && C4::Context->preference("IndependantBranches")) {
             #verifying rights
             my $userenv = C4::Context->userenv();
@@ -295,7 +300,7 @@ foreach my $tag (sort keys %{$tagslib}) {
         $value =~ s/MM/$month/g;
         $value =~ s/DD/$day/g;
     }
-    $subfield_data{visibility} = "display:none;" if (($tagslib->{$tag}->{$subfield}->{hidden} % 2 == 1));
+    $subfield_data{visibility} = "display:none;" if (($tagslib->{$tag}->{$subfield}->{hidden} > 4) || ($tagslib->{$tag}->{$subfield}->{hidden} < -4));
     #testing branch value if IndependantBranches.
     my $test = (C4::Context->preference("IndependantBranches")) &&
               ($tag eq $branchtagfield) && ($subfield eq $branchtagsubfield) &&
@@ -368,10 +373,9 @@ foreach my $tag (sort keys %{$tagslib}) {
                           ($class_source eq $default_source);
               push @authorised_values, $class_source;
               $authorised_lib{$class_source} = $class_sources->{$class_source}->{'description'};
-              $value = $class_source unless ($value);
-              $value = $default_source unless ($value);
           }
-  
+                 $value = $default_source unless ($value);
+
           #---- "true" authorised value
       }
       else {