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

(-)a/C4/Acquisition.pm (-8 / +8 lines)
Lines 876-884 sub GetPendingOrders { Link Here
876
    my $userenv = C4::Context->userenv;
876
    my $userenv = C4::Context->userenv;
877
    if ( C4::Context->preference("IndependentBranches") ) {
877
    if ( C4::Context->preference("IndependentBranches") ) {
878
        if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
878
        if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
879
            $strsth .= " AND (borrowers.branchcode = ?
879
            my $branches = GetIndependentGroupModificationRights( { stringify => 1 } );
880
                        or borrowers.branchcode  = '')";
880
            $strsth .= qq{ AND (borrowers.branchcode IN ( $branches ) OR borrowers.branchcode  = '') };
881
            push @query_params, $userenv->{branch};
882
        }
881
        }
883
    }
882
    }
884
    if ($supplierid) {
883
    if ($supplierid) {
Lines 1740-1746 sub GetParcel { Link Here
1740
    if ( C4::Context->preference("IndependentBranches") ) {
1739
    if ( C4::Context->preference("IndependentBranches") ) {
1741
        my $userenv = C4::Context->userenv;
1740
        my $userenv = C4::Context->userenv;
1742
        if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
1741
        if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
1743
            $strsth .= " and (borrowers.branchcode = ?
1742
            my $branches = GetIndependentGroupModificationRights( { stringify => 1 } );
1743
            $strsth .= " and (borrowers.branchcode IN ( $branches )
1744
                        or borrowers.branchcode  = '')";
1744
                        or borrowers.branchcode  = '')";
1745
            push @query_params, $userenv->{branch};
1745
            push @query_params, $userenv->{branch};
1746
        }
1746
        }
Lines 1959-1966 sub GetLateOrders { Link Here
1959
    if (C4::Context->preference("IndependentBranches")
1959
    if (C4::Context->preference("IndependentBranches")
1960
            && C4::Context->userenv
1960
            && C4::Context->userenv
1961
            && C4::Context->userenv->{flags} != 1 ) {
1961
            && C4::Context->userenv->{flags} != 1 ) {
1962
        $from .= ' AND borrowers.branchcode LIKE ? ';
1962
        my $branches = GetIndependentGroupModificationRights( { stringify => 1 } );
1963
        push @query_params, C4::Context->userenv->{branch};
1963
        $from .= qq{ AND borrowers.branchcode IN ( $branches ) };
1964
    }
1964
    }
1965
    my $query = "$select $from $having\nORDER BY latesince, basketno, borrowers.branchcode, supplier";
1965
    my $query = "$select $from $having\nORDER BY latesince, basketno, borrowers.branchcode, supplier";
1966
    $debug and print STDERR "GetLateOrders query: $query\nGetLateOrders args: " . join(" ",@query_params);
1966
    $debug and print STDERR "GetLateOrders query: $query\nGetLateOrders args: " . join(" ",@query_params);
Lines 2129-2136 sub GetHistory { Link Here
2129
    if ( C4::Context->preference("IndependentBranches") ) {
2129
    if ( C4::Context->preference("IndependentBranches") ) {
2130
        my $userenv = C4::Context->userenv;
2130
        my $userenv = C4::Context->userenv;
2131
        if ( $userenv && ($userenv->{flags} || 0) != 1 ) {
2131
        if ( $userenv && ($userenv->{flags} || 0) != 1 ) {
2132
            $query .= " AND (borrowers.branchcode = ? OR borrowers.branchcode ='' ) ";
2132
            my $branches = GetIndependentGroupModificationRights( { stringify => 1 } );
2133
            push @query_params, $userenv->{branch};
2133
            $query .= qq{ AND ( borrowers.branchcode = ? OR borrowers.branchcode IN ( $branches ) ) };
2134
        }
2134
        }
2135
    }
2135
    }
2136
    $query .= " ORDER BY id";
2136
    $query .= " ORDER BY id";
(-)a/C4/Branch.pm (-10 / +88 lines)
Lines 19-24 package C4::Branch; Link Here
19
use strict;
19
use strict;
20
#use warnings; FIXME - Bug 2505
20
#use warnings; FIXME - Bug 2505
21
require Exporter;
21
require Exporter;
22
use Carp;
22
use C4::Context;
23
use C4::Context;
23
24
24
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
25
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
Lines 42-47 BEGIN { Link Here
42
		&GetBranchCategories
43
		&GetBranchCategories
43
		&GetBranchesInCategory
44
		&GetBranchesInCategory
44
		&ModBranchCategoryInfo
45
		&ModBranchCategoryInfo
46
        &GetIndependentGroupModificationRights
45
		&DelBranch
47
		&DelBranch
46
		&DelBranchCategory
48
		&DelBranchCategory
47
	        &CheckCategoryUnique
49
	        &CheckCategoryUnique
Lines 110-117 sub GetBranches { Link Here
110
    my $query="SELECT * FROM branches";
112
    my $query="SELECT * FROM branches";
111
    my @bind_parameters;
113
    my @bind_parameters;
112
    if ($onlymine && C4::Context->userenv && C4::Context->userenv->{branch}){
114
    if ($onlymine && C4::Context->userenv && C4::Context->userenv->{branch}){
113
      $query .= ' WHERE branchcode = ? ';
115
      my $branches = GetIndependentGroupModificationRights({ stringify => 1 });
114
      push @bind_parameters, C4::Context->userenv->{branch};
116
      $query .= qq{ WHERE branchcode IN ( $branches ) };
115
    }
117
    }
116
        $query.=" ORDER BY branchname";
118
        $query.=" ORDER BY branchname";
117
    $sth = $dbh->prepare($query);
119
    $sth = $dbh->prepare($query);
Lines 299-314 C<$results> is an ref to an array. Link Here
299
=cut
301
=cut
300
302
301
sub GetBranchCategory {
303
sub GetBranchCategory {
302
303
    # returns a reference to an array of hashes containing branches,
304
    my ($catcode) = @_;
304
    my ($catcode) = @_;
305
    my $dbh = C4::Context->dbh;
305
    my $dbh = C4::Context->dbh;
306
    my $sth;
306
    my $sth;
307
307
308
    #    print DEBUG "GetBranchCategory: entry: catcode=".cvs($catcode)."\n";
309
    if ($catcode) {
308
    if ($catcode) {
310
        $sth =
309
        $sth = $dbh->prepare(
311
          $dbh->prepare(
312
            "select * from branchcategories where categorycode = ?");
310
            "select * from branchcategories where categorycode = ?");
313
        $sth->execute($catcode);
311
        $sth->execute($catcode);
314
    }
312
    }
Lines 316-329 sub GetBranchCategory { Link Here
316
        $sth = $dbh->prepare("Select * from branchcategories");
314
        $sth = $dbh->prepare("Select * from branchcategories");
317
        $sth->execute();
315
        $sth->execute();
318
    }
316
    }
317
319
    my @results;
318
    my @results;
320
    while ( my $data = $sth->fetchrow_hashref ) {
319
    while ( my $data = $sth->fetchrow_hashref ) {
321
        push( @results, $data );
320
        push( @results, $data );
322
    }
321
    }
323
    $sth->finish;
322
    $sth->finish;
324
323
325
    #    print DEBUG "GetBranchCategory: exit: returning ".cvs(\@results)."\n";
324
    return wantarray() ? @results : \@results;
326
    return \@results;
327
}
325
}
328
326
329
=head2 GetBranchCategories
327
=head2 GetBranchCategories
Lines 391-397 the categories were already here, and minimally used. Link Here
391
389
392
	#TODO  manage category types.  rename possibly to 'agency domains' ? as borrowergroups are called categories.
390
	#TODO  manage category types.  rename possibly to 'agency domains' ? as borrowergroups are called categories.
393
sub GetCategoryTypes {
391
sub GetCategoryTypes {
394
	return ( 'searchdomain','properties');
392
 return ( 'searchdomain','independent_groups');
395
}
393
}
396
394
397
=head2 GetBranch
395
=head2 GetBranch
Lines 447-452 sub GetBranchesInCategory { Link Here
447
	return( \@branches );
445
	return( \@branches );
448
}
446
}
449
447
448
=head2 GetIndependentGroupModificationRights
449
450
    GetIndependentGroupModificationRights(
451
                                           {
452
                                               branch => $this_branch,
453
                                               for => $other_branch,
454
                                               stringify => 1,
455
                                           }
456
                                          );
457
458
    Returns a list of branches this branch shares a common
459
    independent group with.
460
461
    If 'branch' is not provided, it will be looked up via
462
    C4::Context->userenv->{branch}.
463
464
    If 'for' is provided, the lookup is limited to that branch.
465
466
    If called in a list context, returns a list of
467
    branchcodes ( including $this_branch ).
468
469
    If called in a scalar context, it returns
470
    a count of matching branchcodes. Returns 1 if
471
472
    If stringify param is passed, the return value will
473
    be a string of the comma delimited branchcodes. This
474
    is useful for "branchcode IN $branchcodes" clauses
475
    in SQL queries.
476
477
    $this_branch and $other_branch are equal for efficiency.
478
479
    So you can write:
480
    my @branches = GetIndependentGroupModificationRights();
481
    or something like:
482
    if ( GetIndependentGroupModificationRights( { for => $other_branch } ) ) { do_stuff(); }
483
484
=cut
485
486
sub GetIndependentGroupModificationRights {
487
    my ($params) = @_;
488
489
    my $this_branch  = $params->{branch};
490
    my $other_branch = $params->{for};
491
    my $stringify    = $params->{stringify};
492
493
    $this_branch ||= C4::Context->userenv->{branch};
494
495
    carp("No branch found!") unless ($this_branch);
496
497
    return 1 if ( $this_branch eq $other_branch );
498
499
    my $sql = q{
500
        SELECT DISTINCT(branchcode)
501
        FROM branchrelations
502
        JOIN branchcategories USING ( categorycode )
503
        WHERE categorycode IN (
504
            SELECT categorycode
505
            FROM branchrelations
506
            WHERE branchcode = ?
507
        )
508
        AND branchcategories.categorytype = 'independent_group'
509
    };
510
511
    my @params;
512
    push( @params, $this_branch );
513
514
    if ($other_branch) {
515
        $sql .= q{ AND branchcode = ? };
516
        push( @params, $other_branch );
517
    }
518
519
    my $dbh = C4::Context->dbh;
520
    my @branchcodes = @{ $dbh->selectcol_arrayref( $sql, {}, @params ) };
521
522
    return join( ',', map { qq{'$_'} } ( @branchcodes, $this_branch ) )
523
      if ($stringify);
524
525
    return wantarray() ? ( @branchcodes, $this_branch ) : scalar(@branchcodes);
526
}
527
450
=head2 GetBranchInfo
528
=head2 GetBranchInfo
451
529
452
$results = GetBranchInfo($branchcode);
530
$results = GetBranchInfo($branchcode);
(-)a/C4/Circulation.pm (-2 / +9 lines)
Lines 890-897 sub CanBookBeIssued { Link Here
890
    if ( C4::Context->preference("IndependentBranches") ) {
890
    if ( C4::Context->preference("IndependentBranches") ) {
891
        unless ( C4::Context->IsSuperLibrarian() ) {
891
        unless ( C4::Context->IsSuperLibrarian() ) {
892
            $issuingimpossible{ITEMNOTSAMEBRANCH} = 1
892
            $issuingimpossible{ITEMNOTSAMEBRANCH} = 1
893
              if ( $item->{C4::Context->preference("HomeOrHoldingBranch")} ne $userenv->{branch} );
893
              unless (
894
            $needsconfirmation{BORRNOTSAMEBRANCH} = GetBranchName( $borrower->{'branchcode'} )
894
                GetIndependentGroupModificationRights(
895
                    {
896
                        for => $item->{ C4::Context->preference("HomeOrHoldingBranch") }
897
                    }
898
                )
899
              );
900
            $needsconfirmation{BORRNOTSAMEBRANCH} =
901
              GetBranchName( $borrower->{'branchcode'} )
895
              if ( $borrower->{'branchcode'} ne $userenv->{branch} );
902
              if ( $borrower->{'branchcode'} ne $userenv->{branch} );
896
        }
903
        }
897
    }
904
    }
(-)a/C4/Items.pm (-16 / +28 lines)
Lines 32-37 use C4::Log; Link Here
32
use List::MoreUtils qw/any/;
32
use List::MoreUtils qw/any/;
33
use Data::Dumper; # used as part of logging item record changes, not just for
33
use Data::Dumper; # used as part of logging item record changes, not just for
34
                  # debugging; so please don't remove this
34
                  # debugging; so please don't remove this
35
use C4::Branch qw/GetIndependentGroupModificationRights/;
35
36
36
use vars qw($VERSION @ISA @EXPORT);
37
use vars qw($VERSION @ISA @EXPORT);
37
38
Lines 1247-1264 sub GetItemsInfo { Link Here
1247
        my $datedue = '';
1248
        my $datedue = '';
1248
        $isth->execute( $data->{'itemnumber'} );
1249
        $isth->execute( $data->{'itemnumber'} );
1249
        if ( my $idata = $isth->fetchrow_hashref ) {
1250
        if ( my $idata = $isth->fetchrow_hashref ) {
1250
            $data->{borrowernumber} = $idata->{borrowernumber};
1251
            $data->{borrowernumber}  = $idata->{borrowernumber};
1251
            $data->{cardnumber}     = $idata->{cardnumber};
1252
            $data->{cardnumber}      = $idata->{cardnumber};
1252
            $data->{surname}     = $idata->{surname};
1253
            $data->{surname}         = $idata->{surname};
1253
            $data->{firstname}     = $idata->{firstname};
1254
            $data->{firstname}       = $idata->{firstname};
1254
            $data->{lastreneweddate} = $idata->{lastreneweddate};
1255
            $data->{lastreneweddate} = $idata->{lastreneweddate};
1255
            $datedue                = $idata->{'date_due'};
1256
            $datedue                 = $idata->{'date_due'};
1256
        if (C4::Context->preference("IndependentBranches")){
1257
1257
        my $userenv = C4::Context->userenv;
1258
            if ( C4::Context->preference("IndependentBranches") ) {
1258
        unless ( C4::Context->IsSuperLibrarian() ) {
1259
                unless (
1259
            $data->{'NOTSAMEBRANCH'} = 1 if ($idata->{'bcode'} ne $userenv->{branch});
1260
                    C4::Context->IsSuperLibrarian()
1260
        }
1261
                    || GetIndependentGroupModificationRights( { for => $idata->{'bcode'} } )
1261
        }
1262
                  )
1263
                {
1264
                    $data->{'NOTSAMEBRANCH'} = 1;
1265
                }
1266
            }
1262
        }
1267
        }
1263
		if ( $data->{'serial'}) {	
1268
		if ( $data->{'serial'}) {	
1264
			$ssth->execute($data->{'itemnumber'}) ;
1269
			$ssth->execute($data->{'itemnumber'}) ;
Lines 2210-2221 sub DelItemCheck { Link Here
2210
    my $item = GetItem($itemnumber);
2215
    my $item = GetItem($itemnumber);
2211
    my $onloan=$sth->fetchrow;
2216
    my $onloan=$sth->fetchrow;
2212
2217
2213
    if ($onloan){
2218
    if ($onloan) {
2214
        $error = "book_on_loan" 
2219
        $error = "book_on_loan";
2215
    }
2220
    }
2216
    elsif ( !( C4::Context->userenv->{flags} & 1 )
2221
    elsif (
2222
            !( C4::Context->userenv->{flags} & 1 )
2217
        and C4::Context->preference("IndependentBranches")
2223
        and C4::Context->preference("IndependentBranches")
2218
        and ( C4::Context->userenv->{branch} ne $item->{'homebranch'} ) )
2224
        and GetIndependentGroupModificationRights(
2225
            {
2226
                for => $item->{ C4::Context->preference("HomeOrHoldingBranch") }
2227
            }
2228
        )
2229
      )
2219
    {
2230
    {
2220
        $error = "not_same_branch";
2231
        $error = "not_same_branch";
2221
    }
2232
    }
Lines 2691-2697 sub PrepareItemrecordDisplay { Link Here
2691
                    if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
2702
                    if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
2692
                        if (   ( C4::Context->preference("IndependentBranches") )
2703
                        if (   ( C4::Context->preference("IndependentBranches") )
2693
                            && !C4::Context->IsSuperLibrarian() ) {
2704
                            && !C4::Context->IsSuperLibrarian() ) {
2694
                            my $sth = $dbh->prepare( "SELECT branchcode,branchname FROM branches WHERE branchcode = ? ORDER BY branchname" );
2705
                            my $branches = GetIndependentGroupModificationRights( { stringify => 1 } );
2706
                            my $sth = $dbh->prepare( "SELECT branchcode,branchname FROM branches WHERE branchcode IN ( $branches ) ORDER BY branchname" );
2695
                            $sth->execute( C4::Context->userenv->{branch} );
2707
                            $sth->execute( C4::Context->userenv->{branch} );
2696
                            push @authorised_values, ""
2708
                            push @authorised_values, ""
2697
                              unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
2709
                              unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
(-)a/C4/Letters.pm (-1 / +1 lines)
Lines 126-132 our %letter; Link Here
126
sub getletter {
126
sub getletter {
127
    my ( $module, $code, $branchcode ) = @_;
127
    my ( $module, $code, $branchcode ) = @_;
128
128
129
    $branchcode ||= '';
129
    $branchcode ||= q{};
130
130
131
    if ( C4::Context->preference('IndependentBranches')
131
    if ( C4::Context->preference('IndependentBranches')
132
            and $branchcode
132
            and $branchcode
(-)a/C4/Members.pm (-48 / +61 lines)
Lines 40-46 use DateTime; Link Here
40
use DateTime::Format::DateParse;
40
use DateTime::Format::DateParse;
41
use Koha::DateUtils;
41
use Koha::DateUtils;
42
use Text::Unaccent qw( unac_string );
42
use Text::Unaccent qw( unac_string );
43
43
use C4::Branch qw( GetIndependentGroupModificationRights );
44
our ($VERSION,@ISA,@EXPORT,@EXPORT_OK,$debug);
44
our ($VERSION,@ISA,@EXPORT,@EXPORT_OK,$debug);
45
45
46
BEGIN {
46
BEGIN {
Lines 199-204 sub _express_member_find { Link Here
199
199
200
sub Search {
200
sub Search {
201
    my ( $filter, $orderby, $limit, $columns_out, $search_on_fields, $searchtype ) = @_;
201
    my ( $filter, $orderby, $limit, $columns_out, $search_on_fields, $searchtype ) = @_;
202
    warn "C4::Members::Search";
202
203
203
    my $search_string;
204
    my $search_string;
204
    my $found_borrower;
205
    my $found_borrower;
Lines 257-280 sub Search { Link Here
257
    # Mentioning for the reference
258
    # Mentioning for the reference
258
259
259
    if ( C4::Context->preference("IndependentBranches") ) { # && !$showallbranches){
260
    if ( C4::Context->preference("IndependentBranches") ) { # && !$showallbranches){
260
        if ( my $userenv = C4::Context->userenv ) {
261
        unless ( C4::Context->IsSuperLibrarian() ){
261
            my $branch =  $userenv->{'branch'};
262
            my @branches = GetIndependentGroupModificationRights();
262
            if ( !C4::Context->IsSuperLibrarian() && $branch ){
263
            if ( my $fr = ref $filter ) {
263
                if (my $fr = ref $filter) {
264
                if ( $fr eq "HASH" ) {
264
                    if ( $fr eq "HASH" ) {
265
                    $filter->{branchcode} = \@branches;
265
                        $filter->{branchcode} = $branch;
266
                    }
267
                    else {
268
                        foreach (@$filter) {
269
                            $_ = { '' => $_ } unless ref $_;
270
                            $_->{branchcode} = $branch;
271
                        }
272
                    }
273
                }
266
                }
274
                else {
267
                else {
275
                    $filter = { '' => $filter, branchcode => $branch };
268
                    foreach (@$filter) {
269
                        $_ = { '' => $_ } unless ref $_;
270
                        $_->{branchcode} = \@branches;
271
                    }
276
                }
272
                }
277
            }      
273
            }
274
            else {
275
                $filter = { '' => $filter, branchcode => \@branches };
276
            }
278
        }
277
        }
279
    }
278
    }
280
279
Lines 2041-2053 sub GetBorrowersToExpunge { Link Here
2041
    my $filterdate     = $params->{'not_borrowered_since'};
2040
    my $filterdate     = $params->{'not_borrowered_since'};
2042
    my $filterexpiry   = $params->{'expired_before'};
2041
    my $filterexpiry   = $params->{'expired_before'};
2043
    my $filtercategory = $params->{'category_code'};
2042
    my $filtercategory = $params->{'category_code'};
2044
    my $filterbranch   = $params->{'branchcode'} ||
2043
    my $filterbranch   = $params->{'branchcode'};
2045
                        ((C4::Context->preference('IndependentBranches')
2044
    my @filterbranches =
2046
                             && C4::Context->userenv 
2045
      (      C4::Context->preference('IndependentBranches')
2047
                             && !C4::Context->IsSuperLibrarian()
2046
          && C4::Context->userenv
2048
                             && C4::Context->userenv->{branch})
2047
          && !C4::Context->IsSuperLibrarian()
2049
                         ? C4::Context->userenv->{branch}
2048
          && C4::Context->userenv->{branch} )
2050
                         : "");  
2049
      ? GetIndependentGroupModificationRights()
2050
      : ($filterbranch);
2051
2051
2052
    my $dbh   = C4::Context->dbh;
2052
    my $dbh   = C4::Context->dbh;
2053
    my $query = "
2053
    my $query = "
Lines 2062-2070 sub GetBorrowersToExpunge { Link Here
2062
        AND borrowernumber NOT IN (SELECT guarantorid FROM borrowers WHERE guarantorid IS NOT NULL AND guarantorid <> 0)
2062
        AND borrowernumber NOT IN (SELECT guarantorid FROM borrowers WHERE guarantorid IS NOT NULL AND guarantorid <> 0)
2063
   ";
2063
   ";
2064
    my @query_params;
2064
    my @query_params;
2065
    if ( $filterbranch && $filterbranch ne "" ) {
2065
    if ( @filterbranches ) {
2066
        $query.= " AND borrowers.branchcode = ? ";
2066
        my $placeholders = join( ',', ('?') x @filterbranches );
2067
        push( @query_params, $filterbranch );
2067
        $query.= " AND borrowers.branchcode IN ( $placeholders )";
2068
        push( @query_params, @filterbranches );
2068
    }
2069
    }
2069
    if ( $filterexpiry ) {
2070
    if ( $filterexpiry ) {
2070
        $query .= " AND dateexpiry < ? ";
2071
        $query .= " AND dateexpiry < ? ";
Lines 2107-2119 I<$result> is a ref to an array which all elements are a hasref. Link Here
2107
=cut
2108
=cut
2108
2109
2109
sub GetBorrowersWhoHaveNeverBorrowed {
2110
sub GetBorrowersWhoHaveNeverBorrowed {
2110
    my $filterbranch = shift || 
2111
    my $filterbranch = shift;
2111
                        ((C4::Context->preference('IndependentBranches')
2112
2112
                             && C4::Context->userenv 
2113
    my @filterbranches =
2113
                             && !C4::Context->IsSuperLibrarian()
2114
      (      C4::Context->preference('IndependentBranches')
2114
                             && C4::Context->userenv->{branch})
2115
          && C4::Context->userenv
2115
                         ? C4::Context->userenv->{branch}
2116
          && !C4::Context->IsSuperLibrarian()
2116
                         : "");  
2117
          && C4::Context->userenv->{branch} )
2118
      ? GetIndependentGroupModificationRights()
2119
      : ($filterbranch);
2120
2117
    my $dbh   = C4::Context->dbh;
2121
    my $dbh   = C4::Context->dbh;
2118
    my $query = "
2122
    my $query = "
2119
        SELECT borrowers.borrowernumber,max(timestamp) as latestissue
2123
        SELECT borrowers.borrowernumber,max(timestamp) as latestissue
Lines 2121-2130 sub GetBorrowersWhoHaveNeverBorrowed { Link Here
2121
          LEFT JOIN issues ON borrowers.borrowernumber = issues.borrowernumber
2125
          LEFT JOIN issues ON borrowers.borrowernumber = issues.borrowernumber
2122
        WHERE issues.borrowernumber IS NULL
2126
        WHERE issues.borrowernumber IS NULL
2123
   ";
2127
   ";
2128
2124
    my @query_params;
2129
    my @query_params;
2125
    if ($filterbranch && $filterbranch ne ""){ 
2130
    if (@filterbranches) {
2126
        $query.=" AND borrowers.branchcode= ?";
2131
        my $placeholders = join( ',', ('?') x @filterbranches );
2127
        push @query_params,$filterbranch;
2132
        $query .= " AND borrowers.branchcode IN ( $placeholders ) ";
2133
        push( @query_params, @filterbranches );
2128
    }
2134
    }
2129
    warn $query if $debug;
2135
    warn $query if $debug;
2130
  
2136
  
Lines 2157-2181 This hashref is containt the number of time this borrowers has borrowed before I Link Here
2157
sub GetBorrowersWithIssuesHistoryOlderThan {
2163
sub GetBorrowersWithIssuesHistoryOlderThan {
2158
    my $dbh  = C4::Context->dbh;
2164
    my $dbh  = C4::Context->dbh;
2159
    my $date = shift ||POSIX::strftime("%Y-%m-%d",localtime());
2165
    my $date = shift ||POSIX::strftime("%Y-%m-%d",localtime());
2160
    my $filterbranch = shift || 
2166
    my $filterbranch = shift;
2161
                        ((C4::Context->preference('IndependentBranches')
2167
2162
                             && C4::Context->userenv 
2168
    my @filterbranches =
2163
                             && !C4::Context->IsSuperLibrarian()
2169
      (      C4::Context->preference('IndependentBranches')
2164
                             && C4::Context->userenv->{branch})
2170
          && C4::Context->userenv
2165
                         ? C4::Context->userenv->{branch}
2171
          && !C4::Context->IsSuperLibrarian()
2166
                         : "");  
2172
          && C4::Context->userenv->{branch} )
2173
      ? GetIndependentGroupModificationRights()
2174
      : ($filterbranch);
2175
2167
    my $query = "
2176
    my $query = "
2168
       SELECT count(borrowernumber) as n,borrowernumber
2177
       SELECT count(borrowernumber) as n,borrowernumber
2169
       FROM old_issues
2178
       FROM old_issues
2170
       WHERE returndate < ?
2179
       WHERE returndate < ?
2171
         AND borrowernumber IS NOT NULL 
2180
         AND borrowernumber IS NOT NULL 
2172
    "; 
2181
    "; 
2182
2173
    my @query_params;
2183
    my @query_params;
2174
    push @query_params, $date;
2184
    push( @query_params, $date );
2175
    if ($filterbranch){
2185
2176
        $query.="   AND branchcode = ?";
2186
    if (@filterbranches) {
2177
        push @query_params, $filterbranch;
2187
        my $placeholders = join( ',', ('?') x @filterbranches );
2178
    }    
2188
        $query .= " AND branchcode IN ( $placeholders ) ";
2189
        push( @query_params, @filterbranches );
2190
    }
2191
2179
    $query.=" GROUP BY borrowernumber ";
2192
    $query.=" GROUP BY borrowernumber ";
2180
    warn $query if $debug;
2193
    warn $query if $debug;
2181
    my $sth = $dbh->prepare($query);
2194
    my $sth = $dbh->prepare($query);
(-)a/C4/Serials.pm (-38 / +73 lines)
Lines 215-227 sub GetSerialInformation { Link Here
215
    my ($serialid) = @_;
215
    my ($serialid) = @_;
216
    my $dbh        = C4::Context->dbh;
216
    my $dbh        = C4::Context->dbh;
217
    my $query      = qq|
217
    my $query      = qq|
218
        SELECT serial.*, serial.notes as sernotes, serial.status as serstatus,subscription.*,subscription.subscriptionid as subsid |;
218
        SELECT serial.*,
219
               serial.notes as sernotes,
220
               serial.status as serstatus,
221
               subscription.*,
222
               subscription.subscriptionid as subsid
223
    |;
219
    if (   C4::Context->preference('IndependentBranches')
224
    if (   C4::Context->preference('IndependentBranches')
220
        && C4::Context->userenv
225
        && C4::Context->userenv
221
        && C4::Context->userenv->{'flags'} != 1
226
        && C4::Context->userenv->{'flags'} % 2 != 1
222
        && C4::Context->userenv->{'branch'} ) {
227
        && C4::Context->userenv->{'branch'} ) {
223
        $query .= "
228
        my $branches = GetIndependentGroupModificationRights( { stringify => 1 } );
224
      , ((subscription.branchcode <>\"" . C4::Context->userenv->{'branch'} . "\") and subscription.branchcode <>\"\" and subscription.branchcode IS NOT NULL) as cannotedit ";
229
        $query .= qq|
230
            , ( ( subscription.branchcode NOT IN ( $branches ) ) AND subscription.branchcode <> '' AND subscription.branchcode IS NOT NULL ) AS cannotedit
231
        |;
225
    }
232
    }
226
    $query .= qq|             
233
    $query .= qq|             
227
        FROM   serial LEFT JOIN subscription ON subscription.subscriptionid=serial.subscriptionid
234
        FROM   serial LEFT JOIN subscription ON subscription.subscriptionid=serial.subscriptionid
Lines 315-347 subscription, subscriptionhistory, aqbooksellers.name, biblio.title Link Here
315
sub GetSubscription {
322
sub GetSubscription {
316
    my ($subscriptionid) = @_;
323
    my ($subscriptionid) = @_;
317
    my $dbh              = C4::Context->dbh;
324
    my $dbh              = C4::Context->dbh;
318
    my $query            = qq(
325
326
    my $query = qq|
319
        SELECT  subscription.*,
327
        SELECT  subscription.*,
320
                subscriptionhistory.*,
328
                subscriptionhistory.*,
321
                aqbooksellers.name AS aqbooksellername,
329
                aqbooksellers.name AS aqbooksellername,
322
                biblio.title AS bibliotitle,
330
                biblio.title AS bibliotitle,
323
                subscription.biblionumber as bibnum);
331
                subscription.biblionumber as bibnum
332
    |;
333
324
    if (   C4::Context->preference('IndependentBranches')
334
    if (   C4::Context->preference('IndependentBranches')
325
        && C4::Context->userenv
335
        && C4::Context->userenv
326
        && C4::Context->userenv->{'flags'} != 1
336
        && C4::Context->userenv->{'flags'} % 2 != 1
327
        && C4::Context->userenv->{'branch'} ) {
337
        && C4::Context->userenv->{'branch'} )
328
        $query .= "
338
    {
329
      , ((subscription.branchcode <>\"" . C4::Context->userenv->{'branch'} . "\") and subscription.branchcode <>\"\" and subscription.branchcode IS NOT NULL) as cannotedit ";
339
        my $branches =
340
          GetIndependentGroupModificationRights( { stringify => 1 } );
341
342
        $query .= qq|
343
            , ( ( subscription.branchcode NOT IN ( $branches ) ) AND subscription.branchcode <> '' AND subscription.branchcode IS NOT NULL ) AS cannotedit
344
        |;
330
    }
345
    }
331
    $query .= qq(             
346
347
    $query .= qq|
332
       FROM subscription
348
       FROM subscription
333
       LEFT JOIN subscriptionhistory ON subscription.subscriptionid=subscriptionhistory.subscriptionid
349
       LEFT JOIN subscriptionhistory ON subscription.subscriptionid=subscriptionhistory.subscriptionid
334
       LEFT JOIN aqbooksellers ON subscription.aqbooksellerid=aqbooksellers.id
350
       LEFT JOIN aqbooksellers ON subscription.aqbooksellerid=aqbooksellers.id
335
       LEFT JOIN biblio ON biblio.biblionumber=subscription.biblionumber
351
       LEFT JOIN biblio ON biblio.biblionumber=subscription.biblionumber
336
       WHERE subscription.subscriptionid = ?
352
       WHERE subscription.subscriptionid = ?
337
    );
353
    |;
338
354
339
    #     if (C4::Context->preference('IndependentBranches') &&
340
    #         C4::Context->userenv &&
341
    #         C4::Context->userenv->{'flags'} != 1){
342
    # #       $debug and warn "flags: ".C4::Context->userenv->{'flags'};
343
    #       $query.=" AND subscription.branchcode IN ('".C4::Context->userenv->{'branch'}."',\"\")";
344
    #     }
345
    $debug and warn "query : $query\nsubsid :$subscriptionid";
355
    $debug and warn "query : $query\nsubsid :$subscriptionid";
346
    my $sth = $dbh->prepare($query);
356
    my $sth = $dbh->prepare($query);
347
    $sth->execute($subscriptionid);
357
    $sth->execute($subscriptionid);
Lines 358-365 sub GetSubscription { Link Here
358
sub GetFullSubscription {
368
sub GetFullSubscription {
359
    my ($subscriptionid) = @_;
369
    my ($subscriptionid) = @_;
360
    my $dbh              = C4::Context->dbh;
370
    my $dbh              = C4::Context->dbh;
361
    my $query            = qq|
371
362
  SELECT    serial.serialid,
372
    my $query = qq|
373
        SELECT
374
            serial.serialid,
363
            serial.serialseq,
375
            serial.serialseq,
364
            serial.planneddate, 
376
            serial.planneddate, 
365
            serial.publisheddate, 
377
            serial.publisheddate, 
Lines 369-382 sub GetFullSubscription { Link Here
369
            aqbooksellers.name as aqbooksellername,
381
            aqbooksellers.name as aqbooksellername,
370
            biblio.title as bibliotitle,
382
            biblio.title as bibliotitle,
371
            subscription.branchcode AS branchcode,
383
            subscription.branchcode AS branchcode,
372
            subscription.subscriptionid AS subscriptionid |;
384
            subscription.subscriptionid AS subscriptionid
385
    |;
386
373
    if (   C4::Context->preference('IndependentBranches')
387
    if (   C4::Context->preference('IndependentBranches')
374
        && C4::Context->userenv
388
        && C4::Context->userenv
375
        && C4::Context->userenv->{'flags'} != 1
389
        && C4::Context->userenv->{'flags'} % 2 != 1
376
        && C4::Context->userenv->{'branch'} ) {
390
        && C4::Context->userenv->{'branch'} )
377
        $query .= "
391
    {
378
      , ((subscription.branchcode <>\"" . C4::Context->userenv->{'branch'} . "\") and subscription.branchcode <>\"\" and subscription.branchcode IS NOT NULL) as cannotedit ";
392
        my $branches =
393
          GetIndependentGroupModificationRights( { stringify => 1 } );
394
395
        $query .= qq|
396
            , ( ( subscription.branchcode NOT IN ( $branches ) ) AND subscription.branchcode <> '' AND subscription.branchcode IS NOT NULL ) AS cannotedit
397
        |;
379
    }
398
    }
399
380
    $query .= qq|
400
    $query .= qq|
381
  FROM      serial 
401
  FROM      serial 
382
  LEFT JOIN subscription ON 
402
  LEFT JOIN subscription ON 
Lines 489-501 sub GetSubscriptionsFromBiblionumber { Link Here
489
        $subs->{ "periodicity" . $subs->{periodicity} }     = 1;
509
        $subs->{ "periodicity" . $subs->{periodicity} }     = 1;
490
        $subs->{ "numberpattern" . $subs->{numberpattern} } = 1;
510
        $subs->{ "numberpattern" . $subs->{numberpattern} } = 1;
491
        $subs->{ "status" . $subs->{'status'} }             = 1;
511
        $subs->{ "status" . $subs->{'status'} }             = 1;
492
        $subs->{'cannotedit'} =
512
        $subs->{'cannotedit'} = (
493
          (      C4::Context->preference('IndependentBranches')
513
                 C4::Context->preference('IndependentBranches')
494
              && C4::Context->userenv
514
              && C4::Context->userenv
495
              && !C4::Context->IsSuperLibrarian()
515
              && !C4::Context->IsSuperLibrarian()
496
              && C4::Context->userenv->{branch}
516
              && C4::Context->userenv->{branch}
497
              && $subs->{branchcode}
517
              && $subs->{branchcode}
498
              && ( C4::Context->userenv->{branch} ne $subs->{branchcode} ) );
518
              && GetIndependentGroupModificationRights(
519
                { for => $subs->{branchcode} }
520
              )
521
        );
499
522
500
        if ( $subs->{enddate} eq '0000-00-00' ) {
523
        if ( $subs->{enddate} eq '0000-00-00' ) {
501
            $subs->{enddate} = '';
524
            $subs->{enddate} = '';
Lines 519-526 sub GetSubscriptionsFromBiblionumber { Link Here
519
sub GetFullSubscriptionsFromBiblionumber {
542
sub GetFullSubscriptionsFromBiblionumber {
520
    my ($biblionumber) = @_;
543
    my ($biblionumber) = @_;
521
    my $dbh            = C4::Context->dbh;
544
    my $dbh            = C4::Context->dbh;
522
    my $query          = qq|
545
523
  SELECT    serial.serialid,
546
    my $query = qq|
547
        SELECT
548
            serial.serialid,
524
            serial.serialseq,
549
            serial.serialseq,
525
            serial.planneddate, 
550
            serial.planneddate, 
526
            serial.publisheddate, 
551
            serial.publisheddate, 
Lines 529-541 sub GetFullSubscriptionsFromBiblionumber { Link Here
529
            year(IF(serial.publisheddate="00-00-0000",serial.planneddate,serial.publisheddate)) as year,
554
            year(IF(serial.publisheddate="00-00-0000",serial.planneddate,serial.publisheddate)) as year,
530
            biblio.title as bibliotitle,
555
            biblio.title as bibliotitle,
531
            subscription.branchcode AS branchcode,
556
            subscription.branchcode AS branchcode,
532
            subscription.subscriptionid AS subscriptionid|;
557
            subscription.subscriptionid AS subscriptionid
558
    |;
559
533
    if (   C4::Context->preference('IndependentBranches')
560
    if (   C4::Context->preference('IndependentBranches')
534
        && C4::Context->userenv
561
        && C4::Context->userenv
535
        && C4::Context->userenv->{'flags'} != 1
562
        && C4::Context->userenv->{'flags'} != 1
536
        && C4::Context->userenv->{'branch'} ) {
563
        && C4::Context->userenv->{'branch'} )
537
        $query .= "
564
    {
538
      , ((subscription.branchcode <>\"" . C4::Context->userenv->{'branch'} . "\") and subscription.branchcode <>\"\" and subscription.branchcode IS NOT NULL) as cannotedit ";
565
        my $branches =
566
          GetIndependentGroupModificationRights( { stringify => 1 } );
567
568
        $query .= qq|
569
            , ( ( subscription.branchcode NOT IN ( $branches ) ) AND subscription.branchcode <> '' AND subscription.branchcode IS NOT NULL ) AS cannotedit
570
        |;
539
    }
571
    }
540
572
541
    $query .= qq|      
573
    $query .= qq|      
Lines 629-641 sub GetSubscriptions { Link Here
629
    my @results;
661
    my @results;
630
662
631
    while ( my $line = $sth->fetchrow_hashref ) {
663
    while ( my $line = $sth->fetchrow_hashref ) {
632
        $line->{'cannotedit'} =
664
        $line->{'cannotedit'} = (
633
          (      C4::Context->preference('IndependentBranches')
665
                 C4::Context->preference('IndependentBranches')
634
              && C4::Context->userenv
666
              && C4::Context->userenv
635
              && !C4:Context->IsSuperLibrarian()
667
              && !C4::Context->IsSuperLibrarian()
636
              && C4::Context->userenv->{branch}
668
              && C4::Context->userenv->{branch}
637
              && $line->{branchcode}
669
              && $line->{branchcode}
638
              && ( C4::Context->userenv->{branch} ne $line->{branchcode} ) );
670
              && GetIndependentGroupModificationRights(
671
                { for => $line->{branchcode} }
672
              )
673
        );
639
        push @results, $line;
674
        push @results, $line;
640
    }
675
    }
641
    return @results;
676
    return @results;
(-)a/C4/Suggestions.pm (-12 / +28 lines)
Lines 32-37 use C4::Letters; Link Here
32
use List::MoreUtils qw(any);
32
use List::MoreUtils qw(any);
33
use C4::Dates qw(format_date_in_iso);
33
use C4::Dates qw(format_date_in_iso);
34
use base qw(Exporter);
34
use base qw(Exporter);
35
use C4::Branch qw(GetIndependentGroupModificationRights);
35
36
36
our $VERSION = 3.07.00.049;
37
our $VERSION = 3.07.00.049;
37
our @EXPORT  = qw(
38
our @EXPORT  = qw(
Lines 137-146 sub SearchSuggestion { Link Here
137
        if ($userenv) {
138
        if ($userenv) {
138
            if ( !C4::Context->IsSuperLibrarian() && !$suggestion->{branchcode} )
139
            if ( !C4::Context->IsSuperLibrarian() && !$suggestion->{branchcode} )
139
            {
140
            {
140
                push @sql_params, $$userenv{branch};
141
                my $branches =
141
                push @query,      q{
142
                  GetIndependentGroupModificationRights( { stringify => 1 } );
142
                    AND (suggestions.branchcode=? OR suggestions.branchcode='')
143
                push ( @query, qq{
143
                };
144
                    AND (suggestions.branchcode IN ( $branches ) OR suggestions.branchcode='')
145
                } );
144
            }
146
            }
145
        }
147
        }
146
    } else {
148
    } else {
Lines 340-352 sub GetSuggestionByStatus { Link Here
340
342
341
    # filter on branch
343
    # filter on branch
342
    if ( C4::Context->preference("IndependentBranches") || $branchcode ) {
344
    if ( C4::Context->preference("IndependentBranches") || $branchcode ) {
343
        my $userenv = C4::Context->userenv;
345
344
        if ($userenv) {
346
        if (   C4::Context->userenv
345
            unless ( C4::Context->IsSuperLibrarian() ) {
347
            && C4::Context->preference("IndependentBranches")
346
                push @sql_params, $userenv->{branch};
348
            && !C4::Context->IsSuperLibrarian() )
347
                $query .= q{ AND (U1.branchcode = ? OR U1.branchcode ='') };
349
        {
348
            }
350
351
            my $branches =
352
              GetIndependentGroupModificationRights( { stringify => 1 } );
353
354
            $query .= qq{
355
                    AND (U1.branchcode IN ( $branches ) OR U1.branchcode ='')
356
                };
349
        }
357
        }
358
350
        if ($branchcode) {
359
        if ($branchcode) {
351
            push @sql_params, $branchcode;
360
            push @sql_params, $branchcode;
352
            $query .= q{ AND (U1.branchcode = ? OR U1.branchcode ='') };
361
            $query .= q{ AND (U1.branchcode = ? OR U1.branchcode ='') };
Lines 392-403 sub CountSuggestion { Link Here
392
    if ( C4::Context->preference("IndependentBranches")
401
    if ( C4::Context->preference("IndependentBranches")
393
        && !C4::Context->IsSuperLibrarian() )
402
        && !C4::Context->IsSuperLibrarian() )
394
    {
403
    {
395
        my $query = q{
404
        my $branches =
405
          GetIndependentGroupModificationRights( { stringify => 1 } );
406
407
        my $query = qq{
396
            SELECT count(*)
408
            SELECT count(*)
397
            FROM suggestions
409
            FROM suggestions
398
                LEFT JOIN borrowers ON borrowers.borrowernumber=suggestions.suggestedby
410
                LEFT JOIN borrowers ON borrowers.borrowernumber=suggestions.suggestedby
399
            WHERE STATUS=?
411
            WHERE STATUS=?
400
                AND (borrowers.branchcode='' OR borrowers.branchcode=?)
412
                AND (
413
                    borrowers.branchcode IN ( $branches )
414
                    OR
415
                    borrowers.branchcode=?
416
                )
401
        };
417
        };
402
        $sth = $dbh->prepare($query);
418
        $sth = $dbh->prepare($query);
403
        $sth->execute( $status, $userenv->{branch} );
419
        $sth->execute( $status, $userenv->{branch} );
(-)a/acqui/basket.pl (-8 / +19 lines)
Lines 105-115 if ( $op eq 'delete_confirm' ) { Link Here
105
    $template->param( delete_confirm => 1 );
105
    $template->param( delete_confirm => 1 );
106
    if ( C4::Context->preference("IndependentBranches") ) {
106
    if ( C4::Context->preference("IndependentBranches") ) {
107
        my $userenv = C4::Context->userenv;
107
        my $userenv = C4::Context->userenv;
108
        unless ( $userenv->{flags} == 1 ) {
108
        if ( $userenv->{flags} % 2 != 1 ) {
109
            my $validtest = ( $basket->{creationdate} eq '' )
109
            my $validtest =
110
              || ( $userenv->{branch} eq $basket->{branch} )
110
                 ( $basket->{creationdate} eq '' )
111
              || ( $userenv->{branch} eq '' )
111
              || ( $userenv->{branch} eq '' )
112
              || ( $basket->{branch}  eq '' );
112
              || ( $basket->{branch}  eq '' )
113
              || (
114
                GetIndependentGroupModificationRights(
115
                    { for => $basket->{branch} }
116
                )
117
              );
118
113
            unless ($validtest) {
119
            unless ($validtest) {
114
                print $query->redirect("../mainpage.pl");
120
                print $query->redirect("../mainpage.pl");
115
                exit 1;
121
                exit 1;
Lines 194-204 if ( $op eq 'delete_confirm' ) { Link Here
194
    # get librarian branch...
200
    # get librarian branch...
195
    if ( C4::Context->preference("IndependentBranches") ) {
201
    if ( C4::Context->preference("IndependentBranches") ) {
196
        my $userenv = C4::Context->userenv;
202
        my $userenv = C4::Context->userenv;
197
        unless ( $userenv->{flags} == 1 ) {
203
        if ( $userenv->{flags} % 2 != 1 ) {
198
            my $validtest = ( $basket->{creationdate} eq '' )
204
            my $validtest =
199
              || ( $userenv->{branch} eq $basket->{branch} )
205
                 ( $basket->{creationdate} eq '' )
200
              || ( $userenv->{branch} eq '' )
206
              || ( $userenv->{branch} eq '' )
201
              || ( $basket->{branch}  eq '' );
207
              || ( $basket->{branch}  eq '' )
208
              || (
209
                GetIndependentGroupModificationRights(
210
                    { for => $basket->{branch} }
211
                )
212
              );
202
            unless ($validtest) {
213
            unless ($validtest) {
203
                print $query->redirect("../mainpage.pl");
214
                print $query->redirect("../mainpage.pl");
204
                exit 1;
215
                exit 1;
(-)a/admin/branches.pl (-34 / +16 lines)
Lines 260-272 sub editbranchform { Link Here
260
260
261
    my $catinfo = GetBranchCategory();
261
    my $catinfo = GetBranchCategory();
262
    my @categoryloop = ();
262
    my @categoryloop = ();
263
    my $branch_categories;
263
    foreach my $cat (@$catinfo) {
264
    foreach my $cat (@$catinfo) {
264
        my $checked;
265
        my $checked;
265
        my $tmp     = quotemeta( $cat->{'categorycode'} );
266
        my $tmp     = quotemeta( $cat->{'categorycode'} );
266
        if ( grep { /^$tmp$/ } @{ $data->{'categories'} } ) {
267
        if ( grep { /^$tmp$/ } @{ $data->{'categories'} } ) {
267
            $checked = 1;
268
            $checked = 1;
268
        }
269
        }
269
        push @categoryloop, {
270
        $branch_categories->{ $cat->{categorytype} }->{ $cat->{'categorycode'} } = {
270
            categoryname    => $cat->{'categoryname'},
271
            categoryname    => $cat->{'categoryname'},
271
            categorycode    => $cat->{'categorycode'},
272
            categorycode    => $cat->{'categorycode'},
272
            categorytype    => $cat->{'categorytype'},
273
            categorytype    => $cat->{'categorytype'},
Lines 274-280 sub editbranchform { Link Here
274
            checked         => $checked,
275
            checked         => $checked,
275
        };
276
        };
276
    }
277
    }
277
    $innertemplate->param( categoryloop => \@categoryloop );
278
    $innertemplate->param( branch_categories => $branch_categories );
278
279
279
    for my $obsolete ( 'categoryname', 'categorycode', 'codedescription' ) {
280
    for my $obsolete ( 'categoryname', 'categorycode', 'codedescription' ) {
280
        $innertemplate->param(
281
        $innertemplate->param(
Lines 283-308 sub editbranchform { Link Here
283
}
284
}
284
285
285
sub editcatform {
286
sub editcatform {
286
287
    # prepares the edit form...
288
    my ($categorycode,$innertemplate) = @_;
287
    my ($categorycode,$innertemplate) = @_;
289
    # warn "cat : $categorycode";
290
	my @cats;
291
    my $data;
292
	if ($categorycode) {
288
	if ($categorycode) {
293
        my $data = GetBranchCategory($categorycode);
294
        $data = $data->[0];
295
        $innertemplate->param(
289
        $innertemplate->param(
296
            categorycode    => $data->{'categorycode'},
290
            category => @{ GetBranchCategory($categorycode) }[0],
297
            categoryname    => $data->{'categoryname'},
298
            codedescription => $data->{'codedescription'},
299
            show_in_pulldown => $data->{'show_in_pulldown'},
300
		);
291
		);
301
    }
292
    }
302
	for my $ctype (GetCategoryTypes()) {
303
		push @cats , { type => $ctype , selected => ($data->{'categorytype'} and $data->{'categorytype'} eq $ctype) };
304
	}
305
    $innertemplate->param(categorytype => \@cats);
306
}
293
}
307
294
308
sub branchinfotable {
295
sub branchinfotable {
Lines 373-397 sub branchinfotable { Link Here
373
360
374
        push @loop_data, \%row;
361
        push @loop_data, \%row;
375
    }
362
    }
376
    my @branchcategories = ();
363
377
	for my $ctype ( GetCategoryTypes() ) {
364
    my $catinfo = GetBranchCategories();
378
    	my $catinfo = GetBranchCategories(undef,$ctype);
365
    my $categories;
379
    	my @categories;
366
    foreach my $cat (@$catinfo) {
380
		foreach my $cat (@$catinfo) {
367
        $categories->{ $cat->{categorytype} }->{ $cat->{'categorycode'} } = {
381
            push @categories, {
368
            categoryname    => $cat->{'categoryname'},
382
                categoryname    => $cat->{'categoryname'},
369
            codedescription => $cat->{'codedescription'},
383
                categorycode    => $cat->{'categorycode'},
370
        };
384
                codedescription => $cat->{'codedescription'},
371
    }
385
                categorytype    => $cat->{'categorytype'},
372
386
            };
387
    	}
388
        push @branchcategories, { categorytype => $ctype , $ctype => 1 , catloop => ( @categories ? \@categories : undef) };
389
	}
390
    $innertemplate->param(
373
    $innertemplate->param(
391
        branches         => \@loop_data,
374
        branches          => \@loop_data,
392
        branchcategories => \@branchcategories
375
        branch_categories => $categories
393
    );
376
    );
394
395
}
377
}
396
378
397
sub _branch_to_template {
379
sub _branch_to_template {
(-)a/catalogue/moredetail.pl (-4 / +11 lines)
Lines 172-184 foreach my $item (@items){ Link Here
172
        $item->{status_advisory} = 1;
172
        $item->{status_advisory} = 1;
173
    }
173
    }
174
174
175
    if (C4::Context->preference("IndependentBranches")) {
175
    if ( C4::Context->preference("IndependentBranches") ) {
176
        #verifying rights
176
177
        my $userenv = C4::Context->userenv();
177
        my $userenv = C4::Context->userenv();
178
        unless (($userenv->{'flags'} == 1) or ($userenv->{'branch'} eq $item->{'homebranch'})) {
178
        unless (
179
                $item->{'nomod'}=1;
179
            $userenv->{'flags'} % 2 != 1
180
            || GetIndependentGroupModificationRights(
181
                { for => $item->{'homebranch'} }
182
            )
183
          )
184
        {
185
            $item->{'nomod'} = 1;
180
        }
186
        }
181
    }
187
    }
188
182
    $item->{'homebranchname'} = GetBranchName($item->{'homebranch'});
189
    $item->{'homebranchname'} = GetBranchName($item->{'homebranch'});
183
    $item->{'holdingbranchname'} = GetBranchName($item->{'holdingbranch'});
190
    $item->{'holdingbranchname'} = GetBranchName($item->{'holdingbranch'});
184
    if ($item->{'datedue'}) {
191
    if ($item->{'datedue'}) {
(-)a/cataloguing/additem.pl (-2 / +11 lines)
Lines 689-698 foreach my $field (@fields) { Link Here
689
						|| $subfieldvalue;
689
						|| $subfieldvalue;
690
        }
690
        }
691
691
692
        if (($field->tag eq $branchtagfield) && ($subfieldcode eq $branchtagsubfield) && C4::Context->preference("IndependentBranches")) {
692
        if (   $field->tag eq $branchtagfield
693
            && $subfieldcode eq $branchtagsubfield
694
            && C4::Context->preference("IndependentBranches") )
695
        {
693
            #verifying rights
696
            #verifying rights
694
            my $userenv = C4::Context->userenv();
697
            my $userenv = C4::Context->userenv();
695
            unless (($userenv->{'flags'} == 1) or (($userenv->{'branch'} eq $subfieldvalue))){
698
            unless (
699
                $userenv->{'flags'} % 2 == 1
700
                || GetIndependentGroupModificationRights(
701
                    { for => $subfieldvalue }
702
                )
703
              )
704
            {
696
                $this_row{'nomod'} = 1;
705
                $this_row{'nomod'} = 1;
697
            }
706
            }
698
        }
707
        }
(-)a/circ/circulation-home.pl (-1 / +4 lines)
Lines 23-28 use C4::Auth; Link Here
23
use C4::Output;
23
use C4::Output;
24
use C4::Context;
24
use C4::Context;
25
use C4::Koha;
25
use C4::Koha;
26
use C4::Branch qw/GetIndependentGroupModificationRights/;
26
27
27
my $query = new CGI;
28
my $query = new CGI;
28
my ($template, $loggedinuser, $cookie, $flags)
29
my ($template, $loggedinuser, $cookie, $flags)
Lines 38-44 my $fa = getframeworkinfo('FA'); Link Here
38
$template->param( fast_cataloging => 1 ) if (defined $fa);
39
$template->param( fast_cataloging => 1 ) if (defined $fa);
39
40
40
# Checking if the transfer page needs to be displayed
41
# Checking if the transfer page needs to be displayed
41
$template->param( display_transfer => 1 ) if ( ($flags->{'superlibrarian'} == 1) || (C4::Context->preference("IndependentBranches") == 0) );
42
$template->param( display_transfer => 1 )
43
  if ( $flags->{'superlibrarian'} == 1
44
    || scalar GetIndependentGroupModificationRights() );
42
45
43
46
44
output_html_with_http_headers $query, $cookie, $template->output;
47
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/circ/pendingreserves.pl (-2 / +3 lines)
Lines 32-37 use C4::Auth; Link Here
32
use C4::Dates qw/format_date format_date_in_iso/;
32
use C4::Dates qw/format_date format_date_in_iso/;
33
use C4::Debug;
33
use C4::Debug;
34
use Date::Calc qw/Today Add_Delta_YMD/;
34
use Date::Calc qw/Today Add_Delta_YMD/;
35
use C4::Branch qw/GetIndependentGroupModificationRights/;
35
36
36
my $input = new CGI;
37
my $input = new CGI;
37
my $startdate=$input->param('from');
38
my $startdate=$input->param('from');
Lines 152-159 if ( $run_report ) { Link Here
152
153
153
154
154
    if (C4::Context->preference('IndependentBranches')){
155
    if (C4::Context->preference('IndependentBranches')){
155
        $strsth .= " AND items.holdingbranch=? ";
156
        my @branches = GetIndependentGroupModificationRights( { stringify => 1 } );
156
        push @query_params, C4::Context->userenv->{'branch'};
157
        $strsth .= " AND items.holdingbranch IN ( $branches ) ";
157
    }
158
    }
158
    $strsth .= " GROUP BY reserves.biblionumber ORDER BY biblio.title ";
159
    $strsth .= " GROUP BY reserves.biblionumber ORDER BY biblio.title ";
159
160
(-)a/circ/reserveratios.pl (-3 / +3 lines)
Lines 113-121 my $strsth = Link Here
113
 $sqldatewhere
113
 $sqldatewhere
114
";
114
";
115
115
116
if (C4::Context->preference('IndependentBranches')){
116
if ( C4::Context->preference('IndependentBranches') ) {
117
    $strsth .= " AND items.holdingbranch=? ";
117
    my $branches = GetIndependentGroupModificationRights( { stringify => 1 } );
118
    push @query_params, C4::Context->userenv->{'branch'};
118
    $strsth .= " AND items.holdingbranch IN ( $branches ) ";
119
}
119
}
120
120
121
$strsth .= " GROUP BY reserves.biblionumber ORDER BY reservecount DESC";
121
$strsth .= " GROUP BY reserves.biblionumber ORDER BY reservecount DESC";
(-)a/installer/data/mysql/kohastructure.sql (-1 / +1 lines)
Lines 340-346 CREATE TABLE `branchcategories` ( -- information related to library/branch group Link Here
340
  `categorycode` varchar(10) NOT NULL default '', -- unique identifier for the library/branch group
340
  `categorycode` varchar(10) NOT NULL default '', -- unique identifier for the library/branch group
341
  `categoryname` varchar(32), -- name of the library/branch group
341
  `categoryname` varchar(32), -- name of the library/branch group
342
  `codedescription` mediumtext, -- longer description of the library/branch group
342
  `codedescription` mediumtext, -- longer description of the library/branch group
343
  `categorytype` varchar(16), -- says whether this is a search group or a properties group
343
  `categorytype` ENUM(  'searchdomain',  'independent_group' ) NULL DEFAULT NULL, -- says whether this is a search group or an independent group
344
  `show_in_pulldown` tinyint(1) NOT NULL DEFAULT '0', -- says this group should be in the opac libararies pulldown if it is enabled
344
  `show_in_pulldown` tinyint(1) NOT NULL DEFAULT '0', -- says this group should be in the opac libararies pulldown if it is enabled
345
  PRIMARY KEY  (`categorycode`),
345
  PRIMARY KEY  (`categorycode`),
346
  KEY `show_in_pulldown` (`show_in_pulldown`)
346
  KEY `show_in_pulldown` (`show_in_pulldown`)
(-)a/installer/data/mysql/updatedatabase.pl (-1 / +13 lines)
Lines 6938-6944 $DBversion = "3.13.00.002"; Link Here
6938
if ( CheckVersion($DBversion) ) {
6938
if ( CheckVersion($DBversion) ) {
6939
   $dbh->do("UPDATE systempreferences SET variable = 'IndependentBranches' WHERE variable = 'IndependantBranches'");
6939
   $dbh->do("UPDATE systempreferences SET variable = 'IndependentBranches' WHERE variable = 'IndependantBranches'");
6940
   print "Upgrade to $DBversion done (Bug 10080 - Change system pref IndependantBranches to IndependentBranches)\n";
6940
   print "Upgrade to $DBversion done (Bug 10080 - Change system pref IndependantBranches to IndependentBranches)\n";
6941
   SetVersion ($DBversion);
6941
    SetVersion ($DBversion);
6942
}
6943
6944
$DBversion = "3.11.00.XXX";
6945
if ( CheckVersion($DBversion) ) {
6946
    $dbh->do(q{
6947
        ALTER TABLE branchcategories
6948
        CHANGE categorytype categorytype
6949
          ENUM( 'searchdomain', 'independent_group' )
6950
            NULL DEFAULT NULL
6951
    });
6952
    print "Upgrade to $DBversion done (Remove branch property groups, add independent groups)\n";
6953
    SetVersion ($DBversion);
6942
}
6954
}
6943
6955
6944
$DBversion = '3.13.00.003';
6956
$DBversion = '3.13.00.003';
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt (-71 / +135 lines)
Lines 103-122 tinyMCE.init({ Link Here
103
        </li>
103
        </li>
104
	</ol>
104
	</ol>
105
	</fieldset>
105
	</fieldset>
106
	[% IF ( categoryloop ) %]<fieldset class="rows"><legend>Group(s):</legend>
106
107
        <ol>
107
     [% IF ( branch_categories ) %]
108
		[% FOREACH categoryloo IN categoryloop %]
108
        <fieldset class="rows">
109
            <li><label for="[% categoryloo.categorycode %]">[% categoryloo.categoryname %]: </label>
109
            <legend>Group(s):</legend>
110
                [% IF ( categoryloo.checked ) %]
110
            <ol>
111
                    <input type="checkbox" id="[% categoryloo.categorycode %]" name="[% categoryloo.categorycode %]" checked="checked" />
111
                <fieldset>
112
                [% ELSE %]
112
                    <legend>Search domain</legend>
113
                    <input type="checkbox" id="[% categoryloo.categorycode %]" name="[% categoryloo.categorycode %]" />
113
                    [% FOREACH bc IN branch_categories.searchdomain %]
114
                [% END %]
114
                        <li>
115
                <span class="hint">[% categoryloo.codedescription %]</span>
115
                            <label for="[% bc.key %]">[% bc.value.categoryname %]: </label>
116
            </li>
116
                            [% IF ( bc.value.checked ) %]
117
        [% END %]
117
                                <input type="checkbox" id="[% bc.key %]" name="[% bc.key %]" checked="checked" />
118
		</ol>
118
                            [% ELSE %]
119
</fieldset>[% END %]
119
                                <input type="checkbox" id="[% bc.key %]" name="[% bc.key %]" />
120
                            [% END %]
121
                            <span class="hint">[% bc.value.codedescription %]</span>
122
                        </li>
123
                    [% END %]
124
                </fieldset>
125
            </ol>
126
            <ol>
127
                <fieldset>
128
                    <legend>Independent library groups</legend>
129
                    [% FOREACH bc IN branch_categories.independent_group %]
130
                        <li>
131
                            <label for="[% bc.key %]">[% bc.value.categoryname %]: </label>
132
                            [% IF ( bc.value.checked ) %]
133
                                <input type="checkbox" id="[% bc.key %]" name="[% bc.key %]" checked="checked" />
134
                            [% ELSE %]
135
                                <input type="checkbox" id="[% bc.key %]" name="[% bc.key %]" />
136
                            [% END %]
137
                            <span class="hint">[% bc.value.codedescription %]</span>
138
                        </li>
139
                    [% END %]
140
                <li><label>Note:</label><span class="hint">If independent library groups are enabled ( via the IndependentBranches system preference ), a library may access and alter records and patrons from libraries in any group that also library belongs to. A library may belong to multiple library groups.</span></li>
141
                </fieldset>
142
            </ol>
143
        </fieldset>
144
    [% END %]
145
120
	<fieldset class="rows">
146
	<fieldset class="rows">
121
	<ol>
147
	<ol>
122
        <li><label for="branchaddress1">Address line 1: </label><input type="text" name="branchaddress1" id="branchaddress1" value="[% branchaddress1 |html %]" /></li>
148
        <li><label for="branchaddress1">Address line 1: </label><input type="text" name="branchaddress1" id="branchaddress1" value="[% branchaddress1 |html %]" /></li>
Lines 252-341 tinyMCE.init({ Link Here
252
	[% ELSE %]
278
	[% ELSE %]
253
	<div class="dialog message">There are no libraries defined. <a href="/cgi-bin/koha/admin/branches.pl?op=add">Start defining libraries</a>.</div>
279
	<div class="dialog message">There are no libraries defined. <a href="/cgi-bin/koha/admin/branches.pl?op=add">Start defining libraries</a>.</div>
254
	[% END %]
280
	[% END %]
255
    
281
256
   [% IF ( branchcategories ) %]
282
    <h3>Search domain groups</h3>
257
   [% FOREACH branchcategorie IN branchcategories %]
283
    [% IF branch_categories.searchdomain %]
258
    <h3>Group(s):  [% IF ( branchcategorie.properties ) %]Properties[% ELSE %][% IF ( branchcategorie.searchdomain ) %]Search domain[% END %][% END %]</h3>
284
        <table>
259
    [% IF ( branchcategorie.catloop ) %]
285
            <thead>
260
      <table>
286
                <tr>
261
        <thead>
287
                    <th>Name</th>
262
          <tr>
288
                    <th>Code</th>
263
            <th>Name</th>
289
                    <th>Description</th>
264
            <th>Code</th>
290
                    <th>&nbsp;</th>
265
            <th>Description</th>
291
                    <th>&nbsp;</th>
266
            <th>&nbsp;</th>
292
                  </tr>
267
            <th>&nbsp;</th>
293
            </thead>
268
          </tr>
294
            <tbody>
269
        </thead>
295
                [% FOREACH bc IN branch_categories.searchdomain %]
270
        <tbody>
296
                    <tr>
271
          [% FOREACH catloo IN branchcategorie.catloop %]
297
                      <td>[% bc.value.categoryname %]</td>
272
            <tr>
298
                      <td>[% bc.key %]</td>
273
              <td>[% catloo.categoryname %]</td>
299
                      <td>[% bc.value.codedescription %]</td>
274
              <td>[% catloo.categorycode %]</td>
300
                      <td>
275
              <td>[% catloo.codedescription %]</td>
301
                        <a href="?op=editcategory&amp;categorycode=[% bc.key |url %]">Edit</a>
276
              <td>
302
                      </td>
277
                <a href="[% catloo.action %]?op=editcategory&amp;categorycode=[% catloo.categorycode |url %]">Edit</a>
303
                      <td>
278
              </td>
304
                        <a href="?op=delete_category&amp;categorycode=[% bc.key |url %]">Delete</a>
279
              <td>
305
                      </td>
280
                <a href="[% catloo.action %]?op=delete_category&amp;categorycode=[% catloo.categorycode |url %]">Delete</a>
306
                    </tr>
281
              </td>
307
                [% END %]
282
            </tr>
308
            </tbody>
283
          [% END %]
309
        </table>
284
        </tbody>
285
      </table>
286
    [% ELSE %]
310
    [% ELSE %]
287
      No [% IF ( branchcategorie.properties ) %]properties[% ELSIF ( branchcategorie.searchdomain ) %]search domain[% END %] defined. <a href="/cgi-bin/koha/admin/branches.pl?op=editcategory">Add a new group</a>.
311
        No search domain groups defined.
288
    [% END %]
312
    [% END %]
289
  [% END %]
313
    <a href="/cgi-bin/koha/admin/branches.pl?op=editcategory">Add a new group</a>.
290
  [% ELSE %]
314
291
    <p>No groups defined.</p>
315
    <h3>Independent library groups:</h3>
292
  [% END %] <!-- NAME="branchcategories" -->
316
    [% IF branch_categories.independent_group %]
317
        <table>
318
            <thead>
319
                <tr>
320
                    <th>Name</th>
321
                    <th>Code</th>
322
                    <th>Description</th>
323
                    <th>&nbsp;</th>
324
                    <th>&nbsp;</th>
325
                  </tr>
326
            </thead>
327
            <tbody>
328
                [% FOREACH bc IN branch_categories.independent_group %]
329
                    <tr>
330
                      <td>[% bc.value.categoryname %]</td>
331
                      <td>[% bc.key %]</td>
332
                      <td>[% bc.value.codedescription %]</td>
333
                      <td>
334
                        <a href="?op=editcategory&amp;categorycode=[% bc.key |url %]">Edit</a>
335
                      </td>
336
                      <td>
337
                        <a href="?op=delete_category&amp;categorycode=[% bc.key |url %]">Delete</a>
338
                      </td>
339
                    </tr>
340
                [% END %]
341
            </tbody>
342
        </table>
343
    [% ELSE %]
344
        No independent library groups defined.
345
    [% END %]
346
    <a href="/cgi-bin/koha/admin/branches.pl?op=editcategory">Add a new group</a>.
293
[% END %]
347
[% END %]
294
348
295
[% IF ( editcategory ) %]
349
[% IF ( editcategory ) %]
296
    <h3>[% IF ( categorycode ) %]Edit group [% categorycode %][% ELSE %]Add group[% END %]</h3>
350
    <h3>[% IF ( category ) %]Edit group [% category.categorycode %][% ELSE %]Add group[% END %]</h3>
297
    <form action="[% action %]" name="Aform" method="post">
351
    <form action="[% action %]" name="Aform" method="post">
298
    <input type="hidden" name="op" value="addcategory_validate" />
352
    <input type="hidden" name="op" value="addcategory_validate" />
299
	[% IF ( categorycode ) %]
353
    [% IF ( category.categorycode ) %]
300
	<input type="hidden" name="add" value="0">
354
        <input type="hidden" name="add" value="0">
301
	[% ELSE %]
355
    [% ELSE %]
302
	<input type="hidden" name="add" value="1">
356
        <input type="hidden" name="add" value="1">
303
	[% END %]
357
    [% END %]
304
    <fieldset class="rows">
358
    <fieldset class="rows">
305
        
359
        
306
        <ol><li>
360
        <ol><li>
307
                [% IF ( categorycode ) %]
361
                [% IF ( category.categorycode ) %]
308
				<span class="label">Category code: </span>
362
				<span class="label">Category code: </span>
309
                    <input type="hidden" name="categorycode" id="categorycode" value="[% categorycode |html %]" />
363
                    <input type="hidden" name="categorycode" id="categorycode" value="[% category.categorycode | html %]" />
310
                    [% categorycode %]
364
                    [% category.categorycode %]
311
                [% ELSE %]
365
                [% ELSE %]
312
                <label for="categorycode">Category code:</label>
366
                    <label for="categorycode">Category code:</label>
313
                    <input type="text" name="categorycode" id="categorycode" size="10" maxlength="10" value="[% categorycode |html %]" />
367
                    <input type="text" name="categorycode" id="categorycode" size="10" maxlength="10" value="[% categorycode | html %]" />
314
                [% END %]
368
                [% END %]
315
            </li>
369
            </li>
316
        <li>
370
        <li>
317
            <label for="categoryname">Name: </label>
371
            <label for="categoryname">Name: </label>
318
            <input type="text" name="categoryname" id="categoryname" size="32" maxlength="32" value="[% categoryname |html %]" />
372
            <input type="text" name="categoryname" id="categoryname" size="32" maxlength="32" value="[% category.categoryname | html %]" />
319
        </li>
373
        </li>
320
        <li>
374
        <li>
321
            <label for="codedescription">Description: </label>
375
            <label for="codedescription">Description: </label>
322
            <input type="text" name="codedescription" id="codedescription" size="70" value="[% codedescription |html %]" />
376
            <input type="text" name="codedescription" id="codedescription" size="70" value="[% category.codedescription | html %]" />
323
        </li>
377
        </li>
324
		<li>
378
		<li>
325
        <label for="categorytype">Category type: </label>
379
        <label for="categorytype">Category type: </label>
326
            <select id="categorytype" name="categorytype">
380
            <select id="categorytype" name="categorytype">
327
            [% FOREACH categorytyp IN categorytype %]
381
                [% IF ( category.categorytype == 'searchdomain' ) %]
328
                [% IF ( categorytyp.selected ) %]
382
                    <option value="searchdomain" selected="selected">Search domain</option>
329
                    <option value="[% categorytyp.type %]" selected="selected">
330
                [% ELSE %]
383
                [% ELSE %]
331
                    <option value="[% categorytyp.type %]">
384
                    <option value="searchdomain">Search domain</option>
332
                [% END %] [% categorytyp.type %]</option>
385
                [% END %]
333
            [% END %]
386
387
                [% IF ( category.categorytype == 'independent_group' ) %]
388
                    <option value="independent_group" selected="selected">Independent group</option>
389
                [% ELSE %]
390
                    <option value="independent_group">Independent group</option>
391
                [% END %]
334
            </select>
392
            </select>
335
		</li>
393
		</li>
336
        <li>
394
        <li>
337
            <label for="show_in_pulldown">Show in search pulldown: </label>
395
            <label for="show_in_pulldown">Show in search pulldown: </label>
338
            [% IF ( show_in_pulldown ) %]
396
            [% IF ( category.show_in_pulldown ) %]
339
                <input type="checkbox" name="show_in_pulldown" id="show_in_pulldown" checked="checked"/>
397
                <input type="checkbox" name="show_in_pulldown" id="show_in_pulldown" checked="checked"/>
340
            [% ELSE %]
398
            [% ELSE %]
341
                <input type="checkbox" name="show_in_pulldown" id="show_in_pulldown" />
399
                <input type="checkbox" name="show_in_pulldown" id="show_in_pulldown" />
Lines 343-349 tinyMCE.init({ Link Here
343
        </li>
401
        </li>
344
		</ol>
402
		</ol>
345
    </fieldset>
403
    </fieldset>
346
	<fieldset class="action"><input type="submit" value="Update" /></fieldset>
404
  <fieldset class="action">
405
        [% IF category %]
406
            <input type="submit" value="Update group" />
407
        [% ELSE %]
408
            <input type="submit" value="Add group" />
409
        [% END %]
410
    </fieldset>
347
    </form>
411
    </form>
348
[% END %]
412
[% END %]
349
413
(-)a/members/deletemem.pl (-4 / +9 lines)
Lines 67-76 if ($bor->{category_type} eq "S") { Link Here
67
}
67
}
68
68
69
if (C4::Context->preference("IndependentBranches")) {
69
if (C4::Context->preference("IndependentBranches")) {
70
    my $userenv = C4::Context->userenv;
71
    if ( !C4::Context->IsSuperLibrarian() && $bor->{'branchcode'}){
70
    if ( !C4::Context->IsSuperLibrarian() && $bor->{'branchcode'}){
72
        unless ($userenv->{branch} eq $bor->{'branchcode'}){
71
        unless (
73
            print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_OTHERLIBRARY");
72
            GetIndependentGroupModificationRights(
73
                { for => $bor->{'branchcode'} }
74
            )
75
          )
76
        {
77
            print $input->redirect(
78
                "/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_OTHERLIBRARY"
79
            );
74
            exit;
80
            exit;
75
        }
81
        }
76
    }
82
    }
77
- 

Return to bug 10276