%@language=perlscript%> <% use strict; use vars qw($Request $Response $Session $Server); use lib ($Server->MapPath('/') . '/../../modules/'); use Alchemy::DB; use Alchemy::Win32::ASP; use FamilyHomes::Configuration; use FamilyHomes::Presentation; use NZSki::PropertyListing::Extract; my $db = Alchemy::DB::dbOpenDatabase(FamilyHomes::Configuration::GetOpenDatabaseArgs()); my $error = undef; # Determines how many listings to display on the page my $NumberListings = 10; # Processing my $raListings = []; if ($db) { my $where = "tblProperty.CompanyKey = ".FamilyHomes::Configuration::GetCompanyCode(); my $order = "tblProperty.PK DESC"; if (NZSki::PropertyListing::Extract::getListings('db'=>$db, 'listings'=>$raListings, 'whereClause'=>$where, 'orderClause'=>$order)) { # Processing successful } else { $error = NZSki::PropertyListing::Extract::getListingError(); } Alchemy::DB::dbCloseDatabase($db); } else { $error = "The database could not be contacted at this time"; } # Output the page %>
HOMES FOR SALE
<% if ($error) { FamilyHomes::Presentation::OutputError($error); } else { outputBody(); outputProperties($raListings, $NumberListings, AspGetParam($Request, 'start')); } %>
<% sub outputBody { %> <% } sub outputProperties { my ($raListings, $NumberListings, $startingIndex) = @_; my $pageNumber = 1; if ($startingIndex) { $pageNumber = int($startingIndex/$NumberListings) + 1; } my $pageTotal = int(scalar(@$raListings)/$NumberListings) + 1; %>| Page <%=$pageNumber%> of <%=$pageTotal%> | ||||||||||||||
| ||||||||||||||
| Previous Page | <% } if (scalar(@$raListings) > $startingIndex + $NumberListings) { %>Next Page | <% } %>