<?php

$status = array
(
    1 => array('name' => '待业务初审', 'style' => 'font-weight:bold;color:#436EEE'),
    2 => array('name' => '待财务终审', 'style' => 'font-weight:bold;color:#436EEE'),
    3 => array('name' => '已完成', 'style' => 'font-weight:bold;color:green'),
    4 => array('name' => '驳回', 'style' => 'font-weight:bold;color:#CD3700'),
);

$manage_audit = array
(
    //1 => '待审核',
    2 => '已审核',
    3 => '已作废',
);
$type = array
(
    1 => '未签署',
    2 => '已签署',
    3 => '已作废',
);
$role = function()
{
    $array = array();
    $data = Dever::load('setting/role-state');
    if($data)
    {
        $array += $data;
    }
    return $array;
};

$insert = false;
$col = Dever::input('col');
if (Dever::load('manage/auth')->checkFunc('agent.soft_cash', 'editnew', '新增')) {
	$insert = true;
}
$button = array();
$excel = false;
if(Dever::load('manage/auth')->checkFunc('agent.soft_cash', 'editSoftcash', '数据导出')){
        $excel[] = array('数据导出','软件服务费', 'agent/lib/soft_cash.out_soft_cash');
    }
return array
(
    # 表名
    'name' => 'soft_cash',
    # 显示给用户看的名称
    'lang' => '软件服务费',
    'menu' => true,
    'config_status' => $status,
    'config_type' => $type,
    'start' => array
    (
        'insert' => 'agent/lib/soft_cash.insertSoft',
    ),
    'end' => array
    (
    	'insert' => 'agent/lib/soft_cash.updateSoft',
        'update' => 'agent/lib/soft_cash.updateSoft',
    ),
    # 数据结构
    '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'      => 'Dever::load("agent/lib/member.getOne", {mid}, "agent/member", true)',
            'list_order' => 2,
        ),
         'mobile'      => array
        (
            'type'      => 'bigint-11',
            'name'      => '代理商手机号',
            'default'   => '',
            'desc'      => '请输入手机号',
            'match'     => Dever::rule('mobile'),
            'update'    => 'text',
            # 绑定js脚本，更新时使用，第一个参数是执行的方式，第二个参数执行的方法，第三个参数是传值。
            'bind'        => array('onblur', 'loading', array('url' => Dever::url("lib/soft_cash.search", 'agent'))),
            //'search'    => 'fulltext',
            //'list'      => true,
        ),
     
       'order_num'      => array
        (
            'type'      => 'varchar-100',
            'name'      => '订单号',
            'default'   => '',
            'desc'      => '订单号',
            'match'     => 'is_string',
            // 'update'    => 'text',
            //'search'    => 'fulltext',
            'list_name' => '订单号<br />购买时间<br/>添加时间',
            'list'      => 'Dever::load("agent/lib/soft_cash.soft_show#num",{id})',
            'list_order' => 1,
        ),

        'role'      => array
        (
            'type'      => 'int-11',
            'name'      => '代理角色',
            'default'   => '',
            'desc'      => '代理角色',
            'match'     => 'is_numeric',
            // 'search'    => 'select',
            // 'update'    => 'select',
            'option'    => $role,
            'list'      => true,
        ),

        'agreement_id'      => array
        (
            'type'      => 'int-11',
            'name'      => '合同',
            'default'   => '-1',
            'desc'      => '合同',
            'match'     => 'is_string',
            // 'update'    => 'text',
        ),

        'cash'      => array
        (
            'type'      => 'decimal-11,2',
            'name'      => '软件服务费用',
            'default'   => '0',
            'desc'      => '费用',
            'match'     => 'option',
            'update'    => 'text',
            'list'      => true,
        ),

        'price'      => array
        (
            'type'      => 'decimal-11,2',
            'name'      => '原始期权价值',
            'default'   => '0',
            'desc'      => '原始期权价值',
            'match'     => 'option',
            'update'    => 'text',
            'list'      => true,
        ),

        'pic'       => array
        (
            'type'      => 'text-255',
            'name'      => '支付凭证',
            'default'   => '',
            'desc'      => '多张图片',
            'match'     => 'is_string',
            'update'    => 'images',
            'key'       => '1',
            // 'place'     => '759*562',
        ),

        'status'        => array
        (
            'type'      => 'tinyint-1',
            'name'      => '订单状态',
            'default'   => '2',
            'desc'      => '订单状态',
            'match'     => 'is_numeric',
            // 'update'    => 'radio',
            'option'    => $status,
            'search'    => 'select',
            'list_name' =>'订单状态<br/>合同签署状态<br/>终审时间<br>签署时间',
            'list'      => 'Dever::load("agent/lib/soft_cash.list",{id})',

        ),
        'audit'        => array
        (
            'type'      => 'int-11',
            'name'      => '审核状态',
            'default'   => '2',
            'desc'      => '审核状态',
            'match'     => 'is_numeric',
            'update'    => $col ? 'radio' : false,
            'option'    => $manage_audit,
            'mul'       => true,
            'control'   => 'audit',
        ),

        'audit_desc'      => array
        (
            'type'      => 'varchar-600',
            'name'      => '备注',
            'default'   => '',
            'desc'      => '审核说明',
            'match'     => 'is_string',
            'update'    => $col ? 'textarea' : false,
            // 'list'      => '"{audit_desc}" ? "{audit_desc}" : "-"',
            // 'list_order'  => 9,
            'show'      => 'audit=3',
        ),

        'type'        => array
        (
            'type'      => 'tinyint-1',
            'name'      => '合同签署状态',
            'default'   => '1',
            'desc'      => '合同签署状态',
            'match'     => 'is_numeric',
            // 'update'    => 'radio',
            'option'    => $type,
            'search'    => 'select',
        ),

        'admin_desc'      => array
        (
            'type'      => 'varchar-600',
            'name'      => '管理员备注',
            'default'   => '',
            'desc'      => '管理员备注',
            'match'     => 'option',
            'update'    => 'textarea',
        ),

        'buy_date'     => array
        (
            'type'      => 'int-11',
            'name'      => '购买时间',
            'match'     => 'option',
            'default'   => '0',
            'desc'      => '',
            'match'     => 'is_numeric',
            'update'    => 'day',
            'search'    => 'date',
            'callback'  => 'maketime',
            // 'list'        => '{buy_date} > 0 ? date("Y-m-d H:i", {buy_date}) : "无"',
        ),

        'zdate'     => array
        (
            'type'      => 'int-11',
            'name'      => '终审时间',
            'default'   => '',
            'match'     => 'is_numeric',
            'search'    => 'date',
            'desc'      => '',
            // 'list'      => 'date("Y-m-d H:i:s", {zdate})',
        ),

        'fdate'     => array
        (
            'type'      => 'int-11',
            'name'      => '签署时间',
            'default'   => '',
            'match'     => 'is_numeric',
            'search'    => 'date',
            'desc'      => '',
            // 'list'      => 'date("Y-m-d H:i:s", {zdate})',
        ),

        '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})',
        ),
    ),

    'alter' => array
    (
        10 => array
        (
            array('update', 'cash', 'cash', 'decimal-11,2 0 软件服务费'),
            array('update', 'price', 'price', 'decimal-11,2 0 期权价值'),
        ),
        'version' => 10,
    ),

    'manage' => array
    (
    	'insert' => $insert,
    	'delete' => false,
    	'edit'   => false,
        'excel' => $excel,
        'button' => $button,
    	'list_button' => array
        (
        	 'list' => array('查看详情', '"member_prize&project=agent&id={id}&page_type=1&[refer]"'),
        ),
    ),

    'request' => array
    (
        'getList' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                // 'main' => 'yes',
                'mobile' => 'yes',
                'state' => 1,
            ),
            'order' => array('id' => 'desc'),
            'type' => 'all',
            'col' => '*',
        ),

        'getTotal' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'fstart' => array('yes-fdate', '>='),
                'fend' => array('yes-fdate', '<='),
                'status' => array('yes', 'in'),
                'role' =>'yes',
                'mid' => 'yes',
                'state' => 1,
            ),
            'type' => 'one',
            'col' => 'sum(cash) as total',
        ),
        'getPrice' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'fstart' => array('yes-fdate', '>='),
                'fend' => array('yes-fdate', '<='),
                'status' => array('yes', 'in'),
                'role' =>'yes',
                'mid' => 'yes',
                'state' => 1,
            ),
            'type' => 'one',
            'col' => 'sum(price) as total',
        ),

        'getSoftCash' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'fstart' => array('yes-zdate', '>='),
                'fend' => array('yes-zdate', '<='),
                'status' => array('yes', 'in'),
                'role' =>'yes',
                'mid' => 'yes',
                'state' => 1,
            ),
            'type' => 'one',
            'col' => 'sum(cash) as total',
        ),
        'getSoftNoCash' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'fstart' => array('yes-cdate', '>='),
                'fend' => array('yes-cdate', '<='),
                'status' => array('yes', 'in'),
                'state' => 1,
            ),
            'type' => 'one',
            'col' => 'sum(cash) as total',
        ),
        'getSoftNum' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'fstart' => array('yes-zdate', '>='),
                'fend' => array('yes-zdate', '<='),
                'status' => array('yes','in'),
                'state' => 1,
            ),
            'type' => 'count',
            'col' => '*',
        ),
        'getSoftNoNum' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'fstart' => array('yes-cdate', '>='),
                'fend' => array('yes-cdate', '<='),
                'status' => array('yes','in'),
                'state' => 1,
            ),
            'type' => 'count',
            'col' => '*',
        ),

        'getExcelAll' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'fstart' => array('yes-zdate', '>='),
                'fend' => array('yes-zdate', '<='),
                'bstart' => array('yes-buy_date', '>='),
                'bend' => array('yes-buy_date', '<='),
                'start' => array('yes-fdate', '>='),
                'end' => array('yes-fdate', '<='),
                'status' => 'yes',
                'type' => 'yes',
                'state' => 1,
            ),
            'type' => 'all',
            'col' => '*',
        ),

    ),
);
