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

	<!-- Amenzi Barlad -->
	<screen id="select_person_type" type="selector/bigbutton" title="Alege categoria">
		<fields>
			<selector-field id="pType" 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">
				<switch value="pType">
					<case value="pf"><goto target="amenzi_PF"/></case>
					<case value="pj"><goto target="amenzi_PJ"/></case>
					<default/>
				</switch>
			</action>
			<action type="Prev" title="Inapoi">
				<goto target="exit"/>
			</action>
			<action type="Exit" title="Pagina principala">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<screen id="amenzi_PF" type="table" title="Alege tipul amenzii">
		<fields>
			<table-field id="tf" title="Tabel" read-only="false">
				<columns>
					<column key="amendaId" title="Amenda PF" width="0.8"/>
				</columns>
				<items>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="932"
							  value-title="Amenda depunere peste termen a decl. de impunere (Legea 207/2015) PF" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="933"
							  value-title="Amenda depunere peste termen a decl. de impunere (Legea 227/2015) PF" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="96" value-title="AMENDA I.T.M. PF" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="191" value-title="Amenda urbanism PF" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="95" value-title="AmendaITC PF" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="89" value-title="AMENZI AUT.NAT.A VAMILOR PF" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="21" value-title="Amenzi auto rutiere PF" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="232" value-title="Amenzi Autoritate Supraveghere Fiscala PF" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="52" value-title="Amenzi CFR PF" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="24" value-title="Amenzi corp control PF" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="25" value-title="Amenzi diverse PF" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="76" value-title="Amenzi GARDA FINANCIARA PF" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="81" value-title="Amenzi L 61/1991 PF" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="85" value-title="Amenzi Legea 12/1990 PF" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="90" value-title="AMENZI P.S.I PF" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="23" value-title="Amenzi politia comunitara PF" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="82" value-title="Amenzi Protectia Consumatorului PF" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="86" value-title="AMENZI PROTECTIA MEDIULUI PF" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="84" value-title="Amenzi Silvice PF" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="22" value-title="Amenzi transport in comun PF" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="92" value-title="AMENZIpmb PF" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="94" value-title="Compania Nationala Autostrazi PF" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="87" value-title="Dir.San.Vet.si.pt.Siguranta.Alimentelor PF" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="222" value-title="Directia de Sanatate Publica Vaslui PF" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="79" value-title="VENITURI AMENZI RUTIERE PF" />
					</item>
				</items>
			</table-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<goto target="account"/>
			</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="amenzi_PJ" type="table" title="Alege tipul amenzii">
		<fields>
			<table-field id="tf" title="Tabel" read-only="false">
				<columns>
					<column key="amendaId" title="Amenda PF" width="0.8"/>
				</columns>
				<items>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="932"
							  value-title="Amenda depunere peste termen a decl. de impunere (Legea 207/2015) PJ" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="933"
							  value-title="Amenda depunere peste termen a decl. de impunere (Legea 227/2015) PJ" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="191" value-title="Amenda urbanism PJ" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="21" value-title="Amenzi auto rutiere PJ" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="24" value-title="Amenzi corp control PJ" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="25" value-title="Amenzi diverse PJ" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="81" value-title="Amenzi L 61/1991 PJ" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="23" value-title="Amenzi politia comunitara PJ" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="84" value-title="Amenzi Silvice PJ" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="22" value-title="Amenzi transport in comun PJ" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="92" value-title="AMENZIpmb PJ" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="94" value-title="Compania Nationala Autostrazi PJ" />
					</item>
					<item>
						<cell key="amendaId" key-title="Tip amenda" value="79" value-title="VENITURI AMENZI RUTIERE PJ" />
					</item>
				</items>
			</table-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<goto target="account"/>
			</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="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_Barlad"/>
				<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="set_seriaPV"/>
								</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="Serverul 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 PB" />
				</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="account"/>
			</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="2023-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,pType,amendaId,dataProcesVerbal,dataComunicarii,sumaProcesVerbal,sumaMinima,serieProcesVerbal,numarProcesVerbal,pId,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>
