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

(-)a/admin/branches.pl (-357 / +180 lines)
Lines 1-6 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# Copyright 2000-2002 Katipo Communications
3
# Copyright 2000-2002 Katipo Communications
4
# Copyright 2015 Koha Development Team
4
#
5
#
5
# This file is part of Koha.
6
# This file is part of Koha.
6
#
7
#
Lines 17-418 Link Here
17
# You should have received a copy of the GNU General Public License
18
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
20
=head1 branches.pl
21
use Modern::Perl;
21
22
 FIXME: individual fields in branch address need to be exported to templates,
23
        in order to fix bug 180; need to notify translators
24
 FIXME: looped html (e.g., list of checkboxes) need to be properly
25
        TMPL_LOOP'ized; doing this properly will fix bug 130; need to
26
        notify translators
27
 FIXME: need to implement the branch categories stuff
28
 FIXME: there are too many TMPL_IF's; the proper way to do it is to have
29
        separate templates for each individual action; need to notify
30
        translators
31
 FIXME: there are lots of error messages exported to the template; a lot
32
        of these should be converted into exported booleans / counters etc
33
        so that the error messages can be localized; need to notify translators
34
35
 Finlay working on this file from 26-03-2002
36
 Reorganising this branches admin page.....
37
38
=cut
39
40
use strict;
41
use warnings;
42
use CGI qw ( -utf8 );
22
use CGI qw ( -utf8 );
43
use C4::Auth;
23
use C4::Auth;
44
use C4::Context;
24
use C4::Context;
45
use C4::Output;
25
use C4::Output;
46
use C4::Koha;
26
use C4::Koha;
47
use C4::Branch;
27
use Koha::Borrowers;
48
28
use Koha::Items;
49
# Fixed variables
29
use Koha::Libraries;
50
my $script_name = "/cgi-bin/koha/admin/branches.pl";
30
use Koha::LibraryCategories;
51
31
52
################################################################################
53
# Main loop....
54
my $input        = new CGI;
32
my $input        = new CGI;
55
my $branchcode   = $input->param('branchcode');
33
my $branchcode   = $input->param('branchcode');
56
my $branchname   = $input->param('branchname');
57
my $categorycode = $input->param('categorycode');
34
my $categorycode = $input->param('categorycode');
58
my $op           = $input->param('op') || '';
35
my $op           = $input->param('op') || 'list';
36
my @messages;
59
37
60
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
38
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
61
    {
39
    {   template_name   => "admin/branches.tt",
62
        template_name   => "admin/branches.tt",
63
        query           => $input,
40
        query           => $input,
64
        type            => "intranet",
41
        type            => "intranet",
65
        authnotrequired => 0,
42
        authnotrequired => 0,
66
        flagsrequired   => { parameters => 'parameters_remaining_permissions'},
43
        flagsrequired   => { parameters => 'parameters_remaining_permissions' },
67
        debug           => 1,
44
        debug           => 1,
68
    }
45
    }
