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