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

	<!-- Orange Options -->
	<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="1" value-title="1 Euro"/><cell key="price" key-title="key-title" value="7" value-title="7 RON"/></item>
					<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="13" value-title="13 Euro"/><cell key="price" key-title="key-title" value="91" value-title="91 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="16" value-title="16 Euro"/><cell key="price" key-title="key-title" value="112" value-title="112 RON"/></item>
					<item><cell key="nominal" key-title="Valore credit" value="21" value-title="21 Euro"/><cell key="price" key-title="key-title" value="147" value-title="147 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_options"/>
				<online-request type="default" function="get_options" params="id1,nominal,service_name">
					<actions>
						<action type="success">
							<if condition="code == 0">
								<then>
									<goto target="select_option"/>
								</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>

	<screen id="select_option" type="table" title="Optiune">
		<fields>
			<table-field id="tf" title="Tabel" read-only="false">
				<columns>
					<column key="option_name" title="Optiune" width="1"/>
				</columns>
				<items type="data" key="#options"/>
			</table-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<goto target="confirm"/>
			</action>
			<action type="Prev" title="Inapoi">
				<goto target="account"/>
			</action>
			<action type="Exit" title="Pagina principala">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<!-- Confirmare -->
	<screen id="confirm" type="confirm" title="Confirmare">
		<fields list="option_name,option_price"/>
		<actions>
			<action type="Next" title="Achita">
				<set-sum from="option_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>
