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

	<!-- Load Info Page
   331 - Urban
    Smith & Smith
    -->
	<screen type="Void" id="LoadInfo">
		<actions>
			<action type="Next">
				<set key="#file" value="file://okto.html" />
				<goto target="InfoPage"/>
			</action>
		</actions>
	</screen>

	<!-- Info -->
	<screen id="InfoPage" type="info" title="Informare">
		<field key="#file" />
		<actions>
			<action type="Next">
				<goto target="account"/>
			</action>
			<action type="Prev">
				<goto target="previous"/>
			</action>
			<action type="Exit">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<!-- OKtoCash -->
	<screen id="account" type="numeric" title="Cod referinta">
		<fields>
			<text-field id="id1" keyboard="any:[en,symb]:lower:true" max-len="10" title="Cod de plata">
				<validator type="regex">
					<rules>
						<rule regex="^(\d{5,10})$"/>
					</rules>
				</validator>
				<help>
					<![CDATA[<html>Introduceti codul de plata sau scanati codul de bare]]>
				</help>
			</text-field>
		</fields>
		<barcode-scanner>
			<barcode-parser type="regex">
				<rules validate="^.*$">
					<rule key="id1" title="Cod plata" regex="^(.*)$" is-bind="true"/>
				</rules>
			</barcode-parser>
		</barcode-scanner>
		<actions>
			<action type="Next" title="Inainte">
				<online-request type="default" function="check_product" params="id1">
					<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="exit"/>
			</action>
			<action type="Exit" title="Pagina principala">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<!-- Confirmare -->
	<screen id="confirm" type="confirm" title="Confirmare">
		<fields list="id1,valoare"/>
		<actions>
			<action type="Next" title="Achita">
<!--				<set key="summ" value="1" />-->
				<set-sum from="valoare" type="units"/>
				<goto target="pay"/>
			</action>
			<action type="Prev" title="Inapoi">
				<goto target="account"/>
			</action>
			<action type="Exit" title="Acasa">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>
</scenario>
