<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zjw  
    $Date: 2011-9-6 下午02:49:20  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure>
        <a:model-query fetchAll="true" model="fnd.FND2440.fnd_sob_period_sets" rootPath="fieldset"/>
    </a:init-procedure>
    <a:view>
        <a:link id="fnd_sob_period_status_err_link" url="${/request/@context_path}/modules/fnd/FND2440/fnd_sob_period_status_err.lview"/>
        <a:link id="fnd_sob_period_pkg_init_period_link" model="db.fnd_sob_period_pkg.init_period" modelaction="update"/>
        <a:link id="fnd_sob_period_pkg_close_link" model="db.fnd_sob_period_pkg.close_period" modelaction="update"/>
        <a:link id="fnd_sob_period_pkg_open_link" model="db.fnd_sob_period_pkg.open_period" modelaction="update"/>
        <a:link id="sys_service_welcome_link" url="${/request/@context_path}/welcome.lview"/>
        <script type="text/javascript"><![CDATA[
            function PeriodStatus(value, record, name) {
                if (Ext.isEmpty(value)) {
                    return '${l:PROMPT.NOT_OPEN}';
                } else if (value == 'O') {
                    return '${l:PROMPT.OPENED}';
                } else if (value == 'C') {
                    return '${l:PROMPT.CLOSED}';
                }
            }
            
            function OpenPeriod(value, record, name) {
                var period_set_code = record.get('period_status_code');
                var recordString = Ext.urlEncode(record.data);
                if (Ext.isEmpty(period_set_code) || period_set_code == 'C') {
                    var openurl = /*${/request/@context_path}/autocrud/fnd.fnd_sob_period_pkg_open/update*/$('fnd_sob_period_pkg_open_link').getUrl();
                    return '<a href="javascript:execute(\'' + openurl + '\',\'' + record.get('period_set_code') + '\',\'' + record.get('period_name') + '\');">' + '${l:OPEN_PERIOD}' + '</a>';
                } else if (period_set_code == 'O') {
                    var closeurl = /*${/request/@context_path}/autocrud/fnd.fnd_sob_period_pkg_close/update*/$('fnd_sob_period_pkg_close_link').getUrl();
                    return '<a href="javascript:execute(\'' + closeurl + '\',\'' + record.get('period_set_code') + '\',\'' + record.get('period_name') + '\');">' + '${l:CLOSE_PERIOD}' + '</a>';
                }
            }
            
            function execute(ourl, rd1, rd2) {
                if ($('set_gld_period_status_o_query_ds').getAll().length == 0) {
                    Leaf.request({
                        url: /*${/request/@context_path}/autocrud/fnd.fnd_sob_period_pkg_init_period/update*/$('fnd_sob_period_pkg_init_period_link').getUrl(),
                        para: {
                            'period_name': rd2,
                            'period_set_code': rd1
                        },
                        success: function() {
            
                           /* Leaf.showMessage('${l:PROMPT}', '${l:FND_DIMENSION_VALUES.OPR_SUC}', function(cmp) {
                                //  document.location.reload();
                                cmp.close();
                            });*/
                            doQuery();
                        },
                        scope: this
                    });
            
                } else {
                    Leaf.request({
                        url: ourl,
                        para: {
                            'period_name': rd2,
                            'period_set_code': rd1
                        },
                        success: function() {
            
                            /*Leaf.showMessage('${l:PROMPT}', '${l:FND_DIMENSION_VALUES.OPR_SUC}', function(cmp) {
                                //  document.location.reload();
                                cmp.close();
                            });*/
                            doQuery();
                        },
                        scope: this
                    });
            
                }
            }
            
            function doQuery() {
                $('set_gld_period_status_o_query_ds').setQueryParameter('period_set_code', '${/model/fieldset/record/@period_set_code}');
                $('set_gld_period_status_o_query_ds').query();
                $('set_gld_period_status_u_query_ds').setQueryParameter('period_set_code', '${/model/fieldset/record/@period_set_code}');
                $('set_gld_period_status_u_query_ds').query();
            }
            
            function errorLog() {
                window.open(/*fnd_sob_period_status_err.screen*/$('fnd_sob_period_status_err_link').getUrl());
            }]]></script>
        <a:dataSets>
            <a:dataSet id="set_gld_period_sets_ds">
                <a:datas dataSource="/model/fieldset"/>
                <a:fields>
                    <a:field name="period_set_code" prompt="GLD_PERIOD_SET.PERIOD_SET_CODE" readOnly="true"/>
                    <a:field name="total_period_num" prompt="GLD_PERIOD_SET.TOTAL_PERIOD_NUM" readOnly="true"/>
                    <a:field name="period_set_name" prompt="GLD_PERIOD_SET.PERIOD_SET_NAME" readOnly="true"/>
                    <a:field name="set_of_books_code" prompt="GLD_PERIOD_SET.PERIOD_SET_NAME" readOnly="true"/>
                    <a:field name="set_of_books_name" prompt="GLD_PERIOD_SET.PERIOD_SET_NAME" readOnly="true"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="set_gld_period_sets_query_ds" autoCreate="true">
                <a:fields>
                    <a:field name="period_set_code" defaultValue="${/model/fieldset/record/@period_set_code}"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="set_gld_period_status_o_query_ds" autoCount="true" autoQuery="true" model="fnd.FND2440.fnd_sob_period_status_o_query" pageSize="10" queryDataSet="set_gld_period_sets_query_ds">
                <a:fields>
                    <a:field name="adjustment_flag" checkedValue="Y" defaultValue="N" readOnly="true" uncheckedValue="N"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="set_gld_period_status_u_query_ds" autoCount="true" autoQuery="true" model="fnd.FND2440.fnd_sob_period_status_u_query" pageSize="10" queryDataSet="set_gld_period_sets_query_ds">
                <a:fields>
                    <a:field name="adjustment_flag" checkedValue="Y" defaultValue="N" readOnly="true" uncheckedValue="N"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar height="29">
                <a:button click="fnd_2440_back" height="20" icon="${/request/@context_path}/images/back.png" iconAlign="left" text="HLS.BACK" width="50"/>
                <a:separator style="margin-left:3px;"/>
                <a:button click="fnd_2440_next" height="20" icon="${/request/@context_path}/images/forward.png" iconAlign="left" text="HLS.FORWARD" width="50"/>
                <a:separator style="margin-left:3px;"/>
                <a:button click="fnd_2440_quit" height="20" icon="${/request/@context_path}/images/quit.png" iconAlign="left" text="HLS.EXIT" width="50"/>
                <a:separator style="margin-left:3px;"/>
                <a:button click="doQuery" height="20" icon="${/request/@context_path}/images/search.png" iconAlign="left" text="查询" width="50"/>
                <a:separator style="margin-left:3px;"/>
                <a:button click="errorLog" height="20" text="查看日志" width="50"/>
                <a:separator style="margin-left:3px;"/>
            </a:screenTopToolbar>
            <a:form id="gld_period_sets_ds_form" Title="FND_SET_BOOK_CONTROL.ACCOUNTING" column="1">
                <a:hBox>
                    <a:textField name="period_set_code" bindTarget="set_gld_period_sets_ds"/>
                    <a:textField name="period_set_name" bindTarget="set_gld_period_sets_ds"/>
                    <a:textField name="total_period_num" bindTarget="set_gld_period_sets_ds"/>
                </a:hBox>
                <a:hBox>
                    <a:textField name="set_of_books_code" bindTarget="set_gld_period_sets_ds" prompt="FND_SET_BOOK_CONTROL.BOOKCODE"/>
                    <a:textField name="set_of_books_name" bindTarget="set_gld_period_sets_ds" prompt="FND_SET_BOOK_CONTROL.BOOKNAME"/>
                </a:hBox>
            </a:form>
            <a:grid id="gld_period_status_u_query_ds_grid" bindTarget="set_gld_period_status_u_query_ds" height="220" marginWidth="20" navBar="true" width="1000">
                <a:columns>
                    <a:column name="period_year" prompt="GLD_PERIODS.PERIOD_YEAR"/>
                    <a:column name="period_num" prompt="FND_DIMENSIONS.DIMENSION_SEQUENCE"/>
                    <a:column name="start_date_c" prompt="GLD_EXCHANGE_RATE.START_DATE"/>
                    <a:column name="end_date_c" prompt="GLD_EXCHANGE_RATE.END_DATE"/>
                    <a:column name="quarter_num" prompt="GLD_PERIOD_STATUS.QUARTER"/>
                    <a:column name="period_name" prompt="GLD_PERIODS.PERIOD_NAME"/>
                    <a:column name="period_status_code" prompt="GLD_PERIOD_STATUS.PERIOD_STATUS" renderer="PeriodStatus"/>
                    <a:column name="OpenPeriod" prompt="GLD_PERIOD_STATUS.ADJUST_PERIOD" renderer="OpenPeriod"/>
                    <a:column name="adjustment_flag" Align="left" editor="CheckBox_close" prompt="GLD_PERIOD_STATUS.ADJUST"/>
                </a:columns>
                <a:editors>
                    <a:checkBox id="CheckBox_close"/>
                </a:editors>
            </a:grid>
            <a:grid id="gld_period_status_o_query_ds_grid" bindTarget="set_gld_period_status_o_query_ds" height="220" marginWidth="20" navBar="true" width="1000">
                <a:columns>
                    <a:column name="period_year" prompt="GLD_PERIODS.PERIOD_YEAR"/>
                    <a:column name="period_num" prompt="FND_DIMENSIONS.DIMENSION_SEQUENCE"/>
                    <a:column name="start_date_c" prompt="GLD_EXCHANGE_RATE.START_DATE"/>
                    <a:column name="end_date_c" prompt="GLD_EXCHANGE_RATE.END_DATE"/>
                    <a:column name="quarter_num" prompt="GLD_PERIOD_STATUS.QUARTER"/>
                    <a:column name="period_name" prompt="GLD_PERIODS.PERIOD_NAME"/>
                    <a:column name="period_status_code" prompt="GLD_PERIOD_STATUS.PERIOD_STATUS" renderer="PeriodStatus"/>
                    <a:column name="OpenPeriod" prompt="GLD_PERIOD_STATUS.ADJUST_PERIOD" renderer="OpenPeriod"/>
                    <a:column name="adjustment_flag" Align="left" editor="CheckBox_open" prompt="GLD_PERIOD_STATUS.ADJUST"/>
                </a:columns>
                <a:editors>
                    <a:checkBox id="CheckBox_open"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
        <script type="text/javascript"><![CDATA[
            
            ]]></script>
    </a:view>
</a:screen>