From bfeb60efd2f4f8111841bbb7217435fdef568187 Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Date: Fri, 27 Jul 2018 15:46:32 -0300
Subject: [PATCH] Bug 15184: Prepare the ground - Move order search filters
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
We are going to reuse these filters so we move it to a separate include
file.
Sponsored-by: BULAC - http://www.bulac.fr/
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
---
acqui/histsearch.pl | 87 +++++++------------
.../prog/en/includes/filter-orders.inc | 96 +++++++++++++++++++++
.../prog/en/modules/acqui/histsearch.tt | 98 +---------------------
3 files changed, 128 insertions(+), 153 deletions(-)
create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/filter-orders.inc
diff --git a/acqui/histsearch.pl b/acqui/histsearch.pl
index b30eda31dd..663ab604ae 100755
--- a/acqui/histsearch.pl
+++ b/acqui/histsearch.pl
@@ -59,27 +59,7 @@ use C4::Koha;
use Koha::DateUtils;
my $input = new CGI;
-my $title = $input->param( 'title');
-my $author = $input->param('author');
-my $isbn = $input->param('isbn');
-my $name = $input->param( 'name' );
-my $ean = $input->param('ean');
-my $basket = $input->param( 'basket' );
-my $basketgroupname = $input->param('basketgroupname');
-my $booksellerinvoicenumber = $input->param( 'booksellerinvoicenumber' );
my $do_search = $input->param('do_search') || 0;
-my $budget = $input->param( 'budget' );
-my $orderstatus = $input->param( 'orderstatus' );
-my $ordernumber = $input->param( 'ordernumber' );
-my $search_children_too = $input->param( 'search_children_too' );
-my @created_by = $input->multi_param('created_by');
-
-my $from_placed_on = eval { dt_from_string( scalar $input->param('from') ) } || dt_from_string;
-my $to_placed_on = eval { dt_from_string( scalar $input->param('to') ) } || dt_from_string;
-unless ( $input->param('from') ) {
- # Fill the form with year-1
- $from_placed_on->subtract( years => 1 );
-}
my $dbh = C4::Context->dbh;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
@@ -93,26 +73,35 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
}
);
+my $filters = {
+ basket => scalar $input->param('basket'),
+ title => scalar $input->param('title'),
+ author => scalar $input->param('author'),
+ isbn => scalar $input->param('isbn'),
+ name => scalar $input->param('name'),
+ ean => scalar $input->param('ean'),
+ basketgroupname => scalar $input->param('basketgroupname'),
+ budget => scalar $input->param('budget'),
+ booksellerinvoicenumber => scalar $input->param('booksellerinvoicenumber'),
+ budget => scalar $input->param('budget'),
+ orderstatus => scalar $input->param('orderstatus'),
+ ordernumber => scalar $input->param('ordernumber'),
+ search_children_too => scalar $input->param('search_children_too'),
+ created_by => scalar $input->multi_param('created_by'),
+};
+my $from_placed_on = eval { dt_from_string( scalar $input->param('from') ) } || dt_from_string;
+my $to_placed_on = eval { dt_from_string( scalar $input->param('to') ) } || dt_from_string;
+unless ( $input->param('from') ) {
+ # Fill the form with year-1
+ $from_placed_on->subtract( years => 1 );
+}
+$filters->{from_placed_on} = output_pref( { dt => $from_placed_on, dateformat => 'iso', dateonly => 1 } ),
+$filters->{to_placed_on} = output_pref( { dt => $to_placed_on, dateformat => 'iso', dateonly => 1 } ),
+
my $order_loop;
# If we're supplied any value then we do a search. Otherwise we don't.
if ($do_search) {
- $order_loop = GetHistory(
- title => $title,
- author => $author,
- isbn => $isbn,
- ean => $ean,
- name => $name,
- from_placed_on => output_pref( { dt => $from_placed_on, dateformat => 'iso', dateonly => 1 } ),
- to_placed_on => output_pref( { dt => $to_placed_on, dateformat => 'iso', dateonly => 1 } ),
- basket => $basket,
- booksellerinvoicenumber => $booksellerinvoicenumber,
- basketgroupname => $basketgroupname,
- budget => $budget,
- orderstatus => $orderstatus,
- ordernumber => $ordernumber,
- search_children_too => $search_children_too,
- created_by => \@created_by,
- );
+ $order_loop = GetHistory(%$filters);
}
my $budgetperiods = C4::Budgets::GetBudgetPeriods;
@@ -126,26 +115,10 @@ for my $bp ( @{$budgetperiods} ) {
}
$template->param(
- order_loop => $order_loop,
- numresults => $order_loop ? scalar(@$order_loop) : undef,
- title => $title,
- author => $author,
- isbn => $isbn,
- ean => $ean,
- name => $name,
- basket => $basket,
- booksellerinvoicenumber => $booksellerinvoicenumber,
- basketgroupname => $basketgroupname,
- ordernumber => $ordernumber,
- search_children_too => $search_children_too,
- from_placed_on => $from_placed_on,
- to_placed_on => $to_placed_on,
- orderstatus => $orderstatus,
- budget_id => $budget,
- bp_loop => $bp_loop,
- search_done => $do_search,
- debug => $debug || $input->param('debug') || 0,
- uc(C4::Context->preference("marcflavour")) => 1
+ order_loop => $order_loop,
+ filters => $filters,
+ bp_loop => $bp_loop,
+ search_done => $do_search,
);
output_html_with_http_headers $input, $cookie, $template->output;
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/filter-orders.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/filter-orders.inc
new file mode 100644
index 0000000000..806551cc3e
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/filter-orders.inc
@@ -0,0 +1,96 @@
+[% USE Koha %]
+<ol>
+ <li><label for="title">Title: </label> <input type="text" name="title" id="title" value="[% filters.title | html %]" /></li>
+ <li><label for="author">Author: </label> <input type="text" name="author" id="author" value="[% filters.author | html %]" /></li>
+ <li><label for="isbn">ISBN: </label> <input type="text" name="isbn" id="isbn" value="[% filters.isbn | html %]" /></li>
+ [% IF Koha.Preference('marcflavour') == 'UNIMARC' %]
+ <li><label for="ean">EAN: </label> <input type="text" name="ean" id="ean" value="[% filters.ean | html %]" /></li>
+ [% END %]
+ <li><label for="name">Vendor: </label> <input type="text" name="name" id="name" value="[% filters.name | html %]" /></li>
+ <li><label for="basket">Basket: </label> <input type="text" name="basket" id="basket" value="[% filters.basket | html %]" /></li>
+ <li><label for="basket_creators">Basket created by: </label>
+ <input autocomplete="off" id="find_patron" type="text" style="width:150px" class="noEnterSubmit" />
+ <div>
+ <div id="basket_creators" style="float:left;"></div>
+ </div>
+ </li>
+ <li><label for="booksellerinvoicenumber ">Bookseller invoice no: </label> <input type="text" name="booksellerinvoicenumber" id="booksellerinvoicenumber" value="[% filters.booksellerinvoicenumber | html %]" /></li>
+ <li>
+ <label for="basketgroupname">Basket group:</label>
+ <input type="text" name="basketgroupname" id="basketgroupname" value="[% filters.basketgroupname | html %]" />
+ </li>
+ <li>
+ <label for="ordernumber">Order line:</label>
+ <input type="text" name="ordernumber" id="ordernumber" value="[% filters.ordernumber | html %]" />
+ [% IF filters.search_children_too %]
+ <input type="checkbox" name="search_children_too" id="search_children_too" value="1" checked="checked" />
+ [% ELSE %]
+ <input type="checkbox" name="search_children_too" id="search_children_too" value="1" />
+ [% END %]
+ <label class="yesno" for="search_children_too">Display children too.</label>
+ </li>
+
+ <li>
+ <label for="orderstatus">Order status: </label>
+ <select name="orderstatus" id="orderstatus">
+ [% IF filters.orderstatus == "" %]
+ <option value="">Any status except cancelled</option>
+ [% ELSE %]
+ <option value="" selected="selected"></option>
+ [% END %]
+ [% IF filters.orderstatus == "new" %]
+ <option value="new" selected="selected">New</option>
+ [% ELSE %]
+ <option value="new">New</option>
+ [% END %]
+ [% IF filters.orderstatus == "ordered" %]
+ <option value="ordered" selected="selected">Ordered</option>
+ [% ELSE %]
+ <option value="ordered">Ordered</option>
+ [% END %]
+ [% IF filters.orderstatus == "partial" %]
+ <option value="partial" selected="selected">Partially received</option>
+ [% ELSE %]
+ <option value="partial">Partially received</option>
+ [% END %]
+ [% IF filters.orderstatus == "complete" %]
+ <option value="complete" selected="selected">Received</option>
+ [% ELSE %]
+ <option value="complete">Received</option>
+ [% END %]
+ [% IF filters.orderstatus == "cancelled" %]
+ <option value="cancelled" selected="selected">Cancelled</option>
+ [% ELSE %]
+ <option value="cancelled">Cancelled</option>
+ [% END %]
+ </select>
+ </li>
+ <li>
+ <label for="fund">Fund: </label>
+ <select name="budget" id="fund">
+ <option value="">All funds</option>
+ [% FOREACH bp_loo IN bp_loop %]
+ <optgroup label="[% bp_loo.budget_period_description | html %]">
+ [% FOREACH h_loo IN bp_loo.hierarchy %]
+ [% IF h_loo.budget_id == filters.budget %]
+ <option type="text" value="[% h_loo.budget_id | html %]" branchcode="[% h_loo.budget_branchcode | html %]" selected="selected">
+ [% ELSE %]
+ <option type="text" value="[% h_loo.budget_id | html %]" branchcode="[% h_loo.budget_branchcode | html %]">
+ [% END %]
+ [% h_loo.budget_display_name %]
+ </option>
+ [% END %]
+ </optgroup>
+ [% END %]
+ </select>
+ </li>
+
+ <li><label for="from">From: </label>
+ <input type="text" size="10" id="from" name="from" value="[% filters.from_placed_on | $KohaDates %]" class="datepickerfrom" />
+ <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
+ </li>
+ <li><label for="to">To: </label>
+ <input type="text" size="10" id="to" name="to" value="[% filters.to_placed_on | $KohaDates %]" class="datepickerto" />
+ <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
+ </li>
+</ol>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt
index 284b07b5dd..c324728a76 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt
@@ -23,102 +23,8 @@
[% UNLESS ( order_loop ) %]<form action="/cgi-bin/koha/acqui/histsearch.pl" method="post">
<fieldset class="rows">
<legend>Search orders</legend>
- <ol>
- <li><label for="title">Title: </label> <input type="text" name="title" id="title" value="[% title | html %]" /></li>
- <li><label for="author">Author: </label> <input type="text" name="author" id="author" value="[% author | html %]" /></li>
- <li><label for="isbn">ISBN: </label> <input type="text" name="isbn" id="isbn" value="[% isbn | html %]" /></li>
- [% IF (UNIMARC) %]
- <li><label for="ean">EAN: </label> <input type="text" name="ean" id="ean" value="[% ean | html %]" /></li>
- [% END %]
- <li><label for="name">Vendor: </label> <input type="text" name="name" id="name" value="[% name | html %]" /></li>
- <li><label for="basket">Basket: </label> <input type="text" name="basket" id="basket" value="[% basket | html %]" /></li>
- <li><label for="basket_creators">Basket created by: </label>
- <input autocomplete="off" id="find_patron" type="text" style="width:150px" class="noEnterSubmit" />
- <div>
- <div id="basket_creators" style="float:left;"></div>
- </div>
- </li>
- <li><label for="booksellerinvoicenumber ">Bookseller invoice no: </label> <input type="text" name="booksellerinvoicenumber" id="booksellerinvoicenumber" value="[% booksellerinvoicenumber | html %]" /></li>
- <li>
- <label for="basketgroupname">Basket group:</label>
- <input type="text" name="basketgroupname" id="basketgroupname" value="[% basketgroupname | html %]" />
- </li>
- <li>
- <label for="ordernumber">Order line:</label>
- <input type="text" name="ordernumber" id="ordernumber" value="[% ordernumber | html %]" />
- [% IF search_children_too %]
- <input type="checkbox" name="search_children_too" id="search_children_too" value="1" checked="checked" />
- [% ELSE %]
- <input type="checkbox" name="search_children_too" id="search_children_too" value="1" />
- [% END %]
- <label class="yesno" for="search_children_too">Display children too.</label>
- </li>
-
- <li>
- <label for="orderstatus">Order status: </label>
- <select name="orderstatus" id="orderstatus">
- [% IF orderstatus == "" %]
- <option value="">Any status except cancelled</option>
- [% ELSE %]
- <option value="" selected="selected"></option>
- [% END %]
- [% IF orderstatus == "new" %]
- <option value="new" selected="selected">New</option>
- [% ELSE %]
- <option value="new">New</option>
- [% END %]
- [% IF orderstatus == "ordered" %]
- <option value="ordered" selected="selected">Ordered</option>
- [% ELSE %]
- <option value="ordered">Ordered</option>
- [% END %]
- [% IF orderstatus == "partial" %]
- <option value="partial" selected="selected">Partially received</option>
- [% ELSE %]
- <option value="partial">Partially received</option>
- [% END %]
- [% IF orderstatus == "complete" %]
- <option value="complete" selected="selected">Received</option>
- [% ELSE %]
- <option value="complete">Received</option>
- [% END %]
- [% IF orderstatus == "cancelled" %]
- <option value="cancelled" selected="selected">Cancelled</option>
- [% ELSE %]
- <option value="cancelled">Cancelled</option>
- [% END %]
- </select>
- </li>
- <li>
- <label for="fund">Fund: </label>
- <select name="budget" id="fund">
- <option value="">All funds</option>
- [% FOREACH bp_loo IN bp_loop %]
- <optgroup label="[% bp_loo.budget_period_description | html %]">
- [% FOREACH h_loo IN bp_loo.hierarchy %]
- [% IF h_loo.budget_id == budget_id %]
- <option type="text" value="[% h_loo.budget_id | html %]" branchcode="[% h_loo.budget_branchcode | html %]" selected="selected">
- [% ELSE %]
- <option type="text" value="[% h_loo.budget_id | html %]" branchcode="[% h_loo.budget_branchcode | html %]">
- [% END %]
- [% h_loo.budget_display_name | html %]
- </option>
- [% END %]
- </optgroup>
- [% END %]
- </select>
- </li>
-
- <li><label for="from">From: </label>
- <input type="text" size="10" id="from" name="from" value="[% from_placed_on | $KohaDates %]" class="datepickerfrom" />
- <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
- </li>
- <li><label for="to">To: </label>
- <input type="text" size="10" id="to" name="to" value="[% to_placed_on | $KohaDates %]" class="datepickerto" />
- <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
- </li>
- </ol>
- </fieldset>
+ [% INCLUDE 'filter-orders.inc' %]
+</fieldset>
<input type="hidden" name="do_search" value="1" />
<fieldset class="action"><input type="submit" value="Search" /></fieldset>
</form>[% END %]
--
2.11.0