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

	<!-- Amenzi S5 -->
	<screen id="select_person_type" type="selector/bigbutton" title="Alege categoria">
		<fields>
			<selector-field id="tipPersoana" title="Tip persoana">
				<items type="static">
					<item value="pf" title="Persoane fizice" />
					<item value="pj" title="Persoane juridice" />
				</items>
			</selector-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<goto target="account"/>
			</action>
			<action type="Prev" title="Inapoi">
				<goto target="exit"/>
			</action>
			<action type="Exit" title="Pagina principala">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<screen id="account" type="numeric" title="CNP / CIF">
		<fields>
			<text-field id="id1" keyboard="Digital" max-len="13" title="CNP / CIF">
				<validator type="regex">
					<rules>
						<rule regex="^[0-9]{4,13}"/>
					</rules>
				</validator>
				<help>
					<![CDATA[<html>]]>
				</help>
			</text-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<set key="service_name" value="Amenzi_S5"/>
				<set key="action_type" value="check_person"/>
				<online-request type="default" function="check_person" params="id1,service_name,action_type">
					<actions>
						<action type="success">
							<if condition="code == 0">
								<then>
									<goto target="select_fine_type"/>
								</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="Lista taxelor este inaccesibila momentan" 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_person_type"/>
			</action>
			<action type="Exit" title="Pagina principala">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<screen id="select_fine_type" type="selector/button" title="Alege categoria">
		<fields>
			<selector-field id="tipAmenda" title="Tip amenda">
				<items type="static">
					<item value="pl" title="Amenzi politia locala" />
					<item value="p" title="Amenzi persoane" />
					<item value="pmb" title="Amenzi politia locala PMB" />
				</items>
			</selector-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<goto target="set_seriaPV"/>
			</action>
			<action type="Prev" title="Inapoi">
				<goto target="select_person_type"/>
			</action>
			<action type="Exit" title="Pagina principala">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<screen id="set_seriaPV" type="group" title="Serie proces verbal">
		<fields>
			<text-field id="serieProcesVerbal" keyboard="any:[ro,en,symb]:lower:true" max-len="17" message="Introduceti seria procesului verbal" title="Serie proces verbal" default="">
				<validator type="regex">
					<rules>
						<rule regex="[a-zA-Z0-9]{2,20}"/>
					</rules>
				</validator>
				<help>
					<![CDATA[<html><center>Introduceti seria procesului verbal]]>
				</help>
			</text-field>
			<text-field id="numarProcesVerbal" keyboard="any:[ro,en,symb]:lower:true" max-len="17" message="Introduceti numarul procesului verbal" title="Numar proces verbal" default="">
				<validator type="regex">
					<rules>
						<rule regex="[a-zA-Z0-9]{2,20}"/>
					</rules>
				</validator>
				<help>
					<![CDATA[<html><center>Introduceti numarul procesului verbal]]>
				</help>
			</text-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<dialog type="Info" title="Data proces verbal" message="Alegeti data procesului verbal" timeout="10" default="okay">
					<actions>
						<action type="okay" title="OK">
							<goto target="select_dataProcesVerbal"/>
						</action>
					</actions>
				</dialog>
			</action>
			<action type="Prev" title="Inapoi">
				<goto target="select_fine_type"/>
			</action>
			<action type="Exit" title="Acasa">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<screen id="select_dataProcesVerbal" type="date" title="Alegeti data proces verbal">
		<fields>
			<date-field id="dataProcesVerbal" title="Data proces verbal" format="yyyy-MM-dd" format-title="yyyy-MM-dd" from="2020-01-01" to="2052-12-31"/>
		</fields>
		<actions>
			<action type="Next" title="Achita">
				<if condition="is-not-null dataProcesVerbal">
					<then>
						<dialog type="Info" title="Data comunicarii procesului verbal" message="Alegeti data comunicarii procesului verbal" timeout="10" default="okay">
							<actions>
								<action type="okay" title="OK">
									<goto target="select_dataComunicarii"/>
								</action>
							</actions>
						</dialog>
					</then>
					<else>
						<dialog type="Info" title="Eroare" message="Alegeti data procesului verbal" timeout="10" default="okay">
							<actions>
								<action type="okay" title="OK">
									<cancel/>
								</action>
							</actions>
						</dialog>
					</else>
				</if>
			</action>
			<action type="Prev" title="Inapoi">
				<goto target="select_fine_type"/>
			</action>
			<action type="Exit" title="Acasa">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<screen id="select_dataComunicarii" type="date" title="Alegeti data comunicare proces verbal">
		<fields>
			<date-field id="dataComunicarii" title="Data proces verbal" format="yyyy-MM-dd" format-title="yyyy-MM-dd" from="2020-01-01" to="2052-12-31"/>
		</fields>
		<actions>
			<action type="Next" title="Achita">
				<if condition="is-not-null dataComunicarii">
					<then>
						<goto target="set_sumaProcesVerbal"/>
					</then>
					<else>
						<dialog type="Info" title="Eroare" message="Alegeti data comunicarii procesului verbal" timeout="10" default="okay">
							<actions>
								<action type="okay" title="OK">
									<cancel/>
								</action>
							</actions>
						</dialog>
					</else>
				</if>
			</action>
			<action type="Prev" title="Inapoi">
				<goto target="select_dataProcesVerbal"/>
			</action>
			<action type="Exit" title="Acasa">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<screen id="set_sumaProcesVerbal" type="group/numeric" title="Suma proces verbal">
		<fields>
			<text-field id="sumaProcesVerbal" keyboard="Digital" max-len="17" message="Introduceti suma procesului verbal" title="Suma proces verbal" default="">
				<validator type="regex">
					<rules>
						<rule regex="\d{1,10}"/>
					</rules>
				</validator>
				<help>
					<![CDATA[<html><center>Introduceti suma totala de plata a procesului verbal]]>
				</help>
			</text-field>
			<text-field id="sumaMinima" keyboard="Digital" max-len="17" message="Introduceti suma minima a procesului verbal" title="Suma minima" default="">
				<validator type="regex">
					<rules>
						<rule regex="\d{1,10}"/>
					</rules>
				</validator>
				<help>
					<![CDATA[<html><center>Introduceti suma minima de plata a procesului verbal]]>
				</help>
			</text-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<goto target="set_datePV"/>
			</action>
			<action type="Prev" title="Inapoi">
				<goto target="account"/>
			</action>
			<action type="Exit" title="Acasa">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<screen id="set_datePV" type="group" title="Serie proces verbal">
		<fields>
			<text-field id="emitent" keyboard="any:[ro,en,symb]:lower:true" max-len="50" message="Introduceti emitentul procesului verbal" title="Emitent proces verbal" default="">
				<validator type="regex">
					<rules>
						<rule regex=".*${5,50}"/>
					</rules>
				</validator>
				<help>
					<![CDATA[<html><center>Emitentul procesului verbal]]>
				</help>
			</text-field>
			<text-field id="locul" keyboard="any:[ro,en,symb]:lower:true" max-len="50" message="Introduceti locul procesului verbal" title="Locatie proces verbal" default="">
				<validator type="regex">
					<rules>
						<rule regex=".*${5,50}"/>
					</rules>
				</validator>
				<help>
					<![CDATA[<html><center>Introduceti locatia procesului verbal]]>
				</help>
			</text-field>
			<text-field id="mentiuni" keyboard="any:[ro,en,symb]:lower:true" max-len="50" message="Introduceti mentiuni ale procesului verbal" title="Mentiuni proces verbal" default="">
				<validator type="regex">
					<rules>
						<rule regex="^.*${5,50}"/>
					</rules>
				</validator>
				<help>
					<![CDATA[<html><center>Introduceti mentiuni ale procesului verbal]]>
				</help>
			</text-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<online-request type="default" function="get_min_sum" params="id1,tipPersoana,tipAmenda,dataProcesVerbal,dataComunicarii,sumaProcesVerbal,sumaMinima,serieProcesVerbal,numarProcesVerbal,identificatorPersoanaId,emitent,locul,mentiuni,service_name">
					<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 verificati toate datele" 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="set_sumaProcesVerbal"/>
			</action>
			<action type="Exit" title="Acasa">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

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