Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 175 lines (162 sloc) 6.56 kb
a0b06fb @ctfliblime Prepare for perlbrew usage by changing all script magic to "#!/usr/bi…
ctfliblime authored
1 #!/usr/bin/env perl
f8e9fb6 rel_3_0 moved to HEAD (introducing new files)
tipaul authored
2
3 # Copyright 2000-2002 Katipo Communications
4 #
5 # This file is part of Koha.
6 #
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
10 # version.
11 #
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.
15 #
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
19
20 use strict;
21 use CGI;
22 use C4::Auth;
3607caa @ctfliblime Add Koha.pm and include it universally
ctfliblime authored
23 use Koha;
f8e9fb6 rel_3_0 moved to HEAD (introducing new files)
tipaul authored
24 use C4::Context;
25 use C4::Output;
c596d55 HUGE COMMIT : code cleaning circulation.
tipaul authored
26 use C4::Biblio;
c6c8e80 start of BIB change -- introduce C4::Items
Galen Charlton authored
27 use C4::Items;
1b381df cleanup of tools/ after Dates ... missing format_date, etc.
Joshua Ferraro authored
28 use C4::Dates qw/format_date format_date_in_iso/;
f8e9fb6 rel_3_0 moved to HEAD (introducing new files)
tipaul authored
29 use C4::Koha;
30 use C4::Branch; # GetBranches
fc798b0 (bug #3329) Dependency missing in inventory.pl
Nahuel ANGELINETTI authored
31 use C4::Circulation;
f8e9fb6 rel_3_0 moved to HEAD (introducing new files)
tipaul authored
32
33 my $input = new CGI;
ee7499d tweak Inventory tool and sub in C4/Items so call number min and max a…
Michael Hafen authored
34 my $minlocation=$input->param('minlocation') || '';
f8e9fb6 rel_3_0 moved to HEAD (introducing new files)
tipaul authored
35 my $maxlocation=$input->param('maxlocation');
ee7499d tweak Inventory tool and sub in C4/Items so call number min and max a…
Michael Hafen authored
36 $maxlocation=$minlocation.'Z' unless ( $maxlocation || ! $minlocation );
2b6116a Adding selection by location
hdl authored
37 my $location=$input->param('location');
309f4fa @PaulPoulain bugfixing inventory
PaulPoulain authored
38 my $itemtype=$input->param('itemtype');
96412f1 Add option to inventory tool to ignore copies on loan
Michael Hafen authored
39 my $ignoreissued=$input->param('ignoreissued');
f8e9fb6 rel_3_0 moved to HEAD (introducing new files)
tipaul authored
40 my $datelastseen = $input->param('datelastseen');
41 my $offset = $input->param('offset');
42 my $markseen = $input->param('markseen');
43 $offset=0 unless $offset;
44 my $pagesize = $input->param('pagesize');
45 $pagesize=50 unless $pagesize;
46 my $uploadbarcodes = $input->param('uploadbarcodes');
47 my $branchcode = $input->param('branchcode');
48 my $op = $input->param('op');
49 # warn "uploadbarcodes : ".$uploadbarcodes;
2b6116a Adding selection by location
hdl authored
50 # use Data::Dumper; warn Dumper($input);
f8e9fb6 rel_3_0 moved to HEAD (introducing new files)
tipaul authored
51 my ($template, $borrowernumber, $cookie)
52 = get_template_and_user({template_name => "tools/inventory.tmpl",
53 query => $input,
54 type => "intranet",
55 authnotrequired => 0,
fc6ccb1 granular permissions - updated Tools
Galen Charlton authored
56 flagsrequired => {tools => 'inventory'},
f8e9fb6 rel_3_0 moved to HEAD (introducing new files)
tipaul authored
57 debug => 1,
58 });
59
60 my $branches = GetBranches();
61 my @branch_loop;
9d29ce5 improvements to zebra configuration files
Joshua Ferraro authored
62 push @branch_loop, {value => "", branchname => "All Locations", };
f8e9fb6 rel_3_0 moved to HEAD (introducing new files)
tipaul authored
63 for my $branch_hash (keys %$branches) {
64 push @branch_loop, {value => "$branch_hash",
65 branchname => $branches->{$branch_hash}->{'branchname'},
66 selected => ($branch_hash eq $branchcode?1:0)};
67 }
2b6116a Adding selection by location
hdl authored
68
309f4fa @PaulPoulain bugfixing inventory
PaulPoulain authored
69
70 my $itemtypes = GetItemTypes;
71 my @itemtypesloop;
72 foreach my $thisitemtype (sort keys %$itemtypes) {
b522e8e @colinsc Merge BatchEditItem1_19
colinsc authored
73 my $selected;
74 if ($thisitemtype eq $itemtype) {
75 $selected = 1;
76 }
309f4fa @PaulPoulain bugfixing inventory
PaulPoulain authored
77 my %row =(value => $thisitemtype,
78 selected => $selected,
79 description => $itemtypes->{$thisitemtype}->{'description'},
80 );
81 push @itemtypesloop, \%row;
82 }
83 $template->param(itemtypeloop => \@itemtypesloop);
84
2b6116a Adding selection by location
hdl authored
85 my @authorised_value_list;
86 my $authorisedvalue_categories;
87
88 my $dbh=C4::Context->dbh;
309f4fa @PaulPoulain bugfixing inventory
PaulPoulain authored
89 my $rqauthcategorie=$dbh->prepare("SELECT authorised_value FROM marc_subfield_structure WHERE frameworkcode=? AND kohafield='items.location'");
90 my $rq=$dbh->prepare("SELECT frameworkcode FROM biblio_framework");
2b6116a Adding selection by location
hdl authored
91 $rq->execute;
92 while (my ($fwkcode)=$rq->fetchrow){
93 $rqauthcategorie->execute($fwkcode);
94 while (my ($authcat)=$rqauthcategorie->fetchrow){
95 if ($authcat && $authorisedvalue_categories!~/\b$authcat\W/){
96 $authorisedvalue_categories.="$authcat ";
97 my $data=GetAuthorisedValues($authcat);
98 foreach my $value (@$data){
99 $value->{selected}=1 if ($value->{authorised_value} eq ($location));
100 }
101 push @authorised_value_list,@$data;
102 }
103 }
104 }
105
106
107
320e726 adding calendar popup to inventory/stocktaking
kados authored
108 $template->param(branchloop => \@branch_loop,
2b6116a Adding selection by location
hdl authored
109 authorised_values=>\@authorised_value_list,
2e0e56a tools subdir - Dates.pm integration and warnings fixes.
Joe Atzberger authored
110 DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
320e726 adding calendar popup to inventory/stocktaking
kados authored
111 minlocation => $minlocation,
f8e9fb6 rel_3_0 moved to HEAD (introducing new files)
tipaul authored
112 maxlocation => $maxlocation,
2b6116a Adding selection by location
hdl authored
113 location=>$location,
96412f1 Add option to inventory tool to ignore copies on loan
Michael Hafen authored
114 ignoreissued=>$ignoreissued,
2b6116a Adding selection by location
hdl authored
115 branchcode=>$branchcode,
f8e9fb6 rel_3_0 moved to HEAD (introducing new files)
tipaul authored
116 offset => $offset,
117 pagesize => $pagesize,
118 datelastseen => $datelastseen,
119 );
120 if ($uploadbarcodes && length($uploadbarcodes)>0){
121 my $dbh=C4::Context->dbh;
2e0e56a tools subdir - Dates.pm integration and warnings fixes.
Joe Atzberger authored
122 my $date = format_date_in_iso($input->param('setdate')) || C4::Dates->today('iso');
f8e9fb6 rel_3_0 moved to HEAD (introducing new files)
tipaul authored
123 # warn "$date";
9222f7a created old_issues and old_reserves tables
Galen Charlton authored
124 my $strsth="select * from issues, items where items.itemnumber=issues.itemnumber and items.barcode =?";
f8e9fb6 rel_3_0 moved to HEAD (introducing new files)
tipaul authored
125 my $qonloan = $dbh->prepare($strsth);
890f673 Bug 3224 : inventory tool fails on DOS newlines
Ryan Higgins authored
126 $strsth="select * from items where items.barcode =? and items.wthdrawn = 1";
f8e9fb6 rel_3_0 moved to HEAD (introducing new files)
tipaul authored
127 my $qwthdrawn = $dbh->prepare($strsth);
128 my @errorloop;
129 my $count=0;
130 while (my $barcode=<$uploadbarcodes>){
890f673 Bug 3224 : inventory tool fails on DOS newlines
Ryan Higgins authored
131 $barcode =~ s/\r?\n$//;
f8e9fb6 rel_3_0 moved to HEAD (introducing new files)
tipaul authored
132 if ($qwthdrawn->execute($barcode) &&$qwthdrawn->rows){
133 push @errorloop, {'barcode'=>$barcode,'ERR_WTHDRAWN'=>1};
134 }else{
a91b10d inventory: two fixes
Galen Charlton authored
135 my $item = GetItem('', $barcode);
890f673 Bug 3224 : inventory tool fails on DOS newlines
Ryan Higgins authored
136 if (defined $item && $item->{'itemnumber'}){
a91b10d inventory: two fixes
Galen Charlton authored
137 ModItem({ datelastseen => $date }, undef, $item->{'itemnumber'});
138 $count++;
f8e9fb6 rel_3_0 moved to HEAD (introducing new files)
tipaul authored
139 $qonloan->execute($barcode);
140 if ($qonloan->rows){
141 my $data = $qonloan->fetchrow_hashref;
c596d55 HUGE COMMIT : code cleaning circulation.
tipaul authored
142 my ($doreturn, $messages, $iteminformation, $borrower) =AddReturn($barcode, $data->{homebranch});
f8e9fb6 rel_3_0 moved to HEAD (introducing new files)
tipaul authored
143 if ($doreturn){push @errorloop, {'barcode'=>$barcode,'ERR_ONLOAN_RET'=>1}}
144 else {push @errorloop, {'barcode'=>$barcode,'ERR_ONLOAN_NOT_RET'=>1}}
145 }
146 } else {
147 push @errorloop, {'barcode'=>$barcode,'ERR_BARCODE'=>1};
148 }
149 }
150 }
151 $qonloan->finish;
152 $qwthdrawn->finish;
2b6116a Adding selection by location
hdl authored
153 $template->param(date=>format_date($date),Number=>$count);
f8e9fb6 rel_3_0 moved to HEAD (introducing new files)
tipaul authored
154 # $template->param(errorfile=>$errorfile) if ($errorfile);
155 $template->param(errorloop=>\@errorloop) if (@errorloop);
156 }else{
157 if ($markseen) {
2e0e56a tools subdir - Dates.pm integration and warnings fixes.
Joe Atzberger authored
158 foreach ($input->param) {
159 /SEEN-(.+)/ and &ModDateLastSeen($1);
f8e9fb6 rel_3_0 moved to HEAD (introducing new files)
tipaul authored
160 }
161 }
2e0e56a tools subdir - Dates.pm integration and warnings fixes.
Joe Atzberger authored
162 if ($markseen or $op) {
96412f1 Add option to inventory tool to ignore copies on loan
Michael Hafen authored
163 my $res = GetItemsForInventory($minlocation,$maxlocation,$location,$itemtype,$ignoreissued,$datelastseen,$branchcode,$offset,$pagesize);
f8e9fb6 rel_3_0 moved to HEAD (introducing new files)
tipaul authored
164 $template->param(loop =>$res,
165 nextoffset => ($offset+$pagesize),
166 prevoffset => ($offset?$offset-$pagesize:0),
167 );
168 }
169 }
170 output_html_with_http_headers $input, $cookie, $template->output;
171
172 # Local Variables:
173 # tab-width: 8
174 # End:
Something went wrong with that request. Please try again.