Commit 865abfaf1eef4a3d012e3965af926f864c6658e5

Authored by andryeyev
1 parent 3052fe2e

+ fix фильтров по полу и размеру

Showing 1 changed file with 377 additions and 201 deletions   Show diff stats
libs/catalogs.class.php
... ... @@ -1075,7 +1075,7 @@ function SaveProduct ($data, $upload)
1075 1075 //$search[] = sprintf("catalogs_keys_products_filters.filter_id='%d'", $params['filterID']);
1076 1076 $search[] = "catalogs_keys_products_filters.filter_id in (".implode(",",$params['filterID']).")";
1077 1077 }*/
1078   -
  1078 +
1079 1079 if(isset($filter['f']) && count($filter['f'])>0){
1080 1080 $search[] = "catalogs_keys_products_filters.filter_id in (".implode(",",$filter['f']).")";
1081 1081 }
... ... @@ -1139,25 +1139,30 @@ function SaveProduct ($data, $upload)
1139 1139 'spacesBeforeSeparator' => 1,
1140 1140 'spacesAfterSeparator' => 1
1141 1141 );
1142   - //echo $sql;
1143   - //$sql="";
1144   - $res = Pager_Wrapper_DB($this->db, $sql, $pagerOptions, false, DB_FETCHMODE_ASSOC, array());
1145   -
1146   -//if($_GET['test']=='1')
1147   -for($i=0;$i<count($res['data']);$i++){
1148   - $res['data'][$i]['mod'] = $this->db->getRow('select * from catalogs_modifications where product_id=? and active=1 Order By id Asc',array($res['data'][$i]['id']),DB_FETCHMODE_ASSOC);
1149   - $res['data'][$i]['ph1'] = $this->getFilterPh1($res['data'][$i]['id'],$lang);
1150   -
1151   - $res['data'][$i]['rating2'] = $res['data'][$i]['rating'];
1152   - if( @$res['data'][$i]['rating'] ) $res['data'][$i]['rating'] = round( (@$res['data'][$i]['rating'] / @$res['data'][$i]['vote_num']), 0 );
1153   - else $res['data'][$i]['rating'] = 0;
1154   - $res['data'][$i]['rating'] = @$res['data'][$i]['rating'] * 17;
1155   -}
1156   -
1157   -//if($_GET['test']=='1') print_r($res);
1158   -
1159   - $this->tpl->assign('productsData', $res);
1160   - return $res;
  1142 + // echo $sql;
  1143 + // $sql="";
  1144 + $res = Pager_Wrapper_DB ($this->db, $sql, $pagerOptions, false, DB_FETCHMODE_ASSOC, array ());
  1145 + if (! empty ($res))
  1146 + {
  1147 + // if($_GET['test']=='1')
  1148 + for ($i = 0; $i < count ($res['data']); $i ++)
  1149 + {
  1150 + $res['data'][$i]['mod'] = $this->db->getRow ('select * from catalogs_modifications where product_id=? and active=1 Order By id Asc', array (
  1151 + $res['data'][$i]['id']
  1152 + ), DB_FETCHMODE_ASSOC);
  1153 + $res['data'][$i]['ph1'] = $this->getFilterPh1 ($res['data'][$i]['id'], $lang);
  1154 +
  1155 + $res['data'][$i]['rating2'] = $res['data'][$i]['rating'];
  1156 + if (@$res['data'][$i]['rating'])
  1157 + $res['data'][$i]['rating'] = round ((@$res['data'][$i]['rating'] / @$res['data'][$i]['vote_num']), 0);
  1158 + else
  1159 + $res['data'][$i]['rating'] = 0;
  1160 + $res['data'][$i]['rating'] = @$res['data'][$i]['rating'] * 17;
  1161 + }
  1162 + }
  1163 +
  1164 + $this->tpl->assign ('productsData', $res);
  1165 + return $res;
