コード例 #1
0
 function m_addProductForm()
 {
     $comFunc = new c_commonFunctions();
     $comFunc->obDb = $this->obDb;
     $this->ObTpl = new template();
     $this->ObTpl->set_file("TPL_ADDPRODUCT_FILE", $this->addTemplate);
     $this->ObTpl->set_block("TPL_ADDPRODUCT_FILE", "TPL_KIT_BLK", "kit_blk");
     $this->ObTpl->set_block("TPL_KIT_BLK", "TPL_KITELEMENT_BLK", "kitElement_blk");
     if (!isset($this->request['orderid']) || !isset($this->request['productid'])) {
         $this->libFunc->m_mosRedirect(SITE_URL . "order/adminindex.php?action=orders.home");
         exit;
     }
     $query = "SELECT vTitle,vSku,fPrice,iKit FROM " . PRODUCTS . " WHERE iProdId_PK='" . $this->request['productid'] . "'";
     $this->obDb->query = $query;
     $queryResult = $this->obDb->fetchQuery();
     #SETTING TEMPLATE VARIABLE
     $this->ObTpl->set_var("TPL_VAR_MAINOPTIONS", "");
     $this->ObTpl->set_var("TPL_VAR_MAINCHOICES", "");
     $this->ObTpl->set_var("TPL_VAR_ISKIT", "0");
     $this->ObTpl->set_var("kit_blk", "");
     $this->ObTpl->set_var("kitElement_blk", "");
     $this->ObTpl->set_var("GRAPHICSMAINPATH", GRAPHICS_PATH);
     $this->ObTpl->set_var("TPL_VAR_SITEURL", SITE_URL);
     $this->ObTpl->set_var("TPL_VAR_ORDERID", $this->request['orderid']);
     $this->ObTpl->set_var("TPL_VAR_CURRENCY", CONST_CURRENCY);
     $this->ObTpl->set_var("TPL_VAR_PRODUCTID", $this->request['productid']);
     $this->ObTpl->set_var("TPL_VAR_SKU", $this->libFunc->m_displayContent($queryResult[0]->vSku));
     $this->ObTpl->set_var("TPL_VAR_TITLE", $this->libFunc->m_displayContent($queryResult[0]->vTitle));
     $this->ObTpl->set_var("TPL_VAR_PRICE", number_format($queryResult[0]->fPrice));
     #PRODUCT ID FOR COMMON FUNCTION CLASS
     $comFunc->productId = $this->request['productid'];
     if ($queryResult[0]->iKit == 1) {
         $this->ObTpl->set_var("TPL_VAR_ISKIT", "1");
         $this->obDb->query = "SELECT iProdId_FK,iQty,vTitle,vSeoTitle,vSku FROM " . PRODUCTKITS . "," . PRODUCTS . " WHERE iProdId_FK=iProdId_PK AND iKitId ='" . $this->request['productid'] . "'";
         $rsKit = $this->obDb->fetchQuery();
         $rsKitCount = $this->obDb->record_count;
         if ($rsKitCount > 0) {
             for ($i = 0; $i < $rsKitCount; $i++) {
                 $this->ObTpl->set_var("TPL_VAR_COUNT", $i + 1);
                 $kitElementUrl = SITE_URL . "ecom/index.php?action=ecom.pdetails&mode=" . $rsKit[$i]->vSeoTitle;
                 $comFunc->productId = $rsKit[$i]->iProdId_FK;
                 $this->ObTpl->set_var("TPL_VAR_KITSKU", $rsKit[$i]->vSku);
                 $this->ObTpl->set_var("TPL_VAR_QTY", $rsKit[$i]->iQty);
                 #GET OPTIONS
                 $this->ObTpl->set_var("TPL_VAR_OPTIONS", $comFunc->m_getOptions('1'));
                 $this->ObTpl->set_var("TPL_VAR_KITELEMENT_URL", $this->libFunc->m_safeUrl($kitElementUrl));
                 $this->ObTpl->set_var("TPL_VAR_KITELEMENT", $this->libFunc->m_displayContent($rsKit[$i]->vTitle));
                 $this->ObTpl->parse("kitElement_blk", "TPL_KITELEMENT_BLK", true);
             }
             #END FOR I LOOP
             $this->ObTpl->parse("kit_blk", "TPL_KIT_BLK");
         }
         #END IF
     } else {
         #GET OPTIONS
         $this->ObTpl->set_var("TPL_VAR_MAINOPTIONS", $comFunc->m_getOptions('0'));
         #GET CHOICES
         $this->ObTpl->set_var("TPL_VAR_MAINCHOICES", $comFunc->m_getChoices());
     }
     return $this->ObTpl->parse("return", "TPL_ADDPRODUCT_FILE");
 }
コード例 #2
0
 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", "");
     }
 }