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 74-86 C<description>. Link Here
74
=cut
74
=cut
75
75
76
sub all {
76
sub all {
77
    my $class = shift;
77
    my ( $class ) = @_;
78
    map {
78
    my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
79
        utf8::encode($_->{description});
79
    my $dbh = C4::Context->dbh;
80
        $class->new($_);
80
    # The categories table is small enough for
81
    } @{C4::Context->dbh->selectall_arrayref(
81
    # `SELECT *` to be harmless.
82
        "SELECT * FROM categories ORDER BY description", { Slice => {} }
82
    my $query = "SELECT * FROM categories";
83
    )};
83
    $query .= qq{
84
        LEFT JOIN categories_branches ON categories_branches.categorycode = categories.categorycode
85
        WHERE categories_branches.branchcode = ? OR categories_branches.branchcode IS NULL
86
    } if $branch_limit;
87
    $query .= " ORDER BY description";
88
    return map { $class->new($_) } @{
89
        $dbh->selectall_arrayref(
90
            $query,
91
            { Slice => {} },
92
            $branch_limit ? $branch_limit : ()
93
        )
94
    };
84
}
95
}
85
96
86
97
(-)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 (-12 / +34 lines)
Lines 1013-1040 C<$opac> If set to a true value, displays OPAC descriptions rather than normal o Link Here
1013
=cut
1013
=cut
1014
1014
1015
sub GetAuthorisedValues {
1015
sub GetAuthorisedValues {
1016
    my ($category,$selected,$opac) = @_;
1016
    my ( $category, $selected, $opac ) = @_;
1017
    my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
1017
    my @results;
1018
    my @results;
1018
    my $dbh      = C4::Context->dbh;
1019
    my $dbh      = C4::Context->dbh;
1019
    my $query    = "SELECT * FROM authorised_values";
1020
    my $query = qq{
1020
    $query .= " WHERE category = '" . $category . "'" if $category;
1021
        SELECT *
1021
    $query .= " ORDER BY category, lib, lib_opac";
1022
        FROM authorised_values
1023
    };
1024
    $query .= qq{
1025
          LEFT JOIN authorised_values_branches ON ( id = av_id )
1026
    } if $branch_limit;
1027
    my @where_strings;
1028
    my @where_args;
1029
    if($category) {
1030
        push @where_strings, "category = ?";
1031
        push @where_args, $category;
1032
    }
1033
    if($branch_limit) {
1034
        push @where_strings, "( branchcode = ? OR branchcode IS NULL )";
1035
        push @where_args, $branch_limit;
1036
    }
1037
    if(@where_strings > 0) {
1038
        $query .= " WHERE " . join(" AND ", @where_strings);
1039
    }
1040
    $query .= " GROUP BY lib ORDER BY category, lib, lib_opac";
1041
1022
    my $sth = $dbh->prepare($query);
1042
    my $sth = $dbh->prepare($query);
1023
    $sth->execute;
1043
1044
    $sth->execute( @where_args );
1024
    while (my $data=$sth->fetchrow_hashref) {
1045
    while (my $data=$sth->fetchrow_hashref) {
1025
        if ( (defined($selected)) && ($selected eq $data->{'authorised_value'}) ) {
1046
        if ( defined $selected and $selected eq $data->{authorised_value} ) {
1026
            $data->{'selected'} = 1;
1047
            $data->{selected} = 1;
1027
        }
1048
        }
1028
        else {
1049
        else {
1029
            $data->{'selected'} = 0;
1050
            $data->{selected} = 0;
1030
        }
1051
        }
1031
        if ($opac && $data->{'lib_opac'}) {
1052
1032
            $data->{'lib'} = $data->{'lib_opac'};
1053
        if ($opac && $data->{lib_opac}) {
1054
            $data->{lib} = $data->{lib_opac};
1033
        }
1055
        }
1034
        push @results, $data;
1056
        push @results, $data;
1035
    }
1057
    }
1036
    #my $data = $sth->fetchall_arrayref({});
1058
    $sth->finish;
1037
    return \@results; #$data;
1059
    return \@results;
1038
}
1060
}
1039
1061
1040
=head2 GetAuthorisedValueCategories
1062
=head2 GetAuthorisedValueCategories
(-)a/C4/Members.pm (-21 / +42 lines)
Lines 1382-1401 to category descriptions. Link Here
1382
1382
1383
#'
1383
#'
1384
sub GetborCatFromCatType {
1384
sub GetborCatFromCatType {
1385
    my ( $category_type, $action ) = @_;
1385
    my ( $category_type, $action, $no_branch_limit ) = @_;
1386
	# FIXME - This API  seems both limited and dangerous. 
1386
1387
    my $branch_limit = $no_branch_limit
1388
        ? 0
1389
        : C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
1390
1391
    # FIXME - This API  seems both limited and dangerous. 
1387
    my $dbh     = C4::Context->dbh;
1392
    my $dbh     = C4::Context->dbh;
1388
    my $request = qq|   SELECT categorycode,description 
1393
1389
            FROM categories 
1394
    my $request = qq{
1390
            $action
1395
        SELECT categories.categorycode, categories.description
1391
            ORDER BY categorycode|;
1396
        FROM categories
1392
    my $sth = $dbh->prepare($request);
1397
    };
1393
	if ($action) {
1398
    $request .= qq{
1394
        $sth->execute($category_type);
1399
        LEFT JOIN categories_branches ON categories.categorycode = categories_branches.categorycode
1395
    }
1400
    } if $branch_limit;
1396
    else {
1401
    if($action) {
1397
        $sth->execute();
1402
        $request .= " $action ";
1403
        $request .= " AND (branchcode = ? OR branchcode IS NULL) GROUP BY description" if $branch_limit;
1404
    } else {
1405
        $request .= " WHERE branchcode = ? OR branchcode IS NULL GROUP BY description" if $branch_limit;
1398
    }
1406
    }
1407
    $request .= " ORDER BY categorycode";
1408
1409
    my $sth = $dbh->prepare($request);
1410
    $sth->execute(
1411
        $action ? $category_type : (),
1412
        $branch_limit ? $branch_limit : ()
1413
    );
1399
1414
1400
    my %labels;
1415
    my %labels;
1401
    my @codes;
1416
    my @codes;
Lines 1404-1409 sub GetborCatFromCatType { Link Here
1404
        push @codes, $data->{'categorycode'};
1419
        push @codes, $data->{'categorycode'};
1405
        $labels{ $data->{'categorycode'} } = $data->{'description'};
1420
        $labels{ $data->{'categorycode'} } = $data->{'description'};
1406
    }
1421
    }
1422
    $sth->finish;
1407
    return ( \@codes, \%labels );
1423
    return ( \@codes, \%labels );
1408
}
1424
}
1409
1425
Lines 1462-1477 If no category code provided, the function returns all the categories. Link Here
1462
=cut
1478
=cut
1463
1479
1464
sub GetBorrowercategoryList {
1480
sub GetBorrowercategoryList {
1481
    my $no_branch_limit = @_ ? shift : 0;
1482
    my $branch_limit = $no_branch_limit
1483
        ? 0
1484
        : C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
1465
    my $dbh       = C4::Context->dbh;
1485
    my $dbh       = C4::Context->dbh;
1466
    my $sth       =
1486
    my $query = "SELECT * FROM categories";
1467
    $dbh->prepare(
1487
    $query .= qq{
1468
    "SELECT * 
1488
        LEFT JOIN categories_branches ON categories.categorycode = categories_branches.categorycode
1469
    FROM categories 
1489
        WHERE branchcode = ? OR branchcode IS NULL GROUP BY description
1470
    ORDER BY description"
1490
    } if $branch_limit;
1471
        );
1491
    $query .= " ORDER BY description";
1472
    $sth->execute;
1492
    my $sth = $dbh->prepare( $query );
1473
    my $data =
1493
    $sth->execute( $branch_limit ? $branch_limit : () );
1474
    $sth->fetchall_arrayref({});
1494
    my $data = $sth->fetchall_arrayref( {} );
1495
    $sth->finish;
1475
    return $data;
1496
    return $data;
1476
}    # sub getborrowercategory
1497
}    # sub getborrowercategory
1477
1498
(-)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 71-76 marked for OPAC display are returned. Link Here
71
sub GetBorrowerAttributes {
71
sub GetBorrowerAttributes {
72
    my $borrowernumber = shift;
72
    my $borrowernumber = shift;
73
    my $opac_only = @_ ? shift : 0;
73
    my $opac_only = @_ ? shift : 0;
74
    my $branch_limit = @_ ? shift : 0;
74
75
75
    my $dbh = C4::Context->dbh();
76
    my $dbh = C4::Context->dbh();
76
    my $query = "SELECT code, description, attribute, lib, password, display_checkout, category_code, class
77
    my $query = "SELECT code, description, attribute, lib, password, display_checkout, category_code, class
Lines 96-101 sub GetBorrowerAttributes { Link Here
96
            class             => $row->{'class'},
97
            class             => $row->{'class'},
97
        }
98
        }
98
    }
