Bugzilla – Attachment 93454 Details for
Bug 13881
Add ability to defined circulation desks
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13881: Add desk management
Bug-13881-Add-desk-management.patch (text/plain), 18.77 KB, created by
Nicolas Legrand
on 2019-10-02 12:53:22 UTC
(
hide
)
Description:
Bug 13881: Add desk management
Filename:
MIME Type:
Creator:
Nicolas Legrand
Created:
2019-10-02 12:53:22 UTC
Size:
18.77 KB
patch
obsolete
>From dfca3e35e87f307ac00c30de0de8d41d8707b848 Mon Sep 17 00:00:00 2001 >From: Nicolas Legrand <nicolas.legrand@bulac.fr> >Date: Wed, 2 Oct 2019 14:09:21 +0200 >Subject: [PATCH] Bug 13881: Add desk management > >Add a desk and linked it to a library (branch). That's it. In the >future it'll have super features like being able to link waiting >reserve to a specific desk. > >Test plan: > >1. go to the administration page and notice there isn't any mention of >desk whatsoever >2. apply patches >3. ./installer/data/mysql/updatedatabase.pl >4. you now have desks links in admin-home and admin-menu >5. click the link >6. add a desk >7. add another one >8. delete one >9. you should have a fair list of all current desks defined >10. Done >--- > Koha/Desk.pm | 44 +++++ > Koha/Desks.pm | 50 ++++++ > admin/desks.pl | 116 ++++++++++++ > .../intranet-tmpl/prog/en/includes/admin-menu.inc | 1 + > .../prog/en/includes/desks-admin-search.inc | 31 ++++ > .../prog/en/modules/admin/admin-home.tt | 2 + > .../intranet-tmpl/prog/en/modules/admin/desks.tt | 195 +++++++++++++++++++++ > 7 files changed, 439 insertions(+) > create mode 100644 Koha/Desk.pm > create mode 100644 Koha/Desks.pm > create mode 100755 admin/desks.pl > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/desks-admin-search.inc > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/admin/desks.tt > >diff --git a/Koha/Desk.pm b/Koha/Desk.pm >new file mode 100644 >index 0000000..831d67a >--- /dev/null >+++ b/Koha/Desk.pm >@@ -0,0 +1,44 @@ >+package Koha::Desk; >+ >+# 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, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use Carp; >+ >+use Koha::Database; >+ >+use base qw(Koha::Object); >+ >+=head1 NAME >+ >+Koha::Desk - Koha Desk Object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'Desk'; >+} >+ >+1; >diff --git a/Koha/Desks.pm b/Koha/Desks.pm >new file mode 100644 >index 0000000..1485dec >--- /dev/null >+++ b/Koha/Desks.pm >@@ -0,0 +1,50 @@ >+package Koha::Desks; >+ >+# 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, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use Carp; >+ >+use Koha::Database; >+ >+use Koha::Desk; >+ >+use base qw(Koha::Objects); >+ >+=head1 NAME >+ >+Koha::Desks - Koha Desk Object set class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'Desk'; >+} >+ >+sub object_class { >+ return 'Koha::Desk'; >+} >+ >+1; >diff --git a/admin/desks.pl b/admin/desks.pl >new file mode 100755 >index 0000000..34e98be >--- /dev/null >+++ b/admin/desks.pl >@@ -0,0 +1,116 @@ >+#! /usr/bin/perl >+ >+# Copyright 2006 SAN OUEST-PROVENCE et Paul POULAIN >+# Copyright 2015 Koha Development Team >+# >+# 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::Auth; >+use C4::Output; >+ >+use Koha::Desks; >+ >+my $input = new CGI; >+my $searchfield = $input->param('desk_name') // q||; >+my $desk_id = $input->param('desk_id') || ''; >+my $op = $input->param('op') || 'list'; >+my @messages; >+ >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { template_name => "admin/desks.tt", >+ query => $input, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => { parameters => 'manage_desks' }, >+ debug => 1, >+ } >+); >+ >+my $branches = Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed; >+ >+if ( $op eq 'add_form' ) { >+ my $desk; >+ if ($desk_id) { >+ $desk = Koha::Desks->find($desk_id); >+ } >+ >+ $template->param( desk => $desk, ); >+} elsif ( $op eq 'add_validate' ) { >+ my $desk_id = $input->param('desk_id'); >+ my $desk_name = $input->param('desk_name'); >+ my $branchcode = $input->param('branchcode'); >+ >+ if (Koha::Desks->find($desk_id)) { >+ my $desk = Koha::Desks->find($desk_id); >+ $desk->desk_name($desk_name); >+ $desk->branchcode($branchcode); >+ eval { $desk->store; }; >+ if ($@) { >+ push @messages, { type => 'error', code => 'error_on_update' }; >+ } else { >+ push @messages, { type => 'message', code => 'success_on_update' }; >+ } >+ } else { >+ my $desk = Koha::Desk->new( >+ { >+ desk_id => $desk_id, >+ desk_name => $desk_name, >+ branchcode => $branchcode, >+ } >+ ); >+ eval { $desk->store; }; >+ if ($@) { >+ push @messages, { type => 'error', code => 'error_on_insert' }; >+ } else { >+ push @messages, { type => 'message', code => 'success_on_insert' }; >+ } >+ } >+ $searchfield = q||; >+ $op = 'list'; >+} elsif ( $op eq 'delete_confirm' ) { >+ my $desk = Koha::Desks->find($desk_id); >+ $template->param( desk => $desk, ); >+} elsif ( $op eq 'delete_confirmed' ) { >+ my $desk = Koha::Desks->find($desk_id); >+ my $deleted = eval { $desk->delete; }; >+ >+ if ( $@ or not $deleted ) { >+ push @messages, { type => 'error', code => 'error_on_delete' }; >+ } else { >+ push @messages, { type => 'message', code => 'success_on_delete' }; >+ } >+ $op = 'list'; >+} >+ >+if ( $op eq 'list' || ! $op) { >+ my $desks = Koha::Desks->search( { desk_name => { -like => "%$searchfield%" } } ); >+ $template->param( desks => $desks, ); >+} >+ >+use Data::Dumper; >+ >+$template->param( >+ desk_id => $desk_id, >+ searchfield => $searchfield, >+ messages => \@messages, >+ op => $op, >+ branches => $branches, >+); >+ >+output_html_with_http_headers $input, $cookie, $template->output; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc >index 1578c2d..bd755c0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc >@@ -16,6 +16,7 @@ > [% IF ( CAN_user_parameters_manage_libraries ) %] > <li><a href="/cgi-bin/koha/admin/branches.pl">Libraries</a></li> > <li><a href="/cgi-bin/koha/admin/library_groups.pl">Library groups</a></li> >+ <li><a href="/cgi-bin/koha/admin/desks.pl">Desks</a></li> > [% END %] > [% IF ( CAN_user_parameters_manage_itemtypes ) %] > <li><a href="/cgi-bin/koha/admin/itemtypes.pl">Item types</a></li> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/desks-admin-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/desks-admin-search.inc >new file mode 100644 >index 0000000..53a4315 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/desks-admin-search.inc >@@ -0,0 +1,31 @@ >+[% USE Koha %] >+<div class="gradient"> >+<h1 id="logo"><a href="/cgi-bin/koha/mainpage.pl">[% LibraryName %]</a></h1><!-- Begin Desks Resident Search Box --> >+<div id="header_search"> >+ <div id="desk_search" class="residentsearch"> >+ <p class="tip">Desk search:</p> >+ <form action="[% script_name %]" method="post"> >+ <input class="head-searchbox" type="text" name="desk_name" value="[% searchfield %]" size="40" /> >+ <input type="submit" name="submit" value="OK" class="submit" /> >+ </form> >+ </div> >+ >+ [% INCLUDE 'patron-search-box.inc' %] >+ >+ [% IF ( CAN_user_catalogue ) %] >+ <div id="catalog_search" class="residentsearch"> >+ <p class="tip">Enter search keywords:</p> >+ <form action="/cgi-bin/koha/catalogue/search.pl" method="get" id="cat-search-block"> >+ [% IF ( Koha.Preference('IntranetCatalogSearchPulldown') ) %][% INCLUDE 'search_indexes.inc' %][% END %] >+ <input type="text" name="q" id="search-form" size="40" value="" title="Enter the terms you wish to search for." class="head-searchbox form-text" /> >+ <input type="submit" value="Submit" class="submit" /> >+ </form> >+ </div>[% END %] >+ <ul> >+ <li><a class="keep_text" href="#desk_search">Search desks</a></li> >+ [% IF ( CAN_user_circulate_circulate_remaining_permissions ) %]<li><a class="keep_text" href="#circ_search">Check out</a></li>[% END %] >+ [% IF ( CAN_user_catalogue ) %]<li><a class="keep_text" href="#catalog_search">Search the catalog</a></li>[% END %] >+ </ul> >+</div> >+</div> >+<!-- End Desks Resident Search Box --> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt >index 4095e51..9542c01 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt >@@ -54,6 +54,8 @@ > <dd>Define libraries.</dd> > <dt><a href="/cgi-bin/koha/admin/library_groups.pl">Library groups</a></dt> > <dd>Define hierarchical library groups.</dd> >+ <dt><a href="/cgi-bin/koha/admin/desks.pl">Desks</a></dt> >+ <dd>Define desks.</dd> > [% END %] > [% IF ( CAN_user_parameters_manage_itemtypes ) %] > <dt><a href="/cgi-bin/koha/admin/itemtypes.pl">Item types</a></dt> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/desks.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/desks.tt >new file mode 100644 >index 0000000..f66cf6c >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/desks.tt >@@ -0,0 +1,195 @@ >+[% USE raw %] >+[% USE Branches %] >+[% USE Asset %] >+[% SET footerjs = 1 %] >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Koha › Administration › [% IF op =='add_form' %]Desks › [% IF desk.desk_id %] Modify desk[% ELSE %] New desk[% END %][% ELSE %][% IF op == 'delete_confirm' %]Desks › Confirm deletion of desk[% ELSE %] Desks[% END %][% END %]</title> >+[% INCLUDE 'doc-head-close.inc' %] >+</head> >+ >+<body id="admin_desks" class="admin"> >+[% INCLUDE 'header.inc' %] >+[% INCLUDE 'desks-admin-search.inc' %] >+ >+<div id="breadcrumbs"> >+ <a href="/cgi-bin/koha/mainpage.pl">Home</a> >+ › <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> >+ › <a href="/cgi-bin/koha/admin/desks.pl">Desks</a> >+ [% IF op == 'add_form' %] >+ › [% IF desk.desk_id %]Modify[% ELSE %]New[% END %] Desk >+ [% ELSIF op == 'delete_confirm' %] >+ › Confirm deletion of desk >+ [% END %] >+</div> >+ >+<div class="main container-fluid"> >+ <div class="row"> >+ <div class="col-sm-10 col-sm-push-2"> >+ <main> >+ >+[% FOR m IN messages %] >+ <div class="dialog [% m.type | html %]"> >+ [% SWITCH m.code %] >+ [% CASE 'error_on_update' %] >+ An error occurred when updating this desk. Perhaps it already exists. >+ [% CASE 'error_on_insert' %] >+ An error occurred when adding this desk. The desk id might already exist. >+ [% CASE 'error_on_delete' %] >+ An error occurred when deleting this desk. Check the logs. >+ [% CASE 'success_on_update' %] >+ Desk updated successfully. >+ [% CASE 'success_on_insert' %] >+ Desk added successfully. >+ [% CASE 'success_on_delete' %] >+ Desk deleted successfully. >+ [% CASE 'already_exists' %] >+ This desk already exists. >+ [% CASE %] >+ [% m.code | html %] >+ [% END %] >+ </div> >+[% END %] >+ >+[% IF op == 'add_form' %] >+ [% IF desk %] >+ <h1>Modify a desk</h1> >+ [% ELSE %] >+ <h1>New desk</h1> >+ [% END %] >+ >+ <form action="/cgi-bin/koha/admin/desks.pl" name="Aform" method="post" class="validated"> >+ <input type="hidden" name="op" value="add_validate" /> >+ [% IF desk_id %] >+ <input type="hidden" name="desk_id" value="[% desk.desk_id | html %]" /> >+ [% END %] >+ <fieldset class="rows"> >+ <ol> >+ [% IF desk_id %] >+ <li><span class="label">Desk ID: </span>[% desk.desk_id | html %]</li> >+ [% ELSE %] >+ <li> >+ <label for="desk_name" class="required">Desk ID:</label> >+ <input type="text" name="desk_id" id="deskdi" size="11" maxlength="11" value="[% desk.desk_id | html %]" required="required" class="required" /> <span class="required">Required</span> >+ [% END %] >+ <li> >+ <label for="desk_name" class="required">Desk: </label> >+ <input type="text" name="desk_name" id="desk_name" size="80" maxlength="100" value="[% desk.desk_name | html %]" required="required" class="required" /> <span class="required">Required</span> >+ </li> >+ <li> >+ <label for="branchcode" class="required">Library: </label> >+ <select id="branchcode" name="branchcode" required="required"> >+ <option value=""></option> >+ [% FOREACH branch IN branches %] >+ [% IF (Branches.GetLoggedInBranchcode == branch.branchcode) %] >+ <option value="[% branch.branchcode %]" selected="selected">[% branch.branchname %]</option> >+ [% ELSE %] >+ <option value="[% branch.branchcode %]">[% branch.branchname %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ </li> >+ >+ </ol> >+ </fieldset> >+ >+ <fieldset class="action"> >+ <input type="submit" value="Submit" /> >+ <a class="cancel" href="/cgi-bin/koha/admin/desks.pl">Cancel</a> >+ </fieldset> >+ </form> >+[% END %] >+ >+[% IF op == 'delete_confirm' %] >+ <div class="dialog alert"> >+ <h3>Delete desk "[% desk.desk_name | html %]?"</h3> >+ <table> >+ <tr><th>Desk id</th> >+ <td>[% desk.desk_id | html %]</td> >+ </tr> >+ <tr><th>Desk</th> >+ <td>[% desk.desk_name | html %]</td> >+ </tr> >+ <tr><th>Library</th> >+ <td>[% desk.branchcode | html %]</td> >+ </tr> >+ </table> >+ <form action="/cgi-bin/koha/admin/desks.pl" method="post"> >+ <input type="hidden" name="op" value="delete_confirmed" /> >+ <input type="hidden" name="desk_id" value="[% desk.desk_id | html %]" /> >+ <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button> >+ </form> >+ <form action="/cgi-bin/koha/admin/desks.pl" method="get"> >+ <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button> >+ </form> >+ </div> >+[% END %] >+ >+[% IF op == 'list' %] >+ >+ <div id="toolbar" class="btn-toolbar"> >+ <a class="btn btn-default" id="newdesk" href="/cgi-bin/koha/admin/desks.pl?op=add_form"><i class="fa fa-plus"></i> New desk</a> >+ </div> >+ >+ <h2>Desks</h2> >+ [% IF searchfield %] >+ Searching: [% searchfield | html %] >+ [% END %] >+ >+ [% IF desks.count %] >+ <table id="table_desks"> >+ <thead> >+ <tr> >+ <th>Desk ID</th> >+ <th>Desk</th> >+ <th>Library</th> >+ <th>Action</th> >+ </tr> >+ </thead> >+ <tbody> >+ [% FOREACH desk IN desks %] >+ <tr> >+ <td>[% desk.desk_id | html %]</td> >+ <td>[% desk.desk_name | html %]</td> >+ <td>[% desk.branchcode | html %]</td> >+ <td class="actions"> >+ <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/desks.pl?op=add_form&desk_id=[% desk.desk_id | html %]"><i class="fa fa-pencil"></i> Edit</a> >+ <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/desks.pl?op=delete_confirm&desk_id=[% desk.desk_id | html %]"><i class="fa fa-trash"></i> Delete</a> >+ </td> >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+ [% ELSE %] >+ <div class="dialog message"> >+ There are no desks defined. <a href="/cgi-bin/koha/admin/desks.pl?op=add_form">Create a new desk</a>. >+ </div> >+ [% END %] >+[% END %] >+ >+ </main> >+ </div> <!-- /.col-sm-10.col-sm-push-2 --> >+ >+ <div class="col-sm-2 col-sm-pull-10"> >+ <aside> >+ [% INCLUDE 'admin-menu.inc' %] >+ </aside> >+ </div> <!-- /.col-sm-2.col-sm-pull-10 --> >+ </div> <!-- /.row --> >+ >+[% MACRO jsinclude BLOCK %] >+ [% Asset.js("js/admin-menu.js") | $raw %] >+ [% INCLUDE 'datatables.inc' %] >+ <script> >+ $(document).ready(function() { >+ $("#table_desks").dataTable($.extend(true, {}, dataTablesDefaults, { >+ "aoColumnDefs": [ >+ { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false }, >+ ], >+ "aaSorting": [[ 1, "asc" ]], >+ "iDisplayLength": 10, >+ "sPaginationType": "full_numbers" >+ })); >+ }); >+ </script> >+[% END %] >+[% INCLUDE 'intranet-bottom.inc' %] >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 13881
:
37808
|
39837
|
40186
|
40569
|
40709
|
40895
|
41233
|
42804
|
43664
|
93445
|
93446
|
93447
|
93452
|
93453
|
93454
|
95287
|
95288
|
95289
|
95293
|
95294
|
95295
|
101033
|
101050
|
101064
|
101065
|
101479
|
101543
|
101544
|
101545
|
101546
|
101547
|
105009