69
);
46
);
70
$template->param(
71
     script_name => $script_name,
72
     action      => $script_name,
73
);
74
$template->param( ($op || 'else') => 1 );
75
76
if ( $op eq 'add' ) {
77
47
78
    # If the user has pressed the "add new branch" button.
48
if ( $op eq 'add_form' ) {
79
    $template->param( 'heading_branches_add_branch_p' => 1 );
49
    my $library;
80
    editbranchform($branchcode,$template);
50
    if ($branchcode) {
81
51
        $library = Koha::Libraries->find($branchcode);
82
}
52
    }
83
elsif ( $op eq 'edit' ) {
84
53
85
    # if the user has pressed the "edit branch settings" button.
54
    $template->param(
86
    $template->param( 'heading_branches_add_branch_p' => 0,
55
        library    => $library,
87
                        'add' => 1, );
56
        categories => [ Koha::LibraryCategories->search( {}, { order_by => [ 'categorytype', 'categoryname' ] } ) ],
88
    editbranchform($branchcode,$template);
57
        $library ? ( selected_categorycodes => [ map { $_->categorycode } $library->get_categories ] ) : (),
89
}
58
    );
90
elsif ( $op eq 'add_validate' ) {
59
} elsif ( $op eq 'add_validate' ) {
60
    my @fields = qw(
61
      branchname
62
      branchaddress1
63
      branchaddress2
64
      branchaddress3
65
      branchzip
66
      branchcity
67
      branchstate
68
      branchcountry
69
      branchphone
70
      branchfax
71
      branchemail
72
      branchreplyto
73
      branchreturnpath
74
      branchurl
75
      issuing
76
      branchip
77
      branchnotes
78
      opac_info
79
    );
80
    my $is_a_modif = $input->param('is_a_modif');
91
81
92
    # confirm settings change...
82
    my @categories;
93
    my $params = $input->Vars;
83
    for my $category ( Koha::LibraryCategories->search ) {
94
    unless ( $params->{'branchcode'} && $params->{'branchname'} ) {
84
        push @categories, $category
95
        $template->param( else => 1 );
85
          if $input->param( "selected_categorycode_" . $category->categorycode );
96
        default("MESSAGE1",$template);
97
    }
86
    }
98
    else {
87
    if ($is_a_modif) {
99
        my $mod_branch = 1;
88
        my $library = Koha::Libraries->find($branchcode);
100
        if ($params->{add}) {
89
        for my $field (@fields) {
101
            my ($existing) =
90
            $library->$field( $input->param($field) );
102
                C4::Context->dbh->selectrow_array("SELECT count(*) FROM branches WHERE branchcode = ?", {}, $branchcode);
91
        }
103
            if ($existing > 0) {
92
        $library->update_categories( \@categories );
104
                $mod_branch = 0;
93
105
                _branch_to_template($params, $template); # preserve most (FIXME) of user's input
94
        eval { $library->store; };
106
                $template->param( 'heading_branches_add_branch_p' => 1, 'add' => 1, 'ERROR1' => 1 );
95
        if ($@) {
107
            }
96
            push @messages, { type => 'error', code => 'error_on_update' };
97
        } else {
98
            push @messages, { type => 'message', code => 'success_on_update' };
108
        }
99
        }
109
        if ($mod_branch) {
100
    } else {
110
            my $error = ModBranch($params); # FIXME: causes warnings to log on duplicate branchcode
101
        $branchcode =~ s|\s||g;
111
            # if error saving, stay on edit and rise error
102
        my $library = Koha::Library->new(
112
            if ($error) {
103
            {   branchcode => $branchcode,
113
                # copy input parameters back to form
104
                ( map { $_ => $input->param($_) || undef } @fields )
114
                # FIXME - doing this doesn't preserve any branch group selections, but good enough for now
115
                editbranchform($branchcode,$template);
116
                $template->param( 'heading_branches_add_branch_p' => 1, 'add' => 1, "ERROR$error" => 1 );
117
            } else {
118
                $template->param( else => 1);
119
                default("MESSAGE2",$template);
120
            }
105
            }
106
        );
107
        eval { $library->store; };
108
        $library->add_to_categories( \@categories );
109
        if ($@) {
110
            push @messages, { type => 'error', code => 'error_on_insert' };
111
        } else {
112
            push @messages, { type => 'message', code => 'success_on_insert' };
121
        }
113
        }
122
    }
114
    }
123
}
115
    $op = 'list';
124
elsif ( $op eq 'delete' ) {
116
} elsif ( $op eq 'delete_confirm' ) {
125
    # if the user has pressed the "delete branch" button.
117
    my $library       = Koha::Libraries->find($branchcode);
126
    
118
    my $items_count = Koha::Items->search(
127
    # check to see if the branchcode is being used in the database somewhere....
119
        {   -or => {
128
    my $dbh = C4::Context->dbh;
120
                holdingbranch => $branchcode,
129
    my $sthitems     = $dbh->prepare("select count(*) from items where holdingbranch=? or homebranch=?");
121
                homebranch    => $branchcode
130
    my $sthborrowers = $dbh->prepare("select count(*) from borrowers where branchcode=?");
122
            },
131
    $sthitems->execute( $branchcode, $branchcode );
123
        }
132
    $sthborrowers->execute( $branchcode );
124
    )->count;
133
    my ($totalitems)     = $sthitems->fetchrow_array;
125
    my $patrons_count = Koha::Borrowers->search( { branchcode => $branchcode, } )->count;
134
    my ($totalborrowers) = $sthborrowers->fetchrow_array;
126
135
    if ($totalitems && !$totalborrowers) {
127
    if ( $items_count or $patrons_count ) {
136
        $template->param( else => 1 );
128
        push @messages,
137
        default("MESSAGE10", $template);
129
          { type => 'error',
138
    }
130
            code => 'cannot_delete_library',
139
    elsif (!$totalitems && $totalborrowers){
131
            data => {
140
        $template->param( else => 1 );
132
                items_count   => $items_count,
141
        default("MESSAGE11", $template);
133
                patrons_count => $patrons_count,
142
    }
134
            },
143
    elsif ($totalitems && $totalborrowers){
135
          };
144
        $template->param( else => 1 );
136
        $op = 'list';
145
        default("MESSAGE7", $template);
146
    }
147
    else {
148
        $template->param( delete_confirm => 1 );
149
        $template->param( branchname     => $branchname );
150
        $template->param( branchcode     => $branchcode );
151
    }
152
}
153
elsif ( $op eq 'delete_confirmed' ) {
154
155
    # actually delete branch and return to the main screen....
156
    DelBranch($branchcode);
157
    $template->param( else => 1 );
158
    default("MESSAGE3",$template);
159
}
160
elsif ( $op eq 'editcategory' ) {
161
162
    # If the user has pressed the "add new category" or "modify" buttons.
163
    $template->param( 'heading_branches_edit_category_p' => 1 );
164
    editcatform($categorycode,$template);
165
}
166
elsif ( $op eq 'addcategory_validate' ) {
167
168
    $template->param( else => 1 );
169
    # confirm settings change...
170
    my $params = $input->Vars;
171
    $params->{'show_in_pulldown'} = ( $params->{'show_in_pulldown'} eq 'on' ) ? 1 : 0;
172
173
    unless ( $params->{'categorycode'} && $params->{'categoryname'} ) {
174
        default("MESSAGE4",$template);
175
    }
176
    elsif ($input->param('add')){
177
	# doing an add must check the code is unique
178
	if (CheckCategoryUnique($input->param('categorycode'))){
179
	    ModBranchCategoryInfo($params);
180
        default("MESSAGE5",$template);
181
	}
182
	else {
183
	    default("MESSAGE9",$template);
184
	}
185
    }
186
    else {
187
        ModBranchCategoryInfo($params);
188
        default("MESSAGE5",$template);
189
    }
190
}
191
elsif ( $op eq 'delete_category' ) {
192
193
    # if the user has pressed the "delete branch" button.
194
    if ( CheckBranchCategorycode($categorycode) ) {
195
        $template->param( else => 1 );
196
        default( 'MESSAGE8', $template );
197
    } else {
137
    } else {
198
        $template->param( delete_category => 1 );
138
        $template->param(
199
        $template->param( categorycode    => $categorycode );
139
            library       => $library,
140
            items_count   => $items_count,
141
            patrons_count => $patrons_count,
142
        );
200
    }
143
    }
201
}
144
} elsif ( $op eq 'delete_confirmed' ) {
202
elsif ( $op eq 'categorydelete_confirmed' ) {
145
    my $library = Koha::Libraries->find($branchcode);
203
204
    # actually delete branch and return to the main screen....
205
    DelBranchCategory($categorycode);
206
    $template->param( else => 1 );
207
    default("MESSAGE6",$template);
208
146
209
}
147
    my $deleted = eval { $library->delete; };
210
else {
211
    # if no operation has been set...
212
    default("",$template);
213
}
214
148
215
################################################################################
149
    if ( $@ or not $deleted ) {
216
#
150
        push @messages, { type => 'error', code => 'error_on_delete' };
217
# html output functions....
151
    } else {
218
152
        push @messages, { type => 'message', code => 'success_on_delete' };
219
sub default {
153
    }
220
    my $message       = shift || '';
154
    $op = 'list';
221
    my $innertemplate = shift or return;
155
} elsif ( $op eq 'add_form_category' ) {
222
    $innertemplate->param($message => 1) if $message;
156
    my $category;
223
    $innertemplate->param(
157
    if ($categorycode) {
224
        'heading_branches_p' => 1,
158
        $category = Koha::LibraryCategories->find($categorycode);
159
    }
160
    $template->param( category => $category, );
161
} elsif ( $op eq 'add_validate_category' ) {
162
    my $is_a_modif = $input->param('is_a_modif');
163
    my @fields     = qw(
164
      categoryname
165
      codedescription
166
      categorytype
225
    );
167
    );
226
    branchinfotable("",$innertemplate);
168
    if ($is_a_modif) {
227
}
169
        my $category = Koha::LibraryCategories->find($categorycode);
228
170
        for my $field (@fields) {
229
sub editbranchform {
171
            $category->$field( $input->param($field) );
230
    my ($branchcode,$innertemplate) = @_;
172
        }
231
    # initiate the scrolling-list to select the printers
173
        $category->show_in_pulldown( $input->param('show_in_pulldown') eq 'on' );
232
    my $printers = GetPrinters();
174
        eval { $category->store; };
233
    my @printerloop;
175
        if ($@) {
234
    my $data;
176
            push @messages, { type => 'error', code => 'error_on_update_category' };
235
    my $oldprinter = "";
177
        } else {
236
178
            push @messages, { type => 'message', code => 'success_on_update_category' };
237
179
        }
238
    # make the checkboxes.....
180
    } else {
239
    my $catinfo = GetBranchCategories();
181
        my $category = Koha::LibraryCategory->new(
240
182
            {   categorycode => $categorycode,
241
    if ($branchcode) {
183
                ( map { $_ => $input->param($_) || undef } @fields )
242
        $data = GetBranchInfo($branchcode);
184
            }
243
        $data = $data->[0];
185
        );
244
        if ( exists $data->{categories} ) {
186
        $category->show_in_pulldown( $input->param('show_in_pulldown') eq 'on' );
245
            # Set the selected flag for the categories of this branch
187
        eval { $category->store; };
246
            $catinfo = [
188
        if ($@) {
247
                map {
189
            push @messages, { type => 'error', code => 'error_on_insert_category' };
248
                    my $catcode = $_->{categorycode};
190
        } else {
249
                    if ( grep {/$catcode/} @{$data->{categories}} ){
191
            push @messages, { type => 'message', code => 'success_on_insert_category' };
250
                        $_->{selected} = 1;
251
                    }
252
                    $_;
253
                } @{$catinfo}
254
            ];
255
        }
192
        }
256
257
        # get the old printer of the branch
258
        $oldprinter = $data->{'branchprinter'} || '';
259
        _branch_to_template($data, $innertemplate);
260
    }
261
    $innertemplate->param( categoryloop => $catinfo );
262
263
    foreach my $thisprinter ( keys %$printers ) {
264
        push @printerloop, {
265
            value         => $thisprinter,
266
            selected      => ( $oldprinter eq $printers->{$thisprinter} ),
267
            branchprinter => $printers->{$thisprinter}->{'printqueue'},
268
        };
269
    }
193
    }
270
194
    $op = 'list';
271
    $innertemplate->param( printerloop => \@printerloop );
195
} elsif ( $op eq 'delete_confirm_category' ) {
272
196
    my $category = Koha::LibraryCategories->find($categorycode);
273
    for my $obsolete ( 'categoryname', 'categorycode', 'codedescription' ) {
197
    if ( my $libraries_count = scalar( $category->branchcodes ) ) {
274
        $innertemplate->param(
198
        push @messages,
275
            $obsolete => 'Your template is out of date (bug 130)' );
199
          { type => 'error',
200
            code => 'cannot_delete_category',
201
            data => { libraries_count => $libraries_count, },
202
          };
203
        $op = 'list';
204
    } else {
205
        $template->param( category => $category );
276
    }
206
    }
277
}
207
} elsif ( $op eq 'delete_confirmed_category' ) {
278
208
    my $category = Koha::LibraryCategories->find($categorycode);
279
sub editcatform {
209
    my $deleted = eval { $category->delete; };
280
210
281
    # prepares the edit form...
211
    if ( $@ or not $deleted ) {
282
    my ($categorycode,$innertemplate) = @_;
212
        push @messages, { type => 'error', code => 'error_on_delete_category' };
283
    # warn "cat : $categorycode";
213
    } else {
284
	my @cats;
214
        push @messages, { type => 'message', code => 'success_on_delete_category' };
285
    my $data;
286
	if ($categorycode) {
287
        $data = GetBranchCategory($categorycode);
288
        $innertemplate->param(
289
            categorycode    => $data->{'categorycode'},
290
            categoryname    => $data->{'categoryname'},
291
            codedescription => $data->{'codedescription'},
292
            show_in_pulldown => $data->{'show_in_pulldown'},
293
		);
294
    }
215
    }
295
	for my $ctype (GetCategoryTypes()) {
216
    $op = 'list';
296
		push @cats , { type => $ctype , selected => ($data->{'categorytype'} and $data->{'categorytype'} eq $ctype) };
217
} else {
297
	}
218
    $op = 'list';
298
    $innertemplate->param(categorytype => \@cats);
299
}
219
}
300
220
301
sub branchinfotable {
221
if ( $op eq 'list' ) {
302
222
    my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, );
303
# makes the html for a table of branch info from reference to an array of hashs.
223
    $template->param(
304
224
        libraries   => $libraries,
305
    my ($branchcode,$innertemplate) = @_;
225
        group_types => [
306
    my $branchinfo = $branchcode ? GetBranchInfo($branchcode) : GetBranchInfo();
226
            {   categorytype => 'searchdomain',
307
    my @loop_data = ();
227
                categories   => [ Koha::LibraryCategories->search( { categorytype => 'searchdomain' } ) ],
308
    foreach my $branch (@$branchinfo) {
228
            },
309
        #
229
            {   categorytype => 'properties',
310
        # We export the following fields to the template. These are not
230
                categories   => [ Koha::LibraryCategories->search( { categorytype => 'properties' } ) ],
311
        # pre-composed as a single "address" field because the template
231
            },
312
        # might (and should) escape what is exported here. (See bug 180)
232
        ]
313
        #
314
        # - branch_name     (Note: not "branchname")
315
        # - branch_code     (Note: not "branchcode")
316
        # - address         (containing a static error message)
317
        # - branchaddress1 \
318
        # - branchaddress2  |
319
        # - branchaddress3  | comprising the old "address" field
320
        # - branchzip       |
321
        # - branchcity      |
322
        # - branchcountry   |
323
        # - branchphone     |
324
        # - branchfax       |
325
        # - branchemail    /
326
        # - branchurl      /
327
        # - opac_info (can contain HTML)
328
        # - address-empty-p (1 if no address information, 0 otherwise)
329
        # - categories      (containing a static error message)
330
        # - category_list   (loop containing "categoryname")
331
        # - no-categories-p (1 if no categories set, 0 otherwise)
332
        # - value
333
        #
334
        my %row = ();
335
336
        # Handle address fields separately
337
        my $address_empty_p = 1;
338
        for my $field (
339
            'branchaddress1', 'branchaddress2',
340
            'branchaddress3', 'branchzip',
341
            'branchcity', 'branchstate', 'branchcountry',
342
            'branchphone', 'branchfax',
343
            'branchemail', 'branchurl', 'opac_info',
344
            'branchip',       'branchprinter', 'branchnotes'
345
          )
346
        {
347
            $row{$field} = $branch->{$field};
348
            $address_empty_p = 0 if ( $branch->{$field} );
349
        }
350
        $row{'address-empty-p'} = $address_empty_p;
351
352
        # Handle categories
353
        my $no_categories_p = 1;
354
        my @categories;
355
        foreach my $cat ( @{ $branch->{'categories'} } ) {
356
            my $catinfo = GetBranchCategory($cat);
357
            push @categories, { 'categoryname' => $catinfo->{'categoryname'} };
358
            $no_categories_p = 0;
359
        }
360
361
        $row{'category_list'}   = \@categories;
362
        $row{'no-categories-p'} = $no_categories_p;
363
        $row{'branch_name'} = $branch->{'branchname'};
364
        $row{'branch_code'} = $branch->{'branchcode'};
365
        $row{'value'}       = $branch->{'branchcode'};
366
367
        push @loop_data, \%row;
368
    }
369
    my @branchcategories = ();
370
	for my $ctype ( GetCategoryTypes() ) {
371
        my $catinfo = GetBranchCategories($ctype);
372
        my @categories;
373
		foreach my $cat (@$catinfo) {
374
            push @categories, {
375
                categoryname    => $cat->{'categoryname'},
376
                categorycode    => $cat->{'categorycode'},
377
                codedescription => $cat->{'codedescription'},
378
                categorytype    => $cat->{'categorytype'},
379
            };
380
    	}
381
        push @branchcategories, { categorytype => $ctype , $ctype => 1 , catloop => ( @categories ? \@categories : undef) };
382
	}
383
    $innertemplate->param(
384
        branches         => \@loop_data,
385
        branchcategories => \@branchcategories
386
    );
233
    );
387
388
}
234
}
389
235
390
sub _branch_to_template {
236
$template->param(
391
    my ($data, $template) = @_;
237
    messages => \@messages,
392
    $template->param( 
238
    op       => $op,
393
         branchcode     => $data->{'branchcode'},
239
);
394
         branch_name    => $data->{'branchname'},
395
         branchaddress1 => $data->{'branchaddress1'},
396
         branchaddress2 => $data->{'branchaddress2'},
397
         branchaddress3 => $data->{'branchaddress3'},
398
         branchzip      => $data->{'branchzip'},
399
         branchcity     => $data->{'branchcity'},
400
         branchstate    => $data->{'branchstate'},
401
         branchcountry  => $data->{'branchcountry'},
402
         branchphone    => $data->{'branchphone'},
403
         branchfax      => $data->{'branchfax'},
404
         branchemail    => $data->{'branchemail'},
405
         branchreplyto  => $data->{'branchreplyto'},
406
         branchreturnpath => $data->{'branchreturnpath'},
407
         branchurl      => $data->{'branchurl'},
408
         opac_info      => $data->{'opac_info'},
409
         branchip       => $data->{'branchip'},
410
         branchnotes    => $data->{'branchnotes'}, 
411
    );
412
}
413
240
414
output_html_with_http_headers $input, $cookie, $template->output;
241
output_html_with_http_headers $input, $cookie, $template->output;
415
416
# Local Variables:
417
# tab-width: 8
418
# End:
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt (-285 / +307 lines)
Lines 1-13 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Administration &rsaquo; Libraries and groups
2
<title>Koha &rsaquo; Administration &rsaquo; Libraries and groups
3
[% IF ( editcategory ) %]
3
[% IF op == 'editcategory' %]
4
    &rsaquo;[% IF ( categorycode ) %]Edit group [% categorycode %][% ELSE %]New group[% END %]