99
    }
100
    $sth->finish;
99
    return \@results;
101
    return \@results;
100
}
102
}
101
103
(-)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 2844-2849 CREATE TABLE `quotes` ( Link Here
2844
  PRIMARY KEY (`id`)
2844
  PRIMARY KEY (`id`)
2845
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2845
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2846
2846
2847
--
2848
-- Table structure for table categories_branches
2849
--
2850
2851
DROP TABLE IF EXISTS categories_branches;
2852
CREATE TABLE categories_branches( -- association table between categories and branches
2853
    categorycode VARCHAR(10),
2854
    branchcode VARCHAR(10),
2855
    FOREIGN KEY (categorycode) REFERENCES categories(categorycode) ON DELETE CASCADE,
2856
    FOREIGN KEY (branchcode) REFERENCES branches(branchcode) ON DELETE CASCADE
2857
) ENGINE=INNODB DEFAULT CHARSET=utf8;
2858
2859
--
2860
-- Table structure for table authorised_values_branches
2861
--
2862
2863
DROP TABLE IF EXISTS authorised_values_branches;
2864
CREATE TABLE authorised_values_branches( -- association table between authorised_values and branches
2865
    av_id INTEGER,
2866
    branchcode VARCHAR(10),
2867
    FOREIGN KEY (av_id) REFERENCES authorised_values(id) ON DELETE CASCADE,
2868
    FOREIGN KEY (branchcode) REFERENCES branches(branchcode) ON DELETE CASCADE
2869
) ENGINE=INNODB DEFAULT CHARSET=utf8;
2870
2871
2872
--
2873
-- Table structure for table borrower_attribute_types_branches
2874
--
2875
2876
DROP TABLE IF EXISTS borrower_attribute_types_branches;
2877
CREATE TABLE borrower_attribute_types_branches( -- association table between borrower_attribute_types and branches
2878
    bat_code VARCHAR(10),
2879
    b_branchcode VARCHAR(10),
2880
    FOREIGN KEY (bat_code) REFERENCES borrower_attribute_types(code) ON DELETE CASCADE,
2881
    FOREIGN KEY (b_branchcode) REFERENCES branches(branchcode) ON DELETE CASCADE
2882
) ENGINE=INNODB DEFAULT CHARSET=utf8;
2883
2884
2847
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
2885
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
2848
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
2886
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
2849
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
2887
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
(-)a/installer/data/mysql/updatedatabase.pl (+17 lines)
Lines 5308-5313 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
5308
    SetVersion ($DBversion);
5308
    SetVersion ($DBversion);
5309
}
5309
}
5310
5310
5311
5312
5313
5314
5315
5316
$DBversion = "3.07.00.XXX";
5317
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5318
    $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;});
