Main Koha release repository https://koha-community.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

105 lines
2.1 KiB

  1. package Koha::Template::Plugin::Desks;
  2. # Copyright (C) BULAC 2020
  3. # This file is part of Koha.
  4. #
  5. # Koha is free software; you can redistribute it and/or modify it
  6. # under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # Koha is distributed in the hope that it will be useful, but
  11. # WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with Koha; if not, see <http://www.gnu.org/licenses>.
  17. use Modern::Perl;
  18. use Template::Plugin;
  19. use base qw( Template::Plugin );
  20. use C4::Context;
  21. use Koha::Desks;
  22. =head1 NAME
  23. Koha::Template::Plugin::Desks - A module for dealing with desks in templates
  24. =head1 DESCRIPTION
  25. This plugin contains getters functions, to fetch all desks a library
  26. got or the current one.
  27. =head2 Methods
  28. =head3 GetLoggedInDeskId
  29. [% Desks.GetLoggedInDeskId %]
  30. return the desk name that is attached to the session or empty string
  31. =cut
  32. sub GetLoggedInDeskId {
  33. my ($self) = @_;
  34. return C4::Context->userenv
  35. ? C4::Context->userenv->{'desk_id'}
  36. : '';
  37. }
  38. =head3 GetLoggedInDeskName
  39. [% Desks.GetLoggedInDeskName %]
  40. Return the desk name that is attached to the session or empty string
  41. =cut
  42. sub GetLoggedInDeskName {
  43. my ($self) = @_;
  44. return C4::Context->userenv
  45. ? C4::Context->userenv->{'desk_name'}
  46. : '';
  47. }
  48. =head3 ListForLibrary
  49. [% Desks.ListForLibrary %]
  50. returns all desks existing at the current library
  51. =cut
  52. sub ListForLibrary {
  53. my ($self) = @_;
  54. my $branch_limit =
  55. C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
  56. return scalar Koha::Desks->search(
  57. { branchcode => $branch_limit },
  58. { order_by => { '-asc' => 'desk_name' } }
  59. );
  60. }
  61. =head3 all
  62. [% Desks.all %]
  63. returns all desks existing at all libraries
  64. =cut
  65. sub all {
  66. my ( $self ) = @_;
  67. return Koha::Desks->search();
  68. }
  69. 1;