5 =head1 NAME $RCSfile: processschedule.cgi,v $
15 Andrew DeFaria <Andrew@ClearSCM.com>
23 Mon Oct 25 11:10:47 PDT 2008
27 $Date: 2011/02/14 14:53:36 $
33 Usage processschedule.cgi: [-u|sage] [-ve|rbose] [-d|ebug]
34 action=[Add|Delete|Edit|Post]
38 -u|sage: Displays usage
40 -d|ebug: Output debug messages
42 action: Specifies to add, delete, edit or post an alert
43 schedule: Schedule to delete or edit
47 This script adds, deletes, edits or posts a schedule
56 use CGI qw (:standard :cgi-lib *table start_Tr end_Tr);
57 use CGI::Carp 'fatalsToBrowser';
59 use lib "$FindBin::Bin/lib", "$FindBin::Bin/../lib";
66 my $VERSION = '$Revision: 1.3 $';
67 ($VERSION) = ($VERSION =~ /\$Revision: (.*) /);
73 usage => sub { Usage },
74 verbose => sub { set_verbose },
75 debug => sub { set_debug },
76 ) or Usage 'Invalid parameter';
79 verbose "$FindBin::Script v$VERSION";
81 $clearadm = Clearadm->new;
85 my $title = 'Schedule';
89 unless ($opts{'delete.x'} or $opts{'edit.x'} or $opts{action}) {
90 displayError 'Action not defined!';
94 unless ($opts{action} eq 'Add') {
95 unless ($opts{name}) {
96 displayError 'Schedule not defined!';
103 if ($opts{action} eq 'Add') {
104 display h1 {class => 'center'}, 'Add Schedule';
106 } elsif ($opts{'delete.x'}) {
107 ($err, $msg) = $clearadm->DeleteSchedule ($opts{name});
109 if ($msg !~ /Records deleted/) {
110 displayError "Unable to delete schedule $opts{name}\n$msg";
112 display h1 {class => 'center'}, $title;
113 display h3 {class => 'center'}, "Schedule $opts{name} deleted";
117 } elsif ($opts{'edit.x'}) {
118 display h1 {class => 'center'}, 'Edit Schedule: ', $opts{name};
119 editSchedule ($opts{name});
120 } elsif ($opts{action} eq 'Post') {
121 delete $opts{action};
123 my $nbr = delete $opts{nbr};
124 my $multiplier = delete $opts{multiplier};
127 $multiplier = substr $multiplier, 0, -1;
130 $opts{frequency} = "$nbr $multiplier";
132 my %schedule = $clearadm->GetSchedule ($opts{name});
134 if (%schedule or $opts{oldname}) {
135 my $name = delete $opts{oldname};
137 $name ||= $opts{name};
139 $opts{active} = 'false'
140 unless $opts{active};
142 ($err, $msg) = $clearadm->UpdateSchedule ($name, %opts);
145 displayError "$msg (Status: $err)";
147 display h1 {class => 'center'}, $title;
148 display h3 {class => 'center'}, "Schedule $opts{name} updated";
153 ($err, $msg) = $clearadm->AddSchedule (%opts);
156 displayError "$msg (Status: $err)";
159 display h1 {class => 'center'}, $title;
160 display h3 {class => 'center'}, "Schedule $opts{name} added";
166 displayError "Unknown action - $opts{action}";
173 =head1 CONFIGURATION AND ENVIRONMENT
175 DEBUG: If set then $debug is set to this level.
177 VERBOSE: If set then $verbose is set to this level.
179 TRACE: If set then $trace is set to this level.
187 L<CGI::Carp|CGI::Carp>
191 L<Getopt::Long|Getopt::Long>
193 =head2 ClearSCM Perl Modules
207 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/Clearadm.pm">Clearadm</a><br>
208 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/ClearadmWeb.pm">ClearadmWeb</a><br>
209 <a href="http://clearscm.com/php/scm_man.php?file=lib/Display.pm">Display</a><br>
210 <a href="http://clearscm.com/php/scm_man.php?file=lib/Utils.pm">Utils</a><br>
215 =head1 BUGS AND LIMITATIONS
217 There are no known bugs in this script
219 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
221 =head1 LICENSE AND COPYRIGHT
223 Copyright (c) 2010, ClearSCM, Inc. All rights reserved.