<?php

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

$type = Dever::db('cash/shop')->config['config_type'];

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

return array
(
    # 表名
    'name' => 'store',
    # 显示给用户看的名称
    'lang' => '仓库对账单',
    'order' => 80,
    '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}")',
        ),

        'store_id'      => array
        (
            'type'      => 'int-11',
            'name'      => '对账仓库',
            'default'   => '',
            'desc'      => '对账仓库',
            'match'     => 'is_numeric',
            'search'    => 'select',
            'option'    => $store,
            'update'    => 'hidden',
            'value'     => Dever::input('search_option_store_id'),
            'list'      => 'Dever::load("store/info-one#name", {store_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'      => true,
        ),

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

        'store_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=store"'),

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

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