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

(-)a/admin/authorised_values.pl (-18 / +14 lines)
Lines 237-248 exit 0; Link Here
237
237
238
sub default_form {
238
sub default_form {
239
    # build categories list
239
    # build categories list
240
    my $sth = $dbh->prepare("select distinct category from authorised_values");
240
    my $category_list = C4::Koha::GetAuthorisedValueCategories();
241
    $sth->execute;
241
    my @category_list = @{$category_list};
242
    my @category_list;
243
    my %categories;    # a hash, to check that some hardcoded categories exist.
242
    my %categories;    # a hash, to check that some hardcoded categories exist.
244
    while ( my ($category) = $sth->fetchrow_array ) {
243
    for my $category ( @category_list ) {
245
        push( @category_list, $category );
246
        $categories{$category} = 1;
244
        $categories{$category} = 1;
247
    }
245
    }
248
246
Lines 252-274 sub default_form { Link Here
252
    }
250
    }
253
251
254
	#reorder the list
252
	#reorder the list
255
	@category_list = sort {$a cmp $b} @category_list;
253
    @category_list = sort {lc($a) cmp lc($b)} @category_list;
256
	my $tab_list = CGI::scrolling_list(-name=>'searchfield',
257
	        -id=>'searchfield',
258
			-values=> \@category_list,
259
			-default=>"",
260
			-size=>1,
261
			-multiple=>0,
262
			);
263
	if (!$searchfield) {
254
	if (!$searchfield) {
264
		$searchfield=$category_list[0];
255
		$searchfield=$category_list[0];
265
	}
256
	}
257
    my $tab_list = {
258
        values  => \@category_list,
259
        default => $searchfield,
260
    };
266
    my ($results) = AuthorizedValuesForCategory($searchfield);
261
    my ($results) = AuthorizedValuesForCategory($searchfield);
267
    my $count = scalar(@$results);
262
    my $count = scalar(@$results);
268
	my @loop_data = ();
263
	my @loop_data = ();
269
	# builds value list
264
	# builds value list
270
    my $dbh = C4::Context->dbh;
265
    my $sth = $dbh->prepare("SELECT b.branchcode, b.branchname FROM authorised_values_branches AS avb, branches AS b WHERE avb.branchcode = b.branchcode AND avb.av_id = ?");
271
    $sth = $dbh->prepare("SELECT b.branchcode, b.branchname FROM authorised_values_branches AS avb, branches AS b WHERE avb.branchcode = b.branchcode AND avb.av_id = ?");
272
	for (my $i=0; $i < $count; $i++){
266
	for (my $i=0; $i < $count; $i++){
273
        $sth->execute( $results->[$i]{id} );
267
        $sth->execute( $results->[$i]{id} );
274
        my @selected_branches;
268
        my @selected_branches;
Lines 287-294 sub default_form { Link Here
287
		push(@loop_data, \%row_data);
281
		push(@loop_data, \%row_data);
288
	}
282
	}
289
283
290
	$template->param( loop     => \@loop_data,
284
    $template->param(
291
                          tab_list => $tab_list,
285
            loop     => \@loop_data,
292
                          category => $searchfield );
286
            tab_list => $tab_list,
287
            category => $searchfield,
288
    );
293
}
289
}
294
290
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt (-2 / +13 lines)
Lines 194-200 $(document).ready(function() { Link Here
194
<div class="dialog alert">Could not add value &quot;[% duplicate_value %]&quot; for category &quot;[% duplicate_category %]&quot; &mdash; value already present.
194
<div class="dialog alert">Could not add value &quot;[% duplicate_value %]&quot; for category &quot;[% duplicate_category %]&quot; &mdash; value already present.
195
</div>
195
</div>
196
[% END %]
196
[% END %]
197
<form action="/cgi-bin/koha/admin/authorised_values.pl" method="post" id="category"><label for="searchfield">Show category: </label>[% tab_list %] <input type="submit" value="Submit" /></form>
197
<form action="/cgi-bin/koha/admin/authorised_values.pl" method="post" id="category">
198
    <label for="searchfield">Show category: </label>
199
    <select name="searchfield" id="searchfield" size="1">
200
    [% FOREACH value IN tab_list.values %]
201
    [% IF ( value == tab_list.default ) %]
202
        <option value="[% value %]" selected="selected">[% value %]</option>
203
    [% ELSE %]
204
        <option value="[% value %]">[% value %]</option>
205
    [% END %]
206
    [% END %]
207
    </select>
208
    <input type="submit" value="Submit" />
209
</form>
198
[% IF ( category == 'Bsort1' ) %]
210
[% IF ( category == 'Bsort1' ) %]
199
    <p>An authorized value attached to patrons, that can be used for stats purposes</p>
211
    <p>An authorized value attached to patrons, that can be used for stats purposes</p>
200
[% END %]
212
[% END %]
201
- 

Return to bug 766