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

(-)a/C4/Koha.pm (-2 / +19 lines)
Lines 1151-1156 sub GetAuthorisedValues { Link Here
1151
    return $result if $result;
1151
    return $result if $result;
1152
1152
1153
    my @results;
1153
    my @results;
1154
    my $lang_results_hash;
1155
    my $language = C4::Languages::getlanguage();
1154
    my $dbh      = C4::Context->dbh;
1156
    my $dbh      = C4::Context->dbh;
1155
    my $query = qq{
1157
    my $query = qq{
1156
        SELECT *
1158
        SELECT *
Lines 1161-1173 sub GetAuthorisedValues { Link Here
1161
    } if $branch_limit;
1163
    } if $branch_limit;
1162
    my @where_strings;
1164
    my @where_strings;
1163
    my @where_args;
1165
    my @where_args;
1166
    my @where_args_lang;
1164
    if($category) {
1167
    if($category) {
1165
        push @where_strings, "category = ?";
1168
        push @where_strings, "category = ?";
1166
        push @where_args, $category;
1169
        push @where_args, $category;
1170
        push @where_args_lang, $category.'-'.$language;
1167
    }
1171
    }
1168
    if($branch_limit) {
1172
    if($branch_limit) {
1169
        push @where_strings, "( branchcode = ? OR branchcode IS NULL )";
1173
        push @where_strings, "( branchcode = ? OR branchcode IS NULL )";
1170
        push @where_args, $branch_limit;
1174
        push @where_args, $branch_limit;
1175
        push @where_args_lang, $branch_limit;
1171
    }
1176
    }
1172
    if(@where_strings > 0) {
1177
    if(@where_strings > 0) {
1173
        $query .= " WHERE " . join(" AND ", @where_strings);
1178
        $query .= " WHERE " . join(" AND ", @where_strings);
Lines 1178-1187 sub GetAuthorisedValues { Link Here
1178
                      : 'lib, lib_opac'
1183
                      : 'lib, lib_opac'
1179
              );
1184
              );
1180
1185
1181
    my $sth = $dbh->prepare($query);
1186
    # Prepare language overlay
1187
    my $sth_lang = $dbh->prepare($query);
1188
    $sth_lang->execute( @where_args_lang );
1189
    while (my $data_lang=$sth_lang->fetchrow_hashref) {
1190
        $lang_results_hash->{$data_lang->{authorised_value}}= $data_lang;
1191
    }
1192
    $sth_lang->finish;
1182
1193
1194
    # Get original values and overlay them if appropriate
1195
    my $sth = $dbh->prepare($query);
1183
    $sth->execute( @where_args );
1196
    $sth->execute( @where_args );
1184
    while (my $data=$sth->fetchrow_hashref) {
1197
    while (my $data=$sth->fetchrow_hashref) {
1198
        #Do language overlay
1199
        if (defined $lang_results_hash->{$data->{authorised_value}} ){
1200
            $data = $lang_results_hash->{$data->{authorised_value}};
1201
        }
1202
1185
        if ( defined $selected and $selected eq $data->{authorised_value} ) {
1203
        if ( defined $selected and $selected eq $data->{authorised_value} ) {
1186
            $data->{selected} = 1;
1204
            $data->{selected} = 1;
1187
        }
1205
        }
1188
- 

Return to bug 14063