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

(-)a/C4/Budgets.pm (-5 / +18 lines)
Lines 354-365 sub GetBudgetAuthCats { Link Here
354
# -------------------------------------------------------------------
354
# -------------------------------------------------------------------
355
sub GetAuthvalueDropbox {
355
sub GetAuthvalueDropbox {
356
    my ( $authcat, $default ) = @_;
356
    my ( $authcat, $default ) = @_;
357
    my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
357
    my $dbh = C4::Context->dbh;
358
    my $dbh = C4::Context->dbh;
358
    my $sth = $dbh->prepare(
359
359
        'SELECT authorised_value,lib FROM authorised_values
360
    my $query = qq{
360
        WHERE category = ? ORDER BY lib'
361
        SELECT *
361
    );
362
        FROM authorised_values
362
    $sth->execute( $authcat );
363
    };
364
    $query .= qq{
365
          LEFT JOIN authorised_values_branches ON ( id = av_id )
366
    } if $branch_limit;
367
    $query .= qq{
368
        WHERE category = ?
369
    };
370
    $query .= " AND ( branchcode = ? OR branchcode IS NULL )" if $branch_limit;
371
    $query .= " GROUP BY lib ORDER BY category, lib, lib_opac";
372
    my $sth = $dbh->prepare($query);
373
    $sth->execute( $authcat, $branch_limit ? $branch_limit : () );
374
375
363
    my $option_list = [];
376
    my $option_list = [];
364
    my @authorised_values = ( q{} );
377
    my @authorised_values = ( q{} );
365
    while (my ($value, $lib) = $sth->fetchrow_array) {
378
    while (my ($value, $lib) = $sth->fetchrow_array) {
(-)a/C4/Category.pm (-7 / +18 lines)
Lines 71-83 C<description>. Link Here
71
=cut
71
=cut
72
72
73
sub all {
73
sub all {
74
    my $class = shift;
74
    my ( $class ) = @_;
75
    map {
75
    my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
76
        utf8::encode($_->{description});
76
    my $dbh = C4::Context->dbh;
77
        $class->new($_);
77
    # The categories table is small enough for
78
    } @{C4::Context->dbh->selectall_arrayref(
78
    # `SELECT *` to be harmless.
79
        "SELECT * FROM categories ORDER BY description", { Slice => {} }
79
    my $query = "SELECT * FROM categories";
80
    )};
80
    $query .= qq{
81
        LEFT JOIN categories_branches ON categories_branches.categorycode = categories.categorycode
82
        WHERE categories_branches.branchcode = ? OR categories_branches.branchcode IS NULL
83
    } if $branch_limit;
84
    $query .= " ORDER BY description";
85
    return map { $class->new($_) } @{
86
        $dbh->selectall_arrayref(
87
            $query,
88
            { Slice => {} },
89
            $branch_limit ? $branch_limit : ()
90
        )
91
    };
81
}
92
}
82
93
83
94
(-)a/C4/Input.pm (-26 / +41 lines)
Lines 119-151 Returns NULL if no authorised values found Link Here
119
=cut
119
=cut
120
120
121
sub buildCGIsort {
121
sub buildCGIsort {
122
	my ($name,$input_name,$data) = @_;
122
    my ( $name, $input_name, $data ) = @_;
123
	my $dbh=C4::Context->dbh;
123
    my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
124
	my $query=qq{SELECT * FROM authorised_values WHERE category=? order by lib};
124
125
	my $sth=$dbh->prepare($query);
125
    my $dbh=C4::Context->dbh;
126
	$sth->execute($name);
126
    my $query = qq{
127
	my $CGISort;
127
        SELECT *
128
	if ($sth->rows>0){
128
        FROM authorised_values
129
		my @values;
129
    };
130
		my %labels;
130
    $query .= qq{
131
131
          LEFT JOIN authorised_values_branches ON ( id = av_id )
132
		for (my $i =0;$i<$sth->rows;$i++){
132
    } if $branch_limit;
133
			my $results = $sth->fetchrow_hashref;
133
    $query .= qq{
134
			push @values, $results->{authorised_value};
134
        WHERE category = ?
135
			$labels{$results->{authorised_value}}=$results->{lib};
135
    };
136
		}
136
    $query .= qq{ AND ( branchcode = ? OR branchcode IS NULL )} if $branch_limit;
137
		$CGISort= CGI::scrolling_list(
137
    $query .= qq{ GROUP BY lib ORDER BY lib};
138
					-name => $input_name,
138
139
					-id =>   $input_name,
139
    my $sth=$dbh->prepare($query);
140
					-values => \@values,
140
    $sth->execute( $branch_limit ? $branch_limit : (), $name );
141
					-labels => \%labels,
141
    my $CGISort;
142
					-default=> $data,
142
    if ($sth->rows>0){
143
					-size => 1,
143
        my @values;
144
					-multiple => 0);
144
        my %labels;
145
	}
145
146
	$sth->finish;
146
        for (my $i =0;$i<$sth->rows;$i++){
147
	return $CGISort;
147
            my $results = $sth->fetchrow_hashref;
148
            push @values, $results->{authorised_value};
149
            $labels{$results->{authorised_value}}=$results->{lib};
150
        }
151
        $CGISort= CGI::scrolling_list(
152
                    -name => $input_name,
153
                    -id =>   $input_name,
154
                    -values => \@values,
155
                    -labels => \%labels,
156
                    -default=> $data,
157
                    -size => 1,
158
                    -multiple => 0);
159
    }
160
    $sth->finish;
161
    return $CGISort;
148
}
162
}
163
149
END { }       # module clean-up code here (global destructor)
164
END { }       # module clean-up code here (global destructor)
150
165
151
1;
166
1;
(-)a/C4/Koha.pm (-17 / +37 lines)
Lines 1007-1031 C<$opac> If set to a true value, displays OPAC descriptions rather than normal o Link Here
1007
=cut
1007
=cut
1008
1008
1009
sub GetAuthorisedValues {
1009
sub GetAuthorisedValues {
1010
    my ($category,$selected,$opac) = @_;
1010
    my ( $category, $selected, $opac ) = @_;
1011
	my @results;
1011
    my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
1012
    my @results;
1012
    my $dbh      = C4::Context->dbh;
1013
    my $dbh      = C4::Context->dbh;
1013
    my $query    = "SELECT * FROM authorised_values";
1014
    my $query = qq{
1014
    $query .= " WHERE category = '" . $category . "'" if $category;
1015
        SELECT *
1015
    $query .= " ORDER BY category, lib, lib_opac";
1016
        FROM authorised_values
1017
    };
1018
    $query .= qq{
1019
          LEFT JOIN authorised_values_branches ON ( id = av_id )
1020
    } if $branch_limit;
1021
    my @where_strings;
1022
    my @where_args;
1023
    if($category) {
1024
        push @where_strings, "category = ?";
1025
        push @where_args, $category;
1026
    }
1027
    if($branch_limit) {
1028
        push @where_strings, "( branchcode = ? OR branchcode IS NULL )";
1029
        push @where_args, $branch_limit;
1030
    }
1031
    if(@where_strings > 0) {
1032
        $query .= " WHERE " . join(" AND ", @where_strings);
1033
    }
1034
    $query .= " GROUP BY lib ORDER BY category, lib, lib_opac";
1035
1016
    my $sth = $dbh->prepare($query);
1036
    my $sth = $dbh->prepare($query);
1017
    $sth->execute;
1037
    $sth->execute( @where_args );
1018
	while (my $data=$sth->fetchrow_hashref) {
1038
    while (my $data=$sth->fetchrow_hashref) {
1019
	    if ($selected && $selected eq $data->{'authorised_value'} ) {
1039
        if ($selected && $selected eq $data->{'authorised_value'} ) {
1020
		    $data->{'selected'} = 1;
1040
            $data->{'selected'} = 1;
1021
	    }
1041
        }
1022
	    if ($opac && $data->{'lib_opac'}) {
1042
        if ($opac && $data->{'lib_opac'}) {
1023
		$data->{'lib'} = $data->{'lib_opac'};
1043
            $data->{'lib'} = $data->{'lib_opac'};
1024
	    }
1044
        }
1025
	    push @results, $data;
1045
        push @results, $data;
1026
	}
1046
    }
1027
    #my $data = $sth->fetchall_arrayref({});
1047
    $sth->finish;
1028
    return \@results; #$data;
1048
    return \@results;
1029
}
1049
}
1030
1050
1031
=head2 GetAuthorisedValueCategories
1051
=head2 GetAuthorisedValueCategories
(-)a/C4/Members.pm (-21 / +42 lines)
Lines 1373-1392 to category descriptions. Link Here
1373
1373
1374
#'
1374
#'
1375
sub GetborCatFromCatType {
1375
sub GetborCatFromCatType {
1376
    my ( $category_type, $action ) = @_;
1376
    my ( $category_type, $action, $no_branch_limit ) = @_;
1377
	# FIXME - This API  seems both limited and dangerous. 
1377
1378
    my $branch_limit = $no_branch_limit
1379
        ? 0
1380
        : C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
1381
1382
    # FIXME - This API  seems both limited and dangerous. 
1378
    my $dbh     = C4::Context->dbh;
1383
    my $dbh     = C4::Context->dbh;
1379
    my $request = qq|   SELECT categorycode,description 
1384
1380
            FROM categories 
1385
    my $request = qq{
1381
            $action
1386
        SELECT categories.categorycode, categories.description
1382
            ORDER BY categorycode|;
1387
        FROM categories
1383
    my $sth = $dbh->prepare($request);
1388
    };
1384
	if ($action) {
1389
    $request .= qq{
1385
        $sth->execute($category_type);
1390
        LEFT JOIN categories_branches ON categories.categorycode = categories_branches.categorycode
1386
    }
1391
    } if $branch_limit;
1387
    else {
1392
    if($action) {
1388
        $sth->execute();
1393
        $request .= " $action ";
1394
        $request .= " AND (branchcode = ? OR branchcode IS NULL) GROUP BY description" if $branch_limit;
1395
    } else {
1396
        $request .= " WHERE branchcode = ? OR branchcode IS NULL GROUP BY description" if $branch_limit;
1389
    }
1397
    }
1398
    $request .= " ORDER BY categorycode";
1399
1400
    my $sth = $dbh->prepare($request);
1401
    $sth->execute(
1402
        $action ? $category_type : (),
1403
        $branch_limit ? $branch_limit : ()
1404
    );
1390
1405
1391
    my %labels;
1406
    my %labels;
1392
    my @codes;
1407
    my @codes;
Lines 1395-1400 sub GetborCatFromCatType { Link Here
1395
        push @codes, $data->{'categorycode'};
1410
        push @codes, $data->{'categorycode'};
1396
        $labels{ $data->{'categorycode'} } = $data->{'description'};
1411
        $labels{ $data->{'categorycode'} } = $data->{'description'};
1397
    }
1412
    }
1413
    $sth->finish;
1398
    return ( \@codes, \%labels );
1414
    return ( \@codes, \%labels );
1399
}
1415
}
1400
1416
Lines 1437-1452 If no category code provided, the function returns all the categories. Link Here
1437
=cut
1453
=cut
1438
1454
1439
sub GetBorrowercategoryList {
1455
sub GetBorrowercategoryList {
1456
    my $no_branch_limit = @_ ? shift : 0;
1457
    my $branch_limit = $no_branch_limit
1458
        ? 0
1459
        : C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
1440
    my $dbh       = C4::Context->dbh;
1460
    my $dbh       = C4::Context->dbh;
1441
    my $sth       =
1461
    my $query = "SELECT * FROM categories";
1442
    $dbh->prepare(
1462
    $query .= qq{
1443
    "SELECT * 
1463
        LEFT JOIN categories_branches ON categories.categorycode = categories_branches.categorycode
1444
    FROM categories 
1464
        WHERE branchcode = ? OR branchcode IS NULL GROUP BY description
1445
    ORDER BY description"
1465
    } if $branch_limit;
1446
        );
1466
    $query .= " ORDER BY description";
1447
    $sth->execute;
1467
    my $sth = $dbh->prepare( $query );
1448
    my $data =
1468
    $sth->execute( $branch_limit ? $branch_limit : () );
1449
    $sth->fetchall_arrayref({});
1469
    my $data = $sth->fetchall_arrayref( {} );
1470
    $sth->finish;
1450
    return $data;
1471
    return $data;
1451
}    # sub getborrowercategory
1472
}    # sub getborrowercategory
1452
1473
(-)a/C4/Members/AttributeTypes.pm (-4 / +58 lines)
Lines 69-80 If $all_fields is true, then each hashref also contains the other fields from bo Link Here
69
=cut
69
=cut
70
70
71
sub GetAttributeTypes {
71
sub GetAttributeTypes {
72
    my ($all) = @_;
72
    my $all    = @_   ? shift : 0;
73
    my $select = $all ? '*' : 'code, description, class';
73
    my $no_branch_limit = @_ ? shift : 0;
74
    my $branch_limit = $no_branch_limit
75
        ? 0
76
        : C4::Context->userenv ? C4::Context->userenv->{"branch"} : 0;
77
    my $select = $all ? '*'   : 'DISTINCT(code), description';
78
74
    my $dbh = C4::Context->dbh;
79
    my $dbh = C4::Context->dbh;
75
    my $sth = $dbh->prepare("SELECT $select FROM borrower_attribute_types ORDER by code");
80
    my $query = "SELECT $select FROM borrower_attribute_types";
76
    $sth->execute();
81
    $query .= qq{
82
        LEFT JOIN borrower_attribute_types_branches ON bat_code = code
83
        WHERE b_branchcode = ? OR b_branchcode IS NULL
84
    } if $branch_limit;
85
    $query .= " ORDER BY code";
86
    my $sth    = $dbh->prepare($query);
87
    $sth->execute( $branch_limit ? $branch_limit : () );
77
    my $results = $sth->fetchall_arrayref({});
88
    my $results = $sth->fetchall_arrayref({});
89
    $sth->finish;
78
    return @$results;
90
    return @$results;
79
}
91
}
80
92
Lines 166-171 sub fetch { Link Here
166
    $self->{'category_description'}      = $row->{'category_description'};
178
    $self->{'category_description'}      = $row->{'category_description'};
167
    $self->{'class'}                     = $row->{'class'};
179
    $self->{'class'}                     = $row->{'class'};
168
180
181
    $sth = $dbh->prepare("SELECT branchcode, branchname FROM borrower_attribute_types_branches, branches WHERE b_branchcode = branchcode AND bat_code = ?;");
182
    $sth->execute( $code );
183
    while ( my $data = $sth->fetchrow_hashref ) {
184
        push @{ $self->{branches} }, $data;
185
    }
186
    $sth->finish();
187
169
    bless $self, $class;
188
    bless $self, $class;
170
    return $self;
189
    return $self;
171
}
190
}
Lines 219-224 sub store { Link Here
219
    $sth->bind_param(11, $self->{'code'});
238
    $sth->bind_param(11, $self->{'code'});
220
    $sth->execute;
239
    $sth->execute;
221
240
241
    if ( defined $$self{branches} ) {
242
        $sth = $dbh->prepare("DELETE FROM borrower_attribute_types_branches WHERE bat_code = ?");
243
        $sth->execute( $$self{code} );
244
        $sth = $dbh->prepare(
245
            "INSERT INTO borrower_attribute_types_branches
246
                        ( bat_code, b_branchcode )
247
                        VALUES ( ?, ? )"
248
        );
249
        for my $branchcode ( @{$$self{branches}} ) {
250
            next if not $branchcode;
251
            $sth->bind_param( 1, $$self{code} );
252
            $sth->bind_param( 2, $branchcode );
253
            $sth->execute;
254
        }
255
    }
256
    $sth->finish;
222
}
257
}
223
258
224
=head2 code
259
=head2 code
Lines 250-255 sub description { Link Here
250
    @_ ? $self->{'description'} = shift : $self->{'description'};
285
    @_ ? $self->{'description'} = shift : $self->{'description'};
251
}
286
}
252
287
288
=head2 branches
289
290
=over 4
291
292
my $branches = $attr_type->branches();
293
$attr_type->branches($branches);
294
295
=back
296
297
Accessor.
298
299
=cut
300
301
sub branches {
302
    my $self = shift;
303
    @_ ? $self->{branches} = shift : $self->{branches};
304
}
305
253
=head2 repeatable
306
=head2 repeatable
254
307
255
  my $repeatable = $attr_type->repeatable();
308
  my $repeatable = $attr_type->repeatable();
Lines 432-437 sub delete { Link Here
432
    my $dbh = C4::Context->dbh;
485
    my $dbh = C4::Context->dbh;
433
    my $sth = $dbh->prepare_cached("DELETE FROM borrower_attribute_types WHERE code = ?");
486
    my $sth = $dbh->prepare_cached("DELETE FROM borrower_attribute_types WHERE code = ?");
434
    $sth->execute($code);
487
    $sth->execute($code);
488
    $sth->finish;
435
}
489
}
436
490
437
=head2 num_patrons
491
=head2 num_patrons
(-)a/C4/Members/Attributes.pm (+2 lines)
Lines 70-75 marked for OPAC display are returned. Link Here
70
sub GetBorrowerAttributes {
70
sub GetBorrowerAttributes {
71
    my $borrowernumber = shift;
71
    my $borrowernumber = shift;
72
    my $opac_only = @_ ? shift : 0;
72
    my $opac_only = @_ ? shift : 0;
73
    my $branch_limit = @_ ? shift : 0;
73
74
74
    my $dbh = C4::Context->dbh();
75
    my $dbh = C4::Context->dbh();
75
    my $query = "SELECT code, description, attribute, lib, password, display_checkout, category_code, class
76
    my $query = "SELECT code, description, attribute, lib, password, display_checkout, category_code, class
Lines 94-99 sub GetBorrowerAttributes { Link Here
94
            class             => $row->{'class'},
95
            class             => $row->{'class'},
95
        }
96
        }
96
    }
