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

	<!-- Vodafone prepay 5-200E -->
	<screen type="void" decor="button" title="" id="online_request">
		<fields/>
		<actions>
			<action type="Next" title="Verifica curs de schimb">
				<set key="service_name" value="vf_prepay"/>
				<set key="action_type" value="get_exchange_rates"/>
				<set key="cat" value="cat_5_200"/>
				<online-request type="default" function="get_products" params="service_name,action_type,cat">
					<actions>
						<goto-action type="success" target="select_products"/>
						<action type="error">
							<dialog type="Info" title="Eroare" message="Lista produselor este inaccesibila momentan" timeout="10" default="okay">
								<actions>
									<action type="okay" title="OK">
										<cancel/>
									</action>
								</actions>
							</dialog>
						</action>
					</actions>
				</online-request>
			</action>
			<goto-action type="Inapoi" title="Inapoi" target="previous"/>
			<goto-action type="Pagina principala" title="Pagina principala" target="exit"/>
		</actions>
	</screen>

	<screen id="select_products" type="table" title="Alege produsul dorit">
		<fields>
			<table-field id="tf" title="Tabel" read-only="false">
				<columns>
					<column key="nominal" title="Nominal (EUR)" width="0.3"/>
					<column key="price" title="Pret (RON)" width="0.7"/>
				</columns>
				<items type="data" key="#products"/>
			</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="select_direct" type="table" title="Alege produsul">
		<fields>
			<table-field id="tf" title="Tabel" read-only="false">
				<columns>
					<column key="nominal" title="Nominal" width="0.4"/>
					<column key="price" title="Pret" width="0.6"/>
				</columns>
				<items>
					<item><cell key="nominal" key-title="key-title" value="5" value-title="5 Euro"/><cell key="price" key-title="key-title" value="37" value-title="35 RON"/></item>
					<item><cell key="nominal" key-title="key-title" value="6" value-title="6 Euro"/><cell key="price" key-title="key-title" value="42" value-title="42 RON"/></item>
					<item><cell key="nominal" key-title="key-title" value="7" value-title="7 Euro"/><cell key="price" key-title="key-title" value="49" value-title="49 RON"/></item>
					<item><cell key="nominal" key-title="key-title" value="8" value-title="8 Euro"/><cell key="price" key-title="key-title" value="56" value-title="56 RON"/></item>
					<item><cell key="nominal" key-title="key-title" value="9" value-title="9 Euro"/><cell key="price" key-title="key-title" value="63" value-title="63 RON"/></item>
					<item><cell key="nominal" key-title="key-title" value="10" value-title="10 Euro"/><cell key="price" key-title="key-title" value="70" value-title="70 RON"/></item>
					<item><cell key="nominal" key-title="key-title" value="15" value-title="15 Euro"/><cell key="price" key-title="key-title" value="105" value-title="105 RON"/></item>
					<item><cell key="nominal" key-title="key-title" value="20" value-title="20 Euro"/><cell key="price" key-title="key-title" value="140" value-title="140 RON"/></item>
					<item><cell key="nominal" key-title="key-title" value="25" value-title="25 Euro"/><cell key="price" key-title="key-title" value="175" value-title="175 RON"/></item>
					<item><cell key="nominal" key-title="key-title" value="30" value-title="30 Euro"/><cell key="price" key-title="key-title" value="210" value-title="210 RON"/></item>
					<item><cell key="nominal" key-title="key-title" value="35" value-title="35 Euro"/><cell key="price" key-title="key-title" value="245" value-title="245 RON"/></item>
					<item><cell key="nominal" key-title="key-title" value="40" value-title="40 Euro"/><cell key="price" key-title="key-title" value="280" value-title="280 RON"/></item>
					<item><cell key="nominal" key-title="key-title" value="50" value-title="50 Euro"/><cell key="price" key-title="key-title" value="350" value-title="350 RON"/></item>
					<item><cell key="nominal" key-title="key-title" value="75" value-title="75 Euro"/><cell key="price" key-title="key-title" value="525" value-title="525 RON"/></item>
					<item><cell key="nominal" key-title="key-title" value="100" value-title="100 Euro"/><cell key="price" key-title="key-title" value="700" value-title="700 RON"/></item>
					<item><cell key="nominal" key-title="key-title" value="200" value-title="200 Euro"/><cell key="price" key-title="key-title" value="1400" value-title="1400 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="Online check">
		<fields>
			<text-field id="id1" keyboard="Digital" prefix="07" 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>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_products"/>
			</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>
