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

(-)a/admin/categorie.pl (-17 / +29 lines)
Lines 71-78 my $input = new CGI; Link Here
71
my $searchfield   = $input->param('description');
71
my $searchfield   = $input->param('description');
72
my $script_name   = "/cgi-bin/koha/admin/categorie.pl";
72
my $script_name   = "/cgi-bin/koha/admin/categorie.pl";
73
my $categorycode  = $input->param('categorycode');
73
my $categorycode  = $input->param('categorycode');
74
my $op            = $input->param('op') // '';
74
my $op            = $input->param('op') // 'list';
75
my $block_expired = $input->param("block_expired");
75
my $block_expired = $input->param("block_expired");
76
my @messages;
76
77
77
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
78
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
78
    {
79
    {
Lines 85-96 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
85
    }
86
    }
86
);
87
);
87
88
88
$template->param(
89
    script_name  => $script_name,
90
    categorycode => $categorycode,
91
    searchfield  => $searchfield
92
);
93
94
################## ADD_FORM ##################################
89
################## ADD_FORM ##################################
95
# called by default. Used to create form to add or  modify a record
90
# called by default. Used to create form to add or  modify a record
96
if ( $op eq 'add_form' ) {
91
if ( $op eq 'add_form' ) {
Lines 171-177 if ( $op eq 'add_form' ) { Link Here
171
    # called by add_form, used to insert/modify data in DB
166
    # called by add_form, used to insert/modify data in DB
172
}
167
}
173
elsif ( $op eq 'add_validate' ) {
168
elsif ( $op eq 'add_validate' ) {
174
    $template->param( add_validate => 1 );
175
169
176
    my $is_a_modif = $input->param("is_a_modif");
170
    my $is_a_modif = $input->param("is_a_modif");
177
171
Lines 249-255 elsif ( $op eq 'add_validate' ) { Link Here
249
                default_privacy
243
                default_privacy
250
            )
244
            )
251
            VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)" );
245
            VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)" );
252
        $sth->execute(
246
        my $inserted = $sth->execute(
253
            map { $input->param($_) } (
247
            map { $input->param($_) } (
254
                'categorycode',    'description',
248
                'categorycode',    'description',
255
                'enrolmentperiod', 'enrolmentperioddate',
249
                'enrolmentperiod', 'enrolmentperioddate',
Lines 260-274 elsif ( $op eq 'add_validate' ) { Link Here
260
                'default_privacy',
254
                'default_privacy',
261
            )
255
            )
262
        );
256
        );
263
        $sth->finish;
257
        if ( $inserted ) {
258
            push @messages, { type => 'message', code => 'success_on_insert' };
259
        } else {
260
            $searchfield = q||;
261
            push @messages, { type => 'error', code => 'error_on_insert' };
262
        }
264
    }
263
    }
265
264
266
    if ( C4::Context->preference('EnhancedMessagingPreferences') ) {
265
    if ( C4::Context->preference('EnhancedMessagingPreferences') ) {
267
        C4::Form::MessagingPreferences::handle_form_action( $input,
266
        C4::Form::MessagingPreferences::handle_form_action( $input,
268
            { categorycode => $input->param('categorycode') }, $template );
267
            { categorycode => $input->param('categorycode') }, $template );
269
    }
268
    }
270
    print $input->redirect("/cgi-bin/koha/admin/categorie.pl");
269
271
    exit;
270
    $op = 'list';
272
271
273
    # END $OP eq ADD_VALIDATE
272
    # END $OP eq ADD_VALIDATE
