@@ -, +, @@ --- C4/Utils/DataTables.pm | 80 +-------------------------- C4/Utils/DataTables/VirtualShelves.pm | 2 + 2 files changed, 3 insertions(+), 79 deletions(-) --- a/C4/Utils/DataTables.pm +++ a/C4/Utils/DataTables.pm @@ -25,7 +25,7 @@ use vars qw(@ISA @EXPORT); BEGIN { @ISA = qw(Exporter); - @EXPORT = qw(dt_build_orderby dt_build_having dt_get_params); + @EXPORT = qw(dt_build_orderby dt_get_params); } =head1 NAME @@ -46,8 +46,6 @@ C4::Utils::DataTables - Utility subs for building query when DataTables source i FROM borrowers WHERE borrowernumber = ? }; - my ($having, $having_params) = dt_build_having($vars); - $query .= $having; $query .= dt_build_orderby($vars); $query .= " LIMIT ?,? "; @@ -106,82 +104,6 @@ sub dt_build_orderby { return $orderby; } -=head2 dt_build_having - - my ($having, $having_params) = dt_build_having($dt_params) - - This function takes a reference to a hash containing DataTables parameters - and build the corresponding 'HAVING' clause. - This hash must contains the following keys: - sSearch is the text entered in the global filter - iColumns is the number of columns - bSearchable_N is a boolean value that is true if the column is searchable - mDataProp_N is a mapping between the column index, and the name of a SQL field - sSearch_N is the text entered in individual filter for column N - -=cut - -sub dt_build_having { - my $param = shift; - - my @filters; - my @params; - - # Global filter - if($param->{'sSearch'}) { - my $sSearch = $param->{'sSearch'}; - my $i = 0; - my @gFilters; - my @gParams; - while($i < $param->{'iColumns'}) { - if($param->{'bSearchable_'.$i} eq 'true') { - my $mDataProp = $param->{'mDataProp_'.$i}; - my @filter_fields = $param->{$mDataProp.'_filteron'} - ? split(' ', $param->{$mDataProp.'_filteron'}) - : (); - if(@filter_fields > 0) { - foreach my $field (@filter_fields) { - push @gFilters, " $field LIKE ? "; - push @gParams, "%$sSearch%"; - } - } else { - push @gFilters, " $mDataProp LIKE ? "; - push @gParams, "%$sSearch%"; - } - } - $i++; - } - push @filters, " (" . join(" OR ", @gFilters) . ") "; - push @params, @gParams; - } - - # Individual filters - my $i = 0; - while($i < $param->{'iColumns'}) { - my $sSearch = $param->{'sSearch_'.$i}; - if($sSearch) { - my $mDataProp = $param->{'mDataProp_'.$i}; - my @filter_fields = $param->{$mDataProp.'_filteron'} - ? split(' ', $param->{$mDataProp.'_filteron'}) - : (); - if(@filter_fields > 0) { - my @localfilters; - foreach my $field (@filter_fields) { - push @localfilters, " $field LIKE ? "; - push @params, "%$sSearch%"; - } - push @filters, " ( ". join(" OR ", @localfilters) ." ) "; - } else { - push @filters, " $mDataProp LIKE ? "; - push @params, "%$sSearch%"; - } - } - $i++; - } - - return (\@filters, \@params); -} - =head2 dt_get_params my %dtparam = = dt_get_params( $input ) --- a/C4/Utils/DataTables/VirtualShelves.pm +++ a/C4/Utils/DataTables/VirtualShelves.pm @@ -107,6 +107,8 @@ sub search { ($orderby ? $orderby : ""), ($limit ? $limit : "") ); + warn $query; + use Data::Printer colored => 1; warn p @args; my $shelves = $dbh->selectall_arrayref( $query, { Slice => {} }, @args ); # Get the iTotalDisplayRecords DataTable variable --