View | Details | Raw Unified | Return to bug 17500
Collapse All | Expand All

(-)a/C4/Utils/DataTables.pm (-6 / +16 lines)
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
(-)a/C4/Utils/DataTables/Members.pm (-1 / +3 lines)
Lines 119-130 sub search { Link Here
119
    }
119
    }
120
120
121
    @conditions = ('*') unless @conditions;
121
    @conditions = ('*') unless @conditions;
122
    my $orderby = dt_build_orderby($dt_params);
122
    my $query = {
123
    my $query = {
123
        query => {
124
        query => {
124
            query_string => {
125
            query_string => {
125
                query => join ' AND ', @conditions,
126
                query => join ' AND ', @conditions,
126
            }
127
            }
127
        }
128
        },
129
        sort => $orderby->{es},
128
    };
130
    };
129
131
130
    # Do not display more than 1000 patrons
132
    # Do not display more than 1000 patrons
(-)a/C4/Utils/DataTables/VirtualShelves.pm (-2 / +1 lines)
Lines 81-87 sub search { Link Here
81
81
82
    my $where;
82
    my $where;
83
    $where = " WHERE " . join (" AND ", @where_strs) if @where_strs;
83
    $where = " WHERE " . join (" AND ", @where_strs) if @where_strs;
84
    my $orderby = dt_build_orderby($dt_params);
84
    my $orderby = dt_build_orderby($dt_params)->{sql};
85
    $orderby =~ s|shelfnumber|vs.shelfnumber| if $orderby;
85
    $orderby =~ s|shelfnumber|vs.shelfnumber| if $orderby;
86
86
87
    my $limit;
87
    my $limit;
88
- 

Return to bug 17500