AloVoiceAgi.php 2 KB
Newer Older
Kulya's avatar
Kulya committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
<?php namespace AloVoice; date_default_timezone_set('Asia/Tashkent');

use AloVoice\AloVoiceConnector as ALVC;

class AloVoiceAgi
{
    private $options;
    private $config;
	private $smsparts;
	
	public function __construct($config) {
		$this->config = $config;
	}
	
	public function run($datas) {
		self::aLog($_SERVER['argv'],'----=== RUN ARG vars:');
		
		
		self::aLog($datas,'----=== RUN AGI datas:');
		
		$crmPhoneSearchResult = BxRest::call("crm.duplicate.findbycomm",array(
			'type' => "PHONE",
			'values' => [$datas["caller_id"]],
		));

		self::aLog($crmPhoneSearchResult,'----=== AGI BX PHONE Search RES:');
		
		$crmEntitySearchResult = BxRest::call("telephony.externalCall.searchCrmEntities",array(
			'PHONE_NUMBER' => $datas["caller_id"],
		));
					
		self::aLog($crmEntitySearchResult,'----=== AGI BX ENTITY Search RES:');
		
		// $agi = new AGI();
		// $called_ext = $agi->request['agi_extension'];
		// 

		if(!empty($_SERVER['argv'][1])){
			// $runMethod = strtolower($_SERVER['argv'][1]);
			// if(method_exists($this,strtolower($runMethod))){
				// $rq=[];
				// if(count($_SERVER['argv'])>2){
					// foreach($_SERVER['argv'] as $i=>$arg){
						// if($i>1){
							// $v = explode("=",$arg);
							// if(!empty($v[1])){ $rq[$v[0]] = $v[1]; } else { $rq[] = $v[0]; }
						// }
					// }
				// }
				// return $this->$runMethod($rq);
			// }
			
		}
		
		echo '111';
		return false;
	}
	
	public function consoleMethod($r) {
		if(!empty($_SERVER['argv'][1])){
			$runMethod = strtolower($_SERVER['argv'][1]);
			if(method_exists($this,strtolower($runMethod))){
				$rq=[];
				if(count($_SERVER['argv'])>2){
					foreach($_SERVER['argv'] as $i=>$arg){
						if($i>1){
							$v = explode("=",$arg);
							if(!empty($v[1])){ $rq[$v[0]] = $v[1]; } else { $rq[] = $v[0]; }
						}
					}
				}
				return $this->$runMethod($rq);
			}
			
		}
		
		return false;
	}
	
	public function aLog($d,$t='') {
		ALVC::eLog($d, $t, 'agi');
	}
}
?>