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

(-)a/C4/Auth.pm (-2 / +2 lines)
Lines 1077-1083 sub checkauth { Link Here
1077
                        $branchcode = $query->param('branch');
1077
                        $branchcode = $query->param('branch');
1078
                        $branchname = Koha::Libraries->find($branchcode)->branchname;
1078
                        $branchname = Koha::Libraries->find($branchcode)->branchname;
1079
                    }
1079
                    }
1080
                    my $branches = C4::Branch::GetBranches();
1080
                    my $branches = { map { $_->branchcode => $_->unblessed } Koha::Libraries->search };
1081
                    if ( C4::Context->boolean_preference('IndependentBranches') && C4::Context->boolean_preference('Autolocation') ) {
1081
                    if ( C4::Context->boolean_preference('IndependentBranches') && C4::Context->boolean_preference('Autolocation') ) {
1082
1082
1083
                        # we have to check they are coming from the right ip range
1083
                        # we have to check they are coming from the right ip range
Lines 1527-1533 sub check_api_auth { Link Here
1527
                    $branchcode = $query->param('branch');
1527
                    $branchcode = $query->param('branch');
1528
                    $branchname = Koha::Libraries->find($branchcode)->branchname;
1528
                    $branchname = Koha::Libraries->find($branchcode)->branchname;
1529
                }
1529
                }
1530
                my $branches = C4::Branch::GetBranches();
1530
                my $branches = { map { $_->branchcode => $_->unblessed } Koha::Libraries->search };
1531
                foreach my $br ( keys %$branches ) {
1531
                foreach my $br ( keys %$branches ) {
1532
1532
1533
                    #     now we work with the treatment of ip
1533
                    #     now we work with the treatment of ip
(-)a/C4/Branch.pm (-69 lines)
Lines 28-34 BEGIN { Link Here
28
	@ISA    = qw(Exporter);
28
	@ISA    = qw(Exporter);
29
	@EXPORT = qw(
29
	@EXPORT = qw(
30
		&GetBranch
30
		&GetBranch
31
		&GetBranches
32
	);
31
	);
33
    @EXPORT_OK = qw( &onlymine );
32
    @EXPORT_OK = qw( &onlymine );
34
}
33
}
Lines 47-122 The functions in this module deal with branches. Link Here
47
46
48
=head1 FUNCTIONS
47
=head1 FUNCTIONS
49
48
50
=head2 GetBranches
51
52
  $branches = &GetBranches();
53
54
Returns informations about ALL branches, IndependentBranches Insensitive.
55
56
Create a branch selector with the following code.
57
58
=head3 in PERL SCRIPT
59
60
    my $branches = GetBranches;
61
    my @branchloop;
62
    foreach my $thisbranch (sort keys %$branches) {
63
        my $selected = 1 if $thisbranch eq $branch;
64
        my %row =(value => $thisbranch,
65
                    selected => $selected,
66
                    branchname => $branches->{$thisbranch}->{branchname},
67
                );
68
        push @branchloop, \%row;
69
    }
70
71
=head3 in TEMPLATE
72
73
    <select name="branch" id="branch">
74
        <option value=""></option>
75
            [% FOREACH branchloo IN branchloop %]
76
                [% IF ( branchloo.selected ) %]
77
                    <option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>
78
                [% ELSE %]
79
                    <option value="[% branchloo.value %]" >[% branchloo.branchname %]</option>
80
                [% END %]
81
            [% END %]
82
    </select>
83
84
=cut
49
=cut
85
50
86
sub GetBranches {
87
    my ($onlymine) = @_;
88
89
    # returns a reference to a hash of references to ALL branches...
90
    my %branches;
91
    my $dbh = C4::Context->dbh;
92
    my $sth;
93
    my $query = "SELECT * FROM branches";
94
    my @bind_parameters;
95
    if ( $onlymine && C4::Context->userenv && C4::Context->userenv->{branch} ) {
96
        $query .= ' WHERE branchcode = ? ';
97
        push @bind_parameters, C4::Context->userenv->{branch};
98
    }
99
    $query .= " ORDER BY branchname";
100
    $sth = $dbh->prepare($query);
101
    $sth->execute(@bind_parameters);
102
103
    my $relations_sth =
104
      $dbh->prepare("SELECT branchcode,categorycode FROM branchrelations");
105
    $relations_sth->execute();
106
    my %relations;
107
    while ( my $rel = $relations_sth->fetchrow_hashref ) {
108
        push @{ $relations{ $rel->{branchcode} } }, $rel->{categorycode};
109
    }
110
111
    while ( my $branch = $sth->fetchrow_hashref ) {
112
        foreach my $cat ( @{ $relations{ $branch->{branchcode} } } ) {
113
            $branch->{category}{$cat} = 1;
114
        }
115
        $branches{ $branch->{'branchcode'} } = $branch;
116
    }
117
    return ( \%branches );
118
}
119
120
sub onlymine {
51
sub onlymine {
121
    return
52
    return
122
         C4::Context->preference('IndependentBranches')
53
         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 310-316 sub transferbook { Link Here
310
    my ( $tbr, $barcode, $ignoreRs ) = @_;
309
    my ( $tbr, $barcode, $ignoreRs ) = @_;
311
    my $messages;
310
    my $messages;
312
    my $dotransfer      = 1;
311
    my $dotransfer      = 1;
313
    my $branches        = GetBranches();
314
    my $itemnumber = GetItemnumberFromBarcode( $barcode );
312
    my $itemnumber = GetItemnumberFromBarcode( $barcode );
315
    my $issue      = GetItemIssue($itemnumber);
313
    my $issue      = GetItemIssue($itemnumber);
316
    my $biblio = GetBiblioFromItemNumber($itemnumber);
314
    my $biblio = GetBiblioFromItemNumber($itemnumber);
Lines 339-345 sub transferbook { Link Here
339
    }
337
    }
340
338
341
    # if is permanent...
339
    # if is permanent...
342
    if ( $hbr && $branches->{$hbr}->{'PE'} ) {
340
    # FIXME Is this still used by someone?
341
    # See other FIXME in AddReturn
342
    my $library = Koha::Libraries->find($hbr);
343
    if ( $library and $library->get_categories->search({'me.categorycode' => 'PE'})->count ) {
343
        $messages->{'IsPermanent'} = $hbr;
344
        $messages->{'IsPermanent'} = $hbr;
344
        $dotransfer = 0;
345
        $dotransfer = 0;
345
    }
346
    }
Lines 2007-2014 sub AddReturn { Link Here
2007
    # check if the book is in a permanent collection....
2008
    # check if the book is in a permanent collection....
2008
    # FIXME -- This 'PE' attribute is largely undocumented.  afaict, there's no user interface that reflects this functionality.
2009
    # FIXME -- This 'PE' attribute is largely undocumented.  afaict, there's no user interface that reflects this functionality.
2009
    if ( $returnbranch ) {
2010
    if ( $returnbranch ) {
2010
        my $branches = GetBranches();    # a potentially expensive call for a non-feature.
2011
        my $library = Koha::Libraries->find($returnbranch);
2011
        $branches->{$returnbranch}->{PE} and $messages->{'IsPermanent'} = $returnbranch;
2012
        if ( $library and $library->get_categories->search({'me.categorycode' => 'PE'})->count ) {
2013
            $messages->{'IsPermanent'} = $returnbranch;
2014
        }
2012
    }
2015
    }
2013
2016
2014
    # check if the return is allowed at this branch
2017
    # check if the return is allowed at this branch
(-)a/C4/Context.pm (+6 lines)
Lines 1140-1145 sub interface { Link Here
1140
    return $context->{interface} // 'opac';
1140
    return $context->{interface} // 'opac';
1141
}
1141
}
1142
1142
1143
# always returns a string for OK comparison via "eq" or "ne"
1144
sub mybranch {
1145
    C4::Context->userenv           or return '';
1146
    return C4::Context->userenv->{branch} || '';
1147
}
1148
1143
1;
1149
1;
1144
__END__
1150
__END__
1145
1151
(-)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 628-635 sub HoldTitle { Link Here
628
    # Pickup branch management
627
    # Pickup branch management
629
    if ( $cgi->param('pickup_location') ) {
628
    if ( $cgi->param('pickup_location') ) {
630
        $branch = $cgi->param('pickup_location');
629
        $branch = $cgi->param('pickup_location');
631
        my $branches = GetBranches;
630
        return { code => 'LocationNotFound' } unless Koha::Libraries->find($branch);
632
        return { code => 'LocationNotFound' } unless $$branches{$branch};
633
    } else { # if the request provide no branch, use the borrower's branch
631
    } else { # if the request provide no branch, use the borrower's branch
634
        $branch = $$borrower{branchcode};
632
        $branch = $$borrower{branchcode};
635
    }
633
    }
Lines 706-713 sub HoldItem { Link Here
706
    my $branch;
704
    my $branch;
707
    if ( $cgi->param('pickup_location') ) {
705
    if ( $cgi->param('pickup_location') ) {
708
        $branch = $cgi->param('pickup_location');
706
        $branch = $cgi->param('pickup_location');
709
        my $branches = GetBranches();
707
        return { code => 'LocationNotFound' } unless Koha::Libraries->find($branch);
710
        return { code => 'LocationNotFound' } unless $$branches{$branch};
711
    } else { # if the request provide no branch, use the borrower's branch
708
    } else { # if the request provide no branch, use the borrower's branch
712
        $branch = $$borrower{branchcode};
709
        $branch = $$borrower{branchcode};
713
    }
710
    }
(-)a/C4/Items.pm (+1 lines)
Lines 1336-1341 sub GetItemsInfo { Link Here
1336
           COALESCE( localization.translation, itemtypes.description ) AS translated_description,
1336
           COALESCE( localization.translation, itemtypes.description ) AS translated_description,
1337
           itemtypes.notforloan as notforloan_per_itemtype,
1337
           itemtypes.notforloan as notforloan_per_itemtype,
1338
           holding.branchurl,
1338
           holding.branchurl,
1339
           holding.branchcode,
1339
           holding.branchname,
1340
           holding.branchname,
1340
           holding.opac_info as holding_branch_opac_info,
1341
           holding.opac_info as holding_branch_opac_info,
1341
           home.opac_info as home_branch_opac_info
1342
           home.opac_info as home_branch_opac_info
(-)a/C4/Overdues.pm (-2 / +2 lines)
Lines 36-41 use C4::Debug; Link Here
36
use Koha::DateUtils;
36
use Koha::DateUtils;
37
use Koha::Account::Line;
37
use Koha::Account::Line;
38
use Koha::Account::Lines;
38
use Koha::Account::Lines;
39
use Koha::Libraries;
39
40
40
use vars qw(@ISA @EXPORT);
41
use vars qw(@ISA @EXPORT);
41
42
Lines 786-793 sub GetBranchcodesWithOverdueRules { Link Here
786
    |);
787
    |);
787
    if ( $branchcodes->[0] eq '' ) {
788
    if ( $branchcodes->[0] eq '' ) {
788
        # If a default rule exists, all branches should be returned
789
        # If a default rule exists, all branches should be returned
789
        my $availbranches = C4::Branch::GetBranches();
790
        return map { $_->branchcode } Koha::Libraries->search({}, { order_by => 'branchname' });
790
        return keys %$availbranches;
791
    }
791
    }
792
    return @$branchcodes;
792
    return @$branchcodes;
793
}
793
}
(-)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 331-336 sub getRecords { Link Here
331
    my @servers = @$servers_ref;
330
    my @servers = @$servers_ref;
332
    my @sort_by = @$sort_by_ref;
331
    my @sort_by = @$sort_by_ref;
333
332
333
    $branches ||= { map { $_->branchcode => $_->branchname } Koha::Libraries->search };
334
334
    # Initialize variables for the ZOOM connection and results object
335
    # Initialize variables for the ZOOM connection and results object
335
    my $zconn;
336
    my $zconn;
336
    my @zconns;
337
    my @zconns;
Lines 857-862 sub pazGetRecords { Link Here
857
        $query_type,       $scan
858
        $query_type,       $scan
858
    ) = @_;
859
    ) = @_;
859
860
861
    $branches ||= { map { $_->branchcode => $_->branchname } Koha::Libraries->search };
862
860
    my $paz = C4::Search::PazPar2->new(C4::Context->config('pazpar2url'));
863
    my $paz = C4::Search::PazPar2->new(C4::Context->config('pazpar2url'));
861
    $paz->init();
864
    $paz->init();
862
    $paz->search($simple_query);
865
    $paz->search($simple_query);
Lines 1840-1853 sub searchResults { Link Here
1840
    }
1843
    }
1841
1844
1842
    #Build branchnames hash
1845
    #Build branchnames hash
1843
    #find branchname
1846
    my %branches = map { $_->branchcode => $_->branchname } Koha::Libraries->search({}, { order_by => 'branchname' });
1844
    #get branch information.....
1847
1845
    my %branches;
1846
    my $bsth =$dbh->prepare("SELECT branchcode,branchname FROM branches"); # FIXME : use C4::Branch::GetBranches
1847
    $bsth->execute();
1848
    while ( my $bdata = $bsth->fetchrow_hashref ) {
1849
        $branches{ $bdata->{'branchcode'} } = $bdata->{'branchname'};
1850
    }
1851
# FIXME - We build an authorised values hash here, using the default framework
1848
# FIXME - We build an authorised values hash here, using the default framework
1852
# though it is possible to have different authvals for different fws.
1849
# though it is possible to have different authvals for different fws.
1853
1850
(-)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(@ISA @EXPORT @EXPORT_OK);
30
use vars qw(@ISA @EXPORT @EXPORT_OK);
31
31
Lines 117-123 sub GetNearbyItems { Link Here
117
        if $gap <= $num_each_side;
117
        if $gap <= $num_each_side;
118
118
119
    my $dbh         = C4::Context->dbh;
119
    my $dbh         = C4::Context->dbh;
120
    my $branches = GetBranches();
121
120
122
    my $sth_get_item_details = $dbh->prepare("SELECT cn_sort,homebranch,location,ccode from items where itemnumber=?");
121
    my $sth_get_item_details = $dbh->prepare("SELECT cn_sort,homebranch,location,ccode from items where itemnumber=?");
123
    $sth_get_item_details->execute($itemnumber);
122
    $sth_get_item_details->execute($itemnumber);
Lines 129-135 sub GetNearbyItems { Link Here
129
    if (C4::Context->preference('ShelfBrowserUsesHomeBranch') && 
128
    if (C4::Context->preference('ShelfBrowserUsesHomeBranch') && 
130
    	defined($item_details_result->{'homebranch'})) {
129
    	defined($item_details_result->{'homebranch'})) {
131
        $start_homebranch->{code} = $item_details_result->{'homebranch'};
130
        $start_homebranch->{code} = $item_details_result->{'homebranch'};
132
        $start_homebranch->{description} = $branches->{$item_details_result->{'homebranch'}}{branchname};
131
        $start_homebranch->{description} = Koha::Libraries->find($item_details_result->{'homebranch'})->branchname;
133
    }
132
    }
134
    if (C4::Context->preference('ShelfBrowserUsesLocation') && 
133
    if (C4::Context->preference('ShelfBrowserUsesLocation') && 
135
    	defined($item_details_result->{'location'})) {
134
    	defined($item_details_result->{'location'})) {
(-)a/C4/XSLT.pm (-3 / +4 lines)
Lines 276-282 sub buildKohaItemsNamespace { Link Here
276
    my $shelflocations = GetKohaAuthorisedValues('items.location',GetFrameworkCode($biblionumber), 'opac');
276
    my $shelflocations = GetKohaAuthorisedValues('items.location',GetFrameworkCode($biblionumber), 'opac');
277
    my $ccodes         = GetKohaAuthorisedValues('items.ccode',GetFrameworkCode($biblionumber), 'opac');
277
    my $ccodes         = GetKohaAuthorisedValues('items.ccode',GetFrameworkCode($biblionumber), 'opac');
278
278
279
    my $branches = GetBranches();
279
    my %branches = map { $_->branchcode => $_->branchname } Koha::Libraries->search({}, { order_by => 'branchname' });
280
280
    my $itemtypes = GetItemTypes();
281
    my $itemtypes = GetItemTypes();
281
    my $location = "";
282
    my $location = "";
282
    my $ccode = "";
283
    my $ccode = "";
Lines 317-324 sub buildKohaItemsNamespace { Link Here
317
        } else {
318
        } else {
318
            $status = "available";
319
            $status = "available";
319
        }
320
        }
320
        my $homebranch = $item->{homebranch}? xml_escape($branches->{$item->{homebranch}}->{'branchname'}):'';
321
        my $homebranch = $item->{homebranch}? xml_escape($branches{$item->{homebranch}}):'';
321
        my $holdingbranch = $item->{holdingbranch}? xml_escape($branches->{$item->{holdingbranch}}->{'branchname'}):'';
322
        my $holdingbranch = $item->{holdingbranch}? xml_escape($branches{$item->{holdingbranch}}):'';
322
        $location = $item->{location}? xml_escape($shelflocations->{$item->{location}}||$item->{location}):'';
323
        $location = $item->{location}? xml_escape($shelflocations->{$item->{location}}||$item->{location}):'';
323
        $ccode = $item->{ccode}? xml_escape($ccodes->{$item->{ccode}}||$item->{ccode}):'';
324
        $ccode = $item->{ccode}? xml_escape($ccodes->{$item->{ccode}}||$item->{ccode}):'';
324
        my $itemcallnumber = xml_escape($item->{itemcallnumber});
325
        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 (-10 / +8 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
use Koha::Database;
39
use Koha::Database;
40
use Koha::EDI qw( create_edi_order get_edifact_ean );
40
use Koha::EDI qw( create_edi_order get_edifact_ean );
Lines 236-241 elsif ( $op eq 'ediorder' ) { Link Here
236
                exit 1;
236
                exit 1;
237
            }
237
            }
238
        }
238
        }
239
239
        if (!defined $basket->{branch} or $basket->{branch} eq $userenv->{branch}) {
240
        if (!defined $basket->{branch} or $basket->{branch} eq $userenv->{branch}) {
240
            push @branches_loop, {
241
            push @branches_loop, {
241
                branchcode => $userenv->{branch},
242
                branchcode => $userenv->{branch},
Lines 245-264 elsif ( $op eq 'ediorder' ) { Link Here
245
        }
246
        }
246
    } else {
247
    } else {
247
        # get branches
248
        # get branches
248
        my $branches = C4::Branch::GetBranches;
249
        my $branches = Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed;
249
        my @branchcodes = sort {
250
        foreach my $branch (@$branches) {
250
            $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname}
251
        } keys %$branches;
252
        foreach my $branch (@branchcodes) {
253
            my $selected = 0;
251
            my $selected = 0;
254
            if (defined $basket->{branch}) {
252
            if (defined $basket->{branch}) {
255
                $selected = 1 if $branch eq $basket->{branch};
253
                $selected = 1 if $branch->{branchcode} eq $basket->{branch};
256
            } else {
254
            } else {
257
                $selected = 1 if $branch eq C4::Context->userenv->{branch};
255
                $selected = 1 if $branch->{branchcode} eq C4::Context->userenv->{branch};
258
            }
256
            }
259
            push @branches_loop, {
257
            push @branches_loop, {
260
                branchcode => $branch,
258
                branchcode => $branch->{branchcode},
261
                branchname => $branches->{$branch}->{branchname},
259
                branchname => $branch->{branchname},
262
                selected => $selected
260
                selected => $selected
263
            };
261
            };
264
        }
262
        }
(-)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 107-130 foreach (@suppliers) { Link Here
107
      };
106
      };
108
}
107
}
109
108
110
# Build branches list
111
my $branches      = GetBranches();
112
my $branches_loop = [];
113
my $branchname;
114
foreach ( sort keys %$branches ) {
115
    my $selected = 0;
116
    if ( $branch && $branch eq $_ ) {
117
        $selected   = 1;
118
        $branchname = $branches->{$_}->{'branchname'};
119
    }
120
    push @{$branches_loop},
121
      {
122
        branchcode => $_,
123
        branchname => $branches->{$_}->{branchname},
124
        selected   => $selected,
125
      };
126
}
127
128
my $budgets = GetBudgets();
109
my $budgets = GetBudgets();
129
my @budgets_loop;
110
my @budgets_loop;
130
foreach my $budget (@$budgets) {
111
foreach my $budget (@$budgets) {
Lines 149-157 $template->param( Link Here
149
    publisher       => $publisher,
130
    publisher       => $publisher,
150
    publicationyear => $publicationyear,
131
    publicationyear => $publicationyear,
151
    branch          => $branch,
132
    branch          => $branch,
152
    branchname      => $branchname,
153
    suppliers_loop  => $suppliers_loop,
133
    suppliers_loop  => $suppliers_loop,
154
    branches_loop   => $branches_loop,
155
);
134
);
156
135
157
output_html_with_http_headers $input, $cookie, $template->output;
136
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 141-158 if ($op eq 'add_form') { Link Here
141
    }
140
    }
142
    $budget_parent = GetBudget($budget_parent_id);
141
    $budget_parent = GetBudget($budget_parent_id);
143
142
144
    # build branches select
145
    my $branches = GetBranches;
146
    my @branchloop_select;
147
    foreach my $thisbranch ( sort keys %$branches ) {
148
        my %row = (
149
            value      => $thisbranch,
150
            branchname => $branches->{$thisbranch}->{'branchname'},
151
        );
152
        $row{selected} = 1 if $budget and $thisbranch eq $budget->{'budget_branchcode'};
153
        push @branchloop_select, \%row;
154
    }
155
156
    # populates the YUI planning button
143
    # populates the YUI planning button
157
    my $categories = GetAuthorisedValueCategories();
144
    my $categories = GetAuthorisedValueCategories();
158
    my @auth_cats_loop1 = ();
145
    my @auth_cats_loop1 = ();
Lines 200-206 if ($op eq 'add_form') { Link Here
200
        budget_has_children => BudgetHasChildren( $budget->{budget_id} ),
187
        budget_has_children => BudgetHasChildren( $budget->{budget_id} ),
201
        budget_parent_id    		  => $budget_parent->{'budget_id'},
188
        budget_parent_id    		  => $budget_parent->{'budget_id'},
202
        budget_parent_name    		  => $budget_parent->{'budget_name'},
189
        budget_parent_name    		  => $budget_parent->{'budget_name'},
203
        branchloop_select         => \@branchloop_select,
204
		%$period,
190
		%$period,
205
		%$budget,
191
		%$budget,
206
    );
192
    );
Lines 258-264 if ($op eq 'add_form') { Link Here
258
}
244
}
259
245
260
if ( $op eq 'list' ) {
246
if ( $op eq 'list' ) {
261
    my $branches = GetBranches();
262
    $template->param(
247
    $template->param(
263
        budget_id => $budget_id,
248
        budget_id => $budget_id,
264
        %$period,
249
        %$period,
(-)a/admin/authorised_values.pl (-8 / +7 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-70 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( {}, { order_by => ['branchname'] } )->unblessed;
60
    my @branches_loop;
60
    my @branches_loop;
61
61
    foreach my $branch ( @$branches ) {
62
    foreach my $branchcode ( sort { uc($branches->{$a}->{branchname}) cmp uc($branches->{$b}->{branchname}) } keys %$branches ) {
62
        my $selected = ( grep {$_ eq $branch->{branchcode}} @$selected_branches ) ? 1 : 0;
63
        my $selected = ( grep {$_ eq $branchcode} @$selected_branches ) ? 1 : 0;
64
        push @branches_loop, {
63
        push @branches_loop, {
65
            branchcode => $branchcode,
64
            branchcode => $branch->{branchcode},
66
            branchname => $branches->{$branchcode}->{branchname},
65
            branchname => $branch->{branchname},
67
            selected => $selected,
66
            selected   => $selected,
68
        };
67
        };
69
    }
68
    }
70
69
(-)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::Patrons;
28
use Koha::Patrons;
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 { $_ eq $branch->{branchcode} } @$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 => $branch->{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 252-265 sub edit_attribute_type_form { Link Here
252
    $template->param(classes_val_loop => GetAuthorisedValues( 'PA_CLASS' ));
252
    $template->param(classes_val_loop => GetAuthorisedValues( 'PA_CLASS' ));
253
253
254
254
255
    my $branches = GetBranches;
255
    my $branches = Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed;
256
    my @branches_loop;
256
    my @branches_loop;
257
    my $selected_branches = $attr_type->branches;
257
    my $selected_branches = $attr_type->branches;
258
    foreach my $branch (sort keys %$branches) {
258
    foreach my $branch (@$branches) {
259
        my $selected = ( grep {$$_{branchcode} eq $branch} @$selected_branches ) ? 1 : 0;
259
        my $selected = ( grep {$_->{branchcode} eq $branch->{branchcode}} @$selected_branches ) ? 1 : 0;
260
        push @branches_loop, {
260
        push @branches_loop, {
261
            branchcode => $branches->{$branch}{branchcode},
261
            branchcode => $branch->{branchcode},
262
            branchname => $branches->{$branch}{branchname},
262
            branchname => $branch->{branchname},
263
            selected => $selected,
263
            selected => $selected,
264
        };
264
        };
265
    }
265
    }
(-)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 27-33 use C4::Output; Link Here
27
use C4::Biblio;
27
use C4::Biblio;
28
use C4::Items;
28
use C4::Items;
29
use C4::Circulation;
29
use C4::Circulation;
30
use C4::Branch;
31
use C4::Reserves;
30
use C4::Reserves;
32
use C4::Members; # to use GetMember
31
use C4::Members; # to use GetMember
33
use C4::Serials;
32
use C4::Serials;
Lines 125-131 my $marchostsarray = GetMarcHosts($record,$marcflavour); Link Here
125
my $subtitle         = GetRecordValue('subtitle', $record, $fw);
124
my $subtitle         = GetRecordValue('subtitle', $record, $fw);
126
125
127
# Get Branches, Itemtypes and Locations
126
# Get Branches, Itemtypes and Locations
128
my $branches = GetBranches();
129
my $itemtypes = GetItemTypes();
127
my $itemtypes = GetItemTypes();
130
my $dbh = C4::Context->dbh;
128
my $dbh = C4::Context->dbh;
131
129
Lines 256-262 foreach my $item (@items) { Link Here
256
        $item->{ReservedForBorrowernumber}     = $reservedfor;
254
        $item->{ReservedForBorrowernumber}     = $reservedfor;
257
        $item->{ReservedForSurname}     = $ItemBorrowerReserveInfo->{'surname'};
255
        $item->{ReservedForSurname}     = $ItemBorrowerReserveInfo->{'surname'};
258
        $item->{ReservedForFirstname}   = $ItemBorrowerReserveInfo->{'firstname'};
256
        $item->{ReservedForFirstname}   = $ItemBorrowerReserveInfo->{'firstname'};
259
        $item->{ExpectedAtLibrary}      = $branches->{$expectedAt}{branchname};
257
        $item->{ExpectedAtLibrary}      = $expectedAt;
260
        $item->{Reservedcardnumber}             = $ItemBorrowerReserveInfo->{'cardnumber'};
258
        $item->{Reservedcardnumber}             = $ItemBorrowerReserveInfo->{'cardnumber'};
261
        # Check waiting status
259
        # Check waiting status
262
        $item->{waitingdate} = $wait;
260
        $item->{waitingdate} = $wait;
Lines 267-274 foreach my $item (@items) { Link Here
267
    my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($item->{itemnumber});
265
    my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($item->{itemnumber});
268
    if ( defined( $transfertwhen ) && ( $transfertwhen ne '' ) ) {
266
    if ( defined( $transfertwhen ) && ( $transfertwhen ne '' ) ) {
269
        $item->{transfertwhen} = $transfertwhen;
267
        $item->{transfertwhen} = $transfertwhen;
270
        $item->{transfertfrom} = $branches->{$transfertfrom}{branchname};
268
        $item->{transfertfrom} = $transfertfrom;
271
        $item->{transfertto}   = $branches->{$transfertto}{branchname};
269
        $item->{transfertto}   = $transfertto;
272
        $item->{nocancel} = 1;
270
        $item->{nocancel} = 1;
273
    }
271
    }
274
272
(-)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 (-2 / +4 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 216-222 if($cgi->cookie("intranet_bib_list")){ Link Here
216
# load the branches
215
# load the branches
217
my $categories = Koha::LibraryCategories->search( { categorytype => 'searchdomain' }, { order_by => [ 'categorytype', 'categorycode' ] } );
216
my $categories = Koha::LibraryCategories->search( { categorytype => 'searchdomain' }, { order_by => [ 'categorytype', 'categorycode' ] } );
218
217
219
$template->param(searchdomainloop => $categories);
218
$template->param(
219
    selected_branchcode => ( C4::Context->IsSuperLibrarian ? C4::Context->userenv : '' ),
220
    searchdomainloop => $categories
221
);
220
222
221
# load the Type stuff
223
# load the Type stuff
222
my $itemtypes = GetItemTypes;
224
my $itemtypes = GetItemTypes;
(-)a/cataloguing/addbiblio.pl (-12 / +6 lines)
Lines 31-42 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;
33
use C4::Koha;
34
use C4::Branch;
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
use Koha::BiblioFrameworks;
37
use Koha::BiblioFrameworks;
39
38
39
use Koha::Libraries;
40
40
use Date::Calc qw(Today);
41
use Date::Calc qw(Today);
41
use MARC::File::USMARC;
42
use MARC::File::USMARC;
42
use MARC::File::XML;
43
use MARC::File::XML;
Lines 172-189 sub build_authorized_values_list { Link Here
172
173
173
    #---- branch
174
    #---- branch
174
    if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
175
    if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
175
        #Use GetBranches($onlymine)
176
        my $libraries = Koha::Libraries->search_filtered({}, {order_by => ['branchname']});
176
        my $onlymine =
177
        while ( my $l = $libraries->next ) {
177
             C4::Context->preference('IndependentBranches')
178
            push @authorised_values, $l->branchcode;;
178
          && C4::Context->userenv
179
            $authorised_lib{$l->branchcode} = $l->branchname;
179
          && !C4::Context->IsSuperLibrarian()
180
          && C4::Context->userenv->{branch};
181
        my $branches = GetBranches($onlymine);
182
        foreach my $thisbranch ( sort keys %$branches ) {
183
            push @authorised_values, $thisbranch;
184
            $authorised_lib{$thisbranch} = $branches->{$thisbranch}->{'branchname'};
185
        }
180
        }
186
187
    }
181
    }
188
    elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) {
182
    elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) {
189
        push @authorised_values, ""
183
        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/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 (-1 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;
(-)a/circ/returns.pl (-19 / +4 lines)
Lines 45-51 use C4::Biblio; Link Here
45
use C4::Items;
45
use C4::Items;
46
use C4::Members;
46
use C4::Members;
47
use C4::Members::Messaging;
47
use C4::Members::Messaging;
48
use C4::Branch; # GetBranches
49
use C4::Koha;   # FIXME : is it still useful ?
48
use C4::Koha;   # FIXME : is it still useful ?
50
use C4::RotatingCollections;
49
use C4::RotatingCollections;
51
use Koha::DateUtils;
50
use Koha::DateUtils;
Lines 83-89 if ( $query->param('print_slip') ) { Link Here
83
82
84
#####################
83
#####################
85
#Global vars
84
#Global vars
86
my $branches = GetBranches();
87
my $printers = GetPrinters();
85
my $printers = GetPrinters();
88
my $userenv = C4::Context->userenv;
86
my $userenv = C4::Context->userenv;
89
my $userenv_branch = $userenv->{'branch'} // '';
87
my $userenv_branch = $userenv->{'branch'} // '';
Lines 401-407 if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) { Link Here
401
    );
399
    );
402
400
403
    my $reserve    = $messages->{'ResFound'};
401
    my $reserve    = $messages->{'ResFound'};
404
    my $branchname = $branches->{ $reserve->{'branchcode'} }->{'branchname'};
405
    my $borr = C4::Members::GetMember( borrowernumber => $reserve->{'borrowernumber'} );
402
    my $borr = C4::Members::GetMember( borrowernumber => $reserve->{'borrowernumber'} );
406
    my $name = $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'};
403
    my $name = $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'};
407
    $template->param(
404
    $template->param(
Lines 427-433 if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) { Link Here
427
#
424
#
428
if ( $messages->{'ResFound'}) {
425
if ( $messages->{'ResFound'}) {
429
    my $reserve    = $messages->{'ResFound'};
426
    my $reserve    = $messages->{'ResFound'};
430
    my $branchname = $branches->{ $reserve->{'branchcode'} }->{'branchname'};
431
    my $borr = C4::Members::GetMember( borrowernumber => $reserve->{'borrowernumber'} );
427
    my $borr = C4::Members::GetMember( borrowernumber => $reserve->{'borrowernumber'} );
432
    my $holdmsgpreferences =  C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $reserve->{'borrowernumber'}, message_name   => 'Hold_Filled' } );
428
    my $holdmsgpreferences =  C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $reserve->{'borrowernumber'}, message_name   => 'Hold_Filled' } );
433
    if ( $reserve->{'ResFound'} eq "Waiting" or $reserve->{'ResFound'} eq "Reserved" ) {
429
    if ( $reserve->{'ResFound'} eq "Waiting" or $reserve->{'ResFound'} eq "Reserved" ) {
Lines 447-454 if ( $messages->{'ResFound'}) { Link Here
447
        # same params for Waiting or Reserved
443
        # same params for Waiting or Reserved
448
        $template->param(
444
        $template->param(
449
            found          => 1,
445
            found          => 1,
450
            currentbranch  => $branches->{$userenv_branch}->{'branchname'},
446
            destbranchname => $reserve->{'branchcode'},
451
            destbranchname => $branches->{ $reserve->{'branchcode'} }->{'branchname'},
452
            name           => $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'},
447
            name           => $borr->{'surname'} . ", " . $borr->{'title'} . " " . $borr->{'firstname'},
453
            borfirstname   => $borr->{'firstname'},
448
            borfirstname   => $borr->{'firstname'},
454
            borsurname     => $borr->{'surname'},
449
            borsurname     => $borr->{'surname'},
Lines 485-491 foreach my $code ( keys %$messages ) { Link Here
485
    elsif ( $code eq 'NotIssued' ) {
480
    elsif ( $code eq 'NotIssued' ) {
486
        $err{notissued} = 1;
481
        $err{notissued} = 1;
487
        $err{msg} = '';
482
        $err{msg} = '';
488
        $err{msg} = $branches->{ $messages->{'IsPermanent'} }->{'branchname'} if $messages->{'IsPermanent'};
483
        $err{msg} = $messages->{'IsPermanent'} if $messages->{'IsPermanent'};
489
    }
484
    }
490
    elsif ( $code eq 'LocalUse' ) {
485
    elsif ( $code eq 'LocalUse' ) {
491
        $err{localuse} = 1;
486
        $err{localuse} = 1;
Lines 512-519 foreach my $code ( keys %$messages ) { Link Here
512
    elsif ( ( $code eq 'IsPermanent' ) && ( not $messages->{'ResFound'} ) ) {
507
    elsif ( ( $code eq 'IsPermanent' ) && ( not $messages->{'ResFound'} ) ) {
513
        if ( $messages->{'IsPermanent'} ne $userenv_branch ) {
508
        if ( $messages->{'IsPermanent'} ne $userenv_branch ) {
514
            $err{ispermanent} = 1;
509
            $err{ispermanent} = 1;
515
            $err{msg}         =
510
            $err{msg}         = $messages->{'IsPermanent'};
516
              $branches->{ $messages->{'IsPermanent'} }->{'branchname'};
517
        }
511
        }
518
    }
512
    }
519
    elsif ( $code eq 'WrongTransfer' ) {
513
    elsif ( $code eq 'WrongTransfer' ) {
Lines 617-634 foreach ( sort { $a <=> $b } keys %returneditems ) { Link Here
617
    }
611
    }
618
    push @riloop, \%ri;
612
    push @riloop, \%ri;
619
}
613
}
620
my ($genbrname, $genprname);
614
621
if (my $b = $branches->{$userenv_branch}) {
622
    $genbrname = $b->{'branchname'};
623
}
624
if (my $p = $printers->{$printer}) {
625
    $genprname = $p->{'printername'};
626
}
627
$template->param(
615
$template->param(
628
    riloop         => \@riloop,
616
    riloop         => \@riloop,
629
    genbrname      => $genbrname,
630
    genprname      => $genprname,
631
    branchname     => $genbrname,
632
    printer        => $printer,
617
    printer        => $printer,
633
    errmsgloop     => \@errmsgloop,
618
    errmsgloop     => \@errmsgloop,
634
    exemptfine     => $exemptfine,
619
    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 11-22 END %] Link Here
11
    [% FOREACH branch IN branches %]
11
    [% FOREACH branch IN branches %]
12
        <div class="branchgriditem">
12
        <div class="branchgriditem">
13
            [% IF branch.selected || (selectall == 1) %]
13
            [% IF branch.selected || (selectall == 1) %]
14
                <input id="branch_[% branch.value %]" class="branch_select" type="checkbox" name="branch" value="[% branch.value %]" checked="checked" />
14
                <input id="branch_[% branch.branchcode %]" class="branch_select" type="checkbox" name="branch" value="[% branch.branchcode %]" checked="checked" />
15
            [% ELSE %]
15
            [% ELSE %]
16
                <input id="branch_[% branch.value %]" class="branch_select" type="checkbox" name="branch" value="[% branch.value %]" />
16
                <input id="branch_[% branch.branchcode %]" class="branch-select" type="checkbox" name="branch" value="[% branch.branchcode %]" />
17
            [% END %]
17
            [% END %]
18
18
19
            <label for="branch_[% branch.value %]">[% branch.branchname %]</label>
19
            <label for="branch_[% branch.branchcode %]">[% branch.branchname %]</label>
20
        </div>
20
        </div>
21
        [% IF loop.count() % 4 == 0 && !loop.last() %]
21
        [% IF loop.count() % 4 == 0 && !loop.last() %]
22
            </div>
22
            </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 522-528 var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") Link Here
522
    <label for="budget_branchcode">Library: </label>
523
    <label for="budget_branchcode">Library: </label>
523
    <select name="budget_branchcode" id="budget_branchcode">
524
    <select name="budget_branchcode" id="budget_branchcode">
524
        <option value=""></option>
525
        <option value=""></option>
525
        [% PROCESS options_for_libraries libraries => branchloop_select %]
526
        [% PROCESS options_for_libraries libraries => Branches.all( selected => budget_branchcode, unfiltered => 1 ) %]
526
    </select>
527
    </select>
527
    </li>
528
    </li>
528
529
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branch_transfer_limits.tt (-9 / +3 lines)
Lines 58-72 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>
65
            [% ELSE %]
66
                <option value="[% branch_loo.value %]">[% branch_loo.branchname %]</option>
67
            [% END %]
68
		[% END %]
69
            </select>
70
    </form>
64
    </form>
71
65
72
<p class="help">Check the boxes for the libraries you accept to checkin items from.</p>
66
<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 / +4 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; Administration &rsaquo; Item circulation alerts</title>
3
<title>Koha &rsaquo; Administration &rsaquo; Item circulation alerts</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'doc-head-close.inc' %]
Lines 103-115 $(function(){ Link Here
103
<h2>Select a library:</h2>
104
<h2>Select a library:</h2>
104
<form id="branch_selector" method="get" action="/cgi-bin/koha/admin/item_circulation_alerts.pl">
105
<form id="branch_selector" method="get" action="/cgi-bin/koha/admin/item_circulation_alerts.pl">
105
<select id="branch" name="branch">
106
<select id="branch" name="branch">
106
[% FOREACH branche IN branches %]
107
    <option value="*">Default</option>
107
[% IF ( branche.selected ) %]
108
    [% 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>
109
</select>
114
<input type="submit" name="pick" value="Pick" />
110
<input type="submit" name="pick" value="Pick" />
115
</form>
111
</form>
Lines 141-147 $(function(){ Link Here
141
</div>
137
</div>
142
</div>
138
</div>
143
139
144
<h2>Circulation alerts for [% branch_name %]</h2>
140
<h2>Circulation alerts for [% Branches.GetName( branch ) || 'Default' %]</h2>
145
<p>Click on the grid to toggle the settings.</p>
141
<p>Click on the grid to toggle the settings.</p>
146
142
147
<div id="alerttabs" class="toptabs">
143
<div id="alerttabs" class="toptabs">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-2 / +2 lines)
Lines 143-149 $(document).ready(function() { Link Here
143
        Select a library :
143
        Select a library :
144
            <select name="branch" id="branch" style="width:20em;">
144
            <select name="branch" id="branch" style="width:20em;">
145
                <option value="*">All libraries</option>
145
                <option value="*">All libraries</option>
146
                [% PROCESS options_for_libraries libraries => Branches.all( selected => current_branch ) %]
146
                [% PROCESS options_for_libraries libraries => Branches.all( selected => current_branch, unfiltered => 1 ) %]
147
            </select>
147
            </select>
148
        </form>
148
        </form>
149
        [% IF ( definedbranch ) %]
149
        [% IF ( definedbranch ) %]
Lines 151-157 $(document).ready(function() { Link Here
151
                <label for="tobranch"><strong>Clone these rules to:</strong></label>
151
                <label for="tobranch"><strong>Clone these rules to:</strong></label>
152
                <input type="hidden" name="frombranch" value="[% current_branch %]" />
152
                <input type="hidden" name="frombranch" value="[% current_branch %]" />
153
                <select name="tobranch" id="tobranch">
153
                <select name="tobranch" id="tobranch">
154
                    [% FOREACH l IN Branches.all() %]
154
                    [% FOREACH l IN Branches.all( unfiltered => 1 ) %]
155
                        <option value="[% l.value %]">[% l.branchname %]</option>
155
                        <option value="[% l.value %]">[% l.branchname %]</option>
156
                    [% END %]
156
                    [% END %]
157
                </select>
157
                </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 252-258 Link Here
252
<fieldset id="select-libs">
253
<fieldset id="select-libs">
253
        <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;}'>
254
        <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;}'>
254
        <option value="">All libraries</option>
255
        <option value="">All libraries</option>
255
        [% PROCESS options_for_libraries libraries => Branches.all() %]
256
        [%# FIXME Should not we filter the libraries displayed? %]
257
        [% PROCESS options_for_libraries libraries => Branches.all( selected => selected_branchcode, unfiltered => 1 ) %]
256
        </select></p>
258
        </select></p>
257
    <!-- <input type="hidden" name="limit" value="branch: MAIN" /> -->
259
    <!-- <input type="hidden" name="limit" value="branch: MAIN" /> -->
258
        [% IF ( searchdomainloop ) %]
260
        [% IF ( searchdomainloop ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-2 / +2 lines)
Lines 675-681 function verify_images() { Link Here
675
                                : due [% item.datedue %]
675
                                : due [% item.datedue %]
676
                            </span>
676
                            </span>
677
                        [% ELSIF ( item.transfertwhen ) %]
677
                        [% ELSIF ( item.transfertwhen ) %]
678
                            <span class="intransit">In transit from [% item.transfertfrom %] to [% item.transfertto %] since [% item.transfertwhen | $KohaDates %]</span>
678
                            <span class="intransit">In transit from [% Branches.GetName( item.transfertfrom ) %] to [% Branches.GetName( item.transfertto ) %] since [% item.transfertwhen | $KohaDates %]</span>
679
                        [% END %]
679
                        [% END %]
680
680
681
                        [% IF ( item.itemlost ) %]
681
                        [% IF ( item.itemlost ) %]
Lines 731-737 function verify_images() { Link Here
731
                            [% IF ( item.waitingdate ) %]
731
                            [% IF ( item.waitingdate ) %]
732
                                at[% ELSE %]for delivery at
732
                                at[% ELSE %]for delivery at
733
                            [% END %]
733
                            [% END %]
734
                            [% item.ExpectedAtLibrary %]
734
                            [% Branches.GetName( item.ExpectedAtLibrary ) %]
735
                            [% IF ( item.waitingdate ) %]
735
                            [% IF ( item.waitingdate ) %]
736
                                since [% item.waitingdate | $KohaDates %]
736
                                since [% item.waitingdate | $KohaDates %]
737
                            [% ELSE %]
737
                            [% 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 |html %]</title>
4
<title>Koha &rsaquo; Circulation &rsaquo; Circulation statistics for [% title |html %]</title>
4
[% INCLUDE 'doc-head-close.inc' %]
5
[% INCLUDE 'doc-head-close.inc' %]
Lines 25-33 $(document).ready(function(){ Link Here
25
<h3>Barcode [% barcode %]</h3>
26
<h3>Barcode [% barcode %]</h3>
26
<table>
27
<table>
27
        <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>
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>
28
		
29
29
		<tr><td>[% homebranch %]</td>
30
        <tr><td>[% Branches.GetName( homebranch ) %]</td>
30
            <td>[% holdingbranch %]</td>
31
            <td>[% Branches.GetName( holdingbranch ) %]</td>
31
            <td>[% IF ( lastdate ) %][% lastdate | $KohaDates %][% ELSE %]Item has no transfer record[% END %]</td>
32
            <td>[% IF ( lastdate ) %][% lastdate | $KohaDates %][% ELSE %]Item has no transfer record[% END %]</td>
32
            <td>[% count %]</td>
33
            <td>[% count %]</td>
33
        </tr>
34
        </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 261-270 $(document).ready(function () { Link Here
261
            [% INCLUDE display_bormessagepref %]
261
            [% INCLUDE display_bormessagepref %]
262
[% IF ( debarred ) %]<li class="error">Patron is RESTRICTED</li>[% END %]
262
[% IF ( debarred ) %]<li class="error">Patron is RESTRICTED</li>[% END %]
263
[% IF ( gonenoaddress ) %]<li class="error">Patron's address is in doubt</li>[% END %]</ul>
263
[% IF ( gonenoaddress ) %]<li class="error">Patron's address is in doubt</li>[% END %]</ul>
264
		[% IF ( transfertodo ) %]
264
        [% IF ( transfertodo ) %]
265
            <h4><strong>Transfer to:</strong> [% destbranchname %]</h4>
265
            <h4><strong>Transfer to:</strong> [% Branches.GetName( destbranchname ) %]</h4>
266
		[% ELSE %]
266
        [% ELSE %]
267
		<h4><strong>Hold at</strong> [% destbranchname %]</h4>
267
            <h4><strong>Hold at</strong> [% Branches.GetName( destbranchname ) %]</h4>
268
        [% END %]
268
        [% END %]
269
        <form method="post" action="returns.pl" class="confirm">
269
        <form method="post" action="returns.pl" class="confirm">
270
            <button type="submit" class="approve"><i class="fa fa-check"></i> Confirm</button>
270
            <button type="submit" class="approve"><i class="fa fa-check"></i> Confirm</button>
Lines 487-493 $(document).ready(function () { Link Here
487
                        <p class="problem">No item with barcode: [% errmsgloo.msg %]</p>
487
                        <p class="problem">No item with barcode: [% errmsgloo.msg %]</p>
488
                    [% END %]
488
                    [% END %]
489
                    [% IF ( errmsgloo.ispermanent ) %]
489
                    [% IF ( errmsgloo.ispermanent ) %]
490
                        <p class="problem">Please return item to: [% errmsgloo.msg %]</p>
490
                        <p class="problem">Please return item to: [% Branches.GetName( errmsgloo.msg ) %]</p>
491
                    [% END %]
491
                    [% END %]
492
                    [% IF ( errmsgloo.notissued ) %]
492
                    [% IF ( errmsgloo.notissued ) %]
493
                        <p class="problem">Not checked out.</p>
493
                        <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 194-204 function filterByFirstLetterSurname(letter) { Link Here
194
                    <li>
195
                    <li>
195
                        <label for="branchcode_filter">Library:</label>
196
                        <label for="branchcode_filter">Library:</label>
196
                        <select id="branchcode_filter">
197
                        <select id="branchcode_filter">
197
                            [% IF branches.size != 1 %]
198
                            [% SET libraries = Branches.all() %]
199
                            [% IF libraries.size != 1 %]
198
                                <option value="">Any</option>
200
                                <option value="">Any</option>
199
                            [% END %]
201
                            [% END %]
200
                            [% FOREACH branch IN branches %]
202
                            [% FOREACH l IN libraries %]
201
                                <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
203
                                <option value="[% l.branchcode %]">[% l.branchname %]</option>
202
                            [% END %]
204
                            [% END %]
203
                        </select>
205
                        </select>
204
                    </li>
206
                    </li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/borrowers_stats.tt (-1 / +1 lines)
Lines 142-148 Link Here
142
			<td>
142
			<td>
143
                <select name="Filter"  size="1" id="branch">
143
                <select name="Filter"  size="1" id="branch">
144
                <option value=""></option>
144
                <option value=""></option>
145
                [% FOREACH l IN Branches.all() %]
145
                [% FOREACH l IN Branches.all( unfiltered => 1 ) %]
146
                    <option value="[% l.branchcode %]">[% l.branchcode %] - [% l.branchname || 'UNKNOWN' %]</option>
146
                    <option value="[% l.branchcode %]">[% l.branchcode %] - [% l.branchname || 'UNKNOWN' %]</option>
147
                [% END %]
147
                [% END %]
148
                </select>
148
                </select>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (-7 / +7 lines)
Lines 16-25 Link Here
16
<script type="text/javascript">
16
<script type="text/javascript">
17
    // <![CDATA[
17
    // <![CDATA[
18
var MSG_CONFIRM_DELETE_HOLD   = _("Are you sure you want to cancel this hold?");
18
var MSG_CONFIRM_DELETE_HOLD   = _("Are you sure you want to cancel this hold?");
19
var patron_homebranch = "[% borrower_branchname |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]";
19
var patron_homebranch = "[% Branches.GetName( borrower_branchcode ) |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]";
20
var override_items = {[% FOREACH bibitemloo IN bibitemloop %][% FOREACH itemloo IN bibitemloo.itemloop %][% IF ( itemloo.override ) %]
20
var override_items = {[% FOREACH bibitemloo IN bibitemloop %][% FOREACH itemloo IN bibitemloo.itemloop %][% IF ( itemloo.override ) %]
21
    [% itemloo.itemnumber %]: {
21
    [% itemloo.itemnumber %]: {
22
        homebranch: "[% itemloo.homebranchname |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
22
        homebranch: "[% Branches.GetName( itemloo.homebranch ) |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
23
        holdallowed: [% itemloo.holdallowed %]
23
        holdallowed: [% itemloo.holdallowed %]
24
    },
24
    },
25
[% END %][% END %][% END %]
25
[% END %][% END %][% END %]
Lines 472-481 function checkMultiHold() { Link Here
472
                        [% itemloo.barcode %]
472
                        [% itemloo.barcode %]
473
                    </td>
473
                    </td>
474
                    <td>
474
                    <td>
475
                        [% itemloo.homebranchname %]
475
                        [% Branches.GetName( itemloo.homebranch ) %]
476
                    </td>
476
                    </td>
477
                    <td>
477
                    <td>
478
                        [% itemloo.holdingbranchname %]
478
                        [% Branches.GetName( itemloo.holdingbranch ) %]
479
                    </td>
479
                    </td>
480
                    <td>
480
                    <td>
481
                        [% itemloo.itemcallnumber %]
481
                        [% itemloo.itemcallnumber %]
Lines 494-501 function checkMultiHold() { Link Here
494
                [% ELSE %]
494
                [% ELSE %]
495
                    <span title="0000-00-00">
495
                    <span title="0000-00-00">
496
                        [% IF ( itemloo.transfertwhen ) %]
496
                        [% IF ( itemloo.transfertwhen ) %]
497
                            In transit from [% itemloo.transfertfrom %],
497
                            In transit from [% Branches.GetName( itemloo.transfertfrom ) %],
498
                            to [% itemloo.transfertto %], since [% itemloo.transfertwhen %]
498
                            to [% Branches.GetName( itemloo.transfertto ) %], since [% itemloo.transfertwhen %]
499
                        [% END %]
499
                        [% END %]
500
                    </span>
500
                    </span>
501
                [% END %]
501
                [% END %]
Lines 513-519 function checkMultiHold() { Link Here
513
                            Can't be cancelled when item is in transit
513
                            Can't be cancelled when item is in transit
514
                    [% ELSE %]
514
                    [% ELSE %]
515
                    [% IF ( itemloo.waitingdate ) %]Waiting[% ELSE %]On hold[% END %]
515
                    [% IF ( itemloo.waitingdate ) %]Waiting[% ELSE %]On hold[% END %]
516
                    [% 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 %]
516
                    [% 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 ) %]
517
                    since
517
                    since
518
                    [% 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>
518
                    [% 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>
519
519
(-)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
                <li>
96
                <li>
(-)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 421-428 h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o Link Here
421
    <fieldset class="rows"> <legend>Acquisition information</legend><ol>
421
    <fieldset class="rows"> <legend>Acquisition information</legend><ol>
422
        <li><label for="branchcode">Library:</label>
422
        <li><label for="branchcode">Library:</label>
423
            <select name="branchcode" id="branchcode">
423
            <select name="branchcode" id="branchcode">
424
                <option value="">Any</option>[% FOREACH branchloo IN branchloop %]
424
                <option value="">Any</option>
425
                [% IF ( branchloo.selected ) %]<option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>[% ELSE %]<option value="[% branchloo.value %]">[% branchloo.branchname %]</option>[% END %][% END %]
425
                [% IF branchfilter %]
426
                    [% PROCESS options_for_libraries libraries => Branches.all( selected => branchfilter ) %]
427
                [% ELSE %]
428
                    [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode ) %]
429
                [% END %]
426
            </select>
430
            </select>
427
        </li>
431
        </li>
428
        <li><label for="budgetid">Fund:</label>
432
        <li><label for="budgetid">Fund:</label>
Lines 787-795 h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o Link Here
787
                    </select></li>
791
                    </select></li>
788
                    <li><label for="branchcode">Library:</label>
792
                    <li><label for="branchcode">Library:</label>
789
                    <select name="branchcode" id="branchcode">
793
                    <select name="branchcode" id="branchcode">
790
                        <option value="__ANY__">Any</option>[% FOREACH branchloo IN branchloop %]
794
                        <option value="__ANY__">Any</option>
791
                            [% IF ( branchloo.selected ) %] <option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>[% ELSE %] <option value="[% branchloo.value %]">[% branchloo.branchname %]</option>[% END %]
795
                        [% IF branchfilter %]
792
                            [% END %]
796
                            [% PROCESS options_for_libraries libraries => Branches.all( selected => branchfilter ) %]
797
                        [% ELSE %]
798
                            [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode ) %]
799
                        [% END %]
793
                    </select></li><li><input type="submit" value="Go" /></li></ol>
800
                    </select></li><li><input type="submit" value="Go" /></li></ol>
794
                </fieldset>
801
                </fieldset>
795
    </div>
802
    </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; Export data</title>
3
<title>Koha &rsaquo; Tools &rsaquo; Export data</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'doc-head-close.inc' %]
Lines 92-98 $(document).ready(function() { Link Here
92
        <li>
93
        <li>
93
            <label>Library: </label>
94
            <label>Library: </label>
94
            [% INCLUDE 'branch-selector.inc'
95
            [% INCLUDE 'branch-selector.inc'
95
                branches = branchloop %]
96
                branches = libraries %]
96
        </li>
97
        </li>
97
    </ol>
98
    </ol>
98
99
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt (-1 lines)
Lines 320-326 td.repeatableyearly a.ui-state-default { background: #FFCC66 none; color : Bl Link Here
320
    <!-- ***************************** Panel to deal with new holidays **********************  -->
320
    <!-- ***************************** Panel to deal with new holidays **********************  -->
321
    <div class="panel" id="newHoliday">
321
    <div class="panel" id="newHoliday">
322
         <form action="/cgi-bin/koha/tools/newHolidays.pl" method="post">
322
         <form action="/cgi-bin/koha/tools/newHolidays.pl" method="post">
323
                <input type="hidden" name="branchCodes" id="branchCodes" value="[% branchcodes %]" /> 
324
            <fieldset class="brief">
323
            <fieldset class="brief">
325
            <h3>Add new holiday</h3>
324
            <h3>Add new holiday</h3>
326
            <ol>
325
            <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 112-129 Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div> Link Here
112
            <li>
113
            <li>
113
                <label for="branch">Library: </label>
114
                <label for="branch">Library: </label>
114
                <select id="branch" name="branch">
115
                <select id="branch" name="branch">
115
                [% IF ( new_detail.branchcode == '' ) %]
116
                    [% IF ( new_detail.branchcode == '' ) %]
116
                    <option value="" selected="selected">All libraries</option>
117
                        <option value="" selected="selected">All libraries</option>
117
                [% ELSE %]
118
                    [% ELSE %]
118
                    <option value=""         >All libraries</option>
119
                        <option value=""         >All libraries</option>
119
                [% END %]
120
                    [% END %]
120
                [% FOREACH branch_item IN branch_list %]
121
                    [% PROCESS options_for_libraries libraries => Branches.all( selected => new_detail.branchcode, unfiltered => 1, ) %]
121
                [% IF ( branch_item.value.branchcode == new_detail.branchcode ) %]
122
                    <option value="[% branch_item.value.branchcode %]" selected="selected">[% branch_item.value.branchname %]</option>
123
                [% ELSE %]
124
                    <option value="[% branch_item.value.branchcode %]">[% branch_item.value.branchname %]</option>
125
                [% END %]
126
                [% END %]
127
                </select>
122
                </select>
128
            </li>
123
            </li>
129
            <li>
124
            <li>
Lines 191-207 Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div> Link Here
191
                [% ELSE %]
186
                [% ELSE %]
192
                <option value=""         >All libraries</option>
187
                <option value=""         >All libraries</option>
193
                [% END %]
188
                [% END %]
194
                [% FOREACH branch_item IN branch_list %]
189
                [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode, unfiltered => 1, ) %]
195
                [% IF ( branch_item.value.branchcode == branchcode ) %]
196
                    <option value="[% branch_item.value.branchcode %]"
197
                            selected="selected">[% branch_item.value.branchname %]
198
                    </option>
199
                [% ELSE %]
200
                    <option value="[% branch_item.value.branchcode %]"
201
                                    >[% branch_item.value.branchname %]
202
                    </option>
203
                [% END %]
204
                [% END %]
205
            </select>
190
            </select>
206
            <input type="submit" class="button" value="Filter" />
191
            <input type="submit" class="button" value="Filter" />
207
        </form>
192
        </form>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc (-2 / +2 lines)
Lines 37-44 not use an API to fetch items that populates item.datedue. Link Here
37
37
38
[% IF ( item.transfertwhen ) %]
38
[% IF ( item.transfertwhen ) %]
39
    [% SET itemavailable = 0 %]
39
    [% SET itemavailable = 0 %]
40
    <span class="item-status intransit">In transit from [% item.transfertfrom %]
40
    <span class="item-status intransit">In transit from [% Branches.GetName( item.transfertfrom ) %]
41
    to [% item.transfertto %] since [% item.transfertwhen | $KohaDates %]</span>
41
    to [% Branches.GetName( item.transfertto ) %] since [% item.transfertwhen | $KohaDates %]</span>
42
[% END %]
42
[% END %]
43
43
44
[% IF ( item.waiting ) %]
44
[% IF ( item.waiting ) %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt (-3 / +3 lines)
Lines 346-353 Link Here
346
346
347
                                                                    <td class="barcode">[% itemLoo.barcode %]</td>
347
                                                                    <td class="barcode">[% itemLoo.barcode %]</td>
348
                                                                    [% UNLESS ( singleBranchMode ) %]
348
                                                                    [% UNLESS ( singleBranchMode ) %]
349
                                                                        <td class="homebranch">[% itemLoo.homeBranchName %]</td>
349
                                                                        <td class="homebranch">[% Branches.GetName( itemLoo.homeBranchName ) %]</td>
350
                                                                        <td class="holdingbranch">[% itemLoo.holdingBranchName %]</td>
350
                                                                        <td class="holdingbranch">[% Branches.GetName( itemLoo.holdingBranchName ) %]</td>
351
                                                                    [% END %]
351
                                                                    [% END %]
352
                                                                    <td class="call_no">[% itemLoo.callNumber %]</td>
352
                                                                    <td class="call_no">[% itemLoo.callNumber %]</td>
353
                                                                    [% IF ( itemdata_enumchron ) %]
353
                                                                    [% IF ( itemdata_enumchron ) %]
Lines 357-363 Link Here
357
                                                                        [% IF ( itemLoo.dateDue ) %]
357
                                                                        [% IF ( itemLoo.dateDue ) %]
358
                                                                            <span class="checkedout">Due [% itemLoo.dateDue %]</span>
358
                                                                            <span class="checkedout">Due [% itemLoo.dateDue %]</span>
359
                                                                        [% ELSIF ( itemLoo.transfertwhen ) %]
359
                                                                        [% ELSIF ( itemLoo.transfertwhen ) %]
360
                                                                            <span class="intransit">In transit from [% itemLoo.transfertfrom %] to [% itemLoo.transfertto %] since [% itemLoo.transfertwhen %]</span>
360
                                                                            <span class="intransit">In transit from [% Branches.GetName( itemLoo.transfertfrom ) %] to [% Branches.GetName( itemLoo.transfertto ) %] since [% itemLoo.transfertwhen %]</span>
361
                                                                        [% END %]
361
                                                                        [% END %]
362
362
363
                                                                        [% IF ( itemLoo.message ) %]
363
                                                                        [% 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 [% timeLimit |html %] months
48
                                    in the past [% timeLimit |html %] 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
use Koha::Patron::Images;
33
use Koha::Patron::Images;
35
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
34
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
(-)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::Patron::Debarments;
41
use Koha::Patron::Debarments;
43
use Koha::Cities;
42
use Koha::Cities;
(-)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
use Koha::Patron::Images;
43
use Koha::Patron::Images;
45
44
(-)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
use Koha::Patron::Images;
31
use Koha::Patron::Images;
33
32
34
use Koha::Patron::Categories;
33
use Koha::Patron::Categories;
(-)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 74-81 if ( $borrowernumber eq C4::Context->preference('AnonymousPatron') ){ Link Here
74
    $issues = GetAllIssues($borrowernumber,$order,$limit);
73
    $issues = GetAllIssues($borrowernumber,$order,$limit);
75
}
74
}
76
75
77
my $branches = GetBranches();
78
79
#   barcode export
76
#   barcode export
80
if ( $op eq 'export_barcodes' ) {
77
if ( $op eq 'export_barcodes' ) {
81
    if ( $data->{'privacy'} < 2) {
78
    if ( $data->{'privacy'} < 2) {
Lines 128-134 $template->param( Link Here
128
    privacy           => $data->{'privacy'},
125
    privacy           => $data->{'privacy'},
129
    categoryname      => $data->{description},
126
    categoryname      => $data->{description},
130
    is_child          => ( $data->{category_type} eq 'C' ),
127
    is_child          => ( $data->{category_type} eq 'C' ),
131
    branchname        => $branches->{ $data->{branchcode} }->{branchname},
132
    loop_reading      => $issues,
128
    loop_reading      => $issues,
133
    activeBorrowerRelationship =>
129
    activeBorrowerRelationship =>
134
      ( C4::Context->preference('borrowerRelationship') ne '' ),
130
      ( 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/;
24
use C4::Auth qw/:DEFAULT/;
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 42-49 my ( $template, $loggedinuser, $cookie ) = get_template_and_user ( Link Here
42
    }
41
    }
43
);
42
);
44
43
45
my $branches = GetBranches();
46
47
my $findborrower = $query->param('findborrower');
44
my $findborrower = $query->param('findborrower');
48
$findborrower =~ s|,| |g;
45
$findborrower =~ s|,| |g;
49
46
(-)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 196-202 if ($session->param('busc')) { Link Here
196
        my ($arrParamsBusc, $offset, $results_per_page) = @_;
196
        my ($arrParamsBusc, $offset, $results_per_page) = @_;
197
197
198
        my $expanded_facet = $arrParamsBusc->{'expand'};
198
        my $expanded_facet = $arrParamsBusc->{'expand'};
199
        my $branches = GetBranches();
200
        my $itemtypes = GetItemTypes;
199
        my $itemtypes = GetItemTypes;
201
        my @servers;
200
        my @servers;
202
        @servers = @{$arrParamsBusc->{'server'}} if $arrParamsBusc->{'server'};
201
        @servers = @{$arrParamsBusc->{'server'}} if $arrParamsBusc->{'server'};
Lines 208-214 if ($session->param('busc')) { Link Here
208
        $sort_by[0] = $default_sort_by if !$sort_by[0] && defined($default_sort_by);
207
        $sort_by[0] = $default_sort_by if !$sort_by[0] && defined($default_sort_by);
209
        my ($error, $results_hashref, $facets);
208
        my ($error, $results_hashref, $facets);
210
        eval {
209
        eval {
211
            ($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'});
210
            ($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'});
212
        };
211
        };
213
        my $hits;
212
        my $hits;
214
        my @newresults;
213
        my @newresults;
Lines 488-494 if ($hideitems) { Link Here
488
    @items = @all_items;
487
    @items = @all_items;
489
}
488
}
490
489
491
my $branches = GetBranches();
492
my $branch = '';
490
my $branch = '';
493
if (C4::Context->userenv){
491
if (C4::Context->userenv){
494
    $branch = C4::Context->userenv->{branch};
492
    $branch = C4::Context->userenv->{branch};
Lines 499-517 if ( C4::Context->preference('HighlightOwnItemsOnOPAC') ) { Link Here
499
        ||
497
        ||
500
        C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch'
498
        C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch'
501
    ) {
499
    ) {
502
        my $branchname;
500
        my $branchcode;
503
        if ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'PatronBranch' ) {
501
        if ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'PatronBranch' ) {
504
            $branchname = $branches->{$branch}->{'branchname'};
502
            $branchcode = $branch;
505
        }
503
        }
506
        elsif (  C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch' ) {
504
        elsif (  C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch' ) {
507
            $branchname = $branches->{ $ENV{'BRANCHCODE'} }->{'branchname'};
505
            $branchcode = $ENV{'BRANCHCODE'};
508
        }
506
        }
509
507
510
        my @our_items;
508
        my @our_items;
511
        my @other_items;
509
        my @other_items;
512
510
513
        foreach my $item ( @items ) {
511
        foreach my $item ( @items ) {
514
           if ( $item->{'branchname'} eq $branchname ) {
512
           if ( $item->{branchcode} eq $branchcode ) {
515
               $item->{'this_branch'} = 1;
513
               $item->{'this_branch'} = 1;
516
               push( @our_items, $item );
514
               push( @our_items, $item );
517
           } else {
515
           } else {
Lines 666-673 if ( not $viewallitems and @items > $max_items_to_display ) { Link Here
666
     my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($itm->{itemnumber});
664
     my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($itm->{itemnumber});
667
     if ( defined( $transfertwhen ) && $transfertwhen ne '' ) {
665
     if ( defined( $transfertwhen ) && $transfertwhen ne '' ) {
668
        $itm->{transfertwhen} = $transfertwhen;
666
        $itm->{transfertwhen} = $transfertwhen;
669
        $itm->{transfertfrom} = $branches->{$transfertfrom}{branchname};
667
        $itm->{transfertfrom} = $transfertfrom;
670
        $itm->{transfertto}   = $branches->{$transfertto}{branchname};
668
        $itm->{transfertto}   = $transfertto;
671
     }
669
     }
672
    
670
    
673
    if (    C4::Context->preference('OPACAcquisitionDetails')
671
    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 88-95 if ( $borr->{'BlockExpiredPatronOpacActions'} ) { Link Here
88
if ($borr->{reservefee} > 0){
87
if ($borr->{reservefee} > 0){
89
    $template->param( RESERVE_CHARGE => sprintf("%.2f",$borr->{reservefee}));
88
    $template->param( RESERVE_CHARGE => sprintf("%.2f",$borr->{reservefee}));
90
}
89
}
91
# get branches and itemtypes
90
92
my $branches = GetBranches();
93
my $itemTypes = GetItemTypes();
91
my $itemTypes = GetItemTypes();
94
92
95
# There are two ways of calling this script, with a single biblio num
93
# There are two ways of calling this script, with a single biblio num
Lines 124-130 if (($#biblionumbers < 0) && (! $query->param('place_reserve'))) { Link Here
124
122
125
# pass the pickup branch along....
123
# pass the pickup branch along....
126
my $branch = $query->param('branch') || $borr->{'branchcode'} || C4::Context->userenv->{branch} || '' ;
124
my $branch = $query->param('branch') || $borr->{'branchcode'} || C4::Context->userenv->{branch} || '' ;
127
($branches->{$branch}) or $branch = "";     # Confirm branch is real
128
$template->param( branch => $branch );
125
$template->param( branch => $branch );
129
126
130
# Is the person allowed to choose their branch
127
# Is the person allowed to choose their branch
Lines 434-440 foreach my $biblioNum (@biblionumbers) { Link Here
434
431
435
        $itemLoopIter->{itemnumber} = $itemNum;
432
        $itemLoopIter->{itemnumber} = $itemNum;
436
        $itemLoopIter->{barcode} = $itemInfo->{barcode};
433
        $itemLoopIter->{barcode} = $itemInfo->{barcode};
437
        $itemLoopIter->{homeBranchName} = $branches->{$itemInfo->{homebranch}}{branchname};
434
        $itemLoopIter->{homeBranchName} = $itemInfo->{homebranch};
438
        $itemLoopIter->{callNumber} = $itemInfo->{itemcallnumber};
435
        $itemLoopIter->{callNumber} = $itemInfo->{itemcallnumber};
439
        $itemLoopIter->{enumchron} = $itemInfo->{enumchron};
436
        $itemLoopIter->{enumchron} = $itemInfo->{enumchron};
440
        $itemLoopIter->{copynumber} = $itemInfo->{copynumber};
437
        $itemLoopIter->{copynumber} = $itemInfo->{copynumber};
Lines 447-454 foreach my $biblioNum (@biblionumbers) { Link Here
447
        # If the holdingbranch is different than the homebranch, we show the
444
        # If the holdingbranch is different than the homebranch, we show the
448
        # holdingbranch of the document too.
445
        # holdingbranch of the document too.
449
        if ( $itemInfo->{homebranch} ne $itemInfo->{holdingbranch} ) {
446
        if ( $itemInfo->{homebranch} ne $itemInfo->{holdingbranch} ) {
450
            $itemLoopIter->{holdingBranchName} =
447
            $itemLoopIter->{holdingBranchName} = $itemInfo->{holdingbranch};
451
              $branches->{ $itemInfo->{holdingbranch} }{branchname};
452
        }
448
        }
453
449
454
        # If the item is currently on loan, we display its return date and
450
        # If the item is currently on loan, we display its return date and
Lines 506-514 foreach my $biblioNum (@biblionumbers) { Link Here
506
          GetTransfers($itemNum);
502
          GetTransfers($itemNum);
507
        if ( $transfertwhen && ($transfertwhen ne '') ) {
503
        if ( $transfertwhen && ($transfertwhen ne '') ) {
508
            $itemLoopIter->{transfertwhen} = output_pref({ dt => dt_from_string($transfertwhen), dateonly => 1 });
504
            $itemLoopIter->{transfertwhen} = output_pref({ dt => dt_from_string($transfertwhen), dateonly => 1 });
509
            $itemLoopIter->{transfertfrom} =
505
            $itemLoopIter->{transfertfrom} = $transfertfrom;
510
              $branches->{$transfertfrom}{branchname};
506
            $itemLoopIter->{transfertto} = $transfertto;
511
            $itemLoopIter->{transfertto} = $branches->{$transfertto}{branchname};
512
            $itemLoopIter->{nocancel} = 1;
507
            $itemLoopIter->{nocancel} = 1;
513
        }
508
        }
514
509
(-)a/opac/opac-search.pl (-8 / +6 lines)
Lines 49-55 use C4::Search::History; Link Here
49
use C4::Biblio;  # GetBiblioData
49
use C4::Biblio;  # GetBiblioData
50
use C4::Koha;
50
use C4::Koha;
51
use C4::Tags qw(get_tags);
51
use C4::Tags qw(get_tags);
52
use C4::Branch; # GetBranches
53
use C4::SocialData;
52
use C4::SocialData;
54
use C4::Ratings;
53
use C4::Ratings;
55
use C4::External::OverDrive;
54
use C4::External::OverDrive;
Lines 213-219 if ($cgi->cookie("search_path_code")) { Link Here
213
    }
212
    }
214
}
213
}
215
214
216
my $branches = GetBranches();   # used later in *getRecords, probably should be internalized by those functions after caching in C4::Branch is established
217
my $library_categories = Koha::LibraryCategories->search( { categorytype => 'searchdomain' }, { order_by => [ 'categorytype', 'categorycode' ] } );
215
my $library_categories = Koha::LibraryCategories->search( { categorytype => 'searchdomain' }, { order_by => [ 'categorytype', 'categorycode' ] } );
218
$template->param( searchdomainloop => $library_categories );
216
$template->param( searchdomainloop => $library_categories );
219
217
Lines 608-614 if ($tag) { Link Here
608
    # FIXME: No facets for tags search.
606
    # FIXME: No facets for tags search.
609
} elsif ($build_grouped_results) {
607
} elsif ($build_grouped_results) {
610
    eval {
608
    eval {
611
        ($error, $results_hashref, $facets) = C4::Search::pazGetRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan);
609
        ($error, $results_hashref, $facets) = C4::Search::pazGetRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,undef,$query_type,$scan);
612
    };
610
    };
613
} else {
611
} else {
614
    $pasarParams .= '&amp;query=' . uri_escape_utf8($query);
612
    $pasarParams .= '&amp;query=' . uri_escape_utf8($query);
Lines 616-622 if ($tag) { Link Here
616
    $pasarParams .= '&amp;simple_query=' . uri_escape_utf8($simple_query);
614
    $pasarParams .= '&amp;simple_query=' . uri_escape_utf8($simple_query);
617
    $pasarParams .= '&amp;query_type=' . uri_escape_utf8($query_type) if ($query_type);
615
    $pasarParams .= '&amp;query_type=' . uri_escape_utf8($query_type) if ($query_type);
618
    eval {
616
    eval {
619
        ($error, $results_hashref, $facets) = $searcher->search_compat($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$itemtypes,$query_type,$scan,1);
617
        ($error, $results_hashref, $facets) = $searcher->search_compat($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,undef,$itemtypes,$query_type,$scan,1);
620
};
618
};
621
}
619
}
622
620
Lines 798-809 for (my $i=0;$i<@servers;$i++) { Link Here
798
                    ||
796
                    ||
799
                    C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch'
797
                    C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch'
800
                ) {
798
                ) {
801
                    my $branchname;
799
                    my $branchcode;
802
                    if ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'PatronBranch' ) {
800
                    if ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'PatronBranch' ) {
803
                        $branchname = $branches->{$branch}->{'branchname'};
801
                        $branchcode = $branch;
804
                    }
802
                    }
805
                    elsif (  C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch' ) {
803
                    elsif (  C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch' ) {
806
                        $branchname = $branches->{ $ENV{'BRANCHCODE'} }->{'branchname'};
804
                        $branchcode = $ENV{'BRANCHCODE'};
807
                    }
805
                    }
808
806
809
                    foreach my $res ( @newresults ) {
807
                    foreach my $res ( @newresults ) {
Lines 811-817 for (my $i=0;$i<@servers;$i++) { Link Here
811
                        my @top_loop;
809
                        my @top_loop;
812
                        my @old_loop = @{$res->{'available_items_loop'}};
810
                        my @old_loop = @{$res->{'available_items_loop'}};
813
                        foreach my $item ( @old_loop ) {
811
                        foreach my $item ( @old_loop ) {
814
                            if ( $item->{'branchname'} eq $branchname ) {
812
                            if ( $item->{'branchcode'} eq $branchcode ) {
815
                                $item->{'this_branch'} = 1;
813
                                $item->{'this_branch'} = 1;
816
                                push( @top_loop, $item );
814
                                push( @top_loop, $item );
817
                            } else {
815
                            } 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::Holds;
37
use Koha::Holds;
39
use Koha::Database;
38
use Koha::Database;
(-)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 63-70 my $multihold = $input->param('multi_hold'); Link Here
63
$template->param(multi_hold => $multihold);
62
$template->param(multi_hold => $multihold);
64
my $showallitems = $input->param('showallitems');
63
my $showallitems = $input->param('showallitems');
65
64
66
# get Branches and Itemtypes
67
my $branches = GetBranches();
68
my $itemtypes = GetItemTypes();
65
my $itemtypes = GetItemTypes();
69
66
70
# Select borrowers infos
67
# Select borrowers infos
Lines 347-359 foreach my $biblionumber (@biblionumbers) { Link Here
347
344
348
            $item->{itypename} = $itemtypes->{ $item->{itype} }{description};
345
            $item->{itypename} = $itemtypes->{ $item->{itype} }{description};
349
            $item->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $item->{itype} }{imageurl} );
346
            $item->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $item->{itype} }{imageurl} );
350
            $item->{homebranchname} = $branches->{ $item->{homebranch} }{branchname};
347
            $item->{homebranch} = $item->{homebranch};
351
348
352
            # if the holdingbranch is different than the homebranch, we show the
349
            # if the holdingbranch is different than the homebranch, we show the
353
            # holdingbranch of the document too
350
            # holdingbranch of the document too
354
            if ( $item->{homebranch} ne $item->{holdingbranch} ) {
351
            if ( $item->{homebranch} ne $item->{holdingbranch} ) {
355
                $item->{holdingbranchname} =
352
                $item->{holdingbranch} = $item->{holdingbranch};
356
                  $branches->{ $item->{holdingbranch} }{branchname};
357
            }
353
            }
358
354
359
		if($item->{biblionumber} ne $biblionumber){
355
		if($item->{biblionumber} ne $biblionumber){
Lines 379-385 foreach my $biblionumber (@biblionumbers) { Link Here
379
                $item->{ReservedForBorrowernumber}     = $reservedfor;
375
                $item->{ReservedForBorrowernumber}     = $reservedfor;
380
                $item->{ReservedForSurname}     = $ItemBorrowerReserveInfo->{'surname'};
376
                $item->{ReservedForSurname}     = $ItemBorrowerReserveInfo->{'surname'};
381
                $item->{ReservedForFirstname}     = $ItemBorrowerReserveInfo->{'firstname'};
377
                $item->{ReservedForFirstname}     = $ItemBorrowerReserveInfo->{'firstname'};
382
                $item->{ExpectedAtLibrary}     = $branches->{$expectedAt}{branchname};
378
                $item->{ExpectedAtLibrary}     = $expectedAt;
383
                $item->{waitingdate} = $wait;
379
                $item->{waitingdate} = $wait;
384
            }
380
            }
385
381
Lines 411-419 foreach my $biblionumber (@biblionumbers) { Link Here
411
407
412
            if ( defined $transfertwhen && $transfertwhen ne '' ) {
408
            if ( defined $transfertwhen && $transfertwhen ne '' ) {
413
                $item->{transfertwhen} = output_pref({ dt => dt_from_string( $transfertwhen ), dateonly => 1 });
409
                $item->{transfertwhen} = output_pref({ dt => dt_from_string( $transfertwhen ), dateonly => 1 });
414
                $item->{transfertfrom} =
410
                $item->{transfertfrom} = $transfertfrom;
415
                  $branches->{$transfertfrom}{branchname};
411
                $item->{transfertto} = $transfertto;
416
                $item->{transfertto} = $branches->{$transfertto}{branchname};
417
                $item->{nocancel} = 1;
412
                $item->{nocancel} = 1;
418
            }
413
            }
419
414
Lines 589-598 foreach my $biblionumber (@biblionumbers) { Link Here
589
                     C4::Search::enabled_staff_search_views,
584
                     C4::Search::enabled_staff_search_views,
590
                    );
585
                    );
591
    if (defined $borrowerinfo && exists $borrowerinfo->{'branchcode'}) {
586
    if (defined $borrowerinfo && exists $borrowerinfo->{'branchcode'}) {
592
        $template->param(
587
        $template->param( borrower_branchcode => $borrowerinfo->{'branchcode'},);
593
                     borrower_branchname => $branches->{$borrowerinfo->{'branchcode'}}->{'branchname'},
594
                     borrower_branchcode => $borrowerinfo->{'branchcode'},
595
        );
596
    }
588
    }
597
589
598
    $biblioloopiter{biblionumber} = $biblionumber;
590
    $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
    location_filter => $location,
144
    location_filter => $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");
128
my $locations_loop = GetAuthorisedValues("LOC");
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 61-67 sub GetCriteriumDesc{ Link Here
61
        }
60
        }
62
        return ($criteriumvalue eq 'ASKED'?"Pending":ucfirst(lc( $criteriumvalue))) if ($displayby =~/status/i);
61
        return ($criteriumvalue eq 'ASKED'?"Pending":ucfirst(lc( $criteriumvalue))) if ($displayby =~/status/i);
63
    }
62
    }
64
    return Koha::Libraries->find($criteriumvalue)->branchname;
63
    return Koha::Libraries->find($criteriumvalue)->branchname
65
        if $displayby =~ /branchcode/;
64
        if $displayby =~ /branchcode/;
66
    return GetAuthorisedValueByCode('SUGGEST_FORMAT', $criteriumvalue) || "Unknown" if ($displayby =~/itemtype/);
65
    return GetAuthorisedValueByCode('SUGGEST_FORMAT', $criteriumvalue) || "Unknown" if ($displayby =~/itemtype/);
67
    if ($displayby =~/suggestedby/||$displayby =~/managedby/||$displayby =~/acceptedby/){
66
    if ($displayby =~/suggestedby/||$displayby =~/managedby/||$displayby =~/acceptedby/){
Lines 299-329 if(defined($returnsuggested) and $returnsuggested ne "noone") Link Here
299
    print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=".$returnsuggested."#suggestions");
298
    print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=".$returnsuggested."#suggestions");
300
}
299
}
301
300
302
####################
301
my $branchfilter = ($displayby ne "branchcode") ? $input->param('branchcode') : C4::Context->userenv->{'branch'};
303
## Initializing selection lists
304
305
#branch display management
306
my $branchfilter = ($displayby ne "branchcode") ? $input->param('branchcode') : '';
307
my $onlymine =
308
     C4::Context->preference('IndependentBranches')
309
  && C4::Context->userenv
310
  && !C4::Context->IsSuperLibrarian()
311
  && C4::Context->userenv->{branch};
312
my $branches = GetBranches($onlymine);
313
my @branchloop;
314
315
foreach my $thisbranch ( sort {$branches->{$a}->{'branchname'} cmp $branches->{$b}->{'branchname'}} keys %$branches ) {
316
    my %row = (
317
        value      => $thisbranch,
318
        branchname => $branches->{$thisbranch}->{'branchname'},
319
        selected   => ($branchfilter and $branches->{$thisbranch}->{'branchcode'} eq $branchfilter ) || ( $$suggestion_ref{'branchcode'} and $branches->{$thisbranch}->{'branchcode'} eq $$suggestion_ref{'branchcode'} )
320
    );
321
    push @branchloop, \%row;
322
}
323
$branchfilter=C4::Context->userenv->{'branch'} if ($onlymine && !$branchfilter);
324
302
325
$template->param( branchloop => \@branchloop,
303
$template->param(
326
                branchfilter => $branchfilter);
304
    branchfilter => $branchfilter,
305
);
327
306
328
$template->param( returnsuggestedby => $returnsuggestedby );
307
$template->param( returnsuggestedby => $returnsuggestedby );
329
308
(-)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::Koha;               # GetItemTypes
24
use C4::Koha;               # GetItemTypes
26
use C4::Output;
25
use C4::Output;
27
26
Lines 31-36 use Koha::CsvProfiles; 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->multi_param("branch");
70
my @branch = $query->multi_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->multi_param("biblionumbers");
75
    my @biblionumbers      = $query->multi_param("biblionumbers");
93
    my @itemnumbers        = $query->multi_param("itemnumbers");
76
    my @itemnumbers        = $query->multi_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 140-146 if ( $op eq "export" ) { Link Here
140
                            }
134
                            }
141
                        )
135
                        )
142
                        : (),
136
                        : (),
143
                    ( @branch ? ( 'items.homebranch' => { in => \@branch } ) : () ),
137
                    ( @branchcodes ? ( 'items.homebranch' => { in => \@branchcodes } ) : () ),
144
                    ( $itemtype
138
                    ( $itemtype
145
                        ?
139
                        ?
146
                          C4::Context->preference('item-level_itypes')
140
                          C4::Context->preference('item-level_itypes')
Lines 274-296 else { Link Here
274
        );
268
        );
275
        push @itemtypesloop, \%row;
269
        push @itemtypesloop, \%row;
276
    }
270
    }
277
    my $branches = GetBranches($only_my_branch);
278
    my @branchloop;
279
    for my $thisbranch (
280
        sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} }
281
        keys %{$branches}
282
      )
283
    {
284
        push @branchloop,
285
          {
286
            value      => $thisbranch,
287
            selected   => %branchmap ? $branchmap{$thisbranch} : 1,
288
            branchname => $branches->{$thisbranch}->{'branchname'},
289
          };
290
    }
291
271
292
    my $authority_types = Koha::Authority::Types->search( {}, { order_by => ['authtypecode'] } );
272
    my $authority_types = Koha::Authority::Types->search( {}, { order_by => ['authtypecode'] } );
293
273
274
    my $libraries = Koha::Libraries->search_filtered({}, { order_by => ['branchname'] })->unblessed;
275
    for my $library ( @$libraries ) {
276
        $library->{selected} = 1 if grep { $library->{branchcode} eq $_ } @branch;
277
    }
278
294
    if (   $flags->{superlibrarian}
279
    if (   $flags->{superlibrarian}
295
        && C4::Context->config('backup_db_via_tools')
280
        && C4::Context->config('backup_db_via_tools')
296
        && $backupdir
281
        && $backupdir
Lines 312-318 else { Link Here
312
    }
297
    }
313
298
314
    $template->param(
299
    $template->param(
315
        branchloop               => \@branchloop,
300
        libraries                => $libraries,
316
        itemtypeloop             => \@itemtypesloop,
301
        itemtypeloop             => \@itemtypesloop,
317
        authority_types          => $authority_types,
302
        authority_types          => $authority_types,
318
        export_remove_fields     => C4::Context->preference("ExportRemoveFields"),
303
        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 84-93 foreach my $language ( @$tlangs ) { Link Here
84
    }
83
    }
85
}
84
}
86
85
87
my $branches = GetBranches;
88
89
$template->param( lang_list   => \@lang_list,
86
$template->param( lang_list   => \@lang_list,
90
                  branch_list => $branches,
91
                  branchcode  => $branchcode );
87
                  branchcode  => $branchcode );
92
88
93
my $op = $cgi->param('op') // '';
89
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