<?php

$status = array
(
    1 => '未对账',
    2 => '已对账',
);

$type = array
(
    1 => '按月对账',
    2 => '按周对账',
    3 => '按天对账',
);

$shop = function()
{
	$array = array();
	$info = Dever::db('shop/info')->state();
	if($info)
	{
		$array += $info;
	}
	return $array;
};

return array
(
    # 表名
    'name' => 'shop_sell',
    # 显示给用户看的名称
    'lang' => '门店零售对账单',
    'order' => 89,
    'config_status' => $status,
    'config_type' => $type,
    # 数据结构
    'struct' => array
    (
    
        'id'        => array
        (
            'type'      => 'int-11',
            'name'      => 'ID',
            'default'   => '',
            'desc'      => '',
            'match'     => 'is_numeric',
            'search'    => 'order',
            //'list'      => true,
        ),

        'type'        => array
        (
            'type'      => 'tinyint-1',
            'name'      => '对账单类型',
            'default'   => '1',
            'desc'      => '对账单类型',
            'match'     => 'is_numeric',
        ),

        'day'     => array
        (
            'type'      => 'int-11',
            'name'      => '对账单时间',
            'default'   => '',
            'match'     => 'is_numeric',
            'desc'      => '',
            'search'	=> 'day',
            'order'		=> 'desc',
            'list'      => 'Dever::load("cash/lib/set.statDate", "{type}", "{day}")',
        ),

        'shop_id'      => array
        (
            'type'      => 'int-11',
            'name'      => '对账门店',
            'default'   => '',
            'desc'      => '对账门店',
            'match'     => 'is_numeric',
            'search'    => 'select',
            'option'    => $shop,
            'update'    => 'hidden',
            'value'     => Dever::input('search_option_shop_id'),
            'list'      => 'Dever::load("shop/info-one#name", {shop_id})',
        ),

        'start'     => array
        (
            'type'      => 'int-11',
            'name'      => '对账单开始时间',
            'default'   => '',
            'match'     => 'is_numeric',
            'desc'      => '',
        ),

        'end'     => array
        (
            'type'      => 'int-11',
            'name'      => '对账单结束时间',
            'default'   => '',
            'match'     => 'is_numeric',
            'desc'      => '',
            'list_name'	=> '对账周期',
            'list'		=> 'Dever::load("cash/lib/set.statTime", "{start}", "{end}")',
        ),

        'cash'      => array
        (
            'type'      => 'varchar-100',
            'name'      => '对账金额',
            'default'   => '0',
            'desc'      => '对账金额',
            'match'     => 'option',
            'update'    => 'text',
            'list'      => 'Dever::load("cash/lib/set.getCash", "{cash}")',
        ),

        'num'      => array
        (
            'type'      => 'varchar-100',
            'name'      => '对账数量',
            'default'   => '0',
            'desc'      => '对账数量',
            'match'     => 'option',
            'update'    => 'text',
            //'list'		=> true,
        ),

        'shop_status'        => array
        (
            'type'      => 'int-11',
            'name'      => '门店对账状态',
            'default'   => '1',
            'desc'      => '门店对账状态',
            'match'     => 'is_numeric',
            'update'    => 'radio',
            'search'    => 'select',
            'option'    => $status,
            'list'      => true,
        ),

        'status'        => array
        (
            'type'      => 'int-11',
            'name'      => '平台对账状态',
            'default'   => '1',
            'desc'      => '平台对账状态',
            'match'     => 'is_numeric',
            'update'    => 'radio',
            'search'    => 'select',
            'option'    => $status,
            '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})',
            //'list'      => 'Dever::load("service/lib/manage.showOrderTime", "{id}")',
        ),
    ),

    'manage' => array
    (
        'delete' => false,
        'edit' => false,
        'insert' => false,
        'excel'	=> true,

        'list_button' => array(

        	'list' => array('查看详情', '"order&project=cash&id={id}&page_type=1&type=shop_sell"'),

            'oper'  => array('确认对账金额', '"cash/lib/set.audit?id={id}&type=shop_sell"', '{status} == 1', 'Dever::load("cash/lib/set.statYes", "{id}", "shop_sell")', '请确认'),
        ),
    ),

    'request' => array
    (
        # 获取总金额
        'getAll' => array
        (
            # 匹配的正则或函数 选填项
            'option' => array
            (
                'start' => array('yes-day', '>='),
                'end' => array('yes-day', '<='),
                'shop_id' => 'yes',
                'status' => 'yes',
                'state' => 1,
            ),
            'type' => 'all',
            'order' => array('day'=>'desc','id' => 'desc'),
            'page' => array(10, 'list'),
            'col' => '*',
        ),
    ),
);