[Koha-cvs] koha/C4 Biblio.pm [rel_3_0]

Henri-Damien LAURENT laurenthdl at alinto.com
Mon Oct 2 11:32:02 CEST 2006


CVSROOT:	/cvsroot/koha
Module name:	koha
Branch:		rel_3_0
Changes by:	Henri-Damien LAURENT <hdl>	06/10/02 09:32:02

Modified files:
	C4             : Biblio.pm 

Log message:
	Adding GetItemStatus and GetItemLocation function in order to make serials-receive.pl work.
	
	*************WARNING.***************
	tested for UNIMARC and using 'marcflavour' system preferences to set defaut_record_format.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Biblio.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.178.2.9&r2=1.178.2.10

Patches:
Index: Biblio.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Biblio.pm,v
retrieving revision 1.178.2.9
retrieving revision 1.178.2.10
diff -u -b -r1.178.2.9 -r1.178.2.10
--- Biblio.pm	26 Sep 2006 07:54:20 -0000	1.178.2.9
+++ Biblio.pm	2 Oct 2006 09:32:02 -0000	1.178.2.10
@@ -83,7 +83,7 @@
   &char_decode
   &DisplayISBN
 &itemcalculator &calculatelc
-&GetItemInfosOf
+&GetItemInfosOf &GetItemStatus &GetItemLocation
 &GetBiblioItemInfosOf
 );
 
@@ -241,6 +241,9 @@
 
 =cut
 
+
+MARC::File::XML::default_record_format("UNIMARC") if (C4::Context->preference("marcflavour") eq "UNIMARC");
+
 sub MARCgettagslib {
     my ( $dbh, $forlibrarian, $frameworkcode ) = @_;
     $frameworkcode = "" unless $frameworkcode;
@@ -390,8 +393,8 @@
     $sth->execute($bibid);
     my ($marcxml)=$sth->fetchrow;
     my $record = MARC::Record->new();
-    MARC::File::XML::default_record_format("UNIMARC") if (C4::Context->preference("marcflavour") eq "UNIMARC");
     $record = MARC::Record::new_from_xml( $marcxml,"utf8" ) if $marcxml;
+    warn "record dans Biblio.pm ".$record->as_formatted;
 	return $record;
 }
 ############OLD VERSION HERE###############################################
@@ -2507,6 +2510,129 @@
 
 	return(@results);
 }
