<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: DJ  
    $Date: 2013-11-13 下午2:20:52  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="SYS_SMS_HISTORY">
    <bm:fields>
        <bm:field name="sms_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SMS_ID" prompt="SYS_SMS_HISTORY.SMS_ID"/>
        <bm:field name="sms_date" databaseType="DATE" datatype="java.util.Date" physicalName="SMS_DATE" prompt="SYS_SMS_HISTORY.SMS_DATE"/>
        <bm:field name="sms_date_str" forInsert="false" forUpdate="false"/>
        <bm:field name="sent_date" databaseType="DATE" datatype="java.util.Date" physicalName="SENT_DATE" prompt="SYS_SMS_HISTORY.SENT_DATE"/>
        <bm:field name="sent_date_str" forInsert="false" forUpdate="false"/>
        <bm:field name="priority" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PRIORITY" prompt="SYS_SMS_HISTORY.PRIORITY"/>
        <bm:field name="priority_desc" forInsert="false" forUpdate="false"/>
        <bm:field name="phone_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PHONE_NUMBER" prompt="SYS_SMS_HISTORY.PHONE_NUMBER"/>
        <bm:field name="text" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TEXT" prompt="SYS_SMS_HISTORY.TEXT"/>
        <bm:field name="msg_id" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="MSG_ID" prompt="SYS_SMS_HISTORY.MSG_ID"/>
        <bm:field name="contract_number" databaseType="VARCHAR2" datatype="java.lang.String"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
    			select t1.sms_id,
				       t1.sms_date,
				       to_char(t1.sms_date,'yyyy-mm-dd hh24:mi:ss') as sms_date_str,
				       t1.sent_date,
				       to_char(t1.sent_date,'yyyy-mm-dd hh24:mi:ss') as sent_date_str,
				       t1.priority,
				       (select v.code_value_name
				          from sys_code_values_v v
				         where v.code = 'SYS402_SMS_PRIORITY'
				           and v.code_value = t1.priority) as priority_desc,
				       t1.phone_number,
				       t1.text,
				       t1.msg_id,
				       t1.contract_number
				  from sys_sms_history t1
				  #WHERE_CLAUSE#
				 order by t1.sent_date desc
    		]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:features>
        <f:standard-who/>
    </bm:features>
    <bm:query-fields>
        <bm:query-field name="phone_number" queryExpression="phone_number like ${@phone_number}"/>
        <bm:query-field name="contract_number" queryExpression="contract_number like ${@contract_number}"/>
        <bm:query-field name="sms_date_f" queryExpression="trunc(sms_date) &gt;= to_date(${@sms_date_f},&apos;yyyy-mm-dd&apos;)"/>
        <bm:query-field name="sms_date_t" queryExpression="trunc(sms_date) &lt;= to_date(${@sms_date_t},&apos;yyyy-mm-dd&apos;)"/>
        <bm:query-field name="sent_date_f" queryExpression="trunc(sent_date) &gt;= to_date(${@sent_date_f},&apos;yyyy-mm-dd&apos;)"/>
        <bm:query-field name="sent_date_t" queryExpression="trunc(sent_date) &lt;= to_date(${@sent_date_t},&apos;yyyy-mm-dd&apos;)"/>
    </bm:query-fields>
</bm:model>
