Пример #1
0
 function getYMMOptions($params, $ymm_type)
 {
     switch ($ymm_type) {
         case 'year':
             $options = "<option value=''>--select year--</option>";
             $filter_array = array();
             //$ymm_qry = "select group_concat(v.prodstartyear separator '~') as prodstartyear , group_concat(v.prodendyear separator '~') as prodendyear from [|PREFIX|]products p LEFT JOIN [|PREFIX|]import_variations AS v ON v.productid = p.productid where p.prodvisible='1' ";
             $ymm_qry = " select min(v.prodstartyear) as prodstartyear , max(v.prodendyear)  as prodendyear from isc_products p LEFT JOIN isc_import_variations AS v ON v.productid = p.productid where p.prodvisible='1' and v.prodstartyear is not null and v.prodstartyear !='' and v.prodstartyear !='all'  and v.prodendyear is not null and v.prodendyear !='' and v.prodendyear !='all'  ";
             if (isset($params['make']) && $GLOBALS['UniversalCat'] == 0) {
                 $ymm_qry .= " and prodmake = '" . $params['make'] . "' ";
             }
             if (isset($params['model']) && (!isset($params['model_flag']) || $params['model_flag'] == 1) && $GLOBALS['UniversalCat'] == 0) {
                 $ymm_qry .= " and prodmodel = '" . $params['model'] . "' ";
             }
             //$ymm_qry .= " group by p.productid ";
             $ymm_res = $GLOBALS['ISC_CLASS_DB']->Query($ymm_qry);
             if ($ymm_row = $GLOBALS['ISC_CLASS_DB']->Fetch($ymm_res)) {
                 if (empty($ymm_row["prodstartyear"]) || !isnumeric($ymm_row["prodstartyear"])) {
                     $startyear = 1950;
                 }
                 if (empty($ymm_row["prodendyear"]) || !isnumeric($ymm_row["prodendyear"])) {
                     $endyear = date('Y');
                 }
                 $startyear = $ymm_row["prodstartyear"];
                 $endyear = $ymm_row["prodendyear"];
                 //2011-1-20 Ronnie add,year range 1900~2050
                 $YMMMinYear = 1900;
                 $YMMMaxYear = 2050;
                 if ($startyear < $YMMMinYear) {
                     $startyear = $YMMMinYear;
                 }
                 if ($startyear > $YMMMaxYear) {
                     $startyear = $YMMMaxYear;
                 }
                 if ($endyear < $YMMMinYear) {
                     $endyear = $YMMMinYear;
                 }
                 if ($endyear > $YMMMaxYear) {
                     $endyear = $YMMMaxYear;
                 }
                 //$endyear=$YMMMaxYear;
                 for ($i = $startyear; $i <= $endyear; $i++) {
                     if (!in_array($i, $filter_array)) {
                         $filter_array[] = $i;
                     }
                 }
                 /*$grp_startyear = explode("~",$ymm_row['prodstartyear']);
                 					$grp_endyear = explode("~",$ymm_row['prodendyear']);
                 					for($g=0;$g<count($grp_startyear);$g++)
                 					{
                 						$prod_start_year = $grp_startyear[$g];
                 						$prod_end_year = $grp_endyear[$g];
                 
                 						if(is_numeric($prod_start_year) && is_numeric($prod_end_year))
                 						{
                 							$prod_year_diff = $prod_end_year - $prod_start_year;
                 							for($i=0;$i<=$prod_year_diff;$i++)
                 							{
                 								$actual_year = $prod_start_year + $i;
                 								if(in_array($actual_year,$filter_array)) {
                 									$count_filter_array[$actual_year]++;
                 								}  else {
                 									$filter_array[] = $actual_year;
                 									$count_filter_array[$actual_year] = 1;
                 								}
                 							}
                 						}
                 					}*/
             }
             rsort($filter_array);
             foreach ($filter_array as $key => $value) {
                 $selected = "";
                 if (isset($params['year']) && strcasecmp($params['year'], $value) == 0) {
                     $selected = " selected";
                 }
                 if (!empty($this->productImpVariations) && !ISC_PRODUCT::CheckYMMUseVariation($value, $this->productImpVariations, 'year')) {
                     continue;
                 }
                 $options .= "<option value='" . MakeURLSafe(strtolower($value)) . "'{$selected}>{$value}</option>";
             }
             break;
         case 'make':
             $filter_array = array();
             $GLOBALS['ISC_YMMS'] = GetClass('ISC_YMMS');
             $result = $GLOBALS['ISC_YMMS']->getResultArray("make", "", "", "");
             $options = "<option value=''>--select make--</option>";
             //$ymm_qry = "select group_concat(DISTINCT v.prodmake separator '~') as prodmake from [|PREFIX|]products p LEFT JOIN [|PREFIX|]import_variations AS v ON v.productid = p.productid where p.prodvisible='1' ";
             //$ymm_qry = "select DISTINCT v.prodmake  as prodmake from [|PREFIX|]products p LEFT JOIN [|PREFIX|]import_variations AS v ON v.productid = p.productid where p.prodvisible='1' ";
             //$ymm_res = $GLOBALS['ISC_CLASS_DB']->Query($ymm_qry);
             //while($ymm_row = $GLOBALS['ISC_CLASS_DB']->Fetch($ymm_res))
             //{
             /*$filters = explode('~',$ymm_row['prodmake']);
             		for($j=0;$j<count($filters);$j++) 
             	    {
             			$filter_value = $filters[$j]; 
             			if(strtoupper($filter_value) != "NON-SPEC VEHICLE" && strtolower($filter_value) != "all" && $filter_value != "")
             			{
             				if(in_array($filter_value,$filter_array))   {
             					$count_filter_array[$filter_value]++;
             				} else {
             					$filter_array[] = $filter_value;
             					$count_filter_array[$filter_value] = 1;
             				}
             			}
             	    }*/
             //if(strtoupper($ymm_row['prodmake']) != "NON-SPEC VEHICLE" && strtolower($ymm_row['prodmake']) != "all" && $ymm_row['prodmake'] != "")
             //{
             //	$filter_array[] = $ymm_row['prodmake'];
             //}
             //}
             foreach ($result as $key => $value) {
                 if (strtoupper($value) != "NON-SPEC VEHICLE" && strtolower($value) != "all" && $value != "") {
                     $filter_array[] = $value;
                 }
             }
             sort($filter_array);
             $all_makes = array('CHEVROLET', 'GMC', 'FORD', 'DODGE', 'TOYOTA', 'NISSAN', 'HONDA', 'JEEP', 'HYUNDAI', 'CHRYSLER', 'INFINITI', 'LEXUS');
             //$temp_arr =  array_diff($filter_array,$all_makes);	// commented as client told to include the above makes in other list also
             $temp_arr = $filter_array;
             //alandy_2011-10-13 modify.
             array_unique($temp_arr);
             if (!$GLOBALS['ProductIds']) {
                 foreach ($all_makes as $key => $value) {
                     $selected = "";
                     if (!empty($this->productImpVariations) && !ISC_PRODUCT::CheckYMMUseVariation($value, $this->productImpVariations, 'make')) {
                         continue;
                     }
                     if (isset($params['make']) && strcasecmp($params['make'], $value) == 0) {
                         $selected = " selected";
                     }
                     $options .= "<option value='" . MakeURLSafe(strtolower($value)) . "'{$selected}>{$value}</option>";
                 }
                 $options .= "<option value=''>------------</option>";
             }
             foreach ($temp_arr as $key => $value) {
                 $selected = "";
                 if (!empty($this->productImpVariations) && !ISC_PRODUCT::CheckYMMUseVariation($value, $this->productImpVariations, 'make')) {
                     continue;
                 }
                 if (isset($params['make']) && strcasecmp($params['make'], $value) == 0) {
                     $selected = " selected";
                 }
                 $options .= "<option value='" . MakeURLSafe(strtolower($value)) . "'{$selected}>{$value}</option>";
             }
             break;
         case 'model':
             $options = "<option value=''>--select model--</option>";
             if (isset($params['make'])) {
                 $filter_array = array();
                 $ymm_qry = "select distinct prodmodel from [|PREFIX|]products p LEFT JOIN [|PREFIX|]import_variations AS v ON v.productid = p.productid where p.prodvisible='1' ";
                 if (isset($params['make'])) {
                     $ymm_qry .= " and prodmake = '" . $params['make'] . "' ";
                 }
                 if (isset($params['year']) && $GLOBALS['UniversalCat'] == 0) {
                     $ymm_qry .= " and " . $params['year'] . " between prodstartyear and prodendyear ";
                 }
                 //$ymm_qry .= " group by p.productid ";
                 $ymm_res = $GLOBALS['ISC_CLASS_DB']->Query($ymm_qry);
                 while ($ymm_row = $GLOBALS['ISC_CLASS_DB']->Fetch($ymm_res)) {
                     if (!empty($ymm_row['prodmodel']) && $ymm_row['prodmodel'] != '~') {
                         $filters = explode('~', $ymm_row['prodmodel']);
                         for ($j = 0; $j < count($filters); $j++) {
                             $filter_value = ucwords(strtolower($filters[$j]));
                             if (strtolower($filter_value) != "all") {
                                 if (in_array($filter_value, $filter_array)) {
                                 } else {
                                     $filter_array[] = $filter_value;
                                 }
                             }
                         }
                     }
                 }
                 sort($filter_array);
                 foreach ($filter_array as $key => $value) {
                     $selected = "";
                     if (isset($params['model']) && strcasecmp($params['model'], $value) == 0) {
                         $selected = " selected";
                     }
                     if (!empty($this->productImpVariations) && !ISC_PRODUCT::CheckYMMUseVariation($value, $this->productImpVariations, 'model')) {
                         continue;
                     }
                     $options .= "<option value='" . MakeURLSafe(strtolower($value)) . "'{$selected}>{$value}</option>";
                 }
             }
             break;
     }
     return $options;
 }
