Beispiel #1
0
 function ShowProductList($mmy_links, $params, $catg_desc_arr, $ext_links, $vq_column_title)
 {
     // dada.wang 2012-04-13 for display script
     $GLOBALS['DisplayScript'] = '';
     $displayScript = array();
     $filter_var = array('vq', 'pq');
     $path = GetConfig('ShopPath');
     $GLOBALS['AlternateClass'] = '';
     $counter = 1;
     $CurCatId = 0;
     $map_names = array();
     $display_names = array();
     $qimg_arr = array();
     $qcmt_arr = array();
     $qimg_par_arr = array();
     $qcmt_par_arr = array();
     //$GLOBALS['SearchResults'] is an array for product data.
     //while($row = $GLOBALS['ISC_CLASS_DB']->Fetch($GLOBALS['SearchResults'])) {
     foreach ($GLOBALS["SearProductsInfos"] as $row) {
         /* Added by Simha to check inf prodcucts comes from different categories*/
         //if(empty($params['srch_category']) || !isset($params['srch_category']))
         //{
         if ($CurCatId != $row['categoryid']) {
             $CurCatId = $row['categoryid'];
             $filter_names = "SELECT DISTINCT qn.qid, qn.column_name, qn.display_names, qa.hoverimage as qimg, qa.comments as qcmt from\n                                                [|PREFIX|]qualifier_names qn\n                                                LEFT JOIN [|PREFIX|]qualifier_associations qa ON qa.qualifierid = qn.qid\n                                                WHERE (qa.categoryid = '{$CurCatId}') \n                                                AND qn.column_name regexp '^(pq|vq)'";
             // || qa.categoryid IN (SELECT catparentid FROM isc_categories WHERE categoryid = '$CurCatId')
             $filter_result = $GLOBALS['ISC_CLASS_DB']->Query($filter_names);
             while ($filter_row = $GLOBALS['ISC_CLASS_DB']->Fetch($filter_result)) {
                 $map_names[$filter_row['qid']] = $filter_row['column_name'];
                 $display_names[$filter_row['qid']] = $filter_row['display_names'];
             }
             $this->GetAssocDetails($CurCatId, $OwnAssoc, $ParentAssoc, $OwnValue, $ParentValue);
             $new_filter = "SELECT qualifierid as qid, hoverimage as qimg, comments as qcmt \n\t\t\t\t\tFROM [|PREFIX|]qualifier_associations \n\t\t\t\t\tWHERE categoryid = '{$CurCatId}'";
             $new_result = $GLOBALS['ISC_CLASS_DB']->Query($new_filter);
             while ($new_row = $GLOBALS['ISC_CLASS_DB']->Fetch($new_result)) {
                 $qimg_arr[$new_row['qid']] = $new_row['qimg'];
                 $qcmt_arr[$new_row['qid']] = $new_row['qcmt'];
             }
             $prt_filter = "SELECT c.catparentid as cpc, qa.qualifierid as qid, qa.hoverimage as qimg, qa.comments as qcmt \n\t\t\t\t\tFROM [|PREFIX|]categories as c\n\t\t\t\t\tLEFT JOIN [|PREFIX|]qualifier_associations as qa ON c.catparentid = qa.categoryid\n\t\t\t\t\tWHERE c.categoryid = '{$CurCatId}'";
             $par_result = $GLOBALS['ISC_CLASS_DB']->Query($prt_filter);
             while ($prt_row = $GLOBALS['ISC_CLASS_DB']->Fetch($par_result)) {
                 $qimg_par_arr[$prt_row['qid']] = $prt_row['qimg'];
                 $qcmt_par_arr[$prt_row['qid']] = $prt_row['qcmt'];
             }
         }
         //}
         /* Added by Simha Ends */
         $GLOBALS['SearchTrackClass'] = "TrackLink";
         $imagefile = "";
         if ($GLOBALS['AlternateClass'] == 'Odd') {
             $GLOBALS['AlternateClass'] = 'Even';
         } else {
             $GLOBALS['AlternateClass'] = 'Odd';
         }
         $qry_string = $this->GetQueryString($params);
         if ($GLOBALS['results_page_flag'] == 0 && !isset($params['srch_category'])) {
             break;
         }
         //wirror_mark_condition1
         /*if( isset($params['srch_category']) )  {
         	 $GLOBALS['CatgDescandBrandImage'] = isset($catg_desc_arr['catdesc']) ? $catg_desc_arr['catdesc'] : ''; // description will be added here to show it at the top of product listing page.
         	 }*/
         if (isset($params['category']) || !isset($params['subcategory']) && isset($params['series'])) {
             $GLOBALS['CatgDescandBrandImage'] = $row['seriesdescription'];
             //$GLOBALS['CatgBrandSeriesFooter'] = $row['seriesfooter'];
             $GLOBALS['CatgBrandSeriesFooter'] = "";
             if ((isset($params['category']) || isset($params['subcategory'])) && $GLOBALS['CatgDescandBrandImage'] == "") {
                 $GLOBALS['CatgDescandBrandImage'] = isset($catg_desc_arr['catdesc']) ? $catg_desc_arr['catdesc'] : '';
                 //$GLOBALS['CatgBrandSeriesFooter'] = isset($catg_desc_arr['categoryfooter']) ? $catg_desc_arr['categoryfooter'] : '';
                 $GLOBALS['CatgBrandSeriesFooter'] = "";
             }
         } else {
             if (isset($params['srch_category'])) {
                 $GLOBALS['CatgDescandBrandImage'] = isset($catg_desc_arr['catdesc']) ? $catg_desc_arr['catdesc'] : '';
                 $GLOBALS['CatgBrandSeriesFooter'] = isset($catg_desc_arr['categoryfooter']) ? $catg_desc_arr['categoryfooter'] : '';
                 if (isset($params['series']) && $row['seriesdescription'] != "") {
                     $GLOBALS['CatgDescandBrandImage'] = $row['seriesdescription'];
                     //$GLOBALS['CatgBrandSeriesFooter'] = $row['seriesfooter'];
                     $GLOBALS['CatgBrandSeriesFooter'] = "";
                 }
                 if ($GLOBALS['CatgDescandBrandImage'] == '' && $GLOBALS['CatgBrandSeriesFooter'] == '' && isset($params['brand'])) {
                     $GLOBALS['CatgDescandBrandImage'] = isset($brand_desc_arr['branddescription']) ? $brand_desc_arr['branddescription'] : '';
                     //$GLOBALS['CatgBrandSeriesFooter'] = isset($brand_desc_arr['brandfooter']) ? $brand_desc_arr['brandfooter'] : '';
                     $GLOBALS['CatgBrandSeriesFooter'] = "";
                 }
             } else {
                 if (isset($params['brand'])) {
                     $GLOBALS['CatgDescandBrandImage'] = isset($brand_desc_arr['branddescription']) ? $brand_desc_arr['branddescription'] : '';
                     $GLOBALS['CatgBrandSeriesFooter'] = isset($brand_desc_arr['brandfooter']) ? $brand_desc_arr['brandfooter'] : '';
                 }
             }
         }
         /* No need to show footer description when YMM are selected */
         if (isset($params['make']) || isset($params['model']) || isset($params['year'])) {
             $GLOBALS['CatgBrandSeriesFooter'] = "";
         }
         $GLOBALS['ProductCartQuantity'] = '';
         if (isset($GLOBALS['CartQuantity' . $row['productid']])) {
             $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']];
         }
         if ($counter % 2 == 0) {
             $GLOBALS['RowColor'] = 'grayrow';
         } else {
             $GLOBALS['RowColor'] = 'whiterow';
         }
         $counter++;
         $GLOBALS['ProductId'] = (int) $row['productid'];
         $GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
         //alandy_2012-2-20 modify product url = vendorprefix_sku
         //$GLOBALS['ProductLink'] = ProdLink($row['prodname']);
         $prodcode = encode_sku($row['prodcode']);
         $GLOBALS['ProductLink'] = ProdLinkSKU($row['prodvendorprefix'], $prodcode);
         $GLOBALS['ProductRating'] = (int) $row['prodavgrating'];
         //$GLOBALS['BrandName'] = $row['brandname'];
         /* -- The below code is added to display the brand and series logo -- */
         $GLOBALS['BrandName'] = "";
         $brandlogo = realpath(ISC_BASE_PATH . '/product_images/' . $row['brandimagefile']);
         if ($row['brandimagefile'] != '' && file_exists($brandlogo)) {
             $GLOBALS['BrandName'] .= "<img src=\"" . $GLOBALS['ShopPath'] . "/product_images/" . $row['brandimagefile'] . "\" class=\"BrandSeriesLogo\" />";
         } else {
             $GLOBALS['BrandName'] .= $row['brandname'];
         }
         $serieslogo = realpath(ISC_BASE_PATH . '/series_images/' . $row['serieslogoimage']);
         if ($row['serieslogoimage'] != '' && file_exists($serieslogo)) {
             $GLOBALS['BrandName'] .= "<br><img src=\"" . $GLOBALS['ShopPath'] . "/series_images/" . $row['serieslogoimage'] . "\" />";
         } else {
             $GLOBALS['BrandName'] .= "<br>" . $row['seriesname'];
         }
         /* --- ends --- */
         $GLOBALS['ProdCode'] = $row['prodcode'];
         //$GLOBALS['ProdDesc'] = $this->strip_html_tags($row['proddesc']);
         $GLOBALS['icon_file'] = '';
         if (isset($row['icon_file'])) {
             if (stripos($row['icon_file'], 'http://') >= 0) {
                 $GLOBALS['icon_file'] = "<img src='" . $row['icon_file'] . "' border=0 class='icon_image_class' width='125' />";
             } else {
                 $GLOBALS['icon_file'] = "<img src='" . $GLOBALS["SHOP_PATH"] . "/" . $row['icon_file'] . "' border=0 class='icon_image_class' width='125'/>";
             }
         }
         //$GLOBALS['ProductId']
         //$GLOBALS['ProdOptions'] = $row['productoption'];
         $GLOBALS['VehicleOptions'] = "";
         $GLOBALS['ProdOptions'] = "";
         foreach ($row as $key => $val) {
             if ($val != "" && $val != "~") {
                 if (($qualifier_id = array_search($key, $map_names)) !== false) {
                     if (eregi('^vq', $key)) {
                         $val = trim($val, "~");
                         $val = preg_split('/[~;]+/', $val);
                         $val = array_unique($val);
                         $val = array_values($val);
                         $val = implode(",", $val);
                         /* -- Setting display name for qualifier name -- */
                         if (isset($OwnAssoc[$qualifier_id]) && $OwnAssoc[$qualifier_id][0]['qname'] != '') {
                             $key = $OwnAssoc[$qualifier_id][0]['qname'];
                         } else {
                             if (isset($ParentAssoc[$qualifier_id]) && $ParentAssoc[$qualifier_id][0]['qname'] != '') {
                                 $key = $ParentAssoc[$qualifier_id][0]['qname'];
                             } else {
                                 if (isset($display_names[$qualifier_id]) && !empty($display_names[$qualifier_id])) {
                                     $key = $display_names[$qualifier_id];
                                 } else {
                                     $key = ucfirst(str_ireplace($filter_var, "", $key));
                                 }
                             }
                         }
                         /* -- Setting display name for qualifier name ends -- */
                         /* -- Setting display name for qualifier value -- */
                         if (isset($OwnValue[$qualifier_id]) && ($m = array_search(strtolower($val), $OwnValue[$qualifier_id])) !== false && $OwnAssoc[$qualifier_id][$m]['vname'] != "") {
                             $val = $OwnAssoc[$qualifier_id][$m]['vname'];
                         } else {
                             if (isset($ParentValue[$qualifier_id]) && ($m = array_search(strtolower($val), $ParentValue[$qualifier_id])) !== false && $ParentAssoc[$qualifier_id][$m]['vname'] != "") {
                                 $val = $ParentAssoc[$qualifier_id][$m]['vname'];
                             }
                         }
                         /* -- Setting display name for qualifier value ends-- */
                         $qimg = $qimg_arr[$qualifier_id];
                         $qcmt = $qcmt_arr[$qualifier_id];
                         if ($qimg == '' && $qcmt == '') {
                             $qimg = $qimg_par_arr[$qualifier_id];
                             $qcmt = $qcmt_par_arr[$qualifier_id];
                         }
                         $qcmt = nl2br($qcmt);
                         $qcmt = str_replace("\n", "", $qcmt);
                         $qcmt = str_replace("\r", "", $qcmt);
                         $qcmt = str_replace('"', "&quot;", $qcmt);
                         $qcmt = str_replace("'", "\\'", $qcmt);
                         $helpdiv = "<img id='" . $qualifier_id . "' onmouseover=\"showPqVqHelp(this,255, '" . $qimg . "', '" . $qcmt . "');\" onmouseout=\"hidePqVqHelp('" . $qualifier_id . "');\" src='/images/pqvq_help.gif'/></img> ";
                         if ($qimg != '' && $qcmt != '') {
                             $GLOBALS['VehicleOptions'] .= "<div class='qualifierwrap'><div class='qualifiertitle'>" . $key . " :</div> " . $helpdiv . $val . "</div>";
                         } else {
                             //$GLOBALS['VehicleOptions'] .= "<b>".$key."</b> : ".$val."<br>";
                             $GLOBALS['VehicleOptions'] .= "<div class='qualifierwrap'><div class='qualifiertitle'>" . $key . " :</div> " . $val . "</div>";
                         }
                     }
                     if (eregi('^pq', $key)) {
                         $val = trim($val, "~");
                         $val = preg_split('/[~;]+/', $val);
                         $val = array_unique($val);
                         $val = array_values($val);
                         $val = implode(",", $val);
                         /* -- Setting display name for qualifier name -- */
                         if (isset($OwnAssoc[$qualifier_id]) && $OwnAssoc[$qualifier_id][0]['qname'] != '') {
                             $key = $OwnAssoc[$qualifier_id][0]['qname'];
                         } else {
                             if (isset($ParentAssoc[$qualifier_id]) && $ParentAssoc[$qualifier_id][0]['qname'] != '') {
                                 $key = $ParentAssoc[$qualifier_id][0]['qname'];
                             } else {
                                 if (isset($display_names[$qualifier_id]) && !empty($display_names[$qualifier_id])) {
                                     $key = $display_names[$qualifier_id];
                                 } else {
                                     $key = ucfirst(str_ireplace($filter_var, "", $key));
                                 }
                             }
                         }
                         /* -- Setting display name for qualifier name ends -- */
                         /* -- Setting display name for qualifier value -- */
                         if (isset($OwnValue[$qualifier_id]) && ($m = array_search(strtolower($val), $OwnValue[$qualifier_id])) !== false && $OwnAssoc[$qualifier_id][$m]['vname'] != '') {
                             $val = $OwnAssoc[$qualifier_id][$m]['vname'];
                         } else {
                             if (isset($ParentValue[$qualifier_id]) && ($m = array_search(strtolower($val), $ParentValue[$qualifier_id])) !== false && $ParentValue[$qualifier_id][$m]['vname'] != '') {
                                 $val = $ParentAssoc[$qualifier_id][$m]['vname'];
                             }
                         }
                         /* -- Setting display name for qualifier value ends-- */
                         $qimg = $qimg_arr[$qualifier_id];
                         $qcmt = $qcmt_arr[$qualifier_id];
                         if ($qimg == '' && $qcmt == '') {
                             $qimg = $qimg_par_arr[$qualifier_id];
                             $qcmt = $qcmt_par_arr[$qualifier_id];
                         }
                         $qcmt = nl2br($qcmt);
                         $qcmt = str_replace("\n", "", $qcmt);
                         $qcmt = str_replace("\r", "", $qcmt);
                         $qcmt = str_replace('"', "&quot;", $qcmt);
                         $qcmt = str_replace("'", "\\'", $qcmt);
                         $helpdiv = "<img id='" . $qualifier_id . "' onmouseover=\"showPqVqHelp(this,255, '" . $qimg . "', '" . $qcmt . "');\" onmouseout=\"hidePqVqHelp('" . $qualifier_id . "');\" src='/images/pqvq_help.gif'/></img> ";
                         if ($qimg != '' && $qcmt != '') {
                             $GLOBALS['ProdOptions'] .= "<div class='qualifierwrap'><div class='qualifiertitle'>" . $key . " :</div> " . $helpdiv . $val . "</div>";
                         } else {
                             //$GLOBALS['ProdOptions'] .= "<b>".$key."</b> : ".$val."<br>";
                             $GLOBALS['ProdOptions'] .= "<div class='qualifierwrap'><div class='qualifiertitle'>" . $key . " :</div> " . $val . "</div>";
                         }
                     }
                 }
             }
         }
         if (isset($row['vehicleoption'])) {
             $GLOBALS['VehicleOptions'] = $row['vehicleoption'];
         }
         if (isset($row['productoption'])) {
             $GLOBALS['ProdOptions'] = $row['productoption'];
         }
         if (isset($row['catuniversal']) && $row['catuniversal'] == 1) {
             $GLOBALS['VehicleOptions'] = $GLOBALS['ProductName'];
             if ($vq_column_title == "") {
                 $vq_column_title = "Product Name";
             } else {
                 if ($vq_column_title != "Product Name") {
                     $vq_column_title = "Product Name / Vehicle";
                 }
             }
         } else {
             if ($vq_column_title == "") {
                 $vq_column_title = "Vehicle Options";
             } else {
                 if ($vq_column_title != "Vehicle Options") {
                     $vq_column_title = "Product Name / Vehicle";
                 }
             }
         }
         if (empty($GLOBALS['ProdOptions']) && empty($GLOBALS['VehicleOptions'])) {
             $GLOBALS['ProdOptions'] = "&nbsp;";
         }
         if (empty($GLOBALS['VehicleOptions'])) {
             $GLOBALS['VehicleOptions'] = "&nbsp;";
         }
         /*--- the below lines are added for back 2 search link in the product detail page. Also modified line no 56 & 60 --- */
         if ($GLOBALS['EnableSEOUrls'] == 1) {
             //alandy-2012-1-12 modify.
             //$GLOBALS['ProductLink'] .= "/refer=true".$ext_links;
             if (isset($GLOBALS['SearchId'])) {
                 //$GLOBALS['ProductLink'] .= '/SearchLogId/'.$GLOBALS['SearchId'];
                 $_SESSION['SearchLogId'] = $GLOBALS['SearchId'];
             }
         } else {
             //alandy-2012-1-12 modify.
             //$GLOBALS['ProductLink'] .= "&refer=true".$ext_links;
             if (isset($GLOBALS['SearchId'])) {
                 //$GLOBALS['ProductLink'] .= '&SearchLogId='.$GLOBALS['SearchId'];
                 $_SESSION['SearchLogId'] = $GLOBALS['SearchId'];
             }
         }
         ### Added by Simha for onsale addition
         // Determine the price of this product
         //$GLOBALS['ProductPrice'] = CalculateProductPrice_retail($row);
         $GLOBALS['ProductPrice'] = CalculateProductPriceRetail($row);
         $FinalPrice = $GLOBALS['ProductPrice'];
         $SalePrice = $row['prodsaleprice'];
         //$DiscountAmount = $FinalPrice;
         $discounttype = 0;
         $discountname = '';
         if ((double) $SalePrice > 0 && $SalePrice < $FinalPrice) {
             $DiscountPrice = $SalePrice;
         } else {
             $DiscountPrice = $FinalPrice;
             $DiscountPrice = CalculateDiscountPrice($FinalPrice, $DiscountPrice, $row['categoryid'], $row['brandseriesid'], $discounttype, $discountname);
             /*if($discounttype == 0)    {
             	 $DiscountPrice = $FinalPrice;
             	 }*/
         }
         /*
         foreach($DiscountInfo as $DiscountInfoSub)   {
         if(isset($DiscountInfoSub['catids']))    {
         $catids = explode(",", $DiscountInfoSub['catids']);
         foreach($catids as $catid) {
         if($catid == $row['categoryid']) {
         $DiscountAmount = $FinalPrice * ((int)$DiscountInfoSub['amount']/100);
         if ($DiscountAmount < 0) {
         $DiscountAmount = 0;
         }
         $DiscountPrice  = $FinalPrice - $DiscountAmount;
         }
         }
         }
         }
         */
         if (isset($DiscountPrice) && $DiscountPrice < $FinalPrice && $discounttype == 0) {
             //&& GetConfig('ShowOnSale')
             $GLOBALS['ProductPrice'] = '<strike>' . CurrencyConvertFormatPrice($FinalPrice) . '</strike>';
             $GLOBALS['ProductPrice'] .= '<br><div class="finalprice">' . CurrencyConvertFormatPrice($DiscountPrice) . '</div> ';
             if (strtolower($discountname) == "clearance") {
                 $GLOBALS['ShowOnSaleImage'] = '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/clearance.gif" alt="">';
             } else {
                 $GLOBALS['ShowOnSaleImage'] = '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/onsale.gif" alt="">';
             }
             if (GetConfig('ShowOnSale')) {
                 $GLOBALS['ProductPrice'] .= '' . $GLOBALS['ShowOnSaleImage'] . '';
             }
         } else {
             $GLOBALS['ProductPrice'] = '<div class="finalprice">' . CurrencyConvertFormatPrice($FinalPrice) . '</div>';
         }
         ### Added by Simha Ends
         // commented the below line by vikas
         //$GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname']));
         $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], $GLOBALS['ProductLink']);
         if (isId($row['prodvariationid']) || trim($row['prodconfigfields']) != '' || $row['prodeventdaterequired'] == 1) {
             //$GLOBALS['ProductURL'] = ProdLink($row['prodname']); // commented by vikas
             $GLOBALS['ProductURL'] = $GLOBALS['ProductLink'];
             $GLOBALS['ProductAddText'] = GetLang('ProductChooseOptionLink');
         } else {
             //$GLOBALS['ProductURL'] = CartLink($row['productid']);
             //$GLOBALS['ProductURL'] = ProdLink($row['prodname']); // commented by vikas
             $GLOBALS['ProductURL'] = $GLOBALS['ProductLink'];
             //blessen
             if (intval($row['prodretailprice']) <= 0) {
                 //$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink'); // commented by vikas on 15-7-09
                 $GLOBALS['ProductAddText'] = "<img src='{$path}/templates/default/images/view.gif' border=0>";
             } else {
                 //$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink1'); // commented by vikas on 15-7-09
                 $GLOBALS['ProductAddText'] = "<img src='{$path}/templates/default/images/view.gif' border=0>";
             }
             //blessen
             // original $GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink');
         }
         if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) {
             $GLOBALS['HideActionAdd'] = '';
         } else {
             $GLOBALS['HideActionAdd'] = 'none';
         }
         $GLOBALS['HideProductVendorName'] = 'display: none';
         $GLOBALS['ProductVendor'] = '';
         if (GetConfig('ShowProductVendorNames') && $row['prodvendorid'] > 0) {
             $vendorCache = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('Vendors');
             if (isset($vendorCache[$row['prodvendorid']])) {
                 $GLOBALS['ProductVendor'] = '<a href="' . VendorLink($vendorCache[$row['prodvendorid']]) . '">' . isc_html_escape($vendorCache[$row['prodvendorid']]['vendorname']) . '</a>';
                 $GLOBALS['HideProductVendorName'] = '';
             }
         }
         $qpvq_search = $_SESSION['searchterms']['dynfilters'];
         if (empty($qpvq_search)) {
             $GLOBALS['pqvqSearch'] = 0;
         } else {
             $GLOBALS['pqvqSearch'] = 1;
         }
         //alandy_2011-6-15 modify. add prodallowpurchase check!
         //$GLOBALS['CartURL'] = CartLink($row['productid']);
         $GLOBALS['CartURL'] = NewCartLink($row['productid'], $row['prodallowpurchases']);
         //$GLOBALS['ClickCartButton']=ClickCartButton($row['prodallowpurchases'],$row['productid']);
         //alandy_2011-12-21 modify.continue to check product attribute.
         //if(empty($GLOBALS['ClickCartButton'])){
         //$GLOBALS['ClickCartButton'] = CheckProductAttribute($row['productid']);
         //}
         if (isset($GLOBALS['SearchId'])) {
             $GLOBALS['CartURL'] .= '&SearchLogId=' . $GLOBALS['SearchId'];
         }
         $offer = $this->IsProductMakeanOffer($row['brandseriesid'], $row['brandname'], $row['categoryid']);
         if ($offer == 'yes') {
             $GLOBALS['HideOfferButton'] = 'block';
             $GLOBALS['OfferButtonLink'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("OfferButtonLink");
             //zcs=
         } else {
             $GLOBALS['HideOfferButton'] = 'none';
             $GLOBALS['OfferButtonLink'] = '';
             //zcs=
         }
         // dada.wang 2012.04.12 call for best price
         $callForBestPrice = GetClass('ISC_PRODUCT_HELPER')->GetProductCallForBestPrice($row);
         $GLOBALS['BestPrice'] = '';
         if ($callForBestPrice) {
             $displayScript[] = $callForBestPrice['displayScript'];
             $GLOBALS['BestPrice'] = '<div data="' . htmlspecialchars($callForBestPrice['popupMessage']) . '" onmouseover="showcallbestprice(this,385);" onmouseout="hidecallbestprice(this)"><img src="/images/call-in-trans.gif"/></div>';
         }
         $GLOBALS['SearchResultList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoryProductsItem");
     }
     if (!empty($displayScript) && count(array_unique($displayScript)) == 1) {
         $GLOBALS['DisplayScript'] = $displayScript[0];
     }
 }
