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

(-)a/C4/RotatingCollections.pm (-245 / +266 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 81-108 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 ) VALUES ( NULL, ?, ? )
101
  $sth->execute( $title, $description ) or return ( 0, 3, $sth->errstr() );
101
    ");
102
  $sth->finish;
102
    $sth->execute( $title, $description ) or return ( 0, 3, $sth->errstr() );
103
    $sth->finish;
104
105
    return 1;
103
106
104
  return 1;
105
 
106
}
107
}
107
108
108
=head2 UpdateCollection
109
=head2 UpdateCollection
Lines 124-154 Updates a collection Link Here
124
=cut
125
=cut
125
126
126
sub UpdateCollection {
127
sub UpdateCollection {
127
  my ( $colId, $title, $description ) = @_;
128
    my ( $colId, $title, $description ) = @_;
128
129
129
  ## Check for all neccessary parameters
130
    ## Check for all neccessary parameters
130
  if ( ! $colId ) {
131
    if ( !$colId ) {
131
    return ( 0, 1, "No Id Given" );
132
        return ( 0, 1, "No Id Given" );
132
  }
133
    }
133
  if ( ! $title ) {
134
    if ( !$title ) {
134
    return ( 0, 2, "No Title Given" );
135
        return ( 0, 2, "No Title Given" );
135
  } 
136
    }
136
  if ( ! $description ) {
137
    if ( !$description ) {
137
    return ( 0, 3, "No Description Given" );
138
        return ( 0, 3, "No Description Given" );
138
  } 
139
    }
139
140
140
  my $dbh = C4::Context->dbh;
141
    my $dbh = C4::Context->dbh;
141
142
142
  my $sth;
143
    my $sth;
143
  $sth = $dbh->prepare("UPDATE collections
144
    $sth = $dbh->prepare("
144
                        SET 
145
        UPDATE collections SET colTitle = ?, colDesc = ? WHERE colId = ?
145
                        colTitle = ?, colDesc = ? 
146
    ");
146
                        WHERE colId = ?");
147
    $sth->execute( $title, $description, $colId )
147
  $sth->execute( $title, $description, $colId ) or return ( 0, 4, $sth->errstr() );
148
      or return ( 0, 4, $sth->errstr() );
148
  $sth->finish;
149
    $sth->finish;
149
  
150
150
  return 1;
151
    return 1;
151
  
152
152
}
153
}
153
154
154
=head2 DeleteCollection
155
=head2 DeleteCollection
Lines 167-188 sub UpdateCollection { Link Here
167
=cut
168
=cut
168
169
169
sub DeleteCollection {
170
sub DeleteCollection {
170
  my ( $colId ) = @_;
171
    my ($colId) = @_;
171
172
172
  ## Paramter check
173
    ## Paramter check
173
  if ( ! $colId ) {
174
    if ( !$colId ) {
174
    return ( 0, 1, "No Collection Id Given" );;
175
        return ( 0, 1, "No Collection Id Given" );
175
  }
176
    }
176
  
177
  my $dbh = C4::Context->dbh;
178
177
179
  my $sth;
178
    my $dbh = C4::Context->dbh;
180
179
181
  $sth = $dbh->prepare("DELETE FROM collections WHERE colId = ?");
180
    my $sth;
182
  $sth->execute( $colId ) or return ( 0, 4, $sth->errstr() );
183
  $sth->finish;
184
181
185
  return 1;
182
    $sth = $dbh->prepare("DELETE FROM collections WHERE colId = ?");
183
    $sth->execute($colId) or return ( 0, 4, $sth->errstr() );
184
    $sth->finish;
185
186
    return 1;
186
}
187
}
187
188
188
=head2 GetCollections
189
=head2 GetCollections
Lines 201-219 sub DeleteCollection { Link Here
201
202
202
sub GetCollections {
203
sub GetCollections {
203
204
204
  my $dbh = C4::Context->dbh;
205
    my $dbh = C4::Context->dbh;
205
  
206
206
  my $sth = $dbh->prepare("SELECT * FROM collections");
207
    my $sth = $dbh->prepare("SELECT * FROM collections");
207
  $sth->execute() or return ( 1, $sth->errstr() );
208
    $sth->execute() or return ( 1, $sth->errstr() );
208
  
209
209
  my @results;
210
    my @results;
210
  while ( my $row = $sth->fetchrow_hashref ) {
211
    while ( my $row = $sth->fetchrow_hashref ) {
211
    push( @results , $row );
212
        push( @results, $row );
212
  }
213
    }
213
  
214
214
  $sth->finish;
215
    $sth->finish;
215
  
216
216
  return \@results;
217
    return \@results;
217
}
218
}
218
219
219
=head2 GetItemsInCollection
220
=head2 GetItemsInCollection
Lines 234-267 sub GetCollections { Link Here
234
=cut
235
=cut
235
236
236
sub GetItemsInCollection {
237
sub GetItemsInCollection {
237
  my ( $colId ) = @_;
238
    my ($colId) = @_;
238
239
239
  ## Paramter check
240
    ## Paramter check
240
  if ( ! $colId ) {
241
    if ( !$colId ) {
241
    return ( 0, 0, 1, "No Collection Id Given" );;
242
        return ( 0, 0, 1, "No Collection Id Given" );
242
  }
243
    }
243
244
244
  my $dbh = C4::Context->dbh;
245
    my $dbh = C4::Context->dbh;
245
  
246
246
  my $sth = $dbh->prepare("SELECT 
247
    my $sth = $dbh->prepare("
247
                             biblio.title,
248
        SELECT 
248
                             items.itemcallnumber,
249
            biblio.title,
249
                             items.barcode
250
            items.itemcallnumber,
250
                           FROM collections, collections_tracking, items, biblio
251
            items.barcode
251
                           WHERE collections.colId = collections_tracking.colId
252
        FROM 
252
                           AND collections_tracking.itemnumber = items.itemnumber
253
            collections, 
253
                           AND items.biblionumber = biblio.biblionumber
254
            collections_tracking, 
254
                           AND collections.colId = ? ORDER BY biblio.title");
255
            items, biblio
255
  $sth->execute( $colId ) or return ( 0, 0, 2, $sth->errstr() );
256
        WHERE collections.colId = collections_tracking.colId
256
  
257
          AND collections_tracking.itemnumber = items.itemnumber
257
  my @results;
258
          AND items.biblionumber = biblio.biblionumber
258
  while ( my $row = $sth->fetchrow_hashref ) {
259
          AND collections.colId = ? ORDER BY biblio.title
259
    push( @results , $row );
260
    ");
260
  }
261
    $sth->execute($colId) or return ( 0, 0, 2, $sth->errstr() );
261
  
262
262
  $sth->finish;
263
    my @results;
263
  
264
    while ( my $row = $sth->fetchrow_hashref ) {
264
  return \@results;
265
        push( @results, $row );
266
    }
267
268
    $sth->finish;
269
270
    return \@results;
265
}
271
}
266
272
267
=head2 GetCollection
273
=head2 GetCollection
Lines 278-302 Returns information about a collection Link Here
278
=cut
284
=cut
279
285
280
sub GetCollection {
286
sub GetCollection {
281
  my ( $colId ) = @_;
287
    my ($colId) = @_;
282
288
283
  my $dbh = C4::Context->dbh;
289
    my $dbh = C4::Context->dbh;
284
290
285
  my ( $sth, @results );
291
    my ( $sth, @results );
286
  $sth = $dbh->prepare("SELECT * FROM collections WHERE colId = ?");
292
    $sth = $dbh->prepare("SELECT * FROM collections WHERE colId = ?");
287
  $sth->execute( $colId ) or return 0;
293
    $sth->execute($colId) or return 0;
288
    
294
289
  my $row = $sth->fetchrow_hashref;
295
    my $row = $sth->fetchrow_hashref;
290
  
296
291
  $sth->finish;
297
    $sth->finish;
292
  
298
293
  return (
299
    return (
294
      $$row{'colId'},
300
        $$row{'colId'},   $$row{'colTitle'},
295
      $$row{'colTitle'},
301
        $$row{'colDesc'}, $$row{'colBranchcode'}
296
      $$row{'colDesc'},
302
    );
297
      $$row{'colBranchcode'}
303
298
  );
299
    
300
}
304
}
301
305
302
=head2 AddItemToCollection
306
=head2 AddItemToCollection
Lines 316-347 Adds an item to a rotating collection. Link Here
316
=cut
320
=cut
317
321
318
sub AddItemToCollection {
322
sub AddItemToCollection {
319
  my ( $colId, $itemnumber ) = @_;
323
    my ( $colId, $itemnumber ) = @_;
320
324
321
  ## Check for all neccessary parameters
325
    ## Check for all neccessary parameters
322
  if ( ! $colId ) {
326
    if ( !$colId ) {
323
    return ( 0, 1, "No Collection Given" );
327
        return ( 0, 1, "No Collection Given" );
324
  } 
328
    }
325
  if ( ! $itemnumber ) {
329
    if ( !$itemnumber ) {
326
    return ( 0, 2, "No Itemnumber Given" );
330
        return ( 0, 2, "No Itemnumber Given" );
327
  } 
331
    }
328
  
332
329
  if ( isItemInThisCollection( $itemnumber, $colId ) ) {
333
    if ( isItemInThisCollection( $itemnumber, $colId ) ) {
330
    return ( 0, 2, "Item is already in the collection!" );
334
        return ( 0, 2, "Item is already in the collection!" );
331
  } elsif ( isItemInAnyCollection( $itemnumber ) ) {
335
    }
332
    return ( 0, 3, "Item is already in a different collection!" );
336
    elsif ( isItemInAnyCollection($itemnumber) ) {
333
  }
337
        return ( 0, 3, "Item is already in a different collection!" );
334
338
    }
335
  my $dbh = C4::Context->dbh;
339
336
340
    my $dbh = C4::Context->dbh;
337
  my $sth;
341
338
  $sth = $dbh->prepare("INSERT INTO collections_tracking ( ctId, colId, itemnumber ) 
342
    my $sth;
339
                        VALUES ( NULL, ?, ? )");
343
    $sth = $dbh->prepare("
340
  $sth->execute( $colId, $itemnumber ) or return ( 0, 3, $sth->errstr() );
344
        INSERT INTO collections_tracking ( 
341
  $sth->finish;
345
            ctId, 
342
346
            colId, i
343
  return 1;
347
            temnumber 
344
  
348
        ) VALUES ( NULL, ?, ? )
349
    ");
350
    $sth->execute( $colId, $itemnumber ) or return ( 0, 3, $sth->errstr() );
351
    $sth->finish;
352
353
    return 1;
354
345
}
355
}
346
356
347
=head2  RemoveItemFromCollection
357
=head2  RemoveItemFromCollection
Lines 362-387 Removes an item to a collection Link Here
362
=cut
372
=cut
363
373
364
sub RemoveItemFromCollection {
374
sub RemoveItemFromCollection {
365
  my ( $colId, $itemnumber ) = @_;
375
    my ( $colId, $itemnumber ) = @_;
366
376
367
  ## Check for all neccessary parameters
377
    ## Check for all neccessary parameters
368
  if ( ! $itemnumber ) {
378
    if ( !$itemnumber ) {
369
    return ( 0, 2, "No Itemnumber Given" );
379
        return ( 0, 2, "No Itemnumber Given" );
370
  } 
380
    }
371
  
381
372
  if ( ! isItemInThisCollection( $itemnumber, $colId ) ) {
382
    if ( !isItemInThisCollection( $itemnumber, $colId ) ) {
373
    return ( 0, 2, "Item is not in the collection!" );
383
        return ( 0, 2, "Item is not in the collection!" );
374
  } 
384
    }
375
385
376
  my $dbh = C4::Context->dbh;
386
    my $dbh = C4::Context->dbh;
377
387
378
  my $sth;
388
    my $sth;
379
  $sth = $dbh->prepare("DELETE FROM collections_tracking 
389
    $sth = $dbh->prepare("DELETE FROM collections_tracking WHERE itemnumber = ?");
380
                        WHERE itemnumber = ?");
390
    $sth->execute($itemnumber) or return ( 0, 3, $sth->errstr() );
381
  $sth->execute( $itemnumber ) or return ( 0, 3, $sth->errstr() );
391
    $sth->finish;
382
  $sth->finish;
392
383
393
    return 1;
384
  return 1;
385
}
394
}
386
395
387
=head2 TransferCollection
396
=head2 TransferCollection
Lines 402-440 Transfers a collection to another branch Link Here
402
=cut
411
=cut
403
412
404
sub TransferCollection {
413
sub TransferCollection {
405
  my ( $colId, $colBranchcode ) = @_;
414
    my ( $colId, $colBranchcode ) = @_;
406
415
407
  ## Check for all neccessary parameters
416
    ## Check for all neccessary parameters
408
  if ( ! $colId ) {
417
    if ( !$colId ) {
409
    return ( 0, 1, "No Id Given" );
418
        return ( 0, 1, "No Id Given" );
410
  }
419
    }
411
  if ( ! $colBranchcode ) {
420
    if ( !$colBranchcode ) {
412
    return ( 0, 2, "No Branchcode Given" );
421
        return ( 0, 2, "No Branchcode Given" );
413
  } 
422
    }
414
423
415
  my $dbh = C4::Context->dbh;
424
    my $dbh = C4::Context->dbh;
416
425
417
  my $sth;
426
    my $sth;
418
  $sth = $dbh->prepare("UPDATE collections
427
    $sth = $dbh->prepare("UPDATE collections SET colBranchcode = ? WHERE colId = ?");
419
                        SET 
428
    $sth->execute( $colBranchcode, $colId ) or return ( 0, 4, $sth->errstr() );
420
                        colBranchcode = ? 
429
    $sth->finish;
421
                        WHERE colId = ?");
430
422
  $sth->execute( $colBranchcode, $colId ) or return ( 0, 4, $sth->errstr() );
431
    $sth = $dbh->prepare("
423
  $sth->finish;
432
        SELECT barcode 
424
  
433
        FROM 
425
  $sth = $dbh->prepare("SELECT barcode FROM items, collections_tracking 
434
            items, 
426
                        WHERE items.itemnumber = collections_tracking.itemnumber
435
            collections_tracking 
427
                        AND collections_tracking.colId = ?");
436
        WHERE items.itemnumber = collections_tracking.itemnumber
428
  $sth->execute( $colId ) or return ( 0, 4, $sth->errstr );
437
          AND collections_tracking.colId = ?
429
  my @results;
438
    ");
430
  while ( my $item = $sth->fetchrow_hashref ) {
439
    $sth->execute($colId) or return ( 0, 4, $sth->errstr );
431
    my ( $dotransfer, $messages, $iteminformation ) = transferbook( $colBranchcode, $item->{'barcode'}, my $ignore_reserves = 1);
440
    my @results;
432
  }
441
    while ( my $item = $sth->fetchrow_hashref ) {
433
  
442
        my ( $dotransfer, $messages, $iteminformation ) =
434
443
          transferbook( $colBranchcode, $item->{'barcode'},
435
  
444
            my $ignore_reserves = 1 );
436
  return 1;
445
    }
437
  
446
447
    return 1;
448
438
}
449
}
439
450
440
=head2 GetCollectionItemBranches
451
=head2 GetCollectionItemBranches
Lines 444-472 sub TransferCollection { Link Here
444
=cut
455
=cut
445
456
446
sub GetCollectionItemBranches {
457
sub GetCollectionItemBranches {
447
  my ( $itemnumber ) = @_;
458
    my ($itemnumber) = @_;
448
459
449
  if ( ! $itemnumber ) {
460
    if ( !$itemnumber ) {
450
    return;
461
        return;
451
  }
462
    }
452
463
453
  my $dbh = C4::Context->dbh;
464
    my $dbh = C4::Context->dbh;
454
465
455
  my ( $sth, @results );
466
    my ( $sth, @results );
456
  $sth = $dbh->prepare("SELECT holdingbranch, colBranchcode FROM items, collections, collections_tracking 
467
    $sth = $dbh->prepare("
457
                        WHERE items.itemnumber = collections_tracking.itemnumber
468
        SELECT 
458
                        AND collections.colId = collections_tracking.colId
469
            holdingbranch, 
459
                        AND items.itemnumber = ?");
470
            colBranchcode 
460
  $sth->execute( $itemnumber );
471
        FROM 
461
    
472
            items, 
462
  my $row = $sth->fetchrow_hashref;
473
            collections, 
463
  
474
            collections_tracking 
464
  $sth->finish;
475
        WHERE items.itemnumber = collections_tracking.itemnumber
465
  
476
          AND collections.colId = collections_tracking.colId
466
  return (
477
          AND items.itemnumber = ?
467
      $$row{'holdingbranch'},
478
    ");
468
      $$row{'colBranchcode'},
479
    $sth->execute($itemnumber);
469
  );  
480
481
    my $row = $sth->fetchrow_hashref;
482
483
    $sth->finish;
484
485
    return ( $$row{'holdingbranch'}, $$row{'colBranchcode'}, );
470
}
486
}
471
487
472
=head2 isItemInThisCollection
488
=head2 isItemInThisCollection
Lines 476-491 sub GetCollectionItemBranches { Link Here
476
=cut
492
=cut
477
493
478
sub isItemInThisCollection {
494
sub isItemInThisCollection {
479
  my ( $itemnumber, $colId ) = @_;
495
    my ( $itemnumber, $colId ) = @_;
480
  
496
481
  my $dbh = C4::Context->dbh;
497
    my $dbh = C4::Context->dbh;
482
  
498
483
  my $sth = $dbh->prepare("SELECT COUNT(*) as inCollection FROM collections_tracking WHERE itemnumber = ? AND colId = ?");
499
    my $sth = $dbh->prepare("
484
  $sth->execute( $itemnumber, $colId ) or return( 0 );
500
        SELECT COUNT(*) as inCollection FROM collections_tracking WHERE itemnumber = ? AND colId = ?
485
      
501
    ");
486
  my $row = $sth->fetchrow_hashref;
502
    $sth->execute( $itemnumber, $colId ) or return (0);
487
        
503
488
  return $$row{'inCollection'};
504
    my $row = $sth->fetchrow_hashref;
505
506
    return $$row{'inCollection'};
489
}
507
}
490
508
491
=head2 isItemInAnyCollection
509
=head2 isItemInAnyCollection
Lines 495-517 $inCollection = isItemInAnyCollection( $itemnumber ); Link Here
495
=cut
513
=cut
496
514
497
sub isItemInAnyCollection {
515
sub isItemInAnyCollection {
498
  my ( $itemnumber ) = @_;
516
    my ($itemnumber) = @_;
499
  
517
500
  my $dbh = C4::Context->dbh;
518
    my $dbh = C4::Context->dbh;
501
  
519
502
  my $sth = $dbh->prepare("SELECT itemnumber FROM collections_tracking WHERE itemnumber = ?");
520
    my $sth = $dbh->prepare("
503
  $sth->execute( $itemnumber ) or return( 0 );
521
        SELECT itemnumber FROM collections_tracking WHERE itemnumber = ?
504
      
522
    ");
505
  my $row = $sth->fetchrow_hashref;
523
    $sth->execute($itemnumber) or return (0);
506
        
524
507
  $itemnumber = $row->{itemnumber};
525
    my $row = $sth->fetchrow_hashref;
508
  $sth->finish;
526
509
            
527
    $itemnumber = $row->{itemnumber};
510
  if ( $itemnumber ) {
528
    $sth->finish;
511
    return 1;
529
512
  } else {
530
    if ($itemnumber) {
513
    return 0;
531
        return 1;
514
  }
532
    }
533
    else {
534
        return 0;
535
    }
515
}
536
}
516
537
517
1;
538
1;
(-)a/rotating_collections/addItems.pl (-59 / +68 lines)
Lines 27-99 use C4::Items; Link Here
27
use CGI;
27
use CGI;
28
28
29
my $query = new CGI;
29
my $query = new CGI;
30
my ($template, $loggedinuser, $cookie)
30
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
31
    = get_template_and_user({template_name => "rotating_collections/addItems.tmpl",
31
    {
32
			     query => $query,
32
        template_name   => "rotating_collections/addItems.tmpl",
33
			     type => "intranet",
33
        query           => $query,
34
			     authnotrequired => 0,
34
        type            => "intranet",
35
                          flagsrequired => { tools => 'rotating_collections' },
35
        authnotrequired => 0,
36
			     debug => 1,
36
        flagsrequired   => { tools => 'rotating_collections' },
37
			     });
37
        debug           => 1,
38
    }
39
);
38
40
39
if ( $query->param('action') eq 'addItem' ) {
41
if ( $query->param('action') eq 'addItem' ) {
40
  ## Add the given item to the collection
42
    ## Add the given item to the collection
41
  my $colId = $query->param('colId');
43
    my $colId      = $query->param('colId');
42
  my $barcode = $query->param('barcode');
44
    my $barcode    = $query->param('barcode');
43
  my $removeItem = $query->param('removeItem');
45
    my $removeItem = $query->param('removeItem');
44
  my $itemnumber = GetItemnumberFromBarcode( $barcode );
46
    my $itemnumber = GetItemnumberFromBarcode($barcode);
45
47
46
  my ( $success, $errorCode, $errorMessage );
48
    my ( $success, $errorCode, $errorMessage );
47
  
49
48
  if ( ! $removeItem ) {
50
    if ( !$removeItem ) {
49
    ( $success, $errorCode, $errorMessage ) = AddItemToCollection( $colId, $itemnumber );
51
        ( $success, $errorCode, $errorMessage ) =
50
52
          AddItemToCollection( $colId, $itemnumber );
51
    $template->param(
53
52
      previousActionAdd => 1,
54
        $template->param(
53
      addedBarcode => $barcode,
55
            previousActionAdd => 1,
54
    );
56
            addedBarcode      => $barcode,
55
57
        );
56
    if ( $success ) {
58
57
      $template->param( addSuccess => 1 );
59
        if ($success) {
58
    } else {
60
            $template->param( addSuccess => 1 );
59
      $template->param( addFailure => 1 );
61
        }
60
      $template->param( failureMessage => $errorMessage );
62
        else {
61
    }
63
            $template->param( addFailure     => 1 );
62
  } else {
64
            $template->param( failureMessage => $errorMessage );
63
    ## Remove the given item from the collection
65
        }
64
    ( $success, $errorCode, $errorMessage ) = RemoveItemFromCollection( $colId, $itemnumber );
65
66
    $template->param(
67
      previousActionRemove => 1,
68
      removedBarcode => $barcode,
69
      removeChecked => 1,
70
    );
71
72
    if ( $success ) {
73
      $template->param( removeSuccess => 1 );
74
    } else {
75
      $template->param( removeFailure => 1 );
76
      $template->param( failureMessage => $errorMessage );
77
    }
66
    }
67
    else {
68
        ## Remove the given item from the collection
69
        ( $success, $errorCode, $errorMessage ) =
70
          RemoveItemFromCollection( $colId, $itemnumber );
71
72
        $template->param(
73
            previousActionRemove => 1,
74
            removedBarcode       => $barcode,
75
            removeChecked        => 1,
76
        );
77
78
        if ($success) {
79
            $template->param( removeSuccess => 1 );
80
        }
81
        else {
82
            $template->param( removeFailure  => 1 );
83
            $template->param( failureMessage => $errorMessage );
84
        }
78
85
79
  }  
86
    }
80
}
87
}
81
88
82
my ( $colId, $colTitle, $colDescription, $colBranchcode ) = GetCollection( $query->param('colId') );
89
my ( $colId, $colTitle, $colDescription, $colBranchcode ) =
83
my $collectionItems = GetItemsInCollection( $colId );
90
  GetCollection( $query->param('colId') );
84
if ( $collectionItems ) {
91
my $collectionItems = GetItemsInCollection($colId);
85
  $template->param( collectionItemsLoop => $collectionItems );
92
if ($collectionItems) {
93
    $template->param( collectionItemsLoop => $collectionItems );
86
}
94
}
87
95
88
$template->param(
96
$template->param(
89
                intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
97
    intranetcolorstylesheet =>
90
                intranetstylesheet => C4::Context->preference("intranetstylesheet"),
98
      C4::Context->preference("intranetcolorstylesheet"),
91
                IntranetNav => C4::Context->preference("IntranetNav"),
99
    intranetstylesheet => C4::Context->preference("intranetstylesheet"),
92
                                  
100
    IntranetNav        => C4::Context->preference("IntranetNav"),
93
                colId => $colId,
101
94
                colTitle => $colTitle,
102
    colId          => $colId,
95
                colDescription => $colDescription,
103
    colTitle       => $colTitle,
96
                colBranchcode => $colBranchcode,
104
    colDescription => $colDescription,
97
                );
105
    colBranchcode  => $colBranchcode,
106
);
98
107
99
output_html_with_http_headers $query, $cookie, $template->output;
108
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/rotating_collections/editCollections.pl (-68 / +75 lines)
Lines 27-118 use C4::Context; Link Here
27
use C4::RotatingCollections;
27
use C4::RotatingCollections;
28
28
29
my $query = new CGI;
29
my $query = new CGI;
30
my ($template, $loggedinuser, $cookie)
30
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
31
    = get_template_and_user({template_name => "rotating_collections/editCollections.tmpl",
31
    {
32
			     query => $query,
32
        template_name   => "rotating_collections/editCollections.tmpl",
33
			     type => "intranet",
33
        query           => $query,
34
			     authnotrequired => 0,
34
        type            => "intranet",
35
                          flagsrequired => { tools => 'rotating_collections' },
35
        authnotrequired => 0,
36
			     debug => 1,
36
        flagsrequired   => { tools => 'rotating_collections' },
37
			     });
37
        debug           => 1,
38
    }
39
);
38
40
39
# Create new Collection
41
# Create new Collection
40
if ( $query->param('action') eq 'create' ) {
42
if ( $query->param('action') eq 'create' ) {
41
  my $title = $query->param('title');
43
    my $title       = $query->param('title');
42
  my $description = $query->param('description');
44
    my $description = $query->param('description');
43
                            
45
44
  my ( $createdSuccessfully, $errorCode, $errorMessage ) = CreateCollection( $title, $description );
46
    my ( $createdSuccessfully, $errorCode, $errorMessage ) =
45
                              
47
      CreateCollection( $title, $description );
46
  $template->param(
48
47
    previousActionCreate => 1,
49
    $template->param(
48
    createdTitle => $title,
50
        previousActionCreate => 1,
49
  );
51
        createdTitle         => $title,
50
                                          
52
    );
51
  if ( $createdSuccessfully ) {
53
52
    $template->param( createSuccess => 1 );
54
    if ($createdSuccessfully) {
53
  } else {
55
        $template->param( createSuccess => 1 );
54
    $template->param( createFailure => 1 );
56
    }
55
    $template->param( failureMessage => $errorMessage );
57
    else {
56
  }                                                        
58
        $template->param( createFailure  => 1 );
59
        $template->param( failureMessage => $errorMessage );
60
    }
57
}
61
}
58
62
59
## Delete a club or service
63
## Delete a club or service
60
elsif ( $query->param('action') eq 'delete' ) {
64
elsif ( $query->param('action') eq 'delete' ) {
61
  my $colId = $query->param('colId');
65
    my $colId = $query->param('colId');
62
  my ( $success, $errorCode, $errorMessage ) = DeleteCollection( $colId );
66
    my ( $success, $errorCode, $errorMessage ) = DeleteCollection($colId);
63
    
67
64
  $template->param( previousActionDelete => 1 );
68
    $template->param( previousActionDelete => 1 );
65
  if ( $success ) {
69
    if ($success) {
66
    $template->param( deleteSuccess => 1 );
70
        $template->param( deleteSuccess => 1 );
67
  } else {
71
    }
68
    $template->param( deleteFailure => 1 );
72
    else {
69
    $template->param( failureMessage => $errorMessage );
73
        $template->param( deleteFailure  => 1 );
70
  }
74
        $template->param( failureMessage => $errorMessage );
75
    }
71
}
76
}
72
77
73
## Edit a club or service: grab data, put in form.
78
## Edit a club or service: grab data, put in form.
74
elsif ( $query->param('action') eq 'edit' ) {
79
elsif ( $query->param('action') eq 'edit' ) {
75
  my $colId = $query->param('colId');
80
    my $colId = $query->param('colId');
76
  my ( $colId, $colTitle, $colDesc, $colBranchcode ) = GetCollection( $colId );
81
    my ( $colId, $colTitle, $colDesc, $colBranchcode ) = GetCollection($colId);
77
82
78
  $template->param(
83
    $template->param(
79
      previousActionEdit => 1,
84
        previousActionEdit => 1,
80
      editColId => $colId,
85
        editColId          => $colId,
81
      editColTitle => $colTitle,
86
        editColTitle       => $colTitle,
82
      editColDescription => $colDesc,
87
        editColDescription => $colDesc,
83
  );
88
    );
84
}
89
}
85
90
86
# Update a Club or Service
91
# Update a Club or Service
87
elsif ( $query->param('action') eq 'update' ) {
92
elsif ( $query->param('action') eq 'update' ) {
88
  my $colId = $query->param('colId');
93
    my $colId       = $query->param('colId');
89
  my $title = $query->param('title');
94
    my $title       = $query->param('title');
90
  my $description = $query->param('description');
95
    my $description = $query->param('description');
91
                            
96
92
  my ( $createdSuccessfully, $errorCode, $errorMessage ) 
97
    my ( $createdSuccessfully, $errorCode, $errorMessage ) =
93
    = UpdateCollection( $colId, $title, $description );
98
      UpdateCollection( $colId, $title, $description );
94
                              
99
95
  $template->param(
100
    $template->param(
96
    previousActionUpdate => 1,
101
        previousActionUpdate => 1,
97
    updatedTitle => $title,
102
        updatedTitle         => $title,
98
  );
103
    );
99
                                          
104
100
  if ( $createdSuccessfully ) {
105
    if ($createdSuccessfully) {
101
    $template->param( updateSuccess => 1 );
106
        $template->param( updateSuccess => 1 );
102
  } else {
107
    }
103
    $template->param( updateFailure => 1 );
108
    else {
104
    $template->param( failureMessage => $errorMessage );
109
        $template->param( updateFailure  => 1 );
105
  }                                                        
110
        $template->param( failureMessage => $errorMessage );
111
    }
106
}
112
}
107
                                                        
113
108
my $collections = GetCollections();
114
my $collections = GetCollections();
109
115
110
$template->param(
116
$template->param(
111
		intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
117
    intranetcolorstylesheet =>
112
		intranetstylesheet => C4::Context->preference("intranetstylesheet"),
118
      C4::Context->preference("intranetcolorstylesheet"),
113
		IntranetNav => C4::Context->preference("IntranetNav"),
119
    intranetstylesheet => C4::Context->preference("intranetstylesheet"),
114
		
120
    IntranetNav        => C4::Context->preference("IntranetNav"),
115
		collectionsLoop => $collections,
121
116
		);
122
    collectionsLoop => $collections,
123
);
117
124
118
output_html_with_http_headers $query, $cookie, $template->output;
125
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/rotating_collections/rotatingCollections.pl (-15 / +18 lines)
Lines 26-50 use C4::Context; Link Here
26
use C4::RotatingCollections;
26
use C4::RotatingCollections;
27
27
28
my $query = new CGI;
28
my $query = new CGI;
29
my ($template, $loggedinuser, $cookie)
29
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
30
    = get_template_and_user({template_name => "rotating_collections/rotatingCollections.tmpl",
30
    {
31
			     query => $query,
31
        template_name   => "rotating_collections/rotatingCollections.tmpl",
32
			     type => "intranet",
32
        query           => $query,
33
			     authnotrequired => 0,
33
        type            => "intranet",
34
                          flagsrequired => { tools => 'rotating_collections' },
34
        authnotrequired => 0,
35
			     debug => 1,
35
        flagsrequired   => { tools => 'rotating_collections' },
36
			     });
36
        debug           => 1,
37
    }
38
);
37
39
38
my $branchcode = $query->cookie('branch');
40
my $branchcode = $query->cookie('branch');
39
41
40
my $collections = GetCollections();
42
my $collections = GetCollections();
41
43
42
$template->param(
44
$template->param(
43
                intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
45
    intranetcolorstylesheet =>
44
                intranetstylesheet => C4::Context->preference("intranetstylesheet"),
46
      C4::Context->preference("intranetcolorstylesheet"),
45
                IntranetNav => C4::Context->preference("IntranetNav"),
47
    intranetstylesheet => C4::Context->preference("intranetstylesheet"),
46
                                  
48
    IntranetNav        => C4::Context->preference("IntranetNav"),
47
                collectionsLoop => $collections,
49
48
                );
50
    collectionsLoop => $collections,
49
                                                                                                
51
);
52
50
output_html_with_http_headers $query, $cookie, $template->output;
53
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/rotating_collections/transferCollection.pl (-38 / +43 lines)
Lines 28-82 use CGI; Link Here
28
28
29
my $query = new CGI;
29
my $query = new CGI;
30
30
31
my $colId = $query->param('colId');
31
my $colId    = $query->param('colId');
32
my $toBranch = $query->param('toBranch');
32
my $toBranch = $query->param('toBranch');
33
33
34
my ($template, $loggedinuser, $cookie)
34
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
35
    = get_template_and_user({template_name => "rotating_collections/transferCollection.tmpl",
35
    {
36
			     query => $query,
36
        template_name   => "rotating_collections/transferCollection.tmpl",
37
			     type => "intranet",
37
        query           => $query,
38
			     authnotrequired => 0,
38
        type            => "intranet",
39
                          flagsrequired => { tools => 'rotating_collections' },
39
        authnotrequired => 0,
40
			     debug => 1,
40
        flagsrequired   => { tools => 'rotating_collections' },
41
			     });
41
        debug           => 1,
42
    }
43
);
42
44
43
## Transfer collection
45
## Transfer collection
44
my ( $success, $errorCode, $errorMessage );
46
my ( $success, $errorCode, $errorMessage );
45
if ( $toBranch ) {
47
if ($toBranch) {
46
  ( $success, $errorCode, $errorMessage ) = TransferCollection( $colId, $toBranch );
48
    ( $success, $errorCode, $errorMessage ) =
49
      TransferCollection( $colId, $toBranch );
47
50
48
  if ( $success ) {
51
    if ($success) {
49
    $template->param( transferSuccess => 1 );
52
        $template->param( transferSuccess => 1 );
50
  } else {
53
    }
51
    $template->param( transferFailure => 1,
54
    else {
52
                      errorCode => $errorCode,
55
        $template->param(
53
                      errorMessage => $errorMessage
56
            transferFailure => 1,
54
    );
57
            errorCode       => $errorCode,
55
  }
58
            errorMessage    => $errorMessage
59
        );
60
    }
56
}
61
}
57
62
58
## Set up the toBranch select options
63
## Set up the toBranch select options
59
my $branches = GetBranches();
64
my $branches = GetBranches();
60
my @branchoptionloop;
65
my @branchoptionloop;
61
foreach my $br (keys %$branches) {
66
foreach my $br ( keys %$branches ) {
62
  my %branch;
67
    my %branch;
63
  $branch{code}=$br;
68
    $branch{code} = $br;
64
  $branch{name}=$branches->{$br}->{'branchname'};
69
    $branch{name} = $branches->{$br}->{'branchname'};
65
  push (@branchoptionloop, \%branch);
70
    push( @branchoptionloop, \%branch );
66
}
71
}
67
    
72
68
## Get data about collection
73
## Get data about collection
69
my ( $colId, $colTitle, $colDesc, $colBranchcode ) = GetCollection( $colId );                                
74
my ( $colId, $colTitle, $colDesc, $colBranchcode ) = GetCollection($colId);
70
$template->param(
75
$template->param(
71
                intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
76
    intranetcolorstylesheet =>
72
                intranetstylesheet => C4::Context->preference("intranetstylesheet"),
77
      C4::Context->preference("intranetcolorstylesheet"),
73
                IntranetNav => C4::Context->preference("IntranetNav"),
78
    intranetstylesheet => C4::Context->preference("intranetstylesheet"),
74
                                  
79
    IntranetNav        => C4::Context->preference("IntranetNav"),
75
                colId => $colId,
80
76
                colTitle => $colTitle,
81
    colId            => $colId,
77
                colDesc => $colDesc,
82
    colTitle         => $colTitle,
78
                colBranchcode => $colBranchcode,
83
    colDesc          => $colDesc,
79
                branchoptionloop => \@branchoptionloop
84
    colBranchcode    => $colBranchcode,
80
                );
85
    branchoptionloop => \@branchoptionloop
81
                                                                                                
86
);
87
82
output_html_with_http_headers $query, $cookie, $template->output;
88
output_html_with_http_headers $query, $cookie, $template->output;
83
- 

Return to bug 8836