+=head2 getitemstatus
+
+  $itemstatushash = &getitemstatus($fwkcode);
+  returns information about status.
+  Can be MARC dependant.
+  fwkcode is optional.
+  But basically could be can be loan or not
+  Create a status selector with the following code
+  
+=head3 in PERL SCRIPT
+
+my $itemstatushash = getitemstatus;
+my @itemstatusloop;
+foreach my $thisstatus (keys %$itemstatushash) {
+	my %row =(value => $thisstatus,
+				statusname => $itemstatushash->{$thisstatus}->{'statusname'},
+			);
+	push @itemstatusloop, \%row;
+}
+$template->param(statusloop=>\@itemstatusloop);
+
+
+=head3 in TEMPLATE  
+			<select name="statusloop">
+				<option value="">Default</option>
+			<!-- TMPL_LOOP name="statusloop" -->
+				<option value="<!-- TMPL_VAR name="value" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name="statusname" --></option>
+			<!-- /TMPL_LOOP -->
+			</select>
+
+=cut
+sub GetItemStatus {
+# returns a reference to a hash of references to status...
+	my ($fwk)=@_;
+	my %itemstatus;
+ 	my $dbh = C4::Context->dbh;
+ 	my $sth;
+	$fwk='' unless ($fwk);
+ 	my ($tag,$subfield)=MARCfind_marc_from_kohafield($dbh,"items.notforloan",$fwk);
+	if ($tag and $subfield){
+		my $sth = $dbh->prepare("select authorised_value from marc_subfield_structure where tagfield=? and tagsubfield=? and frameworkcode=?");
+		$sth->execute($tag,$subfield,$fwk);
+		if (my ($authorisedvaluecat)=$sth->fetchrow){
+			my $authvalsth=$dbh->prepare("select authorised_value, lib from authorised_values where category=? order by lib");
+			$authvalsth->execute($authorisedvaluecat);
+			while (my ($authorisedvalue, $lib)=$authvalsth->fetchrow){
+				$itemstatus{$authorisedvalue}=$lib;
+			}
+			$authvalsth->finish;
+			return \%itemstatus;
+			exit 1;
+		} else{
+			#No authvalue list
+			# build default
+		}
+		$sth->finish;
+	}
+	#No authvalue list
+	#build default
+	$itemstatus{"1"}="Not For Loan";
+	return \%itemstatus;
+}
+=head2 getitemlocation
+
+  $itemlochash = &getitemlocation($fwk);
+  returns informations about location.
+  where fwk stands for an optional framework code.
+  Create a location selector with the following code
+  
+=head3 in PERL SCRIPT
+
+my $itemlochash = getitemlocation;
+my @itemlocloop;
+foreach my $thisloc (keys %$itemlochash) {
+	my $selected = 1 if $thisbranch eq $branch;
+	my %row =(locval => $thisloc,
+				selected => $selected,
+				locname => $itemlochash->{$thisloc},
+			);
+	push @itemlocloop, \%row;
+}
+$template->param(itemlocationloop => \@itemlocloop);
+
+=head3 in TEMPLATE  
+			<select name="location">
+				<option value="">Default</option>
+			<!-- TMPL_LOOP name="itemlocationloop" -->
+				<option value="<!-- TMPL_VAR name="locval" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name="locname" --></option>
+			<!-- /TMPL_LOOP -->
+			</select>
+
+=cut
+sub GetItemLocation {
+# returns a reference to a hash of references to location...
+	my ($fwk)=@_;
+	my %itemlocation;
+ 	my $dbh = C4::Context->dbh;
+ 	my $sth;
+	$fwk='' unless ($fwk);
+ 	my ($tag,$subfield)=MARCfind_marc_from_kohafield($dbh,"items.location",$fwk);
+	if ($tag and $subfield){
+		my $sth = $dbh->prepare("select authorised_value from marc_subfield_structure where tagfield=? and tagsubfield=? and frameworkcode=?");
+		$sth->execute($tag,$subfield,$fwk);
+		if (my ($authorisedvaluecat)=$sth->fetchrow){
+			my $authvalsth=$dbh->prepare("select authorised_value, lib from authorised_values where category=? order by lib");
+			$authvalsth->execute($authorisedvaluecat);
+			while (my ($authorisedvalue, $lib)=$authvalsth->fetchrow){
+				$itemlocation{$authorisedvalue}=$lib;
+			}
+			$authvalsth->finish;
+			return \%itemlocation;
+			exit 1;
+		} else{
+			#No authvalue list
+			# build default
+		}
+		$sth->finish;
+	}
+	#No authvalue list
+	#build default
+	$itemlocation{"1"}="Not For Loan";
+	return \%itemlocation;
+}
 
 sub countitems {
     my ($bibitemnum) = @_;
@@ -3219,8 +3345,14 @@
 
 =cut
 
-# $Id: Biblio.pm,v 1.178.2.9 2006/09/26 07:54:20 hdl Exp $
+# $Id: Biblio.pm,v 1.178.2.10 2006/10/02 09:32:02 hdl Exp $
 # $Log: Biblio.pm,v $
+# Revision 1.178.2.10  2006/10/02 09:32:02  hdl
+# Adding GetItemStatus and GetItemLocation function in order to make serials-receive.pl work.
+#
+# *************WARNING.***************
+# tested for UNIMARC and using 'marcflavour' system preferences to set defaut_record_format.
+#
 # Revision 1.178.2.9  2006/09/26 07:54:20  hdl
 # Bug FIX: Correct accents for UNIMARC biblio MARC details.
 # (Adding the use of default_record_format in MARCgetbiblio if UNIMARC marcflavour is chosen. This should be widely used as soon as we use xml records)





More information about the Koha-cvs mailing list