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

    <!-- Load Info Page
    ID: 318 / 1318 - DRPCIV - Certificat de inmatriculare PJ
    Smith & Smith
    -->
    <screen type="Void" id="LoadInfo">
        <actions>
            <action type="Next">
                <set key="#file" value="file://smith6.html" />
                <goto target="InfoPage"/>
            </action>
        </actions>
    </screen>

    <!-- Info -->
    <screen id="InfoPage" type="info" title="Informare">
        <field key="#file" />
        <actions>
            <action type="Next">
                <goto target="StepZero"/>
            </action>
            <action type="Prev">
                <goto target="previous"/>
            </action>
            <action type="Exit">
                <goto target="exit"/>
            </action>
        </actions>
    </screen>

    <screen id="StepZero" type="group" title="Introduceti datele titularului">
        <fields>
            <text-field id="id2" keyboard="any:[en]:upper:false" max-len="35" title="Nume societate">
                <validator type="regex">
                    <rules>
                        <rule regex="^[a-zA-Z\s]*$"/>
                    </rules>
                </validator>
                <help>
                    <![CDATA[<html>Introduceti numele societatii pentru care se face plata]]>
                </help>
            </text-field>
            <text-field id="id1" keyboard="Digital" max-len="15" title="CUI / CIF">
                <validator type="regex">
                    <rules>
                        <rule regex="^(\d{4,15})$"/>
                    </rules>
                </validator>
                <help>
                    <![CDATA[<html>Introduceti CUI / CIF al beneficiarului]]>
                </help>
            </text-field>
        </fields>
        <actions>
            <action type="Next">
                <goto target="StepOne"/>
            </action>
            <action type="Prev">
                <goto target="InfoPage"/>
            </action>
            <action type="Exit">
                <goto target="exit"/>
            </action>
        </actions>
    </screen>

    <screen id="StepOne" type="group" title="Introduceti datele titularului">
        <fields>
            <text-field id="id4" keyboard="any:[en]:upper:false" max-len="35" title="Nume">
                <validator type="regex">
                    <rules>
                        <rule regex="^[a-zA-Z\s]*$"/>
                    </rules>
                </validator>
                <help>
                    <![CDATA[<html>Introduceti numele dvs]]>
                </help>
            </text-field>
            <text-field id="id5" keyboard="any:[en]:upper:false" max-len="35" title="Prenume">
                <validator type="regex">
                    <rules>
                        <rule regex="^[a-zA-Z\s]*$"/>
                    </rules>
                </validator>
                <help>
                    <![CDATA[<html>Introduceti prenumele dvs]]>
                </help>
            </text-field>
            <text-field id="id3" keyboard="Digital" max-len="13" title="CNP platitor">
                <validator type="regex">
                    <rules>
                        <rule regex="^(\d{13})$"/>
                    </rules>
                </validator>
                <help>
                    <![CDATA[<html>Introduceti CNP-ul dvs]]>
                </help>
            </text-field>
            <text-field id="id6" keyboard="Digital" max-len="10" title="Numar telefon">
                <validator type="regex">
                    <rules>
                        <rule regex="^(\d{10})$"/>
                    </rules>
                </validator>
                <help>
                    <![CDATA[<html>Introduceti numarul dvs de telefon]]>
                </help>
            </text-field>
        </fields>
        <actions>
            <action type="Next">
                <set key="price" value="49"/>
                <set key="service_name" value="DRPCIVinmatricularePJ"/>
                <online-request type="default" function="check_request" params="id1,id2,id3,id4,id5,id6,service_name">
                    <actions>
                        <action type="success">
                            <if condition="code == 0">
                                <then>
                                    <goto target="ConfirmPage"/>
                                </then>
                                <else>
                                    <dialog type="Info" title="Eroare" message="Eroare: {0}" timeout="10" default="okay" mess-params="exception">
                                        <actions>
                                            <action type="okay" title="OK">
                                                <cancel/>
                                            </action>
                                        </actions>
                                    </dialog>
                                </else>
                            </if>
                        </action>
                        <action type="error">
                            <dialog type="Info" title="Eroare" message="A intervenit o eroare, va rugam sa incercati din nou" timeout="10" default="okay">
                                <actions>
                                    <action type="okay" title="OK">
                                        <cancel/>
                                    </action>
                                </actions>
                            </dialog>
                        </action>
                    </actions>
                </online-request>
            </action>
            <action type="Prev">
                <goto target="StepZero"/>
            </action>
            <action type="Exit">
                <goto target="exit"/>
            </action>
        </actions>
    </screen>

    <!-- Confirm -->
    <screen id="ConfirmPage" type="confirm" title="Verificati corectitudinea datelor introduse">
        <fields list="id1,id2,id3,id4,id5,id6"/>
        <actions>
            <action type="Next" title="Achita">
                <clear keys="#file"/>
                <set-sum from="price" type="units"/>
                <dialog type="Info" title="Info" message="Sunteti de acord cu prelucrarea datelor cu caracter personal in scopuri de marketing?" timeout="10" default="cancel" mess-params="name">
                    <actions>
                        <action type="okay" title="Da">
                            <set key="gdpr" value="1"/>
                            <goto target="pay"/>
                        </action>
                        <action type="cancel" title="Nu">
                            <set key="gdpr" value="0"/>
                            <goto target="pay"/>
                        </action>
                    </actions>
                </dialog>
            </action>
            <action type="Prev" title="Inapoi">
                <goto target="StepOne"/>
            </action>
            <action type="Exit" title="Acasa">
                <goto target="exit"/>
            </action>
        </actions>
    </screen>
</scenario>
