@@ -, +, @@ results --- 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(-) --- a/C4/Items.pm +++ a/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 --- a/catalogue/itemsearch.pl +++ a/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; } } --- a/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.csv.inc +++ a/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 %]" --- a/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.json.inc +++ a/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 ~%]
[%~ END %]" --- a/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/catalogue/itemsearch.tt +++ a/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 -%] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt @@ -173,6 +173,7 @@

Item search

+

Go to advanced search

@@ -203,6 +204,15 @@ [% IF withdrawns.size %] [% INCLUDE form_field_select name="withdrawn" options = withdrawns empty_option = "All statuses" %] [% END %] +
+ + + + + + + +
[% INCLUDE form_field_select_text %] @@ -326,6 +336,8 @@ + ' ' + _("Lost status") + '' + ' ' + _("Withdrawn status") + '' + ' ' + _("Checkouts") + '' + + ' ' + _("Availability") + '' + + ' ' + _("Due date") + '' + ' ' + ' ' 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 ] }); --