C4::Context->_unset_userenv($sessionID);
}
my ( $borrowernumber, $firstname, $surname, $userflags,
- $branchcode, $branchname, $emailaddress );
+ $branchcode, $branchname, $emailaddress, $desk_id, $desk_name );
if ( $return == 1 ) {
my $select = "
my $library = Koha::Libraries->find($branchcode);
$branchname = $library? $library->branchname: '';
}
+ if ( $query->param('desk_id') ) {
+ $desk_id = $query->param('desk_id');
+ my $desk = Koha::Desks->find($desk_id);
+ $desk_name = $desk ? $desk->desk_name : '';
+ }
my $branches = { map { $_->branchcode => $_->unblessed } Koha::Libraries->search };
if ( $type ne 'opac' and C4::Context->boolean_preference('AutoLocation') ) {
$session->param( 'surname', $surname );
$session->param( 'branch', $branchcode );
$session->param( 'branchname', $branchname );
+ $session->param( 'desk_id', $desk_id);
+ $session->param( 'desk_name', $desk_name);
$session->param( 'flags', $userflags );
$session->param( 'emailaddress', $emailaddress );
$session->param( 'ip', $session->remote_addr() );
$session->param('surname'), $session->param('branch'),
$session->param('branchname'), $session->param('flags'),
$session->param('emailaddress'), $session->param('shibboleth'),
- $session->param('desk_id'), $session->param('desk_name')
+ $session->param('desk_id'), $session->param('desk_name')
);
}
[% Desks.ListForLibrary %]
-returns all desks existing at the library
+returns all desks existing at the current library
=cut
);
}
+=head3 all
+
+[% Desks.all %]
+
+returns all desks existing at all libraries
+
+=cut
+
+
+sub all {
+
+ my ( $self ) = @_;
+ return Koha::Desks->search( )->unblessed;
+}
+
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 C4::Koha;
use Koha::BiblioFrameworks;
use Koha::Libraries;
+use Koha::Desks;
my $query = CGI->new();
my $session = get_session($sessionID);
my $branch = $query->param('branch' );
+my $desk_id = $query->param('desk_id');
my $userenv_branch = C4::Context->userenv->{'branch'} || '';
+my $userenv_desk = C4::Context->userenv->{'desk_id'} || '';
my @updated;
# $session lddines here are doing the updating
new_branch => $branch,
};
} # else branch the same, no update
+ if ( $desk_id && (!$userenv_desk or $userenv_desk ne $desk_id) ) {
+ my $desk = Koha::Desks->find( { desk_id => $desk_id } );
+ my $old_desk_name = '';
+ if ($userenv_desk) {
+ $old_desk_name = Koha::Desks->find( { desk_id => $userenv_desk })->desk_name;
+ }
+ $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 );
+ $session->flush();
+ push @updated, {
+ updated_desk => 1,
+ old_desk => $old_desk_name,
+ };
+ }
} else {
$branch = $userenv_branch; # fallback value
+ $desk_id = $userenv_desk;
}
$template->param(updated => \@updated) if (scalar @updated);
foreach ($query->param()) {
$_ or next; # disclude blanks
$_ eq "branch" and next; # disclude branch
+ $_ eq "desk_id" and next; # disclude desk_id
$_ eq "oldreferer" and next; # disclude oldreferer
push @recycle_loop, {
param => $_,
$template->param(
referer => $referer,
branch => $branch,
+ desk_id => $desk_id,
recycle_loop=> \@recycle_loop,
);
[% 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.ListForLibrary.count %]
- <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 %]
<a class="toplinks" href="/cgi-bin/koha/circ/set-library.pl">Set library</a>
</li>
[% END %]
- [% IF Desks.ListForLibrary.count %]
- <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>
[% END %]
[% END %]
+[% BLOCK options_for_desks %]
+ <option id="nodesk" value="">---</option>
+ [% FOREACH d IN desks %]
+ [% IF d.branchcode == branch %]
+ <option class="[% d.branchcode | html %]" value="[% d.desk_id | html %]" >[% d.desk_name | html %]</option>
+ [% ELSE %]
+ <option class="[% d.branchcode | html %]" value="[% d.desk_id | html %]" disabled hidden>[% d.desk_name | html %]</option>
+ [% END%]
+ [% END %]
+ [% END %]
+
[% BLOCK options_for_authorised_value_categories %]
[% FOREACH avc IN authorised_value_categories %]
[% IF avc.selected %]
[% jsinclude | $raw # Parse the page template's JavaScript block if necessary %]
[% END %]
[% KohaPlugins.get_plugins_intranet_js | $raw %]
+
</body>
</html>
[% Asset.js("lib/jquery/plugins/jquery.validate.min.js") | $raw %]
<!-- koha core js -->
[% Asset.js("js/staff-global.js") | $raw %]
+[% IF setdesk %]
+[% Asset.js("js/desk_selection.js") | $raw %]
+[% END %]
[% INCLUDE 'validator-strings.inc' %]
[% IF ( IntranetUserJS ) %]
[% USE raw %]
[% USE Koha %]
[% USE Branches %]
+[% USE Desks %]
[% USE Categories %]
[% SET footerjs = 1 %]
+[% IF Desks.all %]
+ [% SET setdesk = 1 %]
+[% END %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha ›
[% IF ( nopermission ) %]Access denied[% END %]
[% END %]
</select>
</p>
+ [% IF Desks.all %]
+ <p>
+ <label for="desk">Desk:</label>
+ <select name="desk_id" id="desk_id" class="input" tabindex="3">
+ <option id="nodesk" value="">---</option>
+ [% FOREACH d IN Desks.all %]
+ <option class="[% d.branchcode | html %]" value="[% d.desk_id | html %]" disabled >[% d.desk_name | html %]</option>
+ [% END %]
+ </select>
+ </p>
+</fieldset>
+[% END %]
[% END %]
<!-- <p><label><input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="3" />Remember me</label></p> -->
[% 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.ListForLibrary.count %]
- <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>
[% USE Branches %]
+[% USE Desks %]
[% USE Koha %]
+[% IF Desks.all %]
+ [% SET setdesk = 1 %]
+[% END %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha › Circulation › Set library</title>
[% INCLUDE 'doc-head-close.inc' %]
[% FOREACH update IN updated %]
[% IF ( update.updated_branch ) %]
<li>Library: [% update.old_branch or "?" | html %] ⇒ [% update.new_branch or "?" | html %]</li>
+ [% ELSIF (update.updated_desk) %]
+ <li>Desk: [% update.old_desk or "?" | html %] ⇒ [% LoginDeskname or "?" | html %]</li>
[% ELSE %]
<li>ERROR - unknown</li>
[% END %]
<li><label for="branch">Choose library:</label>
<select name="branch" id="branch">
[% PROCESS options_for_libraries libraries => Branches.all( selected => branch ) %]
- [% PROCESS options_for_yallah yallah => Branches.all( selected => branch ) %]
</select></li>
[% END %]
</ol>
</fieldset>
+[% IF Desks.all %]
+<fieldset class="rows">
+ <legend>Set Desk</legend>
+ <ol>
+ <li><label for="desk">Choose Desk:</label>
+ <select name="desk_id" id="desk_id">
+ [% PROCESS options_for_desks desks => Desks.all( selected => desk_id ) %]
+ </select></li>
+ </ol>
+</fieldset>
+[% END %]
<fieldset class="action">
<input type="submit" value="Submit" />
<a class="cancel" id="cancel_set_library" href="[% referer or '/cgi-bin/koha/circ/circulation.pl' %]">Cancel</a>
--- /dev/null
+$(document).ready(function() {
+ $("#desk_id").children().each(function() {
+ var selectedBranch = $("#branch"). children("option:selected"). val();
+ if ($(this).attr('id') === "nodesk") { //set no desk by default, should be first element
+ $(this).prop("selected", true);
+ $(this).prop("disabled", false);
+ $(this).show();
+ }
+ else if ($(this).hasClass(selectedBranch)) {
+ $('#nodesk').prop("disabled", true); // we have desk, no need for nodesk option
+ $('#nodesk').hide();
+ $(this).prop("disabled", false);
+ $(this).show();
+ $(this).prop("selected", true)
+ } else {
+ $(this).prop("disabled", true);
+ $(this).hide();
+ }
+ });
+
+ $("#branch").on("change", function() {
+
+ $("#desk_id").children().each(function() {
+ var selectedBranch = $("#branch"). children("option:selected"). val();
+ if ($(this).attr('id') === "nodesk") { //set no desk by default, should be first element
+ $(this).prop("selected", true);
+ $(this).prop("disabled", false);
+ $(this).show();
+ }
+ else if ($(this).hasClass(selectedBranch)) {
+ $('#nodesk').prop("disabled", true); // we have desk, no need for nodesk option
+ $('#nodesk').hide();
+ $(this).prop("disabled", false);
+ $(this).show();
+ $(this).prop("selected", true)
+ } else {
+ $(this).prop("disabled", true);
+ $(this).hide();
+ }
+ });
+ });
+}) ;