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

	<!-- Lyca mobile -->
	<screen id="select_category" type="table" title="Alege categoria">
		<fields>
			<table-field id="tf" title="Tabel" read-only="false">
				<columns>
					<column key="category" title="Categoria" width="1"/>
				</columns>
				<items>
					<item><cell key="category" key-title="key-title" value="Pachete" value-title="Pachete"/></item>
					<item><cell key="category" key-title="key-title" value="Credit" value-title="Credit"/></item>
				</items>
			</table-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<set key="summ" value="1" />
				<if condition="category == Pachete">
					<then>
						<goto target="select_pachet"/>
					</then>
					<else>
						<goto target="select_credit"/>
					</else>
				</if>
			</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_pachet" type="table" title="Alege produsul">
		<fields>
			<table-field id="tf" title="Tabel" read-only="false">
				<columns>
					<column key="nominal" title="Pachet" width="0.2"/>
					<column key="price" title="Pret" width="0.8"/>
				</columns>
				<items>
					<item><cell key="nominal" key-title="key-title" value="1003" value-title="3 Euro"/><cell key="price" key-title="key-title" value="21" value-title="Romania Start 21 RON"/></item>
					<item><cell key="nominal" key-title="key-title" value="1005" value-title="5 Euro"/><cell key="price" key-title="key-title" value="35" value-title="Romania Mini 35 RON"/></item>
					<item><cell key="nominal" key-title="key-title" value="1006" value-title="6 Euro"/><cell key="price" key-title="key-title" value="42" value-title="Romania Super 42 RON"/></item>
					<item><cell key="nominal" key-title="key-title" value="1007" value-title="7 Euro"/><cell key="price" key-title="key-title" value="49" value-title="Romania Mega 49 RON"/></item>
					<item><cell key="nominal" key-title="key-title" value="1008" value-title="8 Euro"/><cell key="price" key-title="key-title" value="56" value-title="Romania Ultra 56 RON"/></item>
				</items>
			</table-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<goto target="online"/>
			</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_credit" 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="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>
					<item><cell key="nominal" key-title="key-title" 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="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="30" value-title="30 Euro"/><cell key="price" key-title="key-title" value="210" value-title="210 RON"/></item>
				</items>
			</table-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<goto target="online"/>
			</action>
			<action type="Prev" title="Inapoi">
				<goto target="previous"/>
			</action>
			<action type="Exit" title="Pagina principala">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<screen id="online" type="void" title="Onlice check">
		<fields/>
		<actions>
			<action type="Next" title="Achita">
					<online-request type="default" function="get_pin" params="nominal,price">
						<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_category"/>
			</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"/>-->
				<set-sum from="price" 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>
