3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 2 of the License, or (at your option) any later
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along with
15 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
16 # Suite 330, Boston, MA 02111-1307 USA
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 # Create new Collection
43 if ( $query->param('action') eq 'create' ) {
44 my $title = $query->param('title');
45 my $description = $query->param('description');
47 my ( $createdSuccessfully, $errorCode, $errorMessage ) =
48 CreateCollection( $title, $description );
51 previousActionCreate => 1,
52 createdTitle => $title,
55 if ($createdSuccessfully) {
56 $template->param( createSuccess => 1 );
59 $template->param( createFailure => 1 );
60 $template->param( failureMessage => $errorMessage );
64 ## Delete a club or service
65 elsif ( $query->param('action') eq 'delete' ) {
66 my $colId = $query->param('colId');
67 my ( $success, $errorCode, $errorMessage ) = DeleteCollection($colId);
69 $template->param( previousActionDelete => 1 );
71 $template->param( deleteSuccess => 1 );
74 $template->param( deleteFailure => 1 );
75 $template->param( failureMessage => $errorMessage );
79 ## Edit a club or service: grab data, put in form.
80 elsif ( $query->param('action') eq 'edit' ) {
81 my $colId = $query->param('colId');
82 my ( $colId, $colTitle, $colDesc, $colBranchcode ) = GetCollection($colId);
85 previousActionEdit => 1,
87 editColTitle => $colTitle,
88 editColDescription => $colDesc,
92 # Update a Club or Service
93 elsif ( $query->param('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 my $collections = GetCollections();
118 intranetcolorstylesheet =>
119 C4::Context->preference("intranetcolorstylesheet"),
120 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
121 IntranetNav => C4::Context->preference("IntranetNav"),
123 collectionsLoop => $collections,
126 output_html_with_http_headers $query, $cookie, $template->output;