MT 2269 : Do not display all the items if there is a large amount of items

Also fix the barcode not found problem (due to empty lines)

Signed-off-by: Henri-Damien LAURENT <henridamien.laurent@biblibre.com>
Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
This commit is contained in:
Matthias Meusburger 2010-03-10 22:26:14 +01:00 committed by Galen Charlton
parent 67f9ea0264
commit 4dd2086deb
5 changed files with 110 additions and 11 deletions

View File

@ -58,6 +58,7 @@ BEGIN {
&GetBiblioItemInfosOf
&GetBiblioItemByBiblioNumber
&GetBiblioFromItemNumber
&GetBiblionumberFromItemnumber
&GetRecordValue
&GetFieldMapping
@ -716,6 +717,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

View File

@ -66,6 +66,7 @@ BEGIN {
GetItemsInfo
get_itemnumbers_of
GetItemnumberFromBarcode
GetBarcodeFromItemnumber
DelItemCheck
MoveItemFromBiblio
@ -1517,6 +1518,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.

View File

@ -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>

View File

@ -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" -->&amp;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>

View File

@ -90,7 +90,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")){
@ -107,7 +106,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);
}
}
#
@ -124,7 +130,7 @@ if ($op eq "show"){
if ($filefh){
while (my $content=<$filefh>){
chomp $content;
push @contentlist, $content;
push @contentlist, $content if $content;
}
switch ($filecontent) {
@ -161,8 +167,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;