;dialplan_centrala_1.conf


[pickup]  ; przejmowanie połączenia przez *8 i numer
exten => _*8XXX,1,Set(GLOBAL(PICKUPMARK)=${EXTEN:2})
same => n,Pickup(${EXTEN:2}@PICKUPMARK)

; demo demo demo

[demo_0]
exten => s,1,Wait,1			; Wait a second, just for fun
exten => s,n,Answer			; Answer the line
exten => s,n,Set(TIMEOUT(digit)=5)	; Set Digit Timeout to 5 seconds
exten => s,n,Set(TIMEOUT(response)=10)	; Set Response Timeout to 10 seconds
exten => s,n(restart),BackGround(demo-congrats)	; Play a congratulatory message
exten => s,n(instruct),BackGround(demo-instruct)	; Play some instructions
exten => s,n,WaitExten		; Wait for an extension to be dialed.

exten => 2,1,BackGround(demo-moreinfo)	; Give some more information.
exten => 2,n,Goto(s,instruct)

exten => 3,1,Set(LANGUAGE()=fr)		; Set language to french
exten => 3,n,Goto(s,restart)			; Start with the congratulations

;exten => 1000,1,Goto(default,s,1)
 
exten => 1234,1,Playback(transfer,skip)		; "Please hold while..." 
					; (but skip if channel is not up)
exten => 1234,n,Macro(stdexten,1234,${CONSOLE})

exten => 1235,1,Voicemail(u1234)		; Right to voicemail

exten => 1236,1,Dial(Console/dsp)		; Ring forever
exten => 1236,n,Voicemail(u1234)		; Unless busy

exten => #,1,Playback(demo-thanks)		; "Thanks for trying the demo"
exten => #,n,Hangup			; Hang them up.

