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

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