[Koha-cvs] CVS: koha/C4 Acquisition.pm,1.9,1.10 AuthoritiesMarc.pm,1.9,1.10 Biblio.pm,1.115,1.116 Bull.pm,1.6,1.7 Context.pm,1.18,1.19 Search.pm,1.99,1.100 SearchMarc.pm,1.37,1.38

Paul POULAIN tipaul at users.sourceforge.net
Tue Mar 1 14:42:02 CET 2005


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

Modified Files:
	Acquisition.pm AuthoritiesMarc.pm Biblio.pm Bull.pm Context.pm 
	Search.pm SearchMarc.pm 
Log Message:
merging 2.2 branch with head. Sorry for not making it before, many many commits done here

Index: Acquisition.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Acquisition.pm,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** Acquisition.pm	24 Nov 2004 15:59:15 -0000	1.9
--- Acquisition.pm	1 Mar 2005 13:40:48 -0000	1.10
***************
*** 600,604 ****
  	my ($title,$author,$name)=@_;
  	my $dbh= C4::Context->dbh;
! 	my $query = "select biblio.title,aqorders.basketno,name,aqbasket.creationdate,aqorders.datereceived, aqorders.quantity
  							from aqorders,aqbasket,aqbooksellers,biblio 
  							where aqorders.basketno=aqbasket.basketno and aqbasket.booksellerid=aqbooksellers.id and
--- 600,604 ----
  	my ($title,$author,$name)=@_;
  	my $dbh= C4::Context->dbh;
! 	my $query = "select biblio.title,aqorders.basketno,name,aqbasket.creationdate,aqorders.datereceived, aqorders.quantity, aqorders.ecost
  							from aqorders,aqbasket,aqbooksellers,biblio 
  							where aqorders.basketno=aqbasket.basketno and aqbasket.booksellerid=aqbooksellers.id and

Index: AuthoritiesMarc.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/AuthoritiesMarc.pm,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** AuthoritiesMarc.pm	23 Dec 2004 09:48:11 -0000	1.9
--- AuthoritiesMarc.pm	1 Mar 2005 13:40:48 -0000	1.10
***************
*** 62,66 ****
--- 62,83 ----
  	#		(m1.subfieldvalue like "Des%" and m2.subfieldvalue like "27%")
  
+ 	# the marclist may contain "mainentry". In this case, search the tag_to_report, that depends on
+ 	# the authtypecode. Then, search on $a of this tag_to_report
+ 	for (my $i=0;$i<$#{$tags};$i++) {
+ 		if (@$tags[$i] eq "mainentry") {
+ 			my $sth = $dbh->prepare("select auth_tag_to_report from auth_types where authtypecode=?");
+ 			$sth->execute($authtypecode);
+ 			my ($tag_to_report) = $sth->fetchrow;
+ 			@$tags[$i] = $tag_to_report."a";
+ 		}
+ 	}
+ 
  	# "Normal" statements
+ 	# quote marc fields/subfields
+ 	for (my $i=0;$i<$#{$tags};$i++) {
+ 		if (@$tags[$i]) {
+ 			@$tags[$i] = $dbh->quote(@$tags[$i]);
+ 		}
+ 	}
  	my @normal_tags = ();
  	my @normal_and_or = ();
***************
*** 512,516 ****
  	&AUTHdelauthority($dbh,$authid,1);
  	&AUTHaddauthority($dbh,$record,$authid,AUTHfind_authtypecode($dbh,$authid));
! 	# FIXME : modify the authority in biblio too.
  }
  
--- 529,537 ----
  	&AUTHdelauthority($dbh,$authid,1);
  	&AUTHaddauthority($dbh,$record,$authid,AUTHfind_authtypecode($dbh,$authid));
! 	# save the file in localfile/modified_authorities
! 	my $filename = C4::Context->config("intranetdir")."/localfile/modified_authorities/$authid.authid";
! 	open AUTH, "> $filename";
! 	print AUTH $authid;
! 	close AUTH;
  }
  
***************
*** 838,841 ****
--- 859,875 ----
  # $Id$
  # $Log$
