<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: jessen  
    $Date: 2011-9-8 下午12:20:48  
    $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 distinct * 
              from (
                select e.employee_id,
                       e.employee_code,
                       e.name,
                       e.email,
                       e.mobil,
                       e.phone,
                       e.bank_of_deposit,
                       e.bank_account,
                       e.enabled_flag,
                       e.employee_type_id,
                       e.id_type,
                       e.id_code,
                       eev.employee_type_code,
                       eev.description employee_type_name,
                       e.notes--,
                       --a.company_id
                  from exp_employees e ,exp_employee_types_vl eev
                 where eev.employee_type_id = e.employee_type_id
                   and (exists ( select 1 from exp_employee_assigns a where (a.company_id = ${/session/@company_id} or exists (
	                   select 1 
	                     from fnd_companies_vl c 
	                    where a.company_id = c.company_id 
	                      and c.parent_company_id=${/session/@company_id})) and a.employee_id = e.employee_id )) 
            )
            #WHERE_CLAUSE#       
            order by employee_code
        ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field name="employee_id" datatype="java.lang.Integer" queryexpression="employee_id = ${@employee_id}"/>
        <bm:query-field name="enabled_flag" datatype="java.lang.String" queryexpression="enabled_flag = ${@enabled_flag}"/>
        <bm:query-field name="employee_code" datatype="java.lang.String" queryexpression="upper(employee_code) like &apos;%&apos;||upper(${@employee_code})||&apos;%&apos;"/>
        <bm:query-field name="name" datatype="java.lang.String" queryexpression="upper(name) like &apos;%&apos;||upper(${@name})||&apos;%&apos;"/>
    </bm:query-fields>
</bm:model>
