Bugzilla – Attachment 9591 Details for
Bug 7175
Improve order receiving page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 7175: Allow to choose which items to receive
0002-Bug-7175-Allow-to-choose-which-items-to-receive.patch (text/plain), 18.69 KB, created by
Julian Maurice
on 2012-05-15 15:05:49 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 7175: Allow to choose which items to receive
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2012-05-15 15:05:49 UTC
Size:
18.69 KB
patch
obsolete
>From e3ddd2a489b60035dbe506afda8d18352ba79694 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >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 items table is automatically updated) >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 | 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 > >diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm >index e881a16..4518d25 100644 >--- a/C4/Acquisition.pm >+++ b/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=? >diff --git a/acqui/finishreceive.pl b/acqui/finishreceive.pl >index d09a40a..84391f5 100755 >--- a/acqui/finishreceive.pl >+++ b/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 ); >diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl >index 430faf8..1ea0bd1 100755 >--- a/acqui/orderreceive.pl >+++ b/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'}, >diff --git a/catalogue/getitem-ajax.pl b/catalogue/getitem-ajax.pl >new file mode 100755 >index 0000000..772a352 >--- /dev/null >+++ b/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'; >+ >diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl >index 9c8120e..f970890 100755 >--- a/cataloguing/additem.pl >+++ b/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, > ); > >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 97a7223..821dcd3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >+++ b/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<tds.length; i++) { >+ var column = items_columns[i]; >+ $(tds[i]).text(item[column]); >+ } >+ } >+ ); >+ } >+ }, 500); >+ } >+ >+ function CalcQtyToReceive() { >+ var qty = $("input[name='items_to_receive']:checked").length; >+ $("#quantity").val(qty); >+ } >+ >+ function CheckNItems(n) { >+ $("input[name='items_to_receive']").each(function() { >+ $(this).attr('checked', false); >+ }); >+ $("input[name='items_to_receive']:lt("+n+")").each(function () { >+ $(this).attr('checked', true); >+ }); >+ } >+ [% END %] >+ > $(document).ready(function() { > [% IF (AcqCreateItemReceiving) %] > cloneItemBlock(0, '[% UniqueItemFields %]'); >+ [% ELSIF (AcqCreateItem == 'ordering') %] >+ $("input[name='items_to_receive']").change(function() { >+ CalcQtyToReceive(); >+ }); >+ CalcQtyToReceive(); >+ $("#quantity").keyup(function() { >+ var qty = parseInt($("#quantity").val()); >+ var qtyto = parseInt($("#quantity_to_receive").val()); >+ if(qty > qtyto) { >+ $("#qtyrecerror").show(); >+ } else { >+ $("#qtyrecerror").hide(); >+ } >+ CheckNItems($(this).val()); >+ }); > [% END %] > }); > //]]> >@@ -127,7 +186,55 @@ > [% END %] > <div id="outeritemblock"></div> > </fieldset> >- [% END %][%# IF (AcqCreateItemReceiving) %] >+ [% ELSIF (AcqCreateItem == 'ordering') %] >+ [% IF (items.size) %] >+ <h5>Items</h5> >+ <div style="width:100%;overflow:auto"> >+ <table> >+ <thead> >+ <tr> >+ <th>Receive?</th> >+ <th> </th> >+ <th>Barcode</th> >+ <th>Home branch</th> >+ <th>Holding branch</th> >+ <th>Not for loan</th> >+ <th>Restricted</th> >+ <th>Location</th> >+ <th>Call number</th> >+ <th>Copy number</th> >+ <th>Stock number</th> >+ <th>Collection code</th> >+ <th>Item type</th> >+ <th>Materials</th> >+ <th>Notes</th> >+ </tr> >+ </thead> >+ <tbody> >+ [% FOREACH item IN items %] >+ <tr id="item_[% item.itemnumber %]"> >+ <td style="text-align:center"><input type="checkbox" name="items_to_receive" value="[% item.itemnumber %]" /></td> >+ <td><a style="cursor:pointer" onclick="PopupEditPage([% item.biblionumber %],[% item.itemnumber %]);">Edit</a></td> >+ <td>[% item.barcode %]</td> >+ <td>[% item.homebranchname %]</td> >+ <td>[% item.holdingbranchname %]</td> >+ <td>[% item.notforloan %]</td> >+ <td>[% item.restricted %]</td> >+ <td>[% item.location %]</td> >+ <td>[% item.itemcallnumber %]</td> >+ <td>[% item.copynumber %]</td> >+ <td>[% item.stocknumber %]</td> >+ <td>[% item.collection %]</td> >+ <td>[% item.itemtype %]</td> >+ <td>[% item.materials %]</td> >+ <td>[% item.itemnotes %]</td> >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+ </div> >+ [% END %] >+ [% END %] > <input type="hidden" name="biblionumber" value="[% biblionumber %]" /> > <input type="hidden" name="ordernumber" value="[% ordernumber %]" /> > <input type="hidden" name="biblioitemnumber" value="[% biblioitemnumber %]" /> >@@ -143,7 +250,7 @@ > <li><label for="datereceived">Date received: </label><span> [% datereceived %] </span></li> > <li><label for="bookfund">Budget: </label><span> [% bookfund %] </span></li> > <li><label for="creator">Created by: </label><span> [% IF ( memberfirstname and membersurname ) %][% IF ( memberfirstname ) %][% memberfirstname %][% END %] [% membersurname %][% ELSE %]No name[% END %]</span></li> >- <li><label for="quantityto">Quantity to receive: </label><span class="label"> >+ <li><label for="quantity_to_receive">Quantity to receive: </label><span class="label"> > [% IF ( edit ) %] > <input type="text" id="quantity_to_receive" name="quantity" value="[% quantity %]" /> > [% ELSE %] >@@ -168,12 +275,16 @@ > [% END %] > [% ELSE %] > [% IF ( items ) %] >- <input READONLY type="text" id="quantity" size="20" name="quantityrec" value="1" /> >+ <input type="text" id="quantity" size="20" name="quantityrec" value="1" /> > [% ELSE %] > <input type="text" size="20" id="quantity" name="quantityrec" value="1" /> > [% END %] > <input id="origquantityrec" READONLY type="hidden" name="origquantityrec" value="0" /> > [% END %] >+ <div id="qtyrecerror" style="display:none"> >+ <p class="error">Warning, you have entered more items than expected. >+ Items will not be created.</p> >+ </div> > [% END %][%# IF (AcqCreateItemReceiving) %] > </li> > <li><label for="rrp">Replacement cost: </label><input type="text" size="20" name="rrp" id="rrp" value="[% rrp %]" /></li> >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 eabf5a8..296f795 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,11 @@ > <script type="text/javascript"> > //<![CDATA[ > $(document).ready(function(){ >+ [% IF (popup) %] >+ [% IF (opisadd) %] >+ window.close(); >+ [% END %] >+ [% END %] > $("fieldset.rows input").keydown(function(e){ return checkEnter(e); }); > /* Inline edit/delete links */ > var biblionumber = $("input[name='biblionumber']").attr("value"); >@@ -219,6 +224,9 @@ $(document).ready(function() { > <div id="cataloguing_additem_newitem"> > <form method="post" action="/cgi-bin/koha/cataloguing/additem.pl" name="f"> > <input type="hidden" name="op" value="[% op %]" /> >+ [% IF (popup) %] >+ <input type="hidden" name="popup" value="1" /> >+ [% END %] > <input type="hidden" name="biblionumber" value="[% biblionumber %]" /> > [% IF ( opisadd ) %] > <h2 id="additema">Add item</h2> >-- >1.7.10 >
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 7175
:
6232
|
7139
|
7141
|
7164
|
7278
|
7852
|
7853
|
8680
|
8681
|
8770
|
8771
|
8772
|
9145
|
9146
|
9147
|
9431
|
9432
|
9590
| 9591