<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: LR  
    $Date: 2013-7-18 上午09:34:28  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true">
    <a:init-procedure><![CDATA[
    ]]></a:init-procedure>
    <a:view>
        <a:link id="acp_invoice_query_link" url="${/request/@context_path}/modules/acp/ACP310/acp_invoice_check.lview"/>
        <script type="text/javascript"><![CDATA[
            function acp514_grid_update(invoice_hd_id) {
                var win = new Leaf.Window({
                    id: 'acp_invoice_check_window',
                    url: $('acp_invoice_query_link').getUrl(),
                    params: {
                        invoice_hd_id: invoice_hd_id,
                        winId: 'acp_invoice_check_window'
                    },
                    title: '应付发票信息',
                    fullScreen: true
                });
                win.on('close', function() {
                    $('acp514_invoice_result_ds').query();
                });
            }
            
            function acp514_document_number_render(value, record, name) {
                return '<a href="javascript:acp514_grid_update(' + record.get('invoice_hd_id') + ')">' + value + '</a>';
            }
            function acp514_invoice_query() {
                $('acp514_invoice_result_ds').query();
            }
            
            function acp514_invoice_reset() {
                $('acp514_invoice_query_ds').reset();
            }
            
            function acp514_invoice_reverse() {
                var records = $('acp514_invoice_result_ds').getSelected();
                if (!records.length) {
                    Leaf.showMessage('${l:PROMPT}', '请至少选择一条记录');
                    return;
                }
                $('acp514_invoice_result_ds').submitSelected();
            }
            
            function acp514_invoice_result_ds_submitsuccess(ds) {
                $('acp514_invoice_update_grid_ds').clear();
            }
            
            function acp514_formatMoney(value, record, name) {
                return Leaf.formatNumber(value);
            }
            
            function construct_from_to() {
                var config = ['document_number', 'invoice_number', 'contract_number', 'invoice_date', 'accounting_date', 'total_amount'];
                var pattern = ['_f', '_t'];
                var obj = {};
                for (var i = 0,
                    j = config.length;i < j;i++) {
                    for (var m = 0,
                        n = pattern.length;m < n;m++) {
                        obj[config[i] + pattern[m]] = config[i] + pattern[n - 1 - m];
                    }
                }
                return obj;
            }
            
            function acp514_invoice_query_Onupdate(ds, record, name, value, oldVlaue) {
                var from_to = construct_from_to();
                var opposite_name = from_to[name];
                if (!Ext.isEmpty(opposite_name)) {
                    var opposite_value = record.get(opposite_name);
                    if (!Ext.isEmpty(value) && Ext.isEmpty(opposite_value)) {
                        record.set(opposite_name, value);
                    }
                }
                /*if (name == 'document_number_f') {
                 if (Leaf.isEmpty(record.get('document_number_t'))) {
                 record.set('document_number_t', value);
                 }
                 } else if (name == 'project_number_f') {
                 if (Leaf.isEmpty(record.get('project_number_t'))) {
                 record.set('project_number_t', value);
                 }
                 } else if (name == 'invoice_number_f') {
                 if (Leaf.isEmpty(record.get('invoice_number_t'))) {
                 record.set('invoice_number_t', value);
                 }
                 } else if (name == 'contract_number_f') {
                 if (Leaf.isEmpty(record.get('contract_number_t'))) {
                 record.set('contract_number_t', value);
                 }
                 } else if (name == 'invoice_bp_code_f') {
                 if (Leaf.isEmpty(record.get('invoice_bp_code_t'))) {
                 record.set('invoice_bp_code_t', value);
                 }
                 } else if (name == 'total_amount_f') {
                 if (Leaf.isEmpty(record.get('total_amount_t'))) {
                 record.set('total_amount_t', value);
                 }
                 }
                 if (Ext.isEmpty(record.get('project_number_f')) && Ext.isEmpty(record.get('project_number_t'))) {
                 record.set('query_project_number', '');
                 } else {
                 record.set('query_project_number', 'Y');
                 }
                if (Ext.isEmpty(record.get('contract_number_f')) && Ext.isEmpty(record.get('contract_number_t'))) {
                    record.set('query_contract_number', '');
                } else {
                    record.set('query_contract_number', 'Y');
                }*/
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="acp514_invoice_query_ds">
                <a:fields>
                    <a:field name="created_by_name" lovGridHeight="320" lovHeight="500" lovService="acp.ACP512.acp_invoice_sys_user_lov" lovWidth="500" title="开票人选择">
                        <a:mapping>
                            <a:map from="user_id" to="created_by"/>
                            <a:map from="description" to="created_by_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="invoice_bp_code_f" lovGridHeight="320" lovHeight="480" lovService="acp.ACP512.acp_invoice_bp_master_list" lovWidth="500" title="客户选择">
                        <a:mapping>
                            <a:map from="bp_code" to="invoice_bp_code_f"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="invoice_bp_code_t" lovGridHeight="320" lovHeight="480" lovService="acp.ACP512.acp_invoice_bp_master_list" lovWidth="500" title="客户选择">
                        <a:mapping>
                            <a:map from="bp_code" to="invoice_bp_code_t"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="project_number_f" lovGridHeight="320" lovHeight="480" lovService="acp.ACP512.acp_invoice_project_list" lovWidth="500" title="项目选择">
                        <a:mapping>
                            <a:map from="project_number" to="project_number_f"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="project_number_t" lovGridHeight="320" lovHeight="480" lovService="acp.ACP512.acp_invoice_project_list" lovWidth="500" title="项目选择">
                        <a:mapping>
                            <a:map from="project_number" to="project_number_t"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="contract_number_f" lovGridHeight="320" lovHeight="480" lovService="acp.ACP512.acp_invoice_contract_list" lovWidth="500" title="合同选择">
                        <a:mapping>
                            <a:map from="contract_number" to="contract_number_f"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="contract_number_t" lovGridHeight="320" lovHeight="480" lovService="acp.ACP512.acp_invoice_contract_list" lovWidth="500" title="合同选择">
                        <a:mapping>
                            <a:map from="contract_number" to="contract_number_t"/>
                        </a:mapping>
                    </a:field>
                </a:fields>
                <a:events>
                    <a:event name="update" handler="acp514_invoice_query_Onupdate"/>
                </a:events>
            </a:dataSet>
            <a:dataSet id="acp514_invoice_result_ds" autoPageSize="true" autoQuery="true" model="acp.ACP514.acp_invoice_reverse" queryDataSet="acp514_invoice_query_ds" selectable="true">
                <a:fields>
                    <a:field name="reverse_date" required="true"/>
                </a:fields>
                <a:events>
                    <a:event name="submitsuccess" handler="acp514_invoice_result_ds_submitsuccess"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:toolbarButton click="acp514_invoice_query" text="HLS.QUERY"/>
                <a:toolbarButton click="acp514_invoice_reset" text="HLS.RESET"/>
                <a:toolbarButton click="acp514_invoice_reverse" text="HLS.REVERSE"/>
            </a:screenTopToolbar>
            <a:form column="4" marginWidth="30" title="应付发票维护">
                <a:textField name="document_number_f" bindTarget="acp514_invoice_query_ds" prompt="HLS.DOCUMENT_NUMBER_FROM"/>
                <a:textField name="document_number_t" bindTarget="acp514_invoice_query_ds" prompt="HLS.DOCUMENT_NUMBER_TO"/>
                <a:textField name="invoice_number_f" bindTarget="acp514_invoice_query_ds" prompt="ACR.INVOICE_NUMBER_FROM"/>
                <a:textField name="invoice_number_t" bindTarget="acp514_invoice_query_ds" prompt="ACR.INVOICE_NUMBER_TO"/>
                <a:lov name="contract_number_f" bindTarget="acp514_invoice_query_ds" prompt="HLS.CONTRACT_NUMBER_FROM"/>
                <a:lov name="contract_number_t" bindTarget="acp514_invoice_query_ds" prompt="HLS.CONTRACT_NUMBER_TO"/>
                <a:datePicker name="invoice_date_f" bindTarget="acp514_invoice_query_ds" prompt="ACR.INVOICE_DATE_FROM"/>
                <a:datePicker name="invoice_date_t" bindTarget="acp514_invoice_query_ds" prompt="ACR.INVOICE_DATE_TO"/>
                <a:datePicker name="accounting_date_f" bindTarget="acp514_invoice_query_ds" prompt="HLS.ACCOUNT_DATE_FROM"/>
                <a:datePicker name="accounting_date_t" bindTarget="acp514_invoice_query_ds" prompt="HLS.ACCOUNT_DATE_TO"/>
                <a:numberField name="total_amount_f" allowFormat="true" bindTarget="acp514_invoice_query_ds" prompt="ACR.TOTAL_AMOUNT_FROM"/>
                <a:numberField name="total_amount_t" allowFormat="true" bindTarget="acp514_invoice_query_ds" prompt="ACR.TOTAL_AMOUNT_TO"/>
                <!--<a:hBox labelSeparator=" ">
                    <a:textField name="document_number_f" bindTarget="acp514_invoice_query_ds" prompt="HLS.DOCUMENT_NUMBER_FROM" width="135"/>
                    <div><![CDATA[${l:HLS.DOCUMENT_NUMBER_TO}]]></div>
                    <a:textField name="document_number_t" bindTarget="acp514_invoice_query_ds" prompt="" width="135"/>
                    <a:lov name="project_number_f" bindTarget="acp514_invoice_query_ds" prompt="HLS.PROJECT_NUMBER_FROM" width="135"/>
                    <div><![CDATA[${l:HLS.DOCUMENT_NUMBER_TO}]]></div>
                    <a:lov name="project_number_t" bindTarget="acp514_invoice_query_ds" prompt="" width="135"/>
                    <a:comboBox name="business_type_desc" bindTarget="acp514_invoice_query_ds" prompt="HLS.BUSINESS_TYPE_DESC" width="135"/>
                    <a:comboBox name="currency_name" bindTarget="acp514_invoice_query_ds" prompt="HLS.CURRENCY" width="135"/>
                </a:hBox>
                <a:hBox labelSeparator=" ">
                    <a:textField name="invoice_number_f" bindTarget="acp514_invoice_query_ds" prompt="ACR.INVOICE_NUMBER_FROM" width="135"/>
                    <div><![CDATA[${l:ACR.INVOICE_NUMBER_TO}]]></div>
                    <a:textField name="invoice_number_t" bindTarget="acp514_invoice_query_ds" prompt="" width="135"/>
                    <a:lov name="contract_number_f" bindTarget="acp514_invoice_query_ds" prompt="HLS.CONTRACT_NUMBER_FROM" width="135"/>
                    <div><![CDATA[${l:HLS.CONTRACT_NUMBER_TO}]]></div>
                    <a:lov name="contract_number_t" bindTarget="acp514_invoice_query_ds" prompt="" width="135"/>
                    <a:lov name="created_by_name" bindTarget="acp514_invoice_query_ds" prompt="ACR.CREATED_BY_NAME" width="135"/>
                </a:hBox>
                <a:hBox labelSeparator=" ">
                    <a:datePicker name="invoice_date_f" bindTarget="acp514_invoice_query_ds" prompt="ACR.INVOICE_DATE_FROM" width="135"/>
                    <div><![CDATA[${l:ACR.INVOICE_DATE_TO}]]></div>
                    <a:datePicker name="invoice_date_t" bindTarget="acp514_invoice_query_ds" prompt="" width="135"/>
                    <a:lov name="invoice_bp_code_f" bindTarget="acp514_invoice_query_ds" prompt="HLS.CUSTOMER_NUMBER_FROM" width="135"/>
                    <div><![CDATA[${l:HLS.CUSTOMER_NUMBER_TO}]]></div>
                    <a:lov name="invoice_bp_code_t" bindTarget="acp514_invoice_query_ds" prompt="" width="135"/>
                    <a:comboBox name="invoice_kind_desc" bindTarget="acp514_invoice_query_ds" prompt="ACR.INVOICE_KIND" width="135"/>
                </a:hBox>
                <a:hBox labelSeparator=" ">
                    <a:datePicker name="accounting_date_f" bindTarget="acp514_invoice_query_ds" prompt="HLS.ACCOUNT_DATE_FROM" width="135"/>
                    <div><![CDATA[${l:HLS.ACCOUNT_DATE_TO}]]></div>
                    <a:datePicker name="accounting_date_t" bindTarget="acp514_invoice_query_ds" prompt="" width="135"/>
                    <a:numberField name="total_amount_f" allowFormat="true" bindTarget="acp514_invoice_query_ds" prompt="ACR.TOTAL_AMOUNT_FROM" width="135"/>
                    <div><![CDATA[${l:ACR.TOTAL_AMOUNT_TO}]]></div>
                    <a:numberField name="total_amount_t" allowFormat="true" bindTarget="acp514_invoice_query_ds" prompt="" width="135"/>
                    <a:textField name="invoice_title" bindTarget="acp514_invoice_query_ds" prompt="ACR.INVOICE_TITLE" width="135"/>
                </a:hBox>-->
            </a:form>
            <a:grid id="acp514_invoice_update_grid_ds" bindTarget="acp514_invoice_result_ds" marginHeight="250" marginWidth="30" navBar="true">
                <a:columns>
                    <a:column name="document_number" lock="true" prompt="HLS.DOCUMENT_NUMBER" renderer="acp514_document_number_render" width="120"/>
                    <!--<a:column name="business_type_desc" prompt="HLS.BUSINESS_TYPE_DESC" width="80"/>-->
                    <a:column name="invoice_kind_desc" prompt="ACR.INVOICE_KIND" width="100"/>
                    <a:column name="invoice_number" prompt="ACR.INVOICE_NUMBER" width="120"/>
                    <a:column name="invoice_date" prompt="ACR.INVOICE_DATE" width="100"/>
                    <a:column name="reverse_date" editor="invoice_grid_dp" prompt="HLS.REVERSE_DATE" renderer="Leaf.formatDate" width="100"/>
                    <!--<a:column name="project_name" autoAdjust="false" prompt="HLS.PROJECT_NAME" showTitle="true" width="150"/>-->
                    <a:column name="contract_number" prompt="HLS.CONTRACT_NUMBER" width="120"/>
                    <!--<a:column name="bp_code" prompt="HLS.CUSTOMER_NUMBER" width="100"/>-->
                    <a:column name="invoice_title" autoAdjust="false" prompt="ACR.INVOICE_TITLE" showTitle="true" width="150"/>
                    <a:column name="total_amount" align="right" prompt="ACR.TOTAL_AMOUNT" renderer="Leaf.formatMoney" width="100"/>
                    <!--<a:column name="currency" prompt="HLS.CURRENCY" width="80"/>-->
                    <a:column name="created_by_name" autoAdjust="false" prompt="ACR.CREATED_BY_NAME" showTitle="true" width="150"/>
                    <a:column name="invoice_status_desc" prompt="ACR.INVOICE_STATUS" width="100"/>
                    <a:column name="accounting_date" prompt="HLS.ACCOUNT_DATE" width="100"/>
                    <a:column name="invoice_bp_name" autoAdjust="false" prompt="HLS.CUSTOMER_NAME" showTitle="true" width="150"/>
                    <!--<a:column name="project_number" prompt="HLS.PROJECT_NUMBER" width="120"/>-->
                    <a:column name="contract_name" autoAdjust="false" prompt="HLS.CONTRACT_NAME" showTitle="true" width="150"/>
                </a:columns>
                <a:editors>
                    <a:datePicker id="invoice_grid_dp"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>