From 6c086454ffcd20ec4cea048faa47459eebfdafaa Mon Sep 17 00:00:00 2001 From: Paul Poulain Date: Tue, 10 Nov 2009 18:28:53 +0100 Subject: [PATCH] revamping a little opac-detail for subscription (adding more history information) --- C4/Serials.pm | 61 ++++++++++--------- installer/data/mysql/kohastructure.sql | 2 +- .../prog/en/modules/opac-detail.tmpl | 9 ++- opac/opac-detail.pl | 4 ++ 4 files changed, 42 insertions(+), 34 deletions(-) diff --git a/C4/Serials.pm b/C4/Serials.pm index 3c47651bb4..c6372e4575 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -533,7 +533,7 @@ sub GetSubscriptionsFromBiblionumber { while ( my $subs = $sth->fetchrow_hashref ) { $subs->{startdate} = format_date( $subs->{startdate} ); $subs->{histstartdate} = format_date( $subs->{histstartdate} ); - $subs->{histenddate} = format_date( $subs->{histenddate} ); + $subs->{enddate} = format_date( $subs->{enddate} ); $subs->{opacnote} =~ s/\n/\/g; $subs->{missinglist} =~ s/\n/\/g; $subs->{recievedlist} =~ s/\n/\/g; @@ -625,44 +625,45 @@ sub GetSubscriptions { my $dbh = C4::Context->dbh; my $sth; my $sql = qq( - SELECT subscription.*,biblio.title,biblioitems.issn,biblio.biblionumber + SELECT subscription.*, subscriptionhistory.*, biblio.title,biblioitems.issn,biblio.biblionumber FROM subscription + LEFT JOIN subscriptionhistory USING(subscriptionid) LEFT JOIN biblio ON biblio.biblionumber = subscription.biblionumber LEFT JOIN biblioitems ON biblio.biblionumber = biblioitems.biblionumber ); - my @bind_params; - my $sqlwhere; + my @bind_params; + my $sqlwhere; if ($biblionumber) { $sqlwhere=" WHERE biblio.biblionumber=?"; - push @bind_params,$biblionumber; + push @bind_params,$biblionumber; } if ($string){ - my @sqlstrings; - my @strings_to_search; - @strings_to_search=map {"%$_%"} split (/ /,$string); - foreach my $index qw(biblio.title subscription.callnumber subscription.location subscription.notes subscription.internalnotes){ - push @bind_params,@strings_to_search; - my $tmpstring= "AND $index LIKE ? "x scalar(@strings_to_search); - $debug && warn "$tmpstring"; - $tmpstring=~s/^AND //; - push @sqlstrings,$tmpstring; - } - $sqlwhere.= ($sqlwhere?" AND ":" WHERE ")."(".join(") OR (",@sqlstrings).")"; - } + my @sqlstrings; + my @strings_to_search; + @strings_to_search=map {"%$_%"} split (/ /,$string); + foreach my $index qw(biblio.title subscription.callnumber subscription.location subscription.notes subscription.internalnotes){ + push @bind_params,@strings_to_search; + my $tmpstring= "AND $index LIKE ? "x scalar(@strings_to_search); + $debug && warn "$tmpstring"; + $tmpstring=~s/^AND //; + push @sqlstrings,$tmpstring; + } + $sqlwhere.= ($sqlwhere?" AND ":" WHERE ")."(".join(") OR (",@sqlstrings).")"; + } if ($issn){ - my @sqlstrings; - my @strings_to_search; - @strings_to_search=map {"%$_%"} split (/ /,$issn); - foreach my $index qw(biblioitems.issn subscription.callnumber){ - push @bind_params,@strings_to_search; - my $tmpstring= "OR $index LIKE ? "x scalar(@strings_to_search); - $debug && warn "$tmpstring"; - $tmpstring=~s/^OR //; - push @sqlstrings,$tmpstring; - } - $sqlwhere.= ($sqlwhere?" AND ":" WHERE ")."(".join(") OR (",@sqlstrings).")"; - } - $sql.="$sqlwhere ORDER BY title"; + my @sqlstrings; + my @strings_to_search; + @strings_to_search=map {"%$_%"} split (/ /,$issn); + foreach my $index qw(biblioitems.issn subscription.callnumber){ + push @bind_params,@strings_to_search; + my $tmpstring= "OR $index LIKE ? "x scalar(@strings_to_search); + $debug && warn "$tmpstring"; + $tmpstring=~s/^OR //; + push @sqlstrings,$tmpstring; + } + $sqlwhere.= ($sqlwhere?" AND ":" WHERE ")."(".join(") OR (",@sqlstrings).")"; + } + $sql.="$sqlwhere ORDER BY title"; $debug and warn "GetSubscriptions query: $sql params : ", join (" ",@bind_params); $sth = $dbh->prepare($sql); $sth->execute(@bind_params); diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index ba40e631eb..9f0c2c17be 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1704,7 +1704,7 @@ CREATE TABLE `subscriptionhistory` ( `biblionumber` int(11) NOT NULL default 0, `subscriptionid` int(11) NOT NULL default 0, `histstartdate` date default NULL, - `enddate` date default NULL, + `histenddate` date default NULL, `missinglist` longtext NOT NULL, `recievedlist` longtext NOT NULL, `opacnote` varchar(150) NOT NULL default '', diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl index 6795b17c4c..095463555e 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl @@ -569,13 +569,16 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
-

This is a serial subscription

-

(There are subscriptions associated with this title).

+

This is a serial

+

There are subscription(s) associated with this title.

At library:

At branch:

- +

Issues between: and: now (current)

+

Missing issues:

+

()

+

The latest issues for this subscription:

diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index cc679472ca..fdd1b875ea 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -112,6 +112,10 @@ foreach my $subscription (@subscriptions) { my %cell; $cell{subscriptionid} = $subscription->{subscriptionid}; $cell{subscriptionnotes} = $subscription->{notes}; + $cell{missinglist} = $subscription->{missinglist}; + $cell{opacnote} = $subscription->{opacnote}; + $cell{histstartdate} = format_date($subscription->{histstartdate}); + $cell{histenddate} = format_date($subscription->{histenddate}); $cell{branchcode} = $subscription->{branchcode}; $cell{branchname} = GetBranchName($subscription->{branchcode}); $cell{hasalert} = $subscription->{hasalert}; -- 2.39.5