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

(-)a/Koha/Template/Plugin/Desks.pm (-64 / +16 lines)
Lines 37-56 got or the current one. Link Here
37
37
38
=head2 Methods
38
=head2 Methods
39
39
40
=head3 GetName
41
42
[% Desk.GetName(desk_id) %]
43
44
return desk name or empty string
45
46
=cut
47
48
sub GetName {
49
    my ( $self, $desk_id ) = @_;
50
    my $d = Koha::Desks->search( { desk_id => $desk_id} )->unblessed;
51
    return @$d ? $d->{'desk_name'} : q{};
52
}
53
54
=head3 GetLoggedInDeskId
40
=head3 GetLoggedInDeskId
55
41
56
[% Desks.GetLoggedInDeskId %]
42
[% Desks.GetLoggedInDeskId %]
Lines 62-70 return the desk name that is attached to the session or empty string Link Here
62
sub GetLoggedInDeskId {
48
sub GetLoggedInDeskId {
63
    my ($self) = @_;
49
    my ($self) = @_;
64
50
65
    return C4::Context->userenv ?
51
    return C4::Context->userenv
66
        C4::Context->userenv->{'desk_id'} :
52
      ? C4::Context->userenv->{'desk_id'}
67
        '';
53
      : '';
68
}
54
}
69
55
70
=head3 GetLoggedInDeskName
56
=head3 GetLoggedInDeskName
Lines 78-138 Return the desk name that is attached to the session or empty string Link Here
78
sub GetLoggedInDeskName {
64
sub GetLoggedInDeskName {
79
    my ($self) = @_;
65
    my ($self) = @_;
80
66
81
    return C4::Context->userenv ?
67
    return C4::Context->userenv
82
        C4::Context->userenv->{'desk_name'} :
68
      ? C4::Context->userenv->{'desk_name'}
83
        '';
69
      : '';
84
}
70
}
85
71
86
=head3 all
72
=head3 ListForLibrary
87
73
88
[% Desks.all %]
74
[% Desks.ListForLibrary %]
89
75
90
returns all desks existing at the library
76
returns all desks existing at the library
91
77
92
=cut
78
=cut
93
79
94
sub all {
80
sub ListForLibrary {
95
    my ( $self, $params ) = @_;
81
    my ($self) = @_;
96
    my $selected = $params->{selected};
82
    my $branch_limit =
97
    my $unfiltered = $params->{unfiltered} || 0;
83
      C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
98
    my $search_params = $params->{search_params} || {};
84
    return scalar Koha::Desks->search(
99
85
        { branchcode => $branch_limit },
100
    if ( !$unfiltered ) {
86
        { order_by   => { '-asc' => 'desk_name' } }
101
        $search_params->{only_from_group} = $params->{only_from_group} || 0;
87
    );
102
    }
103
104
    my $desks = $unfiltered
105
      ? Koha::Desks->search( $search_params, { order_by => ['desk_name'] } )->unblessed
106
      : Koha::Desks->search_filtered( $search_params, { order_by => ['desk_name'] } )->unblessed;
107
108
    for my $d ( @$desks ) {
109
        if (       defined $selected and $d->{desk_id} eq $selected
110
            or not defined $selected and C4::Context->userenv and $d->{branchcode} eq ( C4::Context->userenv->{desk_id} // q{} )
111
        ) {
112
            $d->{selected} = 1;
113
        }
114
    }
115
116
    return $desks;
117
}
118
119
=head3 defined
120
121
[% Desks.defined %]
122
123
return 1 if there is at least a desk defined for the library.
124
125
=cut
126
127
sub defined {
128
    my ( $self ) = @_;
129
    my $desks = Koha::Desks->search()->unblessed;
130
    if (@$desks) {
131
        return 1 ;
132
    }
133
    else {
134
        return 0;
135
    }
136
}
88
}
137
89
138
1;
90
1;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc (-1 / +1 lines)
Lines 18-24 Link Here
18
            [% IF ( AutoLocation ) %][% ELSE %][% IF ( IndependentBranches ) %][% ELSE %]
18
            [% IF ( AutoLocation ) %][% ELSE %][% IF ( IndependentBranches ) %][% ELSE %]
19
                <li><a href="/cgi-bin/koha/circ/set-library.pl">Set library</a></li>
19
                <li><a href="/cgi-bin/koha/circ/set-library.pl">Set library</a></li>
20
            [% END %][% END %]
20
            [% END %][% END %]
21
            [% IF ( Desks.defined ) %]
21
            [% IF Desks.ListForLibrary.count %]
22
                <li><a href="/cgi-bin/koha/circ/selectdesk.pl">Set desk</a></li>
22
                <li><a href="/cgi-bin/koha/circ/selectdesk.pl">Set desk</a></li>
23
            [% END %]
23
            [% END %]
24
            [% IF ( fast_cataloging ) %][% IF ( CAN_user_editcatalogue_fast_cataloging ) %]
24
            [% IF ( fast_cataloging ) %][% IF ( CAN_user_editcatalogue_fast_cataloging ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc (-3 / +3 lines)
Lines 86-92 Link Here
86
                                <span class="logged-in-branch-code content_hidden">[% Branches.GetLoggedInBranchcode | html %]</span>
86
                                <span class="logged-in-branch-code content_hidden">[% Branches.GetLoggedInBranchcode | html %]</span>
87
                            </strong>
87
                            </strong>
88
                        [% END %]
88
                        [% END %]
89
                        [% IF (Desks.defined) %]
89
                        [% IF Desks.ListForLibrary.count %]
90
                            <span class="separator">|</span>
90
                            <span class="separator">|</span>
91
                            <strong>
91
                            <strong>
92
                                [% IF ( Desks.GetLoggedInDeskName == '' ) %]
92
                                [% IF ( Desks.GetLoggedInDeskName == '' ) %]
Lines 119-125 Link Here
119
                    </li>
119
                    </li>
120
                    <li class="loggedin-menu-label">
120
                    <li class="loggedin-menu-label">
121
                        Desk: <br />
121
                        Desk: <br />
122
                        [% IF ( Desks.GetLoggedInDeskName == '' AND Desks.defined ) %]
122
                        [% IF ( Desks.GetLoggedInDeskName == '' AND Desks.ListForLibrary.count ) %]
123
                           <span class="logged-in-desk-name">NO DESK SET</span>
123
                           <span class="logged-in-desk-name">NO DESK SET</span>
124
                        [% ELSIF ( Desks.GetLoggedInDeskName != '' ) %]
124
                        [% ELSIF ( Desks.GetLoggedInDeskName != '' ) %]
125
                            <span class="logged-in-desk-name">[% Desks.GetLoggedInDeskName | html %]</span>
125
                            <span class="logged-in-desk-name">[% Desks.GetLoggedInDeskName | html %]</span>
Lines 139-145 Link Here
139
                        <a class="toplinks" href="/cgi-bin/koha/circ/set-library.pl">Set library</a>
139
                        <a class="toplinks" href="/cgi-bin/koha/circ/set-library.pl">Set library</a>
140
                    </li>
140
                    </li>
141
                    [% END %]
141
                    [% END %]
142
                    [% IF Desks.defined %]
142
                    [% IF Desks.ListForLibrary.count %]
143
                    <li>
143
                    <li>
144
                        <a class="toplinks" href="/cgi-bin/koha/circ/selectdesk.pl">Set desk</a>
144
                        <a class="toplinks" href="/cgi-bin/koha/circ/selectdesk.pl">Set desk</a>
145
                    </li>
145
                    </li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt (-1 / +1 lines)
Lines 34-40 Link Here
34
                            <a class="circ-button" href="/cgi-bin/koha/circ/set-library.pl"><i class="fa fa-home"></i> Set library</a>
34
                            <a class="circ-button" href="/cgi-bin/koha/circ/set-library.pl"><i class="fa fa-home"></i> Set library</a>
35
                        </li>
35
                        </li>
36
                    [% END %]
36
                    [% END %]
37
                    [% IF Desks.defined %]
37
                    [% IF Desks.ListForLibrary.count %]
38
                        <li>
38
                        <li>
39
                            <a class="circ-button" href="/cgi-bin/koha/circ/selectdesk.pl"><i class="fa fa-location-arrow"></i> Set desk</a>
39
                            <a class="circ-button" href="/cgi-bin/koha/circ/selectdesk.pl"><i class="fa fa-location-arrow"></i> Set desk</a>
40
                        </li>
40
                        </li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/set-library.tt (-1 / +1 lines)
Lines 63-68 Updated:<ul> Link Here
63
        <li><label for="branch">Choose library:</label>
63
        <li><label for="branch">Choose library:</label>
64
        <select name="branch" id="branch">
64
        <select name="branch" id="branch">
65
            [% PROCESS options_for_libraries libraries => Branches.all( selected => branch ) %]
65
            [% PROCESS options_for_libraries libraries => Branches.all( selected => branch ) %]
66
                        [% PROCESS options_for_yallah yallah => Branches.all( selected => branch ) %]
66
        </select></li>
67
        </select></li>
67
    [% END %]
68
    [% END %]
68
    </ol>
69
    </ol>
69
- 

Return to bug 24201