<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: ouyangzhaochang2663 $
    $Date: 2010/11/22 01:49:49 $
    $Revision: 1.2 $
    $Purpose: 会计期定义 - 创建期间
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure><![CDATA[     
    ]]></a:init-procedure>
    <a:view>
        <script type="text/javascript"><![CDATA[
            function closeWindow() {
                $('gld_period_create_window').close();
            }
            
            function createPeriod() {
                $('check_period_exists_ds').on('load', afterExitsQuery);
                $('check_period_exists_ds').query();
            }
            
            function afterExitsQuery() {
                if ($('check_period_exists_ds').getCurrentRecord().get('total') == 1) {
                    Leaf.showConfirm('${l:PROMPT}', '${l:PERIOD_ALREADY_EXISTS}', function(cmp) {
                        $('check_period_used_ds').on('load', afterUsedQuery);
                        $('check_period_used_ds').query();
                        cmp.close();
                    }, null, null, 100);
                } else {
                    $('check_period_used_ds').on('load', afterUsedQuery);
                    $('check_period_used_ds').query();
                }
            }
            
            function afterUsedQuery() {
                if ($('check_period_used_ds').getCurrentRecord().get('total') == 1) {
                    Leaf.showConfirm('${l:PROMPT}', '${l:PERIOD_ALREADY_EXISTS}', function() {
                        $('period_create_ds').submit();
                    }, null, null, 100);
                } else {
                    $('period_create_ds').submit();
                }
            }
            
            function oncreatePeriodSuccess() {
                Leaf.showMessage('${l:PROMPT}', '${l:CREATING_SUCCESS}');
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="period_create_ds" submitUrl="${/request/@context_path}/autocrud/db.gld_period_pkg.create_period/batch_update">
                <a:fields>
                    <a:field name="period_set_code" defaultValue="${/parameter/@period_set_code}"/>
                    <a:field name="year_from" required="true"/>
                    <a:field name="year_to" required="true"/>
                </a:fields>
                <a:events>
                    <a:event name="submitsuccess" handler="oncreatePeriodSuccess"/>
                </a:events>
            </a:dataSet>
            <a:dataSet id="check_period_exists_ds" autoCreate="true" model="gld.FND2120.gld_period_check_period_exists" queryDataSet="period_create_ds">
                <a:fields>
                    <a:field name="period_set_code" defaultValue="${/parameter/@period_set_code}"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="check_period_used_ds" autoCreate="true" model="gld.FND2120.gld_period_check_period_used" queryDataSet="period_create_ds">
                <a:fields>
                    <a:field name="period_set_code" defaultValue="${/parameter/@period_set_code}"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton click="closeWindow" text="HLS.CLOSE"/>
                <a:gridButton click="createPeriod" text="HLS.CREATE"/>
            </a:screenTopToolbar>
            <a:form column="1" title="GLD_PERIOD_SET.PERIOD_SET_QUERY" width="350">
                <a:textField name="period_set_code" bindTarget="periodSetInfoDs" prompt="GLD_PERIOD_SET.PERIOD_SET_CODE"/>
                <a:textField name="period_set_name" bindTarget="periodSetInfoDs" prompt="GLD_PERIOD_SET.PERIOD_SET_NAME"/>
                <a:numberField name="year_from" allowDecimals="false" allowNegative="false" bindTarget="period_create_ds" prompt="GLD_PERIOD_CREATE.YEAR_FROM"/>
                <a:numberField name="year_to" allowDecimals="false" allowNegative="false" bindTarget="period_create_ds" prompt="GLD_PERIOD_CREATE_YEAR_TO"/>
            </a:form>
        </a:screenBody>
    </a:view>
</a:screen>