<?php

$role = function()
{
    $info = Dever::db('setting/role')->select();
    return $info;
};

$value_type = array
(
    1 => '百分比',
    2 => '数值',
);

$is_give = array
(
	1 => '是',
	2 => '否',
);

$prize = function()
{
    $info = Dever::db('setting/prize')->select();
    return $info;
};

$role_id = Dever::input('search_option_role_id');

$update = false;
$value = '3,4';
if ($role_id) {
    $role_info = Dever::db('setting/role')->find($role_id);
    if ($role_info && $role_info['type'] == 2 && $role_info['area'] < 3) {
        if ($role_info['area'] == 2) {
            $value = '4';
        }
        $update = 'text';
    }
}

return array
(
    # 表名
    'name' => 'role_reward_give',
    # 显示给用户看的名称
    'lang' => '直推额外奖励',
    'menu' => false,
    # 数据结构
    'struct' => array
    (
    
        'id'        => array
        (
            'type'      => 'int-11',
            'name'      => 'ID',
            'default'   => '',
            'desc'      => '',
            'match'     => 'is_numeric',
            'search'    => 'order',
            'update'    => 'hidden',
            //'list'        => true,
        ),

        'reward_id'      => array
        (
            'type'      => 'int-11',
            'name'      => '角色信息',
            'default'   => '',
            'desc'      => '奖励id',
            'match'     => 'is_numeric',
            'update'    => 'hidden',
            //'search'    => 'hidden',
            'value'     => Dever::input('search_option_reward_id'),
            'list'      => 'Dever::load("setting/lib/manage.showReward", {reward_id})',
        ),

        'num'      => array
        (
            'type'      => 'int-11',
            'name'      => '推荐个数-每推荐多少个，就会赠送多少额外奖励',
            'default'   => '1',
            'desc'      => '推荐个数',
            'match'     => 'is_numeric',
            'update'    => 'text',
            'list'      => true,
        ),

        '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:s", {cdate})',
        ),
    ),

    'manage' => array
    (
    	'edit' => false,
        'list_button' => array
        (
        	'fast' => array('编辑', '"role_reward_give&where_id={id}&oper_save_jump=role_reward_give&oper_table=role_reward_give&oper_parent=role_reward_give"'),
            'location1' => array('权益设置', Dever::url('lib/reward_set.home', 'agent')),
        )
    ),

    'request' => array
    (
        'getData' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'reward_id' => 'yes',
                'state' => 1,
            ),
            'type' => 'all',
            'order' => array('num' => 'desc', 'cdate' => 'desc'),
            'col' => '*',
        ),
    ),
);
