<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Spencer 3893  
    $Date: 2016-7-18 上午10:56:55  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
    <bm:fields>
        <bm:field name="group_name"/>
        <bm:field name="staff_name"/>
        <bm:field name="staff_id"/>
        <bm:field name="district"/>
        <bm:field name="note"/>
        <bm:field name="document_type"/>
        <bm:field name="document_type_desc"/>
        <bm:field name="admin_flag"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT
                    *
                FROM
                    (SELECT
                        ccg.group_name,
                        ccp.staff_name,
                        ccp.staff_id,
                        ccp.district,
                        ccp.note,
                        ccg.document_type,
                        (SELECT
                            dt.description
                        FROM
                            hls_document_type dt
                        WHERE
                            dt.document_type=ccg.document_type
                        ) document_type_desc,
                        ccg.leader_user_id,
                        (SELECT u.admin_flag FROM sys_user u WHERE u.user_id = ${/session/@user_id}
                        ) admin_flag
                    FROM
                        con_collection_group ccg,
                        con_collection_persons ccp
                    WHERE
                        ccg.group_id = ccp.group_id
                    ) t1 #WHERE_CLAUSE#
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field name="document_type" queryExpression="t1.document_type=${@document_type}"/>
        <!-- <bm:query-field name="leader_user_id" queryExpression="t1.leader_user_id=${@leader_user_id}"/> -->
    </bm:query-fields>
    <bm:data-filters>
        <bm:data-filter enforceOperations="query" expression="(t1.leader_user_id =${/session/@user_id} or t1.admin_flag =&apos;Y&apos;)"/>
    </bm:data-filters>
</bm:model>
