<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
                BEGIN
                update con_contract cc
                   set cc.ec_sign_type         = 'SIGNED',
                       cc.sign_contract_status = 'SIGN',
                       cc.last_update_date     = sysdate
                 where cc.contract_id =
                       (select cf.contract_id
                          from con_contract_ele_flow cf
                         where cf.ele_flow_id = ${@flow_id}
                           and cf.ele_flow_type in ('CE', 'ET'));

                  update con_contract_ele_flow cf
                     set cf.flow_status      = ${@flow_status},
                         cf.last_update_date = sysdate
                   where cf.ele_flow_id = ${@flow_id};

                   update con_contract_ele_signer cs
                      set cs.ec_sign_status = 'Y',
                          cs.last_update_date = sysdate
                    where cs.contract_id =
                        (select cf.contract_id
                              from con_contract_ele_flow cf
                             where cf.ele_flow_id = ${@flow_id});
                END;
            ]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="execute">
            <bm:update-sql><![CDATA[
                begin
                    update con_contract c
                       set c.ec_sign_type = 'NEW',
                           c.sign_contract_status = 'NEW',
                           c.last_update_date = sysdate,
                           c.last_updated_by = nvl(${/session/@user_id},'1')
                     where c.contract_id = (select cf.contract_id
                              from con_contract_ele_flow cf
                             where cf.ele_flow_id = ${@flow_id}
                               and cf.ele_flow_type in ('CE', 'ET'));

                    delete from con_contract_ele_signer cs where cs.contract_id =
                                                                (select cf.contract_id
                                                                          from con_contract_ele_flow cf
                                                                         where cf.ele_flow_id = ${@flow_id}
                                                                         and cf.ele_flow_type in ('CE', 'ET'));
                    delete from CON_CONTRACT_ELE_FLOW t where t.ele_flow_id = ${@flow_id};
                commit;
                end;
            ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
