<scenario begin="input_data">

    <screen type="group/comunal"  title="NTS Give COFFEE" id="input_data">
        <fields>
            <text-field id="id1" title="Telefon companie" max-len="10" keyboard="Digital" secure="false">
                <validator type="regex">
                    <rules>
                        <rule regex="^\d{10}$"/>
                    </rules>
                </validator>
                <formatter type="regex">
                    <rules default="**** *** ***"/>
                </formatter>
            </text-field>
            <text-field id="id2" title="Codul PIN" max-len="6" keyboard="Digital" secure="true">
                <validator type="regex">
                    <rules>
                        <rule regex="^\d{6}$"/>
                    </rules>
                </validator>
            </text-field>   
        </fields>
        <actions>
            <action type="Next" title="INAINTE">
                <online-request type="default" function="verify" params="id1,id2">
                    <actions>
                        <action type="success">
							<modify src-key="id1" t-key="^(.*)$" v-key="id3"/>
							<modify src-key="id2" t-key="^(.*)$" v-key="id4"/>
							<modify src-key="attr1" t-key-title="^.*$" v-key-title="Bauturi ramase"/>
							<set key="#newsum" value="100"/>
							
							<if condition="attr1 > 0">
								<then>
									<dialog type="Info" title="Atentie" timeout="10" default="okay" message="Mai aveti {0} bauturi ramase" mess-params="attr1">
										<actions>
											<action type="okay" title="Continuare">
												<redirect target="67" params="$all"/>
											</action>
										</actions>
									</dialog>
								</then>
							
							</if>
							<if condition="attr1 == 0">
								<then>
									<dialog type="Info" title="Atentie" timeout="10" default="okay" message="Ati ramas fara bauturi in cont">
										<actions>
											<action type="okay" title="OK">
												<goto target="previos"/>
											</action>
										</actions>
									</dialog>
								</then>
							
							</if>
                        </action>
                        <action type="error">
                            <dialog type="Info" title="Error" message="Ne pare rau, acest cont nu exista" timeout="10" default="okay">
                                <actions>
                                    <action type="okay" title="OK">
										<clear keys="sum"/>
                                        <cancel/>
                                    </action>                                            
                                </actions>
                            </dialog>                            
                        </action>
                        <action type="exception">
                            <dialog type="Info" title="Error" message="Nu exista conexiune cu serverul" timeout="10" default="okay">
                                <actions>
                                    <action type="okay" title="OK">
                                        <clear keys="sum"/>
                                        <cancel/>
                                    </action>                                            
                                </actions>
                            </dialog>
                        </action>
                    </actions>
                </online-request>
            </action>
            <action type="Prev" title="INAPOI">
                <goto target="previos"/>
            </action>
            <action type="Exit" title="MENIU">
                <goto target="exit"/>
            </action>
        </actions>
    </screen>
    
</scenario>