koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] koha/cataloguing addbiblio.pl additem.pl addbib...


From: Tumer Garip
Subject: [Koha-cvs] koha/cataloguing addbiblio.pl additem.pl addbib...
Date: Fri, 01 Sep 2006 15:45:02 +0000

CVSROOT:        /sources/koha
Module name:    koha
Changes by:     Tumer Garip <tgarip1957>        06/09/01 15:45:01

Modified files:
        cataloguing    : addbiblio.pl additem.pl 
Removed files:
        cataloguing    : addbiblio-nomarc.pl additem-nomarc.pl 
                         keywordsearch.pl savebiblio.pl saveitem.pl 
                         thesaurus_popup.pl websitesearch.pl 

Log message:
        MARCXML only. No more MARC record. No more non-marc handling
        Install LibXML or Expat for fast parsing. either will work
        Bug in addbiblio when adding authorities fixed

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/cataloguing/addbiblio.pl?cvsroot=koha&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/koha/cataloguing/additem.pl?cvsroot=koha&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/koha/cataloguing/addbiblio-nomarc.pl?cvsroot=koha&r1=1.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/koha/cataloguing/additem-nomarc.pl?cvsroot=koha&r1=1.4&r2=0
http://cvs.savannah.gnu.org/viewcvs/koha/cataloguing/keywordsearch.pl?cvsroot=koha&r1=1.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/koha/cataloguing/savebiblio.pl?cvsroot=koha&r1=1.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/koha/cataloguing/saveitem.pl?cvsroot=koha&r1=1.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/koha/cataloguing/thesaurus_popup.pl?cvsroot=koha&r1=1.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/koha/cataloguing/websitesearch.pl?cvsroot=koha&r1=1.1&r2=0

Patches:
Index: addbiblio.pl
===================================================================
RCS file: /sources/koha/koha/cataloguing/addbiblio.pl,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- addbiblio.pl        3 Apr 2006 00:17:13 -0000       1.14
+++ addbiblio.pl        1 Sep 2006 15:45:01 -0000       1.15
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# $Id: addbiblio.pl,v 1.14 2006/04/03 00:17:13 kados Exp $
+# $Id: addbiblio.pl,v 1.15 2006/09/01 15:45:01 tgarip1957 Exp $
 
 # Copyright 2000-2002 Katipo Communications
 #
@@ -25,60 +25,24 @@
 use C4::Output;
 use C4::Interface::CGI::Output;
 use C4::Biblio;
-use C4::Search;
-use C4::SearchMarc; # also includes Biblio.pm, SearchMarc is used to 
FindDuplicate
+use C4::Search; # also includes Biblio.pm, Search is used to FindDuplicate
 use C4::Context;
-use C4::Log;
 use C4::Koha; # XXX subfield_is_koha_internal_p
-use HTML::Template;
-use MARC::File::USMARC;
-use MARC::File::XML;
-
+use MARC::Record;
+use Encode;
 use vars qw( $tagslib);
 use vars qw( $authorised_values_sth);
 use vars qw( $is_a_modif );
-
+my $input = new CGI;
+my $z3950 = $input->param('z3950');
+#my $logstatus=C4::Context->preference('Activate_log');
+my $xml;
 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);
-}
-
 
 =item MARCfindbreeding
 
-    $record = MARCfindbreeding($dbh, $breedingid);
+    $record = MARCfindbreeding($dbh, $breedingid,$frameworkcode);
 
 Look up the breeding farm with database handle $dbh, for the
 record with id $breedingid.  If found, returns the decoded
