[from-pstn]
exten => _X.,1,Verbose(Llamada entrante desde la PSTN ${CHANNEL(peername)} al número ${EXTEN})
same => n,Set(CDR(type)=incoming)
same => n,Set(CDR(src_callerid)=${CALLERID(num)})
same => n,Set(CDR(dst_dialed)=${EXTEN})
same => n,Gosub(sub_geolocation_caller,start,1)
same => n,Set(ARRAY(EMPRESA,DIDCUSTOM,DIDID)=${ODBC_DIDEMPRESA(${EXTEN})})
same => n,GotoIf($[${EXISTS(${EMPRESA})}]?:noasignado,1)
same => n,Set(CDR(dst_company)=${EMPRESA})
same => n,Verbose(El DID está asignado a la empresa ${EMPRESA})
same => n,GoSub(sub_record_call,start,1(${EMPRESA},${CDR(type)},${EXTEN},${CALLERID(num)}))
same => n,GotoIf($["${DIDCUSTOM}" == "1"]?sub_custom_${EMPRESA}_${EXTEN},start,1)
same => n,Set(IDTRATAMIENTO=${ODBC_DIDCONFIGURED(${DIDID})})
same => n,GotoIf($[${EXISTS(${IDTRATAMIENTO})}]?:notratamiento,1)
same => n,Agi(peke_processing.php,${IDTRATAMIENTO})
same => n,GotoIf($[${EXISTS(${PROMPT})}]?:destino)
same => n,Playback(${SOUNDPATH}/${EMPRESA}/${PROMPT})
same => n(destino),GoSub(sub_destination,start,1(${EMPRESA},${DESTINATION}))
exten => noasignado,1,Verbose(DID no encontrado o no asignado a empresa)
same => n,Hangup()
exten => notratamiento,1,Verbose(DID no está configurado)
same => n,Hangup()