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

(-)a/Koha/Template/Plugin/Branches.pm (-8 lines)
Lines 37-50 sub GetName { Link Here
37
    return $b ? $b->{'branchname'} : q{};
37
    return $b ? $b->{'branchname'} : q{};
38
}
38
}
39
39
40
sub GetLoggedInBranchcode {
41
    my ($self) = @_;
42
43
    return C4::Context->userenv ?
44
        C4::Context->userenv->{'branch'} :
45
        '';
46
}
47
48
sub GetURL {
40
sub GetURL {
49
    my ( $self, $branchcode ) = @_;
41
    my ( $self, $branchcode ) = @_;
50
42
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-1 / +1 lines)
Lines 787-793 Link Here
787
                                                    Hold placed on [% w.reservedate | $KohaDates %].
787
                                                    Hold placed on [% w.reservedate | $KohaDates %].
788
788
789
                                                    <br/>
789
                                                    <br/>
790
                                                    [% IF ( w.branch.branchcode == Branches.GetLoggedInBranchcode()  ) %]<strong class="waitinghere">[% ELSE %]<strong>[% END %]
790
                                                    [% IF ( w.branch.branchcode == logged_in_user.branchcode ) %]<strong class="waitinghere">[% ELSE %]<strong>[% END %]
791
                                                        [% SET expires_on = w.expirationdate %]
791
                                                        [% SET expires_on = w.expirationdate %]
792
                                                        Waiting at [% w.branch.branchname | html %] [% IF expires_on %] until [% expires_on | $KohaDates %] [% END %]
792
                                                        Waiting at [% w.branch.branchname | html %] [% IF expires_on %] until [% expires_on | $KohaDates %] [% END %]
793
                                                    </strong>
793
                                                    </strong>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt (-1 / +1 lines)
Lines 136-142 Link Here
136
                                            <label for="branchcode">Pickup library:</label>
136
                                            <label for="branchcode">Pickup library:</label>
137
                                            <select name="branchcode" id="branchcode">
137
                                            <select name="branchcode" id="branchcode">
138
                                                [% FOREACH b IN Branches.all %]
138
                                                [% FOREACH b IN Branches.all %]
139
                                                    [% IF b.branchcode == Branches.GetLoggedInBranchcode %]
139
                                                    [% IF b.branchcode == logged_in_user.branchcode %]
140
                                                        <option value="[% b.branchcode | html %]" selected="selected">[% b.branchname | html %]</option>
140
                                                        <option value="[% b.branchcode | html %]" selected="selected">[% b.branchname | html %]</option>
141
                                                    [% ELSE %]
141
                                                    [% ELSE %]
142
                                                        <option value="[% b.branchcode | html %]">[% b.branchname | html %]</option>
142
                                                        <option value="[% b.branchcode | html %]">[% b.branchname | html %]</option>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (-1 / +1 lines)
Lines 862-868 Link Here
862
        var interface = "[% interface | html %]";
862
        var interface = "[% interface | html %]";
863
        var theme = "[% theme | html %]";
863
        var theme = "[% theme | html %]";
864
        var borrowernumber = "[% patron.borrowernumber | html %]";
864
        var borrowernumber = "[% patron.borrowernumber | html %]";
865
        var branchcode = "[% Branches.GetLoggedInBranchcode() | html %]";
865
        var branchcode = "[% logged_in_user.branchcode | html %]";
866
        var exports_enabled = "[% Koha.Preference('ExportCircHistory') | html %]";
866
        var exports_enabled = "[% Koha.Preference('ExportCircHistory') | html %]";
867
        var AllowCirculate = [% (CAN_user_circulate_circulate_remaining_permissions)? 1 : 0 | html %]
867
        var AllowCirculate = [% (CAN_user_circulate_circulate_remaining_permissions)? 1 : 0 | html %]
868
        var AllowRenewalLimitOverride = [% (CAN_user_circulate_override_renewals && Koha.Preference('AllowRenewalLimitOverride') )? 1: 0 | html %];
868
        var AllowRenewalLimitOverride = [% (CAN_user_circulate_override_renewals && Koha.Preference('AllowRenewalLimitOverride') )? 1: 0 | html %];
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/cleanborrowers.tt (-1 / +1 lines)
Lines 52-58 Link Here
52
    </form>
52
    </form>
53
    [% END %]
53
    [% END %]
54
[% ELSE %]
54
[% ELSE %]
55
    <h1>Batch patron deletion and anonymization for [% Branches.GetName( Branches.GetLoggedInBranchcode ) | html %]</h1>
55
    <h1>Batch patron deletion and anonymization for [% logged_in_user.library.branchname | html %]</h1>
56
[% END %]
56
[% END %]
57
57
58
[% IF step == 1 %]
58
[% IF step == 1 %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-request-article.tt (-1 / +1 lines)
Lines 112-118 Link Here
112
                            <label for="branchcode">Pickup library:</label>
112
                            <label for="branchcode">Pickup library:</label>
113
                            <select name="branchcode" id="branchcode" required="required">
113
                            <select name="branchcode" id="branchcode" required="required">
114
                                [% FOREACH b IN Branches.all %]
114
                                [% FOREACH b IN Branches.all %]
115
                                    [% IF b.branchcode == Branches.GetLoggedInBranchcode %]
115
                                    [% IF b.branchcode == logged_in_user.library.branchcode %]
116
                                        <option value="[% b.branchcode | html %]" selected="selected">[% b.branchname | html %]</option>
116
                                        <option value="[% b.branchcode | html %]" selected="selected">[% b.branchname | html %]</option>
117
                                    [% ELSE %]
117
                                    [% ELSE %]
118
                                        <option value="[% b.branchcode | html %]">[% b.branchname | html %]</option>
118
                                        <option value="[% b.branchcode | html %]">[% b.branchname | html %]</option>
(-)a/t/db_dependent/Template/Plugin/Branches.t (-7 / +1 lines)
Lines 39-45 my $builder = t::lib::TestBuilder->new; Link Here
39
39
40
subtest 'all() tests' => sub {
40
subtest 'all() tests' => sub {
41
41
42
    plan tests => 16;
42
    plan tests => 14;
43
43
44
    $schema->storage->txn_begin;
44
    $schema->storage->txn_begin;
45
45
Lines 68-79 subtest 'all() tests' => sub { Link Here
68
    $name = $plugin->GetName(undef);
68
    $name = $plugin->GetName(undef);
69
    is($name, '', 'received empty string as name of NULL/undefined library code');
69
    is($name, '', 'received empty string as name of NULL/undefined library code');
70
70
71
    $library = $plugin->GetLoggedInBranchcode();
72
    is($library, '', 'no active library if there is no active user session');
73
74
    t::lib::Mocks::mock_userenv({ branchcode => 'MYLIBRARY' });
71
    t::lib::Mocks::mock_userenv({ branchcode => 'MYLIBRARY' });
75
    $library = $plugin->GetLoggedInBranchcode();
76
    is($library, 'MYLIBRARY', 'GetLoggedInBranchcode() returns active library');
77
72
78
    t::lib::Mocks::mock_preference( 'IndependentBranches', 0 );
73
    t::lib::Mocks::mock_preference( 'IndependentBranches', 0 );
79
    my $libraries = $plugin->all();
74
    my $libraries = $plugin->all();
80
- 

Return to bug 21746