From e0d4e702c3b34b60e94f3ba8bdae99348c9fbea0 Mon Sep 17 00:00:00 2001 From: tipaul Date: Tue, 19 Nov 2002 12:32:22 +0000 Subject: [PATCH] road to 1.3.2 --- acqui.simple/addbiblio.pl | 250 ++++++--------- acqui.simple/additem.pl | 492 +++++++++++++----------------- admin/authorised_values.pl | 1 + admin/marc_subfields_structure.pl | 2 + 4 files changed, 298 insertions(+), 447 deletions(-) diff --git a/acqui.simple/addbiblio.pl b/acqui.simple/addbiblio.pl index ab3cc0d3fd..f0edcc0f07 100755 --- a/acqui.simple/addbiblio.pl +++ b/acqui.simple/addbiblio.pl @@ -2,13 +2,6 @@ # $Id$ -# -# TODO -# -# Add info on biblioitems and items already entered as you enter new ones -# - - # Copyright 2000-2002 Katipo Communications # # This file is part of Koha. @@ -36,6 +29,7 @@ use MARC::File::USMARC; sub find_value { my ($tagfield,$insubfield,$record) = @_; +# warn "$tagfield / $insubfield // "; my $result; my $indicator; foreach my $field ($record->field($tagfield)) { @@ -69,23 +63,26 @@ sub MARCfindbreeding { } my $input = new CGI; my $error = $input->param('error'); -my $oldbiblionumber=$input->param('bib'); # if bib exists, it's a modif, not a new biblio. +my $oldbiblionumber=$input->param('oldbiblionumber'); # if bib exists, it's a modif, not a new biblio. my $isbn = $input->param('isbn'); my $op = $input->param('op'); my $dbh = C4::Context->dbh; my $bibid; -if ($oldbiblionumber) {; - $bibid = &MARCfind_MARCbibid_from_oldbiblionumber($dbh,$oldbiblionumber) +if ($oldbiblionumber) { + $bibid = &MARCfind_MARCbibid_from_oldbiblionumber($dbh,$oldbiblionumber); }else { $bibid = $input->param('bibid'); } my $template; my $tagslib = &MARCgettagslib($dbh,1); - -my $record = MARCgetbiblio($dbh,$bibid) if ($oldbiblionumber); -my $record = MARCfindbreeding($dbh,$isbn) if ($isbn); - +my $record; +$record = MARCgetbiblio($dbh,$bibid) if ($bibid); +$record = MARCfindbreeding($dbh,$isbn) if ($isbn); +my $is_a_modif=0; +if ($bibid) { + $is_a_modif=1; +} #------------------------------------------------------------------------------------------------------------------------------ if ($op eq "addbiblio") { #------------------------------------------------------------------------------------------------------------------------------ @@ -101,135 +98,17 @@ if ($op eq "addbiblio") { $indicators{$ind_tag[$i]} = $indicator[$i]; } my $record = MARChtml2marc($dbh,\@tags,\@subfields,\@values,%indicators); -# warn "record ".$record->as_formatted(); # MARC::Record builded => now, record in DB - my ($bibid,$oldbibnum,$oldbibitemnum) = NEWnewbiblio($dbh,$record); - my $authorised_values_sth = $dbh->prepare("select authorised_value from authorised_values where category=?"); -# build item screen. There is no item for instance. - my @loop_data =(); - my $i=0; - foreach my $tag (keys %{$tagslib}) { - my $previous_tag = ''; - # loop through each subfield - foreach my $subfield (keys %{$tagslib->{$tag}}) { - next if ($subfield eq 'lib'); - next if ($subfield eq 'tab'); - next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "10"); - $i++; - my %subfield_data; - $subfield_data{tag}=$tag; - $subfield_data{subfield}=$subfield; - $subfield_data{marc_lib}=$tagslib->{$tag}->{$subfield}->{lib}; - $subfield_data{marc_mandatory}=$tagslib->{$tag}->{$subfield}->{mandatory}; - $subfield_data{marc_repeatable}=$tagslib->{$tag}->{$subfield}->{repeatable}; - if ($tagslib->{$tag}->{$subfield}->{authorised_value}) { - $authorised_values_sth->execute($tagslib->{$tag}->{$subfield}->{authorised_value}); - my @authorised_values; - push @authorised_values, "" unless ($subfield_data{mandatory}); - while ((my $value) = $authorised_values_sth->fetchrow_array) { - push @authorised_values, $value; - } - $subfield_data{marc_value}= CGI::scrolling_list(-name=>'field_value', - -values=> \@authorised_values, - -size=>1, - -multiple=>0, - ); - } elsif ($tagslib->{$tag}->{$subfield}->{thesaurus_category}) { - $subfield_data{marc_value}=" {$tag}->{$subfield}->{thesaurus_category}&index=$i',$i)\">..."; - } else { - $subfield_data{marc_value}=""; - } - push(@loop_data, \%subfield_data); - } + my $oldbibnum; + my $oldbibitemnum; + if ($is_a_modif) { + ($bibid,$oldbibnum,$oldbibitemnum) = NEWmodbiblio($dbh,$record,$bibid); + } else { + ($bibid,$oldbibnum,$oldbibitemnum) = NEWnewbiblio($dbh,$record); } - $template = gettemplate("acqui.simple/addbiblio2.tmpl"); - $template->param(bibid => $bibid, - item => \@loop_data); -#------------------------------------------------------------------------------------------------------------------------------ -} elsif ($op eq "additem") { -#------------------------------------------------------------------------------------------------------------------------------ - my @tags = $input->param('tag'); - my @subfields = $input->param('subfield'); - my @values = $input->param('field_value'); -# my @ind_tag = $input->param('ind_tag'); -# my @indicator = $input->param('indicator'); -# my %indicators; -# for (my $i=0;$i<=$#ind_tag;$i++) { -# $indicators{$ind_tag[$i]} = $indicator[$i]; -# } - my %indicators; - $indicators{995}=' '; - warn "REs : $tags[0] - $tags[1] - $subfields[0] - $subfields[1] - $values[0] - $values[1]"; - my $record = MARChtml2marc($dbh,\@tags,\@subfields,\@values,%indicators); - my ($bibid,$oldbibnum,$oldbibitemnum) = NEWnewitem($dbh,$record,$bibid); - # now, build existiing item list - my $temp = MARCgetbiblio($dbh,$bibid); - my @fields = $temp->fields(); - my %witness; #---- stores the list of subfields used at least once, with the "meaning" of the code - my @big_array; - foreach my $field (@fields) { - my @subf=$field->subfields; - my %this_row; - # loop through each subfield - for my $i (0..$#subf) { - next if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab} ne 10); - $witness{$subf[$i][0]} = $tagslib->{$field->tag()}->{$subf[$i][0]}->{lib}; - $this_row{$subf[$i][0]} =$subf[$i][1]; - } - if (%this_row) { - push(@big_array, \%this_row); - } - } - #fill big_row with missing datas - foreach my $subfield_code (keys(%witness)) { - for (my $i=0;$i<=$#big_array;$i++) { - $big_array[$i]{$subfield_code}=" " unless ($big_array[$i]{$subfield_code}); - } - } - # now, construct template ! - my @item_value_loop; - my @header_value_loop; - for (my $i=0;$i<=$#big_array; $i++) { - my $items_data; - foreach my $subfield_code (keys(%witness)) { - $items_data .="".$big_array[$i]{$subfield_code}.""; - } - my %row_data; - $row_data{item_value} = $items_data; - push(@item_value_loop,\%row_data); - } - foreach my $subfield_code (keys(%witness)) { - my %header_value; - $header_value{header_value} = $witness{$subfield_code}; - push(@header_value_loop, \%header_value); - } - -# next item form - my @loop_data =(); - my $i=0; - foreach my $tag (keys %{$tagslib}) { - my $previous_tag = ''; - # loop through each subfield - foreach my $subfield (keys %{$tagslib->{$tag}}) { - next if ($subfield eq 'lib'); - next if ($subfield eq 'tab'); - next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "10"); - my %subfield_data; - $subfield_data{tag}=$tag; - $subfield_data{subfield}=$subfield; - $subfield_data{marc_lib}=$tagslib->{$tag}->{$subfield}->{lib}; - $subfield_data{marc_mandatory}=$tagslib->{$tag}->{$subfield}->{mandatory}; - $subfield_data{marc_repeatable}=$tagslib->{$tag}->{$subfield}->{repeatable}; - $subfield_data{marc_value}=""; - push(@loop_data, \%subfield_data); - $i++ - } - } - $template = gettemplate("acqui.simple/addbiblio2.tmpl"); - $template->param(item_loop => \@item_value_loop, - item_header_loop => \@header_value_loop, - bibid => $bibid, - item => \@loop_data); +# now, redirect to additem page + print "Content-Type: text/html\n\n"; + exit; #------------------------------------------------------------------------------------------------------------------------------ } else { #------------------------------------------------------------------------------------------------------------------------------ @@ -243,12 +122,12 @@ if ($op eq "addbiblio") { for (my $tabloop = 0; $tabloop<=9;$tabloop++) { # my @fields = $record->fields(); my @loop_data =(); - foreach my $tag (keys %{$tagslib}) { + foreach my $tag (sort(keys (%{$tagslib}))) { my $previous_tag = ''; my @subfields_data; my $indicator; # loop through each subfield - foreach my $subfield (keys %{$tagslib->{$tag}}) { + foreach my $subfield (sort(keys %{$tagslib->{$tag}})) { next if ($subfield eq 'lib'); # skip lib and tabs, which are koha internal next if ($subfield eq 'tab'); next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop); @@ -263,11 +142,32 @@ if ($op eq "addbiblio") { my ($x,$value) = find_value($tag,$subfield,$record); $indicator = $x if $x; if ($tagslib->{$tag}->{$subfield}->{authorised_value}) { - $authorised_values_sth->execute($tagslib->{$tag}->{$subfield}->{authorised_value}); my @authorised_values; - push @authorised_values, "" unless ($subfield_data{mandatory}); - while ((my $value) = $authorised_values_sth->fetchrow_array) { - push @authorised_values, $value; + # builds list, depending on authorised value... + #---- branch + warn "==> $tagslib->{$tag}->{$subfield}->{mandatory} / ".$tagslib->{$tag}->{$subfield}->{'authorised_value'}; + if ($tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) { + my $sth=$dbh->prepare("select branchcode,branchname from branches"); + $sth->execute; + push @authorised_values, "" unless ($tagslib->{$tag}->{$subfield}->{mandatory}); + while (my ($branchcode,$branchname) = $sth->fetchrow_array) { + push @authorised_values, $branchcode; + } + #----- itemtypes + } elsif ($tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes") { + my $sth=$dbh->prepare("select itemtype,description from itemtypes"); + $sth->execute; + push @authorised_values, "" unless ($tagslib->{$tag}->{$subfield}->{mandatory}); + while (my ($itemtype,$description) = $sth->fetchrow_array) { + push @authorised_values, $itemtype; + } + #---- "true" authorised value + } else { + $authorised_values_sth->execute($tagslib->{$tag}->{$subfield}->{authorised_value}); + push @authorised_values, "" unless ($tagslib->{$tag}->{$subfield}->{mandatory}); + while ((my $value) = $authorised_values_sth->fetchrow_array) { + push @authorised_values, $value; + } } $subfield_data{marc_value}= CGI::scrolling_list(-name=>'field_value', -values=> \@authorised_values, @@ -276,32 +176,62 @@ if ($op eq "addbiblio") { -multiple=>0, ); } elsif ($tagslib->{$tag}->{$subfield}->{thesaurus_category}) { - $subfield_data{marc_value}=" {$tag}->{$subfield}->{thesaurus_category}&index=$i',$i)\">..."; - } elsif ($tagslib->{$tag}->{$subfield}->{value_builder}) { - $subfield_data{marc_value}=" {$tag}->{$subfield}->{value_builder}?index=$i',$i)\">..."; + $subfield_data{marc_value}=" {$tag}->{$subfield}->{thesaurus_category}&index=$i',$i)\">..."; #" + } elsif ($tagslib->{$tag}->{$subfield}->{'value_builder'}) { + my $plugin="../value_builder/".$tagslib->{$tag}->{$subfield}->{'value_builder'}; + require $plugin; + my $extended_param = plugin_parameters($dbh,$record,$tagslib,$i,$tabloop); + $subfield_data{marc_value}=" {$tag}->{$subfield}->{value_builder}&index=$i$extended_param',$i)\">..."; } else { - $subfield_data{marc_value}=""; + $subfield_data{marc_value}=""; } # if breeding is empty } else { + my ($x,$value); + ($x,$value) = find_value($tag,$subfield,$record) if ($record); if ($tagslib->{$tag}->{$subfield}->{authorised_value}) { - $authorised_values_sth->execute($tagslib->{$tag}->{$subfield}->{authorised_value}); my @authorised_values; - push @authorised_values, "" unless ($subfield_data{mandatory}); - while ((my $value) = $authorised_values_sth->fetchrow_array) { - push @authorised_values, $value; + # builds list, depending on authorised value... + #---- branch + warn "==> $tagslib->{$tag}->{$subfield}->{mandatory} / ".$tagslib->{$tag}->{$subfield}->{'authorised_value'}; + if ($tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) { + my $sth=$dbh->prepare("select branchcode,branchname from branches"); + $sth->execute; + push @authorised_values, "" unless ($tagslib->{$tag}->{$subfield}->{mandatory}); + while (my ($branchcode,$branchname) = $sth->fetchrow_array) { + push @authorised_values, $branchcode; + } + #----- itemtypes + } elsif ($tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes") { + my $sth=$dbh->prepare("select itemtype,description from itemtypes"); + $sth->execute; + push @authorised_values, "" unless ($tagslib->{$tag}->{$subfield}->{mandatory}); + while (my ($itemtype,$description) = $sth->fetchrow_array) { + push @authorised_values, $itemtype; + } + #---- "true" authorised value + } else { + $authorised_values_sth->execute($tagslib->{$tag}->{$subfield}->{authorised_value}); + push @authorised_values, "" unless ($tagslib->{$tag}->{$subfield}->{mandatory}); + while ((my $value) = $authorised_values_sth->fetchrow_array) { + push @authorised_values, $value; + } } $subfield_data{marc_value}= CGI::scrolling_list(-name=>'field_value', -values=> \@authorised_values, + -default=>"$value", -size=>1, -multiple=>0, ); } elsif ($tagslib->{$tag}->{$subfield}->{thesaurus_category}) { - $subfield_data{marc_value}=" {$tag}->{$subfield}->{thesaurus_category}&index=$i',$i)\">..."; - } elsif ($tagslib->{$tag}->{$subfield}->{value_builder}) { - $subfield_data{marc_value}=" {$tag}->{$subfield}->{value_builder}?index=$i',$i)\">..."; + $subfield_data{marc_value}=" {$tag}->{$subfield}->{thesaurus_category}&index=$i',$i)\">..."; + } elsif ($tagslib->{$tag}->{$subfield}->{'value_builder'}) { + my $plugin="../value_builder/".$tagslib->{$tag}->{$subfield}->{'value_builder'}; + require $plugin; + my $extended_param = plugin_parameters($dbh,$record,$tagslib,$i,$tabloop); + $subfield_data{marc_value}=" {$tag}->{$subfield}->{value_builder}&index=$i$extended_param',$i)\">..."; } else { - $subfield_data{marc_value}=""; + $subfield_data{marc_value}=">"; } } push(@subfields_data, \%subfield_data); @@ -338,7 +268,7 @@ if ($op eq "addbiblio") { } } $template->param( - biblionumber => $oldbiblionumber, + oldbiblionumber => $oldbiblionumber, bibid => $bibid); } print "Content-Type: text/html\n\n", $template->output; diff --git a/acqui.simple/additem.pl b/acqui.simple/additem.pl index 9bffa2d959..2254808b38 100755 --- a/acqui.simple/additem.pl +++ b/acqui.simple/additem.pl @@ -21,293 +21,211 @@ use CGI; use strict; -use C4::Catalogue; -use C4::Biblio; use C4::Output; - +use C4::Biblio; +use C4::Context; +use HTML::Template; +use MARC::File::USMARC; + +sub find_value { + my ($tagfield,$insubfield,$record) = @_; +# warn "$tagfield / $insubfield // "; + my $result; + my $indicator; + foreach my $field ($record->field($tagfield)) { + my @subfields = $field->subfields(); + foreach my $subfield (@subfields) { + if (@$subfield[0] eq $insubfield) { + $result .= @$subfield[1]; + $indicator = $field->indicator(1).$field->indicator(2); + } + } + } + return($indicator,$result); +} my $input = new CGI; -my $biblionumber = $input->param('biblionumber'); -my $error = $input->param('error'); -my $maxbarcode; -my $isbn; -my $bibliocount; -my @biblios; -my $biblioitemcount; -my @biblioitems; -my $branchcount; -my @branches; -my %branchnames; -my $itemcount; -my @items; -my $itemtypecount; -my @itemtypes; -my %itemtypedescriptions; - -if (! $biblionumber) { - print $input->redirect('addbooks.pl'); -} else { - - ($bibliocount, @biblios) = &getbiblio($biblionumber); - - if (! $bibliocount) { - print $input->redirect('addbooks.pl'); - } else { - - ($biblioitemcount, @biblioitems) = &getbiblioitembybiblionumber($biblionumber); - ($branchcount, @branches) = &branches; - ($itemtypecount, @itemtypes) = &getitemtypes; - - for (my $i = 0; $i < $itemtypecount; $i++) { - $itemtypedescriptions{$itemtypes[$i]->{'itemtype'}} = $itemtypes[$i]->{'description'}; - } # for - - for (my $i = 0; $i < $branchcount; $i++) { - $branchnames{$branches[$i]->{'branchcode'}} = $branches[$i]->{'branchname'}; - } # for - - print $input->header; - print startpage(); - print startmenu('acquisitions'); - - print << "EOF"; -$biblios[0]->{'title'} -

