[context]
exten => _X.,1,ExecIF($["${DB_EXISTS(dial/count)}" = "0"]?Set(DB(dial/count)=0))
same => n,Set(DB(dial/count)=${IF($[${DB(dial/count)} > 24]?1:$[${DB(dial/count)} +1])})
same => n,Dial(SIP/${EXTEN}@sip${DB(dial/count)},,tT))
same => n,Hangup
[ext-queues]
exten => h,1,GotoIf($["${QUEUESTATUS}"="CONTINUE"]?answered)
same => n,ExecIf($["${CDR(dstchannel)}"=""]?System(/usr/local/bin/sendEmail.pl -f missedcall@kkinfo.ru -t kk-lab@mail.ru -u "Пропущенный звонок" -m "Пропущен звонок из очереди с номера ${CALLERID(num)}" -s smtp.gmail.com:587 -xu mail@mail.su -xp pass -o tls=yes -o message-charset=UTF-8)
same => n(answered),Macro(hangupcall,)
SELECT `r`.`id`, `r`.`name`, `r`.`description`
FROM `recept`
LEFT JOIN (
SELECT DISTINCT `cr`.`parent_id` AS `parent_id`
FROM `component_recept` AS `cr`
LEFT JOIN (
SELECT `parent_id`
FROM `user_component`
WHERE `user_id` = :uid
) AS `uc` ON `uc`.`parent_id` = `cr`.`parent_id`
WHERE `uc`.`parent_id` IS NULL
) AS `xr` ON `xr`.`parent_id` = `r`.`id`
WHERE `xr`.`parent_id` IS NULL