+ # Revision 1.10  2005/03/01 13:40:48  tipaul
+ # merging 2.2 branch with head. Sorry for not making it before, many many commits done here
+ #
+ # Revision 1.9.2.2  2005/02/28 14:03:13  tipaul
+ # * adding search on "main entry" (ie $a subfield) on a given authority (the "search everywhere" field is still here).
+ # * adding a select box to requet "contain" or "begin with" search.
+ # * fixing some bug in authority search (related to "main entry" search)
+ #
+ # Revision 1.9.2.1  2005/02/24 13:12:13  tipaul
+ # saving authority modif in a text file. This will be used soon with another script (in crontab). The script in crontab will retrieve every authorityid in the directory localfile/authorities and modify every biblio using this authority. Those modifs may be long. So they can't be done through http, because we may encounter a webserver timeout, and kill the process before end of the job.
+ # So, it will be done through a cron job.
+ # (/me agree we need some doc for command line scripts)
+ #
  # Revision 1.9  2004/12/23 09:48:11  tipaul
  # Minor changes in summary "exploding" (the 3 digits AFTER the subfield were not on the right place).

Index: Biblio.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Biblio.pm,v
retrieving revision 1.115
retrieving revision 1.116
diff -C2 -r1.115 -r1.116
*** Biblio.pm	6 Jan 2005 14:32:17 -0000	1.115
--- Biblio.pm	1 Mar 2005 13:40:48 -0000	1.116
***************
*** 67,70 ****
--- 67,71 ----
    &MARCgetbiblio &MARCgetitem
    &MARCaddword &MARCdelword
+   &MARCdelsubfield
    &char_decode
    
***************
*** 202,205 ****
--- 203,207 ----
  
  MARCdelsubfield delete a subfield for a bibid/tag/tagorder/subfield/subfieldorder
+ If $subfieldorder is not set, delete all the $tag$subfield subfields 
  
  =item &MARCdelbiblio($dbh,$bibid);
***************
*** 879,887 ****
      # delete a subfield for $bibid / tag / tagorder / subfield / subfieldorder
      my ( $dbh, $bibid, $tag, $tagorder, $subfield, $subfieldorder ) = @_;
!     $dbh->do( "delete from marc_subfield_table where bibid='$bibid' and
! 			tag='$tag' and tagorder='$tagorder'
! 			and subfieldcode='$subfield' and subfieldorder='$subfieldorder'
! 			"
!     );
  }
  
--- 881,904 ----
      # delete a subfield for $bibid / tag / tagorder / subfield / subfieldorder
      my ( $dbh, $bibid, $tag, $tagorder, $subfield, $subfieldorder ) = @_;
! 	if ($subfieldorder) {
! 		$dbh->do( "delete from marc_subfield_table where bibid='$bibid' and
! 				tag='$tag' and tagorder='$tagorder'
! 				and subfieldcode='$subfield' and subfieldorder='$subfieldorder'
! 				"
! 		);
! 		$dbh->do( "delete from marc_word where bibid='$bibid' and
! 				tagsubfield='$tag$subfield' and tagorder='$tagorder'
! 				and subfieldorder='$subfieldorder'
! 				"
! 		);
! 	} else {
! 		$dbh->do( "delete from marc_subfield_table where bibid='$bibid' and
! 				tag='$tag' and tagorder='$tagorder'
! 				and subfieldcode='$subfield'"
! 		);
! 		$dbh->do( "delete from marc_word where bibid='$bibid' and
! 				tagsubfield='$tag$subfield' and tagorder='$tagorder'"
! 		);
! 	}
  }
  
***************
*** 957,961 ****
      $sth2->execute($biblionumber);
      while ( my $row = $sth2->fetchrow_hashref ) {
!         &MARCkoha2marcOnefield( $sth, $record, "bibliosubtitle.title",
              $row->{'subtitle'},'' );
      }
--- 974,978 ----
      $sth2->execute($biblionumber);
      while ( my $row = $sth2->fetchrow_hashref ) {
!         &MARCkoha2marcOnefield( $sth, $record, "bibliosubtitle.subtitle",
              $row->{'subtitle'},'' );
      }
***************
*** 1137,1147 ****
      ( $tagfield, $subfield ) = MARCfind_marc_from_kohafield("",$kohatable.".".$kohafield,$frameworkcode);
      foreach my $field ( $record->field($tagfield) ) {
!         if ( $field->subfield($subfield) ) {
!             if ( $result->{$kohafield} ) {
!                 $result->{$kohafield} .= " | " . $field->subfield($subfield);
!             }
!             else {
!                 $result->{$kohafield} = $field->subfield($subfield);
!             }
          }
      }
