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

(-)a/C4/Items.pm (-63 lines)
Lines 774-842 has copy-and-paste work. Link Here
774
774
775
=cut
775
=cut
776
776
777
=head2 GetLostItems
778
779
  $items = GetLostItems( $where );
780
781
This function gets a list of lost items.
782
783
=over 2
784
785
=item input:
786
787
C<$where> is a hashref. it containts a field of the items table as key
788
and the value to match as value. For example:
789
790
{ barcode    => 'abc123',
791
  homebranch => 'CPL',    }
792
793
=item return:
794
795
C<$items> is a reference to an array full of hashrefs with columns
796
from the "items" table as keys.
797
798
=item usage in the perl script:
799
800
  my $where = { barcode => '0001548' };
801
  my $items = GetLostItems( $where );
802
  $template->param( itemsloop => $items );
803
804
=back
805
806
=cut
807
808
sub GetLostItems {
809
    # Getting input args.
810
    my $where   = shift;
811
    my $dbh     = C4::Context->dbh;
812
813
    my $query   = "
814
        SELECT title, author, lib, itemlost, authorised_value, barcode, datelastseen, price, replacementprice, homebranch,
815
               itype, itemtype, holdingbranch, location, itemnotes, items.biblionumber as biblionumber, itemcallnumber
816
        FROM   items
817
            LEFT JOIN biblio ON (items.biblionumber = biblio.biblionumber)
818
            LEFT JOIN biblioitems ON (items.biblionumber = biblioitems.biblionumber)
819
            LEFT JOIN authorised_values ON (items.itemlost = authorised_values.authorised_value)
820
        WHERE
821
        	authorised_values.category = 'LOST'
822
          	AND itemlost IS NOT NULL
823
         	AND itemlost <> 0
824
    ";
825
    my @query_parameters;
826
    foreach my $key (keys %$where) {
827
        $query .= " AND $key LIKE ?";
828
        push @query_parameters, "%$where->{$key}%";
829
    }
830
831
    my $sth = $dbh->prepare($query);
832
    $sth->execute( @query_parameters );
833
    my $items = [];
834
    while ( my $row = $sth->fetchrow_hashref ){
835
        push @$items, $row;
836
    }
837
    return $items;
838
}
839
840
=head2 GetItemsForInventory
777
=head2 GetItemsForInventory
841
778
842
($itemlist, $iTotalRecords) = GetItemsForInventory( {
779
($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 50-81 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
50
my $params = $query->Vars;
50
my $params = $query->Vars;
51
my $get_items = $params->{'get_items'};
51
my $get_items = $params->{'get_items'};
52
52
53
if ( $get_items ) {
53
if ($get_items) {
54
    my $branchfilter     = $params->{'branchfilter'}    || undef;
54
    my $branchfilter     = $params->{'branchfilter'}     || undef;
55
    my $barcodefilter    = $params->{'barcodefilter'}   || undef;
55
    my $barcodefilter    = $params->{'barcodefilter'}    || undef;
56
    my $itemtypesfilter  = $params->{'itemtypesfilter'} || undef;
56
    my $itemtypesfilter  = $params->{'itemtypesfilter'}  || undef;
57
    my $loststatusfilter = $params->{'loststatusfilter'} || undef;
57
    my $loststatusfilter = $params->{'loststatusfilter'} || undef;
58
58
59
    my %where;
59
    my $params = {
60
    $where{'homebranch'}       = $branchfilter    if defined $branchfilter;
60
        ( $branchfilter ? ( homebranch => $branchfilter ) : () ),
61
    $where{'barcode'}          = $barcodefilter   if defined $barcodefilter;
61
        (
62
    $where{'authorised_value'} = $loststatusfilter if defined $loststatusfilter;
62
            $loststatusfilter
63
63
            ? ( itemlost => $loststatusfilter )
64
    my $itype = C4::Context->preference('item-level_itypes') ? "itype" : "itemtype";
64
            : ( itemlost => { '!=' => 0 } )
65
    $where{$itype}            = $itemtypesfilter if defined $itemtypesfilter;
65
        ),
66
66
        ( $barcodefilter ? ( barcode => { like => "%$barcodefilter%" } ) : () ),
67
    my $items = GetLostItems( \%where );
67
    };
68
    foreach my $it (@$items) {
68
69
        $it->{'datelastseen'} = eval { output_pref( { dt => dt_from_string( $it->{'datelastseen'} ), dateonly => 1 }); }
69
    my $attributes;
70
                   if ( $it->{'datelastseen'} );
70
    if ($itemtypesfilter) {
71
        if ( C4::Context->preference('item-level_itypes') ) {
72
            $params->{itype} = $itemtypesfilter;
73
        }
74
        else {
75
            # We want a join on biblioitems
76
            $attributes = { join => 'biblioitem' };
77
            $params->{'biblioitem.itemtype'} = $itemtypesfilter;
78
        }
71
    }
79
    }
72
80
81
    my $items = Koha::Items->search( $params, $attributes );
82
73
    $template->param(
83
    $template->param(
74
                     total       => scalar @$items,
84
        items     => $items,
75
                     itemsloop   => $items,
85
        get_items => $get_items,
76
                     get_items   => $get_items,
86
    );
77
                     itype_level => C4::Context->preference('item-level_itypes'),
78
                 );
79
}
87
}
80
88
81
# getting all itemtypes
89
# getting all itemtypes
82
- 

Return to bug 18279