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

	<!-- Barcode -->
	<screen id="account" type="numeric" title="Introduceti codul de client">
		<fields>
			<text-field id="id1" keyboard="any:[en]:upper:false" prefix="" max-len="100" message="Scanati codul de bare" title="Cont">
				<validator type="regex">
					<rules>
						<rule regex="^[0-9a-zA-Z]{1,100}$"/>
					</rules>
				</validator>
				<help>
					<![CDATA[<html>Functia de scanare rapida este momentan disponibila pentru urmatoarele servicii: <br><br>Vodafone Postpay, Orange Retea Fixa, NN Asigurari, GroupAma, Apa Canal Ilfov, Eco Aqua Calarasi, Focus Sat Factura, DIGI Factura, Paysafecard Direct, Engie Gaz, Engie Electricitate, Enel, Electrica Furnizare, TBI Money, CEZ Distributie, Distributie Oltenia, Distrigaz Sud Retele, KRUK, BRD Finance, AIK Energy, E-Bloc. ]]>
				</help>
			</text-field>
		</fields>
		<barcode-scanner>
			<barcode-parser type="regex">
				<rules validate="^.*$">
					<rule key="id1" title="Cod" regex="^(.*)$" is-bind="true"/>
				</rules>
			</barcode-parser>
		</barcode-scanner>
		<actions>
			<action type="Next" title="Inainte">
				<set key="service_name" value="barcode_scan"/>
				<online-request type="default" function="barcode_scan" params="id1,service_name">
					<actions>
						<action type="success">
							<if condition="code == 0">
								<then>
									<if condition="xml_id == 174"><then><redirect target="174" params="$all"/></then></if>
									<if condition="xml_id == 139"><then><redirect target="139" params="$all"/></then></if>
									<if condition="xml_id == 138"><then><redirect target="138" params="$all"/></then></if>
									<if condition="xml_id == 176"><then><redirect target="176" params="$all"/></then></if>
									<if condition="xml_id == 137"><then><redirect target="137" params="$all"/></then></if>
									<if condition="xml_id == 136"><then><redirect target="136" params="$all"/></then></if>
									<if condition="xml_id == 134"><then><redirect target="134" params="$all"/></then></if>
									<if condition="xml_id == 169"><then><redirect target="169" params="$all"/></then></if>
									<if condition="xml_id == 118"><then><redirect target="118" params="$all"/></then></if>
									<if condition="xml_id == 166"><then><redirect target="166" params="$all"/></then></if>
									<if condition="xml_id == 130"><then><redirect target="130" params="$all"/></then></if>
									<if condition="xml_id == 129"><then><redirect target="129" params="$all"/></then></if>
									<if condition="xml_id == 121"><then><redirect target="121" params="$all"/></then></if>
									<if condition="xml_id == 122"><then><redirect target="122" params="$all"/></then></if>
									<if condition="xml_id == 133"><then><redirect target="133" params="$all"/></then></if>
									<if condition="xml_id == 112"><then><redirect target="112" params="$all"/></then></if>
									<if condition="xml_id == 127"><then><redirect target="127" params="$all"/></then></if>
									<if condition="xml_id == 196"><then><redirect target="196" params="$all"/></then></if>
									<if condition="xml_id == 251"><then><redirect target="251" params="$all"/></then></if>
									<goto target="select_service"/>
								</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>

	<screen id="select_service" type="table" title="Alege serviciul">
		<fields>
			<table-field id="tf" title="Tabel" read-only="false">
				<columns>
					<column key="service" title="Serviciu" width="1"/>
				</columns>
				<items type="data" key="#services"/>
			</table-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<switch value="service">
					<case value="Engie Gaz"><redirect target="114" params="$all"/></case>
					<case value="Engie Electricitate"><redirect target="113" params="$all"/></case>
					<default><goto target="exit"/></default>
				</switch>
			</action>
			<action type="Prev" title="Inapoi">
				<goto target="account"/>
			</action>
			<action type="Exit" title="Pagina principala">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

</scenario>
