<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: DJ  
    $Date: 2013-10-18 下午5:19:56  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:s="leaf.plugin.script" xmlns:bm="http://www.leaf-framework.org/schema/bm" alias="t1" extend="tre.tre510.tre_funds_reservation" extendMode="reference">
    <bm:fields>
        <bm:field name="reservation_id"/>
        <bm:field name="project_id"/>
        <bm:field name="reserve_amount"/>
        <bm:field name="paid_date"/>
        <bm:field name="paid_probability"/>
        <bm:field name="status"/>
        <bm:field name="status_desc"/>
        <bm:field name="description"/>
        <bm:field name="paid_date_fin"/>
        <bm:field name="confirm_status"/>
        <bm:field name="confirm_status_desc"/>
        <bm:field name="description_fin"/>
        <bm:field name="project_number"/>
        <bm:field name="project_name"/>
        <bm:field name="project_status_desc"/>
        <bm:field name="bp_name"/>
        <bm:field name="employee_name"/>
        <bm:field name="apply_date"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
          	select t1.project_number,
			       t1.project_name,
			       t1.project_status_desc,
			       t1.bp_name,
			       t1.employee_name,
			       t1.project_id,
			       r.reservation_id,
			       r.reserve_amount,
			       r.paid_date,
			       r.paid_probability,
			       r.status,
			       (select c1.code_value_name
			          from sys_code_values_v c1
			         where c1.code = 'RESERVE_STATUS'
			           and c1.code_value = r.status) as status_desc,
			       r.description,
			       r.paid_date_fin,
			       r.confirm_status,
			       (select c2.code_value_name
			          from sys_code_values_v c2
			         where c2.code = 'RESERVATION_CONFIRM_STATUS'
			           and c2.code_value = r.confirm_status) as confirm_status_desc,
			       r.description_fin,
			       r.creation_date as apply_date
			  from prj_project_v t1, tre_funds_reservation r
	          #WHERE_CLAUSE#
	          order by r.confirm_status,r.creation_date
        ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="insert">
            <bm:update-sql><![CDATA[
          begin
            null;
          end;
        ]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
          begin
            null;
          end;
        ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:features>
        <s:bm-script><![CDATA[
            var cx = Packages.leaf.javascript.Context.getCurrentContext();
            Packages.leaf.plugin.script.engine.ScriptImportor.defineExternScript(cx, this, $ctx.getData(), "aut_authority_bm_validate.js");
        ]]></s:bm-script>
    </bm:features>
    <bm:data-filters>
        <bm:data-filter enforceOperations="query" expression="t1.project_id = r.project_id"/>
    </bm:data-filters>
</bm:model>
