|
Lines 149-186
names to values. If C<$serial> is true, include serial publication data.
Link Here
|
| 149 |
sub GetItem { |
149 |
sub GetItem { |
| 150 |
my ($itemnumber,$barcode, $serial) = @_; |
150 |
my ($itemnumber,$barcode, $serial) = @_; |
| 151 |
my $dbh = C4::Context->dbh; |
151 |
my $dbh = C4::Context->dbh; |
| 152 |
my $data; |
152 |
my $data; |
| 153 |
|
153 |
|
| 154 |
if ($itemnumber) { |
154 |
if ($itemnumber) { |
| 155 |
my $sth = $dbh->prepare(" |
155 |
my $sth = $dbh->prepare(" |
| 156 |
SELECT * FROM items |
156 |
SELECT * FROM items |
| 157 |
WHERE itemnumber = ?"); |
157 |
WHERE itemnumber = ?"); |
| 158 |
$sth->execute($itemnumber); |
158 |
$sth->execute($itemnumber); |
| 159 |
$data = $sth->fetchrow_hashref; |
159 |
$data = $sth->fetchrow_hashref; |
| 160 |
} else { |
160 |
} else { |
| 161 |
my $sth = $dbh->prepare(" |
161 |
my $sth = $dbh->prepare(" |
| 162 |
SELECT * FROM items |
162 |
SELECT * FROM items |
| 163 |
WHERE barcode = ?" |
163 |
WHERE barcode = ?" |
| 164 |
); |
164 |
); |
| 165 |
$sth->execute($barcode); |
165 |
$sth->execute($barcode); |
| 166 |
$data = $sth->fetchrow_hashref; |
166 |
$data = $sth->fetchrow_hashref; |
| 167 |
} |
167 |
} |
| 168 |
|
168 |
|
| 169 |
return unless ( $data ); |
169 |
return unless ( $data ); |
| 170 |
|
170 |
|
| 171 |
if ( $serial) { |
171 |
if ($serial) { |
| 172 |
my $ssth = $dbh->prepare("SELECT serialseq,publisheddate from serialitems left join serial on serialitems.serialid=serial.serialid where serialitems.itemnumber=?"); |
172 |
my $ssth = $dbh->prepare("SELECT serialseq,publisheddate from serialitems left join serial on serialitems.serialid=serial.serialid where serialitems.itemnumber=?"); |
| 173 |
$ssth->execute($data->{'itemnumber'}) ; |
173 |
$ssth->execute( $data->{'itemnumber'} ); |
| 174 |
($data->{'serialseq'} , $data->{'publisheddate'}) = $ssth->fetchrow_array(); |
174 |
( $data->{'serialseq'}, $data->{'publisheddate'} ) = $ssth->fetchrow_array(); |
| 175 |
} |
175 |
} |
| 176 |
#if we don't have an items.itype, use biblioitems.itemtype. |
176 |
|
| 177 |
# FIXME this should respect the itypes systempreference |
177 |
# Set the itype to biblioitems.itype unless we are using item level itypes |
| 178 |
# if (C4::Context->preference('item-level_itypes')) { |
178 |
unless ( C4::Context->preference('item-level_itypes') ) { |
| 179 |
if( ! $data->{'itype'} ) { |
179 |
my $sth = $dbh->prepare("SELECT itemtype FROM biblioitems WHERE biblionumber = ?"); |
| 180 |
my $sth = $dbh->prepare("SELECT itemtype FROM biblioitems WHERE biblionumber = ?"); |
180 |
$sth->execute( $data->{'biblionumber'} ); |
| 181 |
$sth->execute($data->{'biblionumber'}); |
181 |
( $data->{'itype'} ) = $sth->fetchrow_array; |
| 182 |
($data->{'itype'}) = $sth->fetchrow_array; |
182 |
} |
| 183 |
} |
183 |
|
| 184 |
return $data; |
184 |
return $data; |
| 185 |
} # sub GetItem |
185 |
} # sub GetItem |
| 186 |
|
186 |
|
| 187 |
- |
|
|