' : '
';
}
/**
* 生成过滤条件:用于 get_goodslist 和 get_goods_list
* @param object $filter
* @return string
*/
function get_where_sql($filter)
{
$time = date('Y-m-d');
$where = isset($filter->is_delete) && $filter->is_delete == '1' ?
' WHERE is_delete = 1 ' : ' WHERE is_delete = 0 ';
$where .= (isset($filter->real_goods) && ($filter->real_goods > -1)) ? ' AND is_real = ' . intval($filter->real_goods) : '';
$where .= isset($filter->cat_id) && $filter->cat_id > 0 ? ' AND ' . get_children_supplier($filter->cat_id) : '';
$where .= isset($filter->brand_id) && $filter->brand_id > 0 ? " AND brand_id = '" . $filter->brand_id . "'" : '';
$where .= isset($filter->intro_type) && $filter->intro_type != '0' ? ' AND ' . $filter->intro_type . " = '1'" : '';
$where .= isset($filter->intro_type) && $filter->intro_type == 'is_promote' ?
" AND promote_start_date <= '$time' AND promote_end_date >= '$time' " : '';
$where .= isset($filter->keyword) && trim($filter->keyword) != '' ?
" AND (goods_name LIKE '%" . mysql_like_quote($filter->keyword) . "%' OR goods_sn LIKE '%" . mysql_like_quote($filter->keyword) . "%' OR g.goods_id LIKE '%" . mysql_like_quote($filter->keyword) . "%') " : '';
$where .= isset($filter->suppliers_id) && trim($filter->suppliers_id) != '' ?
" AND (g.suppliers_id = '" . $filter->suppliers_id . "') " : '';
$where .= isset($filter->in_ids) ? ' AND goods_id ' . db_create_in($filter->in_ids) : '';
$where .= isset($filter->exclude) ? ' AND goods_id NOT ' . db_create_in($filter->exclude) : '';
$where .= isset($filter->stock_warning) ? ' AND goods_number <= warn_number' : '';
return $where;
}
/**
* 获取地区列表的函数。
*
* @access public
* @param int $region_id 上级地区id
* @return void
*/
function area_list($region_id)
{
$area_arr = array();
$sql = 'SELECT * FROM ' . $GLOBALS['ecs']->table('region').
" WHERE parent_id = '$region_id' ORDER BY region_id";
$res = $GLOBALS['db']->query($sql);
while ($row = $GLOBALS['db']->fetchRow($res))
{
$row['type'] = ($row['region_type'] == 0) ? $GLOBALS['_LANG']['country'] : '';
$row['type'] .= ($row['region_type'] == 1) ? $GLOBALS['_LANG']['province'] : '';
$row['type'] .= ($row['region_type'] == 2) ? $GLOBALS['_LANG']['city'] : '';
$row['type'] .= ($row['region_type'] == 3) ? $GLOBALS['_LANG']['cantonal'] : '';
$area_arr[] = $row;
}
return $area_arr;
}
/**
* 取得图表颜色
*
* @access public
* @param integer $n 颜色顺序
* @return void
*/
function chart_color($n)
{
/* 随机显示颜色代码 */
$arr = array('33FF66', 'FF6600', '3399FF', '009966', 'CC3399', 'FFCC33', '6699CC', 'CC3366', '33FF66', 'FF6600', '3399FF');
if ($n > 8)
{
$n = $n % 8;
}
return $arr[$n];
}
/**
* 获得商品类型的列表
*
* @access public
* @param integer $selected 选定的类型编号
* @return string
*/
function goods_type_list($selected)
{
$sql = 'SELECT cat_id, cat_name FROM ' . $GLOBALS['ecs']->table('goods_type') . ' WHERE enabled = 1';
$res = $GLOBALS['db']->query($sql);
$lst = '';
while ($row = $GLOBALS['db']->fetchRow($res))
{
$lst .= "';
}
return $select;
}
else
{
foreach ($options AS $key => $value)
{
$options[$key]['url'] = build_uri('supplier', array('go'=>'category','suppid'=>$_SESSION['supplier_id'],'cid' => $value['cat_id']), $value['cat_name']);
}
return $options;
}
}
/**
* 过滤和排序所有分类,返回一个带有缩进级别的数组
*
* @access private
* @param int $cat_id 上级分类ID
* @param array $arr 含有所有分类的数组
* @param int $level 级别
* @return void
*/
function cat_options_2($spec_cat_id, $arr)
{
static $cat_options = array();
if (isset($cat_options[$spec_cat_id]))
{
return $cat_options[$spec_cat_id];
}
if (!isset($cat_options[0]))
{
$level = $last_cat_id = 0;
$options = $cat_id_array = $level_array = array();
while (!empty($arr))
{
foreach ($arr AS $key => $value)
{
$cat_id = $value['cat_id'];
if ($level == 0 && $last_cat_id == 0)
{
if ($value['parent_id'] > 0)
{
break;
}
$options[$cat_id] = $value;
$options[$cat_id]['level'] = $level;
$options[$cat_id]['id'] = $cat_id;
$options[$cat_id]['name'] = $value['cat_name'];
unset($arr[$key]);
if ($value['has_children'] == 0)
{
continue;
}
$last_cat_id = $cat_id;
$cat_id_array = array($cat_id);
$level_array[$last_cat_id] = ++$level;
continue;
}
if ($value['parent_id'] == $last_cat_id)
{
$options[$cat_id] = $value;
$options[$cat_id]['level'] = $level;
$options[$cat_id]['id'] = $cat_id;
$options[$cat_id]['name'] = $value['cat_name'];
unset($arr[$key]);
if ($value['has_children'] > 0)
{
if (end($cat_id_array) != $last_cat_id)
{
$cat_id_array[] = $last_cat_id;
}
$last_cat_id = $cat_id;
$cat_id_array[] = $cat_id;
$level_array[$last_cat_id] = ++$level;
}
}
elseif ($value['parent_id'] > $last_cat_id)
{
break;
}
}
$count = count($cat_id_array);
if ($count > 1)
{
$last_cat_id = array_pop($cat_id_array);
}
elseif ($count == 1)
{
if ($last_cat_id != end($cat_id_array))
{
$last_cat_id = end($cat_id_array);
}
else
{
$level = 0;
$last_cat_id = 0;
$cat_id_array = array();
continue;
}
}
if ($last_cat_id && isset($level_array[$last_cat_id]))
{
$level = $level_array[$last_cat_id];
}
else
{
$level = 0;
}
}
$cat_options[0] = $options;
}
else
{
$options = $cat_options[0];
}
if (!$spec_cat_id)
{
return $options;
}
else
{
if (empty($options[$spec_cat_id]))
{
return array();
}
$spec_cat_id_level = $options[$spec_cat_id]['level'];
foreach ($options AS $key => $value)
{
if ($key != $spec_cat_id)
{
unset($options[$key]);
}
else
{
break;
}
}
$spec_cat_id_array = array();
foreach ($options AS $key => $value)
{
if (($spec_cat_id_level == $value['level'] && $value['cat_id'] != $spec_cat_id) ||
($spec_cat_id_level > $value['level']))
{
break;
}
else
{
$spec_cat_id_array[$key] = $value;
}
}
$cat_options[$spec_cat_id] = $spec_cat_id_array;
return $spec_cat_id_array;
}
}
/**
* 为每一个创建店铺的商家创建基本信息的保存记录,如果之前没有创建过
*
*/
function create_shop_settiongs()
{
global $db, $ecs, $_LANG;
if(!isset($_SESSION['supplier_id']) || intval($_SESSION['supplier_id'])<=0){
return;
}
$sql = "SELECT count(id) FROM " . $ecs->table('supplier_shop_config') ." WHERE supplier_id=".$_SESSION['supplier_id'];
$num = $db->getOne($sql);
if($num>0){
return;
}else{
$insql = "INSERT INTO ". $ecs->table('supplier_shop_config') ." (`id`, `parent_id`, `code`, `type`, `store_range`, `store_dir`, `value`, `sort_order`, `supplier_id`) VALUES
(1, 0, 'shop_info', 'group', '', '', '', 1, ".$_SESSION['supplier_id']."),
(2, 0, 'hidden', 'hidden', '', '', '', 1, ".$_SESSION['supplier_id']."),
(8, 0, 'sms', 'group', '', '', '', 1, ".$_SESSION['supplier_id']."),
(101, 1, 'shop_name', 'text', '', '', '商家店铺名称', 1, ".$_SESSION['supplier_id']."),
(102, 1, 'shop_title', 'text', '', '', '商家店铺标题', 1, ".$_SESSION['supplier_id']."),
(103, 1, 'shop_desc', 'hidden', '', '', '商家店铺描述', 1, ".$_SESSION['supplier_id']."),
(104, 1, 'shop_keywords', 'text', '', '', '商家店铺关键字', 1, ".$_SESSION['supplier_id']."),
(105, 1, 'shop_country', 'manual', '', '', '1', 1, ".$_SESSION['supplier_id']."),
(106, 1, 'shop_province', 'manual', '', '', '0', 2, ".$_SESSION['supplier_id']."),
(107, 1, 'shop_city', 'manual', '', '', '0', 52, ".$_SESSION['supplier_id']."),
(108, 1, 'shop_address', 'text', '', '', '', 1, ".$_SESSION['supplier_id']."),
(109, 1, 'qq', 'text', '', '', '', 1, ".$_SESSION['supplier_id']."),
(110, 1, 'ww', 'text', '', '', '', 1, ".$_SESSION['supplier_id']."),
(111, 1, 'skype', 'hidden', '', '', '', 1, ".$_SESSION['supplier_id']."),
(112, 1, 'ym', 'hidden', '', '', '', 1, ".$_SESSION['supplier_id']."),
(113, 1, 'msn', 'hidden', '', '', '', 1, ".$_SESSION['supplier_id']."),
(114, 1, 'service_email', 'text', '', '', '', 1, ".$_SESSION['supplier_id']."),
(115, 1, 'service_phone', 'text', '', '', '', 1, ".$_SESSION['supplier_id']."),
(116, 1, 'shop_closed', 'select', '0,1', '', '0', 1, ".$_SESSION['supplier_id']."),
(117, 1, 'close_comment', 'hidden', '', '', '', 1, ".$_SESSION['supplier_id']."),
(118, 1, 'shop_logo', 'file', '', '../themes/".'{$template}'."/images/', '', 1, ".$_SESSION['supplier_id']."),
(119, 1, 'licensed', 'hidden', '0,1', '', '1', 1, ".$_SESSION['supplier_id']."),
(120, 1, 'user_notice', 'hidden', '', '', '用户中心公告!', 1, ".$_SESSION['supplier_id']."),
(121, 1, 'shop_notice', 'textarea', '', '', '商家店铺介绍:欢迎光临手机网,我们的宗旨:诚信经营、服务客户!\r\n', 1, ".$_SESSION['supplier_id']."),
(122, 1, 'shop_reg_closed', 'hidden', '1,0', '', '0', 1, ".$_SESSION['supplier_id']."),
(123, 1, 'shop_index_num', 'textarea', '', '', '8\r\n6\r\n4', 1, ".$_SESSION['supplier_id']."),
(124, 1, 'shop_search_price', 'textarea', '', '', '0-1000元\r\n1000-2000元\r\n2000-4000元', 1, ".$_SESSION['supplier_id']."),
(125, 1, 'close_comment', 'textarea', '', '', '该店铺正在装修', 1, ".$_SESSION['supplier_id']."),
(201, 2, 'shop_header_color', 'hidden', '', '', '#E4368F', 1, ".$_SESSION['supplier_id']."),
(202, 2, 'shop_header_text', 'hidden', '', '', '请上传logo和banner', 1, ".$_SESSION['supplier_id']."),
(203, 2, 'template', 'hidden', '', '', 'dianpu', 1, ".$_SESSION['supplier_id']."),
(204, 2, 'stylename', 'hidden', '', '', '', 1, ".$_SESSION['supplier_id']."),
(205, 2, 'flash_theme', 'hidden', '', '', '".$_SESSION['supplier_name'].$_SESSION['supplier_id']."', 1, ".$_SESSION['supplier_id']."),
(801, 8, 'sms_shop_mobile', 'text', '', '', '', 1, ".$_SESSION['supplier_id']."),
(802, 8, 'sms_order_placed', 'select', '1,0', '', '0', 1, ".$_SESSION['supplier_id']."),
(803, 8, 'sms_order_payed', 'hidden', '1,0', '', '0', 1, ".$_SESSION['supplier_id']."),
(804, 8, 'sms_order_shipped', 'hidden', '1,0', '', '0', 1, ".$_SESSION['supplier_id'].");";
if($db->query($insql) === false){
$links[] = array('text' => $_LANG['navigator'], 'href' => 'navigator.php?act=list');
sys_msg('店铺设置信息创建失败!', 1);
}
return;
}
}
/* 代码增加_start By morestock_morecity */
function get_ssid_list($sid)
{
$sql="select store_id from ". $GLOBALS['ecs']->table('store_main') ." where supplier_id=".$_REQUEST['storetypeid']." and parent_id = '$sid' ";
$ssid_res = $GLOBALS['db']->query($sql);
$arr=array();
while ($ssid_row=$GLOBALS['db']->fetchRow($ssid_res))
{
$arr[]=$ssid_row['store_id'];
}
if (count($arr))
{
return "(".implode(',', $arr).")";
}
else
{
return "(0)";
}
}
/* 获取库房完整名称(两级) */
function get_store_fullname($store_id)
{
if(!$store_id){return '';}
$store_row = $GLOBALS['db']->getRow("select parent_id, store_name from ". $GLOBALS['ecs']->table('store_main') ." where store_id='$store_id' ");
$store_name = $store_row['store_name'];
if($store_row['parent_id'])
{
$store_name_p = $GLOBALS['db']->getOne("select store_name from ". $GLOBALS['ecs']->table('store_main') ." where store_id='$store_row[parent_id]' ");
$store_name = $store_name_p ? $store_name_p."