<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Administrator  
    $Date: 2016-5-18 下午4:44:02  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="insert">
            <bm:update-sql><![CDATA[
            begin
            ${@prj_side_id}:=hn_prj_project_pkg.create_project_side
                 (    p_project_id =>${@project_id} , 
                      p_user_id =>${/session/@user_id} 
                 );
            end;
            ]]></bm:update-sql>
            <bm:parameters>
                <bm:parameter name="prj_side_id" output="true" outputPath="@prj_side_id"/>
            </bm:parameters>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
          begin
             update hn_prj_project_side ps 
               set ps.side_note=${@side_note},
               ps.side_item=${@side_item}
               where ps.prj_side_id=${@prj_side_id}
               and ps.project_id=${@project_id};
              
            end;
          ]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="delete">
            <bm:query-sql><![CDATA[
           begin
             hn_prj_project_pkg.delete_project_side(
             p_prj_side_id =>${@prj_side_id} , 
             p_user_id =>${/session/@user_id} );
end;
           ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="execute">
            <bm:update-sql><![CDATA[
         begin
             update hn_prj_project_side ps 
               set ps.side_note=${@side_note},
               ps.side_item=${@side_item}
               where ps.prj_side_id=${@prj_side_id}
               and ps.project_id=${@project_id};
               hn_prj_project_pkg.SUBMIT_PROJECT_SIDE(
                   P_PRJ_SIDE_ID => ${@prj_side_id},
                   P_USER_ID =>${/session/@user_id} 
               );
            end;
        ]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
           select p.project_id,
p.project_number,
p.project_name,
P.chance_source_n,
P.employee_id_N,
p.lease_organization,
p.company_id,
P.lease_organization_n,
P.business_type_n,
P.LEASE_FORM_N,
P.division_N,
P.pre_rental_business_n,
p.hn_industry_classification,
(select to_number(hfch.lease_item_amount)
          from hls_fin_calculator_hd hfch, prj_quotation q
         where p.project_id=q.document_id
           and q.calc_session_id=hfch.calc_session_id
           and q.document_category='PROJECT'
           and q.quotation_type='MAJOR') lease_item_amount,
(select hfch.lease_term||'年'
          from hls_fin_calculator_hd hfch, prj_quotation q
         where p.project_id=q.document_id
           and q.calc_session_id=hfch.calc_session_id
           and q.document_category='PROJECT'
           and q.quotation_type='MAJOR') lease_term, 
(select to_number(hfch.int_rate)
          from hls_fin_calculator_hd hfch, prj_quotation q
         where p.project_id=q.document_id
           and q.calc_session_id=hfch.calc_session_id
           and q.document_category='PROJECT'
           and q.quotation_type='MAJOR') int_rate, 
p.int_rate_fixing_way_n,
to_number(p.int_rate_fixing_range)  int_rate_fixing_range,
(select ps.side_note from HN_PRJ_PROJECT_SIDE ps where ps.project_id=p.project_id 
and ps.PRJ_SIDE_ID=${@prj_side_id}) side_note,
(select ps.side_item from HN_PRJ_PROJECT_SIDE ps where ps.project_id=p.project_id 
and ps.PRJ_SIDE_ID=${@prj_side_id}) side_item
 from prj_project_lv p
 where p.project_id=${@project_id}
            
           ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
