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

	<!-- Orange Minute -->
	<screen id="select_nominal" type="table" title="Nominal">
		<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="Valore credit" 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="Valore credit" value="4" value-title="4 Euro"/><cell key="price" key-title="key-title" value="28" value-title="28 RON"/></item>
					<item><cell key="nominal" key-title="Valore credit" value="5" value-title="5 Euro"/><cell key="price" key-title="key-title" value="35" value-title="35 RON"/></item>
					<item><cell key="nominal" key-title="Valore credit" 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="Valore credit" 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="Valore credit" 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="Valore credit" 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="Valore credit" 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="Valore credit" 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="Valore credit" 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="Valore credit" 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="Valore credit" 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="Valore credit" 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="Valore credit" 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="Valore credit" value="50" value-title="50 Euro"/><cell key="price" key-title="key-title" value="350" value-title="350 RON"/></item>
				</items>
			</table-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<goto target="account"/>
			</action>
			<action type="Prev" title="Inapoi">
				<goto target="exit"/>
			</action>
			<action type="Exit" title="Pagina principala">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<screen id="account" type="numeric" title="Telefon">
		<fields>
			<text-field id="id1" keyboard="any:[en,symb]:upper:true" max-len="10" title="Telefon">
				<validator type="regex">
					<rules>
						<rule regex="^07(\d{8})$"/>
					</rules>
				</validator>
				<formatter type="regex">
					<rules default="**** *** ***"/>
				</formatter>
				<help>
					<![CDATA[<html>Introduceti numarul de prepay.]]>
				</help>
			</text-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<set key="service_name" value="orange_prepay"/>
				<online-request type="default" function="check_request" params="id1,nominal,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_nominal"/>
			</action>
			<action type="Exit" title="Pagina principala">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<!-- Confirmare -->
	<screen id="confirm" type="confirm" title="Confirmare">
		<fields list="nominal"/>
		<actions>
			<action type="Next" title="Achita">
				<set-sum from="price" type="units"/>
				<dialog type="Info" title="Info" message="Sunteti de acord cu prelucrarea datelor personale?" 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>