|
Lines 23-32
use CGI qw ( -utf8 );
Link Here
|
| 23 |
use C4::Output; |
23 |
use C4::Output; |
| 24 |
use C4::Auth; |
24 |
use C4::Auth; |
| 25 |
use C4::Context; |
25 |
use C4::Context; |
| 26 |
|
|
|
| 27 |
use C4::RotatingCollections; |
26 |
use C4::RotatingCollections; |
| 28 |
|
27 |
|
|
|
28 |
use Koha::RotatingCollections; |
| 29 |
|
| 29 |
my $query = new CGI; |
30 |
my $query = new CGI; |
|
|
31 |
my $action = $query->param('action'); |
| 32 |
my @messages; |
| 30 |
|
33 |
|
| 31 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
34 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
| 32 |
{ |
35 |
{ |
|
Lines 39-47
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Link Here
|
| 39 |
} |
42 |
} |
| 40 |
); |
43 |
); |
| 41 |
|
44 |
|
| 42 |
my $action = $query->param('action'); |
|
|
| 43 |
$template->param( action => $action ); |
| 44 |
|
| 45 |
# Create new Collection |
45 |
# Create new Collection |
| 46 |
if ( $action eq 'create' ) { |
46 |
if ( $action eq 'create' ) { |
| 47 |
my $title = $query->param('title'); |
47 |
my $title = $query->param('title'); |
|
Lines 62-82
if ( $action eq 'create' ) {
Link Here
|
| 62 |
$template->param( createFailure => 1 ); |
62 |
$template->param( createFailure => 1 ); |
| 63 |
$template->param( failureMessage => $errorMessage ); |
63 |
$template->param( failureMessage => $errorMessage ); |
| 64 |
} |
64 |
} |
| 65 |
} |
65 |
} elsif ( $action eq 'delete' ) { # Delete collection |
| 66 |
|
|
|
| 67 |
## Delete a club or service |
| 68 |
elsif ( $action eq 'delete' ) { |
| 69 |
my $colId = $query->param('colId'); |
66 |
my $colId = $query->param('colId'); |
| 70 |
my ( $success, $errorCode, $errorMessage ) = DeleteCollection($colId); |
67 |
my $collection = Koha::RotatingCollections->find($colId); |
|
|
68 |
my $deleted = eval { $collection->delete; }; |
| 71 |
|
69 |
|
| 72 |
$template->param( previousActionDelete => 1 ); |
70 |
if ( $@ or not $deleted ) { |
| 73 |
if ($success) { |
71 |
push @messages, { type => 'error', code => 'error_on_delete' }; |
| 74 |
$template->param( deleteSuccess => 1 ); |
72 |
} else { |
| 75 |
} |
73 |
push @messages, { type => 'message', code => 'success_on_delete' }; |
| 76 |
else { |
|
|
| 77 |
$template->param( deleteFailure => 1 ); |
| 78 |
$template->param( failureMessage => $errorMessage ); |
| 79 |
} |
74 |
} |
|
|
75 |
$action = "list"; |
| 80 |
} |
76 |
} |
| 81 |
|
77 |
|
| 82 |
## Edit a club or service: grab data, put in form. |
78 |
## Edit a club or service: grab data, put in form. |
|
Lines 114-117
elsif ( $action eq 'update' ) {
Link Here
|
| 114 |
} |
110 |
} |
| 115 |
} |
111 |
} |
| 116 |
|
112 |
|
|
|
113 |
$template->param( |
| 114 |
action => $action, |
| 115 |
messages => \@messages, |
| 116 |
); |
| 117 |
|
| 117 |
output_html_with_http_headers $query, $cookie, $template->output; |
118 |
output_html_with_http_headers $query, $cookie, $template->output; |
| 118 |
- |
|
|