<scenario begin="account">

    <screen type="group/info" title="INTRODUCETI CUI/CIF COMPANIE" id="account">
        <fields>
            <text-field id="id1" title="COD" keyboard="any:[en]:upper:false" max-len="30" message="Insert Company's code">
                <validator type="regex">
                    <rules>
                        <rule regex="^.{1,30}$"/>
                    </rules>
                </validator>
            </text-field>
        </fields>
        <actions>
            <action type="Next" title="INAINTE">
				<load from="point.id" key="id2"/>
				<set key="id3" value="0" />
				<online-request type="default" function="activity" params="id1,id2,id3">
                    <actions>
                        <action type="success">
							<clear keys="id3"/> 
							<goto target="select"/>
                        </action>
                        <action type="error">
                            <dialog type="Info" title="Error" message="Nu s-a putut autentifica" timeout="10" default="okay">
                                <actions>
                                    <action type="okay" title="OK">
										<goto target="account"/>
                                    </action>                                            
                                </actions>
                            </dialog>                            
                        </action>
                        <action type="exception">
                            <dialog type="Info" title="Error" message="Nu exista conexiune cu serverul" 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="previos"/>
            </action>
            <action type="Exit" title="MENIU">
                <goto target="exit"/>
            </action>
        </actions>
    </screen>

    <screen type="selector/variant" title="SELECTATI UN RAPORT" id="select">
        <fields>
            <selector-field id="id3" title="Selector">
				<items type="data" key="#dates" />
			</selector-field>
        </fields>
        <actions>
            <action type="Next" title="INAINTE">
				<modify src-key="date" t-key="^.*$" v-key="id3" t-value="^(.*)$" v-value="$1" t-value-title="^(.*)$" v-value-title="$1"/>
				<online-request type="default" function="print" params="id1,id2,id3">
                    <actions>
                        <action type="success">
							<goto target="list"/>
                        </action>
                        <action type="error">
                            <dialog type="Info" title="Error" message="Raportul nu a fost gasit" timeout="10" default="okay">
                                <actions>
                                    <action type="okay" title="OK">
										<goto target="select"/>
                                    </action>                                            
                                </actions>
                            </dialog>                            
                        </action>
                        <action type="exception">
                            <dialog type="Info" title="Error" message="Nu exista conexiune cu serverul" timeout="10" default="okay">
                                <actions>
                                    <action type="okay" title="OK">
                                        <cancel/>
                                    </action>                                            
                                </actions>
                            </dialog>
                        </action>
                    </actions>
                </online-request>
            </action>
            <action type="Prev" title="INAPOI">
				<clear keys="id1"/>
                <goto target="account"/>
            </action>
            <action type="Exit" title="MENIU">
                <goto target="exit"/>
            </action>
        </actions>
    </screen>

    <screen type="selector/variant" title="DETALII RAPORT" id="list">
        <fields>
            <selector-field id="id4" title="Selector">
				<items type="data" key="activity" />
			</selector-field>
        </fields>
        <actions>
            <action type="Next" title="INAINTE">
				<goto target="print"/>
            </action>
            <action type="Prev" title="INAPOI">
				<clear keys="id3"/>
                <goto target="select"/>
            </action>
            <action type="Exit" title="MENIU">
                <goto target="exit"/>
            </action>
        </actions>
    </screen>
	
    <screen type="Void" id="print">
        <actions>
            <action type="Next" title="NEXT">
				<!--print template="rent"/-->
				<!--Actiune trimisa la tiparit.-->
				<dialog type="Info" title="Atentie" timeout="10" default="cancel" message="Momentan nu se poate tipari">
					<actions>
						<action type="okay" title="Inapoi">
							<clear keys="id3"/>
							<goto target="select"/> 
						</action> 
						<action type="cancel" title="Deconectare"> 
							<clear keys="id1,id2,id3"/>
							<goto target="exit"/>
							<cancel/> 
						</action>
					</actions>
				</dialog>
            </action>
        </actions>
    </screen>
	
</scenario>