View | Details | Raw Unified | Return to bug 13372
Collapse All | Expand All

(-)a/C4/Items.pm (-11 / +2 lines)
Lines 957-963 sub GetItemLocation { Link Here
957
957
958
=head2 GetLostItems
958
=head2 GetLostItems
959
959
960
  $items = GetLostItems( $where, $orderby );
960
  $items = GetLostItems( $where );
961
961
962
This function gets a list of lost items.
962
This function gets a list of lost items.
963
963
Lines 971-979 and the value to match as value. For example: Link Here
971
{ barcode    => 'abc123',
971
{ barcode    => 'abc123',
972
  homebranch => 'CPL',    }
972
  homebranch => 'CPL',    }
973
973
974
C<$orderby> is a field of the items table by which the resultset
975
should be orderd.
976
977
=item return:
974
=item return:
978
975
979
C<$items> is a reference to an array full of hashrefs with columns
976
C<$items> is a reference to an array full of hashrefs with columns
Lines 982-988 from the "items" table as keys. Link Here
982
=item usage in the perl script:
979
=item usage in the perl script:
983
980
984
  my $where = { barcode => '0001548' };
981
  my $where = { barcode => '0001548' };
985
  my $items = GetLostItems( $where, "homebranch" );
982
  my $items = GetLostItems( $where );
986
  $template->param( itemsloop => $items );
983
  $template->param( itemsloop => $items );
987
984
988
=back
985
=back
Lines 992-998 from the "items" table as keys. Link Here
992
sub GetLostItems {
989
sub GetLostItems {
993
    # Getting input args.
990
    # Getting input args.
994
    my $where   = shift;
991
    my $where   = shift;
995
    my $orderby = shift;
996
    my $dbh     = C4::Context->dbh;
992
    my $dbh     = C4::Context->dbh;
997
993
998
    my $query   = "
994
    my $query   = "
Lines 1012-1022 sub GetLostItems { Link Here
1012
        $query .= " AND $key LIKE ?";
1008
        $query .= " AND $key LIKE ?";
1013
        push @query_parameters, "%$where->{$key}%";
1009
        push @query_parameters, "%$where->{$key}%";
1014
    }
1010
    }
1015
    my @ordervalues = qw/title author homebranch itype barcode price replacementprice lib datelastseen location/;
1016
    
1017
    if ( defined $orderby && grep($orderby, @ordervalues)) {
1018
        $query .= ' ORDER BY '.$orderby;
1019
    }
1020
1011
1021
    my $sth = $dbh->prepare($query);
1012
    my $sth = $dbh->prepare($query);
1022
    $sth->execute( @query_parameters );
1013
    $sth->execute( @query_parameters );
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tt (-15 / +3 lines)
Lines 96-116 Link Here
96
	[% ELSE %]
96
	[% ELSE %]
97
	
97
	
98
	<form name="f" action="/cgi-bin/koha/reports/itemslost.pl" method="post">
98
	<form name="f" action="/cgi-bin/koha/reports/itemslost.pl" method="post">
99
<fieldset class="rows"><ol>    <li><label for="orderbyfilter">Order by: </label>
99
    <fieldset class="rows">
100
    <select id="orderbyfilter" name="orderbyfilter">
100
        <ol>
101
        <option value=""> --- </option>
101
102
        <option value="title">Title</option>
103
        <option value="author">Author</option>
104
        <option value="homebranch">Home library</option>
105
        <option value="itype">Item types</option>
106
        <option value="barcode">Barcode</option>
107
        <option value="price">Price</option>
108
        <option value="replacementprice">Replacement price</option>
109
        <option value="lib">Lost code</option>
110
        <option value="datelastseen">Date last seen</option>
111
        <option value="location">Location</option>
112
    </select></li>
113
	
114
	<li><label for="barcodefilter">Barcode: </label><input type="text" name="barcodefilter" id="barcodefilter" size="6" /></li>
102
	<li><label for="barcodefilter">Barcode: </label><input type="text" name="barcodefilter" id="barcodefilter" size="6" /></li>
115
	<li><label for="branchfilter">Library: </label><select name="branchfilter" id="branchfilter">
103
	<li><label for="branchfilter">Library: </label><select name="branchfilter" id="branchfilter">
116
                <option value="">All</option>
104
                <option value="">All</option>
(-)a/reports/itemslost.pl (-4 / +2 lines)
Lines 53-59 my $params = $query->Vars; Link Here
53
my $get_items = $params->{'get_items'};
53
my $get_items = $params->{'get_items'};
54
54
55
if ( $get_items ) {
55
if ( $get_items ) {
56
    my $orderbyfilter    = $params->{'orderbyfilter'}   || undef;
57
    my $branchfilter     = $params->{'branchfilter'}    || undef;
56
    my $branchfilter     = $params->{'branchfilter'}    || undef;
58
    my $barcodefilter    = $params->{'barcodefilter'}   || undef;
57
    my $barcodefilter    = $params->{'barcodefilter'}   || undef;
59
    my $itemtypesfilter  = $params->{'itemtypesfilter'} || undef;
58
    my $itemtypesfilter  = $params->{'itemtypesfilter'} || undef;
Lines 63-73 if ( $get_items ) { Link Here
63
    $where{'homebranch'}       = $branchfilter    if defined $branchfilter;
62
    $where{'homebranch'}       = $branchfilter    if defined $branchfilter;
64
    $where{'barcode'}          = $barcodefilter   if defined $barcodefilter;
63
    $where{'barcode'}          = $barcodefilter   if defined $barcodefilter;
65
    $where{'authorised_value'} = $loststatusfilter if defined $loststatusfilter;
64
    $where{'authorised_value'} = $loststatusfilter if defined $loststatusfilter;
66
    
65
67
    my $itype = C4::Context->preference('item-level_itypes') ? "itype" : "itemtype";
66
    my $itype = C4::Context->preference('item-level_itypes') ? "itype" : "itemtype";
68
    $where{$itype}            = $itemtypesfilter if defined $itemtypesfilter;
67
    $where{$itype}            = $itemtypesfilter if defined $itemtypesfilter;
69
68
70
    my $items = GetLostItems( \%where, $orderbyfilter ); 
69
    my $items = GetLostItems( \%where );
71
    foreach my $it (@$items) {
70
    foreach my $it (@$items) {
72
        $it->{'datelastseen'} = format_date($it->{'datelastseen'});
71
        $it->{'datelastseen'} = format_date($it->{'datelastseen'});
73
    }
72
    }
74
- 

Return to bug 13372