[Koha-patches] [PATCH] Bug 10638 - Show alert when receiving an order with holds/reserves

Srdjan srdjan at catalyst.net.nz
Tue Jul 30 05:54:36 CEST 2013


From: David Cook <dcook at prosentient.com.au>

This patch adds an alert message in Acquisitions when receiving new
orders.

If there are bib-level holds for the bib record attached to that order,
it gives a count of the bib-level holds.

If there are item-level holds for items attached to that order, it
shows a count of the items as well as displaying the barcodes for the
items that have holds/reserves on them.

If there are item-level holds for items not attached to that order and
there are no bib-level holds, the message will just say that there are
pending reserves for that bib record.

TEST PLAN

1) Set AcqCreateItem to "placing an order"
2) Place an order in Acquisitions
3) Create three or four items when placing that order
4) In the OPAC or staff client, place a hold on one item
5) Receive the order
6) Note that there is no alert message about the hold/reserve

7) Apply the patch

8) Receive another item for that order
9) Note that there should now be a yellow alert message at the top of
the parcel.pl screen.

10) The message text will vary depending on the reserve/hold situation.

If there are bib-level holds, it will display a count of bib-level holds.

If there are item-level holds for items attached to that order, it will
show a count of those holds and print out their barcodes. (N.B. if you
are receiving part of an order, your order number will change, so it
will only print information for the received items that are attached
to this new order, rather than all items including the original order.)

If there are item-level holds for items attached to a different order
or no order at all, no specific information will be printed. It will
just say that there are pending reserves for that record (or that
there are bib-level holds, if there are bib-level holds).

Signed-off-by: Srdjan <srdjan at catalyst.net.nz>
---
 acqui/finishreceive.pl                             |  6 ++-
 acqui/parcel.pl                                    | 45 ++++++++++++++++++++++
 .../intranet-tmpl/prog/en/modules/acqui/parcel.tt  | 14 +++++++
 3 files changed, 64 insertions(+), 1 deletion(-)

diff --git a/acqui/finishreceive.pl b/acqui/finishreceive.pl
index f9c8532..80df8b6 100755
--- a/acqui/finishreceive.pl
+++ b/acqui/finishreceive.pl
@@ -41,6 +41,7 @@ checkauth($input, 0, $flagsrequired, 'intranet');
 my $user             = $input->remote_user;
 my $biblionumber     = $input->param('biblionumber');
 my $ordernumber      = $input->param('ordernumber');
+my $resordernumber   = $ordernumber;
 my $origquantityrec  = $input->param('origquantityrec');
 my $quantityrec      = $input->param('quantityrec');
 my $quantity         = $input->param('quantity');
@@ -136,11 +137,14 @@ if ($quantityrec > $origquantityrec ) {
         }
     }
 
+    if ($new_ordernumber) {
+        $resordernumber = $new_ordernumber;
+    }
 }
 
 update_item( $_ ) foreach GetItemnumbersFromOrder( $ordernumber );
 
-print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoiceid=$invoiceid");
+print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoiceid=$invoiceid&resbiblionumber=$biblionumber&resordernumber=$resordernumber");
 
 ################################ End of script ################################
 
diff --git a/acqui/parcel.pl b/acqui/parcel.pl
index ee96e3f..85d8a75 100755
--- a/acqui/parcel.pl
+++ b/acqui/parcel.pl
@@ -69,6 +69,8 @@ use C4::Dates qw/format_date format_date_in_iso/;
 use C4::Suggestions;
 use JSON;
 
+use C4::Reserves;
+
 my $input=new CGI;
 
 sub get_value_with_gst_params {
@@ -130,6 +132,49 @@ unless( $invoiceid and $invoice->{invoiceid} ) {
     exit;
 }
 
+my $received_biblionumber = $input->param('resbiblionumber');
+my $received_ordernumber = $input->param('resordernumber');
+if ($received_biblionumber && $received_ordernumber) {
+    my ($reserve_count, $title_reserves) = GetReservesFromBiblionumber($received_biblionumber);
+    if ($reserve_count > 0) {
+
+        my $bib_level_hold = 0;
+        my @matches;
+
+        my $received_biblio_data = GetBiblioData($received_biblionumber);
+        my @received_items = GetItemnumbersFromOrder($received_ordernumber);
+
+        foreach my $reserved_title (@$title_reserves) {
+            my $reserve_itemnumber = $reserved_title->{itemnumber};
+            if (defined $reserve_itemnumber) {
+                push(@matches, grep( $_ == $reserve_itemnumber, @received_items ));
+            }
+            else {
+                $bib_level_hold++;
+            }
+        }
+
+        if ($bib_level_hold > 0) {
+            $template->param('bib_level_holds'  => $bib_level_hold);
+        }
+        if (@matches) {
+            my @reserve_barcodes;
+            foreach my $itemnumber_match (@matches) {
+                my $result_barcode = GetBarcodeFromItemnumber($itemnumber_match);
+                push(@reserve_barcodes,$result_barcode);
+            }
+            if(@reserve_barcodes){
+                $template->param('item_level_holds' =>  \@reserve_barcodes);
+            }
+        }
+
+        $template->param(
+            bib_has_reserves => 1,
+            bib_title => $received_biblio_data->{title},
+        );
+    }
+}
+
 my $op = $input->param('op') // '';
 
 if ($op eq 'cancelreceipt') {
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 10382cb..0150ca7 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt
@@ -166,6 +166,20 @@
         </div>
     [% END %]
 
+    [% IF bib_has_reserves %]
+        <div class="dialog alert">
+            The record [% IF ( bib_title ) %] for "[% bib_title %]"[% END %] has
+            [% IF ( bib_level_holds ) %][% bib_level_holds %] bib-level [% END %]
+            [% IF ( item_level_holds ) %][% IF ( bib_level_holds ) %] and [% END %][% item_level_holds.size %] item-level [% END %]pending reserves.
+            <br /><br />
+            [% IF ( item_level_holds ) %]The item-level reserves are for the following barcodes:
+                <ul>
+                [% FOREACH item_hold IN item_level_holds %]<li>[% item_hold %]</li>[% END %]
+                </ul>
+            [% END %]
+        </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>
-- 
1.8.1.2


More information about the Koha-patches mailing list