<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang  
    $Date: 2013-6-25 上午10:01:05  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT
                    t1.config_id,
                    t1.layout_code,
                    t1.tab_code,
                    lower(t1.column_name) column_name,
                    t1.data_type,
                    t1.system_flag,
                    NVL(t1.enabled_flag, 'N') enabled_flag,
                    NVL(t1.display_flag, 'N') display_flag,
                    t1.display_order,
                    (case when t1.column_name = 'SALES_YEAR1' then
                    	'销售额('||(to_char(sysdate,'yyyy')-3)||'年)'
                   	 when t1.column_name = 'SALES_YEAR2' then
                   	    '销售额('||(to_char(sysdate,'yyyy')-2)||'年)'
                   	 when t1.column_name = 'SALES_YEAR3' then
                   	    '销售额('||(to_char(sysdate,'yyyy')-1)||'年)'
                   	 when t1.column_name = 'SALES_YEAR4' then
                   	    '销售额('||to_char(sysdate,'yyyy')||'年)'
                   	 else
                   	    t1.prompt
                    end) prompt,
                    t1.input_mode,
                    DECODE(t1.input_mode, 'REQUIRED', 'TRUE','REQUIRED_ONLY_ADD','TRUE','FALSE') required_input_mode,
                    (
                        CASE
                            WHEN ${@maintain_type}='READONLY' or lt.query_only='Y'
                            THEN 'TRUE'
                            ELSE DECODE(t1.input_mode, 'READONLY', 'TRUE', 'FALSE')
                        END) readonly_input_mode,
                    (
                        CASE
                            WHEN t1.validation_type IN ('COMBOBOX','LOV','TREE')
                            THEN DECODE(NVL(t1.lov_return_vcode, 'N'),'N',t1.validation_type,t1.validation_type
                                ||'_C')
                            ELSE t1.validation_type
                        END)validation_type,
                    t1.validation_sql,
                    NVL(t1.precision, 2) PRECISION,
                    NVL(t1.zero_fill, 'FALSE') zero_fill,
                    NVL(t1.allow_format, 'FALSE') allow_format,
                    NVL(t1.allow_decimal, 'FALSE') allow_decimal,
                    t1.percent,
                    t1.default_value,
                    hls_document_save_pkg.get_default_value_name(p_layout_code =>t1.layout_code, p_tab_code =>t1.tab_code, p_column_name =>t1.column_name, p_validation_type =>t1.validation_type, p_user_id =>${/session/@user_id},p_session_id=>${/session/@session_id}) default_value_name,
                    t1.upper_limit,
                    t1.lower_limit,
                    NVL(t1.width, 120) width,
                    t1.key_field_flag,
                    NVL(t1.alignment,'center') alignment,
                    NVL(t1.lov_return_vcode, 'N') lov_return_vcode,
                    t1.copy_from_parent_tab,
                    t1.height,
                    decode(${/session/@lov_search_rule},'AUTOCOMPLETE','true','false') autocomplete,
                    decode(${/session/@lov_search_rule},'FETCHSINGLE','true','false') fetchsingle,
                    decode(t1.footerrenderer,'Y','sumFunction','') footerrenderer,
                    (case when t1.validation_type in ('TEXTFIELD','TEXTAREA') then
       					decode(sys_parameter_pkg.value('SYS_GRID_SHOW_TITLE',${/session/@user_id},${/session/@role_id},${/session/@company_id}),'Y','true','false')
   					else 'false'
   					end) sys_grid_show_title,
   					lower(t1.lov_cascade_para1) lov_cascade_para1,
   					lower(t1.lov_cascade_para2) lov_cascade_para2,
   					lower(t1.lov_cascade_para3) lov_cascade_para3,
   					t1.field_javascript
                FROM
                    hls_doc_layout_config t1,hls_doc_layout_tab lt #WHERE_CLAUSE#
                ORDER BY
                    t1.display_order
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="config_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CONFIG_ID"/>
        <bm:field name="layout_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LAYOUT_CODE"/>
        <bm:field name="tab_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TAB_CODE"/>
        <bm:field name="column_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="COLUMN_NAME"/>
        <bm:field name="data_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DATA_TYPE"/>
        <bm:field name="system_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SYSTEM_FLAG"/>
        <bm:field name="enabled_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ENABLED_FLAG"/>
        <bm:field name="display_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DISPLAY_FLAG"/>
        <bm:field name="display_order" databaseType="NUMBER" datatype="java.lang.Long" physicalName="DISPLAY_ORDER"/>
        <bm:field name="prompt" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PROMPT"/>
        <bm:field name="input_mode" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="INPUT_MODE"/>
        <bm:field name="required_input_mode" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REQUIRED_INPUT_MODE"/>
        <bm:field name="readonly_input_mode" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="READONLY_INPUT_MODE"/>
        <bm:field name="validation_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="VALIDATION_TYPE"/>
        <bm:field name="validation_sql" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="VALIDATION_SQL"/>
        <bm:field name="precision" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PRECISION"/>
        <bm:field name="zero_fill" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ZERO_FILL"/>
        <bm:field name="allow_format" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ALLOW_FORMAT"/>
        <bm:field name="allow_decimal" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ALLOW_DECIMAL"/>
        <bm:field name="percent" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PERCENT"/>
        <bm:field name="default_value" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DEFAULT_VALUE"/>
        <bm:field name="default_value_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DEFAULT_VALUE_NAME"/>
        <bm:field name="upper_limit" databaseType="NUMBER" datatype="java.lang.Long" physicalName="UPPER_LIMIT"/>
        <bm:field name="lower_limit" databaseType="NUMBER" datatype="java.lang.Long" physicalName="LOWER_LIMIT"/>
        <bm:field name="width" databaseType="NUMBER" datatype="java.lang.Long" physicalName="WIDTH"/>
        <bm:field name="height" databaseType="NUMBER" datatype="java.lang.Long" physicalName="HEIGHT"/>
        <bm:field name="key_field_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="KEY_FIELD_FLAG"/>
        <bm:field name="alignment" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ALIGNMENT"/>
        <bm:field name="lov_return_vcode" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LOV_RETURN_VCODE"/>
        <bm:field name="copy_from_parent_tab" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="COPY_FROM_PARENT_TAB"/>
        <bm:field name="autocomplete" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="AUTOCOMPLETE"/>
        <bm:field name="fetchsingle" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FETCHSINGLE"/>
        <bm:field name="footerrenderer" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FOOTERRENDERER"/>
        <bm:field name="sys_grid_show_title" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SYS_GRID_SHOW_TITLE"/>
        <bm:field name="lov_cascade_para1" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LOV_CASCADE_PARA1"/>
        <bm:field name="lov_cascade_para2" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LOV_CASCADE_PARA2"/>
        <bm:field name="lov_cascade_para3" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LOV_CASCADE_PARA3"/>
        <bm:field name="field_javascript" databaseType="CLOB" datatype="java.sql.Clob" physicalName="FIELD_JAVASCRIPT"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field field="layout_code" queryExpression="t1.layout_code=${@layout_code}"/>
        <bm:query-field field="enabled_flag" queryExpression="t1.enabled_flag=${@enabled_flag}"/>
        <bm:query-field field="display_flag" queryExpression="t1.display_flag=${@display_flag}"/>
        <bm:query-field name="grid_tab_code" queryExpression="t1.tab_code=${@grid_tab_code}"/>
        <bm:query-field name="textarea_tab_code" queryExpression="t1.tab_code=${@textarea_tab_code}"/>
        <bm:query-field name="form_tab_code" queryExpression="t1.tab_code=${@form_tab_code}"/>
        <bm:query-field field="column_name" queryExpression="t1.column_name=upper(${@column_name})"/>
    </bm:query-fields>
    <bm:data-filters>
        <bm:data-filter enforceOperations="query" expression="(t1.layout_code=lt.layout_code and t1.tab_code=lt.tab_code)"/>
    </bm:data-filters>
</bm:model>