4
    &rsaquo;[% IF category.categorycode %]Edit group [% category.categorycode%][% ELSE %]New group[% END %]
5
[% ELSIF ( delete_category ) %]
5
[% ELSIF op == 'delete_confirm_category' %]
6
    &rsaquo; Confirm deletion of group [% categorycode %]
6
    &rsaquo; Confirm deletion of group [% category.categorycode %]
7
[% ELSIF ( add ) %]
7
[% ELSIF op == 'add_form' %]
8
    &rsaquo;[% IF ( heading_branches_add_branch_p ) %]New library[% ELSE %]Modify library [% branchcode %][% END %]
8
    &rsaquo;[% IF library %]Modify library[% ELSE %]New library [% library.branchcode %][% END %]
9
[% ELSIF ( delete_confirm ) %]
9
[% ELSIF op == 'delete_confirm' %]
10
    &rsaquo; Confirm deletion of library '[% branchcode %]'
10
    &rsaquo; Confirm deletion of library '[% library.branchcode %]'
11
[% END %]
11
[% END %]
12
</title>
12
</title>
13
[% INCLUDE 'doc-head-close.inc' %]
13
[% INCLUDE 'doc-head-close.inc' %]
Lines 25-31 Link Here
25
            "sPaginationType": "four_button"
25
            "sPaginationType": "four_button"
