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

(-)a/C4/Budgets.pm (-5 / +18 lines)
Lines 379-390 sub GetBudgetAuthCats { Link Here
379
# -------------------------------------------------------------------
379
# -------------------------------------------------------------------
380
sub GetAuthvalueDropbox {
380
sub GetAuthvalueDropbox {
381
    my ( $authcat, $default ) = @_;
381
    my ( $authcat, $default ) = @_;
382
    my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
382
    my $dbh = C4::Context->dbh;
383
    my $dbh = C4::Context->dbh;
383
    my $sth = $dbh->prepare(
384
384
        'SELECT authorised_value,lib FROM authorised_values
385
    my $query = qq{
385
        WHERE category = ? ORDER BY lib'
386
        SELECT *
386
    );
387
        FROM authorised_values
387
    $sth->execute( $authcat );
388
    };
389
    $query .= qq{
390
          LEFT JOIN authorised_values_branches ON ( id = av_id )
391
    } if $branch_limit;
392
    $query .= qq{
393
        WHERE category = ?
394
    };
395
    $query .= " AND ( branchcode = ? OR branchcode IS NULL )" if $branch_limit;
396
    $query .= " GROUP BY lib ORDER BY category, lib, lib_opac";
397
    my $sth = $dbh->prepare($query);
398
    $sth->execute( $authcat, $branch_limit ? $branch_limit : () );
399
400
388
    my $option_list = [];
401
    my $option_list = [];
389
    my @authorised_values = ( q{} );
402
    my @authorised_values = ( q{} );
390
    while (my ($value, $lib) = $sth->fetchrow_array) {
403
    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( $name, $branch_limit ? $branch_limit : () );
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/Items.pm (-2 / +18 lines)
Lines 2602-2608 sub PrepareItemrecordDisplay { Link Here
2602
        $itemrecord = C4::Items::GetMarcItem( $bibnum, $itemnum );
2602
        $itemrecord = C4::Items::GetMarcItem( $bibnum, $itemnum );
2603
    }
2603
    }
2604
    my @loop_data;
2604
    my @loop_data;
2605
    my $authorised_values_sth = $dbh->prepare( "SELECT authorised_value,lib FROM authorised_values WHERE category=? ORDER BY lib" );
2605
2606
    my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
2607
    my $query = qq{
2608
        SELECT authorised_value,lib FROM authorised_values
2609
    };
2610
    $query .= qq{
2611
        LEFT JOIN authorised_values_branches ON ( id = av_id )
2612
    } if $branch_limit;
2613
    $query .= qq{
2614
        WHERE category = ?
2615
    };
2616
    $query .= qq{ AND ( branchcode = ? OR branchcode IS NULL )} if $branch_limit;
2617
    $query .= qq{ ORDER BY lib};
2618
    my $authorised_values_sth = $dbh->prepare( $query );
2606
    foreach my $tag ( sort keys %{$tagslib} ) {
2619
    foreach my $tag ( sort keys %{$tagslib} ) {
2607
        my $previous_tag = '';
2620
        my $previous_tag = '';
2608
        if ( $tag ne '' ) {
2621
        if ( $tag ne '' ) {
Lines 2734-2740 sub PrepareItemrecordDisplay { Link Here
2734
2747
2735
                        #---- "true" authorised value
2748
                        #---- "true" authorised value
2736
                    } else {
2749
                    } else {
2737
                        $authorised_values_sth->execute( $tagslib->{$tag}->{$subfield}->{authorised_value} );
2750
                        $authorised_values_sth->execute(
2751
                            $tagslib->{$tag}->{$subfield}->{authorised_value},
2752
                            $branch_limit ? $branch_limit : ()
2753
                        );
2738
                        push @authorised_values, ""
2754
                        push @authorised_values, ""
2739
                          unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
2755
                          unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
2740
                        while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) {
2756
                        while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) {
(-)a/C4/Koha.pm (-12 / +34 lines)
Lines 1036-1063 C<$opac> If set to a true value, displays OPAC descriptions rather than normal o Link Here
1036
=cut
1036
=cut
1037
1037
1038
sub GetAuthorisedValues {
1038
sub GetAuthorisedValues {
1039
    my ($category,$selected,$opac) = @_;
1039
    my ( $category, $selected, $opac ) = @_;
1040
    my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
1040
    my @results;
1041
    my @results;
1041
    my $dbh      = C4::Context->dbh;
1042
    my $dbh      = C4::Context->dbh;
1042
    my $query    = "SELECT * FROM authorised_values";
1043
    my $query = qq{
1043
    $query .= " WHERE category = '" . $category . "'" if $category;
1044
        SELECT *
1044
    $query .= " ORDER BY category, lib, lib_opac";
1045
        FROM authorised_values
1046
    };
1047
    $query .= qq{
1048
          LEFT JOIN authorised_values_branches ON ( id = av_id )
1049
    } if $branch_limit;
1050
    my @where_strings;
1051
    my @where_args;
1052
    if($category) {
1053
        push @where_strings, "category = ?";
1054
        push @where_args, $category;
1055
    }
1056
    if($branch_limit) {
1057
        push @where_strings, "( branchcode = ? OR branchcode IS NULL )";
1058
        push @where_args, $branch_limit;
1059
    }
1060
    if(@where_strings > 0) {
1061
        $query .= " WHERE " . join(" AND ", @where_strings);
1062
    }
1063
    $query .= " GROUP BY lib ORDER BY category, lib, lib_opac";
1064
1045
    my $sth = $dbh->prepare($query);
1065
    my $sth = $dbh->prepare($query);
1046
    $sth->execute;
1066
1067
    $sth->execute( @where_args );
1047
    while (my $data=$sth->fetchrow_hashref) {
1068
    while (my $data=$sth->fetchrow_hashref) {
1048
        if ( (defined($selected)) && ($selected eq $data->{'authorised_value'}) ) {
1069
        if ( defined $selected and $selected eq $data->{authorised_value} ) {
1049
            $data->{'selected'} = 1;
1070
            $data->{selected} = 1;
1050
        }
1071
        }
1051
        else {
1072
        else {
1052
            $data->{'selected'} = 0;
1073
            $data->{selected} = 0;
1053
        }
1074
        }
1054
        if ($opac && $data->{'lib_opac'}) {
1075
1055
            $data->{'lib'} = $data->{'lib_opac'};
1076
        if ($opac && $data->{lib_opac}) {
1077
            $data->{lib} = $data->{lib_opac};
1056
        }
1078
        }
1057
        push @results, $data;
1079
        push @results, $data;
1058
    }
1080
    }
1059
    #my $data = $sth->fetchall_arrayref({});
1081
    $sth->finish;
1060
    return \@results; #$data;
1082
    return \@results;
1061
}
1083
}
1062
1084
1063
=head2 GetAuthorisedValueCategories
1085
=head2 GetAuthorisedValueCategories
(-)a/C4/Members.pm (-21 / +42 lines)
Lines 1374-1393 to category descriptions. Link Here
1374
1374
1375
#'
1375
#'
1376
sub GetborCatFromCatType {
1376
sub GetborCatFromCatType {
1377
    my ( $category_type, $action ) = @_;
1377
    my ( $category_type, $action, $no_branch_limit ) = @_;
1378
	# FIXME - This API  seems both limited and dangerous. 
1378
1379
    my $branch_limit = $no_branch_limit
1380
        ? 0
1381
        : C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
1382
1383
    # FIXME - This API  seems both limited and dangerous.
1379
    my $dbh     = C4::Context->dbh;
1384
    my $dbh     = C4::Context->dbh;
1380
    my $request = qq|   SELECT categorycode,description 
1385
1381
            FROM categories 
1386
    my $request = qq{
1382
            $action
1387
        SELECT categories.categorycode, categories.description
1383
            ORDER BY categorycode|;
1388
        FROM categories
1384
    my $sth = $dbh->prepare($request);
1389
    };
1385
	if ($action) {
1390
    $request .= qq{
1386
        $sth->execute($category_type);
1391
        LEFT JOIN categories_branches ON categories.categorycode = categories_branches.categorycode
1387
    }
1392
    } if $branch_limit;
1388
    else {
1393
    if($action) {
1389
        $sth->execute();
1394
        $request .= " $action ";
1395
        $request .= " AND (branchcode = ? OR branchcode IS NULL) GROUP BY description" if $branch_limit;
1396
    } else {
1397
        $request .= " WHERE branchcode = ? OR branchcode IS NULL GROUP BY description" if $branch_limit;
1390
    }
1398
    }
1399
    $request .= " ORDER BY categorycode";
1400
1401
    my $sth = $dbh->prepare($request);
1402
    $sth->execute(
1403
        $action ? $category_type : (),
1404
        $branch_limit ? $branch_limit : ()
1405
    );
1391
1406
1392
    my %labels;
1407
    my %labels;
1393
    my @codes;
1408
    my @codes;
Lines 1396-1401 sub GetborCatFromCatType { Link Here
1396
        push @codes, $data->{'categorycode'};
1411
        push @codes, $data->{'categorycode'};
1397
        $labels{ $data->{'categorycode'} } = $data->{'description'};
1412
        $labels{ $data->{'categorycode'} } = $data->{'description'};
1398
    }
1413
    }
1414
    $sth->finish;
1399
    return ( \@codes, \%labels );
1415
    return ( \@codes, \%labels );
1400
}
1416
}
1401
1417
Lines 1454-1469 If no category code provided, the function returns all the categories. Link Here
1454
=cut
1470
=cut
1455
1471
1456
sub GetBorrowercategoryList {
1472
sub GetBorrowercategoryList {
1473
    my $no_branch_limit = @_ ? shift : 0;
1474
    my $branch_limit = $no_branch_limit
1475
        ? 0
1476
        : C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
1457
    my $dbh       = C4::Context->dbh;
1477
    my $dbh       = C4::Context->dbh;
1458
    my $sth       =
1478
    my $query = "SELECT * FROM categories";
1459
    $dbh->prepare(
1479
    $query .= qq{
1460
    "SELECT * 
1480
        LEFT JOIN categories_branches ON categories.categorycode = categories_branches.categorycode
1461
    FROM categories 
1481
        WHERE branchcode = ? OR branchcode IS NULL GROUP BY description
1462
    ORDER BY description"
1482
    } if $branch_limit;
1463
        );
1483
    $query .= " ORDER BY description";
1464
    $sth->execute;
1484
    my $sth = $dbh->prepare( $query );
1465
    my $data =
1485
    $sth->execute( $branch_limit ? $branch_limit : () );
1466
    $sth->fetchall_arrayref({});
1486
    my $data = $sth->fetchall_arrayref( {} );
1487
    $sth->finish;
1467
    return $data;
1488
    return $data;
1468
}    # sub getborrowercategory
1489
}    # sub getborrowercategory
1469
1490
(-)a/C4/Members/AttributeTypes.pm (-20 / +54 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
my $branches = $attr_type->branches();
291
$attr_type->branches($branches);
292
293
Accessor.
294
295
=cut
296
297
sub branches {
298
    my $self = shift;
299
    @_ ? $self->{branches} = shift : $self->{branches};
300
}
301
253
=head2 repeatable
302
=head2 repeatable
254
303
255
  my $repeatable = $attr_type->repeatable();
304
  my $repeatable = $attr_type->repeatable();
Lines 324-336 sub staff_searchable { Link Here
324
373
325
=head2 display_checkout
374
=head2 display_checkout
326
375
327
=over 4
328
329
my $display_checkout = $attr_type->display_checkout();
376
my $display_checkout = $attr_type->display_checkout();
330
$attr_type->display_checkout($display_checkout);
377
$attr_type->display_checkout($display_checkout);
331
378
332
=back
333
334
Accessor.  The C<$display_checkout> argument
379
Accessor.  The C<$display_checkout> argument
335
is interpreted as a Perl boolean.
380
is interpreted as a Perl boolean.
336
381
Lines 357-369 sub authorised_value_category { Link Here
357
402
358
=head2 category_code
403
=head2 category_code
359
404
360
=over 4
361
362
my $category_code = $attr_type->category_code();
405
my $category_code = $attr_type->category_code();
363
$attr_type->category_code($category_code);
406
$attr_type->category_code($category_code);
364
407
365
=back
366
367
Accessor.
408
Accessor.
368
409
369
=cut
410
=cut
Lines 375-387 sub category_code { Link Here
375
416
376
=head2 category_description
417
=head2 category_description
377
418
378
=over 4
379
380
my $category_description = $attr_type->category_description();
419
my $category_description = $attr_type->category_description();
381
$attr_type->category_description($category_description);
420
$attr_type->category_description($category_description);
382
421
383
=back
384
385
Accessor.
422
Accessor.
386
423
387
=cut
424
=cut
Lines 393-405 sub category_description { Link Here
393
430
394
=head2 class
431
=head2 class
395
432
396
=over 4
397
398
my $class = $attr_type->class();
433
my $class = $attr_type->class();
399
$attr_type->class($class);
434
$attr_type->class($class);
400
435
401
=back
402
403
Accessor.
436
Accessor.
404
437
405
=cut
438
=cut
Lines 432-437 sub delete { Link Here
432
    my $dbh = C4::Context->dbh;
465
    my $dbh = C4::Context->dbh;
433
    my $sth = $dbh->prepare_cached("DELETE FROM borrower_attribute_types WHERE code = ?");
466
    my $sth = $dbh->prepare_cached("DELETE FROM borrower_attribute_types WHERE code = ?");
434
    $sth->execute($code);
467
    $sth->execute($code);
468
    $sth->finish;
435
}
469
}
436
470
437
=head2 num_patrons
471
=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 95-100 sub GetBorrowerAttributes { Link Here
95
            class             => $row->{'class'},
96
            class             => $row->{'class'},
96
        }
97
        }
97
    }
98
    }
99
    $sth->finish;
98
    return \@results;
100
    return \@results;
99
}
101
}
100
102
(-)a/admin/authorised_values.pl (-4 / +62 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
Lines 219-225 sub default_form { Link Here
219
    my $count = scalar(@$results);
269
    my $count = scalar(@$results);
220
	my @loop_data = ();
270
	my @loop_data = ();
221
	# builds value list
271
	# builds value list
272
    my $dbh = C4::Context->dbh;
273
    $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 = ?");
222
	for (my $i=0; $i < $count; $i++){
274
	for (my $i=0; $i < $count; $i++){
275
        $sth->execute( $results->[$i]{id} );
276
        my @selected_branches;
277
        while ( my $branch = $sth->fetchrow_hashref ) {
278
            push @selected_branches, $branch;
279
        }
223
		my %row_data;  # get a fresh hash for the row data
280
		my %row_data;  # get a fresh hash for the row data
224
		$row_data{category}              = $results->[$i]{'category'};
281
		$row_data{category}              = $results->[$i]{'category'};
225
		$row_data{authorised_value}      = $results->[$i]{'authorised_value'};
282
		$row_data{authorised_value}      = $results->[$i]{'authorised_value'};
Lines 228-233 sub default_form { Link Here
228
		$row_data{imageurl}              = getitemtypeimagelocation( 'intranet', $results->[$i]{'imageurl'} );
285
		$row_data{imageurl}              = getitemtypeimagelocation( 'intranet', $results->[$i]{'imageurl'} );
229
		$row_data{edit}                  = "$script_name?op=add_form&amp;id=".$results->[$i]{'id'}."&amp;offset=$offset";
286
		$row_data{edit}                  = "$script_name?op=add_form&amp;id=".$results->[$i]{'id'}."&amp;offset=$offset";
230
		$row_data{delete}                = "$script_name?op=delete_confirm&amp;searchfield=$searchfield&amp;id=".$results->[$i]{'id'}."&amp;offset=$offset";
287
		$row_data{delete}                = "$script_name?op=delete_confirm&amp;searchfield=$searchfield&amp;id=".$results->[$i]{'id'}."&amp;offset=$offset";
288
        $row_data{branches}              = \@selected_branches;
231
		push(@loop_data, \%row_data);
289
		push(@loop_data, \%row_data);
232
	}
290
	}
233
291
(-)a/admin/categorie.pl (-7 / +51 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 115-120 if ($op eq 'add_form') { Link Here
115
                SMSSendDriver => C4::Context->preference("SMSSendDriver"),
134
                SMSSendDriver => C4::Context->preference("SMSSendDriver"),
116
                TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"),
135
                TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"),
117
				"type_".$data->{'category_type'} => 1,
136
				"type_".$data->{'category_type'} => 1,
137
                branches_loop           => \@branches_loop,
118
				);
138
				);
119
    if (C4::Context->preference('EnhancedMessagingPreferences')) {
139
    if (C4::Context->preference('EnhancedMessagingPreferences')) {
120
        C4::Form::MessagingPreferences::set_form_values({ categorycode => $categorycode } , $template);
140
        C4::Form::MessagingPreferences::set_form_values({ categorycode => $categorycode } , $template);
Lines 133-138 if ($op eq 'add_form') { Link Here
133
	if ($is_a_modif) {
153
	if ($is_a_modif) {
134
            my $sth=$dbh->prepare("UPDATE categories SET description=?,enrolmentperiod=?, enrolmentperioddate=?,upperagelimit=?,dateofbirthrequired=?,enrolmentfee=?,reservefee=?,hidelostitems=?,overduenoticerequired=?,category_type=? WHERE categorycode=?");
154
            my $sth=$dbh->prepare("UPDATE categories SET description=?,enrolmentperiod=?, enrolmentperioddate=?,upperagelimit=?,dateofbirthrequired=?,enrolmentfee=?,reservefee=?,hidelostitems=?,overduenoticerequired=?,category_type=? WHERE categorycode=?");
135
            $sth->execute(map { $input->param($_) } ('description','enrolmentperiod','enrolmentperioddate','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','hidelostitems','overduenoticerequired','category_type','categorycode'));
155
            $sth->execute(map { $input->param($_) } ('description','enrolmentperiod','enrolmentperioddate','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','hidelostitems','overduenoticerequired','category_type','categorycode'));
156
            my @branches = $input->param("branches");
157
            if ( @branches ) {
158
                $sth = $dbh->prepare("DELETE FROM categories_branches WHERE categorycode = ?");
159
                $sth->execute( $input->param( "categorycode" ) );
160
                $sth = $dbh->prepare(
161
                    "INSERT INTO categories_branches
162
                                ( categorycode, branchcode )
163
                                VALUES ( ?, ? )"
164
                );
165
                for my $branchcode ( @branches ) {
166
                    next if not $branchcode;
167
                    $sth->bind_param( 1, $input->param( "categorycode" ) );
168
                    $sth->bind_param( 2, $branchcode );
169
                    $sth->execute;
170
                }
171
            }
136
            $sth->finish;
172
            $sth->finish;
137
        } else {
173
        } else {
138
            my $sth=$dbh->prepare("INSERT INTO categories  (categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,reservefee,hidelostitems,overduenoticerequired,category_type) values (?,?,?,?,?,?,?,?,?,?,?)");
174
            my $sth=$dbh->prepare("INSERT INTO categories  (categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,reservefee,hidelostitems,overduenoticerequired,category_type) values (?,?,?,?,?,?,?,?,?,?,?)");
Lines 197-203 if ($op eq 'add_form') { Link Here
197
	$template->param(else => 1);
233
	$template->param(else => 1);
198
	my @loop;
234
	my @loop;
199
	my ($count,$results)=StringSearch($searchfield,'web');
235
	my ($count,$results)=StringSearch($searchfield,'web');
236
    my $dbh = C4::Context->dbh;
237
    my $sth = $dbh->prepare("SELECT b.branchcode, b.branchname FROM categories_branches AS cb, branches AS b WHERE cb.branchcode = b.branchcode AND cb.categorycode = ?");
200
	for (my $i=0; $i < $count; $i++){
238
	for (my $i=0; $i < $count; $i++){
239
        $sth->execute( $results->[$i]{'categorycode'} );
240
        my @selected_branches;
241
        while ( my $branch = $sth->fetchrow_hashref ) {
242
            push @selected_branches, $branch;
243
        }
201
		my %row = (
244
		my %row = (
202
		        categorycode            => $results->[$i]{'categorycode'},
245
		        categorycode            => $results->[$i]{'categorycode'},
203
				description             => $results->[$i]{'description'},
246
				description             => $results->[$i]{'description'},
Lines 211-217 if ($op eq 'add_form') { Link Here
211
				reservefee              => sprintf("%.2f",$results->[$i]{'reservefee'}),
254
				reservefee              => sprintf("%.2f",$results->[$i]{'reservefee'}),
212
                                hidelostitems           => $results->[$i]{'hidelostitems'},
255
                                hidelostitems           => $results->[$i]{'hidelostitems'},
213
				category_type           => $results->[$i]{'category_type'},
256
				category_type           => $results->[$i]{'category_type'},
214
				"type_".$results->[$i]{'category_type'} => 1);
257
				"type_".$results->[$i]{'category_type'} => 1,
258
                branches                => \@selected_branches,
259
        );
215
        if (C4::Context->preference('EnhancedMessagingPreferences')) {
260
        if (C4::Context->preference('EnhancedMessagingPreferences')) {
216
            my $brief_prefs = _get_brief_messaging_prefs($results->[$i]{'categorycode'});
261
            my $brief_prefs = _get_brief_messaging_prefs($results->[$i]{'categorycode'});
217
            $row{messaging_prefs} = $brief_prefs if @$brief_prefs;
262
            $row{messaging_prefs} = $brief_prefs if @$brief_prefs;
Lines 220-227 if ($op eq 'add_form') { Link Here
220
	}
265
	}
221
	$template->param(loop => \@loop);
266
	$template->param(loop => \@loop);
222
	# check that I (institution) and C (child) exists. otherwise => warning to the user
267
	# check that I (institution) and C (child) exists. otherwise => warning to the user
223
	my $dbh = C4::Context->dbh;
268
	$sth=$dbh->prepare("select category_type from categories where category_type='C'");
224
	my $sth=$dbh->prepare("select category_type from categories where category_type='C'");
225
	$sth->execute;
269
	$sth->execute;
226
	my ($categoryChild) = $sth->fetchrow;
270
	my ($categoryChild) = $sth->fetchrow;
227
	$template->param(categoryChild => $categoryChild);
271
	$template->param(categoryChild => $categoryChild);
(-)a/admin/patron-attr-types.pl (-6 / +38 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-279 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;
267
    for my $class (@classes) {
295
    for my $class (@classes) {
268
        my @items;
296
        my ( @items, $branches );
269
        for my $attr (@attr_types) {
297
        for my $attr (@attr_types) {
270
            push @items, $attr if $attr->{class} eq $class
298
            next if $attr->{class} ne $class;
299
            my $attr_type = C4::Members::AttributeTypes->fetch($attr->{code});
300
            $attr->{branches} = $attr_type->branches;
301
            push @items, $attr;
271
        }
302
        }
272
        my $lib = GetAuthorisedValueByCode( 'PA_CLASS', $class ) || $class;
303
        my $lib = GetAuthorisedValueByCode( 'PA_CLASS', $class ) || $class;
273
        push @attributes_loop, {
304
        push @attributes_loop, {
274
            class => $class,
305
            class => $class,
275
            items => \@items,
306
            items => \@items,
276
            lib   => $lib,
307
            lib   => $lib,
308
            branches => $branches,
277
        };
309
        };
278
    }
310
    }
279
    $template->param(available_attribute_types => \@attributes_loop);
311
    $template->param(available_attribute_types => \@attributes_loop);
(-)a/cataloguing/addbiblio.pl (-7 / +15 lines)
Lines 219-226 sub build_authorized_values_list { Link Here
219
        $value = $default_source unless $value;
219
        $value = $default_source unless $value;
220
    }
220
    }
221
    else {
221
    else {
222
        my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
222
        $authorised_values_sth->execute(
223
        $authorised_values_sth->execute(
223
            $tagslib->{$tag}->{$subfield}->{authorised_value} );
224
            $tagslib->{$tag}->{$subfield}->{authorised_value},
225
            $branch_limit ? $branch_limit : (),
226
        );
224
227
225
        push @authorised_values, ""
228
        push @authorised_values, ""
226
          unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
229
          unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
Lines 230-235 sub build_authorized_values_list { Link Here
230
            $authorised_lib{$value} = $lib;
233
            $authorised_lib{$value} = $lib;
231
        }
234
        }
232
    }
235
    }
236
    $authorised_values_sth->finish;
233
    return CGI::scrolling_list(
237
    return CGI::scrolling_list(
234
        -name     => "tag_".$tag."_subfield_".$subfield."_".$index_tag."_".$index_subfield,
238
        -name     => "tag_".$tag."_subfield_".$subfield."_".$index_tag."_".$index_subfield,
235
        -values   => \@authorised_values,
239
        -values   => \@authorised_values,
Lines 508-519 sub build_tabs { Link Here
508
    my @loop_data = ();
512
    my @loop_data = ();
509
    my $tag;
513
    my $tag;
510
514
511
    my $authorised_values_sth = $dbh->prepare(
515
    my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
512
        "select authorised_value,lib
516
    my $query = "SELECT authorised_value, lib
513
        from authorised_values
517
                FROM authorised_values";
514
        where category=? order by lib"
518
    $query .= qq{ LEFT JOIN authorised_values_branches ON ( id = av_id )} if $branch_limit;
515
    );
519
    $query .= " WHERE category = ?";
516
    
520
    $query .= " AND ( branchcode = ? OR branchcode IS NULL )" if $branch_limit;
521
    $query .= " GROUP BY lib ORDER BY lib, lib_opac";
522
    my $authorised_values_sth = $dbh->prepare( $query );
523
517
    # in this array, we will push all the 10 tabs
524
    # in this array, we will push all the 10 tabs
518
    # to avoid having 10 tabs in the template : they will all be in the same BIG_LOOP
525
    # to avoid having 10 tabs in the template : they will all be in the same BIG_LOOP
519
    my @BIG_LOOP;
526
    my @BIG_LOOP;
Lines 698-703 sub build_tabs { Link Here
698
            };
705
            };
699
        }
706
        }
700
    }
707
    }
708
    $authorised_values_sth->finish;
701
    $template->param( BIG_LOOP => \@BIG_LOOP );
709
    $template->param( BIG_LOOP => \@BIG_LOOP );
702
}
710
}
703
711
(-)a/cataloguing/additem.pl (-7 / +6 lines)
Lines 107-114 sub generate_subfield_form { Link Here
107
  
107
  
108
  my $frameworkcode = &GetFrameworkCode($biblionumber);
108
  my $frameworkcode = &GetFrameworkCode($biblionumber);
109
        my %subfield_data;
109
        my %subfield_data;
110
        my $dbh = C4::Context->dbh;        
110
        my $dbh = C4::Context->dbh;
111
        my $authorised_values_sth = $dbh->prepare("SELECT authorised_value,lib FROM authorised_values WHERE category=? ORDER BY lib");
112
        
111
        
113
        my $index_subfield = int(rand(1000000)); 
112
        my $index_subfield = int(rand(1000000)); 
114
        if ($subfieldtag eq '@'){
113
        if ($subfieldtag eq '@'){
Lines 203-213 sub generate_subfield_form { Link Here
203
                  #---- "true" authorised value
202
                  #---- "true" authorised value
204
            }
203
            }
205
            else {
204
            else {
206
                  push @authorised_values, "" unless ( $subfieldlib->{mandatory} );
205
                  push @authorised_values, qq{} unless ( $subfieldlib->{mandatory} );
207
                  $authorised_values_sth->execute( $subfieldlib->{authorised_value} );
206
                  my $av = GetAuthorisedValues( $subfieldlib->{authorised_value} );
208
                  while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) {
207
                  for my $r ( @$av ) {
209
                      push @authorised_values, $value;
208
                      push @authorised_values, $r->{authorised_value};
210
                      $authorised_lib{$value} = $lib;
209
                      $authorised_lib{$r->{authorised_value}} = $r->{lib};
211
                  }
210
                  }
212
            }
211
            }
213
212
(-)a/installer/data/mysql/kohastructure.sql (+38 lines)
Lines 2938-2943 CREATE TABLE `quotes` ( Link Here
2938
  PRIMARY KEY (`id`)
2938
  PRIMARY KEY (`id`)
2939
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2939
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2940
2940
2941
--
2942
-- Table structure for table categories_branches
2943
--
2944
2945
DROP TABLE IF EXISTS categories_branches;
2946
CREATE TABLE categories_branches( -- association table between categories and branches
2947
    categorycode VARCHAR(10),
2948
    branchcode VARCHAR(10),
2949
    FOREIGN KEY (categorycode) REFERENCES categories(categorycode) ON DELETE CASCADE,
2950
    FOREIGN KEY (branchcode) REFERENCES branches(branchcode) ON DELETE CASCADE
2951
) ENGINE=INNODB DEFAULT CHARSET=utf8;
2952
2953
--
2954
-- Table structure for table authorised_values_branches
2955
--
2956
2957
DROP TABLE IF EXISTS authorised_values_branches;
2958
CREATE TABLE authorised_values_branches( -- association table between authorised_values and branches
2959
    av_id INTEGER,
2960
    branchcode VARCHAR(10),
2961
    FOREIGN KEY (av_id) REFERENCES authorised_values(id) ON DELETE CASCADE,
2962
    FOREIGN KEY (branchcode) REFERENCES branches(branchcode) ON DELETE CASCADE
2963
) ENGINE=INNODB DEFAULT CHARSET=utf8;
2964
2965
2966
--
2967
-- Table structure for table borrower_attribute_types_branches
2968
--
2969
2970
DROP TABLE IF EXISTS borrower_attribute_types_branches;
2971
CREATE TABLE borrower_attribute_types_branches( -- association table between borrower_attribute_types and branches
2972
    bat_code VARCHAR(10),
2973
    b_branchcode VARCHAR(10),
2974
    FOREIGN KEY (bat_code) REFERENCES borrower_attribute_types(code) ON DELETE CASCADE,
2975
    FOREIGN KEY (b_branchcode) REFERENCES branches(branchcode) ON DELETE CASCADE
2976
) ENGINE=INNODB DEFAULT CHARSET=utf8;
2977
2978
2941
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
2979
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
2942
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
2980
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
2943
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
2981
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
(-)a/installer/data/mysql/updatedatabase.pl (+11 lines)
Lines 6080-6085 $DBversion = "3.11.00.001"; Link Here
6080
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6080
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6081
    $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('alphabet','A B C D E F G H I J K L M N O P Q R S T U V W X Y Z','Alphabet that can be expanded into browse links, e.g. on Home > Patrons',NULL,'free')");
6081
    $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('alphabet','A B C D E F G H I J K L M N O P Q R S T U V W X Y Z','Alphabet that can be expanded into browse links, e.g. on Home > Patrons',NULL,'free')");
6082
    print "Upgrade to $DBversion done (Bug 2832 - Add alphabet syspref)\n";
6082
    print "Upgrade to $DBversion done (Bug 2832 - Add alphabet syspref)\n";
6083
}
6084
6085
$DBversion = "3.11.00.XXX";
6086
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6087
    $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;});
6088
6089
    $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;});
6090
6091
    $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;});
6092
6093
    print "Upgrade to $DBversion done (Bug 7919: Display of values depending on the connexion library)\n";
6083
    SetVersion($DBversion);
6094
    SetVersion($DBversion);
6084
}
6095
}
6085
6096
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt (-1 / +31 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 78-83 Link Here
78
            <label for="lib_opac">Description (OPAC)</label>
81
            <label for="lib_opac">Description (OPAC)</label>
79
            <input type="text" name="lib_opac" id="lib_opac" value="[% lib_opac %]" maxlength="200" />
82
            <input type="text" name="lib_opac" id="lib_opac" value="[% lib_opac %]" maxlength="200" />
80
        </li>
83
        </li>
84
        <li><label for="branches">Branches limitation: </label>
85
            <select id="branches" name="branches" multiple size="10">
86
                <option value="">All branches</option>
87
                [% FOREACH branch IN branches_loop %]
88
                  [% IF ( branch.selected ) %]
89
                    <option selected="selected" value="[% branch.branchcode %]">[% branch.branchname %]</option>
90
                  [% ELSE %]
91
                    <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
92
                  [% END %]
93
                [% END %]
94
            </select>
95
            <span>Select All if this authorised value must to be displayed all the time. Otherwise select librairies you want to associate with this value.
96
            </span>
97
        </li>
98
81
		</ol>
99
		</ol>
82
        <div id="icons" class="toptabs" style="clear:both">
100
        <div id="icons" class="toptabs" style="clear:both">
83
        <h5 style="margin-left:10px;">Choose an icon:</h5>
101
        <h5 style="margin-left:10px;">Choose an icon:</h5>
Lines 231-236 Link Here
231
	<th>Description</th>
249
	<th>Description</th>
232
	<th>Description (OPAC)</th>
250
	<th>Description (OPAC)</th>
233
	<th>Icon</th>
251
	<th>Icon</th>
252
    <th>Branches limitations</th>
234
	<th>Edit</th>
253
	<th>Edit</th>
235
	<th>Delete</th>
254
	<th>Delete</th>
236
	</tr>
255
	</tr>
Lines 245-250 Link Here
245
	<td>[% loo.lib %]</td>
264
	<td>[% loo.lib %]</td>
246
	<td>[% loo.lib_opac %]</td>
265
	<td>[% loo.lib_opac %]</td>
247
	<td>[% IF ( loo.imageurl ) %]<img src="[% loo.imageurl %]" alt=""/>[% ELSE %]&nbsp;[% END %]</td>
266
	<td>[% IF ( loo.imageurl ) %]<img src="[% loo.imageurl %]" alt=""/>[% ELSE %]&nbsp;[% END %]</td>
267
    <td>
268
        [% IF loo.branches.size > 0 %]
269
            [% branches_str = "" %]
270
            [% FOREACH branch IN loo.branches %]
271
                [% branches_str = branches_str _ " " _ branch.branchname _ "(" _ branch.branchcode _ ")" %]
272
            [% END %]
273
            <span href="#" title="[% branches_str %]">[% loo.branches.size %] branches limitations</span>
274
        [% ELSE %]
275
            No limitation
276
        [% END %]
277
    </td>
248
	<td><a href="[% loo.edit %]">Edit</a></td>
278
	<td><a href="[% loo.edit %]">Edit</a></td>
249
	<td><a href="[% loo.delete %]">Delete</a></td>
279
	<td><a href="[% loo.delete %]">Delete</a></td>
250
</tr>
280
</tr>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt (-1 / +32 lines)
Lines 14-19 Link Here
14
		headers: { 11: { sorter: false}}
14
		headers: { 11: { sorter: false}}
15
	}).tablesorterPager({container: $("#pagertable_categorie"),positionFixed: false,size: 20});
15
	}).tablesorterPager({container: $("#pagertable_categorie"),positionFixed: false,size: 20});
16
    $( "#enrolmentperioddate" ).datepicker({ minDate: 1 }); // Require that "until date" be in the future
16
    $( "#enrolmentperioddate" ).datepicker({ minDate: 1 }); // Require that "until date" be in the future
17
18
    if ( $("#branches option:selected").length < 1 ) {
19
        $("#branches option:first").attr("selected", "selected");
20
    }
17
}); </script>
21
}); </script>
18
<script type="text/javascript">
22
<script type="text/javascript">
19
//<![CDATA[
23
//<![CDATA[
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 ) %]
Lines 292-297 Confirm deletion of category [% categorycode |html %][% END %]</legend> Link Here
292
            [% IF ( EnhancedMessagingPreferences ) %]
