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 'cud-add') {
100
} elsif ($op eq 'cud-add') {
Lines 151-156 if ($op eq 'add_form') { Link Here
151
    $searchfield = $new_category;
157
    $searchfield = $new_category;
152
} elsif ($op eq 'cud-add_category' ) {
158
} elsif ($op eq 'cud-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 134-139 Link Here
134
                                        <span class="required">Required</span>
134
                                        <span class="required">Required</span>
135
                                        <input type="hidden" name="op" value="cud-add_category" />
135
                                        <input type="hidden" name="op" value="cud-add_category" />
136
                                    </li>
136
                                    </li>
137
                                    <li>
138
                                        <label for="parent">Parent category:</label>
139
                                        <select name="parent" id="parent_auth_value_categories">
140
                                            [% FOR c IN category_names %]
141
                                                <option value="[% c.category_name | html %]">[% c.category_name | html %]</option>
142
                                            [% END %]
143
                                        </select>
144
                                    </li>
137
                                </ol>
145
                                </ol>
138
                            [% ELSE %]
146
                            [% ELSE %]
139
                                <ol>
147
                                <ol>
Lines 247-262 Link Here
247
                                <label for="category_search">Show category: </label>
255
                                <label for="category_search">Show category: </label>
248
                                <select name="searchfield" id="category_search">
256
                                <select name="searchfield" id="category_search">
249
                                    [% FOR c IN category_names %]
257
                                    [% FOR c IN category_names %]
250
                                        [% IF c == searchfield %]
258
                                        [% IF c.category_name == searchfield %]
251
                                            <option value="[% c | html %]" selected="selected">[% c | html %]</option>
259
                                            <option value="[% c.category_name | html %]" selected="selected">[% c.category_name | html %]</option>
252
                                        [% ELSE %]
260
                                        [% ELSE %]
253
                                            <option value="[% c | html %]">[% c | html %]</option>
261
                                            <option value="[% c.category_name | html %]">[% c.category_name | html %]</option>
254
                                        [% END %]
262
                                        [% END %]
255
                                    [% END %]
263
                                    [% END %]
256
                                </select>
264
                                </select>
257
                            </p>
265
                            </p>
258
                        </form> <!-- /#category -->
266
                        </form> <!-- /#category -->
259
267
268
                        [% IF avc.parent %]
269
                            Show parent category: <a href="/cgi-bin/koha/admin/authorised_values.pl?searchfield=[% avc.parent | uri %]">[% avc.parent | html %]</a>
270
                        [% END %]
271
260
                        [% IF loop %]
272
                        [% IF loop %]
261
                            <table id="categoriest" class="authorized_values_table">
273
                            <table id="categoriest" class="authorized_values_table">
262
                                <thead>
274
                                <thead>
Lines 336-353 Link Here
336
                                <tr>
348
                                <tr>
337
                                    <th>Category</th>
349
                                    <th>Category</th>
338
                                    <th>Description</th>
350
                                    <th>Description</th>
351
                                    <th>Parent category</th>
339
                                    <th class="noExport">&nbsp;</th>
352
                                    <th class="noExport">&nbsp;</th>
340
                                </tr>
353
                                </tr>
341
                            </thead>
354
                            </thead>
342
                            <tbody>
355
                            <tbody>
343
                                [% FOR c IN category_names %]
356
                                [% FOR c IN category_names %]
344
                                    <tr>
357
                                    <tr>
345
                                        <td><a href="/cgi-bin/koha/admin/authorised_values.pl?searchfield=[% c | uri %]">[% c | html %]</a></td>
358
                                        <td><a href="/cgi-bin/koha/admin/authorised_values.pl?searchfield=[% c.category_name | uri %]">[% c.category_name | html %]</a></td>
359
                                        <td>
360
                                            [% PROCESS category_descriptions code_category = c.category_name %]
361
                                        </td>
346
                                        <td>
362
                                        <td>
347
                                            [% PROCESS category_descriptions code_category = c %]
363
                                            [% IF c.parent %]
364
                                                <a href="/cgi-bin/koha/admin/authorised_values.pl?searchfield=[% c.parent | uri %]">[% c.parent | html %]</a>
365
                                            [% ELSE %]
366
                                                &nbsp;
367
                                            [% END %]
348
                                        </td>
368
                                        </td>
349
                                        <td>
369
                                        <td>
350
                                            <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>
370
                                            <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>
351
                                        </td>
371
                                        </td>
352
                                    </tr>
372
                                    </tr>
353
                                [% END # /FOR c %]
373
                                [% END # /FOR c %]
354
- 

Return to bug 35067