From cc2c282a76c7ef93b8d44e43fdacff485ece0256 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Fri, 13 Jan 2012 16:55:10 +0100 Subject: [PATCH 2/2] Bug 7175: Allow to choose which items to receive If AcqCreateItem=ordering, when you receive an order, you now have a list of all created items and checkboxes that permit you to choose which items you want to receive. A 'Edit' link open additem.pl page in a popup to allow you edit the items before receiving them (popup is automatically closed after modification, and orderreceive.pl page is reloaded to show modifications) If quantity is set manually in the text box, the appropriate number of checkbox are checked from top to bottom and a warning shows up if quantity is greater than order quantity --- C4/Acquisition.pm | 41 ++++++- acqui/finishreceive.pl | 9 +- acqui/orderreceive.pl | 41 ++++++- cataloguing/additem.pl | 1 + .../prog/en/modules/acqui/orderreceive.tt | 122 +++++++++++++++++--- .../prog/en/modules/cataloguing/additem.tt | 9 ++ 6 files changed, 199 insertions(+), 24 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 0a96a02..189639e 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -56,7 +56,7 @@ BEGIN { &ModReceiveOrder &ModOrderBiblioitemNumber &GetCancelledOrders - &NewOrderItem &ModOrderItem + &NewOrderItem &ModOrderItem &ModItemOrder &GetParcels &GetParcel &GetContracts &GetContract @@ -1018,6 +1018,29 @@ sub ModOrderItem { return 0; } +=head3 ModItemOrder + + ModItemOrder($itemnumber, $ordernumber); + +Modifies the ordernumber of an item in aqorders_items. + +=cut + +sub ModItemOrder { + my ($itemnumber, $ordernumber) = @_; + + return unless ($itemnumber and $ordernumber); + + my $dbh = C4::Context->dbh; + my $query = qq{ + UPDATE aqorders_items + SET ordernumber = ? + WHERE itemnumber = ? + }; + my $sth = $dbh->prepare($query); + return $sth->execute($ordernumber, $itemnumber); +} + #------------------------------------------------------------# @@ -1103,7 +1126,7 @@ C<$ordernumber>. sub ModReceiveOrder { my ( $biblionumber, $ordernumber, $quantrec, $user, $cost, - $invoiceno, $freight, $rrp, $budget_id, $datereceived + $invoiceno, $freight, $rrp, $budget_id, $datereceived, $received_items ) = @_; my $dbh = C4::Context->dbh; @@ -1146,7 +1169,19 @@ sub ModReceiveOrder { $order->{'quantity'} -= $quantrec; $order->{'quantityreceived'} = 0; my $newOrder = NewOrder($order); -} else { + # Change ordernumber in aqorders_items for items not received + my @orderitems = GetItemnumbersFromOrder( $order->{'ordernumber'} ); + my $count = scalar @orderitems; + + for (my $i=0; $i<$count; $i++){ + foreach (@$received_items){ + splice (@orderitems, $i, 1) if ($orderitems[$i] == $_); + } + } + foreach (@orderitems) { + ModItemOrder($_, $newOrder); + } + } else { $sth=$dbh->prepare("update aqorders set quantityreceived=?,datereceived=?,booksellerinvoicenumber=?, unitprice=?,freight=?,rrp=? diff --git a/acqui/finishreceive.pl b/acqui/finishreceive.pl index 90a85fe..81e716d 100755 --- a/acqui/finishreceive.pl +++ b/acqui/finishreceive.pl @@ -92,9 +92,14 @@ if ($quantityrec > $origquantityrec ) { NewOrderItem($itemnumber, $ordernumber); } } - + + my @received_items = (); + if(C4::Context->preference('AcqCreateItem') eq 'ordering') { + @received_items = $input->param('items_to_receive'); + } + # save the quantity received. - $datereceived = ModReceiveOrder($biblionumber,$ordernumber, $quantityrec ,$user,$unitprice,$invoiceno,$freight,$replacement,undef,$datereceived); + $datereceived = ModReceiveOrder($biblionumber,$ordernumber, $quantityrec ,$user,$unitprice,$invoiceno,$freight,$replacement,undef,$datereceived, \@received_items); } update_item( $_ ) foreach GetItemnumbersFromOrder( $ordernumber ); diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl index 9ef0545..ee9e7f7 100755 --- a/acqui/orderreceive.pl +++ b/acqui/orderreceive.pl @@ -112,17 +112,47 @@ my $count = scalar @$results; # prepare the form for receiving if ( $count == 1 ) { my $order = $results->[0]; - if (C4::Context->preference('AcqCreateItem') eq 'receiving') { + my $AcqCreateItem = C4::Context->preference('AcqCreateItem'); + if ($AcqCreateItem eq 'receiving') { # prepare empty item form my $cell = PrepareItemrecordDisplay('','','','ACQ'); unless ($cell) { $cell = PrepareItemrecordDisplay('','','',''); $template->param('NoACQframework' => 1); } - my @itemloop; - push @itemloop,$cell; - - $template->param(items => \@itemloop); + + $template->param(itemform => $cell); + } elsif ($AcqCreateItem eq 'ordering') { + my @itemnumbers = GetItemnumbersFromOrder($order->{ordernumber}); + my @items; + foreach (@itemnumbers) { + my $item = GetItem($_); + if($item->{homebranch}) { + $item->{homebranchname} = GetBranchName($item->{homebranch}); + } + if($item->{holdingbranch}) { + $item->{holdingbranchname} = GetBranchName($item->{holdingbranch}); + } + if(my $code = GetAuthValCode("items.notforloan", "ACQ")) { + $item->{notforloan} = GetKohaAuthorisedValueLib($code, $item->{notforloan}); + } + if(my $code = GetAuthValCode("items.restricted", "ACQ")) { + $item->{restricted} = GetKohaAuthorisedValueLib($code, $item->{restricted}); + } + if(my $code = GetAuthValCode("items.location", "ACQ")) { + $item->{location} = GetKohaAuthorisedValueLib($code, $item->{location}); + } + if(my $code = GetAuthValCode("items.ccode", "ACQ")) { + $item->{collection} = GetKohaAuthorisedValueLib($code, $item->{ccode}); + } + if(my $code = GetAuthValCode("items.materials", "ACQ")) { + $item->{materials} = GetKohaAuthorisedValueLib($code, $item->{materials}); + } + my $itemtype = getitemtypeinfo($item->{itype}); + $item->{itemtype} = $itemtype->{description}; + push @items, $item; + } + $template->param(items => \@items); } if ( $order->{'unitprice'} == 0 ) { @@ -137,6 +167,7 @@ if ( $count == 1 ) { my $budget = GetBudget( $order->{'budget_id'} ); $template->param( + AcqCreateItem => $AcqCreateItem, count => 1, biblionumber => $order->{'biblionumber'}, ordernumber => $order->{'ordernumber'}, diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index 4bf06b5..7039371 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -725,6 +725,7 @@ $template->param( itemtagsubfield => $itemtagsubfield, op => $nextop, opisadd => ($nextop eq "saveitem") ? 0 : 1, + popup => $input->param('popup') ? 1: 0, C4::Search::enabled_staff_search_views, ); 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 e238278..df91cd2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt @@ -2,6 +2,50 @@ Koha › Acquisitions › Receipt summary for : [% name %] [% IF ( invoice ) %]invoice, [% invoice %][% END %] [% INCLUDE 'doc-head-close.inc' %] + [% INCLUDE 'header.inc' %] @@ -48,17 +92,64 @@ [% END %] - [% IF ( items ) %] + [% IF (AcqCreateItem == 'ordering') %] + [% IF (items.size) %] +
Items
+
+ + + + + + + + + + + + + + + + + + + + + + [% FOREACH item IN items %] + + + + + + + + + + + + + + + + + + [% END %] + +
Receive? BarcodeHome branchHolding branchNot for loanRestrictedLocationCall numberCopy numberStock numberCollectionItem typeMaterialsNotes
Edit[% item.barcode %][% item.homebranchname %][% item.holdingbranchname %][% item.notforloan %][% item.restricted %][% item.location %][% item.itemcallnumber %][% item.copynumber %][% item.stocknumber %][% item.collection %][% item.itemtype %][% item.materials %][% item.itemnotes %]
+
+ [% END %] + [% ELSIF (AcqCreateItem == 'receiving') %]
Item [% IF ( NoACQframework ) %]

No ACQ framework, using default. You should create a framework with code ACQ, the items framework would be used

[% END %] - [% FOREACH item IN items %]
-
    [% FOREACH iteminformatio IN item.iteminformation %]
  1. +
      [% FOREACH iteminformatio IN itemform.iteminformation %]
    1. @@ -75,21 +166,20 @@
    2. [% END %]
    - Add - + Add +
- - - - + + + + - + [% END %]
- [% END %] @@ -107,9 +197,9 @@
  • [% IF ( memberfirstname and membersurname ) %][% IF ( memberfirstname ) %][% memberfirstname %][% END %] [% membersurname %][% ELSE %]No name[% END %]
  • [% IF ( edit ) %] - + [% ELSE %] - + [% END %]
  • @@ -127,12 +217,16 @@ [% END %] [% ELSE %] [% IF ( items ) %] - + [% ELSE %] [% END %] [% END %] +
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt index 91c2d48..4ad7581 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt @@ -4,6 +4,12 @@