<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: yuminhui  
    $Date: 2015-10-27 下午03:35:35  
    $Revision: 1.0  
    $Purpose: 年度预算方案
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure>
        <a:model-query model="cont.CON308.con_current_year_query" rootPath="now_year"/>
    </a:init-procedure>
    <a:view>
        <script type="text/javascript"><![CDATA[
        	function con_contract_return() {
                history.go(-1);
            }
            function con_contract_query() {
                var record = $('con_contract_annual_budget_query_ds').getCurrentRecord();
                if(record.get('start_date') == '' || record.get('start_date') == null){
                    Leaf.showMessage(${l:PROMPT},'请输入预算年度，预算年度不能为空！');
                }else{
                $('con_contract_annual_budget_result_ds').query();
            		}
            }
            function con_contract_reset() {
                $('con_contract_annual_budget_query_ds').reset();
            }
            
            function con_contract_balance_export() {
                $('con_contract_annual_budget_result_grid')._export();
            }
            
            function sumFunction_foot(data, name) {
                 if (name == 'row_num') {
                     return '<font color=red>' + '合计' + '</font>';
                   } else if(name == 'deposit'){
                       return colum_caculateTotal(data,name);
                   }else if(name == 'finance_amount'){
                       return colum_caculateTotal(data,name); 
                   }
            }
            
            function colum_caculateTotal(data,name){
                var total=0;
                var length=data.length;
                var value=0;
                for(var i=0;i<length;i++){
                    if(Ext.isEmpty(data[i].get(name))){
                        value=0;
                    }else{
                        value=data[i].get(name);
                    }
                    total=plus(total,value);
                }
                 return '<font color=red>' +Leaf.formatMoney(total)+ '</font>';
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="con_contract_annual_budget_query_ds" autoCreate="true">
                <a:fields>
                    <a:field name="contract_name" autoComplete="true" lovGridHeight="300" lovHeight="450" lovService="cont.CON303B.con_contract_for_query_lov" lovWidth="500" title="合同编号查询">
                        <a:mapping>
                            <a:map from="contract_number" to="contract_number"/>
                            <a:map from="contract_name" to="contract_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="bp_id_tenant_n" autoComplete="true" lovGridHeight="350" lovHeight="500" lovService="cont.CON303B.con_bp_name_for_query_lov" lovWidth="500" title="HLS.BP_TITLE">
                        <a:mapping>
                            <a:map from="bp_id" to="bp_id_tenant"/>
                            <a:map from="bp_name" to="bp_id_tenant_n"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="start_date" defaultValue="${/model/now_year/record/@current_year}" required="true"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con_contract_annual_budget_result_ds" autoPageSize="true" autoQuery="true" model="cont.CON308.con_contract_annual_budget_query" queryDataSet="con_contract_annual_budget_query_ds" queryUrl="${/request/@context_path}/autocrud/cont.CON308.con_contract_annual_budget_query/query"/>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <!-- <a:gridButton click="con_contract_return" text="HLS.RETURN"/> -->
                <a:gridButton click="con_contract_query" text="HLS.QUERY"/>
                <a:gridButton click="con_contract_reset" text="HLS.RESET"/>
                <a:gridButton click="con_contract_balance_export" text="HLS.EXPORT"/>
            </a:screenTopToolbar>
            <a:form column="3" labelWidth="120" marginWidth="30" title="查询条件">
                <a:textField name="start_date" bindTarget="con_contract_annual_budget_query_ds" emptyText="请输入年度例如：2015" prompt="预算年度"/>
                <a:lov name="bp_id_tenant_n" bindTarget="con_contract_annual_budget_query_ds" prompt="承租人名称"/>
                <a:lov name="contract_name" bindTarget="con_contract_annual_budget_query_ds" prompt="合同编号"/>
            </a:form>
            <a:grid id="con_contract_annual_budget_result_grid" bindTarget="con_contract_annual_budget_result_ds" marginHeight="185" marginWidth="20" navBar="true">
                <a:columns>
                    <a:column name="row_num" align="center" footerRenderer="sumFunction_foot" lock="true" prompt="HLS.CONTRACT_SEQ" width="40"/>
                    <a:column name="contract_name" lock="true" prompt="合同名称" width="180"/>
                    <a:column name="contract_number" lock="true" prompt="提款编号" width="120"/>
                    <a:column name="bp_id_tenant_n" prompt="承租人" width="180"/>
                    <a:column name="bp_scale_n" align="center" prompt="承租人规模" width="100"/>
                    <a:column name="lease_term" align="center" prompt="项目年限" width="100"/>
                    <a:column name="price_list_n" align="center" prompt="还款方式" width="100"/>
                    <a:column name="annual_pay_times_n" align="center" prompt="租金支付方式" width="100"/>
                    <a:column name="lease_charge_ratio" align="right" prompt="手续费率" width="100"/>
                    <a:column name="int_rate" align="right" prompt="租赁利率" width="100"/>
                    <a:column prompt="第一季度（项目租金收入：万元）">
                        <a:column name="principal_1_one" align="right" footerRenderer="colum_caculateTotal" prompt="本金" renderer="Leaf.formatMoney" width="100"/>
                        <a:column name="interest_1_one" align="right" footerRenderer="colum_caculateTotal" prompt="租息" renderer="Leaf.formatMoney" width="100"/>
                        <a:column name="due_amount_1_one" align="right" footerRenderer="colum_caculateTotal" prompt="合计" renderer="Leaf.formatMoney" width="100"/>
                    </a:column>
                    <a:column prompt="第二季度（项目租金收入：万元）">
                        <a:column name="principal_1_two" align="right" footerRenderer="colum_caculateTotal" prompt="本金" renderer="Leaf.formatMoney" width="100"/>
                        <a:column name="interest_1_two" align="right" footerRenderer="colum_caculateTotal" prompt="租息" renderer="Leaf.formatMoney" width="100"/>
                        <a:column name="due_amount_1_two" align="right" footerRenderer="colum_caculateTotal" prompt="合计" renderer="Leaf.formatMoney" width="100"/>
                    </a:column>
                    <a:column prompt="第三季度（项目租金收入：万元）">
                        <a:column name="principal_1_three" align="right" footerRenderer="colum_caculateTotal" prompt="本金" renderer="Leaf.formatMoney" width="100"/>
                        <a:column name="interest_1_three" align="right" footerRenderer="colum_caculateTotal" prompt="租息" renderer="Leaf.formatMoney" width="100"/>
                        <a:column name="due_amount_1_three" align="right" footerRenderer="colum_caculateTotal" prompt="合计" renderer="Leaf.formatMoney" width="100"/>
                    </a:column>
                    <a:column prompt="第四季度（项目租金收入：万元）">
                        <a:column name="principal_1_four" align="right" footerRenderer="colum_caculateTotal" prompt="本金" renderer="Leaf.formatMoney" width="100"/>
                        <a:column name="interest_1_four" align="right" footerRenderer="colum_caculateTotal" prompt="租息" renderer="Leaf.formatMoney" width="100"/>
                        <a:column name="due_amount_1_four" align="right" footerRenderer="colum_caculateTotal" prompt="合计" renderer="Leaf.formatMoney" width="100"/>
                    </a:column>
                    <a:column prompt="年度合计（项目租金收入：万元）">
                        <a:column name="principal_1" align="right" footerRenderer="colum_caculateTotal" prompt="本金回流" renderer="Leaf.formatMoney" width="100"/>
                        <a:column name="interest_1" align="right" footerRenderer="colum_caculateTotal" prompt="租息流入" renderer="Leaf.formatMoney" width="100"/>
                        <a:column name="due_amount_1" align="right" footerRenderer="colum_caculateTotal" prompt="现金流入合计" renderer="Leaf.formatMoney" width="100"/>
                    </a:column>
                    <a:column prompt="咨询费收入(万元)">
                        <a:column name="due_amount_15_one" align="right" footerRenderer="colum_caculateTotal" prompt="第1季度" renderer="Leaf.formatMoney" width="100"/>
                        <a:column name="due_amount_15_two" align="right" footerRenderer="colum_caculateTotal" prompt="第2季度" renderer="Leaf.formatMoney" width="100"/>
                        <a:column name="due_amount_15_three" align="right" footerRenderer="colum_caculateTotal" prompt="第3季度" renderer="Leaf.formatMoney" width="100"/>
                        <a:column name="due_amount_15_four" align="right" footerRenderer="colum_caculateTotal" prompt="第4季度" renderer="Leaf.formatMoney" width="100"/>
                        <a:column name="due_amount_15" align="right" footerRenderer="colum_caculateTotal" prompt="全年合计" renderer="Leaf.formatMoney" width="100"/>
                    </a:column>
                </a:columns>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
