Lines 26-32
use Modern::Perl;
Link Here
|
26 |
|
26 |
|
27 |
use C4::Context; |
27 |
use C4::Context; |
28 |
use C4::Circulation; |
28 |
use C4::Circulation; |
29 |
use C4::Reserves qw(GetReserveStatus); |
29 |
use C4::Reserves qw(CheckReserves); |
30 |
|
30 |
|
31 |
use DBI; |
31 |
use DBI; |
32 |
|
32 |
|
Lines 86-95
sub CreateCollection {
Link Here
|
86 |
|
86 |
|
87 |
## Check for all neccessary parameters |
87 |
## Check for all neccessary parameters |
88 |
if ( !$title ) { |
88 |
if ( !$title ) { |
89 |
return ( 0, 1, "No Title Given" ); |
89 |
return ( 0, 1, "NO_TITLE" ); |
90 |
} |
90 |
} |
91 |
if ( !$description ) { |
91 |
if ( !$description ) { |
92 |
return ( 0, 2, "No Description Given" ); |
92 |
return ( 0, 2, "NO_DESCRIPTION" ); |
93 |
} |
93 |
} |
94 |
|
94 |
|
95 |
my $success = 1; |
95 |
my $success = 1; |
Lines 130-142
sub UpdateCollection {
Link Here
|
130 |
|
130 |
|
131 |
## Check for all neccessary parameters |
131 |
## Check for all neccessary parameters |
132 |
if ( !$colId ) { |
132 |
if ( !$colId ) { |
133 |
return ( 0, 1, "No Id Given" ); |
133 |
return ( 0, 1, "NO_ID" ); |
134 |
} |
134 |
} |
135 |
if ( !$title ) { |
135 |
if ( !$title ) { |
136 |
return ( 0, 2, "No Title Given" ); |
136 |
return ( 0, 2, "NO_TITLE" ); |
137 |
} |
137 |
} |
138 |
if ( !$description ) { |
138 |
if ( !$description ) { |
139 |
return ( 0, 3, "No Description Given" ); |
139 |
return ( 0, 3, "NO_DESCRIPTION" ); |
140 |
} |
140 |
} |
141 |
|
141 |
|
142 |
my $dbh = C4::Context->dbh; |
142 |
my $dbh = C4::Context->dbh; |
Lines 175-181
sub DeleteCollection {
Link Here
|
175 |
|
175 |
|
176 |
## Paramter check |
176 |
## Paramter check |
177 |
if ( !$colId ) { |
177 |
if ( !$colId ) { |
178 |
return ( 0, 1, "No Collection Id Given" ); |
178 |
return ( 0, 1, "NO_ID" ); |
179 |
} |
179 |
} |
180 |
|
180 |
|
181 |
my $dbh = C4::Context->dbh; |
181 |
my $dbh = C4::Context->dbh; |
Lines 239-245
sub GetItemsInCollection {
Link Here
|
239 |
|
239 |
|
240 |
## Paramter check |
240 |
## Paramter check |
241 |
if ( !$colId ) { |
241 |
if ( !$colId ) { |
242 |
return ( 0, 0, 1, "No Collection Id Given" ); |
242 |
return ( 0, 0, 1, "NO_ID" ); |
243 |
} |
243 |
} |
244 |
|
244 |
|
245 |
my $dbh = C4::Context->dbh; |
245 |
my $dbh = C4::Context->dbh; |
Lines 317-333
sub AddItemToCollection {
Link Here
|
317 |
|
317 |
|
318 |
## Check for all neccessary parameters |
318 |
## Check for all neccessary parameters |
319 |
if ( !$colId ) { |
319 |
if ( !$colId ) { |
320 |
return ( 0, 1, "No Collection Given" ); |
320 |
return ( 0, 1, "NO_ID" ); |
321 |
} |
321 |
} |
322 |
if ( !$itemnumber ) { |
322 |
if ( !$itemnumber ) { |
323 |
return ( 0, 2, "No Itemnumber Given" ); |
323 |
return ( 0, 2, "NO_ITEM" ); |
324 |
} |
324 |
} |
325 |
|
325 |
|
326 |
if ( isItemInThisCollection( $itemnumber, $colId ) ) { |
326 |
if ( isItemInThisCollection( $itemnumber, $colId ) ) { |
327 |
return ( 0, 2, "Item is already in the collection!" ); |
327 |
return ( 0, 2, "IN_COLLECTION" ); |
328 |
} |
328 |
} |
329 |
elsif ( isItemInAnyCollection($itemnumber) ) { |
329 |
elsif ( isItemInAnyCollection($itemnumber) ) { |
330 |
return ( 0, 3, "Item is already in a different collection!" ); |
330 |
return ( 0, 3, "IN_COLLECTION_OTHER" ); |
331 |
} |
331 |
} |
332 |
|
332 |
|
333 |
my $dbh = C4::Context->dbh; |
333 |
my $dbh = C4::Context->dbh; |
Lines 367-377
sub RemoveItemFromCollection {
Link Here
|
367 |
|
367 |
|
368 |
## Check for all neccessary parameters |
368 |
## Check for all neccessary parameters |
369 |
if ( !$itemnumber ) { |
369 |
if ( !$itemnumber ) { |
370 |
return ( 0, 2, "No Itemnumber Given" ); |
370 |
return ( 0, 2, "NO_ITEM" ); |
371 |
} |
371 |
} |
372 |
|
372 |
|
373 |
if ( !isItemInThisCollection( $itemnumber, $colId ) ) { |
373 |
if ( !isItemInThisCollection( $itemnumber, $colId ) ) { |
374 |
return ( 0, 2, "Item is not in the collection!" ); |
374 |
return ( 0, 2, "NOT_IN_COLLECTION" ); |
375 |
} |
375 |
} |
376 |
|
376 |
|
377 |
my $dbh = C4::Context->dbh; |
377 |
my $dbh = C4::Context->dbh; |
Lines 408-417
sub TransferCollection {
Link Here
|
408 |
|
408 |
|
409 |
## Check for all neccessary parameters |
409 |
## Check for all neccessary parameters |
410 |
if ( !$colId ) { |
410 |
if ( !$colId ) { |
411 |
return ( 0, 1, "No Id Given" ); |
411 |
return ( 0, 1, "NO_ID" ); |
412 |
} |
412 |
} |
413 |
if ( !$colBranchcode ) { |
413 |
if ( !$colBranchcode ) { |
414 |
return ( 0, 2, "No Branchcode Given" ); |
414 |
return ( 0, 2, "NO_BRANCHCODE" ); |
415 |
} |
415 |
} |
416 |
|
416 |
|
417 |
my $dbh = C4::Context->dbh; |
417 |
my $dbh = C4::Context->dbh; |
Lines 435-443
sub TransferCollection {
Link Here
|
435 |
$sth->execute($colId) or return ( 0, 4, $sth->errstr ); |
435 |
$sth->execute($colId) or return ( 0, 4, $sth->errstr ); |
436 |
my @results; |
436 |
my @results; |
437 |
while ( my $item = $sth->fetchrow_hashref ) { |
437 |
while ( my $item = $sth->fetchrow_hashref ) { |
438 |
transferbook( $colBranchcode, $item->{barcode}, |
438 |
my ($status) = CheckReserves( $item->{itemnumber} ); |
439 |
my $ignore_reserves = 1 ) |
439 |
transferbook( $colBranchcode, $item->{barcode}, my $ignore_reserves = 1 ) unless ( $status eq 'Waiting' ); |
440 |
unless ( GetReserveStatus( $item->{itemnumber} ) eq "Waiting" ); |
|
|
441 |
} |
440 |
} |
442 |
|
441 |
|
443 |
return 1; |
442 |
return 1; |