274
################## DELETE_CONFIRM ##################################
273
################## DELETE_CONFIRM ##################################
Lines 301-315 elsif ( $op eq 'delete_confirmed' ) { Link Here
301
300
302
    my $sth = $dbh->prepare("delete from categories where categorycode=?");
301
    my $sth = $dbh->prepare("delete from categories where categorycode=?");
303
302
304
    $sth->execute($categorycode);
303
    my $deleted = $sth->execute($categorycode);
305
    $sth->finish;
306
304
307
    print $input->redirect("/cgi-bin/koha/admin/categorie.pl");
305
    if ( $deleted ) {
308
    exit;
306
        push @messages, { type => 'message', code => 'success_on_delete' };
307
    } else {
308
        push @messages, { type => 'error', code => 'error_on_delete' };
309
    }
310
311
    $op = 'list';
309
312
310
    # END $OP eq DELETE_CONFIRMED
313
    # END $OP eq DELETE_CONFIRMED
311
}
314
}
312
else {    # DEFAULT
315
316
if ( $op eq 'list' ) {
313
    $template->param( else => 1 );
317
    $template->param( else => 1 );
314
    my @loop;
318
    my @loop;
315
    my ( $count, $results ) = StringSearch( $searchfield, 'web' );
319
    my ( $count, $results ) = StringSearch( $searchfield, 'web' );
Lines 378-383 else { # DEFAULT Link Here
378
    $sth->finish;
382
    $sth->finish;
379
383
380
}    #---- END $OP eq DEFAULT
384
}    #---- END $OP eq DEFAULT
385
386
$template->param(
387
    script_name  => $script_name,
388
    categorycode => $categorycode,
389
    searchfield  => $searchfield,
390
    messages     => \@messages,
391
);
392
381
output_html_with_http_headers $input, $cookie, $template->output;
393
output_html_with_http_headers $input, $cookie, $template->output;
382
394
383
exit 0;
395
exit 0;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt (-23 / +18 lines)
Lines 1-9 Link Here
1
[% USE KohaDates -%]
1
[% USE KohaDates -%]
2
[% INCLUDE 'doc-head-open.inc' %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Administration &rsaquo; Patron categories &rsaquo; [% IF ( add_form ) %][% IF ( categorycode ) %]Modify category '[% categorycode |html %]'[% ELSE %]New category[% END %][% END %]
3
<title>Koha &rsaquo; Administration &rsaquo; Patron categories &rsaquo; [% IF ( add_form ) %][% IF ( categorycode ) %]Modify category '[% categorycode |html %]'[% ELSE %]New category[% END %][% END %]
4
[% IF ( add_validate ) %]Data recorded[% END %]
5
[% IF ( delete_confirm ) %][% IF ( patrons_in_category > 0 ) %]Cannot delete: category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %]
4
[% IF ( delete_confirm ) %][% IF ( patrons_in_category > 0 ) %]Cannot delete: category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %]
6
[% IF ( delete_confirmed ) %]Category deleted[% END %]</title>
5
</title>
7
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'doc-head-close.inc' %]
8
[% INCLUDE 'calendar.inc' %]
7
[% INCLUDE 'calendar.inc' %]
9
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
8
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
Lines 98-104 Link Here
98
[% INCLUDE 'patrons-admin-search.inc' %]
97
[% INCLUDE 'patrons-admin-search.inc' %]
99
98
100
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; [% IF ( add_form ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> &rsaquo; [% IF ( categorycode ) %]Modify category '[% categorycode |html %]'[% ELSE %]New category[% END %][% END %]
99
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; [% IF ( add_form ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> &rsaquo; [% IF ( categorycode ) %]Modify category '[% categorycode |html %]'[% ELSE %]New category[% END %][% END %]
101
[% IF ( add_validate ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> &rsaquo; Data recorded[% END %]
102
[% IF ( delete_confirm ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> &rsaquo; [% IF ( patrons_in_category > 0 ) %]Cannot delete: Category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %]
100
[% IF ( delete_confirm ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> &rsaquo; [% IF ( patrons_in_category > 0 ) %]Cannot delete: Category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %]
103
[% IF ( delete_confirmed ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> &rsaquo; Category deleted[% END %]
101
[% IF ( delete_confirmed ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> &rsaquo; Category deleted[% END %]
104
[% IF ( else ) %]Patron categories[% END %]</div>
102
[% IF ( else ) %]Patron categories[% END %]</div>
Lines 109-119 Link Here
109
	<div id="yui-main">
107
	<div id="yui-main">
110
	<div class="yui-b">
108
	<div class="yui-b">
111
109
112
[% IF ( add_form ) %]
110
[% FOR m IN messages %]
113
	
111
    <div class="dialog [% m.type %]">
114
112
        [% SWITCH m.code %]
113
        [% CASE 'error_on_insert' %]
114
            An error occurred when inserting this patron category. Perhaps the category code already exists.
115
        [% CASE 'error_on_delete' %]
116
            An error occurred when deleteing this patron category. Check the logs.
117
        [% CASE 'success_on_insert' %]
118
            Patron category inserted with success.
119
        [% CASE 'success_on_delete' %]
120
            Patron category deleted with success.
121
        [% CASE %]
122
            [% m.code %]
123
        [% END %]
124
    </div>
125
[% END %]
115
126
116
	
127
[% IF ( add_form ) %]
117
	<form name="Aform" action="[% script_name %]" method="post">
128
	<form name="Aform" action="[% script_name %]" method="post">
118
	<input type="hidden" name="op" value="add_validate" />
129
	<input type="hidden" name="op" value="add_validate" />
119
	<input type="hidden" name="checked" value="0" />
130
	<input type="hidden" name="checked" value="0" />
Lines 258-270 Link Here
258
269
259
[% END %]
270
[% END %]
260
271
261
[% IF ( add_validate ) %]
262
<h3>Data recorded</h3>
263
	<form action="[% script_name %]" method="post">
264
		<input type="submit" value="OK" />
265
	</form>
266
[% END %]
267
268
[% IF ( delete_confirm ) %]
272
[% IF ( delete_confirm ) %]
269
    <form action="[% script_name %]" method="post">
273
    <form action="[% script_name %]" method="post">
270
        <fieldset>
274
        <fieldset>
Lines 317-330 Link Here
317
		[% END %]</fieldset></fieldset></form>
321
		[% END %]</fieldset></fieldset></form>
318
[% END %]
322
[% END %]
319
323
320
[% IF ( delete_confirmed ) %]
321
<h3>Category deleted</h3>
322
323
        <form action="[% script_name %]" method="post">
324
        <input type="submit" value="OK" />
325
        </form>
326
[% END %]
327
328
[% IF ( else ) %]
324
[% IF ( else ) %]
329
325
330
<div id="toolbar" class="btn-toolbar">
326
<div id="toolbar" class="btn-toolbar">
331
- 

Return to bug 5002