From 865abfaf1eef4a3d012e3965af926f864c6658e5 Mon Sep 17 00:00:00 2001 From: andryeyev Date: Fri, 18 Dec 2015 17:09:25 +0200 Subject: [PATCH] + fix фильтров по полу и размеру --- libs/catalogs.class.php | 578 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 file changed, 377 insertions(+), 201 deletions(-) diff --git a/libs/catalogs.class.php b/libs/catalogs.class.php index 776d931..f2b827d 100644 --- a/libs/catalogs.class.php +++ b/libs/catalogs.class.php @@ -1075,7 +1075,7 @@ function SaveProduct ($data, $upload) //$search[] = sprintf("catalogs_keys_products_filters.filter_id='%d'", $params['filterID']); $search[] = "catalogs_keys_products_filters.filter_id in (".implode(",",$params['filterID']).")"; }*/ - + if(isset($filter['f']) && count($filter['f'])>0){ $search[] = "catalogs_keys_products_filters.filter_id in (".implode(",",$filter['f']).")"; } @@ -1139,25 +1139,30 @@ function SaveProduct ($data, $upload) 'spacesBeforeSeparator' => 1, 'spacesAfterSeparator' => 1 ); - //echo $sql; - //$sql=""; - $res = Pager_Wrapper_DB($this->db, $sql, $pagerOptions, false, DB_FETCHMODE_ASSOC, array()); - -//if($_GET['test']=='1') -for($i=0;$idb->getRow('select * from catalogs_modifications where product_id=? and active=1 Order By id Asc',array($res['data'][$i]['id']),DB_FETCHMODE_ASSOC); - $res['data'][$i]['ph1'] = $this->getFilterPh1($res['data'][$i]['id'],$lang); - - $res['data'][$i]['rating2'] = $res['data'][$i]['rating']; - if( @$res['data'][$i]['rating'] ) $res['data'][$i]['rating'] = round( (@$res['data'][$i]['rating'] / @$res['data'][$i]['vote_num']), 0 ); - else $res['data'][$i]['rating'] = 0; - $res['data'][$i]['rating'] = @$res['data'][$i]['rating'] * 17; -} - -//if($_GET['test']=='1') print_r($res); - - $this->tpl->assign('productsData', $res); - return $res; + // echo $sql; + // $sql=""; + $res = Pager_Wrapper_DB ($this->db, $sql, $pagerOptions, false, DB_FETCHMODE_ASSOC, array ()); + if (! empty ($res)) + { + // if($_GET['test']=='1') + for ($i = 0; $i < count ($res['data']); $i ++) + { + $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); + $res['data'][$i]['ph1'] = $this->getFilterPh1 ($res['data'][$i]['id'], $lang); + + $res['data'][$i]['rating2'] = $res['data'][$i]['rating']; + if (@$res['data'][$i]['rating']) + $res['data'][$i]['rating'] = round ((@$res['data'][$i]['rating'] / @$res['data'][$i]['vote_num']), 0); + else + $res['data'][$i]['rating'] = 0; + $res['data'][$i]['rating'] = @$res['data'][$i]['rating'] * 17; + } + } + + $this->tpl->assign ('productsData', $res); + return $res; } function getFilterPh1($product_id,$lang = 'ru'){ @@ -2158,54 +2163,96 @@ $row = $row2; $this->tpl->assign('product_years',$row); } - function viewYears($rubric_id,$filters = null){ - $search = array(); - if(isset($_GET['filter']) && count($_GET['filter'])>0)$filter = $this->seralizeFilter($_GET['filter']); - if(isset($filter['f']) && count($filter['f'])>0){ - $search[] = "catalogs_keys_products_filters.filter_id in (".implode(",",$filter['f']).")"; - } - if(isset($filter['s']) && count($filter['s'])>0){ - $search[] = "catalogs_modifications.size in (".implode(",",$filter['s']).")"; - } - if(isset($filter['r']) && count($filter['r'])>0){ - $search[] = "m2.rost in (".implode(",",$filter['r']).")"; - } +function viewYears ($rubric_id, $filters = null) +{ + $search = array (); + if (isset ($_GET['filter']) && count ($_GET['filter']) > 0) + $filter = $this->seralizeFilter ($_GET['filter']); - if(isset($_GET['new']) && $_GET['new']>0)$search[] = sprintf("p.active='%d'",$_GET['new']); - if(isset($_GET['top']) && $_GET['top']>0)$search[] = sprintf("p.top='%d'",$_GET['top']); -if(isset($_GET['akciiID']) && $_GET['akciiID']>0)$search[] = sprintf("p.akcii_id>'%d'",0); - - if(isset($_GET['brend']) && strlen($_GET['brend'])>0)$search[] = "p.brend_id in(".implode(",",$this->getBrendIDs_name($_GET['brend'])).")"; -/* if(isset($_GET['sex']) && strlen($_GET['sex'])>0){ - $sex = array('male'=>1,'female'=>2,'child'=>3,'unisex'=>4); - $search[] = sprintf("p.sex='%d'",$sex[$_GET['sex']]); - } */ - if(isset($_GET['sex']) && strlen($_GET['sex'])>0){ - $sex = $this->seralizeSex($_GET['sex']); - $search[] = "s.sex IN (" . implode(",",$sex) . ")"; - } + if (isset ($filter['f']) && count ($filter['f']) > 0) + { + $search[] = "catalogs_keys_products_filters.filter_id in (" . implode (",", $filter['f']) . ")"; + } - if(strlen($filters)>0 && !isset($filter['f'])){ - $search[] = "catalogs_keys_products_filters.filter_id in (".$filters.")"; - } - - $sql = "select y.* from catalogs_products p, catalogs_keys_products_years k LEFT JOIN catalogs_years y ON y.id=k.year_id "; - 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 "; - 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 ";} - 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 ";} - if(strlen($filters)>0 && !isset($filter['f'])){ - $sql .= "LEFT JOIN catalogs_keys_products_filters ON catalogs_keys_products_filters.product_id=k.product_id "; - } - if(isset($_GET['sex']) && strlen($_GET['sex'])>0){$sql .= "LEFT JOIN catalogs_keys_products_sex s ON s.product_id=k.product_id ";} - $sql .= "where p.id=k.product_id and p.count_modifications>0 "; - if($filters==null)$sql .= " and p.rubric_id='".$rubric_id."' "; - if(count($search))$sql .= "AND " . implode(" AND ",$search) . " "; - $sql .= " GROUP BY k.year_id order by y.name desc"; - // print $sql; - $row = $this->db->getAll($sql,array(),DB_FETCHMODE_ASSOC); - $this->tpl->assign('years', $row); - } + if (isset ($filter['s']) && count ($filter['s']) > 0) + { + $search[] = "catalogs_modifications.size in (" . implode (",", $filter['s']) . ")"; + } + + if (isset ($filter['r']) && count ($filter['r']) > 0) + { + $search[] = "m2.rost in (" . implode (",", $filter['r']) . ")"; + } + + if (isset ($_GET['new']) && $_GET['new'] > 0) + $search[] = sprintf ("p.active='%d'", $_GET['new']); + + if (isset ($_GET['top']) && $_GET['top'] > 0) + $search[] = sprintf ("p.top='%d'", $_GET['top']); + + if (isset ($_GET['akciiID']) && $_GET['akciiID'] > 0) + $search[] = sprintf ("p.akcii_id>'%d'", 0); + + if (isset ($_GET['brend']) && strlen ($_GET['brend']) > 0) + $search[] = "p.brend_id in(" . implode (",", $this->getBrendIDs_name ($_GET['brend'])) . ")"; + + /** + * if(isset($_GET['sex']) && strlen($_GET['sex'])>0){ + * $sex = array('male'=>1,'female'=>2,'child'=>3,'unisex'=>4); + * $search[] = sprintf("p.sex='%d'",$sex[$_GET['sex']]); + * } + */ + if (isset ($_GET['sex']) && strlen ($_GET['sex']) > 0) + { + $sex = $this->seralizeSex ($_GET['sex']); + $search[] = "s.sex IN (" . implode (",", $sex) . ")"; + } + + if (strlen ($filters) > 0 && ! isset ($filter['f'])) + { + $search[] = "catalogs_keys_products_filters.filter_id in (" . $filters . ")"; + } + + $sql = "select y.* from catalogs_products p, catalogs_keys_products_years k LEFT JOIN catalogs_years y ON y.id=k.year_id "; + + 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 "; + + 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 "; + } + + 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 "; + } + + if (strlen ($filters) > 0 && ! isset ($filter['f'])) + { + $sql .= "LEFT JOIN catalogs_keys_products_filters ON catalogs_keys_products_filters.product_id=k.product_id "; + } + + if (isset ($_GET['sex']) && strlen ($_GET['sex']) > 0) + { + $sql .= "LEFT JOIN catalogs_keys_products_sex s ON s.product_id=k.product_id "; + } + + $sql .= "where p.id=k.product_id and p.count_modifications>0 "; + + if ($filters == null) + $sql .= " and p.rubric_id='" . $rubric_id . "' "; + + if (count ($search)) + $sql .= "AND " . implode (" AND ", $search) . " "; + + $sql .= " GROUP BY k.year_id order by y.name desc"; + + // print $sql; + $row = $this->db->getAll ($sql, array (), DB_FETCHMODE_ASSOC); + $this->tpl->assign ('years', $row); +} function viewYearsAll($rubric_id){ $sql = "SELECT * FROM catalogs_years WHERE rubric_id=? ORDER BY id asc "; @@ -2223,67 +2270,125 @@ if(isset($_GET['akciiID']) && $_GET['akciiID']>0)$search[] = sprintf("p.akcii_id $sql = "select sex from catalogs_keys_products_sex where product_id=?"; $row = $this->db->getCol($sql,"sex",array($id)); $this->tpl->assign('product_sex',$row); - } + } - function viewSex($rubric_id,$filters = null,$lang = 'rus'){ - $search = array(); - if(isset($_GET['filter']) && count($_GET['filter'])>0)$filter = $this->seralizeFilter($_GET['filter']); - if(isset($filter['f']) && count($filter['f'])>0){ - $search[] = "catalogs_keys_products_filters.filter_id in (".implode(",",$filter['f']).")"; - } - if(isset($filter['y']) && $filter['y']>0){ - $search[] = "catalogs_keys_products_years.year_id in (".implode(",",$filter['y']).")"; - } - if(isset($filter['s']) && count($filter['s'])>0){ - $search[] = "catalogs_modifications.size in (".implode(",",$filter['s']).")"; - } - if(isset($filter['r']) && count($filter['r'])>0){ - $search[] = "m2.rost in (".implode(",",$filter['r']).")"; - } - if(isset($_GET['new']) && $_GET['new']>0)$search[] = sprintf("p.active='%d'",$_GET['new']); - if(isset($_GET['top']) && $_GET['top']>0)$search[] = sprintf("p.top='%d'",$_GET['top']); -if(isset($_GET['akciiID']) && $_GET['akciiID']>0)$search[] = sprintf("p.akcii_id>'%d'",0); - - if(strlen($filters)>0 && !isset($filter['f'])){ - $search[] = "catalogs_keys_products_filters.filter_id in (".$filters.")"; - } - - if(isset($_GET['brend']) && strlen($_GET['brend'])>0)$search[] = "p.brend_id in(".implode(",",$this->getBrendIDs_name($_GET['brend'])).")"; - - $sql = "select s.sex from catalogs_products p LEFT JOIN catalogs_keys_products_sex s ON s.product_id=p.id "; - if(isset($filter['f']) && count($filter['f'])>0)$sql .= "LEFT JOIN catalogs_keys_products_filters ON catalogs_keys_products_filters.product_id=p.id "; - if(isset($filter['y']) && $filter['y']>0)$sql .= "LEFT JOIN catalogs_keys_products_years ON catalogs_keys_products_years.product_id=p.id "; - 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 ";} - if(isset($filter['r']) && count($filter['r'])>0){$sql .= "LEFT JOIN catalogs_modifications m2 ON m2.product_id=p.id and m2.active=1 ";} - if(strlen($filters)>0 && !isset($filter['f'])){ - $sql .= "LEFT JOIN catalogs_keys_products_filters ON catalogs_keys_products_filters.product_id=p.id "; - } - $sql .= "where p.count_modifications>0 and s.sex<4 "; - if($filters==null)$sql .= " and p.rubric_id='".$rubric_id."' "; - if(count($search))$sql .= "AND " . implode(" AND ",$search) . " "; - $sql .= " GROUP BY s.sex"; - // print $sql; - $res = $this->db->getAll($sql,array(),DB_FETCHMODE_ASSOC); - // print_r($res); - $sex = array(); - if($lang=='ukr') - $arr = array(1=>array('name'=>"×îëîâ³÷èé",'link'=>'male'), - 2=>array('name'=>"Ƴíî÷èé",'link'=>'female'), - 3=>array('name'=>"Äèòÿ÷èé",'link'=>'child'), - // 4=>array('name'=>"Óí³ñåêñ",'link'=>'unisex') - ); - else - $arr = array(1=>array('name'=>"Ìóæñêîé",'link'=>'male'), - 2=>array('name'=>"Æåíñêèé",'link'=>'female'), - 3=>array('name'=>"Äåòñêèé",'link'=>'child'), - // 4=>array('name'=>"Óíèñåêñ",'link'=>'unisex') - ); - foreach($res as $row){ - $sex[] = $arr[$row['sex']]; - } - if(isset($_GET['s']))print_r($sex); - $this->tpl->assign('sex', $sex); - } +function viewSex ($rubric_id, $filters = null, $lang = 'rus') +{ + $search = array (); + + if (isset ($_GET['filter']) && count ($_GET['filter']) > 0) + $filter = $this->seralizeFilter ($_GET['filter']); + + if (isset ($filter['f']) && count ($filter['f']) > 0) + { + $search[] = "catalogs_keys_products_filters.filter_id in (" . implode (",", $filter['f']) . ")"; + } + if (isset ($filter['y']) && $filter['y'] > 0) + { + $search[] = "catalogs_keys_products_years.year_id in (" . implode (",", $filter['y']) . ")"; + } + if (isset ($filter['s']) && count ($filter['s']) > 0) + { + $search[] = "catalogs_modifications.size in (" . implode (",", $filter['s']) . ")"; + } + if (isset ($filter['r']) && count ($filter['r']) > 0) + { + $search[] = "m2.rost in (" . implode (",", $filter['r']) . ")"; + } + if (isset ($_GET['new']) && $_GET['new'] > 0) + $search[] = sprintf ("p.active='%d'", $_GET['new']); + if (isset ($_GET['top']) && $_GET['top'] > 0) + $search[] = sprintf ("p.top='%d'", $_GET['top']); + if (isset ($_GET['akciiID']) && $_GET['akciiID'] > 0) + $search[] = sprintf ("p.akcii_id>'%d'", 0); + + if (strlen ($filters) > 0 && ! isset ($filter['f'])) + { + $search[] = "catalogs_keys_products_filters.filter_id in (" . $filters . ")"; + } + + if (isset ($_GET['brend']) && strlen ($_GET['brend']) > 0) + $search[] = "p.brend_id in(" . implode (",", $this->getBrendIDs_name ($_GET['brend'])) . ")"; + + $sql = "select s.sex from catalogs_products p LEFT JOIN catalogs_keys_products_sex s ON s.product_id=p.id "; + + if (isset ($filter['f']) && count ($filter['f']) > 0) + $sql .= "LEFT JOIN catalogs_keys_products_filters ON catalogs_keys_products_filters.product_id=p.id "; + if (isset ($filter['y']) && $filter['y'] > 0) + $sql .= "LEFT JOIN catalogs_keys_products_years ON catalogs_keys_products_years.product_id=p.id "; + 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 "; + } + if (isset ($filter['r']) && count ($filter['r']) > 0) + { + $sql .= "LEFT JOIN catalogs_modifications m2 ON m2.product_id=p.id and m2.active=1 "; + } + if (strlen ($filters) > 0 && ! isset ($filter['f'])) + { + $sql .= "LEFT JOIN catalogs_keys_products_filters ON catalogs_keys_products_filters.product_id=p.id "; + } + + $sql .= "where p.count_modifications>0 + and s.sex < 4 + and p.sex > 0 + "; + + if ($filters == null) + $sql .= " and p.rubric_id='" . $rubric_id . "' "; + if (count ($search)) + $sql .= "AND " . implode (" AND ", $search) . " "; + + $sql .= " GROUP BY s.sex"; + // print $sql; + $res = $this->db->getAll ($sql, array (), DB_FETCHMODE_ASSOC); + // print_r($res); + $sex = array (); + if ($lang == 'ukr') + $arr = array ( + 1 => array ( + 'name' => "×îëîâ³÷èé", + 'link' => 'male' + ), + 2 => array ( + 'name' => "Ƴíî÷èé", + 'link' => 'female' + ), + 3 => array ( + 'name' => "Äèòÿ÷èé", + 'link' => 'child' + ) + ) + // 4=>array('name'=>"Óí³ñåêñ",'link'=>'unisex') + ; + else + $arr = array ( + 1 => array ( + 'name' => "Ìóæñêîé", + 'link' => 'male' + ), + 2 => array ( + 'name' => "Æåíñêèé", + 'link' => 'female' + ), + 3 => array ( + 'name' => "Äåòñêèé", + 'link' => 'child' + ) + ) + // 4=>array('name'=>"Óíèñåêñ",'link'=>'unisex') + ; + + foreach ($res as $row) + { + $sex[] = $arr[$row['sex']]; + } + + if (isset ($_GET['s'])) + print_r ($sex); + + $this->tpl->assign ('sex', $sex); +} function getYearsName_IDs($ids){ //$sql = "select name from catalogs_years where id in (".implode(",",$ids).") order by name"; @@ -2535,83 +2640,154 @@ if(isset($_GET['akciiID']) && $_GET['akciiID']>0)$search[] = sprintf("p.akcii_id return implode(", ",$name); } - function viewFiltersMod($rubric_id){ - $search = array(); - if(isset($_GET['filter']) && count($_GET['filter'])>0)$filter = $this->seralizeFilter($_GET['filter']); - if(isset($filter['f']) && count($filter['f'])>0){ - $search[] = "catalogs_keys_products_filters.filter_id in (".implode(",",$filter['f']).")"; - } - if(isset($filter['y']) && $filter['y']>0){ - $search[] = "catalogs_keys_products_years.year_id in (".implode(",",$filter['y']).")"; - } - if(isset($filter['r']) && count($filter['r'])>0){ - $search[] = "m2.rost in (".implode(",",$filter['r']).")"; - } - - if(isset($_GET['brend']) && strlen($_GET['brend'])>0)$search[] = "p.brend_id in(".implode(",",$this->getBrendIDs_name($_GET['brend'])).")"; -/* if(isset($_GET['sex']) && strlen($_GET['sex'])>0){ - $sex = array('male'=>1,'female'=>2,'child'=>3,'unisex'=>4); - $search[] = sprintf("p.sex='%d'",$sex[$_GET['sex']]); - } */ - if(isset($_GET['sex']) && strlen($_GET['sex'])>0){ - $sex = $this->seralizeSex($_GET['sex']); - $search[] = "p.sex IN (" . implode(",",$sex) . ")"; - } - if(isset($_GET['new']) && $_GET['new']>0)$search[] = sprintf("p.active='%d'",$_GET['new']); - if(isset($_GET['top']) && $_GET['top']>0)$search[] = sprintf("p.top='%d'",$_GET['top']); -if(isset($_GET['akciiID']) && $_GET['akciiID']>0)$search[] = sprintf("p.akcii_id>'%d'",0); - $sql = "select m.* from catalogs_modifications m,catalogs_products p "; - if(isset($filter['f']) && count($filter['f'])>0)$sql .= "LEFT JOIN catalogs_keys_products_filters ON catalogs_keys_products_filters.product_id=p.id "; - if(isset($filter['y']) && $filter['y']>0)$sql .= "LEFT JOIN catalogs_keys_products_years ON catalogs_keys_products_years.product_id=p.id "; - if(isset($filter['r']) && count($filter['r'])>0){$sql .= "LEFT JOIN catalogs_modifications m2 ON m2.product_id=p.id and m2.active=1 ";} - - $sql .= "where m.size<>'' "; - if(count($search))$sql .= "AND " . implode(" AND ",$search) . " "; - $sql .= "and m.product_id=p.id and m.active=1 and p.rubric_id=? and p.count_modifications>0 GROUP BY m.size"; - $row = $this->db->getAll($sql,array($rubric_id),DB_FETCHMODE_ASSOC); - if($_GET['t']==1){ - print"
";
-         print_r($row);
-         print"
"; - } - $this->tpl->assign('size', $row); - } - - function viewFiltersRost($rubric_id){ - $search = array(); - if(isset($_GET['filter']) && count($_GET['filter'])>0)$filter = $this->seralizeFilter($_GET['filter']); - if(isset($filter['f']) && count($filter['f'])>0){ - $search[] = "catalogs_keys_products_filters.filter_id in (".implode(",",$filter['f']).")"; - } - if(isset($filter['y']) && $filter['y']>0){ - $search[] = "catalogs_keys_products_years.year_id in (".implode(",",$filter['y']).")"; - } + function viewFiltersMod ($rubric_id) +{ + $search = array (); + + if (isset ($_GET['filter']) && count ($_GET['filter']) > 0) + $filter = $this->seralizeFilter ($_GET['filter']); + + if (isset ($filter['f']) && count ($filter['f']) > 0) + { + $search[] = "catalogs_keys_products_filters.filter_id in (" . implode (",", $filter['f']) . ")"; + } - - if(isset($_GET['brend']) && strlen($_GET['brend'])>0)$search[] = "p.brend_id in(".implode(",",$this->getBrendIDs_name($_GET['brend'])).")"; -/* if(isset($_GET['sex']) && strlen($_GET['sex'])>0){ - $sex = array('male'=>1,'female'=>2,'child'=>3,'unisex'=>4); - $search[] = sprintf("p.sex='%d'",$sex[$_GET['sex']]); - } */ - if(isset($_GET['sex']) && strlen($_GET['sex'])>0){ - $sex = $this->seralizeSex($_GET['sex']); - $search[] = "p.sex IN (" . implode(",",$sex) . ")"; - } - $sql = "select m.* from catalogs_modifications m,catalogs_products p "; - if(isset($filter['f']) && count($filter['f'])>0)$sql .= "LEFT JOIN catalogs_keys_products_filters ON catalogs_keys_products_filters.product_id=p.id "; - if(isset($filter['y']) && $filter['y']>0)$sql .= "LEFT JOIN catalogs_keys_products_years ON catalogs_keys_products_years.product_id=p.id "; - - $sql .= "where m.rost<>'' "; - if(count($search))$sql .= "AND " . implode(" AND ",$search) . " "; - $sql .= "and m.product_id=p.id and m.active=1 and p.rubric_id=? and p.count_modifications>0 GROUP BY m.rost"; - $row = $this->db->getAll($sql,array($rubric_id),DB_FETCHMODE_ASSOC); - if($_GET['t']==1){ - print"
";
-         print_r($row);
-         print"
"; - } - $this->tpl->assign('rost', $row); - } + if (isset ($filter['y']) && $filter['y'] > 0) + { + $search[] = "catalogs_keys_products_years.year_id in (" . implode (",", $filter['y']) . ")"; + } + + if (isset ($filter['r']) && count ($filter['r']) > 0) + { + $search[] = "m2.rost in (" . implode (",", $filter['r']) . ")"; + } + + if (isset ($_GET['brend']) && strlen ($_GET['brend']) > 0) + $search[] = "p.brend_id in(" . implode (",", $this->getBrendIDs_name ($_GET['brend'])) . ")"; + /* + * if(isset($_GET['sex']) && strlen($_GET['sex'])>0){ + * $sex = array('male'=>1,'female'=>2,'child'=>3,'unisex'=>4); + * $search[] = sprintf("p.sex='%d'",$sex[$_GET['sex']]); + * } + */ + if (isset ($_GET['sex']) && strlen ($_GET['sex']) > 0) + { + $sex = $this->seralizeSex ($_GET['sex']); + $search[] = "p.sex IN (" . implode (",", $sex) . ")"; + } + + if (isset ($_GET['new']) && $_GET['new'] > 0) + $search[] = sprintf ("p.active='%d'", $_GET['new']); + + if (isset ($_GET['top']) && $_GET['top'] > 0) + $search[] = sprintf ("p.top='%d'", $_GET['top']); + + if (isset ($_GET['akciiID']) && $_GET['akciiID'] > 0) + $search[] = sprintf ("p.akcii_id>'%d'", 0); + + $sql = "select m.* from catalogs_modifications m,catalogs_products p "; + if (isset ($filter['f']) && count ($filter['f']) > 0) + $sql .= "LEFT JOIN catalogs_keys_products_filters ON catalogs_keys_products_filters.product_id=p.id "; + + if (isset ($filter['y']) && $filter['y'] > 0) + $sql .= "LEFT JOIN catalogs_keys_products_years ON catalogs_keys_products_years.product_id=p.id "; + + if (isset ($filter['r']) && count ($filter['r']) > 0) + { + $sql .= "LEFT JOIN catalogs_modifications m2 ON m2.product_id=p.id and m2.active=1 "; + } + + $sql .= "where m.size<>'' "; + + if (count ($search)) + $sql .= "AND " . implode (" AND ", $search) . " "; + + $sql .= " + and m.product_id=p.id + and m.active=1 + and p.rubric_id=? + and p.count_modifications>0 + and m.size > 0 + GROUP BY m.size"; + $row = $this->db->getAll ($sql, array ( + $rubric_id + ), DB_FETCHMODE_ASSOC); + + if ($_GET['t'] == 1) + { + print "
";
+        print_r ($row);
+        print "
"; + } + + $this->tpl->assign ('size', $row); +} + +function viewFiltersRost ($rubric_id) +{ + $search = array (); + + if (isset ($_GET['filter']) && count ($_GET['filter']) > 0) + $filter = $this->seralizeFilter ($_GET['filter']); + + if (isset ($filter['f']) && count ($filter['f']) > 0) + { + $search[] = "catalogs_keys_products_filters.filter_id in (" . implode (",", $filter['f']) . ")"; + } + + if (isset ($filter['y']) && $filter['y'] > 0) + { + $search[] = "catalogs_keys_products_years.year_id in (" . implode (",", $filter['y']) . ")"; + } + + if (isset ($_GET['brend']) && strlen ($_GET['brend']) > 0) + $search[] = "p.brend_id in(" . implode (",", $this->getBrendIDs_name ($_GET['brend'])) . ")"; + /* + * if(isset($_GET['sex']) && strlen($_GET['sex'])>0){ + * $sex = array('male'=>1,'female'=>2,'child'=>3,'unisex'=>4); + * $search[] = sprintf("p.sex='%d'",$sex[$_GET['sex']]); + * } + */ + if (isset ($_GET['sex']) && strlen ($_GET['sex']) > 0) + { + $sex = $this->seralizeSex ($_GET['sex']); + $search[] = "p.sex IN (" . implode (",", $sex) . ")"; + } + + $sql = "select m.* from catalogs_modifications m, catalogs_products p "; + + if (isset ($filter['f']) && count ($filter['f']) > 0) + $sql .= "LEFT JOIN catalogs_keys_products_filters ON catalogs_keys_products_filters.product_id=p.id "; + + if (isset ($filter['y']) && $filter['y'] > 0) + $sql .= "LEFT JOIN catalogs_keys_products_years ON catalogs_keys_products_years.product_id=p.id "; + + $sql .= "where m.rost<>'' "; + + if (count ($search)) + { + $sql .= "AND " . implode (" AND ", $search) . " "; + } + + $sql .= " + and m.product_id=p.id + and m.active=1 + and p.rubric_id=? + and p.count_modifications>0 + GROUP BY m.rost"; + $row = $this->db->getAll ($sql, array ( + $rubric_id + ), DB_FETCHMODE_ASSOC); + + if ($_GET['t'] == 1) + { + print "
";
+        print_r ($row);
+        print "
"; + } + + $this->tpl->assign ('rost', $row); +} function viewRostProduct($id){ $sql = "select m.* from catalogs_modifications m where m.product_id=? GROUP BY m.rost"; -- libgit2 0.21.4