<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Clocc  
    $Date: 2015-8-3 上午9:49:00  
    $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
                    *
                FROM
                    (SELECT
                        
                        ee.employee_id,
                        ee.employee_code,
                        ee.name,
                        ee.phone,
                        su.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_vl eop
                        WHERE
                            ea.employee_id    = su.employee_id AND
                            ea.position_id    = eop.position_id AND
                            eop.POSITION_TYPE = 'SALES'
                        )
                    ) tt #WHERE_CLAUSE#
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="employee_id" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="employee_code" databaseType="VARCHAR2" datatype="java.lang.String" forDisplay="true" forQuery="true" prompt="编码"/>
        <bm:field name="name" databaseType="VARCHAR2" datatype="java.lang.String" forDisplay="true" forQuery="true" prompt="描述"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field field="employee_code" queryOperator="like"/>
        <bm:query-field field="name" queryOperator="like"/>
    </bm:query-fields>
</bm:model>
