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

(-)a/C4/Acquisition.pm (-8 / +8 lines)
Lines 877-885 sub GetPendingOrders { Link Here
877
    my $userenv = C4::Context->userenv;
877
    my $userenv = C4::Context->userenv;
878
    if ( C4::Context->preference("IndependentBranches") ) {
878
    if ( C4::Context->preference("IndependentBranches") ) {
879
        if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
879
        if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
880
            $strsth .= " AND (borrowers.branchcode = ?
880
            my $branches = GetIndependentGroupModificationRights( { stringify => 1 } );
881
                        or borrowers.branchcode  = '')";
881
            $strsth .= qq{ AND (borrowers.branchcode IN ( $branches ) OR borrowers.branchcode  = '') };
882
            push @query_params, $userenv->{branch};
883
        }
882
        }
884
    }
883
    }
885
    if ($supplierid) {
884
    if ($supplierid) {
Lines 1722-1728 sub GetParcel { Link Here
1722
    if ( C4::Context->preference("IndependentBranches") ) {
1721
    if ( C4::Context->preference("IndependentBranches") ) {
1723
        my $userenv = C4::Context->userenv;
1722
        my $userenv = C4::Context->userenv;
1724
        if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
1723
        if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
1725
            $strsth .= " and (borrowers.branchcode = ?
1724
            my $branches = GetIndependentGroupModificationRights( { stringify => 1 } );
1725
            $strsth .= " and (borrowers.branchcode IN ( $branches )
1726
                        or borrowers.branchcode  = '')";
1726
                        or borrowers.branchcode  = '')";
1727
            push @query_params, $userenv->{branch};
1727
            push @query_params, $userenv->{branch};
1728
        }
1728
        }
Lines 1941-1948 sub GetLateOrders { Link Here
1941
    if (C4::Context->preference("IndependentBranches")
1941
    if (C4::Context->preference("IndependentBranches")
1942
            && C4::Context->userenv
1942
            && C4::Context->userenv
1943
            && C4::Context->userenv->{flags} != 1 ) {
1943
            && C4::Context->userenv->{flags} != 1 ) {
1944
        $from .= ' AND borrowers.branchcode LIKE ? ';
1944
        my $branches = GetIndependentGroupModificationRights( { stringify => 1 } );
1945
        push @query_params, C4::Context->userenv->{branch};
1945
        $from .= qq{ AND borrowers.branchcode IN ( $branches ) };
1946
    }
1946
    }
1947
    my $query = "$select $from $having\nORDER BY latesince, basketno, borrowers.branchcode, supplier";
1947
    my $query = "$select $from $having\nORDER BY latesince, basketno, borrowers.branchcode, supplier";
1948
    $debug and print STDERR "GetLateOrders query: $query\nGetLateOrders args: " . join(" ",@query_params);
1948
    $debug and print STDERR "GetLateOrders query: $query\nGetLateOrders args: " . join(" ",@query_params);
Lines 2111-2118 sub GetHistory { Link Here
2111
    if ( C4::Context->preference("IndependentBranches") ) {
2111
    if ( C4::Context->preference("IndependentBranches") ) {
2112
        my $userenv = C4::Context->userenv;
2112
        my $userenv = C4::Context->userenv;
2113
        if ( $userenv && ($userenv->{flags} || 0) != 1 ) {
2113
        if ( $userenv && ($userenv->{flags} || 0) != 1 ) {
2114
            $query .= " AND (borrowers.branchcode = ? OR borrowers.branchcode ='' ) ";
2114
            my $branches = GetIndependentGroupModificationRights( { stringify => 1 } );
2115
            push @query_params, $userenv->{branch};
2115
            $query .= qq{ AND ( borrowers.branchcode = ? OR borrowers.branchcode IN ( $branches ) ) };
2116
        }
2116
        }
2117
    }
2117
    }
2118
    $query .= " ORDER BY id";
2118
    $query .= " ORDER BY id";
(-)a/C4/Branch.pm (-4 / +89 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 114-121 sub GetBranches { Link Here
114
    my $query="SELECT * FROM branches";
116
    my $query="SELECT * FROM branches";
115
    my @bind_parameters;
117
    my @bind_parameters;
116
    if ($onlymine && C4::Context->userenv && C4::Context->userenv->{branch}){
118
    if ($onlymine && C4::Context->userenv && C4::Context->userenv->{branch}){
117
      $query .= ' WHERE branchcode = ? ';
119
      my $branches = GetIndependentGroupModificationRights({ stringify => 1 });
118
      push @bind_parameters, C4::Context->userenv->{branch};
120
      $query .= qq{ WHERE branchcode IN ( $branches ) };
119
    }
121
    }
120
        $query.=" ORDER BY branchname";
122
        $query.=" ORDER BY branchname";
121
    $sth = $dbh->prepare($query);
123
    $sth = $dbh->prepare($query);
Lines 301-307 C<$results> is an hashref Link Here
301
303
302
sub GetBranchCategory {
304
sub GetBranchCategory {
303
    my ($catcode) = @_;
305
    my ($catcode) = @_;
304
    return unless $catcode;
306
    unless ( $catcode ) {
307
        carp("No category code passed in!");
308
        return;
309
    }
305
310
306
    my $dbh = C4::Context->dbh;
311
    my $dbh = C4::Context->dbh;
307
    my $sth;
312
    my $sth;
Lines 371-377 the categories were already here, and minimally used. Link Here
371
376
372
	#TODO  manage category types.  rename possibly to 'agency domains' ? as borrowergroups are called categories.
377
	#TODO  manage category types.  rename possibly to 'agency domains' ? as borrowergroups are called categories.
373
sub GetCategoryTypes {
378
sub GetCategoryTypes {
374
	return ( 'searchdomain','properties');
379
 return ( 'searchdomain','independent_groups');
375
}
380
}
376
381
377
=head2 GetBranch
382
=head2 GetBranch
Lines 426-431 sub GetBranchesInCategory { Link Here
426
	return( \@branches );
431
	return( \@branches );
427
}
432
}
428
433
434
=head2 GetIndependentGroupModificationRights
435
436
    GetIndependentGroupModificationRights(
437
                                           {
438
                                               branch => $this_branch,
439
                                               for => $other_branch,
440
                                               stringify => 1,
441
                                           }
442
                                          );
443
444
    Returns a list of branches this branch shares a common
445
    independent group with.
446
447
    If 'branch' is not provided, it will be looked up via
448
    C4::Context->userenv->{branch}.
449
450
    If 'for' is provided, the lookup is limited to that branch.
451
452
    If called in a list context, returns a list of
453
    branchcodes ( including $this_branch ).
454
455
    If called in a scalar context, it returns
456
    a count of matching branchcodes. Returns 1 if
457
458
    If stringify param is passed, the return value will
459
    be a string of the comma delimited branchcodes. This
460
    is useful for "branchcode IN $branchcodes" clauses
461
    in SQL queries.
462
463
    $this_branch and $other_branch are equal for efficiency.
464
465
    So you can write:
466
    my @branches = GetIndependentGroupModificationRights();
467
    or something like:
468
    if ( GetIndependentGroupModificationRights( { for => $other_branch } ) ) { do_stuff(); }
469
470
=cut
471
472
sub GetIndependentGroupModificationRights {
473
    my ($params) = @_;
474
475
    my $this_branch  = $params->{branch};
476
    my $other_branch = $params->{for};
477
    my $stringify    = $params->{stringify};
478
479
    $this_branch ||= C4::Context->userenv->{branch};
480
481
    carp("No branch found!") unless ($this_branch);
482
483
    return 1 if ( $this_branch eq $other_branch );
484
485
    my $sql = q{
486
        SELECT DISTINCT(branchcode)
487
        FROM branchrelations
488
        JOIN branchcategories USING ( categorycode )
489
        WHERE categorycode IN (
490
            SELECT categorycode
491
            FROM branchrelations
492
            WHERE branchcode = ?
493
        )
494
        AND branchcategories.categorytype = 'independent_group'
495
    };
496
497
    my @params;
498
    push( @params, $this_branch );
499
500
    if ($other_branch) {
501
        $sql .= q{ AND branchcode = ? };
502
        push( @params, $other_branch );
503
    }
504
505
    my $dbh = C4::Context->dbh;
506
    my @branchcodes = @{ $dbh->selectcol_arrayref( $sql, {}, @params ) };
507
508
    return join( ',', map { qq{'$_'} } ( @branchcodes, $this_branch ) )
509
      if ($stringify);
510
511
    return wantarray() ? ( @branchcodes, $this_branch ) : scalar(@branchcodes);
512
}
513
429
=head2 GetBranchInfo
514
=head2 GetBranchInfo
430
515
431
$results = GetBranchInfo($branchcode);
516
$results = GetBranchInfo($branchcode);
(-)a/C4/Circulation.pm (-8 / +12 lines)
Lines 894-907 sub CanBookBeIssued { Link Here
894
        $alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' );
894
        $alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' );
895
    }
895
    }
896
    if ( C4::Context->preference("IndependentBranches") ) {
896
    if ( C4::Context->preference("IndependentBranches") ) {
897
        my $userenv = C4::Context->userenv;
897
        unless ( C4::Context->IsSuperLibrarian() ) {
898
        if ( C4::Context->IsSuperLibrarian() ) {
898
            $issuingimpossible{ITEMNOTSAMEBRANCH} = 1
899
            if ( $item->{C4::Context->preference("HomeOrHoldingBranch")} ne $userenv->{branch} ){
899
              unless (
900
                $issuingimpossible{ITEMNOTSAMEBRANCH} = 1;
900
                GetIndependentGroupModificationRights(
901
                $issuingimpossible{'itemhomebranch'} = $item->{C4::Context->preference("HomeOrHoldingBranch")};
901
                    {
902
            }
902
                        for => $item->{ C4::Context->preference("HomeOrHoldingBranch") }
903
            $needsconfirmation{BORRNOTSAMEBRANCH} = GetBranchName( $borrower->{'branchcode'} )
903
                    }
904
              if ( $borrower->{'branchcode'} ne $userenv->{branch} );
904
                )
905
              );
906
            $needsconfirmation{BORRNOTSAMEBRANCH} =
907
              GetBranchName( $borrower->{'branchcode'} )
908
              if ( $borrower->{'branchcode'} ne C4::Context->userenv->{branch} );
905
        }
909
        }
906
    }
910
    }
907
911
(-)a/C4/Items.pm (-17 / +29 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 1251-1268 sub GetItemsInfo { Link Here
1251
        my $datedue = '';
1252
        my $datedue = '';
1252
        $isth->execute( $data->{'itemnumber'} );
1253
        $isth->execute( $data->{'itemnumber'} );
1253
        if ( my $idata = $isth->fetchrow_hashref ) {
1254
        if ( my $idata = $isth->fetchrow_hashref ) {
1254
            $data->{borrowernumber} = $idata->{borrowernumber};
1255
            $data->{borrowernumber}  = $idata->{borrowernumber};
1255
            $data->{cardnumber}     = $idata->{cardnumber};
1256
            $data->{cardnumber}      = $idata->{cardnumber};
1256
            $data->{surname}     = $idata->{surname};
1257
            $data->{surname}         = $idata->{surname};
1257
            $data->{firstname}     = $idata->{firstname};
1258
            $data->{firstname}       = $idata->{firstname};
1258
            $data->{lastreneweddate} = $idata->{lastreneweddate};
1259
            $data->{lastreneweddate} = $idata->{lastreneweddate};
1259
            $datedue                = $idata->{'date_due'};
1260
            $datedue                 = $idata->{'date_due'};
1260
        if (C4::Context->preference("IndependentBranches")){
1261
1261
        my $userenv = C4::Context->userenv;
1262
            if ( C4::Context->preference("IndependentBranches") ) {
1262
        unless ( C4::Context->IsSuperLibrarian() ) {
1263
                unless (
1263
            $data->{'NOTSAMEBRANCH'} = 1 if ($idata->{'bcode'} ne $userenv->{branch});
1264
                    C4::Context->IsSuperLibrarian()
1264
        }
1265
                    || GetIndependentGroupModificationRights( { for => $idata->{'bcode'} } )
1265
        }
1266
                  )
1267
                {
1268
                    $data->{'NOTSAMEBRANCH'} = 1;
1269
                }
1270
            }
1266
        }
1271
        }
1267
		if ( $data->{'serial'}) {	
1272
		if ( $data->{'serial'}) {	
1268
			$ssth->execute($data->{'itemnumber'}) ;
1273
			$ssth->execute($data->{'itemnumber'}) ;
Lines 2214-2225 sub DelItemCheck { Link Here
2214
    my $item = GetItem($itemnumber);
2219
    my $item = GetItem($itemnumber);
2215
    my $onloan=$sth->fetchrow;
2220
    my $onloan=$sth->fetchrow;
2216
2221
2217
    if ($onloan){
2222
    if ($onloan) {
2218
        $error = "book_on_loan" 
2223
        $error = "book_on_loan";
2219
    }
2224
    }
2220
    elsif ( !( C4::Context->userenv->{flags} & 1 )
2225
    elsif (
2221
        and C4::Context->preference("IndependentBranches")
2226
           !C4::Context->IsSuperLibrarian()
2222
        and ( C4::Context->userenv->{branch} ne $item->{'homebranch'} ) )
2227
        && C4::Context->preference("IndependentBranches")
2228
        && !GetIndependentGroupModificationRights(
2229
            {
2230
                for => $item->{ C4::Context->preference("HomeOrHoldingBranch") }
2231
            }
2232
        )
2233
      )
2223
    {
2234
    {
2224
        $error = "not_same_branch";
2235
        $error = "not_same_branch";
2225
    }
2236
    }
Lines 2695-2701 sub PrepareItemrecordDisplay { Link Here
2695
                    if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
2706
                    if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
2696
                        if (   ( C4::Context->preference("IndependentBranches") )
2707
                        if (   ( C4::Context->preference("IndependentBranches") )
2697
                            && !C4::Context->IsSuperLibrarian() ) {
2708
                            && !C4::Context->IsSuperLibrarian() ) {
2698
                            my $sth = $dbh->prepare( "SELECT branchcode,branchname FROM branches WHERE branchcode = ? ORDER BY branchname" );
2709
                            my $branches = GetIndependentGroupModificationRights( { stringify => 1 } );
2710
                            my $sth = $dbh->prepare( "SELECT branchcode,branchname FROM branches WHERE branchcode IN ( $branches ) ORDER BY branchname" );
2699
                            $sth->execute( C4::Context->userenv->{branch} );
2711
                            $sth->execute( C4::Context->userenv->{branch} );
2700
                            push @authorised_values, ""
2712
                            push @authorised_values, ""
2701
                              unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
2713
                              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 / +68 lines)
Lines 26-31 use C4::Context; Link Here
26
use C4::Dates qw(format_date_in_iso format_date);
26
use C4::Dates qw(format_date_in_iso format_date);
27
use Digest::MD5 qw(md5_base64);
27
use Digest::MD5 qw(md5_base64);
28
use String::Random qw( random_string );
28
use String::Random qw( random_string );
29
use Clone qw(clone);
29
use Date::Calc qw/Today Add_Delta_YM check_date Date_to_Days/;
30
use Date::Calc qw/Today Add_Delta_YM check_date Date_to_Days/;
30
use C4::Log; # logaction
31
use C4::Log; # logaction
31
use C4::Overdues;
32
use C4::Overdues;
Lines 40-46 use DateTime; Link Here
40
use DateTime::Format::DateParse;
41
use DateTime::Format::DateParse;
41
use Koha::DateUtils;
42
use Koha::DateUtils;
42
use Text::Unaccent qw( unac_string );
43
use Text::Unaccent qw( unac_string );
43
44
use C4::Branch qw( GetIndependentGroupModificationRights );
44
our ($VERSION,@ISA,@EXPORT,@EXPORT_OK,$debug);
45
our ($VERSION,@ISA,@EXPORT,@EXPORT_OK,$debug);
45
46
46
BEGIN {
47
BEGIN {
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
            $filter = clone( $filter ); # Modify a copy only
262
            if ( !C4::Context->IsSuperLibrarian() && $branch ){
263
            my @branches = GetIndependentGroupModificationRights();
263
                if (my $fr = ref $filter) {
264
            if ( my $fr = ref $filter ) {
264
                    if ( $fr eq "HASH" ) {
265
                if ( $fr eq "HASH" ) {
265
                        $filter->{branchcode} = $branch;
266
                    $filter->{branchcode} = \@branches;
266
                    }
267
                    else {
268
                        foreach (@$filter) {
269
                            $_ = { '' => $_ } unless ref $_;
270
                            $_->{branchcode} = $branch;
271
                        }
272
                    }
273
                }
267
                }
274
                else {
268
                else {
275
                    $filter = { '' => $filter, branchcode => $branch };
269
                    foreach (@$filter) {
270
                        $_ = { '' => $_ } unless ref $_;
271
                        $_->{branchcode} = \@branches;
272
                    }
276
                }
273
                }
277
            }      
274
            }
275
            else {
276
                $filter = { '' => $filter, branchcode => \@branches };
277
            }
278
        }
278
        }
279
    }
279
    }
280
280
Lines 1313-1318 sub checkuniquemember { Link Here
1313
            ($dateofbirth) ?
1313
            ($dateofbirth) ?
1314
            "SELECT borrowernumber,categorycode FROM borrowers WHERE surname=? and firstname=?  and dateofbirth=?" :
1314
            "SELECT borrowernumber,categorycode FROM borrowers WHERE surname=? and firstname=?  and dateofbirth=?" :
1315
            "SELECT borrowernumber,categorycode FROM borrowers WHERE surname=? and firstname=?";
1315
            "SELECT borrowernumber,categorycode FROM borrowers WHERE surname=? and firstname=?";
1316
1317
    if ( C4::Context->preference('IndependentBranches') ) {
1318
        my $branches = GetIndependentGroupModificationRights( { stringify => 1 } );
1319
        $request .= " AND branchcode IN ( $branches )";
1320
    }
1321
1316
    my $sth = $dbh->prepare($request);
1322
    my $sth = $dbh->prepare($request);
1317
    if ($collectivity) {
1323
    if ($collectivity) {
1318
        $sth->execute( uc($surname) );
1324
        $sth->execute( uc($surname) );
Lines 2063-2075 sub GetBorrowersToExpunge { Link Here
2063
    my $filterdate     = $params->{'not_borrowered_since'};
2069
    my $filterdate     = $params->{'not_borrowered_since'};
2064
    my $filterexpiry   = $params->{'expired_before'};
2070
    my $filterexpiry   = $params->{'expired_before'};
2065
    my $filtercategory = $params->{'category_code'};
2071
    my $filtercategory = $params->{'category_code'};
2066
    my $filterbranch   = $params->{'branchcode'} ||
2072
    my $filterbranch   = $params->{'branchcode'};
2067
                        ((C4::Context->preference('IndependentBranches')
2073
    my @filterbranches =
2068
                             && C4::Context->userenv 
2074
      (      C4::Context->preference('IndependentBranches')
2069
                             && !C4::Context->IsSuperLibrarian()
2075
          && C4::Context->userenv
2070
                             && C4::Context->userenv->{branch})
2076
          && !C4::Context->IsSuperLibrarian()
2071
                         ? C4::Context->userenv->{branch}
2077
          && C4::Context->userenv->{branch} )
2072
                         : "");  
2078
      ? GetIndependentGroupModificationRights()
2079
      : ($filterbranch);
2073
2080
2074
    my $dbh   = C4::Context->dbh;
2081
    my $dbh   = C4::Context->dbh;
2075
    my $query = "
2082
    my $query = "
Lines 2084-2092 sub GetBorrowersToExpunge { Link Here
2084
        AND borrowernumber NOT IN (SELECT guarantorid FROM borrowers WHERE guarantorid IS NOT NULL AND guarantorid <> 0)
2091
        AND borrowernumber NOT IN (SELECT guarantorid FROM borrowers WHERE guarantorid IS NOT NULL AND guarantorid <> 0)
2085
   ";
2092
   ";
2086
    my @query_params;
2093
    my @query_params;
2087
    if ( $filterbranch && $filterbranch ne "" ) {
2094
    if ( @filterbranches ) {
2088
        $query.= " AND borrowers.branchcode = ? ";
2095
        my $placeholders = join( ',', ('?') x @filterbranches );
2089
        push( @query_params, $filterbranch );
2096
        $query.= " AND borrowers.branchcode IN ( $placeholders )";
2097
        push( @query_params, @filterbranches );
2090
    }
2098
    }
2091
    if ( $filterexpiry ) {
2099
    if ( $filterexpiry ) {
2092
        $query .= " AND dateexpiry < ? ";
2100
        $query .= " AND dateexpiry < ? ";
Lines 2129-2141 I<$result> is a ref to an array which all elements are a hasref. Link Here
2129
=cut
2137
=cut
2130
2138
2131
sub GetBorrowersWhoHaveNeverBorrowed {
2139
sub GetBorrowersWhoHaveNeverBorrowed {
2132
    my $filterbranch = shift || 
2140
    my $filterbranch = shift;
2133
                        ((C4::Context->preference('IndependentBranches')
2141
2134
                             && C4::Context->userenv 
2142
    my @filterbranches =
2135
                             && !C4::Context->IsSuperLibrarian()
2143
      (      C4::Context->preference('IndependentBranches')
2136
                             && C4::Context->userenv->{branch})
2144
          && C4::Context->userenv
2137
                         ? C4::Context->userenv->{branch}
2145
          && !C4::Context->IsSuperLibrarian()
2138
                         : "");  
2146
          && C4::Context->userenv->{branch} )
2147
      ? GetIndependentGroupModificationRights()
2148
      : ($filterbranch);
2149
2139
    my $dbh   = C4::Context->dbh;
2150
    my $dbh   = C4::Context->dbh;
2140
    my $query = "
2151
    my $query = "
2141
        SELECT borrowers.borrowernumber,max(timestamp) as latestissue
2152
        SELECT borrowers.borrowernumber,max(timestamp) as latestissue
Lines 2143-2152 sub GetBorrowersWhoHaveNeverBorrowed { Link Here
2143
          LEFT JOIN issues ON borrowers.borrowernumber = issues.borrowernumber
2154
          LEFT JOIN issues ON borrowers.borrowernumber = issues.borrowernumber
2144
        WHERE issues.borrowernumber IS NULL
2155
        WHERE issues.borrowernumber IS NULL
2145
   ";
2156
   ";
2157
2146
    my @query_params;
2158
    my @query_params;
2147
    if ($filterbranch && $filterbranch ne ""){ 
2159
    if (@filterbranches) {
2148
        $query.=" AND borrowers.branchcode= ?";
2160
        my $placeholders = join( ',', ('?') x @filterbranches );
2149
        push @query_params,$filterbranch;
2161
        $query .= " AND borrowers.branchcode IN ( $placeholders ) ";
2162
        push( @query_params, @filterbranches );
2150
    }
2163
    }
2151
    warn $query if $debug;
2164
    warn $query if $debug;
2152
  
2165
  
Lines 2179-2203 This hashref is containt the number of time this borrowers has borrowed before I Link Here
2179
sub GetBorrowersWithIssuesHistoryOlderThan {
2192
sub GetBorrowersWithIssuesHistoryOlderThan {
2180
    my $dbh  = C4::Context->dbh;
2193
    my $dbh  = C4::Context->dbh;
2181
    my $date = shift ||POSIX::strftime("%Y-%m-%d",localtime());
2194
    my $date = shift ||POSIX::strftime("%Y-%m-%d",localtime());
2182
    my $filterbranch = shift || 
2195
    my $filterbranch = shift;
2183
                        ((C4::Context->preference('IndependentBranches')
2196
2184
                             && C4::Context->userenv 
2197
    my @filterbranches =
2185
                             && !C4::Context->IsSuperLibrarian()
2198
      (      C4::Context->preference('IndependentBranches')
2186
                             && C4::Context->userenv->{branch})
2199
          && C4::Context->userenv
2187
                         ? C4::Context->userenv->{branch}
2200
          && !C4::Context->IsSuperLibrarian()
2188
                         : "");  
2201
          && C4::Context->userenv->{branch} )
2202
      ? GetIndependentGroupModificationRights()
2203
      : ($filterbranch);
2204
2189
    my $query = "
2205
    my $query = "
2190
       SELECT count(borrowernumber) as n,borrowernumber
2206
       SELECT count(borrowernumber) as n,borrowernumber
2191
       FROM old_issues
2207
       FROM old_issues
2192
       WHERE returndate < ?
2208
       WHERE returndate < ?
2193
         AND borrowernumber IS NOT NULL 
2209
         AND borrowernumber IS NOT NULL 
2194
    "; 
2210
    "; 
2211
2195
    my @query_params;
2212
    my @query_params;
2196
    push @query_params, $date;
2213
    push( @query_params, $date );
2197
    if ($filterbranch){
2214
2198
        $query.="   AND branchcode = ?";
2215
    if (@filterbranches) {
2199
        push @query_params, $filterbranch;
2216
        my $placeholders = join( ',', ('?') x @filterbranches );
2200
    }    
2217
        $query .= " AND branchcode IN ( $placeholders ) ";
2218
        push( @query_params, @filterbranches );
2219
    }
2220
2201
    $query.=" GROUP BY borrowernumber ";
2221
    $query.=" GROUP BY borrowernumber ";
2202
    warn $query if $debug;
2222
    warn $query if $debug;
2203
    my $sth = $dbh->prepare($query);
2223
    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 486-498 sub GetSubscriptionsFromBiblionumber { Link Here
486
        $subs->{ "periodicity" . $subs->{periodicity} }     = 1;
506
        $subs->{ "periodicity" . $subs->{periodicity} }     = 1;
487
        $subs->{ "numberpattern" . $subs->{numberpattern} } = 1;
507
        $subs->{ "numberpattern" . $subs->{numberpattern} } = 1;
488
        $subs->{ "status" . $subs->{'status'} }             = 1;
508
        $subs->{ "status" . $subs->{'status'} }             = 1;
489
        $subs->{'cannotedit'} =
509
        $subs->{'cannotedit'} = (
490
          (      C4::Context->preference('IndependentBranches')
510
                 C4::Context->preference('IndependentBranches')
491
              && C4::Context->userenv
511
              && C4::Context->userenv
492
              && !C4::Context->IsSuperLibrarian()
512
              && !C4::Context->IsSuperLibrarian()
493
              && C4::Context->userenv->{branch}
513
              && C4::Context->userenv->{branch}
494
              && $subs->{branchcode}
514
              && $subs->{branchcode}
495
              && ( C4::Context->userenv->{branch} ne $subs->{branchcode} ) );
515
              && GetIndependentGroupModificationRights(
516
                { for => $subs->{branchcode} }
517
              )
518
        );
496
519
497
        if ( $subs->{enddate} eq '0000-00-00' ) {
520
        if ( $subs->{enddate} eq '0000-00-00' ) {
498
            $subs->{enddate} = '';
521
            $subs->{enddate} = '';
Lines 516-523 sub GetSubscriptionsFromBiblionumber { Link Here
516
sub GetFullSubscriptionsFromBiblionumber {
539
sub GetFullSubscriptionsFromBiblionumber {
517
    my ($biblionumber) = @_;
540
    my ($biblionumber) = @_;
518
    my $dbh            = C4::Context->dbh;
541
    my $dbh            = C4::Context->dbh;
519
    my $query          = qq|
542
520
  SELECT    serial.serialid,
543
    my $query = qq|
544
        SELECT
545
            serial.serialid,
521
            serial.serialseq,
546
            serial.serialseq,
522
            serial.planneddate, 
547
            serial.planneddate, 
523
            serial.publisheddate, 
548
            serial.publisheddate, 
Lines 526-538 sub GetFullSubscriptionsFromBiblionumber { Link Here
526
            year(IF(serial.publisheddate="00-00-0000",serial.planneddate,serial.publisheddate)) as year,
551
            year(IF(serial.publisheddate="00-00-0000",serial.planneddate,serial.publisheddate)) as year,
527
            biblio.title as bibliotitle,
552
            biblio.title as bibliotitle,
528
            subscription.branchcode AS branchcode,
553
            subscription.branchcode AS branchcode,
529
            subscription.subscriptionid AS subscriptionid|;
554
            subscription.subscriptionid AS subscriptionid
555
    |;
556
530
    if (   C4::Context->preference('IndependentBranches')
557
    if (   C4::Context->preference('IndependentBranches')
531
        && C4::Context->userenv
558
        && C4::Context->userenv
532
        && C4::Context->userenv->{'flags'} != 1
559
        && C4::Context->userenv->{'flags'} != 1
533
        && C4::Context->userenv->{'branch'} ) {
560
        && C4::Context->userenv->{'branch'} )
534
        $query .= "
561
    {
535
      , ((subscription.branchcode <>\"" . C4::Context->userenv->{'branch'} . "\") and subscription.branchcode <>\"\" and subscription.branchcode IS NOT NULL) as cannotedit ";
562
        my $branches =
563
          GetIndependentGroupModificationRights( { stringify => 1 } );
564
565
        $query .= qq|
566
            , ( ( subscription.branchcode NOT IN ( $branches ) ) AND subscription.branchcode <> '' AND subscription.branchcode IS NOT NULL ) AS cannotedit
567
        |;
536
    }
568
    }
537
569
538
    $query .= qq|      
570
    $query .= qq|      
Lines 626-638 sub GetSubscriptions { Link Here
626
    my @results;
658
    my @results;
627
659
628
    while ( my $line = $sth->fetchrow_hashref ) {
660
    while ( my $line = $sth->fetchrow_hashref ) {
629
        $line->{'cannotedit'} =
661
        $line->{'cannotedit'} = (
630
          (      C4::Context->preference('IndependentBranches')
662
                 C4::Context->preference('IndependentBranches')
631
              && C4::Context->userenv
663
              && C4::Context->userenv
632
              && !C4:Context->IsSuperLibrarian()
664
              && !C4::Context->IsSuperLibrarian()
633
              && C4::Context->userenv->{branch}
665
              && C4::Context->userenv->{branch}
634
              && $line->{branchcode}
666
              && $line->{branchcode}
635
              && ( C4::Context->userenv->{branch} ne $line->{branchcode} ) );
667
              && GetIndependentGroupModificationRights(
668
                { for => $line->{branchcode} }
669
              )
670
        );
636
        push @results, $line;
671
        push @results, $line;
637
    }
672
    }
638
    return @results;
673
    return @results;
(-)a/C4/Suggestions.pm (-19 / +29 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 132-148 sub SearchSuggestion { Link Here
132
    }
133
    }
133
134
134
    # filter on user branch
135
    # filter on user branch
135
    if ( C4::Context->preference('IndependentBranches') ) {
136
    if ( C4::Context->preference('IndependentBranches') && !C4::Context->IsSuperLibrarian() && !$suggestion->{branchcode} ) {
136
        my $userenv = C4::Context->userenv;
137
        my $branches =
137
        if ($userenv) {
138
          GetIndependentGroupModificationRights( { stringify => 1 } );
138
            if ( !C4::Context->IsSuperLibrarian() && !$suggestion->{branchcode} )
139
        push ( @query, qq{
139
            {
140
            AND (suggestions.branchcode IN ( $branches ) OR suggestions.branchcode='')
140
                push @sql_params, $$userenv{branch};
141
        } );
141
                push @query,      q{
142
                    AND (suggestions.branchcode=? OR suggestions.branchcode='')
143
                };
144
            }
145
        }
146
    } else {
142
    } else {
147
        if ( defined $suggestion->{branchcode} && $suggestion->{branchcode} ) {
143
        if ( defined $suggestion->{branchcode} && $suggestion->{branchcode} ) {
148
            unless ( $suggestion->{branchcode} eq '__ANY__' ) {
144
            unless ( $suggestion->{branchcode} eq '__ANY__' ) {
Lines 340-352 sub GetSuggestionByStatus { Link Here
340
336
341
    # filter on branch
337
    # filter on branch
342
    if ( C4::Context->preference("IndependentBranches") || $branchcode ) {
338
    if ( C4::Context->preference("IndependentBranches") || $branchcode ) {
343
        my $userenv = C4::Context->userenv;
339
344
        if ($userenv) {
340
        if (   C4::Context->userenv
345
            unless ( C4::Context->IsSuperLibrarian() ) {
341
            && C4::Context->preference("IndependentBranches")
346
                push @sql_params, $userenv->{branch};
342
            && !C4::Context->IsSuperLibrarian() )
347
                $query .= q{ AND (U1.branchcode = ? OR U1.branchcode ='') };
343
        {
348
            }
344
345
            my $branches =
346
              GetIndependentGroupModificationRights( { stringify => 1 } );
347
348
            $query .= qq{
349
                    AND (U1.branchcode IN ( $branches ) OR U1.branchcode ='')
350
                };
349
        }
351
        }
352
350
        if ($branchcode) {
353
        if ($branchcode) {
351
            push @sql_params, $branchcode;
354
            push @sql_params, $branchcode;
352
            $query .= q{ AND (U1.branchcode = ? OR U1.branchcode ='') };
355
            $query .= q{ AND (U1.branchcode = ? OR U1.branchcode ='') };
Lines 392-403 sub CountSuggestion { Link Here
392
    if ( C4::Context->preference("IndependentBranches")
395
    if ( C4::Context->preference("IndependentBranches")
393
        && !C4::Context->IsSuperLibrarian() )
396
        && !C4::Context->IsSuperLibrarian() )
394
    {
397
    {
395
        my $query = q{
398
        my $branches =
399
          GetIndependentGroupModificationRights( { stringify => 1 } );
400
401
        my $query = qq{
396
            SELECT count(*)
402
            SELECT count(*)
397
            FROM suggestions
403
            FROM suggestions
398
                LEFT JOIN borrowers ON borrowers.borrowernumber=suggestions.suggestedby
404
                LEFT JOIN borrowers ON borrowers.borrowernumber=suggestions.suggestedby
399
            WHERE STATUS=?
405
            WHERE STATUS=?
400
                AND (borrowers.branchcode='' OR borrowers.branchcode=?)
406
                AND (
407
                    borrowers.branchcode IN ( $branches )
408
                    OR
409
                    borrowers.branchcode=?
410
                )
401
        };
411
        };
402
        $sth = $dbh->prepare($query);
412
        $sth = $dbh->prepare($query);
403
        $sth->execute( $status, $userenv->{branch} );
413
        $sth->execute( $status, $userenv->{branch} );
(-)a/acqui/basket.pl (-8 / +20 lines)
Lines 35-40 use C4::Members qw/GetMember/; #needed for permissions checking for changing ba Link Here
35
use C4::Items;
35
use C4::Items;
36
use C4::Suggestions;
36
use C4::Suggestions;
37
use Date::Calc qw/Add_Delta_Days/;
37
use Date::Calc qw/Add_Delta_Days/;
38
use C4::Branch qw/GetIndependentGroupModificationRights/;
38
39
39
=head1 NAME
40
=head1 NAME
40
41
Lines 105-115 if ( $op eq 'delete_confirm' ) { Link Here
105
    $template->param( delete_confirm => 1 );
106
    $template->param( delete_confirm => 1 );
106
    if ( C4::Context->preference("IndependentBranches") ) {
107
    if ( C4::Context->preference("IndependentBranches") ) {
107
        my $userenv = C4::Context->userenv;
108
        my $userenv = C4::Context->userenv;
108
        unless ( $userenv->{flags} == 1 ) {
109
        if ( $userenv->{flags} % 2 != 1 ) {
109
            my $validtest = ( $basket->{creationdate} eq '' )
110
            my $validtest =
110
              || ( $userenv->{branch} eq $basket->{branch} )
111
                 ( $basket->{creationdate} eq '' )
111
              || ( $userenv->{branch} eq '' )
112
              || ( $userenv->{branch} eq '' )
112
              || ( $basket->{branch}  eq '' );
113
              || ( $basket->{branch}  eq '' )
114
              || (
115
                GetIndependentGroupModificationRights(
116
                    { for => $basket->{branch} }
117
                )
118
              );
119
113
            unless ($validtest) {
120
            unless ($validtest) {
114
                print $query->redirect("../mainpage.pl");
121
                print $query->redirect("../mainpage.pl");
115
                exit 1;
122
                exit 1;
Lines 194-204 if ( $op eq 'delete_confirm' ) { Link Here
194
    # get librarian branch...
201
    # get librarian branch...
195
    if ( C4::Context->preference("IndependentBranches") ) {
202
    if ( C4::Context->preference("IndependentBranches") ) {
196
        my $userenv = C4::Context->userenv;
203
        my $userenv = C4::Context->userenv;
197
        unless ( $userenv->{flags} == 1 ) {
204
        if ( $userenv->{flags} % 2 != 1 ) {
198
            my $validtest = ( $basket->{creationdate} eq '' )
205
            my $validtest =
199
              || ( $userenv->{branch} eq $basket->{branch} )
206
                 ( $basket->{creationdate} eq '' )
200
              || ( $userenv->{branch} eq '' )
207
              || ( $userenv->{branch} eq '' )
201
              || ( $basket->{branch}  eq '' );
208
              || ( $basket->{branch}  eq '' )
209
              || (
210
                GetIndependentGroupModificationRights(
211
                    { for => $basket->{branch} }
212
                )
213
              );
202
            unless ($validtest) {
214
            unless ($validtest) {
203
                print $query->redirect("../mainpage.pl");
215
                print $query->redirect("../mainpage.pl");
204
                exit 1;
216
                exit 1;
(-)a/admin/branches.pl (-37 / +15 lines)
Lines 258-264 sub editbranchform { Link Here
258
        $oldprinter = $data->{'branchprinter'} || '';
258
        $oldprinter = $data->{'branchprinter'} || '';
259
        _branch_to_template($data, $innertemplate);
259
        _branch_to_template($data, $innertemplate);
260
    }
260
    }
261
    $innertemplate->param( categoryloop => $catinfo );
261
    $innertemplate->param( branch_categories  => $catinfo );
262
262
263
    foreach my $thisprinter ( keys %$printers ) {
263
    foreach my $thisprinter ( keys %$printers ) {
264
        push @printerloop, {
264
        push @printerloop, {
Lines 277-301 sub editbranchform { Link Here
277
}
277
}
278
278
279
sub editcatform {
279
sub editcatform {
280
280
    my ( $categorycode, $innertemplate ) = @_;
281
    # prepares the edit form...
281
    $innertemplate->param( category => GetBranchCategory($categorycode) );
282
    my ($categorycode,$innertemplate) = @_;
283
    # warn "cat : $categorycode";
284
	my @cats;
285
    my $data;
286
	if ($categorycode) {
287
        my $data = GetBranchCategory($categorycode);
288
        $innertemplate->param(
289
            categorycode    => $data->{'categorycode'},
290
            categoryname    => $data->{'categoryname'},
291
            codedescription => $data->{'codedescription'},
292
            show_in_pulldown => $data->{'show_in_pulldown'},
293
		);
294
    }
295
	for my $ctype (GetCategoryTypes()) {
296
		push @cats , { type => $ctype , selected => ($data->{'categorytype'} and $data->{'categorytype'} eq $ctype) };
297
	}
298
    $innertemplate->param(categorytype => \@cats);
299
}
282
}
300
283
301
sub branchinfotable {
284
sub branchinfotable {
Lines 366-390 sub branchinfotable { Link Here
366
349
367
        push @loop_data, \%row;
350
        push @loop_data, \%row;
368
    }
351
    }
369
    my @branchcategories = ();
352
370
	for my $ctype ( GetCategoryTypes() ) {
353
    my $catinfo = GetBranchCategories();
371
        my $catinfo = GetBranchCategories($ctype);
354
    my $categories;
372
        my @categories;
355
    foreach my $cat (@$catinfo) {
373
		foreach my $cat (@$catinfo) {
356
        $categories->{ $cat->{categorytype} }->{ $cat->{'categorycode'} } = {
374
            push @categories, {
357
            categoryname    => $cat->{'categoryname'},
375
                categoryname    => $cat->{'categoryname'},
358
            codedescription => $cat->{'codedescription'},
376
                categorycode    => $cat->{'categorycode'},
359
        };
377
                codedescription => $cat->{'codedescription'},
360
    }
378
                categorytype    => $cat->{'categorytype'},
361
379
            };
380
    	}
381
        push @branchcategories, { categorytype => $ctype , $ctype => 1 , catloop => ( @categories ? \@categories : undef) };
382
	}
383
    $innertemplate->param(
362
    $innertemplate->param(
384
        branches         => \@loop_data,
363
        branches          => \@loop_data,
385
        branchcategories => \@branchcategories
364
        branch_categories => $categories
386
    );
365
    );
387
388
}
366
}
389
367
390
sub _branch_to_template {
368
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 700-709 foreach my $field (@fields) { Link Here
700
						|| $subfieldvalue;
700
						|| $subfieldvalue;
701
        }
701
        }
702
702
703
        if (($field->tag eq $branchtagfield) && ($subfieldcode eq $branchtagsubfield) && C4::Context->preference("IndependentBranches")) {
703
        if (   $field->tag eq $branchtagfield
704
            && $subfieldcode eq $branchtagsubfield
705
            && C4::Context->preference("IndependentBranches") )
706
        {
704
            #verifying rights
707
            #verifying rights
705
            my $userenv = C4::Context->userenv();
708
            my $userenv = C4::Context->userenv();
706
            unless (($userenv->{'flags'} == 1) or (($userenv->{'branch'} eq $subfieldvalue))){
709
            unless (
710
                $userenv->{'flags'} % 2 == 1
711
                || GetIndependentGroupModificationRights(
712
                    { for => $subfieldvalue }
713
                )
714
              )
715
            {
707
                $this_row{'nomod'} = 1;
716
                $this_row{'nomod'} = 1;
708
            }
717
            }
709
        }
718
        }
(-)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 / +139 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.selected %]
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 %]
114
                [% END %]
114
                        [% IF bc.categorytype == "searchdomain" %]
115
                <span class="hint">[% categoryloo.codedescription %]</span>
115
                            <li>
116
            </li>
116
                                <label for="[% bc.categorycode %]">[% bc.categoryname %]: </label>
117
        [% END %]
117
                                [% IF ( bc.selected ) %]
118
		</ol>
118
                                    <input type="checkbox" id="[% bc.categorycode %]" name="[% bc.categorycode %]" checked="checked" />
119
</fieldset>[% END %]
119
                                [% ELSE %]
120
                                    <input type="checkbox" id="[% bc.categorycode %]" name="[% bc.categorycode %]" />
121
                                [% END %]
122
                                <span class="hint">[% bc.codedescription %]</span>
123
                            </li>
124
                        [% END %]
125
                    [% END %]
126
                </fieldset>
127
            </ol>
128
            <ol>
129
                <fieldset>
130
                    <legend>Independent library groups</legend>
131
                    [% FOREACH bc IN branch_categories %]
132
                        [% IF bc.categorytype == "independent_group" %]
133
                            <li>
134
                                <label for="[% bc.categorycode %]">[% bc.categoryname %]: </label>
135
                                [% IF ( bc.selected ) %]
136
                                    <input type="checkbox" id="[% bc.categorycode %]" name="[% bc.categorycode %]" checked="checked" />
137
                                [% ELSE %]
138
                                    <input type="checkbox" id="[% bc.categorycode %]" name="[% bc.categorycode %]" />
139
                                [% END %]
140
                                <span class="hint">[% bc.codedescription %]</span>
141
                            </li>
142
                        [% END %]
143
                    [% END %]
144
                <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>
145
                </fieldset>
146
            </ol>
147
        </fieldset>
148
    [% END %]
149
120
	<fieldset class="rows">
150
	<fieldset class="rows">
121
	<ol>
151
	<ol>
122
        <li><label for="branchaddress1">Address line 1: </label><input type="text" name="branchaddress1" id="branchaddress1" size="60" value="[% branchaddress1 |html %]" /></li>
152
        <li><label for="branchaddress1">Address line 1: </label><input type="text" name="branchaddress1" id="branchaddress1" size="60" value="[% branchaddress1 |html %]" /></li>
Lines 252-341 tinyMCE.init({ Link Here
252
	[% ELSE %]
282
	[% 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>
283
	<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 %]
284
	[% END %]
255
    
285
256
   [% IF ( branchcategories ) %]
286
    <h3>Search domain groups</h3>
257
   [% FOREACH branchcategorie IN branchcategories %]
287
    [% IF branch_categories.searchdomain %]
258
    <h3>Group(s):  [% IF ( branchcategorie.properties ) %]Properties[% ELSE %][% IF ( branchcategorie.searchdomain ) %]Search domain[% END %][% END %]</h3>
288
        <table>
259
    [% IF ( branchcategorie.catloop ) %]
289
            <thead>
260
      <table>
290
                <tr>
261
        <thead>
291
                    <th>Name</th>
262
          <tr>
292
                    <th>Code</th>
263
            <th>Name</th>
293
                    <th>Description</th>
264
            <th>Code</th>
294
                    <th>&nbsp;</th>
265
            <th>Description</th>
295
                    <th>&nbsp;</th>
266
            <th>&nbsp;</th>
296
                  </tr>
267
            <th>&nbsp;</th>
297
            </thead>
268
          </tr>
298
            <tbody>
269
        </thead>
299
                [% FOREACH bc IN branch_categories.searchdomain %]
270
        <tbody>
300
                    <tr>
271
          [% FOREACH catloo IN branchcategorie.catloop %]
301
                      <td>[% bc.value.categoryname %]</td>
272
            <tr>
302
                      <td>[% bc.key %]</td>
273
              <td>[% catloo.categoryname %]</td>
303
                      <td>[% bc.value.codedescription %]</td>
274
              <td>[% catloo.categorycode %]</td>
304
                      <td>
275
              <td>[% catloo.codedescription %]</td>
305
                        <a href="?op=editcategory&amp;categorycode=[% bc.key |url %]">Edit</a>
276
              <td>
306
                      </td>
277
                <a href="[% catloo.action %]?op=editcategory&amp;categorycode=[% catloo.categorycode |url %]">Edit</a>
307
                      <td>
278
              </td>
308
                        <a href="?op=delete_category&amp;categorycode=[% bc.key |url %]">Delete</a>
279
              <td>
309
                      </td>
280
                <a href="[% catloo.action %]?op=delete_category&amp;categorycode=[% catloo.categorycode |url %]">Delete</a>
310
                    </tr>
281
              </td>
311
                [% END %]
282
            </tr>
312
            </tbody>
283
          [% END %]
313
        </table>
284
        </tbody>
314
    [% ELSE %]
285
      </table>
315
        No search domain groups defined.
316
    [% END %]
317
    <a href="/cgi-bin/koha/admin/branches.pl?op=editcategory">Add a new group</a>.
318
319
    <h3>Independent library groups:</h3>
320
    [% IF branch_categories.independent_group %]
321
        <table>
322
            <thead>
323
                <tr>
324
                    <th>Name</th>
325
                    <th>Code</th>
326
                    <th>Description</th>
327
                    <th>&nbsp;</th>
328
                    <th>&nbsp;</th>
329
                  </tr>
330
            </thead>
331
            <tbody>
332
                [% FOREACH bc IN branch_categories.independent_group %]
333
                    <tr>
334
                      <td>[% bc.value.categoryname %]</td>
335
                      <td>[% bc.key %]</td>
336
                      <td>[% bc.value.codedescription %]</td>
337
                      <td>
338
                        <a href="?op=editcategory&amp;categorycode=[% bc.key |url %]">Edit</a>
339
                      </td>
340
                      <td>
341
                        <a href="?op=delete_category&amp;categorycode=[% bc.key |url %]">Delete</a>
342
                      </td>
343
                    </tr>
344
                [% END %]
345
            </tbody>
346
        </table>
286
    [% ELSE %]
347
    [% 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>.
348
        No independent library groups defined.
288
    [% END %]
349
    [% END %]
289
  [% END %]
350
    <a href="/cgi-bin/koha/admin/branches.pl?op=editcategory">Add a new group</a>.
290
  [% ELSE %]
291
    <p>No groups defined.</p>
292
  [% END %] <!-- NAME="branchcategories" -->
293
[% END %]
351
[% END %]
294
352
295
[% IF ( editcategory ) %]
353
[% IF ( editcategory ) %]
296
    <h3>[% IF ( categorycode ) %]Edit group [% categorycode %][% ELSE %]Add group[% END %]</h3>
354
    <h3>[% IF ( category ) %]Edit group [% category.categorycode %][% ELSE %]Add group[% END %]</h3>
297
    <form action="[% action %]" name="Aform" method="post">
355
    <form action="[% action %]" name="Aform" method="post">
298
    <input type="hidden" name="op" value="addcategory_validate" />
356
    <input type="hidden" name="op" value="addcategory_validate" />
299
	[% IF ( categorycode ) %]
357
    [% IF ( category.categorycode ) %]
300
	<input type="hidden" name="add" value="0">
358
        <input type="hidden" name="add" value="0">
301
	[% ELSE %]
359
    [% ELSE %]
302
	<input type="hidden" name="add" value="1">
360
        <input type="hidden" name="add" value="1">
303
	[% END %]
361
    [% END %]
304
    <fieldset class="rows">
362
    <fieldset class="rows">
305
        
363
        
306
        <ol><li>
364
        <ol><li>
307
                [% IF ( categorycode ) %]
365
                [% IF ( category.categorycode ) %]
308
				<span class="label">Category code: </span>
366
				<span class="label">Category code: </span>
309
                    <input type="hidden" name="categorycode" id="categorycode" value="[% categorycode |html %]" />
367
                    <input type="hidden" name="categorycode" id="categorycode" value="[% category.categorycode | html %]" />
310
                    [% categorycode %]
368
                    [% category.categorycode %]
311
                [% ELSE %]
369
                [% ELSE %]
312
                <label for="categorycode">Category code:</label>
370
                    <label for="categorycode">Category code:</label>
313
                    <input type="text" name="categorycode" id="categorycode" size="10" maxlength="10" value="[% categorycode |html %]" />
371
                    <input type="text" name="categorycode" id="categorycode" size="10" maxlength="10" value="[% categorycode | html %]" />
314
                [% END %]
372
                [% END %]
315
            </li>
373
            </li>
316
        <li>
374
        <li>
317
            <label for="categoryname">Name: </label>
375
            <label for="categoryname">Name: </label>
318
            <input type="text" name="categoryname" id="categoryname" size="32" maxlength="32" value="[% categoryname |html %]" />
376
            <input type="text" name="categoryname" id="categoryname" size="32" maxlength="32" value="[% category.categoryname | html %]" />
319
        </li>
377
        </li>
320
        <li>
378
        <li>
321
            <label for="codedescription">Description: </label>
379
            <label for="codedescription">Description: </label>
322
            <input type="text" name="codedescription" id="codedescription" size="70" value="[% codedescription |html %]" />
380
            <input type="text" name="codedescription" id="codedescription" size="70" value="[% category.codedescription | html %]" />
323
        </li>
381
        </li>
324
		<li>
382
		<li>
325
        <label for="categorytype">Category type: </label>
383
        <label for="categorytype">Category type: </label>
326
            <select id="categorytype" name="categorytype">
384
            <select id="categorytype" name="categorytype">
327
            [% FOREACH categorytyp IN categorytype %]
385
                [% IF ( category.categorytype == 'searchdomain' ) %]
328
                [% IF ( categorytyp.selected ) %]
386
                    <option value="searchdomain" selected="selected">Search domain</option>
329
                    <option value="[% categorytyp.type %]" selected="selected">
330
                [% ELSE %]
387
                [% ELSE %]
331
                    <option value="[% categorytyp.type %]">
388
                    <option value="searchdomain">Search domain</option>
332
                [% END %] [% categorytyp.type %]</option>
389
                [% END %]
333
            [% END %]
390
391
                [% IF ( category.categorytype == 'independent_group' ) %]
392
                    <option value="independent_group" selected="selected">Independent group</option>
393
                [% ELSE %]
394
                    <option value="independent_group">Independent group</option>
395
                [% END %]
334
            </select>
396
            </select>
335
		</li>
397
		</li>
336
        <li>
398
        <li>
337
            <label for="show_in_pulldown">Show in search pulldown: </label>
399
            <label for="show_in_pulldown">Show in search pulldown: </label>
338
            [% IF ( show_in_pulldown ) %]
400
            [% IF ( category.show_in_pulldown ) %]
339
                <input type="checkbox" name="show_in_pulldown" id="show_in_pulldown" checked="checked"/>
401
                <input type="checkbox" name="show_in_pulldown" id="show_in_pulldown" checked="checked"/>
340
            [% ELSE %]
402
            [% ELSE %]
341
                <input type="checkbox" name="show_in_pulldown" id="show_in_pulldown" />
403
                <input type="checkbox" name="show_in_pulldown" id="show_in_pulldown" />
Lines 343-349 tinyMCE.init({ Link Here
343
        </li>
405
        </li>
344
		</ol>
406
		</ol>
345
    </fieldset>
407
    </fieldset>
346
	<fieldset class="action"><input type="submit" value="Update" /></fieldset>
408
  <fieldset class="action">
409
        [% IF category %]
410
            <input type="submit" value="Update group" />
411
        [% ELSE %]
412
            <input type="submit" value="Add group" />
413
        [% END %]
414
    </fieldset>
347
    </form>
415
    </form>
348
[% END %]
416
[% END %]
349
417
(-)a/members/deletemem.pl (-3 / +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
    }
(-)a/members/member.pl (-2 / +1 lines)
Lines 48-54 my ($template, $loggedinuser, $cookie) Link Here
48
48
49
my $theme = $input->param('theme') || "default";
49
my $theme = $input->param('theme') || "default";
50
50
51
my $patron = $input->Vars;
51
my $patron = { $input->Vars };
52
foreach (keys %$patron){
52
foreach (keys %$patron){
53
	delete $$patron{$_} unless($$patron{$_});
53
	delete $$patron{$_} unless($$patron{$_});
54
}
54
}
55
- 

Return to bug 10276