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;
31 my $linecolor1='#ffffcc';
32 my $linecolor2='white';
33 my $backgroundimage="/images/background-mem.gif";
34 my $script_name="/cgi-bin/koha/admin/branches.pl";
38 #######################################################################################
41 my $minlocation=$input->param('minlocation');
42 my $maxlocation=$input->param('maxlocation');
43 $maxlocation=$minlocation.'Z' unless $maxlocation;
44 my $datelastseen = $input->param('datelastseen');
45 my $offset = $input->param('offset');
46 my $markseen = $input->param('markseen');
47 $offset=0 unless $offset;
48 my $pagesize = $input->param('pagesize');
49 $pagesize=20 unless $pagesize;
50 my $uploadbarcodes = $input->param('uploadbarcodes');
51 # warn "uploadbarcodes : ".$uploadbarcodes;
53 my ($template, $borrowernumber, $cookie)
54 = get_template_and_user({template_name => "reports/inventory.tmpl",
58 flagsrequired => {reports => 1},
61 $template->param(minlocation => $minlocation,
62 maxlocation => $maxlocation,
64 pagesize => $pagesize,
65 datelastseen => $datelastseen,
66 intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
67 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
68 IntranetNav => C4::Context->preference("IntranetNav"),
70 if ($uploadbarcodes && length($uploadbarcodes)>0){
71 my $dbh=C4::Context->dbh;
72 my $date=format_date($input->param('setdate'));
73 $date = format_date("today") unless $date;
75 my $strsth="update items set (datelastseen = $date) where items.barcode =?";
76 my $qupdate = $dbh->prepare($strsth);
77 my $strsth="select * from issues, items where items.itemnumber=issues.itemnumber and items.barcode =? and issues.returndate is null";
78 my $qonloan = $dbh->prepare($strsth);
79 my $strsth="select * from items where items.barcode =? and issues.wthdrawn=1";
80 my $qwthdrawn = $dbh->prepare($strsth);
83 while (my $barcode=<$uploadbarcodes>){
86 if ($qwthdrawn->execute($barcode) &&$qwthdrawn->rows){
87 push @errorloop, {'barcode'=>$barcode,'ERR_WTHDRAWN'=>1};
89 $qupdate->execute($barcode);
90 $count += $qupdate->rows;
93 $qonloan->execute($barcode);
95 my $data = $qonloan->fetchrow_hashref;
96 my ($doreturn, $messages, $iteminformation, $borrower) =returnbook($barcode, $data->{homebranch});
97 if ($doreturn){push @errorloop, {'barcode'=>$barcode,'ERR_ONLOAN_RET'=>1}}
98 else {push @errorloop, {'barcode'=>$barcode,'ERR_ONLOAN_NOT_RET'=>1}}
101 push @errorloop, {'barcode'=>$barcode,'ERR_BARCODE'=>1};
108 $template->param(date=>$date,Number=>$count);
109 # $template->param(errorfile=>$errorfile) if ($errorfile);
110 $template->param(errorloop=>\@errorloop) if (@errorloop);
113 foreach my $field ($input->param) {
114 if ($field =~ /SEEN-(.*)/) {
120 my $res = C4::Circulation::Circ2::listitemsforinventory($minlocation,$maxlocation,$datelastseen,$offset,$pagesize);
121 $template->param(loop =>$res,
122 nextoffset => ($offset+$pagesize),
123 prevoffset => ($offset?$offset-$pagesize:0),
127 output_html_with_http_headers $input, $cookie, $template->output;