[internal]
exten=>2000,1,Answer()
same=>n,Agi(/var/www/html/mysql_class/extensions_list.php)
same=>n(restart),set(i=0)
same=>n,Noop(-------------- Total number of extensions to call $[${lastExten}+1]-------)
same => n,While($["${DIALSTATUS}" != "ANSWER"]) ;; Stop calling once a call is answered.
same => n,NoOp(Calling to extensions : ${${i}} / Status of the last calls ${DIALSTATUS})
same=>n,Dial(PJSIP/${${i}},${${i}_timeout})
same => n,GotoIf($[${i}>=${lastExten}]?restart)
same => n,Set(i=$[${i}+1])
same=>n,Noop(-------------- Next calling extension: ${i} | Total number of extensions to call $[${lastExten}+1] -------)
same => n,EndWhile()
same=>n,hangup()
--------
#!/usr/bin/env php
<?php
require_once(__DIR__."/dbManager.php");
$db = new dbManager(
host: '127.0.0.1',
user: 'root',
password: '786',
db: 'test_db'
);
$extensions = $db->select("SELECT * FROM extensions order by position asc");
echo "Answer\n";
$i=0;
foreach($extensions as $key=>$v){
echo "{$extensions[$key]['number']} {$extensions[$key]['position']}\n";
echo "SET VARIABLE {$i} \"{$extensions[$key]['number']}\"\n";
echo "SET VARIABLE $i"."_timeout \"{$extensions[$key]['timeout']}\"\n";
$i++;
}
$lastExten=(count($extensions)-1);
echo "SET VARIABLE lastExten \"{$lastExten}\"\n";
echo "EXEC Verbose \"Total of extensions to call : from 0 to {$lastExten} \"\n";
?>