From 75e1a6a083f8196b204b72637ab66e7c0cfccadf Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 27 Jul 2018 15:46:32 -0300 Subject: [PATCH] Bug 15184: Prepare the ground - Move order search filters We are going to reuse these filters so we move it to a separate include file. --- 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..cb4840bf9f --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/filter-orders.inc @@ -0,0 +1,96 @@ +[% USE Koha %] +
    +
  1. +
  2. +
  3. + [% IF Koha.Preference('marcflavour') == 'UNIMARC' %] +
  4. + [% END %] +
  5. +
  6. +
  7. + +
    +
    +
    +
  8. +
  9. +
  10. + + +
  11. +
  12. + + + [% IF filters.search_children_too %] + + [% ELSE %] + + [% END %] + +
  13. + +
  14. + + +
  15. +
  16. + + +
  17. + +
  18. + +
    [% INCLUDE 'date-format.inc' %]
    +
  19. +
  20. + +
    [% INCLUDE 'date-format.inc' %]
    +
  21. +
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 8499d907ca..321c6a5633 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt @@ -22,102 +22,8 @@ [% UNLESS ( order_loop ) %]
Search orders -
    -
  1. -
  2. -
  3. - [% IF (UNIMARC) %] -
  4. - [% END %] -
  5. -
  6. -
  7. - -
    -
    -
    -
  8. -
  9. -
  10. - - -
  11. -
  12. - - - [% IF search_children_too %] - - [% ELSE %] - - [% END %] - -
  13. - -
  14. - - -
  15. -
  16. - - -
  17. - -
  18. - -
    [% INCLUDE 'date-format.inc' %]
    -
  19. -
  20. - -
    [% INCLUDE 'date-format.inc' %]
    -
  21. -
-
+ [% INCLUDE 'filter-orders.inc' %] +
[% END %] -- 2.11.0