<!-- Orange -->
<scenario begin="first_screen">
    
    <!--  Start screen -->
    <screen type="selector/currency" title="SELECTATI VALOAREA OPTIUNII" id="first_screen" sound="select_nominal.mp3">
        <fields>
            <selector-field id="product" title="Nominal">
                <items type="static">
                    <item value="3" title="3 €" sum="3"/>
                    <item value="4" title="4 €" sum="4"/>
                    <item value="5" title="5 €" sum="5"/>
                    <item value="6" title="6 €" sum="6"/>
                    <item value="8" title="8 €" sum="8"/>
                    <item value="10" title="10 €" sum="10"/>	                          
                </items>
            </selector-field>
        </fields>
        <actions>
            <action type="Next" title="INAINTE">
                <goto target="input_phone"/>
            </action>
            <action type="Prev" title="INAPOI">
                <goto target="previos"/>
            </action>
            <action type="Exit" title="MENIU">
                <goto target="exit"/>
            </action>
            <action type="Edit" title="orange.png;0xff6501">
                <redirect target="23" params="menu-item"/>
                <cancel/>
            </action> 
        </actions>
    </screen>
    
    
    <screen type="numeric/info" title="INTRODUCETI NUMARUL DE TELEFON" id="input_phone" sound="input_phone.mp3">
        <fields>
            <text-field id="id1" title="NUMARUL DE TELEFON" max-len="10" prefix="07" keyboard="Digital">
                <validator type="regex">
                    <rules>
                        <rule regex="^\d{10}$"/>
                    </rules>
                </validator>
            </text-field>            
        </fields>
        <actions>
            <action type="Next" title="INAINTE">
                <set key="sum" value="100"/>
                <set key="option" value="0"/>
				<online-request type="default" function="find-provider" params="id1,product,option">
                    <actions>
                        <action type="success">
						<clear keys="sum"/>
						<clear keys="option"/>
                            <modify src-key="id1"  t-value-title="^(\d{3})(\d{3})(\d{2})(\d{2})$" v-value-title="$1.$2.$3.$4"/>
                            <goto target="choose_type"/>
                        </action>
                        <action type="error">
						<clear keys="sum"/>
						<clear keys="option"/>
                            <dialog type="Info" title="Error" message="Numarul de telefon nu a fost gasit" timeout="10" default="okay">
                                <actions>
                                    <action type="okay" title="OK">
										<goto target="input_phone"/>
                                    </action>                                            
                                </actions>
                            </dialog>                            
                        </action>
                        <action type="exception">
						<clear keys="sum"/>
						<clear keys="option"/>
                            <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="first_screen"/>
	      </action>
            <action type="Exit" title="MENIU">
                <goto target="exit"/>
            </action>
        </actions>
    </screen>
    
    <screen type="selector/button" title="ALEGETI TIPUL DORIT" id="choose_type">
        <fields>
            <selector-field id="id2" title="Type">
                <items type="static">
                    <item value="1" title="Optiuni cu minute" />
                    <item value="2" title="Optiuni internet" />
                </items>
            </selector-field>
        </fields>
        <actions>
            <action type="Next" title="INAINTE">
			<!--  3 euro // options -->
			<if condition="product == 3"> 
				<then> 
					<if condition="id2 == 1"> 
						<then> 
							<goto target="option3min"/>
						</then>    
					</if>
					<if condition="id2 == 2"> 
						<then> 
							<dialog type="Info" title="Error" message="Optiuni internet cu {0} euro nu exista" mess-params="product" timeout="10" default="okay">
                                <actions>
                                    <action type="okay" title="OK">
										<goto target="choose_type"/>
                                    </action>                                            
                                </actions>
                            </dialog>
						</then>    
					</if>
				</then>
			</if>
			<!--  4 euro // options -->
			<if condition="product == 4"> 
				<then> 
					<if condition="id2 == 1"> 
						<then> 
							<goto target="option4min"/>
						</then>    
					</if>
					<if condition="id2 == 2"> 
						<then> 
							<goto target="option4int"/>
						</then>    
					</if>
				</then>
			</if>
			<!--  5 euro // options -->
			<if condition="product == 5"> 
				<then> 
					<if condition="id2 == 1"> 
						<then> 
							<goto target="option5min"/>
						</then>    
					</if>
					<if condition="id2 == 2"> 
						<then> 
							<goto target="option5int"/>
						</then>    
					</if>
				</then>
			</if>
			<!--  6 euro // options -->
			<if condition="product == 6"> 
				<then> 
					<if condition="id2 == 1"> 
						<then> 
							<goto target="option6min"/>
						</then>    
					</if>
					<if condition="id2 == 2"> 
						<then> 
							<goto target="option6int"/>
						</then>    
					</if>
				</then>
			</if>
			<!--  8 euro // options -->
			<if condition="product == 8"> 
				<then> 
					<if condition="id2 == 1"> 
						<then> 
							<goto target="option8min"/>
						</then>    
					</if>
					<if condition="id2 == 2"> 
						<then> 
							<goto target="option8int"/>
						</then>    
					</if>
				</then>
			</if>
			<!--  8 euro // options -->
			<if condition="product == 10"> 
				<then> 
					<if condition="id2 == 1"> 
						<then> 
							<goto target="option10min"/>
						</then>    
					</if>
					<if condition="id2 == 2"> 
						<then> 
							<goto target="option10int"/>
						</then>    
					</if>
				</then>
			</if>
            </action>
            <action type="Prev" title="INAPOI">
                <goto target="input_phone"/>
            </action>
            <action type="Exit" title="MENIU">
                <goto target="exit"/>
            </action>           
        </actions>
    </screen>
	
    <!--  Begin options -->
	
    <!--  3 euro // minutes // options -->
    <screen type="selector/button" title="ALEGETI OPTIUNEA  DORITA" id="option3min">
        <fields>
			<selector-field id="option" title="Type">
				<items type="static">
					<item value="324305" title="Nelimitat min/SMS retea+50 min/SMS nat pt 15 zile" />
				</items>
			</selector-field>
        </fields>
        <actions>
            <action type="Next" title="INAINTE">
                <goto target="prepay"/>
            </action>
            <action type="Prev" title="INAPOI">
                <goto target="choose_type"/>
            </action>
            <action type="Exit" title="MENIU">
                <goto target="exit"/>
            </action>            
        </actions>
    </screen>
	
    <!--  4 euro // minutes // options -->
    <screen type="selector/button" title="ALEGETI OPTIUNEA  DORITA" id="option4min">
        <fields>
			<selector-field id="option" title="Type">
				<items type="static">
					<item value="324306" title="Nelimitat min/SMS retea+100 min/SMS nat" />
				</items>
			</selector-field>
        </fields>
        <actions>
            <action type="Next" title="INAINTE">
                <goto target="prepay"/>
            </action>
            <action type="Prev" title="INAPOI">
                <goto target="choose_type"/>
            </action>
            <action type="Exit" title="MENIU">
                <goto target="exit"/>
            </action>            
        </actions>
    </screen>
	
    <!--  4 euro // internet // options -->
    <screen type="selector/button" title="ALEGETI OPTIUNEA  DORITA" id="option4int">
        <fields>
			<selector-field id="option" title="Type">
				<items type="static">
					<item value="428719" title="100 MB internet UE, Islanda, Norvegia, Liechtenstein" />
				</items>
			</selector-field>
        </fields>
        <actions>
            <action type="Next" title="INAINTE">
                <goto target="prepay"/>
            </action>
            <action type="Prev" title="INAPOI">
                <goto target="choose_type"/>
            </action>
            <action type="Exit" title="MENIU">
                <goto target="exit"/>
            </action>            
        </actions>
    </screen>
	
    <!--  5 euro // minutes // options -->
    <screen type="selector/button" title="ALEGETI OPTIUNEA  DORITA" id="option5min">
        <fields>
			<selector-field id="option" title="Type">
				<items type="static">
					<item value="394030" title="Nelimitat Orange +500min/SMS nat/intl fix+500MB" />
					<item value="753858" title="Go Europe" />
				</items>
			</selector-field>
        </fields>
        <actions>
            <action type="Next" title="INAINTE">
                <goto target="prepay"/>
            </action>
            <action type="Prev" title="INAPOI">
                <goto target="choose_type"/>
            </action>
            <action type="Exit" title="MENIU">
                <goto target="exit"/>
            </action>            
        </actions>
    </screen>
	
    <!--  5 euro // internet // options -->
    <screen type="selector/button" title="ALEGETI OPTIUNEA  DORITA" id="option5int">
        <fields>
			<selector-field id="option" title="Type">
				<items type="static">
					<item value="753858" title="Internet Prepay 5 / 1GB " />
				</items>
			</selector-field>
        </fields>
        <actions>
            <action type="Next" title="INAINTE">
                <goto target="prepay"/>
            </action>
            <action type="Prev" title="INAPOI">
                <goto target="choose_type"/>
            </action>
            <action type="Exit" title="MENIU">
                <goto target="exit"/>
            </action>            
        </actions>
    </screen>
	
    <!--  6 euro // minutes // options -->
    <screen type="selector/button" title="ALEGETI OPTIUNEA  DORITA" id="option6min">
        <fields>
			<selector-field id="option" title="Type">
				<items type="static">
					<item value="394031" title="Nelimitat Orange +1000min/SMS nat/intl fix(200 mobil)+1GB" />
				</items>
			</selector-field>
        </fields>
        <actions>
            <action type="Next" title="INAINTE">
                <goto target="prepay"/>
            </action>
            <action type="Prev" title="INAPOI">
                <goto target="choose_type"/>
            </action>
            <action type="Exit" title="MENIU">
                <goto target="exit"/>
            </action>            
        </actions>
    </screen>
	
    <!--  6 euro // internet // options -->
    <screen type="selector/button" title="ALEGETI OPTIUNEA  DORITA" id="option6int">
        <fields>
			<selector-field id="option" title="Type">
				<items type="static">
					<item value="753859" title="Internet Prepay 6 / 2GB " />
				</items>
			</selector-field>
        </fields>
        <actions>
            <action type="Next" title="INAINTE">
                <goto target="prepay"/>
            </action>
            <action type="Prev" title="INAPOI">
                <goto target="choose_type"/>
            </action>
            <action type="Exit" title="MENIU">
                <goto target="exit"/>
            </action>            
        </actions>
    </screen>
	
    <!--  8 euro // minutes // options -->
    <screen type="selector/button" title="ALEGETI OPTIUNEA  DORITA" id="option8min">
        <fields>
			<selector-field id="option" title="Type">
				<items type="static">
					<item value="394033" title="Nelimitat Orange +2000min/SMS nat/intl fix(300 mobil)+2GB" />
				</items>
			</selector-field>
        </fields>
        <actions>
            <action type="Next" title="INAINTE">
                <goto target="prepay"/>
            </action>
            <action type="Prev" title="INAPOI">
                <goto target="choose_type"/>
            </action>
            <action type="Exit" title="MENIU">
                <goto target="exit"/>
            </action>            
        </actions>
    </screen>
	
    <!--  8 euro // internet // options -->
    <screen type="selector/button" title="ALEGETI OPTIUNEA  DORITA" id="option8int">
        <fields>
			<selector-field id="option" title="Type">
				<items type="static">
					<item value="753860" title="Internet Prepay 8 / 4GB " />
				</items>
			</selector-field>
        </fields>
        <actions>
            <action type="Next" title="INAINTE">
                <goto target="prepay"/>
            </action>
            <action type="Prev" title="INAPOI">
                <goto target="choose_type"/>
            </action>
            <action type="Exit" title="MENIU">
                <goto target="exit"/>
            </action>            
        </actions>
    </screen>
	
    <!--  8 euro // minutes // options -->
    <screen type="selector/button" title="ALEGETI OPTIUNEA  DORITA" id="option10min">
        <fields>
			<selector-field id="option" title="Type">
				<items type="static">
					<item value="394034" title="Nelimitat Orange +2000min/SMS nat/intl fix(400 mobil)+3GB" />
					<item value="428716" title="Go World" />
				</items>
			</selector-field>
        </fields>
        <actions>
            <action type="Next" title="INAINTE">
                <goto target="prepay"/>
            </action>
            <action type="Prev" title="INAPOI">
                <goto target="choose_type"/>
            </action>
            <action type="Exit" title="MENIU">
                <goto target="exit"/>
            </action>            
        </actions>
    </screen>
	
    <!--  8 euro // internet // options -->
    <screen type="selector/button" title="ALEGETI OPTIUNEA  DORITA" id="option10int">
        <fields>
			<selector-field id="option" title="Type">
				<items type="static">
					<item value="753861" title="Internet Prepay 10 / 6GB " />
					<item value="428720" title="Roaming date 500MB UE, Islanda, Norvegia, Liechtenstein" />
				</items>
			</selector-field>
        </fields>
        <actions>
            <action type="Next" title="INAINTE">
                <goto target="prepay"/>
            </action>
            <action type="Prev" title="INAPOI">
                <goto target="choose_type"/>
            </action>
            <action type="Exit" title="MENIU">
                <goto target="exit"/>
            </action>            
        </actions>
    </screen>
    <!--  End options -->
    
	<screen type="Void" decor="button" title="" id="prepay">
	<fields/>
		<actions>
			<action type="Next" title="NEXT">
				<if condition="is-not-null #back">
					<then>
						<modify src-key="id1" t-value-title="^(\d{3})(.)(\d{3})(.)(\d{2})(.)(\d{2})$" v-value-title="$1$3$5$7"/>
						<clear keys="#back"/>
						<goto target="first_screen"/>
					</then>
					<else>
						<set key="#back" value="1"/>
						<goto target="pay"/>
					</else>
				</if>
			</action>
		</actions>
	</screen>
	
    <screen type="Sum" sum="sum-trade"/>
</scenario>