311
            [% IF ( EnhancedMessagingPreferences ) %]
293
            <th scope="col">Messaging</th>
312
            <th scope="col">Messaging</th>
294
            [% END %]
313
            [% END %]
314
            <th scope="col">Branches limitations</th>
295
			<th scope="col" colspan="2">&nbsp; </th>
315
			<th scope="col" colspan="2">&nbsp; </th>
296
		</thead>
316
		</thead>
297
		[% FOREACH loo IN loop %]
317
		[% FOREACH loo IN loop %]
Lines 345-350 Confirm deletion of category [% categorycode |html %][% END %]</legend> Link Here
345
                            [% END %]
365
                            [% END %]
346
                        </td>
366
                        </td>
347
                        [% END %]
367
                        [% END %]
368
                        <td>
369
                            [% IF loo.branches.size > 0 %]
370
                                [% branches_str = "" %]
371
                                [% FOREACH branch IN loo.branches %]
372
                                    [% branches_str = branches_str _ " " _ branch.branchname _ "(" _ branch.branchcode _ ")" %]
373
                                [% END %]
374
                                <span title="[% branches_str %]">[% loo.branches.size %] branches limitations</span>
375
                            [% ELSE %]
376
                                No limitation
377
                            [% END %]
378
                        </td>
348
                        <td><a href="[% loo.script_name %]?op=add_form&amp;categorycode=[% loo.categorycode |uri %]">Edit</a></td>
