3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
23 use C4::Output qw( output_html_with_http_headers );
24 use C4::Auth qw( get_template_and_user );
27 use C4::RotatingCollections;
31 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
33 template_name => "rotating_collections/editCollections.tt",
36 flagsrequired => { tools => 'rotating_collections' },
40 my $action = $query->param('action');
41 $template->param( action => $action );
43 # Create new Collection
44 if ( $action eq 'create' ) {
45 my $title = $query->param('title');
46 my $description = $query->param('description');
48 my ( $createdSuccessfully, $errorCode, $errorMessage ) =
49 CreateCollection( $title, $description );
52 previousActionCreate => 1,
53 createdTitle => $title,
56 if ($createdSuccessfully) {
57 $template->param( createSuccess => 1 );
60 $template->param( createFailure => 1 );
61 $template->param( failureMessage => $errorMessage );
65 ## Delete a club or service
66 elsif ( $action eq 'delete' ) {
67 my $colId = $query->param('colId');
68 my ( $success, $errorCode, $errorMessage ) = DeleteCollection($colId);
70 $template->param( previousActionDelete => 1 );
72 $template->param( deleteSuccess => 1 );
75 $template->param( deleteFailure => 1 );
76 $template->param( failureMessage => $errorMessage );
80 ## Edit a club or service: grab data, put in form.
81 elsif ( $action eq 'edit' ) {
82 my ( $colId, $colTitle, $colDesc, $colBranchcode ) = GetCollection( $query->param('colId') );
85 previousActionEdit => 1,
87 editColTitle => $colTitle,
88 editColDescription => $colDesc,
92 # Update a Club or Service
93 elsif ( $action eq 'update' ) {
94 my $colId = $query->param('colId');
95 my $title = $query->param('title');
96 my $description = $query->param('description');
98 my ( $createdSuccessfully, $errorCode, $errorMessage ) =
99 UpdateCollection( $colId, $title, $description );
102 previousActionUpdate => 1,
103 updatedTitle => $title,
106 if ($createdSuccessfully) {
107 $template->param( updateSuccess => 1 );
110 $template->param( updateFailure => 1 );
111 $template->param( failureMessage => $errorMessage );
115 output_html_with_http_headers $query, $cookie, $template->output;