<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:fields>
        <bm:field name="instance_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="INSTANCE_ID"/>
        <bm:field name="approve_count" databaseType="NUMBER" datatype="java.lang.Long" physicalName="APPROVE_COUNT"/>
        <bm:field name="rcpt_record_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="RCPT_RECORD_ID"/>
        <bm:field name="record_id" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="workflow_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="WORKFLOW_ID"/>
        <bm:field name="workflow_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="WORKFLOW_CODE"/>
        <bm:field name="workflow_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="WORKFLOW_DESC"/>
        <bm:field name="company_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="COMPANY_ID"/>
        <bm:field name="company_info" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="instance_status" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="instance_status_desc" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="node_id"/>
        <bm:field name="node_desc"/>
        <bm:field name="sequence_num"/>
        <bm:field name="document_info"/>
        <bm:field name="submitted_by"/>
        <bm:field name="user_name"/>
        <bm:field name="submitted_by_name"/>
        <bm:field name="approve_date"/>
        <bm:field name="action_type_desc"/>
        <bm:field name="record_type"/>
        <bm:field name="current_node_desc"/>
        <bm:field name="approve_user_name"/>
        <bm:field name="rcpt_record_type"/>
        <!-- <bm:field name="contract_number"/> -->
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
            	select  
            	       t1.action_type,
            	       t1.instance_id,
            		   t1.approve_count,
            		   t1.record_id,
            		   t1.rcpt_record_id,
            		   t1.instance_workflow_id,
				       t1.workflow_id,
				       t1.workflow_code,
				       t1.workflow_desc,
				       t1.company_id,
				       t1.company_info,
				       t1.instance_status,
				       t1.instance_status_desc,
				       t1.node_id,
				       t1.node_desc,
				       t1.sequence_num,
				       t1.document_info,
				       t1.submitted_by,
				        (select su.user_name
                                 from sys_user su
                                where su.user_id = t1.submitted_by) user_name,
				       t1.submitted_by_name,
				       t1.approve_date,
				       -- to_date(t1.approve_date,'yyyy-mm-dd') approve_date,
				       t1.action_type_desc,
				       t1.record_type,
				       t1.current_node_desc,
				       t1.approve_user_name,
				       t1.rcpt_record_type
				       --t1.contract_number
				  from zj_wfl_approved_application_v t1  #WHERE_CLAUSE# order by approve_date desc
			]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:data-filters>
        <bm:data-filter enforceOperations="query" expression="t1.user_id=${/session/@user_id} and t1.company_id = ${/session/@company_id}"/>
    </bm:data-filters>
    <bm:query-fields>
        <bm:query-field name="instance_workflow_id" queryExpression="t1.instance_workflow_id = ${@instance_workflow_id}"/>
        <bm:query-field name="node_desc" queryExpression="t1.node_desc like &apos;%&apos;||${@node_desc}||&apos;%&apos;"/>
        <bm:query-field name="instance_id" queryExpression="t1.instance_id = ${@instance_id}"/>
        <bm:query-field name="document_info" queryExpression="t1.document_info like &apos;%&apos;||${@document_info}||&apos;%&apos;"/>
        <bm:query-field name="action_type" queryExpression="t1.action_type = ${@action_type}"/>
        <bm:query-field name="current_node_desc" queryExpression="t1.current_node_desc like &apos;%&apos;||${@current_node_desc}||&apos;%&apos;"/>
        <bm:query-field name="approve_date_from" queryexpression="trunc(to_date(t1.approve_date,&apos;yyyy-mm-dd hh24:mi:ss&apos;)) &gt;= to_date(${@approve_date_from},&apos;yyyy-mm-dd hh24:mi:ss&apos;)"/>
        <bm:query-field name="approve_date_to" queryexpression="trunc(to_date(t1.approve_date,&apos;yyyy-mm-dd hh24:mi:ss&apos;)) &lt;= to_date(${@approve_date_to},&apos;yyyy-mm-dd hh24:mi:ss&apos;)"/>
        <bm:query-field name="instance_status" queryExpression="t1.instance_status = ${@instance_status}"/>
    </bm:query-fields>
</bm:model>
