=over 4
-$items = GetLostItems($where,$orderby);
+$items = GetLostItems( $where, $orderby );
=back
-This function get the items lost into C<$items>.
+This function gets a list of lost items.
=over 2
=item input:
+
C<$where> is a hashref. it containts a field of the items table as key
-and the value to match as value.
-C<$orderby> is a field of the items table.
+and the value to match as value. For example:
+
+{ barcode => 'abc123',
+ homebranch => 'CPL', }
+
+C<$orderby> is a field of the items table by which the resultset
+should be orderd.
=item return:
-C<$items> is a reference to an array full of hasref which keys are items' table column.
+
+C<$items> is a reference to an array full of hashrefs with columns
+from the "items" table as keys.
=item usage in the perl script:
-my %where;
-$where{barcode} = 0001548;
-my $items = GetLostItems( \%where, "homebranch" );
-$template->param(itemsloop => $items);
+my $where = { barcode => '0001548' };
+my $items = GetLostItems( $where, "homebranch" );
+$template->param( itemsloop => $items );
=back
AND itemlost <> 0
";
+ my @query_parameters;
foreach my $key (keys %$where) {
- $query .= " AND " . $key . " LIKE '%" . $where->{$key} . "%'";
+ $query .= " AND $key LIKE ?";
+ push @query_parameters, "%$where->{$key}%";
+ }
+ if ( defined $orderby ) {
+ $query .= ' ORDER BY ?';
+ push @query_parameters, $orderby;
}
- $query .= " ORDER BY ".$orderby." " if defined $orderby;
my $sth = $dbh->prepare($query);
- $sth->execute;
- my @items;
+ $sth->execute( @query_parameters );
+ my $items = [];
while ( my $row = $sth->fetchrow_hashref ){
- push @items, $row;
+ push @$items, $row;
}
- return \@items;
+ return $items;
}
=head2 GetItemsForInventory
return ($result);
}
+=head3 get_item_authorised_values
+
+ find the types and values for all authorised values assigned to this item.
+
+ parameters:
+ itemnumber
+
+ returns: a hashref malling the authorised value to the value set for this itemnumber
+
+ $authorised_values = {
+ 'CCODE' => undef,
+ 'DAMAGED' => '0',
+ 'LOC' => '3',
+ 'LOST' => '0'
+ 'NOT_LOAN' => '0',
+ 'RESTRICTED' => undef,
+ 'STACK' => undef,
+ 'WITHDRAWN' => '0',
+ 'branches' => 'CPL',
+ 'cn_source' => undef,
+ 'itemtypes' => 'SER',
+ };
+
+ Notes: see C4::Biblio::get_biblio_authorised_values for a similar method at the biblio level.
+
+=cut
+
+sub get_item_authorised_values {
+ my $itemnumber = shift;
+
+ # assume that these entries in the authorised_value table are item level.
+ my $query = q(SELECT distinct authorised_value, kohafield
+ FROM marc_subfield_structure
+ WHERE kohafield like 'item%'
+ AND authorised_value != '' );
+
+ my $itemlevel_authorised_values = C4::Context->dbh->selectall_hashref( $query, 'authorised_value' );
+ my $iteminfo = GetItem( $itemnumber );
+ # warn( Data::Dumper->Dump( [ $itemlevel_authorised_values ], [ 'itemlevel_authorised_values' ] ) );
+ my $return;
+ foreach my $this_authorised_value ( keys %$itemlevel_authorised_values ) {
+ my $field = $itemlevel_authorised_values->{ $this_authorised_value }->{'kohafield'};
+ $field =~ s/^items\.//;
+ if ( exists $iteminfo->{ $field } ) {
+ $return->{ $this_authorised_value } = $iteminfo->{ $field };
+ }
+ }
+ # warn( Data::Dumper->Dump( [ $return ], [ 'return' ] ) );
+ return $return;
+}
+
+=head3 get_authorised_value_images
+
+ find a list of icons that are appropriate for display based on the
+ authorised values for a biblio.
+
+ parameters: listref of authorised values, such as comes from
+ get_item_ahtorised_values or
+ from C4::Biblio::get_biblio_authorised_values
+
+ returns: listref of hashrefs for each image. Each hashref looks like
+ this:
+
+ { imageurl => '/intranet-tmpl/prog/img/itemtypeimg/npl/WEB.gif',
+ label => '',
+ category => '',
+ value => '', }
+
+ Notes: Currently, I put on the full path to the images on the staff
+ side. This should either be configurable or not done at all. Since I
+ have to deal with 'intranet' or 'opac' in
+ get_biblio_authorised_values, perhaps I should be passing it in.
+
+=cut
+
+sub get_authorised_value_images {
+ my $authorised_values = shift;
+
+ my @imagelist;
+
+ my $authorised_value_list = GetAuthorisedValues();
+ # warn ( Data::Dumper->Dump( [ $authorised_value_list ], [ 'authorised_value_list' ] ) );
+ foreach my $this_authorised_value ( @$authorised_value_list ) {
+ if ( exists $authorised_values->{ $this_authorised_value->{'category'} }
+ && $authorised_values->{ $this_authorised_value->{'category'} } eq $this_authorised_value->{'authorised_value'} ) {
+ # warn ( Data::Dumper->Dump( [ $this_authorised_value ], [ 'this_authorised_value' ] ) );
+ if ( defined $this_authorised_value->{'imageurl'} ) {
+ push @imagelist, { imageurl => C4::Koha::getitemtypeimagesrc( 'intranet' ) . '/' . $this_authorised_value->{'imageurl'},
+ label => $this_authorised_value->{'lib'},
+ category => $this_authorised_value->{'category'},
+ value => $this_authorised_value->{'authorised_value'}, };
+ }
+ }
+ }
+
+ # warn ( Data::Dumper->Dump( [ \@imagelist ], [ 'imagelist' ] ) );
+ return \@imagelist;
+
+}
+
=head1 LIMITED USE FUNCTIONS
The following functions, while part of the public API,
my ($item_marc, $biblionumber, $frameworkcode) = @_;
my $biblio_marc = GetMarcBiblio($biblionumber);
-
foreach my $field ($item_marc->fields()) {
$biblio_marc->append_fields($field);
}