@@ -, +, @@ categories --- admin/smart-rules.pl | 19 +++++++++++++------ .../prog/en/modules/admin/smart-rules.tt | 13 ++----------- 2 files changed, 15 insertions(+), 17 deletions(-) --- a/admin/smart-rules.pl +++ a/admin/smart-rules.pl @@ -739,6 +739,11 @@ my $patron_categories = Koha::Patron::Categories->search({}, { order_by => ['des my $itemtypes = Koha::ItemTypes->search_with_localization; +my @used_categorycodes = + Koha::CirculationRules->search( {}, { columns => ['categorycode'], distinct => 1, } )->get_column('categorycode'); +my @used_itemtypes = + Koha::CirculationRules->search( {}, { columns => ['itemtype'], distinct => 1, } )->get_column('itemtype'); + my $humanbranch = ( $branch ne '*' ? $branch : undef ); my $all_rules = Koha::CirculationRules->search({ branchcode => $humanbranch }); @@ -753,12 +758,14 @@ while ( my $r = $all_rules->next ) { $template->param(show_branch_cat_rule_form => 1); $template->param( - patron_categories => $patron_categories, - itemtypeloop => $itemtypes, - humanbranch => $humanbranch, - current_branch => $branch, - definedbranch => $definedbranch, - all_rules => $rules, + used_categorycodes => \@used_categorycodes, + used_itemtypes => \@used_itemtypes, + patron_categories => $patron_categories, + itemtypeloop => $itemtypes, + humanbranch => $humanbranch, + current_branch => $branch, + definedbranch => $definedbranch, + all_rules => $rules, ); output_html_with_http_headers $input, $cookie, $template->output; --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt @@ -12,17 +12,8 @@ [% SET branchcode = humanbranch || undef %] -[% SET categorycodes = [] %] -[% FOREACH pc IN patron_categories %] - [% categorycodes.push( pc.id ) %] -[% END %] -[% categorycodes.push(undef) %] - -[% SET itemtypes = [] %] -[% FOREACH i IN itemtypeloop %] - [% itemtypes.push( i.itemtype ) %] -[% END %] -[% itemtypes.push(undef) %] +[% SET categorycodes = used_categorycodes %] +[% SET itemtypes = used_itemtypes %] [% INCLUDE 'doc-head-open.inc' %]