Настроено IVR:
3 --> Custom Destinations --> priority-one
2 --> Custom Destinations --> priority-two
1 --> Custom Destinations --> priority-1c
t --> Custom Destinations --> priority-duty
extensions_custom.conf:
Код: Выделить всё
[priority-1c]
exten => 1,1,Set(DEXTEN=${ODBC_CALL_GET_PRIORITY_1C(${CALLERID(num)})});
exten => 1,2,Set(PRIOR_OTHER=${ODBC_CALL_GET_PRIORITY_OTHER(${CALLERID(num)})});
exten => 1,3,ExecIf($["${DEXTEN}" = ""]?Set(DEXTEN=${PRIOR_OTHER});
exten => 1,n,set(timeoutd=20);
exten => 1,n,dial(Local/${DEXTEN}@from-internal,${timeoutd});
exten => 1,5,Gotoif($["${DIALSTATUS}" = "ANSWER"]?Goto(from-trunk,303,1));
exten => 1,4,ExecIf($["${DEXTEN}" = "${DEXTEN}"]?Goto(from-trunk,${DEXTEN},1);
exten => 1,6,Goto(from-trunk,303,1);
Код: Выделить всё
[CALL_GET_PRIORITY_1C] ; Название функции
dsn=asterisk ; DSN имя которое мы указали в файле res_odbc.conf
;Запрос внутреннего номера менеджера по направлению 1С
readsql=SELECT IF ((SELECT num FROM duty limit 1) > 0, (SELECT num FROM duty limit 1), (SELECT 1c FROM trail WHERE number='${ARG1}' OR number=CONCAT("+7",RIGHT('${ARG1}',10))))
Захотел записать данные о завершенных звонках в отдельную таблицу MissedCalls в БД. Таблица создана. Поля определены.
Прописал:
extensions_custom.conf:
Код: Выделить всё
[priority-1c]
exten => 1,1,Set(DEXTEN=${ODBC_CALL_GET_PRIORITY_1C(${CALLERID(num)})});
exten => 1,2,Set(PRIOR_OTHER=${ODBC_CALL_GET_PRIORITY_OTHER(${CALLERID(num)})});
exten => 1,3,ExecIf($["${DEXTEN}" = ""]?Set(DEXTEN=${PRIOR_OTHER});
exten => 1,n,set(timeoutd=20);
exten => 1,n,dial(Local/${DEXTEN}@from-internal,${timeoutd});
exten => 1,5,Gotoif($["${DIALSTATUS}" = "ANSWER"]?Goto(from-trunk,303,1));
exten => 1,4,ExecIf($["${DEXTEN}" = "${DEXTEN}"]?Goto(from-trunk,${DEXTEN},1);
exten => 1,6,Goto(from-trunk,303,1);
exten => h,1, ODBC_CALL_MISSED_WRITE() ='2024-03-27 21:27:44',${CALLERID(num)},'KtoZvonil','KudaZvonil';
same => n,Hangup();
Код: Выделить всё
[CALL_MISSED_WRITE]
dsn=asterisk;
writesql=INSERT INTO MissedCalls (Date, Number, Name, KudaZvonil) VALUES ('${SQL_ESC(${VAL1})}','${SQL_ESC(${VAL2})}','${SQL_ESC(${VAL3})}','${SQL_ESC(${VAL4})}')
Смотрел логи через -rvvvvvvvvvv пишет:
[2024-03-28 08:49:24] WARNING[5510][C-00000021]: pbx.c:4924 pbx_extension_helper: No application 'ODBC_CALL_MISSED_WRITE' for extension (priority-1c, h, 1)
Если выполнить core show function ODBC_CALL_MISSED_WRITE
ответ:
Код: Выделить всё
-= Info about function 'ODBC_CALL_MISSED_WRITE' =-
[Synopsis]
Runs the referenced query with the specified arguments
[Description]
Runs the following query, as defined in func_odbc.conf, performing
substitution of the arguments into the query as specified by ${ARG1},
${ARG2}, ... ${ARGn}. The values are provided either in whole as
${VALUE} or parsed as ${VAL1}, ${VAL2}, ... ${VALn}.
This function may only be set.
SQL:
INSERT INTO MissedCalls (Date, Number, Name, KudaZvonil) VALUES ('${SQL_ESC(${VAL1})}','${SQL_ESC(${VAL2})}','${SQL_ESC(${VAL3})}','${SQL_ESC(${VAL4})}')
[Syntax]
ODBC_CALL_MISSED_WRITE(<arg1>[...[,<argN>]])
[Arguments]
Not available
[See Also]
Not available