View | Details | Raw Unified | Return to bug 8836
Collapse All | Expand All

(-)a/C4/Circulation.pm (+2 lines)
Lines 42-47 use C4::Koha qw( Link Here
42
    GetKohaAuthorisedValueLib
42
    GetKohaAuthorisedValueLib
43
);
43
);
44
use C4::Overdues qw(CalcFine UpdateFine);
44
use C4::Overdues qw(CalcFine UpdateFine);
45
use C4::RotatingCollections qw(GetCollectionItemBranches);
45
use Algorithm::CheckDigits;
46
use Algorithm::CheckDigits;
46
47
47
use Data::Dumper;
48
use Data::Dumper;
Lines 2006-2011 sub AddReturn { Link Here
2006
            $messages->{'NeedsTransfer'} = 1;   # TODO: instead of 1, specify branchcode that the transfer SHOULD go to, $item->{homebranch}
2007
            $messages->{'NeedsTransfer'} = 1;   # TODO: instead of 1, specify branchcode that the transfer SHOULD go to, $item->{homebranch}
2007
        }
2008
        }
2008
    }
2009
    }
2010
2009
    return ( $doreturn, $messages, $issue, $borrower );
2011
    return ( $doreturn, $messages, $issue, $borrower );
2010
}
2012
}
2011
2013
(-)a/C4/RotatingCollections.pm (-221 / +245 lines)
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;
(-)a/circ/returns.pl (-14 / +10 lines)
Lines 600-619 $template->param( Link Here
600
    BlockReturnOfWithdrawnItems => C4::Context->preference("BlockReturnOfWithdrawnItems"),
600
    BlockReturnOfWithdrawnItems => C4::Context->preference("BlockReturnOfWithdrawnItems"),
601
);
601
);
602
602
603
### Comment out rotating collections for now to allow it a little more time to bake
603
my $itemnumber = GetItemnumberFromBarcode( $query->param('barcode') );
604
### for 3.4; in particular, must ensure that it doesn't fight with transfers required
604
if ( $itemnumber ) {
605
### to fill hold requests
605
   my ( $holdingBranch, $collectionBranch ) = GetCollectionItemBranches( $itemnumber );
606
### -- Galen Charlton 2010-10-06
606
    if ( ! ( $holdingBranch eq $collectionBranch ) ) {
607
#my $itemnumber = GetItemnumberFromBarcode( $query->param('barcode') );
607
        $template->param(
608
#if ( $itemnumber ) {
608
          collectionItemNeedsTransferred => 1,
609
#   my ( $holdingBranch, $collectionBranch ) = GetCollectionItemBranches( $itemnumber );
609
          collectionBranch => GetBranchName($collectionBranch),
610
#    if ( ! ( $holdingBranch eq $collectionBranch ) ) {
610
        );
611
#        $template->param(
611
    }
612
#          collectionItemNeedsTransferred => 1,
612
}
613
#          collectionBranch => GetBranchName($collectionBranch),
614
#        );
615
#    }
616
#}                                                                                                            
617
613
618
# actually print the page!
614
# actually print the page!
619
output_html_with_http_headers $query, $cookie, $template->output;
615
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/installer/data/mysql/kohastructure.sql (-1 / +7 lines)
Lines 480-490 CREATE TABLE collections ( Link Here
480
  colId integer(11) NOT NULL auto_increment,
480
  colId integer(11) NOT NULL auto_increment,
481
  colTitle varchar(100) NOT NULL DEFAULT '',
481
  colTitle varchar(100) NOT NULL DEFAULT '',
482
  colDesc text NOT NULL,
482
  colDesc text NOT NULL,
483
  colBranchcode varchar(4) DEFAULT NULL comment 'branchcode for branch where item should be held.',
483
  colBranchcode varchar(10) DEFAULT NULL, -- 'branchcode for branch where item should be held.'
484
  PRIMARY KEY (colId)
484
  PRIMARY KEY (colId)
485
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8;
485
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8;
486
486
487
--
487
--
488
-- Constraints for table `collections`
489
--
490
ALTER TABLE `collections`
491
  ADD CONSTRAINT `collections_ibfk_1` FOREIGN KEY (`colBranchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE;
492
493
--
488
-- Table: collections_tracking
494
-- Table: collections_tracking
489
--
495
--
490
DROP TABLE IF EXISTS collections_tracking;
496
DROP TABLE IF EXISTS collections_tracking;
(-)a/installer/data/mysql/updatedatabase.pl (+16 lines)
Lines 8603-8608 if ( CheckVersion($DBversion) ) { Link Here
8603
    SetVersion($DBversion);
8603
    SetVersion($DBversion);
8604
}
8604
}
8605
8605
8606
$DBversion = "3.17.00.XXX";
8607
if ( CheckVersion($DBversion) ) {
8608
    $dbh->do(q{
8609
        ALTER TABLE collections CHANGE colBranchcode colBranchcode VARCHAR( 10 ) NULL DEFAULT NULL
8610
    });
8611
    $dbh->do(q{
8612
        ALTER TABLE collections ADD INDEX ( colBranchcode )
8613
    });
8614
    $dbh->do(q{
8615
        ALTER TABLE collections
8616
            ADD CONSTRAINT collections_ibfk_1 FOREIGN KEY (colBranchcode) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE
8617
    });
8618
    print "Upgrade to $DBversion done (Bug 8836 - Resurrect Rotating Collections)\n";
8619
    SetVersion($DBversion);
8620
}
8621
8606
=head1 FUNCTIONS
8622
=head1 FUNCTIONS
8607
8623
8608
=head2 TableExists($table)
8624
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt (-1 / +1 lines)
Lines 109-115 $(document).ready(function () { Link Here
109
[% END %]
109
[% END %]
110
110
111
[% IF ( collectionItemNeedsTransferred ) %]
111
[% IF ( collectionItemNeedsTransferred ) %]
112
	<div id="rotating-collection" class="dialog message">This item is part of a Rotating Collection and needs to be Transferred to [% collectionBranch %]</div>
112
 <div id="rotating-collection" class="dialog message">This item is part of a rotating collection and needs to be transferred to [% collectionBranch %]</div>
113
[% END %]
113
[% END %]
114
114
115
<!-- Patron has fines -->
115
<!-- Patron has fines -->
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/addItems.tt (+7 lines)
Lines 1-6 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Tools &rsaquo; Rotating collections &rsaquo; Add/Remove items</title>
2
<title>Koha &rsaquo; Tools &rsaquo; Rotating collections &rsaquo; Add/Remove items</title>
3
[% INCLUDE 'doc-head-close.inc' %]
3
[% INCLUDE 'doc-head-close.inc' %]
4
<script type="text/javascript">
5
    //<![CDATA[
6
        $( document ).ready(function() {
7
            $("#barcode").focus();
8
        });
9
    //]]>
10
</script>
4
</head>
11
</head>
5
<body>
12
<body>
6
[% INCLUDE 'header.inc' %]
13
[% INCLUDE 'header.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/editCollections.tt (-3 / +7 lines)
Lines 44-56 Link Here
44
      <div>
44
      <div>
45
        [% IF ( collectionsLoop ) %]
45
        [% IF ( collectionsLoop ) %]
46
          <table>
46
          <table>
47
           <thead>
47
            <tr>
48
            <tr>
48
              <th>Title</th>
49
              <th>Title</th>
49
              <th>Description</th>
50
              <th>Description</th>
50
              <th>Holding library</th>
51
              <th>Holding library</th>
51
              <td></td>
52
              <th>&nbsp;</th>
52
              <td></td>
53
              <th>&nbsp;</th>
53
            </tr>
54
            </tr>
55
           <thead>
56
           <tbody>
54
            [% FOREACH collectionsLoo IN collectionsLoop %]
57
            [% FOREACH collectionsLoo IN collectionsLoop %]
55
              <tr>
58
              <tr>
56
                <td>[% collectionsLoo.colTitle %]</td>
59
                <td>[% collectionsLoo.colTitle %]</td>
Lines 60-65 Link Here
60
                <td><a href="editCollections.pl?action=delete&amp;colId=[% collectionsLoo.colId %]">Delete</a></td>
63
                <td><a href="editCollections.pl?action=delete&amp;colId=[% collectionsLoo.colId %]">Delete</a></td>
61
              </tr>
64
              </tr>
62
            [% END %]
65
            [% END %]
66
           </tbody>
63
          </table>
67
          </table>
64
        [% ELSE %]
68
        [% ELSE %]
65
          There are no collections currently defined.
69
          There are no collections currently defined.
Lines 99-105 Link Here
99
                <label for="description">Description: </label>
103
                <label for="description">Description: </label>
100
              </td>
104
              </td>
101
              <td>
105
              <td>
102
                [% IF (editColDescription ) %]<input type="text" size="50" name="description" value="[ editColDescription %]" />
106
                [% IF (editColDescription ) %]<input type="text" size="50" name="description" value="[% editColDescription %]" />
103
                [% ELSE %]<input type="text" size="50" name="description" />[% END %]
107
                [% ELSE %]<input type="text" size="50" name="description" />[% END %]
104
              </td>
108
              </td>
105
            </tr>
109
            </tr>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt (-2 lines)
Lines 142-153 Link Here
142
    <dd>Enter a barcode to generate a printable spine label. For use with dedicated label printers</dd>
142
    <dd>Enter a barcode to generate a printable spine label. For use with dedicated label printers</dd>
143
    [% END %]
143
    [% END %]
144
144
145
<!--
146
    [% IF ( CAN_user_tools_rotating_collections ) %]
145
    [% IF ( CAN_user_tools_rotating_collections ) %]
147
    <dt><a href="/cgi-bin/koha/rotating_collections/rotatingCollections.pl">Rotating collections</a></dt>
146
    <dt><a href="/cgi-bin/koha/rotating_collections/rotatingCollections.pl">Rotating collections</a></dt>
148
    <dd>Manage Rotating Collections</dd>
147
    <dd>Manage Rotating Collections</dd>
149
    [% END %]
148
    [% END %]
150
-->
151
149
152
    [% IF ( CAN_user_tools_marc_modification_templates ) %]
150
    [% IF ( CAN_user_tools_marc_modification_templates ) %]
153
    <dt><a href="/cgi-bin/koha/tools/marc_modification_templates.pl">MARC modification templates</a></dt>
151
    <dt><a href="/cgi-bin/koha/tools/marc_modification_templates.pl">MARC modification templates</a></dt>
(-)a/rotating_collections/addItems.pl (-62 / +70 lines)
Lines 16-24 Link Here
16
# Suite 330, Boston, MA  02111-1307 USA
16
# Suite 330, Boston, MA  02111-1307 USA
17
#
17
#
18
18
19
use strict;
19
use Modern::Perl;
20
#use warnings; FIXME - Bug 2505
21
require Exporter;
22
20
23
use C4::Output;
21
use C4::Output;
24
use C4::Auth;
22
use C4::Auth;
Lines 29-101 use C4::Items; Link Here
29
use CGI;
27
use CGI;
30
28
31
my $query = new CGI;
29
my $query = new CGI;
32
my ($template, $loggedinuser, $cookie)
33
    = get_template_and_user({template_name => "rotating_collections/addItems.tt",
34
			     query => $query,
35
			     type => "intranet",
36
			     authnotrequired => 0,
37
                          flagsrequired => { tools => 'rotating_collections' },
38
			     debug => 1,
39
			     });
40
30
41
if ( $query->param('action') eq 'addItem' ) {
31
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
42
  ## Add the given item to the collection
32
    {
43
  my $colId = $query->param('colId');
33
        template_name   => "rotating_collections/addItems.tmpl",
44
  my $barcode = $query->param('barcode');
34
        query           => $query,
45
  my $removeItem = $query->param('removeItem');
35
        type            => "intranet",
46
  my $itemnumber = GetItemnumberFromBarcode( $barcode );
36
        authnotrequired => 0,
47
37
        flagsrequired   => { tools => 'rotating_collections' },
48
  my ( $success, $errorCode, $errorMessage );
38
        debug           => 1,
49
  
50
  if ( ! $removeItem ) {
51
    ( $success, $errorCode, $errorMessage ) = AddItemToCollection( $colId, $itemnumber );
52
53
    $template->param(
54
      previousActionAdd => 1,
55
      addedBarcode => $barcode,
56
    );
57
58
    if ( $success ) {
59
      $template->param( addSuccess => 1 );
60
    } else {
61
      $template->param( addFailure => 1 );
62
      $template->param( failureMessage => $errorMessage );
63
    }
39
    }
64
  } else {
40
);
65
    ## Remove the given item from the collection
41
66
    ( $success, $errorCode, $errorMessage ) = RemoveItemFromCollection( $colId, $itemnumber );
42
if ( $query->param('action') eq 'addItem' ) {
67
43
    ## Add the given item to the collection
68
    $template->param(
44
    my $colId      = $query->param('colId');
69
      previousActionRemove => 1,
45
    my $barcode    = $query->param('barcode');
70
      removedBarcode => $barcode,
46
    my $removeItem = $query->param('removeItem');
71
      removeChecked => 1,
47
    my $itemnumber = GetItemnumberFromBarcode($barcode);
72
    );
48
73
49
    my ( $success, $errorCode, $errorMessage );
74
    if ( $success ) {
50
75
      $template->param( removeSuccess => 1 );
51
    if ( !$removeItem ) {
76
    } else {
52
        ( $success, $errorCode, $errorMessage ) =
77
      $template->param( removeFailure => 1 );
53
          AddItemToCollection( $colId, $itemnumber );
78
      $template->param( failureMessage => $errorMessage );
54
55
        $template->param(
56
            previousActionAdd => 1,
57
            addedBarcode      => $barcode,
58
        );
59
60
        if ($success) {
61
            $template->param( addSuccess => 1 );
62
        }
63
        else {
64
            $template->param( addFailure     => 1 );
65
            $template->param( failureMessage => $errorMessage );
66
        }
79
    }
67
    }
68
    else {
69
        ## Remove the given item from the collection
70
        ( $success, $errorCode, $errorMessage ) =
71
          RemoveItemFromCollection( $colId, $itemnumber );
72
73
        $template->param(
74
            previousActionRemove => 1,
75
            removedBarcode       => $barcode,
76
            removeChecked        => 1,
77
        );
78
79
        if ($success) {
80
            $template->param( removeSuccess => 1 );
81
        }
82
        else {
83
            $template->param( removeFailure  => 1 );
84
            $template->param( failureMessage => $errorMessage );
85
        }
80
86
81
  }  
87
    }
82
}
88
}
83
89
84
my ( $colId, $colTitle, $colDescription, $colBranchcode ) = GetCollection( $query->param('colId') );
90
my ( $colId, $colTitle, $colDescription, $colBranchcode ) =
85
my $collectionItems = GetItemsInCollection( $colId );
91
  GetCollection( $query->param('colId') );
86
if ( $collectionItems ) {
92
my $collectionItems = GetItemsInCollection($colId);
87
  $template->param( collectionItemsLoop => $collectionItems );
93
if ($collectionItems) {
94
    $template->param( collectionItemsLoop => $collectionItems );
88
}
95
}
89
96
90
$template->param(
97
$template->param(
91
                intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
98
    intranetcolorstylesheet =>
92
                intranetstylesheet => C4::Context->preference("intranetstylesheet"),
99
      C4::Context->preference("intranetcolorstylesheet"),
93
                IntranetNav => C4::Context->preference("IntranetNav"),
100
    intranetstylesheet => C4::Context->preference("intranetstylesheet"),
94
                                  
101
    IntranetNav        => C4::Context->preference("IntranetNav"),
95
                colId => $colId,
102
96
                colTitle => $colTitle,
103
    colId          => $colId,
97
                colDescription => $colDescription,
104
    colTitle       => $colTitle,
98
                colBranchcode => $colBranchcode,
105
    colDescription => $colDescription,
99
                );
106
    colBranchcode  => $colBranchcode,
107
);
100
108
101
output_html_with_http_headers $query, $cookie, $template->output;
109
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/rotating_collections/editCollections.pl (-71 / +78 lines)
Lines 15-23 Link Here
15
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
15
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
16
# Suite 330, Boston, MA  02111-1307 USA
16
# Suite 330, Boston, MA  02111-1307 USA
17
#
17
#
18
use strict;
18
19
#use warnings; FIXME - Bug 2505
19
use Modern::Perl;
20
require Exporter;
21
20
22
use CGI;
21
use CGI;
23
22
Lines 28-119 use C4::Context; Link Here
28
use C4::RotatingCollections;
27
use C4::RotatingCollections;
29
28
30
my $query = new CGI;
29
my $query = new CGI;
31
my ($template, $loggedinuser, $cookie)
30
32
    = get_template_and_user({template_name => "rotating_collections/editCollections.tt",
31
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
33
			     query => $query,
32
    {
34
			     type => "intranet",
33
        template_name   => "rotating_collections/editCollections.tmpl",
35
			     authnotrequired => 0,
34
        query           => $query,
36
                          flagsrequired => { tools => 'rotating_collections' },
35
        type            => "intranet",
37
			     debug => 1,
36
        authnotrequired => 0,
38
			     });
37
        flagsrequired   => { tools => 'rotating_collections' },
38
        debug           => 1,
39
    }
40
);
39
41
40
# Create new Collection
42
# Create new Collection
41
if ( $query->param('action') eq 'create' ) {
43
if ( $query->param('action') eq 'create' ) {
42
  my $title = $query->param('title');
44
    my $title       = $query->param('title');
43
  my $description = $query->param('description');
45
    my $description = $query->param('description');
44
                            
46
45
  my ( $createdSuccessfully, $errorCode, $errorMessage ) = CreateCollection( $title, $description );
47
    my ( $createdSuccessfully, $errorCode, $errorMessage ) =
46
                              
48
      CreateCollection( $title, $description );
47
  $template->param(
49
48
    previousActionCreate => 1,
50
    $template->param(
49
    createdTitle => $title,
51
        previousActionCreate => 1,
50
  );
52
        createdTitle         => $title,
51
                                          
53
    );
52
  if ( $createdSuccessfully ) {
54
53
    $template->param( createSuccess => 1 );
55
    if ($createdSuccessfully) {
54
  } else {
56
        $template->param( createSuccess => 1 );
55
    $template->param( createFailure => 1 );
57
    }
56
    $template->param( failureMessage => $errorMessage );
58
    else {
57
  }                                                        
59
        $template->param( createFailure  => 1 );
60
        $template->param( failureMessage => $errorMessage );
61
    }
58
}
62
}
59
63
60
## Delete a club or service
64
## Delete a club or service
61
elsif ( $query->param('action') eq 'delete' ) {
65
elsif ( $query->param('action') eq 'delete' ) {
62
  my $colId = $query->param('colId');
66
    my $colId = $query->param('colId');
63
  my ( $success, $errorCode, $errorMessage ) = DeleteCollection( $colId );
67
    my ( $success, $errorCode, $errorMessage ) = DeleteCollection($colId);
64
    
68
65
  $template->param( previousActionDelete => 1 );
69
    $template->param( previousActionDelete => 1 );
66
  if ( $success ) {
70
    if ($success) {
67
    $template->param( deleteSuccess => 1 );
71
        $template->param( deleteSuccess => 1 );
68
  } else {
72
    }
69
    $template->param( deleteFailure => 1 );
73
    else {
70
    $template->param( failureMessage => $errorMessage );
74
        $template->param( deleteFailure  => 1 );
71
  }
75
        $template->param( failureMessage => $errorMessage );
76
    }
72
}
77
}
73
78
74
## Edit a club or service: grab data, put in form.
79
## Edit a club or service: grab data, put in form.
75
elsif ( $query->param('action') eq 'edit' ) {
80
elsif ( $query->param('action') eq 'edit' ) {
76
  my $colId = $query->param('colId');
81
    my $colId = $query->param('colId');
77
  my ( $colId, $colTitle, $colDesc, $colBranchcode ) = GetCollection( $colId );
82
    my ( $colId, $colTitle, $colDesc, $colBranchcode ) = GetCollection($colId);
78
83
79
  $template->param(
84
    $template->param(
80
      previousActionEdit => 1,
85
        previousActionEdit => 1,
81
      editColId => $colId,
86
        editColId          => $colId,
82
      editColTitle => $colTitle,
87
        editColTitle       => $colTitle,
83
      editColDescription => $colDesc,
88
        editColDescription => $colDesc,
84
  );
89
    );
85
}
90
}
86
91
87
# Update a Club or Service
92
# Update a Club or Service
88
elsif ( $query->param('action') eq 'update' ) {
93
elsif ( $query->param('action') eq 'update' ) {
89
  my $colId = $query->param('colId');
94
    my $colId       = $query->param('colId');
90
  my $title = $query->param('title');
95
    my $title       = $query->param('title');
91
  my $description = $query->param('description');
96
    my $description = $query->param('description');
92
                            
97
93
  my ( $createdSuccessfully, $errorCode, $errorMessage ) 
98
    my ( $createdSuccessfully, $errorCode, $errorMessage ) =
94
    = UpdateCollection( $colId, $title, $description );
99
      UpdateCollection( $colId, $title, $description );
95
                              
100
96
  $template->param(
101
    $template->param(
97
    previousActionUpdate => 1,
102
        previousActionUpdate => 1,
98
    updatedTitle => $title,
103
        updatedTitle         => $title,
99
  );
104
    );
100
                                          
105
101
  if ( $createdSuccessfully ) {
106
    if ($createdSuccessfully) {
102
    $template->param( updateSuccess => 1 );
107
        $template->param( updateSuccess => 1 );
103
  } else {
108
    }
104
    $template->param( updateFailure => 1 );
109
    else {
105
    $template->param( failureMessage => $errorMessage );
110
        $template->param( updateFailure  => 1 );
106
  }                                                        
111
        $template->param( failureMessage => $errorMessage );
112
    }
107
}
113
}
108
                                                        
114
109
my $collections = GetCollections();
115
my $collections = GetCollections();
110
116
111
$template->param(
117
$template->param(
112
		intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
118
    intranetcolorstylesheet =>
113
		intranetstylesheet => C4::Context->preference("intranetstylesheet"),
119
      C4::Context->preference("intranetcolorstylesheet"),
114
		IntranetNav => C4::Context->preference("IntranetNav"),
120
    intranetstylesheet => C4::Context->preference("intranetstylesheet"),
115
		
121
    IntranetNav        => C4::Context->preference("IntranetNav"),
116
		collectionsLoop => $collections,
122
117
		);
123
    collectionsLoop => $collections,
124
);
118
125
119
output_html_with_http_headers $query, $cookie, $template->output;
126
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/rotating_collections/rotatingCollections.pl (-18 / +20 lines)
Lines 16-24 Link Here
16
# Suite 330, Boston, MA  02111-1307 USA
16
# Suite 330, Boston, MA  02111-1307 USA
17
#
17
#
18
18
19
use strict;
19
use Modern::Perl;
20
#use warnings; FIXME - Bug 2505
21
require Exporter;
22
20
23
use CGI;
21
use CGI;
24
22
Lines 28-52 use C4::Context; Link Here
28
use C4::RotatingCollections;
26
use C4::RotatingCollections;
29
27
30
my $query = new CGI;
28
my $query = new CGI;
31
my ($template, $loggedinuser, $cookie)
29
32
    = get_template_and_user({template_name => "rotating_collections/rotatingCollections.tt",
30
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
33
			     query => $query,
31
    {
34
			     type => "intranet",
32
        template_name   => "rotating_collections/rotatingCollections.tmpl",
35
			     authnotrequired => 0,
33
        query           => $query,
36
                          flagsrequired => { tools => 'rotating_collections' },
34
        type            => "intranet",
37
			     debug => 1,
35
        authnotrequired => 0,
38
			     });
36
        flagsrequired   => { tools => 'rotating_collections' },
37
        debug           => 1,
38
    }
39
);
39
40
40
my $branchcode = $query->cookie('branch');
41
my $branchcode = $query->cookie('branch');
41
42
42
my $collections = GetCollections();
43
my $collections = GetCollections();
43
44
44
$template->param(
45
$template->param(
45
                intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
46
    intranetcolorstylesheet =>
46
                intranetstylesheet => C4::Context->preference("intranetstylesheet"),
47
      C4::Context->preference("intranetcolorstylesheet"),
47
                IntranetNav => C4::Context->preference("IntranetNav"),
48
    intranetstylesheet => C4::Context->preference("intranetstylesheet"),
48
                                  
49
    IntranetNav        => C4::Context->preference("IntranetNav"),
49
                collectionsLoop => $collections,
50
50
                );
51
    collectionsLoop => $collections,
51
                                                                                                
52
);
53
52
output_html_with_http_headers $query, $cookie, $template->output;
54
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/rotating_collections/transferCollection.pl (-41 / +44 lines)
Lines 16-24 Link Here
16
# Suite 330, Boston, MA  02111-1307 USA
16
# Suite 330, Boston, MA  02111-1307 USA
17
#
17
#
18
18
19
use strict;
19
use Modern::Perl;
20
#use warnings; FIXME - Bug 2505
21
require Exporter;
22
20
23
use C4::Output;
21
use C4::Output;
24
use C4::Auth;
22
use C4::Auth;
Lines 30-84 use CGI; Link Here
30
28
31
my $query = new CGI;
29
my $query = new CGI;
32
30
33
my $colId = $query->param('colId');
31
my $colId    = $query->param('colId');
34
my $toBranch = $query->param('toBranch');
32
my $toBranch = $query->param('toBranch');
35
33
36
my ($template, $loggedinuser, $cookie)
34
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
37
    = get_template_and_user({template_name => "rotating_collections/transferCollection.tt",
35
    {
38
			     query => $query,
36
        template_name   => "rotating_collections/transferCollection.tmpl",
39
			     type => "intranet",
37
        query           => $query,
40
			     authnotrequired => 0,
38
        type            => "intranet",
41
                          flagsrequired => { tools => 'rotating_collections' },
39
        authnotrequired => 0,
42
			     debug => 1,
40
        flagsrequired   => { tools => 'rotating_collections' },
43
			     });
41
        debug           => 1,
42
    }
43
);
44
44
45
## Transfer collection
45
## Transfer collection
46
my ( $success, $errorCode, $errorMessage );
46
my ( $success, $errorCode, $errorMessage );
47
if ( $toBranch ) {
47
if ($toBranch) {
48
  ( $success, $errorCode, $errorMessage ) = TransferCollection( $colId, $toBranch );
48
    ( $success, $errorCode, $errorMessage ) =
49
      TransferCollection( $colId, $toBranch );
49
50
50
  if ( $success ) {
51
    if ($success) {
51
    $template->param( transferSuccess => 1 );
52
        $template->param( transferSuccess => 1 );
52
  } else {
53
    }
53
    $template->param( transferFailure => 1,
54
    else {
54
                      errorCode => $errorCode,
55
        $template->param(
55
                      errorMessage => $errorMessage
56
            transferFailure => 1,
56
    );
57
            errorCode       => $errorCode,
57
  }
58
            errorMessage    => $errorMessage
59
        );
60
    }
58
}
61
}
59
62
60
## Set up the toBranch select options
63
## Set up the toBranch select options
61
my $branches = GetBranches();
64
my $branches = GetBranches();
62
my @branchoptionloop;
65
my @branchoptionloop;
63
foreach my $br (keys %$branches) {
66
foreach my $br ( keys %$branches ) {
64
  my %branch;
67
    my %branch;
65
  $branch{code}=$br;
68
    $branch{code} = $br;
66
  $branch{name}=$branches->{$br}->{'branchname'};
69
    $branch{name} = $branches->{$br}->{'branchname'};
67
  push (@branchoptionloop, \%branch);
70
    push( @branchoptionloop, \%branch );
68
}
71
}
69
    
72
70
## Get data about collection
73
## Get data about collection
71
my ( $colId, $colTitle, $colDesc, $colBranchcode ) = GetCollection( $colId );                                
74
my ( $colId, $colTitle, $colDesc, $colBranchcode ) = GetCollection($colId);
72
$template->param(
75
$template->param(
73
                intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
76
    intranetcolorstylesheet =>
74
                intranetstylesheet => C4::Context->preference("intranetstylesheet"),
77
      C4::Context->preference("intranetcolorstylesheet"),
75
                IntranetNav => C4::Context->preference("IntranetNav"),
78
    intranetstylesheet => C4::Context->preference("intranetstylesheet"),
76
                                  
79
    IntranetNav        => C4::Context->preference("IntranetNav"),
77
                colId => $colId,
80
78
                colTitle => $colTitle,
81
    colId            => $colId,
79
                colDesc => $colDesc,
82
    colTitle         => $colTitle,
80
                colBranchcode => $colBranchcode,
83
    colDesc          => $colDesc,
81
                branchoptionloop => \@branchoptionloop
84
    colBranchcode    => $colBranchcode,
82
                );
85
    branchoptionloop => \@branchoptionloop
83
                                                                                                
86
);
87
84
output_html_with_http_headers $query, $cookie, $template->output;
88
output_html_with_http_headers $query, $cookie, $template->output;
85
- 

Return to bug 8836