|
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 22-34
package C4::RotatingCollections;
Link Here
|
| 22 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
22 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
| 23 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
23 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 24 |
|
24 |
|
| 25 |
use strict; |
25 |
use Modern::Perl; |
| 26 |
#use warnings; FIXME - Bug 2505 |
|
|
| 27 |
|
| 28 |
require Exporter; |
| 29 |
|
26 |
|
| 30 |
use C4::Context; |
27 |
use C4::Context; |
| 31 |
use C4::Circulation; |
28 |
use C4::Circulation; |
|
|
29 |
use C4::Reserves qw(GetReserveStatus); |
| 32 |
|
30 |
|
| 33 |
use DBI; |
31 |
use DBI; |
| 34 |
|
32 |
|
|
Lines 47-69
C4::RotatingCollections - Functions for managing rotating collections
Link Here
|
| 47 |
|
45 |
|
| 48 |
=cut |
46 |
=cut |
| 49 |
|
47 |
|
| 50 |
@ISA = qw( Exporter ); |
48 |
BEGIN { |
| 51 |
@EXPORT = qw( |
49 |
require Exporter; |
| 52 |
CreateCollection |
50 |
@ISA = qw( Exporter ); |
| 53 |
UpdateCollection |
51 |
@EXPORT = qw( |
| 54 |
DeleteCollection |
52 |
CreateCollection |
| 55 |
|
53 |
UpdateCollection |
| 56 |
GetItemsInCollection |
54 |
DeleteCollection |
|
|
55 |
|
| 56 |
GetItemsInCollection |
| 57 |
|
| 58 |
GetCollection |
| 59 |
GetCollections |
| 57 |
|
60 |
|
| 58 |
GetCollection |
61 |
AddItemToCollection |
| 59 |
GetCollections |
62 |
RemoveItemFromCollection |
| 60 |
|
63 |
TransferCollection |
| 61 |
AddItemToCollection |
|
|
| 62 |
RemoveItemFromCollection |
| 63 |
TransferCollection |
| 64 |
|
64 |
|
| 65 |
GetCollectionItemBranches |
65 |
GetCollectionItemBranches |
| 66 |
); |
66 |
); |
|
|
67 |
} |
| 67 |
|
68 |
|
| 68 |
=head2 CreateCollection |
69 |
=head2 CreateCollection |
| 69 |
( $success, $errorcode, $errormessage ) = CreateCollection( $title, $description ); |
70 |
( $success, $errorcode, $errormessage ) = CreateCollection( $title, $description ); |
|
Lines 81-107
C4::RotatingCollections - Functions for managing rotating collections
Link Here
|
| 81 |
=cut |
82 |
=cut |
| 82 |
|
83 |
|
| 83 |
sub CreateCollection { |
84 |
sub CreateCollection { |
| 84 |
my ( $title, $description ) = @_; |
85 |
my ( $title, $description ) = @_; |
| 85 |
|
86 |
|
| 86 |
## Check for all neccessary parameters |
87 |
## Check for all neccessary parameters |
| 87 |
if ( ! $title ) { |
88 |
if ( !$title ) { |
| 88 |
return ( 0, 1, "No Title Given" ); |
89 |
return ( 0, 1, "No Title Given" ); |
| 89 |
} |
90 |
} |
| 90 |
if ( ! $description ) { |
91 |
if ( !$description ) { |
| 91 |
return ( 0, 2, "No Description Given" ); |
92 |
return ( 0, 2, "No Description Given" ); |
| 92 |
} |
93 |
} |
| 93 |
|
94 |
|
| 94 |
my $success = 1; |
95 |
my $success = 1; |
| 95 |
|
96 |
|
| 96 |
my $dbh = C4::Context->dbh; |
97 |
my $dbh = C4::Context->dbh; |
| 97 |
|
98 |
|
| 98 |
my $sth; |
99 |
my $sth; |
| 99 |
$sth = $dbh->prepare("INSERT INTO collections ( colId, colTitle, colDesc ) |
100 |
$sth = $dbh->prepare( |
| 100 |
VALUES ( NULL, ?, ? )"); |
101 |
"INSERT INTO collections ( colId, colTitle, colDesc ) |
| 101 |
$sth->execute( $title, $description ) or return ( 0, 3, $sth->errstr() ); |
102 |
VALUES ( NULL, ?, ? )" |
|
|
103 |
); |
| 104 |
$sth->execute( $title, $description ) or return ( 0, 3, $sth->errstr() ); |
| 105 |
|
| 106 |
return 1; |
| 102 |
|
107 |
|
| 103 |
return 1; |
|
|
| 104 |
|
| 105 |
} |
108 |
} |
| 106 |
|
109 |
|
| 107 |
=head2 UpdateCollection |
110 |
=head2 UpdateCollection |
|
Lines 123-152
Updates a collection
Link Here
|
| 123 |
=cut |
126 |
=cut |
| 124 |
|
127 |
|
| 125 |
sub UpdateCollection { |
128 |
sub UpdateCollection { |
| 126 |
my ( $colId, $title, $description ) = @_; |
129 |
my ( $colId, $title, $description ) = @_; |
| 127 |
|
130 |
|
| 128 |
## Check for all neccessary parameters |
131 |
## Check for all neccessary parameters |
| 129 |
if ( ! $colId ) { |
132 |
if ( !$colId ) { |
| 130 |
return ( 0, 1, "No Id Given" ); |
133 |
return ( 0, 1, "No Id Given" ); |
| 131 |
} |
134 |
} |
| 132 |
if ( ! $title ) { |
135 |
if ( !$title ) { |
| 133 |
return ( 0, 2, "No Title Given" ); |
136 |
return ( 0, 2, "No Title Given" ); |
| 134 |
} |
137 |
} |
| 135 |
if ( ! $description ) { |
138 |
if ( !$description ) { |
| 136 |
return ( 0, 3, "No Description Given" ); |
139 |
return ( 0, 3, "No Description Given" ); |
| 137 |
} |
140 |
} |
| 138 |
|
141 |
|
| 139 |
my $dbh = C4::Context->dbh; |
142 |
my $dbh = C4::Context->dbh; |
| 140 |
|
143 |
|
| 141 |
my $sth; |
144 |
my $sth; |
| 142 |
$sth = $dbh->prepare("UPDATE collections |
145 |
$sth = $dbh->prepare( |
|
|
146 |
"UPDATE collections |
| 143 |
SET |
147 |
SET |
| 144 |
colTitle = ?, colDesc = ? |
148 |
colTitle = ?, colDesc = ? |
| 145 |
WHERE colId = ?"); |
149 |
WHERE colId = ?" |
| 146 |
$sth->execute( $title, $description, $colId ) or return ( 0, 4, $sth->errstr() ); |
150 |
); |
| 147 |
|
151 |
$sth->execute( $title, $description, $colId ) |
| 148 |
return 1; |
152 |
or return ( 0, 4, $sth->errstr() ); |
| 149 |
|
153 |
|
|
|
154 |
return 1; |
| 155 |
|
| 150 |
} |
156 |
} |
| 151 |
|
157 |
|
| 152 |
=head2 DeleteCollection |
158 |
=head2 DeleteCollection |
|
Lines 165-185
sub UpdateCollection {
Link Here
|
| 165 |
=cut |
171 |
=cut |
| 166 |
|
172 |
|
| 167 |
sub DeleteCollection { |
173 |
sub DeleteCollection { |
| 168 |
my ( $colId ) = @_; |
174 |
my ($colId) = @_; |
|
|
175 |
|
| 176 |
## Paramter check |
| 177 |
if ( !$colId ) { |
| 178 |
return ( 0, 1, "No Collection Id Given" ); |
| 179 |
} |
| 169 |
|
180 |
|
| 170 |
## Paramter check |
181 |
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 |
|
182 |
|
| 177 |
my $sth; |
183 |
my $sth; |
| 178 |
|
184 |
|
| 179 |
$sth = $dbh->prepare("DELETE FROM collections WHERE colId = ?"); |
185 |
$sth = $dbh->prepare("DELETE FROM collections WHERE colId = ?"); |
| 180 |
$sth->execute( $colId ) or return ( 0, 4, $sth->errstr() ); |
186 |
$sth->execute($colId) or return ( 0, 4, $sth->errstr() ); |
| 181 |
|
187 |
|
| 182 |
return 1; |
188 |
return 1; |
| 183 |
} |
189 |
} |
| 184 |
|
190 |
|
| 185 |
=head2 GetCollections |
191 |
=head2 GetCollections |
|
Lines 198-214
sub DeleteCollection {
Link Here
|
| 198 |
|
204 |
|
| 199 |
sub GetCollections { |
205 |
sub GetCollections { |
| 200 |
|
206 |
|
| 201 |
my $dbh = C4::Context->dbh; |
207 |
my $dbh = C4::Context->dbh; |
| 202 |
|
208 |
|
| 203 |
my $sth = $dbh->prepare("SELECT * FROM collections"); |
209 |
my $sth = $dbh->prepare("SELECT * FROM collections"); |
| 204 |
$sth->execute() or return ( 1, $sth->errstr() ); |
210 |
$sth->execute() or return ( 1, $sth->errstr() ); |
| 205 |
|
211 |
|
| 206 |
my @results; |
212 |
my @results; |
| 207 |
while ( my $row = $sth->fetchrow_hashref ) { |
213 |
while ( my $row = $sth->fetchrow_hashref ) { |
| 208 |
push( @results , $row ); |
214 |
push( @results, $row ); |
| 209 |
} |
215 |
} |
| 210 |
|
216 |
|
| 211 |
return \@results; |
217 |
return \@results; |
| 212 |
} |
218 |
} |
| 213 |
|
219 |
|
| 214 |
=head2 GetItemsInCollection |
220 |
=head2 GetItemsInCollection |
|
Lines 229-244
sub GetCollections {
Link Here
|
| 229 |
=cut |
235 |
=cut |
| 230 |
|
236 |
|
| 231 |
sub GetItemsInCollection { |
237 |
sub GetItemsInCollection { |
| 232 |
my ( $colId ) = @_; |
238 |
my ($colId) = @_; |
|
|
239 |
|
| 240 |
## Paramter check |
| 241 |
if ( !$colId ) { |
| 242 |
return ( 0, 0, 1, "No Collection Id Given" ); |
| 243 |
} |
| 233 |
|
244 |
|
| 234 |
## Paramter check |
245 |
my $dbh = C4::Context->dbh; |
| 235 |
if ( ! $colId ) { |
|
|
| 236 |
return ( 0, 0, 1, "No Collection Id Given" );; |
| 237 |
} |
| 238 |
|
246 |
|
| 239 |
my $dbh = C4::Context->dbh; |
247 |
my $sth = $dbh->prepare( |
| 240 |
|
248 |
"SELECT |
| 241 |
my $sth = $dbh->prepare("SELECT |
|
|
| 242 |
biblio.title, |
249 |
biblio.title, |
| 243 |
items.itemcallnumber, |
250 |
items.itemcallnumber, |
| 244 |
items.barcode |
251 |
items.barcode |
|
Lines 246-260
sub GetItemsInCollection {
Link Here
|
| 246 |
WHERE collections.colId = collections_tracking.colId |
253 |
WHERE collections.colId = collections_tracking.colId |
| 247 |
AND collections_tracking.itemnumber = items.itemnumber |
254 |
AND collections_tracking.itemnumber = items.itemnumber |
| 248 |
AND items.biblionumber = biblio.biblionumber |
255 |
AND items.biblionumber = biblio.biblionumber |
| 249 |
AND collections.colId = ? ORDER BY biblio.title"); |
256 |
AND collections.colId = ? ORDER BY biblio.title" |
| 250 |
$sth->execute( $colId ) or return ( 0, 0, 2, $sth->errstr() ); |
257 |
); |
| 251 |
|
258 |
$sth->execute($colId) or return ( 0, 0, 2, $sth->errstr() ); |
| 252 |
my @results; |
259 |
|
| 253 |
while ( my $row = $sth->fetchrow_hashref ) { |
260 |
my @results; |
| 254 |
push( @results , $row ); |
261 |
while ( my $row = $sth->fetchrow_hashref ) { |
| 255 |
} |
262 |
push( @results, $row ); |
| 256 |
|
263 |
} |
| 257 |
return \@results; |
264 |
|
|
|
265 |
return \@results; |
| 258 |
} |
266 |
} |
| 259 |
|
267 |
|
| 260 |
=head2 GetCollection |
268 |
=head2 GetCollection |
|
Lines 271-293
Returns information about a collection
Link Here
|
| 271 |
=cut |
279 |
=cut |
| 272 |
|
280 |
|
| 273 |
sub GetCollection { |
281 |
sub GetCollection { |
| 274 |
my ( $colId ) = @_; |
282 |
my ($colId) = @_; |
| 275 |
|
283 |
|
| 276 |
my $dbh = C4::Context->dbh; |
284 |
my $dbh = C4::Context->dbh; |
| 277 |
|
285 |
|
| 278 |
my ( $sth, @results ); |
286 |
my ( $sth, @results ); |
| 279 |
$sth = $dbh->prepare("SELECT * FROM collections WHERE colId = ?"); |
287 |
$sth = $dbh->prepare("SELECT * FROM collections WHERE colId = ?"); |
| 280 |
$sth->execute( $colId ) or return 0; |
288 |
$sth->execute($colId) or return 0; |
| 281 |
|
289 |
|
| 282 |
my $row = $sth->fetchrow_hashref; |
290 |
my $row = $sth->fetchrow_hashref; |
| 283 |
|
291 |
|
| 284 |
return ( |
292 |
return ( |
| 285 |
$$row{'colId'}, |
293 |
$$row{'colId'}, $$row{'colTitle'}, |
| 286 |
$$row{'colTitle'}, |
294 |
$$row{'colDesc'}, $$row{'colBranchcode'} |
| 287 |
$$row{'colDesc'}, |
295 |
); |
| 288 |
$$row{'colBranchcode'} |
296 |
|
| 289 |
); |
|
|
| 290 |
|
| 291 |
} |
297 |
} |
| 292 |
|
298 |
|
| 293 |
=head2 AddItemToCollection |
299 |
=head2 AddItemToCollection |
|
Lines 307-337
Adds an item to a rotating collection.
Link Here
|
| 307 |
=cut |
313 |
=cut |
| 308 |
|
314 |
|
| 309 |
sub AddItemToCollection { |
315 |
sub AddItemToCollection { |
| 310 |
my ( $colId, $itemnumber ) = @_; |
316 |
my ( $colId, $itemnumber ) = @_; |
| 311 |
|
317 |
|
| 312 |
## Check for all neccessary parameters |
318 |
## Check for all neccessary parameters |
| 313 |
if ( ! $colId ) { |
319 |
if ( !$colId ) { |
| 314 |
return ( 0, 1, "No Collection Given" ); |
320 |
return ( 0, 1, "No Collection Given" ); |
| 315 |
} |
321 |
} |
| 316 |
if ( ! $itemnumber ) { |
322 |
if ( !$itemnumber ) { |
| 317 |
return ( 0, 2, "No Itemnumber Given" ); |
323 |
return ( 0, 2, "No Itemnumber Given" ); |
| 318 |
} |
324 |
} |
| 319 |
|
325 |
|
| 320 |
if ( isItemInThisCollection( $itemnumber, $colId ) ) { |
326 |
if ( isItemInThisCollection( $itemnumber, $colId ) ) { |
| 321 |
return ( 0, 2, "Item is already in the collection!" ); |
327 |
return ( 0, 2, "Item is already in the collection!" ); |
| 322 |
} elsif ( isItemInAnyCollection( $itemnumber ) ) { |
328 |
} |
| 323 |
return ( 0, 3, "Item is already in a different collection!" ); |
329 |
elsif ( isItemInAnyCollection($itemnumber) ) { |
| 324 |
} |
330 |
return ( 0, 3, "Item is already in a different collection!" ); |
| 325 |
|
331 |
} |
| 326 |
my $dbh = C4::Context->dbh; |
332 |
|
| 327 |
|
333 |
my $dbh = C4::Context->dbh; |
| 328 |
my $sth; |
334 |
|
| 329 |
$sth = $dbh->prepare("INSERT INTO collections_tracking ( collections_tracking_id, colId, itemnumber ) |
335 |
my $sth; |
| 330 |
VALUES ( NULL, ?, ? )"); |
336 |
$sth = $dbh->prepare(" |
| 331 |
$sth->execute( $colId, $itemnumber ) or return ( 0, 3, $sth->errstr() ); |
337 |
INSERT INTO collections_tracking ( |
| 332 |
|
338 |
colId, |
| 333 |
return 1; |
339 |
itemnumber |
| 334 |
|
340 |
) VALUES ( ?, ? ) |
|
|
341 |
"); |
| 342 |
$sth->execute( $colId, $itemnumber ) or return ( 0, 3, $sth->errstr() ); |
| 343 |
|
| 344 |
return 1; |
| 345 |
|
| 335 |
} |
346 |
} |
| 336 |
|
347 |
|
| 337 |
=head2 RemoveItemFromCollection |
348 |
=head2 RemoveItemFromCollection |
|
Lines 352-376
Removes an item to a collection
Link Here
|
| 352 |
=cut |
363 |
=cut |
| 353 |
|
364 |
|
| 354 |
sub RemoveItemFromCollection { |
365 |
sub RemoveItemFromCollection { |
| 355 |
my ( $colId, $itemnumber ) = @_; |
366 |
my ( $colId, $itemnumber ) = @_; |
|
|
367 |
|
| 368 |
## Check for all neccessary parameters |
| 369 |
if ( !$itemnumber ) { |
| 370 |
return ( 0, 2, "No Itemnumber Given" ); |
| 371 |
} |
| 356 |
|
372 |
|
| 357 |
## Check for all neccessary parameters |
373 |
if ( !isItemInThisCollection( $itemnumber, $colId ) ) { |
| 358 |
if ( ! $itemnumber ) { |
374 |
return ( 0, 2, "Item is not in the collection!" ); |
| 359 |
return ( 0, 2, "No Itemnumber Given" ); |
375 |
} |
| 360 |
} |
|
|
| 361 |
|
| 362 |
if ( ! isItemInThisCollection( $itemnumber, $colId ) ) { |
| 363 |
return ( 0, 2, "Item is not in the collection!" ); |
| 364 |
} |
| 365 |
|
376 |
|
| 366 |
my $dbh = C4::Context->dbh; |
377 |
my $dbh = C4::Context->dbh; |
| 367 |
|
378 |
|
| 368 |
my $sth; |
379 |
my $sth; |
| 369 |
$sth = $dbh->prepare("DELETE FROM collections_tracking |
380 |
$sth = $dbh->prepare( |
| 370 |
WHERE itemnumber = ?"); |
381 |
"DELETE FROM collections_tracking |
| 371 |
$sth->execute( $itemnumber ) or return ( 0, 3, $sth->errstr() ); |
382 |
WHERE itemnumber = ?" |
|
|
383 |
); |
| 384 |
$sth->execute($itemnumber) or return ( 0, 3, $sth->errstr() ); |
| 372 |
|
385 |
|
| 373 |
return 1; |
386 |
return 1; |
| 374 |
} |
387 |
} |
| 375 |
|
388 |
|
| 376 |
=head2 TransferCollection |
389 |
=head2 TransferCollection |
|
Lines 391-426
Transfers a collection to another branch
Link Here
|
| 391 |
=cut |
404 |
=cut |
| 392 |
|
405 |
|
| 393 |
sub TransferCollection { |
406 |
sub TransferCollection { |
| 394 |
my ( $colId, $colBranchcode ) = @_; |
407 |
my ( $colId, $colBranchcode ) = @_; |
| 395 |
|
408 |
|
| 396 |
## Check for all neccessary parameters |
409 |
## Check for all neccessary parameters |
| 397 |
if ( ! $colId ) { |
410 |
if ( !$colId ) { |
| 398 |
return ( 0, 1, "No Id Given" ); |
411 |
return ( 0, 1, "No Id Given" ); |
| 399 |
} |
412 |
} |
| 400 |
if ( ! $colBranchcode ) { |
413 |
if ( !$colBranchcode ) { |
| 401 |
return ( 0, 2, "No Branchcode Given" ); |
414 |
return ( 0, 2, "No Branchcode Given" ); |
| 402 |
} |
415 |
} |
| 403 |
|
416 |
|
| 404 |
my $dbh = C4::Context->dbh; |
417 |
my $dbh = C4::Context->dbh; |
| 405 |
|
418 |
|
| 406 |
my $sth; |
419 |
my $sth; |
| 407 |
$sth = $dbh->prepare("UPDATE collections |
420 |
$sth = $dbh->prepare( |
|
|
421 |
"UPDATE collections |
| 408 |
SET |
422 |
SET |
| 409 |
colBranchcode = ? |
423 |
colBranchcode = ? |
| 410 |
WHERE colId = ?"); |
424 |
WHERE colId = ?" |
| 411 |
$sth->execute( $colBranchcode, $colId ) or return ( 0, 4, $sth->errstr() ); |
425 |
); |
| 412 |
|
426 |
$sth->execute( $colBranchcode, $colId ) or return ( 0, 4, $sth->errstr() ); |
| 413 |
$sth = $dbh->prepare("SELECT barcode FROM items, collections_tracking |
427 |
|
| 414 |
WHERE items.itemnumber = collections_tracking.itemnumber |
428 |
$sth = $dbh->prepare(q{ |
| 415 |
AND collections_tracking.colId = ?"); |
429 |
SELECT items.itemnumber, items.barcode FROM collections_tracking |
| 416 |
$sth->execute( $colId ) or return ( 0, 4, $sth->errstr ); |
430 |
LEFT JOIN items ON collections_tracking.itemnumber = items.itemnumber |
| 417 |
my @results; |
431 |
LEFT JOIN issues ON items.itemnumber = issues.itemnumber |
| 418 |
while ( my $item = $sth->fetchrow_hashref ) { |
432 |
WHERE issues.borrowernumber IS NULL |
| 419 |
my ( $dotransfer, $messages, $iteminformation ) = transferbook( $colBranchcode, $item->{'barcode'}, my $ignore_reserves = 1); |
433 |
AND collections_tracking.colId = ? |
| 420 |
} |
434 |
}); |
| 421 |
|
435 |
$sth->execute($colId) or return ( 0, 4, $sth->errstr ); |
| 422 |
return 1; |
436 |
my @results; |
| 423 |
|
437 |
while ( my $item = $sth->fetchrow_hashref ) { |
|
|
438 |
transferbook( $colBranchcode, $item->{barcode}, |
| 439 |
my $ignore_reserves = 1 ) |
| 440 |
unless ( GetReserveStatus( $item->{itemnumber} ) eq "Waiting" ); |
| 441 |
} |
| 442 |
|
| 443 |
return 1; |
| 444 |
|
| 424 |
} |
445 |
} |
| 425 |
|
446 |
|
| 426 |
=head2 GetCollectionItemBranches |
447 |
=head2 GetCollectionItemBranches |
|
Lines 430-456
sub TransferCollection {
Link Here
|
| 430 |
=cut |
451 |
=cut |
| 431 |
|
452 |
|
| 432 |
sub GetCollectionItemBranches { |
453 |
sub GetCollectionItemBranches { |
| 433 |
my ( $itemnumber ) = @_; |
454 |
my ($itemnumber) = @_; |
| 434 |
|
455 |
|
| 435 |
if ( ! $itemnumber ) { |
456 |
if ( !$itemnumber ) { |
| 436 |
return; |
457 |
return; |
| 437 |
} |
458 |
} |
| 438 |
|
459 |
|
| 439 |
my $dbh = C4::Context->dbh; |
460 |
my $dbh = C4::Context->dbh; |
| 440 |
|
461 |
|
| 441 |
my ( $sth, @results ); |
462 |
my ( $sth, @results ); |
| 442 |
$sth = $dbh->prepare("SELECT holdingbranch, colBranchcode FROM items, collections, collections_tracking |
463 |
$sth = $dbh->prepare( |
|
|
464 |
"SELECT holdingbranch, colBranchcode FROM items, collections, collections_tracking |
| 443 |
WHERE items.itemnumber = collections_tracking.itemnumber |
465 |
WHERE items.itemnumber = collections_tracking.itemnumber |
| 444 |
AND collections.colId = collections_tracking.colId |
466 |
AND collections.colId = collections_tracking.colId |
| 445 |
AND items.itemnumber = ?"); |
467 |
AND items.itemnumber = ?" |
| 446 |
$sth->execute( $itemnumber ); |
468 |
); |
| 447 |
|
469 |
$sth->execute($itemnumber); |
| 448 |
my $row = $sth->fetchrow_hashref; |
470 |
|
| 449 |
|
471 |
my $row = $sth->fetchrow_hashref; |
| 450 |
return ( |
472 |
|
| 451 |
$$row{'holdingbranch'}, |
473 |
return ( $$row{'holdingbranch'}, $$row{'colBranchcode'}, ); |
| 452 |
$$row{'colBranchcode'}, |
|
|
| 453 |
); |
| 454 |
} |
474 |
} |
| 455 |
|
475 |
|
| 456 |
=head2 isItemInThisCollection |
476 |
=head2 isItemInThisCollection |
|
Lines 460-475
sub GetCollectionItemBranches {
Link Here
|
| 460 |
=cut |
480 |
=cut |
| 461 |
|
481 |
|
| 462 |
sub isItemInThisCollection { |
482 |
sub isItemInThisCollection { |
| 463 |
my ( $itemnumber, $colId ) = @_; |
483 |
my ( $itemnumber, $colId ) = @_; |
| 464 |
|
484 |
|
| 465 |
my $dbh = C4::Context->dbh; |
485 |
my $dbh = C4::Context->dbh; |
| 466 |
|
486 |
|
| 467 |
my $sth = $dbh->prepare("SELECT COUNT(*) as inCollection FROM collections_tracking WHERE itemnumber = ? AND colId = ?"); |
487 |
my $sth = $dbh->prepare( |
| 468 |
$sth->execute( $itemnumber, $colId ) or return( 0 ); |
488 |
"SELECT COUNT(*) as inCollection FROM collections_tracking WHERE itemnumber = ? AND colId = ?" |
| 469 |
|
489 |
); |
| 470 |
my $row = $sth->fetchrow_hashref; |
490 |
$sth->execute( $itemnumber, $colId ) or return (0); |
| 471 |
|
491 |
|
| 472 |
return $$row{'inCollection'}; |
492 |
my $row = $sth->fetchrow_hashref; |
|
|
493 |
|
| 494 |
return $$row{'inCollection'}; |
| 473 |
} |
495 |
} |
| 474 |
|
496 |
|
| 475 |
=head2 isItemInAnyCollection |
497 |
=head2 isItemInAnyCollection |
|
Lines 479-499
$inCollection = isItemInAnyCollection( $itemnumber );
Link Here
|
| 479 |
=cut |
501 |
=cut |
| 480 |
|
502 |
|
| 481 |
sub isItemInAnyCollection { |
503 |
sub isItemInAnyCollection { |
| 482 |
my ( $itemnumber ) = @_; |
504 |
my ($itemnumber) = @_; |
| 483 |
|
505 |
|
| 484 |
my $dbh = C4::Context->dbh; |
506 |
my $dbh = C4::Context->dbh; |
| 485 |
|
507 |
|
| 486 |
my $sth = $dbh->prepare("SELECT itemnumber FROM collections_tracking WHERE itemnumber = ?"); |
508 |
my $sth = $dbh->prepare( |
| 487 |
$sth->execute( $itemnumber ) or return( 0 ); |
509 |
"SELECT itemnumber FROM collections_tracking WHERE itemnumber = ?"); |
| 488 |
|
510 |
$sth->execute($itemnumber) or return (0); |
| 489 |
my $row = $sth->fetchrow_hashref; |
511 |
|
| 490 |
|
512 |
my $row = $sth->fetchrow_hashref; |
| 491 |
$itemnumber = $row->{itemnumber}; |
513 |
|
| 492 |
if ( $itemnumber ) { |
514 |
$itemnumber = $row->{itemnumber}; |
| 493 |
return 1; |
515 |
if ($itemnumber) { |
| 494 |
} else { |
516 |
return 1; |
| 495 |
return 0; |
517 |
} |
| 496 |
} |
518 |
else { |
|
|
519 |
return 0; |
| 520 |
} |
| 497 |
} |
521 |
} |
| 498 |
|
522 |
|
| 499 |
1; |
523 |
1; |