diff --git a/acqui.simple/addbiblio.pl b/acqui.simple/addbiblio.pl
index a34c10acd8..7f485d0893 100755
--- a/acqui.simple/addbiblio.pl
+++ b/acqui.simple/addbiblio.pl
@@ -82,7 +82,7 @@ my $template;
my $tagslib = &MARCgettagslib($dbh,1);
my $record = MARCgetbiblio($dbh,$bibid) if ($oldbiblionumber);
-#my $record = MARCfindbreeding($dbh,$isbn) if ($isbn);
+my $record = MARCfindbreeding($dbh,$isbn) if ($isbn);
#------------------------------------------------------------------------------------------------------------------------------
if ($op eq "addbiblio") {
@@ -104,15 +104,15 @@ if ($op eq "addbiblio") {
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};
- $subfield_data{marc_value}="";
+ $subfield_data{marc_value}="";
push(@loop_data, \%subfield_data);
- $i++
}
}
$template = gettemplate("acqui.simple/addbiblio2.tmpl");
@@ -184,7 +184,7 @@ if ($op eq "addbiblio") {
$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}="";
+ $subfield_data{marc_value}="";
push(@loop_data, \%subfield_data);
$i++
}
@@ -201,6 +201,8 @@ if ($op eq "addbiblio") {
# fill arrays
my @loop_data =();
my $tag;
+ my $i=0;
+ my $authorised_values_sth = $dbh->prepare("select authorised_value from authorised_values where category=?");
# loop through each tab 0 through 9
for (my $tabloop = 0; $tabloop<=9;$tabloop++) {
# loop through each tag
@@ -217,16 +219,46 @@ if ($op eq "addbiblio") {
my %subfield_data;
$subfield_data{tag}=$tag;
$subfield_data{subfield}=$subfield;
- $subfield_data{marc_lib}=$tagslib->{$tag}->{$subfield}->{lib};
+ $subfield_data{marc_lib}="
".$tagslib->{$tag}->{$subfield}->{lib}."
";
$subfield_data{mandatory}=$tagslib->{$tag}->{$subfield}->{mandatory};
$subfield_data{repeatable}=$tagslib->{$tag}->{$subfield}->{repeatable};
if ($record ne -1) {
- my $value ="";# &find_value($tag,$subfield,$record);
- $subfield_data{marc_value}="";
+ my $value = find_value($tag,$subfield,$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;
+ }
+ $subfield_data{marc_value}= CGI::scrolling_list(-name=>'field_value',
+ -values=> \@authorised_values,
+ -default=>"$value",
+ -size=>1,
+ -multiple=>0,
+ );
+ } else {
+ $subfield_data{marc_value}="";
+ }
} else {
- $subfield_data{marc_value}="";
+ 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,
+ );
+ } else {
+ $subfield_data{marc_value}="";
+ }
}
push(@subfields_data, \%subfield_data);
+ $i++;
}
if ($#subfields_data>=0) {
my %tag_data;
@@ -251,7 +283,7 @@ if ($op eq "addbiblio") {
$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}="";
+ $subfield_data{marc_value}="";
push(@loop_data, \%subfield_data);
$i++
}
diff --git a/admin/authorised_values.pl b/admin/authorised_values.pl
new file mode 100755
index 0000000000..332c19e3ee
--- /dev/null
+++ b/admin/authorised_values.pl
@@ -0,0 +1,181 @@
+#!/usr/bin/perl
+
+# Copyright 2000-2002 Katipo Communications
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA 02111-1307 USA
+
+use strict;
+use CGI;
+use C4::Context;
+use C4::Output;
+use C4::Search;
+use HTML::Template;
+use C4::Context;
+
+
+sub StringSearch {
+ my ($env,$searchstring,$type)=@_;
+ my $dbh = C4::Context->dbh;
+ $searchstring=~ s/\'/\\\'/g;
+ my @data=split(' ',$searchstring);
+ my $count=@data;
+ my $query="Select id,category,authorised_value from authorised_values where (category like \"$data[0]%\") order by category,authorised_value";
+ my $sth=$dbh->prepare($query);
+ $sth->execute;
+ my @results;
+ my $cnt=0;
+ while (my $data=$sth->fetchrow_hashref){
+ push(@results,$data);
+ $cnt ++;
+ }
+ $sth->finish;
+ return ($cnt,\@results);
+}
+
+my $input = new CGI;
+my $searchfield=$input->param('searchfield');
+$searchfield=~ s/\,//g;
+my $id = $input->param('id');
+my $reqsel="select category,authorised_value from authorised_values where id='$id'";
+my $reqdel="delete from authorised_values where id='$id'";
+my $offset=$input->param('offset');
+my $script_name="/cgi-bin/koha/admin/authorised_values.pl";
+my $dbh = C4::Context->dbh;
+
+my $template = gettemplate("parameters/authorised_values.tmpl",0);
+my $pagesize=20;
+my $op = $input->param('op');
+
+if ($op) {
+$template->param(script_name => $script_name,
+ $op => 1); # we show only the TMPL_VAR names $op
+} else {
+$template->param(script_name => $script_name,
+ else => 1); # we show only the TMPL_VAR names $op
+}
+################## ADD_FORM ##################################
+# called by default. Used to create form to add or modify a record
+if ($op eq 'add_form') {
+ my $data;
+ if ($id) {
+ my $dbh = C4::Context->dbh;
+ my $sth=$dbh->prepare("select id,category,authorised_value from authorised_values where id='$id'");
+ $sth->execute;
+ $data=$sth->fetchrow_hashref;
+ $sth->finish;
+ } else {
+ $data->{'category'} = $input->param('category');
+ }
+ if ($searchfield) {
+ $template->param(action => "Modify authorised value");
+ } else {
+ $template->param(action => "Add authorised value");
+ }
+ $template->param(category => $data->{'category'},
+ authorised_value => $data->{'authorised_value'},
+ id => $data->{'id'}
+ );
+ if ($data->{'category'}) {
+ $template->param(category => "$data->{'category'}");
+ } else {
+ $template->param(category => "");
+ }
+################## ADD_VALIDATE ##################################
+# called by add_form, used to insert/modify data in DB
+} elsif ($op eq 'add_validate') {
+ my $dbh = C4::Context->dbh;
+ my $sth=$dbh->prepare("replace authorised_values (id,category,authorised_value) values (?,?,?)");
+ warn "TOTO : ".$input->param('id'), $input->param('category'), $input->param('authorised_value');
+ $sth->execute($input->param('id'), $input->param('category'), $input->param('authorised_value'));
+ $sth->finish;
+ print "Content-Type: text/html\n\nparam('category')."\">