Fixing errors in Portuguese intranet .po file
[koha.git] / cataloguing / additem.pl
index d797c7e..5af5399 100755 (executable)
@@ -149,7 +149,7 @@ if ($op eq "additem") {
         my $items = &GetItemsByBiblioitemnumber($biblioitem->{biblioitemnumber});
 
         foreach my $item (@$items){
-            &DelItem($dbh,$biblionumber,$item->{itemnumber});
+            &DelItemCheck($dbh,$biblionumber,$item->{itemnumber});
         }
     }
     print $input->redirect("/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=$biblionumber");
@@ -198,8 +198,7 @@ my ($branchtagfield, $branchtagsubfield) = &GetMarcFromKohaField("items.homebran
 
 foreach my $field (@fields) {
     next if ($field->tag()<10);
-    my @subf = $field->subfields;
-    (defined @subf) or @subf = ();
+    my @subf = $field->subfields or (); # don't use ||, as that forces $field->subfelds to be interpreted in scalar context
     my %this_row;
 # loop through each subfield
     for my $i (0..$#subf) {
@@ -259,7 +258,7 @@ my $onlymine = C4::Context->preference('IndependantBranches') &&
                C4::Context->userenv                           && 
                C4::Context->userenv->{flags}!=1               && 
                C4::Context->userenv->{branch};
-my $branches = GetBranches($onlymine);  # build once ahead of time, instead of multiple times later.
+my $branches = GetBranchesLoop(undef,$onlymine);  # build once ahead of time, instead of multiple times later.
 
 foreach my $tag (sort keys %{$tagslib}) {
 # loop through each subfield
@@ -287,7 +286,7 @@ foreach my $tag (sort keys %{$tagslib}) {
     unless ($value) {
         $value = $tagslib->{$tag}->{$subfield}->{defaultvalue};
         # get today date & replace YYYY, MM, DD if provided in the default value
-        my ( $year, $month, $day ) = split ',', $today_iso;
+        my ( $year, $month, $day ) = split ',', $today_iso;     # FIXME: iso dates don't have commas!
         $value =~ s/YYYY/$year/g;
         $value =~ s/MM/$month/g;
         $value =~ s/DD/$day/g;
@@ -320,21 +319,28 @@ foreach my $tag (sort keys %{$tagslib}) {
       # builds list, depending on authorised value...
   
       if ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "branches" ) {
-          foreach my $thisbranch ( sort keys %$branches ) {
-              push @authorised_values, $thisbranch;
-              $authorised_lib{$thisbranch} = $branches->{$thisbranch}->{'branchname'};
+          foreach my $thisbranch (@$branches) {
+              push @authorised_values, $thisbranch->{value};
+              $authorised_lib{$thisbranch->{value}} = $thisbranch->{branchname};
+              $value = $thisbranch->{value} if $thisbranch->{selected};
           }
       }
       elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) {
           push @authorised_values, "" unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
           my $sth = $dbh->prepare("select itemtype,description from itemtypes order by description");
           $sth->execute;
-          my $itemtype;     # FIXME: double declaration of $itemtype
           while ( my ( $itemtype, $description ) = $sth->fetchrow_array ) {
               push @authorised_values, $itemtype;
               $authorised_lib{$itemtype} = $description;
           }
-          $value = $itemtype unless ($value);
+
+          unless ( $value ) {
+              my $itype_sth = $dbh->prepare("SELECT itemtype FROM biblioitems WHERE biblionumber = ?");
+              $itype_sth->execute( $biblionumber );
+              ( $value ) = $itype_sth->fetchrow_array;
+          }
+  
+          #---- class_sources
       }
       elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "cn_source" ) {
           push @authorised_values, "" unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
@@ -361,7 +367,7 @@ foreach my $tag (sort keys %{$tagslib}) {
               $authorised_lib{$value} = $lib;
           }
       }
-      $subfield_data{marc_value} =CGI::scrolling_list( # FIXME: factor out scrolling_list
+      $subfield_data{marc_value} =CGI::scrolling_list(      # FIXME: factor out scrolling_list
           -name     => "field_value",
           -values   => \@authorised_values,
           -default  => $value,