<?xml version="1.0" encoding="UTF-8"?>
<scenario begin="StepOne">

    <screen id="StepOne" type="numeric" title="Introduceti CNP-ul/CIF-ul dvs.">
        <fields>
            <text-field id="id1" keyboard="Digital" max-len="13" title="Introduceti CNP-ul">
                <validator type="regex">
                    <rules>
                        <rule regex="^(\d{13})$"/>
                    </rules>
                </validator>
            </text-field>
        </fields>
        <actions>
            <action type="Next">
                <set key="fullname" key-title="Nume" value="Popescu Doina"/>
                <set key="test" value="0"/>
                <modify src-key="id1" t-key-title="^(.*)$" v-key-title="CNP"/>
                <online-request type="default" function="" params="test" timeout="10">
                    <actions>
                        <action type="success">
                            <goto target="StepTwo"/>
                        </action>
                        <action type="error">
                            <goto target="StepTwo"/>
                        </action>
                        <action type="exception">
                            <goto target="StepOne"/>
                        </action>
                    </actions>
                </online-request>
            </action>
            <action type="Prev">
                <goto target="exit"/>
            </action>
            <action type="Exit">
                <goto target="exit"/>
            </action>
        </actions>
    </screen>

    <screen id="StepTwo" type="confirm" title="Verificati corectitudinea datelor introduse">
        <fields list="id1,fullname"/>
        <actions>
            <action type="Next">

                <set key="selected" value="0"/>
                <set key="editable" value="0"/>
                <set key="summ" key-title="Suma" value="10" value-title="10"/>
                <set key="allow-change-state" value="1"/>
                <set key="id2" key-title="Option" value="1" value-title="Impozit teren intravilan"/>
                <set key="name" key-title="Suma" value="Impozit teren intravilan - 10 LEI" value-title="Impozit teren intravilan"/>
                <pack type="data" key="dt1" elements="selected,editable,summ,allow-change-state,id2,name"/>

                <set key="selected" value="0"/>
                <set key="editable" value="0"/>
                <set key="summ" key-title="Suma" value="20" value-title="20"/>
                <set key="allow-change-state" value="1"/>
                <set key="id2" key-title="Option" value="2" value-title="Impozit teren extravilan"/>
                <set key="name" key-title="Suma" value="Impozit teren extravilan - 20 LEI" value-title="Impozit teren extravilan"/>
                <pack type="data" key="dt2" elements="selected,editable,summ,allow-change-state,id2,name"/>

                <pack type="nested" key="#services" elements="dt1,dt2"/>
                <clear keys="selected,editable,summ,allow-change-state,id2,name,dt1,dt2"/>
            
                <goto target="StepThree"/>
            </action>
            <action type="Prev">
                <goto target="StepOne"/>
            </action>
            <action type="Exit">
                <goto target="exit"/>
            </action>
        </actions>
    </screen>


    <screen id="StepThree" type="communal" title="Selectati Taxa si impozitul dorit">
        <fields key="#services"/>
        <actions>
            <action type="Next">
                <sum key="summ" result-key="ssum" input-data="#services" filter="selected=1"/>
                <set-sum from="ssum" type="units"/>
                <clear keys="ssum"/>
                <goto target="pay"/>
            </action>
            <action type="Prev">
                <goto target="StepOne"/>
            </action>
            <action type="Exit">
                <goto target="exit"/>
            </action>
            <action type="Edit">
                <if condition="is-not-null #selected">
                    <then>
                        <unpack type="data" key="#selected" elements="editable,summ,allow-change-state,id2,name"/>
                        <set key="selected" value="1" value-title="1"/>
                        <pack type="data" key="#selected" elements="selected,editable,summ,allow-change-state,id2,name"/>
                        <clear keys="#selected,selected,editable,summ,allow-change-state,id2,name"/>
                        <goto target="StepThree"/>
                    </then>
                    <else>
                        <if condition="is-not-null #removed">
                            <then>
                                <unpack type="data" key="#removed" elements="name"/>
                                <dialog type="Info" title="Sunteti sigur?" message="Sunteti sigur ca doriti sa stergeti {0} din lista?" timeout="10" default="cancel" mess-params="name">
                                    <actions>
                                        <action type="okay" title="DA">
                                            <set key="selected" value="0" value-title="0"/>
                                            <pack type="data" key="#removed" elements="selected,name"/>
                                            <clear keys="name,selected,#removed"/>
                                            <goto target="StepThree"/>
                                        </action>
                                        <action type="cancel" title="NU">
                                            <clear keys="#removed,name"/>
                                            <cancel/>
                                        </action>
                                    </actions>
                                </dialog>
                            </then>
                        </if>
                    </else>
                </if>
            </action>
        </actions>
    </screen>
</scenario>
