Call the company from your mobile and dial an extension to call a third-party company







Important points
Last updated
Was this helpful?
Was this helpful?
<?php
namespace MikoPBX\Core\System;
require_once('Globals.php');
use MikoPBX\Common\Models\ExternalPhones;
use MikoPBX\Core\Asterisk\AGI;
use Phalcon\Mvc\Model\Resultset;
$agi = new AGI();
$number = substr($agi->request['agi_callerid'],-10);
if(strlen($number) < 7){
$agi->noop('Count < 7');
//Checking for the length of the number.
exit(0);
}
$outPhone = ExternalPhones::findFirst([
'conditions' => 'dialstring LIKE :number:',
'bind' => [
'number' => "%$number",
],
'hydration' => Resultset::HYDRATE_ARRAYS,
]);
if(count($outPhone) !== 1){
$agi->noop('ExternalPhones not found '.$number);
// Checking whether the phone number belongs to an employee of the company.
exit(0);
}
$agi->set_variable('AGIEXITONHANGUP', 'yes');
$agi->set_variable('AGISIGHUP', 'yes');
$agi->set_variable('__ENDCALLONANSWER', 'yes');
$agi->exec('Ringing', '');
$agi->Answer();
$result = $agi->getData('vm-enter-num-to-call', 3000, 11);
$selectednum = $result['result']??'';
if(!empty($selectednum)){
// Everything is OK. Ending the call.
$agi->set_variable('__pt1c_UNIQUEID', '');
$agi->exec(
'Dial',
"Local/{$selectednum}@all_peers/n,300," . 'TtekKHhU(dial_answer)b(dial_create_chan,s,1)'
);
}else{
$agi->noop('selectednum is empty');
}[add-trim-prefix-clid-custom]
exten => _.!,1,ExecIf($[ "${EXTEN}" == "h" ]?Hangup()
same => n,AGI(«DIALPLAN-APP-6A9902C631C5E7B5AC8F501C559FD678.php)
same => n,Return()