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

    <!-- Load Info Page
    ID: 94 / 1094 - Premier Energy
    Smith & Smith
    -->
    <screen type="Void" id="LoadInfo">
        <actions>
            <action type="Next">
                <set key="#file" value="file://smith.html" />
                <goto target="InfoPage"/>
            </action>
        </actions>
    </screen>

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

    <!-- Datele titularului
    - Sa contina litere si cifre;
    - Nume si Prenume, doar litere si spatii;
    - CNP, doar cifre, maxim 13 caractere;
    - Sa permita continuarea doar la indeplinirea minimului de caractere;
    -->
    <screen id="StepOne" type="group" title="Introduceti datele clientului">
        <fields>
            <text-field id="id3" 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 clientului înscris pe factura]]>
                </help>
            </text-field>
            <text-field id="id4" 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 clientului înscris pe factura]]>
                </help>
            </text-field>
            <text-field id="id1" keyboard="Digital" max-len="15" title="Cod client">
                <validator type="regex">
                    <rules>
                        <rule regex="^\d{8,15}$"/>
                    </rules>
                </validator>
                <help>
                    <![CDATA[<html>Introduceti codul de client]]>
                </help>
            </text-field>
            <text-field id="id2" keyboard="Digital" max-len="15" title="Numar factura">
                <validator type="regex">
                    <rules>
                        <rule regex="^\d{3,15}$"/>
                    </rules>
                </validator>
                <help>
                    <![CDATA[<html>Introduceti numarul facturii]]>
                </help>
            </text-field>
        </fields>
        <actions>
            <action type="Next">
                <goto target="PhoneNumber"/>
            </action>
            <action type="Prev">
                <goto target="InfoPage"/>
            </action>
            <action type="Exit">
                <goto target="exit"/>
            </action>
        </actions>
    </screen>

    <!-- Numarul de telefon
    - Sa contina prefixul 07, doar retea mobila;
    - Sa fie lungimea maxima 10 impreuna cu prefixul;
    - Sa permita continuarea doar la indeplinirea celor 10 cifre;
    -->
    <screen id="PhoneNumber" type="numeric" title="Introduceti numarul de telefon">
        <fields>
            <text-field id="id5" keyboard="Digital" max-len="10" title="Numarul de telefon">
                <validator type="regex">
                    <rules>
                        <rule regex="^07(\d{8})$"/>
                    </rules>
                </validator>
                <formatter type="regex">
                    <rules default="**** *** ***"/>
                </formatter>
                <help>
                    <![CDATA[<html>Prin continuarea tranzactiei va dati acordul pentru plata unui comision de <b>3 RON</b> pentru procesarea acestei plati;]]>
                </help>
            </text-field>
        </fields>
        <actions>
            <action type="Next">
                <set key="service_name" value="PremierEnergy"/>
                <online-request type="default" function="check_request" params="id1,id2,id3,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="StepOne"/>
            </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"/>
        <actions>
            <action type="Next" title="Achita">
                <clear keys="#file"/>
                <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="PhoneNumber"/>
            </action>
            <action type="Exit" title="Acasa">
                <goto target="exit"/>
            </action>
        </actions>
    </screen>
</scenario>
