@@ -, +, @@ --- C4/Acquisition.pm | 41 ++++++- acqui/finishreceive.pl | 9 +- acqui/orderreceive.pl | 48 +++++++- catalogue/getitem-ajax.pl | 74 +++++++++++++ cataloguing/additem.pl | 1 + .../prog/en/modules/acqui/orderreceive.tt | 117 +++++++++++++++++++- .../prog/en/modules/cataloguing/additem.tt | 8 ++ 7 files changed, 284 insertions(+), 14 deletions(-) create mode 100755 catalogue/getitem-ajax.pl --- a/C4/Acquisition.pm +++ a/C4/Acquisition.pm @@ -57,7 +57,7 @@ BEGIN { &ModReceiveOrder &ModOrderBiblioitemNumber &GetCancelledOrders - &NewOrderItem &ModOrderItem + &NewOrderItem &ModOrderItem &ModItemOrder &GetParcels &GetParcel &GetContracts &GetContract @@ -1053,6 +1053,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); +} + #------------------------------------------------------------# @@ -1138,7 +1161,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; @@ -1181,7 +1204,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=? --- a/acqui/finishreceive.pl +++ a/acqui/finishreceive.pl @@ -94,9 +94,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 ); --- a/acqui/orderreceive.pl +++ a/acqui/orderreceive.pl @@ -112,16 +112,51 @@ my $count = scalar @$results; # prepare the form for receiving if ( $count == 1 ) { my $order = $results->[0]; - if (C4::Context->preference('AcqCreateItem') eq 'receiving') { - # Check if ACQ framework exists - my $marc = GetMarcStructure(1, 'ACQ'); - unless($marc) { - $template->param('NoACQframework' => 1); - } + + # Check if ACQ framework exists + my $acq_fw = GetMarcStructure(1, 'ACQ'); + unless($acq_fw) { + $template->param('NoACQframework' => 1); + } + + my $AcqCreateItem = C4::Context->preference('AcqCreateItem'); + if ($AcqCreateItem eq 'receiving') { $template->param( AcqCreateItemReceiving => 1, UniqueItemFields => C4::Context->preference('UniqueItemFields'), ); + } elsif ($AcqCreateItem eq 'ordering') { + my $fw = ($acq_fw) ? 'ACQ' : ''; + 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", $fw)) { + $item->{notforloan} = GetKohaAuthorisedValueLib($code, $item->{notforloan}); + } + if(my $code = GetAuthValCode("items.restricted", $fw)) { + $item->{restricted} = GetKohaAuthorisedValueLib($code, $item->{restricted}); + } + if(my $code = GetAuthValCode("items.location", $fw)) { + $item->{location} = GetKohaAuthorisedValueLib($code, $item->{location}); + } + if(my $code = GetAuthValCode("items.ccode", $fw)) { + $item->{collection} = GetKohaAuthorisedValueLib($code, $item->{ccode}); + } + if(my $code = GetAuthValCode("items.materials", $fw)) { + $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 ) { @@ -136,6 +171,7 @@ if ( $count == 1 ) { my $budget = GetBudget( $order->{'budget_id'} ); $template->param( + AcqCreateItem => $AcqCreateItem, count => 1, biblionumber => $order->{'biblionumber'}, ordernumber => $order->{'ordernumber'}, --- a/catalogue/getitem-ajax.pl +++ a/catalogue/getitem-ajax.pl @@ -0,0 +1,74 @@ +#!/usr/bin/perl + +# Copyright BibLibre 2012 +# +# 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., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; +use CGI; +use JSON; + +use C4::Biblio; +use C4::Branch; +use C4::Items; +use C4::Koha; +use C4::Output; + +my $cgi = new CGI; +my $item = {}; +my $itemnumber = $cgi->param('itemnumber'); + +if($itemnumber) { + my $acq_fw = GetMarcStructure(1, 'ACQ'); + my $fw = ($acq_fw) ? 'ACQ' : ''; + $item = GetItem($itemnumber); + + if($item->{homebranch}) { + $item->{homebranchname} = GetBranchName($item->{homebranch}); + } + + if($item->{holdingbranch}) { + $item->{holdingbranchname} = GetBranchName($item->{holdingbranch}); + } + + if(my $code = GetAuthValCode("items.notforloan", $fw)) { + $item->{notforloan} = GetKohaAuthorisedValueLib($code, $item->{notforloan}); + } + + if(my $code = GetAuthValCode("items.restricted", $fw)) { + $item->{restricted} = GetKohaAuthorisedValueLib($code, $item->{restricted}); + } + + if(my $code = GetAuthValCode("items.location", $fw)) { + $item->{location} = GetKohaAuthorisedValueLib($code, $item->{location}); + } + + if(my $code = GetAuthValCode("items.ccode", $fw)) { + $item->{collection} = GetKohaAuthorisedValueLib($code, $item->{ccode}); + } + + if(my $code = GetAuthValCode("items.materials", $fw)) { + $item->{materials} = GetKohaAuthorisedValueLib($code, $item->{materials}); + } + + my $itemtype = getitemtypeinfo($item->{itype}); + $item->{itemtype} = $itemtype->{description}; +} + +my $json_text = to_json( $item, { utf8 => 1 } ); + +output_with_http_headers $cgi, undef, $json_text, 'json'; + --- a/cataloguing/additem.pl +++ a/cataloguing/additem.pl @@ -724,6 +724,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, ); --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt @@ -32,9 +32,68 @@ return true; } + [% IF (AcqCreateItem == 'ordering') %] + var items_columns = [null, null, 'barcode', 'homebranchname', + 'holdingbranchname', 'notforloan', 'restricted', 'location', + 'itemcallnumber', 'copynumber', 'stocknumber', 'collection', + 'itemtype', 'materials', 'itemnotes']; + + function PopupEditPage(biblionumber, itemnumber) { + var url = "/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=" + + biblionumber + "&itemnumber=" + itemnumber + "&popup=1#edititem"; + var w = window.open(url); + var watchClose = setInterval(function() { + if (w.closed) { + clearTimeout(watchClose); + $.getJSON('/cgi-bin/koha/catalogue/getitem-ajax.pl', + { + 'itemnumber': itemnumber + }, + function(item) { + var tds = $("#item_"+itemnumber+" td"); + for(var i=2; i qtyto) { + $("#qtyrecerror").show(); + } else { + $("#qtyrecerror").hide(); + } + CheckNItems($(this).val()); + }); [% END %] }); //]]> @@ -127,7 +186,55 @@ [% END %]
- [% END %][%# IF (AcqCreateItemReceiving) %] + [% ELSIF (AcqCreateItem == 'ordering') %] + [% IF (items.size) %] +
Items
+
+ + + + + + + + + + + + + + + + + + + + + + [% FOREACH item IN items %] + + + + + + + + + + + + + + + + + + [% END %] + +
Receive? BarcodeHome branchHolding branchNot for loanRestrictedLocationCall numberCopy numberStock numberCollection codeItem 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 %] + [% END %] @@ -143,7 +250,7 @@
  • [% datereceived %]
  • [% bookfund %]
  • [% IF ( memberfirstname and membersurname ) %][% IF ( memberfirstname ) %][% memberfirstname %][% END %] [% membersurname %][% ELSE %]No name[% END %]
  • -
  • +
  • [% IF ( edit ) %] [% ELSE %] @@ -168,12 +275,16 @@ [% END %] [% ELSE %] [% IF ( items ) %] - + [% ELSE %] [% END %] [% END %] + [% END %][%# IF (AcqCreateItemReceiving) %]
  • --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt @@ -4,6 +4,11 @@