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

	<!-- Taxe FD S5 -->
	<screen id="account" type="numeric" title="CNP / CIF">
		<fields>
			<text-field id="id1" keyboard="Digital" max-len="13" title="Introduceti 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="Taxe_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>
									<if condition="pType == 0">
										<then>
											<goto target="taxe_PF"/>
										</then>
										<else>
											<goto target="taxe_PJ"/>
										</else>
									</if>
								</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="previous"/>
			</action>
			<action type="Exit" title="Pagina principala">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<screen id="taxe_PF" type="selector/bigbutton" title="Alege taxa">
		<fields>
			<selector-field id="categoria" message="Selectati categoria" title="Selectati categoria">
				<items type="static">
					<item value="0" title="Taxe buletin"/>
					<item value="1" title="Taxe PF"/>
				</items>
			</selector-field>
		</fields>
		<actions>
			<action type="Next" title="Next">
				<switch value="categoria">
					<case value="0"><goto target="taxe_buletin"/></case>
					<case value="1"><goto target="taxe_altele"/></case>
					<default/>
				</switch>
			</action>
			<action type="Prev" title="Inapoi">
				<goto target="account"/>
			</action>
			<action type="Exit" title="Pagina principala">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>
	<screen id="taxe_buletin" type="table" title="Alege taxa">
		<fields>
			<table-field id="tf" title="Tabel" read-only="false">
				<columns>
					<column key="taxaId" title="Tip taxa" width="0.8"/>
				</columns>
				<items>
					<item><cell key="taxaId" key-title="Tip taxa" value="10005" value-title="Taxă CI PF" /></item>
					<item><cell key="taxaId" key-title="Tip taxa" value="10006" value-title="CI provizorie PF" /></item>
				</items>
			</table-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<goto target="get_price"/>
			</action>
			<action type="Prev" title="Inapoi">
				<goto target="account"/>
			</action>
			<action type="Exit" title="Pagina principala">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>
	<screen id="taxe_altele" type="table" title="Alege taxa">
		<fields>
			<table-field id="tf" title="Tabel" read-only="false">
				<columns>
					<column key="taxaId" title="Tip taxa" width="0.8"/>
				</columns>
				<items>
					<item><cell key="taxaId" key-title="Tip taxa" value="897" value-title="Taxa ocupare domeniul public"/></item>
					<item><cell key="taxaId" key-title="Tip taxa" value="10007" value-title="Furnizare date persoana"/></item>
					<item><cell key="taxaId" key-title="Tip taxa" value="10008" value-title="Divort administrativ"/></item>
					<item><cell key="taxaId" key-title="Tip taxa" value="10009" value-title="Taxa Acord Administrator de Drum"/></item>
					<item><cell key="taxaId" key-title="Tip taxa" value="10010" value-title="Taxa Aviz Traseu – Retea mai mică de 2 km"/></item>
					<item><cell key="taxaId" key-title="Tip taxa" value="10011" value-title="Taxa Aviz Traseu – Retea mai mare de 2 km"/></item>
					<item><cell key="taxaId" key-title="Tip taxa" value="10012" value-title="Taxa Predare Amplasament"/></item>
					<item><cell key="taxaId" key-title="Tip taxa" value="10015" value-title="Taxa eliberare/vizare anuala autorizatie pentru desfasurarea activitatilor cod CAEN 561, 563, 932 suprafata mai mica de 500 mp"/></item>
					<item><cell key="taxaId" key-title="Tip taxa" value="10016" value-title="Taxa eliberare/vizare anuala autorizatie pentru desfasurarea activitatilor cod CAEN 561, 563, 932 suprafata mai mare de 500 mp"/></item>
				</items>
			</table-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<goto target="get_price"/>
			</action>
			<action type="Prev" title="Inapoi">
				<goto target="account"/>
			</action>
			<action type="Exit" title="Pagina principala">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>
	<screen id="taxe_PJ" type="table" title="Alege taxa">
		<fields>
			<table-field id="tf" title="Tabel" read-only="false">
				<columns>
					<column key="taxaId" title="Tip taxa" width="0.8"/>
				</columns>
				<items>
					<item>
						<cell key="taxaId" key-title="Tip taxa" value="10009" value-title="Taxă Acord Administrator de Drum PJ" />
					</item>
					<item>
						<cell key="taxaId" key-title="Tip taxa" value="10010" value-title="Taxă Aviz Traseu – Rețea mai mică de 2 km PJ" />
					</item>
					<item>
						<cell key="taxaId" key-title="Tip taxa" value="10011" value-title="Taxă Aviz Traseu – Rețea mai mare de 2 km PJ" />
					</item>
					<item>
						<cell key="taxaId" key-title="Tip taxa" value="10012" value-title="Taxă Predare Amplasament PJ" />
					</item>
					<item>
						<cell key="taxaId" key-title="Tip taxa" value="10007" value-title="Furnizare date persoană PJ" />
					</item>
					<item>
						<cell key="taxaId" key-title="Tip taxa" value="10015"
							  value-title="Taxă eliberare/vizare anuală autorizație pentru desfășurarea activităților cod CAEN 561, 563, 932 suprafață mai mică de 500 mp PJ" />
					</item>
					<item>
						<cell key="taxaId" key-title="Tip taxa" value="10016"
							  value-title="Taxă eliberare/vizare anuală autorizație pentru desfășurarea activităților cod CAEN 561, 563, 932 suprafață mai mare de 500 mp PJ" />
					</item>
				</items>
			</table-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<goto target="get_price"/>
			</action>
			<action type="Prev" title="Inapoi">
				<goto target="account"/>
			</action>
			<action type="Exit" title="Pagina principala">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<screen type="void" decor="button" title="" id="get_price">
		<fields/>
		<actions>
			<action type="Next" title="Verifica pretul">
				<set key="action_type" value="get_price"/>
				<online-request type="default" function="get_price" params="id1,taxaId,service_name,action_type">
					<actions>
						<action type="success">
							<if condition="code == 0">
								<then>
									<if condition="price == 0">
										<then>
											<goto target="set_price"/>
										</then>
										<else>
											<if condition="pId == 0">
												<then>
													<goto target="set_name"/>
												</then>
												<else>
													<goto target="confirm"/>
												</else>
											</if>
										</else>
									</if>
								</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 nu raspunde momentan. Incercati mai tarziu" 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="account"/>
			</action>
			<action type="Exit" title="Acasa">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>
	<screen id="set_name" type="group" title="Nume">
		<fields>
			<text-field id="nume" keyboard="any:[ro,en,symb]:lower:true" max-len="64" message="Nume si prenume" title="Nume si prenume" default="">
				<validator type="regex">
					<rules>
						<rule regex="[a-zA-Z .]{5,64}"/>
					</rules>
				</validator>
				<help>
					<![CDATA[<html><center>Introduceti numele si prenumele persoanei pentru care faceti plata]]>
				</help>
			</text-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="Acasa">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>
	<screen id="set_price" type="group" title="Nume">
		<fields>
			<text-field id="price" keyboard="any:[ro,en,symb]:lower:true" max-len="10" message="Suma" title="Suma" default="">
				<validator type="regex">
					<rules>
						<rule regex="[1-9]\d*"/>
					</rules>
				</validator>
				<help>
					<![CDATA[<html><center>Introduceti suma pe care doriti sa o platiti]]>
				</help>
			</text-field>
		</fields>
		<actions>
			<action type="Next" title="Inainte">
				<if condition="pId == 0">
					<then>
						<goto target="set_name"/>
					</then>
					<else>
						<goto target="confirm"/>
					</else>
				</if>
			</action>
			<action type="Prev" title="Inapoi">
				<goto target="account"/>
			</action>
			<action type="Exit" title="Acasa">
				<goto target="exit"/>
			</action>
		</actions>
	</screen>

	<screen id="confirm" type="confirm" title="Confirmare">
		<fields list="id1,taxaId,nume,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>
