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 ListForBranch |
87 |
|
73 |
|
88 |
[% Desks.all %] |
74 |
[% Desks.ListForBranch %] |
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 ListForBranch { |
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; |