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

	<!-- Telekom options -->
	<screen id="select_product" 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="3" value-title="3 Euro"/><cell key="price" key-title="key-title" value="18" value-title="18 RON"/></item>
					<item><cell key="nominal" key-title="key-title" value="4" value-title="4 Euro"/><cell key="price" key-title="key-title" value="24" value-title="24 RON"/></item>
					<item><cell key="nominal" key-title="key-title" value="5" value-title="5 Euro"/><cell key="price" key-title="key-title" value="30" value-title="30 RON"/></item>
					<item><cell key="nominal" key-title="key-title" value="6" value-title="6 Euro"/><cell key="price" key-title="key-title" value="36" value-title="36 RON"/></item>
					<item><cell key="nominal" key-title="key-title" value="7" value-title="7 Euro"/><cell key="price" key-title="key-title" value="42" value-title="42 RON"/></item>
					<item><cell key="nominal" key-title="key-title" value="8" value-title="8 Euro"/><cell key="price" key-title="key-title" value="48" value-title="48 RON"/></item>
					<item><cell key="nominal" key-title="key-title" value="9" value-title="9 Euro"/><cell key="price" key-title="key-title" value="56" value-title="56 RON"/></item>
					<item><cell key="nominal" key-title="key-title" value="10" value-title="10 Euro"/><cell key="price" key-title="key-title" value="60" value-title="60 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" 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="TelekomOptions"/>
				<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_product"/>
			</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="summ" type="units"/>
				<goto target="pay"/>
			</action>
			<action type="Prev" title="Inapoi">
				<goto target="account"/>
			</action>
			<action type="Exit" title="Acasa">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>
</scenario>
