Lines 20-25
package C4::Utils::DataTables;
Link Here
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
require Exporter; |
21 |
require Exporter; |
22 |
|
22 |
|
|
|
23 |
use Koha::DateUtils; |
24 |
|
23 |
use vars qw(@ISA @EXPORT); |
25 |
use vars qw(@ISA @EXPORT); |
24 |
|
26 |
|
25 |
BEGIN { |
27 |
BEGIN { |
Lines 138-151
sub dt_build_having {
Link Here
|
138 |
my $mDataProp = $param->{'mDataProp_'.$i}; |
140 |
my $mDataProp = $param->{'mDataProp_'.$i}; |
139 |
my @filter_fields = $param->{$mDataProp.'_filteron'} |
141 |
my @filter_fields = $param->{$mDataProp.'_filteron'} |
140 |
? split(' ', $param->{$mDataProp.'_filteron'}) |
142 |
? split(' ', $param->{$mDataProp.'_filteron'}) |
141 |
: (); |
143 |
: ($mDataProp); |
142 |
if(@filter_fields > 0) { |
144 |
|
143 |
foreach my $field (@filter_fields) { |
145 |
foreach my $field (@filter_fields) { |
144 |
push @gFilters, " $field LIKE ? "; |
146 |
push @gFilters, " $field LIKE ? "; |
145 |
push @gParams, "%$sSearch%"; |
|
|
146 |
} |
147 |
} else { |
148 |
push @gFilters, " $mDataProp LIKE ? "; |
149 |
push @gParams, "%$sSearch%"; |
147 |
push @gParams, "%$sSearch%"; |
150 |
} |
148 |
} |
151 |
} |
149 |
} |
Lines 163-179
sub dt_build_having {
Link Here
|
163 |
my $mDataProp = $param->{'mDataProp_'.$i}; |
161 |
my $mDataProp = $param->{'mDataProp_'.$i}; |
164 |
my @filter_fields = $param->{$mDataProp.'_filteron'} |
162 |
my @filter_fields = $param->{$mDataProp.'_filteron'} |
165 |
? split(' ', $param->{$mDataProp.'_filteron'}) |
163 |
? split(' ', $param->{$mDataProp.'_filteron'}) |
166 |
: (); |
164 |
: ($mDataProp); |
167 |
if(@filter_fields > 0) { |
165 |
|
168 |
my @localfilters; |
166 |
my @localfilters; |
169 |
foreach my $field (@filter_fields) { |
167 |
foreach my $field (@filter_fields) { |
|
|
168 |
if ($sSearch =~ /^(.*)\~(.*)$/) { |
169 |
my ($from, $to) = ($1, $2); |
170 |
my @datefilters; |
171 |
if ($from) { |
172 |
my $date = dt_from_string($from); |
173 |
push @datefilters, " $field >= ? "; |
174 |
push @params, $date->ymd; |
175 |
} |
176 |
if ($to) { |
177 |
my $date = dt_from_string($to); |
178 |
push @datefilters, " $field <= ? "; |
179 |
push @params, $date->ymd; |
180 |
} |
181 |
if (@datefilters) { |
182 |
push @localfilters, ' (' . join(' AND ', @datefilters) . ') '; |
183 |
} |
184 |
} else { |
170 |
push @localfilters, " $field LIKE ? "; |
185 |
push @localfilters, " $field LIKE ? "; |
171 |
push @params, "%$sSearch%"; |
186 |
push @params, "%$sSearch%"; |
172 |
} |
187 |
} |
|
|
188 |
} |
189 |
if (@localfilters) { |
173 |
push @filters, " ( ". join(" OR ", @localfilters) ." ) "; |
190 |
push @filters, " ( ". join(" OR ", @localfilters) ." ) "; |
174 |
} else { |
|
|
175 |
push @filters, " $mDataProp LIKE ? "; |
176 |
push @params, "%$sSearch%"; |
177 |
} |
191 |
} |
178 |
} |
192 |
} |
179 |
$i++; |
193 |
$i++; |