<?php
$list_button = array();
if (Dever::load('manage/auth')->checkFunc('clue.salepeople', 'edit', '回收全部线索')) {
    $list_button['oper'] = array('回收全部线索','clue/lib/info.back_people?id={id}');
}
$button = array();
if (Dever::load('manage/auth')->checkFunc('clue.salepeople', 'cluesource', '线索来源设置'))
{
$button['线索来源设置'] = array('location', 'l=project/database/list&project=clue&table=source&&oper_table=salepeople');
}
if (Dever::load('manage/auth')->checkFunc('clue.salepeople', 'cluesalestatus', '线索状态设置'))
{
$button['线索状态设置'] = array('location', 'l=project/database/list&project=clue&table=sale_status&&oper_table=salepeople');
}
return array
(
    # 表名
    'name' => 'salepeople',
    # 显示给用户看的名称
    'lang' => '线索销售员设置',
    # 后台菜单排序
    'order' => 1,
    // 'menu' => false,
    // 'auto' => 100000,
    // 'check' => 'group_id',
    'start' => array
    (
        'insert' => 'clue/lib/info.insertSell',
        'update' => 'clue/lib/info.insertSell',
    ),
    'end' => array
    (
        'insert' => 'clue/lib/info.updateSell',
        'update' => 'clue/lib/info.updateSell',
    ),
    # 数据结构
    'struct' => array
    (
        'id'        => array
        (
            'type'      => 'int-11',
            'name'      => 'ID',
            'default'   => '',
            'desc'      => '',
            'match'     => 'is_numeric',
            'search'    => 'order',
            'list'      => true,
            'order'     => 'desc',
        ),

        'company_id'       => array
        (
            'type'      => 'int-11',
            'name'      => '所属公司',
            'default'   => '1',
            'desc'      => '所属公司',
            'match'     => 'is_numeric',
            'update'    => 'hidden',
            //'search'    => $company ? 'select' : false,
            //'list'      => true,
        ),

        'group'      => array
        (
            'type'      => 'varchar-100',
            'name'      => '销售员和部门',
            'default'   => '-1',
            'desc'      => '部门名称',
            'match'     => 'is_string',
            // 'option'    => $group,
            'update'    => 'linkage',
            'option'    => Dever::url('lib/appoint.get?level_total=2', 'work'),
            'list'      => 'Dever::load("clue/lib/manage.getSale#name",{id})',
        ),



        'group_id'      => array
        (
            'type'      => 'int-11',
            'name'      => '部门',
            'default'   => '-1',
            'desc'      => '部门id',
            'match'     => 'is_string',
            // 'option'    => $cadre,
            'update'    => 'hidden',
        ),

        'reorder'       => array
        (
            'type'      => 'int-11',
            'name'      => '排序-数值越大越靠前',
            'default'   => '1',
            'desc'      => '请输入排序',
            'match'     => 'option',
            'update'  => 'text',
            'search'    => 'order',
        ),

        'state'     => array
        (
            'type'      => 'tinyint-1',
            'name'      => '状态',
            'default'   => '1',
            'desc'      => '请选择状态',
            'match'     => 'is_numeric',
        ),
        
        'cdate'     => array
        (
            'type'      => 'int-11',
            'name'      => '创建时间',
            'match'     => array('is_numeric', time()),
            'desc'      => '',
            # 只有insert时才生效
            'insert'    => true,
            'list'      => 'date("Y-m-d H:i:s", {cdate})',
        ),
    ),

    'manage' => array
    (
    	//'insert' => false,
        // 'delete' => false,
        // 'edit' => false,
        'list_button' => $list_button,
        'button' => $button,
       
        # 设置公司权限
        'company' => 'company_id',
    ),

    'request' => array
    (
        'getAll' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                // 'id' => array('yes','>'),
                'state' => 1,
            ),
            'type' => 'all',
            'order' => array('reorder' => 'desc', 'id' => 'asc'),
            'col' => '*',
        ),
        'getState' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                // 'id' => array('yes','>'),
                'state' => 1,
            ),
            'type' => 'all',
            'order' => array('reorder' => 'desc', 'id' => 'asc'),
            'col' => '*|group_id',
        ),
    ),
);
