function m_showHomePage() { $this->ObTpl = new template(); $this->ObTpl->set_file("TPL_VAR_CMS", $this->cmsTemplate); $this->ObTpl->set_block("TPL_VAR_CMS", "TPL_MAINPRODUCT_BLK", "mainproduct_blk"); $this->ObTpl->set_block("TPL_MAINPRODUCT_BLK", "TPL_PRODUCT_BLK", "product_blk"); $this->ObTpl->set_block("TPL_VAR_CMS", "TPL_MAINCONTENT_BLK", "maincontent_blk"); $this->ObTpl->set_block("TPL_MAINCONTENT_BLK", "TPL_CONTENT_BLK", "content_blk"); $this->ObTpl->set_block("TPL_PRODUCT_BLK", "TPL_WISHLIST_BLK", "wishlist_blk"); $this->ObTpl->set_block("TPL_PRODUCT_BLK", "TPL_COMPARE_BLK", "compare_blk"); $this->ObTpl->set_block("TPL_PRODUCT_BLK", "TPL_CONTAINTDEPARTMENT_BLK", "containdepartment_blk"); $this->ObTpl->set_block("TPL_PRODUCT_BLK", "TPL_REVIEW_BLK", "review_blk"); $this->ObTpl->set_var("TPL_VAR_SITEURL", SITE_URL); $this->ObTpl->set_var("TPL_VAR_THEME_PATH", THEMEURLPATH); $this->ObTpl->set_var("GRAPHICSMAINPATH", GRAPHICS_PATH); $this->ObTpl->set_var("TPL_VAR_CURRENCY", CONST_CURRENCY); $this->ObTpl->set_var("theme_blk", ""); $this->ObTpl->set_var("mainproduct_blk", ""); $this->ObTpl->set_var("product_blk", ""); $this->ObTpl->set_var("maincontent_blk", ""); $this->ObTpl->set_var("content_blk", ""); $this->ObTpl->set_var("wishlist_blk", ""); $this->ObTpl->set_var("compare_blk", ""); $this->ObTpl->set_var("containdepartment_blk", ""); $this->ObTpl->set_var("review_blk", ""); #QUERY TO GET CMS ##Defining language pack variables for headings on homepage $this->ObTpl->set_var("LANG_VAR_LATESTPRODUCTS", ""); $this->ObTpl->set_var("LANG_VAR_LATESTNEWS", ""); $this->ObTpl->set_var("LANG_VAR_LATESTNEWS", LATEST_NEWS); $this->obDb->query = "SELECT vSmalltext,tLargetext FROM " . SITESETTINGS . " WHERE vDatatype='index_body'"; $row_setting = $this->obDb->fetchQuery(); $this->ObTpl->set_var("TPL_VAR_HEADING", LANG_WELCOME_TO . SITE_NAME); $this->ObTpl->set_var("TPL_VAR_TEXT", $this->libFunc->m_displayContent1($row_setting[0]->tLargetext)); //Top Sellers if (TOPSELLERS == 1) { $this->ObTpl->set_var("LANG_VAR_HOMEPAGEPRODUCTTEXT", "Top Sellers"); #Getting current product ID's $this->obDb->query = "SELECT * FROM " . PRODUCTS; $rowProductId = $this->obDb->fetchQuery(); $rowIdCount = $this->obDb->record_count; $id_rows = array(); for ($i = 0; $i < $rowIdCount; $i++) { $id_rows[$i] = $rowProductId[$i]->iProdid_PK; } #QUERY TO GET TOP TEN PRODUCTS if ($rowIdCount > 0) { $this->obDb->query = "SELECT iProductid_FK, SUM(iQty) as top_10 FROM " . ORDERPRODUCTS . " WHERE iProductid_FK IN (" . implode(",", $id_rows) . ")\n\t \t\t\t\t\t\t\tGROUP BY iProductid_FK ORDER BY top_10 DESC"; $rowTop10 = $this->obDb->fetchQuery(); $rowCount = $this->obDb->record_count; } else { $rowCount = 0; } if ($rowCount > 0) { for ($i = 0; $i < $rowCount; $i++) { $this->obDb->query = "SELECT * FROM " . PRODUCTS . " WHERE iProdid_PK =" . $rowTop10[$i]->iProductid_FK; $BestSellers = $this->obDb->fetchQuery(); $BestCount = $this->obDb->record_count; #MARGIN CALCULATOR switch (MARGINSTATUS) { case "increase": $BestSellers[$i]->fPrice = $BestSellers[$i]->fPrice * MARGINPERCENT / 100 + $BestSellers[$i]->fPrice; break; case "decrease": $BestSellers[$i]->fPrice = $BestSellers[$i]->fPrice - $BestSellers[$i]->fPrice * MARGINPERCENT / 100; break; default: $BestSellers[$i]->fPrice = $BestSellers[$i]->fPrice; break; } #END MARGIN CALCULATOR $this->ObTpl->set_var("TPL_VAR_ONSALE", ""); if ($BestSellers[0]->iSale == 1) { $this->ObTpl->set_var("TPL_VAR_ONSALE", "<p class=\"onSale\">On Sale</p>"); } $productUrl = SITE_URL . "ecom/index.php?action=ecom.pdetails&mode=" . $BestSellers[0]->vSeoTitle; $this->ObTpl->set_var("TPL_VAR_PRODUCTURL", $this->libFunc->m_safeUrl($productUrl)); $this->ObTpl->set_var("TPL_VAR_ID", $this->libFunc->m_displayContent($BestSellers[0]->iProdid_PK)); $this->ObTpl->set_var("TPL_VAR_TITLE", $this->libFunc->m_displayContent($BestSellers[0]->vTitle)); $this->ObTpl->set_var("TPL_VAR_DESC", $this->libFunc->m_displayContent($BestSellers[0]->tShortDescription)); #TO CHECK WHEATHER TO DISPLAY WISHLIST OR NOT MANAGED BY ADMIN if (USEWISHLIST == 1) { ##WISHLIST URL $wishListUrl = SITE_URL . "ecom/index.php?action=wishlist.add&mode=" . $BestSellers[0]->iProdid_PK; $this->ObTpl->set_var("TPL_VAR_WISHLISTLINK", $this->libFunc->m_safeUrl($wishListUrl)); $this->ObTpl->parse("wishlist_blk", "TPL_WISHLIST_BLK"); } #TO CHECK WHEATHER TO DISPLAY COMPARELIST OR NOT MANAGED BY ADMIN if (USECOMPARE == 1) { $compareListUrl = SITE_URL . "ecom/index.php?action=compare.add&mode=" . $BestSellers[0]->iProdid_PK; $this->ObTpl->set_var("TPL_VAR_COMPARELINK", $this->libFunc->m_safeUrl($compareListUrl)); $this->ObTpl->parse("compare_blk", "TPL_COMPARE_BLK"); } if (CUSTOMER_REVIEWS == 1) { ##OVERALL PRODUCT STAR RANKING $this->obDb->query = "SELECT SUM(vRank) as total, COUNT(iItemid_FK) as reviewcount FROM " . REVIEWS . " WHERE iItemid_FK ='" . $rowTop10[$i]->iProductid_FK . "'"; $OverallReviewRating = $this->obDb->fetchQuery(); $ReviewRating = $OverallReviewRating[0]->total / $OverallReviewRating[0]->reviewcount; $ReviewRating = number_format($ReviewRating, 0, '.', ''); $this->ObTpl->set_var("TPL_VAR_REVIEWCOUNT", "<p class=\"reviewCount\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); switch ($ReviewRating) { case "0": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating0\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; case "1": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating1\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; case "2": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating2\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; case "3": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating3\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; case "4": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating4\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; case "5": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating5\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; case "6": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating6\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; case "7": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating7\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; case "8": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating8\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; case "9": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating9\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; case "10": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating10\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; } $this->ObTpl->parse("review_blk", "TPL_REVIEW_BLK"); } if ($BestSellers[0]->iTaxable == 1) { #GETTING VAT PRICE $vatPercent = $this->libFunc->m_vatCalculate(); $vatPrice = number_format($vatPercent * $BestSellers[0]->fPrice / 100 + $BestSellers[0]->fPrice, 2); if (INC_VAT_FLAG == 1 & INC_VAT == 1) { $this->ObTpl->set_var("TPL_VAR_PRICEMAIN", number_format($BestSellers[0]->fPrice, 2) . " (" . CONST_CURRENCY . $vatPrice . " inc. " . VAT_TAX_TEXT . ")"); $this->ObTpl->set_var("TPL_VAR_PRICE", $this->libFunc->m_displayContent($BestSellers[0]->fPrice) . " (" . CONST_CURRENCY . $vatPrice . " inc. " . VAT_TAX_TEXT . ")"); } else { if (INC_VAT_FLAG == 0 & INC_VAT == 1) { $this->ObTpl->set_var("TPL_VAR_PRICEMAIN", number_format($BestSellers[0]->fPrice, 2) . " (" . CONST_CURRENCY . $vatPrice . ")"); $this->ObTpl->set_var("TPL_VAR_PRICE", $this->libFunc->m_displayContent($BestSellers[0]->fPrice) . " (" . CONST_CURRENCY . $vatPrice . ")"); } else { $this->ObTpl->set_var("TPL_VAR_PRICEMAIN", $vatPrice . " inc. " . VAT_TAX_TEXT); $this->ObTpl->set_var("TPL_VAR_PRICE", $vatPrice . " inc. " . VAT_TAX_TEXT); } } } else { $this->ObTpl->set_var("TPL_VAR_PRICE", $this->libFunc->m_displayContent(number_format($BestSellers[0]->fPrice, 2))); } if (!empty($BestSellers[0]->vImage1)) { $img = $this->libFunc->m_checkFile($BestSellers[0]->vImage1, "product", $this->libFunc->m_displayContent($BestSellers[0]->vTitle)); if ($img) { $this->ObTpl->set_var("TPL_VAR_IMG", $img); } else { $this->ObTpl->set_var("TPL_VAR_IMG", MSG_NOIMG); } } else { $this->ObTpl->set_var("TPL_VAR_IMG", MSG_NOIMG); } $this->ObTpl->parse("product_blk", "TPL_PRODUCT_BLK", true); } $this->ObTpl->parse("mainproduct_blk", "TPL_MAINPRODUCT_BLK", true); } } else { //Start Latest Products $this->ObTpl->set_var("LANG_VAR_HOMEPAGEPRODUCTTEXT", "Latest Products"); #QUERY TO GET PRODUCTS $this->obDb->query = "SELECT iProdid_PK,vSeoTitle,vTitle,tShortDescription,vImage1,fPrice,fRetailPrice,iTaxable,iSale,iSubId_FK,fListPrice,iOwner_FK FROM " . PRODUCTS . "," . FUSIONS . " WHERE ( iProdid_PK=iSubId_FK AND iOwner_FK=0 AND vType='product' AND iState =1) ORDER BY iSort"; $row_product = $this->obDb->fetchQuery(); $row_product_count = $this->obDb->record_count; if ($row_product_count > 0) { for ($i = 0; $i < $row_product_count; $i++) { #MARGIN CALCULATOR switch (MARGINSTATUS) { case "increase": $row_product[$i]->fPrice = $row_product[$i]->fPrice * MARGINPERCENT / 100 + $row_product[$i]->fPrice; break; case "decrease": $row_product[$i]->fPrice = $row_product[$i]->fPrice - $row_product[$i]->fPrice * MARGINPERCENT / 100; break; default: $row_product[$i]->fPrice = $row_product[$i]->fPrice; break; } #END MARGIN CALCULATOR $this->ObTpl->set_var("TPL_VAR_ONSALE", ""); if ($row_product[$i]->iSale == 1) { $this->ObTpl->set_var("TPL_VAR_ONSALE", "<p class=\"onSale\">On Sale</p>"); } //--- Switch to retail price if Retail customer $comFunc = new c_commonFunctions(); if ($comFunc->m_checkCustomerType() == 1 && ENABLE_WHOLESALE == 1 && $row_product[$i]->fRetailPrice > 0) { $row_product[$i]->fPrice = $row_product[$i]->fRetailPrice; } //----End switch price //--------- Select all product in that department. $this->obDb->query = "SELECT iOwner_FK,vTitle,vSeoTitle FROM " . DEPARTMENTS . ", " . FUSIONS . " WHERE iSubId_FK=" . $row_product[$i]->iProdid_PK . " AND vType='product' AND iOwner_FK = iDeptid_PK AND iState =1"; $dept_row = $this->obDb->fetchQuery(); $deptcount = $this->obDb->record_count; if ($deptcount > 0) { $this->ObTpl->set_var("TPL_VAR_DEPTNAME", $dept_row[0]->vTitle); $depturl = SITE_URL . "ecom/index.php?action=ecom.details&mode=" . $dept_row[0]->vSeoTitle; $this->ObTpl->set_var("TPL_VAR_DEPTURL", $this->libFunc->m_safeUrl($depturl)); $this->ObTpl->parse("containdepartment_blk", "TPL_CONTAINTDEPARTMENT_BLK"); } //----------------- $productUrl = SITE_URL . "ecom/index.php?action=ecom.pdetails&mode=" . $row_product[$i]->vSeoTitle; $this->ObTpl->set_var("TPL_VAR_PRODUCTURL", $this->libFunc->m_safeUrl($productUrl)); $this->ObTpl->set_var("TPL_VAR_ID", $this->libFunc->m_displayContent($row_product[$i]->iProdid_PK)); $this->ObTpl->set_var("TPL_VAR_TITLE", $this->libFunc->m_displayContent($row_product[$i]->vTitle)); $this->ObTpl->set_var("TPL_VAR_DESC", $this->libFunc->m_displayContent($row_product[$i]->tShortDescription)); #TO CHECK WHEATHER TO DISPLAY WISHLIST OR NOT MANAGED BY ADMIN if (USEWISHLIST == 1) { ##WISHLIST URL $wishListUrl = SITE_URL . "ecom/index.php?action=wishlist.add&mode=" . $row_product[$i]->iProdid_PK; $this->ObTpl->set_var("TPL_VAR_WISHLISTLINK", $this->libFunc->m_safeUrl($wishListUrl)); $this->ObTpl->parse("wishlist_blk", "TPL_WISHLIST_BLK"); } #TO CHECK WHEATHER TO DISPLAY COMPARELIST OR NOT MANAGED BY ADMIN if (USECOMPARE == 1) { $compareListUrl = SITE_URL . "ecom/index.php?action=compare.add&mode=" . $row_product[$i]->iProdid_PK; $this->ObTpl->set_var("TPL_VAR_COMPARELINK", $this->libFunc->m_safeUrl($compareListUrl)); $this->ObTpl->parse("compare_blk", "TPL_COMPARE_BLK"); } if (CUSTOMER_REVIEWS == 1) { ##OVERALL PRODUCT STAR RANKING $this->obDb->query = "SELECT SUM(vRank) as total, COUNT(iItemid_FK) as reviewcount FROM " . REVIEWS . " WHERE iItemid_FK ='" . $row_product[$i]->iProdid_PK . "'"; $OverallReviewRating = $this->obDb->fetchQuery(); $ReviewRating = $OverallReviewRating[0]->total / $OverallReviewRating[0]->reviewcount; $ReviewRating = number_format($ReviewRating, 0, '.', ''); $this->ObTpl->set_var("TPL_VAR_REVIEWCOUNT", $OverallReviewRating[0]->reviewcount . " reviews"); switch ($ReviewRating) { case "0": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating0\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; case "1": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating1\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; case "2": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating2\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; case "3": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating3\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; case "4": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating4\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; case "5": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating5\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; case "6": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating6\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; case "7": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating7\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; case "8": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating8\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; case "9": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating9\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; case "10": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating10\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; } $this->ObTpl->parse("review_blk", "TPL_REVIEW_BLK"); } if ($row_product[$i]->iTaxable == 1) { $this->ObTpl->set_var("TPL_VAR_PRICE", $comFunc->m_Format_Price($row_product[$i]->fPrice)); } else { $this->ObTpl->set_var("TPL_VAR_PRICE", $this->libFunc->m_displayContent(number_format($row_product[$i]->fPrice, 2))); } if (!$this->libFunc->m_isNull($row_product[$i]->fListPrice) && $row_product[$i]->fListPrice > 0) { $this->ObTpl->set_var("TPL_VAR_RRP_AMOUNT", "<span class=\"rrp\">" . RRP_TEXT . ": <strike>" . CONST_CURRENCY . number_format($row_product[$i]->fListPrice, 2, '.', '') . "</strike></span>"); } else { $this->ObTpl->set_var("TPL_VAR_RRP_AMOUNT", ""); } if (!empty($row_product[$i]->vImage1)) { $img = $this->libFunc->m_checkFile($row_product[$i]->vImage1, "product", $this->libFunc->m_displayContent($row_product[$i]->vTitle)); if ($img) { $this->ObTpl->set_var("TPL_VAR_IMG", $img); } else { $this->ObTpl->set_var("TPL_VAR_IMG", MSG_NOIMG); } } else { $this->ObTpl->set_var("TPL_VAR_IMG", MSG_NOIMG); } $this->ObTpl->parse("product_blk", "TPL_PRODUCT_BLK", true); } $this->ObTpl->parse("mainproduct_blk", "TPL_MAINPRODUCT_BLK", true); } } #QUERY TO GET content $this->obDb->query = "SELECT iContentid_PK,vSeoTitle,vTitle,vImage1 FROM " . CONTENTS . "," . FUSIONS . " WHERE (iContentid_PK=iSubId_FK AND iOwner_FK='0' AND vType='content' AND iState =1) ORDER BY iSort"; $rowContent = $this->obDb->fetchQuery(); $contentCount = $this->obDb->record_count; if ($contentCount > 0) { for ($i = 0; $i < $contentCount; $i++) { $contentUrl = SITE_URL . "ecom/index.php?action=ecom.cdetails&mode=" . $rowContent[$i]->vSeoTitle; $this->ObTpl->set_var("TPL_VAR_CONTENTURL", $this->libFunc->m_safeUrl($contentUrl)); $this->ObTpl->set_var("TPL_VAR_ID", $this->libFunc->m_displayContent($rowContent[$i]->iContentid_PK)); if (!empty($rowContent[$i]->vImage1)) { $img = $this->libFunc->m_checkFile($rowContent[$i]->vImage1, "content", $this->libFunc->m_displayContent($rowContent[$i]->vTitle)); if ($img) { $this->ObTpl->set_var("TPL_VAR_TITLE", $img); } else { $this->ObTpl->set_var("TPL_VAR_TITLE", $this->libFunc->m_displayContent($rowContent[$i]->vTitle)); } } else { $this->ObTpl->set_var("TPL_VAR_TITLE", $this->libFunc->m_displayContent($rowContent[$i]->vTitle)); } $this->ObTpl->parse("content_blk", "TPL_CONTENT_BLK", true); } $this->ObTpl->parse("maincontent_blk", "TPL_MAINCONTENT_BLK", true); } $this->obDb->query = "SELECT * FROM " . COMPANYSETTINGS; $compset = $this->obDb->fetchQuery(); $this->ObTpl->set_var("TPL_VAR_SITENAME", $this->libFunc->m_displayContent($compset[0]->vCname)); $this->ObTpl->set_var("TPL_VAR_SLOGAN", $this->libFunc->m_displayContent($compset[0]->vSlogan)); return $this->ObTpl->parse("return", "TPL_VAR_CMS"); }
function m_attachedProduct($ownerId, $ownerType) { $comFunc = new c_commonFunctions(); $comFunc->obDb = $this->obDb; $attCondition = ""; if ($this->request['sort'] == 'attribute') { $this->ObTpl->set_var("TPL_VAR_ATTRIBUTESELECTED", "class=\"selected\""); $attCondition = " AND iAttrValueId_FK <> 0 "; } else { $this->ObTpl->set_var("TPL_VAR_OPTIONSELECTED", "class=\"selected\""); } if (isset($this->request['listview']) && $this->request['listview'] == "gridview") { $_SESSION['listview'] = $this->request['listview']; } else { unset($_SESSION['listview']); } if ($_SESSION['listview'] == "gridview") { $this->ObTpl->set_var("TPL_VAR_PRODUCTCLASS", "class=\"products grid\""); $this->ObTpl->set_var("TPL_VAR_IMGONLYSELECTED", "selected"); } else { $this->ObTpl->set_var("TPL_VAR_PRODUCTCLASS", "class=\"products\""); } if (!isset($_SESSION['sort'])) { $_SESSION['sort'] = "ORDER BY iSort"; } if (isset($this->request['sortbyprice'])) { if ($this->request['sortbyprice'] == "ASC" || $this->request['sortbyprice'] == "DESC") { $_SESSION['sort'] = "ORDER BY fPrice " . $this->request['sortbyprice']; $_SESSION['pricedirect'] = $this->request['sortbyprice']; unset($_SESSION['alphadirect']); } } if (isset($this->request['alphasort'])) { if ($this->request['alphasort'] == '0') { $_SESSION['sort'] = ""; $_SESSION['alphadirect'] = ""; } elseif ($this->request['alphasort'] == 'ASC') { $_SESSION['sort'] = "ORDER BY vTitle " . $this->request['alphasort']; $_SESSION['alphadirect'] = $this->request['alphasort']; } elseif ($this->request['alphasort'] == 'DESC') { $_SESSION['sort'] = "ORDER BY vTitle " . $this->request['alphasort']; $_SESSION['alphadirect'] = $this->request['alphasort']; } unset($_SESSION['pricedirect']); } if (isset($_SESSION['pricedirect'])) { if ($_SESSION['pricedirect'] == "ASC") { $this->ObTpl->set_var("TPL_VAR_ASC2", "selected = \"selected\""); } if ($_SESSION['pricedirect'] == "DESC") { $this->ObTpl->set_var("TPL_VAR_DESC2", "selected = \"selected\""); } } if (isset($_SESSION['alphadirect'])) { if ($_SESSION['alphadirect'] == "ASC") { $this->ObTpl->set_var("TPL_VAR_ASC1", "selected = \"selected\""); } if ($_SESSION['alphadirect'] == "DESC") { $this->ObTpl->set_var("TPL_VAR_DESC1", "selected = \"selected\""); } } if (isset($this->request['prodperpage']) && $this->request['prodperpage'] != '0' && is_numeric($this->request['prodperpage'])) { $_SESSION['pageSize'] = $this->request['prodperpage']; $this->pageSize = $_SESSION['pageSize']; } elseif (isset($_SESSION['pageSize']) && !empty($_SESSION['pageSize'])) { $this->pageSize = $_SESSION['pageSize']; } if (!isset($this->request['attkey'])) { $query = "SELECT vTitle,iProdid_PK,iAttrValueId_FK,vSeoTitle,tShortDescription,fPrice,fRetailPrice,fListPrice,iTaxable,vImage1,iSale "; $query .= " FROM " . PRODUCTS . " D, " . FUSIONS . " F WHERE iProdid_PK =iSubId_FK AND vtype='product' AND "; $query .= " iOwner_FK='" . $ownerId . "' AND vOwnerType='" . $ownerType . "' AND iState=1 " . $attCondition . $_SESSION['sort']; } else { $query = "SELECT vTitle,iProdid_PK,iAttrValueId_FK,vSeoTitle,tShortDescription,fPrice,fRetailPrice,fListPrice,iTaxable,vImage1,iSale "; $query .= "FROM " . PRODUCTS . ", " . PRODUCTATTRIBUTES . ", " . ATTRIBUTEVALUES; $query .= " WHERE iValueId_PK = iValueid_FK AND iProductid_FK = iProdid_PK"; $query .= " AND tValues LIKE '%?" . $this->request['attkey'] . "?%'"; } $pn = new PrevNext($this->pageTplPath, $this->pageTplFile, $this->obDb); if ($ownerType == "product") { $extraStr = "ecom/index.php?action=ecom.pdetails&mode=" . $this->request['mode']; } elseif ($ownerType == "department") { $extraStr = "ecom/index.php?action=ecom.details&mode=" . $this->request['mode']; } $pn->formno = 1; $navArr = $pn->create($query, $this->pageSize, $extraStr, $this->noPaging); $pn2 = new PrevNext($this->pageTplPath, $this->pageTplFile, $this->obDb); $pn2->formno = 2; $navArr2 = $pn2->create($query, $this->pageSize, $extraStr, $this->noPaging); $rowProduct = $navArr['qryRes']; $totalRecords = $navArr['totalRecs']; $productCount = $navArr['fetchedRecords']; $attributeexistFlag = 0; if ($productCount > 0) { for ($i = 0; $i < $productCount; $i++) { #MARGIN CALCULATOR switch (MARGINSTATUS) { case "increase": $rowProduct[$i]->fPrice = $rowProduct[$i]->fPrice * MARGINPERCENT / 100 + $rowProduct[$i]->fPrice; break; case "decrease": $rowProduct[$i]->fPrice = $rowProduct[$i]->fPrice - $rowProduct[$i]->fPrice * MARGINPERCENT / 100; break; default: $rowProduct[$i]->fPrice = $rowProduct[$i]->fPrice; break; } #END MARGIN CALCULATOR //--- Switch to retail price if Retail customer if ($comFunc->m_checkCustomerType() == 1 && ENABLE_WHOLESALE == 1 && $rowProduct[$i]->fRetailPrice > 0) { $rowProduct[$i]->fPrice = $rowProduct[$i]->fRetailPrice; } //----End switch price # CHECK IF THE DEPARTMENT HAS PRODUCTS WITH ATTRIBUTES if ($rowProduct[$i]->iAttrValueId_FK != 0) { $attributeexistFlag = 1; } # $this->ObTpl->set_var("TPL_VAR_LISTOPTIONS", ""); $this->ObTpl->set_var("TPL_VAR_LISTCHOICES", ""); $this->ObTpl->set_var("TPL_VAR_ONSALE", ""); $this->ObTpl->set_var("rrp_price_blk", ""); $comFunc->productId = $rowProduct[$i]->iProdid_PK; $shopUrl = SITE_URL . "ecom/index.php?action=ecom.addmulticart&mode=" . $rowProduct[$i]->vSeoTitle; $this->ObTpl->set_var("TPL_VAR_SHOPURL", $this->libFunc->m_safeUrl($shopUrl)); if ($rowProduct[$i]->iSale == 1) { $this->ObTpl->set_var("TPL_VAR_ATTACHED_ONSALE", "<p class=\"onSale\">On Sale!</p>"); } else { $this->ObTpl->set_var("TPL_VAR_ATTACHED_ONSALE", ""); } $productUrl = SITE_URL . "ecom/index.php?action=ecom.pdetails&mode=" . $rowProduct[$i]->vSeoTitle; $_SESSION['own'] = $ownerId; $this->ObTpl->set_var("TPL_VAR_PRODUCTURL", $this->libFunc->m_safeUrl($productUrl)); $this->ObTpl->set_var("TPL_VAR_ID", $this->libFunc->m_displayContent($rowProduct[$i]->iProdid_PK)); $this->ObTpl->set_var("TPL_VAR_TITLE", $this->libFunc->m_displayContent($rowProduct[$i]->vTitle)); ##TO CHECK WHEATHER TO DISPLAY WISHLIST OR NOT MANAGED BY ADMIN if (USEWISHLIST == 1) { //if ($this->request['listview']=="gridview"){ //$this->ObTpl->set_var("attached_wishlist_blk",""); //}else{ $wishListUrl = SITE_URL . "ecom/index.php?action=wishlist.add&mode=" . $rowProduct[$i]->iProdid_PK; $this->ObTpl->set_var("TPL_VAR_ATTACHED_WISHLISTLINK", "<p id=\"addWishlistAttached\"><a href=\"" . $this->libFunc->m_safeUrl($wishListUrl) . "\">Add to Wish List</a></p>"); //$this->ObTpl->parse("attached_wishlist_blk", "TPL_ATTACHED_WISHLIST_BLK"); //} } else { $this->ObTpl->set_var("TPL_VAR_ATTACHED_WISHLISTLINK", ""); } #TO CHECK WHETHER TO DISPLAY COMPARELIST OR NOT MANAGED BY ADMIN if (USECOMPARE == 1) { //if ($this->request['listview']=="gridview"){ //$this->ObTpl->set_var("attached_compare_blk",""); //}else{ $compareListUrl = SITE_URL . "ecom/index.php?action=compare.add&mode=" . $rowProduct[$i]->iProdid_PK; $this->ObTpl->set_var("TPL_VAR_ATTACHED_COMPARELINK", "<p id=\"addComparisonAttached\"><a href=\"" . $this->libFunc->m_safeUrl($compareListUrl) . "\">Add to Comparison List</a></p>"); //$this->ObTpl->parse("attached_compare_blk", "TPL_ATTACHED_COMPARE_BLK"); //} } else { $this->ObTpl->set_var("TPL_VAR_ATTACHED_COMPARELINK", ""); } if ($rowProduct[$i]->tShortDescription != "") { if ($this->request['listview'] == "gridview") { $this->ObTpl->set_var("productdesc_blk", ""); } else { $this->ObTpl->set_var("TPL_VAR_DESC", nl2br($this->libFunc->m_displayContent($rowProduct[$i]->tShortDescription))); $this->ObTpl->parse("productdesc_blk", "TPL_PDESC_BLK"); } } else { if ($this->request['listview'] == "gridview") { $this->ObTpl->set_var("productdesc_blk", ""); } else { $this->ObTpl->set_var("TPL_VAR_DESC", ""); $this->ObTpl->parse("productdesc_blk", "TPL_PDESC_BLK"); } } # MANIPULATE NETGROSS & INC_VAT DISPLAY if ($rowProduct[$i]->iTaxable == 1) { $this->ObTpl->set_var("TPL_VAR_PRICE", $comFunc->m_Format_Price($rowProduct[$i]->fPrice)); } else { $this->ObTpl->set_var("TPL_VAR_PRICE", number_format($rowProduct[$i]->fPrice, 2)); } ##CHECK FOR RRP PRICE if (!$this->libFunc->m_isNull($rowProduct[$i]->fListPrice) && $rowProduct[$i]->fListPrice > 0) { $this->ObTpl->set_var("TPL_VAR_RRP_AMOUNT", RRP_TEXT . ": <strike>" . CONST_CURRENCY . number_format($rowProduct[$i]->fListPrice, 2, '.', '') . "</strike>"); $this->ObTpl->parse("rrp_price_blk", "TPL_RRPPRICE_BLK"); } if (!$this->libFunc->m_isNull($rowProduct[$i]->vImage1)) { $img = $this->libFunc->m_checkFile($rowProduct[$i]->vImage1, "product", $this->libFunc->m_displayContent($rowProduct[$i]->vTitle)); if ($img) { $this->ObTpl->set_var("TPL_VAR_IMG", $img); } else { $this->ObTpl->set_var("TPL_VAR_IMG", MSG_NOIMG); } } else { $this->ObTpl->set_var("TPL_VAR_IMG", MSG_NOIMG); } if (CUSTOMER_REVIEWS == 1) { ##OVERALL PRODUCT STAR RANKING $this->obDb->query = "SELECT SUM(vRank) as total, COUNT(iItemid_FK) as reviewcount FROM " . REVIEWS . " WHERE iItemid_FK ='" . $rowProduct[$i]->iProdid_PK . "'"; $OverallReviewRating = $this->obDb->fetchQuery(); $ReviewRating = $OverallReviewRating[0]->total / $OverallReviewRating[0]->reviewcount; $ReviewRating = number_format($ReviewRating, 0, '.', ''); switch ($ReviewRating) { case "0": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating0\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; case "1": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating1\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; case "2": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating2\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; case "3": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating3\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; case "4": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating4\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; case "5": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating5\">" . $OverallReviewRating[0]->reviewcount . "reviews</p>"); break; case "6": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating6\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; case "7": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating7\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; case "8": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating8\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; case "9": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating9\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; case "10": $this->ObTpl->set_var("TPL_VAR_OVERALLRANK", "<p class=\"review rating10\">" . $OverallReviewRating[0]->reviewcount . " reviews</p>"); break; } $this->ObTpl->parse("reviewrank_blk", "TPL_REVIEWRANK_BLK"); } #GET OPTIONS $this->ObTpl->set_var("TPL_VAR_LISTOPTIONS", $comFunc->m_getOptions('0')); #GET CHOICES $this->ObTpl->set_var("TPL_VAR_LISTCHOICES", $comFunc->m_getChoices()); $this->ObTpl->parse("dspproduct_blk", "TPL_PRODUCT_BLK", true); } # END FOR LOOP # DISPLAY "SORT BY ATTRIBUTES" TAB IF THE DEPARTMENT HAS PRODUCTS WITH ATTRIBUTE if ($attributeexistFlag == 1) { $this->ObTpl->parse("sortattributetab_blk", "TPL_SORTATTRIBUTETAB_BLK"); } if ($this->request["sort"] == "attribute") { $this->ObTpl->parse("sortattribute_blk", "TPL_SORTATTRIBUTE_BLK"); } else { $this->ObTpl->parse("sortoptions_blk", "TPL_SORTOPTIONS_BLK"); } $this->ObTpl->parse("mainproduct_blk", "TPL_MAINPRODUCT_BLK"); } # END IF PRODUCT COUNT > 0 if ($totalRecords > $this->pageSize) { #PAGINATION $this->ObTpl->set_var("PagerBlock1", $navArr['pnContents']); $this->ObTpl->set_var("PagerBlock2", $navArr2['pnContents']); } else { $this->ObTpl->set_var("PagerBlock1", ""); $this->ObTpl->set_var("PagerBlock2", ""); } }