26
        }));
26
        }));
27
27
28
        [% IF ( heading_branches_add_branch_p ) %]
28
        [% UNLESS library %]
29
            $("#Aform").on("submit", function( event ) {
29
            $("#Aform").on("submit", function( event ) {
30
                if ( $("#branchcode").val().match(/\s/) ) {
30
                if ( $("#branchcode").val().match(/\s/) ) {
31
                    event.preventDefault();
31
                    event.preventDefault();
Lines 62-373 tinyMCE.init({ Link Here
62
    <a href="/cgi-bin/koha/mainpage.pl">Home</a>
62
    <a href="/cgi-bin/koha/mainpage.pl">Home</a>
63
&rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
63
&rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
64
&rsaquo; <a href="/cgi-bin/koha/admin/branches.pl">Libraries and groups</a>
64
&rsaquo; <a href="/cgi-bin/koha/admin/branches.pl">Libraries and groups</a>
65
[% IF ( editcategory ) %]
65
[% IF op == 'add_form_category' %]
66
&rsaquo; [% IF ( categorycode ) %]Edit group [% categorycode %][% ELSE %]New group[% END %]
66
&rsaquo; [% IF category.categorycode %]Edit group [% category.categorycode %][% ELSE %]New group[% END %]
67
[% ELSIF ( delete_category ) %]
67
[% ELSIF op == 'delete_confirm_category' %]
68
&rsaquo; Confirm deletion of group [% categorycode %]
68
&rsaquo; Confirm deletion of group [% category.categorycode %]
69
[% ELSIF ( add ) %]
69
[% ELSIF op == 'add_form'  %]
70
&rsaquo; [% IF ( heading_branches_add_branch_p ) %]New library[% ELSE %]Modify library [% branchcode %][% END %]
70
&rsaquo; [% IF library %]Modify library[% ELSE %]New library [% library.branchcode %][% END %]
71
[% ELSIF ( delete_confirm ) %]
71
[% ELSIF op == 'delete_confirm' %]
72
&rsaquo; Confirm deletion of library '[% branchcode %]'
72
&rsaquo; Confirm deletion of library '[% library.branchcode %]'
73
[% END %]
73
[% END %]
74
</div>
74
</div>
75
75
76
<div id="doc3" class="yui-t2">
76
<div id="doc3" class="yui-t2">
77
77
78
   <div id="bd">
78
   <div id="bd">
79
	<div id="yui-main">
79
    <div id="yui-main">
80
	<div class="yui-b">
80
    <div class="yui-b">
81
	[% IF ( else ) %]
81
82
[% FOR m IN messages %]
83
    <div class="dialog [% m.type %]">
84
        [% SWITCH m.code %]
85
        [% CASE 'error_on_update' %]
86
            An error occurred when updating this library. Perhaps it already exists.
87
        [% CASE 'error_on_insert' %]
88
            An error occurred when adding this library. The branchcode might already exist.
89
        [% CASE 'error_on_delete' %]
90
            An error occurred when deleting this library. Check the logs.
91
        [% CASE 'success_on_update' %]
92
            Library updated successfully.
93
        [% CASE 'success_on_insert' %]
94
            Library added successfully.
95
        [% CASE 'success_on_delete' %]
96
            Library deleted successfully.
97
        [% CASE 'cannot_delete_library' %]
98
            This library cannot be deleted. Patrons or items are still using it
99
            [% IF m.data.patrons_count and m.data.items_count %]
100
                ([% m.data.patrons_count %] patrons and [% m.data.items_count %] items).
101
            [% ELSIF m.data.patrons_count %]
102
                ([% m.data.patrons_count %] patrons).
103
            [% ELSIF m.data.items_count %]
104
                ([% m.data.items_count %] items).
105
            [% END %]
106
        [% CASE 'error_on_update_category' %]
107
            An error occurred when updating this library category. Perhaps it already exists.
108
        [% CASE 'error_on_insert_category' %]
109
            An error occurred when adding this library category. The categorycode might already exist.
110
        [% CASE 'error_on_delete_category' %]
111
            An error occurred when deleting this library category. Check the logs.
112
        [% CASE 'success_on_update_category' %]
113
            Library category updated successfully.
114
        [% CASE 'success_on_insert_category' %]
115
            Library category added successfully.
116
        [% CASE 'success_on_delete_category' %]
117
            Library category deleted successfully.
118
        [% CASE 'cannot_delete_category' %]
119
            This library category cannot be deleted. [% m.data.libraries_count %] libraries are still using it.
120
        [% CASE %]
121
            [% m.code %]
122
        [% END %]
123
    </div>
124
[% END %]
125
126
[% IF op == 'list' %]
82
    <div id="toolbar" class="btn-toolbar">
127
    <div id="toolbar" class="btn-toolbar">
83
        <a class="btn btn-small" id="newbranch" href="/cgi-bin/koha/admin/branches.pl?op=add"><i class="fa fa-plus"></i> New library</a>
128
        <a class="btn btn-small" id="newbranch" href="/cgi-bin/koha/admin/branches.pl?op=add_form"><i class="fa fa-plus"></i> New library</a>
84
        <a class="btn btn-small" id="newcategory" href="/cgi-bin/koha/admin/branches.pl?op=editcategory"><i class="fa fa-plus"></i> New group</a>
129
        <a class="btn btn-small" id="newcategory" href="/cgi-bin/koha/admin/branches.pl?op=add_form_category"><i class="fa fa-plus"></i> New group</a>
85
    </div>
130
    </div>
86
[% END %]
131
[% END %]
87
132
88
[% IF ( add ) %]
133
[% IF op == 'add_form' %]
89
    [% IF ( ERROR1 ) %]<div class="dialog message">Library with that code already exists &mdash; Please enter a unique code</div>[% END %]
134
    <h3>[% IF library %]Modify library[% ELSE %]New library[% END %]</h3>
90
  <h3>[% IF ( heading_branches_add_branch_p ) %]New library[% ELSE %]Modify library[% END %]</h3>
135
    <form action="/cgi-bin/koha/admin/branches.pl" id="Aform" name="Aform" class="validated" method="post">
91
    <form action="[% action %]" id="Aform" name="Aform" class="validated" method="post">
136
        <fieldset class="rows">
92
	<fieldset class="rows">
137
            <input type="hidden" name="op" value="add_validate" />
93
        <input type="hidden" name="op" value="add_validate" />
138
            [% IF library %]
94
        [% IF ( heading_branches_add_branch_p ) %]
139
                <input type="hidden" name="is_a_modif" value="1" />
95
            <input type="hidden" name="add" value="1" />
96
        [% ELSE %]
97
            <input type="hidden" name="add" value="0" />
98
        [% END %]
99
        <ol><li>
100
            [% IF ( heading_branches_add_branch_p ) %]
101
            <label for="branchcode" class="required">Library code: </label>
102
                <input type="text" name="branchcode" id="branchcode" size="10" maxlength="10" value="[% branchcode |html %]" class="required" required="required" /> <span class="required">Required</span>
103
            [% ELSE %]
104
            <span class="label">Library code: </span>
105
                <input type="hidden" name="branchcode" value="[% branchcode |html %]" />
106
                [% branchcode %]
107
            [% END %]
140
            [% END %]
108
        </li>
141
            <ol>
109
        <li>
142
                <li>
110
            <label for="branchname" class="required">Name: </label>
143
                    [% IF library %]
111
            <input type="text" name="branchname" id="branchname" size="80" value="[% branch_name |html %]" class="required" required="required" /> <span class="required">Required</span>
144
                        <span class="label">Library code: </span>
112
        </li>
145
                        <input type="hidden" name="branchcode" value="[% library.branchcode |html %]" />
113
	</ol>
146
                        [% library.branchcode %]
114
	</fieldset>
147
                    [% ELSE %]
115
	[% IF ( categoryloop ) %]<fieldset class="rows"><legend>Group(s):</legend>
148
                        <label for="branchcode" class="required">Library code: </label>
116
        <ol>
149
                        <input type="text" name="branchcode" id="branchcode" size="10" maxlength="10" value="[% library.branchcode |html %]" class="required" required="required" />
117
		[% FOREACH categoryloo IN categoryloop %]
150
                        <span class="required">Required</span>
118
            <li><label for="[% categoryloo.categorycode %]">[% categoryloo.categoryname %]: </label>
151
                    [% END %]
119
                [% IF categoryloo.selected %]
152
                </li>
120
                    <input type="checkbox" id="[% categoryloo.categorycode %]" name="[% categoryloo.categorycode %]" checked="checked" />
153
                <li>
121
                [% ELSE %]
154
                    <label for="branchname" class="required">Name: </label>
122
                    <input type="checkbox" id="[% categoryloo.categorycode %]" name="[% categoryloo.categorycode %]" />
155
                    <input type="text" name="branchname" id="branchname" size="80" value="[% library.branchname |html %]" class="required" required="required" />
123
                [% END %]
156
                    <span class="required">Required</span>
124
                <span class="hint">[% categoryloo.codedescription %]</span>
157
                </li>
125
            </li>
158
            </ol>
159
        </fieldset>
160
        [% IF categories %]
161
            <fieldset class="rows"><legend>Group(s):</legend>
162
                <ol>
163
                    [% FOREACH category IN categories %]
164
                        <li>
165
                            <label for="[% category.categorycode %]">[% category.categoryname %]: </label>
166
                            [% IF category and selected_categorycodes.grep(category.categorycode).size %]
167
                                <input type="checkbox" id="[% category.categorycode %]" name="selected_categorycode_[% category.categorycode %]" checked="checked" />
168
                            [% ELSE %]
169
                                <input type="checkbox" id="[% category.categorycode %]" name="selected_categorycode_[% category.categorycode %]" />
170
                            [% END %]
171
                            <span class="hint">[% category.codedescription %]</span>
172
                        </li>
173
                    [% END %]
174
                </ol>
175
            </fieldset>
126
        [% END %]
176
        [% END %]
127
		</ol>
177
        <fieldset class="rows">
128
</fieldset>[% END %]
178
            <ol>
129
	<fieldset class="rows">
179
                <li><label for="branchaddress1">Address line 1: </label><input type="text" name="branchaddress1" id="branchaddress1" size="60" value="[% library.branchaddress1 |html %]" /></li>
130
	<ol>
180
                <li><label for="branchaddress2">Address line 2: </label><input type="text" name="branchaddress2" id="branchaddress2" size="60" value="[% library.branchaddress2 |html %]" /></li>
131
        <li><label for="branchaddress1">Address line 1: </label><input type="text" name="branchaddress1" id="branchaddress1" size="60" value="[% branchaddress1 |html %]" /></li>
181
                <li><label for="branchaddress3">Address line 3: </label><input type="text" name="branchaddress3" id="branchaddress3" size="60" value="[% library.branchaddress3 |html %]" /></li>
132
        <li><label for="branchaddress2">Address line 2: </label><input type="text" name="branchaddress2" id="branchaddress2" size="60" value="[% branchaddress2 |html %]" /></li>
182
                <li><label for="branchcity">City: </label><input type="text" name="branchcity" id="branchcity" size="60" value="[% library.branchcity |html %]" /></li>
133
        <li><label for="branchaddress3">Address line 3: </label><input type="text" name="branchaddress3" id="branchaddress3" size="60" value="[% branchaddress3 |html %]" /></li>
183
                <li><label for="branchstate">State: </label><input type="text" name="branchstate" id="branchstate" size="60" value="[% library.branchstate |html %]" /></li>
134
        <li><label for="branchcity">City: </label><input type="text" name="branchcity" id="branchcity" size="60" value="[% branchcity |html %]" /></li>
184
                <li><label for="branchzip">Zip/Postal code: </label><input type="text" name="branchzip" id="branchzip"  size="25" maxlength="25" value="[% library.branchzip |html %]" /></li>
135
        <li><label for="branchstate">State: </label><input type="text" name="branchstate" id="branchstate" size="60" value="[% branchstate |html %]" /></li>
185
                <li><label for="branchcountry">Country: </label><input type="text" name="branchcountry" id="branchcountry" size="60" value="[% library.branchcountry |html %]" /></li>
136
        <li><label for="branchzip">Zip/Postal code: </label><input type="text" name="branchzip" id="branchzip"  size="25" maxlength="25" value="[% branchzip |html %]" /></li>
186
                <li><label for="branchphone">Phone: </label><input type="text" name="branchphone" id="branchphone" size="60" value="[% library.branchphone |html %]" /></li>
137
        <li><label for="branchcountry">Country: </label><input type="text" name="branchcountry" id="branchcountry" size="60" value="[% branchcountry |html %]" /></li>
187
                <li><label for="branchfax">Fax: </label><input type="text" name="branchfax" id="branchfax" size="60" value="[% library.branchfax |html %]" /></li>
138
        <li><label for="branchphone">Phone: </label><input type="text" name="branchphone" id="branchphone" size="60" value="[% branchphone |html %]" /></li>
188
                <li><label for="branchemail">Email: </label><input type="text" name="branchemail" id="branchemail" class="email"  size="80" value="[% library.branchemail |html %]" /></li>
139
        <li><label for="branchfax">Fax: </label><input type="text" name="branchfax" id="branchfax" size="60" value="[% branchfax |html %]" /></li>
189
                <li><label for="branchreplyto">Reply-To (if different to Email): </label> <input type="text" name="branchreplyto" id="branchreplyto" class="email"  size="80" value="[% library.branchreplyto |html %]" /></li>
140
        <li><label for="branchemail">Email: </label><input type="text" name="branchemail" id="branchemail" class="email"  size="80" value="[% branchemail |html %]" /></li>
190
                <li><label for="branchreturnpath">Return-Path (if different to Email): </label> <input type="text" name="branchreturnpath" id="branchreturnpath" class="email"  size="80" value="[% library.branchreturnpath |html %]" /></li>
141
        <li><label for="branchreplyto">Reply-To (if different to Email): </label> <input type="text" name="branchreplyto" id="branchreplyto" class="email"  size="80" value="[% branchreplyto |html %]" /></li>
191
                <li><label for="branchurl">URL: </label><input type="text" name="branchurl" id="branchurl"  size="80" value="[% library.branchurl |html %]" class="url" /></li>
142
        <li><label for="branchreturnpath">Return-Path (if different to Email): </label> <input type="text" name="branchreturnpath" id="branchreturnpath" class="email"  size="80" value="[% branchreturnpath |html %]" /></li>
192
                <li><label for="opac_info">OPAC info: </label><textarea name="opac_info" id="opac_info">[% library.opac_info |html %]</textarea></li>
143
        <li><label for="branchurl">URL: </label><input type="text" name="branchurl" id="branchurl"  size="80" value="[% branchurl |html %]" class="url" /></li>
193
                <li><label for="branchip">IP: </label><input type="text" name="branchip" id="branchip"  size="15" maxlength="15" value="[% library.branchip |html %]" /> <span class="hint">Can be entered as a single IP, or a subnet such as 192.168.1.*</span></li>
144
        <li><label for="opac_info">OPAC info: </label><textarea name="opac_info" id="opac_info">[% opac_info |html %]</textarea></li>
194
                <li><label for="branchnotes">Notes: </label><input type="text" name="branchnotes" id="branchnotes" size="80" value="[% library.branchnotes |html %]" /></li>
145
        <li><label for="branchip">IP: </label><input type="text" name="branchip" id="branchip"  size="15" maxlength="15" value="[% branchip |html %]" /> <span class="hint">Can be entered as a single IP, or a subnet such as 192.168.1.*</span></li>
195
            </ol>
146
		<!--
196
        </fieldset>
147
        <li><label for="branchprinter">Library Printer: </label>
197
        <fieldset class="action">
148
            <select id="branchprinter" name="branchprinter">
198
            <input type="submit" value="Submit" />
149
                <option value="">None</option>
199
            <a class="cancel" href="/cgi-bin/koha/admin/branches.pl">Cancel</a>
150
            [% FOREACH printerloo IN printerloop %]
151
                [% IF ( printerloo.selected ) %]
152
				<option value="[% printerloo.value %]" selected="selected">[% printerloo.branchprinter %]</option>
153
				[% ELSE %]
154
				<option value="[% printerloo.value %]">[% printerloo.branchprinter %]</option>
155
				[% END %]
156
                [% END %]
157
            </select></li>
158
			-->
159
        <li><label for="branchnotes">Notes: </label><input type="text" name="branchnotes" id="branchnotes" size="80" value="[% branchnotes |html %]" /></li>
160
        </ol>
161
        </fieldset>
200
        </fieldset>
162
        <fieldset class="action"><input type="submit" value="Submit" /> <a class="cancel" href="/cgi-bin/koha/admin/branches.pl">Cancel</a></fieldset>
163
    </form>
201
    </form>
164
[% END %]
202
[% END %]
165
203
166
[% IF ( delete_confirm ) %]
204
[% IF op == 'delete_confirm' and not ( items_count or patrons_count )%]
167
    <form action="[% action %]" method="post">
205
    <form action="/cgi-bin/koha/admin/branches.pl" method="post">
168
<fieldset><legend>Confirm deletion of [% branchname %] ([% branchcode %])?</legend><input type="hidden" name="op" value="delete_confirmed" />
206
        <fieldset>
169
        <input type="hidden" name="branchcode" value="[% branchcode |html %]" />
207
            <legend>Confirm deletion of [% library.branchname %] ([% library.branchcode %])?</legend>
170
        <input type="hidden" name="branchname" value="[% branchname |html %]">
208
            <input type="hidden" name="op" value="delete_confirmed" />
171
        <fieldset class="action"><input type="submit" value="Delete Library" /> <a class="cancel" href="/cgi-bin/koha/admin/branches.pl">Cancel</a></fieldset>
209
            <input type="hidden" name="branchcode" value="[% library.branchcode |html %]" />
172
</fieldset></form>
210
            <input type="hidden" name="branchname" value="[% library.branchname |html %]">
211
            <fieldset class="action">
212
                <input type="submit" value="Delete Library" />
213
                <a class="cancel" href="/cgi-bin/koha/admin/branches.pl">Cancel</a>
214
            </fieldset>
215
        </fieldset>
216
    </form>
173
[% END %]
217
[% END %]
174
218
175
[% IF ( else ) %]
219
[% IF op == 'list' %]
176
    <h3>Libraries</h3>
220
    <h3>Libraries</h3>
177
    [% IF ( message ) %]<div class="dialog message">
221
    [% IF libraries %]
178
        [% message %]</div>[% END %]
222
        <table id="branchest">
179
    [% IF ( MESSAGE1 ) %]<div class="dialog message">Library not saved &mdash; code and/or name missing</div>[% END %]
223
            <thead>
180
    [% IF ( MESSAGE2 ) %]<div class="dialog message">Library saved</div>[% END %]
224
                <tr>
181
    [% IF ( MESSAGE3 ) %]<div class="dialog message">Library deleted</div>[% END %]
225
                    <th>Name</th>
182
    [% IF ( MESSAGE4 ) %]<div class="dialog message">Library category added</div>[% END %]
226
                    <th>Code</th>
183
    [% IF ( MESSAGE5 ) %]<div class="dialog message">Library category modified</div>[% END %]
227
                    <th>Address</th>
184
    [% IF ( MESSAGE6 ) %]<div class="dialog message">Library category deleted</div>[% END %]
228
                    <th>Properties</th>
185
    [% IF ( MESSAGE7 ) %]<div class="dialog message">Library cannot be deleted because there are patrons and items using that library</div>[% END %]
229
                    <th>IP</th>
186
    [% IF ( MESSAGE8 ) %]<div class="dialog message">Category cannot be deleted because there are libraries using that category</div>[% END %]
230
                    <th>&nbsp;</th>
187
    [% IF ( MESSAGE9 ) %]<div class="dialog message">Category cannot be added, categorycode already exists</div>[% END %]
231
                    <th>&nbsp;</th>
188
    [% IF ( MESSAGE10 ) %]<div class="dialog message">Library cannot be deleted because there are items held by that library</div>[% END %]
232
                </tr>
189
    [% IF ( MESSAGE11 ) %]<div class="dialog message">Library cannot be deleted because there are patrons registered at that library</div>[% END %]
233
            </thead>
190
[% IF ( branches ) %]
234
            <tbody>
191
    <table id="branchest">
235
                [% FOREACH library IN libraries %]
192
<thead><tr>
236
                    <tr>
193
			<th>Name</th>
237
                        <td>[% library.branchname |html %]</td>
194
            <th>Code</th>
238
                        <td>[% library.branchcode |html %]</td>
195
            <th>Address</th>
239
                        <td>
196
            <th>Properties</th>
240
                            [% IF library.branchaddress1 %]
197
            <th>IP</th>
241
                                [% library.branchaddress1 |html %][% END %]
198
            <!-- <th>Printer</th> -->
242
                            [% IF library.branchaddress2 %]
199
            <th>&nbsp;</th>
243
                                <br />[% library.branchaddress2 |html %][% END %]
200
            <th>&nbsp;</th>
244
                            [% IF library.branchaddress3 %]
201
        </tr></thead><tbody>
245
                                <br />[% library.branchaddress3 |html %][% END %]
202
        [% FOREACH branche IN branches %]
246
                            [% IF library.branchcity %]
203
            <tr>
247
                                <br />[% library.branchcity |html %][% END %][% IF ( library.branchstate ) %],
204
                <td>[% branche.branch_name |html %]</td>
248
                                [% library.branchstate |html %][% END %]
205
                <td>[% branche.branch_code |html %]</td>
249
                            [% IF library.branchzip %]
206
                <td>
250
                                [% library.branchzip |html %][% END %]
207
                    [% IF ( branche.address_empty_p ) %]
251
                            [% IF library.branchcountry %]
208
                        (nothing entered)
252
                                <br />[% library.branchcountry |html %][% END %]
209
                    [% ELSE %]
253
                            [% IF library.branchphone %]
210
                        [% IF ( branche.branchaddress1 ) %]
254
                                <br />Ph: [% library.branchphone |html %][% END %]
211
                            [% branche.branchaddress1 |html %][% END %]
255
                            [% IF library.branchfax %]
212
                        [% IF ( branche.branchaddress2 ) %]
256
                                <br />Fax: [% library.branchfax |html %][% END %]
213
                            <br />[% branche.branchaddress2 |html %][% END %]
257
                            [% IF library.branchemail %]
214
                        [% IF ( branche.branchaddress3 ) %]
258
                                <br /><a href="mailto:[% library.branchemail %]">[% library.branchemail |html %]</a>[% END %]
215
                            <br />[% branche.branchaddress3 |html %][% END %]
259
                            [% IF library.branchurl %]
216
                        [% IF ( branche.branchcity ) %]
260
                                <br /><a href="[% library.branchurl %]">[% library.branchurl |html %]</a>[% END %]
217
                            <br />[% branche.branchcity |html %][% END %][% IF ( branche.branchstate ) %],
261
                            [% IF library.opac_info %]
218
                            [% branche.branchstate |html %][% END %]
262
                                <br />OPAC Info: <div>[% library.opac_info %]</div>[% END %]
219
                        [% IF ( branche.branchzip ) %]
263
                            [% IF library.branchnotes %]
220
                            [% branche.branchzip |html %][% END %]
264
                                <br />Notes: [% library.branchnotes |html %][% END %]
221
                        [% IF ( branche.branchcountry ) %]
265
                        </td>
222
                            <br />[% branche.branchcountry |html %][% END %]
266
                        <td>
223
                        [% IF ( branche.branchphone ) %]
267
                            [% FOREACH category IN library.get_categories %]
224
                            <br />Ph: [% branche.branchphone |html %][% END %]
268
                                [% category.categoryname %]<br />
225
                        [% IF ( branche.branchfax ) %]
269
                            [% END %]
226
                            <br />Fax: [% branche.branchfax |html %][% END %]
270
                        </td>
227
                        [% IF ( branche.branchemail ) %]
271
                        <td>[% library.branchip %]</td>
228
                            <br /><a href="mailto:[% branche.branchemail %]">[% branche.branchemail |html %]</a>[% END %]
272
                        <td>
229
                        [% IF ( branche.branchurl ) %]
273
                            <a href="/cgi-bin/koha/admin/branches.pl?op=add_form&amp;branchcode=[% library.branchcode %]">Edit</a>
230
                            <br /><a href="[% branche.branchurl %]">[% branche.branchurl |html %]</a>[% END %]
274
                        </td>
231
                        [% IF ( branche.opac_info ) %]
275
                        <td>
232
                            <br />OPAC Info: <div>[% branche.opac_info %]</div>[% END %]
276
                            <a href="/cgi-bin/koha/admin/branches.pl?op=delete_confirm&amp;branchcode=[% library.branchcode %]">Delete</a>
233
                        [% IF ( branche.branchnotes ) %]
277
                        </td>
234
                            <br />Notes: [% branche.branchnotes |html %][% END %]
278
                    </tr>
235
                    [% END %]
279
                [% END %]
236
                </td>
280
            </tbody>
237
                <td>
281
        </table>
238
                    [% UNLESS ( branche.no_categories_p ) %]
282
    [% ELSE %]
239
                        [% FOREACH category_lis IN branche.category_list %]
283
        <div class="dialog message">There are no libraries defined. <a href="/cgi-bin/koha/admin/branches.pl?op=add_form">Start defining libraries</a>.</div>
240
                            [% category_lis.categoryname %]<br />
284
    [% END %]
241
                        [% END %]
242
                    [% END %]
243
                </td>
244
                <td>
245
                    [% branche.branchip %]
246
                </td>
247
                <!-- <td>
248
                    [% branche.branchprinter %]
249
                </td> -->
250
                <td>
251
                    <a href="[% branche.action %]?op=edit&amp;branchcode=[% branche.value |url %]">Edit</a>
252
                </td>
253
                <td>
254
                    <a href="[% branche.action %]?branchcode=[% branche.value |url %]&amp;branchname=[% branche.branch_name |url %]&amp;op=delete">Delete</a>
255
                </td>
256
            </tr>
257
        [% END %]</tbody>
258
    </table>
259
	[% ELSE %]
260
	<div class="dialog message">There are no libraries defined. <a href="/cgi-bin/koha/admin/branches.pl?op=add">Start defining libraries</a>.</div>
261
	[% END %]
262
285
263
   [% IF ( branchcategories ) %]
286
    [% IF group_types %]
264
   [% FOREACH branchcategorie IN branchcategories %]
287
        [% FOREACH group_type IN group_types %]
265
    <h3>Group(s):  [% IF ( branchcategorie.properties ) %]Properties[% ELSE %][% IF ( branchcategorie.searchdomain ) %]Search domain[% END %][% END %]</h3>
288
            <h3>[% IF group_type.categorytype == 'properties' %]Properties[% ELSIF group_type.categorytype == 'searchdomain' %]Search domain[% END %]</h3>
266
    [% IF ( branchcategorie.catloop ) %]
289
            [% IF group_type.categories %]
267
      <table>
290
                <table>
268
        <thead>
291
                    <thead>
269
          <tr>
292
                        <tr>
270
            <th>Name</th>
293
                            <th>Name</th>
271
            <th>Code</th>
294
                            <th>Code</th>
272
            <th>Description</th>
295
                            <th>Description</th>
273
            <th>&nbsp;</th>
296
                            <th>&nbsp;</th>
274
            <th>&nbsp;</th>
297
                            <th>&nbsp;</th>
275
          </tr>
298
                        </tr>
276
        </thead>
299
                    </thead>
277
        <tbody>
300
                    <tbody>
278
          [% FOREACH catloo IN branchcategorie.catloop %]
301
                        [% FOREACH category IN group_type.categories %]
279
            <tr>
302
                            <tr>
280
              <td>[% catloo.categoryname %]</td>
303
                                <td>[% category.categoryname %]</td>
281
              <td>[% catloo.categorycode %]</td>
304
                                <td>[% category.categorycode %]</td>
282
              <td>[% catloo.codedescription %]</td>
305
                                <td>[% category.codedescription %]</td>
283
              <td>
306
                                <td>
284
                <a href="[% catloo.action %]?op=editcategory&amp;categorycode=[% catloo.categorycode |url %]">Edit</a>
307
                                  <a href="/cgi-bin/koha/admin/branches.pl?categorycode=[% category.categorycode %]&amp;op=add_form_category">Edit</a>
285
              </td>
308
                                </td>
286
              <td>
309
                                <td>
287
                <a href="[% catloo.action %]?op=delete_category&amp;categorycode=[% catloo.categorycode |url %]">Delete</a>
310
                                    <a href="/cgi-bin/koha/admin/branches.pl?categorycode=[% category.categorycode %]&amp;op=delete_confirm_category">Delete</a>
288
              </td>
311
                                </td>
289
            </tr>
312
                            </tr>
290
          [% END %]
313
                        [% END %]
291
        </tbody>
314
                    </tbody>
292
      </table>
315
                </table>
316
            [% ELSE %]
317
                [% IF group_type.categorytype == 'properties' %]
318
                    No properties defined.
319
                [% ELSIF group_type.categorytype == 'searchdomain' %]
320
                    No search domain defined.
321
                [% END %]
322
                <a href="/cgi-bin/koha/admin/branches.pl?op=add_form_category">Add a new group</a>.
323
            [% END %]
324
        [% END %]
293
    [% ELSE %]
325
    [% ELSE %]
294
      No [% IF ( branchcategorie.properties ) %]properties[% ELSIF ( branchcategorie.searchdomain ) %]search domain[% END %] defined. <a href="/cgi-bin/koha/admin/branches.pl?op=editcategory">Add a new group</a>.
326
        <p>No groups defined.</p>
295
    [% END %]
327
    [% END %]
296
  [% END %]
297
  [% ELSE %]
298
    <p>No groups defined.</p>
299
  [% END %] <!-- NAME="branchcategories" -->
300
[% END %]
328
[% END %]
301
329
302
[% IF ( editcategory ) %]
330
[% IF op == 'add_form_category' %]
303
    <h3>[% IF ( categorycode ) %]Edit group [% categorycode %][% ELSE %]Add group[% END %]</h3>
331
    <h3>[% IF category.categorycode %]Edit group [% category.categorycode %][% ELSE %]Add group[% END %]</h3>
304
    <form action="[% action %]" name="Aform" method="post">
332
    <form action="/cgi-bin/koha/admin/branches.pl" name="Aform" method="post">
305
    <input type="hidden" name="op" value="addcategory_validate" />
333
        <input type="hidden" name="op" value="add_validate_category" />
306
	[% IF ( categorycode ) %]
334
        [% IF category.categorycode %]
307
	<input type="hidden" name="add" value="0">
335
            <input type="hidden" name="is_a_modif" value="1" />
308
	[% ELSE %]
336
        [% END %]
309
	<input type="hidden" name="add" value="1">
337
        <fieldset class="rows">
310
	[% END %]
338
            <ol>
311
    <fieldset class="rows">
339
                <li>
340
                    [% IF category.categorycode %]
341
                        <span class="label">Category code: </span>
342
                        <input type="hidden" name="categorycode" id="categorycode" value="[% category.categorycode |html %]" />
343
                        [% category.categorycode %]
344
                    [% ELSE %]
345
                        <label for="categorycode">Category code:</label>
346
                        <input type="text" name="categorycode" id="categorycode" size="10" maxlength="10" />
347
                    [% END %]
348
                </li>
349
                <li>
350
                    <label for="categoryname">Name: </label>
351
                    <input type="text" name="categoryname" id="categoryname" size="32" maxlength="32" value="[% category.categoryname |html %]" />
352
                </li>
353
                <li>
354
                    <label for="codedescription">Description: </label>
355
                    <input type="text" name="codedescription" id="codedescription" size="70" value="[% category.codedescription |html %]" />
356
                </li>
357
                <li>
358
                    <label for="categorytype">Category type: </label>
359
                    <select id="categorytype" name="categorytype">
360
                        [% IF category.categorytype == 'properties' %]
361
                            <option value="searchdomain">Search domain</option>
362
                            <option value="properties" selected="selected">Properties</option>
363
                        [% ELSE %]
364
                            <option value="searchdomain">Search domain</option>
365
                            <option value="properties">Properties</option>
312
366
313
        <ol><li>
367
                        [% END %]
314
                [% IF ( categorycode ) %]
368
                    </select>
315
				<span class="label">Category code: </span>
369
                </li>
316
                    <input type="hidden" name="categorycode" id="categorycode" value="[% categorycode |html %]" />
370
                <li>
317
                    [% categorycode %]
371
                    <label for="show_in_pulldown">Show in search pulldown: </label>
318
                [% ELSE %]
372
                    [% IF category.show_in_pulldown %]
319
                <label for="categorycode">Category code:</label>
373
                        <input type="checkbox" name="show_in_pulldown" id="show_in_pulldown" checked="checked"/>
320
                    <input type="text" name="categorycode" id="categorycode" size="10" maxlength="10" value="[% categorycode |html %]" />
374
                    [% ELSE %]
321
                [% END %]
375
                        <input type="checkbox" name="show_in_pulldown" id="show_in_pulldown" />
322
            </li>
376
                    [% END %]
323
        <li>
377
                </li>
324
            <label for="categoryname">Name: </label>
378
            </ol>
325
            <input type="text" name="categoryname" id="categoryname" size="32" maxlength="32" value="[% categoryname |html %]" />
379
        </fieldset>
326
        </li>
380
        <fieldset class="action"><input type="submit" value="Update" /></fieldset>
327
        <li>
328
            <label for="codedescription">Description: </label>
329
            <input type="text" name="codedescription" id="codedescription" size="70" value="[% codedescription |html %]" />
330
        </li>
331
		<li>
332
        <label for="categorytype">Category type: </label>
333
            <select id="categorytype" name="categorytype">
334
            [% FOREACH categorytyp IN categorytype %]
335
                [% IF ( categorytyp.selected ) %]
336
                    <option value="[% categorytyp.type %]" selected="selected">
337
                [% ELSE %]
338
                    <option value="[% categorytyp.type %]">
339
                [% END %] [% categorytyp.type %]</option>
340
            [% END %]
341
            </select>
342
		</li>
343
        <li>
344
            <label for="show_in_pulldown">Show in search pulldown: </label>
345
            [% IF ( show_in_pulldown ) %]
346
                <input type="checkbox" name="show_in_pulldown" id="show_in_pulldown" checked="checked"/>
347
            [% ELSE %]
348
                <input type="checkbox" name="show_in_pulldown" id="show_in_pulldown" />
349
            [% END %]
350
        </li>
351
		</ol>
352
    </fieldset>
353
	<fieldset class="action"><input type="submit" value="Update" /></fieldset>
354
    </form>
381
    </form>
355
[% END %]
382
[% END %]
356
383
357
[% IF ( delete_category ) %]
384
[% IF op == 'delete_confirm_category' %]
358
    [% UNLESS ( MESSAGE8 ) %]
359
    <div class="dialog message">
385
    <div class="dialog message">
360
    Confirm delete:
386
    Are you sure you want to delete the group '[% category.codedescription %]' ([% category.categorycode %])?
361
    <form action="[% action %]" method="post">
387
    <form action="/cgi-bin/koha/admin/branches.pl" method="post">
362
        <input type="hidden" name="op" value="categorydelete_confirmed" />
388
        <input type="hidden" name="op" value="delete_confirmed_category" />
363
        <input type="hidden" name="categorycode" value="[% categorycode |html %]" />
389
        <input type="hidden" name="categorycode" value="[% category.categorycode |html %]" />
364
        <input type="submit" value="YES" />
390
        <input type="submit" value="Delete" />
365
    </form>
391
        <a class="cancel" href="/cgi-bin/koha/admin/branches.pl">Cancel</a>
366
    <form action="[% action %]" method="post"><input type="hidden" name="op" value="">
367
        <input type="submit" value="NO" />
368
    </form>
392
    </form>
369
    </div>
393
    </div>
370
    [% END %]
371
[% END %]
394
[% END %]
372
395
373
</div>
396
</div>
374
- 

Return to bug 15295