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

	<!-- Taxa pod Fetesti -->

	<!-- Select country -->
	<screen id="select_country" type="table" title="Alege tara">
		<fields>
			<table-field id="tf" title="Tabel" read-only="false">
				<columns>
					<column key="title" title="Tara (In care este inmatriculata)" width="0.7"/>
					<column key="iso_code" title="ISO" width="0.3"/>
				</columns>
				<items>
					<item><cell key="title" key-title="key-title" value="Romania" value-title="Romania"/><cell key="iso_code" key-title="key-title" value="RO" value-title="RO"/></item>
					<item><cell key="title" key-title="key-title" value="Bulgaria" value-title="Bulgaria"/><cell key="iso_code" key-title="key-title" value="BG" value-title="BG"/></item>
					<item><cell key="title" key-title="key-title" value="Hungary" value-title="Hungary"/><cell key="iso_code" key-title="key-title" value="HU" value-title="HU"/></item>
					<item><cell key="title" key-title="key-title" value="R. Moldova" value-title="R. Moldova"/><cell key="iso_code" key-title="key-title" value="MD" value-title="MD"/></item>
					<item><cell key="title" key-title="key-title" value="Turkey" value-title="Turkey"/><cell key="iso_code" key-title="key-title" value="TR" value-title="TR"/></item>
					<item><cell key="title" key-title="key-title" value="Ukraine" value-title="Ukraine"/><cell key="iso_code" key-title="key-title" value="UA" value-title="UA"/></item>
					<item><cell key="title" key-title="key-title" value="Spain" value-title="Spain"/><cell key="iso_code" key-title="key-title" value="ES" value-title="ES"/></item>
					<item><cell key="title" key-title="key-title" value="Italy" value-title="Italy"/><cell key="iso_code" key-title="key-title" value="IT" value-title="IT"/></item>
					<item><cell key="title" key-title="key-title" value="United Kingdom" value-title="United Kingdom"/><cell key="iso_code" key-title="key-title" value="GB" value-title="GB"/></item>
					<item><cell key="title" key-title="key-title" value="Austria" value-title="Austria"/><cell key="iso_code" key-title="key-title" value="AT" value-title="AT"/></item>
					<item><cell key="title" key-title="key-title" value="Belgium" value-title="Belgium"/><cell key="iso_code" key-title="key-title" value="BE" value-title="BE"/></item>
					<item><cell key="title" key-title="key-title" value="Bosnia and Herzegovina" value-title="Bosnia and Herzegovina"/><cell key="iso_code" key-title="key-title" value="BA" value-title="BA"/></item>
					<item><cell key="title" key-title="key-title" value="Belarus" value-title="Belarus"/><cell key="iso_code" key-title="key-title" value="BY" value-title="BY"/></item>
					<item><cell key="title" key-title="key-title" value="Switzerland" value-title="Switzerland"/><cell key="iso_code" key-title="key-title" value="CH" value-title="CH"/></item>
					<item><cell key="title" key-title="key-title" value="Sweden" value-title="Sweden"/><cell key="iso_code" key-title="key-title" value="SE" value-title="SE"/></item>
					<item><cell key="title" key-title="key-title" value="Albania" value-title="Albania"/><cell key="iso_code" key-title="key-title" value="AL" value-title="AL"/></item>
					<item><cell key="title" key-title="key-title" value="Andorra" value-title="Andorra"/><cell key="iso_code" key-title="key-title" value="AD" value-title="AD"/></item>
					<item><cell key="title" key-title="key-title" value="Croatia" value-title="Croatia"/><cell key="iso_code" key-title="key-title" value="HR" value-title="HR"/></item>
					<item><cell key="title" key-title="key-title" value="Cyprus" value-title="Cyprus"/><cell key="iso_code" key-title="key-title" value="CY" value-title="CY"/></item>
					<item><cell key="title" key-title="key-title" value="Czech Republic" value-title="Czech Republic"/><cell key="iso_code" key-title="key-title" value="CZ" value-title="CZ"/></item>
					<item><cell key="title" key-title="key-title" value="Denmark" value-title="Denmark"/><cell key="iso_code" key-title="key-title" value="DK" value-title="DK"/></item>
					<item><cell key="title" key-title="key-title" value="Estonia" value-title="Estonia"/><cell key="iso_code" key-title="key-title" value="EE" value-title="EE"/></item>
					<item><cell key="title" key-title="key-title" value="Finland" value-title="Finland"/><cell key="iso_code" key-title="key-title" value="FI" value-title="FI"/></item>
					<item><cell key="title" key-title="key-title" value="France" value-title="France"/><cell key="iso_code" key-title="key-title" value="FR" value-title="FR"/></item>
					<item><cell key="title" key-title="key-title" value="Georgia" value-title="Georgia"/><cell key="iso_code" key-title="key-title" value="GE" value-title="GE"/></item>
					<item><cell key="title" key-title="key-title" value="Germany" value-title="Germany"/><cell key="iso_code" key-title="key-title" value="DE" value-title="DE"/></item>
					<item><cell key="title" key-title="key-title" value="Greece" value-title="Greece"/><cell key="iso_code" key-title="key-title" value="GR" value-title="GR"/></item>
					<item><cell key="title" key-title="key-title" value="Greenland" value-title="Greenland"/><cell key="iso_code" key-title="key-title" value="GL" value-title="GL"/></item>
					<item><cell key="title" key-title="key-title" value="Iceland" value-title="Iceland"/><cell key="iso_code" key-title="key-title" value="IS" value-title="IS"/></item>
					<item><cell key="title" key-title="key-title" value="Ireland" value-title="Ireland"/><cell key="iso_code" key-title="key-title" value="IE" value-title="IE"/></item>
					<item><cell key="title" key-title="key-title" value="Israel" value-title="Israel"/><cell key="iso_code" key-title="key-title" value="IL" value-title="IL"/></item>
					<item><cell key="title" key-title="key-title" value="Latvia" value-title="Latvia"/><cell key="iso_code" key-title="key-title" value="LV" value-title="LV"/></item>
					<item><cell key="title" key-title="key-title" value="Liechtenstein" value-title="Liechtenstein"/><cell key="iso_code" key-title="key-title" value="LI" value-title="LI"/></item>
					<item><cell key="title" key-title="key-title" value="Lithuania" value-title="Lithuania"/><cell key="iso_code" key-title="key-title" value="LT" value-title="LT"/></item>
					<item><cell key="title" key-title="key-title" value="Luxembourg" value-title="Luxembourg"/><cell key="iso_code" key-title="key-title" value="LU" value-title="LU"/></item>
					<item><cell key="title" key-title="key-title" value="Macedonia" value-title="Macedonia"/><cell key="iso_code" key-title="key-title" value="MK" value-title="MK"/></item>
					<item><cell key="title" key-title="key-title" value="Malta" value-title="Malta"/><cell key="iso_code" key-title="key-title" value="MT" value-title="MT"/></item>
					<item><cell key="title" key-title="key-title" value="Monaco" value-title="Monaco"/><cell key="iso_code" key-title="key-title" value="MC" value-title="MC"/></item>
					<item><cell key="title" key-title="key-title" value="Montenegro" value-title="Montenegro"/><cell key="iso_code" key-title="key-title" value="ME" value-title="ME"/></item>
					<item><cell key="title" key-title="key-title" value="Netherlands" value-title="Netherlands"/><cell key="iso_code" key-title="key-title" value="NL" value-title="NL"/></item>
					<item><cell key="title" key-title="key-title" value="Norway" value-title="Norway"/><cell key="iso_code" key-title="key-title" value="NO" value-title="NO"/></item>
					<item><cell key="title" key-title="key-title" value="Poland" value-title="Poland"/><cell key="iso_code" key-title="key-title" value="PL" value-title="PL"/></item>
					<item><cell key="title" key-title="key-title" value="Portugal" value-title="Portugal"/><cell key="iso_code" key-title="key-title" value="PT" value-title="PT"/></item>
					<item><cell key="title" key-title="key-title" value="Russian Federation" value-title="Russian Federation"/><cell key="iso_code" key-title="key-title" value="RU" value-title="RU"/></item>
					<item><cell key="title" key-title="key-title" value="San Marino" value-title="San Marino"/><cell key="iso_code" key-title="key-title" value="SM" value-title="SM"/></item>
					<item><cell key="title" key-title="key-title" value="Serbia" value-title="Serbia"/><cell key="iso_code" key-title="key-title" value="RS" value-title="RS"/></item>
					<item><cell key="title" key-title="key-title" value="Slovakia" value-title="Slovakia"/><cell key="iso_code" key-title="key-title" value="SK" value-title="SK"/></item>
					<item><cell key="title" key-title="key-title" value="Slovenia" value-title="Slovenia"/><cell key="iso_code" key-title="key-title" value="SI" value-title="SI"/></item>				</items>
			</table-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<load from="point.address" key="trm_location"/>
				<set key="availabilities" value="0"/>
				<set key="summ" value="10"/>
				<set key="service_name" value="taxafetesti"/>
				<goto target="select_category"/>
			</action>
			<action type="Prev" title="Inapoi">
				<goto target="previous"/>
			</action>
			<action type="Exit" title="Pagina principala">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<!-- Select category -->
	<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="Autoturisme" value-title="Autoturisme"/></item>
					<item><cell key="category" key-title="key-title" value="Microbuze" value-title="Microbuze"/></item>
					<item><cell key="category" key-title="key-title" value="Autobuze" value-title="Autobuze"/></item>
					<item><cell key="category" key-title="key-title" value="Altele" value-title="Altele"/></item>
				</items>
			</table-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<online-request type="default" function="get_prices" params="category,service_name">
					<actions>
						<goto-action type="success" target="select_prices"/>
						<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>
			<action type="Prev" title="Inapoi">
				<goto target="select_country"/>
			</action>
			<action type="Exit" title="Pagina principala">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<!-- Select availabilities -->
	<screen id="select_prices" type="table" title="Treceri">
		<fields>
			<table-field id="tf" title="Tabel" read-only="false">
				<columns>
					<column key="availability_text" title="Numar treceri" width="0.7"/>
					<column key="customer_price" title="Pret (RON)" width="0.3"/>
				</columns>
				<items type="data" key="#prices"/>
			</table-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<goto target="account"/>
				<set key="actionType" value=""/>
			</action>
			<action type="Prev" title="Inapoi">
				<goto target="select_category"/>
			</action>
			<action type="Exit" title="Pagina principala">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<!-- Registration number -->
	<screen id="account" type="group" title="Registration Number">
		<fields>
			<text-field id="id1" keyboard="any:[en,symb]:upper:true" max-len="8" message="Introduceti numarul de inmatriculare" title="Numar de inmatriculare" default="">
				<validator type="regex">
					<rules>
						<rule regex="[a-zA-Z]{1,2}[0-9]{2,3}[a-zA-Z]{3}"/>
					</rules>
				</validator>
				<help>
					<![CDATA[<html><center>Introduceti numarul de inmatriculare]]>
				</help>
			</text-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<goto target="set_chassis_number"/>
			</action>
			<action type="Prev" title="Inapoi">
				<goto target="select_availabilities"/>
			</action>
			<action type="Exit" title="Acasa">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<!-- Input chassis number -->
	<screen id="set_chassis_number" type="group" title="Numar sasiu">
		<fields>
			<text-field id="chassis_no" keyboard="any:[en,symb]:upper:true" max-len="17" message="Introduceti seria sasiului" title="Serie sasiu" default="">
				<validator type="regex">
					<rules>
						<rule regex="[a-zA-Z0-9]{17}"/>
					</rules>
				</validator>
				<help>
					<![CDATA[<html><center>Introduceti seria sasiului]]>
				</help>
			</text-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<goto target="set_phone_number"/>
			</action>
			<action type="Prev" title="Inapoi">
				<goto target="account"/>
			</action>
			<action type="Exit" title="Acasa">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<!-- Input phone number -->
	<screen id="set_phone_number" type="group" title="Numar de telefon">
		<fields>
			<text-field id="phone_number" keyboard="any:[en,symb]:lower:true" max-len="17" message="Introduceti numarul de telefon" title="Numar de telefon" default="">
				<validator type="regex">
					<rules>
						<rule regex="[0-9]{10}"/>
					</rules>
				</validator>
				<help>
					<![CDATA[<html><center>Introduceti numarul de telefon]]>
				</help>
			</text-field>
		</fields>
		<actions>
			<action type="Next" title="Achita">
				<online-request type="default" function="check_fetesti" params="id1,iso_code,category,chassis_no,availability,service_name,customer_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="account"/>
			</action>
			<action type="Exit" title="Acasa">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<!-- Confirmare -->
	<screen id="confirm" type="confirm" title="Confirmare">
		<fields list="registration_number2,phone_number,chassis_number2,guid2,country2,price2,availability2,valid_from2,valid_until2,guid2"/>
		<actions>
			<action type="Next" title="Achita">
				<set-sum from="customer_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>