-EOF - - if ($error eq "nobarcode") { - print << "EOF"; -You must give the item a barcode -

-EOF - } elsif ($error eq "nobiblioitem") { - print << "EOF"; -You must create a new group for your item to be added to -

-EOF - } elsif ($error eq "barcodeinuse") { - print << "EOF"; -Sorry, that barcode is already in use -

-EOF - } # elsif - print << "EOF"; - - - - - - - -EOF - - for (my $i = 0; $i < $biblioitemcount; $i++) { - if ($biblioitems[$i]->{'itemtype'} eq "WEB") { - - print << "EOF"; - - - - - - -EOF - - } else { - $biblioitems[$i]->{'dewey'} =~ /(\d*\.\d\d)/; - $biblioitems[$i]->{'dewey'} = $1; +my $error = $input->param('error'); +my $bibid = $input->param('bibid'); +my $op = $input->param('op'); +my $dbh = C4::Context->dbh; +my $itemnum = $input->param('itemnum'); + +my $tagslib = &MARCgettagslib($dbh,1); +my $record = MARCgetbiblio($dbh,$bibid); +my $itemrecord; +my $nextop="additem"; +#------------------------------------------------------------------------------------------------------------------------------ +if ($op eq "additem") { +#------------------------------------------------------------------------------------------------------------------------------ + # rebuild + my @tags = $input->param('tag'); + my @subfields = $input->param('subfield'); + my @values = $input->param('field_value'); + # build indicator hash. + my @ind_tag = $input->param('ind_tag'); + my @indicator = $input->param('indicator'); + my %indicators; + for (my $i=0;$i<=$#ind_tag;$i++) { + $indicators{$ind_tag[$i]} = $indicator[$i]; + } + my $record = MARChtml2marc($dbh,\@tags,\@subfields,\@values,%indicators); +# MARC::Record builded => now, record in DB + my ($bibid,$oldbibnum,$oldbibitemnum) = NEWnewitem($dbh,$record,$bibid); + $nextop = "additem"; +#------------------------------------------------------------------------------------------------------------------------------ +} elsif ($op eq "edititem") { +#------------------------------------------------------------------------------------------------------------------------------ +# retrieve item if exist => then, it's a modif + $itemrecord = MARCgetitem($dbh,$bibid,$itemnum); + $nextop="saveitem"; +#------------------------------------------------------------------------------------------------------------------------------ +} elsif ($op eq "saveitem") { +#------------------------------------------------------------------------------------------------------------------------------ + # rebuild + my @tags = $input->param('tag'); + my @subfields = $input->param('subfield'); + my @values = $input->param('field_value'); + # build indicator hash. + my @ind_tag = $input->param('ind_tag'); + my @indicator = $input->param('indicator'); + my %indicators; + for (my $i=0;$i<=$#ind_tag;$i++) { + $indicators{$ind_tag[$i]} = $indicator[$i]; + } + my $record = MARChtml2marc($dbh,\@tags,\@subfields,\@values,%indicators); +# MARC::Record builded => now, record in DB + my ($bibid,$oldbibnum,$oldbibitemnum) = NEWmoditem($dbh,$record,$bibid,$itemnum,0); + $nextop="additem"; +} - print << "EOF"; - - - - - - -EOF - - ($itemcount, @items) = &getitemsbybiblioitem($biblioitems[$i]->{'biblioitemnumber'}); - - for (my $j = 0; $j < $itemcount; $j++) { - print << "EOF"; - - - -EOF - } # for - } # else - } # for - - print << "EOF"; -
BIBLIO RECORD $biblionumber
Author: $biblios[0]->{'author'}
-Copyright: $biblios[0]->{'copyrightdate'}
-Series Title: $biblios[0]->{'seriestitle'}
-Notes: $biblios[0]->{'notes'}
$biblioitems[$i]->{'biblioitemnumber'} GROUP - $itemtypedescriptions{$biblioitems[$i]->{'itemtype'}}
URL: $biblioitems[$i]->{'url'}
-Date: $biblioitems[$i]->{'publicationyear'}
-Notes: $biblioitems[$i]->{'notes'}
$biblioitems[$i]->{'biblioitemnumber'} GROUP - $itemtypedescriptions{$biblioitems[$i]->{'itemtype'}}
ISBN: $biblioitems[$i]->{'isbn'}
-Dewey: $biblioitems[$i]->{'dewey'}
-Publisher: $biblioitems[$i]->{'publishercode'}
-Place: $biblioitems[$i]->{'place'}
-Date: $biblioitems[$i]->{'publicationyear'}
Item: $items[$j]->{'barcode'}
-Home Branch: $branchnames{$items[$j]->{'homebranch'}}
-Notes: $items[$j]->{'itemnotes'}
- - -

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ADD NEW ITEM:
-For a website add the group only
Item Barcode:
Branch:
Replacement Price:
Notes:
Add to existing group:
Group:
OR Add to a new Group:
Format:
ISBN:
Publisher:
Publication Year:
Place of Publication:
Illustrator:
Additional Authors:
One Author per line
Subject Headings:
One Subject per line
Website URL:
Dewey:
Dewey Subclass:
ISSN:
LCCN: -
Volume:
Number:
Volume Description:
Pages:
Size:
Notes:
- -
-
-EOF - - print endmenu('acquisitions'); - print endpage(); - } # if -} # if +# +#------------------------------------------------------------------------------------------------------------------------------ +# build screen with existing items. and "new" one +#------------------------------------------------------------------------------------------------------------------------------ + +my %indicators; +$indicators{995}=' '; +# now, build existiing item list +my $temp = MARCgetbiblio($dbh,$bibid); +my @fields = $temp->fields(); +my %witness; #---- stores the list of subfields used at least once, with the "meaning" of the code +my @big_array; +#---- finds where items.itemnumber is stored +my ($itemtagfield,$itemtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"items.itemnumber"); +my @itemnums; # array to store itemnums +foreach my $field (@fields) { + my @subf=$field->subfields; + my %this_row; +# loop through each subfield + for my $i (0..$#subf) { + next if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab} ne 10 && ($field->tag() ne $itemtagfield && $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); + $this_row{$subf[$i][0]} =$subf[$i][1] if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab} eq 10); + push @itemnums,$this_row{$subf[$i][0]} =$subf[$i][1] if ($field->tag() eq $itemtagfield && $subf[$i][0] eq $itemtagsubfield); + } + if (%this_row) { + push(@big_array, \%this_row); + } +} +#fill big_row with missing datas +foreach my $subfield_code (keys(%witness)) { + for (my $i=0;$i<=$#big_array;$i++) { + $big_array[$i]{$subfield_code}=" " unless ($big_array[$i]{$subfield_code}); + } +} +# now, construct template ! +my @item_value_loop; +my @header_value_loop; +for (my $i=0;$i<=$#big_array; $i++) { + my $items_data; + foreach my $subfield_code (sort keys(%witness)) { + $items_data .="".$big_array[$i]{$subfield_code}.""; + } + my %row_data; + $row_data{item_value} = $items_data; + $row_data{itemnum} = $itemnums[$i]; + push(@item_value_loop,\%row_data); +} +foreach my $subfield_code (sort keys(%witness)) { + my %header_value; + $header_value{header_value} = $witness{$subfield_code}; + push(@header_value_loop, \%header_value); +} + +# next item form +my @loop_data =(); +my $i=0; +my $authorised_values_sth = $dbh->prepare("select authorised_value from authorised_values where category=?"); + +foreach my $tag (sort keys %{$tagslib}) { + my $previous_tag = ''; +# loop through each subfield + foreach my $subfield (sort keys %{$tagslib->{$tag}}) { + next if ($subfield eq 'lib'); + next if ($subfield eq 'tab'); + next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "10"); + my %subfield_data; + $subfield_data{tag}=$tag; + $subfield_data{subfield}=$subfield; + $subfield_data{marc_lib}=$tagslib->{$tag}->{$subfield}->{lib}; + $subfield_data{marc_mandatory}=$tagslib->{$tag}->{$subfield}->{mandatory}; + $subfield_data{marc_repeatable}=$tagslib->{$tag}->{$subfield}->{repeatable}; + my ($x,$value); + ($x,$value) = find_value($tag,$subfield,$itemrecord) if ($itemrecord); + if ($tagslib->{$tag}->{$subfield}->{authorised_value}) { + my @authorised_values; + # builds list, depending on authorised value... + #---- branch + if ($tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) { + my $sth=$dbh->prepare("select branchcode,branchname from branches"); + $sth->execute; + push @authorised_values, "" unless ($tagslib->{$tag}->{$subfield}->{mandatory}); + while (my ($branchcode,$branchname) = $sth->fetchrow_array) { + push @authorised_values, $branchcode; + } + #----- itemtypes + } elsif ($tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes") { + my $sth=$dbh->prepare("select itemtype,description from itemtypes"); + $sth->execute; + push @authorised_values, "" unless ($tagslib->{$tag}->{$subfield}->{mandatory}); + while (my ($itemtype,$description) = $sth->fetchrow_array) { + push @authorised_values, $itemtype; + } + #---- "true" authorised value + } else { + $authorised_values_sth->execute($tagslib->{$tag}->{$subfield}->{authorised_value}); + push @authorised_values, "" unless ($tagslib->{$tag}->{$subfield}->{mandatory}); + while ((my $value) = $authorised_values_sth->fetchrow_array) { + push @authorised_values, $value; + } + } + $subfield_data{marc_value}= CGI::scrolling_list(-name=>'field_value', + -values=> \@authorised_values, + -default=>"$value", + -size=>1, + -multiple=>0, + ); + } elsif ($tagslib->{$tag}->{$subfield}->{thesaurus_category}) { + $subfield_data{marc_value}=" {$tag}->{$subfield}->{thesaurus_category}&index=$i',$i)\">..."; + } elsif ($tagslib->{$tag}->{$subfield}->{'value_builder'}) { + my $plugin="../value_builder/".$tagslib->{$tag}->{$subfield}->{'value_builder'}; + require $plugin; + my $extended_param = plugin_parameters($dbh,$record,$tagslib,$i,0); + $subfield_data{marc_value}=" {$tag}->{$subfield}->{value_builder}&index=$i$extended_param',$i)\">..."; + } else { + $subfield_data{marc_value}=""; + } +# $subfield_data{marc_value}=""; + push(@loop_data, \%subfield_data); + $i++ + } +} +my $template = gettemplate("acqui.simple/additem.tmpl"); +# what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit. +$template->param(item_loop => \@item_value_loop, + item_header_loop => \@header_value_loop, + bibid => $bibid, + item => \@loop_data, + itemnum => $itemnum, + op => $nextop); +print "Content-Type: text/html\n\n", $template->output; diff --git a/admin/authorised_values.pl b/admin/authorised_values.pl index 332c19e3ee..528c92fee0 100755 --- a/admin/authorised_values.pl +++ b/admin/authorised_values.pl @@ -137,6 +137,7 @@ if ($op eq 'add_form') { while ( my ($category) = $sth->fetchrow_array) { push(@category_list,$category); } + # push koha system categories my $tab_list = CGI::scrolling_list(-name=>'searchfield', -values=> \@category_list, -default=>"", diff --git a/admin/marc_subfields_structure.pl b/admin/marc_subfields_structure.pl index 7eaa8a20b6..59970a4f1b 100755 --- a/admin/marc_subfields_structure.pl +++ b/admin/marc_subfields_structure.pl @@ -103,6 +103,8 @@ if ($op eq 'add_form') { while ((my $category) = $sth2->fetchrow_array) { push @authorised_values, $category; } + push (@authorised_values,"branches"); + push (@authorised_values,"itemtypes"); # build thesaurus categories list $sth2->finish; $sth2 = $dbh->prepare("select distinct category from bibliothesaurus"); -- 2.39.5