ASNMTAP

 view release on metacpan or  search on metacpan

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


use ASNMTAP::Asnmtap::Applications::CGI v3.002.003;
use ASNMTAP::Asnmtap::Applications::CGI qw(:APPLICATIONS :CGI :ADMIN :DBREADWRITE :DBTABLES);

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

use vars qw($PROGNAME);

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

$PROGNAME       = "holidaysBundle.pl";
my $prgtext     = "Holidays Bundle";
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')           : 'holidayBundleName 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 $CholidayBundleID   = (defined $cgi->param('holidayBundleID'))   ? $cgi->param('holidayBundleID')   : 'new';
my $CholidayBundleName = (defined $cgi->param('holidayBundleName')) ? $cgi->param('holidayBundleName') : '';
my $CcountryIDreload   = (defined $cgi->param('countryIDreload'))   ? $cgi->param('countryIDreload')   : 0;
my $CcountryID         = (defined $cgi->param('countryID'))         ? $cgi->param('countryID')         : 'none';
my @CholidayID         =          $cgi->param('holidayID');
my $Cactivated         = (defined $cgi->param('activated'))         ? $cgi->param('activated')         : 'off';

my $CholidayID = (@CholidayID) ? '/'. join ('/', @CholidayID) .'/' : '';

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

my $htmlTitle = $APPLICATION;

# Init parameters
my ($rv, $dbh, $sth, $sql, $header, $numberRecordsIntoQuery, $nextAction, $formDisabledAll, $formDisabledNoCountryID, $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&holidayBundleID=$CholidayBund...

# Debug information
print "<pre>pagedir            : $pagedir<br>pageset            : $pageset<br>debug              : $debug<br>CGISESSID          : $sessionID<br>page no            : $pageNo<br>page offset        : $pageOffset<br>order by           : $orderBy<br>actio...

if ( defined $sessionID and ! defined $errorUserAccessControl ) {
  my ($catalogIDSelect, $countryIDSelect, $holidaysSelect, $matchingHolidaysBundle, $matchingPlugins, $navigationBar);

  my $urlWithAccessParameters = $ENV{SCRIPT_NAME} . "?pagedir=$pagedir&amp;pageset=$pageset&amp;debug=$debug&amp;CGISESSID=$sessionID&amp;pageNo=$pageNo&amp;pageOffset=$pageOffset&amp;catalogID=$CcatalogID";

  # open connection to database and query data
  $rv  = 1;

  $dbh = DBI->connect("dbi:mysql:$DATABASE:$SERVERNAMEREADWRITE:$SERVERPORTREADWRITE", "$SERVERUSERREADWRITE", "$SERVERPASSREADWRITE" ) or $rv = error_trap_DBI(*STDOUT, "Cannot connect to the database", $debug, $pagedir, $pageset, $htmlTitle, $subTit...

  if ($dbh and $rv) {
    $formDisabledAll = $formDisabledNoCountryID = $formDisabledPrimaryKey = '';

    if ($CcountryIDreload) {
      if ($action eq 'insert' or $action eq 'insertView') {
        $action = 'insertView';
      } elsif ($action eq 'edit' or $action eq 'editView') {
        $action = 'editView';
      } else {
        $action = 'listView';
      }
    }

    if ($action eq 'duplicateView' or $action eq 'insertView') {
      $formDisabledPrimaryKey = 'disabled';
      $htmlTitle    = "Insert Holiday Bundle";
      $submitButton = "Insert";
      $nextAction   = "insert" if ($rv);
    } elsif ($action eq 'insert') {
      $htmlTitle    = "Check if Holiday Bundle $CholidayBundleID from $CcatalogID exist before to insert";

      $sql = "select holidayBundleID from $SERVERTABLHOLIDYSBNDL WHERE catalogID = '$CcatalogID' and holidayBundleID = '$CholidayBundleID'";
      ($rv, $numberRecordsIntoQuery) = do_action_DBI ($rv, $dbh, $sql, $pagedir, $pageset, $htmlTitle, $subTitle, $sessionID, $debug);

	  if ( $numberRecordsIntoQuery ) {
        $htmlTitle    = "Holiday Bundle $CholidayBundleID from $CcatalogID exist already";
        $nextAction   = "insertView";
      } else {
        $htmlTitle    = "Holiday Bundle $CholidayBundleID from $CcatalogID inserted";
        my $dummyActivated = ($Cactivated eq 'on') ? 1 : 0;
        $sql = 'INSERT INTO ' .$SERVERTABLHOLIDYSBNDL. ' SET catalogID="' .$CcatalogID. '", holidayBundleName="' .$CholidayBundleName. '", holidayID="' .$CholidayID. '", countryID="' .$CcountryID. '", activated="' .$dummyActivated. '"';
        $dbh->do ( $sql ) or $rv = error_trap_DBI(*STDOUT, "Cannot dbh->do: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID);
        $nextAction   = "listView" if ($rv);
      }
    } elsif ($action eq 'deleteView') {
      $formDisabledAll = $formDisabledPrimaryKey = 'disabled';
      $htmlTitle    = "Delete Holiday Bundle $CholidayBundleID from $CcatalogID";
      $submitButton = "Delete";
      $nextAction   = "delete" if ($rv);
    } elsif ($action eq 'delete') {
      $sql = "select uKey, test from $SERVERTABLPLUGINS where catalogID = '$CcatalogID' and holidayBundleID = '$CholidayBundleID' order by holidayBundleID";
      ($rv, $matchingHolidaysBundle) = check_record_exist ($rv, $dbh, $sql, 'Plugins from ' .$CcatalogID, 'Unique Key', 'Title', '', $pagedir, $pageset, $htmlTitle, $subTitle, $sessionID, $debug);
	  
	  if ($matchingHolidaysBundle eq '') {
        $sql = 'DELETE FROM ' .$SERVERTABLHOLIDYSBNDL. ' WHERE catalogID="' .$CcatalogID. '" and holidayBundleID="' .$CholidayBundleID. '"';
        $dbh->do ( $sql ) or $rv = error_trap_DBI(*STDOUT, "Cannot dbh->do: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID);
        $nextAction = "listView" if ($rv);
        $htmlTitle = "Holiday Bundle $CholidayBundleID from $CcatalogID deleted";
      } else {
        $htmlTitle = "Holiday Bundle $CholidayBundleID from $CcatalogID not deleted, still used by";
      }
    } elsif ($action eq 'displayView') {
      $formDisabledAll = $formDisabledPrimaryKey = 'disabled';
      $htmlTitle    = "Display Holiday Bundle $CholidayBundleID from $CcatalogID";
      $nextAction   = "listView" if ($rv);
    } elsif ($action eq 'editView') {
      $formDisabledPrimaryKey = 'disabled';
      $htmlTitle    = "Edit Holiday Bundle $CholidayBundleID from $CcatalogID";
      $submitButton = "Edit";



( run in 0.692 second using v1.01-cache-2.11-cpan-140bd7fdf52 )