<?php

$type = array
(
    1 => '普通价格',
    2 => '超值价格',
);

$time_type = array
(
    1 => '天',
    2 => '周',
    3 => '月',
    4 => '年',
);

# 获取小刊分类权限
$auth = Dever::tops();
$cate = function() use ($auth)
{
    $array = array();
    if ($auth) {
        $info = Dever::db('journal/cate')->getIds(array('ids' => $auth));
    } else {
        $info = Dever::db('journal/cate')->state();
    }
    if($info)
    {
        $array += $info;
    }
    return $array;
};

return array
(
    # 表名
    'name' => 'time',
    # 显示给用户看的名称
    'lang' => '时长设置',
    # 后台菜单排序
    'order' => 19,
    # 数据结构
    'struct' => array
    (
        'id'        => array
        (
            'type'      => 'int-11',
            'name'      => 'ID',
            'default'   => '',
            'desc'      => '',
            'match'     => 'is_numeric',
            'search'    => 'order',
            'list'      => true,
            'order'     => 'desc',
        ),

        'cate_id'       => array
        (
            'type'      => 'int-11',
            'name'      => '小刊分类',
            'default'   => '1',
            'desc'      => '小刊分类',
            'match'     => 'is_numeric',
            'update'    => 'select',
            'option'    => $cate,
            //'search'    => 'select',
            'list'      => true,
        ),
        
        'name'        => array
        (
            'type'      => 'varchar-300',
            'name'      => '时长名称-如1年',
            'default'   => '',
            'desc'      => '时长名称',
            'match'     => 'option',
            'search'    => 'fulltext',
            'update'    => 'text',
            'list'		=> true,
        ),

        'time_type'      => array
        (
            'type'      => 'int-11',
            'name'      => '时长单位设置',
            'default'   => '1',
            'desc'      => '时长单位设置',
            'match'     => 'is_numeric',
            'option'    => $time_type,
            'search'    => 'select',
            'update'    => 'select',
            //'list'        => true,
        ),
        
        'time'       => array
        (
            'type'      => 'int-11',
            'default'   => '',
            'name'      => '时长设置-以时长单位为准,直接填写数字即可,如时长单位设置为天,填写7就是7天,请注意,如果时长单位设置为天,这里定义365天,与一年是不同的,有的年份并不是365天,时长单位设置请选择年',
            'match'     => 'is_numeric',
            'desc'      => '时长设置',
            'update'    => 'text',
        ),

        'cash'       => array
        (
            'type'      => 'varchar-50',
            'default'   => '',
            'name'      => '当前价格',
            'match'     => 'is_numeric',
            'desc'      => '当前价格',
            'update'    => 'text',
            'list'		=> true,
        ),

        'price'       => array
        (
            'type'      => 'varchar-50',
            'default'   => '',
            'name'      => '原价格设置',
            'match'     => 'is_numeric',
            'desc'      => '原价格设置',
            'update'    => 'text',
        ),

        'type'      => array
        (
            'type'      => 'int-11',
            'name'      => '时长价格类型',
            'default'   => '1',
            'desc'      => '时长价格类型',
            'match'     => 'is_numeric',
            'option'    => $type,
            'search'    => 'select',
            'update'    => 'radio',
            //'list'        => true,
        ),

        'reorder'       => array
        (
            'type'      => 'int-11',
            'name'      => '排序(数值越大越靠前)',
            'default'   => '1',
            'desc'      => '请输入排序',
            'match'     => 'option',
            'update'    => 'text',
            'search'    => 'order',
            'list'      => true,
            'order'     => 'desc',
            'edit'      => 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,
            'list'      => 'date("Y-m-d H:i:s", {cdate})',
        ),
    ),

    'top' => Dever::config('base')->top,

    # 增加这个,为了给当前的list增加一个option
    'top_option' => array
    (
        'value' => $auth,
        'col' => 'cate_id',
    ),

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

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