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

(-)a/C4/Items.pm (-63 lines)
Lines 778-846 has copy-and-paste work. Link Here
778
778
779
=cut
779
=cut
780
780
781
=head2 GetLostItems
782
783
  $items = GetLostItems( $where );
784
785
This function gets a list of lost items.
786
787
=over 2
788
789
=item input:
790
791
C<$where> is a hashref. it containts a field of the items table as key
792
and the value to match as value. For example:
793
794
{ barcode    => 'abc123',
795
  homebranch => 'CPL',    }
796
797
=item return:
798
799
C<$items> is a reference to an array full of hashrefs with columns
800
from the "items" table as keys.
801
802
=item usage in the perl script:
803
804
  my $where = { barcode => '0001548' };
805
  my $items = GetLostItems( $where );
806
  $template->param( itemsloop => $items );
807
808
=back
809
810
=cut
811
812
sub GetLostItems {
813
    # Getting input args.
814
    my $where   = shift;
815
    my $dbh     = C4::Context->dbh;
816
817
    my $query   = "
818
        SELECT title, author, lib, itemlost, authorised_value, barcode, datelastseen, price, replacementprice, homebranch,
819
               itype, itemtype, holdingbranch, location, itemnotes, items.biblionumber as biblionumber, itemcallnumber
820
        FROM   items
821
            LEFT JOIN biblio ON (items.biblionumber = biblio.biblionumber)
822
            LEFT JOIN biblioitems ON (items.biblionumber = biblioitems.biblionumber)
823
            LEFT JOIN authorised_values ON (items.itemlost = authorised_values.authorised_value)
824
        WHERE
825
        	authorised_values.category = 'LOST'
826
          	AND itemlost IS NOT NULL
827
         	AND itemlost <> 0
828
    ";
829
    my @query_parameters;
830
    foreach my $key (keys %$where) {
831
        $query .= " AND $key LIKE ?";
832
        push @query_parameters, "%$where->{$key}%";
833
    }
834
835
    my $sth = $dbh->prepare($query);
836
    $sth->execute( @query_parameters );
837
    my $items = [];
838
    while ( my $row = $sth->fetchrow_hashref ){
839
        push @$items, $row;
840
    }
841
    return $items;
842
}
843
844
=head2 GetItemsForInventory
781
=head2 GetItemsForInventory
845
782
846
($itemlist, $iTotalRecords) = GetItemsForInventory( {
783
($itemlist, $iTotalRecords) = GetItemsForInventory( {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tt (-17 / +19 lines)
Lines 1-5 Link Here
1
[% USE AuthorisedValues %]
1
[% USE Branches %]
2
[% USE Branches %]
2
[% USE ColumnsSettings %]
3
[% USE ColumnsSettings %]
4
[% USE KohaDates %]
3
[% INCLUDE 'doc-head-open.inc' %]
5
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Reports &rsaquo; Lost items</title>
6
<title>Koha &rsaquo; Reports &rsaquo; Lost items</title>
5
[% INCLUDE 'doc-head-close.inc' %]
7
[% INCLUDE 'doc-head-close.inc' %]
Lines 42-55 Link Here
42
[% IF ( get_items ) %]
44
[% IF ( get_items ) %]
43
45
44
<div class="results">
46
<div class="results">
45
    [% IF ( total ) %]
47
    [% IF items.count%]
46
        [% total %] lost items found
48
        [% items.count %] lost items found
47
    [% ELSE %]
49
    [% ELSE %]
48
        No lost items found
50
        No lost items found
49
    [% END %]
51
    [% END %]
50
</div>
52
</div>
51
53
52
    [% IF itemsloop %]
54
    [% IF items.count %]
53
        <table id="lostitems-table">
55
        <table id="lostitems-table">
54
            <thead>
56
            <thead>
55
                <tr>
57
                <tr>
Lines 69-93 Link Here
69
                </tr>
71
                </tr>
70
            </thead>
72
            </thead>
71
            <tbody>
73
            <tbody>
72
                [% FOREACH itemsloo IN itemsloop %]
74
                [% FOREACH item IN items %]
73
                    <tr>
75
                    <tr>
74
                        <td>
76
                        <td>
75
                            <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% itemsloo.biblionumber %]" title="[% itemsloo.itemnotes %]">[% itemsloo.title |html %]</a>
77
                            <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% item.biblionumber %]" title="[% item.itemnotes %]">[% item.biblio.title |html %]</a>
76
                        </td>
78
                        </td>
77
                        <td>[% itemsloo.author %]</td>
79
                        <td>[% item.biblio.author %]</td>
78
                        <td>[% itemsloo.lib %]</td>
80
                        <td>[% AuthorisedValues.GetByCode( 'LOST', item.itemlost ) %]</td>
79
                        <td>
81
                        <td>
80
                            <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% itemsloo.biblionumber %]" title="[% itemsloo.itemnotes %]">[% itemsloo.barcode %]</a>
82
                            <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% item.biblionumber %]" title="[% item.itemnotes %]">[% item.barcode %]</a>
