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

	<!-- Paysafecash -->
	<screen id="account" type="numeric" title="Cod">
		<fields>
			<text-field id="id1" keyboard="Digital" max-len="99" message="Introduceti cod bare" title="Cod bare" default="">
				<validator type="regex">
					<rules>
						<rule regex="^[0-9]{18,25}$"/>
					</rules>
				</validator>
				<help>
					<![CDATA[<html>Scanati codul de bare]]>
				</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="psc_direct"/>
				<load from="point.id" key="trm_id"/>
				<online-request type="default" function="check_request" params="id1,service_name,trm_id">
					<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="select_product"/>
			</action>
			<action type="Exit" title="Acasa">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

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