97
    }
98
    $sth->finish;
97
    return \@results;
99
    return \@results;
98
}
100
}
99
101
(-)a/admin/authorised_values.pl (-4 / +54 lines)
Lines 22-27 use warnings; Link Here
22
22
23
use CGI;
23
use CGI;
24
use C4::Auth;
24
use C4::Auth;
25
use C4::Branch;
25
use C4::Context;
26
use C4::Context;
26
use C4::Koha;
27
use C4::Koha;
27
use C4::Output;
28
use C4::Output;
Lines 67-79 $template->param( script_name => $script_name, Link Here
67
# called by default. Used to create form to add or  modify a record
68
# called by default. Used to create form to add or  modify a record
68
if ($op eq 'add_form') {
69
if ($op eq 'add_form') {
69
	my $data;
70
	my $data;
71
    my @selected_branches;
70
	if ($id) {
72
	if ($id) {
71
		my $sth=$dbh->prepare("select id, category, authorised_value, lib, lib_opac, imageurl from authorised_values where id=?");
73
		my $sth=$dbh->prepare("select id, category, authorised_value, lib, lib_opac, imageurl from authorised_values where id=?");
72
		$sth->execute($id);
74
		$sth->execute($id);
73
		$data=$sth->fetchrow_hashref;
75
		$data=$sth->fetchrow_hashref;
76
        $sth = $dbh->prepare("SELECT b.branchcode, b.branchname FROM authorised_values_branches AS avb, branches AS b WHERE avb.branchcode = b.branchcode AND avb.av_id = ?;");
77
        $sth->execute( $id );
78
        while ( my $branch = $sth->fetchrow_hashref ) {
79
            push @selected_branches, $branch;
80
        }
74
	} else {
81
	} else {
75
		$data->{'category'} = $input->param('category');
82
		$data->{'category'} = $input->param('category');
76
	}
83
	}
84
85
    my $branches = GetBranches;
86
    my @branches_loop;
87
88
    foreach my $branch (sort keys %$branches) {
89
        my $selected = ( grep {$_->{branchcode} eq $branch} @selected_branches ) ? 1 : 0;
90
        push @branches_loop, {
91
            branchcode => $branches->{$branch}{branchcode},
92
            branchname => $branches->{$branch}{branchname},
93
            selected => $selected,
94
        };
95
    }
96
77
	if ($id) {
97
	if ($id) {
78
		$template->param(action_modify => 1);
98
		$template->param(action_modify => 1);
79
		$template->param('heading_modify_authorized_value_p' => 1);
99
		$template->param('heading_modify_authorized_value_p' => 1);
Lines 92-97 if ($op eq 'add_form') { Link Here
92
                         id               => $data->{'id'},
112
                         id               => $data->{'id'},
93
                         imagesets        => C4::Koha::getImageSets( checked => $data->{'imageurl'} ),
113
                         imagesets        => C4::Koha::getImageSets( checked => $data->{'imageurl'} ),
94
                         offset           => $offset,
114
                         offset           => $offset,
115
                         branches_loop    => \@branches_loop,
95
                     );
116
                     );
96
                          
117
                          
97
################## ADD_VALIDATE ##################################
118
################## ADD_VALIDATE ##################################
Lines 102-107 if ($op eq 'add_form') { Link Here
102
    my $imageurl     = $input->param( 'imageurl' ) || '';
123
    my $imageurl     = $input->param( 'imageurl' ) || '';
103
	$imageurl = '' if $imageurl =~ /removeImage/;
124
	$imageurl = '' if $imageurl =~ /removeImage/;
104
    my $duplicate_entry = 0;
125
    my $duplicate_entry = 0;
126
    my @branches = $input->param('branches');
105
127
106
    if ( $id ) { # Update
128
    if ( $id ) { # Update
107
        my $sth = $dbh->prepare( "SELECT category, authorised_value FROM authorised_values WHERE id = ? ");
129
        my $sth = $dbh->prepare( "SELECT category, authorised_value FROM authorised_values WHERE id = ? ");
Lines 125-131 if ($op eq 'add_form') { Link Here
125
            my $lib_opac = $input->param('lib_opac');
147
            my $lib_opac = $input->param('lib_opac');
126
            undef $lib if ($lib eq ""); # to insert NULL instead of a blank string
148
            undef $lib if ($lib eq ""); # to insert NULL instead of a blank string
127
            undef $lib_opac if ($lib_opac eq ""); # to insert NULL instead of a blank string
149
            undef $lib_opac if ($lib_opac eq ""); # to insert NULL instead of a blank string
128
            $sth->execute($new_category, $new_authorised_value, $lib, $lib_opac, $imageurl, $id);          
150
            $sth->execute($new_category, $new_authorised_value, $lib, $lib_opac, $imageurl, $id);
151
            if ( @branches ) {
152
                $sth = $dbh->prepare("DELETE FROM authorised_values_branches WHERE av_id = ?");
153
                $sth->execute( $id );
154
                $sth = $dbh->prepare(
155
                    "INSERT INTO authorised_values_branches
156
                                ( av_id, branchcode )
157
                                VALUES ( ?, ? )"
158
                );
159
                for my $branchcode ( @branches ) {
160
                    next if not $branchcode;
161
                    $sth->execute($id, $branchcode);
162
                }
163
            }
164
            $sth->finish;
129
            print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=authorised_values.pl?searchfield=".$new_category."&offset=$offset\"></html>";
165
            print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=authorised_values.pl?searchfield=".$new_category."&offset=$offset\"></html>";
130
            exit;
166
            exit;
131
        }
167
        }
Lines 137-149 if ($op eq 'add_form') { Link Here
137
        ($duplicate_entry) = $sth->fetchrow_array();
173
        ($duplicate_entry) = $sth->fetchrow_array();
138
        unless ( $duplicate_entry ) {
174
        unless ( $duplicate_entry ) {
139
            my $sth=$dbh->prepare( 'INSERT INTO authorised_values
175
            my $sth=$dbh->prepare( 'INSERT INTO authorised_values
140
                                    ( id, category, authorised_value, lib, lib_opac, imageurl )
176
                                    ( category, authorised_value, lib, lib_opac, imageurl )
141
                                    values (?, ?, ?, ?, ?, ?)' );
177
                                    values (?, ?, ?, ?, ?)' );
142
    	    my $lib = $input->param('lib');
178
    	    my $lib = $input->param('lib');
143
    	    my $lib_opac = $input->param('lib_opac');
179
    	    my $lib_opac = $input->param('lib_opac');
144
    	    undef $lib if ($lib eq ""); # to insert NULL instead of a blank string
180
    	    undef $lib if ($lib eq ""); # to insert NULL instead of a blank string
145
    	    undef $lib_opac if ($lib_opac eq ""); # to insert NULL instead of a blank string
181
    	    undef $lib_opac if ($lib_opac eq ""); # to insert NULL instead of a blank string
146
    	    $sth->execute($id, $new_category, $new_authorised_value, $lib, $lib_opac, $imageurl );
182
            $sth->execute( $new_category, $new_authorised_value, $lib, $lib_opac, $imageurl );
183
            $id = $dbh->{'mysql_insertid'};
184
            if ( @branches ) {
185
                $sth = $dbh->prepare(
186
                    "INSERT INTO authorised_values_branches
187
                                ( av_id, branchcode )
188
                                VALUES ( ?, ? )"
189
                );
190
                for my $branchcode ( @branches ) {
191
                    next if not $branchcode;
192
                    $sth->execute($id, $branchcode);
193
                }
194
            }
147
    	    print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=authorised_values.pl?searchfield=".$input->param('category')."&offset=$offset\"></html>";
195
    	    print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=authorised_values.pl?searchfield=".$input->param('category')."&offset=$offset\"></html>";
148
    	    exit;
196
    	    exit;
149
        }
197
        }
Lines 176-181 if ($op eq 'add_form') { Link Here
176
	my $id = $input->param('id');
224
	my $id = $input->param('id');
177
	my $sth=$dbh->prepare("delete from authorised_values where id=?");
225
	my $sth=$dbh->prepare("delete from authorised_values where id=?");
178
	$sth->execute($id);
226
	$sth->execute($id);
227
    $sth = $dbh->prepare("DELETE FROM authorised_values_branches WHERE id = ?");
228
    $sth->execute($id);
179
	print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=authorised_values.pl?searchfield=$searchfield&offset=$offset\"></html>";
229
	print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=authorised_values.pl?searchfield=$searchfield&offset=$offset\"></html>";
180
	exit;
230
	exit;
181
													# END $OP eq DELETE_CONFIRMED
231
													# END $OP eq DELETE_CONFIRMED
(-)a/admin/categorie.pl (-5 / +41 lines)
Lines 36-46 Link Here
36
# with Koha; if not, write to the Free Software Foundation, Inc.,
36
# with Koha; if not, write to the Free Software Foundation, Inc.,
37
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
37
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
38
38
39
use strict;
39
use Modern::Perl;
40
#use warnings; FIXME - Bug 2505
40
41
use CGI;
41
use CGI;
42
use C4::Context;
42
use C4::Context;
43
use C4::Auth;
43
use C4::Auth;
44
use C4::Branch;
44
use C4::Output;
45
use C4::Output;
45
use C4::Dates;
46
use C4::Dates;
46
use C4::Form::MessagingPreferences;
47
use C4::Form::MessagingPreferences;
Lines 90-105 if ($op eq 'add_form') { Link Here
90
	
91
	
91
	#---- if primkey exists, it's a modify action, so read values to modify...
92
	#---- if primkey exists, it's a modify action, so read values to modify...
92
	my $data;
93
	my $data;
94
    my @selected_branches;
93
	if ($categorycode) {
95
	if ($categorycode) {
94
		my $dbh = C4::Context->dbh;
96
		my $dbh = C4::Context->dbh;
95
		my $sth=$dbh->prepare("select categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,hidelostitems,overduenoticerequired,category_type from categories where categorycode=?");
97
		my $sth=$dbh->prepare("select categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,hidelostitems,overduenoticerequired,category_type from categories where categorycode=?");
96
		$sth->execute($categorycode);
98
		$sth->execute($categorycode);
97
		$data=$sth->fetchrow_hashref;
99
		$data=$sth->fetchrow_hashref;
98
		$sth->finish;
100
99
	}
101
        $sth = $dbh->prepare("SELECT b.branchcode, b.branchname FROM categories_branches AS cb, branches AS b WHERE cb.branchcode = b.branchcode AND cb.categorycode = ?");
102
        $sth->execute( $categorycode );
103
        while ( my $branch = $sth->fetchrow_hashref ) {
104
            push @selected_branches, $branch;
105
        }
106
        $sth->finish;
107
    }
100
108
101
    $data->{'enrolmentperioddate'} = undef if ($data->{'enrolmentperioddate'} eq '0000-00-00');
109
    $data->{'enrolmentperioddate'} = undef if ($data->{'enrolmentperioddate'} eq '0000-00-00');
102
110
111
    my $branches = GetBranches;
112
    my @branches_loop;
113
    foreach my $branch (sort keys %$branches) {
114
        my $selected = ( grep {$$_{branchcode} eq $branch} @selected_branches ) ? 1 : 0;
115
        push @branches_loop, {
116
            branchcode => $$branches{$branch}{branchcode},
117
            branchname => $$branches{$branch}{branchname},
118
            selected => $selected,
119
        };
120
    }
121
103
	$template->param(description        => $data->{'description'},
122
	$template->param(description        => $data->{'description'},
104
				enrolmentperiod         => $data->{'enrolmentperiod'},
123
				enrolmentperiod         => $data->{'enrolmentperiod'},
105
				enrolmentperioddate     => C4::Dates::format_date($data->{'enrolmentperioddate'}),
124
				enrolmentperioddate     => C4::Dates::format_date($data->{'enrolmentperioddate'}),
Lines 113-119 if ($op eq 'add_form') { Link Here
113
				category_type           => $data->{'category_type'},
132
				category_type           => $data->{'category_type'},
114
				DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
133
				DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
115
				"type_".$data->{'category_type'} => 1,
134
				"type_".$data->{'category_type'} => 1,
116
				SMSSendDriver => C4::Context->preference("SMSSendDriver")
135
				SMSSendDriver => C4::Context->preference("SMSSendDriver"),
136
                branches_loop           => \@branches_loop,
117
				);
137
				);
118
    if (C4::Context->preference('EnhancedMessagingPreferences')) {
138
    if (C4::Context->preference('EnhancedMessagingPreferences')) {
119
        C4::Form::MessagingPreferences::set_form_values({ categorycode => $categorycode } , $template);
139
        C4::Form::MessagingPreferences::set_form_values({ categorycode => $categorycode } , $template);
Lines 132-137 if ($op eq 'add_form') { Link Here
132
	if ($is_a_modif) {
152
	if ($is_a_modif) {
133
            my $sth=$dbh->prepare("UPDATE categories SET description=?,enrolmentperiod=?, enrolmentperioddate=?,upperagelimit=?,dateofbirthrequired=?,enrolmentfee=?,reservefee=?,hidelostitems=?,overduenoticerequired=?,category_type=? WHERE categorycode=?");
153
            my $sth=$dbh->prepare("UPDATE categories SET description=?,enrolmentperiod=?, enrolmentperioddate=?,upperagelimit=?,dateofbirthrequired=?,enrolmentfee=?,reservefee=?,hidelostitems=?,overduenoticerequired=?,category_type=? WHERE categorycode=?");
134
            $sth->execute(map { $input->param($_) } ('description','enrolmentperiod','enrolmentperioddate','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','hidelostitems','overduenoticerequired','category_type','categorycode'));
154
            $sth->execute(map { $input->param($_) } ('description','enrolmentperiod','enrolmentperioddate','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','hidelostitems','overduenoticerequired','category_type','categorycode'));
155
            my @branches = $input->param("branches");
156
            if ( @branches ) {
157
                $sth = $dbh->prepare("DELETE FROM categories_branches WHERE categorycode = ?");
158
                $sth->execute( $input->param( "categorycode" ) );
159
                $sth = $dbh->prepare(
160
                    "INSERT INTO categories_branches
161
                                ( categorycode, branchcode )
162
                                VALUES ( ?, ? )"
163
                );
164
                for my $branchcode ( @branches ) {
165
                    next if not $branchcode;
166
                    $sth->bind_param( 1, $input->param( "categorycode" ) );
167
                    $sth->bind_param( 2, $branchcode );
168
                    $sth->execute;
169
                }
170
            }
135
            $sth->finish;
171
            $sth->finish;
136
        } else {
172
        } else {
137
            my $sth=$dbh->prepare("INSERT INTO categories  (categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,reservefee,hidelostitems,overduenoticerequired,category_type) values (?,?,?,?,?,?,?,?,?,?,?)");
173
            my $sth=$dbh->prepare("INSERT INTO categories  (categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,reservefee,hidelostitems,overduenoticerequired,category_type) values (?,?,?,?,?,?,?,?,?,?,?)");
(-)a/admin/patron-attr-types.pl (-4 / +32 lines)
Lines 19-30 Link Here
19
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
#
20
#
21
21
22
use strict;
22
use Modern::Perl;
23
use warnings;
23
24
use CGI;
24
use CGI;
25
use List::MoreUtils qw/uniq/;
25
use List::MoreUtils qw/uniq/;
26
26
27
use C4::Auth;
27
use C4::Auth;
28
use C4::Branch;
28
use C4::Context;
29
use C4::Context;
29
use C4::Output;
30
use C4::Output;
30
use C4::Koha;
31
use C4::Koha;
Lines 82-91 exit 0; Link Here
82
sub add_attribute_type_form {
83
sub add_attribute_type_form {
83
    my $template = shift;
84
    my $template = shift;
84
85
86
    my $branches = GetBranches;
87
    my @branches_loop;
88
    foreach my $branch (sort keys %$branches) {
89
        push @branches_loop, {
90
            branchcode => $$branches{$branch}{branchcode},
91
            branchname => $$branches{$branch}{branchname},
92
        };
93
    }
94
85
    $template->param(
95
    $template->param(
86
        attribute_type_form => 1,
96
        attribute_type_form => 1,
87
        confirm_op => 'add_attribute_type_confirmed',
97
        confirm_op => 'add_attribute_type_confirmed',
88
        categories => GetBorrowercategoryList,
98
        categories => GetBorrowercategoryList,
99
        branches_loop => \@branches_loop,
89
    );
100
    );
90
    authorised_value_category_list($template);
101
    authorised_value_category_list($template);
91
    pa_classes($template);
102
    pa_classes($template);
Lines 162-167 sub add_update_attribute_type { Link Here
162
    $attr_type->display_checkout($display_checkout);
173
    $attr_type->display_checkout($display_checkout);
163
    $attr_type->category_code($input->param('category_code'));
174
    $attr_type->category_code($input->param('category_code'));
164
    $attr_type->class($input->param('class'));
175
    $attr_type->class($input->param('class'));
176
    my @branches = $input->param('branches');
177
    $attr_type->branches( \@branches );
165
178
166
    if ($op eq 'edit') {
179
    if ($op eq 'edit') {
167
        $template->param(edited_attribute_type => $attr_type->code());
180
        $template->param(edited_attribute_type => $attr_type->code());
Lines 244-249 sub edit_attribute_type_form { Link Here
244
    authorised_value_category_list($template, $attr_type->authorised_value_category());
257
    authorised_value_category_list($template, $attr_type->authorised_value_category());
245
    pa_classes( $template, $attr_type->class );
258
    pa_classes( $template, $attr_type->class );
246
259
260
261
    my $branches = GetBranches;
262
    my @branches_loop;
263
    my $selected_branches = $attr_type->branches;
264
    foreach my $branch (sort keys %$branches) {
265
        my $selected = ( grep {$$_{branchcode} eq $branch} @$selected_branches ) ? 1 : 0;
266
        push @branches_loop, {
267
            branchcode => $branches->{$branch}{branchcode},
268
            branchname => $branches->{$branch}{branchname},
269
            selected => $selected,
270
        };
271
    }
272
    $template->param( branches_loop => \@branches_loop );
273
247
    $template->param ( category_code => $attr_type->category_code );
274
    $template->param ( category_code => $attr_type->category_code );
248
    $template->param ( category_description => $attr_type->category_description );
275
    $template->param ( category_description => $attr_type->category_description );
249
276
Lines 259-266 sub edit_attribute_type_form { Link Here
259
sub patron_attribute_type_list {
286
sub patron_attribute_type_list {
260
    my $template = shift;
287
    my $template = shift;
261
288
262
    my @attr_types = C4::Members::AttributeTypes::GetAttributeTypes();
289
    my @attr_types = C4::Members::AttributeTypes::GetAttributeTypes( 1, 1 );
263
    my @classes = uniq( map {$_->{class}} @attr_types );
290
291
    my @classes = uniq( map { $_->{class} } @attr_types );
264
    @classes = sort @classes;
292
    @classes = sort @classes;
265
293
266
    my @attributes_loop;
294
    my @attributes_loop;
(-)a/cataloguing/addbiblio.pl (-7 / +14 lines)
Lines 221-228 sub build_authorized_values_list { Link Here
221
        #---- "true" authorised value
221
        #---- "true" authorised value
222
    }
222
    }
223
    else {
223
    else {
224
        my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
224
        $authorised_values_sth->execute(
225
        $authorised_values_sth->execute(
225
            $tagslib->{$tag}->{$subfield}->{authorised_value} );
226
            $branch_limit ? $branch_limit : (),
227
            $tagslib->{$tag}->{$subfield}->{authorised_value}
228
        );
226
229
227
        push @authorised_values, ""
230
        push @authorised_values, ""
228
          unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
231
          unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
Lines 232-237 sub build_authorized_values_list { Link Here
232
            $authorised_lib{$value} = $lib;
235
            $authorised_lib{$value} = $lib;
233
        }
236
        }
234
    }
237
    }
238
    $authorised_values_sth->finish;
235
    return CGI::scrolling_list(
239
    return CGI::scrolling_list(
236
        -name     => "tag_".$tag."_subfield_".$subfield."_".$index_tag."_".$index_subfield,
240
        -name     => "tag_".$tag."_subfield_".$subfield."_".$index_tag."_".$index_subfield,
237
        -values   => \@authorised_values,
241
        -values   => \@authorised_values,
Lines 523-534 sub build_tabs { Link Here
523
    my @loop_data = ();
527
    my @loop_data = ();
524
    my $tag;
528
    my $tag;
525
529
526
    my $authorised_values_sth = $dbh->prepare(
530
    my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
527
        "select authorised_value,lib
531
    my $query = "SELECT authorised_value, lib
528
        from authorised_values
532
                FROM authorised_values";
529
        where category=? order by lib"
533
    $query .= qq{ JOIN authorised_values_branches ON ( id = av_id AND ( branchcode = ? OR branchcode IS NULL ) )} if $branch_limit;
530
    );
534
    $query .= " WHERE category = ?";
531
    
535
    $query .= " GROUP BY lib ORDER BY lib, lib_opac";
536
    my $authorised_values_sth = $dbh->prepare( $query );
537
532
    # in this array, we will push all the 10 tabs
538
    # in this array, we will push all the 10 tabs
533
    # to avoid having 10 tabs in the template : they will all be in the same BIG_LOOP
539
    # to avoid having 10 tabs in the template : they will all be in the same BIG_LOOP
534
    my @BIG_LOOP;
540
    my @BIG_LOOP;
Lines 713-718 sub build_tabs { Link Here
713
            };
719
            };
714
        }
720
        }
715
    }
721
    }
722
    $authorised_values_sth->finish;
716
    $template->param( BIG_LOOP => \@BIG_LOOP );
723
    $template->param( BIG_LOOP => \@BIG_LOOP );
717
}
724
}
718
725
(-)a/cataloguing/additem.pl (-7 / +6 lines)
Lines 104-111 sub generate_subfield_form { Link Here
104
  
104
  
105
  my $frameworkcode = &GetFrameworkCode($biblionumber);
105
  my $frameworkcode = &GetFrameworkCode($biblionumber);
106
        my %subfield_data;
106
        my %subfield_data;
107
        my $dbh = C4::Context->dbh;        
107
        my $dbh = C4::Context->dbh;
108
        my $authorised_values_sth = $dbh->prepare("SELECT authorised_value,lib FROM authorised_values WHERE category=? ORDER BY lib");
109
        
108
        
110
        my $index_subfield = int(rand(1000000)); 
109
        my $index_subfield = int(rand(1000000)); 
111
        if ($subfieldtag eq '@'){
110
        if ($subfieldtag eq '@'){
Lines 200-210 sub generate_subfield_form { Link Here
200
                  #---- "true" authorised value
199
                  #---- "true" authorised value
201
            }
200
            }
202
            else {
201
            else {
203
                  push @authorised_values, "" unless ( $subfieldlib->{mandatory} );
202
                  push @authorised_values, qq{} unless ( $subfieldlib->{mandatory} );
204
                  $authorised_values_sth->execute( $subfieldlib->{authorised_value} );
203
                  my $av = GetAuthorisedValues( $subfieldlib->{authorised_value} );
205
                  while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) {
204
                  for my $r ( @$av ) {
206
                      push @authorised_values, $value;
205
                      push @authorised_values, $r->{authorised_value};
207
                      $authorised_lib{$value} = $lib;
206
                      $authorised_lib{$r->{authorised_value}} = $r->{lib};
208
                  }
207
                  }
209
            }
208
            }
210
209
(-)a/installer/data/mysql/kohastructure.sql (+38 lines)
Lines 2828-2833 CREATE TABLE ratings ( Link Here
2828
    CONSTRAINT ratings_ibfk_2 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE
2828
    CONSTRAINT ratings_ibfk_2 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE
2829
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2829
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2830
2830
2831
--
2832
-- Table structure for table categories_branches
2833
--
2834
2835
DROP TABLE IF EXISTS categories_branches;
2836
CREATE TABLE categories_branches( -- association table between categories and branches
2837
    categorycode VARCHAR(10),
2838
    branchcode VARCHAR(10),
2839
    FOREIGN KEY (categorycode) REFERENCES categories(categorycode) ON DELETE CASCADE,
2840
    FOREIGN KEY (branchcode) REFERENCES branches(branchcode) ON DELETE CASCADE
2841
) ENGINE=INNODB DEFAULT CHARSET=utf8;
2842
2843
--
2844
-- Table structure for table authorised_values_branches
2845
--
2846
2847
DROP TABLE IF EXISTS authorised_values_branches;
2848
CREATE TABLE authorised_values_branches( -- association table between authorised_values and branches
2849
    av_id INTEGER,
2850
    branchcode VARCHAR(10),
2851
    FOREIGN KEY (av_id) REFERENCES authorised_values(id) ON DELETE CASCADE,
2852
    FOREIGN KEY (branchcode) REFERENCES branches(branchcode) ON DELETE CASCADE
2853
) ENGINE=INNODB DEFAULT CHARSET=utf8;
2854
2855
2856
--
2857
-- Table structure for table borrower_attribute_types_branches
2858
--
2859
2860
DROP TABLE IF EXISTS borrower_attribute_types_branches;
2861
CREATE TABLE borrower_attribute_types_branches( -- association table between borrower_attribute_types and branches
2862
    bat_code VARCHAR(10),
2863
    b_branchcode VARCHAR(10),
2864
    FOREIGN KEY (bat_code) REFERENCES borrower_attribute_types(code) ON DELETE CASCADE,
2865
    FOREIGN KEY (b_branchcode) REFERENCES branches(branchcode) ON DELETE CASCADE
2866
) ENGINE=INNODB DEFAULT CHARSET=utf8;
2867
2868
2831
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
2869
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
2832
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
2870
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
2833
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
2871
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
(-)a/installer/data/mysql/updatedatabase.pl (+17 lines)
Lines 5197-5202 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
5197
}
5197
}
5198
5198
5199
5199
5200
5201
5202
5203
5204
5205
$DBversion = "3.07.00.XXX";
5206
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5207
    $dbh->do(qq{CREATE TABLE borrower_attribute_types_branches(bat_code VARCHAR(10), b_branchcode VARCHAR(10),FOREIGN KEY (bat_code) REFERENCES borrower_attribute_types(code) ON DELETE CASCADE,FOREIGN KEY (b_branchcode) REFERENCES branches(branchcode) ON DELETE CASCADE ) ENGINE=INNODB DEFAULT CHARSET=utf8;});
5208
5209
    $dbh->do(qq{CREATE TABLE categories_branches(categorycode VARCHAR(10), branchcode VARCHAR(10), FOREIGN KEY (categorycode) REFERENCES categories(categorycode) ON DELETE CASCADE, FOREIGN KEY (branchcode) REFERENCES branches(branchcode) ON DELETE CASCADE ) ENGINE=INNODB DEFAULT CHARSET=utf8;});
5210
5211
    $dbh->do(qq{CREATE TABLE authorised_values_branches(av_id INTEGER, branchcode VARCHAR(10), FOREIGN KEY (av_id) REFERENCES authorised_values(id) ON DELETE CASCADE, FOREIGN KEY  (branchcode) REFERENCES branches(branchcode) ON DELETE CASCADE ) ENGINE=INNODB DEFAULT CHARSET=utf8;});
5212
5213
    print "Upgrade to $DBversion done (Add 3 associations tables with branches)\n";
5214
    SetVersion($DBversion);
5215
}
5216
5200
=head1 FUNCTIONS
5217
=head1 FUNCTIONS
5201
5218
5202
=head2 DropAllForeignKeys($table)
5219
=head2 DropAllForeignKeys($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt (-1 / +19 lines)
Lines 13-19 Link Here
13
		sortList: [[1,0]],
13
		sortList: [[1,0]],
14
		headers: { 4: { sorter: false}, 5: { sorter: false}}
14
		headers: { 4: { sorter: false}, 5: { sorter: false}}
15
		   		}).tablesorterPager({container: $("#pagertable_authorized_values"),positionFixed: false,size: 50});
15
		   		}).tablesorterPager({container: $("#pagertable_authorized_values"),positionFixed: false,size: 50});
16
	
16
17
    if ( $("#branches option:selected").length < 1 ) {
18
        $("#branches option:first").attr("selected", "selected");
19
    }
17
}); </script>
20
}); </script>
18
21
19
<script type="text/JavaScript" language="JavaScript">
22
<script type="text/JavaScript" language="JavaScript">
Lines 77-82 Link Here
77
            <label for="lib_opac">Description (OPAC)</label>
80
            <label for="lib_opac">Description (OPAC)</label>
78
            <input type="text" name="lib_opac" id="lib_opac" value="[% lib_opac %]" maxlength="80" />
81
            <input type="text" name="lib_opac" id="lib_opac" value="[% lib_opac %]" maxlength="80" />
79
        </li>
82
        </li>
83
        <li><label for="branches">Branches limitation: </label>
84
            <select id="branches" name="branches" multiple size="10">
85
                <option value="">All branches</option>
86
                [% FOREACH branch IN branches_loop %]
87
                  [% IF ( branch.selected ) %]
88
                    <option selected="selected" value="[% branch.branchcode %]">[% branch.branchname %]</option>
89
                  [% ELSE %]
90
                    <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
91
                  [% END %]
92
                [% END %]
93
            </select>
94
            <span>Select All if this authorised value must to be displayed all the time. Otherwise select librairies you want to associate with this value.
95
            </span>
96
        </li>
97
80
		</ol>
98
		</ol>
81
		<div id="icons" class="toptabs">
99
		<div id="icons" class="toptabs">
82
        <h5 style="margin-left:10px;">Choose an icon:</h5>
100
        <h5 style="margin-left:10px;">Choose an icon:</h5>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt (-1 / +20 lines)
Lines 12-17 Link Here
12
		widgets: ['zebra'],
12
		widgets: ['zebra'],
13
		headers: { 11: { sorter: false}}
13
		headers: { 11: { sorter: false}}
14
	}).tablesorterPager({container: $("#pagertable_categorie"),positionFixed: false,size: 20});
14
	}).tablesorterPager({container: $("#pagertable_categorie"),positionFixed: false,size: 20});
15
16
    if ( $("#branches option:selected").length < 1 ) {
17
        $("#branches option:first").attr("selected", "selected");
18
    }
15
}); </script>
19
}); </script>
16
[% INCLUDE 'calendar.inc' %]
20
[% INCLUDE 'calendar.inc' %]
17
<script type="text/javascript">
21
<script type="text/javascript">
Lines 179-185 Link Here
179
					[% IF ( type_P ) %]<option value="P" selected="selected">Professional</option>[% ELSE %]<option value="P">Professional</option>[% END %]
183
					[% IF ( type_P ) %]<option value="P" selected="selected">Professional</option>[% ELSE %]<option value="P">Professional</option>[% END %]
180
					[% IF ( type_X ) %]<option value="X" selected="selected">Statistical</option>[% ELSE %]<option value="X">Statistical</option>[% END %]
184
					[% IF ( type_X ) %]<option value="X" selected="selected">Statistical</option>[% ELSE %]<option value="X">Statistical</option>[% END %]
181
					</select>
185
					</select>
182
	</li></ol>
186
    </li>
187
    <li><label for="branches">Branches limitation: </label>
188
        <select id="branches" name="branches" multiple size="10">
189
            <option value="">All branches</option>
190
            [% FOREACH branch IN branches_loop %]
191
              [% IF ( branch.selected ) %]
192
                <option selected="selected" value="[% branch.branchcode %]">[% branch.branchname %]</option>
193
              [% ELSE %]
194
                <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
195
              [% END %]
196
            [% END %]
197
        </select>
198
        <span>Select All if this category type must to be displayed all the time. Otherwise select librairies you want to associate with this value.
199
        </span>
200
    </li>
201
    </ol>
183
</fieldset>
202
</fieldset>
184
203
185
    [% IF ( EnhancedMessagingPreferences ) %]
204
    [% IF ( EnhancedMessagingPreferences ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt (+19 lines)
Lines 15-20 Link Here
15
15
16
<script type="text/javascript">
16
<script type="text/javascript">
17
//<![CDATA[
17
//<![CDATA[
18
$(document).ready(function() {
19
    if ( $("#branches option:selected").length < 1 ) {
20
        $("#branches option:first").attr("selected", "selected");
21
    }
22
} );
18
23
19
function DoCancel(f) {
24
function DoCancel(f) {
20
  f.op.value='';
25
  f.op.value='';
Lines 186-191 function CheckAttributeTypeForm(f) { Link Here
186
                  to be chosen from the authorized value list.  However, an authorized value list is not 
191
                  to be chosen from the authorized value list.  However, an authorized value list is not 
187
                  enforced during batch patron import.</span>
192
                  enforced during batch patron import.</span>
188
        </li>
193
        </li>
194
        <li><label for="branches">Branches limitation: </label>
195
            <select id="branches" name="branches" multiple size="10">
196
                <option value="">All branches</option>
197
                [% FOREACH branch IN branches_loop %]
198
                  [% IF ( branch.selected ) %]
199
                    <option selected="selected" value="[% branch.branchcode %]">[% branch.branchname %]</option>
200
                  [% ELSE %]
201
                    <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
202
                  [% END %]
203
                [% END %]
204
            </select>
205
            <span>Select All if this attribute type must to be displayed all the time. Otherwise select librairies you want to associate with this value.
206
            </span>
207
        </li>
189
        <li>
208
        <li>
190
            <label for="category">Category: </label>
209
            <label for="category">Category: </label>
191
            <select name="category_code" id="category">
210
            <select name="category_code" id="category">
(-)a/members/member.pl (-2 / +2 lines)
Lines 135-142 foreach my $borrower(@$results[$from..$to-1]){ Link Here
135
135
136
  my %row = (
136
  my %row = (
137
    count => $index++,
137
    count => $index++,
138
	%$borrower,
138
    %$borrower,
139
	%{$categories_dislay{$$borrower{categorycode}}},
139
    (defined $categories_dislay{ $borrower->{categorycode} }?   %{ $categories_dislay{ $borrower->{categorycode} } }:()),
140
    overdues => $od,
140
    overdues => $od,
141
    issues => $issue,
141
    issues => $issue,
142
    odissue => "$od/$issue",
142
    odissue => "$od/$issue",
(-)a/tools/batchMod.pl (-2 / +10 lines)
Lines 259-265 if ($op eq "show"){ Link Here
259
# now, build the item form for entering a new item
259
# now, build the item form for entering a new item
260
my @loop_data =();
260
my @loop_data =();
261
my $i=0;
261
my $i=0;
262
my $authorised_values_sth = $dbh->prepare("SELECT authorised_value,lib FROM authorised_values WHERE category=? ORDER BY lib");
262
my $query = qq{
263
    SELECT authorised_value, lib FROM authorised_values
264
    JOIN authorised_values_branches ON ( id = av_id AND ( branchcode = ? OR branchcode IS NULL ) )
265
    WHERE category = ?
266
    GROUP BY lib ORDER BY lib, lib_opac
267
};
268
my $authorised_values_sth = $dbh->prepare( $query );
263
269
264
my $branches = GetBranchesLoop();  # build once ahead of time, instead of multiple times later.
270
my $branches = GetBranchesLoop();  # build once ahead of time, instead of multiple times later.
265
271
Lines 352-358 foreach my $tag (sort keys %{$tagslib}) { Link Here
352
      }
358
      }
353
      else {
359
      else {
354
          push @authorised_values, ""; # unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
360
          push @authorised_values, ""; # unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
355
          $authorised_values_sth->execute( $tagslib->{$tag}->{$subfield}->{authorised_value} );
361
          $authorised_values_sth->execute( C4::Context->userenv ? C4::Context->userenv->{"branch"} : "", $tagslib->{$tag}->{$subfield}->{authorised_value} );
356
          while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) {
362
          while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) {
357
              push @authorised_values, $value;
363
              push @authorised_values, $value;
358
              $authorised_lib{$value} = $lib;
364
              $authorised_lib{$value} = $lib;
Lines 420-425 foreach my $tag (sort keys %{$tagslib}) { Link Here
420
    $i++
426
    $i++
421
  }
427
  }
422
} # -- End foreach tag
428
} # -- End foreach tag
429
$authorised_values_sth->finish;
430
423
431
424
432
425
    # what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit.
433
    # what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit.
(-)a/tools/import_borrowers.pl (-2 / +1 lines)
Lines 304-310 if ( $uploadborrowers && length($uploadborrowers) > 0 ) { Link Here
304
} else {
304
} else {
305
    if ($extended) {
305
    if ($extended) {
306
        my @matchpoints = ();
306
        my @matchpoints = ();
307
        my @attr_types = C4::Members::AttributeTypes::GetAttributeTypes();
307
        my @attr_types = C4::Members::AttributeTypes::GetAttributeTypes(undef, 1);
308
        foreach my $type (@attr_types) {
308
        foreach my $type (@attr_types) {
309
            my $attr_type = C4::Members::AttributeTypes->fetch($type->{code});
309
            my $attr_type = C4::Members::AttributeTypes->fetch($type->{code});
310
            if ($attr_type->unique_id()) {
310
            if ($attr_type->unique_id()) {
311
- 

Return to bug 7919