Bugzilla – Attachment 30337 Details for
Bug 7290
New permission for receiving all (independent of library)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7290: More granular permissions for order receiving
Bug-7290-More-granular-permissions-for-order-recei.patch (text/plain), 27.82 KB, created by
Julian Maurice
on 2014-07-30 14:35:30 UTC
(
hide
)
Description:
Bug 7290: More granular permissions for order receiving
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2014-07-30 14:35:30 UTC
Size:
27.82 KB
patch
obsolete
>From 845ad5ed75ed55edef35fd6f244b7f65c84035d5 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Wed, 5 Feb 2014 17:13:31 +0100 >Subject: [PATCH] Bug 7290: More granular permissions for order receiving > >Add branch to aqorders. >Add subpermission acquisition => order_receive_all > >Users with order_receive_all can receive all orders. >Users with only order_receive can receive an order if: > - order branch is defined and is the same as the current working > branch > - order branch is not defined, basket branch is defined and basket > branch is the same as the current working branch > - order branch and basket branch are not defined > >Use dataTables filters possibilities instead of custom JS solution in parcel.pl > >Unit tests are available in t/Acquisition/CanUserReceiveBasket.t > >Signed-off-by: Paola Rossi <paola.rossi@cineca.it> >--- > C4/Acquisition.pm | 71 +++++++++++++ > acqui/addorder.pl | 1 + > acqui/finishreceive.pl | 10 +- > acqui/neworderempty.pl | 5 +- > acqui/orderreceive.pl | 12 +++ > acqui/parcel.pl | 12 ++- > .../data/mysql/de-DE/mandatory/userpermissions.sql | 1 + > .../data/mysql/en/mandatory/userpermissions.sql | 1 + > .../data/mysql/es-ES/mandatory/userpermissions.sql | 1 + > .../mysql/fr-FR/1-Obligatoire/userpermissions.sql | 1 + > .../data/mysql/it-IT/necessari/userpermissions.sql | 1 + > installer/data/mysql/kohastructure.sql | 3 + > .../mysql/nb-NO/1-Obligatorisk/userpermissions.sql | 1 + > .../data/mysql/pl-PL/mandatory/userpermissions.sql | 1 + > .../ru-RU/mandatory/permissions_and_user_flags.sql | 1 + > .../uk-UA/mandatory/permissions_and_user_flags.sql | 1 + > installer/data/mysql/updatedatabase.pl | 16 +++ > .../prog/en/modules/acqui/neworderempty.tt | 19 ++++ > .../prog/en/modules/acqui/orderreceive.tt | 5 + > .../intranet-tmpl/prog/en/modules/acqui/parcel.tt | 26 ++++- > t/Acquisition/CanUserReceiveBasket.t | 111 ++++++++++++++++++++ > 21 files changed, 289 insertions(+), 11 deletions(-) > create mode 100644 t/Acquisition/CanUserReceiveBasket.t > >diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm >index 0d1745c..e3a3f02 100644 >--- a/C4/Acquisition.pm >+++ b/C4/Acquisition.pm >@@ -50,6 +50,7 @@ BEGIN { > > &GetBasketUsers &ModBasketUsers > &CanUserManageBasket >+ &CanUserReceiveOrder > > &ModBasketHeader > >@@ -817,6 +818,76 @@ sub CanUserManageBasket { > return 1; > } > >+=head3 CanUserReceiveOrder >+ >+ my $bool = CanUserReceiveOrder($borrower, $order[, $userflags]); >+ my $bool = CanUserReceiveOrder($borrowernumber, $orderno[, $userflags]); >+ >+Check if a borrower can receive a order, according to user permissions, current >+working branch and order and basket branches. >+ >+First parameter can be either a borrowernumber or a hashref as returned by >+C4::Members::GetMember. >+ >+Second parameter can be either a ordernumber or a hashref as returned by >+C4::Acquisition::GetOrder. >+ >+The third parameter is optional. If given, it should be a hashref as returned >+by C4::Auth::getuserflags. If not, getuserflags is called. >+ >+If user is authorised to receive order, returns 1. >+Otherwise returns 0. >+ >+=cut >+ >+sub CanUserReceiveOrder { >+ my ($borrower, $order, $userflags) = @_; >+ >+ if (!ref $borrower) { >+ $borrower = C4::Members::GetMember(borrowernumber => $borrower); >+ } >+ if (!ref $order) { >+ $order = GetOrder($order); >+ } >+ >+ return 0 unless ($borrower and $order); >+ >+ if (!defined $userflags) { >+ my $dbh = C4::Context->dbh; >+ my $sth = $dbh->prepare("SELECT flags FROM borrowers WHERE borrowernumber = ?"); >+ $sth->execute($borrower->{borrowernumber}); >+ my ($flags) = $sth->fetchrow_array; >+ $sth->finish; >+ >+ $userflags = C4::Auth::getuserflags($flags, $borrower->{userid}, $dbh); >+ } >+ >+ my $branch = C4::Context->userenv->{'branch'}; >+ >+ unless ($userflags->{superlibrarian} >+ || (!ref $userflags->{acquisition} && $userflags->{acquisition}) >+ || (ref $userflags->{acquisition} && $userflags->{acquisition}->{order_receive_all}) ) >+ { >+ if (!ref $userflags->{acquisition} && !$userflags->{acquisition}) { >+ return 0; >+ } >+ if (ref $userflags->{acquisition} && !$userflags->{acquisition}->{order_receive}) { >+ return 0; >+ } >+ if (defined $order->{branch} && $order->{branch} ne $branch) { >+ return 0; >+ } >+ if (!defined $order->{branch}) { >+ my $basket = GetBasket($order->{basketno}); >+ if (!$basket || (defined $basket->{branch} && $basket->{branch} ne $branch)) { >+ return 0; >+ } >+ } >+ } >+ >+ return 1; >+} >+ > #------------------------------------------------------------# > > =head3 GetBasketsByBasketgroup >diff --git a/acqui/addorder.pl b/acqui/addorder.pl >index e048d05..9dd92c8 100755 >--- a/acqui/addorder.pl >+++ b/acqui/addorder.pl >@@ -226,6 +226,7 @@ my $orderinfo = $input->Vars; > $orderinfo->{'list_price'} ||= 0; > $orderinfo->{'uncertainprice'} ||= 0; > $orderinfo->{subscriptionid} ||= undef; >+$orderinfo->{branch} = undef if (defined $orderinfo->{branch} and $orderinfo->{branch} eq ''); > > my $user = $input->remote_user; > >diff --git a/acqui/finishreceive.pl b/acqui/finishreceive.pl >index 1723520..7d09267 100755 >--- a/acqui/finishreceive.pl >+++ b/acqui/finishreceive.pl >@@ -36,7 +36,8 @@ use List::MoreUtils qw/any/; > my $input=new CGI; > my $flagsrequired = {acquisition => 'order_receive'}; > >-checkauth($input, 0, $flagsrequired, 'intranet'); >+my ($userid, $cookie, undef, $userflags) >+ = checkauth($input, 0, $flagsrequired, 'intranet'); > > my $user = $input->remote_user; > my $biblionumber = $input->param('biblionumber'); >@@ -58,6 +59,13 @@ my $bookfund = $input->param("bookfund"); > my $order = GetOrder($ordernumber); > my $new_ordernumber = $ordernumber; > >+my $borrower = C4::Members::GetMember(userid => $userid); >+unless (CanUserReceiveOrder($borrower, $ordernumber, $userflags)) { >+ my $error = "cannot_receive_order"; >+ print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoiceid=$invoiceid&error=$error"); >+ exit; >+} >+ > #need old recievedate if we update the order, parcel.pl only shows the right parcel this way FIXME > if ($quantityrec > $origquantityrec ) { > my @received_items = (); >diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl >index 6ae3440..e1a04ba 100755 >--- a/acqui/neworderempty.pl >+++ b/acqui/neworderempty.pl >@@ -66,8 +66,7 @@ the item's id in the breeding reservoir > > =cut > >-use warnings; >-use strict; >+use Modern::Perl; > use CGI; > use C4::Context; > use C4::Input; >@@ -242,7 +241,7 @@ foreach my $thisbranch ( sort {$branches->{$a}->{'branchname'} cmp $branches->{$ > value => $thisbranch, > branchname => $branches->{$thisbranch}->{'branchname'}, > ); >- $row{'selected'} = 1 if( $thisbranch && $data->{branchcode} && $thisbranch eq $data->{branchcode}) ; >+ $row{'selected'} = 1 if( $thisbranch && $data->{branch} && $thisbranch eq $data->{branch}) ; > push @branchloop, \%row; > } > $template->param( branchloop => \@branchloop ); >diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl >index ca6de52..e30124f 100755 >--- a/acqui/orderreceive.pl >+++ b/acqui/orderreceive.pl >@@ -114,6 +114,18 @@ unless ( $results and @$results) { > # prepare the form for receiving > my $order = $results->[0]; > >+unless (CanUserReceiveOrder($loggedinuser, $order, $userflags)) { >+ $template->param( >+ cannot_receive_order => 1, >+ ordernumber => $ordernumber, >+ invoice => $invoice, >+ booksellerid => $booksellerid, >+ name => $bookseller->{name} >+ ); >+ output_html_with_http_headers $input, $cookie, $template->output; >+ exit; >+} >+ > # Check if ACQ framework exists > my $acq_fw = GetMarcStructure(1, 'ACQ'); > unless($acq_fw) { >diff --git a/acqui/parcel.pl b/acqui/parcel.pl >index 00e6499..fddbb24 100755 >--- a/acqui/parcel.pl >+++ b/acqui/parcel.pl >@@ -54,8 +54,7 @@ To filter the results list on this given date. > > =cut > >-use strict; >-use warnings; >+use Modern::Perl; > > use C4::Auth; > use C4::Acquisition; >@@ -110,7 +109,7 @@ sub get_gst { > : $value * ( 1 + $gstrate ) - $value; > } > >-my ($template, $loggedinuser, $cookie) >+my ($template, $loggedinuser, $cookie, $userflags) > = get_template_and_user({template_name => "acqui/parcel.tt", > query => $input, > type => "intranet", >@@ -305,6 +304,8 @@ unless( defined $invoice->{closedate} ) { > $line{holds} = $holds; > $line{holds_on_order} = $itemholds?$itemholds:$holds if $line{left_holds_on_order}; > >+ $line{can_receive} = CanUserReceiveOrder($loggedinuser, $pendingorders->[$i], $userflags); >+ > my $budget = GetBudget( $line{budget_id} ); > $line{budget_name} = $budget->{'budget_name'}; > >@@ -316,6 +317,11 @@ unless( defined $invoice->{closedate} ) { > ); > } > >+my @errors = $input->param('error'); >+foreach my $error (@errors) { >+ $template->param("error_$error" => 1); >+} >+ > $template->param( > invoiceid => $invoice->{invoiceid}, > invoice => $invoice->{invoicenumber}, >diff --git a/installer/data/mysql/de-DE/mandatory/userpermissions.sql b/installer/data/mysql/de-DE/mandatory/userpermissions.sql >index 0e16281..7392996 100644 >--- a/installer/data/mysql/de-DE/mandatory/userpermissions.sql >+++ b/installer/data/mysql/de-DE/mandatory/userpermissions.sql >@@ -23,6 +23,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES > (11, 'order_manage_all', 'Bestellungen aller Bibliotheken, unabhängig von Berechtigungen, verwalten'), > (11, 'group_manage', 'Bestellgruppen vewalten'), > (11, 'order_receive', 'Lieferungen verwalten'), >+ (11, 'order_receive_all', 'Receive all orders'), > (11, 'budget_add_del', 'Konten hinzufügen/ändern, aber bestehende nicht ändern'), > (11, 'budget_manage_all', 'Alle Konten verwalten'), > (13, 'edit_news', 'Nachrichten für OPAC und Dienstoberfläche verfassen'), >diff --git a/installer/data/mysql/en/mandatory/userpermissions.sql b/installer/data/mysql/en/mandatory/userpermissions.sql >index ba5ccd0..455ccee 100644 >--- a/installer/data/mysql/en/mandatory/userpermissions.sql >+++ b/installer/data/mysql/en/mandatory/userpermissions.sql >@@ -23,6 +23,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES > (11, 'order_manage_all', 'Manage all orders and baskets, regardless of restrictions on them'), > (11, 'group_manage', 'Manage orders & basketgroups'), > (11, 'order_receive', 'Manage orders & basket'), >+ (11, 'order_receive_all', 'Receive all orders'), > (11, 'budget_add_del', 'Add and delete budgets (but cant modify budgets)'), > (11, 'budget_manage_all', 'Manage all budgets'), > (13, 'edit_news', 'Write news for the OPAC and staff interfaces'), >diff --git a/installer/data/mysql/es-ES/mandatory/userpermissions.sql b/installer/data/mysql/es-ES/mandatory/userpermissions.sql >index 0564d93..c9dd09b 100644 >--- a/installer/data/mysql/es-ES/mandatory/userpermissions.sql >+++ b/installer/data/mysql/es-ES/mandatory/userpermissions.sql >@@ -23,6 +23,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES > (11, 'order_manage_all', 'Manage all orders and baskets, regardless of restrictions on them'), > (11, 'group_manage', 'Manage orders & basketgroups'), > (11, 'order_receive', 'Manage orders & basket'), >+ (11, 'order_receive_all', 'Receive all orders'), > (11, 'budget_add_del', 'Add and delete budgets (but cant modify budgets)'), > (11, 'budget_manage_all', 'Manage all budgets'), > (13, 'edit_news', 'Write news for the OPAC and staff interfaces'), >diff --git a/installer/data/mysql/fr-FR/1-Obligatoire/userpermissions.sql b/installer/data/mysql/fr-FR/1-Obligatoire/userpermissions.sql >index 31faf15..a6865a3 100644 >--- a/installer/data/mysql/fr-FR/1-Obligatoire/userpermissions.sql >+++ b/installer/data/mysql/fr-FR/1-Obligatoire/userpermissions.sql >@@ -41,6 +41,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES > (11, 'order_manage_all', 'Manage all orders and baskets, regardless of restrictions on them'), > (11, 'group_manage', 'Gérer les commandes et les bons de commande'), > (11, 'order_receive', 'Gérer les réceptions'), >+ (11, 'order_receive_all', 'Gérer toutes les réceptions'), > (11, 'budget_add_del', 'Ajouter et supprimer les budgets (mais pas modifier)'), > (11, 'budget_manage_all', 'Gérer tous les budgets'), > (13, 'manage_csv_profiles', 'Gérer les profils d''export CSV'), >diff --git a/installer/data/mysql/it-IT/necessari/userpermissions.sql b/installer/data/mysql/it-IT/necessari/userpermissions.sql >index 5c58e1f..75437c5 100644 >--- a/installer/data/mysql/it-IT/necessari/userpermissions.sql >+++ b/installer/data/mysql/it-IT/necessari/userpermissions.sql >@@ -23,6 +23,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES > (11, 'order_manage_all', 'Gestisci ordini e raccoglitori, indipendentemente dalle restrizioni su di loro'), > (11, 'group_manage', 'Gestisci ordini e ordini d\'acquisto'), > (11, 'order_receive', 'Gestisci arrivi'), >+ (11, 'order_receive_all', 'Receive all orders'), > (11, 'budget_add_del', 'Aggiungi e cancella budgets (senza modificarli)'), > (11, 'budget_manage_all', 'Gestisci tutti i budgets'), > (13, 'edit_news', 'Scrivi le news per l\'OPAC e per l\'interfaccia staff'), >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index b46dc6a..a26a120 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -3026,15 +3026,18 @@ CREATE TABLE `aqorders` ( -- information related to the basket line items > `claimed_date` date default NULL, -- last date a claim was generated > `subscriptionid` int(11) default NULL, -- links this order line to a subscription (subscription.subscriptionid) > parent_ordernumber int(11) default NULL, -- ordernumber of parent order line, or same as ordernumber if no parent >+ branch varchar(10) default NULL, -- order line branch > `orderstatus` varchar(16) default 'new', -- the current status for this line item. Can be 'new', 'ordered', 'partial', 'complete' or 'cancelled' > PRIMARY KEY (`ordernumber`), > KEY `basketno` (`basketno`), > KEY `biblionumber` (`biblionumber`), > KEY `budget_id` (`budget_id`), >+ KEY branch (branch), > CONSTRAINT `aqorders_ibfk_1` FOREIGN KEY (`basketno`) REFERENCES `aqbasket` (`basketno`) ON DELETE CASCADE ON UPDATE CASCADE, > CONSTRAINT `aqorders_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE, > CONSTRAINT aqorders_ibfk_3 FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE SET NULL ON UPDATE CASCADE, > CONSTRAINT `aqorders_subscriptionid` FOREIGN KEY (`subscriptionid`) REFERENCES `subscription` (`subscriptionid`) ON DELETE CASCADE ON UPDATE CASCADE >+ CONSTRAINT aqorders_branch FOREIGN KEY (branch) REFERENCES branches (branchcode) ON UPDATE CASCADE ON DELETE SET NULL > ) ENGINE=InnoDB DEFAULT CHARSET=utf8; > > >diff --git a/installer/data/mysql/nb-NO/1-Obligatorisk/userpermissions.sql b/installer/data/mysql/nb-NO/1-Obligatorisk/userpermissions.sql >index dfe5ebb..18a0f96 100644 >--- a/installer/data/mysql/nb-NO/1-Obligatorisk/userpermissions.sql >+++ b/installer/data/mysql/nb-NO/1-Obligatorisk/userpermissions.sql >@@ -43,6 +43,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES > (11, 'order_manage_all', 'Manage all orders and baskets, regardless of restrictions on them'), > (11, 'group_manage', 'Administrere bestillinger og kurv-grupper'), > (11, 'order_receive', 'Administrere bestillinger og kurver'), >+ (11, 'order_receive_all', 'Receive all orders'), > (11, 'budget_add_del', 'Legge til og slette budsjetter (men ikke endre budsjetter)'), > (11, 'budget_manage_all', 'Administrere alle budsjetter'), > (13, 'edit_news', 'Legge ut nyhter i OPACen og det interne grensesnittet'), >diff --git a/installer/data/mysql/pl-PL/mandatory/userpermissions.sql b/installer/data/mysql/pl-PL/mandatory/userpermissions.sql >index b9fbee4..b597533 100644 >--- a/installer/data/mysql/pl-PL/mandatory/userpermissions.sql >+++ b/installer/data/mysql/pl-PL/mandatory/userpermissions.sql >@@ -23,6 +23,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES > (11, 'order_manage_all', 'Manage all orders and baskets, regardless of restrictions on them'), > (11, 'group_manage', 'Manage orders & basketgroups'), > (11, 'order_receive', 'Manage orders & basket'), >+ (11, 'order_receive_all', 'Receive all orders'), > (11, 'budget_add_del', 'Add and delete budgets (but cant modify budgets)'), > (11, 'budget_manage_all', 'Manage all budgets'), > (13, 'edit_news', 'RTworzeniei publikowanie wiadomoÅci w interfejsie bibliotekarza i OPAC'), >diff --git a/installer/data/mysql/ru-RU/mandatory/permissions_and_user_flags.sql b/installer/data/mysql/ru-RU/mandatory/permissions_and_user_flags.sql >index 22f51a0..5260f5f 100644 >--- a/installer/data/mysql/ru-RU/mandatory/permissions_and_user_flags.sql >+++ b/installer/data/mysql/ru-RU/mandatory/permissions_and_user_flags.sql >@@ -49,6 +49,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES > (11, 'order_manage_all', 'Manage all orders and baskets, regardless of restrictions on them'), > (11, 'group_manage', 'Manage orders & basketgroups'), > (11, 'order_receive', 'Manage orders & basket'), >+ (11, 'order_receive_all', 'Receive all orders'), > (11, 'budget_add_del', 'Add and delete budgets (but cant modify budgets)'), > (11, 'budget_manage_all', 'Manage all budgets'), > (13, 'edit_news', 'ÐапиÑание новоÑÑей Ð´Ð»Ñ ÑлекÑÑонного каÑалога и инÑеÑÑейÑа библиоÑекаÑей'), >diff --git a/installer/data/mysql/uk-UA/mandatory/permissions_and_user_flags.sql b/installer/data/mysql/uk-UA/mandatory/permissions_and_user_flags.sql >index 1ee4c86..0e7570d 100644 >--- a/installer/data/mysql/uk-UA/mandatory/permissions_and_user_flags.sql >+++ b/installer/data/mysql/uk-UA/mandatory/permissions_and_user_flags.sql >@@ -49,6 +49,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES > (11, 'order_manage_all', 'Manage all orders and baskets, regardless of restrictions on them'), > (11, 'group_manage', 'Manage orders & basketgroups'), > (11, 'order_receive', 'Manage orders & basket'), >+ (11, 'order_receive_all', 'Receive all orders'), > (11, 'budget_add_del', 'Add and delete budgets (but cant modify budgets)'), > (11, 'budget_manage_all', 'Manage all budgets'), > (13, 'edit_news', 'ÐапиÑÐ°Ð½Ð½Ñ Ð½Ð¾Ð²Ð¸Ð½ Ð´Ð»Ñ ÐµÐ»ÐµÐºÑÑонного каÑÐ°Ð»Ð¾Ð³Ñ Ñа ÑнÑеÑÑейÑÑ Ð±ÑблÑоÑекаÑÑв'), >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 94bb4ff..18d4b22 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -8577,6 +8577,22 @@ if ( CheckVersion($DBversion) ) { > SetVersion ($DBversion); > } > >+$DBversion = "XXX"; >+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { >+ $dbh->do(" >+ ALTER TABLE aqorders >+ ADD COLUMN branch VARCHAR(10) DEFAULT NULL, >+ ADD CONSTRAINT aqorders_ibfk_3 FOREIGN KEY (branch) >+ REFERENCES branches (branchcode) ON UPDATE CASCADE ON DELETE SET NULL >+ "); >+ $dbh->do(" >+ INSERT INTO permissions (module_bit, code, description) >+ VALUES (11, 'order_receive_all', 'Receive all orders') >+ "); >+ print "Upgrade to $DBversion done (Add aqorders.branch and permission order_receive_all)\n"; >+ SetVersion($DBversion); >+} >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt >index 64ad028..cb123c1 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt >@@ -228,6 +228,25 @@ $(document).ready(function() > <form action="/cgi-bin/koha/acqui/addorder.pl" method="post" id="Aform" onsubmit="return Check(this);"> > > <fieldset class="rows"> >+ <legend>Order details</legend> >+ <ol> >+ <li> >+ <span class="label">Branch:</span> >+ <select name="branch"> >+ <option value=""> </option> >+ [% FOREACH branch IN branchloop %] >+ [% IF branch.selected %] >+ <option selected="selected" value="[% branch.value %]">[% branch.branchname %]</option> >+ [% ELSE %] >+ <option value="[% branch.value %]">[% branch.branchname %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ </li> >+ </ol> >+</fieldset> >+ >+<fieldset class="rows"> > <legend> > Catalog details > [% IF ( biblionumber ) %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >index 422a4a3..ed18c15 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >@@ -129,6 +129,10 @@ > > <h1>Receive items from : [% name %] [% IF ( invoice ) %][[% invoice %]] [% END %] (order #[% ordernumber %])</h1> > >+[% IF (cannot_receive_order) %] >+ <p class="error">You are not authorised to receive this order.</p> >+[% ELSE %] >+ > [% IF ( count ) %] > <form action="/cgi-bin/koha/acqui/finishreceive.pl" method="post" onsubmit="return Check(this);"> > <div class="yui-g"> >@@ -343,6 +347,7 @@ > This ordernumber does not exist. > [% END %] > >+[% END %][%# IF (cannot_receive_order) %] > </div> > </div> > <div class="yui-b"> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt >index f4f6e3e..9f0065f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt >@@ -164,11 +164,19 @@ > <div class="yui-b"> > [% IF ( receive_error ) %] > <div class="dialog alert"> >- <h3>Error adding items:</h3> >+ <h3>Error receiving items:</h3> > <ul> >- [% FOREACH error_loo IN error_loop %] >- <li>[% error_loo.error_param %][% IF ( error_loo.error_duplicate_barcode ) %]Duplicate Barcode[% END %] <!-- todo: other error conditions come here. --></li> >- [% END %] >+ [% FOREACH error IN error_loop %] >+ <li> >+ [% error.error_param %] >+ [% IF ( error.error_duplicate_barcode ) %] >+ Duplicate Barcode >+ [% ELSIF (error.error_cannot_receive_order) %] >+ You were not authorised to receive this order >+ [% END %] >+ <!-- todo: other error conditions come here. --> >+ </li> >+ [% END %] > </ul> > </div> > [% END %] >@@ -215,6 +223,12 @@ > </div> > [% END %] > >+ [% IF error_cannot_receive_order %] >+ <div class="dialog error"> >+ You cannot receive this order. >+ </div> >+ [% END %] >+ > [% UNLESS no_orders_to_display %] > <div id="acqui_receive_summary"> > <p><strong>Invoice number:</strong> [% invoice %] <strong>Received by:</strong> [% loggedinusername %] <strong>On:</strong> [% formatteddatereceived %]</p> >@@ -293,7 +307,11 @@ > <td>[% loop_order.ordertotal %]</td> > <td>[% loop_order.budget_name %]</td> > <td> >+ [% IF (loop_order.can_receive) %] > <a href="orderreceive.pl?ordernumber=[% loop_order.ordernumber %]&invoiceid=[% invoiceid %]">Receive</a> >+ [% ELSE %] >+ Can't receive order >+ [% END %] > <br /> > <a href="#" onclick="transfer_order_popup([% loop_order.ordernumber %]); return false;">Transfer</a> > </td> >diff --git a/t/Acquisition/CanUserReceiveBasket.t b/t/Acquisition/CanUserReceiveBasket.t >new file mode 100644 >index 0000000..a0c4633 >--- /dev/null >+++ b/t/Acquisition/CanUserReceiveBasket.t >@@ -0,0 +1,111 @@ >+#!/usr/bin/perl >+ >+use Modern::Perl; >+use Test::MockModule; >+use Test::More tests => 30; >+ >+use C4::Acquisition; >+ >+my $C4_Acquisition_module = new Test::MockModule('C4::Acquisition'); >+$C4_Acquisition_module->mock('GetBasket', \&Mock_GetBasket); >+my $C4_Context_module = new Test::MockModule('C4::Context'); >+$C4_Context_module->mock('userenv', \&Mock_userenv); >+ >+my $baskets = { >+ 1 => {}, >+ 2 => { >+ branch => 'B1' >+ }, >+ 3 => { >+ branch => 'B2' >+ } >+}; >+ >+my $userenv = {}; >+ >+my $borrower = {}; >+ >+my $order1 = { >+ basketno => 1 >+}; >+my $order2 = { >+ basketno => 1, >+ branch => 'B1' >+}; >+my $order3 = { >+ basketno => 1, >+ branch => 'B2' >+}; >+my $order4 = { >+ basketno => 2 >+}; >+my $order5 = { >+ basketno => 2, >+ branch => 'B1' >+}; >+my $order6 = { >+ basketno => 2, >+ branch => 'B2' >+}; >+my $order7 = { >+ basketno => 3 >+}; >+my $order8 = { >+ basketno => 3, >+ branch => 'B1' >+}; >+my $order9 = { >+ basketno => 3, >+ branch => 'B2' >+}; >+ >+$userenv->{branch} = 'B1'; >+ >+ok( CanUserReceiveOrder($borrower, $order1, {superlibrarian => 1}) ); >+ok( CanUserReceiveOrder($borrower, $order1, {acquisition => 1}) ); >+ok( CanUserReceiveOrder($borrower, $order1, {acquisition => { order_receive_all => 1 }}) ); >+ >+ok( not CanUserReceiveOrder($borrower, $order1, {}) ); >+ok( not CanUserReceiveOrder($borrower, $order1, {acquisition => 0}) ); >+ok( not CanUserReceiveOrder($borrower, $order1, {acquisition => { order_receive => 0 }}) ); >+ >+ok( CanUserReceiveOrder($borrower, $order1, {acquisition => { order_receive => 1 }}) ); >+ok( CanUserReceiveOrder($borrower, $order2, {acquisition => { order_receive => 1 }}) ); >+ok( not CanUserReceiveOrder($borrower, $order3, {acquisition => { order_receive => 1 }}) ); >+ok( CanUserReceiveOrder($borrower, $order4, {acquisition => { order_receive => 1 }}) ); >+ok( CanUserReceiveOrder($borrower, $order5, {acquisition => { order_receive => 1 }}) ); >+ok( not CanUserReceiveOrder($borrower, $order6, {acquisition => { order_receive => 1 }}) ); >+ok( not CanUserReceiveOrder($borrower, $order7, {acquisition => { order_receive => 1 }}) ); >+ok( CanUserReceiveOrder($borrower, $order8, {acquisition => { order_receive => 1 }}) ); >+ok( not CanUserReceiveOrder($borrower, $order9, {acquisition => { order_receive => 1 }}) ); >+ >+ >+$userenv->{branch} = 'B2'; >+ >+ok( CanUserReceiveOrder($borrower, $order1, {superlibrarian => 1}) ); >+ok( CanUserReceiveOrder($borrower, $order1, {acquisition => 1}) ); >+ok( CanUserReceiveOrder($borrower, $order1, {acquisition => { order_receive_all => 1 }}) ); >+ >+ok( not CanUserReceiveOrder($borrower, $order1, {}) ); >+ok( not CanUserReceiveOrder($borrower, $order1, {acquisition => 0}) ); >+ok( not CanUserReceiveOrder($borrower, $order1, {acquisition => { order_receive => 0 }}) ); >+ >+ok( CanUserReceiveOrder($borrower, $order1, {acquisition => { order_receive => 1 }}) ); >+ok( not CanUserReceiveOrder($borrower, $order2, {acquisition => { order_receive => 1 }}) ); >+ok( CanUserReceiveOrder($borrower, $order3, {acquisition => { order_receive => 1 }}) ); >+ok( not CanUserReceiveOrder($borrower, $order4, {acquisition => { order_receive => 1 }}) ); >+ok( not CanUserReceiveOrder($borrower, $order5, {acquisition => { order_receive => 1 }}) ); >+ok( CanUserReceiveOrder($borrower, $order6, {acquisition => { order_receive => 1 }}) ); >+ok( CanUserReceiveOrder($borrower, $order7, {acquisition => { order_receive => 1 }}) ); >+ok( not CanUserReceiveOrder($borrower, $order8, {acquisition => { order_receive => 1 }}) ); >+ok( CanUserReceiveOrder($borrower, $order9, {acquisition => { order_receive => 1 }}) ); >+ >+sub Mock_GetBasket { >+ my ($basketno) = @_; >+ >+ return $baskets->{$basketno}; >+} >+ >+sub Mock_userenv { >+ return $userenv; >+} >-- >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 7290
:
9314
|
9399
|
9944
|
11444
|
13214
|
14517
|
25068
|
26669
|
26671
|
26676
|
28386
|
28387
|
28388
|
28405
|
28406
|
28407
|
30337
|
30338
|
30339
|
30340
|
30926
|
30927
|
30928
|
32074
|
32075
|
32076
|
32077
|
35700
|
35701
|
35702
|
35935
|
35936
|
35937