<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Guoxuezhao  
    $Date: 2013-5-28 下午7:38:35  
    $Revision: 1.0  
    $Purpose: 其它合同  查询
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure>
        <a:model-query defaultWhereClause="t1.document_category=&apos;LOAN_CONTRACT&apos; and t1.business_type=&apos;OTHERS&apos;" fetchAll="true" model="basic.hls_document_type_for_lov" rootPath="document_type_path"/>
    </a:init-procedure>
    <a:view>
        <a:link id="tre_loan_contract_review_link_id" model="tre.tre504.tre_loan_contract_review" modelaction="update"/>
        <script type="text/javascript"><![CDATA[
            function wcl_goBack() {
                window.history.go(-1);
            }

           Leaf.onReady(function() {
                if(Ext.isEmpty('${/parameter/@is_review}')){
               $('wcl_review_id').setVisible(false);   
                }
            });
            
            function lock_current_window() {
                Leaf.Masker.mask(document.documentElement, '${l:HLS.EXECUTING}');
            }
            
            function unlock_current_window() {
                Leaf.Masker.unmask(document.documentElement);
            }
            function wcl_review(){
                lock_current_window();
                var result_ds = $('loan_contract_ds');
                var record = result_ds.getCurrentRecord();
                var ajax_flag = 'N';
                var win = Leaf.showConfirm('${l:HLS.PROMPT}', '${l:TRE503.IS_LOAN_COFIRM}' + record.get('loan_contract_number') + '${l:TRE503.IS_THIS_CONTRACT}', function() {
                    ajax_flag = 'Y';
                    Leaf.request({
                        url: $('tre_loan_contract_review_link_id').getUrl(),
                        para: {loan_contract_id:${/parameter/@loan_contract_id}},
                        success: function(res) {
                            result_ds.query(result_ds.currentPage);
                            unlock_current_window();
                        },
                        failure: function() {
                            unlock_current_window();
                        },
                        error: function() {
                            unlock_current_window();
                        },
                        scope: this
                    });
                }, function() {
                    unlock_current_window();
                });
                win.on('close', function() {
                    if (ajax_flag == 'N') {
                        unlock_current_window();
                    }
                });
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="document_type_name_ds">
                <a:datas dataSource="/model/document_type_path"/>
            </a:dataSet>
            <!-- <a:dataSet id="loan_contract_type_ds" lookupCode="TRE502_LOAN_CONTRACT_TYPE"/> -->
            <a:dataSet id="yes_no_ds" lookupCode="YES_NO"/>
            <a:dataSet id="other_loan_amount_type_ds" lookupCode="TRE502_OTHER_LOAN_AMOUNT_TYPE"/>
            <a:dataSet id="int_rate_fixing_way_ds" lookupCode="TRE502_INT_RATE_FIXING_WAY"/>
            <a:dataSet id="loan_contract_ds" autoQuery="true" model="tre.tre502.tre_loan_contract" queryUrl="${/request/@context_path}/autocrud/tre.tre502.tre_loan_contract/query?loan_contract_id=${/parameter/@loan_contract_id}">
                <a:fields>
                    <a:field name="business_type" defaultValue="OTHERS" readOnly="true"/>
                    <a:field name="document_category" defaultValue="LOAN_CONTRACT" readOnly="true"/>
                    <a:field name="document_type_desc" displayField="description" options="document_type_name_ds" readOnly="true" returnField="document_type" valueField="document_type"/>
                    <!-- <a:field name="loan_contract_type" defaultValue="OTHERS"/>
                    <a:field name="loan_contract_type_desc" displayField="code_value_name" options="loan_contract_type_ds" readOnly="true" returnField="loan_contract_type" valueField="code_value"/> -->
                    <a:field name="loan_contract_number" readOnly="true"/>
                    <a:field name="bank_credit_contract_id" readOnly="true"/>
                    <a:field name="bank_credit_contract_number" lovAutoQuery="true" lovGridHeight="270" lovHeight="400" lovService="tre.tre501.tre_bank_credit_contract_lov" lovWidth="700" readOnly="true" title="TRE_LOAN_CONTRACT.BANK_CREDIT_CONTRACT_ID">
                        <a:mapping>
                            <a:map from="credit_contract_number" to="bank_credit_contract_number"/>
                            <a:map from="credit_contract_id" to="bank_credit_contract_id"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="bank_branch_code" lovGridHeight="350" lovHeight="510" lovLabelWidth="90" lovService="basic.csh_bank_branch_for_lov" lovWidth="580" prompt="HLS.BANK_CODE" readOnly="true" required="true" title="HLS.BANK_CODE">
                        <a:mapping>
                            <a:map from="bank_branch_id" to="bank_branch_id"/>
                            <a:map from="bank_branch_code" to="bank_branch_code"/>
                            <a:map from="bank_branch_name" to="bank_branch_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="bank_branch_id"/>
                    <a:field name="bank_branch_name" prompt="HLS.BANK_NAME" readOnly="true"/>
                    <a:field name="bank_account_code" lovGridHeight="350" lovHeight="510" lovLabelWidth="90" lovService="csh.CSH101.csh_bank_account_lov" lovWidth="580" readOnly="true" required="true" title="CSH511.BANK_ACCOUNT_CODE">
                        <a:mapping>
                            <a:map from="bank_account_id" to="bank_account_id"/>
                            <a:map from="bank_account_code" to="bank_account_code"/>
                            <a:map from="bank_account_num" to="bank_account_num"/>
                            <a:map from="currency_code" to="currency"/>
                            <a:map from="currency_name" to="currency_desc"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="bank_account_id"/>
                    <a:field name="bank_account_num" readOnly="true"/>
                    <a:field name="withdraw_account_code" lovGridHeight="350" lovHeight="510" lovLabelWidth="90" lovService="csh.CSH101.csh_bank_account_lov" lovWidth="580" readOnly="true" required="true" title="CSH511.BANK_ACCOUNT_CODE">
                        <a:mapping>
                            <a:map from="bank_account_id" to="withdraw_account_id"/>
                            <a:map from="bank_account_code" to="withdraw_account_code"/>
                            <a:map from="bank_account_num" to="withdraw_account_num"/>
                            <a:map from="currency_code" to="currency"/>
                            <a:map from="currency_name" to="currency_desc"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="withdraw_account_id"/>
                    <a:field name="withdraw_account_num" readOnly="true"/>
                    <a:field name="loan_certificate_flag_desc" displayField="code_value_name" options="yes_no_ds" readOnly="true" required="true" returnField="loan_certificate_flag" valueField="code_value"/>
                    <a:field name="int_rate_fixing_way_desc" displayField="code_value_name" options="int_rate_fixing_way_ds" readOnly="true" returnField="int_rate_fixing_way" valueField="code_value"/>
                    <a:field name="related_party_flag_desc" displayField="code_value_name" options="yes_no_ds" readOnly="true" required="true" returnField="related_party_flag" valueField="code_value"/>
                    <a:field name="loan_amount" readOnly="true"/>
                    <a:field name="currency" readOnly="true"/>
                    <a:field name="currency_desc" readOnly="true"/>
                    <a:field name="loan_amount_type_desc" displayField="code_value_name" options="other_loan_amount_type_ds" readOnly="true" required="true" returnField="loan_amount_type" valueField="code_value"/>
                    <a:field name="interest_rate" readOnly="true"/>
                    <a:field name="loan_date_from" readOnly="true"/>
                    <a:field name="loan_date_to" readOnly="true"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton click="wcl_goBack" text="HLS.BACK"/>
                <a:gridButton id="wcl_review_id" click="wcl_review" text="TRE502.BUTTON.REVIEW"/>
            </a:screenTopToolbar>
            <a:form marginWidth="30" title="TRE502.FORM_TITLE.OTHERS_LOAN_CONTRACT">
                <a:box column="4" labelWidth="120" width="1112">
                    <a:textField name="loan_contract_number" bindTarget="loan_contract_ds" prompt="TRE_LOAN_CONTRACT.LOAN_CONTRACT_NUMBER"/>
                    <a:comboBox name="document_type_desc" bindTarget="loan_contract_ds" prompt="HLS.CONTRACT_TYPE"/>
                    <a:datePicker name="loan_contract_book_date" bindTarget="loan_contract_ds" prompt="TRE_LOAN_CONTRACT.LOAN_CONTRACT_BOOK_DATE"/>
                    <a:lov name="bank_credit_contract_number" bindTarget="loan_contract_ds" prompt="TRE_LOAN_CONTRACT.BANK_CREDIT_CONTRACT_ID"/>
                    <a:lov name="bank_branch_code" bindTarget="loan_contract_ds"/>
                    <a:textField name="bank_branch_name" bindTarget="loan_contract_ds"/>
                    <a:comboBox name="loan_certificate_flag_desc" bindTarget="loan_contract_ds" prompt="TRE_LOAN_CONTRACT.LOAN_CERTIFICATE_FLAG"/>
                    <a:comboBox name="related_party_flag_desc" bindTarget="loan_contract_ds" prompt="TRE_LOAN_CONTRACT.RELATED_PARTY_FLAG"/>
                    <a:lov name="bank_account_code" bindTarget="loan_contract_ds" prompt="TRE502.REPAYMENT_ACCOUNT_CODE"/>
                    <a:textField name="bank_account_num" bindTarget="loan_contract_ds" prompt="TRE502.REPAYMENT_ACCOUNT_NUM"/>
                    <a:lov name="withdraw_account_code" bindTarget="loan_contract_ds" prompt="TRE502.WITHDRAW_ACCOUNT_CODE"/>
                    <a:textField name="withdraw_account_num" bindTarget="loan_contract_ds" prompt="TRE502.WITHDRAW_ACCOUNT_NUM"/>
                    <a:textField name="note" bindTarget="loan_contract_ds" colspan="2" prompt="HLS.NOTE" width="428"/>
                </a:box>
            </a:form>
            <a:fieldSet title="TRE502.FIELDSET.LOAN_AMOUNT">
                <a:box column="4" labelWidth="120" width="1112">
                    <a:numberField name="loan_amount" allowFormat="true" bindTarget="loan_contract_ds" prompt="TRE_LOAN_CONTRACT.LOAN_AMOUNT"/>
                    <a:lov name="currency_desc" bindTarget="loan_contract_ds" prompt="TRE_LOAN_CONTRACT.CURRENCY"/>
                    <a:datePicker name="loan_date_from" bindTarget="loan_contract_ds" prompt="TRE_LOAN_CONTRACT.LOAN_DATE_FROM_FACTORING"/>
                    <a:datePicker name="loan_date_to" bindTarget="loan_contract_ds" prompt="TRE_LOAN_CONTRACT.LOAN_DATE_TO_FACTORING"/>
                    <a:comboBox name="loan_amount_type_desc" bindTarget="loan_contract_ds" prompt="TRE_LOAN_CONTRACT.AMOUNT_TYPE"/>
                </a:box>
            </a:fieldSet>
            <a:fieldSet title="TRE502.FIELDSET.LOAN_INTEREST">
                <a:box column="4" labelWidth="120" width="1112">
                    <a:percentField name="base_rate" allowNegative="false" bindTarget="loan_contract_ds" prompt="HLS.BASE_RATE" readOnly="true"/>
                    <a:comboBox name="int_rate_fixing_way_desc" bindTarget="loan_contract_ds" prompt="TRE_LOAN_CONTRACT.INT_RATE_FIXING_WAY"/>
                    <a:percentField name="int_rate_fixing_range" allowDecimals="true" allowNegative="true" bindTarget="loan_contract_ds" prompt="TRE503.INT_RATE_FIXING_RANGE" readOnly="true"/>
                    <a:percentField name="interest_rate" allowNegative="false" bindTarget="loan_contract_ds" prompt="TRE503.INTEREST_RATE"/>
                </a:box>
            </a:fieldSet>
        </a:screenBody>
    </a:view>
</a:screen>