1161 1166 }
1162 1167  
1163 1168 function getFilterPh1($product_id,$lang = 'ru'){
... ... @@ -2158,54 +2163,96 @@ $row = $row2;
2158 2163 $this->tpl->assign('product_years',$row);
2159 2164 }
2160 2165  
2161   - function viewYears($rubric_id,$filters = null){
2162   - $search = array();
2163   - if(isset($_GET['filter']) && count($_GET['filter'])>0)$filter = $this->seralizeFilter($_GET['filter']);
2164   - if(isset($filter['f']) && count($filter['f'])>0){
2165   - $search[] = "catalogs_keys_products_filters.filter_id in (".implode(",",$filter['f']).")";
2166   - }
2167   - if(isset($filter['s']) && count($filter['s'])>0){
2168   - $search[] = "catalogs_modifications.size in (".implode(",",$filter['s']).")";
2169   - }
2170   - if(isset($filter['r']) && count($filter['r'])>0){
2171   - $search[] = "m2.rost in (".implode(",",$filter['r']).")";
2172   - }
  2166 +function viewYears ($rubric_id, $filters = null)
  2167 +{
  2168 + $search = array ();
2173 2169  
  2170 + if (isset ($_GET['filter']) && count ($_GET['filter']) > 0)
  2171 + $filter = $this->seralizeFilter ($_GET['filter']);
2174 2172  
2175   - if(isset($_GET['new']) && $_GET['new']>0)$search[] = sprintf("p.active='%d'",$_GET['new']);
2176   - if(isset($_GET['top']) && $_GET['top']>0)$search[] = sprintf("p.top='%d'",$_GET['top']);
2177   -if(isset($_GET['akciiID']) && $_GET['akciiID']>0)$search[] = sprintf("p.akcii_id>'%d'",0);
2178   -
2179   - if(isset($_GET['brend']) && strlen($_GET['brend'])>0)$search[] = "p.brend_id in(".implode(",",$this->getBrendIDs_name($_GET['brend'])).")";
2180   -/* if(isset($_GET['sex']) && strlen($_GET['sex'])>0){
2181   - $sex = array('male'=>1,'female'=>2,'child'=>3,'unisex'=>4);
2182   - $search[] = sprintf("p.sex='%d'",$sex[$_GET['sex']]);
2183   - } */
2184   - if(isset($_GET['sex']) && strlen($_GET['sex'])>0){
2185   - $sex = $this->seralizeSex($_GET['sex']);
2186   - $search[] = "s.sex IN (" . implode(",",$sex) . ")";
2187   - }
  2173 + if (isset ($filter['f']) && count ($filter['f']) > 0)
  2174 + {
  2175 + $search[] = "catalogs_keys_products_filters.filter_id in (" . implode (",", $filter['f']) . ")";
  2176 + }
2188 2177  
2189   - if(strlen($filters)>0 && !isset($filter['f'])){
2190   - $search[] = "catalogs_keys_products_filters.filter_id in (".$filters.")";
2191   - }
2192   -
2193   - $sql = "select y.* from catalogs_products p, catalogs_keys_products_years k LEFT JOIN catalogs_years y ON y.id=k.year_id ";
2194   - if(isset($filter['f']) && count($filter['f'])>0)$sql .= "LEFT JOIN catalogs_keys_products_filters ON catalogs_keys_products_filters.product_id=k.product_id ";
2195   - if(isset($filter['s']) && count($filter['s'])>0){$sql .= "LEFT JOIN catalogs_modifications ON catalogs_modifications.product_id=k.product_id and catalogs_modifications.active=1 ";}
2196   - if(isset($filter['r']) && count($filter['r'])>0){$sql .= "LEFT JOIN catalogs_modifications m2 ON m2.product_id=k.product_id and m2.active=1 ";}
2197   - if(strlen($filters)>0 && !isset($filter['f'])){
2198   - $sql .= "LEFT JOIN catalogs_keys_products_filters ON catalogs_keys_products_filters.product_id=k.product_id ";
2199   - }
2200   - if(isset($_GET['sex']) && strlen($_GET['sex'])>0){$sql .= "LEFT JOIN catalogs_keys_products_sex s ON s.product_id=k.product_id ";}
2201   - $sql .= "where p.id=k.product_id and p.count_modifications>0 ";
2202   - if($filters==null)$sql .= " and p.rubric_id='".$rubric_id."' ";
2203   - if(count($search))$sql .= "AND " . implode(" AND ",$search) . " ";
2204   - $sql .= " GROUP BY k.year_id order by y.name desc";
2205   - // print $sql;
2206   - $row = $this->db->getAll($sql,array(),DB_FETCHMODE_ASSOC);
2207   - $this->tpl->assign('years', $row);
2208   - }
  2178 + if (isset ($filter['s']) && count ($filter['s']) > 0)
  2179 + {
  2180 + $search[] = "catalogs_modifications.size in (" . implode (",", $filter['s']) . ")";
  2181 + }
  2182 +
  2183 + if (isset ($filter['r']) && count ($filter['r']) > 0)
  2184 + {
  2185 + $search[] = "m2.rost in (" . implode (",", $filter['r']) . ")";
  2186 + }
  2187 +
  2188 + if (isset ($_GET['new']) && $_GET['new'] > 0)
  2189 + $search[] = sprintf ("p.active='%d'", $_GET['new']);
  2190 +
  2191 + if (isset ($_GET['top']) && $_GET['top'] > 0)
  2192 + $search[] = sprintf ("p.top='%d'", $_GET['top']);
  2193 +
  2194 + if (isset ($_GET['akciiID']) && $_GET['akciiID'] > 0)
  2195 + $search[] = sprintf ("p.akcii_id>'%d'", 0);
  2196 +
  2197 + if (isset ($_GET['brend']) && strlen ($_GET['brend']) > 0)
  2198 + $search[] = "p.brend_id in(" . implode (",", $this->getBrendIDs_name ($_GET['brend'])) . ")";
  2199 +
  2200 + /**
  2201 + * if(isset($_GET['sex']) && strlen($_GET['sex'])>0){
  2202 + * $sex = array('male'=>1,'female'=>2,'child'=>3,'unisex'=>4);
  2203 + * $search[] = sprintf("p.sex='%d'",$sex[$_GET['sex']]);
  2204 + * }
  2205 + */
  2206 + if (isset ($_GET['sex']) && strlen ($_GET['sex']) > 0)
  2207 + {
  2208 + $sex = $this->seralizeSex ($_GET['sex']);
  2209 + $search[] = "s.sex IN (" . implode (",", $sex) . ")";
  2210 + }
  2211 +
  2212 + if (strlen ($filters) > 0 && ! isset ($filter['f']))
  2213 + {
  2214 + $search[] = "catalogs_keys_products_filters.filter_id in (" . $filters . ")";
  2215 + }
  2216 +
  2217 + $sql = "select y.* from catalogs_products p, catalogs_keys_products_years k LEFT JOIN catalogs_years y ON y.id=k.year_id ";
  2218 +
  2219 + if (isset ($filter['f']) && count ($filter['f']) > 0)
  2220 + $sql .= "LEFT JOIN catalogs_keys_products_filters ON catalogs_keys_products_filters.product_id=k.product_id ";
  2221 +
  2222 + if (isset ($filter['s']) && count ($filter['s']) > 0)
  2223 + {
  2224 + $sql .= "LEFT JOIN catalogs_modifications ON catalogs_modifications.product_id=k.product_id and catalogs_modifications.active=1 ";
  2225 + }
  2226 +
  2227 + if (isset ($filter['r']) && count ($filter['r']) > 0)
  2228 + {
  2229 + $sql .= "LEFT JOIN catalogs_modifications m2 ON m2.product_id=k.product_id and m2.active=1 ";
  2230 + }
  2231 +
  2232 + if (strlen ($filters) > 0 && ! isset ($filter['f']))
  2233 + {
  2234 + $sql .= "LEFT JOIN catalogs_keys_products_filters ON catalogs_keys_products_filters.product_id=k.product_id ";
  2235 + }
  2236 +
  2237 + if (isset ($_GET['sex']) && strlen ($_GET['sex']) > 0)
  2238 + {
  2239 + $sql .= "LEFT JOIN catalogs_keys_products_sex s ON s.product_id=k.product_id ";
  2240 + }
  2241 +
  2242 + $sql .= "where p.id=k.product_id and p.count_modifications>0 ";
  2243 +
  2244 + if ($filters == null)
  2245 + $sql .= " and p.rubric_id='" . $rubric_id . "' ";
  2246 +
  2247 + if (count ($search))
  2248 + $sql .= "AND " . implode (" AND ", $search) . " ";
  2249 +
  2250 + $sql .= " GROUP BY k.year_id order by y.name desc";
  2251 +
  2252 + // print $sql;
  2253 + $row = $this->db->getAll ($sql, array (), DB_FETCHMODE_ASSOC);
  2254 + $this->tpl->assign ('years', $row);
  2255 +}
