<?php
/*
@author waychar
@技术支持 150572314@qq.com
@copyright 2018 waychar.cn 声明：本代码可以用于学习交流使用及要商业化用途
*/
class admin extends db
{
    public function getbasicColumnslist()
    {
        $sql = "select * from table_columns_basic";
        $result = $this->get_data($sql);

        return $result;
    }

    public function table_type_select($table_type)
    {
        $out = "
				<select name = table_type>
					<option value = 1 " . $this->is_select(1, $table_type) . ">客户信息</option>
					<option value = 2 " . $this->is_select(2, $table_type) . ">联系人信息</option>
					<option value = 3 " . $this->is_select(3, $table_type) . ">员工详细信息</option>
					<option value = 4 " . $this->is_select(4, $table_type) . ">项目管理信息</option>
				</select>";

        return $out;
    }

    public function is_select($in, $out)
    {
        if ($in == $out) {
            return "selected";
        }
    }

    public function getPrvmenu($select_id)
    {
        $sql = "select menu_id,menu_name from news_menu where prv_menu_id = 0";
        $result = $this->get_data($sql);

        $out = "<select name = prv_menu_id>
				<option value = 0 " . $this->is_select(0, $select_id) . ">--</option>";
        if ($result) {
            foreach ($result as $row) {
                $out .= "<option value = " . $row['menu_id'] . " " . $this->is_select($row['menu_id'], $select_id) . ">" . $row['menu_name'] . "</option>";
                $out .= $this->get_child($row['menu_id'], "-", $select_id);
            }
        }
        $out .= "</select>";
        return $out;
    }

    public function get_child($menu_id, $before, $select_id)
    {
        $sql = "select menu_id,menu_name from news_menu where prv_menu_id =$menu_id";
        $result = $this->get_data($sql);

        $out = "";
        if ($result) {
            foreach ($result as $row) {
                $out .= "<option value=" . $row['menu_id'] . " " . $this->is_select($row['menu_id'], $select_id) . ">$before" . $row['menu_name'] . "</option>";
                $sql_check_prv = "select menu_id from news_menu where prv_menu_id = " . $row['menu_id'];
                $result_check_prv = $this->get_One($sql_check_prv);

                if ($result_check_prv) {
                    $before .= "-";
                    $out .= $this->get_child($row['menu_id'], $before, $select_id);
                }
            }
        }
        return $out;
    }

    public function getAdminNewsMenu()
    {
        $sql = "select menu_id,menu_name,prv_menu_id from news_menu ";
        $result = $this->get_data($sql);

        return $result;
    }

    public function getAdminNewsList($post, $page)
    {

    }
}