(bug #3196) fix itemlost.pl
This patch fix 3 things: * fix order by * take care of item_level-itype * use join in sql query Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
This commit is contained in:
parent
99b84d69b6
commit
b1180360a8
17
C4/Items.pm
17
C4/Items.pm
|
|
@ -933,23 +933,24 @@ sub GetLostItems {
|
|||
|
||||
my $query = "
|
||||
SELECT *
|
||||
FROM items, biblio, authorised_values
|
||||
FROM items
|
||||
LEFT JOIN biblio ON (items.biblionumber = biblio.biblionumber)
|
||||
LEFT JOIN biblioitems ON (items.biblionumber = biblioitems.biblionumber)
|
||||
LEFT JOIN authorised_values ON (items.itemlost = authorised_values.authorised_value)
|
||||
WHERE
|
||||
items.biblionumber = biblio.biblionumber
|
||||
AND items.itemlost = authorised_values.authorised_value
|
||||
AND authorised_values.category = 'LOST'
|
||||
authorised_values.category = 'LOST'
|
||||
AND itemlost IS NOT NULL
|
||||
AND itemlost <> 0
|
||||
|
||||
";
|
||||
my @query_parameters;
|
||||
foreach my $key (keys %$where) {
|
||||
$query .= " AND $key LIKE ?";
|
||||
push @query_parameters, "%$where->{$key}%";
|
||||
}
|
||||
if ( defined $orderby ) {
|
||||
$query .= ' ORDER BY ?';
|
||||
push @query_parameters, $orderby;
|
||||
my @ordervalues = qw/title author homebranch itype barcode price replacementprice lib datelastseen location/;
|
||||
|
||||
if ( defined $orderby && grep($orderby, @ordervalues)) {
|
||||
$query .= ' ORDER BY '.$orderby;
|
||||
}
|
||||
|
||||
my $sth = $dbh->prepare($query);
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@
|
|||
<td><!-- TMPL_VAR NAME="price" --></td>
|
||||
<td><!-- TMPL_VAR NAME="replacementprice" --></td>
|
||||
<td><!-- TMPL_VAR NAME="homebranch" --></td>
|
||||
<td><!-- TMPL_VAR NAME="itype" --></td>
|
||||
<td><!-- TMPL_IF NAME="itype_level" --><!-- TMPL_VAR NAME="itype" --><!-- TMPL_ELSE --><!-- TMPL_VAR NAME="itemtype" --><!-- /TMPL_IF --></td>
|
||||
<td><!-- TMPL_VAR NAME="holdingbranch"--></td>
|
||||
<td><!-- TMPL_VAR NAME="location"--></td>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -56,14 +56,17 @@ if ( $get_items ) {
|
|||
my %where;
|
||||
$where{'homebranch'} = $branchfilter if defined $branchfilter;
|
||||
$where{'barcode'} = $barcodefilter if defined $barcodefilter;
|
||||
$where{'itype'} = $itemtypesfilter if defined $itemtypesfilter;
|
||||
$where{'authorised_value'} = $loststatusfilter if defined $loststatusfilter;
|
||||
|
||||
my $itype = C4::Context->preference('item-level_itypes') ? "itype" : "itemtype";
|
||||
$where{$itype} = $itemtypesfilter if defined $itemtypesfilter;
|
||||
|
||||
my $items = GetLostItems( \%where, $orderbyfilter );
|
||||
$template->param(
|
||||
total => scalar @$items,
|
||||
itemsloop => $items,
|
||||
get_items => $get_items
|
||||
total => scalar @$items,
|
||||
itemsloop => $items,
|
||||
get_items => $get_items,
|
||||
itype_level => C4::Context->preference('item-level_itypes'),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue