When Desks are defined, a librarian can attach a desk to its session.
Test plan:
1. apply 13881 and create some desks
2. you should see “NO DESK SET” in the intranet header
3. go to circulation > Set desk
4. you should see your desk name in the header, whatever the page
5. you can also set desk with the header menu
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
use Koha::DateUtils qw(dt_from_string);
use Koha::Library::Groups;
use Koha::Libraries;
+use Koha::Desks;
use Koha::Patrons;
use Koha::Patron::Consents;
use POSIX qw/strftime/;
GoogleJackets => C4::Context->preference("GoogleJackets"),
OpenLibraryCovers => C4::Context->preference("OpenLibraryCovers"),
KohaAdminEmailAddress => "" . C4::Context->preference("KohaAdminEmailAddress"),
+ LoginDeskname => ( C4::Context->userenv ? C4::Context->userenv->{"desk_name"} : undef ),
LoginFirstname => ( C4::Context->userenv ? C4::Context->userenv->{"firstname"} : "Bel" ),
LoginSurname => C4::Context->userenv ? C4::Context->userenv->{"surname"} : "Inconnu",
emailaddress => C4::Context->userenv ? C4::Context->userenv->{"emailaddress"} : undef,
IntranetNav => C4::Context->preference("IntranetNav"),
IntranetmainUserblock => C4::Context->preference("IntranetmainUserblock"),
LibraryName => C4::Context->preference("LibraryName"),
+ LoginDeskname => ( C4::Context->userenv ? C4::Context->userenv->{"desk_name"} : undef ),
advancedMARCEditor => C4::Context->preference("advancedMARCEditor"),
canreservefromotherbranches => C4::Context->preference('canreservefromotherbranches'),
intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
opac_name => $opac_name,
LibraryName => "" . C4::Context->preference("LibraryName"),
LibraryNameTitle => "" . $LibraryNameTitle,
+ LoginDeskname => C4::Context->userenv ? C4::Context->userenv->{"desk_name"} : "",
OPACAmazonCoverImages => C4::Context->preference("OPACAmazonCoverImages"),
OPACFRBRizeEditions => C4::Context->preference("OPACFRBRizeEditions"),
OpacHighlightedWords => C4::Context->preference("OpacHighlightedWords"),
$session->param('cardnumber'), $session->param('firstname'),
$session->param('surname'), $session->param('branch'),
$session->param('branchname'), $session->param('flags'),
- $session->param('emailaddress'),
- $session->param('shibboleth')
+ $session->param('emailaddress'), $session->param('shibboleth'),
+ $session->param('desk_id'), $session->param('desk_name')
);
C4::Context::set_shelves_userenv( 'bar', $session->param('barshelves') );
C4::Context::set_shelves_userenv( 'pub', $session->param('pubshelves') );
$session->param('cardnumber'), $session->param('firstname'),
$session->param('surname'), $session->param('branch'),
$session->param('branchname'), $session->param('flags'),
- $session->param('emailaddress'), $session->param('shibboleth')
+ $session->param('emailaddress'), $session->param('shibboleth'),
+ $session->param('desk_id'), $session->param('desk_name')
);
}
$session->param('cardnumber'), $session->param('firstname'),
$session->param('surname'), $session->param('branch'),
$session->param('branchname'), $session->param('flags'),
- $session->param('emailaddress')
+ $session->param('emailaddress'), $session->param('desk_id'),
+ $session->param('desk_name')
);
my $ip = $session->param('ip');
$session->param('number'), $session->param('id'),
$session->param('cardnumber'), $session->param('firstname'),
$session->param('surname'), $session->param('branch'),
- $session->param('branchname'), $session->param('flags'),
- $session->param('emailaddress')
+ $session->param('emailaddress'), $session->param('shibboleth'),
+ $session->param('desk_id'), $session->param('desk_name')
);
return ( "ok", $cookie, $sessionID );
} else {
$session->param('cardnumber'), $session->param('firstname'),
$session->param('surname'), $session->param('branch'),
$session->param('branchname'), $session->param('flags'),
- $session->param('emailaddress')
+ $session->param('emailaddress'), $session->param('shibboleth'),
+ $session->param('desk_id'), $session->param('desk_name')
);
my $ip = $session->param('ip');
C4::Context->set_userenv($usernum, $userid, $usercnum,
$userfirstname, $usersurname,
$userbranch, $branchname, $userflags,
- $emailaddress, $shibboleth);
+ $emailaddress, $shibboleth
+ $desk_id, $desk_name);
Establish a hash of user environment variables.
#'
sub set_userenv {
shift @_;
- my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $shibboleth)=
+ my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $shibboleth, $desk_id, $desk_name)=
map { Encode::is_utf8( $_ ) ? $_ : Encode::decode('UTF-8', $_) } # CGI::Session doesn't handle utf-8, so we decode it here
@_;
my $var=$context->{"activeuser"} || '';
#possibly a law problem
"branch" => $userbranch,
"branchname" => $branchname,
+ "desk_id" => $desk_id,
+ "desk_name" => $desk_name,
"flags" => $userflags,
"emailaddress" => $emailaddress,
"shibboleth" => $shibboleth,
--- /dev/null
+package Koha::Template::Plugin::Desks;
+
+# Copyright (C) BULAC 2020
+
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
+
+use Modern::Perl;
+
+use Template::Plugin;
+use base qw( Template::Plugin );
+
+use C4::Koha;
+use C4::Context;
+use Koha::Desks;
+
+=head1 NAME
+
+Koha::Template::Plugin::Desks - A module for dealing with desks in templates
+
+=head1 DESCRIPTION
+
+This plugin contains getters functions, to fetch all desks a library
+got or the current one.
+
+=head2 Methods
+
+=head3 GetName
+
+[% Desk.GetName(desk_id) %]
+
+return desk name or empty string
+
+=cut
+
+sub GetName {
+ my ( $self, $desk_id ) = @_;
+ my $d = Koha::Desks->search( { desk_id => $desk_id} )->unblessed;
+ return @$d ? $d->{'desk_name'} : q{};
+}
+
+=head3 GetLoggedInDeskId
+
+[% Desks.GetLoggedInDeskId %]
+
+return the desk name that is attached to the session or empty string
+
+=cut
+
+sub GetLoggedInDeskId {
+ my ($self) = @_;
+
+ return C4::Context->userenv ?
+ C4::Context->userenv->{'desk_id'} :
+ '';
+}
+
+=head3 all
+
+[% Desks.all %]
+
+returns all desks existing at the library
+
+=cut
+
+sub all {
+ my ( $self, $params ) = @_;
+ my $selected = $params->{selected};
+ my $unfiltered = $params->{unfiltered} || 0;
+ my $search_params = $params->{search_params} || {};
+
+ if ( !$unfiltered ) {
+ $search_params->{only_from_group} = $params->{only_from_group} || 0;
+ }
+
+ my $desks = $unfiltered
+ ? Koha::Desks->search( $search_params, { order_by => ['desk_name'] } )->unblessed
+ : Koha::Desks->search_filtered( $search_params, { order_by => ['desk_name'] } )->unblessed;
+
+ for my $d ( @$desks ) {
+ if ( defined $selected and $d->{desk_id} eq $selected
+ or not defined $selected and C4::Context->userenv and $d->{branchcode} eq ( C4::Context->userenv->{desk_id} // q{} )
+ ) {
+ $d->{selected} = 1;
+ }
+ }
+
+ return $desks;
+}
+
+=head3 defined
+
+[% Desks.defined %]
+
+return 1 if there is at least a desk defined for the library.
+
+=cut
+
+sub defined {
+ my ( $self ) = @_;
+ my $desks = Koha::Desks->search()->unblessed;
+ if (@$desks) {
+ return 1 ;
+ }
+ else {
+ return 0;
+ }
+}
+
+1;
--- /dev/null
+#!/usr/bin/perl
+
+# Copyright (C) 2020 BULAC
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
+
+use Modern::Perl;
+use CGI qw ( -utf8 );
+
+use C4::Context;
+use C4::Output;
+use C4::Auth qw/:DEFAULT get_session/;
+use C4::Koha;
+use Koha::Desks;
+
+my $query = CGI->new();
+
+my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
+ {
+ template_name => "circ/selectdesk.tt",
+ query => $query,
+ type => "intranet",
+ debug => 1,
+ authnotrequired => 0,
+ flagsrequired => { catalogue => 1, },
+ }
+);
+
+my $sessionID = $query->cookie("CGISESSID");
+my $session = get_session($sessionID);
+
+my $branch = C4::Context->userenv->{'branch'};
+my $searchfield = $query->param('searchfield');
+my $desks_lists;
+if ($branch) {
+ $desks_lists = Koha::Desks->search( { branchcode => $branch } )->unblessed;
+}
+else {
+ $desks_lists = Koha::Desks->search( )->unblessed;
+}
+
+my $desk_id = $query->param('desk_id');
+
+my $userenv_desk = C4::Context->userenv->{'desk_id'} || '';
+my $updated = '';
+
+if ($desk_id) {
+ if ( !$userenv_desk or $userenv_desk ne $desk_id ) {
+ my $desk = Koha::Desks->find( { desk_id => $desk_id } );
+ $template->param( LoginDeskname => $desk->desk_name );
+ $template->param( LoginDeskid => $desk->desk_id );
+ $session->param( desk_name => $desk->desk_name );
+ $session->param( desk_id => $desk->desk_id );
+ $updated = 1;
+ }
+}
+else {
+ $desk_id = $userenv_desk;
+}
+
+$template->param( updated => \$updated );
+
+my $referer = $query->param('oldreferer') || $ENV{HTTP_REFERER};
+if ($updated) {
+ print $query->redirect( $referer || '/cgi-bin/koha/mainpage.pl' );
+}
+
+$template->param(
+ referer => $referer,
+ desks_list => $desks_lists,
+ desk_id => $desk_id,
+);
+
+output_html_with_http_headers $query, $cookie, $template->output;
[% USE Branches %]
+[% USE Desks %]
<div id="navmenu">
<div id="navmenulist">
[% IF ( AutoLocation ) %][% ELSE %][% IF ( IndependentBranches ) %][% ELSE %]
<li><a href="/cgi-bin/koha/circ/set-library.pl">Set library</a></li>
[% END %][% END %]
+ [% IF ( Desks.defined ) %]
+ <li><a href="/cgi-bin/koha/circ/selectdesk.pl">Set desk</a></li>
+ [% END %]
[% IF ( fast_cataloging ) %][% IF ( CAN_user_editcatalogue_fast_cataloging ) %]
<li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?frameworkcode=FA">Fast cataloging</a></li>
[% END %][% END %]
[% USE raw %]
[% USE Branches %]
+[% USE Desks %]
[% USE Koha %]
<nav class="navbar">
<div class="navbar-header">
<span class="logged-in-branch-code content_hidden">[% Branches.GetLoggedInBranchcode | html %]</span>
</strong>
[% END %]
+ [% IF (Desks.defined) %]
+ <span class="separator">|</span>
+ <strong>
+ [% IF ( LoginDeskname == '') %]
+ <span class="logged-in-desk-name">NO DESK SET</span>
+ [% ELSE %]
+ <span class="logged-in-desk-name">[% LoginDeskname | html %]</span>
+ <span class="logged-in-desk-id content_hidden">[% Desks.GetLoggedInDeskId | html %]</span>
+ [% END %]
+ </strong>
+ [% END %]
</span>
<b class="caret"></b>
</a>
<a class="toplinks" href="/cgi-bin/koha/circ/set-library.pl">Set library</a>
</li>
[% END %]
+ [% IF Desks.defined %]
+ <li>
+ <a class="toplinks" href="/cgi-bin/koha/circ/selectdesk.pl">Set desk</a>
+ </li>
+ [% END %]
[% IF EnableSearchHistory %]
<li>
<a class="toplinks" href="/cgi-bin/koha/catalogue/search-history.pl">Search history</a>
[% USE raw %]
[% USE Koha %]
[% USE Branches %]
+[% USE Desks %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha › Circulation</title>
[% INCLUDE 'doc-head-close.inc' %]
<a class="circ-button" href="/cgi-bin/koha/circ/set-library.pl"><i class="fa fa-home"></i> Set library</a>
</li>
[% END %]
+ [% IF Desks.defined %]
+ <li>
+ <a class="circ-button" href="/cgi-bin/koha/circ/selectdesk.pl"><i class="fa fa-location-arrow"></i> Set desk</a>
+ </li>
+ [% END %]
[% IF ( fast_cataloging ) %]
[% IF ( CAN_user_editcatalogue_fast_cataloging ) %]
<li>
--- /dev/null
+[% USE Koha %]
+
+[% INCLUDE 'doc-head-open.inc' %]
+<title>Koha › Circulation › Set Desk</title>
+[% INCLUDE 'doc-head-close.inc' %]
+</head>
+<body id="circ_selectdesk" class="circ">
+[% INCLUDE 'header.inc' %]
+[% INCLUDE 'circ-search.inc' %]
+
+<div id="breadcrumbs">
+ <a href="/cgi-bin/koha/mainpage.pl">Home</a>
+› <a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a>
+› <a href="/cgi-bin/koha/circ/selectdesk.pl">Set Desk</a>
+</div>
+
+<div class="main container-fluid">
+ <div class="row">
+ <div class="col-sm-12">
+ <main>
+ <div class="row">
+
+ [% IF Koha.Preference('CircSidebar') %]
+ <div class="col-sm-10 col-sm-push-2">
+ [% ELSE %]
+ <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
+ [% END %]
+
+<form method="post" action="selectdesk.pl">
+ <fieldset class="rows">
+ <legend>Set desk</legend>
+ <ol>
+ <li><label for="desk">Choose desk:</label>
+ <select name="desk_id" id="desk_id">
+ [% FOREACH desk IN desks_list %]
+ <option value="[% desk.desk_id|html %]">[% desk.desk_name|html %]</option>
+ [% END %]
+ </select>
+ </li>
+ </ol>
+ </fieldset>
+ <fieldset class="action">
+ <input type="submit" value="Submit" />
+ <a class="cancel" id="cancel_set_desk" href="[% referer or '/cgi-bin/koha/circ/circulation.pl'|html %]">Cancel</a>
+ </fieldset>
+ <input type="hidden" name="oldreferer" value="[% referer or "/cgi-bin/koha/mainpage.pl" |html %]" />
+ </form>
+
+ </div> <!-- /.col-sm-10.col-sm-push-2 -->
+ [% IF Koha.Preference('CircSidebar') %]
+ <div class="col-sm-2 col-sm-pull-10">
+ <aside>
+ [% INCLUDE 'circ-nav.inc' %]
+ </aside>
+ </div> <!-- /.col-sm-2.col-sm-pull-10 -->
+ [% END %]
+ </div> <!-- /.row -->
+ </main>
+ </div> <!-- /.col-sm-12 -->
+ </div> <!-- /.row -->
+
+[% INCLUDE 'intranet-bottom.inc' %]