Beispiel #1
0
/**
 * 商户中心分类字段
 */
function insert_cate_id_select($param = array())
{
    $cate_id = 0;
    if ($param['cate_id'] > 0) {
        $cate_id = $param['cate_id'];
    }
    $cate_tree = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_cate where is_delete = 0");
    $cate_tree = toFormatTree($cate_tree, 'name');
    $html = '<select name="cate_id" class="require ui-select filter_select medium">';
    if ($cate_id == 0) {
        $html .= '<option value="0" selected="selected">==请选择分类==</option>';
    } else {
        $html .= '<option value="0" >==请选择分类==</option>';
    }
    foreach ($cate_tree as $k => $cate_item) {
        if ($cate_id == $cate_item['id']) {
            $html .= '<option value="' . $cate_item['id'] . '" selected="selected" >' . $cate_item['title_show'] . '</option>';
        } else {
            $html .= '<option value="' . $cate_item['id'] . '">' . $cate_item['title_show'] . '</option>';
        }
    }
    $html .= '</select>';
    return $html;
}
Beispiel #2
0
 public function edit()
 {
     /* 基本参数初始化 */
     init_app_page();
     $account_info = $GLOBALS['account_info'];
     $supplier_id = $account_info['supplier_id'];
     $account_id = $account_info['id'];
     $id = intval($_REQUEST['id']);
     $edit_type = intval($_REQUEST['edit_type']);
     if ($edit_type == 1 && $id > 0) {
         //判断是否有存在修改
         $deal_submit_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_submit where deal_id = " . $id . " and supplier_id = " . $supplier_id);
         if ($deal_submit_info && $deal_submit_info['admin_check_status'] == 0) {
             showBizErr("已经存在申请操作,请先删除避免重复申请", 0, url("biz", "goods#index"));
             exit;
         }
     }
     /* 业务逻辑 */
     if ($edit_type == 1) {
         //管理员发布
         /*********************************
          * 取真正的商品数据表数据
          ********************************/
         $deal_info = $GLOBALS['db']->getRow("select d.* from " . DB_PREFIX . "deal d left join " . DB_PREFIX . "deal_location_link dll on dll.deal_id = d.id  where d.is_effect = 1 and d.is_delete = 0 and is_shop=1 and id=" . $id . " and supplier_id = " . $supplier_id . "\n                         and dll.location_id in(" . implode(",", $account_info['location_ids']) . ")");
         if (empty($deal_info)) {
             showBizErr("数据不存在或没有操作权限!", 0, url("biz", "goods#index"));
             exit;
         }
         //支持门店 , 门店选中状态
         $location_infos = $GLOBALS['db']->getAll("select id,name from " . DB_PREFIX . "supplier_location where id in(" . implode(",", $GLOBALS['account_info']['location_ids']) . ")");
         $curr_location_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_location_link where  deal_id = " . $id);
         foreach ($curr_location_list as $k => $v) {
             $curr_locations[] = $v['location_id'];
         }
         foreach ($location_infos as $k => $v) {
             if (in_array($v['id'], $curr_locations)) {
                 $location_infos[$k]['checked'] = 1;
             }
         }
         // 图集
         $img_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_gallery where deal_id=" . $id . " order by sort asc");
         $imgs = array();
         foreach ($img_list as $k => $v) {
             $focus_imgs[$v['sort']] = $v['img'];
         }
         // 输出规格库存的配置
         $attr_stock = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "attr_stock where deal_id=" . $id . " order by id asc");
         $go_list_url = url("biz", "goods#index");
     } elseif ($edit_type == 2) {
         //商户提交
         /**********************************
          * 取商户提交数据表
          *********************************/
         $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_submit where is_shop = 1 and id=" . $id . " and supplier_id = " . $supplier_id);
         if (empty($deal_info)) {
             showBizErr("数据不存在或没有操作权限!", 0, url("biz", "goods#no_online_index"));
             exit;
         }
         // 支持门店 , 门店选中状态
         $cache_location_id = unserialize($deal_info['cache_location_id']);
         $location_infos = $GLOBALS['db']->getAll("select id,name from " . DB_PREFIX . "supplier_location where id in(" . implode(",", $GLOBALS['account_info']['location_ids']) . ")");
         foreach ($location_infos as $k => $v) {
             if (in_array($v['id'], $cache_location_id)) {
                 $location_infos[$k]['checked'] = 1;
             }
         }
         // 图集
         $focus_imgs = unserialize($deal_info['cache_focus_imgs']);
         //筛选关键词
         $filter = unserialize($deal_info['cache_deal_filter']);
         // 输出规格库存的配置
         $attr_stock = unserialize($deal_info['cache_attr_stock']);
         $go_list_url = url("biz", "goods#no_online_index");
     }
     // 商品分类
     $shop_cate_tree = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "shop_cate where is_delete = 0");
     $shop_cate_tree = toFormatTree($shop_cate_tree, "name");
     //品牌名称
     $brand_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "Brand");
     //转换头部SCRIPT 用的 库存 JSON
     $attr_cfg_json = "{";
     $attr_stock_json = "{";
     foreach ($attr_stock as $k => $v) {
         $attr_cfg_json .= $k . ":" . "{";
         $attr_stock_json .= $k . ":" . "{";
         foreach ($v as $key => $vvv) {
             if ($key != 'attr_cfg') {
                 $attr_stock_json .= "\"" . $key . "\":" . "\"" . $vvv . "\",";
             }
         }
         $attr_stock_json = substr($attr_stock_json, 0, -1);
         $attr_stock_json .= "},";
         $attr_cfg_data = unserialize($v['attr_cfg']);
         foreach ($attr_cfg_data as $attr_id => $vv) {
             $attr_cfg_json .= $attr_id . ":" . "\"" . $vv . "\",";
         }
         $attr_cfg_json = substr($attr_cfg_json, 0, -1);
         $attr_cfg_json .= "},";
     }
     if ($attr_stock) {
         $attr_cfg_json = substr($attr_cfg_json, 0, -1);
         $attr_stock_json = substr($attr_stock_json, 0, -1);
     }
     $attr_cfg_json .= "}";
     $attr_stock_json .= "}";
     /*******************************************
      * 通用数据部分
      ********************************************/
     // 商品类型
     $goods_type_list = $GLOBALS['db']->getAll("select id,name from " . DB_PREFIX . "goods_type");
     foreach ($goods_type_list as $k => $v) {
         if ($v['id'] == $deal_info['deal_goods_type']) {
             $goods_type_list[$k]['selected'] = 1;
             break;
         }
     }
     // 标签数据
     for ($i = 0; $i < 10; $i++) {
         if ($i != 1 && $i != 3 && $i != 4 && $i != 5) {
             if (($deal_info['deal_tag'] & pow(2, $i)) == pow(2, $i)) {
                 $tags_html .= '<label class="ui-checkbox" rel="common_cbo"><input type="checkbox" name="deal_tag[]" value="' . $i . '" checked="checked"/>' . lang("DEAL_TAG_" . $i) . '</label>';
             } else {
                 $tags_html .= '<label class="ui-checkbox" rel="common_cbo"><input type="checkbox" name="deal_tag[]" value="' . $i . '" />' . lang("DEAL_TAG_" . $i) . '</label>';
             }
         }
     }
     // 时间格式化
     $deal_info['begin_time'] = to_date($deal_info['begin_time'], "Y-m-d H:i");
     $deal_info['end_time'] = to_date($deal_info['end_time'], "Y-m-d H:i");
     $deal_info['coupon_begin_time'] = to_date($deal_info['coupon_begin_time'], "Y-m-d H:i");
     $deal_info['coupon_end_time'] = to_date($deal_info['coupon_end_time'], "Y-m-d H:i");
     /* 数据 */
     $GLOBALS['tmpl']->assign("shop_cate_tree", $shop_cate_tree);
     // 商品分类
     $GLOBALS['tmpl']->assign("brand_list", $brand_list);
     // 品牌
     $GLOBALS['tmpl']->assign("goods_type_list", $goods_type_list);
     // 属性类型
     $GLOBALS['tmpl']->assign("attr_cfg_json", $attr_cfg_json);
     // 属性配置
     $GLOBALS['tmpl']->assign("attr_stock_json", $attr_stock_json);
     // 属性配置
     $GLOBALS['tmpl']->assign("location_infos", $location_infos);
     // 支持门店
     $GLOBALS['tmpl']->assign("tags_html", $tags_html);
     // 标签数据
     $GLOBALS['tmpl']->assign("filter", $filter);
     // 筛选关键词
     $GLOBALS['tmpl']->assign("focus_imgs", $focus_imgs);
     // 图集数组
     $GLOBALS['tmpl']->assign("deal_info", $deal_info);
     // 商品所有数据
     $GLOBALS['tmpl']->assign("edit_type", $edit_type);
     // 请求数据类型
     $GLOBALS['tmpl']->assign("go_list_url", $go_list_url);
     // 返回列表连接
     /* 系统默认 */
     $GLOBALS['tmpl']->assign("ajax_url", url("biz", "goods"));
     $GLOBALS['tmpl']->assign("page_title", "商品项目编辑");
     $GLOBALS['tmpl']->display("pages/project/goods_edit.html");
 }