--- 1154,1169 ----
      ( $tagfield, $subfield ) = MARCfind_marc_from_kohafield("",$kohatable.".".$kohafield,$frameworkcode);
      foreach my $field ( $record->field($tagfield) ) {
!         if ( $field->subfields ) {
!             my @subfields = $field->subfields();
!             foreach my $subfieldcount ( 0 .. $#subfields ) {
! 				if ($subfields[$subfieldcount][0] eq $subfield) {
! 					if ( $result->{$kohafield} ) {
! 						$result->{$kohafield} .= " | " . $subfields[$subfieldcount][1];
! 					}
! 					else {
! 						$result->{$kohafield} = $subfields[$subfieldcount][1];
! 					}
! 				}
! 			}
          }
      }
***************
*** 1230,1234 ****
      }
      ( $tagfield, $tagsubfield ) =
!       MARCfind_marc_from_kohafield( $dbh, "bibliosubtitle.title",$frameworkcode );
      my @subtitlefields = $record->field($tagfield);
      foreach my $subtitlefield (@subtitlefields) {
--- 1252,1256 ----
      }
      ( $tagfield, $tagsubfield ) =
!       MARCfind_marc_from_kohafield( $dbh, "bibliosubtitle.subtitle",$frameworkcode );
      my @subtitlefields = $record->field($tagfield);
      foreach my $subtitlefield (@subtitlefields) {
***************
*** 1305,1310 ****
  	foreach my $subtitlefield (@subtitlefields) {
  		my @subtitlesubfields = $subtitlefield->subfield($tagsubfield);
  		foreach my $subfieldcount (0..$#subtitlesubfields) {
! 			OLDmodsubtitle($dbh,$oldbiblionumber,$subtitlesubfields[$subfieldcount]);
  		}
  	}
--- 1327,1337 ----
  	foreach my $subtitlefield (@subtitlefields) {
  		my @subtitlesubfields = $subtitlefield->subfield($tagsubfield);
+ 		# delete & create subtitle again because OLDmodsubtitle can't handle new subtitles
+ 		# between 2 modifs
+ 		$dbh->do("delete from bibliosubtitle where biblionumber=$oldbiblionumber");
  		foreach my $subfieldcount (0..$#subtitlesubfields) {
! 			foreach my $subtit(split /\||#/,$subtitlesubfields[$subfieldcount]) {
! 				OLDnewsubtitle($dbh,$oldbiblionumber,$subtit);
! 			}
  		}
  	}
***************
*** 1602,1607 ****
  sub OLDmodbibitem {
      my ( $dbh, $biblioitem ) = @_;
- 
-     #    my $dbh   = C4Connect;
      my $query;
  
--- 1629,1632 ----
***************
*** 1609,1612 ****
--- 1634,1638 ----
      $biblioitem->{'url'}           = $dbh->quote( $biblioitem->{'url'} );
      $biblioitem->{'isbn'}          = $dbh->quote( $biblioitem->{'isbn'} );
+     $biblioitem->{'issn'}          = $dbh->quote( $biblioitem->{'issn'} );
      $biblioitem->{'publishercode'} =
        $dbh->quote( $biblioitem->{'publishercode'} );
***************
*** 1628,1631 ****
--- 1654,1658 ----
  url             = $biblioitem->{'url'},
  isbn            = $biblioitem->{'isbn'},
+ issn            = $biblioitem->{'issn'},
  publishercode   = $biblioitem->{'publishercode'},
  publicationyear = $biblioitem->{'publicationyear'},
***************
*** 1645,1650 ****
          warn "$query";
      }
- 
-     #    $dbh->disconnect;
  }    # sub modbibitem
  
--- 1672,1675 ----
***************
*** 1721,1725 ****
        $dbh->prepare(
          "insert into bibliosubtitle set biblionumber = ?, subtitle = ?");
!     $sth->execute( $bibnum, $subtitle );
      $sth->finish;
  }
--- 1746,1750 ----
        $dbh->prepare(
          "insert into bibliosubtitle set biblionumber = ?, subtitle = ?");
