<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2013-11-28 上午10:07:37  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:s="leaf.plugin.script" xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
    	    select   t1.legal_info_req_id,
                     t1.bp_id,
                     t1.bp_class,
                     v.bp_type,
                     v.bp_class_desc,
                     v.extra_nam,
                     t1.employee_id,
                     (select e.name
                        from exp_employees e
                       where e.employee_id = t1.employee_id) employee_name,
                     t1.owner_user_id,
                     t1.document_category,
                     t1.document_type,
                     t1.wfl_instance_id,
                     t1.company_id,
                     t1.req_status,
                     (select scv.code_value_name
                        from sys_code_values_v scv
                       where scv.code = 'HLS_CREDIT_INFO_REQ_STATUS'
                         and scv.code_value = t1.req_status) req_status_desc,
                     t1.req_date,
                     t1.submit_date,
                     t1.pste_query_date,
                     t1.fl_reg_query_date,
                     t1.ac_pledge_query_date,
                     t1.confirm_date,
                     t1.pste_note,
                     t1.fl_reg_note,
                     t1.ac_pledge_note,
                     v.bp_code,
                     v.bp_name,
                     v.loan_card_num,
                     v.ref_v01,
                     v.enabled_flag,
                     v.id_card_no,
                     v.organization_code
                from hls_bp_legal_info_req t1, hls_bp_master_all_data_v v
							 #WHERE_CLAUSE#
							 order by t1.req_date desc
 ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="legal_info_req_id"/>
        <bm:field name="bp_id"/>
        <bm:field name="extra_nam"/>
        <bm:field name="bp_class"/>
        <bm:field name="bp_class_desc"/>
        <bm:field name="bp_type"/>
        <bm:field name="employee_id"/>
        <bm:field name="employee_name"/>
        <bm:field name="owner_user_id"/>
        <bm:field name="document_category"/>
        <bm:field name="document_type"/>
        <bm:field name="wfl_instance_id"/>
        <bm:field name="company_id"/>
        <bm:field name="req_status"/>
        <bm:field name="req_status_desc"/>
        <bm:field name="req_date" databaseType="DATE" datatype="java.util.Date"/>
        <bm:field name="submit_date" databaseType="DATE" datatype="java.util.Date"/>
        <bm:field name="pste_query_date" databaseType="DATE" datatype="java.util.Date"/>
        <bm:field name="fl_reg_query_date" databaseType="DATE" datatype="java.util.Date"/>
        <bm:field name="ac_pledge_query_date" databaseType="DATE" datatype="java.util.Date"/>
        <bm:field name="confirm_date" databaseType="DATE" datatype="java.util.Date"/>
        <bm:field name="pste_note"/>
        <bm:field name="fl_reg_note"/>
        <bm:field name="ac_pledge_note"/>
        <bm:field name="bp_code"/>
        <bm:field name="bp_name"/>
        <bm:field name="loan_card_num"/>
        <bm:field name="ref_v01"/>
        <bm:field name="enabled_flag"/>
        <bm:field name="id_card_no"/>
        <bm:field name="organization_code"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field name="bp_class" queryExpression="v.bp_class=${@bp_class}"/>
        <bm:query-field field="bp_type" queryOperator="="/>
        <bm:query-field name="bp_code_from" queryExpression="v.bp_code &gt;= ${@bp_code_from} "/>
        <bm:query-field name="bp_code_to" queryExpression="v.bp_code &lt;= ${@bp_code_to} "/>
        <bm:query-field field="bp_name" queryOperator="like"/>
        <bm:query-field name="bp_project_id" queryExpression="t1.bp_id in (select ppb.bp_id from prj_project pp ,prj_project_bp ppb where pp.project_id=ppb.project_id and pp.project_id=${@bp_project_id})"/>
        <bm:query-field name="bp_project_name" queryExpression="t1.bp_id in (select ppb.bp_id from prj_project pp ,prj_project_bp ppb where pp.project_id=ppb.project_id and pp.project_name like ${@bp_project_name})"/>
        <bm:query-field name="bp_contract_id" queryExpression="t1.bp_id in (select ccb.bp_id from con_contract cc ,con_contract_bp ccb where cc.contract_id=ccb.contract_id and cc.contract_id =${@bp_contract_id})"/>
        <bm:query-field name="bp_contract_name" queryExpression="t1.bp_id in (select ccb.bp_id from con_contract cc ,con_contract_bp ccb where cc.contract_id=ccb.contract_id and cc.contract_name like ${@bp_contract_name})"/>
        <bm:query-field field="req_status" queryOperator="="/>
        <bm:query-field field="extra_nam" queryOperator="like"/>
        <bm:query-field field="enabled_flag" queryExpression="(v.enabled_flag=${@enabled_flag} or ${@enabled_flag}=&apos;ALL&apos;)"/>
    </bm:query-fields>
    <bm:data-filters>
        <bm:data-filter enforceOperations="query" expression="v.bp_id = t1.bp_id"/>
    </bm:data-filters>
    <bm:features>
        <s:bm-script><![CDATA[
            var cx = Packages.leaf.javascript.Context.getCurrentContext();
            Packages.leaf.plugin.script.engine.ScriptImportor.defineExternScript(cx, this, $ctx.getData(), "aut_authority_bm_validate.js");
        ]]></s:bm-script>
    </bm:features>
</bm:model>
