<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: qwm  
    $Date: 2013-8-13 下午2:19:28  
    $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="PRJ_PROJECT_V" defaultOrderBy="CREATION_DATE desc">
    <bm:fields>
        <bm:field name="project_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PROJECT_ID" prompt="PRJ_PROJECT_V.PROJECT_ID"/>
        <bm:field name="project_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PROJECT_NUMBER" prompt="PRJ_PROJECT_V.PROJECT_NUMBER"/>
        <bm:field name="project_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PROJECT_NAME" prompt="PRJ_PROJECT_V.PROJECT_NAME"/>
        <bm:field name="short_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SHORT_NAME" prompt="PRJ_PROJECT_V.SHORT_NAME"/>
        <bm:field name="bp_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BP_ID" prompt="PRJ_PROJECT_V.BP_ID"/>
        <bm:field name="bp_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_CODE" prompt="PRJ_PROJECT_V.BP_CODE"/>
        <bm:field name="bp_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_NAME" prompt="PRJ_PROJECT_V.BP_NAME"/>
        <bm:field name="bp_class" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_CLASS" prompt="PRJ_PROJECT_V.BP_CLASS"/>
        <bm:field name="document_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DOCUMENT_TYPE" prompt="PRJ_PROJECT_V.DOCUMENT_TYPE"/>
        <bm:field name="document_type_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DOCUMENT_TYPE_DESC" prompt="PRJ_PROJECT_V.DOCUMENT_TYPE_DESC"/>
        <bm:field name="document_category" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DOCUMENT_CATEGORY" prompt="PRJ_PROJECT_V.DOCUMENT_CATEGORY"/>
        <bm:field name="business_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BUSINESS_TYPE" prompt="PRJ_PROJECT_V.BUSINESS_TYPE"/>
        <bm:field name="project_status" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PROJECT_STATUS" prompt="PRJ_PROJECT_V.PROJECT_STATUS"/>
        <bm:field name="project_status_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PROJECT_STATUS_DESC" prompt="PRJ_PROJECT_V.PROJECT_STATUS_DESC"/>
        <bm:field name="company_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="COMPANY_ID" prompt="PRJ_PROJECT_V.COMPANY_ID"/>
        <bm:field name="lease_organization" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LEASE_ORGANIZATION" prompt="PRJ_PROJECT_V.LEASE_ORGANIZATION"/>
        <bm:field name="lease_organization_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LEASE_ORGANIZATION_DESC" prompt="PRJ_PROJECT_V.LEASE_ORGANIZATION_DESC"/>
        <bm:field name="lease_channel" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LEASE_CHANNEL" prompt="PRJ_PROJECT_V.LEASE_CHANNEL"/>
        <bm:field name="lease_channel_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LEASE_CHANNEL_DESC" prompt="PRJ_PROJECT_V.LEASE_CHANNEL_DESC"/>
        <bm:field name="division" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DIVISION" prompt="PRJ_PROJECT_V.DIVISION"/>
        <bm:field name="division_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DIVISION_DESC" prompt="PRJ_PROJECT_V.DIVISION_DESC"/>
        <bm:field name="search_term_1" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SEARCH_TERM_1" prompt="PRJ_PROJECT_V.SEARCH_TERM_1"/>
        <bm:field name="search_term_2" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SEARCH_TERM_2" prompt="PRJ_PROJECT_V.SEARCH_TERM_2"/>
        <bm:field name="chance_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CHANCE_ID" prompt="PRJ_PROJECT_V.CHANCE_ID"/>
        <bm:field name="chance_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CHANCE_NUMBER" prompt="PRJ_PROJECT_V.CHANCE_NUMBER"/>
        <bm:field name="owner_user_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="OWNER_USER_ID" prompt="PRJ_PROJECT_V.OWNER_USER_ID"/>
        <bm:field name="employee_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="EMPLOYEE_ID" prompt="PRJ_PROJECT_V.EMPLOYEE_ID"/>
        <bm:field name="employee_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EMPLOYEE_NAME" prompt="PRJ_PROJECT_V.EMPLOYEE_NAME"/>
        <bm:field name="unit_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="UNIT_ID" prompt="PRJ_PROJECT_V.UNIT_ID"/>
        <bm:field name="unit_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="UNIT_NAME" prompt="PRJ_PROJECT_V.UNIT_NAME"/>
        <bm:field name="employee_id_of_manager" databaseType="NUMBER" datatype="java.lang.Long" physicalName="EMPLOYEE_ID_OF_MANAGER" prompt="PRJ_PROJECT_V.EMPLOYEE_ID_OF_MANAGER"/>
        <bm:field name="employee_id_of_manager_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EMPLOYEE_ID_OF_MANAGER_DESC" prompt="PRJ_PROJECT_V.EMPLOYEE_ID_OF_MANAGER_DESC"/>
        <bm:field name="finance_amount" databaseType="NUMBER" datatype="java.lang.Long" physicalName="FINANCE_AMOUNT" prompt="PRJ_PROJECT_V.FINANCE_AMOUNT"/>
        <bm:field name="financing_purpose" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FINANCING_PURPOSE" prompt="PRJ_PROJECT_V.FINANCING_PURPOSE"/>
        <bm:field name="description" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DESCRIPTION" prompt="PRJ_PROJECT_V.DESCRIPTION"/>
        <bm:field name="cdd_list_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CDD_LIST_ID" prompt="PRJ_PROJECT_V.CDD_LIST_ID"/>
        <bm:field name="summary_bp" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SUMMARY_BP" prompt="PRJ_PROJECT_V.SUMMARY_BP"/>
        <bm:field name="description_summary_bp" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DESCRIPTION_SUMMARY_BP" prompt="PRJ_PROJECT_V.DESCRIPTION_SUMMARY_BP"/>
        <bm:field name="summary_guarantee" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SUMMARY_GUARANTEE" prompt="PRJ_PROJECT_V.SUMMARY_GUARANTEE"/>
        <bm:field name="description_summary_guarantee" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DESCRIPTION_SUMMARY_GUARANTEE" prompt="PRJ_PROJECT_V.DESCRIPTION_SUMMARY_GUARANTEE"/>
        <bm:field name="description_lease_item" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DESCRIPTION_LEASE_ITEM" prompt="PRJ_PROJECT_V.DESCRIPTION_LEASE_ITEM"/>
        <bm:field name="description_mortgage" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DESCRIPTION_MORTGAGE" prompt="PRJ_PROJECT_V.DESCRIPTION_MORTGAGE"/>
        <bm:field name="desc_quotation" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DESC_QUOTATION" prompt="PRJ_PROJECT_V.DESC_QUOTATION"/>
        <bm:field name="risk_analysis_tenant" databaseType="CLOB" datatype="java.sql.Clob" physicalName="RISK_ANALYSIS_TENANT" prompt="PRJ_PROJECT_V.RISK_ANALYSIS_TENANT"/>
        <bm:field name="risk_analysis_project" databaseType="CLOB" datatype="java.sql.Clob" physicalName="RISK_ANALYSIS_PROJECT" prompt="PRJ_PROJECT_V.RISK_ANALYSIS_PROJECT"/>
        <bm:field name="analysis_primary_product" databaseType="CLOB" datatype="java.sql.Clob" physicalName="ANALYSIS_PRIMARY_PRODUCT" prompt="PRJ_PROJECT_V.ANALYSIS_PRIMARY_PRODUCT"/>
        <bm:field name="forecast_sales" databaseType="CLOB" datatype="java.sql.Clob" physicalName="FORECAST_SALES" prompt="PRJ_PROJECT_V.FORECAST_SALES"/>
        <bm:field name="forecast_profitability" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FORECAST_PROFITABILITY" prompt="PRJ_PROJECT_V.FORECAST_PROFITABILITY"/>
        <bm:field name="description_feasibility" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DESCRIPTION_FEASIBILITY" prompt="PRJ_PROJECT_V.DESCRIPTION_FEASIBILITY"/>
        <bm:field name="superiority" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SUPERIORITY" prompt="PRJ_PROJECT_V.SUPERIORITY"/>
        <bm:field name="weakness" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="WEAKNESS" prompt="PRJ_PROJECT_V.WEAKNESS"/>
        <bm:field name="opportunity" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="OPPORTUNITY" prompt="PRJ_PROJECT_V.OPPORTUNITY"/>
        <bm:field name="threat" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="THREAT" prompt="PRJ_PROJECT_V.THREAT"/>
        <bm:field name="description_swot" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DESCRIPTION_SWOT" prompt="PRJ_PROJECT_V.DESCRIPTION_SWOT"/>
        <bm:field name="risk_market" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="RISK_MARKET" prompt="PRJ_PROJECT_V.RISK_MARKET"/>
        <bm:field name="risk_operating" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="RISK_OPERATING" prompt="PRJ_PROJECT_V.RISK_OPERATING"/>
        <bm:field name="risk_finance" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="RISK_FINANCE" prompt="PRJ_PROJECT_V.RISK_FINANCE"/>
        <bm:field name="description_risk" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DESCRIPTION_RISK" prompt="PRJ_PROJECT_V.DESCRIPTION_RISK"/>
        <bm:field name="summarize" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SUMMARIZE" prompt="PRJ_PROJECT_V.SUMMARIZE"/>
        <bm:field name="description_summarize" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DESCRIPTION_SUMMARIZE" prompt="PRJ_PROJECT_V.DESCRIPTION_SUMMARIZE"/>
        <bm:field name="number_of_tenant" databaseType="NUMBER" datatype="java.lang.Long" physicalName="NUMBER_OF_TENANT" prompt="PRJ_PROJECT_V.NUMBER_OF_TENANT"/>
        <bm:field name="number_of_guarantor" databaseType="NUMBER" datatype="java.lang.Long" physicalName="NUMBER_OF_GUARANTOR" prompt="PRJ_PROJECT_V.NUMBER_OF_GUARANTOR"/>
        <bm:field name="number_of_actual_controller" databaseType="NUMBER" datatype="java.lang.Long" physicalName="NUMBER_OF_ACTUAL_CONTROLLER" prompt="PRJ_PROJECT_V.NUMBER_OF_ACTUAL_CONTROLLER"/>
        <bm:field name="number_of_quotation" databaseType="NUMBER" datatype="java.lang.Long" physicalName="NUMBER_OF_QUOTATION" prompt="PRJ_PROJECT_V.NUMBER_OF_QUOTATION"/>
        <bm:field name="declare_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DECLARE_FLAG" prompt="PRJ_PROJECT_V.DECLARE_FLAG"/>
        <bm:field name="approved_date" databaseType="VARCHAR2" datatype="java.lang.String" expression="to_char(approved_date,&apos;yyyy-mm-dd&apos;)" physicalName="APPROVED_DATE" prompt="PRJ_PROJECT_V.APPROVED_DATE"/>
        <bm:field name="ref_v01" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V01" prompt="PRJ_PROJECT_V.REF_V01"/>
        <bm:field name="ref_v02" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V02" prompt="PRJ_PROJECT_V.REF_V02"/>
        <bm:field name="ref_v03" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V03" prompt="PRJ_PROJECT_V.REF_V03"/>
        <bm:field name="ref_v04" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V04" prompt="PRJ_PROJECT_V.REF_V04"/>
        <bm:field name="ref_v05" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V05" prompt="PRJ_PROJECT_V.REF_V05"/>
        <bm:field name="ref_v06" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V06" prompt="PRJ_PROJECT_V.REF_V06"/>
        <bm:field name="ref_v07" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V07" prompt="PRJ_PROJECT_V.REF_V07"/>
        <bm:field name="ref_v08" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V08" prompt="PRJ_PROJECT_V.REF_V08"/>
        <bm:field name="ref_v09" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V09" prompt="PRJ_PROJECT_V.REF_V09"/>
        <bm:field name="ref_v10" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V10" prompt="PRJ_PROJECT_V.REF_V10"/>
        <bm:field name="ref_n01" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N01" prompt="PRJ_PROJECT_V.REF_N01"/>
        <bm:field name="ref_n02" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N02" prompt="PRJ_PROJECT_V.REF_N02"/>
        <bm:field name="ref_n03" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N03" prompt="PRJ_PROJECT_V.REF_N03"/>
        <bm:field name="ref_n04" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N04" prompt="PRJ_PROJECT_V.REF_N04"/>
        <bm:field name="ref_n05" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N05" prompt="PRJ_PROJECT_V.REF_N05"/>
        <bm:field name="ref_n06" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N06" prompt="PRJ_PROJECT_V.REF_N06"/>
        <bm:field name="ref_n07" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N07" prompt="PRJ_PROJECT_V.REF_N07"/>
        <bm:field name="ref_n08" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N08" prompt="PRJ_PROJECT_V.REF_N08"/>
        <bm:field name="ref_n09" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N09" prompt="PRJ_PROJECT_V.REF_N09"/>
        <bm:field name="ref_n10" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N10" prompt="PRJ_PROJECT_V.REF_N10"/>
        <bm:field name="ref_d01" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D01" prompt="PRJ_PROJECT_V.REF_D01"/>
        <bm:field name="ref_d02" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D02" prompt="PRJ_PROJECT_V.REF_D02"/>
        <bm:field name="ref_d03" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D03" prompt="PRJ_PROJECT_V.REF_D03"/>
        <bm:field name="ref_d04" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D04" prompt="PRJ_PROJECT_V.REF_D04"/>
        <bm:field name="ref_d05" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D05" prompt="PRJ_PROJECT_V.REF_D05"/>
        <bm:field name="ref_d06" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D06" prompt="PRJ_PROJECT_V.REF_D06"/>
        <bm:field name="ref_d07" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D07" prompt="PRJ_PROJECT_V.REF_D07"/>
        <bm:field name="ref_d08" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D08" prompt="PRJ_PROJECT_V.REF_D08"/>
        <bm:field name="ref_d09" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D09" prompt="PRJ_PROJECT_V.REF_D09"/>
        <bm:field name="ref_d10" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D10" prompt="PRJ_PROJECT_V.REF_D10"/>
    </bm:fields>
    <bm:features>
        <f:standard-who forQuery="true"/>
        <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:query-fields>
        <bm:query-field field="project_number" queryOperator="like"/>
        <bm:query-field field="employee_id" queryOperator="="/>
        <bm:query-field field="lease_organization" queryOperator="="/>
        <bm:query-field field="lease_channel" queryOperator="="/>
        <bm:query-field field="bp_name" queryOperator="like"/>
        <bm:query-field field="project_name" queryOperator="like"/>
        <bm:query-field field="division" queryOperator="="/>
        <bm:query-field field="employee_id_of_manager" queryOperator="="/>
        <bm:query-field field="document_type" queryOperator="="/>
        <bm:query-field field="project_status" queryOperator="="/>
        <bm:query-field name="not_project_status" queryExpression="t1.project_status!=${@not_project_status}"/>
        <bm:query-field field="bp_id" queryOperator="="/>
        <bm:query-field field="chance_number" queryOperator="like"/>
        <bm:query-field field="search_term_1" queryOperator="like"/>
        <bm:query-field field="search_term_2" queryOperator="like"/>
        <bm:query-field field="project_id" queryOperator="="/>
        <bm:query-field name="prj_update_status_flag" queryExpression="(${@prj_update_status_flag}=&apos;Y&apos; and t1.project_status in (&apos;NEW&apos;,&apos;CONDITIONAL&apos;,&apos;APPROVED_RETURN&apos;,&apos;APPROVED&apos;))"/>
    </bm:query-fields>
    <bm:operations>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
                BEGIN
                    prj_project_pkg.update_prj_bp_count_parameter(p_project_id                  =>${@project_id},
					                                              p_number_of_tenant            =>${@number_of_tenant},
					                                              p_number_of_guarantor         =>${@number_of_guarantor},
					                                              p_number_of_actual_controller =>${@number_of_actual_controller},
					                                              p_user_id                     =>${/session/@user_id});
                END;
            ]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="execute">
            <bm:update-sql><![CDATA[
                BEGIN
                    prj_project_pkg.update_prj_project_status(p_project_id =>${@project_id}, p_user_id =>${/session/@user_id});
                END;
            ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
