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

	<!-- Alerta SMS-->
	<screen id="account" type="numeric" title="Introduceti numarul de telefon">
		<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.]]>
				</help>
			</text-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<set key="service_name" value="alertaSMS"/>
				<goto target="set_guid"/>
			</action>
			<action type="Prev" title="Inapoi">
				<goto target="exit"/>
			</action>
			<action type="Exit" title="Acasa">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<screen id="set_guid" type="group" title="Introduceti numarul de telefon">
		<fields>
			<text-field id="target" keyboard="any:[en,symb]:upper:true" max-len="99" message="Introduceti GUID vigneta" title="GUID vigneta">
				<validator type="regex">
					<rules>
						<rule regex="^[a-zA-Z0-9]+$"/>
					</rules>
				</validator>
				<help>
					<![CDATA[<html>Introduceti GUID vigneta.]]>
				</help>
			</text-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<online-request type="default" function="check_SMS" params="id1,target,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 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="account"/>
			</action>
			<action type="Exit" title="Acasa">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<!-- Confirm -->
	<screen id="confirm" type="confirm" title="Confirmare">
		<fields list="phone_number,price,guid_sms"/>
		<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="set_guid"/>
			</action>
			<action type="Exit" title="Acasa">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>
</scenario>
