コード例 #1
0
ファイル: GoodsController.class.php プロジェクト: noikiy/sryy
 public function goods()
 {
     $map = array();
     $goods_name = trim($_GET['goods_name']);
     $gc_id = intval($_GET['gc_id']);
     if ($goods_name) {
         $map['goods_name'] = array('like', '%' . $goods_name . '%');
     }
     if ($gc_id) {
         $all_next_gc_id = '';
         $in_arr = get_all_gc_id($gc_id);
         //该分类下的所有分类
         $all_next_gc_id = '';
         $map['gc_id'] = array('in', $in_arr);
     }
     $totalRows = $this->model->where($map)->count();
     $page = new Page($totalRows, 10);
     $list = $this->model->where($map)->relation('GoodsClass')->limit($page->firstRow . ',' . $page->listRows)->order('add_time desc')->select();
     $this->assign('list', $list);
     $this->assign('search', $_GET);
     $this->assign('page_show', $page->show());
     /**
      * 父类列表,只取到第二级
      */
     $class_list = getTreeClassList(3);
     if (is_array($class_list)) {
         foreach ($class_list as $k => $v) {
             $class_list[$k]['gc_name'] = str_repeat(" ", $v['deep'] * 2) . '├ ' . $v['gc_name'];
         }
     }
     $this->assign('class_list', $class_list);
     $this->display();
 }
コード例 #2
0
ファイル: function.php プロジェクト: noikiy/ypx
/**
 * 显示某类别的所有下级类别ID
 *
 * @param int $f_pid 类别id
 * @return string 
 */
function get_all_gc_id($pid)
{
    global $all_next_gc_id;
    $rs = M("GoodsClass")->where('gc_parent_id=' . $pid)->order('gc_sort asc')->select();
    if (is_array($rs) && !empty($rs)) {
        foreach ($rs as $vo) {
            $all_next_gc_id .= $vo['gc_id'] . ',';
            get_all_gc_id($vo['gc_id']);
        }
    }
    return $all_next_gc_id . $pid;
}
コード例 #3
0
 public function goods_class_del()
 {
     $GoodsClass = M("GoodsClass");
     $gc_id = intval($_GET['gc_id']);
     if ($gc_id) {
         $map = array();
         $all_next_gc_id = '';
         $in_arr = get_all_gc_id($gc_id);
         //该分类下的所有分类
         $all_next_gc_id = '';
         $map['gc_id'] = array('in', $in_arr);
         $gc_list = $GoodsClass->where($map)->select();
         if (is_array($gc_list) && !empty($gc_list)) {
             foreach ($gc_list as $gc) {
                 if ($gc['gc_img']) {
                     //删除图片
                     @unlink(BasePath . '/Uploads/' . $gc['gc_img']);
                 }
             }
         }
         $delnum = $GoodsClass->where($map)->delete();
         if ($delnum) {
             $this->success('操作成功!', U('goods_class'));
         } else {
             $this->error('操作失败!');
         }
     }
 }