You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
334 lines
13 KiB
334 lines
13 KiB
<?php
|
|
|
|
define('IN_ECS', true);
|
|
|
|
require(dirname(__FILE__) . '/includes/init.php');
|
|
require_once('includes/lib_template.php');
|
|
require_once(ROOT_PATH . '/' . ADMIN_PATH . '/includes/lib_goods.php');
|
|
|
|
$act=empty($_REQUEST['act'])?'list':trim($_REQUEST['act']);
|
|
|
|
/*------------------------------------------------------ */
|
|
//-- 模版列表
|
|
/*------------------------------------------------------ */
|
|
if ($act == 'list')
|
|
{
|
|
admin_priv('template_select');
|
|
|
|
$filename=empty($_REQUEST['filename'])?'index':trim($_REQUEST['filename']);
|
|
$smarty->assign('ur_here', $_LANG['floor_content_list']);
|
|
|
|
$smarty->assign('action_link', array('text' => $_LANG['floor_content_add'], 'href' => "set_floor_brand.php?act=add&filename=".$filename));
|
|
|
|
// 获得当前的模版的信息
|
|
$curr_template = $_CFG['template'];
|
|
$floor_content=get_floors($curr_template,$filename);
|
|
$smarty->assign('floor_content',$floor_content);
|
|
|
|
$smarty->assign('full_page', 1);
|
|
$smarty->display('floor_content_list.htm');
|
|
}
|
|
elseif($act=='add')
|
|
{
|
|
admin_priv('template_select');
|
|
$filename=empty($_REQUEST['filename'])?'index':trim($_REQUEST['filename']);
|
|
$smarty->assign('action_link', array('text' => $_LANG['floor_content_list'], 'href' => "set_floor_brand.php?act=list&filename=".$filename));
|
|
/* 获得当前的模版的信息 */
|
|
$curr_template = $_CFG['template'];
|
|
$template=get_template($curr_template, $filename, '首页楼层');
|
|
|
|
$smarty->assign('filename',$filename);
|
|
$smarty->assign('template',$template);
|
|
|
|
$smarty->assign('cat_list', cat_list_one(0));
|
|
$smarty->assign('brand_list', get_brand_list());
|
|
$smarty->assign('ur_here', $_LANG['set_floor']);
|
|
$smarty->display('floor_content_add.htm');
|
|
}
|
|
elseif($act=='edit')
|
|
{
|
|
admin_priv('template_select');
|
|
/* 获得当前的模版的信息 */
|
|
|
|
$filename = !empty($_GET['filename'])?trim($_GET['filename']):'';
|
|
$theme = !empty($_GET['theme'])?trim($_GET['theme']):'';
|
|
$region = !empty($_GET['region'])?trim($_GET['region']):'';
|
|
$cat_id = !empty($_GET['id'])?intval($_GET['id']):0;
|
|
|
|
$smarty->assign('action_link', array('text' => $_LANG['floor_content_list'], 'href' => "set_floor_brand.php?act=list"));
|
|
|
|
$floor_content = get_floor_content($theme,$filename,$cat_id,$region);
|
|
$template=get_template($theme, $filename, '首页楼层');
|
|
|
|
$smarty->assign('filename',$filename);
|
|
$smarty->assign('template',$template);
|
|
$smarty->assign('floor_content',$floor_content);
|
|
|
|
$smarty->assign('cat_id', $cat_id);
|
|
|
|
$smarty->assign('cat_list', cat_list_one(0));
|
|
$smarty->assign('brand_list', get_brand_list());
|
|
$smarty->assign('ur_here', $_LANG['set_floor']);
|
|
$smarty->display('floor_content_add.htm');
|
|
}
|
|
/*------------------------------------------------------ */
|
|
//-- 增加一个楼层内容
|
|
/*------------------------------------------------------ */
|
|
elseif ($act == 'add_floor_content')
|
|
{
|
|
include_once(ROOT_PATH . 'includes/cls_json.php');
|
|
$json = new JSON;
|
|
|
|
check_authz_json('template_select');
|
|
|
|
$fittings = $json->decode($_GET['add_ids']);
|
|
$arguments = $json->decode($_GET['JSON']);
|
|
|
|
$filename = $arguments[0];
|
|
$value = $arguments[1];
|
|
$value = explode("|", $value);
|
|
$cat_id = $value[0];
|
|
$region = $value[1];
|
|
$curr_template = $_CFG['template'];
|
|
|
|
|
|
$sql = "select cat_name from " .$GLOBALS['ecs']->table('category'). " where cat_id = '$cat_id'";
|
|
$cat_name = $GLOBALS['db']->getOne($sql);
|
|
|
|
$message = "";
|
|
foreach ($fittings AS $val)
|
|
{
|
|
$brand_name = $GLOBALS['db']->getOne("SELECT brand_name FROM ".$GLOBALS['ecs']->table('brand')." WHERE brand_id = '$val' LIMIT 1");
|
|
|
|
$sql = "select fb_id from " .$GLOBALS['ecs']->table('floor_content'). " where brand_id = '$val' AND filename = '$filename' AND id = '$cat_id' AND region = '$region' AND theme = '$curr_template'";
|
|
if(!$GLOBALS['db']->getOne($sql)){
|
|
$sql = "INSERT INTO " . $GLOBALS['ecs']->table('floor_content') .
|
|
"(filename, region, id, id_name, brand_id, brand_name, theme) " .
|
|
"VALUES('$filename', '$region', '$cat_id', '$cat_name', '$val','$brand_name','$curr_template')";//by mike add
|
|
$GLOBALS['db']->query($sql, 'SILENT');
|
|
}
|
|
}
|
|
|
|
$arr = get_floor_content($curr_template, $filename, $cat_id, $region);
|
|
$opt = array();
|
|
|
|
foreach ($arr AS $val)
|
|
{
|
|
$opt[] = array(
|
|
'value' => $val['fb_id'],
|
|
'text' => '['.$val['id_name'].']'.$val['brand_name'],
|
|
'data' => $val['id']
|
|
);
|
|
}
|
|
|
|
clear_cache_files();
|
|
make_json_result($opt, $message, array('error' => $error));
|
|
}
|
|
/*------------------------------------------------------ */
|
|
//-- 删除一个楼层内容
|
|
/*------------------------------------------------------ */
|
|
elseif ($act == 'drop_floor_content')
|
|
{
|
|
include_once(ROOT_PATH . 'includes/cls_json.php');
|
|
$json = new JSON;
|
|
|
|
check_authz_json('template_select');
|
|
|
|
$fittings = $json->decode($_GET['drop_ids']);
|
|
$arguments = $json->decode($_GET['JSON']);
|
|
|
|
$filename = $arguments[0];
|
|
$fb_id=$fittings;
|
|
$curr_template = $_CFG['template'];
|
|
$message = "";
|
|
$opt = array();
|
|
|
|
if(count($fb_id)>0)
|
|
{
|
|
$fb_id = implode(',', $fb_id);
|
|
$sql = "SELECT filename,region,id FROM ".$GLOBALS['ecs']->table('floor_content')." WHERE fb_id ".db_create_in($fb_id)." LIMIT 1";
|
|
$floor_info=$GLOBALS['db']->getRow($sql);
|
|
|
|
$sql = "DELETE FROM " .$GLOBALS['ecs']->table('floor_content'). " WHERE fb_id ".db_create_in($fb_id);
|
|
$GLOBALS['db']->query($sql);
|
|
|
|
$arr = get_floor_content($curr_template, $floor_info['filename'], $floor_info['id'], $floor_info['region']);
|
|
|
|
foreach ($arr AS $val)
|
|
{
|
|
$opt[] = array(
|
|
'value' => $val['fb_id'],
|
|
'text' => '['.$val['id_name'].']'.$val['brand_name'],
|
|
'data' => $val['id']
|
|
);
|
|
}
|
|
}
|
|
clear_cache_files();
|
|
make_json_result($opt, $message, array('error' => $error));
|
|
}
|
|
/*------------------------------------------------------ */
|
|
//-- 搜索内容
|
|
/*------------------------------------------------------ */
|
|
elseif($act == 'get_content')
|
|
{
|
|
include_once(ROOT_PATH . 'includes/cls_json.php');
|
|
$json = new JSON;
|
|
|
|
$filters = $json->decode($_GET['JSON']);
|
|
|
|
$arr = $brand_list = get_brandlist($filters);
|
|
|
|
$opt = array();
|
|
|
|
foreach ($arr AS $key => $val)
|
|
{
|
|
$opt[] = array(
|
|
'value' => $val['brand_id'],
|
|
'text' => $val['brand_name'],
|
|
'data' => $val['brand_id']
|
|
);
|
|
}
|
|
|
|
make_json_result($opt);
|
|
}
|
|
elseif($act=='remove')
|
|
{
|
|
$filename = !empty($_GET['filename'])?trim($_GET['filename']):0;
|
|
$theme = !empty($_GET['theme'])?trim($_GET['theme']):0;
|
|
$region = !empty($_GET['region'])?trim($_GET['region']):'';
|
|
$cat_id = !empty($_GET['id'])?intval($_GET['id']):0;
|
|
|
|
$sql = "DELETE FROM ".$GLOBALS['ecs']->table('floor_content')." WHERE filename = '$filename' AND theme = '$theme' AND id = '$cat_id' AND region = '$region'";
|
|
$GLOBALS['db']->query($sql);
|
|
|
|
/* 提示信息 */
|
|
$link[] = array('text' => $_LANG['go_back'], 'href'=>'set_floor_brand.php?filename=index');
|
|
sys_msg($_LANG['remove_success'], 0, $link);
|
|
}
|
|
|
|
function get_floor_content($curr_template,$filename,$id=0,$region='')
|
|
{
|
|
$where=" where 1 ";
|
|
if(!empty($id))
|
|
{
|
|
$where.=" and id='$id'";
|
|
}
|
|
if(!empty($region))
|
|
{
|
|
$where.=" and region='$region'";
|
|
}
|
|
$sql="select * from ".$GLOBALS['ecs']->table('floor_content').$where." and filename='$filename' and theme='$curr_template'";
|
|
$row=$GLOBALS['db']->getAll($sql);
|
|
|
|
return $row;
|
|
}
|
|
|
|
function get_floors($curr_template,$filename)
|
|
{
|
|
$sql="select * from ".$GLOBALS['ecs']->table('floor_content')." where filename='$filename' and theme='$curr_template' group by filename,theme,id";
|
|
|
|
$row = $GLOBALS['db']->getAll($sql);
|
|
foreach($row as $key=>$val)
|
|
{
|
|
$row[$key]['brand_list']=$GLOBALS['db']->getAll("select b.brand_id, b.brand_name from ".$GLOBALS['ecs']->table('brand') ." AS b, ".
|
|
$GLOBALS['ecs']->table('floor_content') ." AS fc ".
|
|
" where fc.filename = '" .$val['filename']. "' AND theme = '" .$val['theme']. "' AND id = '" .$val['id']. "' AND id = '" .$val['id']. "' AND region = '" .$val['region']. "' AND b.brand_id = fc.brand_id");
|
|
$row[$key]['cat_name']=$GLOBALS['db']->getOne("select cat_name from ".$GLOBALS['ecs']->table('category')." where cat_id='$val[id]' limit 1");
|
|
}
|
|
|
|
return $row;
|
|
}
|
|
|
|
function get_template($curr_template,$filename,$region)
|
|
{
|
|
$sql="select region,id from ".$GLOBALS['ecs']->table('template')." where filename='$filename' and theme='$curr_template' and region='$region'";
|
|
$res = $GLOBALS['db']->getAll($sql);
|
|
|
|
$arr = array();
|
|
foreach($res as $key=> $row){
|
|
$arr[$key] = $row;
|
|
$arr[$key]['cat_name'] = $GLOBALS['db']->getOne("select cat_name from ".$GLOBALS['ecs']->table('category')." where cat_id = '" .$row['id']. "' limit 1");
|
|
}
|
|
|
|
return $arr;
|
|
}
|
|
|
|
/**
|
|
* 获取品牌列表
|
|
*
|
|
* @access public
|
|
* @return array
|
|
*/
|
|
function get_brandlist($filters)
|
|
{
|
|
|
|
$cat_id = !empty($filters->cat_id) ? intval($filters->cat_id) : 0;
|
|
$keyword=!empty($filters->keyword)?trim($filters->keyword):'';
|
|
$brand_id = !empty($filters->brand_id) ? intval($filters->brand_id) : 0;
|
|
|
|
$children = get_category_parentChild_tree1($cat_id, 1);
|
|
$children = arr_foreach($children);
|
|
|
|
if($children){
|
|
$children = implode(",", $children) . "," . $cat_id;
|
|
$children = get_children($children, 0, 1);
|
|
}else{
|
|
$children = "g.cat_id IN ($cat_id)";
|
|
}
|
|
|
|
$where = '1';
|
|
if (!empty($keyword))
|
|
{
|
|
if(strtoupper(EC_CHARSET) == 'GBK')
|
|
{
|
|
$keyword = iconv("UTF-8", "gb2312", $keyword);
|
|
}
|
|
|
|
$where .= " AND brand_name like '%{$keyword}%'";
|
|
}
|
|
|
|
if(!empty($brand_id)){
|
|
$where .= " AND b.brand_id = '$brand_id' ";
|
|
}else{
|
|
$where .= " AND $children OR " . 'gc.cat_id ' . db_create_in(array_unique(array_merge(array($cat_id), array_keys(cat_list($cat_id, 0, false)))));
|
|
}
|
|
|
|
/* 获取分类下平台品牌 */
|
|
$sql = "SELECT b.brand_id, b.brand_name, b.brand_logo, COUNT(*) AS goods_num " .
|
|
"FROM " . $GLOBALS['ecs']->table('brand') . "AS b ".
|
|
" LEFT JOIN " . $GLOBALS['ecs']->table('goods') . " AS g ON g.brand_id = b.brand_id AND g.user_id = 0 AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 ".
|
|
" LEFT JOIN " . $GLOBALS['ecs']->table('goods_cat') . " AS gc ON g.goods_id = gc.goods_id " .
|
|
" WHERE $where AND b.is_show = 1 " .
|
|
"GROUP BY b.brand_id HAVING goods_num > 0 ORDER BY b.sort_order, b.brand_id ASC";
|
|
|
|
$brands_list = $GLOBALS['db']->getAll($sql);
|
|
|
|
/* 获取分类下商家品牌 */
|
|
$sql = "SELECT b.brand_id, b.brand_name , COUNT(*) AS goods_num, g.user_id ".
|
|
"FROM " . $GLOBALS['ecs']->table('brand') . "AS b ".
|
|
" LEFT JOIN " . $GLOBALS['ecs']->table('link_brand') . "AS lb ON lb.brand_id = b.brand_id ".
|
|
" LEFT JOIN " . $GLOBALS['ecs']->table('merchants_shop_brand') . "AS msb ON msb.bid = lb.bid AND msb.audit_status = 1 ".
|
|
" LEFT JOIN " . $GLOBALS['ecs']->table('goods') . " AS g ON g.brand_id = msb.bid AND g.user_id > 0 AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 ".
|
|
" LEFT JOIN " . $GLOBALS['ecs']->table('goods_cat') . " AS gc ON g.goods_id = gc.goods_id " .
|
|
" WHERE $where AND b.is_show = 1 " .
|
|
"GROUP BY b.brand_id HAVING goods_num > 0 ORDER BY b.sort_order, b.brand_id ASC";
|
|
|
|
$msb_brands_list = $GLOBALS['db']->getAll($sql);
|
|
|
|
if($msb_brands_list){
|
|
$new_array = array_merge($brands_list, $msb_brands_list);
|
|
$new = unique_arr($new_array);
|
|
$brands_list = $new;
|
|
}
|
|
|
|
$brands = array();
|
|
foreach ($brands_list AS $key => $val)
|
|
{
|
|
$brands[$key]['brand_id'] = $val['brand_id'];
|
|
$brands[$key]['brand_name'] = $val['brand_name'];
|
|
}
|
|
|
|
return $brands;
|
|
}
|
|
|
|
?>
|