Пример #2
0
 public function GetYmmsForDialogPage()
 {
     $ymmtype = strtolower(MakeURLNormal(isset($_GET['ymmtype']) ? $_GET['ymmtype'] : ""));
     $year = strtolower(MakeURLNormal(isset($_GET['year']) ? $_GET['year'] : ""));
     $make = strtolower(MakeURLNormal(isset($_GET['make']) ? $_GET['make'] : ""));
     $model = strtolower(MakeURLNormal(isset($_GET['model']) ? $_GET['model'] : ""));
     $productId = isset($_GET['productId']) ? (int) $_GET['productId'] : 0;
     $isDialogPQVQ = isset($_GET['isDialogPQVQ']) ? (int) $_GET['isDialogPQVQ'] : 0;
     $output = "";
     $array_str = $impvaritions = array();
     if ($productId) {
         $impvaritions = ISC_PRODUCT::GetImpVariationForYMM($productId, $ymmtype, '', '', '');
     }
     foreach (array('make', 'model', 'year') as $column) {
         $tmp = '';
         $array_str[$column] = "<option value=''>--select {$column}--</option>";
         $ymms_array = $this->getResultArray($column, $year, $make, $model, $productId);
         if ($column == 'model' and empty($ymms_array)) {
             $ymms_array = $this->getResultArray($column, "", $make, $model, $productId);
         }
         switch ($column) {
             case 'year':
                 $tmp = $year;
                 break;
             case 'make':
                 $tmp = $make;
                 break;
             default:
                 $tmp = $model;
                 break;
         }
         foreach ($ymms_array as $value) {
             $selected = "";
             if ($tmp == strtolower($value)) {
                 $selected = "selected";
             }
             if (empty($impvaritions) && !ISC_PRODUCT::CheckYMMUseVariation($value, $impvaritions, $column)) {
                 continue;
             }
             $array_str[$column] .= "<option value='" . strtoupper($value) . "' {$selected}>{$value}</option>";
         }
         //alandy_2012-2-20 add redirct option.
         if ($isDialogPQVQ == 1) {
             $array_str[$column] .= "<option value=1>My " . ucwords($column) . " Not Showing Here</option>";
         }
     }
     if ($ymmtype == "make") {
         $output = $array_str['model'] . '~' . $array_str['year'];
     } elseif ($ymmtype == "year") {
         $output = $array_str['make'] . '~' . $array_str['model'];
     } elseif ($ymmtype == "model") {
         $output = $array_str['year'];
     } else {
     }
     return $output;
 }