<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: ouyangzhaochang2663 $
    $Date: 2010/11/24 02:44:22 $
    $Revision: 1.12 $
    $Purpose: 会计期定义
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure/>
    <a:view>
        <a:link id="gld_period_rule_readonly_link" url="${/request/@context_path}/modules/gld/FND2120/gld_period_rule_readonly.lview"/>
        <a:link id="gld_period_rule_link" url="${/request/@context_path}/modules/gld/FND2120/gld_period_rule.lview"/>
        <a:link id="sys_service_welcome_link" url="${/request/@context_path}/welcome.lview"/>
        <a:screen-include screen="modules/hls/hls_common_javascript.lview"/>
        <script type="text/javascript"><![CDATA[
            function query_periodSetDs() {
                $('periodSetDs').query();
            }
            
            function fnd_2120_grid_add() {
                $('periodSetDs_grid').showEditorByRecord($('periodSetDs').create());
            }
            
            function fnd_2120_grid_clear() {
                $('periodSetDs_grid').clear();
            }
            
            function fnd_2120_grid_submit() {
                var ds = $('periodSetDs');
                if (ds.validate()) {
                    ds.submit();
                }
            }
            
            function fnd_2120_quit() {
                location.href = $('sys_service_welcome_link').getUrl();
            }
            
            function periodSetCodeEdit(record, name) {
                if (record.isNew) {
                    return 'periodSetDs_grid_tf_upper';
                } else {
                    return '';
                }
            }
            
            function totalPeriodNumEdit(record, name) {
            
                if (record.isNew) {
                    return 'periodSetDs_grid_nf_integer';
                } else {
                    return '';
                }
            }
            
            function periodAdditionalFlagEdit(record, name) {
                if (record.isNew) {
                    return 'periodSetDs_grid_comb';
                } else {
                    return '';
                }
            }
            
            function render_periodSetDs_grid(value, record, name) {
                if(name=='rule_count')
                {
                    if (!record.isNew)
                    {
	                    return '<a href=javascript:winOpen_rule_create(\'' + record.get('period_set_code') + '\',' + record.get('rule_count') + ')>${l:GLD_PERIOD_SETS.CREATE_RULE}</a>';
	                }
	                return '';
                }
                return '';
            }
            
            function winOpen_rule_create(period_set_code, rule_count)
            {
                if (Number(rule_count) == 0)
                {
                    new Leaf.Window({
                        id: 'gld_period_rule_window',
                        url: $('gld_period_rule_link').getUrl(),
                        params:{
                        	period_set_code:period_set_code
                        },
                        title: '${l:DEFINITION_OF_ACCOUNTING_PERIOD_CREATE_RULE}',
                        height: 560,
                        width: 710
                    });
                }
                else
                {
                    new Leaf.Window({
                        id: 'gld_period_rule_readonly_window',
                        url: $('gld_period_rule_readonly_link').getUrl(),
                        params:{
                        	period_set_code:period_set_code
                        },
                        title: '${l:DEFINITION_OF_ACCOUNTING_PERIOD_CREATE_RULE}',
                        height: 560,
                        width: 710
                    });
                }
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="periodAdditionalFlagDs" lookupCode="PERIOD_ADDITIONAL_FLAG"/>
            <a:dataSet id="para_periodSetDs" model="gld.gld_period_sets"/>
            <a:dataSet id="periodSetDs" autoQuery="true" fetchAll="false" model="gld.gld_period_sets" notification="有数据没有保存" pageSize="15" queryDataSet="para_periodSetDs" selectable="true" submitUrl="${/request/@context_path}/modules/gld/FND2120/gld_period_set.lsc">
                <a:fields>
                    <a:field name="period_set_code" required="true" validator="hlsCommon_validateCode"/>
                    <a:field name="period_set_name" required="true"/>
                    <a:field name="total_period_num" required="true"/>
                    <a:field name="period_additional_flag_desc" displayField="code_value_name" options="periodAdditionalFlagDs" required="true" returnField="period_additional_flag" valueField="code_value"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton click="fnd_2120_quit" text="HLS.EXIT"/>
                <a:gridButton click="query_periodSetDs" text="HLS.QUERY"/>
                <a:gridButton click="fnd_2120_grid_add" text="HLS.NEW"/>
                <a:gridButton click="fnd_2120_grid_clear" text="HLS.CLEAR"/>
                <a:gridButton click="fnd_2120_grid_submit" text="HLS.SAVE"/>
            </a:screenTopToolbar>
            <a:form column="2" labelWidth="100" title="GLD_PERIOD_SET.PERIOD_SET_QUERY">
                <a:textField name="period_set_code" bindTarget="para_periodSetDs" typeCase="upper">
                    <a:events>
                        <a:event name="enterdown" handler="query_periodSetDs"/>
                    </a:events>
                </a:textField>
                <a:textField name="period_set_name" bindTarget="para_periodSetDs">
                    <a:events>
                        <a:event name="enterdown" handler="query_periodSetDs"/>
                    </a:events>
                </a:textField>
            </a:form>
            <a:grid id="periodSetDs_grid" bindTarget="periodSetDs" height="490" marginWidth="20" navBar="true" width="1000">
                <a:columns>
                    <a:column name="period_set_code" align="left" editorFunction="periodSetCodeEdit" sortable="true" width="200"/>
                    <a:column name="period_set_name" align="left" editor="periodSetDs_grid_tf" width="220"/>
                    <a:column name="total_period_num" align="right" editorFunction="totalPeriodNumEdit" sortable="true" width="70"/>
                    <a:column name="period_additional_flag_desc" align="center" editorFunction="periodAdditionalFlagEdit"/>
                    <a:column name="rule_count" align="center" prompt="GLD_PERIOD_SETS.CREATE_RULE" renderer="render_periodSetDs_grid" width="70"/>
                </a:columns>
                <a:editors>
                    <a:textField id="periodSetDs_grid_tf_upper" typeCase="upper"/>
                    <a:textField id="periodSetDs_grid_tf"/>
                    <a:numberField id="periodSetDs_grid_nf_integer" allowDecimals="false" allowNegative="false"/>
                    <a:comboBox id="periodSetDs_grid_comb"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>