[macro-dialout-trunk]
exten => s,1,Set(DIAL_TRUNK=${ARG1})
; If NODEST is set, clear it. No point in remembering since dialout-trunk will just end in the
; bit bucket. But if answered by an outside line with transfer capability, we want NODEST to be
; clear so a subsequent transfer to an internal extension works and goes to voicmail or other
; destinations.
;
exten => s,n,Set(_NODEST=)
exten => s,n,Set(DIAL_NUMBER=${ARG2})
exten => s,n,Set(ROUTE_PASSWD=${ARG3})
exten => s,n,Set(DIAL_TRUNK_OPTIONS=${DIAL_OPTIONS}) // will be reset to TRUNK_OPTIONS if not intra-company
exten => s,n,GotoIf($["${ROUTE_PASSWD}" = ""]?noauth) ; arg3 is pattern password
exten => s,n(auth),Authenticate(${ROUTE_PASSWD})
exten => s,n(noauth),Set(GROUP()=OUT_${DIAL_TRUNK})
exten => s,n,Macro(user-callerid,SKIPTTL)
exten => s,n,Macro(record-enable,${CALLERID(number)},OUT)
exten => s,n,GotoIf($["${INTRACOMPANYROUTE}" = "YES"]?skipoutcid) ;Set to YES if treated like internal
exten => s,n,Set(DIAL_TRUNK_OPTIONS=${TRUNK_OPTIONS})
exten => s,n,Macro(outbound-callerid,${DIAL_TRUNK})
exten => s,n(skipoutcid),GotoIf($["${OUTMAXCHANS_${DIAL_TRUNK}}foo" = "foo"]?nomax)
exten => s,n(checkmax),GotoIf($[ ${GROUP_COUNT()} > ${OUTMAXCHANS_${DIAL_TRUNK}} ]?chanfull)
exten => s,n(nomax),DeadAGI(fixlocalprefix) ; this sets DIAL_NUMBER to the proper dial string for this trunk
exten => s,n,Set(OUTNUM=${OUTPREFIX_${DIAL_TRUNK}}${DIAL_NUMBER}) ; OUTNUM is the final dial number
exten => s,n,Set(custom=${CUT(OUT_${DIAL_TRUNK},:,1)}) ; Custom trunks are prefixed with "AMP:"
exten => s,n,GotoIf($["${custom}" = "AMP"]?customtrunk)
[B];Modifikation, Wenn Trunk = 1 = zap/g0 ist
exten => s,n,NoOp(TRUNK is '${ARG1}')
exten => s,n,GotoIf($["${ARG1}" = "1"]?50) ; Wenn Trunk=1 (zap/g0) dann ueber LCR waehlen[/B]
exten => s,n,Dial(${OUT_${DIAL_TRUNK}}/${OUTNUM},300,${DIAL_TRUNK_OPTIONS}) ; Regular Trunk Dial
exten => s,n,Goto(s-${DIALSTATUS},1)
exten => s,n(customtrunk),Set(pre_num=${CUT(OUT_${DIAL_TRUNK},$,1)})
exten => s,n,Set(the_num=${CUT(OUT_${DIAL_TRUNK},$,2)}) ; this is where we expect to find string OUTNUM
exten => s,n,Set(post_num=${CUT(OUT_${DIAL_TRUNK},$,3)})
exten => s,n,GotoIf($["${the_num}" = "OUTNUM"]?outnum:skipoutnum) ; if we didn't find "OUTNUM", then skip to Dial
exten => s,n(outnum),Set(the_num=${OUTNUM}) ; replace "OUTNUM" with the actual number to dial
exten => s,n(skipoutnum),Dial(${pre_num:4}${the_num}${post_num},300,${DIAL_TRUNK_OPTIONS})
exten => s,n,Goto(s-${DIALSTATUS},1)
[B]exten => s,50,Noop(Wir waehlen jetzt ueber LCR ---------------------------------------------)
exten => s,51,Macro(tsblcr,${OUTNUM},/etc/asterisk/lcr/tsblcr.routing,${AMPUSER},${AMPUSERCIDNAME},ZAP/g0,/etc/asterisk/sip_additional.conf)
exten => s,52,Goto(s-${DIALSTATUS},1)
[/B]
exten => s,n(chanfull),Noop(max channels used up)