From: Matthias Meusburger <[email protected]> Also fix the barcode not found problem (due to empty lines)
Signed-off-by: Henri-Damien LAURENT <[email protected]> --- C4/Biblio.pm | 19 +++++++++++ C4/Items.pm | 22 +++++++++++++ .../prog/en/modules/tools/batchMod-del.tmpl | 34 ++++++++++++++++--- .../prog/en/modules/tools/batchMod-edit.tmpl | 25 ++++++++++++++- tools/batchMod.pl | 21 ++++++++++-- 5 files changed, 110 insertions(+), 11 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 7e4df18..c78c380 100755 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -58,6 +58,7 @@ BEGIN { &GetBiblioItemInfosOf &GetBiblioItemByBiblioNumber &GetBiblioFromItemNumber + &GetBiblionumberFromItemnumber &GetRecordValue &GetFieldMapping @@ -718,6 +719,24 @@ sub GetBiblioItemByBiblioNumber { return @results; } +=head2 GetBiblionumberFromItemnumber + +=over 4 + +=back + +=cut + +sub GetBiblionumberFromItemnumber { + my ($itemnumber) = @_; + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare("Select biblionumber FROM items WHERE itemnumber = ?"); + + $sth->execute($itemnumber); + my ($result) = $sth->fetchrow; + return ($result); +} + =head2 GetBiblioFromItemNumber =over 4 diff --git a/C4/Items.pm b/C4/Items.pm index b1f0698..2ec4663 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -65,6 +65,7 @@ BEGIN { GetItemsInfo get_itemnumbers_of GetItemnumberFromBarcode + GetBarcodeFromItemnumber DelItemCheck MoveItemFromBiblio @@ -1516,6 +1517,27 @@ sub GetItemnumberFromBarcode { return ($result); } +=head2 GetBarcodeFromItemnumber + +=over 4 + +$result = GetBarcodeFromItemnumber($itemnumber); + +=back + +=cut + +sub GetBarcodeFromItemnumber { + my ($itemnumber) = @_; + my $dbh = C4::Context->dbh; + + my $rq = + $dbh->prepare("SELECT barcode FROM items WHERE items.itemnumber=?"); + $rq->execute($itemnumber); + my ($result) = $rq->fetchrow; + return ($result); +} + =head3 get_item_authorised_values find the types and values for all authorised values assigned to this item. diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tmpl index 7e7b98b..1ba9b24 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tmpl @@ -30,7 +30,6 @@ <!-- TMPL_IF NAME="book_on_loan" --><div class="dialog alert"><strong>Cannot Delete</strong>: item is checked out.</div><!-- /TMPL_IF --> <!-- TMPL_IF NAME="book_reserved" --><div class="dialogalert"><strong>Cannot Delete</strong>: item has a waiting hold.</div><!-- /TMPL_IF --> -<!-- TMPL_IF name="item_loop" --> <!-- TMPL_UNLESS name="action" --> <!-- TMPL_IF name="notfoundbarcodes" --> @@ -47,11 +46,14 @@ <!-- /TMPL_LOOP --> </tbody> </table></div> + <!-- TMPL_UNLESS name="too_many_items" --> <p>The following barcodes were found : </p> + <!-- /TMPL_UNLESS --> <!-- /TMPL_IF --> - <form name="f" action="batchMod.pl" method="post"> +<form name="f" action="batchMod.pl" method="post"> +<!-- TMPL_IF name="item_loop" --> <div id="cataloguing_additem_itemlist"> <div style="overflow:auto"> <table id="itemst"> @@ -72,10 +74,33 @@ </table> </div> </div> +<!-- /TMPL_IF --> + +<!-- TMPL_IF NAME="simple_items_display" --> + <ul> + <!-- TMPL_LOOP NAME="simple_items_display" --> + <li> + <a href="<!-- TMPL_VAR NAME="itemnumber" -->"><!-- TMPL_VAR NAME="barcode" --></a> + </li> + <!-- /TMPL_LOOP --> + </ul> +<!-- /TMPL_IF --> + + + <!-- TMPL_IF name="show" --> + +<!-- TMPL_IF name="too_many_items" --> + <p>Too many items (<!-- TMPL_VAR NAME="too_many_items" -->): not displaying each one individually.</p> + <!-- TMPL_LOOP name="itemnumbers_hashref" --> + <input type="hidden" name="itemnumber" value="<!-- TMPL_VAR NAME="itemnumber" -->" /> + <!-- /TMPL_LOOP --> +<!-- /TMPL_IF --> + + <div id="cataloguing_additem_newitem"> <input type="hidden" name="op" value="<!-- TMPL_VAR NAME="op" -->" /> - <p>This will delete the selected items.</p> + <p>This will delete <!-- TMPL_IF NAME="too_many_items" -->all the<!-- TMPL_ELSE -->the selected<!-- /TMPL_IF --> items.</p> <input type="hidden" name="del" value="1" /> <fieldset class="action"> <input type="submit" name="submit" value="Go" /> @@ -83,9 +108,6 @@ </div> <!-- /TMPL_IF --> <!-- /TMPL_UNLESS --> -<!-- TMPL_ELSE --> - <p>No item found</p> -<!-- /TMPL_IF --> <!-- TMPL_IF name="action" --> <p><!-- TMPL_VAR NAME="deleted_items" --> item(s) deleted.</p> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tmpl index 40640cc..acc9e12 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tmpl @@ -44,11 +44,13 @@ <!-- /TMPL_LOOP --> </tbody> </table></div> + <!-- TMPL_UNLESS name="too_many_items" --> <p>The following barcodes were found : </p> + <!-- /TMPL_UNLESS --> <!-- /TMPL_IF --> -<!-- TMPL_IF name="item_loop" --> <form name="f" action="batchMod.pl" method="post"> +<!-- TMPL_IF name="item_loop" --> <div id="cataloguing_additem_itemlist"> <div style="overflow:auto"> <table id="itemst"> @@ -71,7 +73,28 @@ </table> </div> </div> +<!-- /TMPL_IF --> + +<!-- TMPL_IF NAME="simple_items_display" --> + <p>The following items were modified:</p> + <ul> + <!-- TMPL_LOOP NAME="simple_items_display" --> + <li> + <a href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=12<!-- TMPL_VAR NAME="biblionumber" -->&itemnumber=<!-- TMPL_VAR NAME="itemnumber" -->"><!-- TMPL_VAR NAME="barcode" --></a> + </li> + <!-- /TMPL_LOOP --> + </ul> +<!-- /TMPL_IF --> + <!-- TMPL_IF name="show" --> + +<!-- TMPL_IF name="too_many_items" --> + <p>Too many items (<!-- TMPL_VAR NAME="too_many_items" -->): not displaying each one individually.</p> + <!-- TMPL_LOOP name="itemnumbers_hashref" --> + <input type="hidden" name="itemnumber" value="<!-- TMPL_VAR NAME="itemnumber" -->" /> + <!-- /TMPL_LOOP --> +<!-- /TMPL_IF --> + <div id="cataloguing_additem_newitem"> <input type="hidden" name="op" value="<!-- TMPL_VAR NAME="op" -->" /> <h2>Edit Items</h2> diff --git a/tools/batchMod.pl b/tools/batchMod.pl index 12e7eea..b421863 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -89,7 +89,6 @@ if ($op eq "action") { my $xml = TransformHtmlToXml(\...@tags,\...@subfields,\...@values,\...@indicator,\...@ind_tag, 'ITEM'); my $marcitem = MARC::Record::new_from_xml($xml, 'UTF-8'); my $localitem = TransformMarcToKoha( $dbh, $marcitem, "", 'items' ); - foreach my $itemnumber(@itemnumbers){ my $itemdata=GetItem($itemnumber); if ($input->param("del")){ @@ -106,7 +105,14 @@ if ($op eq "action") { eval{my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = ModItemFromMarc($localmarcitem,$itemdata->{biblionumber},$itemnumber)}; } } - $items_display_hashref=BuildItemsData(@itemnumbers); + # If we have a reasonable amount of items, we display them + if (scalar(@itemnumbers) <= 1000) { + $items_display_hashref=BuildItemsData(@itemnumbers); + } else { + # Else, we only display the barcode + my @simple_items_display = map {{ itemnumber => $_, barcode => GetBarcodeFromItemnumber($_), biblionumber => GetBiblionumberFromItemnumber($_) }} @itemnumbers; + $template->param("simple_items_display" => \...@simple_items_display); + } } # @@ -123,7 +129,7 @@ if ($op eq "show"){ if ($filefh){ while (my $content=<$filefh>){ chomp $content; - push @contentlist, $content; + push @contentlist, $content if $content; } switch ($filecontent) { @@ -160,8 +166,15 @@ if ($op eq "show"){ } } + # Only display the items if there are no more than 1000 + if (scalar(@itemnumbers) <= 1000) { $items_display_hashref=BuildItemsData(@itemnumbers); - + } else { + $template->param("too_many_items" => scalar(@itemnumbers)); + # Even if we do not display the items, we need the itemnumbers + my @itemnumbers_hashref = map {{itemnumber => $_}} @itemnumbers; + $template->param("itemnumbers_hashref" => \...@itemnumbers_hashref); + } # now, build the item form for entering a new item my @loop_data =(); my $i=0; -- 1.6.3.3 _______________________________________________ Koha-patches mailing list [email protected] http://lists.koha.org/mailman/listinfo/koha-patches
