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

	<!-- Carturesti -->
	<screen id="select_product" type="selector/image" title="Alege produsul">
		<fields>
			<selector-field id="product" title="Produs">
				<items type="static">
					<item value="CARTSTIRO100" title="CARTSTIRO100" image="carturesti100.png"/>
				</items>
			</selector-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<online-request type="default" function="check_product" params="product">
					<actions>
						<action type="success">
							<if condition="code == 0">
								<then>
									<goto target="account"/>
								</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 incercati din nou" 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="exit"/>
			</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_product"/>
			</action>
			<action type="Exit" title="Acasa">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

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