@@ -88,17 +52,36 @@
 =cut
 
 sub MARCfindbreeding {
-       my ($dbh,$id) = @_;
-       my $sth = $dbh->prepare("select file,marc,encoding from marc_breeding 
where id=?");
+       my ($dbh,$id,$oldbiblionumber) = @_;
+       my $sth = $dbh->prepare("select marc,encoding from marc_breeding where 
id=?");
        $sth->execute($id);
-       my ($file,$marc,$encoding) = $sth->fetchrow;
+       my ($marc,$encoding) = $sth->fetchrow;
+       $sth->finish;
        if ($marc) {
                my $record = MARC::File::USMARC::decode($marc);
                if (ref($record) eq undef) {
                        return -1;
-               } else {
-                       return $record,$encoding;
                }
+       
+##Delete biblionumber tag in case a similar tag is used in imported MARC
+       my  (  $tagfield,  $tagsubfield )  
=MARCfind_marc_from_kohafield("biblionumber","biblios");
+               my $old_field = $record->field($tagfield);
+               $record->delete_field($old_field);
+               ##add the old biblionumber if a modif but coming from 
breedingfarm
+               if ($oldbiblionumber){
+                       my $newfield;
+                       if ($tagfield<10){
+                       $newfield = MARC::Field->new($tagfield,  
$oldbiblionumber);
+                       }else{
+                       $newfield = MARC::Field->new($tagfield, '', '', 
"$tagsubfield" => $oldbiblionumber);
+                       }       
+               $record->insert_fields_ordered($newfield);
+               }
+       my $xml=  $record->as_xml_record();
+       $xml=Encode::encode('utf8',$xml);
+       my $xmlhash=XML_xml2hash_onerecord($xml);
+               return $xmlhash,$encoding;
+               
        }
        return -1;
 }
@@ -164,10 +147,11 @@
  builds the <input ...> entry for a subfield.
 =cut
 sub create_input () {
-       my ($tag,$subfield,$value,$i,$tabloop,$rec,$authorised_values_sth) = @_;
+       my ($tag,$subfield,$value,$i,$tabloop,$rec,$authorised_values_sth,$id) 
= @_;    
        $value =~ s/"/&quot;/g;
        my $dbh = C4::Context->dbh;
        my %subfield_data;
+       $subfield_data{id}=$id;
        $subfield_data{tag}=$tag;
        $subfield_data{subfield}=$subfield;
        $subfield_data{marc_lib}="<span 
id=\"error$i\">".$tagslib->{$tag}->{$subfield}->{lib}."</span>";
@@ -175,15 +159,14 @@
        $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
-       # it's an authorised field
+       $subfield_data{visibility} = "display:none" if 
(substr($tagslib->{$tag}->{$subfield}->{hidden},2,1) gt "0") ; #check parity
        if ($tagslib->{$tag}->{$subfield}->{authorised_value}) {
                $subfield_data{marc_value}= build_authorized_values_list($tag, 
$subfield, $value, $dbh,$authorised_values_sth);
        # it's a thesaurus / authority field
        } elsif ($tagslib->{$tag}->{$subfield}->{authtypecode}) {
-               $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\" DISABLE READONLY> <a  style=\"cursor: help;\" 
href=\"javascript:Dopop('../authorities/auth_finder.pl?authtypecode=".$tagslib->{$tag}->{$subfield}->{authtypecode}."&index=$i',$i)\">...</a>";
+               
+               $subfield_data{marc_value}="<input 
onblur=\"this.style.backgroundColor='#ffffff';\" 
onfocus=\"this.style.backgroundColor='#ffffff;'\"\" tabindex=\"1\" 
type=\"text\"   name=\"field_value\" id=\"field_value$id\" value=\"$value\" 
size=\"40\" maxlength=\"255\" DISABLE READONLY> <a  style=\"cursor: help;\" 
href=\"javascript:Dopop('../authorities/auth_finder.pl?authtypecode=".$tagslib->{$tag}->{$subfield}->{authtypecode}."&index=$id',$id);\">...</a>";
        # it's a plugin field
        } elsif ($tagslib->{$tag}->{$subfield}->{'value_builder'}) {
                # opening plugin. Just check wether we are on a developper 
computer on a production one
@@ -196,29 +179,31 @@
                require $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";
+               $subfield_data{marc_value}="<input tabindex=\"1\" type=\"text\" 
 name=\"field_value\" id=\"field_value$id\"  value=\"$value\" size=\"40\" 
maxlength=\"255\" DISABLE READONLY 
OnFocus=\"javascript:Focus$function_name($i)\" 
OnBlur=\"javascript:Blur$function_name($i); \"> <a  style=\"cursor: help;\" 
href=\"javascript:Clic$function_name($i)\">...</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\" >";
+               $subfield_data{marc_value}="<input 
onblur=\"this.style.backgroundColor='#ffffff';\" 
onfocus=\"this.style.backgroundColor='#ffffff'; \" tabindex=\"1\" 
type=\"hidden\" name=\"field_value\" id=\"field_value$id\"  value=\"$value\">";
+       } elsif  (substr($tagslib->{$tag}->{$subfield}->{'hidden'},2,1) gt "1") 
{
+
+               $subfield_data{marc_value}="<input 
onblur=\"this.style.backgroundColor='#ffffff';\" 
onfocus=\"this.style.backgroundColor='#ffffff'; \" tabindex=\"1\" type=\"text\" 
name=\"field_value\" id=\"field_value$id\"   value=\"$value\" size=\"40\" 
maxlength=\"255\" >";
        # it's a standard field
        } else {
                if (length($value) >100) {
-                       $subfield_data{marc_value}="<textarea 
name=\"field_value\" cols=\"70\" rows=\"5\" >$value</textarea>";
+                       $subfield_data{marc_value}="<textarea tabindex=\"1\" 
name=\"field_value\" id=\"field_value$id\"  cols=\"40\" 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\">"; #"
+                       $subfield_data{marc_value}="<input 
onblur=\"this.style.backgroundColor='#ffffff';\" 
onfocus=\"this.style.backgroundColor='#ffffff'; \" tabindex=\"1\" type=\"text\" 
name=\"field_value\" id=\"field_value$id\"  value=\"$value\" size=\"50\">"; #"
                }
        }
        return \%subfield_data;
 }
 
-sub build_tabs ($$$$) {
-    my($template, $record, $dbh,$encoding) = @_;
+sub build_tabs  ($$$;$){
+    my($template, $xmlhash, $dbh,$addedfield) = @_;
     # fill arrays
     my @loop_data =();
     my $tag;
     my $i=0;
+my $id=100;
        my $authorised_values_sth = $dbh->prepare("select authorised_value,lib
                from authorised_values
                where category=? order by lib");
@@ -230,47 +215,67 @@
                        my $indicator;
        # 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')) {
-                               my @fields;
-                               if ($tag ne '000') {
-                                       @fields = $record->field($tag);
-                               } else {
-                                       push @fields,$record->leader();
-                               }
-                               foreach my $field (@fields)  {
+                       if ($xmlhash) {
+                       ####
                                        my @subfields_data;
-                                       if ($tag<10) {
-                                               my ($value,$subfield);
-                                               if ($tag ne '000') {
-                                                       $value=$field->data();
-                                                       $subfield="@";
-                                               } else {
-                                                       $value = $field;
-                                                       $subfield='@';
+                       my %definedsubfields;
+                       my $hiddenrequired;
+                       my ($ind1,$ind2);
+                       my $biblio=$xmlhash->{'datafield'};
+                       my $controlfields=$xmlhash->{'controlfield'};
+                       my $leader=$xmlhash->{'leader'};
+                        if ($tag>9){
+                                       foreach my $data (@$biblio){
+                                          if ($data->{'tag'} eq $tag){
+                                           $ind1="  ";
+                                             $ind2="  ";               
+                                             foreach my $subfield ( 
$data->{'subfield'}){
+                                                foreach my $code ( @$subfield){
+                                                       if 
(@$subfield>1){$hiddenrequired=1;}
+                                                       my 
$subfield=$code->{'code'}  ;
+                                                       my 
$value=$code->{'content'};
+                                                       
$definedsubfields{$tag}{$code->{'code'}}=1 ;
+                                                       next if 
($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
+                                                       push(@subfields_data, 
&create_input($tag,$subfield,$value,$i,$tabloop,$xmlhash,$authorised_values_sth,$id));
+                                                       $i++;
+                                               }
+                                             }
+                                           $ind1=$data->{'ind1'};
+                                           $ind2=      $data->{'ind2'};
+                                         }
                                                }
+                        }else{
+                               if ($tag eq "000" || $tag eq "LDR"){
+                                       my $subfield="@";
+                                       my $value=$leader->[0] if $leader->[0];
+                                       $definedsubfields{$tag}{'@'}=1;
                                                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));
+                                       push(@subfields_data, 
&create_input($tag,$subfield,$value,$i,$tabloop,$xmlhash,$authorised_values_sth,$id));
                                    
                                                $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);
+                                }else{
+                                foreach my $control (@$controlfields){
+                                       if ($control->{'tag'} eq $tag){
+                                       my $subfield="@";
+                                       my $value=$control->{'content'} ;
+                                       $definedsubfields{$tag}{'@'}=1;
                                                        next if 
($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
-                                                       push(@subfields_data, 
&create_input($tag,$subfield,$value,$i,$tabloop,$record,$authorised_values_sth));
+                                       push(@subfields_data, 
&create_input($tag,$subfield,$value,$i,$tabloop,$xmlhash,$authorised_values_sth,$id));
                                    
                                                        $i++;
                                                }
                                        }
-# now, loop again to add parameter subfield that are not in the MARC::Record
+                              }
+                       }##tag >9
+
+
+                       #####
+                               
+                               # 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));
+                                               next if 
((substr($tagslib->{$tag}->{$subfield}->{hidden},2,1) gt "1")  ); #check for 
visibility flag
+                                               next if 
($definedsubfields{$tag}{$subfield} );
+                                               push(@subfields_data, 
&create_input($tag,$subfield,'',$i,$tabloop,$xmlhash,$authorised_values_sth,$id));
                                                $i++;
                                        }
                                        if ($#subfields_data >= 0) {
@@ -278,7 +283,7 @@
                                                $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{indicator} = 
$ind1.$ind2 if ($tag>=10);
                                                $tag_data{subfield_loop} = 
address@hidden;
                                                if ($tag<10) {
                                                                                
                        $tag_data{fixedfield} = 1;
@@ -286,11 +291,13 @@
 
                                                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) {
+                                       if ($hiddenrequired && $#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));
+                                               push(@subfields_data, 
&create_input('','','',$i,$tabloop,$xmlhash,$authorised_values_sth,$id));
                                                $tag_data{tag} = '';
                                                $tag_data{tag_lib} = '';
                                                $tag_data{indicator} = '';
@@ -301,15 +308,37 @@
                                                push (@loop_data, \%tag_data);
                                                $i++;
                                        }
+                                       if ($addedfield eq $tag) {
+                                               my %tag_data;
+                                               my @subfields_data;
+                                                       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 
((substr($tagslib->{$tag}->{$subfield}->{hidden},2,1) gt "1")  ); #check for 
visibility flag
+                                               push(@subfields_data, 
&create_input($tag,$subfield,'',$i,$tabloop,$xmlhash,$authorised_values_sth,$id));
+                                               $i++;
+                                                       }
+                                               $tag_data{tag} = $tag;
+                                               $tag_data{tag_lib} = 
$tagslib->{$tag}->{lib};
+                                               $tag_data{repeatable} = 
$tagslib->{$tag}->{repeatable};
+                                               $tag_data{indicator} = 
$ind1.$ind2 if ($tag>=10);
+                                               $tag_data{subfield_loop} = 
address@hidden;
+                                               if ($tag<10) {
+                                                                       
$tag_data{fixedfield} = 1;
+                                                                       }
+                                               push (@loop_data, \%tag_data);
+                                               $i++;
                                }
+                               
        # if breeding is empty
                        } 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 
((substr($tagslib->{$tag}->{$subfield}->{hidden},2,1) gt "1")  ); #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));
+                                       push(@subfields_data, 
&create_input($tag,$subfield,'',$i,$tabloop,$xmlhash,$authorised_values_sth,$id));
                                        $i++;
                                }
                                if ($#subfields_data >= 0) {
@@ -326,6 +355,7 @@
                                        push (@loop_data, \%tag_data);
                                }
                        }
+               $id++;
                }
                $template->param($tabloop."XX" =>address@hidden);
        }
@@ -365,21 +395,21 @@
 #=========================
 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.
-if (!$biblionumber){
-    $biblionumber=$input->param('oldbiblionumber');
-       warn "OLDBIBLIONUMBER".$biblionumber;
-    }
+my $oldbiblionumber=$input->param('oldbiblionumber'); # if bib exists, it's a 
modif, not a new biblio.
 my $breedingid = $input->param('breedingid');
 my $z3950 = $input->param('z3950');
 my $op = $input->param('op');
+my $duplicateok = $input->param('duplicateok');
+
 my $frameworkcode = $input->param('frameworkcode');
 my $dbh = C4::Context->dbh;
+my $biblionumber;
+
+$biblionumber=$oldbiblionumber if $oldbiblionumber;
 
-$frameworkcode = &MARCfind_frameworkcode($dbh,$biblionumber) if ($biblionumber 
and not ($frameworkcode));
 $frameworkcode='' if ($frameworkcode eq 'Default');
 my ($template, $loggedinuser, $cookie)
-    = get_template_and_user({template_name => "acqui.simple/addbiblio.tmpl",
+    = get_template_and_user({template_name => "cataloguing/addbiblio.tmpl",
                             query => $input,
                             type => "intranet",
                             authnotrequired => 0,
@@ -388,7 +418,7 @@
                             });
 
 #Getting the list of all frameworks
-my $queryfwk =$dbh->prepare("select frameworktext, frameworkcode from 
biblio_framework");
+my $queryfwk =$dbh->prepare("select frameworktext, frameworkcode from 
biblios_framework");
 $queryfwk->execute;
 my %select_fwk;
 my @select_fwk;
@@ -409,70 +439,81 @@
                        -size     => 1,
                        -multiple => 0 );
 $template->param( framework => $framework);
-
+my $xmlhash;
+my $xml;
+#####DO NOT RETRIVE FROM ZEBRA######
+my $record =XMLgetbiblio($dbh,$biblionumber) if ($biblionumber);
+$xmlhash=XML_xml2hash_onerecord($record) if ($biblionumber);
+$frameworkcode=MARCfind_frameworkcode( $dbh, $biblionumber );
+###########
 $tagslib = &MARCgettagslib($dbh,1,$frameworkcode);
-my $record=-1;
-my $encoding="";
-#$record = MARCgetbiblio($dbh,$biblionumber) if ($biblionumber);
-$record=get_record($biblionumber) if ($biblionumber);
 
-($record,$encoding) = MARCfindbreeding($dbh,$breedingid) if ($breedingid);
+my $encoding="";
+($xmlhash,$encoding) = MARCfindbreeding($dbh,$breedingid,$oldbiblionumber) if 
($breedingid);
 
 $is_a_modif=0;
-my ($biblionumtagfield,$biblionumtagsubfield);
-my 
($biblioitemnumtagfield,$biblioitemnumtagsubfield,$bibitem,$biblioitemnumber);
-if ($biblionumber) {
+$is_a_modif=1 if $oldbiblionumber; 
+my ($oldbiblionumtagfield,$oldbiblionumtagsubfield);
+if ($biblionumber  && !$z3950) {
        $is_a_modif=1;
-       # if it's a modif, retrieve bibli and biblioitem numbers for the future 
modification of old-DB.
-       ($biblionumtagfield,$biblionumtagsubfield) = 
&MARCfind_marc_from_kohafield($dbh,"biblio.biblionumber",$frameworkcode);
-       ($biblioitemnumtagfield,$biblioitemnumtagsubfield) = 
&MARCfind_marc_from_kohafield($dbh,"biblioitems.biblioitemnumber",$frameworkcode);
-       # search biblioitems value
-       my $sth=$dbh->prepare("select biblioitemnumber from biblioitems where 
biblionumber=?");
-       $sth->execute($biblionumber);
-       ($biblioitemnumber) = $sth->fetchrow;
+       # if it's a modif, retrieve old biblionumber for the future 
modification of old-DB.
+       ($oldbiblionumtagfield,$oldbiblionumtagsubfield) = 
&MARCfind_marc_from_kohafield($dbh,"biblionumber","biblios");
+
+       
 }
 
#------------------------------------------------------------------------------------------------------------------------------
 if ($op eq "addbiblio") {
 
#------------------------------------------------------------------------------------------------------------------------------
        # rebuild
        my @tags = $input->param('tag');
-       my @subfields = $input->param('subfield');
-       my @values = $input->param('field_value');
+       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 = 
MARChtml2xml(address@hidden,address@hidden,address@hidden,address@hidden,address@hidden);
-    my $record=MARC::Record::new_from_xml($xml, 'UTF-8');
-       # check for a duplicate
-       my ($duplicatebiblionumber,$duplicatebibid,$duplicatetitle) = 
FindDuplicate($record) if ($op eq "addbiblio") && (!$is_a_modif);
+       
+       
+       
+## check for malformed xml -- non UTF-8 like (MARC8) will break xml without 
warning
+### This usually happens with data coming from other Z3950 servers
+## Slows the saving process so comment out at your own risk
+eval{
+ $xml = 
MARChtml2xml(address@hidden,address@hidden,address@hidden,address@hidden,address@hidden);
      
+};
+ if ($@){
+warn $@;
+ $template->param(error             =>1,xmlerror=>1,);
+goto FINAL;
+  };
+my $xmlhash=XML_xml2hash_onerecord($xml);
+       my ($duplicatebiblionumber,$duplicatetitle) = FindDuplicate($xmlhash) 
if (($op eq "addbiblio") && (!$is_a_modif) && (!$duplicateok));
        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
+               my $oldbibnum;
+               my $oldbibitemnum;
                if ($is_a_modif) {
-               warn "CONFIRM ITS A MODIF : .$biblionumber";
-                       
NEWmodbiblioframework($dbh,$biblionumber,$frameworkcode);
-                       NEWmodbiblio($dbh,$record,$biblionumber,$frameworkcode);
+                       
NEWmodbiblio($dbh,$biblionumber,$xmlhash,$frameworkcode);
+
                } else {
-                       my $biblioitemnumber;
-                       ($biblionumber,$biblioitemnumber) = 
NEWnewbiblio($dbh,$record,$frameworkcode);
-                       
logaction($loggedinuser,"acqui.simple","add",$biblionumber,"record : 
".$record->as_formatted) if (C4::Context->preference("Activate_Log"));
+
+                       ($biblionumber) = 
NEWnewbiblio($dbh,$xmlhash,$frameworkcode);
+
                }
        # now, redirect to additem page
                print 
$input->redirect("additem.pl?biblionumber=$biblionumber&frameworkcode=$frameworkcode");
                exit;
        } else {
+FINAL:
        # it may be a duplicate, warn the user and do nothing
-               build_tabs ($template, $record, $dbh,$encoding);
+               build_tabs ($template, $xmlhash, $dbh);
                build_hidden_data;
                $template->param(
-                       oldbiblionumber          => $biblionumber,
+                       oldbiblionumber             => $oldbiblionumber,
                        biblionumber             => $biblionumber,
-                       biblionumtagfield        => $biblionumtagfield,
-                       biblionumtagsubfield     => $biblionumtagsubfield,
-                       biblioitemnumtagfield    => $biblioitemnumtagfield,
-                       biblioitemnumtagsubfield => $biblioitemnumtagsubfield,
-                       biblioitemnumber         => $biblioitemnumber,
+                       oldbiblionumtagfield        => $oldbiblionumtagfield,
+                       oldbiblionumtagsubfield     => $oldbiblionumtagsubfield,
                        duplicatebiblionumber           => 
$duplicatebiblionumber,
                        duplicatetitle                          => 
$duplicatetitle,
                         );
@@ -481,65 +522,69 @@
 } elsif ($op eq "addfield") {
 
#------------------------------------------------------------------------------------------------------------------------------
        my $addedfield = $input->param('addfield_field');
-       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 = 
MARChtml2xml(address@hidden,address@hidden,address@hidden,address@hidden,address@hidden);
-    my $record=MARC::Record::new_from_xml($xml, 'UTF-8');
+       my $xmlhash=XML_xml2hash_onerecord($xml);
        # adding an empty field
-       my $field = 
MARC::Field->new("$addedfield",'','','$tagaddfield_subfield' => "");
-       $record->append_fields($field);
-       build_tabs ($template, $record, $dbh,$encoding);
+       build_tabs ($template, $xmlhash, $dbh,$addedfield);
        build_hidden_data;
        $template->param(
-               oldbiblionumber          => $biblionumber,
+               oldbiblionumber             => $oldbiblionumber,
                biblionumber             => $biblionumber,
-               biblionumtagfield        => $biblionumtagfield,
-               biblionumtagsubfield     => $biblionumtagsubfield,
-               biblioitemnumtagfield    => $biblioitemnumtagfield,
-               biblioitemnumtagsubfield => $biblioitemnumtagsubfield,
-               biblioitemnumber         => $biblioitemnumber );
+               oldbiblionumtagfield        => $oldbiblionumtagfield,
+               oldbiblionumtagsubfield     => $oldbiblionumtagsubfield,
+                );
 } elsif ($op eq "delete") {
 
#------------------------------------------------------------------------------------------------------------------------------
-       &NEWdelbiblio($dbh,$biblionumber);
-       logaction($loggedinuser,"acqui.simple","del",$biblionumber,"") if 
(logstatus);
+my $sth=$dbh->prepare("select iss.itemnumber from items i ,issues iss where 
iss.itemnumber=i.itemnumber and iss.returndate is null and  i.biblionumber=?");
+ $sth->execute($biblionumber);
+my $onloan=$sth->fetchrow;
        
-       print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; 
URL=/cgi-bin/koha/search.marc/search.pl?type=intranet\"></html>";
+       if (!$onloan){  
+       NEWdelbiblio($dbh,$biblionumber);
+print  $input->redirect("/cgi-bin/koha/catalogue/catalogue-search.pl");
        exit;
+       }else{
+
+$template->param(error            => 1, onloan=>1,);
+
+goto OUT;
+       }
 
#------------------------------------------------------------------------------------------------------------------------------
 
#------------------------------------------------------------------------------------------------------------------------------
 } else {
 
#------------------------------------------------------------------------------------------------------------------------------
-       # If we're in a duplication case, we have to set to "" the bibid and 
biblionumber
+
+       # 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= "";
+               $biblionumber = "";
+               $oldbiblionumber= "";
+       $template->param(duplicateok            => 1);
        }
-       #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;
-       my $urecord = MARC::Record::new_from_xml($uxml, 'UTF-8'); 
-               $record = $urecord;
-       };
-       build_tabs ($template, $record, $dbh,$encoding);
+       build_tabs ($template, $xmlhash, $dbh);
        build_hidden_data;
        $template->param(
-           oldbiblionumber                      => $biblionumber,
+               oldbiblionumber             => $oldbiblionumber,
                biblionumber             => $biblionumber,
-               biblionumtagfield        => $biblionumtagfield,
-               biblionumtagsubfield     => $biblionumtagsubfield,
-               biblioitemnumtagfield    => $biblioitemnumtagfield,
-               biblioitemnumtagsubfield => $biblioitemnumtagsubfield,
-               biblioitemnumber         => $biblioitemnumber,
+               oldbiblionumtagfield        => $oldbiblionumtagfield,
+               oldbiblionumtagsubfield     => $oldbiblionumtagsubfield         
        
                );
 }
 $template->param(
                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"),
                );
+
 output_html_with_http_headers $input, $cookie, $template->output;

Index: additem.pl
===================================================================
RCS file: /sources/koha/koha/cataloguing/additem.pl,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- additem.pl  3 Apr 2006 04:00:02 -0000       1.7
+++ additem.pl  1 Sep 2006 15:45:01 -0000       1.8
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# $Id: additem.pl,v 1.7 2006/04/03 04:00:02 rangi Exp $
+# $Id: additem.pl,v 1.8 2006/09/01 15:45:01 tgarip1957 Exp $
 
 # Copyright 2000-2002 Katipo Communications
 #
@@ -28,175 +28,280 @@
 use C4::Context;
 use C4::Koha; # XXX subfield_is_koha_internal_p
 use C4::Search;
-use HTML::Template;
-use MARC::File::USMARC;
-use Smart::Comments;
+use C4::Circulation::Circ2;
+use Encode;
+use C4::Log;
+
+my $logstatus=C4::Context->preference('Activate_log');
 
 sub find_value {
        my ($tagfield,$insubfield,$record) = @_;
        my $result;
        my $indicator;
-       foreach my $field ($record->field($tagfield)) {
-               my @subfields = $field->subfields();
-               foreach my $subfield (@subfields) {
-                       if (@$subfield[0] eq $insubfield) {
-                               $result .= @$subfield[1];
-                               $indicator = 
$field->indicator(1).$field->indicator(2);
-                       }
-               }
-       }
+my $item=$record->{datafield};
+my $controlfield=$record->{controlfield};
+my $leader=$record->{leader};
+ if ($tagfield eq '000'){
+## We are getting the leader
+$result=$leader->[0];
+return($indicator,$result);
+}
+     if ($tagfield <10){
+       foreach my $control (@$controlfield) {
+               if ($control->{tag} eq $tagfield){
+               $result.=$control->{content};
+               }
+       }
+      }else{
+       foreach my $field (@$item) {            
+             if ($field->{tag} eq $tagfield){  
+                   foreach my $subfield ( $field->{'subfield'}){
+                      foreach my $code ( @$subfield){
+                       if ($code->{code} eq $insubfield) {
+                               $result .= $code->{content};
+                               $indicator = $field->{ind1}.$field->{ind2};
+                       }
+                     }## each code
+                 }##each subfield
+             }## if tag
+       }### $field
+     }## tag<10
        return($indicator,$result);
 }
 my $input = new CGI;
 my $dbh = C4::Context->dbh;
 my $error = $input->param('error');
 my $biblionumber = $input->param('biblionumber');
-if (!$biblionumber){
-    $biblionumber=$input->param('bibid');
-}
-my $biblioitemnumber = find_biblioitemnumber($dbh,$biblionumber);
-my $itemnumber = $input->param('itemnumber');
-if (!$itemnumber){
-    $itemnumber=$input->param('itemnum');
-    }
-
+my $oldbiblionumber =$biblionumber;
+my $frameworkcode=$input->param('frameworkcode');
 my $op = $input->param('op');
-
-# find itemtype
-my $itemtype = &MARCfind_frameworkcode($dbh,$biblionumber);
-
-my $tagslib = &MARCgettagslib($dbh,1,$itemtype);
-my $record = MARCgetbiblio($dbh,$biblionumber);
-# warn "==>".$record->as_formatted;
-my $oldrecord = MARCmarc2koha($dbh,$record);
+my $itemnumber = $input->param('itemnumber');
+my $fromserials=$input->param('fromserials');## if a serial is being added do 
not display navigation menus
+my $serialid=$input->param('serialid');
+my @itemrecords; ##Builds existing items
+my $bibliorecord; #Bibliorecord relared to this item
+my $newrecord; ## the new record buing built
+my $itemrecexist; #item record we are editing
+my $xml; ## data on html
+ $frameworkcode=MARCfind_frameworkcode($dbh,$biblionumber) unless 
$frameworkcode;
+my $tagslib = &MARCitemsgettagslib($dbh,1,$frameworkcode);
 my $itemrecord;
 my $nextop="additem";
 my @errors; # store errors found while checking data BEFORE saving item.
+
+###DO NOT CHANGE TO RETRIVE FROM ZEBRA#####
+my $record =XMLgetbiblio($dbh,$biblionumber);
+$bibliorecord=XML_xml2hash_onerecord($record);
+my @itemxmls=XMLgetallitems($dbh,$biblionumber);
+       foreach my $itemrecord(@itemxmls){
+       my $itemhash=XML_xml2hash($itemrecord);
+       push @itemrecords, $itemhash;
+       }
+####
+
+my ($template, $loggedinuser, $cookie)
+    = get_template_and_user({template_name => "cataloguing/additem.tmpl",
+                            query => $input,
+                            type => "intranet",
+                            authnotrequired => 0,
+                            flagsrequired => {editcatalogue => 1},
+                            debug => 1,
+                            });
+
 
#------------------------------------------------------------------------------------------------------------------------------
 if ($op eq "additem") {
 
#------------------------------------------------------------------------------------------------------------------------------
        # rebuild
+
        my @tags = $input->param('tag');
        my @subfields = $input->param('subfield');
        my @values = $input->param('field_value');
        # build indicator hash.
        my @ind_tag = $input->param('ind_tag');
        my @indicator = $input->param('indicator');
-       my $xml = 
MARChtml2xml(address@hidden,address@hidden,address@hidden,address@hidden,address@hidden);
-        my $record=MARC::Record::new_from_xml($xml, 'UTF-8');
+       my %indicators;
+       for (my $i=0;$i<=$#ind_tag;$i++) {
+               $indicators{$ind_tag[$i]} = $indicator[$i];
+       }
+## check for malformed xml -- non UTF-8 like (MARC8) will break xml without 
warning
+### This usually happens with data coming from other Z3950 servers
+## Slows the saving process so comment out at your own risk
+eval{
+ $xml = 
MARChtml2xml(address@hidden,address@hidden,address@hidden,address@hidden,address@hidden);
      
+};
+ if ($@){
+push @errors,"non_utf8" ;
+$nextop = "additem";
+goto FINAL;
+  };
+ my $newrecord=XML_xml2hash_onerecord($xml);
+my $newbarcode=XML_readline_onerecord($newrecord,"barcode","holdings");        
+
        # if autoBarcode is ON, calculate barcode...
        if (C4::Context->preference('autoBarcode')) {
-               my ($tagfield,$tagsubfield) = 
&MARCfind_marc_from_kohafield($dbh,"items.barcode");
-               unless ($record->field($tagfield)->subfield($tagsubfield)) {
+               unless ($newbarcode) {
                        my $sth_barcode = $dbh->prepare("select 
max(abs(barcode)) from items");
                        $sth_barcode->execute;
-                       my ($newbarcode) = $sth_barcode->fetchrow;
+                       ($newbarcode) = $sth_barcode->fetchrow;
                        $newbarcode++;
                        # OK, we have the new barcode, now create the entry in 
MARC record
-                       my $fieldItem = $record->field($tagfield);
-                       $record->delete_field($fieldItem);
-                       $fieldItem->add_subfields($tagsubfield => $newbarcode);
-                       $record->insert_fields_ordered($fieldItem);
+                       $newrecord=XML_writeline( $newrecord, "barcode", 
$newbarcode,"holdings" );
                }
        }
 # check for item barcode # being unique
-       my $addedolditem = MARCmarc2koha($dbh,$record);
-       my $exists = get_item_from_barcode($addedolditem->{'barcode'});
-       push @errors,"barcode_not_unique" if($exists);
-       # if barcode exists, don't create, but report The problem.
-       $itemnumber = NEWnewitem($dbh,$record,$biblionumber,$biblioitemnumber) 
unless ($exists);
+       my ($oldrecord)=XMLgetitem($dbh,"",$newbarcode);
+       
+       push @errors,"barcode_not_unique" if($oldrecord);
+# MARC::Record builded => now, record in DB
+## User may be keeping serialids in marc records -- check and add it 
+if ($fromserials){
+$newrecord=XML_writeline( $newrecord, "serialid", $serialid,"holdings" );
+}
+       # if barcode exists, don't create, but report the problem.
+       unless ($oldrecord){
+         $itemnumber=NEWnewitem($dbh,$newrecord,$biblionumber) ;
+               if ($fromserials){
+               my 
$holdingbranch=XML_readline_onerecord($newrecord,"holdingbranch","holdings");   
     
+               $template->param(exit=>1,holdingbranch=>$holdingbranch);
+               }
+       $nextop = "additem";
+       }
+       else{
        $nextop = "additem";
+               $itemrecexist = $newrecord;
+       } 
 
#------------------------------------------------------------------------------------------------------------------------------
 } elsif ($op eq "edititem") {
 
#------------------------------------------------------------------------------------------------------------------------------
 # retrieve item if exist => then, it's a modif
-       $itemrecord = get_record($biblionumber);
+        ($itemrecexist) = XMLfinditem($itemnumber,@itemrecords);## item is 
already in our array-getit
        $nextop="saveitem";
+       
+#logaction($loggedinuser,"acqui.simple","modify",$oldbiblionumber,"item : 
".$itemnumber) if ($logstatus);
+       
 
#------------------------------------------------------------------------------------------------------------------------------
 } elsif ($op eq "delitem") {
 
#------------------------------------------------------------------------------------------------------------------------------
 # retrieve item if exist => then, it's a modif
-       &NEWdelitem($dbh,$biblionumber,$itemnumber);
+my $sth=$dbh->prepare("select * from issues i where i.returndate is null and 
i.itemnumber=?");
+ $sth->execute($itemnumber);
+my $onloan=$sth->fetchrow;
+push @errors,"book_on_loan" if ($onloan);
+       if ($onloan){
+       $nextop = "additem";
+}else{
+       &NEWdelitem($dbh,$itemnumber);
        $nextop="additem";
+}
 
#------------------------------------------------------------------------------------------------------------------------------
 } elsif ($op eq "saveitem") {
 
#------------------------------------------------------------------------------------------------------------------------------
        # rebuild
+#warn "save item";
        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 $itemnumber = $input->param('itemnumber');
-       my $xml = 
MARChtml2xml(address@hidden,address@hidden,address@hidden,address@hidden,address@hidden);
-        my $itemrecord=MARC::Record::new_from_xml($xml, 'UTF-8');
-# MARC::Record builded => now, record in DB
-# warn "R: ".$record->as_formatted;
-       my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = 
NEWmoditem($dbh,$itemrecord,$biblionumber,$itemnumber,0);
+       my $itemnumber = $input->param('itemnumber');
+       my %indicators;
+       for (my $i=0;$i<=$#ind_tag;$i++) {
+               $indicators{$ind_tag[$i]} = $indicator[$i];
+       }
+## check for malformed xml -- non UTF-8 like (MARC8) will break xml without 
warning
+### This usually happens with data coming from other Z3950 servers
+## Slows the saving process so comment out at your own risk
+eval{
+ $xml = 
MARChtml2xml(address@hidden,address@hidden,address@hidden,address@hidden,address@hidden);
      
+};
+        if ($@){
+push @errors,"non_utf8" ;
+$nextop = "edititem";
+goto FINAL;
+  };
+ my $newrecord=XML_xml2hash_onerecord($xml);
+       my $newbarcode=XML_readline_onerecord($newrecord,"barcode","holdings");
+       my ($oldrecord)=XMLgetitem($dbh,"",$newbarcode);
+       $oldrecord=XML_xml2hash_onerecord($oldrecord);
+       my $exist=XML_readline_onerecord($oldrecord,"itemnumber","holdings") if 
$oldrecord;
+       if ($exist && ($exist ne $itemnumber)){
+       push @errors,"barcode_not_unique" ; ## Although editing user may have 
changed the barcode
+       $nextop="edititem";
+       }else{
+        NEWmoditem($dbh,$newrecord,$biblionumber,$itemnumber);
        $itemnumber="";
        $nextop="additem";
+
+       }
 }
 
 #
 
#------------------------------------------------------------------------------------------------------------------------------
 # build screen with existing items. and "new" one
 
#------------------------------------------------------------------------------------------------------------------------------
-my ($template, $loggedinuser, $cookie)
-    = get_template_and_user({template_name => "acqui.simple/additem.tmpl",
-                            query => $input,
-                            type => "intranet",
-                            authnotrequired => 0,
-                            flagsrequired => {editcatalogue => 1},
-                            debug => 1,
-                            });
-
+FINAL:
 my %indicators;
 $indicators{995}='  ';
-# now, build existiing item list
-my $temp = get_record($biblionumber);
-my @fields = $temp->fields();
-#my @fields = $record->fields();
+# now, build existing item list
+
+
+
+my ($itemtagfield,$itemtagsubfield) = 
&MARCfind_marc_from_kohafield("itemnumber","holdings");
+my @itemnums;
+my @fields;
 my %witness; #---- stores the list of subfields used at least once, with the 
"meaning" of the code
 my @big_array;
-#---- finds where items.itemnumber is stored
-my ($itemtagfield,$itemtagsubfield) = 
&MARCfind_marc_from_kohafield($dbh,"items.itemnumber",$itemtype);
-my ($branchtagfield,$branchtagsubfield) = 
&MARCfind_marc_from_kohafield($dbh,"items.homebranch",$itemtype);
-
-foreach my $field (@fields) {
-       next if ($field->tag()<10);
-       my @subf=$field->subfields;
-       my %this_row;
-# loop through each subfield
-       for my $i (0..$#subf) {
-               next if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab}  ne 
10 && ($field->tag() ne $itemtagfield && $subf[$i][0] ne $itemtagsubfield));
-               $witness{$subf[$i][0]} = 
$tagslib->{$field->tag()}->{$subf[$i][0]}->{lib} if 
($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab}  eq 10);
-               $this_row{$subf[$i][0]} =$subf[$i][1] if 
($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab}  eq 10);
-               if (($field->tag eq $branchtagfield) && ($subf[$i][$0] eq 
$branchtagsubfield) && C4::Context->preference("IndependantBranches")) {
-                       #verifying rights
-                       my $userenv = C4::Context->userenv;
-                       unless (($userenv->{'flags'} == 1) or 
(($userenv->{'branch'} eq $subf[$i][1]))){
-                                       $this_row{'nomod'}=1;
-                       }
-               }
-               $this_row{itemnum} = $subf[$i][1] if ($field->tag() eq 
$itemtagfield && $subf[$i][0] eq $itemtagsubfield);
+my @item_value_loop;
+my @header_value_loop;
+unless($fromserials){ ## do not display existing items if adding a serial. It 
could be a looong list
+foreach my $itemrecord (@itemrecords){
+
+my $item=$itemrecord->{datafield};
+my $controlfield=$itemrecord->{controlfield};
+my $leader=$itemrecord->{leader};
+my %this_row;
+       ### The leader
+       unless ($tagslib->{'000'}->{'@'}->{tab}  ne 10 || 
substr($tagslib->{'000'}->{'@'}->{hidden},1,1)>0){
+       my @datasub='000@';
+       $witness{$datasub[0]} = $tagslib->{'000'}->{'@'}->{lib};
+       $this_row{$datasub[0]} =$leader->[0];
+       }## leader
+       foreach my $control (@$controlfield){
+               push @itemnums,$control->{content} if ($control->{tag} eq 
$itemtagfield);
+               next if ($tagslib->{$control->{tag}}->{'@'}->{tab}  ne 10);
+               next if 
(substr($tagslib->{$control->{tag}}->{'@'}->{hidden},1,1)>0);   
+                                       
+                       my @datasub=$control->{tag}.'@';
+                       $witness{$datasub[0]} = 
$tagslib->{$control->{tag}}->{'@'}->{lib};
+                       $this_row{$datasub[0]} =$control->{content};            
        
+       }## Controlfields 
+       foreach my $data (@$item){
+               foreach my $subfield ( $data->{'subfield'}){
+                       foreach my $code ( @$subfield){ 
+                       # loop through each subfield                    
+                       push @itemnums,$code->{content} if ($data->{tag} eq 
$itemtagfield && $code->{code} eq $itemtagsubfield);
+                       next if 
($tagslib->{$data->{tag}}->{$code->{code}}->{tab}  ne 10);
+                       next if 
(substr($tagslib->{$data->{tag}}->{$code->{code}}->{hidden},1,1)>0);
+                       $witness{$data->{tag}.$code->{code}} = 
$tagslib->{$data->{tag}}->{$code->{code}}->{lib};
+                       $this_row{$data->{tag}.$code->{code}} =$code->{content};
        }
+                       
+               }# subfield
+       
+       }## each data
        if (%this_row) {
                push(@big_array, \%this_row);
        }
-}
+}## each record
 #fill big_row with missing datas
 foreach my $subfield_code  (keys(%witness)) {
        for (my $i=0;$i<=$#big_array;$i++) {
                $big_array[$i]{$subfield_code}="&nbsp;" unless 
($big_array[$i]{$subfield_code});
        }
 }
-my ($holdingbrtagf,$holdingbrtagsubf) = 
&MARCfind_marc_from_kohafield($dbh,"items.holdingbranch",$itemtype);
address@hidden = sort {$a->{$holdingbrtagsubf} cmp $b->{$holdingbrtagsubf}} 
@big_array;
-
 # now, construct template !
-my @item_value_loop;
-my @header_value_loop;
+
 for (my $i=0;$i<=$#big_array; $i++) {
        my $items_data;
        foreach my $subfield_code (sort keys(%witness)) {
@@ -204,9 +309,7 @@
        }
        my %row_data;
        $row_data{item_value} = $items_data;
-       $row_data{itemnum} = $big_array[$i]->{itemnum};
-       #reporting this_row values
-       $row_data{'nomod'} = $big_array[$i]{'nomod'};
+       $row_data{itemnumber} = $itemnums[$i];
        push(@item_value_loop,\%row_data);
 }
 foreach my $subfield_code (sort keys(%witness)) {
@@ -214,40 +317,43 @@
        $header_value{header_value} = $witness{$subfield_code};
        push(@header_value_loop, \%header_value);
 }
-
+}## unless from serials
 # next item form
 my @loop_data =();
 my $i=0;
 my $authorised_values_sth = $dbh->prepare("select authorised_value,lib from 
authorised_values where category=? order by lib");
 
 foreach my $tag (sort keys %{$tagslib}) {
+ if ($itemtagfield <10){
+next if($tag==$itemtagfield);
+}
        my $previous_tag = '';
 # loop through each subfield
        foreach my $subfield (sort keys %{$tagslib->{$tag}}) {
                next if subfield_is_koha_internal_p($subfield);
                next if ($tagslib->{$tag}->{$subfield}->{'tab'}  ne "10");
+               next if  ($tagslib->{$tag} eq $itemtagfield && 
$tagslib->{$tag}->{$subfield} eq $itemtagsubfield);
                my %subfield_data;
                $subfield_data{tag}=$tag;
                $subfield_data{subfield}=$subfield;
-#              $subfield_data{marc_lib}=$tagslib->{$tag}->{$subfield}->{lib};
                $subfield_data{marc_lib}="<span 
id=\"error$i\">".$tagslib->{$tag}->{$subfield}->{lib}."</span>";
                
$subfield_data{mandatory}=$tagslib->{$tag}->{$subfield}->{mandatory};
                
$subfield_data{repeatable}=$tagslib->{$tag}->{$subfield}->{repeatable};
+       $subfield_data{hidden}= "display:none" if 
(substr($tagslib->{$tag}->{$subfield}->{hidden},2,1)>0);
+       
                my ($x,$value);
-               ($x,$value) = find_value($tag,$subfield,$itemrecord) if 
($itemrecord);
-               #testing branch value if IndependantBranches.
-               my $test = (C4::Context->preference("IndependantBranches")) && 
-                                       ($tag eq $branchtagfield) && ($subfield 
eq $branchtagsubfield) &&
-                                       (C4::Context->userenv->{flags} != 1) && 
($value) && ($value ne C4::Context->userenv->{branch}) ;
-#              print $input->redirect(".pl?biblionumber=$biblionumber") if 
($test);
+               ($x,$value) = find_value($tag,$subfield,$itemrecexist) if 
($itemrecexist);
                # search for itemcallnumber if applicable
-               if ($tagslib->{$tag}->{$subfield}->{kohafield} eq 
'items.itemcallnumber' && C4::Context->preference('itemcallnumber')) {
+               my 
($itemcntag,$itemcntagsub)=MARCfind_marc_from_kohafield("itemcallnumber","holdings");
+               if ($tag eq $itemcntag && $subfield eq $itemcntagsub && 
C4::Context->preference('itemcallnumber')) {
                        my $CNtag = 
substr(C4::Context->preference('itemcallnumber'),0,3);
                        my $CNsubfield = 
substr(C4::Context->preference('itemcallnumber'),3,1);
-                       my $temp = $record->field($CNtag);
-                       if ($temp) {
-                               $value = $temp->subfield($CNsubfield);
-                       }
+                       my $CNsubfield2 = 
substr(C4::Context->preference('itemcallnumber'),4,1);
+                       my $temp1 = 
XML_readline_onerecord($bibliorecord,"","",$CNtag,$CNsubfield);
+                       my $temp2 = 
XML_readline_onerecord($bibliorecord,"","",$CNtag,$CNsubfield2);
+                       $value = $temp1.' '.$temp2;
+                       $value=~s/^\s+|\s+$//g;
+                       
                }
                if ($tagslib->{$tag}->{$subfield}->{authorised_value}) {
                        my @authorised_values;
@@ -255,15 +361,6 @@
                        # builds list, depending on authorised value...
                        #---- branch
                        if ($tagslib->{$tag}->{$subfield}->{'authorised_value'} 
eq "branches" ) {
-                               if 
((C4::Context->preference("IndependantBranches")) && 
(C4::Context->userenv->{flags} != 1)){
-                                               my $sth=$dbh->prepare("select 
branchcode,branchname from branches where branchcode = ? order by branchname");
-                                               
$sth->execute(C4::Context->userenv->{branch});
-                                               push @authorised_values, "" 
unless ($tagslib->{$tag}->{$subfield}->{mandatory});
-                                               while (my 
($branchcode,$branchname) = $sth->fetchrow_array) {
-                                                       push 
@authorised_values, $branchcode;
-                                                       
$authorised_lib{$branchcode}=$branchname;
-                                               }
-                               } else {
                                        my $sth=$dbh->prepare("select 
branchcode,branchname from branches order by branchname");
                                        $sth->execute;
                                        push @authorised_values, "" unless 
($tagslib->{$tag}->{$subfield}->{mandatory});
@@ -271,7 +368,6 @@
                                                push @authorised_values, 
$branchcode;
                                                
$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");
@@ -292,20 +388,21 @@
                        }
                        $subfield_data{marc_value}= 
CGI::scrolling_list(-name=>'field_value',
                                                                                
                                                                -values=> 
address@hidden,
-                                                                               
                                                                
-default=>"$value",
-                                                                               
                                                                -labels => 
\%authorised_lib,
-                                                                               
                                                                -size=>1,
-                                                                               
                                                                -multiple=>0,
-                                                                               
                                                                );
+                                                                               
                                                                
-default=>"$value",                                                             
                                                                                
-labels => \%authorised_lib,                                                    
                                                                                
        -size=>1,
+                                                                               
                                                                -multiple=>0,   
                                                                                
        );
                } elsif ($tagslib->{$tag}->{$subfield}->{thesaurus_category}) {
-                       $subfield_data{marc_value}="<input type=\"text\" 
name=\"field_value\"  size=47 maxlength=255> <a 
href=\"javascript:Dopop('../thesaurus_popup.pl?category=$tagslib->{$tag}->{$subfield}->{thesaurus_category}&index=$i',$i)\">...</a>";
+                       $subfield_data{marc_value}="<input type=\"text\" 
name=\"field_value\"  size=47 maxlength=255 DISABLE READONLY> <a 
href=\"javascript:Dopop('../authorities/auth_finder.pl?authtypecode=".$tagslib->{$tag}->{$subfield}->{authtypecode}."&index=$i',$i)\">...</a>";
                        #"
                } elsif ($tagslib->{$tag}->{$subfield}->{'value_builder'}) {
-                       my 
$plugin="../value_builder/".$tagslib->{$tag}->{$subfield}->{'value_builder'};
+               my $cgidir = C4::Context->intranetdir ."/cgi-bin/value_builder";
+               unless (opendir(DIR, "$cgidir")) {
+                       $cgidir = C4::Context->intranetdir."/value_builder";
+               } 
+               my 
$plugin=$cgidir."/".$tagslib->{$tag}->{$subfield}->{'value_builder'}; 
                        require $plugin;
-                       my $extended_param = 
plugin_parameters($dbh,$record,$tagslib,$i,0);
-                       my ($function_name,$javascript) = 
plugin_javascript($dbh,$record,$tagslib,$i,0);
-                       $subfield_data{marc_value}="<input type=\"text\" 
name=\"field_value\"  size=47 maxlength=255 DISABLE READONLY 
OnFocus=\"javascript:Focus$function_name($i)\" 
OnBlur=\"javascript:Blur$function_name($i)\"> <a 
href=\"javascript:Clic$function_name($i)\">...</a> $javascript";
+               my $extended_param = 
plugin_parameters($dbh,$newrecord,$tagslib,$i,0);
+               my ($function_name,$javascript) = 
plugin_javascript($dbh,$newrecord,$tagslib,$i,0);
+               $subfield_data{marc_value}="<input type=\"text\" 
name=\"field_value\"  value=\"$value\" size=\"47\" maxlength=\"255\" DISABLE 
READONLY OnFocus=\"javascript:Focus$function_name($i)\" 
OnBlur=\"javascript:Blur$function_name($i)\"> <a 
href=\"javascript:Clic$function_name($i)\">...</a> $javascript";
                } else {
                        $subfield_data{marc_value}="<input type=\"text\" 
name=\"field_value\" value=\"$value\" size=50 maxlength=255>";
                }
@@ -315,21 +412,32 @@
        }
 }
 
+
 # what's the next op ? it's what we are not in : an add if we're editing, 
otherwise, and edit.
 $template->param(item_loop => address@hidden,
                                                item_header_loop => 
address@hidden,
-                                               biblionumber => $biblionumber,
-                                                bibid        => $biblionumber, 
-                                               title => $oldrecord->{title},
-                                               author => $oldrecord->{author},
+                                               biblionumber =>$biblionumber,
+                                               title => 
&XML_readline_onerecord($bibliorecord,"title","biblios"),
+                                               author => 
&XML_readline_onerecord($bibliorecord,"author","biblios"),
                                                item => address@hidden,
                                                itemnumber => $itemnumber,
-                                               itemnum => $itemnumber,
                                                itemtagfield => $itemtagfield,
                                                itemtagsubfield 
=>$itemtagsubfield,
                                                op => $nextop,
-                                               opisadd => ($nextop eq 
"saveitem")?0:1);
+                                               opisadd => ($nextop eq 
"saveitem")?0:1,
+                                               fromserials=>$fromserials, 
serialid=>$serialid,);
 foreach my $error (@errors) {
        $template->param($error => 1);
+
 }
 output_html_with_http_headers $input, $cookie, $template->output;
+
+sub XMLfinditem {
+my ($itemnumber,@itemrecords)address@hidden;
+foreach my $record (@itemrecords){
+my $inumber=XML_readline_onerecord($record,"itemnumber","holdings");
+       if ($inumber ==$itemnumber){
+       return $record;
+       }
+}
+}

Index: addbiblio-nomarc.pl
===================================================================
RCS file: addbiblio-nomarc.pl
diff -N addbiblio-nomarc.pl
--- addbiblio-nomarc.pl 17 Jan 2006 16:40:54 -0000      1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,68 +0,0 @@
-#!/usr/bin/perl
-
-# $Id: addbiblio-nomarc.pl,v 1.1 2006/01/17 16:40:54 tipaul Exp $
-
-#
-# TODO
-#
-# Add info on biblioitems and items already entered as you enter new ones
-#
-
-# Copyright 2000-2002 Katipo Communications
-#
-# This file is part of Koha.
-#
-# 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
-
-# $Log: addbiblio-nomarc.pl,v $
-# Revision 1.1  2006/01/17 16:40:54  tipaul
-# moving acqui.simple directory to cataloguing, as acqui.simple contains 
cataloguing scripts...
-#
-# Revision 1.3  2005/05/04 08:45:22  tipaul
-# synch'ing 2.2 and head
-#
-# Revision 1.2.4.1  2005/03/25 12:52:42  tipaul
-# needs "editcatalogue" flag, not "catalogue"
-#
-# Revision 1.2  2003/05/09 23:47:22  rangi
-# This script is now templated
-# 3 more to go i think
-#
-
-use CGI;
-use strict;
-use C4::Output;
-use HTML::Template;
-use C4::Auth;
-use C4::Interface::CGI::Output;
-
-my $input = new CGI;
-my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
-    {
-        template_name   => "acqui.simple/addbiblio-nomarc.tmpl",
-        query           => $input,
-        type            => "intranet",
-        authnotrequired => 0,
-        flagsrequired   => { editcatalogue => 1 },
-        debug           => 1,
-    }
-);
-
-my $error = $input->param('error');
-
-$template->param(
-    ERROR => $error,
-);
-
-output_html_with_http_headers $input, $cookie, $template->output;

Index: additem-nomarc.pl
===================================================================
RCS file: additem-nomarc.pl
diff -N additem-nomarc.pl
--- additem-nomarc.pl   27 Jul 2006 13:52:49 -0000      1.4
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,220 +0,0 @@
-#!/usr/bin/perl
-
-# $Id: additem-nomarc.pl,v 1.4 2006/07/27 13:52:49 toins Exp $
-
-# 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
-
-# $Log: additem-nomarc.pl,v $
-# Revision 1.4  2006/07/27 13:52:49  toins
-# 1 sub renamed and cleaned.
-#
-# Revision 1.3  2006/07/21 10:12:00  toins
-# subs renamed according to coding guidelines.
-#
-# Revision 1.2  2006/07/12 17:17:12  toins
-# getitemtypes renamed to GetItemTypes
-#
-# Revision 1.1  2006/01/17 16:40:54  tipaul
-# moving acqui.simple directory to cataloguing, as acqui.simple contains 
cataloguing scripts...
-#
-# Revision 1.8  2005/10/26 09:11:34  tipaul
-# big commit, still breaking things...
-#
-# * synch with rel_2_2. Probably the last non manual synch, as rel_2_2 should 
not be modified deeply.
-# * code cleaning (cleaning warnings from perl -w) continued
-#
-# Revision 1.4.2.1  2005/03/25 12:52:44  tipaul
-# needs "editcatalogue" flag, not "catalogue"
-#
-# Revision 1.4  2004/11/19 16:41:49  tipaul
-# improving behaviour when MARC=OFF
-#
-# Revision 1.3  2004/08/13 16:37:25  tipaul
-# adding frameworkcode to API in some subs
-#
-# Revision 1.2  2003/05/11 06:59:11  rangi
-# Mostly templated.
-# Still needs some work
-#
-
-use CGI;
-use strict;
-use C4::Biblio;
-use C4::Koha;
-use C4::Output;
-use HTML::Template;
-use C4::Auth;
-use C4::Interface::CGI::Output;
-
-my $input        = new CGI;
-my $biblionumber = $input->param('biblionumber');
-my $error        = $input->param('error');
-my $maxbarcode;
-my $isbn;
-my $bibliocount;
-my @biblios;
-my $biblioitemcount;
-my @biblioitems;
-# my @branches;
-# my %branchnames;
-my $itemcount;
-my @items;
-
-if ( !$biblionumber ) {
-       print $input->redirect('addbooks.pl');
-}
-else {
-       my $input = new CGI;
-       my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
-               {
-                       template_name   => "acqui.simple/additem-nomarc.tmpl",
-                       query           => $input,
-                       type            => "intranet",
-                       authnotrequired => 0,
-                       flagsrequired   => { editcatalogue => 1 },
-                       debug           => 1,
-               }
-       );
-       ( $bibliocount, @biblios ) = &getbiblio($biblionumber);
-
-       if ( !$bibliocount ) {
-               print $input->redirect('addbooks.pl');
-       }
-       else {
-               @biblioitems = &GetBiblioItemByBiblioNumber($biblionumber);
-        $biblioitemcount = scalar @biblioitems;
-               my $branches = GetBranches;
-               my @branchloop;
-               foreach my $thisbranch (sort keys %$branches) {
-                       my %row =(value => $thisbranch,
-                                               branchname => 
$branches->{$thisbranch}->{'branchname'},
-                                       );
-                       push @branchloop, \%row;
-               }
-               my $itemtypes = &GetItemTypes;
-               my @itemtypeloop;
-               foreach my $thisitemtype (sort keys %$itemtypes) {
-                       my %row =(value => $thisitemtype,
-                                               description => 
$itemtypes->{$thisitemtype}->{'description'},
-                                       );
-                       push @itemtypeloop, \%row;
-               }
-               if ( $error eq "nobarcode" ) {
-                       $template->param( NOBARCODE => 1 );
-               }
-               elsif ( $error eq "nobiblioitem" ) {
-                       $template->param( NOBIBLIOITEM => 1 );
-               }
-               elsif ( $error eq "barcodeinuse" ) {
-                       $template->param( BARCODEINUSE => 1 );
-               }    # elsif
-
-               for ( my $i = 0 ; $i < $biblioitemcount ; $i++ ) {
-                       if ( $biblioitems[$i]->{'itemtype'} eq "WEB" ) {
-                               $biblioitems[$i]->{'WEB'} = 1;
-                       }
-                       $biblioitems[$i]->{'dewey'} =~ /(\d*\.\d\d)/;
-                       $biblioitems[$i]->{'dewey'} = $1;
-                       ( $itemcount, @items ) = &getitemsbybiblioitem( 
$biblioitems[$i]->{'biblioitemnumber'} );
-                       $biblioitems[$i]->{'items'} = address@hidden;
-               }    # for
-               $template->param(
-                       BIBNUM    => $biblionumber,
-                       AUTHOR    => $biblios[0]->{'author'},
-                       TITLE     => $biblios[0]->{'title'},
-                       COPYRIGHT => $biblios[0]->{'copyrightdate'},
-                       SERIES    => $biblios[0]->{'seriestitle'},
-                       NOTES     => $biblios[0]->{'notes'},
-                       BIBITEMS  => address@hidden,
-                       branchloop  => address@hidden,
-                       itemtypeloop => address@hidden,
-
-    ( $bibliocount, @biblios ) = &getbiblio($biblionumber);
-
-    if ( !$bibliocount ) {
-        print $input->redirect('addbooks.pl');
-    }
-    else {
-
-        @biblioitems =&GetBiblioItemByBiblioNumber($biblionumber);
-        $biblioitemcount = scalar @biblioitems;
-        @branches   = &GetBranches;
-        ( $itemtypecount, @itemtypes ) = &GetItemTypes;
-
-        for ( my $i = 0 ; $i < $itemtypecount ; $i++ ) {
-            $itemtypedescriptions{ $itemtypes[$i]->{'itemtype'} } =
-              $itemtypes[$i]->{'description'};
-        }    # for
-
-        for ( my $i = 0 ; $i < $#branches ; $i++ ) {
-            $branchnames{ $branches[$i]->{'branchcode'} } =
-              $branches[$i]->{'branchname'};
-        }    # for
-
-        #      print $input->header;
-        #      print startpage();
-        #      print startmenu('acquisitions');
-        my $input = new CGI;
-        my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
-            {
-                template_name   => "acqui.simple/additem-nomarc.tmpl",
-                query           => $input,
-                type            => "intranet",
-                authnotrequired => 0,
-                flagsrequired   => { editcatalogue => 1 },
-                debug           => 1,
-            }
-        );
-
-        if ( $error eq "nobarcode" ) {
-            $template->param( NOBARCODE => 1 );
-        }
-        elsif ( $error eq "nobiblioitem" ) {
-            $template->param( NOBIBLIOITEM => 1 );
-        }
-        elsif ( $error eq "barcodeinuse" ) {
-            $template->param( BARCODEINUSE => 1 );
-        }    # elsif
-
-        for ( my $i = 0 ; $i < $biblioitemcount ; $i++ ) {
-            if ( $biblioitems[$i]->{'itemtype'} eq "WEB" ) {
-                $biblioitems[$i]->{'WEB'} = 1;
-
-            }
-            $biblioitems[$i]->{'dewey'} =~ /(\d*\.\d\d)/;
-            $biblioitems[$i]->{'dewey'} = $1;
-            ( $itemcount, @items ) =
-              &getitemsbybiblioitem( $biblioitems[$i]->{'biblioitemnumber'} );
-            $biblioitems[$i]->{'items'} = address@hidden;
-        }    # for
-        $template->param(
-            BIBNUM    => $biblionumber,
-            AUTHOR    => $biblios[0]->{'author'},
-            TITLE     => $biblios[0]->{'title'},
-            COPYRIGHT => $biblios[0]->{'copyrightdate'},
-            SERIES    => $biblios[0]->{'seriestitle'},
-            NOTES     => $biblios[0]->{'notes'},
-            BIBITEMS  => address@hidden,
-            BRANCHES  => address@hidden,
-            ITEMTYPES => address@hidden,
-
-        );
-
-        output_html_with_http_headers $input, $cookie, $template->output;
-    }    # if
-}    # if

Index: keywordsearch.pl
===================================================================
RCS file: keywordsearch.pl
diff -N keywordsearch.pl
--- keywordsearch.pl    17 Jan 2006 16:40:54 -0000      1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,123 +0,0 @@
-#!/usr/bin/perl
-
-
-# Copyright 2000-2002 Katipo Communications
-#
-# This file is part of Koha.
-#
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
-#
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA  02111-1307 USA
-
-use CGI;
-use strict;
-# use C4::Catalogue;
-use C4::Biblio;
-use C4::Search;
-use C4::Output;
-
-my $input    = new CGI;
-my $keywords = $input->param('keyword');
-my $offset   = $input->param('offset');
-my $num      = $input->param('num');
-my $total;
-my $count;
-my @results;
-
-if (! $keywords) {
-    print $input->redirect('addbooks.pl');
-} else {
-    if (! $offset) { $offset = 0 };
-    if (! $num) { $num = 10 };
-    my %search;
-    $search{'keyword'}=$keywords;
-    ($count, @results) = KeywordSearch(undef,'intra',\%search,$num,$offset);
-
-    if ($count < ($offset + $num)) {
-        $total = $count;
-    } else {
-       $total = $offset + $num;
-    } # else
-
-    print $input->header;
-    print startpage();
-    print startmenu('acquisitions');
-
-    print << "EOF";
-<font size="6"><em>Biblio Search Results</em></font><br />
-<CENTER>
-You searched on <b>keywords $keywords,</b> $count results found <br />
-Results $offset to $total displayed
-<div align="right">
-<h2><a href="addbiblio.pl">Add New Biblio</a></h2>
-</div>
-<p />
-<table border="0" cellspacing="0" cellpadding="5">
-<tr valign=top bgcolor=#cccc99>
-<td background="/images/background-mem.gif"><b>TITLE</b></td>
-<td background="/images/background-mem.gif"><b>AUTHOR</b></td>
-<td background="/images/background-mem.gif"><b>&copy;</b></td>
-</tr>
-EOF
-
-    for (my $i = 0; $i < ($total - $offset); $i++) {
-       if ($i % 2) {
-           print << "EOF";
-<tr valign="top" bgcolor="#ffffcc">
-EOF
-       } else {
-           print << "EOF";
-<tr valign="top" bgcolor="#ffffff">
-EOF
-       } # else
-
-       print << "EOF";
-<td><a 
href="additem.pl?biblionumber=$results[$i]->{'biblionumber'}">$results[$i]->{'title'}</a></td>
-<td><a 
href="additem.pl?biblionumber=$results[$i]->{'biblionumber'}">$results[$i]->{'author'}</a></td>
-<td>$results[$i]->{'copyrightdate'}</td>
-</tr>
-EOF
-    } # for
-
-    print << "EOF";
-<tr valign=top bgcolor=#cccc99>
-<td background="/images/background-mem.gif">&nbsp;</td>
-<td background="/images/background-mem.gif">&nbsp;</td>
-<td background="/images/background-mem.gif">&nbsp;</td>
-</tr>
-</table>
-<br />
-EOF
-
-    for (my $i = 0; ($i * $num) < $count; $i++) {
-       my $newoffset = $i * $num;
-       my $shownumber = $i + 1;
-       print << "EOF";
-<a 
href="keywordsearch.pl?keyword=$keywords&offset=$newoffset&num=$num">$shownumber</a>
-EOF
-    } # for
-
-    print << "EOF";
-<p />
-Results per page:
-<a href="keywordsearch.pl?keyword=$keywords&offset=$offset&num=5">5</a>
-<a href="keywordsearch.pl?keyword=$keywords&offset=$offset&num=10">10</a>
-<a href="keywordsearch.pl?keyword=$keywords&offset=$offset&num=20">20</a>
-<a href="keywordsearch.pl?keyword=$keywords&offset=$offset&num=50">50</a>
-</CENTER>
-<br clear="all" />
-<p>&nbsp;</p>
-EOF
-
-    print endmenu();
-    print endpage();
-} # else

Index: savebiblio.pl
===================================================================
RCS file: savebiblio.pl
diff -N savebiblio.pl
--- savebiblio.pl       17 Jan 2006 16:40:54 -0000      1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,57 +0,0 @@
-#!/usr/bin/perl
-
-# Copyright 2000-2002 Katipo Communications
-#
-# This file is part of Koha.
-#
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
-#
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA  02111-1307 USA
-
-use CGI;
-use strict;
-# use C4::Catalogue;
-use C4::Biblio;
-
-my $input  = new CGI;
-my $biblio = {
-    title    => $input->param('title'),
-    subtitle => $input->param('subtitle') ? $input->param('subtitle') : "",
-    author   => $input->param('author') ? $input->param('author') : "",
-    seriestitle => $input->param('seriestitle') ? $input->param('seriestitle')
-    : "",
-    copyrightdate => $input->param('copyrightdate')
-    ? $input->param('copyrightdate')
-    : "",
-    abstract => $input->param('abstract') ? $input->param('abstract') : "",
-    notes    => $input->param('notes')    ? $input->param('notes')    : ""
-};    # my $biblio
-
-my $subjectheadings = $input->param('subjectheadings');
-# Different O.S.es use different codes to end lines. This ensures that all 
cases
-# are allowed for.
-my @subjects = split ( /\n|\r|\n\r|\r\n/, $subjectheadings );
-my $biblionumber;
-my $aauthors = $input->param('additionalauthors');
-my @authors  = split ( /\n|\r|\n\r|\r\n/, $aauthors );
-my $force    = $input->param('force');
-
-if ( !$biblio->{'title'} ) {
-    print $input->redirect('addbiblio-nomarc.pl?error=notitle');
-}
-else {
-    $biblionumber = &newbiblio($biblio);
-    &newsubtitle( $biblionumber, $biblio->{'subtitle'} );
-    my $error = modsubject( $biblionumber, 1, @subjects );
-    modaddauthor( $biblionumber, @authors );
-    print $input->redirect("additem-nomarc.pl?biblionumber=$biblionumber");
-}    # else

Index: saveitem.pl
===================================================================
RCS file: saveitem.pl
diff -N saveitem.pl
--- saveitem.pl 17 Jan 2006 16:40:54 -0000      1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,95 +0,0 @@
-#!/usr/bin/perl
-
-# $Id: saveitem.pl,v 1.1 2006/01/17 16:40:54 tipaul Exp $
-
-# 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 CGI;
-use strict;
-# use C4::Catalogue;
-use C4::Biblio;
-
-my $input            = new CGI;
-my $barcode          = $input->param('barcode');
-my $biblionumber     = $input->param('biblionumber');
-my $biblioitemnumber = $input->param('biblioitemnumber');
-my $item             = {
-    biblionumber     => $biblionumber,
-    biblioitemnumber => $biblioitemnumber?$biblioitemnumber:"",
-    homebranch       => $input->param('homebranch'),
-    holdingbranch       => $input->param('homebranch'),
-    replacementprice => 
$input->param('replacementprice')?$input->param('replacementprice'):"",
-    itemnotes        => $input->param('notes')?$input->param('notes'):""
-}; # my $item
-my $biblioitem       = {
-    biblionumber      => $biblionumber,
-    itemtype          => $input->param('itemtype'),
-    isbn              => $input->param('isbn')?$input->param('isbn'):"",
-    publishercode     => 
$input->param('publishercode')?$input->param('publishercode'):"",
-    publicationyear   => 
$input->param('publicationyear')?$input->param('publicationyear'):"",
-    place             => $input->param('place')?$input->param('place'):"",
-    illus             => $input->param('illus')?$input->param('illus'):"",
-    url               => $input->param('url')?$input->param('url'):"",
-    dewey             => $input->param('dewey')?$input->param('dewey'):"",
-    subclass          => 
$input->param('subclass')?$input->param('subclass'):"",
-    issn              => $input->param('issn')?$input->param('issn'):"",
-    lccn              => $input->param('lccn')?$input->param('lccn'):"",
-    volume            => $input->param('volume')?$input->param('volume'):"",
-    number            => $input->param('number')?$input->param('number'):"",
-    volumeddesc       => 
$input->param('volumeddesc')?$input->param('volumeddesc'):"",
-    pages             => $input->param('pages')?$input->param('pages'):"",
-    size              => $input->param('size')?$input->param('size'):"",
-    notes             => 
$input->param('itemnotes')?$input->param('itemnotes'):""
-}; # my biblioitem
-my $newgroup = 0;
-my $website  = 0;
-my $count;
-my @results;
-
-if ($input->param('newgroup')) {
-    $newgroup = 1;
-    if ($biblioitem->{'itemtype'} eq "WEB") {
-       $website = 1;
-    } # if
-} # if
-
-if (! $biblionumber) {
-    print $input->redirect('addbooks.pl');
-} elsif ((! $barcode) && (! $website)) {
-    print 
$input->redirect("additem-nomarc.pl?biblionumber=$biblionumber&error=nobarcode");
-} elsif ((! $newgroup) && (! $biblioitemnumber)) {
-    print 
$input->redirect("additem-nomarc.pl?biblionumber=$biblionumber&error=nobiblioitem");
-} else {
-
-    if ($website) {
-       &newbiblioitem($biblioitem);
-               print 
$input->redirect("additem-nomarc.pl?biblionumber=$biblionumber");
-    } elsif (&checkitems(1,$barcode)) {
-       print 
$input->redirect("additem-nomarc.pl?biblionumber=$biblionumber&error=barcodeinuse");
-    } else {
-
-       if ($newgroup) {
-           $biblioitemnumber = &newbiblioitem($biblioitem);
-           $item->{'biblioitemnumber'} = $biblioitemnumber;
-       } # if
-
-       &newitems($item, ($barcode));
-
-       print $input->redirect("additem-nomarc.pl?biblionumber=$biblionumber");
-    } # else
-} # else

Index: thesaurus_popup.pl
===================================================================
RCS file: thesaurus_popup.pl
diff -N thesaurus_popup.pl
--- thesaurus_popup.pl  17 Jan 2006 16:40:54 -0000      1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,126 +0,0 @@
-#!/usr/bin/perl
-
-# written 10/5/2002 by Paul
-# build result field using bibliothesaurus table
-
-
-# Copyright 2000-2002 Katipo Communications
-#
-# This file is part of Koha.
-#
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
-#
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA  02111-1307 USA
-
-use strict;
-use C4::Auth;
-use CGI;
-use C4::Context;
-use HTML::Template;
-use C4::Search;
-use C4::Output;
-use C4::Authorities;
-use C4::Interface::CGI::Output;
-# get all the data ....
-my %env;
-
-my $input = new CGI;
-my $result = $input->param('result');
-my $search_string= $input->param('search_string');
-$search_string = $result unless ($search_string);
-my $op = $input->param('op');
-my $id = $input->param('id');
-my $category = $input->param('category');
-my $index= $input->param('index');
-my $insert = $input->param('insert');
-my $nohierarchy = $input->param('nohierarchy'); # if 1, just show the last 
part of entry (Marseille). If 0, show everything (Europe -- France --Marseille)
-my $dbh = C4::Context->dbh;
-
-# make the page ...
-#print $input->header;
-if ($op eq "select") {
-       my $sti = $dbh->prepare("select father,stdlib from bibliothesaurus 
where id=?");
-       $sti->execute($id);
-       my ($father,$freelib_text) = $sti->fetchrow_array;
-       if (length($result)>0) {
-               if ($nohierarchy) {
-                       $result .= "|$freelib_text";
-               } else {
-                       $result .= "|$father $freelib_text";
-               }
-       } else {
-               if ($nohierarchy) {
-                       $result = "$freelib_text";
-               } else {
-                       $result = "$father $freelib_text";
-               }
-       }
-}
-if ($op eq "add") {
-       newauthority($dbh,$category,$insert,$insert,'',1,'');
-       $search_string=$insert;
-}
-my ($template, $loggedinuser, $cookie)
-    = get_template_and_user({template_name => "thesaurus_popup.tmpl",
-                            query => $input,
-                            type => "intranet",
-                            authnotrequired => 0,
-                            flagsrequired => {parameters => 1},
-                            debug => 1,
-                            });
-# /search thesaurus terms starting by search_string
-my @freelib;
-my %stdlib;
-my $select_list;
-if ($search_string) {
-#      my $sti=$dbh->prepare("select id,freelib from bibliothesaurus where 
freelib like '".$search_string."%' and category ='$category'");
-       my $sti=$dbh->prepare("select id,freelib,father from bibliothesaurus 
where match (category,freelib) AGAINST (?) and category =?");
-       $sti->execute($search_string,$category);
-       while (my $line=$sti->fetchrow_hashref) {
-               if ($nohierarchy) {
-                       $stdlib{$line->{'id'}} = "$line->{'freelib'}";
-               } else {
-                       $stdlib{$line->{'id'}} = "$line->{'father'} 
$line->{'freelib'}";
-               }
-               push(@freelib,$line->{'id'});
-       }
-       $select_list= CGI::scrolling_list( -name=>'id',
-                       -values=> address@hidden,
-                       -default=> "",
-                       -size=>1,
-                       -multiple=>0,
-                       -labels=> \%stdlib
-                       );
-}
-my @x = SearchDeeper('',$category,$search_string);
-#my @son;
-#foreach (my $value @$x) {
-#      warn address@hidden>{'stdlib'};
-#}
-my $dig_list= CGI::scrolling_list( -name=>'search_string',
-               -values=> address@hidden,
-               -default=> "",
-               -size=>1,
-               -multiple=>0,
-               );
-
-$template->param(select_list => $select_list,
-                                               search_string => $search_string,
-                                               dig_list => $dig_list,
-                                               result => $result,
-                                               category => $category,
-                                               index => $index,
-                                               nohierarchy => $nohierarchy,
-                                               );
-output_html_with_http_headers $input, $cookie, $template->output;
-
-

Index: websitesearch.pl
===================================================================
RCS file: websitesearch.pl
diff -N websitesearch.pl
--- websitesearch.pl    17 Jan 2006 16:40:54 -0000      1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,119 +0,0 @@
-#!/usr/bin/perl
-
-
-# Copyright 2000-2002 Katipo Communications
-#
-# This file is part of Koha.
-#
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
-#
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA  02111-1307 USA
-
-use CGI;
-use strict;
-# use C4::Catalogue;
-use C4::Biblio;
-use C4::Output;
-
-my $input    = new CGI;
-my $keywords = $input->param('keyword');
-my $offset   = $input->param('offset');
-my $num      = $input->param('num');
-my $total;
-my $count;
-my @results;
-
-if (! $keywords) {
-    print $input->redirect('addbooks.pl');
-} else {
-    if (! $offset) { $offset = 0 };
-    if (! $num) { $num = 10 };
-
-    ($count, @results) = &websitesearch($keywords);
-
-    if ($count < ($offset + $num)) {
-        $total = $count;
-    } else {
-       $total = $offset + $num;
-    } # else
-
-    print $input->header;
-    print startpage();
-    print startmenu('acquisitions');
-
-    print << "EOF";
-<font size="6"><em>Website Search Results</em></font><br />
-<CENTER>
-You searched on <b>keywords $keywords,</b> $count results found <br />
-Results $offset to $total displayed
-<div align="right">
-<h2><a href="addbiblio.pl">Add New Biblio</a></h2>
-</div>
-<p />
-<table border="0" cellspacing="0" cellpadding="5">
-<tr valign=top bgcolor=#cccc99>
-<td background="/images/background-mem.gif"><b>TITLE</b></td>
-<td background="/images/background-mem.gif"><b>AUTHOR</b></td>
-<td background="/images/background-mem.gif"><b>&copy;</b></td>
-</tr>
-EOF
-
-    for (my $i = $offset; $i < $total; $i++) {
-       if ($i % 2) {
-           print << "EOF";
-<tr valign="top" bgcolor="#ffffcc">
-EOF
-       } else {
-           print << "EOF";
-<tr valign="top" bgcolor="#ffffff">
-EOF
-       } # else
-
-       print << "EOF";
-<td><a 
href="additem.pl?biblionumber=$results[$i]->{'biblionumber'}">$results[$i]->{'title'}</a></td>
-<td><a 
href="additem.pl?biblionumber=$results[$i]->{'biblionumber'}">$results[$i]->{'author'}</a></td>
-<td>$results[$i]->{'copyrightdate'}</td>
-</tr>
-EOF
-    } # for
-    print << "EOF";
-<tr valign=top bgcolor=#cccc99>
-<td background="/images/background-mem.gif">&nbsp;</td>
-<td background="/images/background-mem.gif">&nbsp;</td>
-<td background="/images/background-mem.gif">&nbsp;</td>
-</tr>
-</table>
-<br />
-EOF
-
-    for (my $i = 0; ($i * $num) < $count; $i++) {
-       my $newoffset = $i * $num;
-       print << "EOF";
-<a href="keywordsearch.pl?keyword=$keywords&offset=$newoffset&num=$num">$i</a>
-EOF
-    } # for
-
-    print << "EOF";
-<p />
-Results per page:
-<a href="keywordsearch.pl?keyword=$keywords&offset=$offset&num=5">5</a>
-<a href="keywordsearch.pl?keyword=$keywords&offset=$offset&num=10">10</a>
-<a href="keywordsearch.pl?keyword=$keywords&offset=$offset&num=20">20</a>
-<a href="keywordsearch.pl?keyword=$keywords&offset=$offset&num=50">50</a>
-</CENTER>
-<br clear="all" />
-<p>&nbsp;</p>
-EOF
-
-    print endmenu();
-    print endpage();
-} # else




reply via email to

[Prev in Thread] Current Thread [Next in Thread]