MT 2426 : Default currency is chosen for price calculation when bookseller's listpric...
[koha.git] / rotating_collections / editCollections.pl
blob1dba296352a4a80af102fca00aa8afe11237cfa5
1 #!/usr/bin/perl
3 use strict;
4 require Exporter;
6 use CGI;
8 use C4::Output;
9 use C4::Auth;
10 use C4::Context;
12 use C4::RotatingCollections;
14 my $query = new CGI;
15 my ($template, $loggedinuser, $cookie)
16 = get_template_and_user({template_name => "rotating_collections/editCollections.tmpl",
17 query => $query,
18 type => "intranet",
19 authnotrequired => 1,
20 flagsrequired => {parameters => 1},
21 debug => 1,
22 });
24 # Create new Collection
25 if ( $query->param('action') eq 'create' ) {
26 my $title = $query->param('title');
27 my $description = $query->param('description');
29 my ( $createdSuccessfully, $errorCode, $errorMessage ) = CreateCollection( $title, $description );
31 $template->param(
32 previousActionCreate => 1,
33 createdTitle => $title,
36 if ( $createdSuccessfully ) {
37 $template->param( createSuccess => 1 );
38 } else {
39 $template->param( createFailure => 1 );
40 $template->param( failureMessage => $errorMessage );
44 ## Delete a club or service
45 elsif ( $query->param('action') eq 'delete' ) {
46 my $colId = $query->param('colId');
47 my ( $success, $errorCode, $errorMessage ) = DeleteCollection( $colId );
49 $template->param( previousActionDelete => 1 );
50 if ( $success ) {
51 $template->param( deleteSuccess => 1 );
52 } else {
53 $template->param( deleteFailure => 1 );
54 $template->param( failureMessage => $errorMessage );
58 ## Edit a club or service: grab data, put in form.
59 elsif ( $query->param('action') eq 'edit' ) {
60 my $colId = $query->param('colId');
61 my ( $colId, $colTitle, $colDesc, $colBranchcode ) = GetCollection( $colId );
63 $template->param(
64 previousActionEdit => 1,
65 editColId => $colId,
66 editColTitle => $colTitle,
67 editColDescription => $colDesc,
71 # Update a Club or Service
72 elsif ( $query->param('action') eq 'update' ) {
73 my $colId = $query->param('colId');
74 my $title = $query->param('title');
75 my $description = $query->param('description');
77 my ( $createdSuccessfully, $errorCode, $errorMessage )
78 = UpdateCollection( $colId, $title, $description );
80 $template->param(
81 previousActionUpdate => 1,
82 updatedTitle => $title,
85 if ( $createdSuccessfully ) {
86 $template->param( updateSuccess => 1 );
87 } else {
88 $template->param( updateFailure => 1 );
89 $template->param( failureMessage => $errorMessage );
93 my $collections = GetCollections();
95 $template->param(
96 intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
97 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
98 IntranetNav => C4::Context->preference("IntranetNav"),
100 collectionsLoop => $collections,
103 output_html_with_http_headers $query, $cookie, $template->output;