Exemple #1
0
function cateTree($pid = 0, $level = 0, $db = 0, $Status = '')
{
    $cate = M('' . $db . '');
    $array = array();
    $arrayWhere = array();
    if ($Status == '') {
        $arrayWhere = array('pid' => $pid);
    } else {
        $arrayWhere = array('pid' => $pid, 'status' => $Status);
    }
    //     if($level!=0&&isset($level))
    //     {
    //         array_push($arrayWhere, array('level' => array('elt',$level)));
    //     }
    //var_dump($arrayWhere);
    $tmp = $cate->where($arrayWhere)->order("sort")->select();
    //      var_dump($cate->getLastSql());
    //      return $cate->getLastSql();
    if (is_array($tmp)) {
        foreach ($tmp as $v) {
            $v['level'] = $level;
            // $v['pid']>0;
            $array[count($array)] = $v;
            $sub = cateTree($v['id'], $level + 1, $db, $Status);
            if (is_array($sub)) {
                $array = array_merge($array, $sub);
            }
        }
    }
    return $array;
}
 public function _befor_view()
 {
     $list = cateTree($pid = 0, $level = 0, $this->dbname);
     $this->assign('type', I('get.type'));
     $this->assign('list', $list);
 }
Exemple #3
0
function cateTree($data, $p = '', $pid)
{
    $p = empty($p) ? '' : $p . ' - ';
    $cls = empty($p) ? "style ='font-weight:bold'" : '';
    $html = '';
    foreach ($data as $k) {
        $html .= "<tr>\n\t\t\t\t  <td {$cls}>" . $k['a'] . "</td>\n\t\t\t\t  <td {$cls}> " . $p . $k['t'] . "</td>\n\t\t\t\t  <td {$cls}>\n\t\t\t\t  <a href='javascript:;' onclick='edit(" . $k['a'] . ")'>修改</a>&nbsp;";
        if (empty($p)) {
            $html .= "<a href='" . U('group/Admin/delCategory', array('id' => $k['a'])) . "' onclick='javascript:return confirm('确实删除“" . $k['t'] . "”?');'>删除</a>";
        } else {
            $html .= "<a href='" . U('group/Admin/delCategory', array('id' => $k['a'], 'pid' => $pid)) . "' onclick='javascript:return confirm('确实删除“" . $p . $k['t'] . "”?');'>删除</a>";
        }
        $html .= "</td></tr>";
        $html .= !empty($k['d']) ? cateTree($k['d'], $p . $k['t'], $k['a']) : '';
    }
    return $html;
}
Exemple #4
0
/**
 * 生成父子关系
 * @param  integer $pid   [description]
 * @param  integer $level [description]
 * @param  integer $db    [description]
 * @return [type]         [description]
 */
function cateTree($pid = 0, $level = 0, $db = 0)
{
    $cate = M('' . $db . '');
    $array = array();
    $tmp = $cate->where(array('pid' => $pid))->order("sort")->select();
    if (is_array($tmp) && !empty($tmp)) {
        foreach ($tmp as $v) {
            $v['level'] = $level;
            $array[] = $v;
            $sub = cateTree($v['id'], $level + 1, $db);
            if (is_array($sub) && !empty($sub)) {
                $array = array_merge($array, $sub);
            }
        }
    }
    return $array;
}
 public function GetMasters()
 {
     //规定类型
     //$orglist=M("Provsions")->where("status=1")->field("id,name,level")->order("sort asc")->select();
     //var_dump($list);
     $list = cateTree($id = 0, $level = 0, "Provsions", $status = 1);
     $this->assign('provsionslist', $list);
     //部门
     $orglist = cateTree($id = 0, $level = 0, "Org");
     //M("Org")->where("status=1")->field("id,name,level")->order("sort asc")->select();
     //var_dump($list);
     $this->assign('orglist', $orglist);
     $strID = $_REQUEST['id'];
     $fujian_flag = M($this->dbname)->table(C('DB_PREFIX') . "provsionspublish a")->join("left join " . C('DB_PREFIX') . "files b on a.attid=b.attid")->field("a.id,sum(if(ifnull(b.id,'')='',0,1)) attcount")->where("a.id='" . $strID . "'")->select();
     $attcount = 0;
     if (count($fujian_flag) > 0) {
         $attcount = $fujian_flag[0]["attcount"];
     }
     $this->assign('attcount', $attcount);
 }
 public function GetMasters()
 {
     //规定类型
     //$orglist=M("Provsions")->where("status=1")->field("id,name,level")->order("sort asc")->select();
     //var_dump($list);
     $list = cateTree($id = 0, $level = 0, "Provsions", $status = 1);
     $this->assign('provsionslist', $list);
     //部门
     $orglist = cateTree($id = 0, $level = 0, "Org");
     //M("Org")->where("status=1")->field("id,name,level")->order("sort asc")->select();
     //var_dump($list);
     $this->assign('orglist', $orglist);
 }
 public function _befor_edit()
 {
     $list = cateTree($pid = 0, $level = 0, 'uv_authrule');
     $this->assign('list', $list);
 }
 public function _befor_edit()
 {
     $list = cateTree($pid = 0, $level = 0, $this->dbname);
     $this->assign('list', $list);
 }