[Koha-cvs] CVS: koha/C4 Bull.pm,1.6,1.6.2.1

Paul POULAIN tipaul at users.sourceforge.net
Tue Jan 11 16:08:04 CET 2005


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

Modified Files:
      Tag: rel_2_2
	Bull.pm 
Log Message:
modifs to handdle correctly more than 1 subscription of the same biblio. Enter subscription detail in subscription notes (like "for branch XX" or "for 2nd floor"). The subscription details are all shown in OPAC.

you can now delete a subscription that is not yet active (= has only 1 issue in "waiting" state)



Index: Bull.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Bull.pm,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -C2 -r1.6 -r1.6.2.1
*** Bull.pm	3 Dec 2004 14:34:54 -0000	1.6
--- Bull.pm	11 Jan 2005 15:07:58 -0000	1.6.2.1
***************
*** 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,186 ----
  	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) {
+ 		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;
--- 207,235 ----
  }
  
+ 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) = @_;
--- 244,250 ----
  	$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;
  }
  
--- 259,266 ----
  		push @serials,$line;
  	}
! 	$sth=$dbh->prepare("select count(*) from serial where subscriptionid=?");
! 	$sth->execute($subscriptionid);
! 	my ($totalissues) = $sth->fetchrow;
! 	return ($totalissues, at serials);
  }
  





More information about the Koha-cvs mailing list