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

	<!-- Telefon -->
	<screen id="account" type="numeric" title="Cod client">
		<fields>
			<text-field id="id1" keyboard="Digital" max-len="99" message="Cod client" title="Cod client">
				<validator type="regex">
					<rules>
						<rule regex="^[0-9]{9}$"/>
					</rules>
				</validator>
				<help>
					<![CDATA[<html>Introduceti manual datele sau scanati codul de bare de pe factura]]>
				</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">
				<online-request type="default" function="get_products" params="id1">
					<actions>
						<action type="success">
<!--							<if condition="code == 0">-->
<!--								<then>-->
									<goto target="select_bill"/>
<!--								</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="previous"/>
			</action>
			<action type="Exit" title="Pagina principala">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<screen id="select_bill" type="table" title="Facturi">
		<fields>
			<table-field id="tf" title="Tabel" read-only="false">
				<columns>
					<column key="contract" title="Cod contract" width="0.4"/>
					<column key="dueDate" title="Scadenta" width="0.4"/>
					<column key="price" title="Pret" width="0.2"/>
				</columns>
				<items type="data" key="#products"/>
			</table-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<goto target="confirm"/>
			</action>
			<action type="Prev" title="Inapoi">
				<goto target="account"/>
			</action>
			<action type="Exit" title="Pagina principala">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<!-- Confirm -->
	<screen id="confirm" type="confirm" title="Confirmare">
		<fields list="contract,dueDate,price"/>
		<actions>
			<action type="Next" title="Achita">
				<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>
