[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] koha cataloguing/addbiblio.pl cataloguing/addit...
From: |
Antoine Farnault |
Subject: |
[Koha-cvs] koha cataloguing/addbiblio.pl cataloguing/addit... |
Date: |
Tue, 31 Jul 2007 16:03:10 +0000 |
CVSROOT: /sources/koha
Module name: koha
Changes by: Antoine Farnault <toins> 07/07/31 16:03:10
Modified files:
cataloguing : addbiblio.pl additem.pl
koha-tmpl/intranet-tmpl/prog/en/cataloguing: addbiblio.tmpl
koha-tmpl/intranet-tmpl/prog/en/includes: intranet2.css
Log message:
addbiblio cleaned.
TODO: There is still a encoding pb when modifying a biblio.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/cataloguing/addbiblio.pl?cvsroot=koha&r1=1.30&r2=1.31
http://cvs.savannah.gnu.org/viewcvs/koha/cataloguing/additem.pl?cvsroot=koha&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/prog/en/cataloguing/addbiblio.tmpl?cvsroot=koha&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/prog/en/includes/intranet2.css?cvsroot=koha&r1=1.5&r2=1.6
Patches:
Index: cataloguing/addbiblio.pl
===================================================================
RCS file: /sources/koha/koha/cataloguing/addbiblio.pl,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- cataloguing/addbiblio.pl 20 Jul 2007 16:38:21 -0000 1.30
+++ cataloguing/addbiblio.pl 31 Jul 2007 16:03:09 -0000 1.31
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# $Id: addbiblio.pl,v 1.30 2007/07/20 16:38:21 hdl Exp $
+# $Id: addbiblio.pl,v 1.31 2007/07/31 16:03:09 toins Exp $
# Copyright 2000-2002 Katipo Communications
#
@@ -21,8 +21,8 @@
use strict;
use CGI;
-use C4::Auth;
use C4::Output;
+use C4::Auth;
use C4::Biblio;
use C4::Search;
use C4::AuthoritiesMarc;
@@ -31,54 +31,14 @@
use C4::Log;
use C4::Koha; # XXX subfield_is_koha_internal_p
use Date::Calc qw(Today);
-
use MARC::File::USMARC;
use MARC::File::XML;
-if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
- MARC::File::XML->default_record_format( 'UNIMARC' );
-}
-
-use vars qw( $tagslib);
-use vars qw( $authorised_values_sth);
-use vars qw( $is_a_modif );
-
-my $itemtype; # created here because it can be used in
build_authorized_values_list sub
-
-=item find_value
-
- ($indicators, $value) = find_value($tag, $subfield, $record,$encoding);
-
-Find the given $subfield in the given $tag in the given
-MARC::Record $record. If the subfield is found, returns
-the (indicators, value) pair; otherwise, (undef, undef) is
-returned.
-
-=cut
-sub find_value {
- my ($tagfield,$insubfield,$record,$encoding) = @_;
- my @result;
- my $indicator;
- if ($tagfield <10) {
- if ($record->field($tagfield)) {
- push @result, $record->field($tagfield)->data();
- } else {
- push @result,"";
- }
- } else {
- foreach my $field ($record->field($tagfield)) {
- my @subfields = $field->subfields();
- foreach my $subfield (@subfields) {
- if (@$subfield[0] eq $insubfield) {
- push @result,@$subfield[1];
- $indicator = $field->indicator(1).$field->indicator(2);
- }
- }
- }
- }
- return($indicator,@result);
+if ( C4::Context->preference('marcflavour') eq 'UNIMARC' ) {
+ MARC::File::XML->default_record_format('UNIMARC');
}
+our($tagslib,$authorised_values_sth,$is_a_modif,$usedTagsLib,$mandatory_z3950);
=item MARCfindbreeding
@@ -92,89 +52,108 @@
=cut
sub MARCfindbreeding {
- my ($dbh,$id) = @_;
- my $sth = $dbh->prepare("select file,marc,encoding from marc_breeding
where id=?");
+ my ( $dbh, $id ) = @_;
+ my $sth =
+ $dbh->prepare("select file,marc,encoding from marc_breeding where id=?");
$sth->execute($id);
- my ($file,$marc,$encoding) = $sth->fetchrow;
+ my ( $file, $marc, $encoding ) = $sth->fetchrow;
if ($marc) {
my $record = MARC::Record->new_from_usmarc($marc);
- if ($record->field('010')){
- foreach my $field ($record->field('010'))
- {
- foreach my $subfield ($field->subfield('a')){
+ if ( $record->field('010') ) {
+ foreach my $field ( $record->field('010') ) {
+ foreach my $subfield ( $field->subfield('a') ) {
my $newisbn = $field->subfield('a');
$newisbn =~ s/-//g;
$field->update( 'a' => $newisbn );
}
- # $record->insert_fields_ordered($record->field('010'));
+ # record->insert_fields_ordered($record->field('010'));
}
}
+
if ($record->subfield(100,'a')) {
my $f100a=$record->subfield(100,'a');
my $f100 = $record->field(100);
my $f100temp = $f100->as_string;
$record->delete_field($f100);
- if (length($f100temp)>28) {
- substr($f100temp,26,2,"50");
- $f100->update('a' => $f100temp);
- my $f100 = MARC::Field->new('100','','','a' => $f100temp);
+ if ( length($f100temp) > 28 ) {
+ substr( $f100temp, 26, 2, "50" );
+ $f100->update( 'a' => $f100temp );
+ my $f100 = MARC::Field->new( '100', '', '', 'a' => $f100temp );
$record->insert_fields_ordered($f100);
}
}
- if (ref($record) eq undef) {
+
+ if ( ref($record) eq undef ) {
return -1;
- } else {
- if (C4::Context->preference("z3950NormalizeAuthor") and
C4::Context->preference("z3950AuthorAuthFields")){
- my ($tag,$subfield) = GetMarcFromKohaField("biblio.author");
-# my $summary = C4::Context->preference("z3950authortemplate");
- my $auth_fields =
C4::Context->preference("z3950AuthorAuthFields");
- my @auth_fields= split /,/,$auth_fields;
+ }
+ else {
+ if ( C4::Context->preference("z3950NormalizeAuthor")
+ and C4::Context->preference("z3950AuthorAuthFields") )
+ {
+ my ( $tag, $subfield ) = GetMarcFromKohaField("biblio.author");
+
+ # my $summary =
C4::Context->preference("z3950authortemplate");
+ my $auth_fields =
+ C4::Context->preference("z3950AuthorAuthFields");
+ my @auth_fields = split /,/, $auth_fields;
my $field;
- #warn $record->as_formatted;
- if ($record->field($tag)){
- foreach my $tmpfield ($record->field($tag)->subfields){
-# foreach my $subfieldcode ($tmpfield->subfields){
- my $subfieldcode=shift @$tmpfield;
- my $subfieldvalue=shift @$tmpfield;
- if ($field){
-
$field->add_subfields("$subfieldcode"=>$subfieldvalue) if ($subfieldcode ne
$subfield);
- } else {
-
$field=MARC::Field->new($tag,"","",$subfieldcode=>$subfieldvalue) if
($subfieldcode ne $subfield);
+
+ if ( $record->field($tag) ) {
+ foreach my $tmpfield ( $record->field($tag)->subfields ) {
+
+ # foreach my $subfieldcode
($tmpfield->subfields){
+ my $subfieldcode = shift @$tmpfield;
+ my $subfieldvalue = shift @$tmpfield;
+ if ($field) {
+ $field->add_subfields(
+ "$subfieldcode" => $subfieldvalue )
+ if ( $subfieldcode ne $subfield );
}
+ else {
+ $field =
+ MARC::Field->new( $tag, "", "",
+ $subfieldcode => $subfieldvalue )
+ if ( $subfieldcode ne $subfield );
}
-# warn $field->as_formatted;
-# }
}
- $record->delete_field($record->field($tag));
- foreach my $fieldtag (@auth_fields){
- next unless ($record->field($fieldtag));
+ }
+ $record->delete_field( $record->field($tag) );
+ foreach my $fieldtag (@auth_fields) {
+ next unless ( $record->field($fieldtag) );
my $lastname = $record->field($fieldtag)->subfield('a');
- my $firstname= $record->field($fieldtag)->subfield('b');
+ my $firstname = $record->field($fieldtag)->subfield('b');
my $title = $record->field($fieldtag)->subfield('c');
- my $number= $record->field($fieldtag)->subfield('d');
- if ($title){
+ my $number = $record->field($fieldtag)->subfield('d');
+ if ($title) {
+
# $field->add_subfields("$subfield"=>"[
".ucfirst($title).ucfirst($firstname)." ".$number." ]");
- $field->add_subfields("$subfield"=>ucfirst($title)."
".ucfirst($firstname)." ".$number);
- }else{
+ $field->add_subfields(
+ "$subfield" => ucfirst($title) . " "
+ . ucfirst($firstname) . " "
+ . $number );
+ }
+ else {
+
# $field->add_subfields("$subfield"=>"[
".ucfirst($firstname).", ".ucfirst($lastname)." ]");
-
$field->add_subfields("$subfield"=>ucfirst($firstname).", ".ucfirst($lastname));
+ $field->add_subfields(
+ "$subfield" => ucfirst($firstname) . ", "
+ . ucfirst($lastname) );
}
}
$record->insert_fields_ordered($field);
}
- return $record,$encoding;
+ return $record, $encoding;
}
}
return -1;
}
-
=item build_authorized_values_list
=cut
-sub build_authorized_values_list ($$$$$) {
- my($tag, $subfield, $value, $dbh,$authorised_values_sth) = @_;
+sub build_authorized_values_list ($$$$$$$) {
+ my ( $tag, $subfield, $value, $dbh,
$authorised_values_sth,$index_tag,$index_subfield ) = @_;
my @authorised_values;
my %authorised_lib;
@@ -182,47 +161,95 @@
# builds list, depending on authorised value...
#---- branch
- if ($tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
- my $sth=$dbh->prepare("select branchcode,branchname from branches order by
branchname");
+ if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
+ my $sth =
+ $dbh->prepare(
+ "select branchcode,branchname from branches order by branchname");
$sth->execute;
push @authorised_values, ""
- unless ($tagslib->{$tag}->{$subfield}->{mandatory});
+ unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
- while (my ($branchcode,$branchname) = $sth->fetchrow_array) {
+ while ( my ( $branchcode, $branchname ) = $sth->fetchrow_array ) {
push @authorised_values, $branchcode;
- $authorised_lib{$branchcode}=$branchname;
+ $authorised_lib{$branchcode} = $branchname;
}
#----- itemtypes
- } elsif ($tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes")
{
- my $sth=$dbh->prepare("select itemtype,description from itemtypes
order by description");
+ }
+ elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" )
{
+ my $sth =
+ $dbh->prepare(
+ "select itemtype,description from itemtypes order by description");
$sth->execute;
- push @authorised_values, "" unless
($tagslib->{$tag}->{$subfield}->{mandatory});
+ push @authorised_values, ""
+ unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
- while (my ($itemtype,$description) = $sth->fetchrow_array) {
+ my $itemtype;
+
+ while ( my ( $itemtype, $description ) = $sth->fetchrow_array ) {
push @authorised_values, $itemtype;
- $authorised_lib{$itemtype}=$description;
+ $authorised_lib{$itemtype} = $description;
}
- $value=$itemtype unless ($value);
+ $value = $itemtype unless ($value);
#---- "true" authorised value
- } else {
-
$authorised_values_sth->execute($tagslib->{$tag}->{$subfield}->{authorised_value});
+ }
+ else {
+ $authorised_values_sth->execute(
+ $tagslib->{$tag}->{$subfield}->{authorised_value} );
- push @authorised_values, "" unless
($tagslib->{$tag}->{$subfield}->{mandatory});
+ push @authorised_values, ""
+ unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
- while (my ($value,$lib) = $authorised_values_sth->fetchrow_array) {
+ while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array )
{
push @authorised_values, $value;
- $authorised_lib{$value}=$lib;
+ $authorised_lib{$value} = $lib;
}
}
- return CGI::scrolling_list( -name => 'field_value',
+ return CGI::scrolling_list(
+ -name =>
"tag_".$tag."_subfield_".$subfield."_".$index_tag."_".$index_subfield,
-values => address@hidden,
-default => $value,
-labels => \%authorised_lib,
-override => 1,
-size => 1,
- -multiple => 0 );
+ -multiple => 0,
+ -tabindex => 1,
+ -id =>
"tag_".$tag."_subfield_".$subfield."_".$index_tag."_".$index_subfield,
+ -class => "input_marceditor",
+ );
+}
+
+=item CreateKey
+
+ Create a random value to set it into the input name
+
+=cut
+
+sub CreateKey(){
+ return int(rand(1000000));
+}
+
+=item GetMandatoryFieldZ3950
+
+ This function return an hashref which containts all mandatory field
+ to search with z3950 server.
+
+=cut
+
+sub GetMandatoryFieldZ3950($){
+ my $frameworkcode = shift;
+ my @isbn = GetMarcFromKohaField('biblioitems.isbn',$frameworkcode);
+ my @title = GetMarcFromKohaField('biblio.title',$frameworkcode);
+ my @author = GetMarcFromKohaField('biblio.author',$frameworkcode);
+ my @issn = GetMarcFromKohaField('biblioitems.issn',$frameworkcode);
+
+ return {
+ $isbn[0].$isbn[1] => 'isbn',
+ $title[0].$title[1] => 'title',
+ $author[0].$author[1] => 'author',
+ $issn[0].$issn[1] => 'issn',
+ };
}
=item create_input
@@ -231,275 +258,335 @@
=cut
-sub create_input () {
- my ($tag,$subfield,$value,$i,$tabloop,$rec,$authorised_values_sth) = @_;
- # must be encoded as utf-8 before it reaches the editor
- #use Encode;
- #$value = encode('utf-8', $value);
+sub create_input {
+ my ( $tag, $subfield, $value, $index_tag, $tabloop, $rec,
$authorised_values_sth,$cgi ) = @_;
+
+ my $index_subfield = CreateKey(); # create a specifique key for each
subfield
+
$value =~ s/"/"/g;
+
# if there is no value provided but a default value in parameters, get it
unless ($value) {
$value = $tagslib->{$tag}->{$subfield}->{defaultvalue};
+
# get today date & replace YYYY, MM, DD if provided in the default
value
- my ($year,$month,$day) = Today();
- $month = sprintf("%02d",$month);
- $day = sprintf("%02d",$day);
+ my ( $year, $month, $day ) = Today();
+ $month = sprintf( "%02d", $month );
+ $day = sprintf( "%02d", $day );
$value =~ s/YYYY/$year/g;
$value =~ s/MM/$month/g;
$value =~ s/DD/$day/g;
-
}
my $dbh = C4::Context->dbh;
- my %subfield_data;
- $subfield_data{tag}=$tag;
- $subfield_data{subfield}=$subfield;
- $subfield_data{marc_lib}="<span id=\"error$i\"
title=\"".$tagslib->{$tag}->{$subfield}->{lib}."\">".substr($tagslib->{$tag}->{$subfield}->{lib},0,15)."</span>";
- $subfield_data{marc_lib_plain}=$tagslib->{$tag}->{$subfield}->{lib};
- $subfield_data{tag_mandatory}=$tagslib->{$tag}->{mandatory};
- $subfield_data{mandatory}=$tagslib->{$tag}->{$subfield}->{mandatory};
- $subfield_data{repeatable}=$tagslib->{$tag}->{$subfield}->{repeatable};
- $subfield_data{kohafield}=$tagslib->{$tag}->{$subfield}->{kohafield};
- $subfield_data{index} = $i;
- $subfield_data{visibility} = "display:none" unless
(($tagslib->{$tag}->{$subfield}->{hidden}%2==0) or $value ne ''); #check parity
+ my %subfield_data = (
+ tag => $tag,
+ subfield => $subfield,
+ marc_lib => substr( $tagslib->{$tag}->{$subfield}->{lib}, 0, 22 ),
+ marc_lib_plain => $tagslib->{$tag}->{$subfield}->{lib},
+ tag_mandatory => $tagslib->{$tag}->{mandatory},
+ mandatory => $tagslib->{$tag}->{$subfield}->{mandatory},
+ repeatable => $tagslib->{$tag}->{$subfield}->{repeatable},
+ kohafield => $tagslib->{$tag}->{$subfield}->{kohafield},
+ index => $index_tag,
+ id =>
"tag_".$tag."_subfield_".$subfield."_".$index_tag."_".$index_subfield,
+ value => $value,
+ );
+ if($subfield eq '@'){
+ $subfield_data{id} =
"tag_".$tag."_subfield_00_".$index_tag."_".$index_subfield;
+ } else {
+ $subfield_data{id} =
"tag_".$tag."_subfield_".$subfield."_".$index_tag."_".$index_subfield;
+ }
+
+ if(exists $mandatory_z3950->{$tag.$subfield}){
+ $subfield_data{z3950_mandatory} = $mandatory_z3950->{$tag.$subfield};
+ }
+
+ $subfield_data{visibility} = "display:none;"
+ unless ( ( $tagslib->{$tag}->{$subfield}->{hidden} % 2 == 0 )
+ or $value ne '' ); #check parity
+
# it's an authorised field
- if ($tagslib->{$tag}->{$subfield}->{authorised_value}) {
- $subfield_data{marc_value}= build_authorized_values_list($tag,
$subfield, $value, $dbh,$authorised_values_sth);
+ if ( $tagslib->{$tag}->{$subfield}->{authorised_value} ) {
+ $subfield_data{marc_value} =
+ build_authorized_values_list( $tag, $subfield, $value, $dbh,
+ $authorised_values_sth,$index_tag,$index_subfield );
+
# it's a thesaurus / authority field
- } elsif ($tagslib->{$tag}->{$subfield}->{authtypecode}) {
- $subfield_data{marc_value}="<input type=\"text\"
onblur=\"this.style.backgroundColor='#ffffff';\"
onfocus=\"this.style.backgroundColor='#ffff00;'\"\" tabindex=\"1\"
type=\"text\" name=\"field_value\" value=\"$value\" size=\"70\"
maxlength=\"255\"> <a style=\"cursor: help;\"
href=\"javascript:Dopop('../authorities/auth_finder.pl?authtypecode=".$tagslib->{$tag}->{$subfield}->{authtypecode}."&index=$i',$i)\">...</a>";
+ }
+ elsif ( $tagslib->{$tag}->{$subfield}->{authtypecode} ) {
+ $subfield_data{marc_value} =
+ "<input type=\"text\"
+ id=".$subfield_data{id}."
+ name=".$subfield_data{id}."
+ value=\"$value\"
+ class=\"input_marceditor\"
+ tabindex=\"1\"
+ DISABLE READONLY \/>
+ <span class=\"buttonDot\"
+
onclick=\"Dopop('/cgi-bin/koha/authorities/auth_finder.pl?authtypecode=".$tagslib->{$tag}->{$subfield}->{authtypecode}."&index=$subfield_data{id}','$subfield_data{id}')\">...</span>
+ ";
# it's a plugin field
- } elsif ($tagslib->{$tag}->{$subfield}->{'value_builder'}) {
+ }
+ elsif ( $tagslib->{$tag}->{$subfield}->{'value_builder'} ) {
+
# opening plugin. Just check wether we are on a developper computer on
a production one
# (the cgidir differs)
- my $cgidir = C4::Context->intranetdir
."/cgi-bin/cataloguing/value_builder";
- unless (opendir(DIR, "$cgidir")) {
- $cgidir = C4::Context->intranetdir."/cataloguing/value_builder";
+ my $cgidir = C4::Context->intranetdir .
"/cgi-bin/cataloguing/value_builder";
+ unless ( opendir( DIR, "$cgidir" ) ) {
+ $cgidir = C4::Context->intranetdir . "/cataloguing/value_builder";
}
- my
$plugin=$cgidir."/".$tagslib->{$tag}->{$subfield}->{'value_builder'};
+ my $plugin = $cgidir . "/" .
$tagslib->{$tag}->{$subfield}->{'value_builder'};
+
do $plugin;
- my $extended_param = plugin_parameters($dbh,$rec,$tagslib,$i,$tabloop);
- my ($function_name,$javascript) =
plugin_javascript($dbh,$rec,$tagslib,$i,$tabloop);
- $subfield_data{marc_value}="<input tabindex=\"1\" type=\"text\"
name=\"field_value\" value=\"$value\" size=\"70\" maxlength=\"255\"
OnFocus=\"javascript:Focus$function_name($i)\"
OnBlur=\"javascript:Blur$function_name($i); \"> <a style=\"cursor: help;\"
href=\"javascript:Clic$function_name($i)\">...</a> $javascript";
+ my $extended_param = plugin_parameters( $dbh, $rec, $tagslib,
$subfield_data{id}, $tabloop );
+ my ( $function_name, $javascript ) = plugin_javascript( $dbh, $rec,
$tagslib, $subfield_data{id}, $tabloop );
+# my ( $function_name, $javascript,$extended_param );
+
+ $subfield_data{marc_value} =
+ "<input tabindex=\"1\"
+ type=\"text\"
+ id=".$subfield_data{id}."
+ name=".$subfield_data{id}."
+ value=\"$value\"
+ class=\"input_marceditor\"
+ onfocus=\"javascript:Focus$function_name($index_tag)\"
+ onblur=\"javascript:Blur$function_name($index_tag); \"
\/>
+ <span class=\"buttonDot\"
+
onclick=\"Clic$function_name('$subfield_data{id}')\">...</a>
+ $javascript";
# it's an hidden field
- } elsif ($tag eq '') {
- $subfield_data{marc_value}="<input
onblur=\"this.style.backgroundColor='#ffffff';\"
onfocus=\"this.style.backgroundColor='#ffff00'; \" tabindex=\"1\"
type=\"hidden\" name=\"field_value\" value=\"$value\">";
- } elsif ($tagslib->{$tag}->{$subfield}->{'hidden'}) {
- $subfield_data{marc_value}="<input
onblur=\"this.style.backgroundColor='#ffffff';\"
onfocus=\"this.style.backgroundColor='#ffff00'; \" tabindex=\"1\" type=\"text\"
name=\"field_value\" value=\"$value\" size=\"70\" maxlength=\"255\" >";
+ }
+ elsif ( $tag eq '' ) {
+ $subfield_data{marc_value} =
+ "<input tabindex=\"1\"
+ type=\"hidden\"
+ id=".$subfield_data{id}."
+ name=".$subfield_data{id}."
+ value=\"$value\" \/>
+ ";
+ }
+ elsif ( $tagslib->{$tag}->{$subfield}->{'hidden'} ) {
+ $subfield_data{marc_value} =
+ "<input type=\"text\"
+ id=".$subfield_data{id}."
+ name=".$subfield_data{id}."
+ class=\"input_marceditor\"
+ tabindex=\"1\"
+ value=\"$value\"
+ \/>";
+
# it's a standard field
- } else {
- if (length($value) >100 or (C4::Context->preference("marcflavour") eq
"UNIMARC" && $tag >=300 and $tag <400 && $subfield eq 'a') or ($tag >=500 and
$tag <600 && C4::Context->preference("marcflavour") eq "MARC21")) {
- $subfield_data{marc_value}="<textarea tabindex=\"1\"
name=\"field_value\" cols=\"70\" rows=\"5\" >$value</textarea>";
- } else {
- $subfield_data{marc_value}="<input
onblur=\"this.style.backgroundColor='#ffffff';\"
onfocus=\"this.style.backgroundColor='#ffff00'; \" tabindex=\"1\" type=\"text\"
name=\"field_value\" value=\"$value\" size=\"70\">"; #"
+ }
+ else {
+ if (
+ length($value) > 100
+ or
+ ( C4::Context->preference("marcflavour") eq "UNIMARC" && $tag >=
300
+ and $tag < 400 && $subfield eq 'a' )
+ or ( $tag >= 500
+ and $tag < 600
+ && C4::Context->preference("marcflavour") eq "MARC21" )
+ )
+ {
+ $subfield_data{marc_value} =
+ "<textarea cols=\"70\"
+ rows=\"4\"
+ id=".$subfield_data{id}."
+ name=".$subfield_data{id}."
+ class=\"input_marceditor\"
+ tabindex=\"1\"
+ >$value</textarea>
+ ";
+ }
+ else {
+ $subfield_data{marc_value} =
+ "<input type=\"text\"
+ id=".$subfield_data{id}."
+ name=".$subfield_data{id}."
+ value=\"$value\"
+ tabindex=\"1\"
+ class=\"input_marceditor\"
+ \/>
+ ";
}
}
+ $subfield_data{'index_subfield'} = $index_subfield;
return \%subfield_data;
}
-sub build_tabs ($$$$) {
- my($template, $record, $dbh,$encoding) = @_;
+sub build_tabs ($$$$$) {
+ my ( $template, $record, $dbh, $encoding,$input ) = @_;
+
# fill arrays
- my @loop_data =();
+ my @loop_data = ();
my $tag;
- my $i=0;
- my $authorised_values_sth = $dbh->prepare("select authorised_value,lib
+
+ my $authorised_values_sth = $dbh->prepare(
+ "select authorised_value,lib
from authorised_values
- where category=? order by lib");
+ where category=? order by lib"
+ );
# in this array, we will push all the 10 tabs
# to avoid having 10 tabs in the template : they will all be in the same
BIG_LOOP
my @BIG_LOOP;
+ my %seen;
+ my @tab_data; # all tags to display
-# loop through each tab 0 through 9
- for (my $tabloop = 0; $tabloop <= 9; $tabloop++) {
- my @loop_data = ();
- foreach my $tag (sort(keys (%{$tagslib}))) {
+ foreach my $used ( @$usedTagsLib ){
+ push @tab_data,$used->{tagfield} if not $seen{$used->{tagfield}};
+ $seen{$used->{tagfield}}++;
+ }
+
+ my $max_num_tab=-1;
+ foreach(@$usedTagsLib){
+ if($_->{tab} > -1 && $_->{tab} >= $max_num_tab && $_->{tagfield} !=
'995'){ # FIXME : MARC21 ?
+ $max_num_tab = $_->{tab};
+ }
+ }
+ if($max_num_tab >= 9){
+ $max_num_tab = 9;
+ }
+ # loop through each tab 0 through 9
+ for ( my $tabloop = 0 ; $tabloop <= $max_num_tab ; $tabloop++ ) {
+ my @loop_data = (); #innerloop in the template.
+ my $i = 0;
+ foreach my $tag (@tab_data) {
+ $i++;
+ next if ! $tag;
my $indicator;
- # if MARC::Record is not empty => use it as master loop, then add missing
subfields that should be in the tab.
+ my $index_tag = CreateKey;
+
+ # 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) || $tag eq '000')) {
+ if ( $record ne -1 && ( $record->field($tag) || $tag eq '000' ) ) {
my @fields;
- if ($tag ne '000') {
+ if ( $tag ne '000' ) {
@fields = $record->field($tag);
- } else {
- push @fields,$record->leader();
+ }
+ else {
+ push @fields, $record->leader(); # if tag == 000
}
foreach my $field (@fields) {
+
my @subfields_data;
- if ($tag<10) {
- my ($value,$subfield);
- if ($tag ne '000') {
- $value=$field->data();
- $subfield="@";
- } else {
- $value = $field;
- $subfield='@';
+ if ( $tag < 10 ) {
+ my ( $value, $subfield );
+ if ( $tag ne '000' ) {
+ $value = $field->data();
+ $subfield = "@";
}
- next if ($tagslib->{$tag}->{$subfield}->{tab} ne
$tabloop);
- next if ($tagslib->{$tag}->{$subfield}->{kohafield} eq
'biblio.biblionumber');
- push(@subfields_data,
&create_input($tag,$subfield,$value,$i,$tabloop,$record,$authorised_values_sth));
- $i++;
- } else {
- my @subfields=$field->subfields();
- foreach my $subfieldcount (0..$#subfields) {
- my $subfield=$subfields[$subfieldcount][0];
- my $value=$subfields[$subfieldcount][1];
- next if (length $subfield !=1);
- next if ($tagslib->{$tag}->{$subfield}->{tab} ne
$tabloop);
- push(@subfields_data,
&create_input($tag,$subfield,$value,$i,$tabloop,$record,$authorised_values_sth));
- $i++;
+ else {
+ $value = $field;
+ $subfield = '@';
}
+ next if ( $tagslib->{$tag}->{$subfield}->{tab} ne
$tabloop );
+ next
+ if ( $tagslib->{$tag}->{$subfield}->{kohafield} eq
+ 'biblio.biblionumber' );
+ push(
+ @subfields_data,
+ &create_input(
+ $tag, $subfield, $value, $index_tag, $tabloop,
$record,
+ $authorised_values_sth,$input
+ )
+ );
}
-# now, loop again to add parameter subfield that are not in the MARC::Record
- foreach my $subfield (sort( keys %{$tagslib->{$tag}})) {
- next if (length $subfield !=1);
- next if ($tagslib->{$tag}->{$subfield}->{tab} ne
$tabloop);
- next if ($tag<10);
- next if (($tagslib->{$tag}->{$subfield}->{hidden}<=-4)
or ($tagslib->{$tag}->{$subfield}->{hidden}>=5) ); #check for visibility flag
- next if (defined($field->subfield($subfield)));
- push(@subfields_data,
&create_input($tag,$subfield,'',$i,$tabloop,$record,$authorised_values_sth));
- $i++;
+ else {
+ my @subfields = $field->subfields();
+ foreach my $subfieldcount ( 0 .. $#subfields ) {
+ my $subfield = $subfields[$subfieldcount][0];
+ my $value = $subfields[$subfieldcount][1];
+ next if ( length $subfield != 1 );
+ next if ( $tagslib->{$tag}->{$subfield}->{tab} ne
$tabloop );
+ push(
+ @subfields_data,
+ &create_input(
+ $tag, $subfield, $value, $index_tag,
$tabloop,
+ $record, $authorised_values_sth,$input
+ )
+ );
}
- if ($#subfields_data >= 0) {
- my %tag_data;
- $tag_data{tag} = $tag;
- $tag_data{tag_lib} = $tagslib->{$tag}->{lib};
- $tag_data{repeatable} = $tagslib->{$tag}->{repeatable};
- $tag_data{indicator} =
$record->field($tag)->indicator(1). $record->field($tag)->indicator(2) if
($tag>=10);
- $tag_data{subfield_loop} = address@hidden;
- if ($tag<10) {
- $tag_data{fixedfield} = 1;
}
- push (@loop_data, \%tag_data);
- }
-# If there is more than 1 field, add an empty hidden field as separator.
- if ($#fields >=1 && $#loop_data >=0 &&
$loop_data[$#loop_data]->{'tag'} eq $tag) {
- my @subfields_data;
- my %tag_data;
- push(@subfields_data,
&create_input('','','',$i,$tabloop,$record,$authorised_values_sth));
- $tag_data{tag} = '';
- $tag_data{tag_lib} = '';
- $tag_data{indicator} = '';
- $tag_data{subfield_loop} = address@hidden;
- if ($tag<10) {
- $tag_data{fixedfield} =
1;
+ # now, loop again to add parameter subfield that are not
in the MARC::Record
+ foreach my $subfield ( sort( keys %{ $tagslib->{$tag} } ) )
+ {
+ next if ( length $subfield != 1 );
+ next if ( $tagslib->{$tag}->{$subfield}->{tab} ne
$tabloop );
+ next if ( $tag < 10 );
+ next
+ if ( ( $tagslib->{$tag}->{$subfield}->{hidden} <= -4
)
+ or ( $tagslib->{$tag}->{$subfield}->{hidden} >= 5 )
+ ); #check for visibility flag
+ next if ( defined( $field->subfield($subfield) ) );
+ push(
+ @subfields_data,
+ &create_input(
+ $tag, $subfield, '', $index_tag, $tabloop,
$record,
+ $authorised_values_sth,$input
+ )
+ );
}
- push (@loop_data, \%tag_data);
- $i++;
+ if ( $#subfields_data >= 0 ) {
+ my %tag_data = (
+ tag => $tag,
+ index => $index_tag,
+ tag_lib => $tagslib->{$tag}->{lib},
+ subfield_loop => address@hidden,
+ fixedfield => ($tag < 10)?(1):(0),
+ );
+ if ($tag >= 010){ # no indicator for theses tag
+ $tag_data{indicator} =
$field->indicator(1).$field->indicator(2);
}
+ push( @loop_data, \%tag_data );
}
+ } # foreach $field end
+
# if breeding is empty
- } else {
+ }
+ else {
my @subfields_data;
- foreach my $subfield (sort(keys %{$tagslib->{$tag}})) {
- next if (length $subfield !=1);
- next if (($tagslib->{$tag}->{$subfield}->{hidden}<=-5) or
($tagslib->{$tag}->{$subfield}->{hidden}>=4) ); #check for visibility flag
- next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
- push(@subfields_data,
&create_input($tag,$subfield,'',$i,$tabloop,$record,$authorised_values_sth));
- $i++;
+ foreach my $subfield ( sort( keys %{ $tagslib->{$tag} } ) ) {
+ next if ( length $subfield != 1 );
+ next
+ if ( ( $tagslib->{$tag}->{$subfield}->{hidden} <= -5 )
+ or ( $tagslib->{$tag}->{$subfield}->{hidden} >= 4 ) )
+ ; #check for visibility flag
+ next
+ if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
+ push(
+ @subfields_data,
+ &create_input(
+ $tag, $subfield, '', $index_tag, $tabloop, $record,
+ $authorised_values_sth,$input
+ )
+ );
}
- if ($#subfields_data >= 0) {
- my %tag_data;
- $tag_data{tag} = $tag;
- $tag_data{tag_lib} = $tagslib->{$tag}->{lib};
- $tag_data{repeatable} = $tagslib->{$tag}->{repeatable};
- $tag_data{indicator} = $indicator;
- $tag_data{subfield_loop} = address@hidden;
- $tag_data{tagfirstsubfield} = $tag_data{subfield_loop}[0];
- if ($tag<10) {
- $tag_data{fixedfield} = 1;
- }
- push (@loop_data, \%tag_data);
- }
- }
- }
- if ($#loop_data >=0) {
- my %big_loop_line;
- $big_loop_line{number}=$tabloop;
- address@hidden;
- push @BIG_LOOP,\%big_loop_line;
- }
-# $template->param($tabloop."XX" =>address@hidden);
- }
- $template->param(BIG_LOOP => address@hidden);
-}
-
-
-
-sub build_hidden_data () {
- # build hidden data =>
- # we store everything, even if we show only requested subfields.
-
- 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 ($subfield eq 'mandatory');
- next if ($subfield eq 'repeatable');
- next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "-1");
- my %subfield_data;
- $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}="<input type=\"hidden\"
name=\"field_value[]\">";
- push(@loop_data, \%subfield_data);
- $i++
+ if ( $#subfields_data >= 0 ) {
+ my %tag_data = (
+ tag => $tag,
+ index => $index_tag,
+ tag_lib => $tagslib->{$tag}->{lib},
+ repeatable => $tagslib->{$tag}->{repeatable},
+ indicator => $indicator,
+ subfield_loop => address@hidden,
+ tagfirstsubfield => $subfields_data[0],
+ fixedfield => ($tag < 10)?(1):(0)
+ );
+
+ push @loop_data, \%tag_data ;
}
}
-}
-
-
-sub BiblioAddAuthorities{
- my ( $record, $frameworkcode ) = @_;
- my $dbh=C4::Context->dbh;
- my $query=$dbh->prepare(qq|
-SELECT authtypecode,tagfield
-FROM marc_subfield_structure
-WHERE frameworkcode=?
-AND (authtypecode IS NOT NULL AND authtypecode<>\"\")|);
-# SELECT authtypecode,tagfield
-# FROM marc_subfield_structure
-# WHERE frameworkcode=?
-# AND (authtypecode IS NOT NULL OR authtypecode<>\"\")|);
- $query->execute($frameworkcode);
- my ($countcreated,$countlinked);
- while (my $data=$query->fetchrow_hashref){
- if ($record->field($data->{tagfield})){
- next if
($record->subfield($data->{tagfield},'3')||$record->subfield($data->{tagfield},'9'));
- # No authorities id in the tag.
- # Search if there is any authorities to link to.
- my $query='at='.$data->{authtypecode}.' ';
- map {$query.= " and he=\"".$_->[1]."\"" if ($_->[0]=~/[A-z]/)}
$record->field($data->{tagfield})->subfields();
- warn $query;
- my ($error,$results)=SimpleSearch($query,"authorityserver");
- # there is at least 1 result => return the 1st one
- if (@$results>1) {
- my $marcrecord = MARC::File::USMARC::decode($results->[0]);
-
$record->field($data->{tagfield})->add_subfields('9'=>$marcrecord->field('001')->data);
- $countlinked++;
- } else {
- #There are no results, build authority record, add it to Authorities, get
authid and add it to 9
- ###NOTICE : This is only valid if a subfield is linked to one and only one
authtypecode
-
-
- my $authtypedata=GetAuthType($data->{authtypecode});
- my $marcrecordauth=MARC::Record->new();
- my
$field=MARC::Field->new($authtypedata->{auth_tag_to_report},'','',"a"=>"".$record->subfield($data->{tagfield},'a'));
- map { $field->add_subfields($_->[0]=>$_->[1]) if ($_->[0]=~/[A-z]/ &&
$_->[0] ne "a" )} $record->field($data->{tagfield})->subfields();
- $marcrecordauth->insert_fields_ordered($field);
- my $authid=AddAuthority($record,'',$data->{authtypecode});
- $countcreated++;
- $record->field($data->{tagfield})->add_subfields('9'=>$authid);
}
+ if ( $#loop_data >= 0 ) {
+ push @BIG_LOOP, {
+ number => $tabloop,
+ innerloop => address@hidden,
+ };
}
}
- return ($countlinked,$countcreated);
+ $template->param( BIG_LOOP => address@hidden );
}
# ========================
@@ -507,7 +594,7 @@
#=========================
my $input = new CGI;
my $error = $input->param('error');
-my $biblionumber=$input->param('biblionumber'); # if biblionumber exists, it's
a modif, not a new biblio.
+my $biblionumber = $input->param('biblionumber'); # if biblionumber exists,
it's a modif, not a new biblio.
my $breedingid = $input->param('breedingid');
my $z3950 = $input->param('z3950');
my $op = $input->param('op');
@@ -515,32 +602,35 @@
my $frameworkcode = $input->param('frameworkcode');
my $dbh = C4::Context->dbh;
-$frameworkcode = &GetFrameworkCode($biblionumber) if ($biblionumber and not
($frameworkcode));
+$frameworkcode = &GetFrameworkCode($biblionumber)
+ if ( $biblionumber and not($frameworkcode) );
-$frameworkcode='' if ($frameworkcode eq 'Default');
-my ($template, $loggedinuser, $cookie)
- = get_template_and_user({template_name => "cataloguing/addbiblio.tmpl",
+$frameworkcode = '' if ( $frameworkcode eq 'Default' );
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ {
+ template_name => "cataloguing/addbiblio.tmpl",
query => $input,
type => "intranet",
authnotrequired => 0,
- flagsrequired => {editcatalogue => 1},
- debug => 1,
- });
+ flagsrequired => { editcatalogue => 1 },
+ }
+);
#Getting the list of all frameworks
-my $queryfwk =$dbh->prepare("select frameworktext, frameworkcode from
biblio_framework");
+my $queryfwk = $dbh->prepare("select frameworktext, frameworkcode from
biblio_framework");
$queryfwk->execute;
my %select_fwk;
my @select_fwk;
my $curfwk;
-push @select_fwk,"Default";
+push @select_fwk, "Default";
$select_fwk{"Default"} = "Default";
-while (my ($description, $fwk) =$queryfwk->fetchrow) {
+
+while ( my ( $description, $fwk ) = $queryfwk->fetchrow ) {
push @select_fwk, $fwk;
$select_fwk{$fwk} = $description;
}
-$curfwk=$frameworkcode;
-my $framework=CGI::scrolling_list(
+$curfwk = $frameworkcode;
+my $framework = CGI::scrolling_list(
-name => 'Frameworks',
-id => 'Frameworks',
-default => $curfwk,
@@ -548,69 +638,80 @@
-values => address@hidden,
-labels => \%select_fwk,
-size => 1,
- -multiple => 0 );
-$template->param( framework => $framework, breedingid => $breedingid);
+ -multiple => 0
+);
+$template->param( framework => $framework, breedingid => $breedingid );
+
+# ++ Global
+$tagslib = &GetMarcStructure( 1, $frameworkcode );
+$usedTagsLib = &GetUsedMarcStructure( $frameworkcode );
+$mandatory_z3950 = GetMandatoryFieldZ3950($frameworkcode);
+# -- Global
+
+my $record = -1;
+my $encoding = "";
+my (
+ $biblionumtagfield,
+ $biblionumtagsubfield,
+ $biblioitemnumtagfield,
+ $biblioitemnumtagsubfield,
+ $bibitem,
+ $biblioitemnumber
+);
+
+if (($biblionumber) && !($breedingid)){
+ $record = GetMarcBiblio($biblionumber);
+}
+if ($breedingid) {
+ ( $record, $encoding ) = MARCfindbreeding( $dbh, $breedingid ) ;
+}
+
+$is_a_modif = 0;
-$tagslib = &GetMarcStructure(1,$frameworkcode);
-my $record=-1;
-my $encoding="";
-$record = GetMarcBiblio( $biblionumber ) if ($biblionumber);
-($record,$encoding) = MARCfindbreeding($dbh,$breedingid) if ($breedingid);
-
-# warn "biblionumber : $biblionumber = ".$record->as_formatted;
-$is_a_modif=0;
-my ($biblionumtagfield,$biblionumtagsubfield);
-my
($biblioitemnumtagfield,$biblioitemnumtagsubfield,$bibitem,$biblioitemnumber);
if ($biblionumber) {
- $is_a_modif=1;
+ $is_a_modif = 1;
+
# if it's a modif, retrieve bibli and biblioitem numbers for the future
modification of old-DB.
- ($biblionumtagfield,$biblionumtagsubfield) =
&GetMarcFromKohaField("biblio.biblionumber",$frameworkcode);
- ($biblioitemnumtagfield,$biblioitemnumtagsubfield) =
&GetMarcFromKohaField("biblioitems.biblioitemnumber",$frameworkcode);
+ ( $biblionumtagfield, $biblionumtagsubfield ) =
+ &GetMarcFromKohaField( "biblio.biblionumber", $frameworkcode );
+ ( $biblioitemnumtagfield, $biblioitemnumtagsubfield ) =
+ &GetMarcFromKohaField( "biblioitems.biblioitemnumber", $frameworkcode );
+
# search biblioitems value
- my $sth=$dbh->prepare("select biblioitemnumber from biblioitems where
biblionumber=?");
+ my $sth = $dbh->prepare("select biblioitemnumber from biblioitems where
biblionumber=?");
$sth->execute($biblionumber);
($biblioitemnumber) = $sth->fetchrow;
}
+
#-------------------------------------------------------------------------------------
-if ($op eq "addbiblio") {
+if ( $op eq "addbiblio" ) {
#-------------------------------------------------------------------------------------
- # 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');
- if (C4::Context->preference('TemplateEncoding') eq "iso-8859-1") {
- $record =
TransformHtmlToMarc($dbh,address@hidden,address@hidden,address@hidden,address@hidden,address@hidden);
- } else {
- my $xml =
TransformHtmlToXml(address@hidden,address@hidden,address@hidden,address@hidden,address@hidden);
-
$record=MARC::Record->new_from_xml($xml,C4::Context->preference('TemplateEncoding'),C4::Context->preference('marcflavour'));
-# warn "MARC :".$record->as_formatted;
-# die;
- }
+ # getting html input
+ my @params = $input->param();
+ $record = TransformHtmlToMarc( address@hidden , $input );
# check for a duplicate
my ($duplicatebiblionumber,$duplicatetitle) = FindDuplicate($record) if
(!$is_a_modif);
my $confirm_not_duplicate = $input->param('confirm_not_duplicate');
# it is not a duplicate (determined either by Koha itself or by user
checking it's not a duplicate)
- if (!$duplicatebiblionumber or $confirm_not_duplicate) {
- # MARC::Record built => now, record in DB
+ if ( !$duplicatebiblionumber or $confirm_not_duplicate ) {
my $oldbibnum;
my $oldbibitemnum;
- if ($is_a_modif) {
- ModBiblioframework($biblionumber,$frameworkcode);
- ModBiblio($record,$biblionumber,$frameworkcode);
+ if ( $is_a_modif ) {
+ ModBiblioframework( $biblionumber, $frameworkcode );
+ ModBiblio( $record, $biblionumber, $frameworkcode );
}
else {
- ($biblionumber,$oldbibitemnum) = AddBiblio($record,$frameworkcode);
+ ( $biblionumber, $oldbibitemnum ) = AddBiblio( $record,
$frameworkcode );
}
+
if (C4::Context->preference("BiblioAddsAuthorities")){
my
($countlinked,$countcreated)=BiblioAddAuthorities($record,$frameworkcode);
}
- # now, redirect to additem page
if ($mode ne "popup"){
- print
$input->redirect("/cgi-bin/koha/cataloguing/additem.pl?biblionumber=$biblionumber&frameworkcode=$frameworkcode");
+ print $input->redirect(
+
"/cgi-bin/koha/cataloguing/additem.pl?biblionumber=$biblionumber&frameworkcode=$frameworkcode"
+ );
exit;
} else {
$template->param(
@@ -622,15 +723,14 @@
$template->param( title => $record->title() ) if ($record ne "-1" &&
C4::Context->preference('marcflavour') eq "usmarc");
$template->param(
popup => $mode,
- itemtype => $frameworkcode, # HINT: if the library has
itemtype = framework, itemtype is auto filled !
+ itemtype => $frameworkcode,
);
output_html_with_http_headers $input, $cookie, $template->output;
exit;
}
} else {
# it may be a duplicate, warn the user and do nothing
- build_tabs ($template, $record, $dbh,$encoding);
- build_hidden_data;
+ build_tabs ($template, $record, $dbh,$encoding,$input);
$template->param(
biblionumber => $biblionumber,
biblionumtagfield => $biblionumtagfield,
@@ -643,73 +743,36 @@
duplicatetitle => $duplicatetitle,
);
}
-#--------------------------------------------------------------------------
-} elsif ($op eq "addfield") {
-#--------------------------------------------------------------------------
- my $addedfield = $input->param('addfield_field');
- my $cntrepeatfield=$input->param('repeat_field');
- $cntrepeatfield=1 unless ($cntrepeatfield);
- my $tagaddfield_subfield = $input->param('addfield_subfield');
- 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 $xml =
TransformHtmlToXml(address@hidden,address@hidden,address@hidden,address@hidden,address@hidden);
- my $record;
- if (C4::Context->preference('TemplateEncoding') eq "iso-8859-1") {
- my %indicators;
- for (my $i=0;$i<=$#ind_tag;$i++) {
- $indicators{$ind_tag[$i]} = $indicator[$i];
- }
- $record =
TransformHtmlToMarc($dbh,address@hidden,address@hidden,address@hidden,%indicators);
- } else {
- my $xml =
TransformHtmlToXml(address@hidden,address@hidden,address@hidden,address@hidden,address@hidden);
-
$record=MARC::Record->new_from_xml($xml,C4::Context->preference('TemplateEncoding'),C4::Context->preference('marcflavour'));
- }
- for (my $i=1;$i<=$cntrepeatfield;$i++){
- my $field =
MARC::Field->new("$addedfield",'','',"$tagaddfield_subfield" => "");
- $record->append_fields($field);
- }
- #warn "result : ".$record->as_formatted;
- build_tabs ($template, $record, $dbh,$encoding);
- build_hidden_data;
- $template->param(
- biblionumber => $biblionumber,
- biblionumtagfield => $biblionumtagfield,
- biblionumtagsubfield => $biblionumtagsubfield,
- biblioitemnumtagfield => $biblioitemnumtagfield,
- biblioitemnumtagsubfield => $biblioitemnumtagsubfield,
- biblioitemnumber => $biblioitemnumber );
-} elsif ($op eq "delete") {
-#-----------------------------------------------------------------------------
+}
+elsif ( $op eq "delete" ) {
+
my $error = &DelBiblio($biblionumber);
if ($error) {
warn "ERROR when DELETING BIBLIO $biblionumber : $error";
print "Content-Type: text/html\n\n<html><body><h1>ERROR when DELETING
BIBLIO $biblionumber : $error</h1></body></html>";
- } else {
- print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0;
URL=/cgi-bin/koha/catalogue/search.pl?type=intranet\"></html>";
+ exit;
}
+
+ print $input->redirect('/cgi-bin/koha/catalogue/search.pl');
exit;
-#----------------------------------------------------------------------------
+
} else {
-#----------------------------------------------------------------------------
+
#----------------------------------------------------------------------------
# If we're in a duplication case, we have to set to "" the biblionumber
# as we'll save the biblio as a new one.
- if ($op eq "duplicate")
- {
- $biblionumber= "";
+ if ( $op eq "duplicate" ) {
+ $biblionumber = "";
}
- #FIXME: it's kind of silly to go from MARC::Record to MARC::File::XML and
then back again just to fix the encoding
+
+#FIXME: it's kind of silly to go from MARC::Record to MARC::File::XML and then
back again just to fix the encoding
eval {
my $uxml = $record->as_xml;
- MARC::Record::default_record_format("UNIMARC") if
(C4::Context->preference("marcflavour") eq "UNIMARC");
- my $urecord = MARC::Record::new_from_xml($uxml, 'UTF-8');
+ MARC::Record::default_record_format("UNIMARC")
+ if ( C4::Context->preference("marcflavour") eq "UNIMARC" );
+ my $urecord = MARC::Record::new_from_xml( $uxml, 'UTF-8' );
$record = $urecord;
};
- build_tabs ($template, $record, $dbh,$encoding);
- build_hidden_data;
+ build_tabs( $template, $record, $dbh, $encoding,$input );
$template->param(
biblionumber => $biblionumber,
biblionumtagfield => $biblionumtagfield,
@@ -719,15 +782,12 @@
biblioitemnumber => $biblioitemnumber,
);
}
-$template->param( title => $record->title() ) if ($record ne "-1");
+
+$template->param( title => $record->title() ) if ( $record ne "-1" );
$template->param(
popup => $mode,
frameworkcode => $frameworkcode,
- itemtype => $frameworkcode, # HINT: if the library has itemtype =
framework, itemtype is auto filled !
- hide_marc => C4::Context->preference('hide_marc'),
- intranetcolorstylesheet =>
C4::Context->preference("intranetcolorstylesheet"),
- intranetstylesheet => C4::Context->preference("intranetstylesheet"),
- IntranetNav => C4::Context->preference("IntranetNav"),
- advancedMARCEditor => C4::Context->preference("advancedMARCEditor"),
- );
+ itemtype => $frameworkcode,
+);
+
output_html_with_http_headers $input, $cookie, $template->output;
Index: cataloguing/additem.pl
===================================================================
RCS file: /sources/koha/koha/cataloguing/additem.pl,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- cataloguing/additem.pl 6 Jul 2007 12:59:06 -0000 1.19
+++ cataloguing/additem.pl 31 Jul 2007 16:03:09 -0000 1.20
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# $Id: additem.pl,v 1.19 2007/07/06 12:59:06 hdl Exp $
+# $Id: additem.pl,v 1.20 2007/07/31 16:03:09 toins Exp $
# Copyright 2000-2002 Katipo Communications
#
@@ -68,7 +68,7 @@
my $tagslib = &GetMarcStructure(1,$frameworkcode);
my $record = GetMarcBiblio($biblionumber);
-# warn "==>".$record->as_formatted;
+warn "==>".$record->as_formatted;
my $oldrecord = TransformMarcToKoha($dbh,$record);
my $itemrecord;
my $nextop="additem";
Index: koha-tmpl/intranet-tmpl/prog/en/cataloguing/addbiblio.tmpl
===================================================================
RCS file:
/sources/koha/koha/koha-tmpl/intranet-tmpl/prog/en/cataloguing/addbiblio.tmpl,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- koha-tmpl/intranet-tmpl/prog/en/cataloguing/addbiblio.tmpl 16 Jul 2007
15:41:40 -0000 1.8
+++ koha-tmpl/intranet-tmpl/prog/en/cataloguing/addbiblio.tmpl 31 Jul 2007
16:03:09 -0000 1.9
@@ -3,28 +3,27 @@
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
<!--TMPL_UNLESS Name="popup"-->
-<!-- TMPL_INCLUDE NAME="menus.inc" -->
-<!-- TMPL_INCLUDE NAME="menu-catalogue.inc" -->
+ <!-- TMPL_INCLUDE NAME="menus.inc" -->
+ <!-- TMPL_INCLUDE NAME="menu-catalogue.inc" -->
<!--/TMPL_UNLESS-->
+
<!--TMPL_IF Name="done"-->
-<script language="JavaScript" type="text/javascript">
+ <script language="javascript" type="text/javascript">
opener.document.forms['f'].biblionumber.value=<!--TMPL_VAR
Name="biblionumber"-->;
opener.document.forms['f'].title.value='<!--TMPL_VAR Name="title"
ESCAPE=HTML-->';
- self.close();
-</script>
+ window.close();
+ </script>
<!--TMPL_ELSE-->
-<form method="post" name="f" id="f" action="addbiblio.pl">
+ <form method="post" name="f" id="f"
action="/cgi-bin/koha/cataloguing/addbiblio.pl" onsubmit="return Check();">
+<!-- /TMPL_IF -->
+
<h1><!-- TMPL_IF NAME="biblionumtagfield" -->Edit MARC Record Number <!--
TMPL_VAR name="biblionumber" --><!-- TMPL_ELSE -->Add MARC Record<!-- /TMPL_IF
--></h1>
<div id="action">
<!-- TMPL_IF name="biblionumber" -->
- <input type="button" value="Save Bibliographic Record and go to Items"
onclick="Check(this.form)" accesskey="w" />
+ <input type="submit" value="Save Bibliographic Record" />
<!-- TMPL_ELSE -->
- <!--TMPL_IF Name="popup"-->
- <input type="button" value="Add Bibliographic Record"
onclick="Check(this.form)" accesskey="w" />
- <!--TMPL_ELSE-->
- <input type="button" value="Add Bibliographic Record and go to Items"
onclick="Check(this.form)" accesskey="w" />
- <!-- /TMPL_IF -->
+ <input type="submit" value="Add Bibliographic Record" />
<!-- /TMPL_IF -->
<input type="button" value="z39.50 Search" onclick="PopupZ3950(); return
false;" />
</div>
@@ -32,16 +31,14 @@
Change framework : <!--TMPL_VAR Name="framework" -->
<input type="hidden" name="op" value="addbiblio" />
+
<!--TMPL_IF Name="popup"-->
<input type="hidden" name="mode" value="popup" />
<!--/TMPL_IF-->
- <input type="hidden" name="repeat_field" />
- <input type="hidden" name="addfield_field" />
<input type="hidden" name="frameworkcode" value="<!-- TMPL_VAR
NAME="frameworkcode" -->" />
<input type="hidden" name="biblionumber" value="<!-- TMPL_VAR
NAME="biblionumber" -->" />
<input type="hidden" name="breedingid" value="<!-- TMPL_VAR
NAME="breedingid" -->" />
-
<div id="tabs">
<!-- TMPL_LOOP name="BIG_LOOP" -->
<!-- TMPL_IF name="number" -->
@@ -52,7 +49,6 @@
<!-- /TMPL_LOOP -->
</div>
-<!-- RESET PAGINATION -->
<!-- TMPL_LOOP name="BIG_LOOP" -->
<!-- hide every tab except the 1st -->
<!-- TMPL_IF name="number" -->
@@ -64,108 +60,120 @@
<!-- show duplicate warning on tab 0 only -->
<!-- TMPL_IF name="duplicatebiblionumber" -->
<div class="error">
- <p class="problem">Is this a duplicate of <a
href="../catalogue/MARCdetail.pl?biblionumber=<!-- TMPL_VAR
name="duplicatebiblionumber" -->"
onclick="openWindow('../MARCdetail.pl?biblionumber=<!-- TMPL_VAR
name="duplicatebiblionumber" -->&popup=1', 'Duplicate biblio'; return
false;)"><!-- TMPL_VAR name="duplicatetitle" --></a>?</p>
+ <p class="problem">Is this a duplicate of <a
href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=<!-- TMPL_VAR
name="duplicatebiblionumber" -->"
onclick="openWindow('../MARCdetail.pl?biblionumber=<!-- TMPL_VAR
name="duplicatebiblionumber" -->&popup=1', 'Duplicate biblio'; return
false;)"><!-- TMPL_VAR name="duplicatetitle" --></a>?</p>
<p>You must either :</p>
<ul>
- <li>If it <em>is</em> a duplicate, <a
href="additem.pl?biblionumber=<!-- TMPL_VAR name="duplicatebiblionumber"
-->">Edit Items</a> of the existing record.</li>
+ <li>If it <em>is</em> a duplicate, <a
href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=<!-- TMPL_VAR
name="duplicatebiblionumber" -->">Edit Items</a> of the existing record.</li>
<li>If not, click to <input type="hidden"
value="0" id="confirm_not_duplicate" name="confirm_not_duplicate" /> <a
href="#" onclick="confirmnotdup(); return false;">Confirm it's not a
duplicate</a></li>
</ul>
</div>
<!-- /TMPL_IF -->
<!-- /TMPL_UNLESS -->
+
<!-- TMPL_LOOP NAME="innerloop" -->
- <div style=";" id="tag<!-- TMPL_VAR name="tag"-->">
- <!-- TMPL_IF name="tag" -->
- <p class="tag">
- <input type="hidden" name="ind_tag" value="<!-- TMPL_VAR
NAME="tag" -->">
+ <!-- TMPL_IF NAME="tag" -->
+ <div class="tag" id="tag_<!-- TMPL_VAR name="tag"-->_<!-- TMPL_VAR
NAME='index'-->">
+ <div class="tag_title" name="div_indicator">
<!-- TMPL_UNLESS name="hide_marc" -->
- <a title="<!-- TMPL_VAR NAME="tag_lib" -->"><!-- TMPL_VAR
NAME="tag" --></a>
+ <span title="<!-- TMPL_VAR NAME="tag_lib" -->"><!-- TMPL_VAR
NAME="tag" --></span>
<!-- TMPL_IF NAME="fixedfield" -->
- <input tabindex="1"
onblur="this.style.backgroundColor='#ffffff';"
onfocus="this.style.backgroundColor='#ffff00;'" type="text"
style="display:none;" name="indicator" size="2" maxlength="2" value="<!--
TMPL_VAR NAME="indicator" -->" class="flat">
+ <input tabindex="1"
+ class="indicator"
+ type="text"
+ style="display:none;"
+ name="tag_<!-- TMPL_VAR NAME="tag"
-->_indicator_<!-- TMPL_VAR NAME='index'-->"
+ size="2"
+ maxlength="2"
+ value="<!-- TMPL_VAR NAME="indicator" -->"
+ class="flat" />
<!-- TMPL_ELSE -->
- <input tabindex="1"
onblur="this.style.backgroundColor='#ffffff';"
onfocus="this.style.backgroundColor='#ffff00;'" type="text" name="indicator"
size="2" maxlength="2" value="<!-- TMPL_VAR NAME="indicator" -->" class="flat">
+ <input tabindex="1"
+ class="indicator"
+ type="text"
+ name="tag_<!-- TMPL_VAR NAME="tag"
-->_indicator_<!-- TMPL_VAR NAME='index'-->"
+ size="2"
+ maxlength="2"
+ value="<!-- TMPL_VAR NAME="indicator" -->"
+ class="flat" />
<!-- /TMPL_IF --> -
<!-- TMPL_ELSE -->
<!-- TMPL_IF NAME="fixedfield" -->
- <input tabindex="1" type="hidden" style="display:none;"
name="indicator" value="<!-- TMPL_VAR NAME="indicator" -->">
+ <input tabindex="1"
+ type="hidden"
+ name="tag_<!-- TMPL_VAR NAME="tag"
-->_indicator_<!-- TMPL_VAR NAME='index'-->"
+ value="<!-- TMPL_VAR NAME="indicator" -->" />
<!-- TMPL_ELSE -->
- <input tabindex="1" type="hidden" name="indicator" value="<!--
TMPL_VAR NAME="indicator" -->">
+ <input tabindex="1"
+ type="hidden"
+ name="tag_<!-- TMPL_VAR NAME="tag"
-->_indicator_<!-- TMPL_VAR NAME='index'-->"
+ value="<!-- TMPL_VAR NAME="indicator" -->" />
<!-- /TMPL_IF -->
<!-- /TMPL_UNLESS -->
+
<!-- TMPL_UNLESS NAME="advancedMARCEditor" -->
<!-- TMPL_VAR NAME="tag_lib" -->
<!-- /TMPL_UNLESS -->
+
<!-- TMPL_IF name="repeatable" -->
- <a href="#<!-- TMPL_VAR NAME="tag" -->"
onclick="javascript:this.nextSibling.type='text';this.nextSibling.focus()">+</a><input
type="hidden" value="" size="2" onchange="javascript:AddField('<!-- TMPL_VAR
NAME="tag" -->',this.value)" ><!-- /TMPL_IF -->
- </p>
+ <span class="buttonPlus" onclick="CloneField('tag_<!--
TMPL_VAR name="tag"-->_<!-- TMPL_VAR NAME='index'-->')">+</span>
<!-- /TMPL_IF -->
+
+ </div>
+
<!-- TMPL_LOOP NAME="subfield_loop" -->
- <p class="subfield">
- <!-- TMPL_IF NAME="visibility" -->
- <a tabindex="1" style="color: grey; font-size: 80%; cursor:
se-resize;" id="label<!-- TMPL_VAR name="index" -->"
onclick="unHideSubfield('subfield<!-- TMPL_VAR NAME="tag" --><!-- TMPL_VAR
name="index" -->','label<!-- TMPL_VAR name="index" -->')">
- <!-- TMPL_VAR NAME="subfield" -->
- </a>
- <!-- /TMPL_IF -->
- <div style="<!-- TMPL_VAR NAME='visibility' -->;" id="subfield<!--
TMPL_VAR NAME='tag' --><!-- TMPL_VAR NAME='index' -->">
- <p>
- <!-- TMPL_UNLESS NAME="advancedMARCEditor" -->
- <label <!-- TMPL_IF NAME="fixedfield" -->
style="display:none;" <!-- /TMPL_IF --> class="labelsubfield">
+ <!-- One line on the marc editor -->
+ <div name="line" class="subfield_line" style="<!-- TMPL_VAR
NAME='visibility' -->;" id="subfield<!-- TMPL_VAR NAME='tag' --><!-- TMPL_VAR
NAME='subfield' -->">
+
+ <!--TMPL_UNLESS NAME="advancedMARCEditor" -->
+ <label for="tag_<!-- TMPL_VAR NAME='tag'-->_subfield_<!--
TMPL_VAR NAME='subfield'-->_<!-- TMPL_VAR NAME='index'-->_<!-- TMPL_VAR
NAME='index_subfield'-->"
+ <!-- TMPL_IF NAME="fixedfield" -->
style="display:none;" <!-- /TMPL_IF --> class="labelsubfield" >
<!-- /TMPL_UNLESS -->
+
<!-- TMPL_UNLESS name="hide_marc" -->
- <img style="cursor: crosshair; color: grey; font-size:
80%;" <!-- TMPL_IF NAME="fixedfield" --> style="display:none;" <!-- /TMPL_IF
--> src="<!-- TMPL_VAR NAME="themelang" -->/images/up.png"
onclick="upSubfield('subfield<!-- TMPL_VAR NAME="tag" --><!-- TMPL_VAR
name="index" -->')"/>
- <input title="<!-- TMPL_VAR NAME="marc_lib_plain" -->"
style=" <!-- TMPL_IF NAME="fixedfield" -->display:none; <!-- /TMPL_IF
-->border:0;" type="text" name="subfield" value="<!-- TMPL_VAR NAME="subfield"
-->" size="1" maxlength="1" class="flat" tabindex=-1 />
+ <img class="buttonUp" <!-- TMPL_IF NAME="fixedfield" -->
style="display:none;" <!-- /TMPL_IF --> src="<!-- TMPL_VAR NAME="themelang"
-->/images/up.png" onclick="upSubfield('subfield<!-- TMPL_VAR NAME='tag'
--><!-- TMPL_VAR NAME='subfield' -->')"/>
+ <input title="<!-- TMPL_VAR NAME='marc_lib_plain' -->"
+ style=" <!-- TMPL_IF NAME="fixedfield"
-->display:none; <!-- /TMPL_IF -->border:0;" type="text"
+ name="tag_<!-- TMPL_VAR NAME='tag'-->_code_<!--
TMPL_VAR NAME='subfield'-->_<!-- TMPL_VAR NAME='index'-->_<!-- TMPL_VAR
NAME='index_subfield'-->"
+ value="<!-- TMPL_VAR NAME="subfield" -->"
+ size="1"
+ maxlength="1"
+ class="flat"
+ tabindex=-1 />
<!-- TMPL_ELSE -->
- <input type="hidden" name="subfield" value="<!-- TMPL_VAR
NAME="subfield" -->"/>
+ <input type="hidden"
+ name="tag_<!-- TMPL_VAR NAME='tag'-->_code_<!--
TMPL_VAR NAME='subfield'-->_<!-- TMPL_VAR NAME='index'-->_<!-- TMPL_VAR
NAME='index_subfield'-->"
+ value="<!-- TMPL_VAR NAME="subfield" -->"/>
<!-- /TMPL_UNLESS -->
+
<!-- TMPL_UNLESS NAME="advancedMARCEditor" -->
- <!-- TMPL_IF name="mandatory" --><b><!-- /TMPL_IF -->
+ <!-- TMPL_IF name="mandatory" --><span
class="subfield_mandatory"><!-- /TMPL_IF -->
<!-- TMPL_VAR NAME="marc_lib" -->
- <!-- TMPL_IF name="mandatory" --> *</b><!-- /TMPL_IF -->
+ <!-- TMPL_IF name="mandatory" --></span><!-- /TMPL_IF -->
</label>
<!-- /TMPL_UNLESS -->
+
<!-- TMPL_VAR NAME="marc_value" -->
+
<!-- TMPL_IF NAME="repeatable" -->
- <a style="cursor: crosshair; color: grey; font-size: 80%;"
onclick="cloneSubfield('subfield<!-- TMPL_VAR NAME="tag" --><!-- TMPL_VAR
name="index" -->')">+</a>
+ <span class="buttonPlus"
onclick="CloneSubfield('subfield<!-- TMPL_VAR NAME='tag' --><!-- TMPL_VAR
NAME='subfield' -->')">+</span>
<!-- /TMPL_IF -->
- <input type="hidden" name="tag" value="<!-- TMPL_VAR
NAME="tag" -->"/>
- <input type="hidden" name="subfieldYYY" value="<!-- TMPL_VAR
NAME="subfield" -->" size="2" maxlength="1"/>
- <input type="hidden" name="mandatory" value="<!-- TMPL_VAR
NAME="mandatory" -->"/>
- <input type="hidden" name="kohafield" value="<!-- TMPL_VAR
NAME="kohafield" -->"/>
- <input type="hidden" name="tag_mandatory" value="<!-- TMPL_VAR
NAME="tag_mandatory" -->"/>
- </p>
+
</div>
+ <!-- End of the line -->
+
<!-- /TMPL_LOOP -->
</div>
+ <!-- /TMPL_IF --><!-- tag -->
<!-- /TMPL_LOOP -->
</div>
<!-- /TMPL_LOOP -->
- <div name="hidden" id="hidden" class="tab">
- <!-- TMPL_LOOP NAME="hidden_loop" -->
- <input type="hidden" name="tag" value="<!--
TMPL_VAR NAME="tag" -->">
- <input type="hidden" name="subfield"
value="<!-- TMPL_VAR NAME="subfield" -->">
- <input type="hidden" name="mandatory"
value="<!-- TMPL_VAR NAME="mandatory" -->">
- <input type="hidden" name="kohafield"
value="<!-- TMPL_VAR NAME="kohafield" -->">
- <input type="hidden" name="tag_mandatory"
value="<!-- TMPL_VAR NAME="tag_mandatory" -->">
- <!-- /TMPL_LOOP -->
- </div>
- <!-- TMPL_IF name="biblionumtagfield" -->
- <input type="hidden" name="tag" value="<!-- TMPL_VAR
NAME="biblionumtagfield" -->">
- <input type="hidden" name="subfield" value="<!--
TMPL_VAR NAME="biblionumtagsubfield" -->">
- <input type="hidden" name="field_value" value="<!--
TMPL_VAR NAME="biblionumber" -->">
- <input type="hidden" name="mandatory" value="0">
- <input type="hidden" name="kohafield" value="<!--
TMPL_VAR NAME="kohafield" -->">
- <input type="hidden" name="tag" value="<!-- TMPL_VAR
NAME="biblioitemnumtagfield" -->">
- <input type="hidden" name="subfield" value="<!--
TMPL_VAR NAME="biblioitemnumtagsubfield" -->">
- <input type="hidden" name="field_value" value="<!--
TMPL_VAR NAME="biblioitemnumber" -->">
- <input type="hidden" name="mandatory" value="0">
- <input type="hidden" name="kohafield" value="<!--
TMPL_VAR NAME="kohafield" -->">
- <input type="hidden" name="tag_mandatory" value="<!--
TMPL_VAR NAME="tag_mandatory" -->">
- <!-- /TMPL_IF -->
- </form>
-<script language="JavaScript" type="text/javascript">
-function loading(){
- document.getElementById("loading").style.display = "none";
-}
+
+</form>
+
+<script language="javascript" type="text/javascript">
+
+function _(s) { return s } // dummy function for gettext
+
function confirmnotdup(){
document.getElementById("confirm_not_duplicate").value = 1;
var checkform = document.getElementById("f");
@@ -199,136 +207,113 @@
}
}
-function Check(f) {
- document.body.style.cursor ="wait";
- // Scan for nonempty fields
- var field_is_nonempty_p = new Array();
- for (i=0 ; i<f.field_value.length ; i++) {
- field_is_nonempty_p[f.tag[i].value] = 0;
- }
- for (i=0 ; i<f.field_value.length ; i++) {
- if (f.field_value[i].value.length != 0) {
- field_is_nonempty_p[f.tag[i].value] += 1;
- }
+/**
+ *
+ *
+ */
+function Check(){
+ var StrAlert = AreMandatoriesNotOk();
+ if( ! StrAlert ){
+ document.f.submit;
+ return true;
+ } else {
+ alert(StrAlert);
+ return false;
}
+}
- // Scan for missing mandatory subfields
- var total_missing_mandatory_subfields = 0;
- var missing_mandatory_subfields = new Array();
- for (i=0 ; i<f.field_value.length-2 ; i++) {
- if (f.field_value[i].value.length==0 &&
f.mandatory[i].value==1) {
- // We should not flag an error unless the tag is also
- // mandatory, or if something else in the tag is entered
-
- if (f.tag_mandatory[i].value == 1 ||
field_is_nonempty_p[f.tag[i].value]) {
-
f.field_value[i].style.backgroundColor="#FF0000";
- total_missing_mandatory_subfields++;
- if (f.field_value[i].parentNode.tagName == "B")
- {
-
missing_mandatory_subfields.push(f.field_value[i].innerHTML + " (tab " +
f.field_value[i].parentNode.parentNode.parentNode.parentNode.id.substr(0,1) +
")");
- }
- else
- {
-
missing_mandatory_subfields.push(f.field_value[i].innerHTML + " (tab " +
f.field_value[i].parentNode.parentNode.parentNode.id.substr(0,1) + ")");
- }
+function Dopop(link,i) {
+ defaultvalue = document.getElementById(i).value;
+ window.open(link+"&result="+defaultvalue,"value
builder",'width=700,height=550,toolbar=false,scrollbars=yes');
+}
- }
+/**
+ * this function open a popup to search on z3950 server.
+ */
+function PopupZ3950() {
+ var strQuery = AreZ3950MandoriesOk();
+ if(strQuery){
+
window.open("/cgi-bin/koha/cataloguing/z3950_search.pl?biblionumber=<!--
TMPL_VAR NAME="biblionumber" -->&frameworkcode=<!-- TMPL_VAR
NAME="frameworkcode"
-->"+strQuery,"z3950search",'width=640,height=400,location=yes,toolbar=no,scrollbars=yes');
} else {
- f.field_value[i].style.backgroundColor="#FFFFFF";
- }
- }
-
- // Scan for missing mandatory tags
- var total_missing_mandatory_tags = 0;
- var seen_mandatory_tag_p = new Array();
- var missing_mandatory_tags = new Array();
- for (i=0 ; i<f.field_value.length ; i++) {
- var j = f.tag[i].value;
- if (!field_is_nonempty_p[j] && f.tag_mandatory[i].value == 1) {
- if (seen_mandatory_tag_p[j] != 1) {
- seen_mandatory_tag_p[j] = 1;
- total_missing_mandatory_tags++;
- if (f.field_value[i].parentNode.tagName == "B")
- {
-
missing_mandatory_tags.push(f.field_value[i].innerHTML + " (tab " +
f.field_value[i].parentNode.parentNode.parentNode.parentNode.id.substr(0,1) +
")");
- }
- else
- {
-
missing_mandatory_tags.push(f.field_value[i].innerHTML + " (tab " +
f.field_value[i].parentNode.parentNode.parentNode.id.substr(0,1) + ")");
- }
- }
- f.field_value[i].style.backgroundColor="#FFFF00";
- }
+ var strAlert = _("To perform a z39.50 search, you must enter at least
one of the following: \n\n ISBN\n ISSN\n Title\n Author\n");
+ alert(strAlert);
}
+}
- var total_errors = total_missing_mandatory_tags +
total_missing_mandatory_subfields;
- var alertString2;
- if (total_errors!=0) {
- alertString2 = _("Form not submitted because of the following
problem(s)");
- alertString2 +=
"\n------------------------------------------------------------------------------------\n";
- alertString2 += "\n- "+ total_missing_mandatory_tags +_("
mandatory tags empty");
- for (i=0; i<missing_mandatory_tags.length; i++)
- {
- alertString2 += "\n--->"+ missing_mandatory_tags[i];
+/**
+ * check if mandatory subfields are writed
+ */
+function AreMandatoriesNotOk(){
+ var mandatories = new Array();
+ var tab = new Array();
+ var label = new Array();
+ var flag=0;
+ <!-- TMPL_LOOP NAME='BIG_LOOP' -->
+ <!-- TMPL_LOOP NAME='innerloop' -->
+ <!-- TMPL_LOOP NAME='subfield_loop'-->
+ <!-- TMPL_IF NAME='mandatory'-->
+ mandatories.push("<!-- TMPL_VAR NAME='id' -->");
+ tab.push("<!-- TMPL_VAR NAME='number' -->");
+ label.push("<!-- TMPL_VAR NAME='marc_lib' -->");
+ <!-- /TMPL_IF -->
+ <!-- /TMPL_LOOP -->
+ <!-- /TMPL_LOOP -->
+ <!-- /TMPL_LOOP -->
+ var StrAlert = "Can't save this record because the following field aren't
filled :\n\n";
+ for(var i=0,len=mandatories.length; i<len ; i++){
+ if( ! document.getElementById(mandatories[i]).value){
+ flag = 1;
+
document.getElementById(mandatories[i]).setAttribute('class','subfield_not_filled');
+ document.getElementById(mandatories[i]).focus();
+ StrAlert += "\t* "+label[i]+" in tab "+tab[i]+"\n";
}
- alertString2 += "\n- "+ total_missing_mandatory_subfields +_("
mandatory fields empty (see bold subfields)");
- for (i=0; i<missing_mandatory_subfields.length; i++)
- {
- alertString2 += "\n--->"+
missing_mandatory_subfields[i];
}
- alert(alertString2);
+ if(flag){
+ return StrAlert;
} else {
- document.forms['f'].submit();
+ return flag;
}
}
-function Dopop(link,i) {
- defaultvalue=document.forms['f'].field_value[i].value;
- newin=window.open(link+"&result="+defaultvalue,"value
builder",'width=700,height=550,toolbar=false,scrollbars=yes');
-}
-function PopupZ3950() {
- var strQuery="";
+/**
+ * check if z3950 mandatories are set or not
+ */
+function AreZ3950MandoriesOk(){
+ var mandatories = new Array();
+ var mandatories_label = new Array();
+
+ <!-- TMPL_LOOP NAME='BIG_LOOP' -->
+ <!-- TMPL_LOOP NAME='innerloop' -->
+ <!-- TMPL_LOOP NAME='subfield_loop'-->
+ <!-- TMPL_IF NAME='z3950_mandatory'-->
+ mandatories.push("<!-- TMPL_VAR NAME='id' -->");
+ mandatories_label.push("<!-- TMPL_VAR
NAME='z3950_mandatory' -->");
+ <!-- /TMPL_IF -->
+ <!-- /TMPL_LOOP -->
+ <!-- /TMPL_LOOP -->
+ <!-- /TMPL_LOOP -->
+
var error = 0;
- for (i=0 ; i<document.forms['f'].field_value.length ; i++) {
- if (document.forms['f'].kohafield[i].value ==
"biblioitems.isbn"){
- if(document.forms['f'].field_value[i].value.length>0) {
- strQuery +=
"&isbn="+document.forms['f'].field_value[i].value;
- } else {
- error++;
- }
- }
- if (document.forms['f'].kohafield[i].value == "biblio.title"){
- if(document.forms['f'].field_value[i].value.length>0) {
- strQuery +=
"&title="+document.forms['f'].field_value[i].value;
- } else {
- error++;
- }
- }
- if (document.forms['f'].kohafield[i].value == "biblio.author"){
- if(document.forms['f'].field_value[i].value.length>0) {
- strQuery +=
"&author="+document.forms['f'].field_value[i].value;
- } else {
+ var strQuery="";
+ for(var i=0,len=mandatories.length; i<len ; i++){
+ var field_value = document.getElementById(mandatories[i]).value;
+ if( ! field_value ){
error++;
- }
- }
- if (document.forms['f'].kohafield[i].value ==
"biblioitems.issn"){
- if(document.forms['f'].field_value[i].value.length>0) {
- strQuery +=
"&issn="+document.forms['f'].field_value[i].value;
} else {
- error++;
- }
+ strQuery += "&"+mandatories_label[i]+"="+field_value;
}
}
if(error < 4){
- newin=window.open("z3950_search.pl?biblionumber=<!-- TMPL_VAR
NAME="biblionumber" -->&frameworkcode=<!-- TMPL_VAR NAME="frameworkcode"
-->"+strQuery,"z3950search",'width=640,height=400,location=yes,toolbar=no,scrollbars=yes');
+ return strQuery;
} else {
- alert("To perform a z39.50 search, you must enter at least one
of the following: \n\n ISBN\n ISSN\n Title\n Author\n");
+ return false;
}
}
function Changefwk(FwkList) {
var fwk = FwkList.options[FwkList.selectedIndex].value;
- window.location = "addbiblio.pl?biblionumber=<!--TMPL_VAR
Name="biblionumber"-->&breedingid=<!-- TMPL_VAR name="breedingid"
-->&frameworkcode="+fwk;
+ window.location =
"/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=<!--TMPL_VAR
Name="oldbiblionumber"-->&breedingid=<!-- TMPL_VAR name="breedingid"
-->&frameworkcode="+fwk;
+
}
function openAuth(tagid,authtype,X) {
@@ -339,61 +324,248 @@
newin=window.open("../authorities/auth_finder.pl?authtypecode="+
authtype+ "&tagid="+Y, "value
builder",'width=700,height=550,toolbar=false,scrollbars=yes');
}
+/**
+ * To clone a field or a subfield by clickink on '+' button
+ */
+function CloneField(index) {
+ var original = document.getElementById(index); //original <div>
+ var clone = original.cloneNode(true);
+ var new_key = CreateKey();
+ var new_id = original.getAttribute('id')+new_key;
+
+ clone.setAttribute('id',new_id); // setting a new id for the parent div
+
+ var divs = clone.getElementsByTagName('div');
+
+ <!-- TMPL_UNLESS NAME='hide_marc'--> // No indicator if hide_marc
+ // setting a new name for the new indicator
+ var indicator = clone.getElementsByTagName('input')[0];
+ indicator.setAttribute('name',indicator.getAttribute('name')+new_key);
+ <!-- /TMPL_UNLESS -->
+
+ // settings all subfields
+ for(var i=0,divslen = divs.length ; i<divslen ; i++){ // foreach div
+ if(divs[i].getAttribute("name") == 'line'){ // if it s a subfield
+
+ // set the attribute for the new 'div' subfields
+ divs[i].setAttribute('id',divs[i].getAttribute('id')+new_key);
+
+ var inputs = divs[i].getElementsByTagName('input');
+ var id_input = "";
+
+ inputs[0].setAttribute('id',inputs[0].getAttribute('id')+new_key);
+
inputs[0].setAttribute('name',inputs[0].getAttribute('name')+new_key);
+ var id_input;
+ try {
+ id_input = inputs[1].getAttribute('id')+new_key;
+ inputs[1].setAttribute('id',id_input);
+
inputs[1].setAttribute('name',inputs[1].getAttribute('name')+new_key);
+ } catch(e) {
+ try{ // it s a select if it is not an input
+ var selects = divs[i].getElementsByTagName('select');
+ id_input = selects[0].getAttribute('id')+new_key;
+ selects[0].setAttribute('id',id_input);
+
selects[0].setAttribute('name',selects[0].getAttribute('name')+new_key);
+ }catch(e2){ // it is a textarea if it s not a select or an
input
+ var textaeras =
divs[i].getElementsByTagName('textarea');
+ id_input = textaeras[0].getAttribute('id')+new_key;
+ textaeras[0].setAttribute('id',id_input);
+
textaeras[0].setAttribute('name',textaeras[0].getAttribute('name')+new_key);
+ }
+ }
+
+ <!-- TMPL_UNLESS NAME='advancedMARCEditor'-->
+ // when cloning a subfield, re set its label too.
+ var labels = divs[i].getElementsByTagName('label');
+ labels[0].setAttribute('for',id_input);
+ <!-- /TMPL_UNLESS -->
+
+ <!-- TMPL_UNLESS NAME='hide_marc'-->
+ // updating javascript parameters on button up
+ var imgs = divs[i].getElementsByTagName('img');
+
imgs[0].setAttribute('onclick',"upSubfield(\'"+divs[i].getAttribute('id')+"\');");
+ <!-- /TMPL_UNLESS -->
+
+ // setting its '+' button
+ var CloneButtonPlus=0;
+ try {
+ CloneButtonPlus = divs[i].getElementsByTagName('span')[0];
+ if(CloneButtonPlus.getAttribute('class') == 'buttonPlus'){
+ CloneButtonPlus.setAttribute('onclick',"CloneSubfield('" +
divs[i].getAttribute('id') + "')");
+ } else {
+ CloneButtonPlus = 0;
+ }
+ }
+ catch(e){
+ // do nothig if ButtonPlus & CloneButtonPlus don t exist.
+ }
+
+ // button ...
+ var spans=0;
+ try {
+ spans = divs[i].getElementsByTagName('span');
+ } catch(e) {
+ // no spans
+ }
+ if(spans){
+ var buttonDot;
+ if(!CloneButtonPlus){ // it s impossible to have + ...
(buttonDot AND buttonPlus)
+ buttonDot = spans[0];
+ if(buttonDot){
+ // 2 possibilities :
+ try{
+ var buttonDotOnClick =
buttonDot.getAttribute('onclick');
+ if(buttonDotOnClick.match('Clictag')){ // -1- It
s a plugin
+ var re = /\('.*'\)/i;
+ buttonDotOnClick =
buttonDotOnClick.replace(re,"('"+inputs[1].getAttribute('id')+"')");
+ if(buttonDotOnClick){
+
buttonDot.setAttribute('onclick',buttonDotOnClick);
+ }
+ } else {
+ if(buttonDotOnClick.match('Dopop')) { // -2-
It's a auth value
+
+ var re1 = /&index=.*',/;
+ var re2 = /,.*\)/;
+
+ buttonDotOnClick =
buttonDotOnClick.replace(re1,"&index="+inputs[1].getAttribute('id')+"',");
+ buttonDotOnClick =
buttonDotOnClick.replace(re2,",'"+inputs[1].getAttribute('id')+"')");
+
+ if(buttonDotOnClick){
+
buttonDot.setAttribute('onclick',buttonDotOnClick);
+ }
+ }
+ }
+ try {
+ // do not copy the script section.
+ var script =
spans[0].getElementsByTagName('script')[0];
+ spans[0].removeChild(script);
+ } catch(e) {
+ // do nothing if there is no script
+ }
+ }catch(e){}
+ }
+ }
+ }
+ <!-- TMPL_UNLESS NAME='hide_marc'-->
+ var buttonUp = divs[i].getElementsByTagName('img')[0];
+ buttonUp.setAttribute('onclick',"upSubfield('" +
divs[i].getAttribute('id') + "')");
+ <!-- /TMPL_UNLESS -->
-function AddField(field,cntrepeatfield) {
- document.forms['f'].op.value = "addfield";
- document.forms['f'].addfield_field.value=field;
- document.forms['f'].repeat_field.value=cntrepeatfield;
- //alert(document.forms['f'].repeat_field.value);
- document.f.submit();
+ } else { // it's a indicator div
+ if(divs[i].getAttribute('name') == 'div_indicator'){
+ var inputs = divs[i].getElementsByTagName('input');
+
inputs[0].setAttribute('id',inputs[0].getAttribute('id')+new_key);
+
+ var CloneButtonPlus;
+ try {
+ CloneButtonPlus = divs[i].getElementsByTagName('span')[1];
// 0 is the title
+ CloneButtonPlus.setAttribute('onclick',"CloneField('" +
divs[i].parentNode.getAttribute('id') + "')");
+ }
+ catch(e){
+ // do nothig CloneButtonPlus doesn't exist.
+ }
+ }
+ }
+ }
+
+ // insert this line on the page
+ original.parentNode.insertBefore(clone,original.nextSibling);
}
-function cloneSubfield(index) {
+function CloneSubfield(index){
var original = document.getElementById(index); //original <div>
var clone = original.cloneNode(true);
+ var new_key = CreateKey();
+ var new_id = original.getAttribute('id')+new_key;
// set the attribute for the new 'div' subfields
- clone.setAttribute('id',index + index);//set another id.
- var NumTabIndex;
- NumTabIndex = parseInt(original.getAttribute('tabindex'));
- if(isNaN(NumTabIndex)) NumTabIndex = 0;
- clone.setAttribute('tabindex',NumTabIndex+1);
+ var inputs = clone.getElementsByTagName('input');
+ var selects = clone.getElementsByTagName('select');
+ var textareas = clone.getElementsByTagName('textarea');
+
+ // input
+ var id_input = "";
+ for(var i=0,len=inputs.length; i<len ; i++ ){
+ id_input = inputs[i].getAttribute('id')+new_key;
+ inputs[i].setAttribute('id',id_input);
+ inputs[i].setAttribute('name',inputs[i].getAttribute('name')+new_key);
+ }
+
+ // select
+ for(var i=0,len=selects.length; i<len ; i++ ){
+ id_input = selects[i].getAttribute('id')+new_key;
+ selects[i].setAttribute('id',selects[i].getAttribute('id')+new_key);
+
selects[i].setAttribute('name',selects[i].getAttribute('name')+new_key);
+ }
+
+ // textarea
+ for(var i=0,len=textareas.length; i<len ; i++ ){
+ id_input = textareas[i].getAttribute('id')+new_key;
+
textareas[i].setAttribute('id',textareas[i].getAttribute('id')+new_key);
+
textareas[i].setAttribute('name',textareas[i].getAttribute('name')+new_key);
+ }
+
+ <!-- TMPL_UNLESS NAME='advancedMARCEditor' -->
+ // when cloning a subfield, reset its label too.
+ var label = clone.getElementsByTagName('label')[0];
+ label.setAttribute('for',id_input);
+ <!-- /TMPL_UNLESS -->
+
+ // setting a new if for the parent div
+ clone.setAttribute('id',new_id);
var CloneButtonPlus;
- try{
- CloneButtonPlus = clone.getElementsByTagName('a')[0];
- CloneButtonPlus.setAttribute('onclick',"cloneSubfield('" + index +
index + "')");
+ try {
+ var spans = clone.getElementsByTagName('span');
+ if(spans.length){
+ for(var i = 0 ,lenspans = spans.length ; i < lenspans ; i++){
+ if(spans[i].getAttribute('class') == 'buttonPlus'){
+ CloneButtonPlus = spans[i];
+ CloneButtonPlus.setAttribute('onclick',"CloneSubfield('" +
new_id + "')");
var buttonUp = clone.getElementsByTagName('img')[0];
-// alert(buttonUp.getAttribute('id'));
- buttonUp.setAttribute('onclick',"upSubfield('" + index + index + "')");
+ buttonUp.setAttribute('onclick',"upSubfield('" + new_id +
"')");
+ }
+ }
+ }
}
catch(e){
// do nothig if ButtonPlus & CloneButtonPlus don't exist.
}
-
// insert this line on the page
original.parentNode.insertBefore(clone,original.nextSibling);
}
+/**
+ * This function create a random number
+ */
+function CreateKey(){
+ return parseInt(Math.random() * 100000);
+}
+
+/**
+ * This function allows to move a subfield up by clickink on the 'up' button .
+ */
function upSubfield(index) {
try{
var line = document.getElementById(index); // get the line
where the user has clicked.
} catch(e) {
- return;
+ return; // this line doesn't exist...
}
- var tag = line.parentNode; // get the dad of this line. (should be
"<div tag=XXX>")
+ var tag = line.parentNode; // get the dad of this line. (should be "<div
id='tag_...'>")
// getting all subfields for this tag
var subfields = tag.getElementsByTagName('div');
var subfieldsLength = subfields.length;
+
if(subfieldsLength<=1) return; // nothing to do if there is just one
subfield.
+
// among all subfields
for(var i=0;i<subfieldsLength;i++){
if(subfields[i].getAttribute('id') == index){ //looking for the
subfield which is clicked :
- if(i==0){ // if the clicked subfield is on the top
- tag.appendChild(subfields[0]);
+ if(i==1){ // if the clicked subfield is on the top
+ tag.appendChild(subfields[1]);
return;
- }else{
+ } else {
var lineAbove = subfields[i-1];
tag.insertBefore(line,lineAbove);
return;
@@ -402,12 +574,13 @@
}
}
-function unHideSubfield(index,labelindex) {
+function unHideSubfield(index,labelindex) { // FIXME :: is it used ?
subfield = document.getElementById(index);
subfield.style.display = 'block';
label = document.getElementById(labelindex);
label.style.display='none';
}
+
</script>
-<!--/TMPL_IF-->
+
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
Index: koha-tmpl/intranet-tmpl/prog/en/includes/intranet2.css
===================================================================
RCS file:
/sources/koha/koha/koha-tmpl/intranet-tmpl/prog/en/includes/intranet2.css,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- koha-tmpl/intranet-tmpl/prog/en/includes/intranet2.css 2 Jul 2007
09:14:52 -0000 1.5
+++ koha-tmpl/intranet-tmpl/prog/en/includes/intranet2.css 31 Jul 2007
16:03:10 -0000 1.6
@@ -89,7 +89,6 @@
vertical-align:top;
display:block;
float:left;
-/* text-align:right; */
width:10em;
margin-right:0.2em;
}
@@ -119,6 +118,14 @@
text-decoration:none;
}
+.click{
+ cursor:pointer;
+ color: #027ac6;/*blue*/
+}
+.click:hover{
+ text-decoration:underline;
+}
+
#problem {
color: red;
background-color:white;
@@ -146,6 +153,13 @@
margin:10px;
}
+.toogle{
+ background-color:#ffffcc;
+}
+
+.pages{
+ margin:.7em;
+}
/* css styles for reserves color alerts */
.onloan {
background-color: #FFED3D;
@@ -463,8 +477,9 @@
#tabs a {
color:white;
text-decoration:none;
- padding-right:10px;
- padding-left:10px;
+ padding-right:1.2em;
+ padding-left:1.2em;
+ -moz-border-radius:4px;
}
/* specify that we to do when the mouse is on 1 button */
@@ -473,8 +488,8 @@
}
#tabs {
- margin-top:45px;
- margin-bottom:5px;
+ margin-top:35px;
+ margin-bottom:20px;
}
/* styles for the 11 content blocks */
@@ -490,22 +505,10 @@
display:block;
}
-/* the style of tag description */
-p.tag {
- font-weight:bold;
-}
-/* the style of subfield paragraph */
-p.subfield {
-
-}
-
-
-
.lineSelected {
background-color:yellow;
}
-
/* display more informations with css layer */
a.info {
position: relative;
@@ -551,3 +554,116 @@
#itemtypelist p {
margin:0px;
}
\ No newline at end of file
+
+/* MARC Editor stylesheet */
+
+/* the style of tag description */
+div.tag_title {
+ font-weight:bold;
+}
+
+div.tag_title span {
+ display:inline;
+ letter-spacing:5px;
+ font-size:1.2em;
+ text-transform: capitalize;
+ color : #027ac6;
+}
+
+div.tag_title a:hover{
+ text-decoration:none;
+}
+
+div.tag {
+ margin-bottom:1.8em;
+}
+
+.subfield_line{
+ margin-left:1.1em;
+}
+
+.CursorHelp{
+ cursor:help;
+}
+
+.buttonDot{
+ cursor:help;
+}
+
+.buttonUp {
+ cursor: crosshair;
+ color: grey;
+ font-size: .8em;
+}
+
+.labelsubfield{
+ min-width:210px;
+ display:inline;
+}
+
+.subfield_mandatory{
+ color:red;
+}
+
+.subfield_not_filled {
+ width:506px;
+ color:darkblue;
+ background-color:#ffe5ed;
+ border:1px solid #ffe5ed;
+ border-bottom:1px solid red;
+ padding:0.15em;
+}
+
+.line_not_filled{
+ margin-left:1.1em;
+ background-color:#ffe5ed;
+ border:1px solid red;
+}
+
+.indicator{
+ width:20px;
+ color:darkblue;
+ background-color: #ffffff;
+ border:1px dotted #a4cde6;
+ padding:0.15em;
+}
+
+.indicator:focus {
+ background-color:#fdfde3;
+ border-bottom:1px solid darkblue;
+ width:20px;
+ color:darkblue;
+}
+
+.input_marceditor {
+ width:506px;
+ color:darkblue;
+ background-color:#ffffff;
+ border:1px solid #ffffff;
+ border-bottom:1px solid lightgray;
+ padding:0.15em;
+}
+
+.input_marceditor:focus{
+ background-color:#fdfde3;
+ border-bottom:1px solid darkblue;
+ width:506px;
+ color:darkblue;
+}
+
+.tag{
+ padding-bottom:1.1em;
+/* border-bottom:1px dotted #a4cde6; */
+}
+
+.buttonPlus {
+ cursor: crosshair;
+ color: grey;
+ font-size: 80%;
+}
+
+/*.flat{
+ border:0px;
+}*/
+
+/* End of Marc Editor stylesheet */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Koha-cvs] koha cataloguing/addbiblio.pl cataloguing/addit...,
Antoine Farnault <=