<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="CON_COLLECTION_CALL_LN">
    <bm:fields>
        <bm:field name="call_ln_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CALL_LN_ID" prompt="CON_COLLECTION_CALL_LN.CALL_LN_ID"/>
        <bm:field name="call_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CALL_ID" prompt="CON_COLLECTION_CALL_LN.CALL_ID"/>
        <bm:field name="bp_type_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_TYPE_DESC" prompt="CON_COLLECTION_CALL_LN.BP_TYPE_DESC"/>
        <bm:field name="collection_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="COLLECTION_NAME" prompt="CON_COLLECTION_CALL_LN.COLLECTION_NAME"/>
        <bm:field name="cell_phone" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CELL_PHONE" prompt="CON_COLLECTION_CALL_LN.CELL_PHONE"/>
        <bm:field name="call_time" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CALL_TIME" prompt="CON_COLLECTION_CALL_LN.CALL_TIME"/>
        <bm:field name="staff_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="STAFF_ID" prompt="CON_COLLECTION_CALL_LN.STAFF_ID"/>
        <bm:field name="staff_name" forInsert="true" forUpdate="true"/>
        <bm:field name="note" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="NOTE" prompt="CON_COLLECTION_CALL_LN.NOTE"/>
    </bm:fields>
    <bm:features>
        <f:standard-who/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="call_ln_id"/>
    </bm:primary-key>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT
                    t1.call_ln_id,
                    t1.call_id,
                    t1.bp_type_desc,
                    t1.collection_name,
                    t1.cell_phone,
                    TO_CHAR(t1.call_time,'yyyy-mm-dd hh24:mi:ss') call_time,
                    t1.staff_id,
                    (SELECT
                        e.staff_name
                    FROM
                        CON_COLLECTION_PERSONS e
                    WHERE
                        e.staff_id = t1.staff_id
                    ) staff_name,
                    t1.note
                FROM
                    con_collection_call_ln t1
                WHERE
                    t1.type       =${/parameter/@type} AND
                    t1.contract_id=${/parameter/@contract_id}
                ORDER BY
                    t1.call_ln_id ASC
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
