ASNMTAP
view release on metacpan or search on metacpan
applications/htmlroot/cgi-bin/admin/holidays.pl view on Meta::CPAN
#!/usr/bin/env perl
# ---------------------------------------------------------------------------------------------------------
# © Copyright 2003-2011 Alex Peeters [alex.peeters@citap.be]
# ---------------------------------------------------------------------------------------------------------
# 2011/mm/dd, v3.002.003, holidays.pl for ASNMTAP::Asnmtap::Applications::CGI
# ---------------------------------------------------------------------------------------------------------
use strict;
use warnings; # Must be used in test mode only. This reduces a little process speed
#use diagnostics; # Must be used in test mode only. This reduces a lot of process speed
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BEGIN { if ( $ENV{ASNMTAP_PERL5LIB} ) { eval 'use lib ( "$ENV{ASNMTAP_PERL5LIB}" )'; } }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
use DBI;
use CGI;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
use ASNMTAP::Asnmtap::Applications::CGI v3.002.003;
use ASNMTAP::Asnmtap::Applications::CGI qw(:APPLICATIONS :CGI :ADMIN :DBREADWRITE :DBTABLES);
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
use vars qw($PROGNAME);
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$PROGNAME = "holidays.pl";
my $prgtext = "Holidays";
my $version = do { my @r = (q$Revision: 3.002.003$ =~ /\d+/g); sprintf "%d."."%03d" x $#r, @r }; # must be all on one line or MakeMaker will get confused.
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# URL Access Parameters
my $cgi = new CGI;
my $pagedir = (defined $cgi->param('pagedir')) ? $cgi->param('pagedir') : '<NIHIL>'; $pagedir =~ s/\+/ /g;
my $pageset = (defined $cgi->param('pageset')) ? $cgi->param('pageset') : 'admin'; $pageset =~ s/\+/ /g;
my $debug = (defined $cgi->param('debug')) ? $cgi->param('debug') : 'F';
my $pageNo = (defined $cgi->param('pageNo')) ? $cgi->param('pageNo') : 1;
my $pageOffset = (defined $cgi->param('pageOffset')) ? $cgi->param('pageOffset') : 0;
my $orderBy = (defined $cgi->param('orderBy')) ? $cgi->param('orderBy') : 'holiday asc, countryName asc, formule asc, month asc, day asc, offset asc';
my $action = (defined $cgi->param('action')) ? $cgi->param('action') : 'listView';
my $CcatalogID = (defined $cgi->param('catalogID')) ? $cgi->param('catalogID') : $CATALOGID;
my $CcatalogIDreload = (defined $cgi->param('catalogIDreload')) ? $cgi->param('catalogIDreload') : 0;
my $CholidayID = (defined $cgi->param('holidayID')) ? $cgi->param('holidayID') : 'none';
my $Cformule = (defined $cgi->param('formule')) ? $cgi->param('formule') : 0;
my $Cmonth = (defined $cgi->param('month')) ? $cgi->param('month') : 0;
my $Cday = (defined $cgi->param('day')) ? $cgi->param('day') : 0;
my $Coffset = (defined $cgi->param('offset')) ? $cgi->param('offset') : 0;
my $CcountryID = (defined $cgi->param('countryID')) ? $cgi->param('countryID') : 'none';
my $Choliday = (defined $cgi->param('holiday')) ? $cgi->param('holiday') : '';
my $Cactivated = (defined $cgi->param('activated')) ? $cgi->param('activated') : 'off';
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my $htmlTitle = $APPLICATION;
# Init parameters
my ($rv, $dbh, $sth, $sql, $header, $numberRecordsIntoQuery, $nextAction, $formDisabledAll, $formDisabledPrimaryKey, $submitButton);
# User Session and Access Control
my ($sessionID, $iconAdd, $iconDelete, $iconDetails, $iconEdit, $iconQuery, $iconTable, $errorUserAccessControl, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, $subTitle) = user_session_and_access_control (1, 'admin', $c...
# Serialize the URL Access Parameters into a string
my $urlAccessParameters = "pagedir=$pagedir&pageset=$pageset&debug=$debug&CGISESSID=$sessionID&pageNo=$pageNo&pageOffset=$pageOffset&orderBy=$orderBy&action=$action&catalogID=$CcatalogID&catalogIDreload=$CcatalogIDreload&holidayID=$CholidayID&formule...
applications/htmlroot/cgi-bin/admin/holidays.pl view on Meta::CPAN
if ($action eq 'duplicateView') {
$CcatalogID = $CATALOGID;
$CholidayID = '';
}
$Cactivated = ($Cactivated == 1) ? 'on' : 'off';
$sth->finish() or $rv = error_trap_DBI(*STDOUT, "Cannot sth->finish: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID);
}
}
if ($action eq 'deleteView' or $action eq 'displayView' or $action eq 'duplicateView' or $action eq 'editView' or $action eq 'insertView') {
$sql = "select countryID, countryName from $SERVERTABLCOUNTRIES where activated = '1' order by countryName";
($rv, $countryIDSelect, undef) = create_combobox_from_DBI ($rv, $dbh, $sql, 1, '', $CcountryID, 'countryID', 'none', '-Select-', $formDisabledPrimaryKey, '', $pagedir, $pageset, $htmlTitle, $subTitle, $sessionID, $debug);
}
$dbh->disconnect or $rv = error_trap_DBI(*STDOUT, "Sorry, the database was unable to add your entry.", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID);
}
if ( $rv ) {
# HTML - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if ($action eq 'duplicateView' or $action eq 'editView' or $action eq 'insertView') {
print_header (*STDOUT, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, "onload=\"javascript:enableDisableFields();\"", 'F', '', $sessionID);
print <<HTML;
<script language="JavaScript1.2" type="text/javascript">
function enableDisableFields() {
if ( document.holidays.formule.value == 0 ) {
document.holidays.month.disabled=false;
document.holidays.day.disabled=false;
document.holidays.offset.disabled=true;
document.holidays.offset.value=0;
} else {
document.holidays.month.disabled=true;
document.holidays.day.disabled=true;
document.holidays.month.value=0;
document.holidays.day.value=0;
document.holidays.offset.disabled=false;
}
}
function validateForm() {
if ( document.holidays.formule.value == null || document.holidays.formule.value == '' ) {
document.holidays.formule.focus();
alert('Please select a formule!');
return false;
} else {
if ( document.holidays.formule.value == 0 ) {
// month of year (1-12)
var objectRegularExpressionMonthValue = /\^([1-9]|1[0-2])\$/;
if ( document.holidays.month.value == null || document.holidays.month.value == '' ) {
document.holidays.month.focus();
alert('Please enter month of year!');
return false;
} else {
if ( ! objectRegularExpressionMonthValue.test(document.holidays.month.value) ) {
document.holidays.month.focus();
alert('Please re-enter month of the year: Bad month of the year value!');
return false;
}
}
// day of month (1-31)
var objectRegularExpressionDayValue = /\^([1-9]|[1-2][0-9]|3[0-1])\$/;
if ( document.holidays.day.value == null || document.holidays.day.value == '' ) {
document.holidays.day.focus();
alert('Please enter day of the month!');
return false;
} else {
if ( ! objectRegularExpressionDayValue.test(document.holidays.day.value) ) {
document.holidays.day.focus();
alert('Please re-enter day of the month: Bad day of the month value!');
return false;
}
}
}
}
// offset (0-364)
var objectRegularExpressionOffsetValue = /\^([0-9]|[0-9][0-9]|[1-2][0-9][0-9]|[3][0-5][0-9]|[3][6][0-4])\$/;
if ( document.holidays.offset.value == null || document.holidays.offset.value == '' ) {
document.holidays.offset.focus();
alert('Please enter offset!');
return false;
} else {
if ( ! objectRegularExpressionOffsetValue.test(document.holidays.offset.value) ) {
document.holidays.offset.focus();
alert('Please re-enter offset: Bad offset value!');
return false;
}
}
if ( document.holidays.countryID.value == null || document.holidays.countryID.value == 'none' ) {
document.holidays.countryID.focus();
alert('Please create/select a country!');
return false;
}
if ( document.holidays.holiday.value == null || document.holidays.holiday.value == '' ) {
document.holidays.holiday.focus();
alert('Please enter a holiday name!');
return false;
}
return true;
}
</script>
<form action="$ENV{SCRIPT_NAME}" method="post" name="holidays" onSubmit="return validateForm();">
HTML
} elsif ($action eq 'listView') {
print_header (*STDOUT, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', 'F', '', $sessionID);
print <<HTML;
<script language="JavaScript1.2" type="text/javascript">
function submitForm() {
document.holidays.catalogIDreload.value = 1;
document.holidays.submit();
return true;
}
</script>
<form action="$ENV{SCRIPT_NAME}" method="post" name="holidays">
HTML
} elsif ($action eq 'deleteView') {
print_header (*STDOUT, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', 'F', '', $sessionID);
print "<form action=\"" . $ENV{SCRIPT_NAME} . "\" method=\"post\" name=\"holidays\">\n";
$pageNo = 1; $pageOffset = 0;
} else {
print_header (*STDOUT, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', 'F', '', $sessionID);
}
if ($action eq 'deleteView' or $action eq 'duplicateView' or $action eq 'editView' or $action eq 'insertView' or $action eq 'listView') {
print <<HTML;
<input type="hidden" name="pagedir" value="$pagedir">
<input type="hidden" name="pageset" value="$pageset">
<input type="hidden" name="debug" value="$debug">
<input type="hidden" name="CGISESSID" value="$sessionID">
<input type="hidden" name="pageNo" value="$pageNo">
<input type="hidden" name="pageOffset" value="$pageOffset">
<input type="hidden" name="action" value="$nextAction">
<input type="hidden" name="orderBy" value="$orderBy">
<input type="hidden" name="catalogIDreload" value="0">
HTML
} else {
print "<br>\n";
( run in 0.390 second using v1.01-cache-2.11-cpan-f52f0507bed )