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

(-)a/C4/Items.pm (-1 / +1 lines)
Lines 963-969 sub GetItemsForInventory { Link Here
963
    my ( @bind_params, @where_strings );
963
    my ( @bind_params, @where_strings );
964
964
965
    my $query = <<'END_SQL';
965
    my $query = <<'END_SQL';
966
SELECT items.itemnumber, barcode, itemcallnumber, title, author, biblio.biblionumber, datelastseen
966
SELECT items.itemnumber, barcode, itemcallnumber, title, author, biblio.biblionumber, datelastseen, homebranch, location
967
FROM items
967
FROM items
968
  LEFT JOIN biblio ON items.biblionumber = biblio.biblionumber
968
  LEFT JOIN biblio ON items.biblionumber = biblio.biblionumber
969
  LEFT JOIN biblioitems on items.biblionumber = biblioitems.biblionumber
969
  LEFT JOIN biblioitems on items.biblionumber = biblioitems.biblionumber
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt (-6 / +22 lines)
Lines 127-133 $(document).ready(function(){ Link Here
127
                                    <label for="[% value.id %]">
127
                                    <label for="[% value.id %]">
128
                                      [% value.lib %]
128
                                      [% value.lib %]
129
                                    </label>
129
                                    </label>
130
                                    <input type="checkbox" name="status-[% value.fieldname %]-[% value.id %]" id="[% value.id %]" />
130
                                    <input type="checkbox" name="status-[% value.fieldname %]-[% value.authorised_value %]" id="[% value.authorised_value %]" />
131
                                  </li>[% END %]
131
                                  </li>[% END %]
132
                              [% END %]
132
                              [% END %]
133
                              </ul>
133
                              </ul>
Lines 196-202 $(document).ready(function(){ Link Here
196
        <tr>
196
        <tr>
197
            <th>Seen</th>
197
            <th>Seen</th>
198
            <th>Barcode</th>
198
            <th>Barcode</th>
199
            <th>Location</th>
199
            <th>Title</th>
200
            <th>Title</th>
201
            <th>Status</th>
202
            <th>Lost</th>
203
            <th>Damaged</th>
200
            <th>Unseen since</th>
204
            <th>Unseen since</th>
201
            <th>Problems</th>
205
            <th>Problems</th>
202
        </tr>
206
        </tr>
Lines 209-225 $(document).ready(function(){ Link Here
209
                [% loo.barcode %]
213
                [% loo.barcode %]
210
            </td>
214
            </td>
211
            <td>
215
            <td>
212
                <p><b>[% loo.itemcallnumber %]</b> - <a href="#" onclick="window.open('/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=[% loo.biblionumber %]','marcview','width=800,height=600,toolbar=0,scrollbars=1');">[% loo.title |html %]</a></p>
216
                [% loo.homebranch %] [% loo.location %] [[% loo.itemcallnumber %]]
217
            </td>
218
            <td>
219
                <p><a href="#" onclick="window.open('/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=[% loo.biblionumber %]','marcview','width=800,height=600,toolbar=0,scrollbars=1');">[% loo.title |html %]</a></p>
213
                <p>[% loo.author %]</p>
220
                <p>[% loo.author %]</p>
214
            </td>
221
            </td>
215
            <td>
222
            <td>
223
                [% loo.notforloan %]
224
            </td>
225
            <td>
226
                [% loo.itemlost %]
227
            </td>
228
            <td>
229
                [% loo.damaged %]
230
            </td>
231
            <td>
216
                <p>[% loo.datelastseen %]</p>
232
                <p>[% loo.datelastseen %]</p>
217
            </td>
233
            </td>
218
            <td>
234
            <td>
219
                 [% IF ( loo.notfoundbarcode ) %]
235
                 [% IF ( loo.wrongplace ) %]
220
                     <p style="background: red;">Not found among barcodes in barcodes file.</p>
236
                     <p style="background: red;">Item should not have been scanned.</p>
221
                 [% ELSIF ( loo.notfoundkoha ) %]
237
                 [% ELSIF ( loo.missingitem ) %]
222
                     <p style="background: red;">Not found in Koha.</p>
238
                     <p style="background: red;">Item missing.</p>
223
                 [% ELSE %]
239
                 [% ELSE %]
224
                     <p style="background: green;">None</p>
240
                     <p style="background: green;">None</p>
225
                 [% END %]
241
                 [% END %]
(-)a/tools/inventory.pl (-39 / +56 lines)
Lines 18-28 Link Here
18
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# with Koha; if not, write to the Free Software Foundation, Inc.,
19
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
20
21
use strict;
21
use Modern::Perl;
22
use warnings;
23
22
24
#need to open cgi and get the fh before anything else opens a new cgi context (see C4::Auth)
23
#need to open cgi and get the fh before anything else opens a new cgi context (see C4::Auth)
25
use CGI;
24
use CGI;
25
use List::MoreUtils qw /none/;
26
26
my $input = CGI->new;
27
my $input = CGI->new;
27
my $uploadbarcodes = $input->param('uploadbarcodes');
28
my $uploadbarcodes = $input->param('uploadbarcodes');
28
29
Lines 104-115 for my $statfield (qw/items.notforloan items.itemlost items.wthdrawn items.damag Link Here
104
    }
105
    }
105
}
106
}
106
$template->param( statuses => $statuses );
107
$template->param( statuses => $statuses );
107
my $staton = {};								#authorized values that are ticked
108
my $staton = {}; #authorized values that are ticked
108
for my $authvfield (@$statuses) {
109
for my $authvfield (@$statuses) {
109
    $staton->{$authvfield->{fieldname}} = [];
110
    $staton->{$authvfield->{fieldname}} = [];
110
    for my $authval (@{$authvfield->{values}}){
111
    for my $authval (@{$authvfield->{values}}){
111
        if ( defined $input->param('status-' . $authvfield->{fieldname} . '-' . $authval->{id}) && $input->param('status-' . $authvfield->{fieldname} . '-' . $authval->{id}) eq 'on' ){
112
        if ( defined $input->param('status-' . $authvfield->{fieldname} . '-' . $authval->{authorised_value}) && $input->param('status-' . $authvfield->{fieldname} . '-' . $authval->{authorised_value}) eq 'on' ){
112
            push @{$staton->{$authvfield->{fieldname}}}, $authval->{id};
113
            push @{$staton->{$authvfield->{fieldname}}}, $authval->{authorised_value};
113
        }
114
        }
114
    }
115
    }
115
}
116
}
Lines 179-218 if ($uploadbarcodes && length($uploadbarcodes)>0){ Link Here
179
# 	$template->param(errorfile=>$errorfile) if ($errorfile);
180
# 	$template->param(errorfile=>$errorfile) if ($errorfile);
180
    $template->param(errorloop=>\@errorloop) if (@errorloop);
181
    $template->param(errorloop=>\@errorloop) if (@errorloop);
181
}
182
}
182
#if we want to compare the results to a list of barcodes, or we have no barcode file
183
183
if ( ! ($uploadbarcodes && length($uploadbarcodes)>0 ) || ( $input->param('compareinv2barcd') eq 'on' && length($uploadbarcodes)>0) ) {
184
# mark seen if applicable (ie: coming form mark seen checkboxes)
184
    if ($markseen) {
185
if ($markseen) {
185
        foreach ($input->param) {
186
    foreach ( $input->param ) {
186
            /SEEN-(.+)/ and &ModDateLastSeen($1);
187
        /SEEN-(.+)/ and &ModDateLastSeen($1);
187
        }
188
    }
189
    if ($markseen or $op) {
190
        $res = GetItemsForInventory( $minlocation, $maxlocation, $location, $itemtype, $ignoreissued, $datelastseen, $branchcode, $branch, $offset, $pagesize, $staton );
191
        $template->param(loop =>$res,
192
                        nextoffset => ($offset+$pagesize),
193
                        prevoffset => ($offset?$offset-$pagesize:0),
194
                        );
195
    }
188
    }
196
    if ( defined $input->param('compareinv2barcd') && ( ( $input->param('compareinv2barcd') eq 'on' ) && ( scalar @brcditems != scalar @$res ) ) && length($uploadbarcodes) > 0 ){
189
}
197
        if ( scalar @brcditems > scalar @$res ){
190
# now build the result list: inventoried items if requested, and mis-placed items -always-
198
            for my $brcditem (@brcditems) {
191
my $inventorylist;
199
                if (! grep( $_->{barcode} =~ /$brcditem->{barcode}/ , @$res) ){
192
if ( $markseen or $op ) {
200
                    $brcditem->{notfoundkoha} = 1;
193
    # retrieve all items in this range.
201
                    push @$res, $brcditem;
194
    $inventorylist = GetItemsForInventory($minlocation, $maxlocation, $location, $itemtype, $ignoreissued, '', $branchcode, $branch, $offset, $pagesize, $staton);
202
                }
195
    # if comparison is requested, then display all the result (otherwise, we'll use the inventorylist to find missplaced items, later
203
            }
196
    $res = $inventorylist if $input->param('compareinv2barcd');
204
        } else {
197
}
205
            my @notfound;
198
# set "missing" flags for all items with a datelastseen before the choosen datelastseen
206
            for my $item (@$res) {
199
foreach (@$res) {$_->{missingitem}=1 if C4::Dates->new($_->{datelastseen})->output('iso') lt C4::Dates->new($datelastseen)->output('iso')}
207
                if ( ! grep( $_->{barcode} =~ /$item->{barcode}/ , @brcditems) ){
200
# insert "wrongplace" to all scanned items that are not supposed to be in this range
208
                    $item->{notfoundbarcode} = 1;
201
# note this list is always displayed, whatever the librarian has choosen for comparison
209
                    push @notfound, $item;
202
foreach my $temp (@brcditems) {
210
                }
203
    next if $temp->{onloan}; # skip checked out items
211
            }
204
    if (none { defined $_->{barcode} and $temp->{barcode} eq $_->{barcode} and !$_->{onloan} } @$inventorylist) {
212
            $res = [@$res, @notfound];
205
        $temp->{wrongplace}=1;
213
        }
206
        my $biblio = C4::Biblio::GetBiblioData($temp->{biblionumber});
207
        $temp->{title} = $biblio->{title};
208
        $temp->{author} = $biblio->{author};
209
        push @$res, $temp;
214
    }
210
    }
215
}
211
}
212
$template->param(
213
    loop       => $res,
214
    nextoffset => ( $offset + $pagesize ),
215
    prevoffset => ( $offset ? $offset - $pagesize : 0 ),
216
);
216
217
217
if (defined $input->param('CSVexport') && $input->param('CSVexport') eq 'on'){
218
if (defined $input->param('CSVexport') && $input->param('CSVexport') eq 'on'){
218
    eval {use Text::CSV};
219
    eval {use Text::CSV};
Lines 222-232 if (defined $input->param('CSVexport') && $input->param('CSVexport') eq 'on'){ Link Here
222
        -type       => 'text/csv',
223
        -type       => 'text/csv',
223
        -attachment => 'inventory.csv',
224
        -attachment => 'inventory.csv',
224
    );
225
    );
226
    $csv->combine(qw / title author barcode itemnumber homebranch location itemcallnumber notforloan lost damaged /);
227
    print $csv->string, "\n";
225
    for my $re (@$res){
228
    for my $re (@$res){
226
        my @line;
229
        my @line;
227
        for my $key (keys %$re) {
230
        for my $key ( qw / title author barcode itemnumber homebranch location itemcallnumber notforloan itemlost damaged / ) {
228
            push @line, $re->{$key};
231
            given ( $key ) {
232
                when ( /notforloan/ ) {
233
                    push @line, GetAuthorisedValueDesc('', '', $re->{$key}, '', '', 'NOT_LOAN', '');
234
                }
235
                when ( /itemlost/ ) {
236
                    push @line, GetAuthorisedValueDesc('', '', $re->{$key}, '', '', 'LOST', '');
237
                }
238
                when ( /damaged/ ) {
239
                    push @line, GetAuthorisedValueDesc('', '', $re->{$key}, '', '', 'DAMAGED', '');
240
                }
241
                default {
242
                    push @line, $re->{$key};
243
                }
244
            }
229
        }
245
        }
246
        push @line, "wrong place" if $re->{wrongplace};
247
        push @line, "missing item" if $re->{missingitem};
230
        $csv->combine(@line);
248
        $csv->combine(@line);
231
        print $csv->string, "\n";
249
        print $csv->string, "\n";
232
    }
250
    }
233
- 

Return to bug 7684