!     $sth->execute( $bibnum, $subtitle ) if $subtitle;
      $sth->finish;
  }
***************
*** 1808,1816 ****
          $item->{'location'},	   $item->{'itemnum'}
      );
-     if ( $item->{'barcode'} eq '' ) {
-         $item->{'notforloan'} = 0 unless $item->{'notforloan'};
-         $query = "update items set notforloan=? where itemnumber=?";
-         @bind = ( $item->{'notforloan'}, $item->{'itemnum'} );
-     }
      if ( $item->{'lost'} ne '' ) {
          $query = "update items set biblioitemnumber=?,
--- 1833,1836 ----
***************
*** 2634,2637 ****
--- 2654,2676 ----
  # $Id$
  # $Log$
+ # Revision 1.116  2005/03/01 13:40:48  tipaul
+ # merging 2.2 branch with head. Sorry for not making it before, many many commits done here
+ #
+ # Revision 1.115.2.5  2005/02/24 13:54:04  tipaul
+ # exporting MARCdelsubfield sub. It's used in authority merging.
+ # Modifying it too to enable deletion of all subfields from a given tag/subfield or just one.
+ #
+ # Revision 1.115.2.4  2005/02/17 12:44:25  tipaul
+ # bug in acquisition : the title was also stored as subtitle.
+ #
+ # Revision 1.115.2.3  2005/02/10 13:14:36  tipaul
+ # * multiple main authors are now correctly handled in simple (non-MARC) view
+ #
+ # Revision 1.115.2.2  2005/01/11 16:02:35  tipaul
+ # in catalogue, modifs were not stored properly the non-MARC item DB. Affect only libraries without barcodes.
+ #
+ # Revision 1.115.2.1  2005/01/11 14:45:37  tipaul
+ # bugfix : issn were not stored correctly in non-MARC DB on biblio modification
+ #
  # Revision 1.115  2005/01/06 14:32:17  tipaul
  # improvement of speed for bulkmarcimport.

Index: Bull.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Bull.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** Bull.pm	3 Dec 2004 14:34:54 -0000	1.6
--- Bull.pm	1 Mar 2005 13:40:48 -0000	1.7
***************
*** 45,49 ****
  
  @ISA = qw(Exporter);
! @EXPORT = qw(&newsubscription &modsubscription &getsubscriptions &getsubscription &getsubscriptionfrombiblionumber
  			&modsubscriptionhistory
  			&getserials &serialchangestatus
--- 45,50 ----
  
  @ISA = qw(Exporter);
! @EXPORT = qw(&newsubscription &modsubscription &delsubscription &getsubscriptions &getsubscription 
! 			&getsubscriptionfrombiblionumber &get_subscription_list_from_biblionumber
  			&modsubscriptionhistory
  			&getserials &serialchangestatus
***************
*** 137,150 ****
  	$sth = $dbh->prepare("insert into serial (serialseq,subscriptionid,biblionumber,status, planneddate) values (?,?,?,?,?)");
  	$sth->execute($serialseq, $subscriptionid, $val->{'biblionumber'}, 1, format_date_in_iso($startdate));
- 
- 	# next issue number
- 	#my ($newserialseq,$newlastvalue1,$newlastvalue2,$newlastvalue3,$newinnerloop1,$newinnerloop2,$newinnerloop3) = Get_Next_Seq($val);
- 	# next date (calculated from actual date & frequency parameters)
- 	#my $nextplanneddate = Get_Next_Date($startdate,$val);
- # 	$sth = $dbh->prepare("update subscription set lastvalue1=?, lastvalue2=?,lastvalue3=?,
- # 													innerloop1=?,innerloop2=?,innerloop3=?
- # 													where subscriptionid = ?");
- # 	$sth->execute($newlastvalue1,$newlastvalue2,$newlastvalue3,$newinnerloop1,$newinnerloop2,$newinnerloop3,$subscriptionid);
- # 	$sth->finish;  
  	return $subscriptionid;
  }
--- 138,141 ----
***************
*** 167,176 ****
  	my ($biblionumber) = @_;
  	my $dbh = C4::Context->dbh;
! 	my $sth = $dbh->prepare('select subscriptionid from subscription where biblionumber=?');
  	$sth->execute($biblionumber);
! 	my $subscriptionid = $sth->fetchrow;
! 	return $subscriptionid;
  }
  
  sub modsubscription {
  	my ($auser,$aqbooksellerid,$cost,$aqbudgetid,$startdate,
--- 158,187 ----
  	my ($biblionumber) = @_;
  	my $dbh = C4::Context->dbh;
! 	my $sth = $dbh->prepare('select count(*) from subscription where biblionumber=?');
  	$sth->execute($biblionumber);
! 	my $subscriptionsnumber = $sth->fetchrow;
! 	return $subscriptionsnumber;
  }
  
+ sub get_subscription_list_from_biblionumber {
+ 	my ($biblionumber) = @_;
+ 	my $dbh = C4::Context->dbh;
+ 	my $sth = $dbh->prepare('select subscription.*,subscriptionhistory.*,aqbudget.bookfundid,aqbooksellers.name as aqbooksellername,biblio.title as bibliotitle 
+ 							from subscription 
+ 							left join subscriptionhistory on subscription.subscriptionid=subscriptionhistory.subscriptionid
+ 							left join aqbudget on subscription.aqbudgetid=aqbudget.aqbudgetid 
+ 							left join aqbooksellers on subscription.aqbooksellerid=aqbooksellers.id 
+ 							left join biblio on biblio.biblionumber=subscription.biblionumber 
+ 							where subscription.biblionumber = ?');
+ 	$sth->execute($biblionumber);
+ 	my @res;
+ 	while (my $subs = $sth->fetchrow_hashref) {
+ 		$subs->{'startdate'} = format_date($subs->{'startdate'});
+ 		push @res,$subs;
+ 	}
+ 	return \@res;
+ }
+ 
+ 
  sub modsubscription {
  	my ($auser,$aqbooksellerid,$cost,$aqbudgetid,$startdate,
***************
*** 197,208 ****
  }
  
  sub getsubscriptions {
! 	my ($title,$ISSN) = @_;
! 	return unless $title or $ISSN;
  	my $dbh = C4::Context->dbh;
  	my $sth;
! 	$sth = $dbh->prepare("select subscription.subscriptionid,biblio.title,biblioitems.issn from subscription,biblio,biblioitems where  biblio.biblionumber = biblioitems.biblionumber and biblio.biblionumber=subscription.biblionumber and (biblio.title like ? or biblioitems.issn = ? )");
! 	$sth->execute("%$title%",$ISSN);
! 	my @results;
  	while (my $line = $sth->fetchrow_hashref) {
  		push @results, $line;
--- 208,236 ----
  }
  
+ sub delsubscription {
+ 	my ($subscriptionid) = @_;
+ 	# check again there is only one issue (the subscription is new)
+ 	my ($totalissues) = getserials($subscriptionid);
+ 	if ($totalissues eq 1) {
+ 		my $dbh = C4::Context->dbh;
+ 		$subscriptionid=$dbh->quote($subscriptionid);
+ 		$dbh->do("delete from subscription where subscriptionid=$subscriptionid");
+ 		$dbh->do("delete from subscriptionhistory where subscriptionid=$subscriptionid");
+ 		$dbh->do("delete from serial where subscriptionid=$subscriptionid");
+ 	}
+ }
  sub getsubscriptions {
! 	my ($title,$ISSN,$biblionumber) = @_;
! 	return unless $title or $ISSN or $biblionumber;
  	my $dbh = C4::Context->dbh;
  	my $sth;
! 	if ($biblionumber) {
! 		$sth = $dbh->prepare("select subscription.subscriptionid,biblio.title,biblioitems.issn,subscription.notes from subscription,biblio,biblioitems where  biblio.biblionumber = biblioitems.biblionumber and biblio.biblionumber=subscription.biblionumber and biblio.biblionumber=?");
! 		$sth->execute($biblionumber);
! 	} else {
! 		$sth = $dbh->prepare("select subscription.subscriptionid,biblio.title,biblioitems.issn,subscription.notes from subscription,biblio,biblioitems where  biblio.biblionumber = biblioitems.biblionumber and biblio.biblionumber=subscription.biblionumber and (biblio.title like ? or biblioitems.issn = ? )");
! 		$sth->execute("%$title%",$ISSN);
! 	}
! 		my @results;
  	while (my $line = $sth->fetchrow_hashref) {
  		push @results, $line;
***************
*** 217,221 ****
  	$sth->execute($histstartdate,$enddate,$recievedlist,$missinglist,$opacnote,$librariannote,$subscriptionid);
  }
! # get every serial not arrived for a given subscription.
  sub getserials {
  	my ($subscriptionid) = @_;
--- 245,251 ----
  	$sth->execute($histstartdate,$enddate,$recievedlist,$missinglist,$opacnote,$librariannote,$subscriptionid);
  }
! # get every serial not arrived for a given subscription
! # as well as the number of issues registered in the database (all types)
! # this number is used to see if a subscription can be deleted (=it must have only 1 issue)
  sub getserials {
  	my ($subscriptionid) = @_;
***************
*** 230,234 ****
  		push @serials,$line;
  	}
! 	return @serials;
  }
  
--- 260,267 ----
  		push @serials,$line;
  	}
! 	$sth=$dbh->prepare("select count(*) from serial where subscriptionid=?");
! 	$sth->execute($subscriptionid);
! 	my ($totalissues) = $sth->fetchrow;
! 	return ($totalissues, at serials);
  }
  

Index: Context.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Context.pm,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -r1.18 -r1.19
*** Context.pm	14 Dec 2004 15:48:34 -0000	1.18
--- Context.pm	1 Mar 2005 13:40:48 -0000	1.19
***************
*** 227,230 ****
--- 227,231 ----
  	# Load the desired config file.
  	$self->{"config"} = &read_config_file($conf_fname);
+ 	warn "read_config_file($conf_fname) returned undef" if !defined($self->{"config"});
  	return undef if !defined($self->{"config"});
  

Index: Search.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Search.pm,v
retrieving revision 1.99
retrieving revision 1.100
diff -C2 -r1.99 -r1.100
*** Search.pm	15 Dec 2004 06:08:06 -0000	1.99
--- Search.pm	1 Mar 2005 13:40:48 -0000	1.100
***************
*** 1318,1324 ****
  	while (my $data=$sth->fetchrow_hashref){
  		my $datedue = '';
! 		my $isth=$dbh->prepare("Select * from issues where itemnumber = ? and returndate is null");
  		$isth->execute($data->{'itemnumber'});
  		if (my $idata=$isth->fetchrow_hashref){
  		$datedue = format_date($idata->{'date_due'});
  		}
--- 1318,1326 ----
  	while (my $data=$sth->fetchrow_hashref){
  		my $datedue = '';
! 		my $isth=$dbh->prepare("Select issues.*,borrowers.cardnumber from issues,borrowers where itemnumber = ? and returndate is null and issues.borrowernumber=borrowers.borrowernumber");
  		$isth->execute($data->{'itemnumber'});
  		if (my $idata=$isth->fetchrow_hashref){
+ 		$data->{borrowernumber} = $idata->{borrowernumber};
+ 		$data->{cardnumber} = $idata->{cardnumber};
  		$datedue = format_date($idata->{'date_due'});
  		}
***************
*** 1346,1356 ****
  			$data->{'branchname'} = $bdata->{'branchname'};
  		}
- 	#   $results[$i]="$data->{'title'}\t$data->{'barcode'}\t$datedue\t$data->{'branchname'}\t$data->{'dewey'}";
- 		# FIXME - If $data->{'datelastseen'} is NULL, perhaps it'd be prettier
- 		# to leave it empty, rather than convert it to "//".
- 		# Also ideally this should use the local format for displaying dates.
  		my $date=format_date($data->{'datelastseen'});
  		$data->{'datelastseen'}=$date;
  		$data->{'datedue'}=$datedue;
  		$results[$i]=$data;
  		$i++;
--- 1348,1364 ----
  			$data->{'branchname'} = $bdata->{'branchname'};
  		}
  		my $date=format_date($data->{'datelastseen'});
  		$data->{'datelastseen'}=$date;
  		$data->{'datedue'}=$datedue;
+ 	# get notforloan complete status if applicable
+ 		my $sthnflstatus = $dbh->prepare('select authorised_value from marc_subfield_structure where kohafield="items.notforloan"');
+ 		$sthnflstatus->execute;
+ 		my ($authorised_valuecode) = $sthnflstatus->fetchrow;
+ 		if ($authorised_valuecode) {
+ 			$sthnflstatus = $dbh->prepare("select lib from authorised_values where category=? and authorised_value=?");
+ 			$sthnflstatus->execute($authorised_valuecode,$data->{itemnotforloan});
+ 			my ($lib) = $sthnflstatus->fetchrow;
+ 			$data->{notforloan} = $lib;
+ 		}
  		$results[$i]=$data;
  		$i++;
***************
*** 1481,1484 ****
--- 1489,1493 ----
  								left join bibliosubtitle on
  								biblio.biblionumber = bibliosubtitle.biblionumber
+ 								left join itemtypes on biblioitems.itemtype=itemtypes.itemtype
  								where biblio.biblionumber = ?
  								and biblioitems.biblionumber = biblio.biblionumber");
***************
*** 1487,1490 ****
--- 1496,1510 ----
  	$data  = $sth->fetchrow_hashref;
  	$sth->finish;
+ 	# handle management of repeated subtitle
+ 	$sth   = $dbh->prepare("Select * from bibliosubtitle where biblionumber = ?");
+ 	$sth->execute($bibnum);
+ 	my @subtitles;
+ 	while (my $dat = $sth->fetchrow_hashref){
+ 		my %line;
+ 		$line{subtitle} = $dat->{subtitle};
+ 		push @subtitles, \%line;
+ 	} # while
+ 	$data->{subtitles} = \@subtitles;
+ 	$sth->finish;
  	$sth   = $dbh->prepare("Select * from bibliosubject where biblionumber = ?");
  	$sth->execute($bibnum);
***************
*** 1782,1786 ****
  #called by member.pl
  sub BornameSearch  {
! 	my ($env,$searchstring,$type)=@_;
  	my $dbh = C4::Context->dbh;
  	my $query = ""; my $count; my @data;
--- 1802,1806 ----
  #called by member.pl
  sub BornameSearch  {
! 	my ($env,$searchstring,$orderby,$type)=@_;
  	my $dbh = C4::Context->dbh;
  	my $query = ""; my $count; my @data;
***************
*** 1789,1793 ****
  	if($type eq "simple")	# simple search for one letter only
  	{
! 		$query="Select * from borrowers where surname like ? order by surname,firstname";
  		@bind=("$searchstring%");
  	}
--- 1809,1813 ----
  	if($type eq "simple")	# simple search for one letter only
  	{
! 		$query="Select * from borrowers where surname like ? order by $orderby";
  		@bind=("$searchstring%");
  	}
***************
*** 1810,1815 ****
  					# FIXME - .= <<EOT;
  		}
! 		$query=$query.") or cardnumber = ?
! 		order by surname,firstname";
  		push(@bind,$searchstring);
  					# FIXME - .= <<EOT;
--- 1830,1835 ----
  					# FIXME - .= <<EOT;
  		}
! 		$query=$query.") or cardnumber like ?
! 		order by $orderby";
  		push(@bind,$searchstring);
  					# FIXME - .= <<EOT;
***************
*** 1817,1820 ****
--- 1837,1841 ----
  
  	my $sth=$dbh->prepare($query);
+ 	warn "Q $orderby : $query";
  	$sth->execute(@bind);
  	my @results;

Index: SearchMarc.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/SearchMarc.pm,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -r1.37 -r1.38
*** SearchMarc.pm	22 Feb 2005 22:38:21 -0000	1.37
--- SearchMarc.pm	1 Mar 2005 13:40:49 -0000	1.38
***************
*** 167,171 ****
  sub catalogsearch {
  	my ($dbh, $tags, $and_or, $excluding, $operator, $value, $offset,$length,$orderby) = @_;
- 	warn "@$tags[0], @$and_or[0], @$excluding[0], @$operator[0], @$value[0], $offset,$length,$orderby";
  	# build the sql request. She will look like :
  	# select m1.bibid
--- 167,170 ----
***************
*** 197,201 ****
  # 		$_=~ s/\,/ /g;
  # 	}
! 	
  	for(my $i = 0 ; $i <= $#{$value} ; $i++)
  	{
--- 196,214 ----
  # 		$_=~ s/\,/ /g;
  # 	}
! 
! # the item.notforloan contains an integer. Every value <>0 means "book unavailable for loan".
! # but each library can have it's own table of meaning for each value. Get them
! # 1st search if there is a list of authorised values connected to items.notforloan
! 	my $sth = $dbh->prepare('select authorised_value from marc_subfield_structure where kohafield="items.notforloan"');
! 	$sth->execute;
! 	my %notforloanstatus;
! 	my ($authorised_valuecode) = $sth->fetchrow;
! 	if ($authorised_valuecode) {
! 		$sth = $dbh->prepare("select authorised_value,lib from authorised_values where category=?");
! 		$sth->execute($authorised_valuecode);
! 		while (my ($authorised_value,$lib) = $sth->fetchrow) {
! 			$notforloanstatus{$authorised_value} = $lib?$lib:$authorised_value;
! 		}
! 	}
  	for(my $i = 0 ; $i <= $#{$value} ; $i++)
  	{
***************
*** 241,246 ****
  					$word =~ s/%//g unless length($word)>4;
  					unless (C4::Context->stopwords->{uc($word)} or length($word)==1) {	#it's NOT a stopword => use it. Otherwise, ignore
- 						my $tag = substr(@$tags[$i],0,3);
- 						my $subf = substr(@$tags[$i],3,1);
  						push @normal_tags, @$tags[$i];
  						push @normal_and_or, "and";	# assumes "foo" and "bar" if "foo bar" is entered
--- 254,257 ----
***************
*** 274,277 ****
--- 285,289 ----
  	$sth->execute();
  	my @result = ();
+         my $subtitle; # Added by JF for Subtitles
  
  	# Processes the NOT if any and there are results
***************
*** 329,332 ****
--- 341,345 ----
  							LEFT JOIN itemtypes on itemtypes.itemtype=biblioitems.itemtype
  							WHERE biblio.biblionumber = marc_biblio.biblionumber AND bibid = ?");
+         my $sth_subtitle = $dbh->prepare("SELECT subtitle FROM bibliosubtitle WHERE biblionumber=?"); # Added BY JF for Subtitles
  	my @finalresult = ();
  	my @CNresults=();
***************
*** 343,346 ****
--- 356,369 ----
  		my $line = $sth->fetchrow_hashref;
  		my $biblionumber=$line->{bn};
+         # Return subtitles first ADDED BY JF
+                 $sth_subtitle->execute($biblionumber);
+                 my $subtitle_here.= $sth_subtitle->fetchrow." ";
+                 chop $subtitle_here;
+                 $subtitle = $subtitle_here;
+ #               warn "Here's the Biblionumber ".$biblionumber;
+ #                warn "and here's the subtitle: ".$subtitle_here;
+ 
+         # /ADDED BY JF
+ 
  # 		$continue=0 unless $line->{bn};
  # 		my $lastitemnumber;
***************
*** 366,369 ****
--- 389,393 ----
  			$lineCN{location} = $item->{location};
  			$lineCN{date_due} = format_date($date_due);
+ 			$lineCN{notforloan} = $notforloanstatus{$item->{notforloan}} if ($item->{notforloan});
  			$notforloan=0 unless ($item->{notforloan} or $item->{wthdrawn} or $item->{itemlost});
  			push @CNresults,\%lineCN;
***************
*** 374,381 ****
--- 398,414 ----
  		%newline = %$line;
  		$newline{totitem} = $totalitems;
+ 		# if $totalitems == 0, check if it's being ordered.
+ 		if ($totalitems == 0) {
+ 			my $sth = $dbh->prepare("select count(*) from aqorders where biblionumber=?");
+ 			$sth->execute($biblionumber);
+ 			my ($ordered) = $sth->fetchrow;
+ 			$newline{onorder} = 1 if $ordered;
+ 		}
  		$newline{biblionumber} = $biblionumber;
  		$newline{norequests} = 0;
  		$newline{norequests} = 1 if ($line->{notforloan}); # itemtype not issuable
  		$newline{norequests} = 1 if (!$line->{notforloan} && $notforloan); # itemtype issuable but all items not issuable for instance
+                 $newline{subtitle} = $subtitle;  # put the subtitle in ADDED BY JF
+ 
  		my @CNresults2= @CNresults;
  		$newline{CN} = \@CNresults2;





More information about the Koha-cvs mailing list