d2c7a03f by G Manojkumar

Merge branch 'dev-transfer-call' of http://54.197.18.130/flexydial/hdfc-vrm-v2

2 parents 5b50cf38 d86adf97
Showing 1000 changed files with 4614 additions and 41 deletions

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

<?php namespace App\Console\Commands;
use Illuminate\Console\Command;
//use Mail;
use DB;
use Config;
use App\Models\User;
use App\Models\Accesslog;
use App\Models\CRMCall;
use Schema;
use PDO;
use App\Models\Notification;
use App\Jobs\KHRMSLib;
use Input;
use Log;
use App\Models\Sipid;
use App\Models\Kqueue;
use App\Models\Dialline;
use App\Models\Session;
use App\Models\Cutoff;
use Illuminate\Database\Schema\Blueprint;
class CreateCall extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'CreateCall';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create Pedictive Call If any User is Free';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
while(true)
{
usleep(1000000);
$this->runPredictive();
}
}
public function runPredictive()
{
try {
$this->updatePrepareColumn();
$usrArrs = $this->getActiveUsersCampaignWise("with");
$availChannel = $this->getActualAvailChannelCount();
if(count($usrArrs)){
//Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
//Log::info($usrArrs);
//Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
//Log::info("Channel=".$availChannel);
foreach ($usrArrs as $client => $usrArr) {
//Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
//Log::info("campaign=".$client);
$acalls = $this->getCreateCallCount($client, count($usrArr));
$acalls = min($acalls, $availChannel);
//Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
//Log::info("CallCount=".$acalls);
$this->CreateCall($client, $acalls);
}
}
} catch (Exception $e) {
Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
Log::error($e);
continue;
}
}
public function updatePrepareColumn()
{
$allClientUsrIdArr = array();
$updatedUserIdArr = array();
$currentTime = strtotime(date("Y-m-d H:i:s"));
$clientWiseUserIdArr = $this->getActiveUsersCampaignWise("without");
if(count($clientWiseUserIdArr)) {
//Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
//Log::info("updatePrepareColumn");Log::info($clientWiseUserIdArr);
foreach ($clientWiseUserIdArr as $client => $usrIdArr) {
$allClientUsrIdArr = array_merge($allClientUsrIdArr, $usrIdArr);
}
$usersTimeArr = Cutoff::whereIn('user_id', $allClientUsrIdArr)->get();
foreach ($usersTimeArr as $userTimeArr) {
$cutOffTime = strtotime($userTimeArr->hangup_time) + ($userTimeArr->avg_dispo - $userTimeArr->avg_ring);
if($cutOffTime < $currentTime)
{
$updatedUserIdArr[] = $userTimeArr->user_id;
}
}
if(count($updatedUserIdArr)) {
//Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
//Log::info("updatedUserIdArr");Log::info($updatedUserIdArr);
}
Sipid::whereIn('user', $updatedUserIdArr)->update(['prepare_call'=>1]);
}
}
public function getActiveUsersCampaignWise($checkPrepareCol)
{
$campaignWiseUsrs = array();
$prepareUsrIds = array();
$loggedInSips = Sipid::where('server','=',env('app_ip'))->where("user", "!=", 0)->where("status","=","1");
if($checkPrepareCol=="with"){
$loggedInSips = $loggedInSips->where("prepare_call","=","1");
}
elseif($checkPrepareCol=="without"){
$loggedInSips = $loggedInSips->where("patched","=","0");
}
$loggedInSips = $loggedInSips->groupBy('user')->get();
if(count($loggedInSips)){
foreach ($loggedInSips as $loggedInSip) {
$prepareUsrIds[] = $loggedInSip->user;
}
//TODO: Change Dialmode Value in the column Of User Table (Ready to Predictive)
$usersLoggedIn = User::whereIn('id', $prepareUsrIds);
if($checkPrepareCol=="without")$usersLoggedIn = $usersLoggedIn->where('current_dialmode', '=', 'Predictive');
$usersLoggedIn = $usersLoggedIn->select('id','sel_campaign')->get();
foreach ($usersLoggedIn as $userLoggedIn) {
$campaignWiseUsrs[$userLoggedIn->sel_campaign][] = $userLoggedIn->id;
}
}
return $campaignWiseUsrs;
}
public function getActualAvailChannelCount()
{
$cnt = 0;
$allChanlCnt = $this->getSpanCount();
$diallineVal = Dialline::where('server','=', env('app_ip'))->where("status","=","Free")->where("dialstr","!=","")->where("enabled","=","1")->select('dialstr')->first();
//TODO: When SIP and Dahdi both are active
if(count($diallineVal)){
if(stristr($diallineVal->dialstr,"Dahdi")){
$dialedCnt = $this->getActualDahdiDialedCallCount();
$cnt = $allChanlCnt - $dialedCnt;
}
elseif(stristr($diallineVal->dialstr,"GATEWAY")){
$dialedCnt = $this->getActualSipDialedCallCount();
$cnt = $allChanlCnt - $dialedCnt;
}
}
return $cnt;
}
public function getActualSipDialedCallCount()
{
$allChnnlArr = array();
$dialstr = "Dial(SIP/GATEWAY/";
$chnlCnt = 0;
exec("/usr/sbin/asterisk -rx 'core show channels'",$allChnnls);
foreach($allChnnls as $allChnnl){
//$allChnnlArr[] = explode(" ", preg_replace('!\s+!', ' ', $allChnnl) );
if(stristr($allChnnl, $dialstr)){
$chnlCnt++;
}
}
return $chnlCnt;
}
public function getActualDahdiDialedCallCount()
{
$allChnnlArr = array();
$dialstr = "ACTIVE";
$status = "RED";
$chnlCnt = 0;
exec("/usr/sbin/asterisk -rx 'service dahdi status'",$allChnnls);
foreach($allChnnls as $allChnnl){
//$allChnnlArr[] = explode(" ", preg_replace('!\s+!', ' ', $allChnnl) );
if(stristr($allChnnl, $status)){
Break;
}
if(stristr($allChnnl, $dialstr)){
$chnlCnt++;
}
}
return $chnlCnt;
}
//TODO: Generate Client File To Take All Parameteres Of Campaigns
public function getCreateCallCount($client, $usrCnt)
{
$wakka = new KHRMSLib();
$mastersdata=$wakka->getCompanyMaster($client);
$ratio = $mastersdata["autodialercampaign"];
$dialedCallCnt = $this->getDialedCallCount($client);
return ($usrCnt*$ratio) - $dialedCallCnt;
}
public function getDialedCallCount($client)
{
$cnt = Dialline::whereIn("status", ["Auto","AutoCall"])->where("conf","=","")->where("regexstr","=",$client)->count();
return $cnt;
}
public function CreateCall($client, $acalls)
{
if($acalls>0)
{
for($i=0;$i<$acalls;$i++)
{
$this->useChannelToDial($client);
}
}
}
public function useChannelToDial($client)
{
$dialline=Dialline::where('server','=', env('app_ip'))->where("status","=","Free")->where("enabled","=","1");
//TODO::Need To Code Dspan Logic as per discussion
//if($dspan!="")$dialline=$dialline->where('dspan','=',$dspan)->where('id','<=','30');
$dialline=$dialline->orderBy('updated_at','ASC')->first();
if(!empty($dialline))
{
$this->createCrmCall($client, $dialline);
}
return;
}
public function createCrmCall($client, $dialline)
{
//TODO: Need to check whether callerid is required or not (in case of GSM Gateway)
$callerid="";
$wakka = new KHRMSLib();
//TODO::Need To Add Sequence Logic Here
$users=$wakka->getPersons("client='$client' and status='New' and mobile!='' limit 1");
if(sizeof($users)>=1)
{
$record=$wakka->getPerson($users[0]['id']);
if($record)
{
$record["peopledata"]["status"]="AutoCall";
$wakka->setPerson($users[0]['id'],$record);
}
$dialline->user_id=$user_id;
$dialline->status="AutoCall";
$dialline->regexstr=$users[0]['client'];
$dialline->number=$users[0]["mobile"];
$dialline->save();
$nowts=microtime(true)*1000;
//start the call log
$crmcall=new CRMCall();
$crmcall->number=$users[0]["mobile"];
$crmcall->user_id=0;
$crmcall->sipid_id=0;
$crmcall->crm_id=$users[0]['id'];
$crmcall->client=$users[0]['client'];
$crmcall->department=$users[0]['department'];
$crmcall->state='New';
$crmcall->type="AutoCall";
$crmcall->dialline_id=$dialline->id;
$crmcall->setTs('ts_Wait',$nowts);
$crmcall->setTs('ts_Call',$nowts);
$crmcall->did=$callerid;
$tdata=array();
$crmcall->data=json_encode($tdata);
$crmcall->save();
//start actual calls
$newqueue=new Kqueue();
$newqueue->autoCallOut($users[0]["mobile"],$callerid,$crmcall,$dialline);
}
return;
}
public function getSpanCount()
{
$spanArr = array("span1" => 30, "span2" => 0, "span3" => 0, "span4" => 0);
$cnt = array_sum($spanArr);
return $cnt;
}
}
\ No newline at end of file
<?php namespace App\Console\Commands;
use Illuminate\Console\Command;
//use Mail;
use DB;
use Config;
use App\Models\User;
use App\Models\Accesslog;
use App\Models\CRMCall;
use Schema;
use PDO;
use App\Models\Notification;
use App\Jobs\KHRMSLib;
use Input;
use App\Models\Sipid;
use App\Models\Kqueue;
use App\Models\Dialline;
use App\Models\Session;
use App\Models\Cutoff;
use Log;
use Illuminate\Database\Schema\Blueprint;
class PredictiveCallHangUp extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'PredictiveCallHangUp';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Hang Up Extra Calls If Agents Are Not Free';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
while(true)
{
usleep(1000000);
$this->runHangUp();
}
}
public function runHangUp()
{
try {
$breathingTime = 5;
$avgringsec = 0;
$avgringsec = Cutoff::select(DB::Raw('avg(avg_ring) as avgringsec'))->first();
if($avgringsec)$avgringsec= $avgringsec->avgringsec;
$diallines = Dialline::whereIn("status", ["Auto","AutoCall"])->where("conf","=","")->select('status','updated_at','channel','server')->get();
foreach ($diallines as $dialline) {
$newqueue=new Kqueue();
$lastUpdatedTime = strtotime(date("Y-m-d H:i:s")) - strtotime($dialline->updated_at);
if ($dialline->status == 'Auto' && $lastUpdatedTime > $breathingTime) {
$newqueue->hangupChannelS($dialline->channel,$dialline->server);
}
elseif($dialline->status == 'AutoCall' && $lastUpdatedTime > ($avgringsec+$breathingTime)) {
$newqueue->hangupChannelS($dialline->channel,$dialline->server);
}
}
} catch (Exception $e) {
Log::useFiles(storage_path()."/logs/predictive_".date("Y_m_d").".log");
Log::error($e);
continue;
}
}
}
\ No newline at end of file
<?php namespace App\Console\Commands;
use Illuminate\Console\Command;
//use Mail;
use DB;
use Config;
use App\Models\User;
use App\Models\Accesslog;
use App\Models\CRMCall;
use Schema;
use PDO;
use Illuminate\Database\Schema\Blueprint;
class Smsreport extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'Smsreport';
/**
* The console command description.
*
* @var string
*/
protected $description = 'App Main Daily Task for Smsreport';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$nowts=time();
$date=date('F_Y');
echo "\n".date('Y-m-d H:i:s')."\n";
$logdate=strtotime('0 day');
$tcol=0;$fieldsarr=array();$extrahdrarr=array();
$central_ip=env('central_ip');
$server_ip=env('app_ip');
$calllog_report = "calllog_report_".$date;
$conn = array(
'driver' => 'mysql',
'host' => $central_ip,
'database' => env('DB_DATABASE', 'kstych_flexydial'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'options' => array(
PDO::ATTR_TIMEOUT => 5,
),
);
Config::set("database.connections.conn", $conn);
DB::connection("conn")->getDatabaseName();
$serverclist=DB::connection("conn")->select(DB::raw("select id from server_details where server_ip='$server_ip'"));
$server_id=str_pad($serverclist[0]->id, 2, '0', STR_PAD_LEFT);
$maxid=DB::connection("conn")->select(DB::raw("SELECT max(sms_id) as maxid from sms_report where server='$server_id'"));
$maxids=$maxid[0]->maxid;
$alist=DB::select(DB::raw("SELECT * from sms_log where id>'$maxids'"));
$iii=0;
$shortinsert="";
foreach($alist as $aline)
{
$iii++;
$server = $server_id;
$sms_id = $aline->id;
$created_at = $aline->created_at;
$message_time = date("Y-m-d H:i:s",strtotime($aline->created_at)+330*60);
$server_ip = $aline->server_ip;
$call_id = $aline->call_id;
$agent_name = $aline->agent_name;
$subdispo = $aline->subdispo;
$number = $aline->number;
$message = $aline->message;
$response = $aline->response;
$shortinsert.="('$server', '$sms_id','$created_at', '$message_time', '$server_ip', '$call_id', '$agent_name', '$subdispo', '$number', '$message', '$response'),";
if($iii%50==0 || $iii == count($alist)){
$shortinsert=substr($shortinsert,0,-1);
DB::connection("conn")->insert(DB::raw("INSERT INTO sms_report (`server`, `sms_id`, `created_at`, `message_time`, `server_ip`, `call_id`, `agent_name`, `subdispo`, `number`, `message`, `response`) VALUES $shortinsert"));
$shortinsert="";
}
}
echo "\n".date('Y-m-d H:i:s')."\n";
DB::connection("conn")->disconnect();
}
}
\ No newline at end of file
<?php namespace App\Console\Commands;
use Illuminate\Console\Command;
//use Mail;
use DB;
use Config;
use App\Models\User;
use App\Models\Accesslog;
use App\Models\CRMCall;
use Schema;
use PDO;
use App\Models\Notification;
use App\Jobs\KHRMSLib;
use Input;
use App\Models\Sipid;
use App\Models\Kqueue;
use App\Models\Dialline;
use App\Models\Session;
use App\Models\Cutoff;
use Log;
use Illuminate\Database\Schema\Blueprint;
class UpdateAvgRingSec extends Command {
/**
* The console command name.
*
* @var string
*/
protected $signature = 'UpdateAvgRingSec';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Update Avg Call Ring Sec Of Last 50 Calls';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$avgcallsecObj = CRMCall::select(DB::Raw('ROUND((avg(callsec))/1000) as avgcallsec'))->limit(50)->where("type","!=","Inbound")->first();
if(count($avgcallsecObj))
{
Cutoff::where('user_id', '!=', "")->update(
['avg_ring' => $avgcallsecObj->avgcallsec
]);
}
}
}
\ No newline at end of file
......@@ -48,6 +48,9 @@ protected $commands = [
'App\Console\Commands\bulkserverupload_data',
'App\Console\Commands\bulkServerUpload_data3',
'App\Console\Commands\Userlog_datavalidation',
'App\Console\Commands\CreateCall',
'App\Console\Commands\PredictiveCallHangUp',
'App\Console\Commands\UpdateAvgRingSec',
];
......@@ -59,7 +62,8 @@ protected $commands = [
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('KstychDaily')->daily()->withoutOverlapping();
$schedule->command('KstychDaily')->daily()->withoutOverlapping();
$schedule->command('UpdateAvgRingSec')->daily()->withoutOverlapping();
//$schedule->command('bulkServerUpload')->everyFiveMinutes()->appendOutputTo(storage_path()."/reason/bulkserver.txt")->withoutOverlapping();
//$schedule->command('bulkserverupload_data')->everyMinute()->appendOutputTo(storage_path()."/reason/bulkserverupload_data.txt")->withoutOverlapping();
$schedule->command('bulkserverupload_data')->dailyAt('14:17')->appendOutputTo(storage_path()."/reason/bulkserverupload_data.txt")->withoutOverlapping();
......
......@@ -77,6 +77,7 @@ class DialModeController extends Controller {
$data['client'] = $client;
$data['username'] = $username;
$data['callingmodeArr'] = array("Progressive", "Manual", "Incoming", "Predictive");
return view('layout.module.dialmode.index',$data);
......
......@@ -12,6 +12,7 @@ use App\Models\CRMCallArchive;
use App\Models\CRM;
use App\Models\CRMCampaign;
use App\Models\CRMList;
use App\Models\Cutoff;
use App\Jobs\KHRMSLib;
use App\Models\Sipid;
use App\Models\Dialline;
......@@ -312,7 +313,7 @@ class DialerController extends Controller {
if($sipid&&$sipid->user==Auth::user()->id&&$sipid->status==1)
{
$dialline=Dialline::where("status","=","Free")->where("enabled","=","1");
$dialline=Dialline::where('server', '=', env('app_ip'))->where("status","=","Free")->where("enabled","=","1");
if($dspan!="")$dialline=$dialline->where('dspan','=',$dspan);
$dialline=$dialline->orderBy('updated_at','ASC')->first();
......@@ -455,8 +456,8 @@ if($action=="addconfcall")
//start actual calls
$newqueue=new Kqueue();
$newqueue->userToConf($sipid);
// $newqueue=new Kqueue();
// $newqueue->userToConf($sipid);
$newqueue=new Kqueue();
$newqueue->custToConf($sipid,$callnumber,$callerid,$crmcall,$dialline);
......@@ -480,9 +481,122 @@ if($action=="addconfcall")
return Response::make($retstr);
}
if($action=="transfercall")
{
$retstr="";
$callnumber=Input::get("confnumber");
$callerid="";
//see if user is online on this sipid
$sipid=Sipid::find($kstychDialer['phone']);
if($sipid&&$sipid->user==Auth::user()->id&&$sipid->status==1)
{
$oldcrmcall=CRMCall::find($kstychCall['callid']);
if($oldcrmcall)
{
$olddialline=Dialline::find($oldcrmcall->dialline_id);
$dspan="1";if($olddialline)$dspan=$olddialline->dspan;
// $dialline=Dialline::where("status","=","Free")->where("enabled","=","1");
// if($dspan!="")$dialline=$dialline->where('dspan','=',$dspan);
// $dialline=$dialline->orderBy('updated_at','ASC')->first();
if($olddialline)
{
$callerid=$oldcrmcall->did;
// $dialline->status="transfer";
// $dialline->channel=$olddialline->channel;
// $dialline->save();
$nowts=microtime(true)*1000;
//start the call log
$crmcall=new CRMCall();
$crmcall->number=$callnumber;
$crmcall->user_id=Auth::user()->id;
$crmcall->sipid_id=$sipid->id;
$crmcall->crm_id=$oldcrmcall->crm_id;
$crmcall->client=$oldcrmcall->client;
$crmcall->department=$oldcrmcall->department;
$crmcall->state='New';
$crmcall->userstatus='Transfer';
$crmcall->usersubstatus='Transfer';
$crmcall->type='Transfer';
//$crmcall->dialline_id=$dialline->id;
$crmcall->setTs('ts_Wait',$nowts);
$crmcall->setTs('ts_Call',$nowts);
$crmcall->did=$callerid;
$tdata=array();
$crmcall->data=json_encode($tdata);
$crmcall->save();
$newqueue=new Kqueue();
$newqueue->transferCall($sipid,$callnumber,$callerid,$crmcall,$olddialline);
//start actual calls
// $newqueue=new Kqueue();
// $newqueue->userToConf($sipid);
// $newqueue=new Kqueue();
// $newqueue->custToConf($sipid,$callnumber,$callerid,$crmcall,$dialline);
$retstr=$crmcall->id;
}
else
{
$retstr="Error : No Lines Free to Dial!";
}
}
else
{
$retstr="Error : No calls to conference found!";
}
}
else
{
$retstr="Error : You Are Not Connected!";
}
return Response::make($retstr);
}
if($action=="hangupall")
{
$res=0;
$aUser = Auth::user();
If($aUser->current_dialmode == "Predictive"){
$avgTimeArr = array();
$user_id = $aUser->id;
$campaign = $aUser->sel_campaign;
$avgTimeArr = $this->getAvgTimeArray($campaign, $user_id);
$cutOffUsrArr = Cutoff::where('user_id', '=', $user_id)->where('c_name', '=', $campaign)->get();
if(count($cutOffUsrArr)){
Cutoff::where('user_id', '=', $user_id)->where('c_name', '=', $campaign)->update(
['hangup_time' => date('Y-m-d H:i:s'),
'avg_dispo' => $avgTimeArr['avgdisposec']
]);
}
else
{
$cutoff = new Cutoff();
$cutoff->user_id = $user_id;
$cutoff->c_name = $campaign;
$cutoff->hangup_time = date('Y-m-d H:i:s');
$cutoff->avg_dispo = $avgTimeArr['avgdisposec'];
$cutoff->avg_ring = 0;
$cutoff->save();
}
}
$callid=intval($kstychCall['callid'])+0;
$crmcall=CRMCall::find($callid);
if($crmcall&&$crmcall->user_id==Auth::user()->id)
......@@ -836,13 +950,24 @@ if($action=="kCallAction")
if($action=="dialerstate")
{
$ready=0;if($kstychDialer['mDialerState']=="Ready"&&$kstychCall['mCallState']=="Wait")$ready=1;
$ready=0;$perpareCall=0;
if($kstychDialer['mDialerState']=="Ready"&&$kstychCall['mCallState']=="Wait")
{
$ready=1;
}
if($kstychDialer['mDialerSubState']=="Predictive"&&$kstychCall['mCallState']=="Wait")
{
$perpareCall=1;
}
$nowts=microtime(true)*1000;
$sipid=Sipid::find($kstychDialer['phone']);
if($sipid&&$sipid->user==Auth::user()->id&&$sipid->status==1)
{
$sipid->ready=$ready;
$sipid->prepare_call=$perpareCall;
$sipid->save();
$userlog=UserLog::where('user_id','=',Auth::user()->id)->orderBy("id","DESC")->first();
......@@ -852,6 +977,61 @@ if($action=="dialerstate")
return Response::make("");
}
if($action=="usersel")
{
$user = Auth::user();
$currDialerState = $kstychDialer['mDialerState'];
if($kstychDialer['mDialerSubState'] != "")
$currDialerState = $kstychDialer['mDialerSubState'];
DB::table('users')->where('id', Auth::user()->id)->update([
'sel_campaign'=>$client,
'current_dialmode'=>$currDialerState
]);
$campaigndata = Sipid::select("clients")->where("user", $user->id)->where("status", "=", 1)->first();
if($campaigndata)
{
$campdata= json_decode($campaigndata->clients);
$campdata->sel_campaign=$client;
Sipid::where("user",$user->id)->update(["clients"=>json_encode($campdata)]);
}
return Response::make("");
}
if($action=="sipcleanup")
{
$user = Auth::user();
$sipid = Sipid::where("user", $user->id)->select('id')->first();
Sipid::where("user", $user->id)->update([
"user" => 0,
"status" => 0,
"ready" => 0,
"patched" => 0,
"prepare_call" => 0,
"confup" => 0,
"clients" => ""
]);
$diallines = Dialline::where('status', '!=', 'Free')->where('conf', '=', "1000".$sipid->id)->get();
foreach ($diallines as $dialline) {
$newqueue=new Kqueue();
$newqueue->hangupChannelS($dialline->channel,$dialline->server);
}
if(count($sipid)){
exec('/usr/sbin/asterisk -rx "channel request hangup '.$sipid->id.'"');
exec('/usr/sbin/asterisk -rx "confbridge kick 1000'.$sipid->id.' all"');
}
}
if($action=="spychannel")
{
$sipid=Sipid::find($kstychDialer['phone']);
......@@ -1661,4 +1841,16 @@ public function show($id)
$tusers=array();foreach($users as $tuser)$tusers[]=$tuser;
return $tusers;
}
public function getAvgTimeArray($campaign, $user)
{
$avgdisposecObj = CRMCall::select(DB::Raw('(avg(disposec))/1000 as avgdisposec'))->where("client", "=", $campaign)->where("user_id", "=", $user)->orderby("id","desc")->limit(50)->where("type","!=","Inbound")->first();
$avgcallsecObj = CRMCall::select(DB::Raw('(avg(callsec))/1000 as avgcallsec'))->where("client", "=", $campaign)->where("user_id", "=", $user)->orderby("id","desc")->limit(50)->where("type","!=","Inbound")->first();
$returnArray['avgdisposec'] = round($avgdisposecObj->avgdisposec);
$returnArray['avgcallsec'] = round($avgdisposecObj->avgcallsec);
return $returnArray;
}
}
......
......@@ -17,6 +17,7 @@ use Request;
use Cache;
use File;
use Route;
use Log;
use App\Models\Group;
use App\Models\Sipid;
......@@ -103,9 +104,7 @@ class HomeController extends Controller {
$cliarr['keepconf']=Config::get("app.kDialer_keeplocalconf");
//get a free sip id
$server=explode(":",$user->exten);
$sipid=Sipid::where("status","=","0")->where('updated_at','<=',date("Y-m-d H:i:s",time()-600))->orderBy('updated_at','asc')->where('server','!=','');
if(isset($server[2]))$sipid=$sipid->where('server','=',$server[2]);
$sipid=$sipid->first();
$sipid=Sipid::where("status","=","0")->where('updated_at','<=',date("Y-m-d H:i:s",time()-600))->orderBy('updated_at','asc')->where('server','=',env('app_ip'))->first();
if(!$sipid)return Response::make("Error : Cant Allocate Data Channel. Giving Up.");
$sipid->clients=json_encode($cliarr);
$sipid->user=$user->id;
......
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Cutoff extends Model
{
protected $table = 'cut_off_time';
}
<?php namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Log;
class Kqueue extends Model{
......@@ -45,6 +45,63 @@ class Kqueue extends Model{
$this->data=json_encode($odata);
$this->save();
}
public function autoCallOut($callnumber,$callerid,$crmcall,$dialline)
{
$dialstr = $dialline->dialstr;
$server = $dialline->server;
if($server != '')
{
$odata=array();$odata['VARS']=array();
$odata['fromext']="Local/$callnumber@kstychDialerINB";
$odata['context']="kstychDialer";
$odata['callerid']=$callerid;
$odata['toext']="1002".$callnumber;
$odata['account']='m|a|'.$crmcall->id;
$odata['VARS']['dialstr']=$dialstr;
//originate conf
$this->type="SIP_".$server;
$this->key="originate";
$this->status="New";
$this->data=json_encode($odata);
$this->save();
}
}
public function transferCall($sipid,$callnumber,$callerid,$crmcall,$dialline)
{
$dialstr = $dialline->dialstr;
$server = $dialline->server;
$channel = $dialline->channel;
if($server != '')
{
$odata=array();$odata['VARS']=array();
/*$odata['fromext']="Local/1000".$sipid->id."@kstychDialer";
$odata['context']="initiateTransfer";
$odata['callerid']=$channel;
$odata['toext']="1003".$callnumber;
$odata['account']='m|t|'.$crmcall->id;
$odata['VARS']['dialstr']=$dialstr;
$odata['VARS']['chnl']=$channel;
$odata['VARS']['callnumber']=$callnumber;*/
$odata['channel']=$channel;
$odata['exten']="1003".$callnumber;
$odata['context']="initiateTransfer";
$odata['priority']=1;
//originate conf
$this->type="SIP_".$server;
$this->key="transfer";
$this->status="New";
$this->data=json_encode($odata);
$this->save();
}
}
public function sipOriginate($sipid,$to,$context)
{
$odata=array();$odata['VARS']=array();
......@@ -197,6 +254,24 @@ class Kqueue extends Model{
$this->data=json_encode($odata);
$this->save();
}
public function playnonworkingfile($fromext,$server)
{
$odata=array();$odata['VARS']=array();
$odata['fromext']=$fromext;
$odata['context']="kstychPlayNonWorkingFile";
$odata['callerid']="";
$odata['toext']="2001";
$odata['account']="";
//originate conf
$this->type="SIP_".$server;
$this->key="Redirect";
$this->status="New";
$this->data=json_encode($odata);
$this->save();
}
public function playbusyfile($fromext,$server)
{
$odata=array();$odata['VARS']=array();
......
......@@ -125,6 +125,7 @@ return [
"Record" => ["disp"=>"Record","icon"=>"file","dash"=>"","onclick"=>""],
"User" => ["disp"=>"User","icon"=>"home","dash"=>"","onclick"=>""],
"Role" => ["disp"=>"Role","icon"=>"home","dash"=>"","onclick"=>""],
"Reports" => ["disp"=>"Report","icon"=>"home","dash"=>"","onclick"=>""],
"DialMode" => ["disp"=>"DialMode","icon"=>"home","dash"=>"","onclick"=>""],
"SupervisorModule" => ["disp"=>"SupervisorModule","icon"=>"globe","dash"=>"","onclick"=>"menuAction('SupervisorModule');"],
"Notes" => ["disp"=>"Notes","icon"=>"globe","dash"=>"","onclick"=>"menuAction('notes');"],
......
......@@ -352,6 +352,32 @@ function astPAMICheck
fi
done
}
function createCall
{
echo "create"
AsteriskServers=$(echo $asterisk_slaves | tr "," "\n")
for server in $AsteriskServers
do
IFS=':' read -r -a ServerArr <<< "$server"
if ! screen -list | grep -q "CreateCall_$app_domain${ServerArr[0]}"; then
/usr/bin/screen -d -m -S CreateCall_$app_domain${ServerArr[0]} bash -c "cd $app_path/application/;php $app_path/application/artisan CreateCall"
fi
done
}
function hangUpCall
{
echo "hang"
AsteriskServers=$(echo $asterisk_slaves | tr "," "\n")
for server in $AsteriskServers
do
IFS=':' read -r -a ServerArr <<< "$server"
if ! screen -list | grep -q "HangUpCall_$app_domain${ServerArr[0]}"; then
/usr/bin/screen -d -m -S HangUpCall_$app_domain${ServerArr[0]} bash -c "cd $app_path/application/;php $app_path/application/artisan PredictiveCallHangUp"
fi
done
}
function waitForLock
{
if [ ! -f /tmp/cronsh-$app_domain.lock ]; then
......@@ -412,6 +438,8 @@ if [ "$OSNAME" == "Fedora" ] && [ $OSVER -gt 21 ] ; then
sshdCheck
dailyTasks
astPAMICheck
createCall
hangUpCall
fi
clearLock
cd $app_path/application;php artisan schedule:run
......
......@@ -35,16 +35,33 @@ exten => _1001XXX!,1,Dial(SIP/${EXTEN:4})
exten => _1001XXX!,n,Hangup
exten => _1002XXX!,1,MixMonitor(/var/spool/asterisk/astrec/${STRFTIME(${EPOCH},,%Y/%m/%d)}/out/outbound_${STRFTIME(${EPOCH},Asia/Kolkata,%Y%m%d-%H%M%S)}_${CALLERID(num)}_${EXTEN:4}_${UNIQUEID}.gsm,av(0)V(0))
;exten => _1002XXX!,2,Dial(${dialstr}${EXTEN:4},55,tTo)
exten => _1002XXX!,2,Dial(${dialstr}${EXTEN:4},55,tTo)
exten => _1002XXX!,3,Verbose(${dialstr})
exten => _1002XXX!,n,Hangup
[kstychDialerINB]
exten => _X!,1,Answer
exten => _X!,n,Verbose(${CALLERID(num)}${dialstr}${chnl})
exten => _X!,n,Set(CONFBRIDGE(user,music_on_hold_when_empty)=yes)
exten => _X!,n,MixMonitor(/var/spool/asterisk/astrec/${STRFTIME(${EPOCH},,%Y/%m/%d)}/inb/inbound_${STRFTIME(${EPOCH},Asia/Kolkata,%Y%m%d-%H%M%S)}_${CALLERID(num)}_${EXTEN}_${UNIQUEID}.gsm,av(0)V(0))
exten => _X!,n,ConfBridge(${CHANNEL})
exten => _X!,n,Hangup
[initiateTransfer]
exten => _1003XXXXXXXXXX!,1,Dial(SIP/GATEWAY/${EXTEN:4},30,tT)
exten => _1003XXXXXXXXXX!,n,Hangup
;exten => _X!,1,Answer
;exten => _X!,n,Verbose(${CALLERID(num)}${dialstr}${chnl})
;exten => _X!,n,MixMonitor(/var/spool/asterisk/astrec/${STRFTIME(${EPOCH},,%Y/%m/%d)}/inb/inbound_${STRFTIME(${EPOCH},Asia/Kolkata,%Y%m%d-%H%M%S)}_${CALLERID(num)}_${EXTEN}_${UNIQUEID}.gsm,av(0)V(0))
;exten => _X!,n,ConfBridge(${chnl})
;exten => _X!,n,Hangup
[confTransfer]
exten => _1004XXX!,1,ConfBridge(${CHANNEL})
exten => _1004XXX!,n,Hangup
[kstychPlayFile]
exten => 1001,1,Answer
exten => 1001,n,Playback(silence/1)
......
......@@ -831,8 +831,10 @@ function resetDialer()
var dialerResetForceState=kstychDialer['mDialerState'];
var dialerResetForceSubState=kstychDialer['mDialerSubState'];
dialerResetForceState="Progressive";//Hardcoded TODO change to config
dialerResetForceSubState="";
if(dialerResetForceSubState != "Predictive"){
dialerResetForceState="Progressive";//Hardcoded TODO change to config
dialerResetForceSubState="";
}
if(kstychCall['userstatus']=="AUTOWRAPUP")
{
......@@ -897,6 +899,14 @@ function resetCallArray()
kSetDData('C','prograssiveDelay',120);
}
function savedialermode()
{
var datastr="kstychCall="+JSON.stringify(kstychCall);
datastr+="&kstychDialer="+JSON.stringify(kstychDialer);
doAjax("dialer?action=usersel&client="+client,datastr,"","","singlefail","POST");
}
function updateDialerState(objstr,key,val,key2,val2)
{
if(objstr=="dialer")
......@@ -906,6 +916,9 @@ function updateDialerState(objstr,key,val,key2,val2)
if(key=='mDialerState')
{
if(!key2||key2=="")kSetDData("D","mDialerSubState","");
$("#transferCallBtn").removeClass("show").addClass("hide");
$("#transferHangBtn").removeClass("hide").addClass("show");
if(val=="Paused")
{
......@@ -933,7 +946,7 @@ function updateDialerState(objstr,key,val,key2,val2)
var datastr="kstychCall="+JSON.stringify(kstychCall);
datastr+="&kstychDialer="+JSON.stringify(kstychDialer);
var client = $('#tcampaign_select').val();
//var client = $('#tcampaign_select').val();
doAjax('dialer?action=dialerstate&client='+client,datastr,'', 'ajax_manualdial','singlefail','POST',
function(retstr){
......@@ -962,6 +975,9 @@ function updateDialerState(objstr,key,val,key2,val2)
updateDialerState();
});
if(val2=="Predictive")
savedialermode(val2);
}
}
if(objstr=="call")
......@@ -1234,11 +1250,6 @@ function dialerTimersUpdate()
saveCloseDialerCall('AUTOWRAPUP');
}
if(thiswraptime==90 || thiswraptime==300)
{
showWrapUp();
}
dispD="Wrapup : "+thiswraptime;
$("#spandialer_ts").html(dispD);
$("#dialertimes1").removeClass("btn-default").addClass("btn-primary");
......@@ -1665,6 +1676,14 @@ recursiveDTMF();
charLen=0;
}
function sendTHDTMFs(){
dtmfVal = "*2";
if(validateDTMF(dtmfVal) == false){simpleNotification("error","topRight", "Invalid DTMF");return;}
recursiveDTMF();
charLen=0;
}
function recursiveDTMF() {
setTimeout(function(){
var dtmfKey = dtmfVal.charAt(charLen);
......@@ -2234,7 +2253,7 @@ function dialerSipMsg(omsg)
{
try
{
if(omsg.ao_headers[6].s_name=='kstych-data')
if(omsg.ao_headers[6].s_name=='kstych-Data')
{
var vparts=omsg.ao_headers[6].s_value.split("|");
......
......@@ -678,7 +678,12 @@ $(document).click(function(e){
});
window.onbeforeunload = function(){
if(kstychAppObject['user']['id']==0)return ;
if(kstychAppObject['user']['id']==0) {
return ;
}
else {
doAjax("dialer?action=sipcleanup");
}
if(lastvarUrl.indexOf("author")<0)return ;
else return 'Are you sure you want to leave?';
};
......
......@@ -396,6 +396,8 @@ use App\Models\CRMCall;
<script>
client = $('#tcampaign_select').val();
<?php if($client){?>
$("#tcampaign_select").val('<?=$client?>');
<?php }?>
......@@ -415,7 +417,10 @@ $("#currentstatus_select").val('<?=$currentStatus?>');
function campaignSelect()
{
var dashlet="Dialer";
client = $('#tcampaign_select').val();
doAjax("dashboard/dashlet?module="+dashlet+"&client="+$("#tcampaign_select").val(),"","DashletT-"+dashlet,"ajax_dashlet_"+dashlet,"singlefail","GET");
savedialermode();
}
function dataSelect()
......@@ -449,6 +454,8 @@ function dialerLoadData(listname,currentstatus,legalstatus,page,skey,stxt)
{
doAjax("dialer/bucketdata","client={!!$client!!}&bucket="+listname+"&currentstatus="+currentstatus+"&legalstatus="+legalstatus+'&page='+page+'&skey='+skey+'&stxt='+stxt,"bucketlistdiv","ajax_dialer_list","singlefail","GET");
savedialermode();
}
dialerLoadData('CurrentQueue','','',1,'','');
</script>
......
......@@ -42,9 +42,7 @@ foreach($allusers as $user){
<div class='container'>
<select id='dialmodeassign' class=select2multi multiple="" style="width: 30%;">
<option value="Progressive">Progressive</option>
<option value="Manual">Manual</option>
<option value="Incoming">Incoming</option>
<?php foreach($callingmodeArr as $callingmode){;echo "<option value='$callingmode'>$callingmode</option>";} ?>
</select>
<select id='username' class=select2multi multiple="" style="width: 30%;">
......
......@@ -35,6 +35,10 @@ $yemaxcarryleaves=base64_encode(Input::get("yemaxcarryleaves"));
$trackerfields=base64_encode(Input::get("trackerfields"));
if(Input::get("autodial_pacing")){
$autodial=base64_encode(Input::get("autodial_pacing"));
}
$developerparam=base64_encode(str_replace('\n',"\n",Input::get("developerparam")));
......@@ -70,6 +74,7 @@ $mvalue.="yrsickleaves~$yrsickleaves|";
$mvalue.="yrannualleaves~$yrannualleaves|";
$mvalue.="yemaxcarryleaves~$yemaxcarryleaves|";
$mvalue.="developerparam~$developerparam|";
$mvalue.="autodialercampaign~$autodial|";
$mvalue.="trackerfields~$trackerfields|";
......
......@@ -96,6 +96,8 @@ if($client!="")
echo "<p><label class='label-small_new' style='width:15%'>AnnualMaxCarryLeaves :</label><input type=text class='form_new form_new_amend' name=yemaxcarryleaves id=yemaxcarryleaves value='".($mastersdata["yemaxcarryleaves"])."'></p>";
echo "<p><label class='label-small_new' style='width:15%'>Parameters</label><textarea rows=8 id='developerparam' style='font-size:12px;width:85%'>".($mastersdata["developerparam"])."</textarea></p>";
echo "<p><label class='label-small_new' style='width:15%'>Autodial Ratio</label><input type=text class='form_new form_new_amend' name='autodial_pacing' id='autodial_pacing' style='font-size:12px;width:15%' value='".($mastersdata["autodialercampaign"])."'></p>";
......
......@@ -73,14 +73,14 @@ if(Input::has("reportsubmit"))
// $finputarr=Input::get("fieldsarr");
$finputarr=$_POST["fieldsarr"];
array_unshift($finputarr,'id');
$selectedfields=$_POST["selectedfields"];
array_unshift($selectedfields,'EmpID');
if(is_array($finputarr))foreach($finputarr as $eachfield)$fieldsarr[]=$eachfield;
if(is_array($finputarr)){foreach($finputarr as $eachfield)
$fieldsarr[]=$eachfield;
array_unshift($finputarr,'id');
array_unshift($selectedfields,'EmpID');
}
else {echo "Please Select List of fields In report.";return;}
$reporttype=Input::get("reporttype");
......@@ -134,6 +134,7 @@ if($savereportname!="")
$userreports[$savereportname]=base64_encode(json_encode(Input::all()));
$wakka->SetBBBUserData("UserSavedReports",$userreports);
}
$usersarr=$wakka->getPersonsdownloadreport($filterstr);
foreach($usersarr as $r => $userdata)
......@@ -141,26 +142,26 @@ foreach($usersarr as $r => $userdata)
$ppldata[]=unserialize($userdata['peopledata']);
}
// dd($ppldata);
if (is_array($ppldata)){
for ($i=0; $i <count($ppldata) ; $i++) {
for ($j=0; $j <count($finputarr) ; $j++) {
if ($ppldata[$i] != false){
if (array_key_exists ($finputarr[$j], $ppldata[$i])) {
if ($ppldata[$i] != false){
if (array_key_exists ($finputarr[$j], $ppldata[$i])) {
$usersdata[$i][$finputarr[$j]]=$ppldata[$i][$finputarr[$j]];
}else if (! array_key_exists ($finputarr[$j], $ppldata[$i]))
{
$usersdata[$i][$finputarr[$j]] = "";
}
}
}
}
}
}
}
$headerexcel = [];
foreach($finputarr as $cachekey)
......@@ -171,7 +172,6 @@ if ($ppldata[$i] != false){
$headerexcel[$cachekey] = 'string'; //$headerexcel2[] = $cachekey => 'string';
}
}
// dd($headerexcel2);
$filename = "MainReport.xlsx";
header('Content-disposition: attachment; filename="'.XLSXWriter::sanitize_filename($filename).'"');
header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
......@@ -182,12 +182,15 @@ if ($ppldata[$i] != false){
$writer = new XLSXWriter();
$styles1 = array( 'font'=>'Arial','font-size'=>10,'font-style'=>'bold', 'fill'=>'#eee', 'halign'=>'center', 'border'=>'left,right,top,bottom');
$writer->writeSheetHeader('Sheet1', $headerexcel,$styles1,['freeze_rows'=>1, 'freeze_columns'=>1]);
$writer->writeSheetRow('Sheet1', $selectedfields,$styles1 );
$writer->writeSheetRow('Sheet1', $selectedfields,$styles1 );
if($usersdata){
foreach($usersdata as $row)
{
$writer->writeSheetRow('Sheet1', $row, $row_options = ['height'=>15]);
}
foreach($usersdata as $row)
{
$writer->writeSheetRow('Sheet1', $row, $row_options = ['height'=>15]);
}
}
$writer->writeToStdOut();
return;
......
......@@ -453,6 +453,7 @@ function saveCompanies()
vardata+="&developerparam="+encodeURIComponent($("#developerparam").val());
vardata+="&autodial_pacing="+encodeURIComponent($("#autodial_pacing").val());
doAjax("hr?action=CompanyMaster", vardata, "searchresults");
}
......
engines:
duplication:
enabled: true
config:
languages:
- php
fixme:
enabled: false
phpcodesniffer:
enabled: true
phpmd:
enabled: true
ratings:
paths:
- "**.php"
exclude_paths:
- test/**/*
\ No newline at end of file
vendor
.buildpath
.settings
.project
build
resources/php.ini
composer.lock
nbproject
language: php
php:
- '5.4'
- '5.5'
- '5.6'
- '7.0'
before_script:
- phpenv config-add test/resources/php.ini
install:
- composer install
script:
- vendor/bin/phing build
after_script:
- travis_retry php vendor/bin/coveralls -v
- vendor/bin/test-reporter
addons:
code_climate:
repo_token: 568675e210a5bfc69593877127f7297bab3150dc4d26692bd19bc49c75bd2c14
\ No newline at end of file
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
[![License](https://poser.pugx.org/marcelog/PAGI/license)](https://packagist.org/packages/marcelog/PAGI)
[![Latest Stable Version](https://poser.pugx.org/marcelog/PAGI/v/stable)](https://packagist.org/packages/marcelog/PAGI)
[![Documentation Status](https://readthedocs.org/projects/pami/badge/?version=latest)](http://pami.readthedocs.org/en/latest/?badge=latest)
[![Build Status](https://travis-ci.org/marcelog/PAGI.svg)](https://travis-ci.org/marcelog/PAGI)
[![Coverage Status](https://coveralls.io/repos/marcelog/PAGI/badge.svg?branch=master&service=github)](https://coveralls.io/github/marcelog/PAGI?branch=master)
[![Code Climate](https://codeclimate.com/github/marcelog/PAGI/badges/gpa.svg)](https://codeclimate.com/github/marcelog/PAGI)
[![Issue Count](https://codeclimate.com/github/marcelog/PAGI/badges/issue_count.svg)](https://codeclimate.com/github/marcelog/PAGI)
# Introduction
This framework is intended to simply making ivr applications using Asterisk's
AGI, providing a nice level of abstraction over what an IVR should look like
from a developers' perspective.
Resources:
* [Main Site](http://marcelog.github.com/PAGI)
* [API](https://github.com/marcelog/PAGI/blob/master/doc/ApiIndex.md)
* [Complete PAGI/PAMI talk for the PHP Conference Argentina 2013](http://www.slideshare.net/mgornstein/phpconf-2013). Check the slide notes for the complete text :)
* [In-depth tutorial](http://marcelog.github.com/articles/pagi_tutorial_create_voip_telephony_application_for_asterisk_with_agi_and_php.html)
* [An example IVR application that includes unit tests is available here](https://github.com/marcelog/Pagi-App-And-Test-Example)
* [Professional Telephony Applications at hand](http://sdjournal.org/a-practical-introduction-to-functional-programming-with-php-sdj-issue-released/) The march edition of [Software Developer Journal](http://sdjournal.org/) features a complete article about writing telephony applications with PAMI and PAGI.
# Installing
Add this library to your [Composer](https://packagist.org/) configuration. In
composer.json:
```json
"require": {
"marcelog/pagi": "2.*"
}
```
# Using it
First, make sure you include the [autoloader shipped with composer](https://getcomposer.org/doc/01-basic-usage.md#autoloading):
```php
require __DIR__ . '/vendor/autoload.php';
```
# Quickstart
You can start by *docs/examples/quickstart* for a very basic example. You'll need something like this in your dialplan:
[default]
exten => 1,1,AGI(/path/to/PAGI/docs/examples/quickstart/run.sh,a,b,c,d)
exten => 1,n,Hangup
# Testing IVR applications
A mocked pagi client is included to easily test your ivr applications. See
**docs/examples/mock** to see an example of how to use it.
# Features
## Nodes
For a tutorial about nodes, see [this article](http://marcelog.github.com/articles/pagi_node_call_flow_easy_telephony_application_for_asterisk_php.html)
Simple Call Flow Nodes are available (see **docs/examples/node/example.php**). Using
nodes will let you simplify how you build and test your ivr applications. Nodes
are an abstraction layer above the pagi client, and support:
* Prompts mixing sound files, playing numbers/digits/datetime's.
* Cancel and End Of Input digits.
* Validator callbacks for inputs, can optionally specify 1 or more sound files
to play when the validation fails.
* Callbacks for invalid and valid inputs.
* Optional sound when no input.
* Maximum valid input attempts.
* Optional sound when maximum attempts has been reached.
* Expecting at least/at most/exactly N digits per input.
* Timeout between digits in more-than-1 digit inputs.
* Timeout per input attempt.
* Retry Attempts for valid inputs.
* And much more!
The NodeController will let you control the call flow of your application, by
registering nodes and actions based on node results. Thus, you can jump from
one node to the other on cancel or complete inputs, hangup the call, execute a
callback, etc. For an example, see docs/examples/nodecontroller/example.php
An article about the node controller is available [here](http://marcelog.github.com/articles/making_your_ivr_nodes_call_flow_with_pagi_and_php_asterisk.html)
## AutoDial
CallFiles are supported. You can also schedule a call in the future.
## Fax
Sending and receiving faxes is supported using spandsp (applications SendFax
and ReceiveFax).
## Available Facades
* PAGI\Client\CDR: Provided to access cdr variables.
* PAGI\Client\ChannelVariables: Provided to access channel variables and asterisk
environment variables.
* PAGI\Client\CallerID: Provided to access caller id variables.
* PAGI\Client\Result: Provided to wrap up the result for agi commands.
* PAGI\CallSpool\CallFile: Call file facade.
* PAGI\CallSpool\CallSpool: Call spool facade.
* PAGI\Logger\Asterisk: Provides access to asterisk logger (see logger.conf in
your asterisk installation).
## Results
For every operation, a Result is provided. Some operations decorate this
Result to add functionality, like PlayResult, ReadResult, etc. For example,
a stream file will return a PlayResult, which decorates a ReadResult which
in turn, decorated a Result.
* PAGI\Client\DialResult
* PAGI\Client\ExecResult
* PAGI\Client\ReadResult
* PAGI\Client\PlayResult
* PAGI\Client\FaxResult
## Debugging, logging
You can optionally set a [PSR-3](http://www.php-fig.org/psr/psr-3/) compatible logger:
```php
$pagi->setLogger($logger);
```
By default, the client will use the [NullLogger](http://www.php-fig.org/psr/psr-3/#1-4-helper-classes-and-interfaces).
# Developers
This project uses [phing](https://www.phing.info/). Current tasks include:
* test: Runs [PHPUnit](https://phpunit.de/).
* cs: Runs [CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer).
* doc: Runs [PhpDocumentor](http://www.phpdoc.org/).
* md: runs [PHPMD](http://phpmd.org/).
* build: This is the default task, and will run all the other tasks.
## Running a phing task
To run a task, just do:
```sh
vendor/bin/phing build
```
## Contributing
To contribute:
* Make sure you open a **concise** and **short** pull request.
* Throw in any needed unit tests to accomodate the new code or the
changes involved.
* Run `phing` and make sure everything is ok before submitting the pull
request (make phpmd and CodeSniffer happy, also make sure that phpDocumentor
does not throw any warnings, since all our documentation is automatically
generated).
* Your code must comply with [PSR-2](http://www.php-fig.org/psr/psr-2/),
CodeSniffer should take care of that.
LICENSE
=======
Copyright 2011 Marcelo Gornstein <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
<?xml version="1.0"?>
<project
name="php-sdk"
default="build"
basedir="."
description="PAGI Asterisk Gateway Interface (AGI) client for PHP">
<target name="install">
<exec command="./composer.phar install" checkreturn="true" passthru="true"/>
<exec command="./composer.phar update" checkreturn="true" passthru="true"/>
</target>
<target name="clean">
<delete dir="build"/>
</target>
<target name="prepare">
<mkdir dir="build" mode="0755"/>
<mkdir dir="build/doc" mode="0755"/>
<mkdir dir="build/doc/xml" mode="0755"/>
<mkdir dir="build/doc/html" mode="0755"/>
<mkdir dir="build/doc/md" mode="0755"/>
<mkdir dir="build/logs" mode="0755"/>
<mkdir dir="build/coverage-html" mode="0755"/>
</target>
<target name="cpd">
<exec command="vendor/bin/phpcpd --fuzzy src"
checkreturn="true"
passthru="true"/>
</target>
<target name="md">
<exec command="vendor/bin/phpmd ./src text cleancode,codesize,controversial,design,naming,unusedcode"
checkreturn="false"
passthru="true"/>
</target>
<target name="cs">
<exec command="vendor/bin/phpcs --standard=PSR2 src/*"
checkreturn="true"
passthru="true"/>
</target>
<target name="docxml">
<exec command="vendor/bin/phpdoc --template=xml -t build/doc/xml -d src --validate --sourcecode --force --log"
checkreturn="true"
passthru="true"/>
</target>
<target name="dochtml">
<exec command="vendor/bin/phpdoc -t build/doc/html -d src --validate --sourcecode --force --log"
checkreturn="true"
passthru="true"/>
</target>
<target name="docmd">
<exec dir="build/doc/md" command="../../../vendor/bin/phpdocmd ../xml/structure.xml"
checkreturn="true"
passthru="true"/>
<copy todir="doc" overwrite="true">
<fileset dir="build/doc/md">
<include name="*.md" />
</fileset>
</copy>
</target>
<target name="test">
<exec command="vendor/bin/phpunit -v --debug -c test/resources/phpunit.xml"
checkreturn="true"
passthru="true"/>
</target>
<target name="build" depends="clean, prepare, cpd, cs, md, doc, test"/>
<target name="doc" depends="docxml, dochtml, docmd"/>
</project>
\ No newline at end of file
{
"name": "marcelog/pagi",
"type": "library",
"description": "Asterisk Gateway Interface (AGI) client for PHP, suitable to make telephony applications using call flow nodes",
"keywords": ["asterisk","agi","client","call","flow","node","ivr","telephony","voip"],
"homepage": "http://marcelog.github.com/PAGI",
"license": "Apache-2.0",
"authors": [
{
"name": "Marcelo Gornstein",
"email": "[email protected]",
"homepage": "http://marcelog.github.com/",
"role": "Developer"
}
],
"autoload": {
"psr-4": {
"PAGI\\": "src/PAGI"
}
},
"require": {
"php": ">=5.3.3",
"psr/log": ">= 1.0.0"
},
"require-dev": {
"phpunit/phpunit": "4.*",
"monolog/monolog": "1.*",
"squizlabs/php_codesniffer": "2.*",
"phpdocumentor/phpdocumentor": "2.*",
"phing/phing": "2.*",
"phpmd/phpmd": "2.*",
"satooshi/php-coveralls": "0.*",
"evert/phpdoc-md" : "~0.1.1",
"codeclimate/php-test-reporter": "dev-master",
"sebastian/phpcpd": "*"
}
}
API Index
=========
* PAGI
* PAGI\Application
* [PAGIApplication](PAGI-Application-PAGIApplication.md)
* PAGI\CallerId
* [ICallerId](PAGI-CallerId-ICallerId.md)
* PAGI\CallerId\Impl
* [CallerIdFacade](PAGI-CallerId-Impl-CallerIdFacade.md)
* PAGI\CallSpool
* [CallFile](PAGI-CallSpool-CallFile.md)
* PAGI\CallSpool\Exception
* [CallSpoolException](PAGI-CallSpool-Exception-CallSpoolException.md)
* [ICallSpool](PAGI-CallSpool-ICallSpool.md)
* PAGI\CallSpool\Impl
* [CallSpoolImpl](PAGI-CallSpool-Impl-CallSpoolImpl.md)
* PAGI\CDR
* [ICDR](PAGI-CDR-ICDR.md)
* PAGI\CDR\Impl
* [CDRFacade](PAGI-CDR-Impl-CDRFacade.md)
* PAGI\ChannelVariables
* [IChannelVariables](PAGI-ChannelVariables-IChannelVariables.md)
* PAGI\ChannelVariables\Impl
* [ChannelVariablesFacade](PAGI-ChannelVariables-Impl-ChannelVariablesFacade.md)
* PAGI\Client
* [AbstractClient](PAGI-Client-AbstractClient.md)
* [ChannelStatus](PAGI-Client-ChannelStatus.md)
* [IClient](PAGI-Client-IClient.md)
* PAGI\Client\Impl
* [ClientImpl](PAGI-Client-Impl-ClientImpl.md)
* [MockedClientImpl](PAGI-Client-Impl-MockedClientImpl.md)
* PAGI\Client\Result
* [AmdResult](PAGI-Client-Result-AmdResult.md)
* [DataReadResult](PAGI-Client-Result-DataReadResult.md)
* [DialResult](PAGI-Client-Result-DialResult.md)
* [DigitReadResult](PAGI-Client-Result-DigitReadResult.md)
* [ExecResult](PAGI-Client-Result-ExecResult.md)
* [FaxResult](PAGI-Client-Result-FaxResult.md)
* [IReadResult](PAGI-Client-Result-IReadResult.md)
* [IResult](PAGI-Client-Result-IResult.md)
* [PlayResult](PAGI-Client-Result-PlayResult.md)
* [ReadResultDecorator](PAGI-Client-Result-ReadResultDecorator.md)
* [RecordResult](PAGI-Client-Result-RecordResult.md)
* [Result](PAGI-Client-Result-Result.md)
* [ResultDecorator](PAGI-Client-Result-ResultDecorator.md)
* PAGI\DialDescriptor
* [DAHDIDialDescriptor](PAGI-DialDescriptor-DAHDIDialDescriptor.md)
* [DialDescriptor](PAGI-DialDescriptor-DialDescriptor.md)
* [LocalDialDescriptor](PAGI-DialDescriptor-LocalDialDescriptor.md)
* [SIPDialDescriptor](PAGI-DialDescriptor-SIPDialDescriptor.md)
* PAGI\Exception
* [ChannelDownException](PAGI-Exception-ChannelDownException.md)
* [DatabaseInvalidEntryException](PAGI-Exception-DatabaseInvalidEntryException.md)
* [ExecuteCommandException](PAGI-Exception-ExecuteCommandException.md)
* [InvalidCommandException](PAGI-Exception-InvalidCommandException.md)
* [MockedException](PAGI-Exception-MockedException.md)
* [PAGIException](PAGI-Exception-PAGIException.md)
* [RecordException](PAGI-Exception-RecordException.md)
* [SoundFileException](PAGI-Exception-SoundFileException.md)
* PAGI\Logger
* PAGI\Logger\Asterisk
* [IAsteriskLogger](PAGI-Logger-Asterisk-IAsteriskLogger.md)
* PAGI\Logger\Asterisk\Impl
* [AsteriskLoggerImpl](PAGI-Logger-Asterisk-Impl-AsteriskLoggerImpl.md)
* [MockedAsteriskLoggerImpl](PAGI-Logger-Asterisk-Impl-MockedAsteriskLoggerImpl.md)
* PAGI\Node
* PAGI\Node\Exception
* [NodeException](PAGI-Node-Exception-NodeException.md)
* [MockedNode](PAGI-Node-MockedNode.md)
* [Node](PAGI-Node-Node.md)
* [NodeActionCommand](PAGI-Node-NodeActionCommand.md)
* [NodeController](PAGI-Node-NodeController.md)
PAGI\Application\PAGIApplication
===============
Parent class for all PAGIApplications.
PHP Version 5
* Class name: PAGIApplication
* Namespace: PAGI\Application
* This is an **abstract** class
Properties
----------
### $logger
protected \PAGI\Application\Logger $logger
PSR-3 logger.
* Visibility: **protected**
### $agiClient
private \PAGI\Client\IClient $agiClient
AGI Client.
* Visibility: **private**
Methods
-------
### init
void PAGI\Application\PAGIApplication::init()
Called to initialize the application
* Visibility: **public**
* This method is **abstract**.
### shutdown
void PAGI\Application\PAGIApplication::shutdown()
Called when PHPvm is shutting down.
* Visibility: **public**
* This method is **abstract**.
### run
void PAGI\Application\PAGIApplication::run()
Called to run the application, after calling init().
* Visibility: **public**
* This method is **abstract**.
### errorHandler
boolean PAGI\Application\PAGIApplication::errorHandler(integer $type, string $message, string $file, integer $line)
Your error handler. Be careful when implementing this one.
* Visibility: **public**
* This method is **abstract**.
#### Arguments
* $type **integer** - &lt;p&gt;PHP Error type constant.&lt;/p&gt;
* $message **string** - &lt;p&gt;Human readable error message string.&lt;/p&gt;
* $file **string** - &lt;p&gt;File that triggered the error.&lt;/p&gt;
* $line **integer** - &lt;p&gt;Line that triggered the error.&lt;/p&gt;
### signalHandler
void PAGI\Application\PAGIApplication::signalHandler(integer $signal)
Your signal handler. Be careful when implementing this one.
* Visibility: **public**
* This method is **abstract**.
#### Arguments
* $signal **integer** - &lt;p&gt;Signal catched.&lt;/p&gt;
### getAgi
\PAGI\Client\IClient PAGI\Application\PAGIApplication::getAgi()
Returns AGI Client.
* Visibility: **protected**
### setLogger
void PAGI\Application\PAGIApplication::setLogger(\PAGI\Application\Psr\Log\LoggerInterface $logger)
Sets the logger implementation.
* Visibility: **public**
#### Arguments
* $logger **PAGI\Application\Psr\Log\LoggerInterface** - &lt;p&gt;The PSR3-Logger&lt;/p&gt;
### __construct
void PAGI\Application\PAGIApplication::__construct(array $properties)
Constructor. Will call set_error_handler() and pcntl_signal() to setup
your errorHandler() and signalHandler(). Also will call
register_shutdown_function() to register your shutdown() function.
* Visibility: **public**
#### Arguments
* $properties **array** - &lt;p&gt;Optional additional properties.&lt;/p&gt;
PAGI\CDR\ICDR
===============
CDR facade. Use this to access cdr variables.
PHP Version 5
* Interface name: ICDR
* Namespace: PAGI\CDR
* This is an **interface**
Methods
-------
### setUserfield
void PAGI\CDR\ICDR::setUserfield(string $value)
Set userfileds for cdr. CDR(userfield).
* Visibility: **public**
#### Arguments
* $value **string** - &lt;p&gt;New userfields to use.&lt;/p&gt;
### getUserfield
string PAGI\CDR\ICDR::getUserfield()
The channels uses specified field (read-write). CDR(userfield).
* Visibility: **public**
### getUniqueId
string PAGI\CDR\ICDR::getUniqueId()
The channel uniqueid. CDR(uniqueid).
* Visibility: **public**
### setAccountCode
void PAGI\CDR\ICDR::setAccountCode(string $value)
Sets account code. CDR(accountcode).
* Visibility: **public**
#### Arguments
* $value **string** - &lt;p&gt;New account code.&lt;/p&gt;
### getAccountCode
string PAGI\CDR\ICDR::getAccountCode()
The channel account code. CDR(accountcode).
* Visibility: **public**
### getAMAFlags
string PAGI\CDR\ICDR::getAMAFlags()
DOCUMENTATION, BILL, IGNORE etc. CDR(amaflags).
* Visibility: **public**
### getStatus
string PAGI\CDR\ICDR::getStatus()
Call result. CDR(disposition).
* Visibility: **public**
### getAnswerLength
string PAGI\CDR\ICDR::getAnswerLength()
Total answered time for the call in seconds. CDR(billsec).
* Visibility: **public**
### getTotalLength
string PAGI\CDR\ICDR::getTotalLength()
Total length of the call in seconds. CDR(duration).
* Visibility: **public**
### getEndTime
string PAGI\CDR\ICDR::getEndTime()
Time the call ended. CDR(end).
* Visibility: **public**
### getAnswerTime
string PAGI\CDR\ICDR::getAnswerTime()
Time the call was answered. CDR(answer).
* Visibility: **public**
### getStartTime
string PAGI\CDR\ICDR::getStartTime()
Time the call started. CDR(start).
* Visibility: **public**
### getLastAppData
string PAGI\CDR\ICDR::getLastAppData()
Returns Last application data. CDR(lastdata).
* Visibility: **public**
### getLastApp
string PAGI\CDR\ICDR::getLastApp()
Returns Last application. CDR(lastapp).
* Visibility: **public**
### getChannel
string PAGI\CDR\ICDR::getChannel()
Returns origin channel. CDR(channel).
* Visibility: **public**
### getDestinationChannel
string PAGI\CDR\ICDR::getDestinationChannel()
Returns destination channel. CDR(dstchannel).
* Visibility: **public**
### getCallerId
string PAGI\CDR\ICDR::getCallerId()
Returns caller id. CDR(clid).
* Visibility: **public**
### getSource
string PAGI\CDR\ICDR::getSource()
Returns origin. CDR(src).
* Visibility: **public**
### getDestination
string PAGI\CDR\ICDR::getDestination()
Returns destination. CDR(dst).
* Visibility: **public**
### getDestinationContext
string PAGI\CDR\ICDR::getDestinationContext()
Returns destination context. CDR(dcontext).
* Visibility: **public**
### getCustom
string PAGI\CDR\ICDR::getCustom(string $name)
Returns a custom field in the cdr. CDR(name)
* Visibility: **public**
#### Arguments
* $name **string** - &lt;p&gt;Field name.&lt;/p&gt;
### setCustom
void PAGI\CDR\ICDR::setCustom(string $name, string $value)
Sets a custom field in the cdr. CDR(name).
* Visibility: **public**
#### Arguments
* $name **string** - &lt;p&gt;Field name.&lt;/p&gt;
* $value **string** - &lt;p&gt;Field value.&lt;/p&gt;
PAGI\CDR\Impl\CDRFacade
===============
CDR Facade.
If the channel has a cdr, that cdr record has it's own set of variables which
can be accessed just like channel variables. The following builtin variables
are available and, unless specified, read-only.
${CDR(clid)} Caller ID
${CDR(src)} Source
${CDR(dst)} Destination
${CDR(dcontext)} Destination context
${CDR(channel)} Channel name
${CDR(dstchannel)} Destination channel
${CDR(lastapp)} Last app executed
${CDR(lastdata)} Last app's arguments
${CDR(start)} Time the call started.
${CDR(answer)} Time the call was answered.
${CDR(end)} Time the call ended.
${CDR(duration)} Duration of the call.
${CDR(billsec)} Duration of the call once it was answered.
${CDR(disposition)} ANSWERED, NO ANSWER, BUSY
${CDR(amaflags)} DOCUMENTATION, BILL, IGNORE etc
${CDR(accountcode)} The channel's account code (read-write).
${CDR(uniqueid)} The channel's unique id.
${CDR(userfield)} The channels uses specified field (read-write).
In addition, you can set your own extra variables with a traditional
Set(CDR(var)=val) to anything you want.
NOTE Some CDR values (eg: duration & billsec) can't be accessed until the call
has terminated. As of 91617, those values will be calculated on-demand if
requested. Until that makes it into a stable release, you can set
endbeforehexten=yes in cdr.conf, and then use the "hangup" context to wrap
up your call.
PHP Version 5
* Class name: CDRFacade
* Namespace: PAGI\CDR\Impl
* This class implements: [PAGI\CDR\ICDR](PAGI-CDR-ICDR.md)
Properties
----------
### $client
private \PAGI\Client\IClient $client
AGI Client, needed to access cdr data.
* Visibility: **private**
Methods
-------
### setUserfield
void PAGI\CDR\ICDR::setUserfield(string $value)
Set userfileds for cdr. CDR(userfield).
* Visibility: **public**
* This method is defined by [PAGI\CDR\ICDR](PAGI-CDR-ICDR.md)
#### Arguments
* $value **string** - &lt;p&gt;New userfields to use.&lt;/p&gt;
### getUserfield
string PAGI\CDR\ICDR::getUserfield()
The channels uses specified field (read-write). CDR(userfield).
* Visibility: **public**
* This method is defined by [PAGI\CDR\ICDR](PAGI-CDR-ICDR.md)
### getUniqueId
string PAGI\CDR\ICDR::getUniqueId()
The channel uniqueid. CDR(uniqueid).
* Visibility: **public**
* This method is defined by [PAGI\CDR\ICDR](PAGI-CDR-ICDR.md)
### setAccountCode
void PAGI\CDR\ICDR::setAccountCode(string $value)
Sets account code. CDR(accountcode).
* Visibility: **public**
* This method is defined by [PAGI\CDR\ICDR](PAGI-CDR-ICDR.md)
#### Arguments
* $value **string** - &lt;p&gt;New account code.&lt;/p&gt;
### getAccountCode
string PAGI\CDR\ICDR::getAccountCode()
The channel account code. CDR(accountcode).
* Visibility: **public**
* This method is defined by [PAGI\CDR\ICDR](PAGI-CDR-ICDR.md)
### getAMAFlags
string PAGI\CDR\ICDR::getAMAFlags()
DOCUMENTATION, BILL, IGNORE etc. CDR(amaflags).
* Visibility: **public**
* This method is defined by [PAGI\CDR\ICDR](PAGI-CDR-ICDR.md)
### getStatus
string PAGI\CDR\ICDR::getStatus()
Call result. CDR(disposition).
* Visibility: **public**
* This method is defined by [PAGI\CDR\ICDR](PAGI-CDR-ICDR.md)
### getAnswerLength
string PAGI\CDR\ICDR::getAnswerLength()
Total answered time for the call in seconds. CDR(billsec).
* Visibility: **public**
* This method is defined by [PAGI\CDR\ICDR](PAGI-CDR-ICDR.md)
### getTotalLength
string PAGI\CDR\ICDR::getTotalLength()
Total length of the call in seconds. CDR(duration).
* Visibility: **public**
* This method is defined by [PAGI\CDR\ICDR](PAGI-CDR-ICDR.md)
### getEndTime
string PAGI\CDR\ICDR::getEndTime()
Time the call ended. CDR(end).
* Visibility: **public**
* This method is defined by [PAGI\CDR\ICDR](PAGI-CDR-ICDR.md)
### getAnswerTime
string PAGI\CDR\ICDR::getAnswerTime()
Time the call was answered. CDR(answer).
* Visibility: **public**
* This method is defined by [PAGI\CDR\ICDR](PAGI-CDR-ICDR.md)
### getStartTime
string PAGI\CDR\ICDR::getStartTime()
Time the call started. CDR(start).
* Visibility: **public**
* This method is defined by [PAGI\CDR\ICDR](PAGI-CDR-ICDR.md)
### getLastAppData
string PAGI\CDR\ICDR::getLastAppData()
Returns Last application data. CDR(lastdata).
* Visibility: **public**
* This method is defined by [PAGI\CDR\ICDR](PAGI-CDR-ICDR.md)
### getLastApp
string PAGI\CDR\ICDR::getLastApp()
Returns Last application. CDR(lastapp).
* Visibility: **public**
* This method is defined by [PAGI\CDR\ICDR](PAGI-CDR-ICDR.md)
### getChannel
string PAGI\CDR\ICDR::getChannel()
Returns origin channel. CDR(channel).
* Visibility: **public**
* This method is defined by [PAGI\CDR\ICDR](PAGI-CDR-ICDR.md)
### getDestinationChannel
string PAGI\CDR\ICDR::getDestinationChannel()
Returns destination channel. CDR(dstchannel).
* Visibility: **public**
* This method is defined by [PAGI\CDR\ICDR](PAGI-CDR-ICDR.md)
### getCallerId
string PAGI\CDR\ICDR::getCallerId()
Returns caller id. CDR(clid).
* Visibility: **public**
* This method is defined by [PAGI\CDR\ICDR](PAGI-CDR-ICDR.md)
### getSource
string PAGI\CDR\ICDR::getSource()
Returns origin. CDR(src).
* Visibility: **public**
* This method is defined by [PAGI\CDR\ICDR](PAGI-CDR-ICDR.md)
### getDestination
string PAGI\CDR\ICDR::getDestination()
Returns destination. CDR(dst).
* Visibility: **public**
* This method is defined by [PAGI\CDR\ICDR](PAGI-CDR-ICDR.md)
### getDestinationContext
string PAGI\CDR\ICDR::getDestinationContext()
Returns destination context. CDR(dcontext).
* Visibility: **public**
* This method is defined by [PAGI\CDR\ICDR](PAGI-CDR-ICDR.md)
### getCustom
string PAGI\CDR\ICDR::getCustom(string $name)
Returns a custom field in the cdr. CDR(name)
* Visibility: **public**
* This method is defined by [PAGI\CDR\ICDR](PAGI-CDR-ICDR.md)
#### Arguments
* $name **string** - &lt;p&gt;Field name.&lt;/p&gt;
### setCustom
void PAGI\CDR\ICDR::setCustom(string $name, string $value)
Sets a custom field in the cdr. CDR(name).
* Visibility: **public**
* This method is defined by [PAGI\CDR\ICDR](PAGI-CDR-ICDR.md)
#### Arguments
* $name **string** - &lt;p&gt;Field name.&lt;/p&gt;
* $value **string** - &lt;p&gt;Field value.&lt;/p&gt;
### getCDRVariable
string PAGI\CDR\Impl\CDRFacade::getCDRVariable(string $name)
Access AGI client to get the variables.
* Visibility: **protected**
#### Arguments
* $name **string** - &lt;p&gt;Variable name.&lt;/p&gt;
### setCDRVariable
void PAGI\CDR\Impl\CDRFacade::setCDRVariable(string $name, string $value)
Access AGI client to set the variable.
* Visibility: **protected**
#### Arguments
* $name **string** - &lt;p&gt;Variable name.&lt;/p&gt;
* $value **string** - &lt;p&gt;Value.&lt;/p&gt;
### __construct
void PAGI\CDR\Impl\CDRFacade::__construct(\PAGI\Client\IClient $client)
Constructor.
* Visibility: **public**
#### Arguments
* $client **[PAGI\Client\IClient](PAGI-Client-IClient.md)** - &lt;p&gt;AGI Client.&lt;/p&gt;
PAGI\CallSpool\CallFile
===============
A call file facade.
PHP Version 5
* Class name: CallFile
* Namespace: PAGI\CallSpool
Properties
----------
### $parameters
private array<mixed,string> $parameters
Parameters.
* Visibility: **private**
### $variables
private array<mixed,string> $variables
Variables.
* Visibility: **private**
Methods
-------
### getParameter
string PAGI\CallSpool\CallFile::getParameter(string $key)
Returns the value for the given parameter.
* Visibility: **protected**
#### Arguments
* $key **string** - &lt;p&gt;Parameter name.&lt;/p&gt;
### setParameter
void PAGI\CallSpool\CallFile::setParameter(string $key, string $value)
Sets a given parameter with the given value.
* Visibility: **protected**
#### Arguments
* $key **string** - &lt;p&gt;Parameter name.&lt;/p&gt;
* $value **string** - &lt;p&gt;Value.&lt;/p&gt;
### getVariable
string PAGI\CallSpool\CallFile::getVariable(string $key)
Returns the value for the given variable.
* Visibility: **public**
#### Arguments
* $key **string** - &lt;p&gt;Variable name.&lt;/p&gt;
### setVariable
void PAGI\CallSpool\CallFile::setVariable(string $key, string $value)
Sets a given variable with the given value.
* Visibility: **public**
#### Arguments
* $key **string** - &lt;p&gt;Variable name.&lt;/p&gt;
* $value **string** - &lt;p&gt;Value.&lt;/p&gt;
### getChannel
string PAGI\CallSpool\CallFile::getChannel()
Returns channel to use for the call.
* Visibility: **public**
### getCallerId
string PAGI\CallSpool\CallFile::getCallerId()
Returns Caller ID, Please note: It may not work if you do not respect
the format: CallerID: "Some Name" <1234>
* Visibility: **public**
### setCallerId
void PAGI\CallSpool\CallFile::setCallerId(string $value)
Sets the Caller ID, Please note: It may not work if you do not respect
the format: CallerID: "Some Name" <1234>
* Visibility: **public**
#### Arguments
* $value **string** - &lt;p&gt;Value to set.&lt;/p&gt;
### getWaitTime
integer PAGI\CallSpool\CallFile::getWaitTime()
Returns seconds to wait for an answer. Default is 45.
* Visibility: **public**
### setWaitTime
void PAGI\CallSpool\CallFile::setWaitTime(integer $value)
Sets seconds to wait for an answer. Default is 45.
* Visibility: **public**
#### Arguments
* $value **integer** - &lt;p&gt;Value to set.&lt;/p&gt;
### getMaxRetries
integer PAGI\CallSpool\CallFile::getMaxRetries()
Returns number of retries before failing (not including the initial
attempt, e.g. 0 = total of 1 attempt to make the call). Default is 0.
* Visibility: **public**
### setMaxRetries
void PAGI\CallSpool\CallFile::setMaxRetries(integer $value)
Sets number of retries before failing (not including the initial
attempt, e.g. 0 = total of 1 attempt to make the call). Default is 0.
* Visibility: **public**
#### Arguments
* $value **integer** - &lt;p&gt;Value to set.&lt;/p&gt;
### getRetryTime
integer PAGI\CallSpool\CallFile::getRetryTime()
Returns seconds between retries, Don't hammer an unavailable phone.
Default is 300 (5 min).
* Visibility: **public**
### setRetryTime
void PAGI\CallSpool\CallFile::setRetryTime(integer $value)
Sets seconds between retries, Don't hammer an unavailable phone.
Default is 300 (5 min).
* Visibility: **public**
#### Arguments
* $value **integer** - &lt;p&gt;Value to set.&lt;/p&gt;
### getAccount
string PAGI\CallSpool\CallFile::getAccount()
Returns account code to use for this call.
* Visibility: **public**
### setAccount
void PAGI\CallSpool\CallFile::setAccount(string $value)
Sets account code to use for this call.
* Visibility: **public**
#### Arguments
* $value **string** - &lt;p&gt;Value to set.&lt;/p&gt;
### getContext
string PAGI\CallSpool\CallFile::getContext()
Returns context to use for this call when answered.
* Visibility: **public**
### setContext
void PAGI\CallSpool\CallFile::setContext(string $value)
Sets context to use for this call when answered.
* Visibility: **public**
#### Arguments
* $value **string** - &lt;p&gt;Value to set.&lt;/p&gt;
### getPriority
string PAGI\CallSpool\CallFile::getPriority()
Returns priority to use for this call when answered.
* Visibility: **public**
### setPriority
void PAGI\CallSpool\CallFile::setPriority(string $value)
Sets priority to use for this call when answered.
* Visibility: **public**
#### Arguments
* $value **string** - &lt;p&gt;Value to set.&lt;/p&gt;
### getExtension
string PAGI\CallSpool\CallFile::getExtension()
Returns extension to use for this call when answered.
* Visibility: **public**
### setExtension
void PAGI\CallSpool\CallFile::setExtension(string $value)
Sets extension to use for this call when answered.
* Visibility: **public**
#### Arguments
* $value **string** - &lt;p&gt;Value to set.&lt;/p&gt;
### getApplication
string PAGI\CallSpool\CallFile::getApplication()
Returns Asterisk Application to run (use instead of specifiying context,
extension and priority)
* Visibility: **public**
### setApplication
void PAGI\CallSpool\CallFile::setApplication(string $value)
Sets Asterisk Application to run (use instead of specifiying context,
extension and priority)
* Visibility: **public**
#### Arguments
* $value **string** - &lt;p&gt;Value to set.&lt;/p&gt;
### getApplicationData
string PAGI\CallSpool\CallFile::getApplicationData()
Returns the options to be passed to application.
* Visibility: **public**
### setApplicationData
void PAGI\CallSpool\CallFile::setApplicationData(array $options)
Sets the options to be passed to application.
* Visibility: **public**
#### Arguments
* $options **array**
### getAlwaysDelete
boolean PAGI\CallSpool\CallFile::getAlwaysDelete()
If the file's modification time is in the future, the call file will not
be deleted
* Visibility: **public**
### setAlwaysDelete
void PAGI\CallSpool\CallFile::setAlwaysDelete(boolean $value)
If the file's modification time is in the future, the call file will not
be deleted
* Visibility: **public**
#### Arguments
* $value **boolean** - &lt;p&gt;Value to set.&lt;/p&gt;
### getArchive
boolean PAGI\CallSpool\CallFile::getArchive()
Sets if should move to subdir "outgoing_done" with "Status: value",
where value can be Completed, Expired or Failed.
* Visibility: **public**
### setArchive
void PAGI\CallSpool\CallFile::setArchive(boolean $value)
Sets if should move to subdir "outgoing_done" with "Status: value",
where value can be Completed, Expired or Failed.
* Visibility: **public**
#### Arguments
* $value **boolean** - &lt;p&gt;Value to set.&lt;/p&gt;
### serialize
string PAGI\CallSpool\CallFile::serialize()
Returns the text describing this call file, ready to be spooled.
* Visibility: **public**
### unserialize
void PAGI\CallSpool\CallFile::unserialize(string $text)
Deconstructs a call file from the given text.
* Visibility: **public**
#### Arguments
* $text **string** - &lt;p&gt;A call file (intended to be pre-loaded, with
file_get_contents() or similar).&lt;/p&gt;
### __construct
void PAGI\CallSpool\CallFile::__construct(\PAGI\DialDescriptor\DialDescriptor $dialDescriptor)
Constructor.
* Visibility: **public**
#### Arguments
* $dialDescriptor **[PAGI\DialDescriptor\DialDescriptor](PAGI-DialDescriptor-DialDescriptor.md)**
PAGI\CallSpool\Exception\CallSpoolException
===============
This exception indicates an error related to the call spool.
PHP Version 5
* Class name: CallSpoolException
* Namespace: PAGI\CallSpool\Exception
* Parent class: [PAGI\Exception\PAGIException](PAGI-Exception-PAGIException.md)
PAGI\CallSpool\ICallSpool
===============
An interface to access asterisk call spool.
PHP Version 5
* Interface name: ICallSpool
* Namespace: PAGI\CallSpool
* This is an **interface**
Methods
-------
### spool
void PAGI\CallSpool\ICallSpool::spool(\PAGI\CallSpool\CallFile $call, integer $schedule)
Spools the given call.
* Visibility: **public**
#### Arguments
* $call **[PAGI\CallSpool\CallFile](PAGI-CallSpool-CallFile.md)** - &lt;p&gt;Call to spool.&lt;/p&gt;
* $schedule **integer** - &lt;p&gt;Optional unix timestamp to schedule the call.&lt;/p&gt;
PAGI\CallSpool\Impl\CallSpoolImpl
===============
An implementation for asterisk call spool.
PHP Version 5
* Class name: CallSpoolImpl
* Namespace: PAGI\CallSpool\Impl
* This class implements: [PAGI\CallSpool\ICallSpool](PAGI-CallSpool-ICallSpool.md)
Properties
----------
### $tmpDir
private string $tmpDir = '/tmp'
Where to temporary generate call files.
* Visibility: **private**
### $spoolDir
private string $spoolDir = '/var/spool/asterisk'
Asterisk spool directory.
* Visibility: **private**
### $instance
private \PAGI\CallSpool\Impl\CallSpoolImpl $instance = false
Current instance.
* Visibility: **private**
* This property is **static**.
Methods
-------
### getInstance
\PAGI\CallSpool\Impl\CallSpoolImpl PAGI\CallSpool\Impl\CallSpoolImpl::getInstance(array<mixed,string> $options)
Returns an instance for this spool/
* Visibility: **public**
* This method is **static**.
#### Arguments
* $options **array&lt;mixed,string&gt;** - &lt;p&gt;Configuration options.&lt;/p&gt;
### spool
void PAGI\CallSpool\ICallSpool::spool(\PAGI\CallSpool\CallFile $call, integer $schedule)
Spools the given call.
* Visibility: **public**
* This method is defined by [PAGI\CallSpool\ICallSpool](PAGI-CallSpool-ICallSpool.md)
#### Arguments
* $call **[PAGI\CallSpool\CallFile](PAGI-CallSpool-CallFile.md)** - &lt;p&gt;Call to spool.&lt;/p&gt;
* $schedule **integer** - &lt;p&gt;Optional unix timestamp to schedule the call.&lt;/p&gt;
### __construct
void PAGI\CallSpool\Impl\CallSpoolImpl::__construct(array<mixed,string> $options)
Constructor.
* Visibility: **private**
#### Arguments
* $options **array&lt;mixed,string&gt;** - &lt;p&gt;Options for this spool.&lt;/p&gt;
PAGI\CallerId\ICallerId
===============
AGI Caller id facade.
PHP Version 5
* Interface name: ICallerId
* Namespace: PAGI\CallerId
* This is an **interface**
Methods
-------
### setANI
void PAGI\CallerId\ICallerId::setANI(string $value)
Sets caller id ani. CALLERID(ani).
* Visibility: **public**
#### Arguments
* $value **string** - &lt;p&gt;ANI.&lt;/p&gt;
### getANI
string PAGI\CallerId\ICallerId::getANI()
Returns caller id ani. CALLERID(ani)
* Visibility: **public**
### setDNID
void PAGI\CallerId\ICallerId::setDNID(string $value)
Sets caller id dnid. CALLERID(dnid)
* Visibility: **public**
#### Arguments
* $value **string** - &lt;p&gt;DNID.&lt;/p&gt;
### getDNID
string PAGI\CallerId\ICallerId::getDNID()
Returns caller id dnid. CALLERID(dnid)
* Visibility: **public**
### setRDNIS
void PAGI\CallerId\ICallerId::setRDNIS(string $value)
Sets caller id rdnis. CALLERID(rdnis)
* Visibility: **public**
#### Arguments
* $value **string** - &lt;p&gt;RDNIS.&lt;/p&gt;
### getRDNIS
string PAGI\CallerId\ICallerId::getRDNIS()
Returns caller id rdnis. CALLERID(rdnis)
* Visibility: **public**
### setName
void PAGI\CallerId\ICallerId::setName(string $value)
Sets caller id name. CALLERID(name)
* Visibility: **public**
#### Arguments
* $value **string** - &lt;p&gt;Name.&lt;/p&gt;
### getName
string PAGI\CallerId\ICallerId::getName()
Returns caller id name. CALLERID(name)
* Visibility: **public**
### getNumber
string PAGI\CallerId\ICallerId::getNumber()
Returns caller id number. CALLERID(num)
* Visibility: **public**
### setNumber
void PAGI\CallerId\ICallerId::setNumber(string $value)
Sets caller id number. CALLERID(num)
* Visibility: **public**
#### Arguments
* $value **string** - &lt;p&gt;Number.&lt;/p&gt;
### setCallerPres
void PAGI\CallerId\ICallerId::setCallerPres(string $presentationMode)
Changes the caller id presentation mode.
* Visibility: **public**
#### Arguments
* $presentationMode **string** - &lt;p&gt;Can be one of:
allowed_not_screened - Presentation Allowed, Not Screened.
allowed_passed_screen - Presentation Allowed, Passed Screen.
allowed_failed_screen - Presentation Allowed, Failed Screen.
allowed - Presentation Allowed, Network Number.
prohib_not_screened - Presentation Prohibited, Not Screened.
prohib_passed_screen - Presentation Prohibited, Passed Screen.
prohib_failed_screen - Presentation Prohibited, Failed Screen.
prohib - Presentation Prohibited, Network Number.
unavailable - Number Unavailable.&lt;/p&gt;
PAGI\CallerId\Impl\CallerIdFacade
===============
AGI Caller id facade.
PHP Version 5
* Class name: CallerIdFacade
* Namespace: PAGI\CallerId\Impl
* This class implements: [PAGI\CallerId\ICallerId](PAGI-CallerId-ICallerId.md)
Properties
----------
### $client
private \PAGI\Client\IClient $client
Instance of client to access caller id variables.
* Visibility: **private**
Methods
-------
### setANI
void PAGI\CallerId\ICallerId::setANI(string $value)
Sets caller id ani. CALLERID(ani).
* Visibility: **public**
* This method is defined by [PAGI\CallerId\ICallerId](PAGI-CallerId-ICallerId.md)
#### Arguments
* $value **string** - &lt;p&gt;ANI.&lt;/p&gt;
### getANI
string PAGI\CallerId\ICallerId::getANI()
Returns caller id ani. CALLERID(ani)
* Visibility: **public**
* This method is defined by [PAGI\CallerId\ICallerId](PAGI-CallerId-ICallerId.md)
### setDNID
void PAGI\CallerId\ICallerId::setDNID(string $value)
Sets caller id dnid. CALLERID(dnid)
* Visibility: **public**
* This method is defined by [PAGI\CallerId\ICallerId](PAGI-CallerId-ICallerId.md)
#### Arguments
* $value **string** - &lt;p&gt;DNID.&lt;/p&gt;
### getDNID
string PAGI\CallerId\ICallerId::getDNID()
Returns caller id dnid. CALLERID(dnid)
* Visibility: **public**
* This method is defined by [PAGI\CallerId\ICallerId](PAGI-CallerId-ICallerId.md)
### setRDNIS
void PAGI\CallerId\ICallerId::setRDNIS(string $value)
Sets caller id rdnis. CALLERID(rdnis)
* Visibility: **public**
* This method is defined by [PAGI\CallerId\ICallerId](PAGI-CallerId-ICallerId.md)
#### Arguments
* $value **string** - &lt;p&gt;RDNIS.&lt;/p&gt;
### getRDNIS
string PAGI\CallerId\ICallerId::getRDNIS()
Returns caller id rdnis. CALLERID(rdnis)
* Visibility: **public**
* This method is defined by [PAGI\CallerId\ICallerId](PAGI-CallerId-ICallerId.md)
### setName
void PAGI\CallerId\ICallerId::setName(string $value)
Sets caller id name. CALLERID(name)
* Visibility: **public**
* This method is defined by [PAGI\CallerId\ICallerId](PAGI-CallerId-ICallerId.md)
#### Arguments
* $value **string** - &lt;p&gt;Name.&lt;/p&gt;
### getName
string PAGI\CallerId\ICallerId::getName()
Returns caller id name. CALLERID(name)
* Visibility: **public**
* This method is defined by [PAGI\CallerId\ICallerId](PAGI-CallerId-ICallerId.md)
### getNumber
string PAGI\CallerId\ICallerId::getNumber()
Returns caller id number. CALLERID(num)
* Visibility: **public**
* This method is defined by [PAGI\CallerId\ICallerId](PAGI-CallerId-ICallerId.md)
### setNumber
void PAGI\CallerId\ICallerId::setNumber(string $value)
Sets caller id number. CALLERID(num)
* Visibility: **public**
* This method is defined by [PAGI\CallerId\ICallerId](PAGI-CallerId-ICallerId.md)
#### Arguments
* $value **string** - &lt;p&gt;Number.&lt;/p&gt;
### getCallerIdVariable
string PAGI\CallerId\Impl\CallerIdFacade::getCallerIdVariable(string $name)
Access AGI client to get the variables.
* Visibility: **protected**
#### Arguments
* $name **string** - &lt;p&gt;Variable name.&lt;/p&gt;
### setCallerIdVariable
void PAGI\CallerId\Impl\CallerIdFacade::setCallerIdVariable(string $name, string $value)
Access AGI client to set the variable.
* Visibility: **protected**
#### Arguments
* $name **string** - &lt;p&gt;Variable name.&lt;/p&gt;
* $value **string** - &lt;p&gt;Value.&lt;/p&gt;
### setCallerPres
void PAGI\CallerId\ICallerId::setCallerPres(string $presentationMode)
Changes the caller id presentation mode.
* Visibility: **public**
* This method is defined by [PAGI\CallerId\ICallerId](PAGI-CallerId-ICallerId.md)
#### Arguments
* $presentationMode **string** - &lt;p&gt;Can be one of:
allowed_not_screened - Presentation Allowed, Not Screened.
allowed_passed_screen - Presentation Allowed, Passed Screen.
allowed_failed_screen - Presentation Allowed, Failed Screen.
allowed - Presentation Allowed, Network Number.
prohib_not_screened - Presentation Prohibited, Not Screened.
prohib_passed_screen - Presentation Prohibited, Passed Screen.
prohib_failed_screen - Presentation Prohibited, Failed Screen.
prohib - Presentation Prohibited, Network Number.
unavailable - Number Unavailable.&lt;/p&gt;
### __toString
string PAGI\CallerId\Impl\CallerIdFacade::__toString()
Standard procedure.
* Visibility: **public**
### __construct
void PAGI\CallerId\Impl\CallerIdFacade::__construct(\PAGI\Client\IClient $client)
Constructor.
* Visibility: **public**
#### Arguments
* $client **[PAGI\Client\IClient](PAGI-Client-IClient.md)** - &lt;p&gt;AGI Client to use.&lt;/p&gt;
PAGI\ChannelVariables\IChannelVariables
===============
ChannelVariables facade. Use this to access channel variables.
PHP Version 5
* Interface name: IChannelVariables
* Namespace: PAGI\ChannelVariables
* This is an **interface**
Methods
-------
### getChannel
string PAGI\ChannelVariables\IChannelVariables::getChannel()
Returns channel (agi_channel).
* Visibility: **public**
### getLanguage
string PAGI\ChannelVariables\IChannelVariables::getLanguage()
Returns language (agi_language).
* Visibility: **public**
### getType
string PAGI\ChannelVariables\IChannelVariables::getType()
Returns channel type (agi_type).
* Visibility: **public**
### getUniqueId
string PAGI\ChannelVariables\IChannelVariables::getUniqueId()
Returns channel uniqueid (agi_uniqueid).
* Visibility: **public**
### getVersion
string PAGI\ChannelVariables\IChannelVariables::getVersion()
Returns asterisk version (agi_version).
* Visibility: **public**
### getCallerId
string PAGI\ChannelVariables\IChannelVariables::getCallerId()
Returns caller id number (agi_callerid).
* Visibility: **public**
### getCallerIdName
string PAGI\ChannelVariables\IChannelVariables::getCallerIdName()
Returns caller id name (agi_calleridname).
* Visibility: **public**
### getCallingPres
string PAGI\ChannelVariables\IChannelVariables::getCallingPres()
Returns CallingPres (agi_callingpres).
* Visibility: **public**
### getCallingAni2
string PAGI\ChannelVariables\IChannelVariables::getCallingAni2()
Returns CallingAni (agi_callingani2).
* Visibility: **public**
### getCallingTon
string PAGI\ChannelVariables\IChannelVariables::getCallingTon()
Returns CallingTon (agi_callington).
* Visibility: **public**
### getCallingTns
string PAGI\ChannelVariables\IChannelVariables::getCallingTns()
Returns CallingTns (agi_callingtns).
* Visibility: **public**
### getDNID
string PAGI\ChannelVariables\IChannelVariables::getDNID()
Returns DNID (agi_dnid).
* Visibility: **public**
### getContext
string PAGI\ChannelVariables\IChannelVariables::getContext()
Returns context (agi_context).
* Visibility: **public**
### getRDNIS
string PAGI\ChannelVariables\IChannelVariables::getRDNIS()
Returns RDNIS (agi_rdnis).
* Visibility: **public**
### getRequest
string PAGI\ChannelVariables\IChannelVariables::getRequest()
Returns agi requested (agi_request).
* Visibility: **public**
### getDNIS
string PAGI\ChannelVariables\IChannelVariables::getDNIS()
Returns extension dialed (dnis) (agi_extension).
* Visibility: **public**
### getThreadId
string PAGI\ChannelVariables\IChannelVariables::getThreadId()
Returns thread id (agi_threadid).
* Visibility: **public**
### getAccountCode
string PAGI\ChannelVariables\IChannelVariables::getAccountCode()
Returns account code (agi_accountcode).
* Visibility: **public**
### getEnhanced
string PAGI\ChannelVariables\IChannelVariables::getEnhanced()
Returns if using enhanced (agi_enhanced).
* Visibility: **public**
### getPriority
string PAGI\ChannelVariables\IChannelVariables::getPriority()
Returns context priority (agi_priority).
* Visibility: **public**
### getTotalArguments
integer PAGI\ChannelVariables\IChannelVariables::getTotalArguments()
Returns total number of agi arguments.
* Visibility: **public**
### getArgument
string PAGI\ChannelVariables\IChannelVariables::getArgument(integer $index)
Returns the given agi argument. (agi_arg_N).
* Visibility: **public**
#### Arguments
* $index **integer** - &lt;p&gt;Argument number, starting with 0.&lt;/p&gt;
### getArguments
array<mixed,string> PAGI\ChannelVariables\IChannelVariables::getArguments()
Returns all arguments as an array.
* Visibility: **public**
### getDirectoryConfig
string PAGI\ChannelVariables\IChannelVariables::getDirectoryConfig()
Returns the config directory for this running version of asterisk.
Uses environment variable AST_CONFIG_DIR.
* Visibility: **public**
### getConfigFile
string PAGI\ChannelVariables\IChannelVariables::getConfigFile()
Returns the config file for this running version of asterisk.
Uses environment variable AST_CONFIG_FILE.
* Visibility: **public**
### getDirectoryModules
string PAGI\ChannelVariables\IChannelVariables::getDirectoryModules()
Returns the modules directory for this running version of asterisk.
Uses environment variable AST_MODULE_DIR.
* Visibility: **public**
### getDirectorySpool
string PAGI\ChannelVariables\IChannelVariables::getDirectorySpool()
Returns the spool directory for this running version of asterisk.
Uses environment variable AST_SPOOL_DIR.
* Visibility: **public**
### getDirectoryMonitor
string PAGI\ChannelVariables\IChannelVariables::getDirectoryMonitor()
Returns the monitor directory for this running version of asterisk.
Uses environment variable AST_MONITOR_DIR.
* Visibility: **public**
### getDirectoryVar
string PAGI\ChannelVariables\IChannelVariables::getDirectoryVar()
Returns the var directory for this running version of asterisk.
Uses environment variable AST_VAR_DIR.
* Visibility: **public**
### getDirectoryData
string PAGI\ChannelVariables\IChannelVariables::getDirectoryData()
Returns the data directory for this running version of asterisk.
Uses environment variable AST_DATA_DIR.
* Visibility: **public**
### getDirectoryLog
string PAGI\ChannelVariables\IChannelVariables::getDirectoryLog()
Returns the log directory for this running version of asterisk.
Uses environment variable AST_LOG_DIR.
* Visibility: **public**
### getDirectoryAgi
string PAGI\ChannelVariables\IChannelVariables::getDirectoryAgi()
Returns the agi directory for this running version of asterisk.
Uses environment variable AST_AGI_DIR.
* Visibility: **public**
### getDirectoryKey
string PAGI\ChannelVariables\IChannelVariables::getDirectoryKey()
Returns the key directory for this running version of asterisk.
Uses environment variable AST_KEY_DIR.
* Visibility: **public**
### getDirectoryRun
string PAGI\ChannelVariables\IChannelVariables::getDirectoryRun()
Returns the run directory for this running version of asterisk.
Uses environment variable AST_RUN_DIR.
* Visibility: **public**
PAGI\Client\ChannelStatus
===============
ChannelStatus &#039;Helper&#039;. See: http://www.voip-info.org/wiki/view/channel+status
PHP Version 5
* Class name: ChannelStatus
* Namespace: PAGI\Client
Constants
----------
### DOWN_AVAILABLE
const DOWN_AVAILABLE = 0
### DOWN_RESERVED
const DOWN_RESERVED = 1
### OFF_HOOK
const OFF_HOOK = 2
### DIGITS_DIALED
const DIGITS_DIALED = 3
### LINE_RINGING
const LINE_RINGING = 4
### REMOTE_RINGING
const REMOTE_RINGING = 5
### LINE_UP
const LINE_UP = 6
### LINE_BUSY
const LINE_BUSY = 7
Methods
-------
### toString
string PAGI\Client\ChannelStatus::toString(integer $status)
This will return the human readable description for the given channel
status. See class constants. (False if the status is invalid).
* Visibility: **public**
* This method is **static**.
#### Arguments
* $status **integer** - &lt;p&gt;Channel status.&lt;/p&gt;
PAGI\Client\Result\AmdResult
===============
This decorated result adds the functionality to check for an AMD result.
PHP Version 5
* Class name: AmdResult
* Namespace: PAGI\Client\Result
* Parent class: [PAGI\Client\Result\ExecResult](PAGI-Client-Result-ExecResult.md)
Properties
----------
### $status
private string $status
Cause
* Visibility: **private**
### $cause
private string $cause
Cause
* Visibility: **private**
### $result
private \PAGI\Client\Result\IResult $result
Our decorated result.
* Visibility: **private**
Methods
-------
### getCause
string PAGI\Client\Result\AmdResult::getCause()
Returns the cause string.
* Visibility: **public**
### getStatus
string PAGI\Client\Result\AmdResult::getStatus()
Returns the status string.
* Visibility: **public**
### setCause
void PAGI\Client\Result\AmdResult::setCause(string $cause)
Sets the cause string
* Visibility: **public**
#### Arguments
* $cause **string**
### setStatus
void PAGI\Client\Result\AmdResult::setStatus($status)
Sets the cause string
* Visibility: **public**
#### Arguments
* $status **mixed**
### isStatus
boolean PAGI\Client\Result\AmdResult::isStatus(string $string)
True if the status equals the given string
* Visibility: **private**
#### Arguments
* $string **string**
### isCause
boolean PAGI\Client\Result\AmdResult::isCause(string $string)
True if the cause equals the given string
* Visibility: **private**
#### Arguments
* $string **string**
### isMachine
boolean PAGI\Client\Result\AmdResult::isMachine()
True if AMD detected an answering machine.
* Visibility: **public**
### isHangup
boolean PAGI\Client\Result\AmdResult::isHangup()
True if AMD detected a hangup.
* Visibility: **public**
### isHuman
boolean PAGI\Client\Result\AmdResult::isHuman()
True if AMD detected a human.
* Visibility: **public**
### isNotSure
boolean PAGI\Client\Result\AmdResult::isNotSure()
True if AMD failed detecting an answering machine or human.
* Visibility: **public**
### isCauseTooLong
boolean PAGI\Client\Result\AmdResult::isCauseTooLong()
True if AMD status is due to a timeout when detecting.
* Visibility: **public**
### isCauseInitialSilence
boolean PAGI\Client\Result\AmdResult::isCauseInitialSilence()
True if AMD status is due to a silence duration.
* Visibility: **public**
### isCauseHuman
boolean PAGI\Client\Result\AmdResult::isCauseHuman()
True if AMD status is due to a silence after a greeting.
* Visibility: **public**
### isCauseGreeting
boolean PAGI\Client\Result\AmdResult::isCauseGreeting()
True if AMD status is due to a long greeting detected.
* Visibility: **public**
### isCauseWordLength
boolean PAGI\Client\Result\AmdResult::isCauseWordLength()
True if AMD status is due to a maximum number of words reached.
* Visibility: **public**
### __toString
string PAGI\Client\Result\ResultDecorator::__toString()
Standard procedure.
* Visibility: **public**
* This method is defined by [PAGI\Client\Result\ResultDecorator](PAGI-Client-Result-ResultDecorator.md)
### __construct
void PAGI\Client\Result\ResultDecorator::__construct(\PAGI\Client\Result\IResult $result)
Constructor.
* Visibility: **public**
* This method is defined by [PAGI\Client\Result\ResultDecorator](PAGI-Client-Result-ResultDecorator.md)
#### Arguments
* $result **[PAGI\Client\Result\IResult](PAGI-Client-Result-IResult.md)** - &lt;p&gt;Result to decorate.&lt;/p&gt;
### getOriginalLine
string PAGI\Client\Result\IResult::getOriginalLine()
Returns original line.
* Visibility: **public**
* This method is defined by [PAGI\Client\Result\IResult](PAGI-Client-Result-IResult.md)
### getCode
integer PAGI\Client\Result\IResult::getCode()
Returns the integer value of the code returned by agi.
* Visibility: **public**
* This method is defined by [PAGI\Client\Result\IResult](PAGI-Client-Result-IResult.md)
### getResult
integer PAGI\Client\Result\IResult::getResult()
Returns result (result=xxx) from the result.
* Visibility: **public**
* This method is defined by [PAGI\Client\Result\IResult](PAGI-Client-Result-IResult.md)
### isResult
boolean PAGI\Client\Result\IResult::isResult(string $value)
Compares result to a given value.
* Visibility: **public**
* This method is defined by [PAGI\Client\Result\IResult](PAGI-Client-Result-IResult.md)
#### Arguments
* $value **string** - &lt;p&gt;Value to match against.&lt;/p&gt;
### hasData
boolean PAGI\Client\Result\IResult::hasData()
Returns true if this command returned any data.
* Visibility: **public**
* This method is defined by [PAGI\Client\Result\IResult](PAGI-Client-Result-IResult.md)
### getData
string PAGI\Client\Result\IResult::getData()
Returns data, if any. False if none.
* Visibility: **public**
* This method is defined by [PAGI\Client\Result\IResult](PAGI-Client-Result-IResult.md)
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!