<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2013-9-6 下午01:47:51  
    $Revision: 1.0  
    $Purpose: 租金明细
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:view>
        <a:link id="con_contract_balance_fine_link" url="${/request/@context_path}/modules/cont/CON305/con_contract_balance_fine.lview"/>
        <script type="text/javascript"><![CDATA[
            function quit() {
                $('con_contract_balance_details_win').close();
            }
            
            //移除的数据不能导出
            function con_contract_balance_details_clear() {
                $('con_contract_balance_details_line_grid').clear();
            }
            
            function con_contract_balance_details_query() {
                $('con_contract_balance_details_line_ds').query();
            }
            
            function get_fine_details(value, record, name) {
                if (value != 0) {
                    var cashflow_id = record.get('cashflow_id');
                    return '<a href="#' + Math.random() + '"  onclick="open_window(' + cashflow_id + ')">' + Leaf.formatMoney(value) + '<a>';
                } else return Leaf.formatMoney(value);
            }
            
            function open_window(cashflow_id) {
                new Leaf.Window({
                    title: '收款明细及罚金计算表',
                    id: 'con_contract_balance_fine_win',
                    url: $('con_contract_balance_fine_link').getUrl(),
                    params: {
                        'cashflow_id': cashflow_id
                    },
                    width: 950,
                    height: 550
                });
            }
            
            function con_contract_balance_details_export() {
                set_export_parameter();
                $('con_contract_balance_details_line_grid')._export();
            }
            function con_contract_balance_details_line_load(ds) {
                var grid_id = $('con_contract_balance_details_line_grid');
                grid_id.hideColumn('principal');
                grid_id.hideColumn('interest');
                grid_id.hideColumn('received_principal');
                grid_id.hideColumn('received_interest');
                grid_id.hideColumn('outstanding_int_tax_incld');
                grid_id.hideColumn('outstanding_prin_tax_incld');
                grid_id.hideColumn('outstanding_rental_tax_incld');
                grid_id.hideColumn('cf_item');
            
                //var records=ds.getAll();
                // for(var i=0;i<records.length;i++){
                // var record=records[i];
                // if(!Ext.isEmpty(record.get('colour_scheme'))){
                // record.getField('times').setPropertity('tooltip','<span style="color:'+record.get('colour_scheme')+'">已逾期!</span>');
                // }
                // }
            
            }
            
            function times_renderer(value, record, name) {
                return '<span style="color:' + record.get('colour_scheme') + '">' + value + '</span>';
            }
            
            function cf_item_desc_renderer(value, record, name) {
                return '<span style="color:' + record.get('colour_scheme') + '">' + value + '</span>';
            }
            
            function due_date_renderer(value, record, name) {
                return '<span style="color:' + record.get('colour_scheme') + '">' + Leaf.formatDate(value) + '</span>';
            }
            
            function due_amount_renderer(value, record, name) {
                return '<span style="color:' + record.get('colour_scheme') + '">' + Leaf.formatMoney(value) + '</span>';
            }
            
            function last_received_date_renderer(value, record, name) {
                return '<span style="color:' + record.get('colour_scheme') + '">' + Leaf.formatDate(value) + '</span>';
            }
            
            function received_amount_renderer(value, record, name) {
                //return '<span style="color:red"></span>';
                return '<span style="color:' + record.get('colour_scheme') + '">' + Leaf.formatMoney(value) + '</span>';
            }
            
            function unpaid_amount_renderer(value, record, name) {
                return '<span style="color:' + record.get('colour_scheme') + '">' + Leaf.formatMoney(value) + '</span>';
            }
            
            function unpaid_fine_renderer(value, record, name) {
                return '<span style="color:' + record.get('colour_scheme') + '">' + Leaf.formatMoney(value) + '</span>';
            }
            
            function received_fine_renderer(value, record, name) {
                if (value > 0) {
            
                    return '<span style="color:' + record.get('colour_scheme') + '"><a href="javascript:open_window(' + record.get('cashflow_id') + ')">' + Leaf.formatMoney(value) + '</a></span>';
                } else {
                    return '<span style="color:' + record.get('colour_scheme') + '">' + Leaf.formatMoney(value) + '</span>';
                }
            }
            
            function total_amount_renderer(value, record, name) {
                return '<span style="color:' + record.get('colour_scheme') + '">' + Leaf.formatMoney(value) + '</span>';
            }
            
            
            function set_export_parameter(){
                var new_records=$('con_contract_balance_details_line_ds').getAll();
                var all_records=$('con_contract_balance_details_export_ds').getAll();
                if(new_records.length==all_records.length){
                    return;
                }
                var export_record;
                var choose_record;
                var list=[];
                for(var i=0;i<new_records.length;i++){
                     export_record=new_records[i];
                     choose_record=$('con_contract_balance_details_export_ds').find('cashflow_id',export_record.get('cashflow_id'));
                    if(choose_record){
                    	list.push(export_record.get('cashflow_id'));
                    }
                }
                list=list.join(',');
                $('con_contract_balance_details_line_ds').setQueryParameter('export_list',list);
            }
            
            function con_contract_balance_details_line_query(ds,qpara){
                // qpara['export_list']='';
                delete qpara['export_list'];
            }
        ]]></SCRIPT>
        <style><![CDATA[
        	a:link {color: #0000EE}  
        	a:hover {color: #ff8400} 
			a:active {color:#0A0A0A }
			a:visited {color:#0A0A0A} 
        ]]></style>
        <a:dataSets>
            <a:dataSet id="con_contract_balance_details_header_ds" autoQuery="true" queryUrl="${/request/@context_path}/autocrud/cont.CON305.con_contract_balance_details_header/query?contract_id=${/parameter/@contract_id}"/>
            <a:dataSet id="con_contract_balance_details_export_ds" autoQuery="true" model="cont.CON305.con_contract_balance_details_line" pageSize="100" queryUrl="${/request/@context_path}/autocrud/cont.CON305.con_contract_balance_details_line/query?contract_id=${/parameter/@contract_id}" selectable="true"><![CDATA[
            ]]></a:dataSet>
            <a:dataSet id="con_contract_balance_details_line_ds" autoQuery="true" model="cont.CON305.con_contract_balance_details_line" pageSize="100" queryUrl="${/request/@context_path}/autocrud/cont.CON305.con_contract_balance_details_line/query?contract_id=${/parameter/@contract_id}" selectable="true">
                <a:events>
                    <a:event name="load" handler="con_contract_balance_details_line_load"/>
                    <a:event name="query" handler="con_contract_balance_details_line_query"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton click="quit" text="HLS.CLOSE"/>
                <a:gridButton click="con_contract_balance_details_clear" text="HLS.CLEAR"/>
                <a:gridButton click="con_contract_balance_details_query" text="HLS.QUERY"/>
                <a:gridButton click="con_contract_balance_details_export" text="HLS.EXPORT"/>
            </a:screenTopToolbar>
            <a:form title="CON305.SEARCH_RESULT">
                <a:box column="4" labelWidth="80">
                    <!-- <a:textField name="bp_id_tenant" bindTarget="con_contract_balance_details_header_ds" prompt="CON305.BP_ID_TENANT" readOnly="true"/> -->
                    <a:textField name="bp_name" bindTarget="con_contract_balance_details_header_ds" colspan="2" prompt="HLS.CUSTOMER_NAME" readOnly="true" width="328"/>
                    <a:textField name="contract_number" bindTarget="con_contract_balance_details_header_ds" prompt="HLS.CONTRACT_NUMBER" readOnly="true" width="120"/>
                    <a:textField name="document_type_desc" bindTarget="con_contract_balance_details_header_ds" prompt="HLS.CONTRACT_TYPE" readOnly="true" width="120"/>
                    <a:numberField name="total_rental" allowFormat="true" bindTarget="con_contract_balance_details_header_ds" prompt="CON305.TOTAL_RENTAL" readOnly="true" width="120"/>
                    <a:numberField name="total_received" allowFormat="true" bindTarget="con_contract_balance_details_header_ds" prompt="CON305.TOTAL_RENANT_RECEIVED" readOnly="true" width="120"/>
                    <a:numberField name="total_balance" allowFormat="true" bindTarget="con_contract_balance_details_header_ds" prompt="CON305.UNRECEIVED_TOTAL_RENANT" readOnly="true" width="120"/>
                    <a:numberField name="overdue_amount" allowFormat="true" bindTarget="con_contract_balance_details_header_ds" prompt="CON305.OVERDUE_AMOUNT" readOnly="true" width="120"/>
                </a:box>
            </a:form>
            <a:grid id="con_contract_balance_details_line_grid" bindTarget="con_contract_balance_details_line_ds" marginHeight="230" marginWidth="30" navBar="true">
                <a:columns>
                    <a:column name="times" prompt="CON305.TIMES" renderer="times_renderer" width="50"/>
                    <a:column name="cf_item" prompt="HLS.CF_ITEM"/>
                    <a:column name="cf_item_desc" prompt="CON305.CF_ITEM" renderer="cf_item_desc_renderer" width="80"/>
                    <a:column name="due_date" prompt="CON305.DUE_DATE" renderer="due_date_renderer" width="80"/>
                    <a:column name="due_amount" align="right" prompt="CON305.DUE_AMOUNT" renderer="due_amount_renderer"/>
                    <a:column name="principal" align="right" prompt="CON305.ACC_PRINCIPAL" renderer="Leaf.formatMoney"/>
                    <a:column name="interest" align="right" prompt="CON305.ACC_INTEREST" renderer="Leaf.formatMoney"/>
                    <a:column name="last_received_date" prompt="CON305.LAST_RECEIVED_DATE" renderer="last_received_date_renderer"/>
                    <a:column name="received_amount" align="right" prompt="CON305.RECEIVED_AMOUNT" renderer="received_amount_renderer"/>
                    <a:column name="received_principal" align="right" prompt="ACR.RECEIVED_PRINCIPAL" renderer="Leaf.formatMoney"/>
                    <a:column name="received_interest" align="right" prompt="ACR.RECEIVED_INTEREST" renderer="Leaf.formatMoney"/>
                    <a:column name="unpaid_amount" align="right" prompt="CON305.UNPAID_AMOUNT" renderer="unpaid_amount_renderer"/>
                    <a:column name="outstanding_rental_tax_incld" align="right" prompt="TRE503.RESIDUE_RENTAL" renderer="Leaf.formatMoney"/>
                    <a:column name="outstanding_prin_tax_incld" align="right" prompt="TRE503.UNPAY_PRINCIPAL" renderer="Leaf.formatMoney"/>
                    <a:column name="outstanding_int_tax_incld" align="right" prompt="TRE503.UNPAY_INTEREST" renderer="Leaf.formatMoney"/>
                    <a:column name="unpaid_fine" align="right" prompt="CON305.UNPAID_FINE" renderer="unpaid_fine_renderer"/>
                    <a:column name="received_fine" align="right" prompt="CON305.RECEIVED_FINE" renderer="received_fine_renderer"/>
                    <a:column name="total_amount" align="right" prompt="CON305.RECEIVED_TOTAL_AMOUNT" renderer="total_amount_renderer"/>
                </a:columns>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>