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>.
27 use C4
::RotatingCollections
;
31 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
33 template_name
=> "rotating_collections/editCollections.tt",
37 flagsrequired
=> { tools
=> 'rotating_collections' },
42 my $action = $query->param('action');
43 $template->param( action
=> $action );
45 # Create new Collection
46 if ( $action eq 'create' ) {
47 my $title = $query->param('title');
48 my $description = $query->param('description');
50 my ( $createdSuccessfully, $errorCode, $errorMessage ) =
51 CreateCollection
( $title, $description );
54 previousActionCreate
=> 1,
55 createdTitle
=> $title,
58 if ($createdSuccessfully) {
59 $template->param( createSuccess
=> 1 );
62 $template->param( createFailure
=> 1 );
63 $template->param( failureMessage
=> $errorMessage );
67 ## Delete a club or service
68 elsif ( $action eq 'delete' ) {
69 my $colId = $query->param('colId');
70 my ( $success, $errorCode, $errorMessage ) = DeleteCollection
($colId);
72 $template->param( previousActionDelete
=> 1 );
74 $template->param( deleteSuccess
=> 1 );
77 $template->param( deleteFailure
=> 1 );
78 $template->param( failureMessage
=> $errorMessage );
82 ## Edit a club or service: grab data, put in form.
83 elsif ( $action eq 'edit' ) {
84 my ( $colId, $colTitle, $colDesc, $colBranchcode ) = GetCollection
( $query->param('colId') );
87 previousActionEdit
=> 1,
89 editColTitle
=> $colTitle,
90 editColDescription
=> $colDesc,
94 # Update a Club or Service
95 elsif ( $action eq 'update' ) {
96 my $colId = $query->param('colId');
97 my $title = $query->param('title');
98 my $description = $query->param('description');
100 my ( $createdSuccessfully, $errorCode, $errorMessage ) =
101 UpdateCollection
( $colId, $title, $description );
104 previousActionUpdate
=> 1,
105 updatedTitle
=> $title,
108 if ($createdSuccessfully) {
109 $template->param( updateSuccess
=> 1 );
112 $template->param( updateFailure
=> 1 );
113 $template->param( failureMessage
=> $errorMessage );
117 output_html_with_http_headers
$query, $cookie, $template->output;