[Koha-cvs] CVS: koha/C4 Biblio.pm,1.90,1.91 Koha.pm,1.19,1.20

Paul POULAIN tipaul at users.sourceforge.net
Thu Jun 3 12:03:05 CEST 2004


Update of /cvsroot/koha/koha/C4
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24846/C4

Modified Files:
	Biblio.pm Koha.pm 
Log Message:
* frameworks and itemtypes are independant
* in the MARC editor, showing the + to duplicate a tag only if the tag is repeatable

Index: Biblio.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Biblio.pm,v
retrieving revision 1.90
retrieving revision 1.91
diff -C2 -r1.90 -r1.91
*** Biblio.pm	28 May 2004 08:25:53 -0000	1.90
--- Biblio.pm	3 Jun 2004 10:03:01 -0000	1.91
***************
*** 51,55 ****
  	&MARCfind_marc_from_kohafield
  	&MARCfindsubfield
! 	&MARCfind_itemtype
  	&MARCgettagslib
  
--- 51,55 ----
  	&MARCfind_marc_from_kohafield
  	&MARCfindsubfield
! 	&MARCfind_frameworkcode
  	&MARCgettagslib
  
***************
*** 222,245 ****
  
  sub MARCgettagslib {
! 	my ($dbh,$forlibrarian,$itemtype)= @_;
! 	$itemtype="" unless $itemtype;
  	my $sth;
  	my $libfield = ($forlibrarian eq 1)? 'liblibrarian' : 'libopac';
! 	# check that itemtype framework exists
! 	$sth=$dbh->prepare("select count(*) from marc_tag_structure where itemtype=? order by ?");
! 	$sth->execute($itemtype,$itemtype);
  	my ($total) = $sth->fetchrow;
! 	$itemtype="" unless ($total >0);
! 	$sth=$dbh->prepare("select tagfield,$libfield as lib,mandatory from marc_tag_structure where itemtype=? order by tagfield");
! 	$sth->execute($itemtype);
  	my ($lib,$tag,$res,$tab,$mandatory,$repeatable);
! 	while ( ($tag,$lib,$mandatory) = $sth->fetchrow) {
  		$res->{$tag}->{lib}=$lib;
  		$res->{$tab}->{tab}=""; # XXX
  		$res->{$tag}->{mandatory}=$mandatory;
  	}
  
! 	$sth=$dbh->prepare("select tagfield,tagsubfield,$libfield as lib,tab, mandatory, repeatable,authorised_value,thesaurus_category,value_builder,kohafield,seealso,hidden,isurl from marc_subfield_structure where itemtype=? order by tagfield,tagsubfield");
! 	$sth->execute($itemtype);
  
  	my $subfield;
--- 222,246 ----
  
  sub MARCgettagslib {
! 	my ($dbh,$forlibrarian,$frameworkcode)= @_;
! 	$frameworkcode="" unless $frameworkcode;
  	my $sth;
  	my $libfield = ($forlibrarian eq 1)? 'liblibrarian' : 'libopac';
! 	# check that framework exists
! 	$sth=$dbh->prepare("select count(*) from marc_tag_structure where frameworkcode=?");
! 	$sth->execute($frameworkcode);
  	my ($total) = $sth->fetchrow;
! 	$frameworkcode="" unless ($total >0);
! 	$sth=$dbh->prepare("select tagfield,$libfield as lib,mandatory,repeatable from marc_tag_structure where frameworkcode=? order by tagfield");
! 	$sth->execute($frameworkcode);
  	my ($lib,$tag,$res,$tab,$mandatory,$repeatable);
! 	while ( ($tag,$lib,$mandatory,$repeatable) = $sth->fetchrow) {
  		$res->{$tag}->{lib}=$lib;
  		$res->{$tab}->{tab}=""; # XXX
  		$res->{$tag}->{mandatory}=$mandatory;
+ 		$res->{$tag}->{repeatable}=$repeatable;
  	}
  
! 	$sth=$dbh->prepare("select tagfield,tagsubfield,$libfield as lib,tab, mandatory, repeatable,authorised_value,thesaurus_category,value_builder,kohafield,seealso,hidden,isurl from marc_subfield_structure where frameworkcode=? order by tagfield,tagsubfield");
! 	$sth->execute($frameworkcode);
  
  	my $subfield;
***************
*** 294,298 ****
  sub MARCaddbiblio {
  # pass the MARC::Record to this function, and it will create the records in the marc tables
! 	my ($dbh,$record,$biblionumber,$bibid) = @_;
  	my @fields=$record->fields();
  # 	warn "IN MARCaddbiblio $bibid => ".$record->as_formatted;
--- 295,299 ----
  sub MARCaddbiblio {
  # pass the MARC::Record to this function, and it will create the records in the marc tables
! 	my ($dbh,$record,$biblionumber,$frameworkcode,$bibid) = @_;
  	my @fields=$record->fields();
  # 	warn "IN MARCaddbiblio $bibid => ".$record->as_formatted;
***************
*** 303,308 ****
  	unless ($bibid) {
  		$dbh->do("lock tables marc_biblio WRITE,marc_subfield_table WRITE, marc_word WRITE, marc_blob_subfield WRITE, stopwords READ");
! 		my $sth=$dbh->prepare("insert into marc_biblio (datecreated,biblionumber) values (now(),?)");
! 		$sth->execute($biblionumber);
  		$sth=$dbh->prepare("select max(bibid) from marc_biblio");
  		$sth->execute;
--- 304,309 ----
  	unless ($bibid) {
  		$dbh->do("lock tables marc_biblio WRITE,marc_subfield_table WRITE, marc_word WRITE, marc_blob_subfield WRITE, stopwords READ");
! 		my $sth=$dbh->prepare("insert into marc_biblio (datecreated,biblionumber,frameworkcode) values (now(),?,?)");
! 		$sth->execute($biblionumber,$frameworkcode);
  		$sth=$dbh->prepare("select max(bibid) from marc_biblio");
  		$sth->execute;
***************
*** 704,714 ****
  }
  
! sub MARCfind_itemtype {
  	my ($dbh,$bibid) = @_;
! 	my ($tagfield,$tagsubfield) = MARCfind_marc_from_kohafield($dbh,"biblioitems.itemtype");
! 	my $sth = $dbh->prepare("select subfieldvalue from marc_subfield_table where bibid=? and tag=? and subfieldcode=?");
! 	$sth->execute($bibid,$tagfield,$tagsubfield);
! 	my ($subfieldvalue) = $sth->fetchrow;
! 	return $subfieldvalue;
  }
  sub MARCdelsubfield {
--- 705,714 ----
  }
  
! sub MARCfind_frameworkcode {
  	my ($dbh,$bibid) = @_;
! 	my $sth = $dbh->prepare("select frameworkcode from marc_biblio where bibid=?");
! 	$sth->execute($bibid);
! 	my ($frameworkcode) = $sth->fetchrow;
! 	return $frameworkcode;
  }
  sub MARCdelsubfield {
***************
*** 990,1013 ****
  
  sub NEWnewbiblio {
! 	my ($dbh, $record, $oldbiblio, $oldbiblioitem) = @_;
! 	# note $oldbiblio and $oldbiblioitem are not mandatory.
! 	# if not present, they will be builded from $record with MARCmarc2koha function
! 	if (($oldbiblio) and not($oldbiblioitem)) {
! 		print STDERR "NEWnewbiblio : missing parameter\n";
! 		print "NEWnewbiblio : missing parameter : contact koha development  team\n";
! 		die;
! 	}
  	my $oldbibnum;
  	my $oldbibitemnum;
! 	if ($oldbiblio) {
! 		$oldbibnum = OLDnewbiblio($dbh,$oldbiblio);
! 		$oldbiblioitem->{'biblionumber'} = $oldbibnum;
! 		$oldbibitemnum = OLDnewbiblioitem($dbh,$oldbiblioitem);
! 	} else {
! 		my $olddata = MARCmarc2koha($dbh,$record);
! 		$oldbibnum = OLDnewbiblio($dbh,$olddata);
! 		$olddata->{'biblionumber'} = $oldbibnum;
! 		$oldbibitemnum = OLDnewbiblioitem($dbh,$olddata);
! 	}
  	# search subtiles, addiauthors and subjects
  	my ($tagfield,$tagsubfield) = MARCfind_marc_from_kohafield($dbh,"additionalauthors.author");
--- 990,1000 ----
  
  sub NEWnewbiblio {
! 	my ($dbh, $record, $frameworkcode) = @_;
  	my $oldbibnum;
  	my $oldbibitemnum;
! 	my $olddata = MARCmarc2koha($dbh,$record);
! 	$oldbibnum = OLDnewbiblio($dbh,$olddata);
! 	$olddata->{'biblionumber'} = $oldbibnum;
! 	$oldbibitemnum = OLDnewbiblioitem($dbh,$olddata);
  	# search subtiles, addiauthors and subjects
  	my ($tagfield,$tagsubfield) = MARCfind_marc_from_kohafield($dbh,"additionalauthors.author");
***************
*** 1060,1069 ****
  	$record->delete_field($old_field);
  	$record->add_fields($newfield);
! 	my $bibid = MARCaddbiblio($dbh,$record,$oldbibnum);
  	return ($bibid,$oldbibnum,$oldbibitemnum );
  }
  
  sub NEWmodbiblio {
! 	my ($dbh,$record,$bibid) =@_;
  	&MARCmodbiblio($dbh,$bibid,$record,0);
  	my $oldbiblio = MARCmarc2koha($dbh,$record);
--- 1047,1057 ----
  	$record->delete_field($old_field);
  	$record->add_fields($newfield);
! 	my $bibid = MARCaddbiblio($dbh,$record,$oldbibnum,$frameworkcode);
  	return ($bibid,$oldbibnum,$oldbibitemnum );
  }
  
  sub NEWmodbiblio {
! 	my ($dbh,$record,$bibid,$frameworkcode) =@_;
! 	$frameworkcode="" unless $frameworkcode;
  	&MARCmodbiblio($dbh,$bibid,$record,0);
  	my $oldbiblio = MARCmarc2koha($dbh,$record);
***************
*** 2204,2207 ****
--- 2192,2199 ----
  # $Id$
  # $Log$
+ # Revision 1.91  2004/06/03 10:03:01  tipaul
+ # * frameworks and itemtypes are independant
+ # * in the MARC editor, showing the + to duplicate a tag only if the tag is repeatable
+ #
  # Revision 1.90  2004/05/28 08:25:53  tipaul
  # hidding hidden & isurl constraints into MARC subfield structure

Index: Koha.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Koha.pm,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** Koha.pm	28 May 2004 08:26:57 -0000	1.19
--- Koha.pm	3 Jun 2004 10:03:02 -0000	1.20
***************
*** 59,62 ****
--- 59,63 ----
  			&getprinters &getprinter
  			&getitemtypes &getitemtypeinfo
+ 			&getframeworks &getframeworkinfo
  			&getauthtypes
  			$DEBUG);
***************
*** 322,325 ****
--- 323,392 ----
  }
  
+ =head2 getframework
+ 
+   $frameworks = &getframework();
+ 
+ Returns information about existing frameworks
+ 
+ build a HTML select with the following code :
+ 
+ =head3 in PERL SCRIPT
+ 
+ my $frameworks = frameworks();
+ my @frameworkloop;
+ foreach my $thisframework (keys %$frameworks) {
+ 	my $selected = 1 if $thisframework eq $frameworkcode;
+ 	my %row =(value => $thisframework,
+ 				selected => $selected,
+ 				description => $frameworks->{$thisframework}->{'frameworktext'},
+ 			);
+ 	push @frameworksloop, \%row;
+ }
+ $template->param(frameworkloop => \@frameworksloop);
+ 
+ =head3 in TEMPLATE
+ 
+ <form action='<!-- TMPL_VAR name="script_name" -->' method=post>
+ 	<select name="frameworkcode">
+ 		<option value="">Default</option>
+ 	<!-- TMPL_LOOP name="frameworkloop" -->
+ 		<option value="<!-- TMPL_VAR name="value" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name="frameworktext" --></option>
+ 	<!-- /TMPL_LOOP -->
+ 	</select>
+ 	<input type=text name=searchfield value="<!-- TMPL_VAR name="searchfield" -->">
+ 	<input type="submit" value="OK" class="button">
+ </form>
+ 
+ 
+ =cut
+ 
+ sub getframeworks {
+ # returns a reference to a hash of references to branches...
+ 	my %itemtypes;
+ 	my $dbh = C4::Context->dbh;
+ 	my $sth=$dbh->prepare("select * from biblio_framework");
+ 	$sth->execute;
+ 	while (my $IT=$sth->fetchrow_hashref) {
+ 			$itemtypes{$IT->{'frameworkcode'}}=$IT;
+ 	}
+ 	return (\%itemtypes);
+ }
+ =head2 getframeworkinfo
+ 
+   $frameworkinfo = &getframeworkinfo($frameworkcode);
+ 
+ Returns information about an frameworkcode.
+ 
+ =cut
+ 
+ sub getframeworkinfo {
+ 	my ($frameworkcode) = @_;
+ 	my $dbh = C4::Context->dbh;
+ 	my $sth=$dbh->prepare("select * from biblio_framework where frameworkcode=?");
+ 	$sth->execute($frameworkcode);
+ 	my $res = $sth->fetchrow_hashref;
+ 	return $res;
+ }
+ 
  
  =head2 getitemtypeinfo





More information about the Koha-cvs mailing list