2209 2256  
2210 2257 function viewYearsAll($rubric_id){
2211 2258 $sql = "SELECT * FROM catalogs_years WHERE rubric_id=? ORDER BY id asc ";
... ... @@ -2223,67 +2270,125 @@ if(isset($_GET[&#39;akciiID&#39;]) &amp;&amp; $_GET[&#39;akciiID&#39;]&gt;0)$search[] = sprintf(&quot;p.akcii_id
2223 2270 $sql = "select sex from catalogs_keys_products_sex where product_id=?";
2224 2271 $row = $this->db->getCol($sql,"sex",array($id));
2225 2272 $this->tpl->assign('product_sex',$row);
2226   - }
  2273 + }
2227 2274  
2228   - function viewSex($rubric_id,$filters = null,$lang = 'rus'){
2229   - $search = array();
2230   - if(isset($_GET['filter']) && count($_GET['filter'])>0)$filter = $this->seralizeFilter($_GET['filter']);
2231   - if(isset($filter['f']) && count($filter['f'])>0){
2232   - $search[] = "catalogs_keys_products_filters.filter_id in (".implode(",",$filter['f']).")";
2233   - }
2234   - if(isset($filter['y']) && $filter['y']>0){
2235   - $search[] = "catalogs_keys_products_years.year_id in (".implode(",",$filter['y']).")";
2236   - }
2237   - if(isset($filter['s']) && count($filter['s'])>0){
2238   - $search[] = "catalogs_modifications.size in (".implode(",",$filter['s']).")";
2239   - }
2240   - if(isset($filter['r']) && count($filter['r'])>0){
2241   - $search[] = "m2.rost in (".implode(",",$filter['r']).")";
2242   - }
2243   - if(isset($_GET['new']) && $_GET['new']>0)$search[] = sprintf("p.active='%d'",$_GET['new']);
2244   - if(isset($_GET['top']) && $_GET['top']>0)$search[] = sprintf("p.top='%d'",$_GET['top']);
2245   -if(isset($_GET['akciiID']) && $_GET['akciiID']>0)$search[] = sprintf("p.akcii_id>'%d'",0);
2246   -
2247   - if(strlen($filters)>0 && !isset($filter['f'])){
2248   - $search[] = "catalogs_keys_products_filters.filter_id in (".$filters.")";
2249   - }
2250   -
2251   - if(isset($_GET['brend']) && strlen($_GET['brend'])>0)$search[] = "p.brend_id in(".implode(",",$this->getBrendIDs_name($_GET['brend'])).")";
2252   -
2253   - $sql = "select s.sex from catalogs_products p LEFT JOIN catalogs_keys_products_sex s ON s.product_id=p.id ";
2254   - if(isset($filter['f']) && count($filter['f'])>0)$sql .= "LEFT JOIN catalogs_keys_products_filters ON catalogs_keys_products_filters.product_id=p.id ";
2255   - if(isset($filter['y']) && $filter['y']>0)$sql .= "LEFT JOIN catalogs_keys_products_years ON catalogs_keys_products_years.product_id=p.id ";
2256   - if(isset($filter['s']) && count($filter['s'])>0){$sql .= "LEFT JOIN catalogs_modifications ON catalogs_modifications.product_id=p.id and catalogs_modifications.active=1 ";}
2257   - if(isset($filter['r']) && count($filter['r'])>0){$sql .= "LEFT JOIN catalogs_modifications m2 ON m2.product_id=p.id and m2.active=1 ";}
2258   - if(strlen($filters)>0 && !isset($filter['f'])){
2259   - $sql .= "LEFT JOIN catalogs_keys_products_filters ON catalogs_keys_products_filters.product_id=p.id ";
2260   - }
2261   - $sql .= "where p.count_modifications>0 and s.sex<4 ";
2262   - if($filters==null)$sql .= " and p.rubric_id='".$rubric_id."' ";
2263   - if(count($search))$sql .= "AND " . implode(" AND ",$search) . " ";
2264   - $sql .= " GROUP BY s.sex";
2265   - // print $sql;
2266   - $res = $this->db->getAll($sql,array(),DB_FETCHMODE_ASSOC);
2267   - // print_r($res);
2268   - $sex = array();
2269   - if($lang=='ukr')
2270   - $arr = array(1=>array('name'=>"×îëîâ³÷èé",'link'=>'male'),
2271   - 2=>array('name'=>"Ƴíî÷èé",'link'=>'female'),
2272   - 3=>array('name'=>"Äèòÿ÷èé",'link'=>'child'),
2273   - // 4=>array('name'=>"Óí³ñåêñ",'link'=>'unisex')
2274   - );
2275   - else
2276   - $arr = array(1=>array('name'=>"Ìóæñêîé",'link'=>'male'),
2277   - 2=>array('name'=>"Æåíñêèé",'link'=>'female'),
2278   - 3=>array('name'=>"Äåòñêèé",'link'=>'child'),
2279   - // 4=>array('name'=>"Óíèñåêñ",'link'=>'unisex')
2280   - );
2281   - foreach($res as $row){
2282   - $sex[] = $arr[$row['sex']];
2283   - }
2284   - if(isset($_GET['s']))print_r($sex);
2285   - $this->tpl->assign('sex', $sex);
2286   - }
  2275 +function viewSex ($rubric_id, $filters = null, $lang = 'rus')
  2276 +{
  2277 + $search = array ();
  2278 +
  2279 + if (isset ($_GET['filter']) && count ($_GET['filter']) > 0)
  2280 + $filter = $this->seralizeFilter ($_GET['filter']);
  2281 +
  2282 + if (isset ($filter['f']) && count ($filter['f']) > 0)
  2283 + {
  2284 + $search[] = "catalogs_keys_products_filters.filter_id in (" . implode (",", $filter['f']) . ")";
  2285 + }
  2286 + if (isset ($filter['y']) && $filter['y'] > 0)
  2287 + {
  2288 + $search[] = "catalogs_keys_products_years.year_id in (" . implode (",", $filter['y']) . ")";
  2289 + }
  2290 + if (isset ($filter['s']) && count ($filter['s']) > 0)
  2291 + {
  2292 + $search[] = "catalogs_modifications.size in (" . implode (",", $filter['s']) . ")";
  2293 + }
  2294 + if (isset ($filter['r']) && count ($filter['r']) > 0)
  2295 + {
  2296 + $search[] = "m2.rost in (" . implode (",", $filter['r']) . ")";
  2297 + }
  2298 + if (isset ($_GET['new']) && $_GET['new'] > 0)
  2299 + $search[] = sprintf ("p.active='%d'", $_GET['new']);
  2300 + if (isset ($_GET['top']) && $_GET['top'] > 0)
  2301 + $search[] = sprintf ("p.top='%d'", $_GET['top']);
  2302 + if (isset ($_GET['akciiID']) && $_GET['akciiID'] > 0)
  2303 + $search[] = sprintf ("p.akcii_id>'%d'", 0);
  2304 +
  2305 + if (strlen ($filters) > 0 && ! isset ($filter['f']))
  2306 + {
  2307 + $search[] = "catalogs_keys_products_filters.filter_id in (" . $filters . ")";
  2308 + }
  2309 +
  2310 + if (isset ($_GET['brend']) && strlen ($_GET['brend']) > 0)
  2311 + $search[] = "p.brend_id in(" . implode (",", $this->getBrendIDs_name ($_GET['brend'])) . ")";
  2312 +
  2313 + $sql = "select s.sex from catalogs_products p LEFT JOIN catalogs_keys_products_sex s ON s.product_id=p.id ";
  2314 +
  2315 + if (isset ($filter['f']) && count ($filter['f']) > 0)
  2316 + $sql .= "LEFT JOIN catalogs_keys_products_filters ON catalogs_keys_products_filters.product_id=p.id ";
  2317 + if (isset ($filter['y']) && $filter['y'] > 0)
  2318 + $sql .= "LEFT JOIN catalogs_keys_products_years ON catalogs_keys_products_years.product_id=p.id ";
  2319 + if (isset ($filter['s']) && count ($filter['s']) > 0)
  2320 + {
  2321 + $sql .= "LEFT JOIN catalogs_modifications ON catalogs_modifications.product_id=p.id and catalogs_modifications.active=1 ";
  2322 + }
  2323 + if (isset ($filter['r']) && count ($filter['r']) > 0)
  2324 + {
  2325 + $sql .= "LEFT JOIN catalogs_modifications m2 ON m2.product_id=p.id and m2.active=1 ";
  2326 + }
  2327 + if (strlen ($filters) > 0 && ! isset ($filter['f']))
  2328 + {
  2329 + $sql .= "LEFT JOIN catalogs_keys_products_filters ON catalogs_keys_products_filters.product_id=p.id ";
  2330 + }
  2331 +
  2332 + $sql .= "where p.count_modifications>0
  2333 + and s.sex < 4
  2334 + and p.sex > 0
  2335 + ";
  2336 +
  2337 + if ($filters == null)
  2338 + $sql .= " and p.rubric_id='" . $rubric_id . "' ";
  2339 + if (count ($search))
  2340 + $sql .= "AND " . implode (" AND ", $search) . " ";
  2341 +
  2342 + $sql .= " GROUP BY s.sex";
  2343 + // print $sql;
  2344 + $res = $this->db->getAll ($sql, array (), DB_FETCHMODE_ASSOC);
  2345 + // print_r($res);
  2346 + $sex = array ();
  2347 + if ($lang == 'ukr')
  2348 + $arr = array (
  2349 + 1 => array (
  2350 + 'name' => "×îëîâ³÷èé",
  2351 + 'link' => 'male'
  2352 + ),
  2353 + 2 => array (
  2354 + 'name' => "Ƴíî÷èé",
  2355 + 'link' => 'female'
  2356 + ),
  2357 + 3 => array (
  2358 + 'name' => "Äèòÿ÷èé",
  2359 + 'link' => 'child'
  2360 + )
  2361 + )
  2362 + // 4=>array('name'=>"Óí³ñåêñ",'link'=>'unisex')
  2363 + ;
  2364 + else
  2365 + $arr = array (
  2366 + 1 => array (
  2367 + 'name' => "Ìóæñêîé",
  2368 + 'link' => 'male'
  2369 + ),
  2370 + 2 => array (
  2371 + 'name' => "Æåíñêèé",
  2372 + 'link' => 'female'
  2373 + ),
  2374 + 3 => array (
  2375 + 'name' => "Äåòñêèé",
  2376 + 'link' => 'child'
  2377 + )
  2378 + )
  2379 + // 4=>array('name'=>"Óíèñåêñ",'link'=>'unisex')
  2380 + ;
  2381 +
  2382 + foreach ($res as $row)
  2383 + {
  2384 + $sex[] = $arr[$row['sex']];
  2385 + }
  2386 +
  2387 + if (isset ($_GET['s']))
  2388 + print_r ($sex);
  2389 +
  2390 + $this->tpl->assign ('sex', $sex);
  2391 +}
2287 2392  
2288 2393 function getYearsName_IDs($ids){
2289 2394 //$sql = "select name from catalogs_years where id in (".implode(",",$ids).") order by name";
... ... @@ -2535,83 +2640,154 @@ if(isset($_GET[&#39;akciiID&#39;]) &amp;&amp; $_GET[&#39;akciiID&#39;]&gt;0)$search[] = sprintf(&quot;p.akcii_id
2535 2640 return implode(", ",$name);
2536 2641 }
2537 2642  
2538   - function viewFiltersMod($rubric_id){
2539   - $search = array();
2540   - if(isset($_GET['filter']) && count($_GET['filter'])>0)$filter = $this->seralizeFilter($_GET['filter']);
2541   - if(isset($filter['f']) && count($filter['f'])>0){
2542   - $search[] = "catalogs_keys_products_filters.filter_id in (".implode(",",$filter['f']).")";
2543   - }
2544   - if(isset($filter['y']) && $filter['y']>0){
2545   - $search[] = "catalogs_keys_products_years.year_id in (".implode(",",$filter['y']).")";
2546   - }
2547   - if(isset($filter['r']) && count($filter['r'])>0){
2548   - $search[] = "m2.rost in (".implode(",",$filter['r']).")";
2549   - }
2550   -
2551   - if(isset($_GET['brend']) && strlen($_GET['brend'])>0)$search[] = "p.brend_id in(".implode(",",$this->getBrendIDs_name($_GET['brend'])).")";
2552   -/* if(isset($_GET['sex']) && strlen($_GET['sex'])>0){
2553   - $sex = array('male'=>1,'female'=>2,'child'=>3,'unisex'=>4);
2554   - $search[] = sprintf("p.sex='%d'",$sex[$_GET['sex']]);
2555   - } */
2556   - if(isset($_GET['sex']) && strlen($_GET['sex'])>0){
2557   - $sex = $this->seralizeSex($_GET['sex']);
2558   - $search[] = "p.sex IN (" . implode(",",$sex) . ")";
2559   - }
2560   - if(isset($_GET['new']) && $_GET['new']>0)$search[] = sprintf("p.active='%d'",$_GET['new']);
2561   - if(isset($_GET['top']) && $_GET['top']>0)$search[] = sprintf("p.top='%d'",$_GET['top']);
2562   -if(isset($_GET['akciiID']) && $_GET['akciiID']>0)$search[] = sprintf("p.akcii_id>'%d'",0);
2563   - $sql = "select m.* from catalogs_modifications m,catalogs_products p ";
2564   - if(isset($filter['f']) && count($filter['f'])>0)$sql .= "LEFT JOIN catalogs_keys_products_filters ON catalogs_keys_products_filters.product_id=p.id ";
2565   - if(isset($filter['y']) && $filter['y']>0)$sql .= "LEFT JOIN catalogs_keys_products_years ON catalogs_keys_products_years.product_id=p.id ";
2566   - if(isset($filter['r']) && count($filter['r'])>0){$sql .= "LEFT JOIN catalogs_modifications m2 ON m2.product_id=p.id and m2.active=1 ";}
2567   -
2568   - $sql .= "where m.size<>'' ";
2569   - if(count($search))$sql .= "AND " . implode(" AND ",$search) . " ";
2570   - $sql .= "and m.product_id=p.id and m.active=1 and p.rubric_id=? and p.count_modifications>0 GROUP BY m.size";
2571   - $row = $this->db->getAll($sql,array($rubric_id),DB_FETCHMODE_ASSOC);
2572   - if($_GET['t']==1){
2573   - print"<pre>";
2574   - print_r($row);
2575   - print"</pre>";
2576   - }
2577   - $this->tpl->assign('size', $row);
2578   - }
2579   -
2580   - function viewFiltersRost($rubric_id){
2581   - $search = array();
2582   - if(isset($_GET['filter']) && count($_GET['filter'])>0)$filter = $this->seralizeFilter($_GET['filter']);
2583   - if(isset($filter['f']) && count($filter['f'])>0){
2584   - $search[] = "catalogs_keys_products_filters.filter_id in (".implode(",",$filter['f']).")";
2585   - }
2586   - if(isset($filter['y']) && $filter['y']>0){
2587   - $search[] = "catalogs_keys_products_years.year_id in (".implode(",",$filter['y']).")";
2588   - }
  2643 + function viewFiltersMod ($rubric_id)
  2644 +{
  2645 + $search = array ();
  2646 +
  2647 + if (isset ($_GET['filter']) && count ($_GET['filter']) > 0)
  2648 + $filter = $this->seralizeFilter ($_GET['filter']);
  2649 +
  2650 + if (isset ($filter['f']) && count ($filter['f']) > 0)
  2651 + {
  2652 + $search[] = "catalogs_keys_products_filters.filter_id in (" . implode (",", $filter['f']) . ")";
  2653 + }
2589 2654  
2590   -
2591   - if(isset($_GET['brend']) && strlen($_GET['brend'])>0)$search[] = "p.brend_id in(".implode(",",$this->getBrendIDs_name($_GET['brend'])).")";
2592   -/* if(isset($_GET['sex']) && strlen($_GET['sex'])>0){
2593   - $sex = array('male'=>1,'female'=>2,'child'=>3,'unisex'=>4);
2594   - $search[] = sprintf("p.sex='%d'",$sex[$_GET['sex']]);
2595   - } */
2596   - if(isset($_GET['sex']) && strlen($_GET['sex'])>0){
2597   - $sex = $this->seralizeSex($_GET['sex']);
2598   - $search[] = "p.sex IN (" . implode(",",$sex) . ")";
2599   - }
2600   - $sql = "select m.* from catalogs_modifications m,catalogs_products p ";
2601   - if(isset($filter['f']) && count($filter['f'])>0)$sql .= "LEFT JOIN catalogs_keys_products_filters ON catalogs_keys_products_filters.product_id=p.id ";
2602   - if(isset($filter['y']) && $filter['y']>0)$sql .= "LEFT JOIN catalogs_keys_products_years ON catalogs_keys_products_years.product_id=p.id ";
2603   -
2604   - $sql .= "where m.rost<>'' ";
2605   - if(count($search))$sql .= "AND " . implode(" AND ",$search) . " ";
2606   - $sql .= "and m.product_id=p.id and m.active=1 and p.rubric_id=? and p.count_modifications>0 GROUP BY m.rost";
2607   - $row = $this->db->getAll($sql,array($rubric_id),DB_FETCHMODE_ASSOC);
2608   - if($_GET['t']==1){
2609   - print"<pre>";
2610   - print_r($row);
2611   - print"</pre>";
2612   - }
2613   - $this->tpl->assign('rost', $row);
2614   - }
  2655 + if (isset ($filter['y']) && $filter['y'] > 0)
  2656 + {
  2657 + $search[] = "catalogs_keys_products_years.year_id in (" . implode (",", $filter['y']) . ")";
  2658 + }
  2659 +
  2660 + if (isset ($filter['r']) && count ($filter['r']) > 0)
  2661 + {
  2662 + $search[] = "m2.rost in (" . implode (",", $filter['r']) . ")";
  2663 + }
  2664 +
  2665 + if (isset ($_GET['brend']) && strlen ($_GET['brend']) > 0)
  2666 + $search[] = "p.brend_id in(" . implode (",", $this->getBrendIDs_name ($_GET['brend'])) . ")";
  2667 + /*
  2668 + * if(isset($_GET['sex']) && strlen($_GET['sex'])>0){
  2669 + * $sex = array('male'=>1,'female'=>2,'child'=>3,'unisex'=>4);
  2670 + * $search[] = sprintf("p.sex='%d'",$sex[$_GET['sex']]);
  2671 + * }
  2672 + */
  2673 + if (isset ($_GET['sex']) && strlen ($_GET['sex']) > 0)
  2674 + {
  2675 + $sex = $this->seralizeSex ($_GET['sex']);
  2676 + $search[] = "p.sex IN (" . implode (",", $sex) . ")";
  2677 + }
  2678 +
  2679 + if (isset ($_GET['new']) && $_GET['new'] > 0)
  2680 + $search[] = sprintf ("p.active='%d'", $_GET['new']);
  2681 +
  2682 + if (isset ($_GET['top']) && $_GET['top'] > 0)
  2683 + $search[] = sprintf ("p.top='%d'", $_GET['top']);
  2684 +
  2685 + if (isset ($_GET['akciiID']) && $_GET['akciiID'] > 0)
  2686 + $search[] = sprintf ("p.akcii_id>'%d'", 0);
  2687 +
  2688 + $sql = "select m.* from catalogs_modifications m,catalogs_products p ";
  2689 + if (isset ($filter['f']) && count ($filter['f']) > 0)
  2690 + $sql .= "LEFT JOIN catalogs_keys_products_filters ON catalogs_keys_products_filters.product_id=p.id ";
  2691 +
  2692 + if (isset ($filter['y']) && $filter['y'] > 0)
  2693 + $sql .= "LEFT JOIN catalogs_keys_products_years ON catalogs_keys_products_years.product_id=p.id ";
  2694 +
  2695 + if (isset ($filter['r']) && count ($filter['r']) > 0)
  2696 + {
  2697 + $sql .= "LEFT JOIN catalogs_modifications m2 ON m2.product_id=p.id and m2.active=1 ";
  2698 + }
  2699 +
  2700 + $sql .= "where m.size<>'' ";
  2701 +
  2702 + if (count ($search))
  2703 + $sql .= "AND " . implode (" AND ", $search) . " ";
  2704 +
  2705 + $sql .= "
  2706 + and m.product_id=p.id
  2707 + and m.active=1
  2708 + and p.rubric_id=?
  2709 + and p.count_modifications>0
  2710 + and m.size > 0
  2711 + GROUP BY m.size";
  2712 + $row = $this->db->getAll ($sql, array (
  2713 + $rubric_id
  2714 + ), DB_FETCHMODE_ASSOC);
  2715 +
  2716 + if ($_GET['t'] == 1)
  2717 + {
  2718 + print "<pre>";
  2719 + print_r ($row);
  2720 + print "</pre>";
  2721 + }
  2722 +
  2723 + $this->tpl->assign ('size', $row);
  2724 +}
  2725 +
  2726 +function viewFiltersRost ($rubric_id)
  2727 +{
  2728 + $search = array ();
  2729 +
  2730 + if (isset ($_GET['filter']) && count ($_GET['filter']) > 0)
  2731 + $filter = $this->seralizeFilter ($_GET['filter']);
  2732 +
  2733 + if (isset ($filter['f']) && count ($filter['f']) > 0)
  2734 + {
  2735 + $search[] = "catalogs_keys_products_filters.filter_id in (" . implode (",", $filter['f']) . ")";
  2736 + }
  2737 +
  2738 + if (isset ($filter['y']) && $filter['y'] > 0)
  2739 + {
  2740 + $search[] = "catalogs_keys_products_years.year_id in (" . implode (",", $filter['y']) . ")";
  2741 + }
  2742 +
  2743 + if (isset ($_GET['brend']) && strlen ($_GET['brend']) > 0)
  2744 + $search[] = "p.brend_id in(" . implode (",", $this->getBrendIDs_name ($_GET['brend'])) . ")";
  2745 + /*
  2746 + * if(isset($_GET['sex']) && strlen($_GET['sex'])>0){
  2747 + * $sex = array('male'=>1,'female'=>2,'child'=>3,'unisex'=>4);
  2748 + * $search[] = sprintf("p.sex='%d'",$sex[$_GET['sex']]);
  2749 + * }
  2750 + */
  2751 + if (isset ($_GET['sex']) && strlen ($_GET['sex']) > 0)
  2752 + {
  2753 + $sex = $this->seralizeSex ($_GET['sex']);
  2754 + $search[] = "p.sex IN (" . implode (",", $sex) . ")";
  2755 + }
  2756 +
  2757 + $sql = "select m.* from catalogs_modifications m, catalogs_products p ";
  2758 +
  2759 + if (isset ($filter['f']) && count ($filter['f']) > 0)
  2760 + $sql .= "LEFT JOIN catalogs_keys_products_filters ON catalogs_keys_products_filters.product_id=p.id ";
  2761 +
  2762 + if (isset ($filter['y']) && $filter['y'] > 0)
  2763 + $sql .= "LEFT JOIN catalogs_keys_products_years ON catalogs_keys_products_years.product_id=p.id ";
  2764 +
  2765 + $sql .= "where m.rost<>'' ";
  2766 +
  2767 + if (count ($search))
  2768 + {
  2769 + $sql .= "AND " . implode (" AND ", $search) . " ";
  2770 + }
  2771 +
  2772 + $sql .= "
  2773 + and m.product_id=p.id
  2774 + and m.active=1
  2775 + and p.rubric_id=?
  2776 + and p.count_modifications>0
  2777 + GROUP BY m.rost";
  2778 + $row = $this->db->getAll ($sql, array (
  2779 + $rubric_id
  2780 + ), DB_FETCHMODE_ASSOC);
  2781 +
  2782 + if ($_GET['t'] == 1)
  2783 + {
  2784 + print "<pre>";
  2785 + print_r ($row);
  2786 + print "</pre>";
  2787 + }
  2788 +
  2789 + $this->tpl->assign ('rost', $row);
  2790 +}
2615 2791  
2616 2792 function viewRostProduct($id){
2617 2793 $sql = "select m.* from catalogs_modifications m where m.product_id=? GROUP BY m.rost";
... ...