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
26 use C4
::Dates qw
/format_date/;
29 my $linecolor1='#ffffcc';
30 my $linecolor2='white';
31 my $backgroundimage="/images/background-mem.gif";
32 my $script_name="/cgi-bin/koha/admin/branches.pl";
35 #######################################################################################
38 my $minlocation=$input->param('minlocation');
39 my $maxlocation=$input->param('maxlocation');
40 $maxlocation=$minlocation.'Z' unless $maxlocation;
41 my $datelastseen = $input->param('datelastseen');
42 my $offset = $input->param('offset');
43 my $markseen = $input->param('markseen');
44 $offset=0 unless $offset;
45 my $pagesize = $input->param('pagesize');
46 $pagesize=20 unless $pagesize;
47 my $uploadbarcodes = $input->param('uploadbarcodes');
48 # warn "uploadbarcodes : ".$uploadbarcodes;
50 my ($template, $borrowernumber, $cookie)
51 = get_template_and_user
({template_name
=> "reports/inventory.tmpl",
55 flagsrequired
=> {reports
=> 1},
58 $template->param(minlocation
=> $minlocation,
59 maxlocation
=> $maxlocation,
61 pagesize
=> $pagesize,
62 datelastseen
=> $datelastseen,
64 if ($uploadbarcodes && length($uploadbarcodes)>0){
65 my $dbh=C4
::Context
->dbh;
66 my $date = format_date
($input->param('setdate')) || C4
::Dates
->new()->output();
68 my $strsth="update items set (datelastseen = $date) where items.barcode =?";
69 my $qupdate = $dbh->prepare($strsth);
70 $strsth="select * from issues, items where items.itemnumber=issues.itemnumber and items.barcode =? and issues.returndate is null";
71 my $qonloan = $dbh->prepare($strsth);
72 $strsth="select * from items where items.barcode =? and issues.wthdrawn=1";
73 my $qwthdrawn = $dbh->prepare($strsth);
76 while (my $barcode=<$uploadbarcodes>){
79 if ($qwthdrawn->execute($barcode) &&$qwthdrawn->rows){
80 push @errorloop, {'barcode'=>$barcode,'ERR_WTHDRAWN'=>1};
82 $qupdate->execute($barcode);
83 $count += $qupdate->rows;
86 $qonloan->execute($barcode);
88 my $data = $qonloan->fetchrow_hashref;
89 my ($doreturn, $messages, $iteminformation, $borrower) =AddReturn
($barcode, $data->{homebranch
});
90 if ($doreturn){push @errorloop, {'barcode'=>$barcode,'ERR_ONLOAN_RET'=>1}}
91 else {push @errorloop, {'barcode'=>$barcode,'ERR_ONLOAN_NOT_RET'=>1}}
94 push @errorloop, {'barcode'=>$barcode,'ERR_BARCODE'=>1};
101 $template->param(date
=>$date,Number
=>$count);
102 # $template->param(errorfile=>$errorfile) if ($errorfile);
103 $template->param(errorloop
=>\
@errorloop) if (@errorloop);
106 foreach my $field ($input->param) {
107 if ($field =~ /SEEN-(.*)/) {
108 &ModDateLastSeen
($1);
113 my $res = C4
::Circulation
::Circ2
::listitemsforinventory
($minlocation,$maxlocation,$datelastseen,$offset,$pagesize);
114 $template->param(loop =>$res,
115 nextoffset
=> ($offset+$pagesize),
116 prevoffset
=> ($offset?
$offset-$pagesize:0),
120 output_html_with_http_headers
$input, $cookie, $template->output;