From 1bd0192b1ccde031e45809d2e5bda917f46b9f81 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 9 Mar 2012 10:05:38 +0100 Subject: [PATCH] [SIGNED-OFF] Bug 5357: Adds a new page for searching subscriptions Test plan: - go on the serial module - click on the 'Advanced search' link (right of subscriptions search in the header) - Search subscriptions (by ISSN, title, EAN, Publisher, Supplier and/or Branch) - Check results are correct Signed-off-by: Katrin Fischer --- C4/Serials.pm | 69 ++++++++ .../prog/en/includes/biblio-view-menu.inc | 2 +- .../prog/en/includes/serials-search.inc | 60 +++---- .../prog/en/modules/serials/serial-issues.tt | 2 +- .../prog/en/modules/serials/serials-home.tt | 165 ++---------------- .../prog/en/modules/serials/serials-search.tt | 183 ++++++++++++++++++++ serials/serials-home.pl | 71 +------- serials/serials-search.pl | 110 ++++++++++++ 8 files changed, 411 insertions(+), 251 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt create mode 100755 serials/serials-search.pl diff --git a/C4/Serials.pm b/C4/Serials.pm index 98660e9..2100073 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -36,6 +36,7 @@ BEGIN { @EXPORT = qw( &NewSubscription &ModSubscription &DelSubscription &GetSubscriptions &GetSubscription &CountSubscriptionFromBiblionumber &GetSubscriptionsFromBiblionumber + &SearchSubscriptions &GetFullSubscriptionsFromBiblionumber &GetFullSubscription &ModSubscriptionHistory &HasSubscriptionStrictlyExpired &HasSubscriptionExpired &GetExpirationDate &abouttoexpire @@ -631,6 +632,74 @@ sub GetSubscriptions { return @results; } +=head2 SearchSubscriptions + +@results = SearchSubscriptions($args); +$args is a hashref. Its keys can be contained: title, issn, ean, publisher, bookseller and branchcode + +this function gets all subscriptions which have title like $title, ISSN like $issn, EAN like $ean, publisher like $publisher, bookseller like $bookseller AND branchcode eq $branch. + +return: +a table of hashref. Each hash containt the subscription. + +=cut + +sub SearchSubscriptions { + my ( $args ) = @_; + + my $query = qq{ + SELECT subscription.*, subscriptionhistory.*, biblio.*, biblioitems.issn + FROM subscription + LEFT JOIN subscriptionhistory USING(subscriptionid) + LEFT JOIN biblio ON biblio.biblionumber = subscription.biblionumber + LEFT JOIN biblioitems ON biblioitems.biblionumber = subscription.biblionumber + LEFT JOIN aqbooksellers ON subscription.aqbooksellerid = aqbooksellers.id + }; + my @where_strs; + my @where_args; + if( $args->{biblionumber} ) { + push @where_strs, "biblio.biblionumber = ?"; + push @where_args, $args->{biblionumber}; + } + if( $args->{title} ){ + push @where_strs, "biblio.title LIKE ?"; + push @where_args, "%$args->{title}%"; + } + if( $args->{issn} ){ + push @where_strs, "biblioitems.issn LIKE ?"; + push @where_args, "%$args->{issn}%"; + } + if( $args->{ean} ){ + push @where_strs, "biblioitems.ean LIKE ?"; + push @where_args, "%$args->{ean}%"; + } + if( $args->{publisher} ){ + push @where_strs, "biblioitems.publishercode LIKE ?"; + push @where_args, "%$args->{publisher}%"; + } + if( $args->{bookseller} ){ + push @where_strs, "aqbooksellers.name LIKE ?"; + push @where_args, "%$args->{bookseller}%"; + } + if( $args->{branch} ){ + push @where_strs, "subscription.branchcode = ?"; + push @where_args, "$args->{branch}"; + } + + if(@where_strs){ + $query .= " WHERE " . join(" AND ", @where_strs); + } + + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare($query); + $sth->execute(@where_args); + my $results = $sth->fetchall_arrayref( {} ); + $sth->finish; + + return @$results; +} + + =head2 GetSerials ($totalissues,@serials) = GetSerials($subscriptionid); diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc index 903cf3a..b2edbe6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc @@ -25,7 +25,7 @@ [% END %] [% IF ( EasyAnalyticalRecords ) %][% IF ( analyze ) %]
  • [% ELSE %]
  • [% END %]Analytics
  • [% END %] - [% IF ( subscriptionsnumber ) %]
  • Subscription(s)
  • [% END %] + [% IF ( subscriptionsnumber ) %]
  • Subscription(s)
  • [% END %]