<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2014-1-3 下午02:33:27  
    $Revision: 1.0  
    $Purpose: 回访报告维护
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" trace="true">
    <a:init-procedure>
        <a:model-query defaultWhereClause="fc.company_id=${/session/@company_id}" fetchAll="true" model="fnd.fnd_companies" rootPath="default_company_path"/>
    </a:init-procedure>
    <a:view>
        <a:link id="prj_chance_con_contract_update_link_id" url="${/request/@context_path}/modules/cont/CON500/con_contract_update.lview"/>
        <a:link id="con_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <script type="text/javascript"><![CDATA[
        
        	function con_visit_report_hds_query(){
    	    	$('con_visit_report_hds_result_ds').query();
        	}
        	
        	function con_visit_report_hds_reset(){
        	    $('con_visit_report_hds_query_ds').reset();
        	}
        	
    		function con_visit_report_hds_save() {
    		    $('con_visit_report_hds_result_ds').submit();
    		}
    		
    		function con_visit_report_hds_remove(){
    		    $('con_visit_report_hds_grid').remove();
    		}
    		function con_visit_report_hds_new(){
    		    var record = $('con_visit_report_hds_temp_ds').getCurrentRecord();
                    record.set('function_code','CON801');
	                record.set('function_usage', 'CREATE');
	                record.set('document_category', 'VISIT_REPORT');
	                record.set('default_value_dsid', 'con_visit_report_hds_temp_ds');
	                record.data['url_title']='${l:CON801.VISIT_REPORT_CREATE}';
	                var param = record.data;
	                hls_doc_get_layout_code('con_contract_get_layout_code_link_id',param,'prj_chance_con_contract_update_link_id','con_visit_report_hds_result_ds');
    		    
    		}
    		
    		function visit_detail_renderer(value,record,name){
    		    var visit_report_id=record.get('visit_report_id');
    		    if(!Ext.isEmpty(visit_report_id)){
    		        return '<a href="javascript:open_detail_window('+record.id+')">'+'${l:PROMPT.DETAIL}'+'</a>';
    		    }
    		}
    		
    		function open_detail_window(id){
    			var current_record = $('con_visit_report_hds_result_ds').findById(id);
                var param = current_record.data;
                param['function_code'] = 'CON801';
                param['document_id'] = current_record.get('visit_report_id');
                param['function_usage'] = 'MODIFY';
                param['maintain_type'] = 'VISIT_REPORT';
                param['url_title'] = '${l:CON801.VISIT_REPORT_MODIFY}';
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'prj_chance_con_contract_update_link_id', 'con_visit_report_hds_result_ds');
            }
    		
		]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
        <a:screen-include screen="modules/cont/CON500/con_contract_authority_list_validate.lview?document_category=VISIT_REPORT&amp;function_code=CON801"/>
        <a:dataSets>
            <a:dataSet id="con_visit_method_ds" lookupCode="CON_VISIT_METHOD"/>
            <a:dataSet id="con_visit_result_ds" lookupCode="CON_VISIT_RESULT"/>
            <a:dataSet id="con_visit_report_hds_temp_ds" autoCreate="true">
                <a:fields>
                    <a:field name="company_id" defaultValue="${/model/default_company_path/record/@company_id}"/>
                    <a:field name="company_id_n" defaultValue="${/model/default_company_path/record/@company_full_name}"/>
                    <a:field name="owner_user_id"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con_visit_report_hds_query_ds">
                <a:fields>
                    <a:field name="visit_report_desc"/>
                    <a:field name="tenant_id"/>
                    <a:field name="bp_name" lovGridHeight="350" lovHeight="500" lovService="basic.hls_bp_master_v_for_lov?bp_category=TENANT" lovWidth="500">
                        <a:mapping>
                            <a:map from="bp_name" to="bp_name"/>
                            <a:map from="bp_id" to="tenant_id"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="visit_method"/>
                    <a:field name="visit_method_desc" displayField="code_value_name" options="con_visit_method_ds" returnField="visit_method" valueField="code_value"/>
                    <a:field name="visit_date"/>
                    <a:field name="visit_result"/>
                    <a:field name="visit_result_desc" displayField="code_value_name" options="con_visit_result_ds" returnField="visit_result" valueField="code_value"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con_visit_report_hds_result_ds" autoQuery="true" model="cont.CON801.con_visit_report_hds" pageSize="15" queryDataSet="con_visit_report_hds_query_ds" selectable="true">
                <a:fields>
                    <a:field name="document_category" defaultValue="VISIT_REPORT"/>
                    <a:field name="visit_report_desc"/>
                    <a:field name="tenant_id"/>
                    <a:field name="bp_name" lovGridHeight="350" lovHeight="500" lovService="basic.hls_bp_master_v_for_lov?bp_category=TENANT" lovWidth="500">
                        <a:mapping>
                            <a:map from="bp_name" to="bp_name"/>
                            <a:map from="bp_id" to="tenant_id"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="visit_method"/>
                    <a:field name="visit_method_desc" displayField="code_value_name" options="con_visit_method_ds" returnField="visit_method" valueField="code_value"/>
                    <a:field name="visit_date"/>
                    <a:field name="visit_result"/>
                    <a:field name="visit_result_desc" displayField="code_value_name" options="con_visit_result_ds" returnField="visit_result" valueField="code_value"/>
                </a:fields>
                <a:events>
                    <a:event name="query" handler="aut_authority_list_validate_query"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="con_visit_report_hds_query" text="HLS.QUERY"/>
                <a:gridButton click="con_visit_report_hds_reset" text="HLS.RESET"/>
                <a:gridButton click="con_visit_report_hds_new" text="HLS.NEW"/>
                <a:gridButton click="con_visit_report_hds_remove" text="HLS.REMOVE"/>
                <a:gridButton click="con_visit_report_hds_save" text="HLS.SAVE"/>
            </a:screenTopToolbar>
            <a:form column="4" labelWidth="120" marginWidth="30" title="HLS.QUERY_TITLE">
                <!-- <a:textField name="visit_report_desc" bindTarget="con_visit_report_hds_query_ds" prompt="CON801.VISIT_REPORT_DESC"/> -->
                <a:lov name="bp_name" bindTarget="con_visit_report_hds_query_ds" prompt="HLS.TENANT_CODE">
                    <a:events>
                        <a:event name="focus" handler="function(object){on_std_focus(object,&apos;BP&apos;)}"/>
                    </a:events>
                </a:lov>
                <a:comboBox name="visit_method_desc" bindTarget="con_visit_report_hds_query_ds" prompt="CON801.VISIT_METHOD_DESC"/>
                <a:datePicker name="visit_date" bindTarget="con_visit_report_hds_query_ds" prompt="CON801.VISIT_DATE"/>
                <a:comboBox name="visit_result_desc" bindTarget="con_visit_report_hds_query_ds" prompt="CON801.VISIT_RESULT_DESC"/>
            </a:form>
            <a:grid id="con_visit_report_hds_grid" bindTarget="con_visit_report_hds_result_ds" marginHeight="200" marginWidth="30" navBar="true">
                <a:columns>
                    <!-- <a:column name="visit_report_desc" prompt="CON801.VISIT_REPORT_DESC" width="250"/> -->
                    <a:column name="bp_name" prompt="HLS.TENANT_CODE" width="200"/>
                    <a:column name="visit_date" prompt="CON801.VISIT_DATE" renderer="Leaf.formatDate" width="80"/>
                    <a:column name="visit_method_desc" prompt="CON801.VISIT_METHOD_DESC"/>
                    <a:column name="visit_result_desc" prompt="CON801.VISIT_RESULT_DESC"/>
                    <a:column name="visit_detail" align="center" prompt="CON801.VISIT_DETAIL" renderer="visit_detail_renderer" width="80"/>
                </a:columns>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
