|
Lines 1-9
Link Here
|
| 1 |
package C4::RotatingCollections; |
1 |
package C4::RotatingCollections; |
| 2 |
|
2 |
|
| 3 |
# $Id: RotatingCollections.pm,v 0.1 2007/04/20 kylemhall |
3 |
# $Id: RotatingCollections.pm,v 0.1 2007/04/20 kylemhall |
| 4 |
|
4 |
|
| 5 |
# This package is inteded to keep track of what library |
5 |
# This package is inteded to keep track of what library |
| 6 |
# Items of a certain collection should be at. |
6 |
# Items of a certain collection should be at. |
| 7 |
|
7 |
|
| 8 |
# Copyright 2007 Kyle Hall |
8 |
# Copyright 2007 Kyle Hall |
| 9 |
# |
9 |
# |
|
Lines 81-107
BEGIN {
Link Here
|
| 81 |
=cut |
81 |
=cut |
| 82 |
|
82 |
|
| 83 |
sub CreateCollection { |
83 |
sub CreateCollection { |
| 84 |
my ( $title, $description ) = @_; |
84 |
my ( $title, $description ) = @_; |
| 85 |
|
85 |
|
| 86 |
## Check for all neccessary parameters |
86 |
## Check for all neccessary parameters |
| 87 |
if ( ! $title ) { |
87 |
if ( !$title ) { |
| 88 |
return ( 0, 1, "No Title Given" ); |
88 |
return ( 0, 1, "No Title Given" ); |
| 89 |
} |
89 |
} |
| 90 |
if ( ! $description ) { |
90 |
if ( !$description ) { |
| 91 |
return ( 0, 2, "No Description Given" ); |
91 |
return ( 0, 2, "No Description Given" ); |
| 92 |
} |
92 |
} |
| 93 |
|
93 |
|
| 94 |
my $success = 1; |
94 |
my $success = 1; |
| 95 |
|
95 |
|
| 96 |
my $dbh = C4::Context->dbh; |
96 |
my $dbh = C4::Context->dbh; |
| 97 |
|
97 |
|
| 98 |
my $sth; |
98 |
my $sth; |
| 99 |
$sth = $dbh->prepare("INSERT INTO collections ( colId, colTitle, colDesc ) |
99 |
$sth = $dbh->prepare( |
| 100 |
VALUES ( NULL, ?, ? )"); |
100 |
"INSERT INTO collections ( colId, colTitle, colDesc ) |
| 101 |
$sth->execute( $title, $description ) or return ( 0, 3, $sth->errstr() ); |
101 |
VALUES ( NULL, ?, ? )" |
|
|
102 |
); |
| 103 |
$sth->execute( $title, $description ) or return ( 0, 3, $sth->errstr() ); |
| 104 |
|
| 105 |
return 1; |
| 102 |
|
106 |
|
| 103 |
return 1; |
|
|
| 104 |
|
| 105 |
} |
107 |
} |
| 106 |
|
108 |
|
| 107 |
=head2 UpdateCollection |
109 |
=head2 UpdateCollection |
|
Lines 123-152
Updates a collection
Link Here
|
| 123 |
=cut |
125 |
=cut |
| 124 |
|
126 |
|
| 125 |
sub UpdateCollection { |
127 |
sub UpdateCollection { |
| 126 |
my ( $colId, $title, $description ) = @_; |
128 |
my ( $colId, $title, $description ) = @_; |
| 127 |
|
129 |
|
| 128 |
## Check for all neccessary parameters |
130 |
## Check for all neccessary parameters |
| 129 |
if ( ! $colId ) { |
131 |
if ( !$colId ) { |
| 130 |
return ( 0, 1, "No Id Given" ); |
132 |
return ( 0, 1, "No Id Given" ); |
| 131 |
} |
133 |
} |
| 132 |
if ( ! $title ) { |
134 |
if ( !$title ) { |
| 133 |
return ( 0, 2, "No Title Given" ); |
135 |
return ( 0, 2, "No Title Given" ); |
| 134 |
} |
136 |
} |
| 135 |
if ( ! $description ) { |
137 |
if ( !$description ) { |
| 136 |
return ( 0, 3, "No Description Given" ); |
138 |
return ( 0, 3, "No Description Given" ); |
| 137 |
} |
139 |
} |
| 138 |
|
140 |
|
| 139 |
my $dbh = C4::Context->dbh; |
141 |
my $dbh = C4::Context->dbh; |
| 140 |
|
142 |
|
| 141 |
my $sth; |
143 |
my $sth; |
| 142 |
$sth = $dbh->prepare("UPDATE collections |
144 |
$sth = $dbh->prepare( |
|
|
145 |
"UPDATE collections |
| 143 |
SET |
146 |
SET |
| 144 |
colTitle = ?, colDesc = ? |
147 |
colTitle = ?, colDesc = ? |
| 145 |
WHERE colId = ?"); |
148 |
WHERE colId = ?" |
| 146 |
$sth->execute( $title, $description, $colId ) or return ( 0, 4, $sth->errstr() ); |
149 |
); |
| 147 |
|
150 |
$sth->execute( $title, $description, $colId ) |
| 148 |
return 1; |
151 |
or return ( 0, 4, $sth->errstr() ); |
| 149 |
|
152 |
|
|
|
153 |
return 1; |
| 154 |
|
| 150 |
} |
155 |
} |
| 151 |
|
156 |
|
| 152 |
=head2 DeleteCollection |
157 |
=head2 DeleteCollection |
|
Lines 165-185
sub UpdateCollection {
Link Here
|
| 165 |
=cut |
170 |
=cut |
| 166 |
|
171 |
|
| 167 |
sub DeleteCollection { |
172 |
sub DeleteCollection { |
| 168 |
my ( $colId ) = @_; |
173 |
my ($colId) = @_; |
|
|
174 |
|
| 175 |
## Paramter check |
| 176 |
if ( !$colId ) { |
| 177 |
return ( 0, 1, "No Collection Id Given" ); |
| 178 |
} |
| 169 |
|
179 |
|
| 170 |
## Paramter check |
180 |
my $dbh = C4::Context->dbh; |
| 171 |
if ( ! $colId ) { |
|
|
| 172 |
return ( 0, 1, "No Collection Id Given" );; |
| 173 |
} |
| 174 |
|
| 175 |
my $dbh = C4::Context->dbh; |
| 176 |
|
181 |
|
| 177 |
my $sth; |
182 |
my $sth; |
| 178 |
|
183 |
|
| 179 |
$sth = $dbh->prepare("DELETE FROM collections WHERE colId = ?"); |
184 |
$sth = $dbh->prepare("DELETE FROM collections WHERE colId = ?"); |
| 180 |
$sth->execute( $colId ) or return ( 0, 4, $sth->errstr() ); |
185 |
$sth->execute($colId) or return ( 0, 4, $sth->errstr() ); |
| 181 |
|
186 |
|
| 182 |
return 1; |
187 |
return 1; |
| 183 |
} |
188 |
} |
| 184 |
|
189 |
|
| 185 |
=head2 GetCollections |
190 |
=head2 GetCollections |
|
Lines 198-214
sub DeleteCollection {
Link Here
|
| 198 |
|
203 |
|
| 199 |
sub GetCollections { |
204 |
sub GetCollections { |
| 200 |
|
205 |
|
| 201 |
my $dbh = C4::Context->dbh; |
206 |
my $dbh = C4::Context->dbh; |
| 202 |
|
207 |
|
| 203 |
my $sth = $dbh->prepare("SELECT * FROM collections"); |
208 |
my $sth = $dbh->prepare("SELECT * FROM collections"); |
| 204 |
$sth->execute() or return ( 1, $sth->errstr() ); |
209 |
$sth->execute() or return ( 1, $sth->errstr() ); |
| 205 |
|
210 |
|
| 206 |
my @results; |
211 |
my @results; |
| 207 |
while ( my $row = $sth->fetchrow_hashref ) { |
212 |
while ( my $row = $sth->fetchrow_hashref ) { |
| 208 |
push( @results , $row ); |
213 |
push( @results, $row ); |
| 209 |
} |
214 |
} |
| 210 |
|
215 |
|
| 211 |
return \@results; |
216 |
return \@results; |
| 212 |
} |
217 |
} |
| 213 |
|
218 |
|
| 214 |
=head2 GetItemsInCollection |
219 |
=head2 GetItemsInCollection |
|
Lines 229-244
sub GetCollections {
Link Here
|
| 229 |
=cut |
234 |
=cut |
| 230 |
|
235 |
|
| 231 |
sub GetItemsInCollection { |
236 |
sub GetItemsInCollection { |
| 232 |
my ( $colId ) = @_; |
237 |
my ($colId) = @_; |
| 233 |
|
238 |
|
| 234 |
## Paramter check |
239 |
## Paramter check |
| 235 |
if ( ! $colId ) { |
240 |
if ( !$colId ) { |
| 236 |
return ( 0, 0, 1, "No Collection Id Given" );; |
241 |
return ( 0, 0, 1, "No Collection Id Given" ); |
| 237 |
} |
242 |
} |
| 238 |
|
243 |
|
| 239 |
my $dbh = C4::Context->dbh; |
244 |
my $dbh = C4::Context->dbh; |
| 240 |
|
245 |
|
| 241 |
my $sth = $dbh->prepare("SELECT |
246 |
my $sth = $dbh->prepare( |
|
|
247 |
"SELECT |
| 242 |
biblio.title, |
248 |
biblio.title, |
| 243 |
items.itemcallnumber, |
249 |
items.itemcallnumber, |
| 244 |
items.barcode |
250 |
items.barcode |
|
Lines 246-260
sub GetItemsInCollection {
Link Here
|
| 246 |
WHERE collections.colId = collections_tracking.colId |
252 |
WHERE collections.colId = collections_tracking.colId |
| 247 |
AND collections_tracking.itemnumber = items.itemnumber |
253 |
AND collections_tracking.itemnumber = items.itemnumber |
| 248 |
AND items.biblionumber = biblio.biblionumber |
254 |
AND items.biblionumber = biblio.biblionumber |
| 249 |
AND collections.colId = ? ORDER BY biblio.title"); |
255 |
AND collections.colId = ? ORDER BY biblio.title" |
| 250 |
$sth->execute( $colId ) or return ( 0, 0, 2, $sth->errstr() ); |
256 |
); |
| 251 |
|
257 |
$sth->execute($colId) or return ( 0, 0, 2, $sth->errstr() ); |
| 252 |
my @results; |
258 |
|
| 253 |
while ( my $row = $sth->fetchrow_hashref ) { |
259 |
my @results; |
| 254 |
push( @results , $row ); |
260 |
while ( my $row = $sth->fetchrow_hashref ) { |
| 255 |
} |
261 |
push( @results, $row ); |
| 256 |
|
262 |
} |
| 257 |
return \@results; |
263 |
|
|
|
264 |
return \@results; |
| 258 |
} |
265 |
} |
| 259 |
|
266 |
|
| 260 |
=head2 GetCollection |
267 |
=head2 GetCollection |
|
Lines 271-293
Returns information about a collection
Link Here
|
| 271 |
=cut |
278 |
=cut |
| 272 |
|
279 |
|
| 273 |
sub GetCollection { |
280 |
sub GetCollection { |
| 274 |
my ( $colId ) = @_; |
281 |
my ($colId) = @_; |
| 275 |
|
282 |
|
| 276 |
my $dbh = C4::Context->dbh; |
283 |
my $dbh = C4::Context->dbh; |
| 277 |
|
284 |
|
| 278 |
my ( $sth, @results ); |
285 |
my ( $sth, @results ); |
| 279 |
$sth = $dbh->prepare("SELECT * FROM collections WHERE colId = ?"); |
286 |
$sth = $dbh->prepare("SELECT * FROM collections WHERE colId = ?"); |
| 280 |
$sth->execute( $colId ) or return 0; |
287 |
$sth->execute($colId) or return 0; |
| 281 |
|
288 |
|
| 282 |
my $row = $sth->fetchrow_hashref; |
289 |
my $row = $sth->fetchrow_hashref; |
| 283 |
|
290 |
|
| 284 |
return ( |
291 |
return ( |
| 285 |
$$row{'colId'}, |
292 |
$$row{'colId'}, $$row{'colTitle'}, |
| 286 |
$$row{'colTitle'}, |
293 |
$$row{'colDesc'}, $$row{'colBranchcode'} |
| 287 |
$$row{'colDesc'}, |
294 |
); |
| 288 |
$$row{'colBranchcode'} |
295 |
|
| 289 |
); |
|
|
| 290 |
|
| 291 |
} |
296 |
} |
| 292 |
|
297 |
|
| 293 |
=head2 AddItemToCollection |
298 |
=head2 AddItemToCollection |
|
Lines 307-337
Adds an item to a rotating collection.
Link Here
|
| 307 |
=cut |
312 |
=cut |
| 308 |
|
313 |
|
| 309 |
sub AddItemToCollection { |
314 |
sub AddItemToCollection { |
| 310 |
my ( $colId, $itemnumber ) = @_; |
315 |
my ( $colId, $itemnumber ) = @_; |
| 311 |
|
316 |
|
| 312 |
## Check for all neccessary parameters |
317 |
## Check for all neccessary parameters |
| 313 |
if ( ! $colId ) { |
318 |
if ( !$colId ) { |
| 314 |
return ( 0, 1, "No Collection Given" ); |
319 |
return ( 0, 1, "No Collection Given" ); |
| 315 |
} |
320 |
} |
| 316 |
if ( ! $itemnumber ) { |
321 |
if ( !$itemnumber ) { |
| 317 |
return ( 0, 2, "No Itemnumber Given" ); |
322 |
return ( 0, 2, "No Itemnumber Given" ); |
| 318 |
} |
323 |
} |
| 319 |
|
324 |
|
| 320 |
if ( isItemInThisCollection( $itemnumber, $colId ) ) { |
325 |
if ( isItemInThisCollection( $itemnumber, $colId ) ) { |
| 321 |
return ( 0, 2, "Item is already in the collection!" ); |
326 |
return ( 0, 2, "Item is already in the collection!" ); |
| 322 |
} elsif ( isItemInAnyCollection( $itemnumber ) ) { |
327 |
} |
| 323 |
return ( 0, 3, "Item is already in a different collection!" ); |
328 |
elsif ( isItemInAnyCollection($itemnumber) ) { |
| 324 |
} |
329 |
return ( 0, 3, "Item is already in a different collection!" ); |
| 325 |
|
330 |
} |
| 326 |
my $dbh = C4::Context->dbh; |
331 |
|
| 327 |
|
332 |
my $dbh = C4::Context->dbh; |
| 328 |
my $sth; |
333 |
|
| 329 |
$sth = $dbh->prepare("INSERT INTO collections_tracking ( ctId, colId, itemnumber ) |
334 |
my $sth; |
| 330 |
VALUES ( NULL, ?, ? )"); |
335 |
$sth = $dbh->prepare( |
| 331 |
$sth->execute( $colId, $itemnumber ) or return ( 0, 3, $sth->errstr() ); |
336 |
"INSERT INTO collections_tracking ( ctId, colId, itemnumber ) |
| 332 |
|
337 |
VALUES ( NULL, ?, ? )" |
| 333 |
return 1; |
338 |
); |
| 334 |
|
339 |
$sth->execute( $colId, $itemnumber ) or return ( 0, 3, $sth->errstr() ); |
|
|
340 |
|
| 341 |
return 1; |
| 342 |
|
| 335 |
} |
343 |
} |
| 336 |
|
344 |
|
| 337 |
=head2 RemoveItemFromCollection |
345 |
=head2 RemoveItemFromCollection |
|
Lines 352-376
Removes an item to a collection
Link Here
|
| 352 |
=cut |
360 |
=cut |
| 353 |
|
361 |
|
| 354 |
sub RemoveItemFromCollection { |
362 |
sub RemoveItemFromCollection { |
| 355 |
my ( $colId, $itemnumber ) = @_; |
363 |
my ( $colId, $itemnumber ) = @_; |
|
|
364 |
|
| 365 |
## Check for all neccessary parameters |
| 366 |
if ( !$itemnumber ) { |
| 367 |
return ( 0, 2, "No Itemnumber Given" ); |
| 368 |
} |
| 356 |
|
369 |
|
| 357 |
## Check for all neccessary parameters |
370 |
if ( !isItemInThisCollection( $itemnumber, $colId ) ) { |
| 358 |
if ( ! $itemnumber ) { |
371 |
return ( 0, 2, "Item is not in the collection!" ); |
| 359 |
return ( 0, 2, "No Itemnumber Given" ); |
372 |
} |
| 360 |
} |
|
|
| 361 |
|
| 362 |
if ( ! isItemInThisCollection( $itemnumber, $colId ) ) { |
| 363 |
return ( 0, 2, "Item is not in the collection!" ); |
| 364 |
} |
| 365 |
|
373 |
|
| 366 |
my $dbh = C4::Context->dbh; |
374 |
my $dbh = C4::Context->dbh; |
| 367 |
|
375 |
|
| 368 |
my $sth; |
376 |
my $sth; |
| 369 |
$sth = $dbh->prepare("DELETE FROM collections_tracking |
377 |
$sth = $dbh->prepare( |
| 370 |
WHERE itemnumber = ?"); |
378 |
"DELETE FROM collections_tracking |
| 371 |
$sth->execute( $itemnumber ) or return ( 0, 3, $sth->errstr() ); |
379 |
WHERE itemnumber = ?" |
|
|
380 |
); |
| 381 |
$sth->execute($itemnumber) or return ( 0, 3, $sth->errstr() ); |
| 372 |
|
382 |
|
| 373 |
return 1; |
383 |
return 1; |
| 374 |
} |
384 |
} |
| 375 |
|
385 |
|
| 376 |
=head2 TransferCollection |
386 |
=head2 TransferCollection |
|
Lines 391-426
Transfers a collection to another branch
Link Here
|
| 391 |
=cut |
401 |
=cut |
| 392 |
|
402 |
|
| 393 |
sub TransferCollection { |
403 |
sub TransferCollection { |
| 394 |
my ( $colId, $colBranchcode ) = @_; |
404 |
my ( $colId, $colBranchcode ) = @_; |
| 395 |
|
405 |
|
| 396 |
## Check for all neccessary parameters |
406 |
## Check for all neccessary parameters |
| 397 |
if ( ! $colId ) { |
407 |
if ( !$colId ) { |
| 398 |
return ( 0, 1, "No Id Given" ); |
408 |
return ( 0, 1, "No Id Given" ); |
| 399 |
} |
409 |
} |
| 400 |
if ( ! $colBranchcode ) { |
410 |
if ( !$colBranchcode ) { |
| 401 |
return ( 0, 2, "No Branchcode Given" ); |
411 |
return ( 0, 2, "No Branchcode Given" ); |
| 402 |
} |
412 |
} |
| 403 |
|
413 |
|
| 404 |
my $dbh = C4::Context->dbh; |
414 |
my $dbh = C4::Context->dbh; |
| 405 |
|
415 |
|
| 406 |
my $sth; |
416 |
my $sth; |
| 407 |
$sth = $dbh->prepare("UPDATE collections |
417 |
$sth = $dbh->prepare( |
|
|
418 |
"UPDATE collections |
| 408 |
SET |
419 |
SET |
| 409 |
colBranchcode = ? |
420 |
colBranchcode = ? |
| 410 |
WHERE colId = ?"); |
421 |
WHERE colId = ?" |
| 411 |
$sth->execute( $colBranchcode, $colId ) or return ( 0, 4, $sth->errstr() ); |
422 |
); |
| 412 |
|
423 |
$sth->execute( $colBranchcode, $colId ) or return ( 0, 4, $sth->errstr() ); |
| 413 |
$sth = $dbh->prepare("SELECT barcode FROM items, collections_tracking |
424 |
|
|
|
425 |
$sth = $dbh->prepare( |
| 426 |
"SELECT barcode FROM items, collections_tracking |
| 414 |
WHERE items.itemnumber = collections_tracking.itemnumber |
427 |
WHERE items.itemnumber = collections_tracking.itemnumber |
| 415 |
AND collections_tracking.colId = ?"); |
428 |
AND collections_tracking.colId = ?" |
| 416 |
$sth->execute( $colId ) or return ( 0, 4, $sth->errstr ); |
429 |
); |
| 417 |
my @results; |
430 |
$sth->execute($colId) or return ( 0, 4, $sth->errstr ); |
| 418 |
while ( my $item = $sth->fetchrow_hashref ) { |
431 |
my @results; |
| 419 |
my ( $dotransfer, $messages, $iteminformation ) = transferbook( $colBranchcode, $item->{'barcode'}, my $ignore_reserves = 1); |
432 |
while ( my $item = $sth->fetchrow_hashref ) { |
| 420 |
} |
433 |
my ( $dotransfer, $messages, $iteminformation ) = |
| 421 |
|
434 |
transferbook( $colBranchcode, $item->{'barcode'}, |
| 422 |
return 1; |
435 |
my $ignore_reserves = 1 ); |
| 423 |
|
436 |
} |
|
|
437 |
|
| 438 |
return 1; |
| 439 |
|
| 424 |
} |
440 |
} |
| 425 |
|
441 |
|
| 426 |
=head2 GetCollectionItemBranches |
442 |
=head2 GetCollectionItemBranches |
|
Lines 430-456
sub TransferCollection {
Link Here
|
| 430 |
=cut |
446 |
=cut |
| 431 |
|
447 |
|
| 432 |
sub GetCollectionItemBranches { |
448 |
sub GetCollectionItemBranches { |
| 433 |
my ( $itemnumber ) = @_; |
449 |
my ($itemnumber) = @_; |
| 434 |
|
450 |
|
| 435 |
if ( ! $itemnumber ) { |
451 |
if ( !$itemnumber ) { |
| 436 |
return; |
452 |
return; |
| 437 |
} |
453 |
} |
| 438 |
|
454 |
|
| 439 |
my $dbh = C4::Context->dbh; |
455 |
my $dbh = C4::Context->dbh; |
| 440 |
|
456 |
|
| 441 |
my ( $sth, @results ); |
457 |
my ( $sth, @results ); |
| 442 |
$sth = $dbh->prepare("SELECT holdingbranch, colBranchcode FROM items, collections, collections_tracking |
458 |
$sth = $dbh->prepare( |
|
|
459 |
"SELECT holdingbranch, colBranchcode FROM items, collections, collections_tracking |
| 443 |
WHERE items.itemnumber = collections_tracking.itemnumber |
460 |
WHERE items.itemnumber = collections_tracking.itemnumber |
| 444 |
AND collections.colId = collections_tracking.colId |
461 |
AND collections.colId = collections_tracking.colId |
| 445 |
AND items.itemnumber = ?"); |
462 |
AND items.itemnumber = ?" |
| 446 |
$sth->execute( $itemnumber ); |
463 |
); |
| 447 |
|
464 |
$sth->execute($itemnumber); |
| 448 |
my $row = $sth->fetchrow_hashref; |
465 |
|
| 449 |
|
466 |
my $row = $sth->fetchrow_hashref; |
| 450 |
return ( |
467 |
|
| 451 |
$$row{'holdingbranch'}, |
468 |
return ( $$row{'holdingbranch'}, $$row{'colBranchcode'}, ); |
| 452 |
$$row{'colBranchcode'}, |
|
|
| 453 |
); |
| 454 |
} |
469 |
} |
| 455 |
|
470 |
|
| 456 |
=head2 isItemInThisCollection |
471 |
=head2 isItemInThisCollection |
|
Lines 460-475
sub GetCollectionItemBranches {
Link Here
|
| 460 |
=cut |
475 |
=cut |
| 461 |
|
476 |
|
| 462 |
sub isItemInThisCollection { |
477 |
sub isItemInThisCollection { |
| 463 |
my ( $itemnumber, $colId ) = @_; |
478 |
my ( $itemnumber, $colId ) = @_; |
| 464 |
|
479 |
|
| 465 |
my $dbh = C4::Context->dbh; |
480 |
my $dbh = C4::Context->dbh; |
| 466 |
|
481 |
|
| 467 |
my $sth = $dbh->prepare("SELECT COUNT(*) as inCollection FROM collections_tracking WHERE itemnumber = ? AND colId = ?"); |
482 |
my $sth = $dbh->prepare( |
| 468 |
$sth->execute( $itemnumber, $colId ) or return( 0 ); |
483 |
"SELECT COUNT(*) as inCollection FROM collections_tracking WHERE itemnumber = ? AND colId = ?" |
| 469 |
|
484 |
); |
| 470 |
my $row = $sth->fetchrow_hashref; |
485 |
$sth->execute( $itemnumber, $colId ) or return (0); |
| 471 |
|
486 |
|
| 472 |
return $$row{'inCollection'}; |
487 |
my $row = $sth->fetchrow_hashref; |
|
|
488 |
|
| 489 |
return $$row{'inCollection'}; |
| 473 |
} |
490 |
} |
| 474 |
|
491 |
|
| 475 |
=head2 isItemInAnyCollection |
492 |
=head2 isItemInAnyCollection |
|
Lines 479-499
$inCollection = isItemInAnyCollection( $itemnumber );
Link Here
|
| 479 |
=cut |
496 |
=cut |
| 480 |
|
497 |
|
| 481 |
sub isItemInAnyCollection { |
498 |
sub isItemInAnyCollection { |
| 482 |
my ( $itemnumber ) = @_; |
499 |
my ($itemnumber) = @_; |
| 483 |
|
500 |
|
| 484 |
my $dbh = C4::Context->dbh; |
501 |
my $dbh = C4::Context->dbh; |
| 485 |
|
502 |
|
| 486 |
my $sth = $dbh->prepare("SELECT itemnumber FROM collections_tracking WHERE itemnumber = ?"); |
503 |
my $sth = $dbh->prepare( |
| 487 |
$sth->execute( $itemnumber ) or return( 0 ); |
504 |
"SELECT itemnumber FROM collections_tracking WHERE itemnumber = ?"); |
| 488 |
|
505 |
$sth->execute($itemnumber) or return (0); |
| 489 |
my $row = $sth->fetchrow_hashref; |
506 |
|
| 490 |
|
507 |
my $row = $sth->fetchrow_hashref; |
| 491 |
$itemnumber = $row->{itemnumber}; |
508 |
|
| 492 |
if ( $itemnumber ) { |
509 |
$itemnumber = $row->{itemnumber}; |
| 493 |
return 1; |
510 |
if ($itemnumber) { |
| 494 |
} else { |
511 |
return 1; |
| 495 |
return 0; |
512 |
} |
| 496 |
} |
513 |
else { |
|
|
514 |
return 0; |
| 515 |
} |
| 497 |
} |
516 |
} |
| 498 |
|
517 |
|
| 499 |
1; |
518 |
1; |