本文整理汇总了PHP中cat_list函数的典型用法代码示例。如果您正苦于以下问题:PHP cat_list函数的具体用法?PHP cat_list怎么用?PHP cat_list使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cat_list函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_cat_id_goods_list
function get_cat_id_goods_list($cat_id = '', $num = '', $ext = '')
{
$sql = 'Select g.goods_id,g.guige, g.cat_id,c.parent_id, g.goods_name, g.goods_number, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . "promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, goods_img, " . "g.is_best, g.is_new, g.is_hot, g.is_promote,b.brand_name " . 'FROM ' . $GLOBALS['hhs']->table('goods') . ' AS g ' . 'LEFT JOIN ' . $GLOBALS['hhs']->table('category') . ' AS c ON c.cat_id = g.cat_id ' . "LEFT JOIN " . $GLOBALS['hhs']->table('member_price') . " AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . " left join " . $GLOBALS['hhs']->table('brand') . " as b on g.brand_id=b.brand_id " . " Where g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_new = 1 AND g.is_delete = 0 and g.is_mall=1 " . ($sql .= " AND (c.parent_id =" . $cat_id . " OR g.cat_id = " . $cat_id . " OR g.cat_id " . db_create_in(array_unique(array_merge(array($cat_id), array_keys(cat_list($cat_id, 0, false))))) . ")");
$sql .= $ext;
$sql .= " LIMIT {$num}";
$res = $GLOBALS['db']->getAll($sql);
$goods = array();
foreach ($res as $idx => $row) {
$goods[$idx]['id'] = $row['goods_id'];
$goods[$idx]['name'] = $row['goods_name'];
$goods[$idx]['guige'] = $row['guige'];
$goods[$idx]['brief'] = $row['goods_brief'];
$goods[$idx]['brand_name'] = $row['brand_name'];
$goods[$idx]['goods_number'] = $row['goods_number'];
$goods[$idx]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']);
$goods[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
$goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'], $row['goods_name_style']);
$goods[$idx]['market_price'] = price_format($row['market_price']);
$goods[$idx]['shop_price'] = price_format($row['shop_price']);
$goods[$idx]['thumb'] = empty($row['goods_thumb']) ? $GLOBALS['_CFG']['no_picture'] : $row['goods_thumb'];
$goods[$idx]['goods_img'] = empty($row['goods_img']) ? $GLOBALS['_CFG']['no_picture'] : $row['goods_img'];
$goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
if ($GLOBALS['SID']) {
$goods[$idx]['shop_price'] = price_format($row['s_goods_price']);
}
}
return $goods;
}
示例2: get_categories_tree_pro
/**
* 获得指定分类同级的所有分类以及该分类下的子分类
*
* @access public
* @param integer $cat_id 分类编号
* @return array
*/
function get_categories_tree_pro($cat_id = 0)
{
if ($cat_id > 0) {
$sql = 'SELECT parent_id FROM ' . $GLOBALS['ecs']->table('category') . " WHERE cat_id = '{$cat_id}'";
$parent_id = $GLOBALS['db']->getOne($sql);
} else {
$parent_id = 0;
}
/*
判断当前分类中全是是否是底级分类,
如果是取出底级分类上级分类,
如果不是取当前分类及其下的子分类
*/
$sql = 'SELECT count(*) FROM ' . $GLOBALS['ecs']->table('category') . " WHERE parent_id = '{$parent_id}' AND is_show = 1 ";
if ($GLOBALS['db']->getOne($sql) || $parent_id == 0) {
/* 获取当前分类及其子分类 */
$sql = 'SELECT cat_id,cat_name ,parent_id,is_show ' . 'FROM ' . $GLOBALS['ecs']->table('category') . "WHERE parent_id = '{$parent_id}' AND is_show = 1 ORDER BY sort_order ASC, cat_id ASC";
$res = $GLOBALS['db']->getAll($sql);
foreach ($res as $row) {
$cat_id = $row['cat_id'];
$children = get_children($cat_id);
$cat = $GLOBALS['db']->getRow('SELECT cat_name, keywords, cat_desc, style, grade, filter_attr, parent_id FROM ' . $GLOBALS['ecs']->table('category') . " WHERE cat_id = '{$cat_id}'");
/* 获取分类下文章 */
$sql = 'SELECT a.article_id, a.title, ac.cat_name, a.add_time, a.file_url, a.open_type FROM ' . $GLOBALS['ecs']->table('article_cat') . ' AS ac RIGHT JOIN ' . $GLOBALS['ecs']->table('article') . " AS a ON a.cat_id=ac.cat_id AND a.is_open = 1 WHERE ac.cat_name='{$row['cat_name']}' ORDER BY a.article_type,a.article_id DESC LIMIT 4 ";
$articles = $GLOBALS['db']->getAll($sql);
foreach ($articles as $key => $val) {
$articles[$key]['url'] = $val['open_type'] != 1 ? build_uri('article', array('aid' => $val['article_id']), $val['title']) : trim($val['file_url']);
}
/* 获取分类下品牌 */
$sql = "SELECT b.brand_id, b.brand_name, b.brand_logo, COUNT(*) AS goods_num, IF(b.brand_logo > '', '1', '0') AS tag " . "FROM " . $GLOBALS['ecs']->table('brand') . "AS b, " . $GLOBALS['ecs']->table('goods') . " AS g LEFT JOIN " . $GLOBALS['ecs']->table('goods_cat') . " AS gc ON g.goods_id = gc.goods_id " . "WHERE g.brand_id = b.brand_id AND ({$children} OR " . 'gc.cat_id ' . db_create_in(array_unique(array_merge(array($cat_id), array_keys(cat_list($cat_id, 0, false))))) . ") AND b.is_show = 1 " . " AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 " . "GROUP BY b.brand_id HAVING goods_num > 0 ORDER BY b.sort_order, b.brand_id ASC";
$brands = $GLOBALS['db']->getAll($sql);
foreach ($brands as $key => $val) {
$temp_key = $key + 1;
$brands[$temp_key]['brand_name'] = $val['brand_name'];
$brands[$temp_key]['url'] = build_uri('category', array('cid' => $cat_id, 'bid' => $val['brand_id'], 'price_min' => $price_min, 'price_max' => $price_max, 'filter_attr' => $filter_attr_str), $cat['cat_name']);
/* 判断品牌是否被选中 */
if ($brand == $brands[$key]['brand_id']) {
$brands[$temp_key]['selected'] = 1;
} else {
$brands[$temp_key]['selected'] = 0;
}
}
unset($brands[0]);
$cat_arr[$row['cat_id']]['brands'] = $brands;
$cat_arr[$row['cat_id']]['articles'] = $articles;
if ($row['is_show']) {
$cat_arr[$row['cat_id']]['id'] = $row['cat_id'];
$cat_arr[$row['cat_id']]['name'] = $row['cat_name'];
$cat_arr[$row['cat_id']]['url'] = build_uri('category', array('cid' => $row['cat_id']), $row['cat_name']);
if (isset($row['cat_id']) != NULL) {
$cat_arr[$row['cat_id']]['cat_id'] = get_child_tree_pro($row['cat_id']);
}
}
}
}
if (isset($cat_arr)) {
return $cat_arr;
}
}
示例3: write_add_item
function write_add_item()
{
global $_POST;
extract($_POST);
global $_SESSION;
db_connect();
$write_sql = "INSERT INTO auditor_report (cat,detail,date_added,user_added)\n\t\t\t\t\tVALUES ('{$cat}','{$detail}','now','{$_SESSION['USER_NAME']}')";
$run_write = db_exec($write_sql) or errDie("Unable to add report detail");
return cat_list();
}
示例4: cat_list
function cat_list($parent_id = 0, $level = 0)
{
global $db, $prefix;
$cat_list = array();
$rows = $db->get_all("SELECT * FROM {$prefix}category WHERE parent_id = ? ORDER BY sort_order", array($parent_id));
foreach ($rows as $row) {
$row['level'] = $level;
$cat_list[] = $row;
$cat_list = array_merge($cat_list, cat_list($row['id'], $level + 1));
}
return $cat_list;
}
示例5: edit
/**
* 编辑分类信息
*/
public function edit()
{
if (IS_POST) {
$cat_id = I('cat_id');
$cat_info = I('data');
/* 数据验证 */
$msg = Check::rule(array(array(Check::must($cat_info['cat_name']), L('catname_empty'))));
/* 提示信息 */
if ($msg !== true) {
$this->message($msg, NULL, 'error');
}
/* 判断上级目录是否合法 */
$children = array_keys(cat_list($cat_id, 0, false));
// 获得当前分类的所有下级分类
if (in_array($cat_info['parent_id'], $children)) {
$this->message(L('is_leaf_error'), NULL, 'error');
}
/* 更新栏目 */
$this->cat_update($cat_id, $cat_info);
/* 更新栏目图标 */
if ($_FILES['cat_image']['name']) {
/* cat_image图标 */
$result = $this->ectouchUpload('cat_image', 'cat_image');
if ($result['error'] > 0) {
$this->message($result['message'], NULL, 'error');
}
$data['cat_image'] = substr($result['message']['cat_image']['savepath'], 2) . $result['message']['cat_image']['savename'];
$this->model->table('touch_category')->data($data)->where('cat_id=' . $cat_id)->update();
}
/* 清除缓存 */
clear_all_files();
$this->message(L('catedit_succed'), url('index'));
}
$cat_id = I('cat_id');
//查询附表信息
$result = $this->model->table('touch_category')->where('cat_id=' . $cat_id)->find();
if (empty($result)) {
$data['cat_id'] = $cat_id;
$this->model->table('touch_category')->data($data)->insert();
}
// 查询分类信息数据
$cat_info = $this->get_cat_info($cat_id);
/* 模板赋值 */
$this->assign('ur_here', L('category_edit'));
$this->assign('cat_info', $cat_info);
$this->assign('cat_select', cat_list(0, $cat_info['parent_id'], true));
$this->display();
}
示例6: category_get_goods22
function category_get_goods22()
{
$where = "g.is_on_sale = 1 and g.is_bind_card='2' AND g.is_alone_sale = 1 AND " . "g.is_delete = 0 ";
$id = isset($_REQUEST['id']) ? trim($_REQUEST['id']) : 0;
if ($id) {
$where .= " and g.cat_id " . db_create_in(array_unique(array_keys(cat_list($id, 0, false))));
}
/* 获得商品列表 */
$sql = 'SELECT g.goods_id, g.goods_name,g.cat_id, g.goods_name_style, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, g.promote_price, g.goods_type, " . 'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img ' . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . "WHERE {$where} ";
$goodlist = $GLOBALS['db']->getAll($sql);
$arr = array();
foreach ($goodlist as $row) {
if ($row['promote_price'] > 0) {
$promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
} else {
$promote_price = 0;
}
/* 处理商品水印图片 */
$watermark_img = '';
if ($promote_price != 0) {
$watermark_img = "watermark_promote_small";
} elseif ($row['is_new'] != 0) {
$watermark_img = "watermark_new_small";
} elseif ($row['is_best'] != 0) {
$watermark_img = "watermark_best_small";
} elseif ($row['is_hot'] != 0) {
$watermark_img = 'watermark_hot_small';
}
if ($watermark_img != '') {
$arr[$row['goods_id']]['watermark_img'] = $watermark_img;
}
$arr[$row['goods_id']]['goods_id'] = $row['goods_id'];
$arr[$row['goods_id']]['goods_name'] = $row['goods_name'];
$arr[$row['goods_id']]['name'] = $row['goods_name'];
$arr[$row['goods_id']]['goods_brief'] = $row['goods_brief'];
$arr[$row['goods_id']]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']);
$arr[$row['goods_id']]['market_price'] = price_format($row['market_price']);
$arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']);
$arr[$row['goods_id']]['type'] = $row['goods_type'];
$arr[$row['goods_id']]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : '';
$arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
$arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
$arr[$row['goods_id']]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
}
return $arr;
}
示例7: assign_query_info
$smarty->assign($sort_flag['tag'], $sort_flag['img']);
assign_query_info();
$smarty->assign('action_link', array('text' => $_LANG['topic_add'], 'href' => 'topic.php?act=add'));
$smarty->display('topic_list.htm');
}
/* 添加,编辑 */
if ($_REQUEST['act'] == 'add' || $_REQUEST['act'] == 'edit') {
admin_priv('topic_manage');
$isadd = $_REQUEST['act'] == 'add';
$smarty->assign('isadd', $isadd);
$topic_id = empty($_REQUEST['topic_id']) ? 0 : intval($_REQUEST['topic_id']);
include_once ROOT_PATH . 'includes/fckeditor/fckeditor.php';
// 包含 html editor 类文件
$smarty->assign('ur_here', $_LANG['09_topic']);
$smarty->assign('action_link', list_link($isadd));
$smarty->assign('cat_list', cat_list(0, 1));
$smarty->assign('brand_list', get_brand_list());
$smarty->assign('cfg_lang', $_CFG['lang']);
$smarty->assign('topic_style_color', $topic_style_color);
$width_height = get_toppic_width_height();
if (isset($width_height['pic']['width']) && isset($width_height['pic']['height'])) {
$smarty->assign('width_height', sprintf($_LANG['tips_width_height'], $width_height['pic']['width'], $width_height['pic']['height']));
}
if (isset($width_height['title_pic']['width']) && isset($width_height['title_pic']['height'])) {
$smarty->assign('title_width_height', sprintf($_LANG['tips_title_width_height'], $width_height['title_pic']['width'], $width_height['title_pic']['height']));
}
if (!$isadd) {
$sql = 'SELECT * FROM ' . $ecs->table('topic') . " WHERE topic_id = '{$topic_id}'";
$topic = $db->getRow($sql);
$topic['start_time'] = local_date('Y-m-d', $topic['start_time']);
$topic['end_time'] = local_date('Y-m-d', $topic['end_time']);
示例8: get_categories_tree
/**
* 获得指定分类同级的所有分类以及该分类下的子分类
*
* @access public
* @param integer $cat_id 分类编号
* @return array
*/
function get_categories_tree($cat_id = 0)
{
if ($cat_id > 0) {
$sql = 'SELECT parent_id FROM ' . $GLOBALS['ecs']->table('category') . " WHERE cat_id = '{$cat_id}'";
$parent_id = $GLOBALS['db']->getOne($sql);
} else {
$parent_id = 0;
}
/*
判断当前分类中全是是否是底级分类,
如果是取出底级分类上级分类,
如果不是取当前分类及其下的子分类
*/
$sql = 'SELECT count(*) FROM ' . $GLOBALS['ecs']->table('category') . " WHERE parent_id = '{$parent_id}' AND is_show = 1 ";
if ($GLOBALS['db']->getOne($sql) || $parent_id == 0) {
/* 获取当前分类及其子分类 */
$sql = 'SELECT cat_id,cat_name ,parent_id,is_show ' . 'FROM ' . $GLOBALS['ecs']->table('category') . "WHERE parent_id = '{$parent_id}' AND is_show = 1 ORDER BY sort_order ASC, cat_id ASC";
$res = $GLOBALS['db']->getAll($sql);
foreach ($res as $row) {
$cat_id = $row['cat_id'];
$children = get_children($cat_id);
/* 获取分类下品牌 */
$sql = "SELECT b.brand_id, b.brand_logo,b.brand_name, COUNT(*) AS goods_num " . "FROM " . $GLOBALS['ecs']->table('brand') . "AS b, " . $GLOBALS['ecs']->table('goods') . " AS g LEFT JOIN " . $GLOBALS['ecs']->table('goods_cat') . " AS gc ON g.goods_id = gc.goods_id " . "WHERE g.brand_id = b.brand_id AND ({$children} OR " . 'gc.cat_id ' . db_create_in(array_unique(array_merge(array($cat_id), array_keys(cat_list($cat_id, 0, false))))) . ") AND b.is_show = 1 " . " AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 " . "GROUP BY b.brand_id HAVING goods_num > 0 ORDER BY b.sort_order, b.brand_id ASC";
$brands = $GLOBALS['db']->getAll($sql);
foreach ($brands as $key => $val) {
$brands[$key]['logo'] = $val['brand_logo'];
$brands[$key]['brand_name'] = $val['brand_name'];
$brands[$key]['url'] = build_uri('category', array('cid' => $cat_id, 'bid' => $val['brand_id'], 'price_min' => $price_min, 'price_max' => $price_max, 'filter_attr' => $filter_attr_str), $cat['cat_name']);
/* 判断品牌是否被选中 */
if ($brand == $brands[$key]['brand_id']) {
$brands[$key]['selected'] = 1;
} else {
$brands[$key]['selected'] = 0;
}
}
$cat_arr[$row['cat_id']]['brands'] = $brands;
$cat_arr[$row['cat_id']]['articles'] = $articles;
if ($row['is_show']) {
$cat_arr[$row['cat_id']]['id'] = $row['cat_id'];
$cat_arr[$row['cat_id']]['name'] = $row['cat_name'];
$cat_arr[$row['cat_id']]['url'] = build_uri('category', array('cid' => $row['cat_id']), $row['cat_name']);
if (isset($row['cat_id']) != NULL) {
$cat_arr[$row['cat_id']]['cat_id'] = get_child_tree($row['cat_id']);
}
}
}
}
if (isset($cat_arr)) {
return $cat_arr;
}
}
示例9: compute_discount_amount
/**
* 计算购物车中的商品能享受红包支付的总额
* @return float 享受红包支付的总额
*/
function compute_discount_amount()
{
/* 查询优惠活动 */
$now = gmtime();
$user_rank = ',' . $_SESSION['user_rank'] . ',';
$sql = "SELECT *" . "FROM " . $GLOBALS['ecs']->table('favourable_activity') . " WHERE start_time <= '{$now}'" . " AND end_time >= '{$now}'" . " AND CONCAT(',', user_rank, ',') LIKE '%" . $user_rank . "%'" . " AND act_type " . db_create_in(array(FAT_DISCOUNT, FAT_PRICE));
$favourable_list = $GLOBALS['db']->getAll($sql);
if (!$favourable_list) {
return 0;
}
/* 查询购物车商品 */
$sql = "SELECT c.goods_id, c.goods_price * c.goods_number AS subtotal, g.cat_id, g.brand_id " . "FROM " . $GLOBALS['ecs']->table('cart') . " AS c, " . $GLOBALS['ecs']->table('goods') . " AS g " . "WHERE c.goods_id = g.goods_id " . "AND c.session_id = '" . SESS_ID . "' " . "AND c.parent_id = 0 " . "AND c.is_gift = 0 " . "AND rec_type = '" . CART_GENERAL_GOODS . "'";
$goods_list = $GLOBALS['db']->getAll($sql);
if (!$goods_list) {
return 0;
}
/* 初始化折扣 */
$discount = 0;
$favourable_name = array();
/* 循环计算每个优惠活动的折扣 */
foreach ($favourable_list as $favourable) {
$total_amount = 0;
if ($favourable['act_range'] == FAR_ALL) {
foreach ($goods_list as $goods) {
$total_amount += $goods['subtotal'];
}
} elseif ($favourable['act_range'] == FAR_CATEGORY) {
/* 找出分类id的子分类id */
$id_list = array();
$raw_id_list = explode(',', $favourable['act_range_ext']);
foreach ($raw_id_list as $id) {
$id_list = array_merge($id_list, array_keys(cat_list($id, 0, false)));
}
$ids = join(',', array_unique($id_list));
foreach ($goods_list as $goods) {
if (strpos(',' . $ids . ',', ',' . $goods['cat_id'] . ',') !== false) {
$total_amount += $goods['subtotal'];
}
}
} elseif ($favourable['act_range'] == FAR_BRAND) {
foreach ($goods_list as $goods) {
if (strpos(',' . $favourable['act_range_ext'] . ',', ',' . $goods['brand_id'] . ',') !== false) {
$total_amount += $goods['subtotal'];
}
}
} elseif ($favourable['act_range'] == FAR_GOODS) {
foreach ($goods_list as $goods) {
if (strpos(',' . $favourable['act_range_ext'] . ',', ',' . $goods['goods_id'] . ',') !== false) {
$total_amount += $goods['subtotal'];
}
}
} else {
continue;
}
if ($total_amount > 0 && $total_amount >= $favourable['min_amount'] && ($total_amount <= $favourable['max_amount'] || $favourable['max_amount'] == 0)) {
if ($favourable['act_type'] == FAT_DISCOUNT) {
$discount += $total_amount * (1 - $favourable['act_type_ext'] / 100);
} elseif ($favourable['act_type'] == FAT_PRICE) {
$discount += $favourable['act_type_ext'];
}
}
}
return $discount;
}
示例10: get_promotion_show
/**
* 所有的促销活动信息
* @access public
* @return array
*/
function get_promotion_show($goods_id = '') {
$group = array();
$package = array();
$favourable = array();
$gmtime = gmtime();
$sql = 'SELECT act_id, act_name, act_type, start_time, end_time FROM ' . $this->pre . "goods_activity WHERE is_finished=0 AND start_time <= '$gmtime' AND end_time >= '$gmtime'";
if (!empty($goods_id)) {
$sql .= " AND goods_id = '$goods_id'";
}
$res = $this->query($sql);
if (is_array($res))
foreach ($res as $data) {
switch ($data['act_type']) {
case GAT_GROUP_BUY: //团购
$group[$data['act_id']]['type'] = 'group_buy';
break;
case GAT_PACKAGE: //礼包
$package[$data['act_id']]['type'] = 'package';
break;
}
}
$user_rank = ',' . $_SESSION['user_rank'] . ',';
$favourable = array();
$sql = 'SELECT act_id, act_range, act_type,act_range_ext, act_name, start_time, end_time FROM ' . $this->pre . "favourable_activity WHERE start_time <= '$gmtime' AND end_time >= '$gmtime'";
if (!empty($goods_id)) {
$sql .= " AND CONCAT(',', user_rank, ',') LIKE '%" . $user_rank . "%'";
}
$res = $this->query($sql);
if (empty($goods_id)) {
foreach ($res as $rows) {
$favourable[$rows['act_id']]['type'] = 'favourable';
}
} else {
$sql = "SELECT cat_id, brand_id FROM " . $this->pre . "goods WHERE goods_id = '$goods_id'";
$row = $this->row($sql);
$category_id = $row['cat_id'];
$brand_id = $row['brand_id'];
foreach ($res as $rows) {
if ($rows['act_range'] == FAR_ALL) {
$favourable[$rows['act_id']]['act_type'] = $rows['act_type'];
} elseif ($rows['act_range'] == FAR_CATEGORY) {
/* 找出分类id的子分类id */
$id_list = array();
$raw_id_list = explode(',', $rows['act_range_ext']);
foreach ($raw_id_list as $id) {
$id_list = array_merge($id_list, array_keys(cat_list($id, 0, false)));
}
$ids = join(',', array_unique($id_list));
if (strpos(',' . $ids . ',', ',' . $category_id . ',') !== false) {
$favourable[$rows['act_id']]['act_type'] = $rows['act_type'];
}
} elseif ($rows['act_range'] == FAR_BRAND) {
if (strpos(',' . $rows['act_range_ext'] . ',', ',' . $brand_id . ',') !== false) {
$favourable[$rows['act_id']]['act_type'] = $rows['act_type'];
}
} elseif ($rows['act_range'] == FAR_GOODS) {
if (strpos(',' . $rows['act_range_ext'] . ',', ',' . $goods_id . ',') !== false) {
$favourable[$rows['act_id']]['act_type'] = $rows['act_type'];
}
}
}
}
$sort_time = array();
$arr = array_merge($group, $package, $favourable);
foreach ($arr as $key => $value) {
$sort_time[] = $value['sort'];
}
array_multisort($sort_time, SORT_NUMERIC, SORT_DESC, $arr);
return array_unique($arr);
}
示例11: assign_template
function assign_template($ctype = '', $catlist = array())
{
ECTouch::view()->assign('image_width', C('image_width'));
ECTouch::view()->assign('image_height', C('image_height'));
ECTouch::view()->assign('points_name', C('integral_name'));
ECTouch::view()->assign('qq', explode(',', C('qq')));
ECTouch::view()->assign('ww', explode(',', C('ww')));
ECTouch::view()->assign('ym', explode(',', C('ym')));
ECTouch::view()->assign('msn', explode(',', C('msn')));
ECTouch::view()->assign('skype', explode(',', C('skype')));
ECTouch::view()->assign('stats_code', C('stats_code'));
ECTouch::view()->assign('copyright', sprintf(L('copyright'), date('Y'), C('shop_name')));
ECTouch::view()->assign('shop_name', C('shop_name'));
ECTouch::view()->assign('service_email', C('service_email'));
ECTouch::view()->assign('service_phone', C('service_phone'));
ECTouch::view()->assign('shop_address', C('shop_address'));
ECTouch::view()->assign('licensed', license_info());
ECTouch::view()->assign('ecs_version', VERSION);
ECTouch::view()->assign('icp_number', C('icp_number'));
ECTouch::view()->assign('username', !empty($_SESSION['user_name']) ? $_SESSION['user_name'] : '');
ECTouch::view()->assign('category_list', cat_list(0, 0, true, 2, false));
ECTouch::view()->assign('catalog_list', cat_list(0, 0, false, 1, false));
ECTouch::view()->assign('navigator_list', model('Common')->get_navigator($ctype, $catlist));
//自定义导航栏
$search_keywords = C('search_keywords');
if (!empty($search_keywords)) {
$searchkeywords = explode(',', trim(C('search_keywords')));
} else {
$searchkeywords = array();
}
ECTouch::view()->assign('searchkeywords', $searchkeywords);
}
示例12: assign_template
function assign_template($ctype = '', $catlist = array())
{
global $smarty, $db;
$smarty->assign('image_width', $GLOBALS['_CFG']['image_width']);
$smarty->assign('image_height', $GLOBALS['_CFG']['image_height']);
$smarty->assign('points_name', $GLOBALS['_CFG']['integral_name']);
$smarty->assign('qq', explode(',', $GLOBALS['_CFG']['qq']));
$smarty->assign('ww', explode(',', $GLOBALS['_CFG']['ww']));
$smarty->assign('ym', explode(',', $GLOBALS['_CFG']['ym']));
$smarty->assign('msn', explode(',', $GLOBALS['_CFG']['msn']));
$smarty->assign('skype', explode(',', $GLOBALS['_CFG']['skype']));
$smarty->assign('stats_code', $GLOBALS['_CFG']['stats_code']);
$smarty->assign('copyright', sprintf($GLOBALS['_LANG']['copyright'], date('Y'), $GLOBALS['_CFG']['shop_name']));
$smarty->assign('shop_name', $GLOBALS['_CFG']['shop_name']);
$full_uri = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
//by Bragg
$smarty->assign('shop_url', substr($full_uri, 0, strripos($full_uri, "mobile/")));
//by Bragg
$smarty->assign('service_email', $GLOBALS['_CFG']['service_email']);
$smarty->assign('service_phone', $GLOBALS['_CFG']['service_phone']);
$smarty->assign('shop_address', $GLOBALS['_CFG']['shop_address']);
$smarty->assign('licensed', license_info());
$smarty->assign('ecs_version', VERSION);
$smarty->assign('icp_number', $GLOBALS['_CFG']['icp_number']);
$smarty->assign('username', !empty($_SESSION['user_name']) ? $_SESSION['user_name'] : '');
$smarty->assign('category_list', cat_list(0, 0, true, 2, false));
$smarty->assign('catalog_list', cat_list(0, 0, false, 1, false));
$smarty->assign('navigator_list', get_navigator($ctype, $catlist));
//自定义导航栏
//查询地区 by wang
$GLOBALS['_CFG']['shop_country'] = !empty($GLOBALS['_CFG']['shop_country']) ? $GLOBALS['_CFG']['shop_country'] : '0';
$GLOBALS['_CFG']['shop_province'] = !empty($GLOBALS['_CFG']['shop_province']) ? $GLOBALS['_CFG']['shop_province'] : '0';
$GLOBALS['_CFG']['shop_city'] = !empty($GLOBALS['_CFG']['shop_city']) ? $GLOBALS['_CFG']['shop_city'] : '0';
$condition_arr = array($GLOBALS['_CFG']['shop_country'], $GLOBALS['_CFG']['shop_province'], $GLOBALS['_CFG']['shop_city']);
$condition_str = implode(',', $condition_arr);
$sql = "select region_name from " . $GLOBALS['ecs']->table('region') . " where region_id in ({$condition_str})";
$region_arr = $GLOBALS['db']->getAll($sql);
$shop_region = '';
if (is_array($region_arr)) {
foreach ($region_arr as $value) {
$shop_region .= $value['region_name'];
}
}
$smarty->assign('shop_region', $shop_region);
//查询地区 by wang
if (!empty($GLOBALS['_CFG']['search_keywords'])) {
$searchkeywords = explode(',', trim($GLOBALS['_CFG']['search_keywords']));
} else {
$searchkeywords = array();
}
$smarty->assign('searchkeywords', $searchkeywords);
}
示例13: API_EditCategory
function API_EditCategory($post)
{
/* 加载后台主操作函数 */
require_once ROOT_PATH . ADMIN_PATH . '/includes/lib_main.php';
/* 初始化变量 */
$cat_id = !empty($_POST['cat_id']) ? intval($_POST['cat_id']) : 0;
$cat['parent_id'] = !empty($_POST['parent_id']) ? intval($_POST['parent_id']) : 0;
$cat['sort_order'] = !empty($_POST['sort_order']) ? intval($_POST['sort_order']) : 0;
$cat['keywords'] = !empty($_POST['keywords']) ? trim($_POST['keywords']) : '';
$cat['cat_desc'] = !empty($_POST['cat_desc']) ? $_POST['cat_desc'] : '';
$cat['measure_unit'] = !empty($_POST['measure_unit']) ? trim($_POST['measure_unit']) : '';
$cat['cat_name'] = !empty($_POST['cat_name']) ? trim($_POST['cat_name']) : '';
$cat['is_show'] = !empty($_POST['is_show']) ? intval($_POST['is_show']) : 0;
$cat['show_in_nav'] = !empty($_POST['show_in_nav']) ? intval($_POST['show_in_nav']) : 0;
$cat['style'] = !empty($_POST['style']) ? trim($_POST['style']) : '';
$cat['grade'] = !empty($_POST['grade']) ? intval($_POST['grade']) : 0;
$cat['filter_attr'] = !empty($_POST['filter_attr']) ? intval($_POST['filter_attr']) : 0;
/* 判断上级目录是否合法 */
$children = array_keys(cat_list($cat_id, 0, false));
// 获得当前分类的所有下级分类
if (in_array($cat['parent_id'], $children)) {
/* 选定的父类是当前分类或当前分类的下级分类 */
client_show_message(401);
}
if ($cat['grade'] > 10 || $cat['grade'] < 0) {
/* 价格区间数超过范围 */
client_show_message(402);
}
if (cat_exists($cat['cat_name'], $cat['parent_id'], $cat_id)) {
/* 同级别下不能有重复的分类名称 */
client_show_message(403);
}
$dat = $GLOBALS['db']->getRow("SELECT cat_name, show_in_nav FROM " . $GLOBALS['ecs']->table('category') . " WHERE cat_id = '{$cat_id}'");
if ($GLOBALS['db']->autoExecute($GLOBALS['ecs']->table('category'), $cat, 'UPDATE', "cat_id='{$cat_id}'")) {
if ($cat['cat_name'] != $dat['cat_name']) {
//如果分类名称发生了改变
$sql = "UPDATE " . $GLOBALS['ecs']->table('nav') . " SET name = '" . $cat['cat_name'] . "' WHERE ctype = 'c' AND cid = '" . $cat_id . "' AND type = 'middle'";
$GLOBALS['db']->query($sql);
}
if ($cat['show_in_nav'] != $dat['show_in_nav']) {
//是否显示于导航栏发生了变化
if ($cat['show_in_nav'] == 1) {
//显示
$nid = $GLOBALS['db']->getOne("SELECT id FROM " . $GLOBALS['ecs']->table('nav') . " WHERE ctype = 'c' AND cid = '" . $cat_id . "' AND type = 'middle'");
if (empty($nid)) {
//不存在
$vieworder = $GLOBALS['db']->getOne("SELECT max(vieworder) FROM " . $GLOBALS['ecs']->table('nav') . " WHERE type = 'middle'");
$vieworder += 2;
$uri = build_uri('category', array('cid' => $cat_id), $cat['cat_name']);
$sql = "INSERT INTO " . $GLOBALS['ecs']->table('nav') . " (name,ctype,cid,ifshow,vieworder,opennew,url,type) VALUES('" . $cat['cat_name'] . "', 'c', '{$cat_id}','1','{$vieworder}','0', '" . $uri . "','middle')";
} else {
$sql = "UPDATE " . $GLOBALS['ecs']->table('nav') . " SET ifshow = 1 WHERE ctype = 'c' AND cid = '" . $cat_id . "' AND type = 'middle'";
}
$GLOBALS['db']->query($sql);
} else {
//去除
$GLOBALS['db']->query("UPDATE " . $GLOBALS['ecs']->table('nav') . " SET ifshow = 0 WHERE ctype = 'c' AND cid = '" . $cat_id . "' AND type = 'middle'");
}
}
}
/* 更新分類信息成功 */
clear_cache_files();
// 清除缓存
admin_log($_POST['cat_name'], 'edit', 'category');
// 记录管理员操作
client_show_message(0, true);
}
示例14: cart_favourable_amount
/**
* 取得购物车中某优惠活动范围内的总金额
* @param array $favourable 优惠活动
* @return float
*/
function cart_favourable_amount($favourable)
{
$sql_where = $_SESSION['user_id'] > 0 ? "c.user_id='" . $_SESSION['user_id'] . "' " : "c.session_id = '" . SESS_ID . "' AND c.user_id=0 ";
//添加 www.68ecshop.com
/* 查询优惠范围内商品总额的sql */
/* 代码修改_start By www.68ecshop.com 将这块替换掉*/
$sql = "SELECT SUM(c.goods_price * c.goods_number) " . "FROM " . $GLOBALS['ecs']->table('cart') . " AS c, " . $GLOBALS['ecs']->table('goods') . " AS g " . "WHERE c.goods_id = g.goods_id " . "AND {$sql_where} " . "AND c.rec_type = '" . CART_GENERAL_GOODS . "' " . "AND g.supplier_id=" . $favourable['supplier_id'] . " " . "AND c.is_gift = 0 " . "AND c.goods_id > 0 ";
/* 代码修改_end By www.68ecshop.com */
/* 根据优惠范围修正sql */
if ($favourable['act_range'] == FAR_ALL) {
// sql do not change
} elseif ($favourable['act_range'] == FAR_CATEGORY) {
/* 取得优惠范围分类的所有下级分类 */
$id_list = array();
$cat_list = explode(',', $favourable['act_range_ext']);
foreach ($cat_list as $id) {
$id_list = array_merge($id_list, array_keys(cat_list(intval($id), 0, false)));
}
$sql .= "AND g.cat_id " . db_create_in($id_list);
} elseif ($favourable['act_range'] == FAR_BRAND) {
$id_list = explode(',', $favourable['act_range_ext']);
$sql .= "AND g.brand_id " . db_create_in($id_list);
} else {
$id_list = explode(',', $favourable['act_range_ext']);
$sql .= "AND g.goods_id " . db_create_in($id_list);
}
$sql .= isset($_REQUEST['sel_goods']) && !empty($_REQUEST['sel_goods']) ? " AND c.rec_id in (" . $_REQUEST['sel_goods'] . ") " : "";
//计算某个店铺的商品总额
if (isset($_REQUEST['suppid'])) {
$sql .= " AND g.supplier_id=" . intval($_REQUEST['suppid']);
}
//echo $sql;
/* 优惠范围内的商品总额 */
return $GLOBALS['db']->getOne($sql);
}
示例15: agency_goods_list
function agency_goods_list()
{
/* 过滤查询 */
$code = empty($_REQUEST['extension_code']) ? '' : trim($_REQUEST['extension_code']);
$code = $code == 'virtual_card' ? 'virtual_card' : '';
$cat_id = isset($_POST['cat_id']) ? intval($_POST['cat_id']) : 0;
$brand_id = isset($_POST['brand_id']) ? intval($_POST['brand_id']) : 0;
$keyword = isset($_POST['keyword']) ? trim($_POST['keyword']) : '';
$GLOBALS['smarty']->assign('action_link', list_link($is_add, $code));
$GLOBALS['smarty']->assign('cat_list', cat_list(0, $cat_id));
$GLOBALS['smarty']->assign('brand_list', get_brand_list());
$GLOBALS['smarty']->assign('search_keyword', $keyword);
$GLOBALS['smarty']->assign('brand_id', $brand_id);
$filter = array();
$filter['cat_id'] = $cat_id;
$filter['brand_id'] = $brand_id;
$filter['keyword'] = $keyword;
$filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'goods_id' : trim($_REQUEST['sort_by']);
$filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);
$where = ' WHERE is_delete = 0 and admin_agency_id = 0 ';
if ($code) {
$where .= " AND is_real = 0 ";
} else {
$where .= " AND is_real = 1 ";
}
if ($cat_id > 0) {
$where .= " AND cat_id = '{$cat_id}' ";
}
if ($brand_id > 0) {
$where .= " AND brand_id = '{$brand_id}' ";
}
if ($keyword) {
$where .= ' AND goods_name like \'%' . mysql_real_escape_string($keyword) . '%\'' . ' OR goods_sn like \'%' . $keyword . '%\'';
}
$admin_agency_id = admin_agency_id();
if ($admin_agency_id) {
$where .= " AND (SELECT goods_id FROM " . $GLOBALS['ecs']->table('goods_supplier') . " WHERE admin_agency_id = {$admin_agency_id} and host_goods_id = g.goods_id limit 1) is null";
}
/* 获得总记录数据 */
$sql = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('goods_supplier') . ' as g' . $where;
$filter['record_count'] = $GLOBALS['db']->getOne($sql);
$filter = page_and_size($filter);
/* 获得商品数据 */
$arr = array();
$sql = 'SELECT goods_id,goods_name,goods_sn,shop_price,costing_price' . ' FROM ' . $GLOBALS['ecs']->table('goods_supplier') . ' as g ' . $where . ' ORDER BY goods_id desc ';
$res = $GLOBALS['db']->selectLimit($sql, $filter['page_size'], $filter['start']);
while ($rows = $GLOBALS['db']->fetchRow($res)) {
$arr[] = $rows;
}
//是否已添加
foreach ($arr as $good_k => $good_v) {
$goods_id_arr[] = $good_v['goods_id'];
$goods_price_arr[] = $good_v['shop_price'];
}
$filter['goods_id_arr'] = json_encode($goods_id_arr);
$filter['goods_price_arr'] = json_encode($goods_price_arr);
//dump($arr);
return array('goods_res' => $arr, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
}