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

	<!-- Vodafone prepay 3-4E -->
	<screen id="select_prepay" type="table" title="Alege produsul">
		<fields>
			<table-field id="tf" title="Tabel" read-only="false">
				<columns>
					<column key="nominal" title="Produs" width="0.5"/>
					<column key="price" title="Pret" width="0.5"/>
				</columns>
				<items>
					<item><cell key="nominal" key-title="key-title" value="3" value-title="3 Euro"/><cell key="price" key-title="key-title" value="21" value-title="21 RON"/></item>
					<item><cell key="nominal" key-title="key-title" value="4" value-title="4 Euro"/><cell key="price" key-title="key-title" value="28" value-title="28 RON"/></item>
				</items>
			</table-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<goto target="account"/>
			</action>
			<action type="Prev" title="Inapoi">
				<goto target="previous"/>
			</action>
			<action type="Exit" title="Pagina principala">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<screen id="account" type="numeric" title="Onlice check">
		<fields>
			<text-field id="id1" keyboard="Digital"  max-len="10" title="Numarul de telefon">
				<validator type="regex">
					<rules>
						<rule regex="^\d{10}$"/>
					</rules>
				</validator>
				<formatter type="regex">
					<rules default="**** *** ***"/>
				</formatter>
				<help>
					<![CDATA[<html>Introduceti numarul de telefon prepay.]]>
				</help>
			</text-field>
		</fields>
		<actions>
			<action type="Next" title="Achita">
				<set key="service_name" value="vf_prepay"/>
					<online-request type="default" function="check_phone" params="id1,nominal,price,service_name">
						<actions>
							<action type="success">
								<if condition="code == 0">
									<then>
										<goto target="confirm"/>
									</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 verificati toate datele" timeout="10" default="okay">
									<actions>
										<action type="okay" title="OK">
											<cancel/>
										</action>
									</actions>
								</dialog>
							</action>
						</actions>
					</online-request>
			</action>
			<action type="Prev" title="Inapoi">
				<goto target="select_prepay"/>
			</action>
			<action type="Exit" title="Acasa">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<!-- Confirmare -->
	<screen id="confirm" type="confirm" title="Confirmare">
		<fields list="produs,pret"/>
		<actions>
			<action type="Next" title="Achita">
				<set-sum from="pret" 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="account"/>
			</action>
			<action type="Exit" title="Acasa">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>
</scenario>
