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

<!--	Mobilo Finance -->
	<screen id="account" type="numeric" title="CNP">
		<fields>
			<text-field id="id1" keyboard="Digital" max-len="99" title="CNP">
				<validator type="regex">
					<rules>
						<rule regex="^[0-9]{13}$"/>
					</rules>
				</validator>
				<help>
					<![CDATA[<html>Introduceti CNP pentru identificarea contractului.]]>
				</help>
			</text-field>
		</fields>
		<actions>
			<action type="Next">
				<online-request type="default" function="get_bill" params="id1">
					<actions>
						<action type="success">
							<if condition="code == 0">
								<then>
									<goto target="sel_options"/>
								</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">
				<goto target="exit"/>
			</action>
			<action type="Exit">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<!-- Selectarea produselor -->
	<screen id="sel_options" type="table" title="Optiuni">
		<fields>
			<table-field id="tf" title="Tabel" read-only="false">
				<columns>
					<column key="title" title="Optiuni de plata" width="0.7"/>
					<column key="suma" title="Suma de achitat" width="0.3"/>
				</columns>
				<items type="data" key="#options"/>
			</table-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<if condition="manual == 1">
					<then>
						<goto target="input_sum"/>
					</then>
					<else>
						<modify src-key="suma" t-key-title="^(.*)$" v-key-title="Suma de achitat" />
						<goto target="confirm"/>
					</else>
				</if>
			</action>
			<action type="Prev" title="Inapoi">
				<goto target="account"/>
			</action>
			<action type="Exit" title="Pagina principala">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<screen id="input_sum" type="numeric" title="Suma de achitat">
		<fields>
			<text-field id="suma" keyboard="Digital" max-len="99" title="Suma de achitat">
				<validator type="regex">
					<rules>
						<rule regex="^[0-9]{1,5}$"/>
					</rules>
				</validator>
				<help>
					<![CDATA[<html>Introduceti suma pe care doriti sa o achitati.]]>
				</help>
			</text-field>
		</fields>
		<actions>
			<action type="Next">
				<online-request type="default" function="check_sum" params="sold,suma,minim_plata">
					<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">
				<goto target="sel_options"/>
			</action>
			<action type="Exit">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<!-- Confirm -->
	<screen id="confirm" type="confirm" title="Confirmare">
		<fields list="nume,client,contract,suma"/>
		<actions>
			<action type="Next" title="Achita">
				<set-sum from="suma" type="units"/>
				<goto target="pay"/>
			</action>
			<action type="Prev" title="Inapoi">
				<goto target="sel_options"/>
			</action>
			<action type="Exit" title="Acasa">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>
</scenario>
