From 3ce952b9b76f1ffae988f59af73a55dce6868399 Mon Sep 17 00:00:00 2001 From: Jonathan Druart <jonathan.druart@biblibre.com> Date: Fri, 9 Mar 2012 10:05:38 +0100 Subject: [PATCH] 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: Corinne HAYET <corinne.hayet@bulac.fr> --- C4/Serials.pm | 65 +++++++ .../prog/en/includes/serials-search.inc | 60 ++++---- .../prog/en/modules/serials/serials-home.tt | 176 ++++---------------- .../prog/en/modules/serials/serials-search.tt | 172 +++++++++++++++++++ serials/serials-home.pl | 44 ++++-- serials/serials-search.pl | 114 +++++++++++++ 6 files changed, 446 insertions(+), 185 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 58b6078..9508166 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 @@ -630,6 +631,70 @@ 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->{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}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/serials-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/serials-search.inc index dfb908f..beb309c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-search.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/serials-search.inc @@ -1,35 +1,37 @@ <div class="gradient"> -<h1 id="logo"><a href="/cgi-bin/koha/mainpage.pl">[% LibraryName %]</a></h1><!-- Begin Serials Resident Search Box --> -<div id="header_search"> - <div id="subscription_search" class="residentsearch"> + <h1 id="logo"><a href="/cgi-bin/koha/mainpage.pl">[% LibraryName %]</a></h1><!-- Begin Serials Resident Search Box --> + <div id="header_search"> + <div id="subscription_search" class="residentsearch"> <p class="tip">Search subscriptions:</p> - <form action="/cgi-bin/koha/serials/serials-home.pl" method="get"> - [% IF ( routing ) %]<input type="hidden" name="routing" value="[% routing %]" />[% END %] - <input type="hidden" name="searched" value="1" /> - <label for="ISSN_filter">ISSN:</label> <input type="text" size="10" maxlength="11" name="ISSN_filter" id="ISSN_filter" value="[% ISSN_filter %]" /> + <form action="/cgi-bin/koha/serials/serials-search.pl" method="get"> + [% IF ( routing ) %] + <input type="hidden" name="routing" value="[% routing %]" /> + [% END %] + <input type="hidden" name="searched" value="1" /> + <label for="ISSN_filter">ISSN:</label> <input type="text" size="10" maxlength="11" name="ISSN_filter" id="ISSN_filter" value="[% ISSN_filter %]" /> - [% IF (UNIMARC) %] - <label for="EAN_filter">EAN:</label> <input type="text" size="20" maxlength="40" name="EAN_filter" id="EAN_filter" value="[% EAN_filter %]" /> - [% END %] - <label for="title_filter">Title:</label> <input type="text" size="20" maxlength="40" name="title_filter" id="title_filter" value="[% title_filter %]" /> - <input type="submit" value="Search" class="submit" /> - </form> - </div> + [% IF (UNIMARC) %] + <label for="EAN_filter">EAN:</label> <input type="text" size="20" maxlength="40" name="EAN_filter" id="EAN_filter" value="[% EAN_filter %]" /> + [% END %] + <label for="title_filter">Title:</label> <input type="text" size="20" maxlength="40" name="title_filter" id="title_filter" value="[% title_filter %]" /> + <input value="Submit" class="submit" type="submit" /> <a href="/cgi-bin/koha/serials/serials-search.pl">Advanced search</a> + </form> + </div> [% INCLUDE 'patron-search-box.inc' %] - [% IF ( CAN_user_catalogue ) %] - <div id="catalog_search" class="residentsearch"> - <p class="tip">Enter search keywords:</p> - <form action="/cgi-bin/koha/catalogue/search.pl" method="get" id="cat-search-block"> - <input type="text" name="q" id="search-form" size="40" value="" title="Enter the terms you wish to search for." class="form-text" /> - <input type="submit" value="Submit" class="submit" /> - </form> - </div> - [% END %] - <ul> - <li><a href="#subscription_search">Search subscriptions</a></li> - [% IF ( CAN_user_circulate ) %]<li><a href="#circ_search">Check out</a></li>[% END %] - [% IF ( CAN_user_catalogue ) %]<li><a href="#catalog_search">Search the catalog</a></li>[% END %] - </ul> -</div><!-- /header_search --> + [% IF ( CAN_user_catalogue ) %] + <div id="catalog_search" class="residentsearch"> + <p class="tip">Enter search keywords:</p> + <form action="/cgi-bin/koha/catalogue/search.pl" method="get" id="cat-search-block"> + <input type="text" name="q" id="search-form" size="40" value="" title="Enter the terms you wish to search for." class="form-text" /> + <input type="submit" value="Submit" class="submit" /> + </form> + </div> + [% END %] + <ul> + <li><a href="#subscription_search">Search subscriptions</a></li> + [% IF ( CAN_user_circulate ) %]<li><a href="#circ_search">Check out</a></li>[% END %] + [% IF ( CAN_user_catalogue ) %]<li><a href="#catalog_search">Search the catalog</a></li>[% END %] + </ul> + </div><!-- /header_search --> </div><!-- /gradient --> <!-- End Serials Resident Search Box --> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-home.tt index 1fdf693..973fcc9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-home.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-home.tt @@ -1,24 +1,6 @@ [% INCLUDE 'doc-head-open.inc' %] <title>Koha › Serials [% biblionumber %]</title> -<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" /> [% INCLUDE 'doc-head-close.inc' %] -<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script> -[% INCLUDE 'datatables-strings.inc' %] -<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script> -<script type="text/javascript"> -//<![CDATA[ - $(document).ready(function() { - var srlt = $("#srlt").dataTable($.extend(true, {}, dataTablesDefaults, { - "aoColumnDefs": [ - { "aTargets": [ -1, -2, -3 ], "bSortable": false, "bSearchable": false }, - ], - "sPaginationType": "four_button" - } ) ); - - srlt.fnAddFilters("filter", 750); - }); - //]]> -</script> </head> <body id="ser_serials-home" class="ser"> [% INCLUDE 'header.inc' %] @@ -27,133 +9,39 @@ <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › [% IF ( done_searched ) %]<a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a> › Search results[% ELSE %]Serials [% END %] </div> <div id="doc3" class="yui-t2"> - - <div id="bd"> - <div id="yui-main"> - <div class="yui-b"> - [% INCLUDE 'serials-toolbar.inc' %] - -[% IF ( information ) %] -Serials updated : -<table> - <tr> - <th> - Serialseq - </th> - <th> - Status - </th> - <th> - Published date - </th> - <th> - Planned date - </th> - <th> - Notes - </th> - </tr> -[% FOREACH informatio IN information %] - <tr> - <td> - [% informatio.serialseq %] - </td> - <td> - [% informatio.status %] - </td> - <td> - [% informatio.publisheddate %] - </td> - <td> - [% informatio.planneddate %] - </td> - <td> - [% informatio.notes %] - </td> - </tr> -[% END %] -</table> -[% END %] - [% IF ( done_searched ) %] -<h2>Serials subscriptions</h2> - - <table id="srlt"> - <thead> - <tr> - <th>ISSN</th> - <th>Title</th> - <th> Notes </th> - <th> - Library (callnumber) - </th> - [% IF ( routing && CAN_user_serials_routing ) %] - <th>Routing list</th> - [% END %] - <th> </th> - <th> </th> - </tr> - </thead> - <tfoot> - <tr> - <td><input type="text" class="filter" data-column_num="0" placeholder="Search ISSN" /></td> - <td><input type="text" class="filter" data-column_num="1" placeholder="Search title" /></td> - <td><input type="text" class="filter" data-column_num="2" placeholder="Search notes" /></td> - <td><input type="text" class="filter" data-column_num="3" placeholder="Search library" /></td> - [% IF ( routing && CAN_user_serials_routing ) %]<td></td>[% END %] - <td></td> - <td></td> - </tr> - </tfoot> - <tbody> - [% FOREACH subscription IN subscriptions %] +<div id="bd"> + <div id="yui-main"> + <div class="yui-b"> + [% INCLUDE 'serials-toolbar.inc' %] + [% IF ( information ) %] + Serials updated : + <table> + <thead> <tr> - <td> - [% IF ( subscription.issn ) %][% subscription.issn %] - [% END %] - </td> - <td><a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% subscription.subscriptionid %]" class="button" title="subscription detail">[% subscription.title |html %]</a> - </td> - <td>[% IF ( subscription.notes ) %][% subscription.notes %][% END %] - [% IF ( subscription.internalnotes ) %]([% subscription.internalnotes %])[% END %] - </td> - <td> - [% IF ( subscription.branchname ) %][% subscription.branchname %][% END %] - [% IF ( subscription.callnumber ) %]([% subscription.callnumber %])[% END %] - </td> - [% IF ( routing && CAN_user_serials_routing ) %] - <td> - [% IF ( subscription.cannotedit ) %] - - [% ELSE %] - [% IF ( subscription.routingedit ) %] - <a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscription.subscriptionid %]">Edit</a> - [% ELSE %] - <a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscription.subscriptionid %]&op=new">New</a> - [% END %] - [% END %] - </td> - [% END %] - <td><a href="/cgi-bin/koha/serials/serials-collection.pl?subscriptionid=[% subscription.subscriptionid %]">Issue history</a> - </td> - <td> - [% IF ( subscription.cannotedit ) %] - - [% ELSE %] - [% IF ( CAN_user_serials_receive_serials ) %]<a href="/cgi-bin/koha/serials/serials-edit.pl?subscriptionid=[% subscription.subscriptionid %]&serstatus=1,3,7">Serial receive</a>[% END %] - [% END %] - </td> + <th>Serialseq</th> + <th>Status</th> + <th>Published date</th> + <th>Planned date</th> + <th>Notes</th> </tr> - [% END %] - </tbody> - </table> - - [% END %] - -</div> -</div> - -<div class="yui-b"> -[% INCLUDE 'serials-menu.inc' %] -</div> + </thead> + <tbody> + [% FOREACH informatio IN information %] + <tr> + <td>[% informatio.serialseq %]</td> + <td>[% informatio.status %]</td> + <td>[% informatio.publisheddate %]</td> + <td>[% informatio.planneddate %]</td> + <td>[% informatio.notes %]</td> + </tr> + [% END %] + </tbody> + </table> + [% END %] + </div> + </div> + <div class="yui-b"> + [% INCLUDE 'serials-menu.inc' %] + </div> </div> [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt new file mode 100644 index 0000000..4f8dfce --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt @@ -0,0 +1,172 @@ +[% INCLUDE 'doc-head-open.inc' %] +<title>Koha › Serials [% biblionumber %]</title> +<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" /> +[% INCLUDE 'doc-head-close.inc' %] +<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script> +[% INCLUDE 'datatables-strings.inc' %] +<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script> +<script type="text/javascript"> +//<![CDATA[ + $(document).ready(function() { + var srlt = $("#srlt").dataTable($.extend(true, {}, dataTablesDefaults, { + "aoColumnDefs": [ + { "aTargets": [ -1, -2, -3 ], "bSortable": false, "bSearchable": false }, + ], + "sPaginationType": "four_button" + } ) ); + + srlt.fnAddFilters("filter", 750); + }); + //]]> +</script> +</head> +<body id="ser_serials-home" class="ser"> +[% INCLUDE 'header.inc' %] +[% INCLUDE 'serials-search.inc' %] + +<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › [% IF ( done_searched ) %]<a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a> › Search results[% ELSE %]Serials [% END %] </div> + +<div id="doc3" class="yui-t2"> + <div id="bd"> + <div id="yui-main"> + <div class="yui-b"> + [% INCLUDE 'serials-toolbar.inc' %] + + <h2>Serials subscriptions</h2> + + <div id="advsearch"> + <form action="/cgi-bin/koha/serials/serials-search.pl" method="get"> + <fieldset class="brief"> + [% IF ( done_searched ) %] + <a id="unfold_advsearch" style="cursor:pointer" onclick="$('#advsearch_form').slideToggle(400);">Advanced search</a> + <div id="advsearch_form" style="display:none"> + [% ELSE %] + <div> + [% END %] + <ol> + <li> + <label for="issn">ISSN:</label> + <input type="text" id="issn" name="ISSN_filter" value="[% ISSN_filter %]" /> + </li> + <li> + <label for="title">Title:</label> + <input type="text" id="title" name="title_filter" value="[% title_filter %]" /> + </li> + <li> + <label for="ean">EAN:</label> + <input type="text" id="ean" name="EAN_filter" value="[% EAN_filter %]" /> + </li> + <li> + <label for="publisher">Publisher:</label> + <input type="text" id="publisher" name="publisher_filter" value="[% publisher_filter %]" /> + </li> + <li> + <label for="bookseller">Bookseller:</label> + <input type="text" id="bookseller" name="bookseller_filter" value="[% bookseller_filter %]" /> + </li> + <li> + <label for="branch">Branch:</label> + <select id="branch" name="branch_filter"> + <option value="">All</option> + [% FOREACH branch IN branches_loop %] + [% IF ( branch.selected ) %] + <option selected="selected" value="[% branch.branchcode %]">[% branch.branchname %]</option> + [% ELSE %] + <option value="[% branch.branchcode %]">[% branch.branchname %]</option> + [% END %] + [% END %] + </select> + </li> + </ol> + <input type="hidden" name="searched" value="1" /> + <fieldset class="action"> + <input type="submit" value="Search" /> + </fieldset> + </div> + </fieldset> + </form> + </div> + + [% IF ( done_searched ) %] + [% IF ( subscriptions ) %] + <table id="srlt"> + <thead> + <tr> + <th>ISSN</th> + <th>Title</th> + <th> Notes </th> + <th> + Library (callnumber) + </th> + [% IF ( routing && CAN_user_serials_routing ) %] + <th>Routing list</th> + [% END %] + <th> </th> + <th> </th> + </tr> + </thead> + <tfoot> + <tr> + <td><input type="text" class="filter" data-column_num="0" placeholder="Search ISSN" /></td> + <td><input type="text" class="filter" data-column_num="1" placeholder="Search title" /></td> + <td><input type="text" class="filter" data-column_num="2" placeholder="Search notes" /></td> + <td><input type="text" class="filter" data-column_num="3" placeholder="Search library" /></td> + [% IF ( routing && CAN_user_serials_routing ) %]<td></td>[% END %] + <td></td> + <td></td> + </tr> + </tfoot> + <tbody> + [% FOREACH subscription IN subscriptions %] + <tr> + <td> + [% IF ( subscription.issn ) %][% subscription.issn %] + [% END %] + </td> + <td><a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% subscription.subscriptionid %]" class="button" title="subscription detail">[% subscription.title |html %]</a> + </td> + <td>[% IF ( subscription.notes ) %][% subscription.notes %][% END %] + [% IF ( subscription.internalnotes ) %]([% subscription.internalnotes %])[% END %] + </td> + <td> + [% IF ( subscription.branchname ) %][% subscription.branchname %][% END %] + [% IF ( subscription.callnumber ) %]([% subscription.callnumber %])[% END %] + </td> + [% IF ( routing && CAN_user_serials_routing ) %] + <td> + [% IF ( subscription.cannotedit ) %] + + [% ELSE %] + [% IF ( subscription.routingedit ) %] + <a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscription.subscriptionid %]">Edit</a> + [% ELSE %] + <a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscription.subscriptionid %]&op=new">New</a> + [% END %] + [% END %] + </td> + [% END %] + <td><a href="/cgi-bin/koha/serials/serials-collection.pl?subscriptionid=[% subscription.subscriptionid %]">Issue history</a> + </td> + <td> + [% IF ( subscription.cannotedit ) %] + + [% ELSE %] + [% IF ( CAN_user_serials_receive_serials ) %]<a href="/cgi-bin/koha/serials/serials-edit.pl?subscriptionid=[% subscription.subscriptionid %]&serstatus=1,3,7">Serial receive</a>[% END %] + [% END %] + </td> + </tr> + [% END %] + </tbody> + </table> + [% ELSE %] + There is no subscription for your search. + [% END %] + [% END %] + </div> + </div> + + <div class="yui-b"> + [% INCLUDE 'serials-menu.inc' %] + </div> +</div> +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/serials/serials-home.pl b/serials/serials-home.pl index 21b76e0..1eaf469 100755 --- a/serials/serials-home.pl +++ b/serials/serials-home.pl @@ -44,18 +44,21 @@ use strict; use warnings; use CGI; use C4::Auth; -use C4::Serials; -use C4::Output; -use C4::Context; use C4::Branch; +use C4::Context; +use C4::Output; +use C4::Serials; -my $query = new CGI; -my $title = $query->param('title_filter'); -my $ISSN = $query->param('ISSN_filter'); -my $EAN = $query->param('EAN_filter'); -my $routing = $query->param('routing') || C4::Context->preference("RoutingSerials"); -my $searched = $query->param('searched'); -my $biblionumber = $query->param('biblionumber'); +my $query = new CGI; +my $title = $query->param('title_filter'); +my $ISSN = $query->param('ISSN_filter'); +my $EAN = $query->param('EAN_filter'); +my $publisher = $query->param('publisher_filter'); +my $supplier = $query->param('supplier_filter'); +my $branch = $query->param('branch_filter'); +my $routing = $query->param('routing') || C4::Context->preference("RoutingSerials"); +my $searched = $query->param('searched'); +my $biblionumber = $query->param('biblionumber'); my @serialseqs = $query->param('serialseq'); my @planneddates = $query->param('planneddate'); @@ -93,8 +96,8 @@ if (@serialseqs){ $template->param('information'=>\@information); } my @subscriptions; -if ($searched) { - @subscriptions = GetSubscriptions( $title, $ISSN, $EAN, $biblionumber ); +if ($searched){ + @subscriptions = SearchSubscriptions( $title, $ISSN, $EAN, $publisher, $supplier, $branch ); } # to toggle between create or edit routing list options @@ -105,10 +108,27 @@ if ($routing) { } } +my $branches = GetBranches(); +my @branches_loop; +foreach (sort keys %$branches){ + my $selected = 0; + $selected = 1 if( $branch eq $_ ); + push @branches_loop, { + branchcode => $_, + branchname => $branches->{$_}->{'branchname'}, + selected => $selected, + }; +} + $template->param( subscriptions => \@subscriptions, title_filter => $title, ISSN_filter => $ISSN, + EAN_filter => $EAN, + publisher_filter => $publisher, + supplier_filter => $supplier, + branch_filter => $branch, + branches_loop => \@branches_loop, done_searched => $searched, routing => $routing, (uc(C4::Context->preference("marcflavour"))) => 1 diff --git a/serials/serials-search.pl b/serials/serials-search.pl new file mode 100755 index 0000000..098c380 --- /dev/null +++ b/serials/serials-search.pl @@ -0,0 +1,114 @@ +#!/usr/bin/perl + +# Copyright 2012 Koha Team +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + +=head1 NAME + +serials-search.pl + +=head1 DESCRIPTION + +this script is the search page for serials + +=cut + +use Modern::Perl; +use CGI; +use C4::Auth; +use C4::Branch; +use C4::Context; +use C4::Output; +use C4::Serials; + +my $query = new CGI; +my $title = $query->param('title_filter') || ''; +my $ISSN = $query->param('ISSN_filter') || ''; +my $EAN = $query->param('EAN_filter') || ''; +my $publisher = $query->param('publisher_filter') || ''; +my $bookseller = $query->param('bookseller_filter') || ''; +my $branch = $query->param('branch_filter') || ''; +my $routing = $query->param('routing') || C4::Context->preference("RoutingSerials"); +my $searched = $query->param('searched') || 0; + +my @serialseqs = $query->param('serialseq'); +my @planneddates = $query->param('planneddate'); +my @publisheddates = $query->param('publisheddate'); +my @status = $query->param('status'); +my @notes = $query->param('notes'); + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "serials/serials-search.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => { serials => '*' }, + debug => 1, + } +); + +my @subscriptions; +if ($searched){ + @subscriptions = SearchSubscriptions( + { + title =>$title, + isbn => $ISSN, + ean => $EAN, + publisher => $publisher, + bookseller => $bookseller, + branch => $branch + } + ); +} + +# to toggle between create or edit routing list options +if ($routing) { + for my $subscription ( @subscriptions) { + $subscription->{routingedit} = check_routing( $subscription->{subscriptionid} ); + $subscription->{branchname} = GetBranchName ( $subscription->{branchcode} ); + } +} + +my $branches = GetBranches(); +my @branches_loop; +foreach (sort keys %$branches){ + my $selected = 0; + $selected = 1 if( $branch eq $_ ); + push @branches_loop, { + branchcode => $_, + branchname => $branches->{$_}->{'branchname'}, + selected => $selected, + }; +} + +$template->param( + subscriptions => \@subscriptions, + title_filter => $title, + ISSN_filter => $ISSN, + EAN_filter => $EAN, + publisher_filter => $publisher, + bookseller_filter => $bookseller, + branch_filter => $branch, + branches_loop => \@branches_loop, + done_searched => $searched, + routing => $routing, + (uc(C4::Context->preference("marcflavour"))) => 1 +); + +output_html_with_http_headers $query, $cookie, $template->output; -- 1.7.2.5