<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2014-6-10 下午01:49:04  
    $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 pci.cdd_item,
		       pci.description,
		       pci.order_seq,
		       pci.show_seq,
		       pp.send_flag,
		       pp.paper_required,
		       pp.attachment_required,
		       pp.not_applicable,
		       pp.check_id,
		       pci.sys_flag,
		       pci.note,
		       pci.cdd_list_id,
		       pci.cdd_item_id,
		       pci.line_type,
		       pci.chance_required_flag,
		       pci.chance_display_flag,
		       pci.project_required_flag,
		       pci.project_display_flag,
		       pci.contract_required_flag,
		       pci.contract_display_flag,
		       pci.sign_required_flag,
		       pci.sign_display_flag,
		       pci.incept_required_flag,
		       pci.incept_display_flag,
		       pci.lender_required_flag,
		       pci.lender_display_flag,
		       pci.chance_tab_group,
		       pci.project_tab_group,
		       pci.contract_tab_group,
		       pci.sign_tab_group,
		       pci.incept_tab_group,
		       pci.lender_tab_group,
		       NVL(pp.document_id, ${@project_id}) document_id,
		       NVL(pp.document_table, 'PRJ_PROJECT') document_table
		  FROM (SELECT pcf.check_id,
		               pcf.document_id,
		               pcf.document_table,
		               pck.cdd_item_id,
		               pck.send_flag,
		               pck.paper_required,
		               pck.attachment_required,
		               pck.not_applicable
		          FROM prj_cdd_item_doc_ref pcf, prj_cdd_item_check pck
		         WHERE pcf.document_table = 'PRJ_PROJECT'
		           AND pcf.document_id = ${@project_id}
		           AND pck.check_id = pcf.check_id) pp,
		       prj_cdd_item pci 
		 WHERE pci.project_tab_group =99
		   AND pci.project_required_flag = 'Y'
		   AND pci.project_display_flag = 'Y'
		   AND pci.cdd_item_id = pp.cdd_item_id(+)
		   AND pci.cdd_list_id =
		       (select p.cdd_list_id from prj_project p where p.project_id = ${@project_id})
		   AND pci.enabled_flag = 'Y'
		 ORDER BY pci.order_seq
]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="insert">
            <bm:update-sql><![CDATA[
            	BEGIN
            	    prj_cdd_item_pkg.prj_cdd_item_doc_ref_save(p_document_table =>${@document_table},
                                      p_document_id           =>${@document_id},
                                      p_cdd_list_id           =>${@cdd_list_id},
                                      p_cdd_item              =>${@cdd_item},
                                      p_description           =>${@description},
                                      p_line_type             =>'FILE',
                                      p_order_seq             =>${@order_seq},
                                      p_show_seq              =>${@show_seq},
                                      p_enabled_flag          =>'Y',
                                      p_chance_required_flag=>${@chance_required_flag},
						              p_chance_display_flag=>${@chance_display_flag},
						              p_project_required_flag=>${@project_required_flag},
						              p_project_display_flag=>${@project_display_flag},
						              p_contract_required_flag=>${@contract_required_flag},
						              p_contract_display_flag=>${@contract_display_flag},
						              p_sign_required_flag=>${@sign_required_flag},
						              p_sign_display_flag=>${@sign_display_flag},
						              p_incept_required_flag=>${@incept_required_flag},
						              p_incept_display_flag=>${@incept_display_flag},
						              p_lender_required_flag=>${@lender_required_flag},
						              p_lender_display_flag=>${@lender_display_flag},
						              p_chance_tab_group=>${@chance_tab_group},
						              p_project_tab_group=>${@project_tab_group},
						              p_contract_tab_group=>${@contract_tab_group},
						              p_sign_tab_group=>${@sign_tab_group},
						              p_incept_tab_group=>${@incept_tab_group},
						              p_lender_tab_group=>${@lender_tab_group},
                                      p_sys_flag              =>${@sys_flag},
                                      p_note                  =>${@note},
                                      p_send_flag             =>${@send_flag},
                                      p_paper_required        =>${@paper_required},
                                      p_attachment_required   =>${@attachment_required},
                                      p_not_applicable        =>${@not_applicable},
                                      p_cdd_item_id           =>${@cdd_item_id},
                                      p_check_id              =>${@check_id},
                                      p_user_id  =>${/session/@user_id});
            	END;
        	]]></bm:update-sql>
            <bm:parameters>
                <bm:parameter name="cdd_item_id" input="true" inputPath="@cdd_item_id" output="true" outputPath="@cdd_item_id"/>
                <bm:parameter name="check_id" input="true" inputPath="@check_id" output="true" outputPath="@check_id"/>
            </bm:parameters>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
            	BEGIN
            	    prj_cdd_item_pkg.prj_cdd_item_doc_ref_save(p_document_table =>${@document_table},
                                      p_document_id           =>${@document_id},
                                      p_cdd_list_id           =>${@cdd_list_id},
                                      p_cdd_item              =>${@cdd_item},
                                      p_description           =>${@description},
                                      p_line_type             =>'FILE',
                                      p_order_seq             =>${@order_seq},
                                      p_show_seq              =>${@show_seq},
                                      p_enabled_flag          =>'Y',
                                      p_chance_required_flag=>${@chance_required_flag},
							          p_chance_display_flag=>${@chance_display_flag},
							          p_project_required_flag=>${@project_required_flag},
							          p_project_display_flag=>${@project_display_flag},
							          p_contract_required_flag=>${@contract_required_flag},
							          p_contract_display_flag=>${@contract_display_flag},
							          p_sign_required_flag=>${@sign_required_flag},
							          p_sign_display_flag=>${@sign_display_flag},
							          p_incept_required_flag=>${@incept_required_flag},
							          p_incept_display_flag=>${@incept_display_flag},
							          p_lender_required_flag=>${@lender_required_flag},
							          p_lender_display_flag=>${@lender_display_flag},
							          p_chance_tab_group=>${@chance_tab_group},
							          p_project_tab_group=>${@project_tab_group},
							          p_contract_tab_group=>${@contract_tab_group},
							          p_sign_tab_group=>${@sign_tab_group},
							          p_incept_tab_group=>${@incept_tab_group},
							          p_lender_tab_group=>${@lender_tab_group},
                                      p_sys_flag              =>${@sys_flag},
                                      p_note                  =>${@note},
                                      p_send_flag             =>${@send_flag},
                                      p_paper_required        =>${@paper_required},
                                      p_attachment_required   =>${@attachment_required},
                                      p_not_applicable        =>${@not_applicable},
                                      p_cdd_item_id           =>${@cdd_item_id},
                                      p_check_id              =>${@check_id},
                                      p_user_id  =>${/session/@user_id});
            	END;
        	]]></bm:update-sql>
            <bm:parameters>
                <bm:parameter name="cdd_item_id" input="true" inputPath="@cdd_item_id" output="true" outputPath="@cdd_item_id"/>
                <bm:parameter name="check_id" input="true" inputPath="@check_id" output="true" outputPath="@check_id"/>
            </bm:parameters>
        </bm:operation>
        <bm:operation name="delete">
            <bm:update-sql><![CDATA[
            	BEGIN
            	    prj_cdd_item_pkg.prj_cdd_item_doc_ref_delete(p_document_table =>
            	    					${@document_table},
                                        p_document_id    =>${@document_id},
                                        p_cdd_item_id    =>${@cdd_item_id},
                                        p_check_id       =>${@check_id},
                                        p_user_id        =>${/session/@user_id});
            	END;
        	]]></bm:update-sql>
            <bm:parameters>
                <bm:parameter name="cdd_item_id" input="true" inputPath="@cdd_item_id" output="true" outputPath="@cdd_item_id"/>
                <bm:parameter name="check_id" input="true" inputPath="@check_id" output="true" outputPath="@check_id"/>
            </bm:parameters>
        </bm:operation>
    </bm:operations>
</bm:model>
