<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang  
    $Date: 2013-4-15 下午01:13:07  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:s="leaf.plugin.script" xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="HLS_BP_MASTER_V" defaultOrderBy="bp_code" needAccessControl="false">
    <bm:fields>
        <bm:field name="bp_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BP_ID" prompt="HLS_BP_MASTER_V.BP_ID"/>
        <bm:field name="bp_code" databaseType="VARCHAR2" datatype="java.lang.String" displayWidth="210" forDisplay="true" forQuery="true" physicalName="BP_CODE" prompt="HLS.BP_CODE"/>
        <bm:field name="bp_name" databaseType="VARCHAR2" datatype="java.lang.String" displayWidth="210" forDisplay="true" forQuery="true" physicalName="BP_NAME" prompt="HLS.BP_NAME"/>
        <bm:field name="company_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="COMPANY_ID" prompt="HLS_BP_MASTER_V.COMPANY_ID"/>
        <bm:field name="company_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="COMPANY_CODE" prompt="HLS_BP_MASTER_V.COMPANY_CODE"/>
        <bm:field name="company_short_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="COMPANY_SHORT_NAME" prompt="HLS_BP_MASTER_V.COMPANY_SHORT_NAME"/>
        <bm:field name="company_full_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="COMPANY_FULL_NAME" prompt="HLS_BP_MASTER_V.COMPANY_FULL_NAME"/>
        <bm:field name="bp_category" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_CATEGORY"/>
        <bm:field name="bp_category_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_CATEGORY_NAME"/>
        <bm:field name="bp_class" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_CLASS"/>
        <bm:field name="bp_class_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_CLASS_NAME"/>
        <!-- <bm:field name="created_by" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CREATED_BY" prompt="HLS_BP_MASTER_V.CREATED_BY"/> -->
    </bm:fields>

    <bm:query-fields>
        <!-- <bm:query-field field="created_by" queryOperator="="/> -->
        <bm:query-field field="bp_code" queryOperator="like"/>
        <bm:query-field field="bp_name" queryOperator="like"/>
        <bm:query-field field="bp_category" queryOperator="="/>
        <bm:query-field field="company_id" queryOperator="="/>
        <!--<bm:query-field field="created_by" queryExpression="(t1.created_by=${/parameter/@user_id})" queryOperator="="/>-->
    </bm:query-fields>
    <bm:data-filters>
        <bm:data-filter name="company_id" enforceOperations="query" expression="(t1.company_id=${/session/@company_id})"/>
        <bm:data-filter name="enabled_flag" enforceOperations="query" expression="(t1.enabled_flag=&apos;Y&apos;)"/>
        <bm:data-filter enforceOperations="query" expression="( exists (select 1 from aut_trx_user_authorize a1,aut_owner_user_authorize a2 where a1.trx_category =&apos;BP&apos;
            and a1.trx_id = t1.bp_id
            and trunc(sysdate) between a1.start_date and nvl(a1.end_date,trunc(sysdate))
            and a1.user_id = a2.owner_user_id
            and a1.trx_category = a2.trx_category
            and a2.authorized_user_id =${/session/@user_id}
            and trunc(sysdate) between a2.start_date and nvl(a2.end_date,trunc(sysdate))) )"/>
    </bm:data-filters>
</bm:model>
