%@ LANGUAGE = PerlScript %><% use Win32::ADO; use Win32::ASP qw(:strict); use Win32::ASP qw/SetCookie/; use strict; $Response->End(); $Response->{Buffer} = 1; use constant adCmdStoredProc => 0x0004; use constant adInteger => 3; use constant adVarChar => 200; use constant adParamOutput => 0x0002; use constant adParamInput => 0x0001; use constant adOpenForwardOnly => 0; use constant adOpenDynamic => 2; use constant adOpenStatic => 3; use constant adLockOptimistic => 3; my $RecurseLevel = 0; $Response->{Buffer} = 1; ### Read Application Variables ### my $mySQL = $Application->Contents('Connection'); my $COLORProductHeader = $Application->Contents('COLORProductHeader'); my $COLORCategoryHeader = $Application->Contents('COLORCategoryHeader'); my $MyConn = $Server->CreateObject("ADODB.Connection"); $MyConn->Open($mySQL); ### Constants ### use constant COLS => 2; ### Number of category columns ### use constant PAGESIZE => 10; ### Number of items per page ### ### my $action = GetFormValue("action"); my $key = GetFormValue("key"); &PullCat if ($action eq 'grabcat'); &GetItem if ($key > 0); &ShowCats; %> <% sub PullCat { ########################################################## ### Display List of Categories within current Category ### ########################################################## my ($catid, $page) = (GetFormValue('category'), GetFormValue('page')); my ($catPath, $catPage, $catLinks, @subcatList); my $ReturnID = $catid; if (($catid < 1) || ($page < 1)) { &ShowCats; exit; } ### Load Product List Recordset ### my $Rset = $Server->CreateObject("ADODB.Recordset"); $Rset->{'CursorLocation'} = 3; ### Client-side Cursor ### $Rset->Open("SELECT ProductsTable.* FROM Categories INNER JOIN (ProductsTable INNER JOIN ProductCategories ON ProductsTable.ProductID = ProductCategories.ProductID) ON Categories.CategoryID = ProductCategories.CategoryID WHERE Categories.CategoryID = $catid ORDER BY ProductCategories.Position, ProductsTable.ProductName ", $MyConn, 3, 1); $Rset->{'PageSize'} = PAGESIZE; $Rset->{'AbsolutePage'} = $page; my $Rstart = $Rset->{'AbsolutePosition'}; my $Rstop = $Rset->{'AbsolutePosition'} + ($Rset->{'PageSize'} - 1); my $Rtotal = $Rset->{RecordCount}; if ($Rstop > $Rtotal) { $Rstop = $Rtotal; } ### Find originating record to search path ### my $RS = $MyConn->Execute("SELECT * FROM Categories WHERE CategoryID = $catid"); if (!$RS) { $RS->Close; &ShowCats; exit; } my ($mainDescript, $mainPic, $mainCode, $mainLink) = ($RS->Fields("Description")->value, $RS->Fields("PictureFile")->value, $RS->Fields("HTMLCode")->value, $RS->Fields("DescriptionLink")->value ); my ($mainID) = $catid; undef($mainLink) if (length($mainLink) < 1); $mainDescript =~ s/\b(\w)/\U$1/g; $catid = $RS->Fields("ParentCategory")->value; $catPath = " : $mainDescript"; my $infLoop = 0; my $companyName = $mainDescript; while ($catid > 0) { $RS->Close; $RS = $MyConn->Execute("SELECT * FROM Categories WHERE CategoryID = $catid"); if ($RS) { my ($descript, $parent) = ($RS->Fields("Description")->value, $RS->Fields("ParentCategory")->value ); $descript =~ s/\b(\w)/\U$1/g; my $tlink = sprintf("action=grabcat&page=1&category=%d", $Server->URLEncode($catid)); $catPath = sprintf(" : %s%s", $tlink, $descript, $catPath); $companyName = $descript; ### Keeps last description which should be company name if ($catid == $parent) { $catid = 0; } else { $catid = $parent; } } else { $catid = 0; } if ($infLoop++ > 50) { $catid = 0; } ### Break from infinite loops } $RS->Close; $catPath = "All Categories" . $catPath; ### Compile a list of available sub-categories ### $RS = $MyConn->Execute("SELECT * FROM Categories WHERE ParentCategory = $mainID ORDER BY Description"); while(!$RS->EOF) { my ($catid, $descript) = ( $RS->Fields("CategoryID")->value, $RS->Fields("Description")->value ); $descript =~ s/\b(\w)/\U$1/g; if (($catid > 0) && (length($descript) > 0)) { push(@subcatList, sprintf("
<%
print " \n \n"; } else { print "$mainDescript\n"; print " \n \n"; } %> \n"; print " \n \n"; } print "$catPath\n"; print " \n"; ### List sub-categories if they exist ### if ($#subcatList >= 0) { print "
\n"; } ### Construct page selection line ### $catPage = ''; if ($page < 2) { $catPage .= ' | '; } else { $catPage .= sprintf(" | << PREVIOUS | \n", ($page - 1), $mainID); } my $totpages = int((($page * PAGESIZE) + ($Rtotal - $Rstop)) / PAGESIZE); $totpages++ if (($Rtotal - $Rstop) > 0); $catPage .= sprintf("Page %d of %d | ", $page, $totpages); if ($Rstop < $Rtotal) { $catPage .= sprintf("NEXT >> | \n", ($page + 1), $mainID); } else { $catPage .= ''; } ### Construct Quick Page line ### if (($Rtotal / PAGESIZE) > 3) { $catLinks = ''; for (my $ii = 1; $ii <= (int($Rtotal / PAGESIZE)+1); $ii++) { if ($ii == $page) { $catLinks .= "$ii "; next; } $catLinks .= sprintf("%d ", $ii, $mainID, $ii); } $catLinks = '- ' . $catLinks . ' -'; } ### List products on page X ### if (($Rstart < 0) && ($Rstop < 1)) { if ($#subcatList < 0) { print " |
---|
<% #Write out Picture if it exists# #Determine if Additional pics exist# $Response->Write(" ") if ($AddLink); if (length($PictureFile) > 1) { $Response->Write("\n"); } else { $Response->Write("Click here for Picture(s)\n") if ($AddLink); } $Response->Write("\n") if ($AddLink); %> | |
<%
print "$ProductName \n"; print "\U$ProductCode \n"; $Response->Write(sprintf("Our Price: \$%1.2f", $UnitPrice)); if ($MSRP > 0.01) { $Response->Write(sprintf("\n Sugg. Retail Price: \$%1.2f ", $MSRP)); } else { $Response->Write(" \n"); } # Print out a description if available # if (length($Notes) > 1) { $Response->Write("
|
<% #Write out Picture if it exists# #Determine if Additional pics exist# $Response->Write(" ") if ($AddLink); if (length($PictureFile) > 1) { $Response->Write("\n"); } else { $Response->Write("Click here for Picture(s)\n") if ($AddLink); } $Response->Write("\n") if ($AddLink); %> |
<%
print "$ProductName \n"; print "\U$ProductCode \n"; $Response->Write(sprintf("Our Price: \$%1.2f", $UnitPrice)); if ($MSRP > 0.01) { $Response->Write(sprintf("\n Sugg. Retail Price: \$%1.2f ", $MSRP)); } else { $Response->Write(" \n"); } # Print out a description if available # if (length($Notes) > 1) { $Response->Write("
|
<%
print "$ProductName \n"; print "\U$ProductCode \n"; $Response->Write(sprintf("Our Price: \$%1.2f", $UnitPrice)); if ($MSRP > 0.01) { $Response->Write(sprintf("\n Sugg. Retail Price: \$%1.2f ", $MSRP)); } else { $Response->Write(" \n"); } # Print out a description if available # if (length($Notes) > 1) { $Response->Write("
|
<% #Write out Picture if it exists# #Determine if Additional pics exist# $Response->Write(" ") if ($AddLink); if (length($PictureFile) > 1) { $Response->Write("\n"); } else { $Response->Write("Click here for Picture(s)\n") if ($AddLink); } $Response->Write("\n") if ($AddLink); %> |
\n"; $Rset->MoveNext; } } $Rset->Close; %>
|
%s | \n", $tlink, $descript)); $ii++; if (!($ii % COLS)) { $Response->write("
---|
HOME
<%=$Application->Contents('Copyright')%>
E-Mail: <%=$Application->Contents('Email')%>
Produced by 1st Internet Resources
<%
my $Rset = $Server->CreateObject("ADODB.Recordset");
$Rset->{'CursorLocation'} = 3; ### Client-side Cursor ###
$Rset->Open("SELECT ProductsTable.* FROM ProductsTable WHERE ProductsTable.ProductID = $key ORDER BY ProductsTable.WebOrdering, ProductsTable.ProductName, ProductsTable.ProductCode", $MyConn, 3, 1);
my ($ProductID, $ProductCode, $ProductName, $PictureFile, $UnitPrice, $MSRP, $Orientation, $Notes) = (
$Rset->Fields('ProductID')->value, $Rset->Fields('ProductCode')->value,
$Rset->Fields('ProductName')->value, $Rset->Fields('PictureFile')->value,
$Rset->Fields('UnitPrice')->value, $Rset->Fields('MSRP')->value,
$Rset->Fields('Orientation')->value, $Rset->Fields('Notes')->value );
$Orientation =~ s/ +$//g;
if (length($Orientation) < 1) {
$Orientation = 'T';
$Orientation =~ s/ +$//g;
}
#Select Additional Pics#
my $AddLink;
my $AddRS = $MyConn->Execute("SELECT * FROM AdditionalPics WHERE ProductID = $ProductID");
if (!$AddRS->EOF) {
$AddLink = "images.asp?ProductID=$ProductID";
}
else {
undef($AddLink);
}
$AddRS->Close();
print "\n";
##Determine Orientation##
if ($Orientation eq 'T') {
#Orientation is TOP#
%>
\n"; $Rset->Close; %> |