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