Bugzilla – Attachment 107142 Details for
Bug 26032
Add 'is new' filter in items search
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26032: Add 'is new' filter in items search
Bug-26032-Add-is-new-filter-in-items-search.patch (text/plain), 3.78 KB, created by
Fridolin Somers
on 2020-07-21 10:33:51 UTC
(
hide
)
Description:
Bug 26032: Add 'is new' filter in items search
Filename:
MIME Type:
Creator:
Fridolin Somers
Created:
2020-07-21 10:33:51 UTC
Size:
3.78 KB
patch
obsolete
>From 2c6a14ea84120386d346e9022f20d7f760dd6e80 Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Tue, 21 Jul 2020 11:43:55 +0200 >Subject: [PATCH] Bug 26032: Add 'is new' filter in items search > >In items search, add a filter on value of items.new_status with a Ignore/Yes/No. >Yes meaning != 0, No meaning = 0, with considering that NULL value is like 0. > >This patch adds 'isnull' option to filter, this may be reused on other >fields. > >Test plan : >1) Define an item subfield on items.new_status with authorised values YES_NO (0 or 1) >2) Edit an item A to set new_status=1 >3) Edit an item B to set new_status=0 >4) Perform an item search with 'is new' = 'ignore' => you get all items >5) Perform an item search with 'is new' = 'yes' => you get item A >6) Perform an item search with 'is new' = 'no' => you get all items but A >--- > C4/Items.pm | 9 +++++++++ > catalogue/itemsearch.pl | 5 ++++- > .../prog/en/modules/catalogue/itemsearch.tt | 2 ++ > 3 files changed, 15 insertions(+), 1 deletion(-) > >diff --git a/C4/Items.pm b/C4/Items.pm >index f2db7a4894..b325d0e1c4 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -1318,6 +1318,7 @@ sub _SearchItems_build_where_fragment { > if ( (0 < grep { $_ eq $field } @columns) or (substr($field, 0, 5) eq 'marc:') ) { > my $op = $filter->{operator}; > my $query = $filter->{query}; >+ my $ifnull = $filter->{ifnull}; > > if (!$op or (0 == grep { $_ eq $op } @operators)) { > $op = '='; # default operator >@@ -1358,6 +1359,10 @@ sub _SearchItems_build_where_fragment { > $column = $field; > } > >+ if ( defined $ifnull ) { >+ $column = "IFNULL($column, ?)"; >+ } >+ > if (ref $query eq 'ARRAY') { > if ($op eq '=') { > $op = 'IN'; >@@ -1374,6 +1379,10 @@ sub _SearchItems_build_where_fragment { > args => [ $query ], > }; > } >+ >+ if ( defined $ifnull ) { >+ unshift @{ $where_fragment->{args} }, $ifnull; >+ } > } > } > >diff --git a/catalogue/itemsearch.pl b/catalogue/itemsearch.pl >index 2c68bfe35f..a19469e0dd 100755 >--- a/catalogue/itemsearch.pl >+++ b/catalogue/itemsearch.pl >@@ -165,12 +165,15 @@ if (scalar keys %params > 0) { > push @{ $filter->{filters} }, $f; > > # Yes/No parameters >- foreach my $p (qw( damaged )) { >+ foreach my $p (qw( damaged new_status )) { > my $v = $cgi->param($p) // ''; > my $f = { > field => $p, > query => 0, > }; >+ if ( $p eq 'new_status' ) { >+ $f->{ifnull} = 0; >+ } > if ($v eq 'yes') { > $f->{operator} = '!='; > push @{ $filter->{filters} }, $f; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt >index b1fa37e812..d10ae486a5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt >@@ -29,6 +29,7 @@ > [% CASE 'damaged' %]<span>Damaged</span> > [% CASE 'itemlost' %]<span>Lost</span> > [% CASE 'withdrawn' %]<span>Withdrawn</span> >+ [% CASE 'new_status' %]<span>Is new</span> > [% END %] > [% END %] > >@@ -194,6 +195,7 @@ > <span class="hint">(inclusive)</span> > </div> > [% INCLUDE form_field_radio_yes_no name="damaged" %] >+ [% INCLUDE form_field_radio_yes_no name="new_status" %] > <div class="form-field"> > <label class="form-field-label" for="issues_op">Checkout count:</label> > <select id="issues_op" name="issues_op"> >-- >2.27.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 26032
:
107141
|
107142
|
111554
|
111555
|
111834
|
111961
|
111962
|
111963
|
112500
|
112501
|
112502
|
112707
|
112708
|
112709
|
112710
|
112809
|
112810
|
112811
|
112812
|
112915
|
112916
|
112917
|
112918