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 ); |