;!
;! Automatically generated configuration file
;! Filename: extensions.conf (/etc/asterisk/extensions.conf)
;! Generator: Manager
;! Creation Date: Fri Mar 27 14:50:30 2015
;!

;RECORDING OF A CALL 
;exten => 6005,1,Set(CALLFILENAME=${EXTEN:1}-${STRFTIME(,,%H%M)}
;exten => 6005,2,Answer()
;exten => 6005,3,Monitor(wav,${CALLFILENAME},m)
;exten => 6005,4,Dial(SIP/newdude,20)

[general]
static = yes
writeprotect = no
clearglobalvars = yes


[globals]
FEATURES = 
DIALOPTIONS = 
RINGTIME = 20
FOLLOWMEOPTIONS = 
PAGING_HEADER = Intercom
CID_6012 = 6012
QUEUES = undefined,6500,6501,6502,6503,6030,6504,6505,6506
CID_6013 = 6013
CID_6014 = 6014

trunk_1 = SIP/trunk_1

CID_6021 = 6021
CID_6022 = 6022
CID_6023 = 6023
CID_6031 = 6031
CID_6032 = 6032
CID_6033 = 6033
CID_6015 = 6015
CID_6056 = 6056
CID_6024 = 6024
CID_6025 = 6025
CID_6026 = 6026
CID_6034 = 6034
CID_6035 = 6035
CID_6036 = 6036

Audiocodes = SIP/Audiocodes


[default]
exten = _#6XXX,1,Set(MBOX=${EXTEN:1}@default)
exten = _#6XXX,n,VoiceMail(${MBOX})
exten = a,1,VoicemailMain(${MBOX})
exten = 60009,1,VoiceMailMain(${CALLERID(num)}@default)




[macro-stdexten]
exten = s,1,Set(__DYNAMIC_FEATURES=${FEATURES})
exten = s,2,Set(ORIG_ARG1=${ARG1})
exten = s,3,GotoIf($["${FOLLOWME_${ARG1}}" = "1"]?6:4)
exten = s,4,Dial(${ARG2},${RINGTIME},${DIALOPTIONS})
exten = s,5,Goto(s-${DIALSTATUS},1)
exten = s,6,Macro(stdexten-followme,${ARG1},${ARG2})
exten = s-NOANSWER,1,Voicemail(${ORIG_ARG1},u)
exten = s-NOANSWER,2,Goto(default,s,1)
exten = s-BUSY,1,Voicemail(${ORIG_ARG1},b)
exten = s-BUSY,2,Goto(default,s,1)
exten = _s-.,1,Goto(s-NOANSWER,1)
exten = a,1,VoicemailMain(${ORIG_ARG1})

[macro-stdexten-followme]
exten = s,1,Answer
exten = s,2,Set(ORIG_ARG1=${ARG1})
exten = s,3,Dial(${ARG2},${RINGTIME},${DIALOPTIONS})
exten = s,4,Set(__FMCIDNUM=${CALLERID(num)})
exten = s,5,Set(__FMCIDNAME=${CALLERID(name)})
exten = s,6,Followme(${ORIG_ARG1},${FOLLOWMEOPTIONS})
exten = s,7,Voicemail(${ORIG_ARG1},u)
exten = s-NOANSWER,1,Voicemail(${ORIG_ARG1},u)
exten = s-BUSY,1,Voicemail(${ORIG_ARG1},b)
exten = s-BUSY,2,Goto(default,s,1)
exten = _s-.,1,Goto(s-NOANSWER,1)
exten = a,1,VoicemailMain(${ORIG_ARG1})
[macro-pagingintercom]
exten = s,1,SIPAddHeader(Alert-Info: ${PAGING_HEADER})
exten = s,2,Page(${ARG1},${ARG2})
exten = s,3,Hangup


[conferences]
[ringgroups]



[queues]
exten => 6500,1,Answer()
exten => 6500,2,Ringing()
exten => 6500,3,Set(CALLERID(name)='Operator')
exten => 6500,4,Set(CALLERID(RDNIS)='6500')
;exten => 6500,5,Monitor(wav,testfile6500,m) RECORDING OF ALL QUEUE CALLS
exten => 6500,5,Queue(6500)

exten => 6501,1,Answer()
exten => 6501,2,Ringing()
exten => 6501,3,Set(CALLERID(name)='Purchasing')
exten => 6501,4,Set(CALLERID(RDNIS)='6501')
exten => 6501,5,Queue(6501)

exten => 6502,1,Answer()
exten => 6502,2,Ringing()
exten => 6502,3,Set(CALLERID(name)='Sales')
exten => 6502,4,Set(CALLERID(RDNIS)='6502')
exten => 6502,5,Queue(6502)

exten => 6503,1,Answer()
exten => 6503,2,Ringing()
exten => 6503,3,Set(CALLERID(name)='Accounting')
exten => 6503,4,Set(CALLERID(RDNIS)='6503')
exten => 6503,5,Queue(6503)

exten = 6030,1,Queue(6030)

exten => 6504,1,Answer()
;exten => 6504,2,Ringing()
exten => 6504,2,Queue(6504)

exten => 6505,1,Answer()
exten => 6505,2,Ringing()
exten => 6505,3,Queue(6505)

exten => 6506,1,Answer()
exten => 6506,2,Ringing()
exten => 6506,3,Queue(6506)



[voicemenus]
exten = 7001,1,Goto(voicemenu-custom-1,s,1)
exten = 7000,1,Goto(voicemenu-custom-2,s,1)




[voicemailgroups]
[directory]
[page_an_extension]
[pagegroups]
[asterisk_guitools]
exten = executecommand,1,System(${command})
exten = executecommand,n,Hangup()
exten = record_vmenu,1,Answer
exten = record_vmenu,n,Playback(vm-intro)
exten = record_vmenu,n,Record(${var1},0,500,k)
exten = record_vmenu,n,Playback(vm-saved)
exten = record_vmenu,n,Playback(vm-goodbye)
exten = record_vmenu,n,Hangup
exten = play_file,1,Answer
exten = play_file,n,Playback(${var1})
exten = play_file,n,Hangup
[macro-local-callingrule-cid-0.1]
exten = s,1,Set(CALLERID(all)=${IF($[${LEN(${ARG4})} > 2]?${ARG4}:)})
exten = s,n,Goto(${ARG1},${ARG2},${ARG3})

[queue-member-manager]
exten = handle_member,1,Verbose(2, Looping through queues to log in or out queue members)
exten = handle_member,n,Set(thisActiveMember=${CHANNEL(channeltype)}/${CHANNEL(peername)})
exten = handle_member,n,Set(queue_field=2)
exten = handle_member,n,Set(thisQueueXtn=${CUT(QUEUES,\,,${queue_field})})
exten = handle_member,n,While($[${EXISTS(${thisQueueXtn})}])
exten = handle_member,n,Macro(member-loginlogout)
exten = handle_member,n,Set(queue_field=$[${queue_field} + 1])
exten = handle_member,n,Set(thisQueueXtn=${CUT(QUEUES,\,,${queue_field})})
exten = handle_member,n,EndWhile()
[macro-member-loginlogout]
exten = s,1,Verbose(2, Logging queue member in or out of the request queue)
exten = s,n,Set(thisQueue=${thisQueueXtn})
exten = s,n,Set(queueMembers=${QUEUE_MEMBER_LIST(${thisQueue})})
exten = s,n,Set(field=1)
exten = s,n,Set(logged_in=0)
exten = s,n,Set(thisQueueMember=${CUT(queueMembers,\,,${field})})
exten = s,n,While($[${EXISTS(${thisQueueMember})}])
exten = s,n,GotoIf($["${thisQueueMember}" != "${thisActiveMember}"]?check_next)
exten = s,n,Set(logged_in=1)
exten = s,n,ExitWhile()
exten = s,n(check_next),Set(field=$[${field} + 1])
exten = s,n,Set(thisQueueMember=${CUT(queueMembers,\,,${field})})
exten = s,n,EndWhile()
exten = s,n,MacroIf($[${logged_in} = 0]?q_login:q_logout)
[macro-q_login]
exten = s,1,Verbose(2, Logging ${thisActiveMember} into the ${thisQueue} queue)
exten = s,n,AddQueueMember(${thisQueue},${thisActiveMember})
exten = s,n,Playback(silence/1)
exten = s,n,ExecIf($["${AQMSTATUS}" = "ADDED"]?Playback(agent-loginok):Playback(an-error-has-occurred))
[macro-q_logout]
exten = s,1,Verbose(2, Logged ${thisActiveMember} out of ${thisQueue} queue)
exten = s,n,RemoveQueueMember(${thisQueue},${thisActiveMember})
exten = s,n,Playback(silence/1)
exten = s,n,ExecIf($["${RQMSTATUS}" = "REMOVED"]?Playback(agent-loggedoff):Playback(an-error-has-occurred))

[voicemenu-custom-1]
include = default
exten = s,1,NoOp(YC_IVR)
exten = s,2,SayDigits(013344044)
exten = s,3,Goto(queues,6500,1)

[QueueMemberFunctions]
exten => 54,1,Verbose(2,Logging In Queue Member)
same => n,Set(MemberChannel=${CHANNEL(channeltype)}/${CHANNEL(peername)})
same => n,AddQueueMember(6500,${MemberChannel})
same => n,Verbose(1,${AQMSTATUS})  ; ADDED, MEMBERALREADY, NOSUCHQUEUE
same => n,Playback(agent-loginok)
same => n,Hangup()

[DLPN_HyperDialPlan]
include = default
include = parkedcalls
include = conferences
include = ringgroups
include = voicemenus
include = queues
include = voicemailgroups
include = directory
include = pagegroups
include = page_an_extension


[DID_trunk_1]
include = DID_trunk_1_default
[DID_trunk_1_default]
exten = _6500,1,Goto(queues,6500,1)
exten = _X.,1,Goto(default,${EXTEN:_X},1)


[CallingRule_to_BCM]
exten = _8.,1,Macro(trunkdial-failover-0.3,${trunk_1}/${EXTEN:1},,trunk_1,)

[RT_Dialplan]

include = default
include = parkedcalls
include = conferences
include = ringgroups
include = voicemenus
include = queues
include = voicemailgroups
include = directory
include = pagegroups
include = page_an_extension

[voicemenu-custom-2]
exten = s,1,NoOp(YC_IVR_2)
exten = s,2,SayDigits(1)
exten = s,3,Wait(10)
exten = s,4,Busy(10)
exten = s,5,Hangup()

;exten = 1-CONGESTION,n,Hangup()
;exten = 1-out,1,Hangup()

[DID_Audiocodes]
include = DID_Audiocodes_default
[DID_Audiocodes_default]
exten = _6500,1,Goto(queues,6500,1)
[CallingRule_to_PSTN]
exten = _00Z.,1,Macro(trunkdial-failover-0.3,${Audiocodes}/${EXTEN:1},,Audiocodes,)

[CallingRule_GDV_414]
exten = _4140Z.,1,Macro(trunkdial-failover-0.3,${Audiocodes}/${EXTEN:3},,Audiocodes,)

[macro-trunkdial-failover-0.3]
exten = s,1,GotoIf($[${LEN(${FMCIDNUM})} > 6]?1-fmsetcid,1)
exten = s,n,GotoIf($[${LEN(${GLOBAL_OUTBOUNDCIDNAME})} > 1]?1-setgbobname,1)
exten = s,n,Set(CALLERID(num)=${IF($[${LEN(${CID_${CALLERID(num)}})} > 2]?${CID_${CALLERID(num)}}:)})
exten = s,n,Set(CALLERID(all)=${IF($[${LEN(${CID_${CALLERID(num)}})} > 2]?${CID_${CALLERID(num)}}:)})
exten = s,n,GotoIf($[${LEN(${CALLERID(num)})} > 6]?1-dial,1)
exten = s,n,Set(CALLERID(all)=${IF($[${LEN(${CID_${CALLERID(num)}})} > 2]?${CID_${CALLERID(num)}}:)})
exten = s,n,Set(CALLERID(all)=${IF($[${LEN(${CID_${CALLERID(num)}})} > 2]?${CID_${CALLERID(num)}}:)})
exten = s,n,Goto(1-dial,1)
exten = 1-setgbobname,1,Set(CALLERID(name)=${GLOBAL_OUTBOUNDCIDNAME})
exten = 1-setgbobname,n,Goto(s,3)
exten = 1-fmsetcid,1,Set(CALLERID(num)=${FMCIDNUM})
exten = 1-fmsetcid,n,Set(CALLERID(name)=${FMCIDNAME})
exten = 1-fmsetcid,n,Goto(s,4)
exten = 1-dial,1,Dial(${ARG1})
exten = 1-dial,n,Gotoif(${LEN(${ARG2})} > 0 ?1-${DIALSTATUS},1:1-out,1)
exten = 1-CHANUNAVAIL,1,Dial(${ARG2})
exten = 1-CHANUNAVAIL,n,Hangup()
exten = 1-CONGESTION,1,Dial(${ARG2})
exten = 1-CONGESTION,n,Hangup()
exten = 1-out,1,Hangup()
[CallingRule_plus_pstn]
exten = _+.,1,Macro(trunkdial-failover-0.3,${Audiocodes}/00${EXTEN:1},,Audiocodes,)
[DLPN_DialPlan1]
include = CallingRule_to_BCM
include = CallingRule_to_PSTN
include = CallingRule_GDV_414
include = CallingRule_plus_pstn
include = default
include = parkedcalls
include = conferences
include = ringgroups
include = voicemenus
include = queues
include = voicemailgroups
include = directory
include = pagegroups
include = page_an_extension
