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

(-)a/C4/Koha.pm (-2 / +20 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
    }
1172
    
1168
    if($branch_limit) {
1173
    if($branch_limit) {
1169
        push @where_strings, "( branchcode = ? OR branchcode IS NULL )";
1174
        push @where_strings, "( branchcode = ? OR branchcode IS NULL )";
1170
        push @where_args, $branch_limit;
1175
        push @where_args, $branch_limit;
1176
        push @where_args_lang, $branch_limit;
1171
    }
1177
    }
1172
    if(@where_strings > 0) {
1178
    if(@where_strings > 0) {
1173
        $query .= " WHERE " . join(" AND ", @where_strings);
1179
        $query .= " WHERE " . join(" AND ", @where_strings);
Lines 1178-1187 sub GetAuthorisedValues { Link Here
1178
                      : 'lib, lib_opac'
1184
                      : 'lib, lib_opac'
1179
              );
1185
              );
1180
1186
1181
    my $sth = $dbh->prepare($query);
1187
    # Prepare language overlay
1188
    my $sth_lang = $dbh->prepare($query);
1189
    $sth_lang->execute( @where_args_lang );
1190
    while (my $data_lang=$sth_lang->fetchrow_hashref) {
1191
        $lang_results_hash->{$data_lang->{authorised_value}}= $data_lang;
1192
    }
1193
    $sth_lang->finish;
1182
1194
1195
    # Get original values and overlay them if appropriate
1196
    my $sth = $dbh->prepare($query);
1183
    $sth->execute( @where_args );
1197
    $sth->execute( @where_args );
1184
    while (my $data=$sth->fetchrow_hashref) {
1198
    while (my $data=$sth->fetchrow_hashref) {
1199
        #Do language overlay
1200
        if (defined $lang_results_hash->{$data->{authorised_value}} ){
1201
            $data = $lang_results_hash->{$data->{authorised_value}};
1202
        }
1203
1185
        if ( defined $selected and $selected eq $data->{authorised_value} ) {
1204
        if ( defined $selected and $selected eq $data->{authorised_value} ) {
1186
            $data->{selected} = 1;
1205
            $data->{selected} = 1;
1187
        }
1206
        }
1188
- 

Return to bug 14063