Bugzilla – Attachment 130845 Details for
Bug 17748
Show due date in item search results
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17748: Show due date and availability in item search results
Bug-17748-Show-due-date-and-availability-in-item-s.patch (text/plain), 11.01 KB, created by
Jonathan Druart
on 2022-02-18 14:15:02 UTC
(
hide
)
Description:
Bug 17748: Show due date and availability in item search results
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-02-18 14:15:02 UTC
Size:
11.01 KB
patch
obsolete
>From d37f7d6ef3e3b84922ccb3bac4188ef234e1ee3c Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Fri, 5 Feb 2021 16:01:54 +1300 >Subject: [PATCH] Bug 17748: Show due date and availability in item search > results >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This enhancement adds the availability of an item to the item search >results (i.e. shows if checked out or not). If checked out, >shows due date in item search results. The due >date column will also show when exporting results to a CSV file. > >To test: >1) Apply patch and restart services >2) Set up two items. Check out Item A to a borrower. Leave Item B as >is not checked out, and not unavailable status. >3) Go to Search -> Item search. Scroll down and notice the Availability >radio options - Ignore, and Checked out. >4) Leave the Ignore option selected and do a search so that both items show. >5) Confirm the availability and due date columns are showing at the >right end of the table. Confirm Item A says Checked out and has a due >date. Confirm Item B says available. >6) Export all result to CSV. Confirm the results show in the CSV file as >expected. >7) Go to edit your search. Select the 'Checked out' radio option for >Availability and submit the search. Confirm only Item A shows in the >results (not Item B). > >Sponsored-by: Bibliotheksservice-Zentrum Baden-Württemberg (BSZ) > >Signed-off-by: Christian Stelzenmüller <christian.stelzenmueller@bsz-bw.de> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > C4/Items.pm | 9 +++++++-- > catalogue/itemsearch.pl | 19 ++++++++++++++++++- > .../catalogue/itemsearch_item.csv.inc | 5 +++++ > .../catalogue/itemsearch_item.json.inc | 3 +++ > .../csv_headers/catalogue/itemsearch.tt | 4 ++++ > .../prog/en/modules/catalogue/itemsearch.tt | 16 ++++++++++++++++ > 6 files changed, 53 insertions(+), 3 deletions(-) > >diff --git a/C4/Items.pm b/C4/Items.pm >index 502ccb67936..5f68c914fd1 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -1294,7 +1294,7 @@ sub _SearchItems_build_where_fragment { > my @columns = Koha::Database->new()->schema()->resultset('Item')->result_source->columns; > push @columns, Koha::Database->new()->schema()->resultset('Biblio')->result_source->columns; > push @columns, Koha::Database->new()->schema()->resultset('Biblioitem')->result_source->columns; >- my @operators = qw(= != > < >= <= like); >+ my @operators = qw(= != > < >= <= is like); > push @operators, 'not like'; > my $field = $filter->{field} // q{}; > if ( (0 < grep { $_ eq $field } @columns) or (substr($field, 0, 5) eq 'marc:') ) { >@@ -1355,6 +1355,11 @@ sub _SearchItems_build_where_fragment { > str => "$column $op (" . join (',', ('?') x @$query) . ")", > args => $query, > }; >+ } elsif ( $op eq 'is' ) { >+ $where_fragment = { >+ str => "$column $op $query", >+ args => [], >+ }; > } else { > $where_fragment = { > str => "$column $op ?", >@@ -1387,7 +1392,7 @@ A filter has the following keys: > > =item * query: the value to search in this column > >-=item * operator: comparison operator. Can be one of = != > < >= <= like 'not like' >+=item * operator: comparison operator. Can be one of = != > < >= <= like 'not like' is > > =back > >diff --git a/catalogue/itemsearch.pl b/catalogue/itemsearch.pl >index 354ea86ccbb..e18524307ca 100755 >--- a/catalogue/itemsearch.pl >+++ b/catalogue/itemsearch.pl >@@ -62,7 +62,7 @@ if (defined $format and $format eq 'json') { > push @f, $columns[$i]; > push @c, 'and'; > >- if ( grep { $_ eq $columns[$i] } qw( ccode homebranch holdingbranch location itype notforloan itemlost ) ) { >+ if ( grep { $_ eq $columns[$i] } qw( ccode homebranch holdingbranch location itype notforloan itemlost onloan ) ) { > push @q, "$word"; > push @op, '='; > } else { >@@ -185,6 +185,21 @@ if ( defined $format ) { > } > } > >+ # null/is not null parameters >+ foreach my $p (qw( onloan )) { >+ my $v = $cgi->param($p) // ''; >+ my $f = { >+ field => $p, >+ operator => "is", >+ }; >+ if ( $v eq 'IS NOT NULL' ) { >+ $f->{query} = "not null"; >+ } elsif ( $v eq 'IS NULL' ) { >+ $f->{query} = "null"; >+ } >+ push @{ $filter->{filters} }, $f unless ( $v eq "" ); >+ } >+ > if (my $itemcallnumber_from = scalar $cgi->param('itemcallnumber_from')) { > push @{ $filter->{filters} }, { > field => 'itemcallnumber', >@@ -230,6 +245,8 @@ if ( defined $format ) { > my $biblio = Koha::Biblios->find( $item->{biblionumber} ); > $item->{biblio} = $biblio; > $item->{biblioitem} = $biblio->biblioitem->unblessed; >+ my $checkout = Koha::Checkouts->find({ itemnumber => $item->{itemnumber} }); >+ $item->{checkout} = $checkout; > } > } > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.csv.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.csv.inc >index 739c145cb51..705e2716a2a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.csv.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.csv.inc >@@ -1,6 +1,7 @@ > [%- USE raw -%] > [%- USE Branches -%] > [%- USE Koha -%] >+[%- USE KohaDates -%] > [%- USE ItemTypes -%] > [%- USE AuthorisedValues -%] > [%- SET biblio = item.biblio -%] >@@ -35,3 +36,7 @@ > "[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.withdrawn', authorised_value => item.withdrawn ) || "" | replace('"', '""') | $raw %]" > [%- delimiter | $raw -%] > "[% (item.issues || 0) | $raw %]" >+[%- delimiter | $raw -%] >+"[% IF item.onloan %]Checked out[% ELSIF item.withdrawn || item.damaged || item.notforloan || item.itemlost %]Not available[% ELSE %]Available[% END %]" >+[%- delimiter | $raw -%] >+"[% IF item.checkout %][% item.checkout.date_due | $KohaDates | $raw %][% END %]" >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.json.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.json.inc >index 1933950c07e..e0b28ee2ab1 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.json.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.json.inc >@@ -1,5 +1,6 @@ > [%- USE Branches -%] > [%- USE Koha -%] >+[%- USE KohaDates -%] > [%- USE To -%] > [%- USE ItemTypes -%] > [%- USE AuthorisedValues -%] >@@ -28,6 +29,8 @@ > "[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.itemlost', authorised_value => item.itemlost ) || "" | html %]", > "[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.withdrawn', authorised_value => item.withdrawn ) || "" | html %]", > "[% (item.issues || 0) | html %]", >+ "[% IF item.onloan %]Checked out[% ELSIF item.withdrawn || item.damaged || item.notforloan || item.itemlost %]Not available[% ELSE %]Available[% END %]", >+ "[% IF item.checkout %][% item.checkout.date_due | $KohaDates | html %][% END %]", > "[% FILTER escape_quotes ~%] > <div class="btn-group dropup"><button type="button" class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <i class="fa fa-pencil"></i> Edit <span class="caret"></span> </button> <ul class="dropdown-menu pull-right"> <li><a href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=[% item.biblionumber | uri %]&itemnumber=[% item.itemnumber | uri %]">Edit item</a></li> <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% item.biblionumber | html %]">Edit record</a></li> </ul> </div> > [%~ END %]" >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/catalogue/itemsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/catalogue/itemsearch.tt >index eccba14468d..2902fc5df22 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/catalogue/itemsearch.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/catalogue/itemsearch.tt >@@ -31,4 +31,8 @@ > "Withdrawn status" > [%- delimiter | $raw -%] > "Checkouts" >+[%- delimiter | $raw -%] >+"Availability" >+[%- delimiter | $raw -%] >+"Due date" > [%- END -%] >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 3d23fdcd244..c4aa698c85a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt >@@ -173,6 +173,7 @@ > > <div id="item-search-block"> > <h1>Item search</h1> >+ > <p><a href="/cgi-bin/koha/catalogue/search.pl">Go to advanced search</a></p> > <form action="/cgi-bin/koha/catalogue/itemsearch.pl" method="get" id="itemsearchform"> > <div id="toolbar" class="btn-toolbar"> >@@ -203,6 +204,15 @@ > [% IF withdrawns.size %] > [% INCLUDE form_field_select name="withdrawn" options = withdrawns empty_option = "All statuses" %] > [% END %] >+ <div class="form-field"> >+ <label class="form-field-label">Availability:</label> >+ <input type="radio" name="onloan" id="onloan_indifferent" value="" checked="checked"/> >+ <label for="onloan_indifferent">Ignore</label> >+ <input type="radio" name="onloan" id="onloan_yes" value="IS NOT NULL" /> >+ <label for="onloan_yes">Checked out</label> >+ <input type="radio" name="onloan" id="onloan_no" value="IS NULL" /> >+ <label for="onloan_no">Available</label> >+ </div> > </fieldset> > <fieldset> > [% INCLUDE form_field_select_text %] >@@ -326,6 +336,8 @@ > + ' <th id="items_itemlost">' + _("Lost status") + '</th>' > + ' <th id="items_widthdrawn">' + _("Withdrawn status") + '</th>' > + ' <th id="items_checkouts">' + _("Checkouts") + '</th>' >+ + ' <th id="items_availability">' + _("Availability") + '</th>' >+ + ' <th id="items_duedate">' + _("Due date") + '</th>' > + ' <th id=""></th>' > + ' </tr>' > var table = '' >@@ -482,6 +494,8 @@ > { 'sName': 'itemlost' }, > { 'sName': 'withdrawn' }, > { 'sName': 'issues' }, >+ { 'sName': 'availability' }, >+ { 'sName': 'duedate' }, > { 'sName': 'actions', 'bSortable': false } > ], > "sPaginationType": "full_numbers", >@@ -529,6 +543,8 @@ > null, > [% END %] > { 'type': 'text' }, >+ { 'type': 'text' }, >+ { 'type': 'text' }, > null > ] > }); >-- >2.25.1
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 17748
:
116353
|
119341
|
128332
|
128333
|
128582
|
128583
|
128584
|
128591
|
128638
|
128645
|
128646
|
128647
|
129623
|
129624
|
129625
|
130154
| 130845 |
130846
|
130847
|
130848
|
130849
|
131051
|
132016
|
132201