From 2bca25dc4c2237766562ebc54f53da239e063623 Mon Sep 17 00:00:00 2001 From: hdl Date: Tue, 28 Jun 2005 07:35:48 +0000 Subject: [PATCH] Adding not issued and delete state to state collection And display the three latest numbers of every subscription received or lacked in opac. --- C4/Bull.pm | 58 ++++++++++++++----- .../default/en/bull/statecollection.tmpl | 10 ++++ koha-tmpl/opac-tmpl/css/en/opac-detail.tmpl | 48 ++++++++++++--- opac/opac-detail.pl | 16 ++++- 4 files changed, 110 insertions(+), 22 deletions(-) diff --git a/C4/Bull.pm b/C4/Bull.pm index 9711c98243..2f4e1b376a 100755 --- a/C4/Bull.pm +++ b/C4/Bull.pm @@ -48,7 +48,7 @@ Give all XYZ functions &getsubscriptionfrombiblionumber &get_subscription_list_from_biblionumber &get_full_subscription_list_from_biblionumber &modsubscriptionhistory &newissue - &getserials &serialchangestatus + &getserials &getlatestserials &serialchangestatus &Find_Next_Date, &Get_Next_Seq &hassubscriptionexpired &subscriptionexpirationdate &subscriptionrenew &getSupplierListWithLateIssues &GetLateIssues); @@ -347,7 +347,7 @@ sub getserials { my ($subscriptionid) = @_; my $dbh = C4::Context->dbh; # status = 2 is "arrived" - my $sth=$dbh->prepare("select serialid,serialseq, status, planneddate from serial where subscriptionid = ? and status <>2 and status <>4"); + my $sth=$dbh->prepare("select serialid,serialseq, status, planneddate from serial where subscriptionid = ? and status <>2 and status <>4 and status <>5"); $sth->execute($subscriptionid); my @serials; while(my $line = $sth->fetchrow_hashref) { @@ -361,6 +361,26 @@ sub getserials { return ($totalissues,@serials); } +# get the $limit's latest serials arrived or missing for a given subscription +sub getlatestserials{ + my ($subscriptionid,$limit) =@_; + my $dbh = C4::Context->dbh; + # status = 2 is "arrived" + my $strsth="select serialid,serialseq, status, planneddate from serial where subscriptionid = ? and (status =2 or status=4) order by planneddate DESC LIMIT 0,$limit"; + my $sth=$dbh->prepare($strsth); + $sth->execute($subscriptionid); + my @serials; + while(my $line = $sth->fetchrow_hashref) { + $line->{"status".$line->{status}} = 1; # fills a "statusX" value, used for template status select list + $line->{"planneddate"} = format_date($line->{"planneddate"}); + push @serials,$line; + } + $sth=$dbh->prepare("select count(*) from serial where subscriptionid=?"); + $sth->execute($subscriptionid); + my ($totalissues) = $sth->fetchrow; + return \@serials; +} + sub serialchangestatus { my ($serialid,$serialseq,$planneddate,$status)=@_; # warn "($serialid,$serialseq,$planneddate,$status)"; @@ -370,19 +390,22 @@ sub serialchangestatus { $sth->execute($serialid); my ($subscriptionid,$oldstatus) = $sth->fetchrow; # change status & update subscriptionhistory - $sth = $dbh->prepare("update serial set serialseq=?,planneddate=?,status=? where serialid = ?"); - $sth->execute($serialseq,$planneddate,$status,$serialid); - $sth = $dbh->prepare("select missinglist,recievedlist from subscriptionhistory where subscriptionid=?"); - $sth->execute($subscriptionid); - my ($missinglist,$recievedlist) = $sth->fetchrow; - if ($status eq 2) { - $recievedlist .= ",$serialseq"; - } - if ($status eq 4) { - $missinglist .= ",$serialseq"; + if ($status eq 6){ + delissue($serialseq, $subscriptionid) + }else{ + $sth = $dbh->prepare("update serial set serialseq=?,planneddate=?,status=? where serialid = ?"); + $sth->execute($serialseq,$planneddate,$status,$serialid); + $sth = $dbh->prepare("select missinglist,recievedlist from subscriptionhistory where subscriptionid=?"); + $sth->execute($subscriptionid); + my ($missinglist,$recievedlist) = $sth->fetchrow; + if ($status eq 2) { + $recievedlist .= ",$serialseq"; + } + $missinglist .= ",$serialseq" if ($status eq 4) ; + $missinglist .= ",not issued $serialseq" if ($status eq 5); + $sth=$dbh->prepare("update subscriptionhistory set recievedlist=?, missinglist=? where subscriptionid=?"); + $sth->execute($recievedlist,$missinglist,$subscriptionid); } - $sth=$dbh->prepare("update subscriptionhistory set recievedlist=?, missinglist=? where subscriptionid=?"); - $sth->execute($recievedlist,$missinglist,$subscriptionid); # create new waited entry if needed (ie : was a "waited" and has changed) if ($oldstatus eq 1 && $status ne 1) { $sth = $dbh->prepare("select * from subscription where subscriptionid = ? "); @@ -418,6 +441,13 @@ sub newissue { $sth->execute($recievedlist,$missinglist,$subscriptionid); } +sub delissue { + my ($serialseq,$subscriptionid) = @_; + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare("delete from serial where serialseq= ? and subscriptionid= ? "); + $sth->execute($serialseq,$subscriptionid); +} + sub Get_Next_Date(@) { my ($planneddate,$subscription) = @_; my $resultdate; diff --git a/koha-tmpl/intranet-tmpl/default/en/bull/statecollection.tmpl b/koha-tmpl/intranet-tmpl/default/en/bull/statecollection.tmpl index 5e118c5003..126af24dc5 100644 --- a/koha-tmpl/intranet-tmpl/default/en/bull/statecollection.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/bull/statecollection.tmpl @@ -53,6 +53,16 @@ + + + + + + + + + + diff --git a/koha-tmpl/opac-tmpl/css/en/opac-detail.tmpl b/koha-tmpl/opac-tmpl/css/en/opac-detail.tmpl index fcf9134f91..75f5626856 100644 --- a/koha-tmpl/opac-tmpl/css/en/opac-detail.tmpl +++ b/koha-tmpl/opac-tmpl/css/en/opac-detail.tmpl @@ -157,15 +157,49 @@ + -

- This is a serial subscription (we have subscriptions). You can see which - " class="button catalogue" title="Serial issues"> - Issues - we have and don't have -

- +
+

This is a serial subscription (There are subscriptions associated with this title).

+ + Subscription # +

+ +

Here comes a list of the three latest issues related to this subscription :

+ + + + + + + + +
+ + + + + Waited + + Arrived + + Late + + Missing + + Not Issued + + + + + +
+ + +

For more information :Click " title="Serial issues"> here to look for Issues we have or don't have

+
+ diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 7f4f1643bd..eca8a07884 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -29,8 +29,21 @@ my $dat = &bibdata($biblionumber); my ($authorcount, $addauthor) = &addauthor($biblionumber); my ($webbiblioitemcount, @webbiblioitems) = &getwebbiblioitems($biblionumber); my ($websitecount, @websites) = &getwebsites($biblionumber); -my $subscriptionsnumber = getsubscriptionfrombiblionumber($biblionumber); + #coping with subscriptions + my $subscriptionsnumber = getsubscriptionfrombiblionumber($biblionumber); + my @subscriptions = getsubscriptions($dat->{title},$dat->{issn},$biblionumber); + my @subs; + foreach my $subscription (@subscriptions){ + warn "subsid :".$subscription->{subscriptionid}; + my %cell; + $cell{subscriptionid}= $subscription->{subscriptionid}; + $cell{subscriptionnotes}= $subscription->{notes}; + #get the three latest serials. + $cell{latestserials}=getlatestserials($subscription->{subscriptionid},3); + push @subs, \%cell; + } + $dat->{'count'}=@items; $dat->{'additional'}=$addauthor->[0]->{'author'}; @@ -70,6 +83,7 @@ $template->param(BIBLIO_RESULTS => $resultsarray, ITEM_RESULTS => $itemsarray, WEB_RESULTS => $webarray, SITE_RESULTS => $sitearray, + subscriptions => \@subs, subscriptionsnumber => $subscriptionsnumber, LibraryName => C4::Context->preference("LibraryName"), suggestion => C4::Context->preference("suggestion"), -- 2.39.5