<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang  
    $Date: 2013-3-13 上午09:22:56  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:o="leaf.database.local.oracle" xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="LCH_LEASE_CHANCE_KYC">
    <bm:fields>
        <bm:field name="kyc_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="KYC_ID"/>
        <bm:field name="lease_chance_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="LEASE_CHANCE_ID"/>
        <bm:field name="employee_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="EMPLOYEE_ID"/>
        <bm:field name="employee_name" forInsert="false" forUpdate="false" prompt="LCH502.LCH_LEASE_CHANCE_KYC.EMPLOYEE_NAME"/>
        <bm:field name="contact_time" databaseType="DATE" datatype="java.util.Date" physicalName="CONTACT_TIME" prompt="LCH502.LCH_LEASE_CHANCE_KYC.CONTACT_TIME"/>
        <bm:field name="contact_person" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTACT_PERSON" prompt="LCH502.LCH_LEASE_CHANCE_KYC.CONTACT_PERSON"/>
        <bm:field name="kyc_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="KYC_TYPE"/>
        <bm:field name="kyc_type_desc" forInsert="false" forUpdate="false" prompt="LCH502.LCH_LEASE_CHANCE_KYC.KYC_TYPE"/>
        <bm:field name="short_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SHORT_DESC" prompt="LCH502.LCH_LEASE_CHANCE_KYC.SHORT_DESC"/>
        <bm:field name="full_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FULL_DESC" prompt="LCH502.LCH_LEASE_CHANCE_KYC.FULL_DESC"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
    			SELECT t1.kyc_id,
			       t1.lease_chance_id,
			       t1.employee_id,
			       (select emp.name
			          FROM exp_employees emp
			         WHERE emp.employee_id = t1.employee_id) as employee_name,
			       t1.contact_time,
			       t1.contact_person,
			       t1.kyc_type,
			       (SELECT v.code_value_name
			          FROM sys_code_values_v v
			         WHERE v.code = 'LCH502_TRACKING_AFFAIRS'
			           AND v.code_value = t1.kyc_type) as kyc_type_desc,
			       t1.short_desc,
			       t1.full_desc
			  from lch_lease_chance_kyc t1
    		 #WHERE_CLAUSE#
    		]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="insert">
            <bm:parameters>
                <bm:parameter name="kyc_id" input="false" output="true" outputPath="@kyc_id"/>
            </bm:parameters>
            <bm:update-sql><![CDATA[
        		begin
				   lch501_save_pkg.kyc_manage(p_sql_type		=> 'INSERT',
				   							  p_kyc_id          => ${@kyc_id},
								              p_lease_chance_id => ${@lease_chance_id},
								              p_employee_id     => ${@employee_id},
								              p_contact_time    => TO_DATE(${@contact_time},'YYYY-MM-DD'),
								              p_contact_person  => ${@contact_person},
								              p_kyc_type        => ${@kyc_type},
								              p_short_desc      => ${@short_desc},
								              p_full_desc       => ${@full_desc},
								              p_user_id         => ${/session/@user_id});
				end;
        	]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
        		begin
				   lch501_save_pkg.kyc_manage(p_sql_type		=> 'UPDATE',
				   							  p_kyc_id          => ${@kyc_id},
								              p_lease_chance_id => ${@lease_chance_id},
								              p_employee_id     => ${@employee_id},
								              p_contact_time    => TO_DATE(${@contact_time},'YYYY-MM-DD'),
								              p_contact_person  => ${@contact_person},
								              p_kyc_type        => ${@kyc_type},
								              p_short_desc      => ${@short_desc},
								              p_full_desc       => ${@full_desc},
								              p_user_id         => ${/session/@user_id});
				end;
        	]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="delete">
            <bm:update-sql><![CDATA[
        		begin
				   lch501_save_pkg.kyc_manage(p_sql_type		=> 'DELETE',
				   							  p_kyc_id          => ${@kyc_id},
								              p_lease_chance_id => ${@lease_chance_id},
								              p_employee_id     => ${@employee_id},
								              p_contact_time    => TO_DATE(${@contact_time},'YYYY-MM-DD'),
								              p_contact_person  => ${@contact_person},
								              p_kyc_type        => ${@kyc_type},
								              p_short_desc      => ${@short_desc},
								              p_full_desc       => ${@full_desc},
								              p_user_id         => ${/session/@user_id});
				end;
        	]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:features>
        <f:standard-who/>
        <o:sequence-pk/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="kyc_id"/>
    </bm:primary-key>
    <bm:data-filters>
        <bm:data-filter enforceOperations="query" expression="t1.lease_chance_id=${@lease_chance_id}"/>
    </bm:data-filters>
</bm:model>
