<?php

$mid = Dever::input('search_option_mid');
$button = array();
if ($mid) {
    $button = array
    (
        // '返回上一页' => array('location', 'l=project/database/list&project=agent&table=member_area&page_type=1&mid=' . $mid),
    );
}

$role = function()
{
    $array = array();
    $data = Dever::load('setting/role-state');
    if($data)
    {
        $array += $data;
    }
    return $array;
};

$type = array
(
    1 => '客户修改',
    2 => '后台修改',
);

return array
(
    # 表名
    'name' => 'member_area_log',
    # 显示给用户看的名称
    'lang' => '区域变更记录',
    'order' => 9,
    # 数据结构
    'struct' => array
    (
    
        'id'        => array
        (
            'type'      => 'int-11',
            'name'      => 'ID',
            'default'   => '',
            'desc'      => '',
            'match'     => 'is_numeric',
            'search'    => 'order',
            'update'    => 'hidden',
            //'list'        => true,
        ),

        'mid'      => array
        (
            'type'      => 'int-11',
            'name'      => '代理商姓名/手机号',
            'default'   => '-1',
            'desc'      => '代理商',
            'match'     => 'is_string',
            'update'    => 'text',
            'search'    => array
            (
                'api' => 'agent/member-getSearch',
                'col' => 'col',
                'result' => 'id',
                'search' => 'mid',
            ),
            'list_name' => '代理商信息',
            'list'      => 'Dever::load("agent/lib/member.getOne", {mid}, "agent/member", true)',
            'list_order' => 1,
        ),

        'order_id'      => array
        (
            'type'      => 'int-11',
            'name'      => '关联订单',
            'default'   => '',
            'desc'      => '关联订单',
            'match'     => 'is_numeric',
            // 'list'		=> 'Dever::db("agent/order-find#order_num", {order_id})',
            // 'list'      => true,
            // 'list_order' => 6,
        ),

        'agent-member-name'=> array
        (
            'name'      => '代理商',
            'default'   => '',
            'desc'      => '代理商',
            'match'     => 'option',
            # 读取另外表的关联方式
            'sync'      => array('mid', 'id'),
            //'list'      => $mid ? false : true,
            //'list_order' => 3,
        ),

        'old_area'       => array
        (
            'type'      => 'varchar-500',
            'name'      => '变更前区域',
            'default'   => '',
            'desc'      => '变更前区域',
            'match'     => 'option',
            //'search'    => 'linkage',
            'update'    => 'linkage',
            'option'    => Dever::url('api.get?level_total=4', 'area'),
            'list'      => 'Dever::load("area/api.string", "{old_area}")',
        ),

        'area'       => array
        (
            'type'      => 'varchar-500',
            'name'      => '变更后区域',
            'default'   => '',
            'desc'      => '变更后区域',
            'match'     => 'option',
            //'search'    => 'linkage',
            'update'    => 'linkage',
            'option'    => Dever::url('api.get?level_total=4', 'area'),
            'list'      => 'Dever::load("area/api.string", "{area}")',
        ),

        'type'        => array
        (
            'type'      => 'tinyint-1',
            'name'      => '类型',
            'default'   => '1',
            'desc'      => '类型',
            'match'     => 'is_numeric',
            'update'    => 'radio',
            'option'    => $type,
        ),

        'audit_date'     => array
        (
            'type'      => 'int-11',
            'name'      => '审核时间',
            'match'     => 'is_numeric',
            'desc'      => '审核时间',
            'default'   => '',
        ),

        'audit_admin'     => array
        (
            'type'      => 'int-11',
            'name'      => '操作人',
            'default'   => '',
            'match'     => 'is_numeric',
            'desc'      => '操作人',
            'list'      => '"{audit_admin}" > 0 ? Dever::load("manage/admin-find#username", {audit_admin}) : "-"',
            // 'list_order'  => 8,
        ),
        '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,
            'search'    => 'date',
            'list'      => 'date("Y-m-d H:i", {cdate})',
            'list_order' => 2,
        ),
    ),

    'manage' => array
    (
        'edit' => false,
        'insert' => false,
        'delete' => false,
        'button' => $button,
    ),

    'request' => array
    (
        'getData' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'mid' => 'yes',
                'type' => 'yes',
                'state' => 1,
            ),
            'order' => array('type' => 'asc', 'id' => 'desc'),
            'type' => 'all',
            'col' => '*, total_num-sell_num as num',
        ),
    ),
);