/
updateitem.pl
executable file
·163 lines (152 loc) · 4.95 KB
/
updateitem.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/usr/bin/perl
# $Id$
# Copyright 2000-2002 Katipo Communications
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
use strict;
use CGI;
use C4::Context;
use C4::Acquisitions;
use C4::Biblio;
use C4::Output;
use C4::Circulation::Circ2;
use C4::Accounts2;
my $env;
my $input= new CGI;
my $bibnum=checkinp($input->param('bibnum'));
my $itemnum=checkinp($input->param('itemnumber'));
my $copyright=checkinp($input->param('Copyright'));
my $seriestitle=checkinp($input->param('Series'));
my $serial=checkinp($input->param('Serial'));
my $unititle=checkinp($input->param('Unititle'));
my $notes=checkinp($input->param('ItemNotes'));
#need to do barcode check
my $barcode=$input->param('Barcode');
my $bibitemnum=checkinp($input->param('bibitemnum'));
my $itemtype=checkinp($input->param('Item'));
my $isbn=checkinp($input->param('ISBN'));
my $publishercode=checkinp($input->param('Publisher'));
my $publicationdate=checkinp($input->param('Publication'));
my $class=checkinp($input->param('Class'));
my $homebranch=checkinp($input->param('Home'));
my $lost=$input->param('Lost');
my $wthdrawn=$input->param('withdrawn');
my $classification;
my $dewey;
my $subclass;
my $override=$input->param('override');
if ($itemtype ne 'NF'){
$classification=$class;
}
if ($class =~/[0-9]+/){
$dewey= $class;
$dewey=~ s/[a-z]+//gi;
my @temp;
if ($class =~ /\./){
@temp=split(/[0-9]+\.[0-9]+/,$class);
} else {
@temp=split(/[0-9]+/,$class);
}
$classification=$temp[0];
$subclass=$temp[1];
}else{
$dewey='';
}
my $illus=checkinp($input->param('Illustrations'));
my $pages=checkinp($input->param('Pages'));
my $volumeddesc=checkinp($input->param('Volume'));
if ($wthdrawn == 0 && $override ne 'yes'){
moditem( { biblionumber => $bibnum,
loan =>'loan',
itemnum => $itemnum,
bibitemnum => $bibitemnum,
barcode => $barcode,
notes => $notes,
homebranch => $homebranch,
lost => $lost,
wthdranw => $wthdrawn
});
if ($lost ==1){
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("Select * from issues where (itemnumber='$itemnum') and (returndate is null)");
$sth->execute;
my $data=$sth->fetchrow_hashref;
if ($data->{'borrowernumber'} ne '') {
#item on issue add replacement cost to borrowers record
my $accountno=getnextacctno($env,$data->{'borrowernumber'},$dbh);
my $item=getiteminformation($env, $itemnum);
my $account="Insert into accountlines
(borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber)
values
('$data->{'borrowernumber'}','$accountno',now(),'$item->{'replacementprice'}',
'Lost Item $item->{'title'} $item->{'barcode'}','L',
'$item->{'replacementprice'}','$itemnum')";
my $sth2=$dbh->prepare($account);
# print $input->header;
# print $account;
$sth2->execute;
$sth2->finish;
}
$sth->finish;
}
print $input->redirect("moredetail.pl?type=intra&bib=$bibnum&bi=$bibitemnum");
} else {
# print "marking cancelled";
#need to check if it is on reserve or issued
my $dbh = C4::Context->dbh;
my $flag=0;
my ($resbor,$resrec)=C4::Circulation::Circ2::checkreserve($env,$dbh,$itemnum);
# print $resbor;
if ($resbor){
print $input->header;
print "The biblio or biblioitem this item belongs to has a reserve on it";
$flag=1;
}
my $sth=$dbh->prepare("Select * from issues where (itemnumber='$itemnum') and (returndate is null)");
$sth->execute;
my $data=$sth->fetchrow_hashref;
if ($data->{'borrowernumber'} ne '') {
print $input->header;
print "<p>Item is on issue";
$flag=1;
}
$sth->finish;
if ($flag == 1){
my $url=$input->self_url;
$url.="&override=yes";
print "<p> <a href=$url>Cancel Anyway</a> or <a href=\"\">Back</a>";
}else {
moditem({ biblionumber => $bibnum,
loan => 'loan',
itemnum => $itemnum,
bibitemnum => $bibitemnum,
barcode => $barcode,
notes => $notes,
homebranch => $homebranch,
lost => $lost,
wthdrawn => $wthdrawn
});
print $input->redirect("moredetail.pl?type=intra&bib=$bibnum&bi=$bibitemnum");
}
}
#print $bibitemnum;
sub checkinp{
my ($inp)=@_;
$inp=~ s/\'/\\\'/g;
$inp=~ s/\"/\\\"/g;
return($inp);
}
#sub checkissue{