;
; forward extension menu
; forward context exten
;

[macro-forward-set]
exten => s,1,AGI(forward-get.agi,${ARG1},${ARG2})
exten => s,2,GotoIf( $[ "${agiResult}" = "1" ] ? 3 : 30)
exten => s,3,GotoIf( $[ "${forwardType}" = "1" ] ? 10 : 4 )
exten => s,4,GotoIf( $[ "${forwardType}" = "2" ] ? 20 : 5 )
exten => s,5,Playback(sm-030)				; your forward type is unknown
exten => s,6,Goto(type,1)

exten => s,10,Playback(sm-028)				; your number is forwarded
exten => s,11,SayDigits(${forwardNumber})
exten => s,12,Goto(31)

exten => s,20,Playback(sm-029)				; your number will simaltaneously ring
exten => s,21,SayDigits(${forwardNumber})
exten => s,22,Goto(31)

exten => s,30,Playback(sm-031)				; your number is not forwarded
exten => s,31,DigitTimeout(4)
exten => s,32,ResponseTimeout(20)
exten => s,33,Read(setType,sm-033,1)			; press 1 to set, to to erase, 3 to cancel
exten => s,34,GotoIf( $[ "${setType}" = "1" ] ? 40 : 35)
exten => s,35,GotoIf( $[ "${setType}" = "2" ] ? 50 : 36)
exten => s,36,GotoIf( $[ "${setType}" = "3" ] ? 60 : 37)
exten => s,37,GotoIf( $[ "${setType}" = "*" ] ? 60 : 38)
exten => s,38,Goto(31)

exten => s,40,Goto(type,1)
exten => s,50,Goto(erase,1)
exten => s,60,SetVar(MACRO_OFFSET=0)

exten => erase,1,AGI(forward-set.agi,${ARG1},${ARG2},1,-)
exten => erase,2,Goto(s,1)

exten => type,1,DigitTimeout(4)
exten => type,2,ResponseTimeout(20)
exten => type,3,Read(ringType,sm-024,1)				; 1 for forward, 2 for simaltaneous, * to exit
exten => type,4,GotoIf( $[ "${ringType}" = "1" ] ? 30 : 5)
exten => type,5,GotoIf( $[ "${ringType}" = "2" ] ? 30 : 6)
exten => type,6,GotoIf( $[ "${ringType}" = "*" ] ? 7 : 20)
exten => type,7,Goto(s,1)

exten => type,20,Playback(sm-025)					; the ringtype is invalid
exten => type,21,Goto(1)

exten => type,30,Goto(number,1)

exten => number,1,DigitTimeout(4)
exten => number,2,ResponseTimeout(20)
exten => number,3,Read(ringNumber,sm-026,20)			; enter your forwarding number
exten => number,4,GotoIf( $[ "${ringNumber" = "" ] ? 7 : 5)
exten => number,5,GotoIf( $[ "${ringNumber}" = "*" ] ? 7 : 20)
exten => number,7,Goto(s,1)

exten => number,20,AGI(forward-set.agi,${ARG1},${ARG2},${ringType},${ringNumber})
exten => number,21,Goto(s,1)

exten => t,1,Goto(s,1)
exten => i,1,Goto(s,1)
