<?xml version="1.0" encoding="UTF-8"?>
<a:screen xmlns:c="leaf.application.action" xmlns:a="http://www.leaf-framework.org/application" xmlns:p="uncertain.proc" trace="true">
    <a:init-procedure><![CDATA[
    ]]></a:init-procedure>
    <a:view>
        <div style="color:balck;font-size:30px;text-align:center;width:100%;"><![CDATA[承租人租赁案件汇总表]]></div>
        <script type="text/javascript"><![CDATA[

            function summaryRenderer(datas, name) {
            
                var sum = 0;
                for (var i = 0;i < datas.length;i++) {
                    record = datas[i];
                    if (name == "price_desc") {
                        var t_1 = record.get("price_desc");
                        var t_2 = parseFloat(t_1);
                        if (!isNaN(t_2)) {
                            sum += t_2;
                        }
                    }
                }
                if (name == "project_number") {
                    return '<div align="right">合计:</div>';
                }
            }        	
        ]]></script>
        <a:dataSets>
            <a:dataSet id="tenant_history_project_ds" fetchAll="true" model="prj.PRJ502.tenant_history_project" queryUrl="${/request/@context_path}/autocrud/prj.PRJ502.tenant_history_project/query?project_id=${/parameter/@project_id}"><![CDATA[
            ]]></a:dataSet>
            <a:dataSet id="prj_project_bp_query_name_ds" model="prj.PRJ502.prj_project_bp_query_name" queryUrl="${/request/@context_path}/autocrud/prj.PRJ502.prj_project_bp_query_name/query?project_id=${/parameter/@project_id}"/>
        </a:dataSets>
        <a:screenBody>
            <a:form column="1" labelWidth="100">
                <a:hBox labelWidth="100">
                    <a:label name="bp_name" bindTarget="prj_project_bp_query_name_ds" prompt="客户名称"/>
                    <div id="count"/>
                </a:hBox>
            </a:form>
            <a:grid id="tenant_history_project_grid" bindTarget="tenant_history_project_ds" height="300" navBar="true" showRowNumber="true" width="1200">
                <a:columns>
                    <a:column name="contract_number" align="center" footerRenderer="summaryRenderer" prompt="合同编号" width="120"/>
                    <a:column name="contract_status" align="center" prompt="合同状态" width="80"/>
                    <a:column name="model" align="center" prompt="车辆信息" width="240"/>
                    <a:column name="license_number" align="center" prompt="车牌号" width="120"/>
                    <a:column name="finance_amount" align="right" prompt="租金概算本金" renderer="Leaf.formatMoney" width="80"/>
                    <a:column name="net_finance_amount" align="right" prompt="净融资额" renderer="Leaf.formatMoney" width="80"/>
                    <a:column name="total_rental" align="right" prompt="租金总额" renderer="Leaf.formatMoney" width="80"/>
                    <a:column name="lease_term" align="center" prompt="租赁年限(年)" width="80"/>
                    <a:column name="inception_of_lease" align="center" prompt="起租日" width="80"/>
                    <a:column name="total_received_rental" align="right" prompt="已交租金" renderer="Leaf.formatMoney" width="80"/>
                    <a:column name="total_left_rental" align="right" prompt="租金余额" renderer="Leaf.formatMoney" width="80"/>
                    <a:column name="overdue_times" align="center" prompt="逾期次数" width="80"/>
                    <a:column name="overdue_max_days" align="center" prompt="最长逾期天数" width="80"/>
                    <a:column name="total_left_principal" align="right" prompt="剩余本金" renderer="Leaf.formatMoney" width="80"/>
                    <a:column name="risk_exposure" align="right" prompt="风险敞口" renderer="Leaf.formatMoney" width="80"/>
                    <a:column name="description" align="center" prompt="备注" width="80"/>
                </a:columns>
            </a:grid>
        </a:screenBody>
        <script type="text/javascript"><![CDATA[
        	function init(){
        		var project_id = ${/parameter/@project_id};
                var url = '${/request/@context_path}/autocrud/prj.PRJ502.tenant_history_project/query?project_id=' + project_id;
                var ds = $('tenant_history_project_ds');
                ds.setQueryUrl(url);
                ds.query();
                
                url = '${/request/@context_path}/autocrud/prj.PRJ502.prj_project_bp_query_name/query?project_id=' + project_id;
                ds = $('prj_project_bp_query_name_ds');
                ds.setQueryUrl(url);
                ds.query();                
        	}
        	init();
        ]]></script>
    </a:view>
</a:screen>