Lines 85-92
sub dt_build_orderby {
Link Here
|
85 |
my $param = shift; |
85 |
my $param = shift; |
86 |
|
86 |
|
87 |
my $i = 0; |
87 |
my $i = 0; |
88 |
my $orderby; |
88 |
my ( @orderbys, $sql_orderby, $es_orderby ); |
89 |
my @orderbys; |
|
|
90 |
while(exists $param->{'iSortCol_'.$i}){ |
89 |
while(exists $param->{'iSortCol_'.$i}){ |
91 |
my $iSortCol = $param->{'iSortCol_'.$i}; |
90 |
my $iSortCol = $param->{'iSortCol_'.$i}; |
92 |
my $sSortDir = $param->{'sSortDir_'.$i}; |
91 |
my $sSortDir = $param->{'sSortDir_'.$i}; |
Lines 95-109
sub dt_build_orderby {
Link Here
|
95 |
? split(' ', $param->{$mDataProp.'_sorton'}) |
94 |
? split(' ', $param->{$mDataProp.'_sorton'}) |
96 |
: (); |
95 |
: (); |
97 |
if(@sort_fields > 0) { |
96 |
if(@sort_fields > 0) { |
98 |
push @orderbys, "$_ $sSortDir" foreach (@sort_fields); |
97 |
push @orderbys, {field => $_, order => $sSortDir} foreach (@sort_fields); |
99 |
} else { |
98 |
} else { |
100 |
push @orderbys, "$mDataProp $sSortDir"; |
99 |
push @orderbys, {field => $mDataProp, order => $sSortDir}; |
101 |
} |
100 |
} |
102 |
$i++; |
101 |
$i++; |
103 |
} |
102 |
} |
104 |
|
103 |
|
105 |
$orderby = " ORDER BY " . join(',', @orderbys) . " " if @orderbys; |
104 |
$sql_orderby = |
106 |
return $orderby; |
105 |
" ORDER BY " |
|
|
106 |
. join( ',', map { $_->{field} . " " . $_->{order} } @orderbys ) . " " |
107 |
if @orderbys; |
108 |
$es_orderby = [ |
109 |
map { |
110 |
my $f = $_->{field}; |
111 |
$f =~ s|^.*\.||; # Remove table name |
112 |
my $h = { $f => $_->{order} }; |
113 |
$h |
114 |
} @orderbys |
115 |
]; |
116 |
return { sql => $sql_orderby, es => $es_orderby }; |
107 |
} |
117 |
} |
108 |
|
118 |
|
109 |
=head2 dt_build_having |
119 |
=head2 dt_build_having |