exten => t,1,Goto(#,1)			; If they take too long, give up
exten => i,1,Playback(invalid)		; "That's not valid, try again"


exten => 1000,1,NoOp() ;1000
same => n,Set(CDR(userfield)=(${CHANNEL(recvip)},${CHANNEL(peerip)}))
same => n,Dial(SIP/550@hd-telefonie.avm.de)
same => n,Hangup()

exten => 1001,1,NoOp() ;1001
same => n,Set(CDR(userfield)=(${CHANNEL(recvip)},${CHANNEL(peerip)}))
same => n,Playback(demo-abouttotry); Let them know what's going on
;same => n,Dial(IAX2/guest@misery.digium.com/s@default)	; Call the Asterisk demo
same => n,Dial(IAX2/guest@pbx.digium.com/s@default)	; Call the Asterisk demo
same => n,Playback(demo-nogo)	; Couldn't connect to the demo site
same => n,Goto(s,6)		; Return to the start over message.


exten => 1002,1,NoOp() ;1002
same => n,Set(CDR(userfield)=(${CHANNEL(recvip)},${CHANNEL(peerip)}))
same => n,Playback(demo-echotest)	; Let them know what's going on
same => n,Echo			; Do the echo test
same => n,Playback(demo-echodone)	; Let them know it's over
same => n,Goto(s,6)		; Start over

exten => 1003,1,NoOp() ;1003
same => n,Set(CDR(userfield)=(${CHANNEL(recvip)},${CHANNEL(peerip)}))
same => n,VoicemailMain
same => n,Goto(s,6)

exten => 1004,1,NoOp() ;1004
same => n,Set(CDR(userfield)=(${CHANNEL(recvip)},${CHANNEL(peerip)}))
same => n,Ringing						; poczta glosowa na wesolo
same => n,Wait(0,3)
same => n,Set(CHANNEL(language)=pl)
;exten => 1004,n,Answer()
;exten => 1004,n,Playback(poczta_glosowa_na_wesolo,skip)
;exten => 1004,n,Busy(5)
;exten => 1004,n,Hangup()
;same => n,Goto(demo,8500,1)
same => n,VoiceMailMain()

exten => 1005,1,NoOp()
same => n,Set(CDR(userfield)=(${CHANNEL(recvip)},${CHANNEL(peerip)}))
same => n,Answer
same => n,MusicOnHold(native-random)
same => n,Hangup()

exten => 1006,1,NoOp() ;1006
same => n,Set(CDR(userfield)=(${CHANNEL(recvip)},${CHANNEL(peerip)}))
same => n,Answer
same => n,Playback(beep)
same => n,Wait(0,6)
same => n,Set(CHANNEL(language)=pl)
;exten => 1006,n,Playback(vm-num-i-have)
same => n,Playback(twoj-numer-telefonu-to)
same => n,SayDigits(${CALLERID(number)})
same => n,Busy(5)
same => n,Hangup()

exten => 1007,1,NoOp() ;1007
same => n,Set(CDR(userfield)=(${CHANNEL(recvip)},${CHANNEL(peerip)}))
;exten => 1007,n,Answer
;exten => 1007,n,Dial(IAX2/test:test@autoinstall.pl/*@menu)	; stacje meteo
;exten => 1007,n,Dial(IAX2/test:test@meteo.2o.pl/4)		; stacje meteo
;exten => 1007,n,Dial(IAX2/meteo:meteo@meteo.2o.pl/4)
;exten => 1007,n,Dial(SIP/trunk_tlenofon/223988990,,)
same => n,Dial(SIP/trunk_tlenofon_2/223988990,,)
;exten => 1007,n,Dial(SIP/223988990@trunk_tlenofon)
same => n,Busy(5)
same => n,Hangup()

exten => 1008,1,NoOp() ;1008
same => n,Set(CDR(userfield)=(${CHANNEL(recvip)},${CHANNEL(peerip)}))
same => n,Answer
same => n,Set(CHANNEL(language)=pl)
same => n,Playback(beep)
same => n,Wait(0,6)
same => n,Playback(jest-godzina)
;exten => 1008,n,SayUnixTime(,CET, ABdy IMp)		; SayUnixTime(unixtime,timezone,format) 
;exten => 1008,n,SayUnixTime(,CET,IM)
same => n,SayUnixTime(,CET,R AeBY)
same => n,Busy(5)
same => n,Hangup()

exten => 1009,1,NoOp() ;1009
same => n,Set(CDR(userfield)=(${CHANNEL(recvip)},${CHANNEL(peerip)}))
same => n,Set(CALLFILENAME=${KATALOG_NAGRANIA}test_nagrywania-${EPOCH}-${CALLERID(numer)})
;exten => 1009,n,Set(CALLFILENAME=${KATALOG_NAGRANIA}test_nagrywania-${DATETIME}-${CALLERID(numer)})
same => n,Answer
same => n,Wait(0.2)
same => n,Playback(to-jest-test-nagrywania-po-sygnale-zacznij-mowic)
same => n,Wait(0.3)
same => n,Record(${CALLFILENAME}:wav,0,4)
same => n,Playback(beep)
same => n,Wait(0.3)
same => n,Playback(beep)
same => n,Playback(${CALLFILENAME})
same => n,system(/bin/rm ${CALLFILENAME}.wav)
same => n,Record(${CALLFILENAME}:wav,0,4)
same => n,Playback(beep)
same => n,Wait(0.3)
same => n,Playback(beep)
same => n,Playback(${CALLFILENAME})
same => n,system(/bin/rm ${CALLFILENAME}.wav)
same => n,Record(${CALLFILENAME}:wav,0,4)
same => n,Playback(beep)
same => n,Wait(0.3)
same => n,Playback(beep)
same => n,Playback(${CALLFILENAME})
same => n,system(/bin/rm ${CALLFILENAME}.wav)
same => n,Playback(beep)
same => n,Playback(beep)
same => n,Playback(beep)
same => n,Playback(dziekuje)
same => n,Busy(5)
same => n,Hangup()
;exten => h,1,system(,,/bin/rm ${CALLFILENAME}.wav)

;exten => 1010,1,NoOp() ; parkowanie polaczen w meetme.conf

exten => 1011,1,NoOp() ;1011
same => n,Set(CDR(userfield)=(${CHANNEL(recvip)},${CHANNEL(peerip)}))
same => n,Answer
same => n,Wait(0,2)
same => n,Playback(beep)
same => n,Set(CHANNEL(language)=pl);
;same => n,Set(CHANNEL(language)=en);
;same => n,SayNumber(${SIPCHANINFO(recvip)}})	; czyta setne tylko do pierwszej kropki
;same => n,SayDigits(${SIPCHANINFO(recvip)}})	; czyta cyfry bez kropek
;same => n,SayPhonetic(${SIPCHANINFO(recvip)}})	; w miare po angielsku
;same => n,SayAlpha(${SIPCHANINFO(recvip)}})	; perfekcyjnie po angielsku
;same => n,Playback(num:510|say);
;same => n,Wait(0.5); 
same => n,Wait(0,1)
same => n,Playback(twoj-adres-ip-to)
same => n,Wait(0,1)
same => n,Playback(publiczny)
same => n,Wait(0,1)
same => n,SayAlpha(${CHANNEL(recvip)})
same => n,Wait(0,1)
same => n,Playback(beep)
same => n,Wait(0,1)
same => n,GotoIf($["${CHANNEL(recvip)}" = "${CHANNEL(peerip)}"]?beep)
same => n,Wait(0,1)
same => n,Playback(lokalny)
same => n,Wait(0,1)
same => n,SayAlpha(${CHANNEL(peerip)})
same => n,Wait(0,1)
same => n(beep),Playback(beep)
same => n,Wait(0,5)
same => n,Hangup()

exten => 1012,1,NoOp() ;1012
same => n,Set(CDR(userfield)=(${CHANNEL(recvip)},${CHANNEL(peerip)}))
same => n,Set(CALLFILENAME=${KATALOG_NAGRANIA}call_at_${STRFTIME(${EPOCH},,%Y.%m.%d-%H.%M.%S)}_from_${CALLERID(numer)}_to_${EXTEN})
same => n,MixMonitor(${CALLFILENAME}.wav,,(${SOX} ${CALLFILENAME}.wav ${CALLFILENAME}.${EXT_NAGRANIA})&&(/bin/rm ${CALLFILENAME}.wav))
same => n,Answer
same => n,Set(CHANNEL(language)=pl)
;;exten => 1010,n,Wait(1)
;;exten => 1010,n,Authenticate(0000) 
same => n,Meetme(1010,cx)
;;exten => 1010,n,Playback(vm-goodbye)
same => n,Hangup()

exten => 1013,1,NoOp() ;1013
same => n,Answer()
same => n,MusicOnHold(bajki)
same => n,Hangup()


; połączenia wewnętrzne

[wewnetrzne]
exten => _[2]XX,1,NoOp()
same => n,NoOp(Dzwoni: ${CALLERID(num)})
same => n,Set(CHANNEL(language)=pl)
same => n,Set(CHANNEL(musicclass)=native-random)
same => n,Set(CDR(userfield)=(${CHANNEL(recvip)},${CHANNEL(peerip)}))
same => n,Set(CALLFILENAME=${KATALOG_NAGRANIA}call_at_${STRFTIME(${EPOCH},,%Y.%m.%d-%H.%M.%S)}_from_${CALLERID(numer)}_to_${EXTEN})
same => n,MixMonitor(${CALLFILENAME}.wav,,(${SOX} ${CALLFILENAME}.wav ${CALLFILENAME}.${EXT_NAGRANIA})&&(/bin/rm ${CALLFILENAME}.wav))
same => n,GotoIf($["${EXTERNAL_CALL}" = "1"]?+1:+2)
same => n,SIPAddHeader(Alert-Info: <Bellcore-r1>)
same => n,GotoIf($["${EXTERNAL_CALL}" = "1"]?+2:+1)
same => n,SIPAddHeader(Alert-Info: <Bellcore-r2>)
same => n,NoOp(Kodek: ${SIP_CODEC})
same => n,NoOp(Sip From: ${SIP_HEADER(From)})
same => n,NoOp(Numer: ${CALLERID(num)})
same => n,NoOp(Nazwa: ${CALLERID(name)})
; 200
same => n(mama),NoOp()
same => n(nr_200),GotoIf($["${EXTEN}" = "200"]?+1:end_200)
same => n,Dial(SIP/marysia_1&SIP/marysia_2&SIP/marysia_3,120,rTt)
same => n(end_200),NoOp()
; 201
same => n(nr_201),GotoIf($["${EXTEN}" = "201"]?+1:end_201)
same => n,Dial(SIP/marysia_1,120,rTt)
same => n(end_201),NoOp()
; 202
same => n(nr_202),GotoIf($["${EXTEN}" = "202"]?+1:end_202)

same => n,Dial(SIP/marysia_2,120,rTt)
same => n(end_202),NoOp()
; 203
same => n(nr_203),GotoIf($["${EXTEN}" = "203"]?+1:end_203)
same => n,Dial(SIP/marysia_3,120,rTt)
same => n(end_203),NoOp()
; 204
same => n(nr_204),GotoIf($["${EXTEN}" = "204"]?+1:end_204)
same => n,Set(CHANNEL(secure_bridge_media)=1)
same => n,Set(_SIP_SRTP_SDES=optional)
same => n,Dial(SIP/jacek_4,120,rTt)
same => n(end_204),NoOp()
; 205
same => n(nr_205),GotoIf($["${EXTEN}" = "205"]?+1:end_205)
same => n,Set(CHANNEL(secure_bridge_media)=1)
same => n,Set(_SIP_SRTP_SDES=optional)
same => n,Dial(SIP/jacek_5,120,rTt)
same => n(end_205),NoOp()
; 206
same => n(nr_206),GotoIf($["${EXTEN}" = "206"]?+1:end_206)
same => n,Set(CHANNEL(secure_bridge_media)=1)
same => n,Set(_SIP_SRTP_SDES=optional)
same => n,Dial(SIP/jacek_6,120,rTt)
same => n(end_206),NoOp()
; 210
same => n(nr_210),GotoIf($["${EXTEN}" = "210"]?+1:end_210)
same => n,Dial(SIP/jacek_1&SIP/jacek_2&SIP/jacek_3,120,rTt)
same => n(end_210),NoOp()
; 211
same => n(nr_211),GotoIf($["${EXTEN}" = "211"]?+1:end_211)
same => n,Dial(SIP/jacek_1,120,rTt)
same => n(end_211),NoOp()
; 212
same => n(nr_212),GotoIf($["${EXTEN}" = "212"]?+1:end_212)
same => n,Dial(SIP/jacek_2,120,rTt)
same => n(end_212),NoOp()
; 213
same => n(nr_213),GotoIf($["${EXTEN}" = "213"]?+1:end_213)
same => n,Dial(SIP/jacek_3,120,rTt)
same => n(end_213),NoOp()
; 215
same => n(nr_215),GotoIf($["${EXTEN}" = "215"]?+1:end_215)
same => n,Dial(SIP/maciek_1,120,rTt)
same => n(end_215),NoOp()
; 220
same => n(nr_220),GotoIf($["${EXTEN}" = "220"]?+1:end_220)
same => n,Dial(SIP/ichem_1&SIP/ichem_2&SIP/ichem_3,120,rTt)
same => n(end_220),NoOp()
; 221
same => n(nr_221),GotoIf($["${EXTEN}" = "221"]?+1:end_221)
same => n,Dial(SIP/ichem_1,120,rTt)
same => n(end_221),NoOp()
; 222
same => n(nr_222),GotoIf($["${EXTEN}" = "222"]?+1:end_222)
same => n,Dial(SIP/ichem_2,120,rTt)
same => n(end_222),NoOp()
; 223
same => n(nr_223),GotoIf($["${EXTEN}" = "223"]?+1:end_223)
same => n,Dial(SIP/ichem_3,120,rTt)
same => n(end_223),NoOp()
; 225
same => n(nr_225),GotoIf($["${EXTEN}" = "225"]?+1:end_225)
same => n,Dial(SIP/wola_1,120,rTt)
same => n(end_225),NoOp()
; 235
same => n(nr_235),GotoIf($["${EXTEN}" = "235"]?+1:end_235)
same => n,Dial(SIP/kusztale_1,120,rTt)
same => n(end_235),NoOp()
; 240
same => n(nr_240),GotoIf($["${EXTEN}" = "240"]?+1:end_240)
same => n,Dial(SIP/ksawerow_1&SIP/ksawerow_2,120,rTt)
same => n(end_240),NoOp()
; 241
same => n(nr_241),GotoIf($["${EXTEN}" = "241"]?+1:end_241)
same => n,Dial(SIP/ksawerow_1,120,rTt)
same => n(end_241),NoOp()
; 242
same => n(nr_242),GotoIf($["${EXTEN}" = "242"]?+1:end_242)
same => n,Dial(SIP/ksawerow_2,120,rTt)
same => n(end_242),NoOp()
; 245
same => n(nr_245),GotoIf($["${EXTEN}" = "245"]?+1:end_245)
same => n,Dial(SIP/marcin_1,120,rTt)
same => n(end_245),NoOp()
; 250
same => n(nr_250),GotoIf($["${EXTEN}" = "250"]?+1:end_250)
same => n,Dial(SIP/tomek_1,120,rTt)
same => n(end_250),NoOp()
; 251
same => n(251),GotoIf($["${EXTEN}" = "251"]?+1:end_251)
same => n,GoTo(out_ipfon2,422094870,1)
same => n(end_251),NoOp()
; 255
same => n(nr_255),GotoIf($["${EXTEN}" = "255"]?+1:end_255)
same => n,Dial(SIP/retkinia_1&SIP/retkinia_2,120,rTt)
same => n(end_255),NoOp()
; 256
same => n(nr_256),GotoIf($["${EXTEN}" = "256"]?+1:end_256)
same => n,Dial(SIP/retkinia_1,120,rTt)
same => n(end_256),NoOp()
; 257
same => n(nr_257),GotoIf($["${EXTEN}" = "257"]?+1:end_257)
same => n,Dial(SIP/retkinia_2,120,rTt)
same => n(end_257),NoOp()
same => n,NoOp(Dial Status: ${DIALSTATUS})
same => n,GotoIf($["${EXTERNAL_CALL}" = "1"]?hangup:komunikaty)
same => n(komunikaty),Goto(komunikaty,komunikat-${DIALSTATUS},1)
same => n(hangup),Hangup()



; rozmowy przychodzace

[z_ipfonu]
exten => s,1,NoOp()
same => n,NoOp(${SIP_HEADER(To)})
same => n,NoOp(Do: DDI_NUMER=${CUT(CUT(SIP_HEADER(To),@,1),:,2)})
same => n,NoOp(Via: ${SIP_HEADER(Via)})
same => n,NoOp(Alert-Info: ${SIP_HEADER(Alert-Info)})
same => n,Set(EXTERNAL_CALL=1)
same => n,Set(NAZWA_CID=${IF($[$[ "${CALLERID(num)}" = "Unknown" ] | [ "${CALLERID(num)}" = "" ]]?"Brak Numeru":${CALLERID(num)})})
same => n,Set(CALLERID(num)=${IF($[$[ "${CALLERID(num)}" = "Unknown" ] | [ "${CALLERID(num)}" = "" ]]?"Brak Numeru":${CALLERID(num)})})
;
same => n,GotoIf($["${REGEX("426739137" ${CUT(CUT(SIP_HEADER(To),@,1),:,2)})}" = "1"]?+1:+3)
same => n,Set(CALLERID(name)=${NAZWA_CID} IPFon)
;same => n,GoTo(wewnetrzne,200,1)
same => n,GoTo(wewnetrzne,220,1)
;
same => n,GotoIf($["${REGEX("422996294" ${CUT(CUT(SIP_HEADER(To),@,1),:,2)})}" = "1"]?+1:+3)
same => n,Set(CALLERID(name)=${NAZWA_CID} IPFon)
same => n,GoTo(wewnetrzne,210,1)
;
same => n,GotoIf($["${REGEX("422884849" ${CUT(CUT(SIP_HEADER(To),@,1),:,2)})}" = "1"]?+1:+3)
same => n,Set(CALLERID(name)=${NAZWA_CID} IPFon)
same => n,GoTo(wewnetrzne,255,1)
;
same => n,Wait(1)
same => n,Hangup()



; numery alarmowe
; 112 - ogólny numer alarmowy
; 911 - amerykański numer alarmowy
; 984 - Pogotowie Rzeczne,
; 985 - Ratownictwo Morskie i Gorskie
; 986 - straz miejska
; 987 - woj. zarzdzanie kryzysowe
; 989 - info o szczepieniach
; 991 - pogotowie energetyczne,
; 992 - pogotowie gazowe
; 993 - pogotowie cieplownicaze, 
; 994 - pogotowie wodno-kanalizacyjne,
; 997 - policja, 
; 998 - straz pozarna,
; 998 - pogotowie ratunkowe

[numery_alarmowe_via_ipfon1]
exten => 112,1,NoOp()
same => n,Set(CDR(userfield)=(${CHANNEL(recvip)},${CHANNEL(peerip)}))
same => n,Set(CALLFILENAME=${KATALOG_NAGRANIA}call_at_${STRFTIME(${EPOCH},,%Y.%m.%d-%H.%M.%S)}_from_${CALLERID(numer)}_to_${EXTEN})
same => n,MixMonitor(${CALLFILENAME}.wav,,(${SOX} ${CALLFILENAME}.wav ${CALLFILENAME}.${EXT_NAGRANIA})&&(/bin/rm ${CALLFILENAME}.wav))
same => n,Dial(SIP/trunk_ipfon1/${EXTEN})
same => n,Hangup
exten => _98[4-79],1,NoOp()
same => n,Set(CDR(userfield)=(${CHANNEL(recvip)},${CHANNEL(peerip)}))
same => n,Set(CALLFILENAME=${KATALOG_NAGRANIA}call_at_${STRFTIME(${EPOCH},,%Y.%m.%d-%H.%M.%S)}_from_${CALLERID(numer)}_to_${EXTEN})
same => n,MixMonitor(${CALLFILENAME}.wav,,(${SOX} ${CALLFILENAME}.wav ${CALLFILENAME}.${EXT_NAGRANIA})&&(/bin/rm ${CALLFILENAME}.wav))
same => n,Dial(SIP/trunk_ipfon1/${EXTEN})
same => n,Hangup
exten => _99[1-47-9],1,NoOp()
same => n,Set(CDR(userfield)=(${CHANNEL(recvip)},${CHANNEL(peerip)}))
same => n,Set(CALLFILENAME=${KATALOG_NAGRANIA}call_at_${STRFTIME(${EPOCH},,%Y.%m.%d-%H.%M.%S)}_from_${CALLERID(numer)}_to_${EXTEN})
same => n,MixMonitor(${CALLFILENAME}.wav,,(${SOX} ${CALLFILENAME}.wav ${CALLFILENAME}.${EXT_NAGRANIA})&&(/bin/rm ${CALLFILENAME}.wav))
same => n,Dial(SIP/trunk_ipfon1/${EXTEN})
same => n,Hangup

[numery_alarmowe_via_ipfon2]
exten => 112,1,NoOp()
same => n,Set(CDR(userfield)=(${CHANNEL(recvip)},${CHANNEL(peerip)}))
same => n,Set(CALLFILENAME=${KATALOG_NAGRANIA}call_at_${STRFTIME(${EPOCH},,%Y.%m.%d-%H.%M.%S)}_from_${CALLERID(numer)}_to_${EXTEN})
same => n,MixMonitor(${CALLFILENAME}.wav,,(${SOX} ${CALLFILENAME}.wav ${CALLFILENAME}.${EXT_NAGRANIA})&&(/bin/rm ${CALLFILENAME}.wav))
same => n,Dial(SIP/trunk_ipfon2/${EXTEN})
same => n,Hangup
exten => _98[4-79],1,NoOp()
same => n,Set(CDR(userfield)=(${CHANNEL(recvip)},${CHANNEL(peerip)}))
same => n,Set(CALLFILENAME=${KATALOG_NAGRANIA}call_at_${STRFTIME(${EPOCH},,%Y.%m.%d-%H.%M.%S)}_from_${CALLERID(numer)}_to_${EXTEN})
same => n,MixMonitor(${CALLFILENAME}.wav,,(${SOX} ${CALLFILENAME}.wav ${CALLFILENAME}.${EXT_NAGRANIA})&&(/bin/rm ${CALLFILENAME}.wav))
same => n,Dial(SIP/trunk_ipfon2/${EXTEN})
same => n,Hangup
exten => _99[1-47-9],1,NoOp()
same => n,Set(CDR(userfield)=(${CHANNEL(recvip)},${CHANNEL(peerip)}))
same => n,Set(CALLFILENAME=${KATALOG_NAGRANIA}call_at_${STRFTIME(${EPOCH},,%Y.%m.%d-%H.%M.%S)}_from_${CALLERID(numer)}_to_${EXTEN})
same => n,MixMonitor(${CALLFILENAME}.wav,,(${SOX} ${CALLFILENAME}.wav ${CALLFILENAME}.${EXT_NAGRANIA})&&(/bin/rm ${CALLFILENAME}.wav))
same => n,Dial(SIP/trunk_ipfon2/${EXTEN})
same => n,Hangup

[numery_alarmowe_via_ipfon3]
exten => 112,1,NoOp()
same => n,Set(CDR(userfield)=(${CHANNEL(recvip)},${CHANNEL(peerip)}))
same => n,Set(CALLFILENAME=${KATALOG_NAGRANIA}call_at_${STRFTIME(${EPOCH},,%Y.%m.%d-%H.%M.%S)}_from_${CALLERID(numer)}_to_${EXTEN})
same => n,MixMonitor(${CALLFILENAME}.wav,,(${SOX} ${CALLFILENAME}.wav ${CALLFILENAME}.${EXT_NAGRANIA})&&(/bin/rm ${CALLFILENAME}.wav))
same => n,Dial(SIP/trunk_ipfon3/${EXTEN})
same => n,Hangup
exten => _98[4-79],1,NoOp()
same => n,Set(CDR(userfield)=(${CHANNEL(recvip)},${CHANNEL(peerip)}))
same => n,Set(CALLFILENAME=${KATALOG_NAGRANIA}call_at_${STRFTIME(${EPOCH},,%Y.%m.%d-%H.%M.%S)}_from_${CALLERID(numer)}_to_${EXTEN})
same => n,MixMonitor(${CALLFILENAME}.wav,,(${SOX} ${CALLFILENAME}.wav ${CALLFILENAME}.${EXT_NAGRANIA})&&(/bin/rm ${CALLFILENAME}.wav))
same => n,Dial(SIP/trunk_ipfon3/${EXTEN})
same => n,Hangup
exten => _99[1-47-9],1,NoOp()
same => n,Set(CDR(userfield)=(${CHANNEL(recvip)},${CHANNEL(peerip)}))
same => n,Set(CALLFILENAME=${KATALOG_NAGRANIA}call_at_${STRFTIME(${EPOCH},,%Y.%m.%d-%H.%M.%S)}_from_${CALLERID(numer)}_to_${EXTEN})
same => n,MixMonitor(${CALLFILENAME}.wav,,(${SOX} ${CALLFILENAME}.wav ${CALLFILENAME}.${EXT_NAGRANIA})&&(/bin/rm ${CALLFILENAME}.wav))
same => n,Dial(SIP/trunk_ipfon3/${EXTEN})
same => n,Hangup


; trunk do Maćka centrali

[to-maciek]
exten => _6[0-8][01567],1,NoOp()
same => n,NoOp(Dzwoni: ${CALLERID(num)})
same => n,Set(CHANNEL(musicclass)=native-random)
same => n,Set(CDR(userfield)=(${CHANNEL(recvip)},${CHANNEL(peerip)}))
same => n,Set(CALLFILENAME=${KATALOG_NAGRANIA}call_at_${STRFTIME(${EPOCH},,%Y.%m.%d-%H.%M.%S)}_from_${CALLERID(numer)}_to_${EXTEN})
same => n,MixMonitor(${CALLFILENAME}.wav,,(${SOX} ${CALLFILENAME}.wav ${CALLFILENAME}.${EXT_NAGRANIA})&&(/bin/rm ${CALLFILENAME}.wav))
same => n,Dial(IAX2/trunk-iax2-centrala-to-macieks/${EXTEN})
same => n,Hangup()


; specjalne numery techniczne, stany kont

[stany_kont]
exten => _56[78],1,NoOp()  ; sprawdzanie stanu konta
same => n,Set(CDR(userfield)=(${CHANNEL(recvip)},${CHANNEL(peerip)}))
same => n,Set(CALLERID(num)=jomanski001)
same => n,Set(CALLERID(name)=jomanski001)
same => n,Dial(SIP/trunk_ipfon1/${EXTEN},,r)
same => n,Goto(komunikaty,komunikat-${DIALSTATUS},1)
same => n,Hangup()


; wyjscie na miasto

[out_ipfon1]
exten => _XXXX.,1,NoOp()
same => n,NoOp(Dzwoni: ${CALLERID(num)})
same => n,Set(CHANNEL(language)=pl)
same => n,Set(CALLFILENAME=${KATALOG_NAGRANIA}call_at_${STRFTIME(${EPOCH},,%Y.%m.%d-%H.%M.%S)}_from_${CALLERID(numer)}_to_${EXTEN})
same => n,Set(CALLERID(num)=jomanski001)
same => n,Set(CALLERID(name)=jomanski001)
same => n,Set(CDR(userfield)=(${CHANNEL(recvip)},${CHANNEL(peerip)}))
same => n,MixMonitor(${CALLFILENAME}.wav,,(${SOX} ${CALLFILENAME}.wav ${CALLFILENAME}.${EXT_NAGRANIA})&&(/bin/rm ${CALLFILENAME}.wav))
same => n,Dial(SIP/trunk_ipfon1/${EXTEN},,Tt)
same => n,GotoIf($["${DIALSTATUS}" = "ANSWER"]?koniec)
same => n,GotoIf($["${DIALSTATUS}" = "BUSY"]?komunikaty)
same => n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?komunikaty:koniec)
same => n(komunikaty),Goto(komunikaty,komunikat-${DIALSTATUS},1)
same => n(koniec),Hangup()

[out_ipfon2]
exten => _XXXX.,1,NoOp()
same => n,NoOp(Dzwoni: ${CALLERID(num)})
same => n,Set(CHANNEL(language)=pl)
same => n,Set(CALLFILENAME=${KATALOG_NAGRANIA}call_at_${STRFTIME(${EPOCH},,%Y.%m.%d-%H.%M.%S)}_from_${CALLERID(numer)}_to_${EXTEN})
same => n,Set(CALLERID(num)=jomanski003)
same => n,Set(CALLERID(name)=jomanski003)
same => n,Set(CDR(userfield)=(${CHANNEL(recvip)},${CHANNEL(peerip)}))
same => n,MixMonitor(${CALLFILENAME}.wav,,(${SOX} ${CALLFILENAME}.wav ${CALLFILENAME}.${EXT_NAGRANIA})&&(/bin/rm ${CALLFILENAME}.wav))
same => n,Dial(SIP/trunk_ipfon2/${EXTEN},,Tt)
same => n,GotoIf($["${DIALSTATUS}" = "ANSWER"]?koniec)
same => n,GotoIf($["${DIALSTATUS}" = "BUSY"]?komunikaty)
same => n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?komunikaty:koniec)
same => n(komunikaty),Goto(komunikaty,komunikat-${DIALSTATUS},1)
same => n(koniec),Hangup()

[out_ipfon3]
exten => _XXXX.,1,NoOp()
same => n,NoOp(Dzwoni: ${CALLERID(num)})
same => n,Set(CHANNEL(language)=pl)
same => n,Set(CALLFILENAME=${KATALOG_NAGRANIA}call_at_${STRFTIME(${EPOCH},,%Y.%m.%d-%H.%M.%S)}_from_${CALLERID(numer)}_to_${EXTEN})
same => n,Set(CALLERID(num)=jomanski006)
same => n,Set(CALLERID(name)=jomanski006)
same => n,Set(CDR(userfield)=(${CHANNEL(recvip)},${CHANNEL(peerip)}))
same => n,MixMonitor(${CALLFILENAME}.wav,,(${SOX} ${CALLFILENAME}.wav ${CALLFILENAME}.${EXT_NAGRANIA})&&(/bin/rm ${CALLFILENAME}.wav))
same => n,Dial(SIP/trunk_ipfon3/${EXTEN},,Tt)
same => n,GotoIf($["${DIALSTATUS}" = "ANSWER"]?koniec)
same => n,GotoIf($["${DIALSTATUS}" = "BUSY"]?komunikaty)
same => n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?komunikaty:koniec)
same => n(komunikaty),Goto(komunikaty,komunikat-${DIALSTATUS},1)
same => n(koniec),Hangup()



; połączenia przychodzące z trunków IAX2-owych


[from-trunk-iax2-macieks-to-centrala]
include => wewnetrzne



; techniczne

[extended_CDR]
exten => h,1,noop("extended CDR")
same => n,set(CDR(hangupcause)=${HANGUPCAUSE})
same => n,set(CDR(peerip)=${CHANNEL(peerip)})
same => n,set(CDR(recvip)=${CHANNEL(recvip)})
same => n,set(CDR(from,s)=${CHANNEL(from)})
same => n,set(CDR(uri)=${CHANNEL(uri)})
same => n,set(CDR(useragent)=${CHANNEL(useragent)})
same => n,set(CDR(codec1)=${CHANNEL(audioreadformat)})
same => n,set(CDR(codec2)=${CHANNEL(audiowriteformat)})


[ostrzeganie]
exten => _80Z.,1,Progress()
exten => _80Z.,n,Playback(uwaga_polaczenie_o_podwyzszonej_oplacie,noanswer)
exten => _80Z.,n,Wait(5)
exten => _80Z.,n,Playback(beep)
exten => _70X.,1,Progress()
exten => _70X.,n,Playback(uwaga_polaczenie_o_podwyzszonej_oplacie,noanswer)
exten => _70X.,n,Wait(5)
exten => _70X.,n,Playback(beep)


[komunikaty]
exten => komunikat-BUSY,1,Set(CHANNEL(language)=pl)
exten => komunikat-BUSY,n,Playback(numer-jest-zajety-sprobuj-pozniej)
exten => komunikat-BUSY,n,Busy(5)
exten => komunikat-BUSY,n,Hangup()
exten => komunikat-CONGESTION,1,Set(CHANNEL(language)=pl)
exten => komunikat-CONGESTION,n,Congestion(5)
exten => komunikat-CONGESTION,n,Hangup()
exten => komunikat-CHANUNAVAIL,1,Set(CHANNEL(language)=pl)
;exten => komunikat-CHANUNAVAIL,n,Playback(nie-ma-takiego-numeru-lub-numer-jest-nieosiagalny,noanswer)
exten => komunikat-CHANUNAVAIL,n,Playback(nie-ma-takiego-numeru-lub-numer-jest-nieosiagalny)
exten => komunikat-CHANUNAVAIL,n,Congestion(5)
;exten => komunikat-CHANUNAVAIL,n,Busy(5)
exten => komunikat-CHANUNAVAIL,n,Hangup()
exten => komunikat-NOANSWER,1,Set(CHANNEL(language)=pl)
exten => komunikat-NOANSWER,n,Playback(,noanswer)
exten => komunikat-NOANSWER,n,Hangup()


[blokady]
exten => _6.,1,Goto(blok,1)
exten => _7.,1,Goto(blok,1)
exten => _8.,1,Goto(blok,1)
exten => _X.,1,Goto(blok,1)
exten => blok,1,NoCDR()
exten => blok,n,Set(CHANNEL(language)=pl)
exten => blok,n,Answer
exten => blok,n,Wait(0,2)
exten => blok,n,Playback(beep)
exten => blok,n,Wait(0,5)
exten => blok,n,Playback(numer-jest-zablokowany,noanswer)
exten => blok,n,Busy(5)
exten => blok,n,Hangup()



; konteksty zbiorcze

[rokicie]
include => numery_alarmowe_via_ipfon3
include => wewnetrzne
include => pickup
include => demo_0
include => to-maciek
;include => stany_kont
include => ostrzeganie
include => out_ipfon3
include => komunikaty
include => blokady
include => extended_CDR


[retkinia]
include => numery_alarmowe_via_ipfon2
include => wewnetrzne
include => pickup
include => demo_0
include => to-maciek
;include => stany_kont
include => ostrzeganie
include => out_ipfon2
include => komunikaty
include => blokady
include => extended_CDR


[jackowe]
include => numery_alarmowe_via_ipfon1
include => wewnetrzne
include => pickup
include => demo_0
include => to-maciek
;include => stany_kont
include => ostrzeganie
include => out_ipfon1
include => komunikaty
include => blokady
include => extended_CDR


[internal_only]
include => wewnetrzne
include => pickup
include => demo_0
include => to-maciek
include => komunikaty
include => blokady
include => extended_CDR


[ksawerow]
include => numery_alarmowe_via_ipfon1
include => wewnetrzne
include => pickup
include => demo_0
include => to-maciek
;include => stany_kont
include => ostrzeganie
;include => out_ipfon1
include => komunikaty
include => blokady
include => extended_CDR




;------------------------------------------------------------

; testy

[test1]
exten => _10X,1,NoOp()
same => n,NoOp(${SIPPEER(${EXTEN},srtpcapable)})
same => n,NoOp(${SIPPEER(${EXTEN},callerid_name)})
same => n,NoOp(Czy dzwoniacy uzywa TLS / secure_signaling: ${CHANNEL(secure_signaling)})
same => n,NoOp(Czy dzwoniacy uzywa SRTP / secure_media: ${CHANNEL(secure_media)})
;same => n,GotoIf($["${CHANNEL(secure_signaling)}" = "1"]?+1:fail)
;same => n,GotoIf($["${CHANNEL(secure_media)}" = "1"]?+1:fail)
; bledna skladnia same => n,Set(is_secure=$[${CHANNEL(secure_signaling)} & ${CHANNEL(secure_media)}])
;;same => n,NoOp(All_Secure: ${is_secure})
;;same => n,Set(CHANNEL(secure_bridge_signaling)=1) ; wymuszenie TLS
;;same => n,Set(CHANNEL(secure_bridge_media)=1) ; wymuszenie SRTP
;;same => n,Dial(SIP/${EXTEN:0}&SCCP/${EXTEN:0},120,Tt)
;;same => n,Set(CHANNEL(secure_bridge_signaling)=1)
;;same => n,Set(CHANNEL(secure_bridge_media)=0)
;;same => n,Dial(SIP/${EXTEN:0}&SCCP/${EXTEN:0},120,Tt)
;;same => n,Set(CHANNEL(secure_bridge_signaling)=0)
;;same => n,Set(CHANNEL(secure_bridge_media)=1)
;;same => n,Dial(SIP/${EXTEN:0}&SCCP/${EXTEN:0},120,Tt)
;;same => n,Set(CHANNEL(secure_bridge_signaling)=0)
;;same => n,Set(CHANNEL(secure_bridge_media)=0)
;same => n,Wait(1)
same => n,Dial(SIP/${EXTEN:0}&SCCP/${EXTEN:0},120,Tt)
same => n,Hangup()
;same => n(fail),Playback(vm-goodbye, noanswear)
;same => n,Hangup

include => extended_CDR
;
;------------------------------------------------------------