5319
5320
    $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;});
5321
5322
    $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;});
5323
5324
    print "Upgrade to $DBversion done (Add 3 associations tables with branches)\n";
5325
    SetVersion($DBversion);
5326
}
5327
5311
=head1 FUNCTIONS
5328
=head1 FUNCTIONS
5312
5329
5313
=head2 TableExists($table)
5330
=head2 TableExists($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 265-271 if ($op eq "show"){ Link Here
265
# now, build the item form for entering a new item
265
# now, build the item form for entering a new item
266
my @loop_data =();
266
my @loop_data =();
267
my $i=0;
267
my $i=0;
268
my $authorised_values_sth = $dbh->prepare("SELECT authorised_value,lib FROM authorised_values WHERE category=? ORDER BY lib");
268
my $query = qq{
269
    SELECT authorised_value, lib FROM authorised_values
270
    JOIN authorised_values_branches ON ( id = av_id AND ( branchcode = ? OR branchcode IS NULL ) )
271
    WHERE category = ?
272
    GROUP BY lib ORDER BY lib, lib_opac
273
};
274
my $authorised_values_sth = $dbh->prepare( $query );
269
275
270
my $branches = GetBranchesLoop();  # build once ahead of time, instead of multiple times later.
276
my $branches = GetBranchesLoop();  # build once ahead of time, instead of multiple times later.
271
277
Lines 358-364 foreach my $tag (sort keys %{$tagslib}) { Link Here
358
      }
364
      }
359
      else {
365
      else {
360
          push @authorised_values, ""; # unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
366
          push @authorised_values, ""; # unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
361
          $authorised_values_sth->execute( $tagslib->{$tag}->{$subfield}->{authorised_value} );
367
          $authorised_values_sth->execute( C4::Context->userenv ? C4::Context->userenv->{"branch"} : "", $tagslib->{$tag}->{$subfield}->{authorised_value} );
362
          while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) {
368
          while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) {
363
              push @authorised_values, $value;
369
              push @authorised_values, $value;
364
              $authorised_lib{$value} = $lib;
370
              $authorised_lib{$value} = $lib;
Lines 426-431 foreach my $tag (sort keys %{$tagslib}) { Link Here
426
    $i++
432
    $i++
427
  }
433
  }
428
} # -- End foreach tag
434
} # -- End foreach tag
435
$authorised_values_sth->finish;
436
429
437
430
438
431
    # what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit.
439
    # 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