<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Mouse Chow  
    $Date: 2012-9-10 下午05:27:56  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
select 'EXP_REPORT' document_category,h.exp_report_number document_number,'1' as img_type,'GENERAL' as img_name,'1' as current_img_type,'GENERAL' as current_img_name
  from exp_report_headers  h
  where h.exp_report_header_id = ${@header_id}
  and ${@table_name} = 'EXP_REPORT_HEADERS'
union all
select 'EXP_REQUISITION' document_category,erh.exp_requisition_number,'1' as img_type,'GENERAL' as img_name,'1' as current_img_type,'GENERAL' as current_img_name
  from exp_requisition_headers  erh
  where erh.exp_requisition_header_id = ${@header_id}
  and ${@table_name} = 'EXP_REQUISITION_HEADERS'
union all
select 'PAYMENT_REQUISITION' document_category,h.requisition_number,'1' as img_type,'GENERAL' as img_name,'1' as current_img_type,'GENERAL' as current_img_name
  from csh_payment_requisition_hds h
  where h.PAYMENT_REQUISITION_HEADER_ID = ${header_id}
  and ${@table_name} = 'CSH_PAYMENT_REQUISITION_HDS'
union all
select 'PUR_REQUISITION' document_category,h.pur_requisition_number,'1' as img_type,'GENERAL' as img_name,'1' as current_img_type,'GENERAL' as current_img_name
  from pur_requisition_headers  h
  where h.PUR_REQUISITION_HEADER_ID = ${@header_id}
  and ${@table_name} = 'PUR_REQUISITION_HEADERS'
union all
select 'PUR_ORDER' document_category,h.pur_order_number,'1' as img_type,'GENERAL' as img_name,'1' as current_img_type,'GENERAL' as current_img_name
  from pur_order_headers h     
  where h.PUR_ORDER_HEADER_ID = ${@header_id}
  and ${@table_name} = 'PUR_ORDER_HEADERS'
union  all
select 'CON_CONTRACT' document_category,h.contract_number,'1' as img_type,'GENERAL' as img_name,'1' as current_img_type,'GENERAL' as current_img_name
  from con_contract_headers  h
  where h.CONTRACT_HEADER_ID =  ${@header_id}
  and ${@table_name} = 'CON_CONTRACT_HEADERS'
union all
select 'WFL_APPROVE_RECORD' document_category,'wfl_approve_record.'||w.record_id,'0' as img_type,'PROCESS' as img_name,'0' as current_img_type,'PROCESS' as current_img_name
         from wfl_approve_record w
         where w.record_id = ${@header_id}
  and ${@table_name} = 'WFL_APPROVE_RECORD'
			]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
