- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
<?/**
* Возвращаем все товары по фильтру
* @author Алексей Чигинцев
* Доработал и убрал участки еблизма: Арбора Сергей
* Почувствовал, что могу все улучшить, но все разъебал еще хуже чем было изначально: Влад Черноскутов
* Ниче не знаю техничкой роблю: Алексей MOSkvin
* имхо: Вадим стиль руки хуй
* @param array $options - список используемых параметров
* @return array|false - массив товаров либо false
*/
function getGoodsFilter($options = array(),$_FILTER) {
$price_expr = '`price`';$_sub = $_out = array();$sql = $_sub_child = '';
$cat = new Catalog(self::$db);
$cat->load();
$filter_query = self::parseFilterQuery($_FILTER);
if ($options['SS'] && (!$options['first'] && !$options['second'] && !$options['last']))
{//получаем всех детей
$_sub_child = $cat->get_child(41);
if($options['id_man'][0]!=''){$whereand1 = $filter_query;}else{$whereand1 ="";}
if($options['sort_type']){$order1 = ' ORDER BY `'.$options['sort_field'].'` '.$options['sort_type'];
} else {$order1 =""; }
if (!empty($_sub_child)){$i=0;
foreach ($_sub_child as $v){
if($i<count($_sub_child)-1){$_sub_chil .= $v.','; $i++; }else{$_sub_chil .= $v; }}
if($whereand1!=""){$_sub[] = self::$db->resultAsArray('SELECT * FROM `'.self::$table.'` WHERE `is_dollar`= "0" `cid` IN('.$_sub_chil .') '.$whereand1.$order1);
}else{$_sub[] = self::$db->resultAsArray('SELECT * FROM `'.self::$table.'` WHERE `is_dollar`= "0" cid` IN('.$_sub_chil .') AND name` LIKE "%'.mysql_real_escape_string($options['SS']).'%" '.$order1
);}}
if ($_sub){ foreach($_sub as $v){if (!empty($v)){
foreach ($v as $v_child){
$_out[$v_child['id']] = $v_child;
}}}}
if (!empty($_out)) return $_out;
else return false;
}elseif ($options['SS'] && ($options['first'] || $options['second'] || $options['last']))
{ $whereand1 = "";
if($options['id_man'][0]){$whereand1 = $filter_query;}
if($options['sort_type']){
$order1 = ' ORDER BY `'.$options['sort_field'].'` '.$options['sort_type'];}else{$order1 ="";}
$_where_price = false;
if ($options['last']){switch ($options['last']){
case 1: $_where_price .= ' '.$whereand1.'AND ((`is_dollar`=0 AND (`price` > 0 AND `price` <= 25000)) OR (`is_dollar`=1 AND (`price` > 0 AND `price` <= '.__dollar(25000).'))) '.$order1; break;
case 2: $_where_price .= ' '.$whereand1.'AND ((`is_dollar`=0 AND (`price` > 25000 AND `price` <= 50000)) OR (`is_dollar`=1 AND (`price` > '.__dollar(25000).' AND `price` <= '.__dollar(50000).'))) '.$order1; break;
case 3: $_where_price .= ' '.$whereand1.'AND ((`is_dollar`=0 AND `price` > 50000) OR (`is_dollar`=1 AND (`price` > '.__dollar(50000).')))'.$order1; break;
default: $where_price = false; break;
}}$_sub_child = $cat->get_child($options['first']);
if (!$_sub_child){$_out = self::$db->resultAsArray('SELECT * FROM `'.self::$table.'` WHERE
`name` LIKE "%'.mysql_real_escape_string($options['SS']).'%"
AND `is_dollar`= "0" AND `cid`='.intval($options['first']).'
' . ($options['second'] ? ' AND `id_man`='.intval($options['second']).' ' : '') . '
' . ($_where_price ? $_where_price : '') . ''.$whereand1.$order1);
if (!empty($_out)) return $_out;else return false;
}else{foreach ($_sub_child as $v){
$_sub[] = self::$db->resultAsArray('SELECT * FROM `'.self::$table.'` WHERE
`name` LIKE "%'.mysql_real_escape_string($options['SS']).'%"
AND `is_dollar`= "0" AND `cid`='.intval($v).'
' . ($options['second'] ? ' AND `id_man`='.intval($options['second']).' ' : '') . '
' . ($_where_price ? $_where_price : '') . '');
}if ($_sub){foreach ($_sub as $v){if (!empty($v)){
foreach ($v as $v_child){
$_out[$v_child['id']] = $v_child;
}}}}
if (!empty($_out)) return $_out;else return false;
}}elseif (!$options['SS'] && ($options['first'] || $options['second'] || $options['last'])){
$_where_price = false;$whereand1 = "";
if($options['id_man'][0]){$whereand1 = $filter_query;}
if($options['sort_type']){$order1 = ' ORDER BY CAST(`' .$options['sort_field'].'` AS SIGNED) '.$options['sort_type'];}else{$order1 ="";}
if ($options['last']){switch ($options['last']){
case 1: $_where_price .= ' '.$whereand1.'AND (`is_dollar`=1 AND (`price` > 0 AND `price` <= '.__dollar(25000).')) '; break;
case 2: $_where_price .= ' '.$whereand1.'AND (`is_dollar`=1 AND (`price` > '.__dollar(25000).' AND `price` <= '.__dollar(50000).')) '; break;
case 3: $_where_price .= ' '.$whereand1.'AND (`is_dollar`=1 AND (`price` > '.__dollar(50000).'))'; break;
default: $where_price = false; break;
}}
//получаем детей для $options['first'] - если дети есть ищем по их массиву
$_sub_child = $cat->get_child($options['first']);
}else return false;}