[dynamic_did]
exten => _X.,1,Set(CHANNEL(language)=he)
exten => _X.,n,Set(CALLID=${CALLERID(num)})
exten => _X.,n,MYSQL(Connect connidcdr localhost user pass asteriskcdrdb utf8)
exten => _X.,n,MYSQL(Query resultidcdr ${connidcdr} SELECT calldate,src,dst,disposition FROM cdr WHERE dst LIKE '%${CALLID}%' AND calldate > ( now() - interval 2 hour) AND disposition = "NO ANSWER" ORDER BY calldate DESC)
exten => _X.,n,MYSQL(Fetch fetchid ${resultidcdr} calldate src dst)
exten => _X.,n,NoOp( calldate=${calldate} and src=${src} and dst=${dst} )
exten => _X.,n,Set(number=${src})
exten => _X.,n,NoOp(caller --> ${src} callee --> ${dst})
exten => _X.,n,GOTOIF($["${dst}" = ""]?nodst:dst)
exten => _X.,n(dst),MYSQL(Clear ${resultidcdr})
exten => _X.,n,MYSQL(Disconnect ${connidcdr})
exten => _X.,n,Gosub(sub-record-check,s,1(${EXTEN}))
exten => _X.,n,Dial(SIP/${number},20,tT)
exten => _X.,n,GotoIf($["${DIALSTATUS}" = "BUSY"]?nodst)
exten => _X.,n,GotoIf($["${DIALSTATUS}" = "NOANSWER"]?nodst)
exten => _X.,n,GotoIf($["${DIALSTATUS}" = "FAILED"]?nodst)
exten => _X.,n(nodst),MYSQL(Clear ${resultidcdr})
exten => _X.,n,MYSQL(Disconnect ${connidcdr})
exten => _X.,n,Goto(from-trunk,${DID},1)
exten => h,1,hangup()