Bugzilla – Attachment 13214 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), 39.35 KB, created by
Julian Maurice
on 2012-11-02 12:31:28 UTC
(
hide
)
Description:
Bug 7290: More granular permissions for order receiving
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2012-11-02 12:31:28 UTC
Size:
39.35 KB
patch
obsolete
>From fb0e7ef96d94f983d2c4fdc9297237f96d9d5612 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Fri, 27 Apr 2012 16:28:12 +0200 >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 > >This patch needs patch for bug 7295 (for basket branch) > >Unit tests are available in t/Acquisition/CanUserReceiveBasket.t >--- > C4/Acquisition.pm | 71 +++++++++ > acqui/addorder.pl | 1 + > acqui/finishreceive.pl | 16 +- > acqui/neworderempty.pl | 6 +- > acqui/orderreceive.pl | 15 +- > acqui/parcel.pl | 60 +------- > .../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 | 153 +++++++------------- > t/Acquisition/CanUserReceiveBasket.t | 111 ++++++++++++++ > 21 files changed, 329 insertions(+), 156 deletions(-) > create mode 100644 t/Acquisition/CanUserReceiveBasket.t > >diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm >index 835bb16..294846d 100644 >--- a/C4/Acquisition.pm >+++ b/C4/Acquisition.pm >@@ -50,6 +50,7 @@ BEGIN { > > &GetBasketUsers &ModBasketUsers > &CanUserManageBasket >+ &CanUserReceiveOrder > > &ModBasketHeader > >@@ -746,6 +747,76 @@ sub CanUserManageBasket { > return 1; > } > >+=head3 CanUserReceiveBasket >+ >+ my $bool = CanUserReceiveBasket($borrower, $order[, $userflags]); >+ my $bool = CanUserReceiveBasket($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 1dfa0b1..7c3339e 100755 >--- a/acqui/addorder.pl >+++ b/acqui/addorder.pl >@@ -153,6 +153,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > my $orderinfo = $input->Vars; > $orderinfo->{'list_price'} ||= 0; > $orderinfo->{'uncertainprice'} ||= 0; >+$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 0ea16ca..58500b3 100755 >--- a/acqui/finishreceive.pl >+++ b/acqui/finishreceive.pl >@@ -36,7 +36,9 @@ 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 +60,18 @@ my $rrp = $input->param('rrp'); > my $note = $input->param("note"); > my $order = GetOrder($ordernumber); > >+my $borrower = C4::Members::GetMember(userid => $userid); >+unless (CanUserReceiveOrder($borrower, $ordernumber, $userflags)) { >+ my $error = "cannot_receive_order"; >+ $error_url_str = "&error=$error"; >+ print $input->redirect( >+ "/cgi-bin/koha/acqui/parcel.pl?invoice=$invoiceno" >+ . "&booksellerid=$booksellerid&freight=$freight&gst=$gst" >+ . "&datereceived=$datereceived$error_url_str" >+ ); >+ 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 4144033..622d44d 100755 >--- a/acqui/neworderempty.pl >+++ b/acqui/neworderempty.pl >@@ -66,8 +66,8 @@ the item's id in the breeding reservoir > > =cut > >-use warnings; >-use strict; >+use Modern::Perl; >+ > use CGI; > use C4::Context; > use C4::Input; >@@ -239,7 +239,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 17c2d5e..dabba02 100755 >--- a/acqui/orderreceive.pl >+++ b/acqui/orderreceive.pl >@@ -95,7 +95,8 @@ $datereceived = $datereceived ? C4::Dates->new($datereceived, 'iso') : C4::Dates > my $bookseller = GetBookSellerFromId($booksellerid); > my $results = SearchOrder($ordernumber,$search); > >-my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ >+my ( $template, $loggedinuser, $cookie, $userflags ) = get_template_and_user( > { > template_name => "acqui/orderreceive.tmpl", > query => $input, >@@ -111,6 +112,18 @@ my $count = scalar @$results; > if ( $count == 1 ) { > 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 0e0f41b..1b52816 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; >@@ -108,7 +107,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.tmpl", > query => $input, > type => "intranet", >@@ -136,10 +135,6 @@ my $datereceived = C4::Dates->new(); > my $code = $input->param('code'); > my @rcv_err = $input->param('error'); > my @rcv_err_barcode = $input->param('error_bc'); >-my $startfrom=$input->param('startfrom'); >-my $resultsperpage = $input->param('resultsperpage'); >-$resultsperpage = 20 unless ($resultsperpage); >-$startfrom=0 unless ($startfrom); > > > >@@ -214,18 +209,7 @@ push @book_foot_loop, map { $_ } values %foot; > > my @loop_orders = (); > if(!defined $invoice->{closedate}) { >- my $pendingorders; >- if($input->param('op') eq "search"){ >- my $search = $input->param('summaryfilter') || ''; >- my $ean = $input->param('eanfilter') || ''; >- my $basketno = $input->param('basketfilter') || ''; >- my $orderno = $input->param('orderfilter') || ''; >- my $grouped; >- my $owner; >- $pendingorders = GetPendingOrders($booksellerid,$grouped,$owner,$basketno,$orderno,$search,$ean); >- }else{ >- $pendingorders = GetPendingOrders($booksellerid); >- } >+ my $pendingorders = GetPendingOrders($booksellerid); > my $countpendings = scalar @$pendingorders; > > for (my $i = 0 ; $i < $countpendings ; $i++) { >@@ -278,43 +262,12 @@ if(!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'}; > >- push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage); >- } >- >- my $count = $countpendings; >- >- if ($count>$resultsperpage){ >- my $displaynext=0; >- my $displayprev=$startfrom; >- if(($count - ($startfrom+$resultsperpage)) > 0 ) { >- $displaynext = 1; >- } >- >- my @numbers = (); >- for (my $i=1; $i<$count/$resultsperpage+1; $i++) { >- my $highlight=0; >- ($startfrom/$resultsperpage==($i-1)) && ($highlight=1); >- push @numbers, { number => $i, >- highlight => $highlight , >- startfrom => ($i-1)*$resultsperpage}; >- } >- >- my $from = $startfrom*$resultsperpage+1; >- my $to; >- if($count < (($startfrom+1)*$resultsperpage)){ >- $to = $count; >- } else { >- $to = (($startfrom+1)*$resultsperpage); >- } >- $template->param(numbers=>\@numbers, >- displaynext=>$displaynext, >- displayprev=>$displayprev, >- nextstartfrom=>(($startfrom+$resultsperpage<$count)?$startfrom+$resultsperpage:$count), >- prevstartfrom=>(($startfrom-$resultsperpage>0)?$startfrom-$resultsperpage:0) >- ); >+ push @loop_orders, \%line; > } > > $template->param( >@@ -338,7 +291,6 @@ $template->param( > book_foot_loop => \@book_foot_loop, > totalprice => sprintf($cfstr, $totalprice), > totalquantity => $totalquantity, >- resultsperpage => $resultsperpage, > (uc(C4::Context->preference("marcflavour"))) => 1, > total_quantity => $total_quantity, > total_gste => sprintf( "%.2f", $total_gste ), >diff --git a/installer/data/mysql/de-DE/mandatory/userpermissions.sql b/installer/data/mysql/de-DE/mandatory/userpermissions.sql >index f1ddcdd..694ad71 100644 >--- a/installer/data/mysql/de-DE/mandatory/userpermissions.sql >+++ b/installer/data/mysql/de-DE/mandatory/userpermissions.sql >@@ -18,6 +18,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', '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', 'Manage all budgets'), > (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 0c9c952..f6f6432 100644 >--- a/installer/data/mysql/en/mandatory/userpermissions.sql >+++ b/installer/data/mysql/en/mandatory/userpermissions.sql >@@ -18,6 +18,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 0c9c952..f6f6432 100644 >--- a/installer/data/mysql/es-ES/mandatory/userpermissions.sql >+++ b/installer/data/mysql/es-ES/mandatory/userpermissions.sql >@@ -18,6 +18,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 86a7d10..7b2f66b 100644 >--- a/installer/data/mysql/fr-FR/1-Obligatoire/userpermissions.sql >+++ b/installer/data/mysql/fr-FR/1-Obligatoire/userpermissions.sql >@@ -35,6 +35,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 2de4066..341a602 100644 >--- a/installer/data/mysql/it-IT/necessari/userpermissions.sql >+++ b/installer/data/mysql/it-IT/necessari/userpermissions.sql >@@ -20,6 +20,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', 'Gestisci ordini e raccoglitori raggruppati'), > (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', 'Manage all 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 b5b0fa2..1524c73 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -2817,13 +2817,16 @@ CREATE TABLE `aqorders` ( -- information related to the basket line items > `claims_count` int(11) default 0, -- count of claim letters generated > `claimed_date` date default NULL, -- last date a claim was generated > 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 > 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_ibfk_4 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 90aa9d1..2edb480 100644 >--- a/installer/data/mysql/nb-NO/1-Obligatorisk/userpermissions.sql >+++ b/installer/data/mysql/nb-NO/1-Obligatorisk/userpermissions.sql >@@ -39,6 +39,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', 'Manage all budgets'), > (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 a3d487d..f5068fb 100644 >--- a/installer/data/mysql/pl-PL/mandatory/userpermissions.sql >+++ b/installer/data/mysql/pl-PL/mandatory/userpermissions.sql >@@ -18,6 +18,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 f7bf478..ed9360a 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 >@@ -42,6 +42,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 deae407..290dfaa 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 >@@ -42,6 +42,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 52a75b6..1dbd1de 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -6053,6 +6053,22 @@ if ( C4::Context->preference("Version") < TransformToNum($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 > >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 96c6fb6..2e92afd 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt >@@ -211,6 +211,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 c6559c3..7f6f3f7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >@@ -135,6 +135,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"> >@@ -350,6 +354,7 @@ > </div> > [% 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 833e606..a437146 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt >@@ -8,104 +8,65 @@ > <script type="text/javascript" src="[% themelang %]/js/datatables.js"></script> > [% INCLUDE 'greybox.inc' %] > <script type="text/javascript" src="[% yuipath %]/json/json-min.js"></script> >+<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script> >+[% INCLUDE 'datatables-strings.inc' %] >+<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script> > <script type="text/javascript"> > //<![CDATA[ > > dt_overwrite_html_sorting_localeCompare(); >+ var pendingt; > > var rowsToCollapse = 5; > $(document).ready(function(){ >- var pendingt = $("#pendingt").dataTable($.extend(true, {}, dataTablesDefaults, { >+ pendingt = $("#pendingt").dataTable($.extend(true, {}, dataTablesDefaults, { > "aoColumnDefs": [ >- { "aTargets": [ 3, 8, 9 ], "bSortable": false, "bSearchable": false }, >- ], >- "aoColumns": [ >- { "sType": "num-html" }, >- { "sType": "num-html" }, >- { "sType": "html" }, >- null, >- null, >- null, >- null, >- null, >- null, >- null, >+ { "aTargets": [ 4, 9, 10 ], "bSortable": false, "bSearchable": false }, >+ { "aTargets": [ 0, 1 ], "sType": "num-html" }, >+ { "aTargets": [ 2 ], "sType": "html" }, >+ { "aTargets": [ 3 ], "bVisible": false } > ], > "sPaginationType": "four_button" > } ) ); > var receivedt = $("#receivedt").dataTable($.extend(true, {}, dataTablesDefaults, { > "aoColumnDefs": [ > { "aTargets": [ 3, -1 ], "bSortable": false, "bSearchable": false }, >- ], >- "aoColumns": [ >- { "sType": "num-html" }, >- { "sType": "num-html" }, >- { "sType": "html" }, >- null, >- null, >- null, >- null, >- null, >- null >+ { "aTargets": [ 0, 1 ], "sType": "num-html" }, >+ { "aTargets": [ 2 ], "sType": "html" } > ], > "sPaginationType": "four_button" > } ) ); >-/* >- $("#pendingt").tablesorter({ >- headers: { 2: { sorter: 'articles' },3: { sorter: false },8:{sorter:false}} > }); >-*/ >- >- rowCountPending = $("#pendingt tbody.filterclass tr").length; >- rowCountReceived = $("#receivedt tbody.filterclass tr").length; >- if (rowCountPending > rowsToCollapse ) { if ( $.cookie("pendingKeepExpanded") != 1 ) { pendingCollapse(); } else { pendingExpand(); } } >- if (rowCountReceived > rowsToCollapse ) { if ( $.cookie("receivedKeepExpanded") != 1 ) { receivedCollapse(); } else { receivedExpand(); } } >- }); >- >- // Case-insensitive version of jquery's contains function >- jQuery.extend(jQuery.expr[':'], { >- icontains : "jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0" >- }); >- >- // Contains exactly function >- jQuery.extend(jQuery.expr[':'], { >- containsExactly: "$(a).text() == m[3]" >- }); >- >- >- // Collapse pending items table >- function pendingCollapse() { >- $.cookie("pendingKeepExpanded", 0, { path: "/", expires: 9999 }); >- $("#pendingcollapserow").remove(); >- $("#pendingt tr").show(); >- $("#pendingt tbody.filterclass tr:gt(" + (rowsToCollapse-1) + ")").hide(); >- $("#pendingt").before("<p id=\"pendingcollapserow\">" + _("Only the first ") + rowsToCollapse + _(" items are displayed.") + " <a href=\"javascript:pendingExpand();\">" + _("Click here to show all ") + rowCountPending + _(" items") + "<\/a>.<\/p>"); > >- } >+ function filter() { >+ var summaryStatus = jQuery.trim($("#summaryfilter").val()); >+ var basketStatus = $("#basketfilter").val(); >+ var orderStatus = $("#orderfilter").val(); >+ var eanfilter = $("#eanfilter").val(); > >- // Expend pending items table >- function pendingExpand() { >- $.cookie("pendingKeepExpanded", 1, { path: "/", expires: 9999 }); >- $("#pendingcollapserow").remove(); >- $("#pendingt tr").show(); >- $("#pendingt tbody.filterclass tr.orderfound").remove(); >- $("#pendingt").before("<p id=\"pendingcollapserow\">" + rowCountPending + _(" items are displayed.") + " <a href=\"javascript:pendingCollapse();\">" + _("Click here to show only the first ") + rowsToCollapse + _(" items") + "<\/a>.<\/p>"); >- } >+ if (summaryStatus == '' && basketStatus == '' && orderStatus == '' && eanfilter == '') { >+ clearFilters(); >+ return false; >+ } >+ pendingt.fnFilter(summaryStatus,2); >+ pendingt.fnFilter(orderStatus,1); >+ pendingt.fnFilter(basketStatus,0); >+ pendingt.fnFilter(eanfilter, 3); > >- // Collapse already received items table >- function receivedCollapse() { >- $.cookie("receivedKeepExpanded", 0, { path: "/", expires: 9999 }); >- $("#receivedcollapserow").remove(); >- $("#receivedt tbody.filterclass tr:gt(" + (rowsToCollapse-1) + ")").hide(); >- $("#receivedt").before("<p id=\"receivedcollapserow\">" + _("Only the first ") + rowsToCollapse + _(" items are displayed.") + " <a href=\"javascript:receivedExpand();\">" + _("Click here to show all ") + rowCountReceived + _(" items") + "<\/a>.<\/p>"); >+ return false; > } > >- // Expand already received items table >- function receivedExpand() { >- $.cookie("receivedKeepExpanded", 1, { path: "/", expires: 9999 }); >- $("#receivedcollapserow").remove(); >- $("#receivedt tr").show(); >- $("#receivedt").before("<p id=\"receivedcollapserow\">" + _("All ") + rowCountReceived + _(" items are displayed.") + " <a href=\"javascript:receivedCollapse();\">" + _("Click here to show only the first ") + rowsToCollapse + _(" items") + "<\/a>.<\/p>"); >+ // Clear already applied filters >+ function clearFilters() { >+ $("#summaryfilter").val(''); >+ $("#basketfilter").val(''); >+ $("#orderfilter").val(''); >+ $("#eanfilter").val(''); >+ var oSettings = pendingt.fnSettings(); >+ for(iCol = 0; iCol < oSettings.aoPreSearchCols.length; iCol++) { >+ oSettings.aoPreSearchCols[ iCol ].sSearch = ''; >+ } >+ pendingt.fnDraw(); > } > > //]]> >@@ -151,11 +112,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 %] >@@ -209,6 +178,7 @@ > <th>Basket</th> > <th>Order line</th> > <th>Summary</th> >+ <th>EAN</th> > <th>View record</th> > <th>Quantity</th> > <th>Unit cost</th> >@@ -240,13 +210,18 @@ > [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% loop_order.ordernumber %]&referrer=/cgi-bin/koha/acqui/parcel.pl%3Fbooksellerid=[% loop_order.booksellerid %]&datereceived=[% loop_order.invoicedatereceived %]&invoice=[% loop_order.invoice %]">Add note</a>] > [% END %] > </td> >+ <td>[% loop_order.ean %]</td> > <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% loop_order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&id=[% loop_order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">Card</a></td> > <td>[% loop_order.quantity %]</td> > <td>[% loop_order.ecost %]</td> > <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 %] > </td> > <td> > [% IF ( loop_order.left_holds_on_order ) %] >@@ -276,22 +251,6 @@ > [% END %] > </tbody> > </table>[% ELSE %]There are no pending orders.[% END %] >- <div id="resultnumber"> >- <!-- Row of numbers corresponding to search result pages --> >- [% IF ( displayprev ) %] >- <a href="parcel.pl?invoiceid=[% invoiceid %]&startfrom=[% prevstartfrom %][% IF ( resultsperpage ) %]&resultsperpage=[% resultsperpage %][% END %]#resultnumber"><< Previous</a> >- [% END %] >- [% FOREACH number IN numbers %] >- [% IF ( number.highlight ) %] >- <span class="current">[% number.number %]</span> >- [% ELSE %] >- <a href="parcel.pl?invoiceid=[% invoiceid %]&startfrom=[% number.startfrom %][% IF ( resultsperpage ) %]&resultsperpage=[% resultsperpage %][% END %]#resultnumber">[% number.number %]</a> >- [% END %] >- [% END %] >- [% IF ( displaynext ) %] >- <a href="parcel.pl?invoiceid=[% invoiceid %]&startfrom=[% nextstartfrom %][% IF ( resultsperpage ) %]&resultsperpage=[% resultsperpage %][% END %]#resultnumber">Next >></a> >- [% END %] >- </div> > </div> > [% ELSE %] > <p> >@@ -398,7 +357,7 @@ > </div> > </div> > <div class="yui-b"> >-<form action="/cgi-bin/koha/acqui/parcel.pl" id="filterform" method="post"> >+<form onsubmit="return filter();"> > <fieldset class="brief"> > > <h4>Filter</h4> >@@ -432,7 +391,7 @@ > <input type="hidden" value="[% invoice %]" name="invoice" /> > <input type="hidden" value="[% invoicedatereceived %]" name="datereceived" /> > <input type="submit" value="Filter" /> >- <a href="/cgi-bin/koha/acqui/parcel.pl?booksellerid=[% booksellerid %]&invoice=[% invoice %]&op=new&datereceived=[% formatteddatereceived %]">Clear</a> >+ <a href="#" onclick="clearFilters(); return false;">Clear</a> > </fieldset> > > >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