|
Lines 19-25
Link Here
|
| 19 |
use Modern::Perl; |
19 |
use Modern::Perl; |
| 20 |
use CGI; |
20 |
use CGI; |
| 21 |
|
21 |
|
| 22 |
use JSON qw( to_json ); |
22 |
use JSON qw( to_json from_json ); |
| 23 |
|
23 |
|
| 24 |
use C4::Auth qw( get_template_and_user ); |
24 |
use C4::Auth qw( get_template_and_user ); |
| 25 |
use C4::Circulation qw( barcodedecode ); |
25 |
use C4::Circulation qw( barcodedecode ); |
|
Lines 34-40
use Koha::ItemTypes;
Link Here
|
| 34 |
use Koha::Libraries; |
34 |
use Koha::Libraries; |
| 35 |
|
35 |
|
| 36 |
my $cgi = CGI->new; |
36 |
my $cgi = CGI->new; |
| 37 |
my %params = $cgi->Vars; |
|
|
| 38 |
|
37 |
|
| 39 |
my $format = $cgi->param('format'); |
38 |
my $format = $cgi->param('format'); |
| 40 |
my $template_name = 'catalogue/itemsearch.tt'; |
39 |
my $template_name = 'catalogue/itemsearch.tt'; |
|
Lines 43-51
if (defined $format and $format eq 'json') {
Link Here
|
| 43 |
$template_name = 'catalogue/itemsearch_json.tt'; |
42 |
$template_name = 'catalogue/itemsearch_json.tt'; |
| 44 |
|
43 |
|
| 45 |
# Map DataTables parameters with 'regular' parameters |
44 |
# Map DataTables parameters with 'regular' parameters |
| 46 |
$cgi->param('rows', scalar $cgi->param('iDisplayLength')); |
45 |
$cgi->param('rows', scalar $cgi->param('length')); |
| 47 |
$cgi->param('page', (scalar $cgi->param('iDisplayStart') / scalar $cgi->param('iDisplayLength')) + 1); |
46 |
$cgi->param('page', (scalar $cgi->param('start') / scalar $cgi->param('length')) + 1); |
| 48 |
my @columns = split /,/, scalar $cgi->param('sColumns'); |
47 |
my @columns = split /,/, from_json scalar $cgi->param('columns'); |
| 49 |
$cgi->param('sortby', $columns[ scalar $cgi->param('iSortCol_0') ]); |
48 |
$cgi->param('sortby', $columns[ scalar $cgi->param('iSortCol_0') ]); |
| 50 |
$cgi->param('sortorder', scalar $cgi->param('sSortDir_0')); |
49 |
$cgi->param('sortorder', scalar $cgi->param('sSortDir_0')); |
| 51 |
|
50 |
|
|
Lines 275-281
if ( defined $format ) {
Link Here
|
| 275 |
print "$line\n" unless $line =~ m|^\s*$|; |
274 |
print "$line\n" unless $line =~ m|^\s*$|; |
| 276 |
} |
275 |
} |
| 277 |
} elsif ($format eq 'json') { |
276 |
} elsif ($format eq 'json') { |
| 278 |
$template->param(sEcho => scalar $cgi->param('sEcho')); |
277 |
$template->param(draw => scalar $cgi->param('draw')); |
| 279 |
output_with_http_headers $cgi, $cookie, $template->output, 'json'; |
278 |
output_with_http_headers $cgi, $cookie, $template->output, 'json'; |
| 280 |
} |
279 |
} |
| 281 |
|
280 |
|