Bugzilla – Attachment 37808 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]
Add desk management
Add-desk-management.patch (text/plain), 23.09 KB, created by
Nicolas Legrand
on 2015-04-14 10:34:13 UTC
(
hide
)
Description:
Add desk management
Filename:
MIME Type:
Creator:
Nicolas Legrand
Created:
2015-04-14 10:34:13 UTC
Size:
23.09 KB
patch
obsolete
>From d293abbfab9588d0553b2517f220d4513fc54724 Mon Sep 17 00:00:00 2001 >From: Nicolas Legrand <nicolas.legrand@bulac.fr> >Date: Fri, 27 Mar 2015 16:18:56 +0100 >Subject: [PATCH] Add desk management > >Test plan : > >1/ perl installer/data/mysql/updatedatabase.pl (create new table desks) >2/ prove t/db_dependent/Desks.t >3/ go to admin page, click on desk management, try to create, modify >and delete desks > >http://bugs.koha-community.org/show_bug.cgi?id=13881 >--- > C4/Desks.pm | 183 ++++++++++++++++ > admin/desks.pl | 131 ++++++++++++ > .../atomicupdate/bug_13881-add_desk_management.sql | 12 ++ > installer/data/mysql/kohastructure.sql | 18 +- > .../prog/en/modules/admin/admin-home.tt | 2 + > .../intranet-tmpl/prog/en/modules/admin/desks.tt | 220 ++++++++++++++++++++ > t/db_dependent/Desks.t | 70 +++++++ > 7 files changed, 635 insertions(+), 1 deletion(-) > create mode 100644 C4/Desks.pm > create mode 100755 admin/desks.pl > create mode 100644 installer/data/mysql/atomicupdate/bug_13881-add_desk_management.sql > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/admin/desks.tt > create mode 100644 t/db_dependent/Desks.t > >diff --git a/C4/Desks.pm b/C4/Desks.pm >new file mode 100644 >index 0000000..9298b9a >--- /dev/null >+++ b/C4/Desks.pm >@@ -0,0 +1,183 @@ >+# This file is part of Koha. >+# >+# Copyright (C) 2011 Progilone >+# Copyright (C) 2015 BULAC >+# >+# 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>. >+ >+package C4::Desks; >+ >+use Modern::Perl; >+ >+use C4::Context; >+use vars qw(@ISA @EXPORT); >+ >+BEGIN { >+ require Exporter; >+ @ISA = qw(Exporter); >+ @EXPORT = qw( >+ &AddDesk >+ &ModDesk >+ &DelDesk >+ &GetDesk >+ &GetDesks >+ ); >+} >+ >+=head1 NAME >+ >+C4::Desks - Desk management functions >+ >+=head1 DESCRIPTION >+ >+This module contains an API for manipulating issue desks in Koha. It >+is used by circulation. >+ >+=head1 HISTORICAL NOTE >+ >+Developped by Progilone on a customised Koha 3.2 for BULAC >+library. The module is ported to Koha 3.19 and up by the BULAC. >+ >+=cut >+ >+=head2 AddDesk >+ >+ AddDesk({ >+ 'deskcode' => $deskcode, >+ 'deskname' => $deskname, >+ 'deskdescription' => $deskdescription >+ 'branchcode' => $branchcode }); >+ >+ returns 1 on success, undef on error. A return value greater than 1 >+ or just -1 means something went wrong. >+ >+=cut >+ >+sub AddDesk { >+ my ($args) = @_; >+ C4::Context->dbh->do >+ ('INSERT INTO desks ' . >+ '(deskcode, deskname, deskdescription, branchcode) ' . >+ 'VALUES (?,?,?,?)' , >+ undef, >+ $args->{'deskcode'}, >+ $args->{'deskname'}, >+ $args->{'deskdescription'}, >+ $args->{'branchcode'}, >+ ); >+} >+ >+=head2 DelDesk >+ >+ DelDesk($deskcode) >+ >+ returns 1 on success, undef on error. A return value greater than 1 >+ or just -1 means something went wrong. >+ >+=cut >+ >+sub DelDesk { >+ my $deskcode = shift; >+ C4::Context->dbh->do >+ ('DELETE FROM desks WHERE deskcode = ?', >+ undef, >+ $deskcode >+ ); >+} >+ >+=head2 GetDesk >+ >+ $desk_href = GetDesk($deskcode); >+ >+ returns undef when no desk matches $deskcode, return a href >+ containing desk parameters: >+ {'deskcode' => $deskcode, >+ 'deskname' => $deskname, >+ 'deskdescription' => $deskdescription, >+ 'branchcode' => $branchcode } >+ >+=cut >+ >+sub GetDesk { >+ my $deskcode = shift; >+ my $query = ' >+ SELECT * >+ FROM desks >+ WHERE deskcode = ?'; >+ >+ my $sth = C4::Context->dbh->prepare($query); >+ $sth->execute($deskcode); >+ $sth->fetchrow_hashref; >+} >+ >+=head2 GetDesks >+ >+ $desk_aref = GetDesks([$branch]) >+ >+ returns an array ref containing deskcodes. If no desks are >+ available, the array is empty. >+ >+=cut >+ >+sub GetDesks { >+ my $branchcode = shift || ''; >+ my $retaref = []; >+ my $query = 'SELECT deskcode FROM desks'; >+ if ($branchcode) { >+ $query = $query . ' WHERE branchcode = ?'; >+ } >+ my $sth = C4::Context->dbh->prepare($query); >+ if ($branchcode) { >+ $sth->execute($branchcode); >+ } else { >+ $sth->execute(); >+ } >+ while (my $rowaref = $sth->fetchrow_arrayref()) { >+ push @{ $retaref }, $rowaref->[0]; >+ } >+ return $retaref; >+} >+ >+=head2 ModDesks >+ >+ $deskhref = { >+ 'deskcode' => $deskcode, >+ 'deskname' => $deskname, >+ 'deskdescription' => $deskdescription, >+ 'branchcode' => $branchcode >+ } >+ ModDesks($deskhref) >+ >+ Modify desk with $deskcode with values contained in various >+ $deskhref fields. Returns 1 on success, 0 if no desk were >+ modified, undef, -1 or an int greater than 1 if something went >+ terribly wrong. >+ >+=cut >+ >+sub ModDesk { >+ my ($args) = @_; >+ C4::Context->dbh->do('UPDATE desks SET deskname = ? , ' . >+ 'deskdescription = ? , ' . >+ 'branchcode = ? ' . >+ 'WHERE deskcode = ?' , >+ undef, >+ $args->{'deskname'}, >+ $args->{'deskdescription'}, >+ $args->{'branchcode'}, >+ $args->{'deskcode'} >+ ); >+} >+ >+1; >diff --git a/admin/desks.pl b/admin/desks.pl >new file mode 100755 >index 0000000..417b631 >--- /dev/null >+++ b/admin/desks.pl >@@ -0,0 +1,131 @@ >+#!/usr/bin/perl >+# >+# Copyright (C) 2011 Progilone >+# Copyright (C) 2015 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 2 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., 59 Temple Place, >+# Suite 330, Boston, MA 02111-1307 USA >+ >+use Modern::Perl; >+use CGI; >+use C4::Output; >+use C4::Auth; >+use C4::Context; >+use C4::Koha; >+use C4::Branch; >+use C4::Desks; >+ >+my $script_name = "/cgi-bin/koha/admin/desks.pl"; >+ >+my $input = new CGI; >+my $deskcode = $input->param('deskcode'); >+my $branchcode = $input->param('branchcode'); >+my $deskname = $input->param('deskname'); >+my $deskdescription = $input->param('deskdescription'); >+my $op = $input->param('op') || ''; >+ >+my @deskloop; >+my $branches = GetBranches; >+my @branches = keys $branches; >+my @branchloop; >+foreach my $thisbranch (sort keys %$branches) { >+ my $selected = 1 if $thisbranch eq $branchcode; >+ my %row =(value => $thisbranch, >+ selected => $selected, >+ branchname => $branches->{$thisbranch}->{branchname}, >+ ); >+ push @branchloop, \%row; >+} >+ >+ >+my ( $template, $borrowernumber, $cookie ) = >+ get_template_and_user( >+ { >+ template_name => "admin/desks.tt", >+ query => $input, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => { >+ parameters => 'parameters_remaining_permissions' >+ }, >+ debug => 1, >+ } >+ ); >+ >+$template->param(branchloop => \@branchloop); >+ >+$template->param(script_name => $script_name); >+if ($op) { >+ $template->param($op => 1); >+} else { >+ $template->param(else => 1); >+} >+$template->param(deskcode => $deskcode); >+ >+my $desk; >+ >+if ( $op eq 'add_form' || $op eq 'delete_confirm') { >+ $desk = GetDesk($deskcode); >+} >+elsif ( $op eq 'add_validate' ) { >+ $desk = { >+ 'deskcode' => $deskcode, >+ 'deskname' => $deskname, >+ 'deskdescription' => $deskdescription, >+ 'branchcode' => $branchcode, >+ }; >+ if ( GetDesk($deskcode) ) { >+ $template->param(error => 'ALREADY_EXISTS'); >+ print $input->redirect('desks.pl'); >+ exit; >+ } >+ if (AddDesk($desk) != 1) { >+ $template->param(error => 'CANT_ADD'); >+ } >+ print $input->redirect('desks.pl'); >+ exit; >+} >+elsif ( $op eq 'modify_validate' ) { >+ $desk = { >+ 'deskcode' => $deskcode, >+ 'deskname' => $deskname, >+ 'deskdescription' => $deskdescription, >+ 'branchcode' => $branchcode, >+ }; >+ if (ModDesk($desk) != 1) { >+ $template->param(error => 'CANT_MODIFY'); >+ } >+ print $input->redirect('desks.pl'); >+ exit; >+} >+elsif ( $op eq 'delete_confirmed' ) { >+ if ( DelDesk($deskcode) != 1) { >+ $template->param(error => 'CANT_DELETE'); >+ } >+ print $input->redirect('desks.pl'); >+ exit; >+} >+else { >+ my $userenv = C4::Context->userenv; >+ my $desksaref = GetDesks(); >+ foreach my $d (@$desksaref) { >+ push @deskloop, GetDesk($d); >+ } >+ $template->param(deskloop => \@deskloop); >+} >+ >+$template->param(desk => $desk); >+ >+output_html_with_http_headers $input, $cookie, $template->output; >diff --git a/installer/data/mysql/atomicupdate/bug_13881-add_desk_management.sql b/installer/data/mysql/atomicupdate/bug_13881-add_desk_management.sql >new file mode 100644 >index 0000000..eabaec8 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_13881-add_desk_management.sql >@@ -0,0 +1,12 @@ >+DROP TABLE IF EXISTS `desks`; >+CREATE TABLE `desks` ( >+ `deskcode` varchar(10) NOT NULL, -- desk id >+ `branchcode` varchar(10) NOT NULL, -- branch id the desk is attached to >+ `deskname` varchar(80) NOT NULL, -- name used for OPAC or intranet printing >+ `deskdescription` varchar(300) NOT NULL, -- longer description of the desk >+ PRIMARY KEY (`deskcode`), >+ UNIQUE KEY `deskcode` (`deskcode`), >+ KEY `fk_desks_branchcode` (`branchcode`), >+ KEY `fk_desks_name_branchcode` (`branchcode`,`deskname`), >+ CONSTRAINT `fk_desks_branchcode` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE >+) ENGINE=InnoDB DEFAULT CHARSET=utf8; >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 6ddba43..5758210 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -453,7 +453,6 @@ CREATE TABLE `branchtransfers` ( -- information for items that are in transit be > CONSTRAINT `branchtransfers_ibfk_3` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE > ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; > >- > -- > -- Table structure for table `browser` > -- >@@ -957,6 +956,23 @@ CREATE TABLE `deleteditems` ( > ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; > > -- >+-- Table structure for table `desks` >+-- >+ >+DROP TABLE IF EXISTS `desks`; >+CREATE TABLE `desks` ( >+ `deskcode` varchar(10) NOT NULL, -- desk id >+ `branchcode` varchar(10) NOT NULL, -- branch id the desk is attached to >+ `deskname` varchar(80) NOT NULL, -- name used for OPAC or intranet printing >+ `deskdescription` varchar(300) NOT NULL, -- longer description of the desk >+ PRIMARY KEY (`deskcode`), >+ UNIQUE KEY `deskcode` (`deskcode`), >+ KEY `fk_desks_branchcode` (`branchcode`), >+ KEY `fk_desks_name_branchcode` (`branchcode`,`deskname`), >+ CONSTRAINT `fk_desks_branchcode` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE >+) ENGINE=InnoDB DEFAULT CHARSET=utf8; >+ >+-- > -- Table structure for table `ethnicity` > -- > >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 02bc60a..3f6fc12 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 >@@ -32,6 +32,8 @@ > <dl> > <dt><a href="/cgi-bin/koha/admin/branches.pl">Libraries and groups</a></dt> > <dd>Define libraries and groups.</dd> >+ <dt><a href="/cgi-bin/koha/admin/desks.pl">Desks</a></dt> >+ <dd>Define Desks.</dd> > <dt><a href="/cgi-bin/koha/admin/itemtypes.pl">Item types</a></dt> > <dd>Define item types used for circulation rules.</dd> > <dt><a href="/cgi-bin/koha/admin/authorised_values.pl">Authorized values</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..d7b443e >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/desks.tt >@@ -0,0 +1,220 @@ >+[% USE AuthorisedValues %] >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Koha › Administration › Desks [% IF ( add_form ) %]› >+ [% IF ( deskcode ) %] >+Modify desk '[% deskcode %]' >+ [% ELSE %] >+Add desk >+ [% END %] >+[% END %] >+[% IF ( delete_confirm ) %]› >+ Delete desk '[% deskcode %]'? >+[% END %] >+[% IF ( delete_confirmed ) %]› >+Desk deleted >+[% END %] >+</title> >+[% INCLUDE 'doc-head-close.inc' %] >+<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" /> >+[% INCLUDE 'datatables.inc' %] >+<script type="text/javascript"> >+//<![CDATA[ >+ $(document).ready(function() { >+ $('#icons').tabs(); >+ $("#table_desks").dataTable($.extend(true, {}, dataTablesDefaults, { >+ "aoColumnDefs": >+ [{ "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },], >+ "aaSorting": [[ 2, "asc" ]], >+ "iDisplayLength": 10, >+ "sPaginationType": "four_button" >+ })); >+ $( "#deskcodeentry" ).validate({ >+ rules: { >+ deskcode: { required: true }, >+ description: { required: true }, >+ rentalcharge: { number: true } >+ } >+ }); >+ }); >+//]]> >+</script> >+<style type="text/css"> >+ fieldset.rows div.toptabs li { clear:none;margin-right:.5em;padding-bottom:0;width:auto; } >+ fieldset.rows div.toptabs .ui-tabs-nav li.ui-tabs-active {background-color : #F4F8F9; } >+ fieldset.rows .ui-tabs-panel { margin-right : 10px; margin-left : 10px;margin-bottom:10px;} >+ fieldset.rows .ui-tabs-nav { margin-left : 10px; } >+</style> >+</head> >+<body id="admin_desks" class="admin"> >+[% INCLUDE 'header.inc' %] >+[% INCLUDE 'cat-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> › >+[% IF ( add_form ) %] >+ [% IF ( desk.deskcode ) %] >+<a href="/cgi-bin/koha/admin/desks.pl">Desks</a> › Modify desk '[% desk.deskcode %]' >+ [% ELSE %] >+<a href="/cgi-bin/koha/admin/desks.pl">Desks</a> › Add desk >+ [% END %] >+[% END %] >+[% IF ( delete_confirm ) %] >+<a href="/cgi-bin/koha/admin/desks.pl">Desks</a> › Delete desk '[% deskcode %]'? >+[% END %] >+[% IF ( else ) %] >+Desks administration >+[% END %]</div> >+ >+<div id="doc3" class="yui-t2"> >+ <div id="bd"> >+ <div id="yui-main"> >+ <div class="yui-b"> >+ [% IF ( error ) %]$ >+ <div class="dialog alert"> >+ [% IF ( CANT_ADD ) %] >+ <h3>Adding Desk [% deskcode %] failed</h3> >+ [% END %] >+ [% IF ( ALREADY_EXISTS ) %] >+ <h3>Adding Desk [% deskcode %] failed, it already exists</h3> >+ [% END %] >+ [% IF ( CANT_MODIFY ) %] >+ <h3>Modifying Desk [% deskcode %] failed</h3> >+ [% IF ( CANT_DELETE ) %] >+ <h3>Deleting Desk [% deskcode %] failed</h3> >+ [% END %] >+ [% END %] >+</div> >+[% END %] >+[% IF ( else ) %] >+ <div id="toolbar" class="btn-toolbar"> >+ <a class="btn btn-small" id="newdesk" href="/cgi-bin/koha/admin/desks.pl?op=add_form"><i class="icon-plus"></i> New Desk</a> >+ </div> >+[% END %] >+ >+ >+[% IF ( add_form ) %] >+ [% IF ( deskcode ) %] >+ <h3>Modify desk</h3> >+ [% ELSE %] >+ <h3>Add desk</h3> >+ [% END %] >+ <form action="[% script_name %]" name="Aform" method="post" id="deskcodeentry"> >+ <input type="hidden" name="op" value= >+ [% IF ( deskcode ) %] >+ "modify_validate" >+ [% ELSE %] >+ "add_validate" >+ [% END %] >+ /> >+ <input type="hidden" name="checked" value="0" /> >+ <fieldset class="rows"> >+ <ol> >+ [% IF ( desk.deskcode ) %] >+ <li> >+ <span class="label">Desk code: </span> >+ <input type="hidden" name="deskcode" value="[% desk.deskcode %]" /> >+ [% desk.deskcode %] >+ </li> >+ [% ELSE %] >+ <li> >+ <label for="deskcode" class="required">Desk code: </label> >+ <input type="text" id="deskcode" name="deskcode" size="10" maxlength="10" onblur="toUC(this)" required="required" /> >+ <span class="required">Required</span> >+ </li> >+ [% END %] >+ <li> >+ <label for="deskdescription" class="required">Name: </label> >+ <input type="text" id="deskname" name="deskname" size="48" value="[% desk.deskname |html %]" required="required" /> >+ <span class="required">Required</span> >+ </li> >+ <li> >+ <label for="deskdescription" class="required">Description: </label> >+ <input type="text" id="deskdescription" name="deskdescription" size="48" value="[% desk.deskdescription |html %]" required="required" /> >+ <span class="required">Required</span></li> >+ <li> >+ <label for="branchcode" class="required">Branch: </label> >+ <select id="branchcode" name="branchcode" required="required"> >+ <option value=""></option> >+ [% FOREACH branchloo IN branchloop %] >+ [% IF desk.branchcode == branchloo.value %] >+ <option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option> >+ [% ELSE %] >+ <option value="[% branchloo.value %]">[% branchloo.branchname %]</option> >+loop [% END %] >+ [% END %] >+ </select> >+ </li> >+ </ol> >+ </fieldset> >+ <fieldset class="action"> >+ <input type="submit" value="Save changes" /> >+ <a href="/cgi-bin/koha/admin/desks.pl" class="cancel">Cancel</a> >+ </fieldset> >+ </form> >+ <br class="clear" /> >+[% END %] >+ >+ >+[% IF ( delete_confirm ) %] >+ <div class="dialog alert"> >+ <h3>Delete Desk '[% desk.deskcode %]'?</h3> >+ <form action="[% script_name %]" method="post"> >+ <input type='hidden' name='op' value='delete_confirmed'/> >+ <table> >+ <tr> >+ <th scope="row">Desk</th> >+ <td><input type='hidden' name='deskcode' value='[% desk.deskcode %]'/>[% desk.deskcode %]</td> >+ </tr> >+ <tr><th scope="row">Name</th><td>[% desk.deskname %]</td></tr> >+ <tr><th scope="row">Description</th><td>[% desk.deskdescription %]</td></tr> >+ <tr><th scope="row">Branch</th><td>[% desk.branchcode %]</td></tr> >+ </table> >+ <input type="submit" class="approve" value="Delete this Desk" /> >+ </form> >+ <form action="[% script_name %]" method="post"> >+ <input type="submit" class="deny" value="Do Not Delete" /> >+ </form> >+ </div> >+[% END %] >+ >+ >+[% IF ( else ) %] >+ <h2>Desks administration</h2> >+ [% IF ( deskloop ) %] >+ <table id="table_desks"> >+ <thead> >+ <th>Desk code</th> >+ <th>Name</th> >+ <th>Description</th> >+ <th>Branchcode</th> >+ <th>Action</th> >+ </thead> >+ [% FOREACH deskloo IN deskloop %] >+ <tr> >+ <td> >+ <a href="[% deskloo.script_name %]?op=add_form&deskcode=[% loo.deskcode |html %]"> >+ [% deskloo.deskcode %] >+ </a> >+ </td> >+ <td>[% deskloo.deskname %]</td> >+ <td>[% deskloo.deskdescription %]</td> >+ <td>[% deskloo.branchcode %]</td> >+ <td> >+ <a href="[% deskloo.script_name %]?op=add_form&deskcode=[% deskloo.deskcode |html %]">Edit</a> >+ <a href="[% deskloo.script_name %]?op=delete_confirm&deskcode=[% deskloo.deskcode |html %]">Delete</a> >+ </td> >+ </tr> >+ [% END %] >+ </table> >+ [% ELSE %] >+ <div class="dialog message">There are no desk defined</div> >+ [% END %] >+ <div class="pages">[% pagination_bar %]</div> >+[% END %] >+ </div> >+ </div> >+ <div class="yui-b"> >+[% INCLUDE 'admin-menu.inc' %] >+ </div> >+</div> >+[% INCLUDE 'intranet-bottom.inc' %] >diff --git a/t/db_dependent/Desks.t b/t/db_dependent/Desks.t >new file mode 100644 >index 0000000..964617d >--- /dev/null >+++ b/t/db_dependent/Desks.t >@@ -0,0 +1,70 @@ >+#!/usr/bin/perl >+# >+# Copyright (C) 2015 BULAC >+# >+# 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 Test::More tests => 17; >+ >+BEGIN { >+ use_ok('C4::Branch'); >+ use_ok('C4::Desks'); >+} >+ >+my $deskcode = 'MON BUREAU'; >+my $deskname = 'mon bureau'; >+my $deskdescription = "Le beau bureau ici."; >+my $branchcode = shift [keys GetBranches]; >+ >+my $hrdesk = { >+ 'deskcode' => $deskcode, >+ 'deskname' => $deskname, >+ 'deskdescription' => $deskdescription, >+ 'branchcode' => $branchcode >+ }; >+ >+ok(AddDesk($hrdesk) == 1, 'AddDesk creates desk.'); >+ok(! defined AddDesk($hrdesk) >+ , 'AddDesk returns undef when desk already exists'); >+ >+my $desk = GetDesk($deskcode); >+ok (ref($desk) eq 'HASH', 'GetDesk returns hashref.'); >+ok($desk->{'deskcode'} eq $deskcode, 'GetDesk returns desk code'); >+ok($desk->{'deskname'} eq $deskname, 'GetDesk returns desk name'); >+ok($desk->{'deskdescription'} eq $deskdescription, 'GetDesk returns desk description'); >+ok($desk->{'branchcode'} eq $branchcode, 'GetDesk returns branchcode'); >+ok(! defined GetDesk('this desk surely not exists'), >+ "GetDesk returns undef when desk doesn't exist"); >+ >+my $modifieddesk = { >+ 'deskcode' => $deskcode, >+ 'deskname' => 'mon joli bureau', >+ 'deskdescription' => "Celui dans l'entrée", >+ 'branchcode' => $branchcode >+ }; >+ok(ModDesk($modifieddesk) == 1, 'ModDesk modifies Desk'); >+$modifieddesk->{'deskcode'} = 'this desk surely not exists'; >+ok(ModDesk($modifieddesk) == 0, 'ModDesk returns 0 when deskcode is wrong'); >+ >+my $desks = GetDesks(); >+ok(ref($desks) eq 'ARRAY', 'GetDesks returns an array'); >+ok($deskcode ~~ @$desks, 'GetDesks returns desk codes'); >+my $emptydesksset = GetDesks("this branch sureley doesn't exist"); >+ok(! @$emptydesksset , 'GetDesks returns [] when no desks are found'); >+ >+ok(DelDesk($deskcode) == 1, 'DelDesk returns 1 when successfuly deleting desk'); >+ok(DelDesk('this desk surely not exists'), >+ "DelDesk returns 0 when no desk were deleted"); >-- >1.7.10.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