diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm
index 7c69ae0750..c244d60a27 100644
--- a/C4/AuthoritiesMarc.pm
+++ b/C4/AuthoritiesMarc.pm
@@ -20,6 +20,7 @@ use strict;
require Exporter;
use C4::Context;
use C4::Database;
+use C4::Koha;
use MARC::Record;
use vars qw($VERSION @ISA @EXPORT);
@@ -30,8 +31,8 @@ $VERSION = 0.01;
@ISA = qw(Exporter);
@EXPORT = qw(
&AUTHgettagslib
- &MARCfindsubfield
- &MARCfind_frameworkcode
+ &AUTHfindsubfield
+ &AUTHfind_authtypecode
&AUTHaddauthority
&AUTHmodauthority
@@ -39,6 +40,8 @@ $VERSION = 0.01;
&AUTHaddsubfield
&AUTHgetauthority
+ &authoritysearch
+
&MARCmodsubfield
&AUTHhtml2marc
&AUTHaddword
@@ -46,12 +49,209 @@ $VERSION = 0.01;
&char_decode
);
+sub authoritysearch {
+ my ($dbh, $tags, $and_or, $excluding, $operator, $value, $offset,$length,$authtypecode) = @_;
+ # build the sql request. She will look like :
+ # select m1.bibid
+ # from auth_subfield_table as m1, auth_subfield_table as m2
+ # where m1.authid=m2.authid and
+ # (m1.subfieldvalue like "Des%" and m2.subfieldvalue like "27%")
+
+ # "Normal" statements
+ my @normal_tags = ();
+ my @normal_and_or = ();
+ my @normal_operator = ();
+ my @normal_value = ();
+ # Extracts the NOT statements from the list of statements
+ for(my $i = 0 ; $i <= $#{$value} ; $i++)
+ {
+ if(@$operator[$i] eq "contains") # if operator is contains, splits the words in separate requests
+ {
+ foreach my $word (split(/ /, @$value[$i]))
+ {
+ unless (C4::Context->stopwords->{uc($word)}) { #it's NOT a stopword => use it. Otherwise, ignore
+ my $tag = substr(@$tags[$i],0,3);
+ my $subf = substr(@$tags[$i],3,1);
+ push @normal_tags, @$tags[$i];
+ push @normal_and_or, "and"; # assumes "foo" and "bar" if "foo bar" is entered
+ push @normal_operator, @$operator[$i];
+ push @normal_value, $word;
+ }
+ }
+ }
+ else
+ {
+ push @normal_tags, @$tags[$i];
+ push @normal_and_or, @$and_or[$i];
+ push @normal_operator, @$operator[$i];
+ push @normal_value, @$value[$i];
+ }
+ }
+
+ # Finds the basic results without the NOT requests
+ my ($sql_tables, $sql_where1, $sql_where2) = create_request($dbh,\@normal_tags, \@normal_and_or, \@normal_operator, \@normal_value);
+
+ my $sth;
+ if ($sql_where2) {
+ $sth = $dbh->prepare("select distinct m1.authid from auth_header,$sql_tables where m1.authid=auth_header.authid and auth_header.authtypecode=? and $sql_where2 and ($sql_where1)");
+ warn "Q2 : select distinct m1.authid from auth_header,$sql_tables where m1.authid=auth_header.authid and auth_header.authtypecode=? and $sql_where2 and ($sql_where1)";
+ } else {
+ $sth = $dbh->prepare("select distinct m1.authid from auth_header,$sql_tables where m1.authid=auth_header.authid and auth_header.authtypecode=? and $sql_where1");
+ warn "Q : select distinct m1.authid from auth_header,$sql_tables where m1.authid=auth_header.authid and auth_header.authtypecode=? and $sql_where1";
+ }
+ $sth->execute($authtypecode);
+ my @result = ();
+
+ while (my ($authid) = $sth->fetchrow) {
+ warn "AUTH: $authid";
+ push @result,$authid;
+ }
+
+ # we have authid list. Now, loads summary from [offset] to [offset]+[length]
+ my $counter = $offset;
+ my @finalresult = ();
+ my $oldline;
+ while (($counter <= $#result) && ($counter <= ($offset + $length))) {
+ warn "HERE";
+ # get MARC::Record of the authority
+ my $record = AUTHgetauthority($dbh,$result[$counter]);
+ # then build the summary
+ my $authtypecode = AUTHfind_authtypecode($dbh,$result[$counter]);
+ my $authref = getauthtype($authtypecode);
+ my $summary = $authref->{summary};
+ my @fields = $record->fields();
+ foreach my $field (@fields) {
+ my $tag = $field->tag();
+ if ($tag<10) {
+ } else {
+ my @subf = $field->subfields;
+ for my $i (0..$#subf) {
+ my $subfieldcode = $subf[$i][0];
+ my $subfieldvalue = $subf[$i][1];
+ my $tagsubf = $tag.$subfieldcode;
+ $summary =~ s/\[(.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue\[$1$tagsubf$2]$2$3/g;
+ }
+ }
+ }
+ $summary =~ s/\[(.*?)]//g;
+ $summary =~ s/\n/
/g;
+ # then add a line for the template loop
+ my %newline;
+ $newline{summary} = $summary;
+ $newline{authid} = $result[$counter];
+ push @finalresult, \%newline;
+ my $nbresults = $#result + 1;
+ return (\@finalresult, $nbresults);
+ }
+}
+
+# Creates the SQL Request
+
+sub create_request {
+ my ($dbh,$tags, $and_or, $operator, $value) = @_;
+
+ my $sql_tables; # will contain marc_subfield_table as m1,...
+ my $sql_where1; # will contain the "true" where
+ my $sql_where2 = "("; # will contain m1.authid=m2.authid
+ my $nb_active=0; # will contain the number of "active" entries. and entry is active is a value is provided.
+ my $nb_table=1; # will contain the number of table. ++ on each entry EXCEPT when an OR is provided.
+
+ for(my $i=0; $i<=@$value;$i++) {
+ if (@$value[$i]) {
+ $nb_active++;
+ if ($nb_active==1) {
+ if (@$operator[$i] eq "start") {
+ $sql_tables .= "auth_subfield_table as m$nb_table,";
+ $sql_where1 .= "(m1.subfieldvalue like ".$dbh->quote("@$value[$i]%");
+ if (@$tags[$i]) {
+ $sql_where1 .=" and m1.tag+m1.subfieldcode in (@$tags[$i])";
+ }
+ $sql_where1.=")";
+ } elsif (@$operator[$i] eq "contains") {
+ $sql_tables .= "auth_word as m$nb_table,";
+ $sql_where1 .= "(m1.word like ".$dbh->quote("@$value[$i]%");
+ if (@$tags[$i]) {
+ $sql_where1 .=" and m1.tag+m1.subfieldid in (@$tags[$i])";
+ }
+ $sql_where1.=")";
+ } else {
+ $sql_tables .= "auth_subfield_table as m$nb_table,";
+ $sql_where1 .= "(m1.subfieldvalue @$operator[$i] ".$dbh->quote("@$value[$i]");
+ if (@$tags[$i]) {
+ $sql_where1 .=" and m1.tag+m1.subfieldcode in (@$tags[$i])";
+ }
+ $sql_where1.=")";
+ }
+ } else {
+ if (@$operator[$i] eq "start") {
+ $nb_table++;
+ $sql_tables .= "auth_subfield_table as m$nb_table,";
+ $sql_where1 .= "@$and_or[$i] (m$nb_table.subfieldvalue like ".$dbh->quote("@$value[$i]%");
+ if (@$tags[$i]) {
+ $sql_where1 .=" and m$nb_table.tag+m$nb_table.subfieldcode in (@$tags[$i])";
+ }
+ $sql_where1.=")";
+ $sql_where2 .= "m1.authid=m$nb_table.authid and ";
+ } elsif (@$operator[$i] eq "contains") {
+ if (@$and_or[$i] eq 'and') {
+ $nb_table++;
+ $sql_tables .= "auth_word as m$nb_table,";
+ $sql_where1 .= "@$and_or[$i] (m$nb_table.word like ".$dbh->quote("@$value[$i]%");
+ if (@$tags[$i]) {
+ $sql_where1 .=" and m$nb_table.tag+m$nb_table.subfieldid in(@$tags[$i])";
+ }
+ $sql_where1.=")";
+ $sql_where2 .= "m1.authid=m$nb_table.authid and ";
+ } else {
+ $sql_where1 .= "@$and_or[$i] (m$nb_table.word like ".$dbh->quote("@$value[$i]%");
+ if (@$tags[$i]) {
+ $sql_where1 .=" and m$nb_table.tag+m$nb_table.subfieldid in (@$tags[$i])";
+ }
+ $sql_where1.=")";
+ $sql_where2 .= "m1.authid=m$nb_table.authid and ";
+ }
+ } else {
+ $nb_table++;
+ $sql_tables .= "auth_subfield_table as m$nb_table,";
+ $sql_where1 .= "@$and_or[$i] (m$nb_table.subfieldvalue @$operator[$i] ".$dbh->quote(@$value[$i]);
+ if (@$tags[$i]) {
+ $sql_where1 .=" and m$nb_table.tag+m$nb_table.subfieldcode in (@$tags[$i])";
+ }
+ $sql_where2 .= "m1.authid=m$nb_table.authid and ";
+ $sql_where1.=")";
+ }
+ }
+ }
+ }
+
+ if($sql_where2 ne "(") # some datas added to sql_where2, processing
+ {
+ $sql_where2 = substr($sql_where2, 0, (length($sql_where2)-5)); # deletes the trailing ' and '
+ $sql_where2 .= ")";
+ }
+ else # no sql_where2 statement, deleting '('
+ {
+ $sql_where2 = "";
+ }
+ chop $sql_tables; # deletes the trailing ','
+ return ($sql_tables, $sql_where1, $sql_where2);
+}
+
+
+sub AUTHfind_authtypecode {
+ my ($dbh,$authid) = @_;
+ my $sth = $dbh->prepare("select authtypecode from auth_header where authid=?");
+ $sth->execute($authid);
+ my ($authtypecode) = $sth->fetchrow;
+ return $authtypecode;
+}
+
sub AUTHgettagslib {
my ($dbh,$forlibrarian,$authtypecode)= @_;
- warn "AUTH : $authtypecode";
+# warn "AUTH : $authtypecode";
$authtypecode="" unless $authtypecode;
- warn "AUTH : $authtypecode";
+# warn "AUTH : $authtypecode";
my $sth;
my $libfield = ($forlibrarian eq 1)? 'liblibrarian' : 'libopac';
# check that framework exists
@@ -171,7 +371,7 @@ sub AUTHgetauthority {
my $record = MARC::Record->new();
#---- TODO : the leader is missing
$record->leader(' ');
- my $sth=$dbh->prepare("select authid,subfieldid,tag,tagorder,tag_indicator,subfieldcode,subfieldorder,subfieldvalue,valuebloblink
+ my $sth=$dbh->prepare("select authid,subfieldid,tag,tagorder,tag_indicator,subfieldcode,subfieldorder,subfieldvalue
from auth_subfield_table
where authid=? order by tag,tagorder,subfieldcode
");
@@ -558,6 +758,9 @@ Paul POULAIN paul.poulain@free.fr
# $Id$
# $Log$
+# Revision 1.2 2004/06/10 08:29:01 tipaul
+# MARC authority management (continued)
+#
# Revision 1.1 2004/06/07 07:35:01 tipaul
# MARC authority management package
#
diff --git a/C4/Biblio.pm b/C4/Biblio.pm
index 415e23198d..c51749c187 100644
--- a/C4/Biblio.pm
+++ b/C4/Biblio.pm
@@ -240,24 +240,24 @@ sub MARCgettagslib {
$res->{$tag}->{repeatable}=$repeatable;
}
- $sth=$dbh->prepare("select tagfield,tagsubfield,$libfield as lib,tab, mandatory, repeatable,authorised_value,thesaurus_category,value_builder,kohafield,seealso,hidden,isurl from marc_subfield_structure where frameworkcode=? order by tagfield,tagsubfield");
+ $sth=$dbh->prepare("select tagfield,tagsubfield,$libfield as lib,tab, mandatory, repeatable,authorised_value,authtypecode,value_builder,kohafield,seealso,hidden,isurl from marc_subfield_structure where frameworkcode=? order by tagfield,tagsubfield");
$sth->execute($frameworkcode);
my $subfield;
my $authorised_value;
- my $thesaurus_category;
+ my $authtypecode;
my $value_builder;
my $kohafield;
my $seealso;
my $hidden;
my $isurl;
- while ( ($tag, $subfield, $lib, $tab, $mandatory, $repeatable,$authorised_value,$thesaurus_category,$value_builder,$kohafield,$seealso,$hidden,$isurl) = $sth->fetchrow) {
+ while ( ($tag, $subfield, $lib, $tab, $mandatory, $repeatable,$authorised_value,$authtypecode,$value_builder,$kohafield,$seealso,$hidden,$isurl) = $sth->fetchrow) {
$res->{$tag}->{$subfield}->{lib}=$lib;
$res->{$tag}->{$subfield}->{tab}=$tab;
$res->{$tag}->{$subfield}->{mandatory}=$mandatory;
$res->{$tag}->{$subfield}->{repeatable}=$repeatable;
$res->{$tag}->{$subfield}->{authorised_value}=$authorised_value;
- $res->{$tag}->{$subfield}->{thesaurus_category}=$thesaurus_category;
+ $res->{$tag}->{$subfield}->{authtypecode}=$authtypecode;
$res->{$tag}->{$subfield}->{value_builder}=$value_builder;
$res->{$tag}->{$subfield}->{kohafield}=$kohafield;
$res->{$tag}->{$subfield}->{seealso}=$seealso;
@@ -2191,6 +2191,9 @@ Paul POULAIN paul.poulain@free.fr
# $Id$
# $Log$
+# Revision 1.92 2004/06/10 08:29:01 tipaul
+# MARC authority management (continued)
+#
# Revision 1.91 2004/06/03 10:03:01 tipaul
# * frameworks and itemtypes are independant
# * in the MARC editor, showing the + to duplicate a tag only if the tag is repeatable
diff --git a/C4/Koha.pm b/C4/Koha.pm
index e6da0640a0..61a3d554d6 100644
--- a/C4/Koha.pm
+++ b/C4/Koha.pm
@@ -59,7 +59,7 @@ Koha.pm provides many functions for Koha scripts.
&getprinters &getprinter
&getitemtypes &getitemtypeinfo
&getframeworks &getframeworkinfo
- &getauthtypes
+ &getauthtypes &getauthtype
$DEBUG);
use vars qw();
@@ -322,6 +322,17 @@ sub getauthtypes {
return (\%authtypes);
}
+sub getauthtype {
+ my ($authtypecode) = @_;
+# returns a reference to a hash of references to authtypes...
+ my %authtypes;
+ my $dbh = C4::Context->dbh;
+ my $sth=$dbh->prepare("select * from auth_types where authtypecode=?");
+ $sth->execute($authtypecode);
+ my $res=$sth->fetchrow_hashref;
+ return $res;
+}
+
=head2 getframework
$frameworks = &getframework();
diff --git a/authorities/auth_finder.pl b/authorities/auth_finder.pl
new file mode 100755
index 0000000000..f27b8d3023
--- /dev/null
+++ b/authorities/auth_finder.pl
@@ -0,0 +1,164 @@
+#!/usr/bin/perl
+# WARNING: 4-character tab stops here
+
+# 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;
+require Exporter;
+use CGI;
+use C4::Auth;
+use HTML::Template;
+use C4::Context;
+use C4::Search;
+use C4::Auth;
+use C4::Output;
+use C4::Interface::CGI::Output;
+use C4::AuthoritiesMarc;
+use C4::SearchMarc;
+use C4::Catalogue;
+use C4::Koha; # XXX subfield_is_koha_internal_p
+
+my $query=new CGI;
+my $op = $query->param('op');
+my $authtypecode = $query->param('authtypecode');
+my $dbh = C4::Context->dbh;
+
+my $startfrom=$query->param('startfrom');
+$startfrom=0 if(!defined $startfrom);
+my ($template, $loggedinuser, $cookie);
+my $resultsperpage;
+
+my $authtypes = getauthtypes;
+my @authtypesloop;
+foreach my $thisauthtype (keys %$authtypes) {
+ my $selected = 1 if $thisauthtype eq $authtypecode;
+ my %row =(value => $thisauthtype,
+ selected => $selected,
+ authtypetext => $authtypes->{$thisauthtype}{'authtypetext'},
+ );
+ push @authtypesloop, \%row;
+}
+
+if ($op eq "do_search") {
+ my @marclist = $query->param('marclist');
+ my @and_or = $query->param('and_or');
+ my @excluding = $query->param('excluding');
+ my @operator = $query->param('operator');
+ my @value = $query->param('value');
+
+ $resultsperpage= $query->param('resultsperpage');
+ $resultsperpage = 19 if(!defined $resultsperpage);
+ my $orderby = $query->param('orderby');
+
+ # builds tag and subfield arrays
+ my @tags;
+
+ my ($results,$total) = authoritysearch($dbh, \@tags,\@and_or,
+ \@excluding, \@operator, \@value,
+ $startfrom*$resultsperpage, $resultsperpage,$orderby);
+
+ ($template, $loggedinuser, $cookie)
+ = get_template_and_user({template_name => "authorities/auth_finder.tmpl",
+ query => $query,
+ type => 'intranet',
+ authnotrequired => 0,
+ flagsrequired => {borrowers => 1},
+ flagsrequired => {catalogue => 1},
+ debug => 1,
+ });
+
+ # multi page display gestion
+ my $displaynext=0;
+ my $displayprev=$startfrom;
+ if(($total - (($startfrom+1)*($resultsperpage))) > 0 ){
+ $displaynext = 1;
+ }
+
+ my @field_data = ();
+
+
+ for(my $i = 0 ; $i <= $#marclist ; $i++)
+ {
+ push @field_data, { term => "marclist", val=>$marclist[$i] };
+ push @field_data, { term => "and_or", val=>$and_or[$i] };
+ push @field_data, { term => "excluding", val=>$excluding[$i] };
+ push @field_data, { term => "operator", val=>$operator[$i] };
+ push @field_data, { term => "value", val=>$value[$i] };
+ }
+
+ my @numbers = ();
+
+ if ($total>$resultsperpage)
+ {
+ for (my $i=1; $i<$total/$resultsperpage+1; $i++)
+ {
+ if ($i<16)
+ {
+ my $highlight=0;
+ ($startfrom==($i-1)) && ($highlight=1);
+ push @numbers, { number => $i,
+ highlight => $highlight ,
+ searchdata=> \@field_data,
+ startfrom => ($i-1)};
+ }
+ }
+ }
+
+ my $from = $startfrom*$resultsperpage+1;
+ my $to;
+
+ if($total < (($startfrom+1)*$resultsperpage))
+ {
+ $to = $total;
+ } else {
+ $to = (($startfrom+1)*$resultsperpage);
+ }
+ $template->param(result => $results,
+ startfrom=> $startfrom,
+ displaynext=> $displaynext,
+ displayprev=> $displayprev,
+ resultsperpage => $resultsperpage,
+ startfromnext => $startfrom+1,
+ startfromprev => $startfrom-1,
+ searchdata=>\@field_data,
+ total=>$total,
+ from=>$from,
+ to=>$to,
+ numbers=>\@numbers,
+ );
+
+} else {
+ ($template, $loggedinuser, $cookie)
+ = get_template_and_user({template_name => "authorities/auth_finder.tmpl",
+ query => $query,
+ type => 'intranet',
+ authnotrequired => 0,
+ flagsrequired => {catalogue => 1},
+ debug => 1,
+ });
+
+}
+
+$template->param(authtypesloop => \@authtypesloop);
+
+# Print the page
+output_html_with_http_headers $query, $cookie, $template->output;
+
+# Local Variables:
+# tab-width: 4
+# End:
diff --git a/authorities/authorities-home.pl b/authorities/authorities-home.pl
index 3b3d78be8c..3737e434c8 100755
--- a/authorities/authorities-home.pl
+++ b/authorities/authorities-home.pl
@@ -33,63 +33,6 @@ use C4::SearchMarc;
use C4::Catalogue;
use C4::Koha; # XXX subfield_is_koha_internal_p
-# Creates the list of active tags using the active MARC configuration
-sub create_marclist {
- my $dbh = C4::Context->dbh;
- my $tagslib = AUTHgettagslib($dbh,1);
- my @marcarray;
- push @marcarray,"";
- my $widest_menu_item_width = 0;
- for (my $pass = 1; $pass <= 2; $pass += 1)
- {
- for (my $tabloop = 0; $tabloop<=9;$tabloop++)
- {
- my $separator_inserted_p = 0; # FIXME... should not use!!
- foreach my $tag (sort(keys (%{$tagslib})))
- {
- foreach my $subfield (sort(keys %{$tagslib->{$tag}}))
- {
- next if subfield_is_koha_internal_p($subfield);
- next unless ($tagslib->{$tag}->{$subfield}->{tab} eq $tabloop);
- my $menu_item = "$tag$subfield - $tagslib->{$tag}->{$subfield}->{lib}";
- if ($pass == 1)
- {
- $widest_menu_item_width = length $menu_item if($widest_menu_item_width < length $menu_item);
- } else {
- if (!$separator_inserted_p)
- {
- my $w = int(($widest_menu_item_width - 3 + 0.5)/2);
- my $s = ('-' x ($w * 4/5));
- push @marcarray, "$s $tabloop $s";
- $separator_inserted_p = 1;
- }
- push @marcarray, $menu_item;
- }
- }
- }
- }
- }
- return \@marcarray;
-}
-
-# Creates a scrolling list with the associated default value.
-# Using more than one scrolling list in a CGI assigns the same default value to all the
-# scrolling lists on the page !?!? That's why this function was written.
-sub create_scrolling_list {
- my ($params) = @_;
- my $scrollist = sprintf("\n";
-
- return $scrollist;
-}
-
my $query=new CGI;
my $op = $query->param('op');
my $authtypecode = $query->param('authtypecode');
@@ -108,7 +51,6 @@ foreach my $thisauthtype (keys %$authtypes) {
selected => $selected,
authtypetext => $authtypes->{$thisauthtype}{'authtypetext'},
);
- warn "X = $authtypes->{$thisauthtype}{'authtypetext'}";
push @authtypesloop, \%row;
}
@@ -121,30 +63,14 @@ if ($op eq "do_search") {
$resultsperpage= $query->param('resultsperpage');
$resultsperpage = 19 if(!defined $resultsperpage);
- my $orderby = $query->param('orderby');
-
- # builds tag and subfield arrays
my @tags;
- foreach my $marc (@marclist) {
- if ($marc) {
- my ($tag,$subfield) = MARCfind_marc_from_kohafield($dbh,$marc);
- if ($tag) {
- push @tags,$dbh->quote("$tag$subfield");
- } else {
- push @tags, $dbh->quote(substr($marc,0,4));
- }
- } else {
- push @tags, "";
- }
- }
- findseealso($dbh,\@tags);
- my ($results,$total) = catalogsearch($dbh, \@tags,\@and_or,
+ my ($results,$total) = authoritysearch($dbh, \@tags,\@and_or,
\@excluding, \@operator, \@value,
- $startfrom*$resultsperpage, $resultsperpage,$orderby);
-
+ $startfrom*$resultsperpage, $resultsperpage,$authtypecode);
+ warn "R : $results";
($template, $loggedinuser, $cookie)
- = get_template_and_user({template_name => "authorities/authorities-home.tmpl",
+ = get_template_and_user({template_name => "authorities/searchresultlist.tmpl",
query => $query,
type => 'intranet',
authnotrequired => 0,
@@ -199,7 +125,8 @@ if ($op eq "do_search") {
} else {
$to = (($startfrom+1)*$resultsperpage);
}
- $template->param(result => $results,
+ $template->param(result => $results) if $results;
+ $template->param(
startfrom=> $startfrom,
displaynext=> $displaynext,
displayprev=> $displayprev,
@@ -296,64 +223,7 @@ else {
flagsrequired => {catalogue => 1},
debug => 1,
});
- #$template->param(loggedinuser => $loggedinuser);
- my $marcarray = create_marclist();
-
- my $marclist = CGI::scrolling_list(-name=>"marclist",
- -values=> $marcarray,
- -size=>1,
- -multiple=>0,
- -onChange => "sql_update()",
- );
-
- my @statements = ();
-
- # Considering initial search with 3 criterias
- push @statements, { "marclist" => $marclist, "first" => 1 };
- push @statements, { "marclist" => $marclist, "first" => 0 };
- push @statements, { "marclist" => $marclist, "first" => 0 };
- my $sth=$dbh->prepare("Select itemtype,description from itemtypes order by description");
- $sth->execute;
- my @itemtype;
- my %itemtypes;
- push @itemtype, "";
- $itemtypes{''} = "";
- while (my ($value,$lib) = $sth->fetchrow_array) {
- push @itemtype, $value;
- $itemtypes{$value}=$lib;
- }
-
- my $CGIitemtype=CGI::scrolling_list( -name => 'value',
- -values => \@itemtype,
- -labels => \%itemtypes,
- -size => 1,
- -multiple => 0 );
- $sth->finish;
-
- my @branches;
- my @select_branch;
- my %select_branches;
- my ($count2,@branches)=branches();
- push @select_branch, "";
- $select_branches{''} = "";
- for (my $i=0;$i<$count2;$i++){
- push @select_branch, $branches[$i]->{'branchcode'};#
- $select_branches{$branches[$i]->{'branchcode'}} = $branches[$i]->{'branchname'};
- }
- my $CGIbranch=CGI::scrolling_list( -name => 'value',
- -values => \@select_branch,
- -labels => \%select_branches,
- -size => 1,
- -multiple => 0 );
- $sth->finish;
-
-
- $template->param("statements" => \@statements,
- "nbstatements" => 3,
- CGIitemtype => $CGIitemtype,
- CGIbranch => $CGIbranch,
- );
}
$template->param(authtypesloop => \@authtypesloop);
diff --git a/authorities/authorities.pl b/authorities/authorities.pl
index 98c2470d36..391a42efbe 100755
--- a/authorities/authorities.pl
+++ b/authorities/authorities.pl
@@ -172,6 +172,7 @@ sub build_tabs ($$$$) {
my @loop_data = ();
foreach my $tag (sort(keys (%{$tagslib}))) {
my $indicator;
+# warn "TAG : $tag => ".$tagslib->{$tag}->{lib}."//";
# if MARC::Record is not empty => use it as master loop, then add missing subfields that should be in the tab.
# if MARC::Record is empty => use tab as master loop.
if ($record ne -1 && $record->field($tag)) {
@@ -285,9 +286,11 @@ my $error = $input->param('error');
my $authid=$input->param('authid'); # if authid exists, it's a modif, not a new authority.
my $z3950 = $input->param('z3950');
my $op = $input->param('op');
+# warn "OP : $op";
my $authtypecode = $input->param('authtypecode');
my $dbh = C4::Context->dbh;
$authtypecode = &AUTHfind_authtypecode($dbh,$authid) if $authid;
+# warn "authtypecode : $authtypecode && authid = $authid";
my ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name => "authorities/authorities.tmpl",
query => $input,
@@ -300,11 +303,11 @@ my ($template, $loggedinuser, $cookie)
$tagslib = AUTHgettagslib($dbh,1,$authtypecode);
my $record=-1;
my $encoding="";
-$record = AUTHgetauth($dbh,$authid) if ($authid);
+$record = AUTHgetauthority($dbh,$authid) if ($authid);
$is_a_modif=0;
-my ($oldbiblionumtagfield,$oldbiblionumtagsubfield);
-my ($oldbiblioitemnumtagfield,$oldbiblioitemnumtagsubfield,$bibitem,$oldbiblioitemnumber);
+# my ($oldbiblionumtagfield,$oldbiblionumtagsubfield);
+# my ($oldbiblioitemnumtagfield,$oldbiblioitemnumtagsubfield,$bibitem,$oldbiblioitemnumber);
if ($authid) {
$is_a_modif=1;
# if it's a modif, retrieve old biblio and bibitem numbers for the future modification of old-DB.
@@ -331,6 +334,7 @@ if ($op eq "add") {
}
my $record = AUTHhtml2marc($dbh,\@tags,\@subfields,\@values,%indicators);
# MARC::Record built => now, record in DB
+ warn "IN ADD : ".$record->as_formatted();
if ($is_a_modif) {
AUTHmodauthority($dbh,$record,$authid,$authtypecode);
} else {
@@ -384,30 +388,40 @@ if ($op eq "add") {
build_tabs ($template, $record, $dbh,$encoding);
build_hidden_data;
$template->param(
- authid => $authid,
- oldbiblionumtagfield => $oldbiblionumtagfield,
- oldbiblionumtagsubfield => $oldbiblionumtagsubfield,
- oldbiblioitemnumtagfield => $oldbiblioitemnumtagfield,
- oldbiblioitemnumtagsubfield => $oldbiblioitemnumtagsubfield,
- oldbiblioitemnumber => $oldbiblioitemnumber );
+ authid => $authid,);
+# oldbiblionumtagfield => $oldbiblionumtagfield,
+# oldbiblionumtagsubfield => $oldbiblionumtagsubfield,
+# oldbiblioitemnumtagfield => $oldbiblioitemnumtagfield,
+# oldbiblioitemnumtagsubfield => $oldbiblioitemnumtagsubfield,
+# oldbiblioitemnumber => $oldbiblioitemnumber );
} elsif ($op eq "delete") {
#------------------------------------------------------------------------------------------------------------------------------
&AUTHdelauthority($dbh,$authid);
}
-#------------------------------------------------------------------------------------------------------------------------------
-#------------------------------------------------------------------------------------------------------------------------------
-# MAIN
-#------------------------------------------------------------------------------------------------------------------------------
+
build_tabs ($template, $record, $dbh,$encoding);
build_hidden_data;
$template->param(
authid => $authid,
- oldbiblionumtagfield => $oldbiblionumtagfield,
- oldbiblionumtagsubfield => $oldbiblionumtagsubfield,
- oldbiblioitemnumtagfield => $oldbiblioitemnumtagfield,
- oldbiblioitemnumtagsubfield => $oldbiblioitemnumtagsubfield,
- oldbiblioitemnumber => $oldbiblioitemnumber );
-$template->param(
- authtypecode => $authtypecode,
- );
+# oldbiblionumtagfield => $oldbiblionumtagfield,
+# oldbiblionumtagsubfield => $oldbiblionumtagsubfield,
+# oldbiblioitemnumtagfield => $oldbiblioitemnumtagfield,
+# # oldbiblioitemnumtagsubfield => $oldbiblioitemnumtagsubfield,
+# oldbiblioitemnumber => $oldbiblioitemnumber,
+ authtypecode => $authtypecode,
+ );
+
+ my $authtypes = getauthtypes;
+my @authtypesloop;
+foreach my $thisauthtype (keys %$authtypes) {
+ my $selected = 1 if $thisauthtype eq $authtypecode;
+ my %row =(value => $thisauthtype,
+ selected => $selected,
+ authtypetext => $authtypes->{$thisauthtype}{'authtypetext'},
+ );
+ warn "X = $authtypes->{$thisauthtype}{'authtypetext'}";
+ push @authtypesloop, \%row;
+}
+
+$template->param(authtypesloop => \@authtypesloop);
output_html_with_http_headers $input, $cookie, $template->output;
\ No newline at end of file
diff --git a/authorities/detail.pl b/authorities/detail.pl
new file mode 100755
index 0000000000..4e7d0e23c1
--- /dev/null
+++ b/authorities/detail.pl
@@ -0,0 +1,183 @@
+#!/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
+
+=head1 NAME
+
+etail.pl : script to show an authority in MARC format
+
+=head1 SYNOPSIS
+
+
+=head1 DESCRIPTION
+
+This script needs an authid
+
+It shows the authority in a (nice) MARC format depending on authority MARC
+parameters tables.
+
+=head1 FUNCTIONS
+
+=over 2
+
+=cut
+
+
+use strict;
+require Exporter;
+use C4::AuthoritiesMarc;
+use C4::Auth;
+use C4::Context;
+use C4::Output;
+use C4::Interface::CGI::Output;
+use CGI;
+use C4::Search;
+use MARC::Record;
+use C4::Koha;
+# use C4::Biblio;
+# use C4::Catalogue;
+use HTML::Template;
+
+my $query=new CGI;
+
+my $dbh=C4::Context->dbh;
+
+my $authid = $query->param('authid');
+my $authtypecode = &AUTHfind_authtypecode($dbh,$authid);
+my $tagslib = &AUTHgettagslib($dbh,1,$authtypecode);
+
+my $record =AUTHgetauthority($dbh,$authid);
+# open template
+my ($template, $loggedinuser, $cookie)
+ = get_template_and_user({template_name => "authorities/detail.tmpl",
+ query => $query,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => {catalogue => 1},
+ debug => 1,
+ });
+
+# fill arrays
+my @loop_data =();
+my $tag;
+# loop through each tab 0 through 9
+# for (my $tabloop = 0; $tabloop<=10;$tabloop++) {
+# loop through each tag
+ my @fields = $record->fields();
+ my @loop_data =();
+ foreach my $field (@fields) {
+ my @subfields_data;
+ # if tag <10, there's no subfield, use the "@" trick
+ if ($field->tag()<10) {
+# next if ($tagslib->{$field->tag()}->{'@'}->{tab} ne $tabloop);
+ next if ($tagslib->{$field->tag()}->{'@'}->{hidden});
+ my %subfield_data;
+ $subfield_data{marc_lib}=$tagslib->{$field->tag()}->{'@'}->{lib};
+ $subfield_data{marc_value}=$field->data();
+ $subfield_data{marc_subfield}='@';
+ $subfield_data{marc_tag}=$field->tag();
+ push(@subfields_data, \%subfield_data);
+ } else {
+ my @subf=$field->subfields;
+ # loop through each subfield
+ for my $i (0..$#subf) {
+ $subf[$i][0] = "@" unless $subf[$i][0];
+# next if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab} ne $tabloop);
+ next if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{hidden});
+ my %subfield_data;
+ $subfield_data{marc_lib}=$tagslib->{$field->tag()}->{$subf[$i][0]}->{lib};
+ if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{isurl}) {
+ $subfield_data{marc_value}="$subf[$i][1]";
+ } else {
+ $subfield_data{marc_value}=$subf[$i][1];
+ }
+ $subfield_data{marc_subfield}=$subf[$i][0];
+ $subfield_data{marc_tag}=$field->tag();
+ push(@subfields_data, \%subfield_data);
+ }
+ }
+ if ($#subfields_data>=0) {
+ my %tag_data;
+ $tag_data{tag}=$field->tag().' -'. $tagslib->{$field->tag()}->{lib};
+ $tag_data{subfield} = \@subfields_data;
+ push (@loop_data, \%tag_data);
+ }
+ }
+ $template->param("0XX" =>\@loop_data);
+# }
+# now, build item tab !
+# the main difference is that datas are in lines and not in columns : thus, we build the
- + + +
++ + "> - -
-- - - - - - -
-- - - - - -
-- - - - - - -
-- - - - - - -
-- - - - - -
-- - - - - -
-- - - - - - -
- -- - - - - value=""> -
- -- -
- Warning : the "contains" statement does NOT work if you enter 2 or less letters -+ +
+ ++ + +
+ + +