<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: wuhuazhen2689 $
    $Date: 2010/12/20 08:13:56 $
    $Revision: 1.3 $
    $Purpose: “帐套级汇率定义”模块的页面
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure>
        <a:model-query defaultWhereClause="gc.currency_code =gld_common_pkg.get_company_currency_code(${/session/@company_id})" model="gld.gld_currency" rootPath="gerc"/>
    </a:init-procedure>
    <a:view>
        <a:link id="gld_books_exchange_rate_detail_link" url="${/request/@context_path}/modules/gld/FND1100/gld_books_exchange_rate_detail.lview"/>
        <a:link id="sys_service_welcome_link" url="${/request/@context_path}/welcome.lview"/>
        <script type="text/javascript"><![CDATA[
        
            function createRate(){
                $('gld_exchange_rate_ds').post(/*gld_books_exchange_rate_detail.screen*/$('gld_books_exchange_rate_detail_link').getUrl()+'?set_of_books_id=${/parameter/@set_of_books_id}');
            }

            function dataSetUpdate(ds,record,name,value){
                var currency_code_frn=record.getMeta().getField('currency_code_frn');
                var currency_name_frn=record.getMeta().getField('currency_name_frn');
                var period_from=record.getMeta().getField('period_from');
                var period_to=record.getMeta().getField('period_to');
                var date_from=record.getMeta().getField('date_from');
                var date_to=record.getMeta().getField('date_to');

                var currencyCodeValue=record.get("currency_code");

                if (name=='currency_code'){
                    var field = record.getMeta().getField('currency_code_frn');
                    field.setLovPara('currency_code_frn',record.get('currency_code'));
                }

                var typeNameValue=record.get("rate_method_code");
                //alert(typeNameValue);
                if (typeNameValue=="DAILY"){
                    period_from.setReadOnly(true);
                    period_to.setReadOnly(true);

                    date_from.setReadOnly(false);
                    date_to.setReadOnly(false);
                    record.set('date_from',null);
                    record.set('date_to',null);
                }else if (typeNameValue=="PERIOD"){
                    period_from.setReadOnly(false);
                    period_to.setReadOnly(false);
                    record.set('period_from',null);
                    record.set('period_to',null);

                    date_from.setReadOnly(true);
                    date_to.setReadOnly(true);
                }else{
                    period_from.setReadOnly(true);
                    period_to.setReadOnly(true);
                    date_from.setReadOnly(true);
                    date_to.setReadOnly(true);

                    record.set('date_from',null);
                    record.set('date_to',null);
                    record.set('period_from',null);
                    record.set('period_to',null);
                }

            }
            
            function fnd_1100_child_grid_submit() {
                var result_ds = $('sys_service_result_ds');
                if (result_ds.validate()) {
                    result_ds.submit();
                }
            }
            function fnd_1100_child_next(){
                 history.go(1);
            }
            function fnd_1100_child_back(){
                history.go(-1);
            }
            function fnd_1100_child_quit(){
                location.href = $('sys_service_welcome_link').getUrl();
                parent.shMenu('show');
            }


        
        ]]></script>
        <a:dataSets>
            <a:dataSet id="gld_exchange_rate_ds" autocreate="true">
                <a:datas dataSource="/model/gerc"/>
                <a:fields>
                    <a:field name="currency_code" lovGridHeight="300" lovHeight="460" lovService="gld.gld_currency_lov" lovWidth="490" required="true" title="CURRENCY_SELECTION">
                        <a:mapping>
                            <a:map from="currency_code" to="currency_code"/>
                            <a:map from="currency_name" to="currency_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="currency_name" readonly="true"/>
                    <a:field name="type_code" lovGridHeight="300" lovHeight="460" lovService="gld.gld_exchangerate_type_lov" lovWidth="490" required="true" title="TYPE_SELECTION">
                        <a:mapping>
                            <a:map from="type_name" to="type_name"/>
                            <a:map from="type_code" to="type_code"/>
                            <a:map from="rate_method_code" to="rate_method_code"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="type_name" readonly="true"/>
                    <a:field name="currency_code_frn" lovGridHeight="300" lovHeight="460" lovService="gld.gld_currency_lov?currency_code_frn=${/model/gerc/record/@currency_code}" lovWidth="490" title="CURRENCY_SELECTION">
                        <a:mapping>
                            <a:map from="currency_code" to="currency_code_frn"/>
                            <a:map from="currency_name" to="currency_name_frn"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="currency_name_frn" readonly="true"/>
                    <a:field name="period_from" lovGridHeight="300" lovHeight="460" lovService="gld.gld_period_adj_incld_lov" lovWidth="490" readonly="true" title="GLD_EXCHANGE_RATE.PERIOD_FROM">
                        <a:mapping>
                            <a:map from="period_name" to="period_from"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="period_to" lovGridHeight="300" lovHeight="460" lovService="gld.gld_period_adj_incld_lov" lovWidth="490" readonly="true" title="GLD_EXCHANGE_RATE.PERIOD_TO">
                        <a:mapping>
                            <a:map from="period_name" to="period_to"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="date_from" readonly="true"/>
                    <a:field name="date_to" readonly="true"/>
                </a:fields>
                <a:events>
                    <a:event name="update" handler="dataSetUpdate"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar height="29">
                <a:button click="fnd_1100_child_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_1100_child_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="createRate" height="20" icon="${/request/@context_path}/images/save.png" iconAlign="left" text="HLS.SAVE" width="50"/>
                <a:separator style="margin-left:3px;"/>
                <a:button click="fnd_1100_child_quit" height="20" icon="${/request/@context_path}/images/quit.png" iconAlign="left" text="HLS.EXIT" width="50"/>
                <a:separator style="margin-left:3px;"/>
            </a:screenTopToolbar>
            <a:fieldSet column="2" title="GLD_EXCHANGE_RATE.TITLE" width="650">
                <a:lov name="currency_code" bindTarget="gld_exchange_rate_ds" prompt="GLD_CURRENCY.CURRENCY_CODE" width="180"/>
                <a:textField name="currency_name" bindTarget="gld_exchange_rate_ds" prompt="GLD_CURRENCY.CURRENCY_NAME" width="180"/>
                <a:lov name="type_code" bindTarget="gld_exchange_rate_ds" prompt="GLD_EXCHANGERATE_TYPES.TYPE_CODE" width="180"/>
                <a:textField name="type_name" bindTarget="gld_exchange_rate_ds" prompt="GLD_EXCHANGERATE_TYPES.TYPE_NAME" width="180"/>
                <a:lov name="currency_code_frn" bindTarget="gld_exchange_rate_ds" prompt="GLD_CURRENCY.CURRENCY_CODE_FRN" width="180"/>
                <a:textField name="currency_name_frn" bindTarget="gld_exchange_rate_ds" prompt="GLD_CURRENCY.CURRENCY_NAME_FRN" width="180"/>
                <a:lov name="period_from" bindTarget="gld_exchange_rate_ds" prompt="GLD_EXCHANGE_RATE.PERIOD_FROM" width="180"/>
                <a:lov name="period_to" bindTarget="gld_exchange_rate_ds" prompt="GLD_EXCHANGE_RATE.PERIOD_TO" width="180"/>
                <a:datePicker name="date_from" bindTarget="gld_exchange_rate_ds" prompt="GLD_EXCHANGE_RATE.START_DATE" renderer="Leaf.formatDate" width="180"/>
                <a:datePicker name="date_to" bindTarget="gld_exchange_rate_ds" prompt="GLD_EXCHANGE_RATE.END_DATE" renderer="Leaf.formatDate" width="180"/>
            </a:fieldSet>
        </a:screenBody>
    </a:view>
</a:screen>