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
19 #use warnings; FIXME - Bug 2505
28 use C4
::RotatingCollections
;
31 my ($template, $loggedinuser, $cookie)
32 = get_template_and_user
({template_name
=> "rotating_collections/editCollections.tmpl",
36 flagsrequired
=> { tools
=> 'rotating_collections' },
40 # Create new Collection
41 if ( $query->param('action') eq 'create' ) {
42 my $title = $query->param('title');
43 my $description = $query->param('description');
45 my ( $createdSuccessfully, $errorCode, $errorMessage ) = CreateCollection
( $title, $description );
48 previousActionCreate
=> 1,
49 createdTitle
=> $title,
52 if ( $createdSuccessfully ) {
53 $template->param( createSuccess
=> 1 );
55 $template->param( createFailure
=> 1 );
56 $template->param( failureMessage
=> $errorMessage );
60 ## Delete a club or service
61 elsif ( $query->param('action') eq 'delete' ) {
62 my $colId = $query->param('colId');
63 my ( $success, $errorCode, $errorMessage ) = DeleteCollection
( $colId );
65 $template->param( previousActionDelete
=> 1 );
67 $template->param( deleteSuccess
=> 1 );
69 $template->param( deleteFailure
=> 1 );
70 $template->param( failureMessage
=> $errorMessage );
74 ## Edit a club or service: grab data, put in form.
75 elsif ( $query->param('action') eq 'edit' ) {
76 my $colId = $query->param('colId');
77 my ( $colId, $colTitle, $colDesc, $colBranchcode ) = GetCollection
( $colId );
80 previousActionEdit
=> 1,
82 editColTitle
=> $colTitle,
83 editColDescription
=> $colDesc,
87 # Update a Club or Service
88 elsif ( $query->param('action') eq 'update' ) {
89 my $colId = $query->param('colId');
90 my $title = $query->param('title');
91 my $description = $query->param('description');
93 my ( $createdSuccessfully, $errorCode, $errorMessage )
94 = UpdateCollection
( $colId, $title, $description );
97 previousActionUpdate
=> 1,
98 updatedTitle
=> $title,
101 if ( $createdSuccessfully ) {
102 $template->param( updateSuccess
=> 1 );
104 $template->param( updateFailure
=> 1 );
105 $template->param( failureMessage
=> $errorMessage );
109 my $collections = GetCollections
();
112 intranetcolorstylesheet
=> C4
::Context
->preference("intranetcolorstylesheet"),
113 intranetstylesheet
=> C4
::Context
->preference("intranetstylesheet"),
114 IntranetNav
=> C4
::Context
->preference("IntranetNav"),
116 collectionsLoop
=> $collections,
119 output_html_with_http_headers
$query, $cookie, $template->output;