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

(-)a/C4/Auth.pm (-2 / +2 lines)
Lines 1072-1078 sub checkauth { Link Here
1072
                        $branchcode = $query->param('branch');
1072
                        $branchcode = $query->param('branch');
1073
                        $branchname = Koha::Libraries->find($branchcode)->branchname;
1073
                        $branchname = Koha::Libraries->find($branchcode)->branchname;
1074
                    }
1074
                    }
1075
                    my $branches = C4::Branch::GetBranches();
1075
                    my $branches = { map { $_->branchcode => $_->unblessed } Koha::Libraries->search };
1076
                    if ( C4::Context->boolean_preference('IndependentBranches') && C4::Context->boolean_preference('Autolocation') ) {
1076
                    if ( C4::Context->boolean_preference('IndependentBranches') && C4::Context->boolean_preference('Autolocation') ) {
1077
1077
1078
                        # we have to check they are coming from the right ip range
1078
                        # we have to check they are coming from the right ip range
Lines 1511-1517 sub check_api_auth { Link Here
1511
                    $branchcode = $query->param('branch');
1511
                    $branchcode = $query->param('branch');
1512
                    $branchname = Koha::Libraries->find($branchcode)->branchname;
1512
                    $branchname = Koha::Libraries->find($branchcode)->branchname;
1513
                }
1513
                }
1514
                my $branches = C4::Branch::GetBranches();
1514
                my $branches = { map { $_->branchcode => $_->unblessed } Koha::Libraries->search };
1515
                foreach my $br ( keys %$branches ) {
1515
                foreach my $br ( keys %$branches ) {
1516
1516
1517
                    #     now we work with the treatment of ip
1517
                    #     now we work with the treatment of ip
(-)a/C4/Branch.pm (-69 lines)
Lines 30-36 BEGIN { Link Here
30
	@ISA    = qw(Exporter);
30
	@ISA    = qw(Exporter);
31
	@EXPORT = qw(
31
	@EXPORT = qw(
32
		&GetBranch
32
		&GetBranch
33
		&GetBranches
34
	);
33
	);
35
    @EXPORT_OK = qw( &onlymine );
34
    @EXPORT_OK = qw( &onlymine );
36
}
35
}
Lines 49-124 The functions in this module deal with branches. Link Here
49
48
50
=head1 FUNCTIONS
49
=head1 FUNCTIONS
51
50
52
=head2 GetBranches
53
54
  $branches = &GetBranches();
55
56
Returns informations about ALL branches, IndependentBranches Insensitive.
57
58
Create a branch selector with the following code.
59
60
=head3 in PERL SCRIPT
61
62
    my $branches = GetBranches;
63
    my @branchloop;
64
    foreach my $thisbranch (sort keys %$branches) {
65
        my $selected = 1 if $thisbranch eq $branch;
66
        my %row =(value => $thisbranch,
67
                    selected => $selected,
68
                    branchname => $branches->{$thisbranch}->{branchname},
69
                );
70
        push @branchloop, \%row;
71
    }
72
73
=head3 in TEMPLATE
74
75
    <select name="branch" id="branch">
76
        <option value=""></option>
77
            [% FOREACH branchloo IN branchloop %]
78
                [% IF ( branchloo.selected ) %]
79
                    <option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>
80
                [% ELSE %]
81
                    <option value="[% branchloo.value %]" >[% branchloo.branchname %]</option>
82
                [% END %]
83
            [% END %]
84
    </select>
85
86
=cut
51
=cut
87
52
88
sub GetBranches {
89
    my ($onlymine) = @_;
90
91
    # returns a reference to a hash of references to ALL branches...
92
    my %branches;
93
    my $dbh = C4::Context->dbh;
94
    my $sth;
95
    my $query = "SELECT * FROM branches";
96
    my @bind_parameters;
97
    if ( $onlymine && C4::Context->userenv && C4::Context->userenv->{branch} ) {
98
        $query .= ' WHERE branchcode = ? ';
99
        push @bind_parameters, C4::Context->userenv->{branch};
100
    }
101
    $query .= " ORDER BY branchname";
102
    $sth = $dbh->prepare($query);
103
    $sth->execute(@bind_parameters);
104
105
    my $relations_sth =
106
      $dbh->prepare("SELECT branchcode,categorycode FROM branchrelations");
107
    $relations_sth->execute();
108
    my %relations;
109
    while ( my $rel = $relations_sth->fetchrow_hashref ) {
110
        push @{ $relations{ $rel->{branchcode} } }, $rel->{categorycode};
111
    }
112
113
    while ( my $branch = $sth->fetchrow_hashref ) {
114
        foreach my $cat ( @{ $relations{ $branch->{branchcode} } } ) {
115
            $branch->{category}{$cat} = 1;
116
        }
117
        $branches{ $branch->{'branchcode'} } = $branch;
118
    }
119
    return ( \%branches );
120
}
121
122
sub onlymine {
53
sub onlymine {
123
    return
54
    return
124
         C4::Context->preference('IndependentBranches')
55
         C4::Context->preference('IndependentBranches')
(-)a/C4/Circulation.pm (-5 / +8 lines)
Lines 33-39 use C4::Accounts; Link Here
33
use C4::ItemCirculationAlertPreference;
33
use C4::ItemCirculationAlertPreference;
34
use C4::Message;
34
use C4::Message;
35
use C4::Debug;
35
use C4::Debug;
36
use C4::Branch; # GetBranches
37
use C4::Log; # logaction
36
use C4::Log; # logaction
38
use C4::Koha qw(
37
use C4::Koha qw(
39
    GetAuthorisedValueByCode
38
    GetAuthorisedValueByCode
Lines 307-313 sub transferbook { Link Here
307
    my ( $tbr, $barcode, $ignoreRs ) = @_;
306
    my ( $tbr, $barcode, $ignoreRs ) = @_;
308
    my $messages;
307
    my $messages;
309
    my $dotransfer      = 1;
308
    my $dotransfer      = 1;
310
    my $branches        = GetBranches();
311
    my $itemnumber = GetItemnumberFromBarcode( $barcode );
309
    my $itemnumber = GetItemnumberFromBarcode( $barcode );
312
    my $issue      = GetItemIssue($itemnumber);
310
    my $issue      = GetItemIssue($itemnumber);
313
    my $biblio = GetBiblioFromItemNumber($itemnumber);
311
    my $biblio = GetBiblioFromItemNumber($itemnumber);
Lines 336-342 sub transferbook { Link Here
336
    }
334
    }
337
335
338
    # if is permanent...
336
    # if is permanent...
339
    if ( $hbr && $branches->{$hbr}->{'PE'} ) {
337
    # FIXME Is this still used by someone?
338
    # See other FIXME in AddReturn
339
    my $library = Koha::Libraries->find($hbr);
340
    if ( $library and $library->get_categories->search({'me.categorycode' => 'PE'})->count ) {
340
        $messages->{'IsPermanent'} = $hbr;
341
        $messages->{'IsPermanent'} = $hbr;
341
        $dotransfer = 0;
342
        $dotransfer = 0;
342
    }
343
    }
Lines 1875-1882 sub AddReturn { Link Here
1875
    # check if the book is in a permanent collection....
1876
    # check if the book is in a permanent collection....
1876
    # FIXME -- This 'PE' attribute is largely undocumented.  afaict, there's no user interface that reflects this functionality.
1877
    # FIXME -- This 'PE' attribute is largely undocumented.  afaict, there's no user interface that reflects this functionality.
1877
    if ( $returnbranch ) {
1878
    if ( $returnbranch ) {
1878
        my $branches = GetBranches();    # a potentially expensive call for a non-feature.
1879
        my $library = Koha::Libraries->find($returnbranch);
1879
        $branches->{$returnbranch}->{PE} and $messages->{'IsPermanent'} = $returnbranch;
1880
        if ( $library and $library->get_categories->search({'me.categorycode' => 'PE'})->count ) {
1881
            $messages->{'IsPermanent'} = $returnbranch;
1882
        }
1880
    }
1883
    }
1881
1884
1882
    # check if the return is allowed at this branch
1885
    # check if the return is allowed at this branch
(-)a/C4/Context.pm (+6 lines)
Lines 1127-1132 sub interface { Link Here
1127
    return $context->{interface} // 'opac';
1127
    return $context->{interface} // 'opac';
1128
}
1128
}
1129
1129
1130
# always returns a string for OK comparison via "eq" or "ne"
1131
sub mybranch {
1132
    C4::Context->userenv           or return '';
1133
    return C4::Context->userenv->{branch} || '';
1134
}
1135
1130
1;
1136
1;
1131
__END__
1137
__END__
1132
1138
(-)a/C4/ILSDI/Services.pm (-5 / +2 lines)
Lines 23-29 use warnings; Link Here
23
use C4::Members;
23
use C4::Members;
24
use C4::Items;
24
use C4::Items;
25
use C4::Circulation;
25
use C4::Circulation;
26
use C4::Branch;
27
use C4::Accounts;
26
use C4::Accounts;
28
use C4::Biblio;
27
use C4::Biblio;
29
use C4::Reserves qw(AddReserve GetReservesFromBiblionumber GetReservesFromBorrowernumber CanBookBeReserved CanItemBeReserved IsAvailableForItemLevelRequest);
28
use C4::Reserves qw(AddReserve GetReservesFromBiblionumber GetReservesFromBorrowernumber CanBookBeReserved CanItemBeReserved IsAvailableForItemLevelRequest);
Lines 622-629 sub HoldTitle { Link Here
622
    # Pickup branch management
621
    # Pickup branch management
623
    if ( $cgi->param('pickup_location') ) {
622
    if ( $cgi->param('pickup_location') ) {
624
        $branch = $cgi->param('pickup_location');
623
        $branch = $cgi->param('pickup_location');
625
        my $branches = GetBranches;
624
        return { code => 'LocationNotFound' } unless Koha::Libraries->find($branch);
626
        return { code => 'LocationNotFound' } unless $$branches{$branch};
627
    } else { # if the request provide no branch, use the borrower's branch
625
    } else { # if the request provide no branch, use the borrower's branch
628
        $branch = $$borrower{branchcode};
626
        $branch = $$borrower{branchcode};
629
    }
627
    }
Lines 700-707 sub HoldItem { Link Here
700
    my $branch;
698
    my $branch;
701
    if ( $cgi->param('pickup_location') ) {
699
    if ( $cgi->param('pickup_location') ) {
702
        $branch = $cgi->param('pickup_location');
700
        $branch = $cgi->param('pickup_location');
703
        my $branches = GetBranches();
701
        return { code => 'LocationNotFound' } unless Koha::Libraries->find($branch);
704
        return { code => 'LocationNotFound' } unless $$branches{$branch};
705
    } else { # if the request provide no branch, use the borrower's branch
702
    } else { # if the request provide no branch, use the borrower's branch
706
        $branch = $$borrower{branchcode};
703
        $branch = $$borrower{branchcode};
707
    }
704
    }
(-)a/C4/Items.pm (+1 lines)
Lines 1328-1333 sub GetItemsInfo { Link Here
1328
           COALESCE( localization.translation, itemtypes.description ) AS translated_description,
1328
           COALESCE( localization.translation, itemtypes.description ) AS translated_description,
1329
           itemtypes.notforloan as notforloan_per_itemtype,
1329
           itemtypes.notforloan as notforloan_per_itemtype,
1330
           holding.branchurl,
1330
           holding.branchurl,
1331
           holding.branchcode,
1331
           holding.branchname,
1332
           holding.branchname,
1332
           holding.opac_info as holding_branch_opac_info,
1333
           holding.opac_info as holding_branch_opac_info,
1333
           home.opac_info as home_branch_opac_info
1334
           home.opac_info as home_branch_opac_info
(-)a/C4/Overdues.pm (-2 / +2 lines)
Lines 34-39 use C4::Log; # logaction Link Here
34
use C4::Debug;
34
use C4::Debug;
35
use C4::Budgets qw(GetCurrency);
35
use C4::Budgets qw(GetCurrency);
36
use Koha::DateUtils;
36
use Koha::DateUtils;
37
use Koha::Libraries;
37
38
38
use vars qw($VERSION @ISA @EXPORT);
39
use vars qw($VERSION @ISA @EXPORT);
39
40
Lines 774-781 sub GetBranchcodesWithOverdueRules { Link Here
774
    |);
775
    |);
775
    if ( $branchcodes->[0] eq '' ) {
776
    if ( $branchcodes->[0] eq '' ) {
776
        # If a default rule exists, all branches should be returned
777
        # If a default rule exists, all branches should be returned
777
        my $availbranches = C4::Branch::GetBranches();
778
        return map { $_->branchcode } Koha::Libraries->search({}, { order_by => 'branchname' });
778
        return keys %$availbranches;
779
    }
779
    }
780
    return @$branchcodes;
780
    return @$branchcodes;
781
}
781
}
(-)a/C4/Search.pm (-9 / +6 lines)
Lines 28-34 use C4::Search::PazPar2; Link Here
28
use XML::Simple;
28
use XML::Simple;
29
use C4::Members qw(GetHideLostItemsPreference);
29
use C4::Members qw(GetHideLostItemsPreference);
30
use C4::XSLT;
30
use C4::XSLT;
31
use C4::Branch;
32
use C4::Reserves;    # GetReserveStatus
31
use C4::Reserves;    # GetReserveStatus
33
use C4::Debug;
32
use C4::Debug;
34
use C4::Charset;
33
use C4::Charset;
Lines 332-337 sub getRecords { Link Here
332
    my @servers = @$servers_ref;
331
    my @servers = @$servers_ref;
333
    my @sort_by = @$sort_by_ref;
332
    my @sort_by = @$sort_by_ref;
334
333
334
    $branches ||= { map { $_->branchcode => $_->branchname } Koha::Libraries->search };
335
335
    # Initialize variables for the ZOOM connection and results object
336
    # Initialize variables for the ZOOM connection and results object
336
    my $zconn;
337
    my $zconn;
337
    my @zconns;
338
    my @zconns;
Lines 846-851 sub pazGetRecords { Link Here
846
        $query_type,       $scan
847
        $query_type,       $scan
847
    ) = @_;
848
    ) = @_;
848
849
850
    $branches ||= { map { $_->branchcode => $_->branchname } Koha::Libraries->search };
851
849
    my $paz = C4::Search::PazPar2->new(C4::Context->config('pazpar2url'));
852
    my $paz = C4::Search::PazPar2->new(C4::Context->config('pazpar2url'));
850
    $paz->init();
853
    $paz->init();
851
    $paz->search($simple_query);
854
    $paz->search($simple_query);
Lines 1816-1829 sub searchResults { Link Here
1816
    }
1819
    }
1817
1820
1818
    #Build branchnames hash
1821
    #Build branchnames hash
1819
    #find branchname
1822
    my %branches = map { $_->branchcode => $_->branchname } Koha::Libraries->search({}, { order_by => 'branchname' });
1820
    #get branch information.....
1823
1821
    my %branches;
1822
    my $bsth =$dbh->prepare("SELECT branchcode,branchname FROM branches"); # FIXME : use C4::Branch::GetBranches
1823
    $bsth->execute();
1824
    while ( my $bdata = $bsth->fetchrow_hashref ) {
1825
        $branches{ $bdata->{'branchcode'} } = $bdata->{'branchname'};
1826
    }
1827
# FIXME - We build an authorised values hash here, using the default framework
1824
# FIXME - We build an authorised values hash here, using the default framework
1828
# though it is possible to have different authvals for different fws.
1825
# though it is possible to have different authvals for different fws.
1829
1826
(-)a/C4/ShelfBrowser.pm (-3 / +2 lines)
Lines 23-31 use strict; Link Here
23
use warnings;
23
use warnings;
24
24
25
use C4::Biblio;
25
use C4::Biblio;
26
use C4::Branch;
27
use C4::Context;
26
use C4::Context;
28
use C4::Koha;
27
use C4::Koha;
28
use Koha::Libraries;
29
29
30
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
30
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
31
31
Lines 118-124 sub GetNearbyItems { Link Here
118
        if $gap <= $num_each_side;
118
        if $gap <= $num_each_side;
119
119
120
    my $dbh         = C4::Context->dbh;
120
    my $dbh         = C4::Context->dbh;
121
    my $branches = GetBranches();
122
121
123
    my $sth_get_item_details = $dbh->prepare("SELECT cn_sort,homebranch,location,ccode from items where itemnumber=?");
122
    my $sth_get_item_details = $dbh->prepare("SELECT cn_sort,homebranch,location,ccode from items where itemnumber=?");
124
    $sth_get_item_details->execute($itemnumber);
123
    $sth_get_item_details->execute($itemnumber);
Lines 130-136 sub GetNearbyItems { Link Here
130
    if (C4::Context->preference('ShelfBrowserUsesHomeBranch') && 
129
    if (C4::Context->preference('ShelfBrowserUsesHomeBranch') && 
131
    	defined($item_details_result->{'homebranch'})) {
130
    	defined($item_details_result->{'homebranch'})) {
132
        $start_homebranch->{code} = $item_details_result->{'homebranch'};
131
        $start_homebranch->{code} = $item_details_result->{'homebranch'};
133
        $start_homebranch->{description} = $branches->{$item_details_result->{'homebranch'}}{branchname};
132
        $start_homebranch->{description} = Koha::Libraries->find($item_details_result->{'homebranch'})->branchname;
134
    }
133
    }
135
    if (C4::Context->preference('ShelfBrowserUsesLocation') && 
134
    if (C4::Context->preference('ShelfBrowserUsesLocation') && 
136
    	defined($item_details_result->{'location'})) {
135
    	defined($item_details_result->{'location'})) {
(-)a/C4/XSLT.pm (-3 / +5 lines)
Lines 32-37 use C4::Biblio; Link Here
32
use C4::Circulation;
32
use C4::Circulation;
33
use C4::Reserves;
33
use C4::Reserves;
34
use Koha::XSLT_Handler;
34
use Koha::XSLT_Handler;
35
use Koha::Libraries;
35
36
36
use Encode;
37
use Encode;
37
38
Lines 247-253 sub buildKohaItemsNamespace { Link Here
247
    my $shelflocations = GetKohaAuthorisedValues('items.location',GetFrameworkCode($biblionumber), 'opac');
248
    my $shelflocations = GetKohaAuthorisedValues('items.location',GetFrameworkCode($biblionumber), 'opac');
248
    my $ccodes         = GetKohaAuthorisedValues('items.ccode',GetFrameworkCode($biblionumber), 'opac');
249
    my $ccodes         = GetKohaAuthorisedValues('items.ccode',GetFrameworkCode($biblionumber), 'opac');
249
250
250
    my $branches = GetBranches();
251
    my %branches = map { $_->branchcode => $_->branchname } Koha::Libraries->search({}, { order_by => 'branchname' });
252
251
    my $itemtypes = GetItemTypes();
253
    my $itemtypes = GetItemTypes();
252
    my $location = "";
254
    my $location = "";
253
    my $ccode = "";
255
    my $ccode = "";
Lines 288-295 sub buildKohaItemsNamespace { Link Here
288
        } else {
290
        } else {
289
            $status = "available";
291
            $status = "available";
290
        }
292
        }
291
        my $homebranch = $item->{homebranch}? xml_escape($branches->{$item->{homebranch}}->{'branchname'}):'';
293
        my $homebranch = $item->{homebranch}? xml_escape($branches{$item->{homebranch}}->{'branchname'}):'';
292
        my $holdingbranch = $item->{holdingbranch}? xml_escape($branches->{$item->{holdingbranch}}->{'branchname'}):'';
294
        my $holdingbranch = $item->{holdingbranch}? xml_escape($branches{$item->{holdingbranch}}->{'branchname'}):'';
293
        $location = $item->{location}? xml_escape($shelflocations->{$item->{location}}||$item->{location}):'';
295
        $location = $item->{location}? xml_escape($shelflocations->{$item->{location}}||$item->{location}):'';
294
        $ccode = $item->{ccode}? xml_escape($ccodes->{$item->{ccode}}||$item->{ccode}):'';
296
        $ccode = $item->{ccode}? xml_escape($ccodes->{$item->{ccode}}||$item->{ccode}):'';
295
        my $itemcallnumber = xml_escape($item->{itemcallnumber});
297
        my $itemcallnumber = xml_escape($item->{itemcallnumber});
(-)a/Koha/Libraries.pm (-1 / +20 lines)
Lines 21-28 use Modern::Perl; Link Here
21
21
22
use Carp;
22
use Carp;
23
23
24
use Koha::Database;
24
use C4::Context;
25
25
26
use Koha::Database;
26
use Koha::Library;
27
use Koha::Library;
27
28
28
use base qw(Koha::Objects);
29
use base qw(Koha::Objects);
Lines 37-42 Koha::Libraries - Koha Library Object set class Link Here
37
38
38
=cut
39
=cut
39
40
41
=head3 search_filtered
42
43
=cut
44
45
sub search_filtered {
46
    my ( $self, $params, $attributes ) = @_;
47
48
    if (    C4::Context->preference('IndependentBranches')
49
        and C4::Context->userenv
50
        and not C4::Context->IsSuperLibrarian()
51
        and C4::Context->userenv->{branch}
52
    ) {
53
        $params->{branchcode} = C4::Context->userenv->{branch};
54
    }
55
56
    return $self->SUPER::search( $params, $attributes );
57
}
58
40
=head3 type
59
=head3 type
41
60
42
=cut
61
=cut
(-)a/Koha/Template/Plugin/Branches.pm (-15 / +6 lines)
Lines 25-30 use base qw( Template::Plugin ); Link Here
25
25
26
use C4::Koha;
26
use C4::Koha;
27
use C4::Context;
27
use C4::Context;
28
use Koha::Libraries;
28
29
29
sub GetName {
30
sub GetName {
30
    my ( $self, $branchcode ) = @_;
31
    my ( $self, $branchcode ) = @_;
Lines 57-77 sub GetURL { Link Here
57
sub all {
58
sub all {
58
    my ( $self, $params ) = @_;
59
    my ( $self, $params ) = @_;
59
    my $selected = $params->{selected};
60
    my $selected = $params->{selected};
60
    my $dbh = C4::Context->dbh;
61
    my $unfiltered = $params->{unfiltered} || 0;
61
    my @params;
62
62
    my $query = q|
63
    my $libraries = $unfiltered
63
        SELECT branchcode, branchname
64
      ? Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed
64
        FROM branches
65
      : Koha::Libraries->search_filtered( {}, { order_by => ['branchname'] } )->unblessed;
65
    |;
66
    if (    C4::Context->preference('IndependentBranches')
67
        and C4::Context->userenv
68
        && !C4::Context->IsSuperLibrarian()
69
        and C4::Context->userenv->{branch} )
70
    {
71
        $query .= q| WHERE branchcode = ? |;
72
        push @params, C4::Context->userenv->{branch};
73
    }
74
    my $libraries = $dbh->selectall_arrayref( $query, { Slice => {} }, @params );
75
66
76
    for my $l ( @$libraries ) {
67
    for my $l ( @$libraries ) {
77
        if (       $selected and $l->{branchcode} eq $selected
68
        if (       $selected and $l->{branchcode} eq $selected
(-)a/acqui/add_user_search.pl (-5 lines)
Lines 21-27 use Modern::Perl; Link Here
21
21
22
use CGI qw ( -utf8 );
22
use CGI qw ( -utf8 );
23
use C4::Auth;
23
use C4::Auth;
24
use C4::Branch qw( GetBranches );
25
use C4::Output;
24
use C4::Output;
26
use C4::Members;
25
use C4::Members;
27
26
Lines 52-60 my $search_patrons_with_acq_perm_only = Link Here
52
    ( $referer =~ m|acqui/basket.pl| )
51
    ( $referer =~ m|acqui/basket.pl| )
53
        ? 1 : 0;
52
        ? 1 : 0;
54
53
55
my $onlymine = C4::Branch::onlymine;
56
my $branches = C4::Branch::GetBranches( $onlymine );
57
58
my $patron_categories = Koha::Patron::Categories->search_limited;
54
my $patron_categories = Koha::Patron::Categories->search_limited;
59
$template->param(
55
$template->param(
60
    patrons_with_acq_perm_only => $search_patrons_with_acq_perm_only,
56
    patrons_with_acq_perm_only => $search_patrons_with_acq_perm_only,
Lines 64-70 $template->param( Link Here
64
    selection_type => 'add',
60
    selection_type => 'add',
65
    alphabet        => ( C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ),
61
    alphabet        => ( C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ),
66
    categories      => $patron_categories,
62
    categories      => $patron_categories,
67
    branches        => [ map { { branchcode => $_->{branchcode}, branchname => $_->{branchname} } } values %$branches ],
68
    aaSorting       => 1,
63
    aaSorting       => 1,
69
);
64
);
70
output_html_with_http_headers( $input, $cookie, $template->output );
65
output_html_with_http_headers( $input, $cookie, $template->output );
(-)a/acqui/addorderiso2709.pl (-1 lines)
Lines 39-45 use C4::Koha; Link Here
39
use C4::Budgets;
39
use C4::Budgets;
40
use C4::Acquisition;
40
use C4::Acquisition;
41
use C4::Suggestions;    # GetSuggestion
41
use C4::Suggestions;    # GetSuggestion
42
use C4::Branch;         # GetBranches
43
use C4::Members;
42
use C4::Members;
44
43
45
use Koha::Number::Price;
44
use Koha::Number::Price;
(-)a/acqui/basket.pl (-2 / +3 lines)
Lines 28-40 use C4::Output; Link Here
28
use CGI qw ( -utf8 );
28
use CGI qw ( -utf8 );
29
use C4::Acquisition;
29
use C4::Acquisition;
30
use C4::Budgets;
30
use C4::Budgets;
31
use C4::Branch;
32
use C4::Contract;
31
use C4::Contract;
33
use C4::Debug;
32
use C4::Debug;
34
use C4::Biblio;
33
use C4::Biblio;
35
use C4::Members qw/GetMember/;  #needed for permissions checking for changing basketgroup of a basket
34
use C4::Members qw/GetMember/;  #needed for permissions checking for changing basketgroup of a basket
36
use C4::Items;
35
use C4::Items;
37
use C4::Suggestions;
36
use C4::Suggestions;
37
use Koha::Libraries;
38
use Date::Calc qw/Add_Delta_Days/;
38
use Date::Calc qw/Add_Delta_Days/;
39
39
40
=head1 NAME
40
=head1 NAME
Lines 226-231 if ( $op eq 'delete_confirm' ) { Link Here
226
                exit 1;
226
                exit 1;
227
            }
227
            }
228
        }
228
        }
229
229
        if (!defined $basket->{branch} or $basket->{branch} eq $userenv->{branch}) {
230
        if (!defined $basket->{branch} or $basket->{branch} eq $userenv->{branch}) {
230
            push @branches_loop, {
231
            push @branches_loop, {
231
                branchcode => $userenv->{branch},
232
                branchcode => $userenv->{branch},
Lines 235-241 if ( $op eq 'delete_confirm' ) { Link Here
235
        }
236
        }
236
    } else {
237
    } else {
237
        # get branches
238
        # get branches
238
        my $branches = C4::Branch::GetBranches;
239
        my $branches = Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed;
239
        my @branchcodes = sort {
240
        my @branchcodes = sort {
240
            $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname}
241
            $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname}
241
        } keys %$branches;
242
        } keys %$branches;
(-)a/acqui/basketheader.pl (-2 lines)
Lines 50-56 use warnings; Link Here
50
use CGI qw ( -utf8 );
50
use CGI qw ( -utf8 );
51
use C4::Context;
51
use C4::Context;
52
use C4::Auth;
52
use C4::Auth;
53
use C4::Branch;
54
use C4::Output;
53
use C4::Output;
55
use C4::Acquisition qw/GetBasket NewBasket ModBasketHeader/;
54
use C4::Acquisition qw/GetBasket NewBasket ModBasketHeader/;
56
use C4::Contract qw/GetContracts/;
55
use C4::Contract qw/GetContracts/;
Lines 72-78 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
72
#parameters:
71
#parameters:
73
my $booksellerid = $input->param('booksellerid');
72
my $booksellerid = $input->param('booksellerid');
74
my $basketno = $input->param('basketno');
73
my $basketno = $input->param('basketno');
75
my $branches = GetBranches;
76
my $basket;
74
my $basket;
77
my $op = $input ->param('op');
75
my $op = $input ->param('op');
78
my $is_an_edit= $input ->param('is_an_edit');
76
my $is_an_edit= $input ->param('is_an_edit');
(-)a/acqui/invoices.pl (-21 lines)
Lines 34-40 use C4::Auth; Link Here
34
use C4::Output;
34
use C4::Output;
35
35
36
use C4::Acquisition qw/GetInvoices/;
36
use C4::Acquisition qw/GetInvoices/;
37
use C4::Branch qw/GetBranches/;
38
use C4::Budgets;
37
use C4::Budgets;
39
use Koha::DateUtils;
38
use Koha::DateUtils;
40
39
Lines 105-128 foreach (@suppliers) { Link Here
105
      };
104
      };
106
}
105
}
107
106
108
# Build branches list
109
my $branches      = GetBranches();
110
my $branches_loop = [];
111
my $branchname;
112
foreach ( sort keys %$branches ) {
113
    my $selected = 0;
114
    if ( $branch && $branch eq $_ ) {
115
        $selected   = 1;
116
        $branchname = $branches->{$_}->{'branchname'};
117
    }
118
    push @{$branches_loop},
119
      {
120
        branchcode => $_,
121
        branchname => $branches->{$_}->{branchname},
122
        selected   => $selected,
123
      };
124
}
125
126
my $budgets = GetBudgets();
107
my $budgets = GetBudgets();
127
my @budgets_loop;
108
my @budgets_loop;
128
foreach my $budget (@$budgets) {
109
foreach my $budget (@$budgets) {
Lines 147-155 $template->param( Link Here
147
    publisher       => $publisher,
128
    publisher       => $publisher,
148
    publicationyear => $publicationyear,
129
    publicationyear => $publicationyear,
149
    branch          => $branch,
130
    branch          => $branch,
150
    branchname      => $branchname,
151
    suppliers_loop  => $suppliers_loop,
131
    suppliers_loop  => $suppliers_loop,
152
    branches_loop   => $branches_loop,
153
);
132
);
154
133
155
output_html_with_http_headers $input, $cookie, $template->output;
134
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/acqui/lateorders.pl (-1 lines)
Lines 52-58 use C4::Output; Link Here
52
use C4::Context;
52
use C4::Context;
53
use C4::Acquisition;
53
use C4::Acquisition;
54
use C4::Letters;
54
use C4::Letters;
55
use C4::Branch; # GetBranches
56
use Koha::DateUtils;
55
use Koha::DateUtils;
57
56
58
my $input = new CGI;
57
my $input = new CGI;
(-)a/acqui/neworderempty.pl (-1 lines)
Lines 81-87 use C4::Biblio; # GetBiblioData GetMarcPrice Link Here
81
use C4::Items; #PrepareItemRecord
81
use C4::Items; #PrepareItemRecord
82
use C4::Output;
82
use C4::Output;
83
use C4::Koha;
83
use C4::Koha;
84
use C4::Branch;			# GetBranches
85
use C4::Members;
84
use C4::Members;
86
use C4::Search qw/FindDuplicate/;
85
use C4::Search qw/FindDuplicate/;
87
86
(-)a/acqui/newordersubscription.pl (-14 lines)
Lines 21-27 use Modern::Perl; Link Here
21
use CGI qw ( -utf8 );
21
use CGI qw ( -utf8 );
22
use C4::Acquisition;
22
use C4::Acquisition;
23
use C4::Auth;
23
use C4::Auth;
24
use C4::Branch;
25
use C4::Context;
24
use C4::Context;
26
use C4::Output;
25
use C4::Output;
27
use C4::Serials;
26
use C4::Serials;
Lines 76-93 foreach my $sub (@subscriptions) { Link Here
76
    }
75
    }
77
}
76
}
78
77
79
my $branches = GetBranches();
80
my @branches_loop;
81
foreach (sort keys %$branches){
82
    my $selected = 0;
83
    $selected = 1 if defined $branch && $branch eq $_;
84
    push @branches_loop, {
85
        branchcode  => $_,
86
        branchname  => $branches->{$_}->{branchname},
87
        selected    => $selected,
88
    };
89
}
90
91
$template->param(
78
$template->param(
92
    subs_loop        => \@subscriptions,
79
    subs_loop        => \@subscriptions,
93
    title_filter     => $title,
80
    title_filter     => $title,
Lines 96-102 $template->param( Link Here
96
    publisher_filter => $publisher,
83
    publisher_filter => $publisher,
97
    supplier_filter  => $supplier,
84
    supplier_filter  => $supplier,
98
    branch_filter    => $branch,
85
    branch_filter    => $branch,
99
    branches_loop    => \@branches_loop,
100
    done_searched    => $searched,
86
    done_searched    => $searched,
101
    routing          => $routing,
87
    routing          => $routing,
102
    booksellerid     => $booksellerid,
88
    booksellerid     => $booksellerid,
(-)a/acqui/orderreceive.pl (-1 lines)
Lines 69-75 use C4::Auth; Link Here
69
use C4::Output;
69
use C4::Output;
70
use C4::Budgets qw/ GetBudget GetBudgetHierarchy CanUserUseBudget GetBudgetPeriods /;
70
use C4::Budgets qw/ GetBudget GetBudgetHierarchy CanUserUseBudget GetBudgetPeriods /;
71
use C4::Members;
71
use C4::Members;
72
use C4::Branch;    # GetBranches
73
use C4::Items;
72
use C4::Items;
74
use C4::Biblio;
73
use C4::Biblio;
75
use C4::Suggestions;
74
use C4::Suggestions;
(-)a/admin/add_user_search.pl (-5 lines)
Lines 21-27 use Modern::Perl; Link Here
21
21
22
use CGI qw ( -utf8 );
22
use CGI qw ( -utf8 );
23
use C4::Auth;
23
use C4::Auth;
24
use C4::Branch qw( GetBranches );
25
use C4::Output;
24
use C4::Output;
26
use C4::Members;
25
use C4::Members;
27
26
Lines 53-61 my $search_patrons_with_acq_perm_only = Link Here
53
    ( $referer =~ m|admin/aqbudgets.pl| )
52
    ( $referer =~ m|admin/aqbudgets.pl| )
54
        ? 1 : 0;
53
        ? 1 : 0;
55
54
56
my $onlymine = C4::Branch::onlymine;
57
my $branches = C4::Branch::GetBranches( $onlymine );
58
59
my $patron_categories = Koha::Patron::Categories->search_limited;
55
my $patron_categories = Koha::Patron::Categories->search_limited;
60
$template->param(
56
$template->param(
61
    patrons_with_acq_perm_only => $search_patrons_with_acq_perm_only,
57
    patrons_with_acq_perm_only => $search_patrons_with_acq_perm_only,
Lines 65-71 $template->param( Link Here
65
    selection_type => $selection_type,
61
    selection_type => $selection_type,
66
    alphabet        => ( C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ),
62
    alphabet        => ( C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ),
67
    categories      => $patron_categories,
63
    categories      => $patron_categories,
68
    branches        => [ map { { branchcode => $_->{branchcode}, branchname => $_->{branchname} } } values %$branches ],
69
    aaSorting       => 1,
64
    aaSorting       => 1,
70
);
65
);
71
output_html_with_http_headers( $input, $cookie, $template->output );
66
output_html_with_http_headers( $input, $cookie, $template->output );
(-)a/admin/aqbudgets.pl (-15 lines)
Lines 26-32 use List::Util qw/min/; Link Here
26
26
27
use Koha::Database;
27
use Koha::Database;
28
use C4::Auth qw/get_user_subpermissions/;
28
use C4::Auth qw/get_user_subpermissions/;
29
use C4::Branch; # GetBranches
30
use C4::Auth;
29
use C4::Auth;
31
use C4::Acquisition;
30
use C4::Acquisition;
32
use C4::Budgets;
31
use C4::Budgets;
Lines 140-157 if ($op eq 'add_form') { Link Here
140
    }
139
    }
141
    $budget_parent = GetBudget($budget_parent_id);
140
    $budget_parent = GetBudget($budget_parent_id);
142
141
143
    # build branches select
144
    my $branches = GetBranches;
145
    my @branchloop_select;
146
    foreach my $thisbranch ( sort keys %$branches ) {
147
        my %row = (
148
            value      => $thisbranch,
149
            branchname => $branches->{$thisbranch}->{'branchname'},
150
        );
151
        $row{selected} = 1 if $budget and $thisbranch eq $budget->{'budget_branchcode'};
152
        push @branchloop_select, \%row;
153
    }
154
155
    # populates the YUI planning button
142
    # populates the YUI planning button
156
    my $categories = GetAuthorisedValueCategories();
143
    my $categories = GetAuthorisedValueCategories();
157
    my @auth_cats_loop1 = ();
144
    my @auth_cats_loop1 = ();
Lines 199-205 if ($op eq 'add_form') { Link Here
199
        budget_has_children => BudgetHasChildren( $budget->{budget_id} ),
186
        budget_has_children => BudgetHasChildren( $budget->{budget_id} ),
200
        budget_parent_id    		  => $budget_parent->{'budget_id'},
187
        budget_parent_id    		  => $budget_parent->{'budget_id'},
201
        budget_parent_name    		  => $budget_parent->{'budget_name'},
188
        budget_parent_name    		  => $budget_parent->{'budget_name'},
202
        branchloop_select         => \@branchloop_select,
203
		%$period,
189
		%$period,
204
		%$budget,
190
		%$budget,
205
    );
191
    );
Lines 257-263 if ($op eq 'add_form') { Link Here
257
}
243
}
258
244
259
if ( $op eq 'list' ) {
245
if ( $op eq 'list' ) {
260
    my $branches = GetBranches();
261
    $template->param(
246
    $template->param(
262
        budget_id => $budget_id,
247
        budget_id => $budget_id,
263
        %$period,
248
        %$period,
(-)a/admin/authorised_values.pl (-3 / +2 lines)
Lines 21-32 use Modern::Perl; Link Here
21
21
22
use CGI qw ( -utf8 );
22
use CGI qw ( -utf8 );
23
use C4::Auth;
23
use C4::Auth;
24
use C4::Branch;
25
use C4::Context;
24
use C4::Context;
26
use C4::Koha;
25
use C4::Koha;
27
use C4::Output;
26
use C4::Output;
28
27
29
use Koha::AuthorisedValues;
28
use Koha::AuthorisedValues;
29
use Koha::Libraries;
30
30
31
my $input = new CGI;
31
my $input = new CGI;
32
my $id          = $input->param('id');
32
my $id          = $input->param('id');
Lines 56-64 if ($op eq 'add_form') { Link Here
56
        $category = $input->param('category');
56
        $category = $input->param('category');
57
    }
57
    }
58
58
59
    my $branches = GetBranches;
59
    my $branches = Koha::Libraries->search->unblessed;
60
    my @branches_loop;
60
    my @branches_loop;
61
62
    foreach my $branchcode ( sort { uc($branches->{$a}->{branchname}) cmp uc($branches->{$b}->{branchname}) } keys %$branches ) {
61
    foreach my $branchcode ( sort { uc($branches->{$a}->{branchname}) cmp uc($branches->{$b}->{branchname}) } keys %$branches ) {
63
        my $selected = ( grep {$_ eq $branchcode} @$selected_branches ) ? 1 : 0;
62
        my $selected = ( grep {$_ eq $branchcode} @$selected_branches ) ? 1 : 0;
64
        push @branches_loop, {
63
        push @branches_loop, {
(-)a/admin/branch_transfer_limits.pl (-14 lines)
Lines 26-32 use C4::Auth; Link Here
26
use C4::Context;
26
use C4::Context;
27
use C4::Output;
27
use C4::Output;
28
use C4::Koha;
28
use C4::Koha;
29
use C4::Branch; 
30
use C4::Circulation qw{ IsBranchTransferAllowed DeleteBranchTransferLimits CreateBranchTransferLimit };
29
use C4::Circulation qw{ IsBranchTransferAllowed DeleteBranchTransferLimits CreateBranchTransferLimit };
31
30
32
my $input = new CGI;
31
my $input = new CGI;
Lines 50-67 else Link Here
50
	$branchcode = $input->param('branchcode');
49
	$branchcode = $input->param('branchcode');
51
}
50
}
52
51
53
# Getting the branches for user selection
54
my $branches = GetBranches();
55
my @branch_loop;
56
for my $thisbranch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %$branches) {
57
    my %row =(value => $thisbranch,
58
              branchname => $branches->{$thisbranch}->{'branchname'},
59
              selected => $thisbranch eq $branchcode ? 1 : 0,
60
             );
61
    push @branch_loop, \%row;
62
}
63
64
65
# Set the template language for the correct limit type using $limitType
52
# Set the template language for the correct limit type using $limitType
66
my $limitType = C4::Context->preference("BranchTransferLimitsType") || "ccode";
53
my $limitType = C4::Context->preference("BranchTransferLimitsType") || "ccode";
67
54
Lines 132-138 foreach my $code ( @codes ) { Link Here
132
$template->param(
119
$template->param(
133
		branchcount => $branchcount,
120
		branchcount => $branchcount,
134
		codes_loop => \@codes_loop,
121
		codes_loop => \@codes_loop,
135
		branch_loop => \@branch_loop,
136
		branchcode_loop => \@branchcode_loop,
122
		branchcode_loop => \@branchcode_loop,
137
		branchcode => $branchcode,
123
		branchcode => $branchcode,
138
        limitType => $limitType,
124
        limitType => $limitType,
(-)a/admin/categories.pl (-6 / +6 lines)
Lines 23-35 use Modern::Perl; Link Here
23
use CGI qw ( -utf8 );
23
use CGI qw ( -utf8 );
24
use C4::Context;
24
use C4::Context;
25
use C4::Auth;
25
use C4::Auth;
26
use C4::Branch;
27
use C4::Output;
26
use C4::Output;
28
use C4::Form::MessagingPreferences;
27
use C4::Form::MessagingPreferences;
29
use Koha::Borrowers;
28
use Koha::Borrowers;
30
use Koha::Database;
29
use Koha::Database;
31
use Koha::DateUtils;
30
use Koha::DateUtils;
32
use Koha::Patron::Categories;
31
use Koha::Patron::Categories;
32
use Koha::Libraries;
33
33
34
my $input         = new CGI;
34
my $input         = new CGI;
35
my $searchfield   = $input->param('description') // q||;
35
my $searchfield   = $input->param('description') // q||;
Lines 55-67 if ( $op eq 'add_form' ) { Link Here
55
        $selected_branches = $category->branch_limitations;
55
        $selected_branches = $category->branch_limitations;
56
    }
56
    }
57
57
58
    my $branches = GetBranches;
58
    my $branches = Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed;
59
    my @branches_loop;
59
    my @branches_loop;
60
    foreach my $branchcode ( sort { uc( $branches->{$a}->{branchname} ) cmp uc( $branches->{$b}->{branchname} ) } keys %$branches ) {
60
    foreach my $branch ( @$branches ) {
61
        my $selected = ( grep { $_ eq $branchcode } @$selected_branches ) ? 1 : 0;
61
        my $selected = ( grep { $_->{branchcode} eq $branch } @$selected_branches ) ? 1 : 0;
62
        push @branches_loop,
62
        push @branches_loop,
63
          { branchcode => $branchcode,
63
          { branchcode => $branch->{branchcode},
64
            branchname => $branches->{$branchcode}->{branchname},
64
            branchname => $branches->{branchname},
65
            selected   => $selected,
65
            selected   => $selected,
66
          };
66
          };
67
    }
67
    }
(-)a/admin/item_circulation_alerts.pl (-16 lines)
Lines 26-32 use JSON; Link Here
26
26
27
use C4::Auth;
27
use C4::Auth;
28
use C4::Context;
28
use C4::Context;
29
use C4::Branch;
30
use C4::ItemCirculationAlertPreference;
29
use C4::ItemCirculationAlertPreference;
31
use C4::Output;
30
use C4::Output;
32
31
Lines 51-78 sub show { Link Here
51
        }
50
        }
52
    );
51
    );
53
52
54
    my $br       = GetBranches;
55
    my $branch   = $input->param('branch') || '*';
53
    my $branch   = $input->param('branch') || '*';
56
    my @branches = (
57
        {
58
            branchcode => '*',
59
            branchname => 'Default',
60
        },
61
        sort { $a->{branchname} cmp $b->{branchname} } values %$br,
62
    );
63
    for (@branches) {
64
        $_->{selected} = "selected" if ($branch eq $_->{branchcode});
65
    }
66
    my $branch_name = exists($br->{$branch}) && $br->{$branch}->{branchname};
67
68
    my @categories = Koha::Patron::Categories->search_limited;
54
    my @categories = Koha::Patron::Categories->search_limited;
69
    my @item_types = Koha::ItemTypes->search;
55
    my @item_types = Koha::ItemTypes->search;
70
    my $grid_checkout = $preferences->grid({ branchcode => $branch, notification => 'CHECKOUT' });
56
    my $grid_checkout = $preferences->grid({ branchcode => $branch, notification => 'CHECKOUT' });
71
    my $grid_checkin  = $preferences->grid({ branchcode => $branch, notification => 'CHECKIN' });
57
    my $grid_checkin  = $preferences->grid({ branchcode => $branch, notification => 'CHECKIN' });
72
58
73
    $template->param(branch             => $branch);
59
    $template->param(branch             => $branch);
74
    $template->param(branch_name        => $branch_name || 'Default');
75
    $template->param(branches           => \@branches);
76
    $template->param(categories         => \@categories);
60
    $template->param(categories         => \@categories);
77
    $template->param(item_types         => \@item_types);
61
    $template->param(item_types         => \@item_types);
78
    $template->param(grid_checkout      => $grid_checkout);
62
    $template->param(grid_checkout      => $grid_checkout);
(-)a/admin/patron-attr-types.pl (-7 / +7 lines)
Lines 25-36 use CGI qw ( -utf8 ); Link Here
25
use List::MoreUtils qw/uniq/;
25
use List::MoreUtils qw/uniq/;
26
26
27
use C4::Auth;
27
use C4::Auth;
28
use C4::Branch;
29
use C4::Context;
28
use C4::Context;
30
use C4::Output;
29
use C4::Output;
31
use C4::Koha;
30
use C4::Koha;
32
use C4::Members::AttributeTypes;
31
use C4::Members::AttributeTypes;
33
32
33
use Koha::Libraries;
34
use Koha::Patron::Categories;
34
use Koha::Patron::Categories;
35
35
36
my $script_name = "/cgi-bin/koha/admin/patron-attr-types.pl";
36
my $script_name = "/cgi-bin/koha/admin/patron-attr-types.pl";
Lines 84-90 exit 0; Link Here
84
sub add_attribute_type_form {
84
sub add_attribute_type_form {
85
    my $template = shift;
85
    my $template = shift;
86
86
87
    my $branches = GetBranches;
87
    my $branches = Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed;
88
    my @branches_loop;
88
    my @branches_loop;
89
    foreach my $branch (sort keys %$branches) {
89
    foreach my $branch (sort keys %$branches) {
90
        push @branches_loop, {
90
        push @branches_loop, {
Lines 260-273 sub edit_attribute_type_form { Link Here
260
    pa_classes( $template, $attr_type->class );
260
    pa_classes( $template, $attr_type->class );
261
261
262
262
263
    my $branches = GetBranches;
263
    my $branches = Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed;
264
    my @branches_loop;
264
    my @branches_loop;
265
    my $selected_branches = $attr_type->branches;
265
    my $selected_branches = $attr_type->branches;
266
    foreach my $branch (sort keys %$branches) {
266
    foreach my $branch (@$branches) {
267
        my $selected = ( grep {$$_{branchcode} eq $branch} @$selected_branches ) ? 1 : 0;
267
        my $selected = ( grep {$_->{branchcode} eq $branch} @$selected_branches ) ? 1 : 0;
268
        push @branches_loop, {
268
        push @branches_loop, {
269
            branchcode => $branches->{$branch}{branchcode},
269
            branchcode => $branch->{branchcode},
270
            branchname => $branches->{$branch}{branchname},
270
            branchname => $branch->{branchname},
271
            selected => $selected,
271
            selected => $selected,
272
        };
272
        };
273
    }
273
    }
(-)a/admin/smart-rules.pl (-1 / +1 lines)
Lines 25-31 use C4::Output; Link Here
25
use C4::Auth;
25
use C4::Auth;
26
use C4::Koha;
26
use C4::Koha;
27
use C4::Debug;
27
use C4::Debug;
28
use C4::Branch; # GetBranches
28
use C4::Branch;
29
use Koha::DateUtils;
29
use Koha::DateUtils;
30
use Koha::Database;
30
use Koha::Database;
31
use Koha::IssuingRule;
31
use Koha::IssuingRule;
(-)a/admin/transport-cost-matrix.pl (-6 / +3 lines)
Lines 25-33 use C4::Output; Link Here
25
use C4::Auth;
25
use C4::Auth;
26
use C4::Koha;
26
use C4::Koha;
27
use C4::Debug;
27
use C4::Debug;
28
use C4::Branch; # GetBranches
29
use C4::HoldsQueue qw(TransportCostMatrix UpdateTransportCostMatrix);
28
use C4::HoldsQueue qw(TransportCostMatrix UpdateTransportCostMatrix);
30
29
30
use Koha::Libraries;
31
31
use Data::Dumper;
32
use Data::Dumper;
32
33
33
my $input = new CGI;
34
my $input = new CGI;
Lines 50-60 unless ($update) { Link Here
50
    $have_matrix = keys %$cost_matrix if $cost_matrix;
51
    $have_matrix = keys %$cost_matrix if $cost_matrix;
51
}
52
}
52
53
53
my $branches = GetBranches();
54
my @branchloop = map { code => $_->branchcode, name => $_->branchname }, Koha::Libraries->search({}, { order_by => 'branchname' });
54
my @branchloop = map { code => $_,
55
                       name => $branches->{$_}->{'branchname'} },
56
                 sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} }
57
                 keys %$branches;
58
my (@branchfromloop, @errors);
55
my (@branchfromloop, @errors);
59
foreach my $branchfrom ( @branchloop ) {
56
foreach my $branchfrom ( @branchloop ) {
60
    my $fromcode = $branchfrom->{code};
57
    my $fromcode = $branchfrom->{code};
(-)a/catalogue/detail.pl (-5 / +3 lines)
Lines 28-34 use C4::Output; Link Here
28
use C4::Biblio;
28
use C4::Biblio;
29
use C4::Items;
29
use C4::Items;
30
use C4::Circulation;
30
use C4::Circulation;
31
use C4::Branch;
32
use C4::Reserves;
31
use C4::Reserves;
33
use C4::Members; # to use GetMember
32
use C4::Members; # to use GetMember
34
use C4::Serials;
33
use C4::Serials;
Lines 118-124 my $marchostsarray = GetMarcHosts($record,$marcflavour); Link Here
118
my $subtitle         = GetRecordValue('subtitle', $record, $fw);
117
my $subtitle         = GetRecordValue('subtitle', $record, $fw);
119
118
120
# Get Branches, Itemtypes and Locations
119
# Get Branches, Itemtypes and Locations
121
my $branches = GetBranches();
122
my $itemtypes = GetItemTypes();
120
my $itemtypes = GetItemTypes();
123
my $dbh = C4::Context->dbh;
121
my $dbh = C4::Context->dbh;
124
122
Lines 237-243 foreach my $item (@items) { Link Here
237
        $item->{ReservedForBorrowernumber}     = $reservedfor;
235
        $item->{ReservedForBorrowernumber}     = $reservedfor;
238
        $item->{ReservedForSurname}     = $ItemBorrowerReserveInfo->{'surname'};
236
        $item->{ReservedForSurname}     = $ItemBorrowerReserveInfo->{'surname'};
239
        $item->{ReservedForFirstname}   = $ItemBorrowerReserveInfo->{'firstname'};
237
        $item->{ReservedForFirstname}   = $ItemBorrowerReserveInfo->{'firstname'};
240
        $item->{ExpectedAtLibrary}      = $branches->{$expectedAt}{branchname};
238
        $item->{ExpectedAtLibrary}      = $expectedAt;
241
        $item->{Reservedcardnumber}             = $ItemBorrowerReserveInfo->{'cardnumber'};
239
        $item->{Reservedcardnumber}             = $ItemBorrowerReserveInfo->{'cardnumber'};
242
        # Check waiting status
240
        # Check waiting status
243
        $item->{waitingdate} = $wait;
241
        $item->{waitingdate} = $wait;
Lines 248-255 foreach my $item (@items) { Link Here
248
    my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($item->{itemnumber});
246
    my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($item->{itemnumber});
249
    if ( defined( $transfertwhen ) && ( $transfertwhen ne '' ) ) {
247
    if ( defined( $transfertwhen ) && ( $transfertwhen ne '' ) ) {
250
        $item->{transfertwhen} = $transfertwhen;
248
        $item->{transfertwhen} = $transfertwhen;
251
        $item->{transfertfrom} = $branches->{$transfertfrom}{branchname};
249
        $item->{transfertfrom} = $transfertfrom;
252
        $item->{transfertto}   = $branches->{$transfertto}{branchname};
250
        $item->{transfertto}   = $transfertto;
253
        $item->{nocancel} = 1;
251
        $item->{nocancel} = 1;
254
    }
252
    }
255
253
(-)a/catalogue/itemsearch.pl (-9 / +2 lines)
Lines 25-35 use C4::Auth; Link Here
25
use C4::Output;
25
use C4::Output;
26
use C4::Items;
26
use C4::Items;
27
use C4::Biblio;
27
use C4::Biblio;
28
use C4::Branch;
29
use C4::Koha;
28
use C4::Koha;
30
29
31
use Koha::Item::Search::Field qw(GetItemSearchFields);
30
use Koha::Item::Search::Field qw(GetItemSearchFields);
32
use Koha::ItemTypes;
31
use Koha::ItemTypes;
32
use Koha::Libraries;
33
33
34
my $cgi = new CGI;
34
my $cgi = new CGI;
35
my %params = $cgi->Vars;
35
my %params = $cgi->Vars;
Lines 247-260 if (scalar keys %params > 0) { Link Here
247
if ($format eq 'html') {
247
if ($format eq 'html') {
248
    # Retrieve data required for the form.
248
    # Retrieve data required for the form.
249
249
250
    my $branches = GetBranches();
250
    my @branches = map { value => $_->branchcode => label => $_->branchname }, Koha::Libraries->search( {}, { order_by => 'branchname' } );
251
    my @branches;
252
    foreach my $branchcode ( sort { uc($branches->{$a}->{branchname}) cmp uc($branches->{$b}->{branchname}) } keys %$branches) {
253
        push @branches, {
254
            value => $branchcode,
255
            label => $branches->{$branchcode}->{branchname},
256
        };
257
    }
258
    my @locations;
251
    my @locations;
259
    foreach my $location (@$location_values) {
252
    foreach my $location (@$location_values) {
260
        push @locations, {
253
        push @locations, {
(-)a/catalogue/search.pl (-3 / +5 lines)
Lines 149-155 use C4::Koha; Link Here
149
use C4::Members qw(GetMember);
149
use C4::Members qw(GetMember);
150
use URI::Escape;
150
use URI::Escape;
151
use POSIX qw(ceil floor);
151
use POSIX qw(ceil floor);
152
use C4::Branch; # GetBranches
153
use C4::Search::History;
152
use C4::Search::History;
154
153
155
use Koha::LibraryCategories;
154
use Koha::LibraryCategories;
Lines 229-235 if($cgi->cookie("holdfor")){ Link Here
229
228
230
my $categories = Koha::LibraryCategories->search( { categorytype => 'searchdomain' }, { order_by => [ 'categorytype', 'categorycode' ] } );
229
my $categories = Koha::LibraryCategories->search( { categorytype => 'searchdomain' }, { order_by => [ 'categorytype', 'categorycode' ] } );
231
230
232
$template->param(searchdomainloop => $categories);
231
$template->param(
232
    selected_branchcode => ( C4::Context->IsSuperLibrarian ? C4::Context->userenv : '' ),
233
    searchdomainloop => $categories
234
);
233
235
234
# load the Type stuff
236
# load the Type stuff
235
my $itemtypes = GetItemTypes;
237
my $itemtypes = GetItemTypes;
Lines 512-518 my $facets; # this object stores the faceted results that display on the left-ha Link Here
512
my $results_hashref;
514
my $results_hashref;
513
515
514
eval {
516
eval {
515
    ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$itemtypes,$query_type,$scan);
517
    ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,undef,$itemtypes,$query_type,$scan);
516
};
518
};
517
519
518
# This sorts the facets into alphabetical order
520
# This sorts the facets into alphabetical order
(-)a/cataloguing/addbiblio.pl (-12 / +6 lines)
Lines 31-41 use C4::Context; Link Here
31
use MARC::Record;
31
use MARC::Record;
32
use C4::Log;
32
use C4::Log;
33
use C4::Koha;    # XXX subfield_is_koha_internal_p
33
use C4::Koha;    # XXX subfield_is_koha_internal_p
34
use C4::Branch;    # XXX subfield_is_koha_internal_p
35
use C4::ClassSource;
34
use C4::ClassSource;
36
use C4::ImportBatch;
35
use C4::ImportBatch;
37
use C4::Charset;
36
use C4::Charset;
38
37
38
use Koha::Libraries;
39
39
use Date::Calc qw(Today);
40
use Date::Calc qw(Today);
40
use MARC::File::USMARC;
41
use MARC::File::USMARC;
41
use MARC::File::XML;
42
use MARC::File::XML;
Lines 171-188 sub build_authorized_values_list { Link Here
171
172
172
    #---- branch
173
    #---- branch
173
    if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
174
    if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
174
        #Use GetBranches($onlymine)
175
        my $libraries = Koha::Libraries->search_filtered({}, {order_by => ['branchname']});
175
        my $onlymine =
176
        while ( my $l = $libraries->next ) {
176
             C4::Context->preference('IndependentBranches')
177
            push @authorised_values, $l->branchcode;;
177
          && C4::Context->userenv
178
            $authorised_lib{$l->branchcode} = $l->branchname;
178
          && !C4::Context->IsSuperLibrarian()
179
          && C4::Context->userenv->{branch};
180
        my $branches = GetBranches($onlymine);
181
        foreach my $thisbranch ( sort keys %$branches ) {
182
            push @authorised_values, $thisbranch;
183
            $authorised_lib{$thisbranch} = $branches->{$thisbranch}->{'branchname'};
184
        }
179
        }
185
186
    }
180
    }
187
    elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) {
181
    elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) {
188
        push @authorised_values, ""
182
        push @authorised_values, ""
(-)a/cataloguing/value_builder/unimarc_field_4XX.pl (-1 lines)
Lines 31-37 use C4::Output; Link Here
31
use C4::Biblio;
31
use C4::Biblio;
32
use C4::Koha;
32
use C4::Koha;
33
use MARC::Record;
33
use MARC::Record;
34
use C4::Branch;    # GetBranches
35
34
36
use Koha::ItemTypes;
35
use Koha::ItemTypes;
37
36
(-)a/circ/add_message.pl (-1 lines)
Lines 30-36 use C4::Accounts; Link Here
30
use C4::Stats;
30
use C4::Stats;
31
use C4::Koha;
31
use C4::Koha;
32
use C4::Overdues;
32
use C4::Overdues;
33
use C4::Branch;    # GetBranches
34
33
35
my $input = new CGI;
34
my $input = new CGI;
36
35
(-)a/circ/bookcount.pl (-7 / +2 lines)
Lines 29-35 use C4::Circulation; Link Here
29
use C4::Output;
29
use C4::Output;
30
use C4::Koha;
30
use C4::Koha;
31
use C4::Auth;
31
use C4::Auth;
32
use C4::Branch; # GetBranches
33
use C4::Biblio; # GetBiblioItemData
32
use C4::Biblio; # GetBiblioItemData
34
use Koha::DateUtils;
33
use Koha::DateUtils;
35
use Koha::Libraries;
34
use Koha::Libraries;
Lines 38-51 my $input = new CGI; Link Here
38
my $itm          = $input->param('itm');
37
my $itm          = $input->param('itm');
39
my $bi           = $input->param('bi');
38
my $bi           = $input->param('bi');
40
my $biblionumber = $input->param('biblionumber');
39
my $biblionumber = $input->param('biblionumber');
41
my $branches     = GetBranches;
42
40
43
my $idata = itemdatanum($itm);
41
my $idata = itemdatanum($itm);
44
my $data  = GetBiblioItemData($bi);
42
my $data  = GetBiblioItemData($bi);
45
43
46
my $homebranch    = $branches->{ $idata->{'homebranch'}    }->{'branchname'};
47
my $holdingbranch = $branches->{ $idata->{'holdingbranch'} }->{'branchname'};
48
49
my $lastmove = lastmove($itm);
44
my $lastmove = lastmove($itm);
50
45
51
my $lastdate;
46
my $lastdate;
Lines 83-90 $template->param( Link Here
83
    author                  => $data->{'author'},
78
    author                  => $data->{'author'},
84
    barcode                 => $idata->{'barcode'},
79
    barcode                 => $idata->{'barcode'},
85
    biblioitemnumber        => $bi,
80
    biblioitemnumber        => $bi,
86
    homebranch              => $homebranch,
81
    homebranch              => $idata->{homebranch},
87
    holdingbranch           => $holdingbranch,
82
    holdingbranch           => $idata->{holdingbranch},
88
    lastdate                => $lastdate ? $lastdate : 0,
83
    lastdate                => $lastdate ? $lastdate : 0,
89
    count                   => $count,
84
    count                   => $count,
90
    libraries               => $libraries,
85
    libraries               => $libraries,
(-)a/circ/branchtransfers.pl (-10 / +5 lines)
Lines 29-35 use C4::Reserves; Link Here
29
use C4::Biblio;
29
use C4::Biblio;
30
use C4::Items;
30
use C4::Items;
31
use C4::Auth qw/:DEFAULT get_session/;
31
use C4::Auth qw/:DEFAULT get_session/;
32
use C4::Branch; # GetBranches
33
use C4::Koha;
32
use C4::Koha;
34
use C4::Members;
33
use C4::Members;
35
34
Lines 61-68 my ($template, $user, $cookie) = get_template_and_user( Link Here
61
    }
60
    }
62
);
61
);
63
62
64
my $branches = GetBranches;
65
66
my $messages;
63
my $messages;
67
my $found;
64
my $found;
68
my $reserved;
65
my $reserved;
Lines 131-138 if ($barcode) { Link Here
131
        $item{'ccode'}                 = $iteminformation->{'ccode'};
128
        $item{'ccode'}                 = $iteminformation->{'ccode'};
132
        $item{'itemcallnumber'}        = $iteminformation->{'itemcallnumber'};
129
        $item{'itemcallnumber'}        = $iteminformation->{'itemcallnumber'};
133
        $item{'location'}              = GetKohaAuthorisedValueLib("LOC",$iteminformation->{'location'});
130
        $item{'location'}              = GetKohaAuthorisedValueLib("LOC",$iteminformation->{'location'});
134
        $item{'frbrname'}              = $branches->{$frbranchcd}->{'branchname'};
131
        $item{'tobrname'}              = $tobranchcd;
135
        $item{'tobrname'}              = $branches->{$tobranchcd}->{'branchname'};
136
#         }
132
#         }
137
        $item{counter}  = 0;
133
        $item{counter}  = 0;
138
        $item{barcode}  = $barcode;
134
        $item{barcode}  = $barcode;
Lines 164-171 foreach ( $query->param ) { Link Here
164
    $item{'ccode'}                 = $iteminformation->{'ccode'};
160
    $item{'ccode'}                 = $iteminformation->{'ccode'};
165
    $item{'itemcallnumber'}        = $iteminformation->{'itemcallnumber'};
161
    $item{'itemcallnumber'}        = $iteminformation->{'itemcallnumber'};
166
    $item{'location'}              = GetKohaAuthorisedValueLib("LOC",$iteminformation->{'location'});
162
    $item{'location'}              = GetKohaAuthorisedValueLib("LOC",$iteminformation->{'location'});
167
    $item{'frbrname'}              = $branches->{$frbcd}->{'branchname'};
163
    $item{'tobrname'}              = $tobcd;
168
    $item{'tobrname'}              = $branches->{$tobcd}->{'branchname'};
169
    push( @trsfitemloop, \%item );
164
    push( @trsfitemloop, \%item );
170
}
165
}
171
166
Lines 196-211 foreach my $code ( keys %$messages ) { Link Here
196
            $err{errbadcode} = 1;
191
            $err{errbadcode} = 1;
197
        }
192
        }
198
        elsif ( $code eq "NotAllowed" ) {
193
        elsif ( $code eq "NotAllowed" ) {
199
            warn "NotAllowed: $messages->{'NotAllowed'} to  " . $branches->{ $messages->{'NotAllowed'} }->{'branchname'};
194
            warn "NotAllowed: $messages->{'NotAllowed'} to branchcode " . $messages->{'NotAllowed'};
200
            # Do we really want a error log message here? --atz
195
            # Do we really want a error log message here? --atz
201
            $err{errnotallowed} =  1;
196
            $err{errnotallowed} =  1;
202
            my ( $tbr, $typecode ) = split( /::/,  $messages->{'NotAllowed'} );
197
            my ( $tbr, $typecode ) = split( /::/,  $messages->{'NotAllowed'} );
203
            $err{tbr}      = $branches->{ $tbr }->{'branchname'};
198
            $err{tbr}      = $tbr;
204
            $err{code}     = $typecode;
199
            $err{code}     = $typecode;
205
        }
200
        }
206
        elsif ( $code eq 'IsPermanent' ) {
201
        elsif ( $code eq 'IsPermanent' ) {
207
            $err{errispermanent} = 1;
202
            $err{errispermanent} = 1;
208
            $err{msg} = $branches->{ $messages->{'IsPermanent'} }->{'branchname'};
203
            $err{msg} = $messages->{'IsPermanent'};
209
        }
204
        }
210
        elsif ( $code eq 'WasReturned' ) {
205
        elsif ( $code eq 'WasReturned' ) {
211
            $err{errwasreturned} = 1;
206
            $err{errwasreturned} = 1;
(-)a/circ/circulation.pl (-3 lines)
Lines 30-36 use DateTime::Duration; Link Here
30
use C4::Output;
30
use C4::Output;
31
use C4::Print;
31
use C4::Print;
32
use C4::Auth qw/:DEFAULT get_session haspermission/;
32
use C4::Auth qw/:DEFAULT get_session haspermission/;
33
use C4::Branch; # GetBranches
34
use C4::Koha;   # GetPrinter
33
use C4::Koha;   # GetPrinter
35
use C4::Circulation;
34
use C4::Circulation;
36
use C4::Utils::DataTables::Members;
35
use C4::Utils::DataTables::Members;
Lines 133-140 my ( $template, $loggedinuser, $cookie ) = get_template_and_user ( Link Here
133
    }
132
    }
134
);
133
);
135
134
136
my $branches = GetBranches();
137
138
my $force_allow_issue = $query->param('forceallow') || 0;
135
my $force_allow_issue = $query->param('forceallow') || 0;
139
if (!C4::Auth::haspermission( C4::Context->userenv->{id} , { circulate => 'force_checkout' } )) {
136
if (!C4::Auth::haspermission( C4::Context->userenv->{id} , { circulate => 'force_checkout' } )) {
140
    $force_allow_issue = 0;
137
    $force_allow_issue = 0;
(-)a/circ/del_message.pl (-1 lines)
Lines 30-36 use C4::Accounts; Link Here
30
use C4::Stats;
30
use C4::Stats;
31
use C4::Koha;
31
use C4::Koha;
32
use C4::Overdues;
32
use C4::Overdues;
33
use C4::Branch;    # GetBranches
34
33
35
my $input = new CGI;
34
my $input = new CGI;
36
35
(-)a/circ/returns.pl (-19 / +4 lines)
Lines 44-50 use C4::Reserves; Link Here
44
use C4::Biblio;
44
use C4::Biblio;
45
use C4::Items;
45
use C4::Items;
46
use C4::Members;
46
use C4::Members;
47
use C4::Branch; # GetBranches
48
use C4::Koha;   # FIXME : is it still useful ?
47
use C4::Koha;   # FIXME : is it still useful ?
49
use C4::RotatingCollections;
48
use C4::RotatingCollections;
50
use Koha::DateUtils;
49
use Koha::DateUtils;
Lines 82-88 if ( $query->param('print_slip') ) { Link Here
82
81
83
#####################
82
#####################
84
#Global vars
83
#Global vars
85
my $branches = GetBranches();
86
my $printers = GetPrinters();
84
my $printers = GetPrinters();
87
my $userenv = C4::Context->userenv;
85
my $userenv = C4::Context->userenv;
88
my $userenv_branch = $userenv->{'branch'} // '';
86
my $userenv_branch = $userenv->{'branch'} // '';
Lines 388-394 if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) { Link Here
388
    );
386
    );
389
387
390
    my $reserve    = $messages->{'ResFound'};
388
    my $reserve    = $messages->{'ResFound'};
391
    my $branchname = $branches->{ $reserve->{'branchcode'} }->{'branchname'};
392
    my $borr = C4::Members::GetMember( borrowernumber => $reserve->{'borrowernumber'} );
389
    my $borr = C4::Members::GetMember( borrowernumber => $reserve->{'borrowernumber'} );
393
    my $name = $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'};
390
    my $name = $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'};
394
    $template->param(
391
    $template->param(
Lines 414-420 if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) { Link Here
414
#
411
#
415
if ( $messages->{'ResFound'}) {
412
if ( $messages->{'ResFound'}) {
416
    my $reserve    = $messages->{'ResFound'};
413
    my $reserve    = $messages->{'ResFound'};
417
    my $branchname = $branches->{ $reserve->{'branchcode'} }->{'branchname'};
418
    my $borr = C4::Members::GetMember( borrowernumber => $reserve->{'borrowernumber'} );
414
    my $borr = C4::Members::GetMember( borrowernumber => $reserve->{'borrowernumber'} );
419
415
420
    if ( $reserve->{'ResFound'} eq "Waiting" or $reserve->{'ResFound'} eq "Reserved" ) {
416
    if ( $reserve->{'ResFound'} eq "Waiting" or $reserve->{'ResFound'} eq "Reserved" ) {
Lines 434-441 if ( $messages->{'ResFound'}) { Link Here
434
        # same params for Waiting or Reserved
430
        # same params for Waiting or Reserved
435
        $template->param(
431
        $template->param(
436
            found          => 1,
432
            found          => 1,
437
            currentbranch  => $branches->{$userenv_branch}->{'branchname'},
433
            destbranchname => $reserve->{'branchcode'},
438
            destbranchname => $branches->{ $reserve->{'branchcode'} }->{'branchname'},
439
            name           => $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'},
434
            name           => $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'},
440
            borfirstname   => $borr->{'firstname'},
435
            borfirstname   => $borr->{'firstname'},
441
            borsurname     => $borr->{'surname'},
436
            borsurname     => $borr->{'surname'},
Lines 471-477 foreach my $code ( keys %$messages ) { Link Here
471
    elsif ( $code eq 'NotIssued' ) {
466
    elsif ( $code eq 'NotIssued' ) {
472
        $err{notissued} = 1;
467
        $err{notissued} = 1;
473
        $err{msg} = '';
468
        $err{msg} = '';
474
        $err{msg} = $branches->{ $messages->{'IsPermanent'} }->{'branchname'} if $messages->{'IsPermanent'};
469
        $err{msg} = $messages->{'IsPermanent'} if $messages->{'IsPermanent'};
475
    }
470
    }
476
    elsif ( $code eq 'LocalUse' ) {
471
    elsif ( $code eq 'LocalUse' ) {
477
        $err{localuse} = 1;
472
        $err{localuse} = 1;
Lines 498-505 foreach my $code ( keys %$messages ) { Link Here
498
    elsif ( ( $code eq 'IsPermanent' ) && ( not $messages->{'ResFound'} ) ) {
493
    elsif ( ( $code eq 'IsPermanent' ) && ( not $messages->{'ResFound'} ) ) {
499
        if ( $messages->{'IsPermanent'} ne $userenv_branch ) {
494
        if ( $messages->{'IsPermanent'} ne $userenv_branch ) {
500
            $err{ispermanent} = 1;
495
            $err{ispermanent} = 1;
501
            $err{msg}         =
496
            $err{msg}         = $messages->{'IsPermanent'};
502
              $branches->{ $messages->{'IsPermanent'} }->{'branchname'};
503
        }
497
        }
504
    }
498
    }
505
    elsif ( $code eq 'WrongTransfer' ) {
499
    elsif ( $code eq 'WrongTransfer' ) {
Lines 601-618 foreach ( sort { $a <=> $b } keys %returneditems ) { Link Here
601
    }
595
    }
602
    push @riloop, \%ri;
596
    push @riloop, \%ri;
603
}
597
}
604
my ($genbrname, $genprname);
598
605
if (my $b = $branches->{$userenv_branch}) {
606
    $genbrname = $b->{'branchname'};
607
}
608
if (my $p = $printers->{$printer}) {
609
    $genprname = $p->{'printername'};
610
}
611
$template->param(
599
$template->param(
612
    riloop         => \@riloop,
600
    riloop         => \@riloop,
613
    genbrname      => $genbrname,
614
    genprname      => $genprname,
615
    branchname     => $genbrname,
616
    printer        => $printer,
601
    printer        => $printer,
617
    errmsgloop     => \@errmsgloop,
602
    errmsgloop     => \@errmsgloop,
618
    exemptfine     => $exemptfine,
603
    exemptfine     => $exemptfine,
(-)a/circ/selectbranchprinter.pl (-8 / +2 lines)
Lines 26-32 use C4::Output; Link Here
26
use C4::Auth qw/:DEFAULT get_session/;
26
use C4::Auth qw/:DEFAULT get_session/;
27
use C4::Print;  # GetPrinters
27
use C4::Print;  # GetPrinters
28
use C4::Koha;
28
use C4::Koha;
29
use C4::Branch; # GetBranches
30
29
31
use Koha::Libraries;
30
use Koha::Libraries;
32
31
Lines 47-53 my $sessionID = $query->cookie("CGISESSID"); Link Here
47
my $session = get_session($sessionID);
46
my $session = get_session($sessionID);
48
47
49
# try to get the branch and printer settings from http, fallback to userenv
48
# try to get the branch and printer settings from http, fallback to userenv
50
my $branches = GetBranches();
51
my $printers = GetPrinters();
49
my $printers = GetPrinters();
52
my $branch   = $query->param('branch' );
50
my $branch   = $query->param('branch' );
53
my $printer  = $query->param('printer');
51
my $printer  = $query->param('printer');
Lines 58-66 my $userenv_printer = C4::Context->userenv->{'branchprinter'} || ''; Link Here
58
my @updated;
56
my @updated;
59
57
60
# $session lddines here are doing the updating
58
# $session lddines here are doing the updating
61
if ($branch and $branches->{$branch}) {
59
if ( $branch and my $library = Koha::Libraries->find($branch) ) {
62
    if (! $userenv_branch or $userenv_branch ne $branch ) {
60
    if (! $userenv_branch or $userenv_branch ne $branch ) {
63
        my $branchname = Koha::Libraries->find($branch)->branchname;
61
        my $branchname = $library->branchname;
64
        $template->param(LoginBranchname => $branchname);   # update template for new branch
62
        $template->param(LoginBranchname => $branchname);   # update template for new branch
65
        $template->param(LoginBranchcode => $branch);       # update template for new branch
63
        $template->param(LoginBranchcode => $branch);       # update template for new branch
66
        $session->param('branchname', $branchname);         # update sesssion in DB
64
        $session->param('branchname', $branchname);         # update sesssion in DB
Lines 94-103 if ($printer) { Link Here
94
92
95
$template->param(updated => \@updated) if (scalar @updated);
93
$template->param(updated => \@updated) if (scalar @updated);
96
94
97
unless ($branches->{$branch}) {
98
    $branch = (keys %$branches)[0];  # if branch didn't really exist, then replace it w/ one that does
99
}
100
101
my @printkeys = sort keys %$printers;
95
my @printkeys = sort keys %$printers;
102
if (scalar(@printkeys) == 1 or not $printers->{$printer}) {
96
if (scalar(@printkeys) == 1 or not $printers->{$printer}) {
103
    $printer = $printkeys[0];   # if printer didn't really exist, or there is only 1 anyway, then replace it w/ one that does
97
    $printer = $printkeys[0];   # if printer didn't really exist, or there is only 1 anyway, then replace it w/ one that does
(-)a/circ/transferstoreceive.pl (-6 / +6 lines)
Lines 23-29 use warnings; Link Here
23
use CGI qw ( -utf8 );
23
use CGI qw ( -utf8 );
24
use C4::Context;
24
use C4::Context;
25
use C4::Output;
25
use C4::Output;
26
use C4::Branch;     # GetBranches
27
use C4::Auth;
26
use C4::Auth;
28
use Koha::DateUtils;
27
use Koha::DateUtils;
29
use C4::Biblio;
28
use C4::Biblio;
Lines 37-42 use Date::Calc qw( Link Here
37
36
38
use C4::Koha;
37
use C4::Koha;
39
use C4::Reserves;
38
use C4::Reserves;
39
use Koha::Libraries;
40
40
41
my $input = new CGI;
41
my $input = new CGI;
42
my $itemnumber = $input->param('itemnumber');
42
my $itemnumber = $input->param('itemnumber');
Lines 56-73 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
56
my $default = C4::Context->userenv->{'branch'};
56
my $default = C4::Context->userenv->{'branch'};
57
57
58
# get the all the branches for reference
58
# get the all the branches for reference
59
my $branches = GetBranches();
59
my $libraries = Koha::Libraries->search({}, { order_by => 'branchname' });
60
my @branchesloop;
60
my @branchesloop;
61
my $latetransfers;
61
my $latetransfers;
62
foreach my $br ( keys %$branches ) {
62
while ( my $library = $libraries->next ) {
63
    my @transferloop;
63
    my @transferloop;
64
    my %branchloop;
64
    my %branchloop;
65
    my @gettransfers =
65
    my @gettransfers =
66
      GetTransfersFromTo( $branches->{$br}->{'branchcode'}, $default );
66
      GetTransfersFromTo( $library->branchcode, $default );
67
67
68
    if (@gettransfers) {
68
    if (@gettransfers) {
69
        $branchloop{'branchname'} = $branches->{$br}->{'branchname'};
69
        $branchloop{'branchname'} = $library->branchname;
70
        $branchloop{'branchcode'} = $branches->{$br}->{'branchcode'};
70
        $branchloop{'branchcode'} = $library->branchcode;
71
        foreach my $num (@gettransfers) {
71
        foreach my $num (@gettransfers) {
72
            my %getransf;
72
            my %getransf;
73
73
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/branch-selector.inc (-3 / +3 lines)
Lines 10-21 END %] Link Here
10
    [% FOREACH branch IN branches %]
10
    [% FOREACH branch IN branches %]
11
        <div class="branchgriditem">
11
        <div class="branchgriditem">
12
            [% IF branch.selected || (selectall == 1) %]
12
            [% IF branch.selected || (selectall == 1) %]
13
                <input id="branch_[% branch.value %]" type="checkbox" name="branch" value="[% branch.value %]" checked="checked" />
13
                <input id="branch_[% branch.branchcode %]" type="checkbox" name="branch" value="[% branch.branchcode %]" checked="checked" />
14
            [% ELSE %]
14
            [% ELSE %]
15
                <input id="branch_[% branch.value %]" type="checkbox" name="branch" value="[% branch.value %]" />
15
                <input id="branch_[% branch.branchcode %]" type="checkbox" name="branch" value="[% branch.branchcode %]" />
16
            [% END %]
16
            [% END %]
17
17
18
            <label for="branch_[% branch.value %]">[% branch.branchname %]</label>
18
            <label for="branch_[% branch.branchcode %]">[% branch.branchname %]</label>
19
        </div>
19
        </div>
20
        [% IF loop.count() % 4 == 0 && !loop.last() %]
20
        [% IF loop.count() % 4 == 0 && !loop.last() %]
21
            </div>
21
            </div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/subscriptions-search.inc (-7 / +2 lines)
Lines 30-42 Link Here
30
                <label for="branch">Library:</label>
30
                <label for="branch">Library:</label>
31
                <select id="branch" name="branch_filter">
31
                <select id="branch" name="branch_filter">
32
                  <option value="">All</option>
32
                  <option value="">All</option>
33
                  [% FOREACH branch IN branches_loop %]
33
                  [%# FIXME Should not we filter the libraries? %]
34
                    [% IF (branch.selected) %]
34
                  [% PROCESS options_for_libraries libraries => Branches.all( selected => branch_filter, unfiltered => 1 ) %]
35
                      <option selected="branch.selected" value="[% branch.branchcode %]">[% branch.branchname %]</option>
36
                    [% ELSE %]
37
                      <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
38
                    [% END %]
39
                  [% END %]
40
                </select>
35
                </select>
41
              </li>
36
              </li>
42
            </ol>
37
            </ol>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt (-8 / +3 lines)
Lines 262-268 $(document).ready(function() { Link Here
262
                <li>Publication year: [% publicationyear %]</li>
262
                <li>Publication year: [% publicationyear %]</li>
263
              [% END %]
263
              [% END %]
264
              [% IF ( branch ) %]
264
              [% IF ( branch ) %]
265
                <li>Library: [% branchname %]</li>
265
                <li>Library: [% Branches.GetName( branch ) %]</li>
266
              [% END %]
266
              [% END %]
267
            </ul>
267
            </ul>
268
          </p>
268
          </p>
Lines 348-360 $(document).ready(function() { Link Here
348
            <label for="branch">Library:</label>
348
            <label for="branch">Library:</label>
349
            <select id="branch" name="branch">
349
            <select id="branch" name="branch">
350
              <option value="">All</option>
350
              <option value="">All</option>
351
              [% FOREACH branch IN branches_loop %]
351
              [%# FIXME Should not we filter the libraries %]
352
                [% IF ( branch.selected ) %]
352
              [% PROCESS options_for_libraries libraries => Branches.all( selected => branch, unfiltered => 1 ) %]
353
                  <option selected="selected" value="[% branch.branchcode %]">[% branch.branchname %]</option>
354
                [% ELSE %]
355
                  <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
356
                [% END %]
357
              [% END %]
358
            </select>
353
            </select>
359
          </li>
354
          </li>
360
        </ol>
355
        </ol>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt (-1 / +2 lines)
Lines 1-3 Link Here
1
[% USE Branches %]
1
[% USE Price %]
2
[% USE Price %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Administration &rsaquo; Funds[% IF op == 'add_form' %] &rsaquo; [% IF ( budget_id ) %]Modify fund[% IF ( budget_name ) %] '[% budget_name %]'[% END %][% ELSE %]Add fund [% END %][% END %]</title>
4
<title>Koha &rsaquo; Administration &rsaquo; Funds[% IF op == 'add_form' %] &rsaquo; [% IF ( budget_id ) %]Modify fund[% IF ( budget_name ) %] '[% budget_name %]'[% END %][% ELSE %]Add fund [% END %][% END %]</title>
Lines 521-527 var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") Link Here
521
    <label for="budget_branchcode">Library: </label>
522
    <label for="budget_branchcode">Library: </label>
522
    <select name="budget_branchcode" id="budget_branchcode">
523
    <select name="budget_branchcode" id="budget_branchcode">
523
        <option value=""></option>
524
        <option value=""></option>
524
        [% PROCESS options_for_libraries libraries => branchloop_select %]
525
        [% PROCESS options_for_libraries libraries => Branches.all( selected => budget_branchcode, unfiltered => 1 ) %]
525
    </select>
526
    </select>
526
    </li>
527
    </li>
527
528
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branch_transfer_limits.tt (-10 / +4 lines)
Lines 58-73 Link Here
58
<h1>Library [% branchcode %] - [% Branches.GetName( branchcode ) %] Checkin and transfer policy</h1>
58
<h1>Library [% branchcode %] - [% Branches.GetName( branchcode ) %] Checkin and transfer policy</h1>
59
    <form method="get" action="/cgi-bin/koha/admin/branch_transfer_limits.pl" id="selectlibrary">
59
    <form method="get" action="/cgi-bin/koha/admin/branch_transfer_limits.pl" id="selectlibrary">
60
        <label for="branchselect">Select a library :</label>
60
        <label for="branchselect">Select a library :</label>
61
            <select name="branchcode" id="branchselect">
61
        <select name="branchcode" id="branchselect">
62
		[% FOREACH branch_loo IN branch_loop %]
62
            [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode, unfiltered => 1 ) %]
63
			[% IF ( branch_loo.selected ) %]
63
        </select>
64
                <option value="[% branch_loo.value %]" selected="selected">[% branch_loo.branchname %]</option>
64
        <input type="submit" value="Choose" />
65
            [% ELSE %]
66
                <option value="[% branch_loo.value %]">[% branch_loo.branchname %]</option>
67
            [% END %]
68
		[% END %]
69
            </select>
70
	    <input type="submit" value="Choose" />	    
71
    </form>
65
    </form>
72
66
73
<p class="help">Check the boxes for the libraries you accept to checkin items from.</p>
67
<p class="help">Check the boxes for the libraries you accept to checkin items from.</p>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/item_circulation_alerts.tt (-8 / +3 lines)
Lines 103-115 $(function(){ Link Here
103
<h2>Select a library:</h2>
103
<h2>Select a library:</h2>
104
<form id="branch_selector" method="get" action="/cgi-bin/koha/admin/item_circulation_alerts.pl">
104
<form id="branch_selector" method="get" action="/cgi-bin/koha/admin/item_circulation_alerts.pl">
105
<select id="branch" name="branch">
105
<select id="branch" name="branch">
106
[% FOREACH branche IN branches %]
106
    <option value="*">Default</option>
107
[% IF ( branche.selected ) %]
107
    [% PROCESS options_for_libraries libraries => Branches.all( selected => branch, unfiltered => 1 ) %]
108
<option value="[% branche.branchcode %]" selected="selected">[% branche.branchname %]</option>
109
[% ELSE %]
110
<option value="[% branche.branchcode %]">[% branche.branchname %]</option>
111
[% END %]
112
[% END %]
113
</select>
108
</select>
114
<input type="submit" name="pick" value="Pick" />
109
<input type="submit" name="pick" value="Pick" />
115
</form>
110
</form>
Lines 141-147 $(function(){ Link Here
141
</div>
136
</div>
142
</div>
137
</div>
143
138
144
<h2>Circulation alerts for [% branch_name %]</h2>
139
<h2>Circulation alerts for [% Branches.GetName( branch ) || 'Default' %]</h2>
145
<p>Click on the grid to toggle the settings.</p>
140
<p>Click on the grid to toggle the settings.</p>
146
141
147
<div id="alerttabs" class="toptabs">
142
<div id="alerttabs" class="toptabs">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-2 / +2 lines)
Lines 136-142 $(document).ready(function() { Link Here
136
        Select a library :
136
        Select a library :
137
            <select name="branch" id="branch" style="width:20em;">
137
            <select name="branch" id="branch" style="width:20em;">
138
                <option value="*">All libraries</option>
138
                <option value="*">All libraries</option>
139
                [% PROCESS options_for_libraries libraries => Branches.all( selected => current_branch ) %]
139
                [% PROCESS options_for_libraries libraries => Branches.all( selected => current_branch, unfiltered => 1 ) %]
140
            </select>
140
            </select>
141
        </form>
141
        </form>
142
        [% IF ( definedbranch ) %]
142
        [% IF ( definedbranch ) %]
Lines 144-150 $(document).ready(function() { Link Here
144
                <label for="tobranch"><strong>Clone these rules to:</strong></label>
144
                <label for="tobranch"><strong>Clone these rules to:</strong></label>
145
                <input type="hidden" name="frombranch" value="[% current_branch %]" />
145
                <input type="hidden" name="frombranch" value="[% current_branch %]" />
146
                <select name="tobranch" id="tobranch">
146
                <select name="tobranch" id="tobranch">
147
                    [% FOREACH l IN Branches.all() %]
147
                    [% FOREACH l IN Branches.all( unfiltered => 1 ) %]
148
                        <option value="[% l.value %]">[% l.branchname %]</option>
148
                        <option value="[% l.value %]">[% l.branchname %]</option>
149
                    [% END %]
149
                    [% END %]
150
                </select>
150
                </select>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt (-1 / +2 lines)
Lines 1-3 Link Here
1
[% USE Branches %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; 
3
<title>Koha &rsaquo; 
3
    [% IF ( nopermission ) %]Access denied[% END %]
4
    [% IF ( nopermission ) %]Access denied[% END %]
Lines 57-63 Link Here
57
<p><label for="branch">Library:</label>
58
<p><label for="branch">Library:</label>
58
    <select name="branch" id="branch" class="input" tabindex="3">
59
    <select name="branch" id="branch" class="input" tabindex="3">
59
    <option value="">My library</option>
60
    <option value="">My library</option>
60
    [% FOREACH l IN Branches.all() %]
61
    [% FOREACH l IN Branches.all( unfiltered => 1 ) %]
61
        <option value="[% l.branchcode %]">[% l.branchname %]</option>
62
        <option value="[% l.branchcode %]">[% l.branchname %]</option>
62
    [% END %]
63
    [% END %]
63
    </select>
64
    </select>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt (-1 / +3 lines)
Lines 1-3 Link Here
1
[% USE Branches %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Catalog &rsaquo; Advanced search</title>
3
<title>Koha &rsaquo; Catalog &rsaquo; Advanced search</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'doc-head-close.inc' %]
Lines 238-244 Link Here
238
<fieldset id="select-libs">
239
<fieldset id="select-libs">
239
        <p><label for="branchloop">Individual libraries:</label><select name="limit" id="branchloop" onchange='if(this.value != ""){document.getElementById("categoryloop").disabled=true;} else {document.getElementById("categoryloop").disabled=false;}'>
240
        <p><label for="branchloop">Individual libraries:</label><select name="limit" id="branchloop" onchange='if(this.value != ""){document.getElementById("categoryloop").disabled=true;} else {document.getElementById("categoryloop").disabled=false;}'>
240
        <option value="">All libraries</option>
241
        <option value="">All libraries</option>
241
        [% PROCESS options_for_libraries libraries => Branches.all() %]
242
        [%# FIXME Should not we filter the libraries displayed? %]
243
        [% PROCESS options_for_libraries libraries => Branches.all( selected => selected_branchcode, unfiltered => 1 ) %]
242
        </select></p>
244
        </select></p>
243
    <!-- <input type="hidden" name="limit" value="branch: MAIN" /> -->
245
    <!-- <input type="hidden" name="limit" value="branch: MAIN" /> -->
244
        [% IF ( searchdomainloop ) %]
246
        [% IF ( searchdomainloop ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-2 / +2 lines)
Lines 644-650 function verify_images() { Link Here
644
                                : due [% item.datedue %]
644
                                : due [% item.datedue %]
645
                            </span>
645
                            </span>
646
                        [% ELSIF ( item.transfertwhen ) %]
646
                        [% ELSIF ( item.transfertwhen ) %]
647
                            <span class="intransit">In transit from [% item.transfertfrom %] to [% item.transfertto %] since [% item.transfertwhen | $KohaDates %]</span>
647
                            <span class="intransit">In transit from [% Branches.GetName( item.transfertfrom ) %] to [% Branches.GetName( item.transfertto ) %] since [% item.transfertwhen | $KohaDates %]</span>
648
                        [% END %]
648
                        [% END %]
649
649
650
                        [% IF ( item.itemlost ) %]
650
                        [% IF ( item.itemlost ) %]
Lines 700-706 function verify_images() { Link Here
700
                            [% IF ( item.waitingdate ) %]
700
                            [% IF ( item.waitingdate ) %]
701
                                at[% ELSE %]for delivery at
701
                                at[% ELSE %]for delivery at
702
                            [% END %]
702
                            [% END %]
703
                            [% item.ExpectedAtLibrary %]
703
                            [% Branches.GetName( item.ExpectedAtLibrary ) %]
704
                            [% IF ( item.waitingdate ) %]
704
                            [% IF ( item.waitingdate ) %]
705
                                since [% item.waitingdate | $KohaDates %]
705
                                since [% item.waitingdate | $KohaDates %]
706
                            [% ELSE %]
706
                            [% ELSE %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/bookcount.tt (-3 / +4 lines)
Lines 1-4 Link Here
1
[% USE KohaDates %]
1
[% USE KohaDates %]
2
[% USE Branches %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Circulation &rsaquo; Circulation statistics for [% title %]</title>
4
<title>Koha &rsaquo; Circulation &rsaquo; Circulation statistics for [% title %]</title>
4
[% INCLUDE 'doc-head-close.inc' %]
5
[% INCLUDE 'doc-head-close.inc' %]
Lines 26-34 $(document).ready(function(){ Link Here
26
<h3>Barcode [% barcode %]</h3>
27
<h3>Barcode [% barcode %]</h3>
27
<table>
28
<table>
28
        <tr><th>Home library</th><th>Current library</th><th>Date arrived<br />at current library </th><th>Number of checkouts<br />since last transfer</th></tr>
29
        <tr><th>Home library</th><th>Current library</th><th>Date arrived<br />at current library </th><th>Number of checkouts<br />since last transfer</th></tr>
29
		
30
30
		<tr><td>[% homebranch %]</td>
31
        <tr><td>[% Branches.GetName( homebranch ) %]</td>
31
            <td>[% holdingbranch %]</td>
32
            <td>[% Branches.GetName( holdingbranch ) %]</td>
32
            <td>[% IF ( lastdate ) %][% lastdate | $KohaDates %][% ELSE %]Item has no transfer record[% END %]</td>
33
            <td>[% IF ( lastdate ) %][% lastdate | $KohaDates %][% ELSE %]Item has no transfer record[% END %]</td>
33
            <td>[% count %]</td>
34
            <td>[% count %]</td>
34
        </tr>
35
        </tr>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/branchtransfers.tt (-3 / +3 lines)
Lines 111-117 Link Here
111
                                  <li>No Item with barcode: [% errmsgloo.msg %]</li>
111
                                  <li>No Item with barcode: [% errmsgloo.msg %]</li>
112
                              [% END %]
112
                              [% END %]
113
                              [% IF ( errmsgloo.errispermanent ) %]
113
                              [% IF ( errmsgloo.errispermanent ) %]
114
                                  <li>Please return item to home library: [% errmsgloo.msg %]</li>
114
                                  <li>Please return item to home library: [% Branches.GetName( errmsgloo.msg ) %]</li>
115
                              [% END %]
115
                              [% END %]
116
                              [% IF ( errmsgloo.errnotallowed ) %]
116
                              [% IF ( errmsgloo.errnotallowed ) %]
117
                                  <li>Transfer is not allowed for:
117
                                  <li>Transfer is not allowed for:
Lines 121-127 Link Here
121
                                          [% ELSE %]
121
                                          [% ELSE %]
122
                                              <li>Collection code: <b>[% AuthorisedValues.GetByCode( 'CCODE', errmsgloo.code ) %]</b></li>
122
                                              <li>Collection code: <b>[% AuthorisedValues.GetByCode( 'CCODE', errmsgloo.code ) %]</b></li>
123
                                          [% END %]
123
                                          [% END %]
124
                                          <li>Destination library: <b>[% errmsgloo.tbr %]</b></li>
124
                                          <li>Destination library: <b>[% Branches.GetName( errmsgloo.tbr ) %]</b></li>
125
                                      </ol>
125
                                      </ol>
126
                                  </li>
126
                                  </li>
127
                              [% END %]
127
                              [% END %]
Lines 187-193 Link Here
187
                    <td class="tf-itemcallnumber">[% trsfitemloo.itemcallnumber %]</td>
187
                    <td class="tf-itemcallnumber">[% trsfitemloo.itemcallnumber %]</td>
188
                    <td class="tf-itemtype">[% ItemTypes.GetDescription( trsfitemloo.itemtype ) %]</td>
188
                    <td class="tf-itemtype">[% ItemTypes.GetDescription( trsfitemloo.itemtype ) %]</td>
189
                    <td class="tf-ccode">[% AuthorisedValues.GetByCode( 'CCODE', trsfitemloo.ccode ) %]</td>
189
                    <td class="tf-ccode">[% AuthorisedValues.GetByCode( 'CCODE', trsfitemloo.ccode ) %]</td>
190
                    <td class="tf-destination">[% trsfitemloo.tobrname %]</td>
190
                    <td class="tf-destination">[% Branches.GetName( trsfitemloo.tobrname ) %]</td>
191
                </tr>
191
                </tr>
192
            [% END %]
192
            [% END %]
193
        </table>
193
        </table>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt (-5 / +5 lines)
Lines 227-236 $(document).ready(function () { Link Here
227
		   [% IF ( boremail ) %]<li><a id="boremail" href="mailto:[% boremail %]">[% boremail %]</a></li>[% END %]
227
		   [% IF ( boremail ) %]<li><a id="boremail" href="mailto:[% boremail %]">[% boremail %]</a></li>[% END %]
228
[% IF ( debarred ) %]<li class="error">Patron is RESTRICTED</li>[% END %]
228
[% IF ( debarred ) %]<li class="error">Patron is RESTRICTED</li>[% END %]
229
[% IF ( gonenoaddress ) %]<li class="error">Patron's address is in doubt</li>[% END %]</ul>
229
[% IF ( gonenoaddress ) %]<li class="error">Patron's address is in doubt</li>[% END %]</ul>
230
		[% IF ( transfertodo ) %]
230
        [% IF ( transfertodo ) %]
231
            <h4><strong>Transfer to:</strong> [% destbranchname %]</h4>
231
            <h4><strong>Transfer to:</strong> [% Branches.GetName( destbranchname ) %]</h4>
232
		[% ELSE %]
232
        [% ELSE %]
233
		<h4><strong>Hold at</strong> [% destbranchname %]</h4>
233
            <h4><strong>Hold at</strong> [% Branches.GetName( destbranchname ) %]</h4>
234
        [% END %]
234
        [% END %]
235
        <form method="post" action="returns.pl" class="confirm">
235
        <form method="post" action="returns.pl" class="confirm">
236
            <input type="hidden" name="cancel_reserve" value="0" />
236
            <input type="hidden" name="cancel_reserve" value="0" />
Lines 450-456 $(document).ready(function () { Link Here
450
                        <p class="problem">No item with barcode: [% errmsgloo.msg %]</p>
450
                        <p class="problem">No item with barcode: [% errmsgloo.msg %]</p>
451
                    [% END %]
451
                    [% END %]
452
                    [% IF ( errmsgloo.ispermanent ) %]
452
                    [% IF ( errmsgloo.ispermanent ) %]
453
                        <p class="problem">Please return item to: [% errmsgloo.msg %]</p>
453
                        <p class="problem">Please return item to: [% Branches.GetName( errmsgloo.msg ) %]</p>
454
                    [% END %]
454
                    [% END %]
455
                    [% IF ( errmsgloo.notissued ) %]
455
                    [% IF ( errmsgloo.notissued ) %]
456
                        <p class="problem">Not checked out.</p>
456
                        <p class="problem">Not checked out.</p>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt (-3 / +5 lines)
Lines 1-4 Link Here
1
[% USE Koha %]
1
[% USE Koha %]
2
[% USE Branches %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Patron search</title>
4
<title>Koha &rsaquo; Patron search</title>
4
[% INCLUDE 'doc-head-close.inc' %]
5
[% INCLUDE 'doc-head-close.inc' %]
Lines 179-189 function filterByFirstLetterSurname(letter) { Link Here
179
                    <li>
180
                    <li>
180
                        <label for="branchcode_filter">Library:</label>
181
                        <label for="branchcode_filter">Library:</label>
181
                        <select id="branchcode_filter">
182
                        <select id="branchcode_filter">
182
                            [% IF branches.size != 1 %]
183
                            [% SET libraries = Branches.all() %]
184
                            [% IF libraries.size != 1 %]
183
                                <option value="">Any</option>
185
                                <option value="">Any</option>
184
                            [% END %]
186
                            [% END %]
185
                            [% FOREACH branch IN branches %]
187
                            [% FOREACH l IN libraries %]
186
                                <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
188
                                <option value="[% l.branchcode %]">[% l.branchname %]</option>
187
                            [% END %]
189
                            [% END %]
188
                        </select>
190
                        </select>
189
                    </li>
191
                    </li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/borrowers_stats.tt (-1 / +1 lines)
Lines 143-149 Link Here
143
			<td>
143
			<td>
144
                <select name="Filter"  size="1" id="branch">
144
                <select name="Filter"  size="1" id="branch">
145
                <option value=""></option>
145
                <option value=""></option>
146
                [% FOREACH l IN Branches.all() %]
146
                [% FOREACH l IN Branches.all( unfiltered => 1 ) %]
147
                    <option value="[% l.branchcode %]">[% l.branchcode %] - [% l.branchname || 'UNKNOWN' %]</option>
147
                    <option value="[% l.branchcode %]">[% l.branchcode %] - [% l.branchname || 'UNKNOWN' %]</option>
148
                [% END %]
148
                [% END %]
149
                </select>
149
                </select>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (-7 / +7 lines)
Lines 14-23 Link Here
14
<script type="text/javascript">
14
<script type="text/javascript">
15
    // <![CDATA[
15
    // <![CDATA[
16
var MSG_CONFIRM_DELETE_HOLD   = _("Are you sure you want to cancel this hold?");
16
var MSG_CONFIRM_DELETE_HOLD   = _("Are you sure you want to cancel this hold?");
17
var patron_homebranch = "[% borrower_branchname |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]";
17
var patron_homebranch = "[% Branches.GetName( borrower_branchcode ) |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]";
18
var override_items = {[% FOREACH bibitemloo IN bibitemloop %][% FOREACH itemloo IN bibitemloo.itemloop %][% IF ( itemloo.override ) %]
18
var override_items = {[% FOREACH bibitemloo IN bibitemloop %][% FOREACH itemloo IN bibitemloo.itemloop %][% IF ( itemloo.override ) %]
19
    [% itemloo.itemnumber %]: {
19
    [% itemloo.itemnumber %]: {
20
        homebranch: "[% itemloo.homebranchname |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
20
        homebranch: "[% Branches.GetName( itemloo.homebranch ) |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
21
        holdallowed: [% itemloo.holdallowed %]
21
        holdallowed: [% itemloo.holdallowed %]
22
    },
22
    },
23
[% END %][% END %][% END %]
23
[% END %][% END %][% END %]
Lines 496-505 function checkMultiHold() { Link Here
496
                        [% itemloo.barcode %]
496
                        [% itemloo.barcode %]
497
                    </td>
497
                    </td>
498
                    <td>
498
                    <td>
499
                        [% itemloo.homebranchname %]
499
                        [% Branches.GetName( itemloo.homebranch ) %]
500
                    </td>
500
                    </td>
501
                    <td>
501
                    <td>
502
                        [% itemloo.holdingbranchname %]
502
                        [% Branches.GetName( itemloo.holdingbranch ) %]
503
                    </td>
503
                    </td>
504
                    <td>
504
                    <td>
505
                        [% itemloo.itemcallnumber %]
505
                        [% itemloo.itemcallnumber %]
Lines 518-525 function checkMultiHold() { Link Here
518
                [% ELSE %]
518
                [% ELSE %]
519
                    <span title="0000-00-00">
519
                    <span title="0000-00-00">
520
                        [% IF ( itemloo.transfertwhen ) %]
520
                        [% IF ( itemloo.transfertwhen ) %]
521
                            In transit from [% itemloo.transfertfrom %],
521
                            In transit from [% Branches.GetName( itemloo.transfertfrom ) %],
522
                            to [% itemloo.transfertto %], since [% itemloo.transfertwhen %]
522
                            to [% Branches.GetName( itemloo.transfertto ) %], since [% itemloo.transfertwhen %]
523
                        [% END %]
523
                        [% END %]
524
                    </span>
524
                    </span>
525
                [% END %]
525
                [% END %]
Lines 537-543 function checkMultiHold() { Link Here
537
                            Can't be cancelled when item is in transit
537
                            Can't be cancelled when item is in transit
538
                    [% ELSE %]
538
                    [% ELSE %]
539
                    [% IF ( itemloo.waitingdate ) %]Waiting[% ELSE %]On hold[% END %]
539
                    [% IF ( itemloo.waitingdate ) %]Waiting[% ELSE %]On hold[% END %]
540
                    [% IF ( itemloo.canreservefromotherbranches ) %]for <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% itemloo.ReservedForBorrowernumber %]">[% itemloo.ReservedForFirstname %] [% itemloo.ReservedForSurname %]</a>[% END %] [% IF ( itemloo.waitingdate ) %]at[% ELSE %]expected at[% END %] [% itemloo.ExpectedAtLibrary %]
540
                    [% IF ( itemloo.canreservefromotherbranches ) %]for <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% itemloo.ReservedForBorrowernumber %]">[% itemloo.ReservedForFirstname %] [% itemloo.ReservedForSurname %]</a>[% END %] [% IF ( itemloo.waitingdate ) %]at[% ELSE %]expected at[% END %] [% Branches.GetName( itemloo.ExpectedAtLibrary ) %]
541
                    since
541
                    since
542
                    [% IF ( itemloo.waitingdate ) %][% itemloo.waitingdate | $KohaDates %][% ELSE %][% IF ( itemloo.reservedate ) %][% itemloo.reservedate %][% END %][% END %]. <a class="info" href="modrequest.pl?CancelBiblioNumber=[% itemloo.biblionumber %]&amp;CancelBorrowerNumber=[% itemloo.ReservedForBorrowernumber %]&amp;CancelItemnumber=[% itemloo.itemnumber %]"  onclick="return confirmDelete(MSG_CONFIRM_DELETE_HOLD);">Cancel hold</a>
542
                    [% IF ( itemloo.waitingdate ) %][% itemloo.waitingdate | $KohaDates %][% ELSE %][% IF ( itemloo.reservedate ) %][% itemloo.reservedate %][% END %][% END %]. <a class="info" href="modrequest.pl?CancelBiblioNumber=[% itemloo.biblionumber %]&amp;CancelBorrowerNumber=[% itemloo.ReservedForBorrowernumber %]&amp;CancelItemnumber=[% itemloo.itemnumber %]"  onclick="return confirmDelete(MSG_CONFIRM_DELETE_HOLD);">Cancel hold</a>
543
543
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/transferCollection.tt (-8 / +3 lines)
Lines 1-3 Link Here
1
[% USE Branches %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Tools &rsaquo; Rotating collections &rsaquo; Transfer collection</title>
3
<title>Koha &rsaquo; Tools &rsaquo; Rotating collections &rsaquo; Transfer collection</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'doc-head-close.inc' %]
Lines 37-49 Link Here
37
                                    <li>
38
                                    <li>
38
                                        <label for="toBranch">Choose your library:</label>
39
                                        <label for="toBranch">Choose your library:</label>
39
                                        <select id="toBranch" name="toBranch">
40
                                        <select id="toBranch" name="toBranch">
40
                                            [% FOREACH branchoptionloo IN branchoptionloop %]
41
                                            [% PROCESS options_for_libraries libraries => Branches.all( unfiltered => 1 ) %]
41
                                                [% IF ( branchoptionloo.selected ) %]
42
                                                    <option value="[% branchoptionloo.code %]" selected="selected">[% branchoptionloo.name %]</option>
43
                                                [% ELSE %]
44
                                                    <option value="[% branchoptionloo.code %]">[% branchoptionloo.name %]</option>
45
                                                [% END %]
46
                                            [% END %]
47
                                        </select>
42
                                        </select>
48
                                    </li>
43
                                    </li>
49
                                </ol>
44
                                </ol>
Lines 61-64 Link Here
61
            [% INCLUDE 'tools-menu.inc' %]
56
            [% INCLUDE 'tools-menu.inc' %]
62
        </div>
57
        </div>
63
    </div> <!-- /#bd -->
58
    </div> <!-- /#bd -->
64
[% INCLUDE 'intranet-bottom.inc' %]
59
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt (-7 / +2 lines)
Lines 89-101 Link Here
89
                  <label for="branch">Library:</label>
89
                  <label for="branch">Library:</label>
90
                  <select id="branch" name="branch_filter">
90
                  <select id="branch" name="branch_filter">
91
                    <option value="">All</option>
91
                    <option value="">All</option>
92
                    [% FOREACH branch IN branches_loop %]
92
                    [%# FIXME Should not we filter the libraries? %]
93
                      [% IF ( branch.selected ) %]
93
                    [% PROCESS options_for_libraries libraries => Branches.all( selected => branch_filter, unfiltered => 1 ) %]
94
                        <option selected="selected" value="[% branch.branchcode %]">[% branch.branchname %]</option>
95
                      [% ELSE %]
96
                        <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
97
                      [% END %]
98
                    [% END %]
99
                  </select>
94
                  </select>
100
                </li>
95
                </li>
101
                [% IF locations %]
96
                [% IF locations %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt (-6 / +4 lines)
Lines 559-570 $(document).ready(function() { Link Here
559
                                        [% UNLESS ( Independentbranches ) %]
559
                                        [% UNLESS ( Independentbranches ) %]
560
                                            <option value="">None</option>
560
                                            <option value="">None</option>
561
                                        [% END %]
561
                                        [% END %]
562
                                        [% FOREACH branchloo IN branchloop %]
562
                                        [% IF CAN_user_serials_superserials %]
563
                                            [% IF ( branchloo.selected ) %]
563
                                            [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode, unfiltered => 1 ) %]
564
                                                <option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>
564
                                        [% ELSE %]
565
                                            [% ELSE %]
565
                                            [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode ) %]
566
                                                <option value="[% branchloo.value %]">[% branchloo.branchname %]</option>
567
                                            [% END %]
568
                                        [% END %]
566
                                        [% END %]
569
                                    </select> (select a library)
567
                                    </select> (select a library)
570
                                </li>
568
                                </li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt (-5 / +12 lines)
Lines 409-416 h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o Link Here
409
    <fieldset class="rows"> <legend>Acquisition information</legend><ol>
409
    <fieldset class="rows"> <legend>Acquisition information</legend><ol>
410
        <li><label for="branchcode">Library:</label>
410
        <li><label for="branchcode">Library:</label>
411
            <select name="branchcode" id="branchcode">
411
            <select name="branchcode" id="branchcode">
412
                <option value="">Any</option>[% FOREACH branchloo IN branchloop %]
412
                <option value="">Any</option>
413
                [% IF ( branchloo.selected ) %]<option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>[% ELSE %]<option value="[% branchloo.value %]">[% branchloo.branchname %]</option>[% END %][% END %]
413
                [% IF branchfilter %]
414
                    [% PROCESS options_for_libraries libraries => Branches.all( selected => branchfilter ) %]
415
                [% ELSE %]
416
                    [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode ) %]
417
                [% END %]
414
            </select>
418
            </select>
415
        </li>
419
        </li>
416
        <li><label for="budgetid">Fund:</label>
420
        <li><label for="budgetid">Fund:</label>
Lines 763-771 h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o Link Here
763
                    </select></li>
767
                    </select></li>
764
                    <li><label for="branchcode"> For:</label>
768
                    <li><label for="branchcode"> For:</label>
765
                    <select name="branchcode" id="branchcode">
769
                    <select name="branchcode" id="branchcode">
766
                        <option value="__ANY__">Any</option>[% FOREACH branchloo IN branchloop %]
770
                        <option value="__ANY__">Any</option>
767
                            [% IF ( branchloo.selected ) %] <option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>[% ELSE %] <option value="[% branchloo.value %]">[% branchloo.branchname %]</option>[% END %]
771
                        [% IF branchfilter %]
768
                            [% END %]
772
                            [% PROCESS options_for_libraries libraries => Branches.all( selected => branchfilter ) %]
773
                        [% ELSE %]
774
                            [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode ) %]
775
                        [% END %]
769
                    </select></li><li><input type="submit" value="Go" /></li></ol>
776
                    </select></li><li><input type="submit" value="Go" /></li></ol>
770
                </fieldset>
777
                </fieldset>
771
    </div>
778
    </div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt (-1 / +2 lines)
Lines 1-3 Link Here
1
[% USE Branches %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Tools &rsaquo; MARC export</title>
3
<title>Koha &rsaquo; Tools &rsaquo; MARC export</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'doc-head-close.inc' %]
Lines 78-84 $(document).ready(function() { Link Here
78
        <li>
79
        <li>
79
            <label>Library: </label>
80
            <label>Library: </label>
80
            [% INCLUDE 'branch-selector.inc'
81
            [% INCLUDE 'branch-selector.inc'
81
                branches = branchloop %]
82
                branches = libraries %]
82
        </li>
83
        </li>
83
        <li>
84
        <li>
84
            <label for="startcn">From item call number: </label>
85
            <label for="startcn">From item call number: </label>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt (-1 lines)
Lines 313-319 td.repeatableyearly a.ui-state-default { background: #FFCC66 none; color : Bl Link Here
313
    <!-- ***************************** Panel to deal with new holidays **********************  -->
313
    <!-- ***************************** Panel to deal with new holidays **********************  -->
314
    <div class="panel" id="newHoliday">
314
    <div class="panel" id="newHoliday">
315
         <form action="/cgi-bin/koha/tools/newHolidays.pl" method="post">
315
         <form action="/cgi-bin/koha/tools/newHolidays.pl" method="post">
316
                <input type="hidden" name="branchCodes" id="branchCodes" value="[% branchcodes %]" /> 
317
            <fieldset class="brief">
316
            <fieldset class="brief">
318
            <h3>Add new holiday</h3>
317
            <h3>Add new holiday</h3>
319
            <ol>
318
            <ol>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt (-1 / +1 lines)
Lines 139-145 $(document).ready(function(){ Link Here
139
        </li><li>
139
        </li><li>
140
        <label for="branchloop">Library: </label><select id="branchloop" name="branchcode" style="width:12em;">
140
        <label for="branchloop">Library: </label><select id="branchloop" name="branchcode" style="width:12em;">
141
            <option value="">All libraries</option>
141
            <option value="">All libraries</option>
142
            [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode ) %]
142
            [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode, unfiltered => 1, ) %]
143
        </select>
143
        </select>
144
        </li>
144
        </li>
145
        [% IF (authorised_values) %]
145
        [% IF (authorised_values) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt (-23 / +8 lines)
Lines 1-4 Link Here
1
[% USE KohaDates %]
1
[% USE KohaDates %]
2
[% USE Branches %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Tools &rsaquo; News</title>
4
<title>Koha &rsaquo; Tools &rsaquo; News</title>
4
[% INCLUDE 'doc-head-close.inc' %]
5
[% INCLUDE 'doc-head-close.inc' %]
Lines 108-125 Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div> Link Here
108
            <li>
109
            <li>
109
                <label for="branch">Library: </label>
110
                <label for="branch">Library: </label>
110
                <select id="branch" name="branch">
111
                <select id="branch" name="branch">
111
                [% IF ( new_detail.branchcode == '' ) %]
112
                    [% IF ( new_detail.branchcode == '' ) %]
112
                    <option value="" selected="selected">All libraries</option>
113
                        <option value="" selected="selected">All libraries</option>
113
                [% ELSE %]
114
                    [% ELSE %]
114
                    <option value=""         >All libraries</option>
115
                        <option value=""         >All libraries</option>
115
                [% END %]
116
                    [% END %]
116
                [% FOREACH branch_item IN branch_list %]
117
                    [% PROCESS options_for_libraries libraries => Branches.all( selected => new_detail.branchcode, unfiltered => 1, ) %]
117
                [% IF ( branch_item.value.branchcode == new_detail.branchcode ) %]
118
                    <option value="[% branch_item.value.branchcode %]" selected="selected">[% branch_item.value.branchname %]</option>
119
                [% ELSE %]
120
                    <option value="[% branch_item.value.branchcode %]">[% branch_item.value.branchname %]</option>
121
                [% END %]
122
                [% END %]
123
                </select>
118
                </select>
124
            </li>
119
            </li>
125
            <li>
120
            <li>
Lines 187-203 Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div> Link Here
187
                [% ELSE %]
182
                [% ELSE %]
188
                <option value=""         >All libraries</option>
183
                <option value=""         >All libraries</option>
189
                [% END %]
184
                [% END %]
190
                [% FOREACH branch_item IN branch_list %]
185
                [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode, unfiltered => 1, ) %]
191
                [% IF ( branch_item.value.branchcode == branchcode ) %]
192
                    <option value="[% branch_item.value.branchcode %]"
193
                            selected="selected">[% branch_item.value.branchname %]
194
                    </option>
195
                [% ELSE %]
196
                    <option value="[% branch_item.value.branchcode %]"
197
                                    >[% branch_item.value.branchname %]
198
                    </option>
199
                [% END %]
200
                [% END %]
201
            </select>
186
            </select>
202
            <input type="submit" class="button" value="Filter" />
187
            <input type="submit" class="button" value="Filter" />
203
        </form>
188
        </form>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc (-2 / +2 lines)
Lines 41-48 not use an API to fetch items that populates item.datedue. Link Here
41
41
42
[% IF ( item.transfertwhen ) %]
42
[% IF ( item.transfertwhen ) %]
43
    [% SET itemavailable = 0 %]
43
    [% SET itemavailable = 0 %]
44
    <span class="item-status intransit">In transit from [% item.transfertfrom %]
44
    <span class="item-status intransit">In transit from [% Branches.GetName( item.transfertfrom ) %]
45
    to [% item.transfertto %] since [% item.transfertwhen | $KohaDates %]</span>
45
    to [% Branches.GetName( item.transfertto ) %] since [% item.transfertwhen | $KohaDates %]</span>
46
[% END %]
46
[% END %]
47
47
48
[% IF ( item.waiting ) %]
48
[% IF ( item.waiting ) %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt (-3 / +3 lines)
Lines 321-328 Link Here
321
321
322
                                                                    <td class="barcode">[% itemLoo.barcode %]</td>
322
                                                                    <td class="barcode">[% itemLoo.barcode %]</td>
323
                                                                    [% UNLESS ( singleBranchMode ) %]
323
                                                                    [% UNLESS ( singleBranchMode ) %]
324
                                                                        <td class="homebranch">[% itemLoo.homeBranchName %]</td>
324
                                                                        <td class="homebranch">[% Branches.GetName( itemLoo.homeBranchName ) %]</td>
325
                                                                        <td class="holdingbranch">[% itemLoo.holdingBranchName %]</td>
325
                                                                        <td class="holdingbranch">[% Branches.GetName( itemLoo.holdingBranchName ) %]</td>
326
                                                                    [% END %]
326
                                                                    [% END %]
327
                                                                    <td class="call_no">[% itemLoo.callNumber %]</td>
327
                                                                    <td class="call_no">[% itemLoo.callNumber %]</td>
328
                                                                    [% IF ( itemdata_enumchron ) %]
328
                                                                    [% IF ( itemdata_enumchron ) %]
Lines 332-338 Link Here
332
                                                                        [% IF ( itemLoo.dateDue ) %]
332
                                                                        [% IF ( itemLoo.dateDue ) %]
333
                                                                            <span class="checkedout">Due [% itemLoo.dateDue %]</span>
333
                                                                            <span class="checkedout">Due [% itemLoo.dateDue %]</span>
334
                                                                        [% ELSIF ( itemLoo.transfertwhen ) %]
334
                                                                        [% ELSIF ( itemLoo.transfertwhen ) %]
335
                                                                            <span class="intransit">In transit from [% itemLoo.transfertfrom %] to [% itemLoo.transfertto %] since [% itemLoo.transfertwhen %]</span>
335
                                                                            <span class="intransit">In transit from [% Branches.GetName( itemLoo.transfertfrom ) %] to [% Branches.GetName( itemLoo.transfertto ) %] since [% itemLoo.transfertwhen %]</span>
336
                                                                        [% END %]
336
                                                                        [% END %]
337
337
338
                                                                        [% IF ( itemLoo.message ) %]
338
                                                                        [% IF ( itemLoo.message ) %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-topissues.tt (-1 / +2 lines)
Lines 1-4 Link Here
1
[% USE Koha %]
1
[% USE Koha %]
2
[% USE Branches %]
2
[% USE AuthorisedValues %]
3
[% USE AuthorisedValues %]
3
[% USE ItemTypes %]
4
[% USE ItemTypes %]
4
[% INCLUDE 'doc-head-open.inc' %]
5
[% INCLUDE 'doc-head-open.inc' %]
Lines 41-47 Link Here
41
                                    [% END %]
42
                                    [% END %]
42
                                    [% IF ( branch ) %]
43
                                    [% IF ( branch ) %]
43
                                    at
44
                                    at
44
                                    [% branch %]
45
                                    [% Branches.GetName( branch ) %]
45
                                    [% END %]
46
                                    [% END %]
46
                                    [% IF ( timeLimit != 999 ) %]
47
                                    [% IF ( timeLimit != 999 ) %]
47
                                    in the past [% timeLimitFinite %] months
48
                                    in the past [% timeLimitFinite %] months
(-)a/members/deletemem.pl (-1 lines)
Lines 29-35 use C4::Context; Link Here
29
use C4::Output;
29
use C4::Output;
30
use C4::Auth;
30
use C4::Auth;
31
use C4::Members;
31
use C4::Members;
32
use C4::Branch; # GetBranches
33
use Module::Load;
32
use Module::Load;
34
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
33
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
35
    load Koha::NorwegianPatronDB, qw( NLMarkForDeletion NLSync );
34
    load Koha::NorwegianPatronDB, qw( NLMarkForDeletion NLSync );
(-)a/members/guarantor_search.pl (-5 lines)
Lines 21-27 use Modern::Perl; Link Here
21
21
22
use CGI qw ( -utf8 );
22
use CGI qw ( -utf8 );
23
use C4::Auth;
23
use C4::Auth;
24
use C4::Branch qw( GetBranches );
25
use C4::Output;
24
use C4::Output;
26
use C4::Members;
25
use C4::Members;
27
26
Lines 45-53 my $op = $input->param('op') || ''; Link Here
45
44
46
my $referer = $input->referer();
45
my $referer = $input->referer();
47
46
48
my $onlymine = C4::Branch::onlymine;
49
my $branches = C4::Branch::GetBranches( $onlymine );
50
51
my $patron_categories = Koha::Patron::Categories->search_limited;
47
my $patron_categories = Koha::Patron::Categories->search_limited;
52
$template->param(
48
$template->param(
53
    view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
49
    view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
Lines 56-62 $template->param( Link Here
56
    selection_type => 'select',
52
    selection_type => 'select',
57
    alphabet        => ( C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ),
53
    alphabet        => ( C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ),
58
    categories      => $patron_categories,
54
    categories      => $patron_categories,
59
    branches        => [ map { { branchcode => $_->{branchcode}, branchname => $_->{branchname} } } values %$branches ],
60
    aaSorting       => 1,
55
    aaSorting       => 1,
61
);
56
);
62
output_html_with_http_headers( $input, $cookie, $template->output );
57
output_html_with_http_headers( $input, $cookie, $template->output );
(-)a/members/memberentry.pl (-1 lines)
Lines 37-43 use C4::Members::AttributeTypes; Link Here
37
use C4::Koha;
37
use C4::Koha;
38
use C4::Log;
38
use C4::Log;
39
use C4::Letters;
39
use C4::Letters;
40
use C4::Branch; # GetBranches
41
use C4::Form::MessagingPreferences;
40
use C4::Form::MessagingPreferences;
42
use Koha::Borrower::Debarments;
41
use Koha::Borrower::Debarments;
43
use Koha::DateUtils;
42
use Koha::DateUtils;
(-)a/members/pay.pl (-1 lines)
Lines 39-45 use C4::Accounts; Link Here
39
use C4::Stats;
39
use C4::Stats;
40
use C4::Koha;
40
use C4::Koha;
41
use C4::Overdues;
41
use C4::Overdues;
42
use C4::Branch;
43
use C4::Members::Attributes qw(GetBorrowerAttributes);
42
use C4::Members::Attributes qw(GetBorrowerAttributes);
44
43
45
use Koha::Patron::Categories;
44
use Koha::Patron::Categories;
(-)a/members/paycollect.pl (-1 lines)
Lines 28-34 use C4::Members; Link Here
28
use C4::Members::Attributes qw(GetBorrowerAttributes);
28
use C4::Members::Attributes qw(GetBorrowerAttributes);
29
use C4::Accounts;
29
use C4::Accounts;
30
use C4::Koha;
30
use C4::Koha;
31
use C4::Branch;
32
31
33
use Koha::Patron::Categories;
32
use Koha::Patron::Categories;
34
33
(-)a/members/readingrec.pl (-4 lines)
Lines 28-34 use CGI qw ( -utf8 ); Link Here
28
use C4::Auth;
28
use C4::Auth;
29
use C4::Output;
29
use C4::Output;
30
use C4::Members;
30
use C4::Members;
31
use C4::Branch qw(GetBranches);
32
use List::MoreUtils qw/any uniq/;
31
use List::MoreUtils qw/any uniq/;
33
use Koha::DateUtils;
32
use Koha::DateUtils;
34
use C4::Members::Attributes qw(GetBorrowerAttributes);
33
use C4::Members::Attributes qw(GetBorrowerAttributes);
Lines 73-80 if ( $borrowernumber eq C4::Context->preference('AnonymousPatron') ){ Link Here
73
    $issues = GetAllIssues($borrowernumber,$order,$limit);
72
    $issues = GetAllIssues($borrowernumber,$order,$limit);
74
}
73
}
75
74
76
my $branches = GetBranches();
77
78
#   barcode export
75
#   barcode export
79
if ( $op eq 'export_barcodes' ) {
76
if ( $op eq 'export_barcodes' ) {
80
    if ( $data->{'privacy'} < 2) {
77
    if ( $data->{'privacy'} < 2) {
Lines 129-135 $template->param( Link Here
129
    privacy           => $data->{'privacy'},
126
    privacy           => $data->{'privacy'},
130
    categoryname      => $data->{description},
127
    categoryname      => $data->{description},
131
    is_child          => ( $data->{category_type} eq 'C' ),
128
    is_child          => ( $data->{category_type} eq 'C' ),
132
    branchname        => $branches->{ $data->{branchcode} }->{branchname},
133
    loop_reading      => $issues,
129
    loop_reading      => $issues,
134
    activeBorrowerRelationship =>
130
    activeBorrowerRelationship =>
135
      ( C4::Context->preference('borrowerRelationship') ne '' ),
131
      ( C4::Context->preference('borrowerRelationship') ne '' ),
(-)a/members/routing-lists.pl (-3 lines)
Lines 22-28 use strict; Link Here
22
use CGI qw ( -utf8 );
22
use CGI qw ( -utf8 );
23
use C4::Output;
23
use C4::Output;
24
use C4::Auth qw/:DEFAULT get_session/;
24
use C4::Auth qw/:DEFAULT get_session/;
25
use C4::Branch; # GetBranches
26
use C4::Members;
25
use C4::Members;
27
use C4::Members::Attributes qw(GetBorrowerAttributes);
26
use C4::Members::Attributes qw(GetBorrowerAttributes);
28
use C4::Context;
27
use C4::Context;
Lines 53-60 my ( $template, $loggedinuser, $cookie ) = get_template_and_user ( Link Here
53
    }
52
    }
54
);
53
);
55
54
56
my $branches = GetBranches();
57
58
my $findborrower = $query->param('findborrower');
55
my $findborrower = $query->param('findborrower');
59
$findborrower =~ s|,| |g;
56
$findborrower =~ s|,| |g;
60
57
(-)a/opac/opac-basket.pl (-4 / +2 lines)
Lines 21-27 use warnings; Link Here
21
use CGI qw ( -utf8 );
21
use CGI qw ( -utf8 );
22
use C4::Koha;
22
use C4::Koha;
23
use C4::Biblio;
23
use C4::Biblio;
24
use C4::Branch;
25
use C4::Items;
24
use C4::Items;
26
use C4::Circulation;
25
use C4::Circulation;
27
use C4::Auth;
26
use C4::Auth;
Lines 91-97 foreach my $biblionumber ( @bibs ) { Link Here
91
        $dat->{'even'} = 1;
90
        $dat->{'even'} = 1;
92
    }
91
    }
93
92
94
my $branches = GetBranches();
95
    for my $itm (@items) {
93
    for my $itm (@items) {
96
        if ($itm->{'location'}){
94
        if ($itm->{'location'}){
97
            $itm->{'location_opac'} = $shelflocations->{$itm->{'location'} };
95
            $itm->{'location_opac'} = $shelflocations->{$itm->{'location'} };
Lines 99-106 my $branches = GetBranches(); Link Here
99
        my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($itm->{itemnumber});
97
        my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($itm->{itemnumber});
100
        if ( defined( $transfertwhen ) && $transfertwhen ne '' ) {
98
        if ( defined( $transfertwhen ) && $transfertwhen ne '' ) {
101
             $itm->{transfertwhen} = $transfertwhen;
99
             $itm->{transfertwhen} = $transfertwhen;
102
             $itm->{transfertfrom} = $branches->{$transfertfrom}{branchname};
100
             $itm->{transfertfrom} = $transfertfrom;
103
             $itm->{transfertto}   = $branches->{$transfertto}{branchname};
101
             $itm->{transfertto}   = $transfertto;
104
        }
102
        }
105
    }
103
    }
106
    $num++;
104
    $num++;
(-)a/opac/opac-detail.pl (-9 / +7 lines)
Lines 188-194 if ($session->param('busc')) { Link Here
188
        my ($arrParamsBusc, $offset, $results_per_page) = @_;
188
        my ($arrParamsBusc, $offset, $results_per_page) = @_;
189
189
190
        my $expanded_facet = $arrParamsBusc->{'expand'};
190
        my $expanded_facet = $arrParamsBusc->{'expand'};
191
        my $branches = GetBranches();
192
        my $itemtypes = GetItemTypes;
191
        my $itemtypes = GetItemTypes;
193
        my @servers;
192
        my @servers;
194
        @servers = @{$arrParamsBusc->{'server'}} if $arrParamsBusc->{'server'};
193
        @servers = @{$arrParamsBusc->{'server'}} if $arrParamsBusc->{'server'};
Lines 200-206 if ($session->param('busc')) { Link Here
200
        $sort_by[0] = $default_sort_by if !$sort_by[0] && defined($default_sort_by);
199
        $sort_by[0] = $default_sort_by if !$sort_by[0] && defined($default_sort_by);
201
        my ($error, $results_hashref, $facets);
200
        my ($error, $results_hashref, $facets);
202
        eval {
201
        eval {
203
            ($error, $results_hashref, $facets) = getRecords($arrParamsBusc->{'query'},$arrParamsBusc->{'simple_query'},\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$itemtypes,$arrParamsBusc->{'query_type'},$arrParamsBusc->{'scan'});
202
            ($error, $results_hashref, $facets) = getRecords($arrParamsBusc->{'query'},$arrParamsBusc->{'simple_query'},\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,undef,$itemtypes,$arrParamsBusc->{'query_type'},$arrParamsBusc->{'scan'});
204
        };
203
        };
205
        my $hits;
204
        my $hits;
206
        my @newresults;
205
        my @newresults;
Lines 480-486 if ($hideitems) { Link Here
480
    @items = @all_items;
479
    @items = @all_items;
481
}
480
}
482
481
483
my $branches = GetBranches();
484
my $branch = '';
482
my $branch = '';
485
if (C4::Context->userenv){
483
if (C4::Context->userenv){
486
    $branch = C4::Context->userenv->{branch};
484
    $branch = C4::Context->userenv->{branch};
Lines 491-509 if ( C4::Context->preference('HighlightOwnItemsOnOPAC') ) { Link Here
491
        ||
489
        ||
492
        C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch'
490
        C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch'
493
    ) {
491
    ) {
494
        my $branchname;
492
        my $branchcode;
495
        if ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'PatronBranch' ) {
493
        if ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'PatronBranch' ) {
496
            $branchname = $branches->{$branch}->{'branchname'};
494
            $branchcode = $branch;
497
        }
495
        }
498
        elsif (  C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch' ) {
496
        elsif (  C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch' ) {
499
            $branchname = $branches->{ $ENV{'BRANCHCODE'} }->{'branchname'};
497
            $branchcode = $ENV{'BRANCHCODE'};
500
        }
498
        }
501
499
502
        my @our_items;
500
        my @our_items;
503
        my @other_items;
501
        my @other_items;
504
502
505
        foreach my $item ( @items ) {
503
        foreach my $item ( @items ) {
506
           if ( $item->{'branchname'} eq $branchname ) {
504
           if ( $item->{branchcode} eq $branchcode ) {
507
               $item->{'this_branch'} = 1;
505
               $item->{'this_branch'} = 1;
508
               push( @our_items, $item );
506
               push( @our_items, $item );
509
           } else {
507
           } else {
Lines 669-676 if ( not $viewallitems and @items > $max_items_to_display ) { Link Here
669
     my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($itm->{itemnumber});
667
     my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($itm->{itemnumber});
670
     if ( defined( $transfertwhen ) && $transfertwhen ne '' ) {
668
     if ( defined( $transfertwhen ) && $transfertwhen ne '' ) {
671
        $itm->{transfertwhen} = $transfertwhen;
669
        $itm->{transfertwhen} = $transfertwhen;
672
        $itm->{transfertfrom} = $branches->{$transfertfrom}{branchname};
670
        $itm->{transfertfrom} = $transfertfrom;
673
        $itm->{transfertto}   = $branches->{$transfertto}{branchname};
671
        $itm->{transfertto}   = $transfertto;
674
     }
672
     }
675
    
673
    
676
    if (    C4::Context->preference('OPACAcquisitionDetails')
674
    if (    C4::Context->preference('OPACAcquisitionDetails')
(-)a/opac/opac-reserve.pl (-10 / +5 lines)
Lines 30-36 use C4::Items; Link Here
30
use C4::Output;
30
use C4::Output;
31
use C4::Context;
31
use C4::Context;
32
use C4::Members;
32
use C4::Members;
33
use C4::Branch; # GetBranches
34
use C4::Overdues;
33
use C4::Overdues;
35
use C4::Debug;
34
use C4::Debug;
36
use Koha::DateUtils;
35
use Koha::DateUtils;
Lines 87-94 if ( $borr->{'BlockExpiredPatronOpacActions'} ) { Link Here
87
if ($borr->{reservefee} > 0){
86
if ($borr->{reservefee} > 0){
88
    $template->param( RESERVE_CHARGE => sprintf("%.2f",$borr->{reservefee}));
87
    $template->param( RESERVE_CHARGE => sprintf("%.2f",$borr->{reservefee}));
89
}
88
}
90
# get branches and itemtypes
89
91
my $branches = GetBranches();
92
my $itemTypes = GetItemTypes();
90
my $itemTypes = GetItemTypes();
93
91
94
# There are two ways of calling this script, with a single biblio num
92
# There are two ways of calling this script, with a single biblio num
Lines 123-129 if (($#biblionumbers < 0) && (! $query->param('place_reserve'))) { Link Here
123
121
124
# pass the pickup branch along....
122
# pass the pickup branch along....
125
my $branch = $query->param('branch') || $borr->{'branchcode'} || C4::Context->userenv->{branch} || '' ;
123
my $branch = $query->param('branch') || $borr->{'branchcode'} || C4::Context->userenv->{branch} || '' ;
126
($branches->{$branch}) or $branch = "";     # Confirm branch is real
127
$template->param( branch => $branch );
124
$template->param( branch => $branch );
128
125
129
# Is the person allowed to choose their branch
126
# Is the person allowed to choose their branch
Lines 432-438 foreach my $biblioNum (@biblionumbers) { Link Here
432
429
433
        $itemLoopIter->{itemnumber} = $itemNum;
430
        $itemLoopIter->{itemnumber} = $itemNum;
434
        $itemLoopIter->{barcode} = $itemInfo->{barcode};
431
        $itemLoopIter->{barcode} = $itemInfo->{barcode};
435
        $itemLoopIter->{homeBranchName} = $branches->{$itemInfo->{homebranch}}{branchname};
432
        $itemLoopIter->{homeBranchName} = $itemInfo->{homebranch};
436
        $itemLoopIter->{callNumber} = $itemInfo->{itemcallnumber};
433
        $itemLoopIter->{callNumber} = $itemInfo->{itemcallnumber};
437
        $itemLoopIter->{enumchron} = $itemInfo->{enumchron};
434
        $itemLoopIter->{enumchron} = $itemInfo->{enumchron};
438
        $itemLoopIter->{copynumber} = $itemInfo->{copynumber};
435
        $itemLoopIter->{copynumber} = $itemInfo->{copynumber};
Lines 444-451 foreach my $biblioNum (@biblionumbers) { Link Here
444
        # If the holdingbranch is different than the homebranch, we show the
441
        # If the holdingbranch is different than the homebranch, we show the
445
        # holdingbranch of the document too.
442
        # holdingbranch of the document too.
446
        if ( $itemInfo->{homebranch} ne $itemInfo->{holdingbranch} ) {
443
        if ( $itemInfo->{homebranch} ne $itemInfo->{holdingbranch} ) {
447
            $itemLoopIter->{holdingBranchName} =
444
            $itemLoopIter->{holdingBranchName} = $itemInfo->{holdingbranch};
448
              $branches->{ $itemInfo->{holdingbranch} }{branchname};
449
        }
445
        }
450
446
451
        # If the item is currently on loan, we display its return date and
447
        # If the item is currently on loan, we display its return date and
Lines 503-511 foreach my $biblioNum (@biblionumbers) { Link Here
503
          GetTransfers($itemNum);
499
          GetTransfers($itemNum);
504
        if ( $transfertwhen && ($transfertwhen ne '') ) {
500
        if ( $transfertwhen && ($transfertwhen ne '') ) {
505
            $itemLoopIter->{transfertwhen} = output_pref({ dt => dt_from_string($transfertwhen), dateonly => 1 });
501
            $itemLoopIter->{transfertwhen} = output_pref({ dt => dt_from_string($transfertwhen), dateonly => 1 });
506
            $itemLoopIter->{transfertfrom} =
502
            $itemLoopIter->{transfertfrom} = $transfertfrom;
507
              $branches->{$transfertfrom}{branchname};
503
            $itemLoopIter->{transfertto} = $transfertto;
508
            $itemLoopIter->{transfertto} = $branches->{$transfertto}{branchname};
509
            $itemLoopIter->{nocancel} = 1;
504
            $itemLoopIter->{nocancel} = 1;
510
        }
505
        }
511
506
(-)a/opac/opac-search.pl (-8 / +6 lines)
Lines 38-44 use C4::Search::History; Link Here
38
use C4::Biblio;  # GetBiblioData
38
use C4::Biblio;  # GetBiblioData
39
use C4::Koha;
39
use C4::Koha;
40
use C4::Tags qw(get_tags);
40
use C4::Tags qw(get_tags);
41
use C4::Branch; # GetBranches
42
use C4::SocialData;
41
use C4::SocialData;
43
use C4::Ratings;
42
use C4::Ratings;
44
use C4::External::OverDrive;
43
use C4::External::OverDrive;
Lines 202-208 if ($cgi->cookie("search_path_code")) { Link Here
202
    }
201
    }
203
}
202
}
204
203
205
my $branches = GetBranches();   # used later in *getRecords, probably should be internalized by those functions after caching in C4::Branch is established
206
my $library_categories = Koha::LibraryCategories->search( { categorytype => 'searchdomain' }, { order_by => [ 'categorytype', 'categorycode' ] } );
204
my $library_categories = Koha::LibraryCategories->search( { categorytype => 'searchdomain' }, { order_by => [ 'categorytype', 'categorycode' ] } );
207
$template->param( searchdomainloop => $library_categories );
205
$template->param( searchdomainloop => $library_categories );
208
206
Lines 597-603 if ($tag) { Link Here
597
    # FIXME: No facets for tags search.
595
    # FIXME: No facets for tags search.
598
} elsif ($build_grouped_results) {
596
} elsif ($build_grouped_results) {
599
    eval {
597
    eval {
600
        ($error, $results_hashref, $facets) = C4::Search::pazGetRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan);
598
        ($error, $results_hashref, $facets) = C4::Search::pazGetRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,undef,$query_type,$scan);
601
    };
599
    };
602
} else {
600
} else {
603
    $pasarParams .= '&amp;query=' . uri_escape_utf8($query);
601
    $pasarParams .= '&amp;query=' . uri_escape_utf8($query);
Lines 605-611 if ($tag) { Link Here
605
    $pasarParams .= '&amp;simple_query=' . uri_escape_utf8($simple_query);
603
    $pasarParams .= '&amp;simple_query=' . uri_escape_utf8($simple_query);
606
    $pasarParams .= '&amp;query_type=' . uri_escape_utf8($query_type) if ($query_type);
604
    $pasarParams .= '&amp;query_type=' . uri_escape_utf8($query_type) if ($query_type);
607
    eval {
605
    eval {
608
        ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$itemtypes_nocategory,$query_type,$scan,1);
606
        ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,undef,$itemtypes_nocategory,$query_type,$scan,1);
609
    };
607
    };
610
}
608
}
611
# This sorts the facets into alphabetical order
609
# This sorts the facets into alphabetical order
Lines 794-805 for (my $i=0;$i<@servers;$i++) { Link Here
794
                    ||
792
                    ||
795
                    C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch'
793
                    C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch'
796
                ) {
794
                ) {
797
                    my $branchname;
795
                    my $branchcode;
798
                    if ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'PatronBranch' ) {
796
                    if ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'PatronBranch' ) {
799
                        $branchname = $branches->{$branch}->{'branchname'};
797
                        $branchcode = $branch;
800
                    }
798
                    }
801
                    elsif (  C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch' ) {
799
                    elsif (  C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch' ) {
802
                        $branchname = $branches->{ $ENV{'BRANCHCODE'} }->{'branchname'};
800
                        $branchcode = $ENV{'BRANCHCODE'};
803
                    }
801
                    }
804
802
805
                    foreach my $res ( @newresults ) {
803
                    foreach my $res ( @newresults ) {
Lines 807-813 for (my $i=0;$i<@servers;$i++) { Link Here
807
                        my @top_loop;
805
                        my @top_loop;
808
                        my @old_loop = @{$res->{'available_items_loop'}};
806
                        my @old_loop = @{$res->{'available_items_loop'}};
809
                        foreach my $item ( @old_loop ) {
807
                        foreach my $item ( @old_loop ) {
810
                            if ( $item->{'branchname'} eq $branchname ) {
808
                            if ( $item->{'branchcode'} eq $branchcode ) {
811
                                $item->{'this_branch'} = 1;
809
                                $item->{'this_branch'} = 1;
812
                                push( @top_loop, $item );
810
                                push( @top_loop, $item );
813
                            } else {
811
                            } else {
(-)a/opac/opac-topissues.pl (-2 / +1 lines)
Lines 49-55 if ( ! C4::Context->preference('OpacTopissue') ) { Link Here
49
    exit;
49
    exit;
50
}
50
}
51
51
52
my $branches = GetBranches();
53
my $itemtypes = GetItemTypes();
52
my $itemtypes = GetItemTypes();
54
53
55
my ($template, $borrowernumber, $cookie) = get_template_and_user(
54
my ($template, $borrowernumber, $cookie) = get_template_and_user(
Lines 95-101 my @results = GetTopIssues($params); Link Here
95
94
96
$template->param(
95
$template->param(
97
    limit => $limit,
96
    limit => $limit,
98
    branch => $branches->{$branch}->{branchname},
97
    branch => $branch,
99
    timeLimit => $timeLimit,
98
    timeLimit => $timeLimit,
100
    results => \@results,
99
    results => \@results,
101
);
100
);
(-)a/opac/opac-user.pl (-1 lines)
Lines 33-39 use C4::Output; Link Here
33
use C4::Biblio;
33
use C4::Biblio;
34
use C4::Items;
34
use C4::Items;
35
use C4::Letters;
35
use C4::Letters;
36
use C4::Branch; # GetBranches
37
use Koha::DateUtils;
36
use Koha::DateUtils;
38
use Koha::Borrower::Debarments qw(IsDebarred);
37
use Koha::Borrower::Debarments qw(IsDebarred);
39
use Koha::Holds;
38
use Koha::Holds;
(-)a/patroncards/add_user_search.pl (-5 lines)
Lines 21-27 use Modern::Perl; Link Here
21
21
22
use CGI qw ( -utf8 );
22
use CGI qw ( -utf8 );
23
use C4::Auth;
23
use C4::Auth;
24
use C4::Branch qw( GetBranches );
25
use C4::Output;
24
use C4::Output;
26
use C4::Members;
25
use C4::Members;
27
26
Lines 45-53 my $op = $input->param('op') || ''; Link Here
45
44
46
my $referer = $input->referer();
45
my $referer = $input->referer();
47
46
48
my $onlymine = C4::Branch::onlymine;
49
my $branches = C4::Branch::GetBranches( $onlymine );
50
51
my $patron_categories = Koha::Patron::Categories->search_limited;
47
my $patron_categories = Koha::Patron::Categories->search_limited;
52
$template->param(
48
$template->param(
53
    view            => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
49
    view            => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
Lines 56-62 $template->param( Link Here
56
    selection_type  => 'add',
52
    selection_type  => 'add',
57
    alphabet        => ( C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ),
53
    alphabet        => ( C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ),
58
    categories      => $patron_categories,
54
    categories      => $patron_categories,
59
    branches        => [ map { { branchcode => $_->{branchcode}, branchname => $_->{branchname} } } values %$branches ],
60
    aaSorting       => 1,
55
    aaSorting       => 1,
61
);
56
);
62
output_html_with_http_headers( $input, $cookie, $template->output );
57
output_html_with_http_headers( $input, $cookie, $template->output );
(-)a/reports/acquisitions_stats.pl (-6 / +2 lines)
Lines 26-34 use C4::Reports; Link Here
26
use C4::Output;
26
use C4::Output;
27
use C4::Koha;
27
use C4::Koha;
28
use C4::Circulation;
28
use C4::Circulation;
29
use C4::Branch;
30
use C4::Biblio;
29
use C4::Biblio;
31
use Koha::DateUtils;
30
use Koha::DateUtils;
31
use Koha::Libraries;
32
32
33
=head1 NAME
33
=head1 NAME
34
34
Lines 185-195 else { Link Here
185
185
186
    my $CGIsepChoice = GetDelimiterChoices;
186
    my $CGIsepChoice = GetDelimiterChoices;
187
187
188
    my $branches = GetBranches;
188
    my @branches = Koha::Libraries->search({}, { order_by => 'branchname' });
189
    my @branches;
190
    foreach ( sort keys %$branches ) {
191
        push @branches, $branches->{$_};
192
    }
193
189
194
    my $ccode_subfield_structure = GetMarcSubfieldStructureFromKohaField('items.ccode', '');
190
    my $ccode_subfield_structure = GetMarcSubfieldStructureFromKohaField('items.ccode', '');
195
    my $ccode_label;
191
    my $ccode_label;
(-)a/reports/borrowers_stats.pl (-2 / +3 lines)
Lines 23-29 use List::MoreUtils qw/uniq/; Link Here
23
23
24
use C4::Auth;
24
use C4::Auth;
25
use C4::Context;
25
use C4::Context;
26
use C4::Branch; # GetBranches
27
use C4::Koha;
26
use C4::Koha;
28
use Koha::DateUtils;
27
use Koha::DateUtils;
29
use C4::Acquisition;
28
use C4::Acquisition;
Lines 32-37 use C4::Reports; Link Here
32
use C4::Circulation;
31
use C4::Circulation;
33
use C4::Members::AttributeTypes;
32
use C4::Members::AttributeTypes;
34
33
34
use Koha::Libraries;
35
use Koha::Patron::Categories;
35
use Koha::Patron::Categories;
36
36
37
use Date::Calc qw(
37
use Date::Calc qw(
Lines 228-236 sub calculate { Link Here
228
        }
228
        }
229
    }
229
    }
230
230
231
    my @branchcodes = map { $_->branchcode } Koha::Libraries->search;
231
	($status  ) and push @loopfilter,{crit=>"Status",  filter=>$status  };
232
	($status  ) and push @loopfilter,{crit=>"Status",  filter=>$status  };
232
	($activity) and push @loopfilter,{crit=>"Activity",filter=>$activity};
233
	($activity) and push @loopfilter,{crit=>"Activity",filter=>$activity};
233
	push @loopfilter,{debug=>1, crit=>"Branches",filter=>join(" ", sort keys %$branches)};
234
    push @loopfilter,{debug=>1, crit=>"Branches",filter=>join(" ", sort @branchcodes)};
234
	push @loopfilter,{debug=>1, crit=>"(line, column)", filter=>"($line,$column)"};
235
	push @loopfilter,{debug=>1, crit=>"(line, column)", filter=>"($line,$column)"};
235
# year of activity
236
# year of activity
236
	my ( $period_year, $period_month, $period_day )=Add_Delta_YM( Today(),-$period, 0);
237
	my ( $period_year, $period_month, $period_day )=Add_Delta_YM( Today(),-$period, 0);
(-)a/reports/issues_avg_stats.pl (-1 lines)
Lines 23-29 use strict; Link Here
23
use C4::Auth;
23
use C4::Auth;
24
use CGI qw ( -utf8 );
24
use CGI qw ( -utf8 );
25
use C4::Context;
25
use C4::Context;
26
use C4::Branch; # GetBranches
27
use C4::Output;
26
use C4::Output;
28
use C4::Koha;
27
use C4::Koha;
29
use C4::Circulation;
28
use C4::Circulation;
(-)a/reports/issues_by_borrower_category.plugin (-2 lines)
Lines 27-34 use C4::Output; Link Here
27
use C4::Koha;
27
use C4::Koha;
28
use C4::Members;
28
use C4::Members;
29
29
30
use C4::Branch; # GetBranches
31
32
use Koha::Patron::Categories;
30
use Koha::Patron::Categories;
33
31
34
=head1 NAME
32
=head1 NAME
(-)a/reserve/request.pl (-14 / +6 lines)
Lines 28-34 script to place reserves/requests Link Here
28
28
29
use strict;
29
use strict;
30
use warnings;
30
use warnings;
31
use C4::Branch;
32
use CGI qw ( -utf8 );
31
use CGI qw ( -utf8 );
33
use List::MoreUtils qw/uniq/;
32
use List::MoreUtils qw/uniq/;
34
use Date::Calc qw/Date_to_Days/;
33
use Date::Calc qw/Date_to_Days/;
Lines 64-71 my $multihold = $input->param('multi_hold'); Link Here
64
$template->param(multi_hold => $multihold);
63
$template->param(multi_hold => $multihold);
65
my $showallitems = $input->param('showallitems');
64
my $showallitems = $input->param('showallitems');
66
65
67
# get Branches and Itemtypes
68
my $branches = GetBranches();
69
my $itemtypes = GetItemTypes();
66
my $itemtypes = GetItemTypes();
70
67
71
# Select borrowers infos
68
# Select borrowers infos
Lines 346-358 foreach my $biblionumber (@biblionumbers) { Link Here
346
343
347
            $item->{itypename} = $itemtypes->{ $item->{itype} }{description};
344
            $item->{itypename} = $itemtypes->{ $item->{itype} }{description};
348
            $item->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $item->{itype} }{imageurl} );
345
            $item->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $item->{itype} }{imageurl} );
349
            $item->{homebranchname} = $branches->{ $item->{homebranch} }{branchname};
346
            $item->{homebranch} = $item->{homebranch};
350
347
351
            # if the holdingbranch is different than the homebranch, we show the
348
            # if the holdingbranch is different than the homebranch, we show the
352
            # holdingbranch of the document too
349
            # holdingbranch of the document too
353
            if ( $item->{homebranch} ne $item->{holdingbranch} ) {
350
            if ( $item->{homebranch} ne $item->{holdingbranch} ) {
354
                $item->{holdingbranchname} =
351
                $item->{holdingbranch} = $item->{holdingbranch};
355
                  $branches->{ $item->{holdingbranch} }{branchname};
356
            }
352
            }
357
353
358
		if($item->{biblionumber} ne $biblionumber){
354
		if($item->{biblionumber} ne $biblionumber){
Lines 378-384 foreach my $biblionumber (@biblionumbers) { Link Here
378
                $item->{ReservedForBorrowernumber}     = $reservedfor;
374
                $item->{ReservedForBorrowernumber}     = $reservedfor;
379
                $item->{ReservedForSurname}     = $ItemBorrowerReserveInfo->{'surname'};
375
                $item->{ReservedForSurname}     = $ItemBorrowerReserveInfo->{'surname'};
380
                $item->{ReservedForFirstname}     = $ItemBorrowerReserveInfo->{'firstname'};
376
                $item->{ReservedForFirstname}     = $ItemBorrowerReserveInfo->{'firstname'};
381
                $item->{ExpectedAtLibrary}     = $branches->{$expectedAt}{branchname};
377
                $item->{ExpectedAtLibrary}     = $expectedAt;
382
                $item->{waitingdate} = $wait;
378
                $item->{waitingdate} = $wait;
383
            }
379
            }
384
380
Lines 410-418 foreach my $biblionumber (@biblionumbers) { Link Here
410
406
411
            if ( defined $transfertwhen && $transfertwhen ne '' ) {
407
            if ( defined $transfertwhen && $transfertwhen ne '' ) {
412
                $item->{transfertwhen} = output_pref({ dt => dt_from_string( $transfertwhen ), dateonly => 1 });
408
                $item->{transfertwhen} = output_pref({ dt => dt_from_string( $transfertwhen ), dateonly => 1 });
413
                $item->{transfertfrom} =
409
                $item->{transfertfrom} = $transfertfrom;
414
                  $branches->{$transfertfrom}{branchname};
410
                $item->{transfertto} = $transfertto;
415
                $item->{transfertto} = $branches->{$transfertto}{branchname};
416
                $item->{nocancel} = 1;
411
                $item->{nocancel} = 1;
417
            }
412
            }
418
413
Lines 583-592 foreach my $biblionumber (@biblionumbers) { Link Here
583
                     C4::Search::enabled_staff_search_views,
578
                     C4::Search::enabled_staff_search_views,
584
                    );
579
                    );
585
    if (defined $borrowerinfo && exists $borrowerinfo->{'branchcode'}) {
580
    if (defined $borrowerinfo && exists $borrowerinfo->{'branchcode'}) {
586
        $template->param(
581
        $template->param( borrower_branchcode => $borrowerinfo->{'branchcode'},);
587
                     borrower_branchname => $branches->{$borrowerinfo->{'branchcode'}}->{'branchname'},
588
                     borrower_branchcode => $borrowerinfo->{'branchcode'},
589
        );
590
    }
582
    }
591
583
592
    $biblioloopiter{biblionumber} = $biblionumber;
584
    $biblioloopiter{biblionumber} = $biblionumber;
(-)a/rotating_collections/transferCollection.pl (-13 lines)
Lines 22-28 use C4::Output; Link Here
22
use C4::Auth;
22
use C4::Auth;
23
use C4::Context;
23
use C4::Context;
24
use C4::RotatingCollections;
24
use C4::RotatingCollections;
25
use C4::Branch;
26
25
27
use CGI qw ( -utf8 );
26
use CGI qw ( -utf8 );
28
27
Lines 60-76 if ($toBranch) { Link Here
60
    }
59
    }
61
}
60
}
62
61
63
## Set up the toBranch select options
64
my $branches = GetBranches();
65
my @branchoptionloop;
66
foreach my $br ( keys %$branches ) {
67
    my %branch;
68
    $branch{code} = $br;
69
    $branch{name} = $branches->{$br}->{'branchname'};
70
    push( @branchoptionloop, \%branch );
71
}
72
@branchoptionloop = sort {$a->{name} cmp $b->{name}} @branchoptionloop;
73
74
## Get data about collection
62
## Get data about collection
75
my ( $colTitle, $colDesc, $colBranchcode );
63
my ( $colTitle, $colDesc, $colBranchcode );
76
( $colId, $colTitle, $colDesc, $colBranchcode ) = GetCollection($colId);
64
( $colId, $colTitle, $colDesc, $colBranchcode ) = GetCollection($colId);
Lines 79-85 $template->param( Link Here
79
    colTitle         => $colTitle,
67
    colTitle         => $colTitle,
80
    colDesc          => $colDesc,
68
    colDesc          => $colDesc,
81
    colBranchcode    => $colBranchcode,
69
    colBranchcode    => $colBranchcode,
82
    branchoptionloop => \@branchoptionloop
83
);
70
);
84
71
85
output_html_with_http_headers $query, $cookie, $template->output;
72
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/serials/add_user_search.pl (-5 lines)
Lines 21-27 use Modern::Perl; Link Here
21
21
22
use CGI qw ( -utf8 );
22
use CGI qw ( -utf8 );
23
use C4::Auth;
23
use C4::Auth;
24
use C4::Branch qw( GetBranches );
25
use C4::Output;
24
use C4::Output;
26
use C4::Members;
25
use C4::Members;
27
26
Lines 45-54 my $op = $input->param('op') || ''; Link Here
45
44
46
my $referer = $input->referer();
45
my $referer = $input->referer();
47
46
48
my $onlymine = C4::Branch::onlymine;
49
my $branches = C4::Branch::GetBranches( $onlymine );
50
my $patron_categories = Koha::Patron::Categories->search_limited;
47
my $patron_categories = Koha::Patron::Categories->search_limited;
51
52
$template->param(
48
$template->param(
53
    view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
49
    view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
54
    columns => ['cardnumber', 'name', 'branch', 'action'],
50
    columns => ['cardnumber', 'name', 'branch', 'action'],
Lines 56-62 $template->param( Link Here
56
    selection_type => 'add',
52
    selection_type => 'add',
57
    alphabet        => ( C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ),
53
    alphabet        => ( C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ),
58
    categories      => $patron_categories,
54
    categories      => $patron_categories,
59
    branches        => [ map { { branchcode => $_->{branchcode}, branchname => $_->{branchname} } } values %$branches ],
60
    aaSorting       => 1,
55
    aaSorting       => 1,
61
);
56
);
62
output_html_with_http_headers( $input, $cookie, $template->output );
57
output_html_with_http_headers( $input, $cookie, $template->output );
(-)a/serials/serials-search.pl (-15 lines)
Lines 31-37 this script is the search page for serials Link Here
31
use Modern::Perl;
31
use Modern::Perl;
32
use CGI qw ( -utf8 );
32
use CGI qw ( -utf8 );
33
use C4::Auth;
33
use C4::Auth;
34
use C4::Branch;
35
use C4::Context;
34
use C4::Context;
36
use C4::Koha qw( GetAuthorisedValues );
35
use C4::Koha qw( GetAuthorisedValues );
37
use C4::Output;
36
use C4::Output;
Lines 131-149 for my $sub ( @subscriptions ) { Link Here
131
    }
130
    }
132
}
131
}
133
132
134
my $branches = GetBranches();
135
my @branches_loop;
136
foreach (sort keys %$branches){
137
    my $selected = 0;
138
    $selected = 1 if( defined $branch and $branch eq $_ );
139
    push @branches_loop, {
140
        branchcode  => $_,
141
        branchname  => $branches->{$_}->{'branchname'},
142
        selected    => $selected,
143
    };
144
}
145
146
147
$template->param(
133
$template->param(
148
    openedsubscriptions => \@openedsubscriptions,
134
    openedsubscriptions => \@openedsubscriptions,
149
    closedsubscriptions => \@closedsubscriptions,
135
    closedsubscriptions => \@closedsubscriptions,
Lines 157-163 $template->param( Link Here
157
    branch_filter => $branch,
143
    branch_filter => $branch,
158
    locations     => C4::Koha::GetAuthorisedValues('LOC', $location),
144
    locations     => C4::Koha::GetAuthorisedValues('LOC', $location),
159
    expiration_date_filter => $expiration_date_dt,
145
    expiration_date_filter => $expiration_date_dt,
160
    branches_loop => \@branches_loop,
161
    done_searched => $searched,
146
    done_searched => $searched,
162
    routing       => $routing,
147
    routing       => $routing,
163
    additional_field_filters => $additional_field_filters,
148
    additional_field_filters => $additional_field_filters,
(-)a/serials/subscription-add.pl (-22 / +2 lines)
Lines 26-32 use C4::Auth; Link Here
26
use C4::Acquisition;
26
use C4::Acquisition;
27
use C4::Output;
27
use C4::Output;
28
use C4::Context;
28
use C4::Context;
29
use C4::Branch; # GetBranches
30
use C4::Serials;
29
use C4::Serials;
31
use C4::Serials::Frequency;
30
use C4::Serials::Frequency;
32
use C4::Serials::Numberpattern;
31
use C4::Serials::Numberpattern;
Lines 126-154 if ($op eq 'modify' || $op eq 'dup' || $op eq 'modsubscription') { Link Here
126
125
127
}
126
}
128
127
129
my $onlymine =
130
     C4::Context->preference('IndependentBranches')
131
  && C4::Context->userenv
132
  && !C4::Context->IsSuperLibrarian
133
  && (
134
    not C4::Auth::haspermission( C4::Context->userenv->{id}, { serials => 'superserials' } )
135
  )
136
  && C4::Context->userenv->{branch};
137
my $branches = GetBranches($onlymine);
138
my $branchloop;
139
for my $thisbranch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %{$branches}) {
140
    my $selected = 0;
141
    $selected = 1 if (defined($subs) && $thisbranch eq $subs->{'branchcode'});
142
    push @{$branchloop}, {
143
        value => $thisbranch,
144
        selected => $selected,
145
        branchname => $branches->{$thisbranch}->{'branchname'},
146
    };
147
}
148
149
my $locations_loop = GetAuthorisedValues("LOC",$subs->{'location'});
128
my $locations_loop = GetAuthorisedValues("LOC",$subs->{'location'});
150
129
151
$template->param(branchloop => $branchloop,
130
$template->param(
131
    branchcode => $subs->{branchcode},
152
    locations_loop=>$locations_loop,
132
    locations_loop=>$locations_loop,
153
);
133
);
154
134
(-)a/suggestion/suggestion.pl (-26 / +5 lines)
Lines 25-31 use C4::Auth; # get_template_and_user Link Here
25
use C4::Output;
25
use C4::Output;
26
use C4::Suggestions;
26
use C4::Suggestions;
27
use C4::Koha; #GetItemTypes
27
use C4::Koha; #GetItemTypes
28
use C4::Branch;
29
use C4::Budgets;
28
use C4::Budgets;
30
use C4::Search;
29
use C4::Search;
31
use C4::Members;
30
use C4::Members;
Lines 60-66 sub GetCriteriumDesc{ Link Here
60
        }
59
        }
61
        return ($criteriumvalue eq 'ASKED'?"Pending":ucfirst(lc( $criteriumvalue))) if ($displayby =~/status/i);
60
        return ($criteriumvalue eq 'ASKED'?"Pending":ucfirst(lc( $criteriumvalue))) if ($displayby =~/status/i);
62
    }
61
    }
63
    return Koha::Libraries->find($criteriumvalue)->branchname;
62
    return Koha::Libraries->find($criteriumvalue)->branchname
64
        if $displayby =~ /branchcode/;
63
        if $displayby =~ /branchcode/;
65
    return GetAuthorisedValueByCode('SUGGEST_FORMAT', $criteriumvalue) || "Unknown" if ($displayby =~/itemtype/);
64
    return GetAuthorisedValueByCode('SUGGEST_FORMAT', $criteriumvalue) || "Unknown" if ($displayby =~/itemtype/);
66
    if ($displayby =~/suggestedby/||$displayby =~/managedby/||$displayby =~/acceptedby/){
65
    if ($displayby =~/suggestedby/||$displayby =~/managedby/||$displayby =~/acceptedby/){
Lines 298-328 if(defined($returnsuggested) and $returnsuggested ne "noone") Link Here
298
    print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=".$returnsuggested."#suggestions");
297
    print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=".$returnsuggested."#suggestions");
299
}
298
}
300
299
301
####################
300
my $branchfilter = ($displayby ne "branchcode") ? $input->param('branchcode') : C4::Context->userenv->{'branch'};
302
## Initializing selection lists
303
304
#branch display management
305
my $branchfilter = ($displayby ne "branchcode") ? $input->param('branchcode') : '';
306
my $onlymine =
307
     C4::Context->preference('IndependentBranches')
308
  && C4::Context->userenv
309
  && !C4::Context->IsSuperLibrarian()
310
  && C4::Context->userenv->{branch};
311
my $branches = GetBranches($onlymine);
312
my @branchloop;
313
314
foreach my $thisbranch ( sort {$branches->{$a}->{'branchname'} cmp $branches->{$b}->{'branchname'}} keys %$branches ) {
315
    my %row = (
316
        value      => $thisbranch,
317
        branchname => $branches->{$thisbranch}->{'branchname'},
318
        selected   => ($branchfilter and $branches->{$thisbranch}->{'branchcode'} eq $branchfilter ) || ( $$suggestion_ref{'branchcode'} and $branches->{$thisbranch}->{'branchcode'} eq $$suggestion_ref{'branchcode'} )
319
    );
320
    push @branchloop, \%row;
321
}
322
$branchfilter=C4::Context->userenv->{'branch'} if ($onlymine && !$branchfilter);
323
301
324
$template->param( branchloop => \@branchloop,
302
$template->param(
325
                branchfilter => $branchfilter);
303
    branchfilter => $branchfilter,
304
);
326
305
327
$template->param( returnsuggestedby => $returnsuggestedby );
306
$template->param( returnsuggestedby => $returnsuggestedby );
328
307
(-)a/svc/cataloguing/framework (-6 / +2 lines)
Lines 3-14 Link Here
3
use Modern::Perl '2009';
3
use Modern::Perl '2009';
4
4
5
use CGI;
5
use CGI;
6
use C4::Branch;
7
use C4::ClassSource;
6
use C4::ClassSource;
8
use C4::Context;
7
use C4::Context;
9
use C4::Biblio;
8
use C4::Biblio;
10
use C4::Service;
9
use C4::Service;
11
use Koha::Database;
10
use Koha::Database;
11
use Koha::Libraries;
12
12
13
my ( $query, $response ) = C4::Service->init( editcatalogue => 'edit_catalogue' );
13
my ( $query, $response ) = C4::Service->init( editcatalogue => 'edit_catalogue' );
14
14
Lines 29-40 foreach my $tag ( sort keys %$tagslib ) { Link Here
29
my $schema = Koha::Database->new->schema;
29
my $schema = Koha::Database->new->schema;
30
my $authorised_values = {};
30
my $authorised_values = {};
31
31
32
my $branches = { map { $_->branchcode => $_->branchname } Koha::Libraries->search_filtered };
32
$authorised_values->{branches} = [];
33
$authorised_values->{branches} = [];
33
my $onlymine=C4::Context->preference('IndependentBranches') &&
34
        C4::Context->userenv &&
35
        C4::Context->userenv->{flags} % 2 == 0 &&
36
        C4::Context->userenv->{branch};
37
my $branches = GetBranches($onlymine);
38
foreach my $thisbranch ( sort keys %$branches ) {
34
foreach my $thisbranch ( sort keys %$branches ) {
39
    push @{ $authorised_values->{branches} }, { value => $thisbranch, lib => $branches->{$thisbranch}->{'branchname'} };
35
    push @{ $authorised_values->{branches} }, { value => $thisbranch, lib => $branches->{$thisbranch}->{'branchname'} };
40
}
36
}
(-)a/t/db_dependent/Circulation/GetIssues.t (-4 / +4 lines)
Lines 7-15 use Test::MockModule; Link Here
7
use C4::Biblio;
7
use C4::Biblio;
8
use C4::Items;
8
use C4::Items;
9
use C4::Members;
9
use C4::Members;
10
use C4::Branch;
11
use C4::Circulation;
10
use C4::Circulation;
12
use Koha::Library;
11
use Koha::Library;
12
use Koha::Libraries;
13
use Koha::Patron::Categories;
13
use Koha::Patron::Categories;
14
use MARC::Record;
14
use MARC::Record;
15
15
Lines 21-29 $dbh->do(q|DELETE FROM issues|); Link Here
21
21
22
my $branchcode;
22
my $branchcode;
23
my $branch_created;
23
my $branch_created;
24
my @branches = keys %{ GetBranches() };
24
my @libraries = Koha::Libraries->search;
25
if (@branches) {
25
if (@libraries) {
26
    $branchcode = $branches[0];
26
    $branchcode = $libraries[0]->branchcode;
27
} else {
27
} else {
28
    $branchcode = 'B';
28
    $branchcode = 'B';
29
    Koha::Library->new({ branchcode => $branchcode, branchname => 'Branch' })->store;
29
    Koha::Library->new({ branchcode => $branchcode, branchname => 'Branch' })->store;
(-)a/t/db_dependent/Overdues.t (-3 / +2 lines)
Lines 4-10 use Modern::Perl; Link Here
4
use Test::More tests => 16;
4
use Test::More tests => 16;
5
5
6
use C4::Context;
6
use C4::Context;
7
use C4::Branch;
7
use Koha::Libraries;
8
use_ok('C4::Overdues');
8
use_ok('C4::Overdues');
9
can_ok('C4::Overdues', 'GetOverdueMessageTransportTypes');
9
can_ok('C4::Overdues', 'GetOverdueMessageTransportTypes');
10
can_ok('C4::Overdues', 'GetBranchcodesWithOverdueRules');
10
can_ok('C4::Overdues', 'GetBranchcodesWithOverdueRules');
Lines 83-90 $dbh->do(q| Link Here
83
        ( '', '', 1, 'LETTER_CODE1', 1, 5, 'LETTER_CODE2', 1, 10, 'LETTER_CODE3', 1 )
83
        ( '', '', 1, 'LETTER_CODE1', 1, 5, 'LETTER_CODE2', 1, 10, 'LETTER_CODE3', 1 )
84
|);
84
|);
85
85
86
my $all_branches = C4::Branch::GetBranches;
86
my @branchcodes = map { $_->branchcode } Koha::Libraries->search;
87
my @branchcodes = keys %$all_branches;
88
87
89
my @overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules();
88
my @overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules();
90
is_deeply( [ sort @overdue_branches ], [ sort @branchcodes ], 'If a default rule exists, all branches should be returned' );
89
is_deeply( [ sort @overdue_branches ], [ sort @branchcodes ], 'If a default rule exists, all branches should be returned' );
(-)a/tools/export.pl (-34 / +19 lines)
Lines 21-27 use CGI qw ( -utf8 ); Link Here
21
use MARC::File::XML;
21
use MARC::File::XML;
22
use List::MoreUtils qw(uniq);
22
use List::MoreUtils qw(uniq);
23
use C4::Auth;
23
use C4::Auth;
24
use C4::Branch;             # GetBranches
25
use C4::Csv;
24
use C4::Csv;
26
use C4::Koha;               # GetItemTypes
25
use C4::Koha;               # GetItemTypes
27
use C4::Output;
26
use C4::Output;
Lines 31-36 use Koha::Biblioitems; Link Here
31
use Koha::Database;
30
use Koha::Database;
32
use Koha::DateUtils qw( dt_from_string output_pref );
31
use Koha::DateUtils qw( dt_from_string output_pref );
33
use Koha::Exporter::Record;
32
use Koha::Exporter::Record;
33
use Koha::Libraries;
34
34
35
my $query = new CGI;
35
my $query = new CGI;
36
36
Lines 68-99 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( Link Here
68
);
68
);
69
69
70
my @branch = $query->param("branch");
70
my @branch = $query->param("branch");
71
my $only_my_branch;
72
# Limit to local branch if IndependentBranches and not superlibrarian
73
if (
74
    (
75
          C4::Context->preference('IndependentBranches')
76
        && C4::Context->userenv
77
        && !C4::Context->IsSuperLibrarian()
78
        && C4::Context->userenv->{branch}
79
    )
80
    # Limit result to local branch strip_nonlocal_items
81
    or $query->param('strip_nonlocal_items')
82
) {
83
    $only_my_branch = 1;
84
    @branch = ( C4::Context->userenv->{'branch'} );
85
}
86
87
my %branchmap = map { $_ => 1 } @branch; # for quick lookups
88
71
89
if ( $op eq "export" ) {
72
if ( $op eq "export" ) {
90
73
91
    my $export_remove_fields = $query->param("export_remove_fields") || q||;
74
    my $export_remove_fields = $query->param("export_remove_fields") || q||;
92
    my @biblionumbers      = $query->param("biblionumbers");
75
    my @biblionumbers      = $query->param("biblionumbers");
93
    my @itemnumbers        = $query->param("itemnumbers");
76
    my @itemnumbers        = $query->param("itemnumbers");
77
    my $strip_nonlocal_items =  $query->param('strip_nonlocal_items');
94
    my @sql_params;
78
    my @sql_params;
95
    my $sql_query;
79
    my $sql_query;
96
80
81
    my $libraries = $strip_nonlocal_items
82
        ? [ Koha::Libraries->find(C4::Context->userenv->{branch})->unblessed ]
83
        : Koha::Libraries->search_filtered->unblessed;
84
    my @branchcodes;
85
    for my $branchcode ( @branch ) {
86
        if ( grep { $_->{branchcode} eq $branchcode } @$libraries ) {
87
            push @branchcodes, $branchcode;
88
        }
89
    }
90
97
    if ( $record_type eq 'bibs' or $record_type eq 'auths' ) {
91
    if ( $record_type eq 'bibs' or $record_type eq 'auths' ) {
98
        # No need to retrieve the record_ids if we already get them
92
        # No need to retrieve the record_ids if we already get them
99
        unless ( @record_ids ) {
93
        unless ( @record_ids ) {
Lines 138-144 if ( $op eq "export" ) { Link Here
138
                            }
132
                            }
139
                        )
133
                        )
140
                        : (),
134
                        : (),
141
                    ( @branch ? ( 'items.homebranch' => { in => \@branch } ) : () ),
135
                    ( @branchcodes ? ( 'items.homebranch' => { in => \@branchcodes } ) : () ),
142
                    ( $itemtype
136
                    ( $itemtype
143
                        ?
137
                        ?
144
                          C4::Context->preference('item-level_itypes')
138
                          C4::Context->preference('item-level_itypes')
Lines 265-287 else { Link Here
265
        );
259
        );
266
        push @itemtypesloop, \%row;
260
        push @itemtypesloop, \%row;
267
    }
261
    }
268
    my $branches = GetBranches($only_my_branch);
269
    my @branchloop;
270
    for my $thisbranch (
271
        sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} }
272
        keys %{$branches}
273
      )
274
    {
275
        push @branchloop,
276
          {
277
            value      => $thisbranch,
278
            selected   => %branchmap ? $branchmap{$thisbranch} : 1,
279
            branchname => $branches->{$thisbranch}->{'branchname'},
280
          };
281
    }
282
262
283
    my $authority_types = Koha::Authority::Types->search( {}, { order_by => ['authtypecode'] } );
263
    my $authority_types = Koha::Authority::Types->search( {}, { order_by => ['authtypecode'] } );
284
264
265
    my $libraries = Koha::Libraries->search_filtered({}, { order_by => ['branchname'] })->unblessed;
266
    for my $library ( @$libraries ) {
267
        $library->{selected} = 1 if grep { $library->{branchcode} eq $_ } @branch;
268
    }
269
285
    if (   $flags->{superlibrarian}
270
    if (   $flags->{superlibrarian}
286
        && C4::Context->config('backup_db_via_tools')
271
        && C4::Context->config('backup_db_via_tools')
287
        && $backupdir
272
        && $backupdir
Lines 303-309 else { Link Here
303
    }
288
    }
304
289
305
    $template->param(
290
    $template->param(
306
        branchloop               => \@branchloop,
291
        libraries                => $libraries,
307
        itemtypeloop             => \@itemtypesloop,
292
        itemtypeloop             => \@itemtypesloop,
308
        authority_types          => $authority_types,
293
        authority_types          => $authority_types,
309
        export_remove_fields     => C4::Context->preference("ExportRemoveFields"),
294
        export_remove_fields     => C4::Context->preference("ExportRemoveFields"),
(-)a/tools/holidays.pl (-5 lines)
Lines 24-30 use CGI qw ( -utf8 ); Link Here
24
use C4::Auth;
24
use C4::Auth;
25
use C4::Output;
25
use C4::Output;
26
26
27
use C4::Branch; # GetBranches
28
use C4::Calendar;
27
use C4::Calendar;
29
use Koha::DateUtils;
28
use Koha::DateUtils;
30
29
Lines 52-60 $keydate =~ s/-/\//g; Link Here
52
51
53
my $branch= $input->param('branch') || C4::Context->userenv->{'branch'};
52
my $branch= $input->param('branch') || C4::Context->userenv->{'branch'};
54
53
55
# branches calculated - put branch codes in a single string so they can be passed in a form
56
my $branchcodes = join '|', keys %{$branches};
57
58
# Get all the holidays
54
# Get all the holidays
59
55
60
my $calendar = C4::Calendar->new(branchcode => $branch);
56
my $calendar = C4::Calendar->new(branchcode => $branch);
Lines 130-136 $template->param( Link Here
130
    DAY_MONTH_HOLIDAYS_LOOP  => \@day_month_holidays,
126
    DAY_MONTH_HOLIDAYS_LOOP  => \@day_month_holidays,
131
    calendardate             => $calendardate,
127
    calendardate             => $calendardate,
132
    keydate                  => $keydate,
128
    keydate                  => $keydate,
133
    branchcodes              => $branchcodes,
134
    branch                   => $branch,
129
    branch                   => $branch,
135
);
130
);
136
131
(-)a/tools/inventory.pl (-1 lines)
Lines 32-38 use C4::Output; Link Here
32
use C4::Biblio;
32
use C4::Biblio;
33
use C4::Items;
33
use C4::Items;
34
use C4::Koha;
34
use C4::Koha;
35
use C4::Branch; # GetBranches
36
use C4::Circulation;
35
use C4::Circulation;
37
use C4::Reports::Guided;    #_get_column_defs
36
use C4::Reports::Guided;    #_get_column_defs
38
use C4::Charset;
37
use C4::Charset;
(-)a/tools/koha-news.pl (-4 lines)
Lines 32-38 use C4::Output; Link Here
32
use C4::NewsChannels;
32
use C4::NewsChannels;
33
use C4::Languages qw(getTranslatedLanguages);
33
use C4::Languages qw(getTranslatedLanguages);
34
use Date::Calc qw/Date_to_Days Today/;
34
use Date::Calc qw/Date_to_Days Today/;
35
use C4::Branch qw/GetBranches/;
36
use Koha::DateUtils;
35
use Koha::DateUtils;
37
36
38
my $cgi = new CGI;
37
my $cgi = new CGI;
Lines 81-90 foreach my $language ( @$tlangs ) { Link Here
81
    }
80
    }
82
}
81
}
83
82
84
my $branches = GetBranches;
85
86
$template->param( lang_list   => \@lang_list,
83
$template->param( lang_list   => \@lang_list,
87
                  branch_list => $branches,
88
                  branchcode  => $branchcode );
84
                  branchcode  => $branchcode );
89
85
90
my $op = $cgi->param('op') // '';
86
my $op = $cgi->param('op') // '';
(-)a/tools/letter.pl (-1 lines)
Lines 46-52 use CGI qw ( -utf8 ); Link Here
46
use C4::Auth;
46
use C4::Auth;
47
use C4::Context;
47
use C4::Context;
48
use C4::Output;
48
use C4::Output;
49
use C4::Branch; # GetBranches
50
use C4::Letters;
49
use C4::Letters;
51
use C4::Members::Attributes;
50
use C4::Members::Attributes;
52
51
(-)a/tools/newHolidays.pl (-7 / +5 lines)
Lines 57-69 if ($end_dt){ Link Here
57
}
57
}
58
58
59
if($allbranches) {
59
if($allbranches) {
60
	my $branch;
60
    my $libraries = Koha::Libraries->search;
61
	my @branchcodes = split(/\|/, $input->param('branchCodes')); 
61
    while ( my $library = $libraries->next ) {
62
	foreach $branch (@branchcodes) {
62
        add_holiday($newoperation, $library->branchcode, $weekday, $day, $month, $year, $title, $description);
63
		add_holiday($newoperation, $branch, $weekday, $day, $month, $year, $title, $description);
63
    }
64
	}
65
} else {
64
} else {
66
	add_holiday($newoperation, $branchcode, $weekday, $day, $month, $year, $title, $description);
65
    add_holiday($newoperation, $branchcode, $weekday, $day, $month, $year, $title, $description);
67
}
66
}
68
67
69
print $input->redirect("/cgi-bin/koha/tools/holidays.pl?branch=$originalbranchcode&calendardate=$calendardate");
68
print $input->redirect("/cgi-bin/koha/tools/holidays.pl?branch=$originalbranchcode&calendardate=$calendardate");
70
- 

Return to bug 15758