3 # Copyright 2000-2002 Katipo Communications
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
25 use C4::Interface::CGI::Output;
26 use C4::Circulation::Circ2;
29 use C4::Branch; # GetBranches
32 my $minlocation=$input->param('minlocation') || 'A';
33 my $maxlocation=$input->param('maxlocation');
34 $maxlocation=$minlocation.'Z' unless $maxlocation;
35 my $datelastseen = $input->param('datelastseen');
36 $datelastseen = format_date_in_iso($datelastseen);
37 my $offset = $input->param('offset');
38 my $markseen = $input->param('markseen');
39 $offset=0 unless $offset;
40 my $pagesize = $input->param('pagesize');
41 $pagesize=50 unless $pagesize;
42 my $uploadbarcodes = $input->param('uploadbarcodes');
43 my $branchcode = $input->param('branchcode');
44 my $op = $input->param('op');
45 # warn "uploadbarcodes : ".$uploadbarcodes;
47 my ($template, $borrowernumber, $cookie)
48 = get_template_and_user({template_name => "tools/inventory.tmpl",
52 flagsrequired => {tools => 1},
56 my $branches = GetBranches();
58 push @branch_loop, {value => "", branchname => "All Branches", };
59 for my $branch_hash (keys %$branches) {
60 push @branch_loop, {value => "$branch_hash",
61 branchname => $branches->{$branch_hash}->{'branchname'},
62 selected => ($branch_hash eq $branchcode?1:0)};
64 $template->param(branchloop => \@branch_loop,);
66 $template->param(minlocation => $minlocation,
67 maxlocation => $maxlocation,
69 pagesize => $pagesize,
70 datelastseen => $datelastseen,
71 intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
72 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
73 IntranetNav => C4::Context->preference("IntranetNav"),
75 if ($uploadbarcodes && length($uploadbarcodes)>0){
76 my $dbh=C4::Context->dbh;
77 my $date=format_date($input->param('setdate'));
78 $date = format_date("today") unless $date;
80 my $strsth="update items set (datelastseen = $date) where items.barcode =?";
81 my $qupdate = $dbh->prepare($strsth);
82 my $strsth="select * from issues, items where items.itemnumber=issues.itemnumber and items.barcode =? and issues.returndate is null";
83 my $qonloan = $dbh->prepare($strsth);
84 my $strsth="select * from items where items.barcode =? and issues.wthdrawn=1";
85 my $qwthdrawn = $dbh->prepare($strsth);
88 while (my $barcode=<$uploadbarcodes>){
91 if ($qwthdrawn->execute($barcode) &&$qwthdrawn->rows){
92 push @errorloop, {'barcode'=>$barcode,'ERR_WTHDRAWN'=>1};
94 $qupdate->execute($barcode);
95 $count += $qupdate->rows;
98 $qonloan->execute($barcode);
100 my $data = $qonloan->fetchrow_hashref;
101 my ($doreturn, $messages, $iteminformation, $borrower) =returnbook($barcode, $data->{homebranch});
102 if ($doreturn){push @errorloop, {'barcode'=>$barcode,'ERR_ONLOAN_RET'=>1}}
103 else {push @errorloop, {'barcode'=>$barcode,'ERR_ONLOAN_NOT_RET'=>1}}
106 push @errorloop, {'barcode'=>$barcode,'ERR_BARCODE'=>1};
113 $template->param(date=>$date,Number=>$count);
114 # $template->param(errorfile=>$errorfile) if ($errorfile);
115 $template->param(errorloop=>\@errorloop) if (@errorloop);
118 foreach my $field ($input->param) {
119 if ($field =~ /SEEN-(.*)/) {
125 my $res = C4::Circulation::Circ2::GetItemsForInventory($minlocation,$maxlocation,$datelastseen,$branchcode,$offset,$pagesize);
126 $template->param(loop =>$res,
127 nextoffset => ($offset+$pagesize),
128 prevoffset => ($offset?$offset-$pagesize:0),
132 output_html_with_http_headers $input, $cookie, $template->output;