<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: DJ  
    $Date: 2013-1-8 下午2:15:42  
    $Revision: 1.0  
    $Purpose: 
-->
<ns1:model xmlns:ns1="http://www.leaf-framework.org/schema/bm">
    <ns1:fields>
        <ns1:field name="lease_chance_id"/>
        <ns1:field name="lease_chance_code" forDisplay="true" forQuery="true" prompt="机会编号"/>
        <ns1:field name="lease_organizations_id"/>
        <ns1:field name="lease_organizations" forDisplay="true" prompt="组织"/>
        <ns1:field name="lease_channel_id"/>
        <ns1:field name="lease_channel" forDisplay="true" prompt="渠道"/>
        <ns1:field name="division_id"/>
        <ns1:field name="division" forDisplay="true" prompt="产品线"/>
        <ns1:field name="lease_product_id"/>
        <ns1:field name="lease_item" forDisplay="true" forQuery="true" prompt="租赁物"/>
        <ns1:field name="potential_customer" forDisplay="true" forQuery="true" prompt="潜在客户"/>
    </ns1:fields>
    <ns1:operations>
        <ns1:operation name="query">
            <ns1:query-sql><![CDATA[
    		select * from
    		(
    			select t1.lease_chance_id,
				       t1.lease_chance_code,
				       t1.lease_organizations_id,
				       (select lov.description
				          from hls_lease_organizations_vl lov
				         where lov.lease_organizations_id = t1.lease_organizations_id) as lease_organizations,
				       t1.lease_channel_id,
				       (select lcv.description
				          from hls_lease_channels_vl lcv
				         where lcv.lease_channel_id = t1.lease_channel_id) as lease_channel,
				       t1.division_id,
				       (select vl.description
				          from hls_divisions_vl vl
				         where vl.division_id = t1.division_id) as division,
				       t1.potential_customer,
				       t1.lease_product_id,
				       ((select t1.lease_item from dual where t1.lease_product_id is null)
				        union all (select lp.description
				                     from hls_lease_products_vl lp
				                    where lp.lease_products_id = t1.lease_product_id
				                      and t1.lease_product_id is not null)) as lease_item
				  from lch_lease_chance_hds t1
    		)
    		#WHERE_CLAUSE#
    		order by lease_chance_code desc
    		]]></ns1:query-sql>
        </ns1:operation>
    </ns1:operations>
    <ns1:query-fields>
        <ns1:query-field field="lease_organizations_id" queryOperator="="/>
        <ns1:query-field field="lease_channel_id" queryOperator="="/>
        <ns1:query-field field="division_id" queryOperator="="/>
        <ns1:query-field field="potential_customer" queryOperator="like"/>
        <ns1:query-field field="lease_item" queryOperator="like"/>
        <ns1:query-field field="lease_chance_code" queryOperator="like"/>
    </ns1:query-fields>
</ns1:model>
