ASNMTAP

 view release on metacpan or  search on metacpan

applications/htmlroot/cgi-bin/admin/holidays.pl  view on Meta::CPAN

    if ($action eq 'deleteView' or $action eq 'displayView' or $action eq 'duplicateView' or $action eq 'editView') {
      $sql = "select catalogID, holidayID, formule, month, day, offset, countryID, holiday, activated from $SERVERTABLHOLIDYS where catalogID = '$CcatalogID' and holidayID = '$CholidayID'";
      $sth = $dbh->prepare( $sql ) or $rv = error_trap_DBI(*STDOUT, "Cannot dbh->prepare: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID);
      $sth->execute() or $rv = error_trap_DBI(*STDOUT, "Cannot sth->execute: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID) if $rv;

      if ( $rv ) {
        ($CcatalogID, $CholidayID, $Cformule, $Cmonth, $Cday, $Coffset, $CcountryID, $Choliday, $Cactivated) = $sth->fetchrow_array() or $rv = error_trap_DBI(*STDOUT, "Cannot $sth->fetchrow_array: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTi...

        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";

applications/htmlroot/cgi-bin/admin/holidays.pl  view on Meta::CPAN

  <input type=\"hidden\" name=\"month\"     value=\"$Cmonth\">
  <input type=\"hidden\" name=\"day\"       value=\"$Cday\">
  <input type=\"hidden\" name=\"offset\"    value=\"$Coffset\">
  <input type=\"hidden\" name=\"countryID\" value=\"$CcountryID\">
HTML
    }

    print <<HTML;
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr align="center"><td>
	  <table border="0" cellspacing="0" cellpadding="0"><tr>
HTML

    if ( $iconAdd ) {
      print <<HTML;
        <td class="StatusItem"><a href="$urlWithAccessParameters&amp;action=insertView&amp;orderBy=$orderBy">[Insert holiday]</a></td>
        <td class="StatusItem">&nbsp;&nbsp;&nbsp;</td>
HTML
    }

    print <<HTML;
        <td class="StatusItem"><a href="$urlWithAccessParameters&amp;action=listView&amp;orderBy=$orderBy">[List all holidays]</a></td>
	  </tr></table>
    </td></tr>
HTML

    if ($action eq 'deleteView' or $action eq 'displayView' or $action eq 'duplicateView' or $action eq 'editView' or $action eq 'insertView') {
      my $formuleSelect = create_combobox_from_keys_and_values_pairs ('0=>Fixed|1=>Easter', 'V', 0, $Cformule, 'formule', '', '', $formDisabledPrimaryKey, 'onChange="javascript:enableDisableFields();"', $debug);
      my $activatedChecked = ($Cactivated eq 'on') ? ' checked' : '';

      print <<HTML;
    <tr><td>&nbsp;</td></tr>
    <tr><td>
	  <table border="0" cellspacing="0" cellpadding="0">
        <tr><td><b>Catalog ID: </b></td><td>
          <input type="text" name="catalogID" value="$CcatalogID" size="5" maxlength="5" disabled>
        <tr><td><b>Formule: </b></td><td>
          $formuleSelect
        </td></tr>
		<tr><td><b>Month: </b></td><td>
          <input type="text" name="month" value="$Cmonth" size="2" maxlength="2" $formDisabledPrimaryKey>&nbsp;&nbsp;format: 1-12
        </td></tr>
		<tr><td><b>Day: </b></td><td>
          <input type="text" name="day" value="$Cday" size="2" maxlength="2" $formDisabledPrimaryKey>&nbsp;&nbsp;format: 1-31
        </td></tr>
		<tr><td><b>Offset: </b></td><td>
          <input type="text" name="offset" value="$Coffset" size="3" maxlength="3" $formDisabledPrimaryKey>&nbsp;&nbsp;format: 0-364
        </td></tr>
		<tr><td><b>Country: </b></td><td>
          $countryIDSelect
        </td></tr>
		<tr><td><b>Holiday: </b></td><td>
          <input type="text" name="holiday" value="$Choliday" size="64" maxlength="64" $formDisabledAll>
        </td></tr>
		<tr><td><b>Activated: </b></td><td>
          <input type="checkbox" name="activated" $activatedChecked $formDisabledAll>
        </td></tr>
HTML

      print "        <tr><td>&nbsp;</td><td><br>Please enter all required information before committing the required information. Required fields are marked in bold.</td></tr>\n" if ($action eq 'duplicateView' or $action eq 'editView' or $action eq '...
      print "        <tr align=\"left\"><td align=\"right\"><br><input type=\"submit\" value=\"$submitButton\"></td><td><br><input type=\"reset\" value=\"Reset\"></td></tr>\n" if ($action ne 'displayView');
      print "      </table>\n";
    } elsif ($action eq 'delete' or $action eq 'edit' or $action eq 'insert') {
      print "    <tr><td align=\"center\"><br><br><h1>Holiday: $htmlTitle</h1></td></tr>";
      print "    <tr><td align=\"center\">$matchingHolidays</td></tr>" if (defined $matchingHolidays and $matchingHolidays ne '');
    } else {
      print "    <tr><td><br><table align=\"center\" border=0 cellpadding=1 cellspacing=1 bgcolor='#333344'><tr><td align=\"left\"><b>Catalog ID: </b></td><td>$catalogIDSelect</td></tr></table></td></tr>";
      print "    <tr><td align=\"center\"><br>$matchingHolidays</td></tr>";
    }

    print "  </table>\n";

    if ($action eq 'deleteView' or $action eq 'duplicateView' or $action eq 'editView' or $action eq 'insertView' or $action eq 'listView') {
      print "</form>\n";
    } else {
      print "<br>\n";
    }
  }
}

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

print_legend (*STDOUT);
print '</BODY>', "\n", '</HTML>', "\n";

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



( run in 1.946 second using v1.01-cache-2.11-cpan-d8267643d1d )