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

	<!--google play-->
	<screen type="void" decor="button" title="" id="online_request">
		<fields/>
		<actions>
			<action type="Next" title="Verifica lista prodiselor">
				<load from="point.address" key="trm_location"/>
				<set key="products" value="0"/>
				<set key="category_id" value="0"/>
				<set key="sum1" value="1"/>
				<set key="service_name" value="google_play"/>
				<online-request type="default" function="get_products" params="products,category_id,service_name">
					<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>

	<!-- Selectarea produselor -->
	<screen id="select_products" type="table" title="Alege produsul dorit">
		<fields>
			<table-field id="tf" title="Tabel" read-only="false">
				<columns>
					<column key="title" title="Produs" width="0.7"/>
					<column key="price" title="Pret (RON)" width="0.3"/>
				</columns>
				<items type="data" key="#products"/>
			</table-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<if condition="in_stock == 0">
					<then>
						<dialog type="Info" title="Info" message="Produsul selectat este indisponibil momentan" timeout="10" default="cancel">
							<actions>
								<action type="cancel" title="OK">
									<cancel/>
								</action>
							</actions>
						</dialog>
					</then>
				  <else>
					  <modify src-key="title" t-key-title="^(.*)$" v-key-title="Produs" />
					  <modify src-key="price" t-key-title="^(.*)$" v-key-title="Pret" />
					  <modify src-key="price_currency" t-key-title="^(.*)$" v-key-title="Moneda" />
					<goto target="account"/>
				  </else>
				</if>
			</action>
			<action type="Prev" title="Inapoi">
				<goto target="previous"/>
			</action>
			<action type="Exit" title="Pagina principala">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<!-- Adresa de email -->
	<screen id="account" type="group" title="Email">
		<fields>
			<text-field id="id1" keyboard="any:[en,symb]:lower:true" max-len="99" message="Introduceti adresa de email" title="Email" default="">
				<validator type="regex">
					<rules>
						<rule regex="^[-\w.]+@([A-z0-9][-A-z0-9]+\.)+[A-z]{2,4}$"/>
					</rules>
				</validator>
				<help>
					<![CDATA[<html><center>Introduceti o adresa de email valida]]>
				</help>
			</text-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<goto target="confirm"/>
			</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="id1,title,price,price_currency"/>
		<actions>
			<action type="Next" title="Achita">
				<set-sum from="price" 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>
