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

(-)a/admin/authorised_values.pl (-12 / +22 lines)
Lines 67-72 if ($op eq 'add_form') { Link Here
67
        };
67
        };
68
    }
68
    }
69
69
70
    my @category_names = Koha::AuthorisedValueCategories->search(
71
        { category_name => { -not_in => [ '', 'branches', 'itemtypes', 'cn_source' ] } },
72
        { order_by      => ['category_name'] }
73
    )->as_list;
74
70
	if ($id) {
75
	if ($id) {
71
		$template->param(action_modify => 1);
76
		$template->param(action_modify => 1);
72
   } elsif ( ! $category ) {
77
   } elsif ( ! $category ) {
Lines 88-94 if ($op eq 'add_form') { Link Here
88
        );
93
        );
89
    }
94
    }
90
    $template->param(
95
    $template->param(
91
        branches_loop    => \@branches_loop,
96
        branches_loop  => \@branches_loop,
97
        category_names => \@category_names,
92
    );
98
    );
93
99
94
} elsif ($op eq 'add') {
100
} elsif ($op eq 'add') {
Lines 151-156 if ($op eq 'add_form') { Link Here
151
    $searchfield = $new_category;
157
    $searchfield = $new_category;
152
} elsif ($op eq 'add_category' ) {
158
} elsif ($op eq 'add_category' ) {
153
    my $new_category = $input->param('category');
159
    my $new_category = $input->param('category');
160
    my $parent       = $input->param('parent') || undef;
154
161
155
    my $already_exists = Koha::AuthorisedValueCategories->find(
162
    my $already_exists = Koha::AuthorisedValueCategories->find(
156
        {
163
        {
Lines 166-174 if ($op eq 'add_form') { Link Here
166
        }
173
        }
167
    }
174
    }
168
    else { # Insert
175
    else { # Insert
169
        my $av = Koha::AuthorisedValueCategory->new( {
176
        my $av = Koha::AuthorisedValueCategory->new(
170
            category_name => $new_category,
177
            {
171
        } );
178
                category_name => $new_category,
179
                parent        => $parent,
180
            }
181
        );
172
182
173
        eval {
183
        eval {
174
            $av->store;
184
            $av->store;
Lines 206-226 if ($op eq 'add_form') { Link Here
206
    $op = 'list';
216
    $op = 'list';
207
}
217
}
208
218
219
my $avc = Koha::AuthorisedValueCategories->find( $searchfield );
220
209
$template->param(
221
$template->param(
210
    op => $op,
222
    op          => $op,
211
    searchfield => $searchfield,
223
    searchfield => $searchfield,
212
    messages => \@messages,
224
    messages    => \@messages,
225
    avc         => $avc,
213
);
226
);
214
227
215
if ( $op eq 'list' ) {
228
if ( $op eq 'list' ) {
216
    # build categories list
229
    # build categories list
217
    my @category_names = Koha::AuthorisedValueCategories->search(
230
    my @category_names = Koha::AuthorisedValueCategories->search(
218
        {
231
        { category_name => { -not_in => [ '', 'branches', 'itemtypes', 'cn_source' ] } },
219
            category_name =>
232
        { order_by      => ['category_name'] }
220
              { -not_in => [ '', 'branches', 'itemtypes', 'cn_source' ] }
233
    )->as_list;
221
        },
222
        { order_by => ['category_name'] }
223
    )->get_column('category_name');
224
234
225
    $searchfield ||= "";
235
    $searchfield ||= "";
226
236
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt (-7 / +26 lines)
Lines 133-138 Link Here
133
                                        <span class="required">Required</span>
133
                                        <span class="required">Required</span>
134
                                        <input type="hidden" name="op" value="add_category" />
134
                                        <input type="hidden" name="op" value="add_category" />
135
                                    </li>
135
                                    </li>
136
                                    <li>
137
                                        <label for="parent">Parent category:</label>
138
                                        <select name="parent" id="parent_auth_value_categories">
139
                                            [% FOR c IN category_names %]
140
                                                <option value="[% c.category_name | html %]">[% c.category_name | html %]</option>
141
                                            [% END %]
142
                                        </select>
143
                                    </li>
136
                                </ol>
144
                                </ol>
137
                            [% ELSE %]
145
                            [% ELSE %]
138
                                <ol>
146
                                <ol>
Lines 246-261 Link Here
246
                                <label for="category_search">Show category: </label>
254
                                <label for="category_search">Show category: </label>
247
                                <select name="searchfield" id="category_search">
255
                                <select name="searchfield" id="category_search">
248
                                    [% FOR c IN category_names %]
256
                                    [% FOR c IN category_names %]
249
                                        [% IF c == searchfield %]
257
                                        [% IF c.category_name == searchfield %]
250
                                            <option value="[% c | html %]" selected="selected">[% c | html %]</option>
258
                                            <option value="[% c.category_name | html %]" selected="selected">[% c.category_name | html %]</option>
251
                                        [% ELSE %]
259
                                        [% ELSE %]
252
                                            <option value="[% c | html %]">[% c | html %]</option>
260
                                            <option value="[% c.category_name | html %]">[% c.category_name | html %]</option>
253
                                        [% END %]
261
                                        [% END %]
254
                                    [% END %]
262
                                    [% END %]
255
                                </select>
263
                                </select>
256
                            </p>
264
                            </p>
257
                        </form> <!-- /#category -->
265
                        </form> <!-- /#category -->
258
266
267
                        [% IF avc.parent %]
268
                            Show parent category: <a href="/cgi-bin/koha/admin/authorised_values.pl?searchfield=[% avc.parent | uri %]">[% avc.parent | html %]</a>
269
                        [% END %]
270
259
                        [% IF loop %]
271
                        [% IF loop %]
260
                            <table id="categoriest" class="authorized_values_table">
272
                            <table id="categoriest" class="authorized_values_table">
261
                                <thead>
273
                                <thead>
Lines 326-343 Link Here
326
                                <tr>
338
                                <tr>
327
                                    <th>Category</th>
339
                                    <th>Category</th>
328
                                    <th>Description</th>
340
                                    <th>Description</th>
341
                                    <th>Parent category</th>
329
                                    <th class="noExport">&nbsp;</th>
342
                                    <th class="noExport">&nbsp;</th>
330
                                </tr>
343
                                </tr>
331
                            </thead>
344
                            </thead>
332
                            <tbody>
345
                            <tbody>
333
                                [% FOR c IN category_names %]
346
                                [% FOR c IN category_names %]
334
                                    <tr>
347
                                    <tr>
335
                                        <td><a href="/cgi-bin/koha/admin/authorised_values.pl?searchfield=[% c | uri %]">[% c | html %]</a></td>
348
                                        <td><a href="/cgi-bin/koha/admin/authorised_values.pl?searchfield=[% c.category_name | uri %]">[% c.category_name | html %]</a></td>
349
                                        <td>
350
                                            [% PROCESS category_descriptions code_category = c.category_name %]
351
                                        </td>
336
                                        <td>
352
                                        <td>
337
                                            [% PROCESS category_descriptions code_category = c %]
353
                                            [% IF c.parent %]
354
                                                <a href="/cgi-bin/koha/admin/authorised_values.pl?searchfield=[% c.parent | uri %]">[% c.parent | html %]</a>
355
                                            [% ELSE %]
356
                                                &nbsp;
357
                                            [% END %]
338
                                        </td>
358
                                        </td>
339
                                        <td>
359
                                        <td>
340
                                            <a id="addauth" class="btn btn-default btn-xs" href= "/cgi-bin/koha/admin/authorised_values.pl?op=add_form&amp;category=[% c | uri %]"><i class="fa fa-plus"> </i> Add</a>
360
                                            <a id="addauth" class="btn btn-default btn-xs" href= "/cgi-bin/koha/admin/authorised_values.pl?op=add_form&amp;category=[% c.category_name | uri %]"><i class="fa fa-plus"> </i> Add</a>
341
                                        </td>
361
                                        </td>
342
                                    </tr>
362
                                    </tr>
343
                                [% END # /FOR c %]
363
                                [% END # /FOR c %]
344
- 

Return to bug 35067