ASNMTAP
view release on metacpan or search on metacpan
applications/htmlroot/cgi-bin/sadmin/displayGroups.pl view on Meta::CPAN
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>action ...
if ( defined $sessionID and ! defined $errorUserAccessControl ) {
my ($catalogIDSelect, $matchingDisplayGroups, $navigationBar);
my $urlWithAccessParameters = $ENV{SCRIPT_NAME} . "?pagedir=$pagedir&pageset=$pageset&debug=$debug&CGISESSID=$sessionID&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 = $formDisabledPrimaryKey = '';
if ($action eq 'duplicateView' or $action eq 'insertView') {
$formDisabledPrimaryKey = 'disabled';
$htmlTitle = "Insert Display Group";
$submitButton = "Insert";
$nextAction = "insert" if ($rv);
$CcatalogID = $CATALOGID if ($action eq 'insertView');
} elsif ($action eq 'insert') {
$htmlTitle = "Check if Display Group $CdisplayGroupID from $CcatalogID exist before to insert";
$sql = "select displayGroupID from $SERVERTABLDISPLAYGRPS WHERE catalogID = '$CcatalogID' and displayGroupID='$CdisplayGroupID'";
($rv, $numberRecordsIntoQuery) = do_action_DBI ($rv, $dbh, $sql, $pagedir, $pageset, $htmlTitle, $subTitle, $sessionID, $debug);
if ( $numberRecordsIntoQuery ) {
$htmlTitle = "Display Group $CdisplayGroupID from $CcatalogID exist already";
$nextAction = "insertView";
} else {
$htmlTitle = "Display Group $CdisplayGroupID from $CcatalogID inserted";
my $dummyActivated = ($Cactivated eq 'on') ? 1 : 0;
$sql = 'INSERT INTO ' .$SERVERTABLDISPLAYGRPS. ' SET catalogID="' .$CcatalogID. '", groupTitle="' .$CgroupTitle. '", 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') {
$formDisabledPrimaryKey = $formDisabledAll = 'disabled';
$htmlTitle = "Delete Display Group $CdisplayGroupID from $CcatalogID";
$submitButton = "Delete";
$nextAction = "delete" if ($rv);
} elsif ($action eq 'delete') {
$sql = "select uKey, displayDaemon from $SERVERTABLVIEWS where catalogID = '$CcatalogID' and displayGroupID = '$CdisplayGroupID' order by displayDaemon, uKey";
($rv, $matchingDisplayGroups) = check_record_exist ($rv, $dbh, $sql, 'Views from ' .$CcatalogID, 'Unique Key', 'Display Daemon', '', $pagedir, $pageset, $htmlTitle, $subTitle, $sessionID, $debug);
if ($matchingDisplayGroups eq '') {
$htmlTitle = "Display Group $CdisplayGroupID from $CcatalogID deleted";
$sql = 'DELETE FROM ' .$SERVERTABLDISPLAYGRPS. ' WHERE catalogID="' .$CcatalogID. '" and displayGroupID="' .$CdisplayGroupID. '"';
$dbh->do ( $sql ) or $rv = error_trap_DBI(*STDOUT, "Cannot dbh->do: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID);
} else {
$htmlTitle = "Display Group $CdisplayGroupID from $CcatalogID not deleted, still used by";
}
$nextAction = "listView" if ($rv);
} elsif ($action eq 'displayView') {
$formDisabledPrimaryKey = $formDisabledAll = 'disabled';
$htmlTitle = "Display Display Group $CdisplayGroupID from $CcatalogID";
$nextAction = "listView" if ($rv);
} elsif ($action eq 'editView') {
$formDisabledPrimaryKey = 'disabled';
$htmlTitle = "Edit Display Group $CdisplayGroupID from $CcatalogID";
$submitButton = "Edit";
$nextAction = "edit" if ($rv);
} elsif ($action eq 'edit') {
$htmlTitle = "Display Group $CdisplayGroupID from $CcatalogID updated";
my $dummyActivated = ($Cactivated eq 'on') ? 1 : 0;
$sql = 'UPDATE ' .$SERVERTABLDISPLAYGRPS. ' SET catalogID="' .$CcatalogID. '", displayGroupID="' .$CdisplayGroupID. '", groupTitle="' .$CgroupTitle. '", activated="' .$dummyActivated. '" WHERE catalogID="' .$CcatalogID. '" and displayGroupID="'...
$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 'listView') {
$htmlTitle = "All display groups listed";
$nextAction = "listView";
if ( $CcatalogIDreload ) {
$pageNo = 1;
$pageOffset = 0;
}
$sql = "select catalogID, catalogName from $SERVERTABLCATALOG where not catalogID = '$CATALOGID' and activated = '1' order by catalogName asc";
($rv, $catalogIDSelect, undef) = create_combobox_from_DBI ($rv, $dbh, $sql, 1, '', $CcatalogID, 'catalogID', $CATALOGID, '-Parent-', '', 'onChange="javascript:submitForm();"', $pagedir, $pageset, $htmlTitle, $subTitle, $sessionID, $debug);
$sql = "select SQL_NO_CACHE count(displayGroupID) from $SERVERTABLDISPLAYGRPS where catalogID = '$CcatalogID'";
($rv, $numberRecordsIntoQuery) = do_action_DBI ($rv, $dbh, $sql, $pagedir, $pageset, $htmlTitle, $subTitle, $sessionID, $debug);
$navigationBar = record_navigation_bar ($pageNo, $numberRecordsIntoQuery, $RECORDSONPAGE, $ENV{SCRIPT_NAME} . "?pagedir=$pagedir&pageset=$pageset&debug=$debug&CGISESSID=$sessionID&action=listView&catalogID=$CcatalogID&or...
$navigationBar .= record_navigation_bar_alpha ($rv, $dbh, $SERVERTABLDISPLAYGRPS, 'groupTitle', "catalogID = '$CcatalogID'", $numberRecordsIntoQuery, $RECORDSONPAGE, $ENV{SCRIPT_NAME} . "?pagedir=$pagedir&pageset=$pageset&debug=$debug&a...
$sql = "select catalogID, displayGroupID, groupTitle, activated from $SERVERTABLDISPLAYGRPS where catalogID = '$CcatalogID' order by $orderBy limit $pageOffset, $RECORDSONPAGE";
$header = "<th><a href=\"$urlWithAccessParameters&action=listView&orderBy=catalogID desc, groupTitle asc\"><IMG SRC=\"$IMAGESURL/$ICONSRECORD{up}\" ALT=\"Up\" BORDER=0></a> Catalog ID <a href=\"$urlWithAccessParameters&action=listVi...
($rv, $matchingDisplayGroups, $nextAction) = record_navigation_table ($rv, $dbh, $sql, 'Display Group', 'catalogID|displayGroupID', '0|1', '1', '', '', $orderBy, $header, $navigationBar, $iconAdd, $iconDelete, $iconDetails, $iconEdit, $nextActi...
}
if ($action eq 'deleteView' or $action eq 'displayView' or $action eq 'duplicateView' or $action eq 'editView') {
$sql = "select catalogID, displayGroupID, groupTitle, activated from $SERVERTABLDISPLAYGRPS where catalogID='$CcatalogID' and displayGroupID='$CdisplayGroupID'";
$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, $CdisplayGroupID, $CgroupTitle, $Cactivated) = $sth->fetchrow_array() or $rv = error_trap_DBI(*STDOUT, "Cannot $sth->fetchrow_array: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID) if ($sth->rows)...
if ($action eq 'duplicateView') {
$CcatalogID = $CATALOGID;
$CdisplayGroupID = 'new';
}
$Cactivated = ($Cactivated == 1) ? 'on' : 'off';
$sth->finish() or $rv = error_trap_DBI(*STDOUT, "Cannot sth->finish: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', $sessionID);
}
}
$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, '', 'F', '', $sessionID);
print <<HTML;
<script language="JavaScript1.2" type="text/javascript">
function validateForm() {
if ( document.displayGroups.groupTitle.value == null || document.displayGroups.groupTitle.value == '' ) {
document.displayGroups.groupTitle.focus();
alert('Please enter a group title!');
return false;
}
return true;
}
</script>
<form action="$ENV{SCRIPT_NAME}" method="post" name="displayGroups" 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.displayGroups.catalogIDreload.value = 1;
document.displayGroups.submit();
return true;
}
</script>
<form action="$ENV{SCRIPT_NAME}" method="post" name="displayGroups">
HTML
} elsif ($action eq 'deleteView') {
print_header (*STDOUT, $pagedir, $pageset, $htmlTitle, $subTitle, 3600, '', 'F', '', $sessionID);
print "<form action=\"" . $ENV{SCRIPT_NAME} . "\" method=\"post\" name=\"displayGroupID\">\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";
}
print " <input type=\"hidden\" name=\"catalogID\" value=\"$CcatalogID\">\n <input type=\"hidden\" name=\"displayGroupID\" value=\"$CdisplayGroupID\">\n" if ($formDisabledPrimaryKey ne '' and $action ne 'displayView');
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&pageNo=1&pageOffset=0&action=insertView&orderBy=$orderBy">[Insert display groups]</a></td>
<td class="StatusItem"> </td>
HTML
}
print <<HTML;
<td class="StatusItem"><a href="$urlWithAccessParameters&pageNo=1&pageOffset=0&action=listView&orderBy=$orderBy">[List all display groups]</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 $activatedChecked = ($Cactivated eq 'on') ? ' checked' : '';
print <<HTML;
<tr><td> </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>
</td></tr>
<tr><td><b>Display Group ID: </b></td><td>
<input type="text" name="displayGroupID" value="$CdisplayGroupID" size="11" maxlength="11" $formDisabledPrimaryKey>
<tr><td><b>Group Name: </b></td><td>
<input type="text" name="groupTitle" value="$CgroupTitle" size="100" maxlength="100" $formDisabledAll>
<tr><td><b>Activated: </b></td><td>
<input type="checkbox" name="activated" $activatedChecked $formDisabledAll>
</td></tr>
HTML
print " <tr><td> </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>Unique Key: $htmlTitle</h1></td></tr>";
print " <tr><td align=\"center\">$matchingDisplayGroups</td></tr>" if (defined $matchingDisplayGroups and $matchingDisplayGroups 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>$matchingDisplayGroups</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 0.557 second using v1.01-cache-2.11-cpan-39bf76dae61 )