<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: hp  
    $Date: 2015-7-22 下午2:24:06  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT
                    *
                FROM
                    (SELECT
                        ee.employee_code,
                        ee.name employee_name,
                        ee.phone,
                        su.user_id collector_user_id
                    FROM
                        exp_employees ee,
                        sys_user su
                    WHERE
                        ee.enabled_flag = 'Y' AND
                        su.employee_id  = ee.employee_id AND
                        SYSDATE BETWEEN su.start_date AND NVL(su.end_date, TRUNC(SYSDATE + 1)) AND
                        EXISTS
                        (SELECT
                            1
                        FROM
                            exp_employee_assigns ea,
                            exp_org_position eop
                        WHERE
                            ea.employee_id    = su.employee_id AND
                            ea.position_id    = eop.position_id AND
                            eop.position_type = 'COLLECTOR'
                        )
                    ) #WHERE_CLAUSE#
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="employee_code" databaseType="VARCHAR2" datatype="java.lang.String" forDisplay="true" forQuery="true" physicalName="EMPLOYEE_CODE" prompt="编码"/>
        <bm:field name="employee_name" databaseType="VARCHAR2" datatype="java.lang.String" forDisplay="true" forQuery="true" physicalName="EMPLOYEE_NAME" prompt="描述"/>
        <bm:field name="phone" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PHONE"/>
        <bm:field name="collector_user_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="COLLECTOR_USER_ID"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field field="employee_code" queryOperator="like"/>
        <bm:query-field field="employee_name" queryOperator="like"/>
    </bm:query-fields>
</bm:model>
