<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2013-11-6 下午02:26:55  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
            SELECT
    t1.*
FROM
    (SELECT
        a.file_name,
        a.file_path,
        a.file_type_code,
        r.document_id,
        i.description,
        upper(r.document_table)document_table
    FROM
        prj_cdd_item_check c,
        prj_cdd_item_doc_ref r,
        fnd_atm_attachment_multi m,
        fnd_atm_attachment a,
        prj_cdd_item i
    WHERE
        a.attachment_id   =m.attachment_id AND
        m.table_pk_value  =TO_CHAR(c.check_id) AND
        r.check_id        =c.check_id AND
        a.file_type_code IN ('jpg','jpeg','bmp','gif')
        and i.cdd_item_id = c.cdd_item_id
        and i.project_tab_group = (select a.attachment_tab_group
  from hls_doc_layout_tab a
 where a.layout_code = 'PROJECT_MODIFY'
   AND A.TAB_CODE = 'C_TENANT_SUMMARY')
    )t1
WHERE
    t1.document_id =${@project_id} 
    and t1.document_table = 'PRJ_PROJECT'
              
              ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="file_name"/>
        <bm:field name="file_path"/>
        <bm:field name="file_type_code"/>
        <bm:field name="document_id"/>
        <bm:field name="document_table"/>
        <bm:field name="description"/>
    </bm:fields>
</bm:model>