Beispiel #2
0
 private function CheckProductAttribute($productid = 0)
 {
     //first compare cookie YMM WITH product YMM.
     $data = array();
     $tmp = array();
     $catuniversal = 0;
     $query_string = "";
     $search_string = "";
     $search_prefix = $GLOBALS['ShopPathNormal'] . '/';
     $year = "";
     $make = "";
     $model = "";
     $product_string = " productid = " . $productid;
     $url = $_SERVER['REQUEST_URI'];
     $url = ltrim($url, '/');
     $url_arr = explode("/", $url);
     $catname_link = $GLOBALS['ShopPathNormal'];
     $data['showApplication'] = false;
     //fetch product attribute.
     $result = $this->get_product_attribute($productid);
     //fetch product catgory name.
     $catname = $this->getCategoryNameByProductid($productid);
     $categorySearchLink = $this->getCategorySearchLinkByProductid($productid);
     if ($catname) {
         $data['categoryname'] = $catname;
         $data['catname'] = MakeURLSafe($catname);
         $catname_link .= '/' . $data['catname'];
         //$data['catname_link'] = $GLOBALS['ShopPathNormal'].'/'.$data['catname'];
     }
     if ($categorySearchLink) {
         //join category search.ex:categoryname/subcategory/subcategoryname
         $search_prefix .= $categorySearchLink;
     }
     $data['cartURL'] = NewCartLink($productid, 1);
     $data['productid'] = $productid;
     $data['popup'] = '';
     //Firstly,fetch this product attibute.
     if (!empty($result)) {
         $data['prodname'] = $result['prodname'];
         $data['brandname'] = $result['brandname'];
         $data['seriesname'] = $result['seriesname'];
         $search_string .= "/brand/" . MakeURLSafe($result['brandname']);
         $search_string .= "/series/" . MakeURLSafe($result['seriesname']);
     } else {
         $data['prodname'] = '';
         $data['brandname'] = '';
         $data['seriesname'] = '';
     }
     //search prefix.
     if (!empty($search_string)) {
         $search_prefix .= $search_string;
     }
     $data['search_prefix'] = $search_prefix;
     //fetch cookie year.
     if (isset($_COOKIE['last_search_selection']['year'])) {
         $year = $_COOKIE['last_search_selection']['year'];
         if ($year != 'ALL' && (int) $year > 1950) {
             $query_string .= " and prodstartyear <= '" . $year . "' and prodendyear >= '" . $year . "'";
             $search_string .= "/year/" . $year;
             $catname_link .= "/year/" . $year;
         }
     }
     //fetch cookie make.
     if (isset($_COOKIE['last_search_selection']['make'])) {
         $make = $_COOKIE['last_search_selection']['make'];
         if ($make != 'NON-SPEC VEHICLE' && !empty($make)) {
             $query_string .= " and prodmake = '" . $make . "'";
             $search_string .= "/make/" . $make;
             $catname_link .= "/make/" . $make;
         }
     }
     //fetch cookie model.
     if (isset($_COOKIE['last_search_selection']['model'])) {
         $model = $_COOKIE['last_search_selection']['model'];
         if ($model != 'ALL' && !empty($model)) {
             $query_string .= " and prodmodel = '" . $model . "'";
             $search_string .= "/model/" . $model;
             $catname_link .= "/model/" . $model;
         }
     }
     if ($year && $make && $model) {
         $data['detailimg'] = 1;
     }
     $data['catname_link'] = $catname_link;
     if (!$year != 'ALL' && (int) ($year > 1950)) {
         $data['year'] = $year;
     }
     if ($make != 'NON-SPEC VEHICLE' && !empty($make)) {
         $data['make'] = $make;
     }
     if ($model != 'ALL' && !empty($model)) {
         $data['model'] = $model;
     }
     //return ymm selecter.
     $impv = $this->get_product_importVariation($productid);
     if (!empty($impv)) {
         foreach ($impv as $row) {
             if ($row['prodstartyear'] > 0) {
                 $tmp['prodstartyear'][] = $row['prodstartyear'];
             }
             if ($row['prodendyear'] > 0) {
                 $tmp['prodendyear'][] = $row['prodendyear'];
             }
             if ($row['prodmake'] != 'ALL' && !empty($row['prodmake'])) {
                 $tmp['prodmake'][] = $row['prodmake'];
             }
             if ($row['prodmodel'] != 'ALL' && !empty($row['prodmodel'])) {
                 $tmp['prodmodel'][] = $row['prodmodel'];
             }
             //catuniversial.
             if ($row['prodstartyear'] == 'All' || $row['prodendyear'] == 'All' || $row['prodmake'] == 'NON-SPEC VEHICLE' || $row['prodmodel'] == 'All') {
                 $catuniversal = 1;
                 break;
             }
         }
         if ($catuniversal == 0) {
             //alandy_2012-3-6 modify.
             if (isset($tmp['prodstartyear']) && !empty($tmp['prodstartyear'])) {
                 $tmp['prodstartyear'] = min(array_unique($tmp['prodstartyear']));
             } else {
                 $tmp['prodstartyear'] = 0;
             }
             if (isset($tmp['prodendyear']) && !empty($tmp['prodendyear'])) {
                 $tmp['prodendyear'] = max(array_unique($tmp['prodendyear']));
             } else {
                 $tmp['prodendyear'] = 0;
             }
             //auto select model by year+make.
             //2012-3-19 add.
             if (!empty($year) && !empty($make)) {
                 $where = "prodstartyear <='" . $year . "' and prodendyear >='" . $year . "' and prodmake='" . $make . "' ";
                 $ymm = $this->get_product_importVariation($productid, $where);
                 if (!empty($ymm)) {
                     unset($tmp['prodmodel']);
                     foreach ($ymm as $row) {
                         $tmp['prodmodel'][] = $row['prodmodel'];
                     }
                 }
             }
             $tmp['prodmake'] = array_unique($tmp['prodmake']);
             $tmp['prodmodel'] = array_unique($tmp['prodmodel']);
             sort($tmp['prodmake']);
             sort($tmp['prodmodel']);
             $data['year_option'][0] = "<option value=''>--select year--</option>";
             for ($i = $tmp['prodendyear']; $i >= $tmp['prodstartyear']; $i--) {
                 $selected = "";
                 if ($i == $year) {
                     $selected = "selected";
                 }
                 $data['year_option'][] = "<option value='" . $i . "' " . $selected . ">" . $i . "</option>";
             }
             $data['make_option'][0] = "<option value=''>--select make--</option>";
             foreach ($tmp['prodmake'] as $val) {
                 $selected = "";
                 if (strtolower($val) == strtolower($make)) {
                     $selected = "selected";
                 }
                 $data['make_option'][] = "<option value='" . MakeURLSafe(strtolower($val)) . "' {$selected} >" . $val . "</option>";
             }
             $data['model_option'][0] = "<option value=''>--select model--</option>";
             foreach ($tmp['prodmodel'] as $val) {
                 $selected = "";
                 if (strtolower($val) == strtolower($model)) {
                     $selected = "selected";
                 }
                 $data['model_option'][] = "<option value='" . strtoupper($val) . "' " . $selected . ">" . $val . "</option>";
             }
         } else {
             //universial product.
             $data['year_option'][0] = "<option value=''>ALL</option>";
             $data['make_option'][0] = "<option value=''>NON-SPEC VEHICLE</option>";
             $data['model_option'][0] = "<option value=''>ALL</option>";
         }
     }
     $GLOBALS['ISC_CLASS_PRODUCT_PQVQ'] = GetClass('ISC_PRODUCT');
     $data['vehicle_research'] = $GLOBALS['ShopPathNormal'] . '/' . $search_string;
     // dada.wang 2012-03-14 where ymm is complete then show pq/vq
     if (isset($_COOKIE['last_search_selection']) && !empty($_COOKIE['last_search_selection']['make']) && !empty($_COOKIE['last_search_selection']['year']) && !empty($_COOKIE['last_search_selection']['model'])) {
         $data['pqvq'] = $GLOBALS['ISC_CLASS_PRODUCT_PQVQ']->GetProductPQVQHtml($productid, $query_string);
     } else {
         $data['pqvq'] = '';
     }
     $data['query_string'] = $query_string;
     //$product_string .= $query_string;
     $subcategory = isset($_SESSION['searchterms']['subcategory']) ? $_SESSION['searchterms']['subcategory'] : '';
     $model = $_COOKIE['last_search_selection']['model'];
     if ($catuniversal == 0) {
         //non catuniversial.
         $data['vehicle'] = trim($year . " " . ucwords($make) . " " . ucwords($model));
         if (!empty($product_string)) {
             //first,look if this product has variations
             $sql = "select id from [|PREFIX|]import_variations where " . $product_string;
             $query = $GLOBALS['ISC_CLASS_DB']->Query($sql);
             $result = $GLOBALS['ISC_CLASS_DB']->Fetch($query);
             if ($result && !empty($result)) {
                 //has variations.
                 //second,look productid+ymm is exist.
                 $product_string .= $query_string;
                 $sql = "select id from [|PREFIX|]import_variations where " . $product_string;
                 $query = $GLOBALS['ISC_CLASS_DB']->Query($sql);
                 $result = $GLOBALS['ISC_CLASS_DB']->Fetch($query);
                 if ($result && !empty($result)) {
                     if (empty($year) || empty($make) || empty($model)) {
                         //ymm not complete.
                         $data['popup'] = "2";
                     } else {
                         if (empty($qpvq_search)) {
                             $data['popup'] = '4';
                         }
                     }
                 } else {
                     //Scenario 1: not match product attribute.
                     $data['popup'] = "1";
                 }
             } else {
                 $data['ymmisselect'] = '1';
                 unset($data['popup']);
             }
         } else {
             //return '';
         }
     } else {
         $data['popup'] = '4';
         $data['vehicle'] = "This is a Universal Part and fits all vehicles.";
         //KATE CHANGE: "Universal Vehicle.";
     }
     //if product don't have ymm or  was catuniversal product,didn't show application dialog.
     if (!empty($impv) && $catuniversal == 0) {
         $data['showApplication'] = true;
     }
     return $data;
 }