function getColumns() { $ret = array('_cmd' => array('label' => __('操作'), 'width' => 70, 'html' => 'product/package/command.html')); $now = parent::getColumns(); $now['cat_id']['hidden'] = true; $now['type_id']['hidden'] = true; $now['goods_type']['hidden'] = true; $now['brand_id']['hidden'] = true; $now['brief']['hidden'] = true; $now['bn']['hidden'] = false; $now['cost']['hidden'] = true; $now['unit']['hidden'] = true; $now['score']['hidden'] = true; $now['uptime']['hidden'] = true; $now['downtime']['hidden'] = true; $now['last_modify']['hidden'] = true; $now['notify_num']['hidden'] = true; $now['name']['locked'] = 0; $now['name']['label'] = '捆绑商品名称'; $now['goods_id']['label'] = 'ID'; $now['mktprice']['label'] = '原价格'; $now['price']['label'] = '捆绑销售价'; $now['brand']['hidden'] = true; unset($now['brand_id']['filtertype']); unset($now['brand']['filtertype']); unset($now['cat_id']['filtertype']); unset($now['bn']['filtertype']); unset($now['cost']['filtertype']); unset($now['unit']['filtertype']); unset($now['brief']['filtertype']); unset($now['intro']['filtertype']); unset($now['type_id']['filtertype']); return array_merge($ret, $now); }
function getColumns() { $ret = array('_cmd' => array('label' => __('操作'), 'width' => 60, 'html' => 'product/spec/finder_command.html')); $ret = array_merge($ret, parent::getColumns()); $ret['spec_value'] = array('label' => __('规格值'), 'width' => 350, 'type' => 'spec_value', 'sql' => 'spec_id'); return $ret; }
function smarty_function_finder_result($params, &$smarty) { include_once 'shopObject.php'; $objects = shopObject::objects(); $return['_finder'] =& $params; $_smarty_tpl_vars = $smarty->_tpl_vars; $system =& $GLOBALS['system']; if (!($mod = $objects[$params['type']]) || !($o =& $system->loadModel($mod))) { $smarty->trigger_error('Wrong finder tfype: "' . $mod . '"', E_USER_ERROR); } $params['id'] = $o->idColumn; $params['params'] = serialize($params['params']); $params['controller'] = $o->adminCtl; $params['domid'] = 'sel_' . substr(md5(rand(0, time())), 0, 6); if (is_string($params['value'])) { $params['value'] = explode(',', $params['value']); } $cols = $params['cols'] ? $params['cols'] : $o->textColumn; $return['items'] =& $o->getFinder($cols, count($params['value']) > 0 ? array($o->idColumn => $params['value']) : -1, 0, -1, $count); $return['items']['custom_name'] = "商品"; if ($params['type'] == 'gift') { $return['items']['custom_name'] = "赠品"; } if ($params['type'] == 'coupon') { $return['items']['custom_name'] = "优惠券"; } $smarty->_smarty_include(array('smarty_include_tpl_file' => 'finder/input.html', 'smarty_include_vars' => $return)); $smarty->_tpl_vars = $_smarty_tpl_vars; unset($_smarty_tpl_vars); }
function smarty_function_filter($params, &$smarty) { include_once 'shopObject.php'; $objects = shopObject::objects(); $_smarty_tpl_vars = $smarty->_tpl_vars; $system =& $GLOBALS['system']; if (!($mod = $objects[$params['type']]) || !($o =& $system->loadModel($mod))) { $smarty->trigger_error('Wrong finder tfype: "' . $mod . '"', E_USER_ERROR); } if (include_once CORE_DIR . '/admin/controller/' . dirname($o->adminCtl) . '/ctl.' . basename($o->adminCtl) . '.php') { $ctlClass = 'ctl_' . basename($o->adminCtl); $obj = new $ctlClass(); $info = get_object_vars($obj); unset($obj); $value = $params['from'] ? $params['from'] : $params['value']; parse_str($value, $data); $objCat =& $system->loadModel('goods/productCat'); if ($mod == 'member/member') { $obj = $o->getFilter(array_merge($data, array($params['params']))); } else { $obj = $o->getFilterByTypeId(array_merge($data, array($params['params']))); } $include_var = array('filter' => $obj, '_finder' => array('gtype' => $objCat->getTypeList(), 'type' => $params['type'], 'name' => $params['name'], 'view' => $info['filterView'], 'from' => $value, 'value' => $value, 'params' => $params['params'], 'json' => json_encode($data), 'data' => $data, 'controller' => $o->adminCtl, 'domid' => substr(md5(rand(0, time())), 0, 6))); $smarty->_smarty_include(array('smarty_include_tpl_file' => 'finder/filter.html', 'smarty_include_vars' => $include_var)); $smarty->_tpl_vars = $_smarty_tpl_vars; unset($_smarty_tpl_vars); } else { $smarty->trigger_error('adminCtl ??', E_USER_ERROR); } }
function update($data, $filter, &$message) { if (!$this->findError($data, $message)) { return false; } parent::update($data, $filter); return true; }
function mdl_cur($system) { parent::modelFactory($system); if (defined('IN_INSTALLER')) { return; } $this->_money_format = array('decimals' => $this->system->getConf('system.money.operation.decimals'), 'dec_point' => $this->system->getConf('system.money.dec_point'), 'thousands_sep' => $this->system->getConf('system.money.thousands_sep'), 'fonttend_decimal_type' => $this->system->getConf('system.money.operation.carryset'), 'fonttend_decimal_remain' => $this->system->getConf('system.money.operation.decimals')); }
function _filter($filter) { $where = array(1); if ($filter['cpns_id']) { $where[] = 'sdb_pmt_gen_coupon.cpns_id=' . intval($filter['cpns_id']); } return parent::_filter($filter) . ' AND ' . implode($where, ' AND '); }
function _filter($filter) { $where = array(1); if ($filter['pmta_name']) { $where[] = 'pmta_name like\'%' . $filter['pmta_name'] . '%\''; } return parent::_filter($filter) . ' and ' . implode($where, ' and '); }
function mdl_memberattr() { parent::shopObject(); $data = $this->db->select("select attr_id from sdb_member_attr where attr_group = 'defalut' "); if (count($data) == 0) { $this->import_defalutattr(); } }
function mdl_po() { parent::shopObject(); $this->_tolken = $this->system->getConf('certificate.token'); // $this->_tolken = '00002'; // $this->system->setConf('certificate.id', "20000"); $this->api_utility =& $this->system->api_call(PLATFORM, PLATFORM_HOST, PLATFORM_PATH, PLATFORM_PORT, $this->_tolken); }
function getColumns() { $data = parent::getColumns(); //$data['_cmd']['label'] = __('操作'); //$data['_cmd']['width'] = 75; //$data['_cmd']['html'] = 'member/msgbox/msg_command.html'; return $data; }
function recycle($filter) { $data = $this->db->select("select member_id from sdb_members where member_lv_id in(" . implode(',', $filter['member_lv_id']) . ")"); if (count($data) > 0) { echo __('系统发现有会员使用该会员等级,请调整会员等级后再删除'); exit; } return parent::recycle($filter); }
function _filter($filter) { $where = array(1); $filter['to_type'] = 1; $where[] = 'for_id = 0'; if ($filter['msg_from']) { $where[] = "msg_from ='" . $filter['msg_from'] . "'"; } return parent::_filter($filter) . ' AND ' . implode($where, ' AND '); }
function _filter($filter) { if ($filter['target']) { $where = array('trigger_event like "' . $filter['target'] . ':%"'); unset($filter['target']); } else { $where = array(); } return parent::_filter($filter, $tbase, $where); }
function chgPoint($userId, $nPoint, $sReason, $relatedId = null, $type = 0) { //初始化 if ($nPoint == 0) { return true; } else { if (!$this->_chgPoint($userId, $nPoint)) { $nPoint = 0 - $this->getMemberPoint($userId); trigger_error(__('积分扣除超过会员已有积分'), E_USER_ERROR); return false; } } $oMember =& $this->system->loadModel('member/member'); $aPoint = $oMember->getFieldById($userId, array('point')); $oLv =& $this->system->loadModel('member/level'); if ($userId && $oLv->checkMemLvType($userId) != 'wholesale') { $userId = intval($userId); $oPointHistory =& $this->system->loadModel('trading/pointHistory'); $aUserPoint['point'] = $this->getMemberPoint($userId); $aUserPoint['point'] += $nPoint; $rRs = $this->db->query('select * from sdb_members where member_id=' . $userId); $sSql = $this->db->GetUpdateSQL($rRs, $aUserPoint); if ($sSql) { $this->db->exec($sSql); } if (intval($nPoint) != 0 && !$type) { $shopObject = new shopObject(); $shopObject->modelName = 'member/account'; $data['member_id'] = $userId; $shopObject->fireEvent('changepoint', $data, $userId); unset($shopObject); } if (!$this->system->getConf('site.level_switch')) { $this->toUpdatelevel($userId); } $aPointHistory = array('member_id' => $userId, 'point' => $nPoint, 'reason' => $sReason, 'related_id' => $relatedId); $oPointHistory->addHistory($aPointHistory); } return true; }
function insert($data) { $role_id = parent::insert($data); if ($role_id && is_array($data['actions'])) { $sql = 'INSERT INTO `sdb_lnk_acts` (`role_id`,`action_id`) VALUES '; foreach ($data['actions'] as $action_id) { $actions[] = "({$role_id},{$action_id})"; } $sql .= implode($actions, ',') . ';'; $a = $this->db->exec($sql); } return $role_id; }
function _filter($filter) { $where = array(1); if ($filter['no_handle']) { $where[] = ' (status!=4 and status!=5) '; } if (isset($filter['member_name']) && $filter['member_name'] !== '') { $aId = array(0); foreach ($this->db->select('SELECT member_id FROM sdb_members WHERE uname = \'' . $filter['member_name'] . '\'') as $rows) { $aId[] = $rows['member_id']; } $where[] = 'member_id IN (' . implode(',', $aId) . ')'; unset($filter['member_name']); } return parent::_filter($filter) . ' and ' . implode($where, ' AND '); }
function _filter($filter) { $where = array(1); $where[] = 'cpns_type=\'1\''; $where[] = 'cpns_point is not null'; if ($filter['cpns_name']) { $where[] = 'cpns_name like\'%' . $filter['cpns_name'] . '%\''; } if (isset($filter['ifvalid'])) { if ($filter['ifvalid'] === 1) { $curTime = time(); $where[] = 'cpns_status=\'1\' AND pmt_time_begin <= ' . $curTime . ' and pmt_time_end >' . $curTime; } } return parent::_filter($filter, 'c') . ' AND cpns_point > 0 AND ' . implode($where, ' and '); }
function _filter($aFilter) { if ($aFilter['title'] != '') { $aFilter['title'] = addslashes($aFilter['title']); $where[] = 'title LIKE \'' . $aFilter['title'] . '%\''; } $ndata = $this->db->select("select node_id from sdb_sitemaps"); foreach ($ndata as $key => $v) { $data[] = $v['node_id']; } $where[] = 'node_id in (' . implode(",", $data) . ')'; if ($aFilter['article_id']) { if (is_array($aFilter['article_id'])) { foreach ($aFilter['article_id'] as $id) { if ($id != '_ANY_') { $aId[] = intval($id); } } if (count($aId) > 0) { $where[] = 'article_id IN (' . implode(',', $aId) . ')'; } } else { $where[] = 'article_id=' . $aFilter['article_id']; } } if ($aFilter['node_id']) { if (is_array($aFilter['node_id'])) { foreach ($aFilter['node_id'] as $catid) { if ($catid != '_ANY_') { $aCats[] = intval($catid); } } if (count($aCats) > 0) { $where[] = 'node_id IN (' . implode(',', $aCats) . ')'; } } else { $where[] = 'node_id=' . $aFilter['node_id']; } } unset($aFilter['node_id']); unset($aFilter['title']); if (count($where) > 0) { return implode(' AND ', $where) . ' AND ' . parent::_filter($aFilter); } else { return parent::_filter($aFilter); } }
function insert($data) { $tags = $data['tags']; unset($data['tags']); if ($imgId = parent::insert($data)) { $tag =& $this->system->loadModel('system/tag'); foreach ($tags as $t) { if ($tagid = $tag->tagId($t, 'image')) { $tagList[] = $tagid; $this->db->exec('insert into sdb_tag_rel (tag_id,rel_id) values (' . $tagid . ',' . $imgId . ')'); } } $tag->recount($tagList); return $imgId; } else { return false; } }
function tpl_function_finder($params, &$smarty) { include_once 'shopObject.php'; $objects = shopObject::objects(); $system =& $GLOBALS['system']; if (!($mod = $objects[$params['type']]) || !($o =& $system->loadModel($mod))) { $smarty->trigger_error('Wrong finder tfype: ' . $params['type'], E_USER_ERROR); } $includeVars['filter'] =& $o->getFilter(null); $includeVars['_finder'] =& $params; $cols = $o->defaultCols; $params['order'] = $o->defaultOrder; $params['controller'] = $o->adminCtl; $params['filter'] = $params['params']; if ($params['infoUrl']) { $params['rowselect'] = true; } if (!$params['plimit']) { $params['plimit'] = 20; } //todo:自定义列 $includeVars['items'] =& $o->getFinder($cols, $params['filter'], 0, $params['plimit'], $count, $params['order']); $params['_name'] = substr(md5($_SERVER['QUERY_STRING']), 0, 6); if (!$params['var']) { $params['var'] = 'window.finder[\'' . $params['_name'] . '\']'; $params['initvar'] = 'if(!window.finder)window.finder={};'; } else { $params['initvar'] = 'var '; } $pager = array('current' => 1, 'total' => floor($count / $params['plimit']) + 1, 'link' => 'javascript:' . $params['var'] . '.jumpTo.bind(' . $params['var'] . ')(_PPP_)', 'token' => '_PPP_'); if (!$params['finder_action_tpl']) { $params['finder_action_tpl'] = $o->finder_action_tpl; } if (!$params['finder_filter_tpl']) { $params['finder_filter_tpl'] = $o->finder_filter_tpl; } $params['id'] = $o->idColumn; $params['count'] = $count; $params['pager'] =& $pager; $params['searchOptions'] = $o->searchOptions(); $params['orderBy'] = $o->defaultOrder[0]; $params['orderType'] = $o->defaultOrder[1]; $smarty->_fetch_compile_include($params['struct'] ? $params['struct'] : 'finder/common.html', $includeVars); }
function update($data, $filter) { if ($data['prt_tmpl_title']) { if (has_unsafeword($data['prt_tmpl_title'])) { trigger_error('无法保存,标题含有非法字符', E_USER_ERROR); return false; } if (!$filter['prt_tmpl_id']) { trigger_error('无法保存,模板名称不能重复', E_USER_ERROR); return false; } $sql = 'select prt_tmpl_id from sdb_print_tmpl where prt_tmpl_id!=' . intval($filter['prt_tmpl_id']) . ' and prt_tmpl_title="' . $this->db->quote($data['prt_tmpl_title']) . '"'; if ($r = $this->db->selectrow($sql)) { trigger_error('无法保存,存在同名模板', E_USER_ERROR); return false; } } return parent::update($data, $filter); }
function _filter($filter) { if ($filter['gname'] || $filter['gbn']) { if ($filter['gname']) { $gfilter['name'] = $filter['gname']; } if ($filter['gbn']) { $gfilter['bn'] = $filter['gbn']; } $oGoods = $this->system->loadModel('goods/products'); $filter['goods_id'][] = -1; foreach ($oGoods->getList('goods_id', $gfilter, 0, 1000) as $rows) { $filter['goods_id'][] = $rows['goods_id']; } } if ($filter['notifytime']) { $where = ' and creat_time > ' . $filter['notifytime']; } return parent::_filter($filter) . $where; }
function _filter($filter) { $sdtime = ''; if ($filter['sdtime']) { $sdtime = explode("/", $filter['sdtime']); } else { $sdtime = explode("/", $filter['sdtimecommon']); } if (count($sdtime) == 1) { $sdtime = explode('%2F', $sdtime[0]); } $where = array(1); $filter['start_date'] = $sdtime[0]; $filter['end_date'] = $sdtime[1]; if ($filter['start_date']) { $where[] = " mtime >= " . strtotime($filter['start_date']); } if ($filter['end_date']) { $where[] = " mtime <= " . (strtotime($filter['end_date']) + 3600 * 24); } unset($filter['sdtime'], $filter['sdtimecommon'], $sdtime); return parent::_filter($filter) . ' AND ' . implode($where, ' AND '); }
function _filter($filter) { $where = array(1); if (is_array($filter['giftcat_id'])) { foreach ($filter['gcat'] as $giftcat_id) { if ($giftcat_id != '_ANY_') { $cats[] = $giftcat_id; } if (count($cats) > 0) { $where[] = 'giftcat_id in (' . implode($cats, ',') . ')'; } } } if ($filter['cat']) { $where[] = 'cat like\'%' . $filter['cat'] . '%\''; } if (isset($filter['shop_iffb'])) { if ($filter['shop_iffb'] === 1) { $where[] = 'shop_iffb=\'1\''; } } return parent::_filter($filter) . ' and ' . implode($where, ' and '); }
function insert($data) { $data['userpass'] = md5(trim($data['userpass'])); $op_id = parent::insert($data); if ($op_id && is_array($data['roles'])) { $sql = 'INSERT INTO `sdb_lnk_roles` (`op_id`,`role_id`) VALUES '; foreach ($data['roles'] as $role_id) { $roles[] = "({$op_id},{$role_id})"; } $sql .= implode($roles, ',') . ';'; $a = $this->db->exec($sql); } return $op_id; }
function _filter($filter) { $where = array(1); $where[] = 'pmt_type=\'0\''; return parent::_filter($filter) . ' and ' . implode($where, ' and '); }
function prefilter($type) { include_once 'shopObject.php'; $objects = shopObject::objects(); $this->pagedata['type'] = $type; $this->pagedata['filter'] = stripslashes($_POST['data']); $this->pagedata['_finder']['select'] = 'none'; $this->pagedata['options'] = $_POST; $this->setView('finder/pvfilter.html'); $this->output(); }
function _filter($filter) { $where = array(1); if ($filter['cpns_name']) { $where[] = 'cpns_name like\'%' . $filter['cpns_name'] . '%\''; } $where[] = 'pmt_type=\'1\''; if (is_array($filter['cpns_id'])) { foreach ($filter['cpns_id'] as $cpns_id) { if ($cpns_id != '_ANY_') { $coupons[] = 'c.cpns_id=' . intval($cpns_id); } } if (count($coupons) > 0) { $where[] = '(' . implode($coupons, ' or ') . ')'; } } if (!empty($filter['cpns_type']) && is_string($filter['cpns_type'])) { $filter['cpns_type'] = explode(',', $filter['cpns_type']); } if (is_array($filter['cpns_type'])) { foreach ($filter['cpns_type'] as $type) { if ($type != '_ANY_') { $cpns_type[] = 'c.cpns_type=\'' . intval($type) . '\''; } } if (count($cpns_type) > 0) { $where[] = '(' . implode($cpns_type, ' or ') . ')'; } } if (isset($filter['ifvalid'])) { if ($filter['ifvalid'] === 1) { $curTime = time(); $where[] = 'cpns_status=\'1\' and pmt_time_begin <= ' . $curTime . ' and pmt_time_end >' . $curTime; } } return parent::_filter($filter, 'c') . ' and ' . implode($where, ' and '); }
function _filter($filter) { $where = array(1); $aId = array(0); $aBrand = array(); $serach_goodsid = false; if (isset($filter['brand_id']) && is_array($filter['brand_id'])) { foreach ($filter['brand_id'] as $brand_id) { if ($brand_id != '_ANY_') { $aBrand[] = intval($brand_id); } } if (count($aBrand) > 0) { $serach_goodsid = true; foreach ($this->db->select('SELECT goods_id FROM sdb_goods WHERE marketable = \'true\' AND brand_id IN(' . implode(',', $aBrand) . ')') as $rows) { $aId[] = $rows['goods_id']; } } unset($filter['brand_id']); } $aTag = array(); if (isset($filter['tag']) && is_array($filter['tag'])) { foreach ($filter['tag'] as $tag) { if ($tag != '_ANY_') { $aTag[] = intval($tag); } } if (count($aTag) > 0) { $tagId = array(0); foreach ($this->db->select('SELECT rel_id FROM sdb_tag_rel r LEFT JOIN sdb_tags t ON r.tag_id=t.tag_id WHERE t.tag_type = \'goods\' AND r.tag_id IN(' . implode(',', $aTag) . ')') as $rows) { $tagId[] = $rows['rel_id']; } if ($serach_goodsid) { $aId = array_intersect($aId, $tagId); } else { $aId = $tagId; } $serach_goodsid = true; } unset($filter['tag']); } $aGoods = array(); if (isset($filter['cat_id']) && is_array($filter['cat_id'])) { foreach ($filter['cat_id'] as $cat_id) { if ($cat_id != '_ANY_') { $aGoods[] = intval($cat_id); } } if (count($aGoods) > 0) { $catId = array(0); $tmp_array = $this->db->select('SELECT cat_id FROM sdb_goods_cat WHERE cat_path IN (' . implode(',', $aGoods) . ')'); $cId = array(); array_push($cId, implode($aGoods)); foreach ($tmp_array as $k => $v) { array_push($cId, $v['cat_id']); } foreach ($this->db->select('SELECT goods_id FROM sdb_goods WHERE marketable = \'true\' AND cat_id IN(' . implode(',', $cId) . ')') as $rows) { $catId[] = $rows['goods_id']; } if ($serach_goodsid) { $aId = array_intersect($aId, $catId); } else { $aId = $catId; } $serach_goodsid = true; } unset($filter['cat_id']); } $aType = array(); if (isset($filter['type_id']) && $filter['type_id']) { $filter['type_id'] = intval($filter['type_id']); $typeId = array(0); foreach ($this->db->select('SELECT goods_id FROM sdb_goods WHERE marketable = \'true\' AND type_id =' . $filter['type_id']) as $rows) { $typeId[] = $rows['goods_id']; } if ($serach_goodsid) { $aId = array_intersect($aId, $typeId); } else { $aId = $typeId; } $serach_goodsid = true; unset($filter['type_id']); } $aProps = array(); if (isset($filter['props']) && is_array($filter['props'])) { foreach ($filter['props'] as $cols => $rows) { foreach ($rows as $propid) { if ($propid != '_ANY_') { $aProps['p_' . $cols][] = intval($propid); } } } if (count($aProps) > 0) { $catId = array(0); $p_where = array(1); foreach ($aProps as $cols => $rows) { $p_where[] = $cols . ' IN(' . implode(',', $rows) . ')'; } foreach ($this->db->select('SELECT goods_id FROM sdb_goods WHERE marketable = \'true\' AND ' . implode(' AND ', $p_where)) as $rows) { $catId[] = $rows['goods_id']; } if ($serach_goodsid) { $aId = array_intersect($aId, $catId); } else { $aId = $catId; } $serach_goodsid = true; } unset($filter['props']); } if ($serach_goodsid) { $where[] = 'goods_id IN (' . implode(',', $aId) . ')'; } if (isset($filter['product_id']) && is_array($filter['product_id'])) { foreach ($filter['product_id'] as $goods_id) { if ($goods_id != '_ANY_') { $goods[] = intval($goods_id); } } if (count($goods) > 0) { $where[] = 'product_id IN (' . implode(',', $goods) . ')'; } } if (isset($filter['notifytime']) && is_array($filter['notifytime'])) { $where[] = 'creat_time > ' . $filter['notifytime']; } if (isset($filter['price']) && is_array($filter['price'])) { foreach ($filter['price'] as $price) { if ($price != '_ANY_') { $aPrice = explode('-', $price); $aWhere[] = '(price >= ' . $aPrice[0] . ' AND price <= ' . $aPrice[1] . ')'; } } if (!empty($aWhere)) { $where[] = '(' . implode(' OR ', $aWhere) . ')'; } unset($filter['price']); } else { if (trim($filter['pricefrom']) !== '' || trim($filter['priceto']) !== '') { if ($filter['pricefrom'] !== '') { $where[] = 'price >= ' . $filter['pricefrom']; unset($filter['pricefrom']); } if ($filter['priceto'] !== '') { $where[] = 'price <= ' . $filter['priceto']; unset($filter['priceto']); } } } // 过滤掉同步过来的商品(绑定的商品只能是本地商品) $ wubin 2009-9-7 15:05:20 if (isset($filter['is_local']) && $filter['is_local']) { // 是否只取本地商品 $sSql = " AND goods_id IN ( SELECT goods_id FROM sdb_goods WHERE supplier_goods_id = 0 OR supplier_goods_id IS NULL ) "; } else { $sSql = ""; } if (trim($filter['searchname'])) { $where[] = 'name like \'%' . trim($filter['searchname']) . '%\''; unset($filter['searchname']); } return parent::_filter($filter) . ' AND goods_id IS NOT NULL AND ' . implode(' AND ', $where) . (isset($filter['store_alarm']) ? ' AND store <=' . intval($filter['store_alarm']) : ''); }