Merge remote branch 'koha-fbc/k_bug_5215' into master
[koha.git] / rotating_collections / transferCollection.pl
blobe2c5407db7b5295d359f246051fcc89f80e905f8
1 #!/usr/bin/perl
2 use strict;
3 #use warnings; FIXME - Bug 2505
4 require Exporter;
6 use C4::Output;
7 use C4::Auth;
8 use C4::Context;
9 use C4::RotatingCollections;
10 use C4::Branch;
12 use CGI;
14 my $query = new CGI;
16 my $colId = $query->param('colId');
17 my $toBranch = $query->param('toBranch');
19 my ($template, $loggedinuser, $cookie)
20 = get_template_and_user({template_name => "rotating_collections/transferCollection.tmpl",
21 query => $query,
22 type => "intranet",
23 authnotrequired => 1,
24 flagsrequired => {parameters => 1},
25 debug => 1,
26 });
28 ## Transfer collection
29 my ( $success, $errorCode, $errorMessage );
30 if ( $toBranch ) {
31 ( $success, $errorCode, $errorMessage ) = TransferCollection( $colId, $toBranch );
33 if ( $success ) {
34 $template->param( transferSuccess => 1 );
35 } else {
36 $template->param( transferFailure => 1,
37 errorCode => $errorCode,
38 errorMessage => $errorMessage
43 ## Set up the toBranch select options
44 my $branches = GetBranches();
45 my @branchoptionloop;
46 foreach my $br (keys %$branches) {
47 my %branch;
48 $branch{code}=$br;
49 $branch{name}=$branches->{$br}->{'branchname'};
50 push (@branchoptionloop, \%branch);
53 ## Get data about collection
54 my ( $colId, $colTitle, $colDesc, $colBranchcode ) = GetCollection( $colId );
55 $template->param(
56 intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
57 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
58 IntranetNav => C4::Context->preference("IntranetNav"),
60 colId => $colId,
61 colTitle => $colTitle,
62 colDesc => $colDesc,
63 colBranchcode => $colBranchcode,
64 branchoptionloop => \@branchoptionloop
67 output_html_with_http_headers $query, $cookie, $template->output;