#
# This file is part of Koha
#
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 3 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
#
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
#
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use CGI;
-use JSON;
+use JSON qw( to_json );
-use C4::Auth;
-use C4::Output;
-use C4::Items;
-use C4::Biblio;
-use C4::Koha;
+use C4::Auth qw( get_template_and_user );
+use C4::Output qw( output_with_http_headers output_html_with_http_headers );
+use C4::Items qw( SearchItems );
+use C4::Koha qw( GetAuthorisedValues );
use Koha::AuthorisedValues;
use Koha::Biblios;
use Koha::ItemTypes;
use Koha::Libraries;
-my $cgi = new CGI;
+my $cgi = CGI->new;
my %params = $cgi->Vars;
my $format = $cgi->param('format');
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 {
template_name => $template_name,
query => $cgi,
type => 'intranet',
- authnotrequired => 0,
flagsrequired => { catalogue => 1 },
});
$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.withdrawn', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] });
my $withdrawn_values = $mss->count ? GetAuthorisedValues($mss->next->authorised_value) : [];
-if (scalar keys %params > 0) {
+if ( Koha::MarcSubfieldStructures->search( { frameworkcode => '', kohafield => 'items.new_status' } )->count ) {
+ $template->param( has_new_status => 1 );
+}
+
+if ( defined $format ) {
# Parameters given, it's a search
my $filter = {
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;
}
}
+ # 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',
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;
}
}
$template->param(
- filter => $filter,
+ filter => $filter,
search_params => $search_params,
- results => $results,
- total_rows => $total_rows,
+ results => $results,
+ total_rows => $total_rows,
+ user => Koha::Patrons->find( $borrowernumber ),
);
if ($format eq 'csv') {
# Display the search form
-my @branches = map { value => $_->branchcode, label => $_->branchname }, Koha::Libraries->search( {}, { order_by => 'branchname' } );
-my @itemtypes;
-foreach my $itemtype ( Koha::ItemTypes->search ) {
- push @itemtypes, {
- value => $itemtype->itemtype,
- label => $itemtype->translated_description,
- };
-}
+my @branches = map { value => $_->branchcode, label => $_->branchname }, Koha::Libraries->search( {}, { order_by => 'branchname' } )->as_list;
+my @itemtypes = map { value => $_->itemtype, label => $_->translated_description }, Koha::ItemTypes->search_with_localization->as_list;
my @ccodes = Koha::AuthorisedValues->get_descriptions_by_koha_field({ kohafield => 'items.ccode' });
foreach my $ccode (@ccodes) {