81
                        </td>
83
                        </td>
82
                        <td>[% itemsloo.itemcallnumber %]</td>
84
                        <td>[% item.itemcallnumber %]</td>
83
                        <td>[% itemsloo.datelastseen %]</td>
85
                        <td>[% item.datelastseen | $KohaDates %]</td>
84
                        <td>[% itemsloo.price %]</td>
86
                        <td>[% item.price %]</td>
85
                        <td>[% itemsloo.replacementprice %]</td>
87
                        <td>[% item.replacementprice %]</td>
86
                        <td>[% Branches.GetName(itemsloo.homebranch) %]</td>
88
                        <td>[% Branches.GetName(item.homebranch) %]</td>
87
                        <td>[% IF ( itemsloo.itype_level ) %][% itemsloo.itype %][% ELSE %][% itemsloo.itemtype %][% END %]</td>
89
                        <td>[% item.effective_itemtype %]</td>
88
                        <td>[% Branches.GetName(itemsloo.holdingbranch) %]</td>
90
                        <td>[% Branches.GetName(item.holdingbranch) %]</td>
89
                        <td>[% itemsloo.location %]</td>
91
                        <td>[% item.location %]</td>
90
                        <td>[% itemsloo.itemnotes %]</td>
92
                        <td>[% item.itemnotes %]</td>
91
                    </tr>
93
                    </tr>
92
                [% END %]
94
                [% END %]
93
            </tbody>
95
            </tbody>
(-)a/reports/itemslost.pl (-22 / +29 lines)
Lines 51-82 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
51
my $params = $query->Vars;
51
my $params = $query->Vars;
52
my $get_items = $params->{'get_items'};
52
my $get_items = $params->{'get_items'};
53
53
54
if ( $get_items ) {
54
if ($get_items) {
55
    my $branchfilter     = $params->{'branchfilter'}    || undef;
55
    my $branchfilter     = $params->{'branchfilter'}     || undef;
56
    my $barcodefilter    = $params->{'barcodefilter'}   || undef;
56
    my $barcodefilter    = $params->{'barcodefilter'}    || undef;
57
    my $itemtypesfilter  = $params->{'itemtypesfilter'} || undef;
57
    my $itemtypesfilter  = $params->{'itemtypesfilter'}  || undef;
58
    my $loststatusfilter = $params->{'loststatusfilter'} || undef;
58
    my $loststatusfilter = $params->{'loststatusfilter'} || undef;
59
59
60
    my %where;
60
    my $params = {
61
    $where{'homebranch'}       = $branchfilter    if defined $branchfilter;
61
        ( $branchfilter ? ( homebranch => $branchfilter ) : () ),
62
    $where{'barcode'}          = $barcodefilter   if defined $barcodefilter;
62
        (
63
    $where{'authorised_value'} = $loststatusfilter if defined $loststatusfilter;
63
            $loststatusfilter
64
64
            ? ( itemlost => $loststatusfilter )
65
    my $itype = C4::Context->preference('item-level_itypes') ? "itype" : "itemtype";
65
            : ( itemlost => { '!=' => 0 } )
66
    $where{$itype}            = $itemtypesfilter if defined $itemtypesfilter;
66
        ),
67
67
        ( $barcodefilter ? ( barcode => { like => "%$barcodefilter%" } ) : () ),
68
    my $items = GetLostItems( \%where );
68
    };
69
    foreach my $it (@$items) {
69
70
        $it->{'datelastseen'} = eval { output_pref( { dt => dt_from_string( $it->{'datelastseen'} ), dateonly => 1 }); }
70
    my $attributes;
71
                   if ( $it->{'datelastseen'} );
71
    if ($itemtypesfilter) {
72
        if ( C4::Context->preference('item-level_itypes') ) {
73
            $params->{itype} = $itemtypesfilter;
74
        }
75
        else {
76
            # We want a join on biblioitems
77
            $attributes = { join => 'biblioitem' };
78
            $params->{'biblioitem.itemtype'} = $itemtypesfilter;
79
        }
72
    }
80
    }
73
81
82
    my $items = Koha::Items->search( $params, $attributes );
83
74
    $template->param(
84
    $template->param(
75
                     total       => scalar @$items,
85
        items     => $items,
76
                     itemsloop   => $items,
86
        get_items => $get_items,
77
                     get_items   => $get_items,
87
    );
78
                     itype_level => C4::Context->preference('item-level_itypes'),
79
                 );
80
}
88
}
81
89
82
# getting all itemtypes
90
# getting all itemtypes
83
- 

Return to bug 18079