379
                        <td><a href="[% loo.script_name %]?op=add_form&amp;categorycode=[% loo.categorycode |uri %]">Edit</a></td>
349
                        <td><a href="[% loo.script_name %]?op=delete_confirm&amp;categorycode=[% loo.categorycode |uri %]">Delete</a></td>
380
                        <td><a href="[% loo.script_name %]?op=delete_confirm&amp;categorycode=[% loo.categorycode |uri %]">Delete</a></td>
350
		</tr>
381
		</tr>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt (+31 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">
Lines 286-291 function CheckAttributeTypeForm(f) { Link Here
286
        <tr>
305
        <tr>
287
          <th>Code</th>
306
          <th>Code</th>
288
          <th>Description</th>
307
          <th>Description</th>
308
          <th>Branches limitation</th>
289
          <th>Actions</th>
309
          <th>Actions</th>
290
        </tr>
310
        </tr>
291
      </thead>
311
      </thead>
Lines 295-300 function CheckAttributeTypeForm(f) { Link Here
295
            <td>[% item.code |html %]</td>
315
            <td>[% item.code |html %]</td>
296
            <td>[% item.description %]</td>
316
            <td>[% item.description %]</td>
297
            <td>
317
            <td>
318
                [% IF item.branches > 0 %]
319
                    [% branches_str = "" %]
320
                    [% FOREACH branch IN item.branches %]
321
                        [% branches_str = branches_str _ " " _ branch.branchname _ "(" _ branch.branchcode _ ")" %]
322
                    [% END %]
323
                    <span title="[% branches_str %]">[% item.branches.size %] branches limitations</span>
324
                [% ELSE %]
325
                    No limitation
326
                [% END %]
327
            </td>
328
            <td>
298
              <a href="[% item.script_name %]?op=edit_attribute_type&amp;code=[% item.code |html %]">Edit</a>
329
              <a href="[% item.script_name %]?op=edit_attribute_type&amp;code=[% item.code |html %]">Edit</a>
299
              <a href="[% item.script_name %]?op=delete_attribute_type&amp;code=[% item.code |html %]">Delete</a>
330
              <a href="[% item.script_name %]?op=delete_attribute_type&amp;code=[% item.code |html %]">Delete</a>
300
            </td>
331
            </td>
(-)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 266-272 if ($op eq "show"){ Link Here
266
# now, build the item form for entering a new item
266
# now, build the item form for entering a new item
267
my @loop_data =();
267
my @loop_data =();
268
my $i=0;
268
my $i=0;
269
my $authorised_values_sth = $dbh->prepare("SELECT authorised_value,lib FROM authorised_values WHERE category=? ORDER BY lib");
269
my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
270
my $query = qq{SELECT authorised_value, lib FROM authorised_values};
271
$query  .= qq{ LEFT JOIN authorised_values_branches ON ( id = av_id ) } if $branch_limit;
272
$query  .= qq{ WHERE category = ?};
273
$query  .= qq{ AND ( branchcode = ? OR branchcode IS NULL ) } if $branch_limit;
274
$query  .= qq{ GROUP BY lib ORDER BY lib, lib_opac};
275
my $authorised_values_sth = $dbh->prepare( $query );
270
276
271
my $branches = GetBranchesLoop();  # build once ahead of time, instead of multiple times later.
277
my $branches = GetBranchesLoop();  # build once ahead of time, instead of multiple times later.
272
278
Lines 359-365 foreach my $tag (sort keys %{$tagslib}) { Link Here
359
      }
365
      }
360
      else {
366
      else {
361
          push @authorised_values, ""; # unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
367
          push @authorised_values, ""; # unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
362
          $authorised_values_sth->execute( $tagslib->{$tag}->{$subfield}->{authorised_value} );
368
          $authorised_values_sth->execute( $tagslib->{$tag}->{$subfield}->{authorised_value}, $branch_limit ? $branch_limit : () );
363
          while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) {
369
          while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) {
364
              push @authorised_values, $value;
370
              push @authorised_values, $value;
365
              $authorised_lib{$value} = $lib;
371
              $authorised_lib{$value} = $lib;
Lines 427-432 foreach my $tag (sort keys %{$tagslib}) { Link Here
427
    $i++
433
    $i++
428
  }
434
  }
429
} # -- End foreach tag
435
} # -- End foreach tag
436
$authorised_values_sth->finish;
437
430
438
431
439
432
    # what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit.
440
    # 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