492 lines
16 KiB
PHP
492 lines
16 KiB
PHP
|
|
<?php
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
* To change this license header, choose License Headers in Project Properties.
|
|||
|
|
* To change this template file, choose Tools | Templates
|
|||
|
|
* and open the template in the editor.
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Description of Tele2ApiClass
|
|||
|
|
*
|
|||
|
|
* @author Ira
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
ini_set('error_reporting', E_ALL);
|
|||
|
|
ini_set('display_errors', 1);
|
|||
|
|
ini_set('display_startup_errors', 1);
|
|||
|
|
|
|||
|
|
class Tele2ApiClass extends MangoApiClass {
|
|||
|
|
private $company_id;
|
|||
|
|
private $region_id;
|
|||
|
|
private $base_url = "https://ats2.t2.ru/crm/openapi";
|
|||
|
|
private $metod;
|
|||
|
|
private $header;
|
|||
|
|
private $users = array();
|
|||
|
|
private $phone_type;
|
|||
|
|
private $refreshToken;
|
|||
|
|
private $accessToken;
|
|||
|
|
|
|||
|
|
private $phone_types = [0 => 'tele2AbonentNoAnswer',
|
|||
|
|
1 => 'tele2AbonentAnswer',
|
|||
|
|
2 => 'abonentTele2Answer',
|
|||
|
|
3 => 'abonentTele2NoAnswer'];
|
|||
|
|
private $start;
|
|||
|
|
private $end;
|
|||
|
|
|
|||
|
|
public function __construct($company_id, $region_id, $refreshToken, $accessToken){
|
|||
|
|
$this->company_id = $company_id;
|
|||
|
|
$this->region_id = $region_id;
|
|||
|
|
$this->refreshToken = $refreshToken;
|
|||
|
|
$this->accessToken = $accessToken;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private function set_header($refreshToken = false){
|
|||
|
|
// var_dump($refreshToken);
|
|||
|
|
if($refreshToken){
|
|||
|
|
$this->header = ['Content-type:application/json',
|
|||
|
|
'Authorization:'.$this->refreshToken];
|
|||
|
|
} else {
|
|||
|
|
$this->header = ['Content-type:application/json',
|
|||
|
|
'Authorization:'.$this->accessToken];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public function getToken($agency_id){
|
|||
|
|
$result = false;
|
|||
|
|
$this->metod = '/authorization/refresh/token';
|
|||
|
|
$tokens = json_decode($this->sendCurl(false,['type'=>"PUT","body"=>[]], true));
|
|||
|
|
|
|||
|
|
if(isset($tokens->accessToken) && isset($tokens->refreshToken)){
|
|||
|
|
$this->accessToken = $tokens->accessToken;
|
|||
|
|
$this->refreshToken = $tokens->refreshToken;
|
|||
|
|
$sql_up = "UPDATE agency_tele2 SET access_token='{$tokens->accessToken}', refresh_token='$tokens->refreshToken' WHERE agency_id={$agency_id}";
|
|||
|
|
|
|||
|
|
if(mysql_query($sql_up))
|
|||
|
|
$result = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return $result;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private function sendCurl($post = false, $custom = false, $refreshToken = false){
|
|||
|
|
$response = 0;
|
|||
|
|
$url = $this->base_url . $this->metod;
|
|||
|
|
//echo $url.'<br>';
|
|||
|
|
$ch = curl_init($url);
|
|||
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|||
|
|
//if($header){
|
|||
|
|
$this->set_header($refreshToken);
|
|||
|
|
//var_dump($this->header);
|
|||
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
|||
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
|||
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->header);
|
|||
|
|
curl_setopt($ch, CURLOPT_HEADER,0);
|
|||
|
|
if($post){
|
|||
|
|
curl_setopt($ch, CURLOPT_POST, 1);
|
|||
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->post);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if($custom){
|
|||
|
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $custom['type']);
|
|||
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS,$custom['body']);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$response = curl_exec($ch);
|
|||
|
|
$response_info = curl_getinfo($ch);
|
|||
|
|
|
|||
|
|
//var_dump($response);
|
|||
|
|
//var_dump($response_info['http_code']);
|
|||
|
|
if($response_info['http_code'] != 200){
|
|||
|
|
|
|||
|
|
$response = 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if($errno = curl_errno($ch)) {
|
|||
|
|
$error_message = curl_strerror($errno);
|
|||
|
|
echo "cURL error ({$errno}):\n {$error_message}";
|
|||
|
|
}
|
|||
|
|
curl_close($ch);
|
|||
|
|
|
|||
|
|
return $response;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public function getUsers() {
|
|||
|
|
|
|||
|
|
$this->metod = "/employees?company_id=".$this->company_id;
|
|||
|
|
$res = $this->sendCurl(false);
|
|||
|
|
return $res;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//Сохранение пользователя МТС
|
|||
|
|
private function saveUserTele2($user, $agency_id){
|
|||
|
|
|
|||
|
|
$user_id = 0;
|
|||
|
|
$tele2_id = $user->employeeId;
|
|||
|
|
$fio = '';
|
|||
|
|
$set = " SET ";
|
|||
|
|
if(isset($user->surname) && !empty(trim($user->surname))){
|
|||
|
|
$fio .= trim($user->surname);
|
|||
|
|
}
|
|||
|
|
if(isset($user->name) && !empty(trim($user->name))){
|
|||
|
|
if(!empty($fio)) $fio .= ' ';
|
|||
|
|
$fio .= trim($user->name);
|
|||
|
|
}
|
|||
|
|
if(isset($fio) && !empty($fio)){
|
|||
|
|
if($set != " SET ") $set .= ", ";
|
|||
|
|
$set .= "fio='$fio'";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
if(isset($user->fullNumber) && !empty($user->fullNumber)){
|
|||
|
|
|
|||
|
|
$phone = $user->fullNumber;
|
|||
|
|
if($set != " SET ") $set .= ", ";
|
|||
|
|
$set .= "phone='$phone'";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
if(isset($user->shortNumber) && !empty($user->shortNumber)){
|
|||
|
|
$ext = $user->shortNumber;
|
|||
|
|
if($set != " SET ") $set .= ", ";
|
|||
|
|
$set .= "ext='$ext'";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(isset($user->email) && !empty($user->email)){
|
|||
|
|
$email = $user->email;
|
|||
|
|
if($set != " SET ") $set .= ", ";
|
|||
|
|
$set .= "email='$email'";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//Поиск user_id
|
|||
|
|
if(isset($phone)){
|
|||
|
|
$sql = "SELECT id FROM users WHERE phone='".$this->ver_phone($phone)."'";
|
|||
|
|
$q = mysql_query($sql);
|
|||
|
|
if(mysql_num_rows($q) > 0){
|
|||
|
|
$user_id = mysql_fetch_array($q)[0];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if(isset($email) && $user_id == 0){
|
|||
|
|
$sql = "SELECT id FROM users WHERE email='$email'";
|
|||
|
|
$q = mysql_query($sql);
|
|||
|
|
if(mysql_num_rows($q) > 0){
|
|||
|
|
$user_id = mysql_fetch_array($q)[0];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if($set != " SET ") $set .= ", ";
|
|||
|
|
$set .= "user_id='$user_id'";
|
|||
|
|
|
|||
|
|
if($user_id > 0) {
|
|||
|
|
$sql = "SELECT id FROM tele2_users WHERE tele2_id = $tele2_id";
|
|||
|
|
$q = mysql_query($sql);
|
|||
|
|
$row = mysql_num_rows($q);
|
|||
|
|
if($row > 0){
|
|||
|
|
$sql_up = "UPDATE tele2_users $set WHERE tele2_id = $tele2_id";
|
|||
|
|
mysql_query($sql_up);
|
|||
|
|
|
|||
|
|
} else {
|
|||
|
|
if($set != " SET ") $set .= ", ";
|
|||
|
|
$set .= "tele2_id='$tele2_id', agency_id=$agency_id";
|
|||
|
|
$sql_in = "INSERT INTO tele2_users $set";
|
|||
|
|
mysql_query($sql_in);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public function find_user($phone, $agency_id=0){
|
|||
|
|
$user_id = 0;
|
|||
|
|
$phone = $this->ver_phone($phone);
|
|||
|
|
|
|||
|
|
$sql_user = "SELECT id FROM users WHERE phone = '".$phone."' and blocked=0";
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
$q_user = mysql_query($sql_user);
|
|||
|
|
if(mysql_num_rows($q_user) > 0){
|
|||
|
|
$r_user = mysql_fetch_assoc($q_user);
|
|||
|
|
$user_id = $r_user['id'];
|
|||
|
|
}
|
|||
|
|
return $user_id;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//Сохранение данных пользователя телефонии
|
|||
|
|
public function saveUser($user, $agency_id){
|
|||
|
|
|
|||
|
|
$this->saveUserTele2($user, $agency_id);
|
|||
|
|
|
|||
|
|
$user_id = $user->employeeId;
|
|||
|
|
|
|||
|
|
$poles = array();
|
|||
|
|
$poles_up = array();
|
|||
|
|
//Проверка есть ли запись
|
|||
|
|
$sql = "SELECT id FROM mango_call_users WHERE user_id='".$user_id."'";
|
|||
|
|
|
|||
|
|
$q = mysql_query($sql);
|
|||
|
|
//Записываем
|
|||
|
|
|
|||
|
|
$fio = '';
|
|||
|
|
$poles[] = "user_id = '".$user_id."'";
|
|||
|
|
if(isset($user->surname) && !empty(trim($user->surname))){
|
|||
|
|
$fio .= trim($user->surname);
|
|||
|
|
}
|
|||
|
|
if(isset($user->name) && !empty(trim($user->name))){
|
|||
|
|
if(!empty($fio)) $fio .= ' ';
|
|||
|
|
$fio .= trim($user->name);
|
|||
|
|
}
|
|||
|
|
if(!empty($fio)){
|
|||
|
|
$poles[] = "fio = '".$fio."'";
|
|||
|
|
$poles_up[] = "fio = '".$fio."'";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$number_sip = '';
|
|||
|
|
if(isset($user->fullNumber) && !empty($user->fullNumber)){
|
|||
|
|
$poles[] = "number_phone = '".$user->fullNumber."'";
|
|||
|
|
$number_sip = $user->fullNumber;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
if(isset($user->shortNumber) && !empty($user->shortNumber)){
|
|||
|
|
$poles[] = "extension = '".$user->shortNumber."'";
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$poles[] = "number_sip = '".$number_sip."'";
|
|||
|
|
$poles_up[] = "number_sip = '".$number_sip."'";
|
|||
|
|
|
|||
|
|
if(mysql_num_rows($q) == 0){
|
|||
|
|
$poles[] = "agency_id = '".$agency_id."'";
|
|||
|
|
$insert = "INSERT INTO `mango_call_users` set ".implode(', ', $poles);
|
|||
|
|
|
|||
|
|
mysql_query($insert);
|
|||
|
|
} else {
|
|||
|
|
$insert = "UPDATE `mango_call_users` set ".implode(', ', $poles_up)." WHERE user_id = ".$user_id;
|
|||
|
|
mysql_query($insert);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private function getListRecords($call){
|
|||
|
|
$result = false;
|
|||
|
|
$this->metod = '/record/list?'.
|
|||
|
|
'company_id='.$this->company_id.
|
|||
|
|
'®ion_id='.$this->region_id.
|
|||
|
|
'&start='.$this->start.
|
|||
|
|
'&end='.$this->end.
|
|||
|
|
'&caller='.$call->callerNumber.
|
|||
|
|
'&callee='.$call->calleeNumber;
|
|||
|
|
//echo $this->metod."\n";
|
|||
|
|
$res = $this->sendCurl();
|
|||
|
|
//var_dump($res);
|
|||
|
|
return $result;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public function get_record($record_uuid){
|
|||
|
|
$this->metod = '/call-records/file?filename='.rawurlencode($record_uuid);
|
|||
|
|
|
|||
|
|
$res = $this->sendCurl();
|
|||
|
|
return $res;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//
|
|||
|
|
public function recordSaveTele2($call, $agency_id){
|
|||
|
|
$records = array();
|
|||
|
|
if(isset($call->recordFileName) && !empty($call->recordFileName)){
|
|||
|
|
if (!is_dir($_SERVER['DOCUMENT_ROOT'] . "/server/tele2")) {
|
|||
|
|
mkdir($_SERVER['DOCUMENT_ROOT'] . "/server/tele2", 0777);
|
|||
|
|
}
|
|||
|
|
if (!is_dir($_SERVER['DOCUMENT_ROOT'] . "/server/tele2/".$agency_id)) {
|
|||
|
|
mkdir($_SERVER['DOCUMENT_ROOT'] . "/server/tele2/".$agency_id, 0777);
|
|||
|
|
}
|
|||
|
|
$date = date("Ymd", $call->date);
|
|||
|
|
if (!is_dir($_SERVER['DOCUMENT_ROOT'] . "/server/tele2/".$agency_id."/".$date)) {
|
|||
|
|
mkdir($_SERVER['DOCUMENT_ROOT'] . "/server/tele2/".$agency_id."/".$date, 0777);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
$file = trim($this->get_record($call->recordFileName));
|
|||
|
|
|
|||
|
|
if(!empty($file)){
|
|||
|
|
$name = explode('/', $call->recordFileName)[1].'.mp3';
|
|||
|
|
if(!file_exists($_SERVER['DOCUMENT_ROOT'].'/server/tele2/'.$agency_id.'/'.$date.'/'.$name)){
|
|||
|
|
file_put_contents($_SERVER['DOCUMENT_ROOT'].'/server/tele2/'.$agency_id.'/'.$date.'/'.$name, $file);
|
|||
|
|
}
|
|||
|
|
$records[] = explode('/', $call->recordFileName)[1];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
return json_encode($records);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public function callHistory($start, $end) {
|
|||
|
|
$this->start = $start;
|
|||
|
|
$this->end = $end;
|
|||
|
|
$this->metod = "/call-records/info?start=$start&end=$end&size=50";
|
|||
|
|
$res = json_decode($this->sendCurl());
|
|||
|
|
return $res;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public function get_phone_type($phone){
|
|||
|
|
$this->type_phone($phone);
|
|||
|
|
return $this -> phone_type;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public function type_phone($phone){
|
|||
|
|
$type = 0;
|
|||
|
|
$number_phone = $phone->callerNumber;
|
|||
|
|
$sql = "SELECT id FROM tele2_users WHERE phone = '$number_phone'";
|
|||
|
|
//echo $sql."\n";
|
|||
|
|
$q = mysql_query($sql);
|
|||
|
|
if(mysql_num_rows($q) > 0){
|
|||
|
|
if($phone->callStatus == 'ANSWERED_COMMON'
|
|||
|
|
|| $phone->callStatus == 'ANSWERED_BY_ORIGINAL_CLIENT'
|
|||
|
|
|| $phone->callStatus == 'ANSWERED_BY_BUSY_FORWARD_CLIENT'
|
|||
|
|
|| $phone->callStatus == 'ANSWERED_BY_NO_ANSWER_FORWARD_CLIENT'
|
|||
|
|
){
|
|||
|
|
$type = 1;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
$type = 3;
|
|||
|
|
if($phone->callStatus == 'ANSWERED_COMMON'
|
|||
|
|
|| $phone->callStatus == 'ANSWERED_BY_ORIGINAL_CLIENT'
|
|||
|
|
|| $phone->callStatus == 'ANSWERED_BY_BUSY_FORWARD_CLIENT'
|
|||
|
|
|| $phone->callStatus == 'ANSWERED_BY_NO_ANSWER_FORWARD_CLIENT'
|
|||
|
|
){
|
|||
|
|
$type = 2;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$this->phone_type = $this->phone_types[$type];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public function stat($call, $agency_id){
|
|||
|
|
$id = 0;
|
|||
|
|
$this->type_phone($call);
|
|||
|
|
|
|||
|
|
if(!isset($call->calleeNumber)){
|
|||
|
|
$call->calleeNumber = $call->destinationNumber;
|
|||
|
|
}
|
|||
|
|
$to_number = $call->calleeNumber;
|
|||
|
|
$from_number = $call->callerNumber;
|
|||
|
|
$entry_id = $to_number;
|
|||
|
|
|
|||
|
|
|
|||
|
|
$id_uuid = $call->date;
|
|||
|
|
|
|||
|
|
|
|||
|
|
$answer = 0;
|
|||
|
|
$answerResult = $call->callStatus;
|
|||
|
|
if(isset($call->conversationDuration))
|
|||
|
|
{
|
|||
|
|
$answer = $call->date;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$from_extension = '';
|
|||
|
|
if($this->phone_type == 'tele2AbonentAnswer' || $this->phone_type == 'tele2AbonentNoAnswer'){
|
|||
|
|
$from_extension = $call->calleeNumber;
|
|||
|
|
$to_number = $call->callerNumber;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
$start = $call->date;
|
|||
|
|
$finish = $call->date + $call->callDuration;
|
|||
|
|
|
|||
|
|
//echo $to_number.'<br>';
|
|||
|
|
$sql = "SELECT id FROM mango_calls WHERE operator_id=6 and operator_call_id = '".$id_uuid."'";
|
|||
|
|
$q = mysql_query($sql);
|
|||
|
|
$row = mysql_num_rows($q);
|
|||
|
|
$record = "[]";
|
|||
|
|
if($this->phone_type == 'tele2AbonentAnswer' || $this->phone_type == 'abonentTele2Answer'){
|
|||
|
|
$record = $this->recordSaveTele2($call, $agency_id);
|
|||
|
|
}
|
|||
|
|
if($row == 0){
|
|||
|
|
|
|||
|
|
$in = "INSERT INTO `mango_calls` SET
|
|||
|
|
`records`='".$record."',
|
|||
|
|
`start`= $start,
|
|||
|
|
`finish`=$finish,
|
|||
|
|
`answer`=$answer,
|
|||
|
|
`from_extension`='".$from_extension."',
|
|||
|
|
`from_number`= '".$from_number."',
|
|||
|
|
`to_extension`='".$call->calleeNumber."',
|
|||
|
|
`to_number`='".$to_number."',
|
|||
|
|
`disconnect_reason`='".$answerResult."',
|
|||
|
|
`entry_id`='".$entry_id."',
|
|||
|
|
`line_number`='tele2',
|
|||
|
|
`operator_id`=6,
|
|||
|
|
`location`='',
|
|||
|
|
`operator_call_id`='{$id_uuid}',
|
|||
|
|
`agency_id`=$agency_id
|
|||
|
|
";
|
|||
|
|
//echo $in."\n";
|
|||
|
|
|
|||
|
|
mysql_query($in);
|
|||
|
|
$id = mysql_insert_id();
|
|||
|
|
} else {
|
|||
|
|
$r = mysql_fetch_assoc($q);
|
|||
|
|
$id = (int)$r['id'];
|
|||
|
|
$in = "UPDATE `mango_calls` SET
|
|||
|
|
`records`='".$record."',
|
|||
|
|
`start`= $start,
|
|||
|
|
`finish`=$finish,
|
|||
|
|
`answer`=$answer,
|
|||
|
|
`from_extension`='".$from_extension."',
|
|||
|
|
`from_number`= '".$from_number."',
|
|||
|
|
`to_extension`='".$call->calleeNumber."',
|
|||
|
|
`to_number`='".$to_number."',
|
|||
|
|
`disconnect_reason`='".$answerResult."',
|
|||
|
|
`entry_id`='".$entry_id."',
|
|||
|
|
`agency_id`=$agency_id
|
|||
|
|
WHERE
|
|||
|
|
id = {$id}";
|
|||
|
|
mysql_query($in);
|
|||
|
|
|
|||
|
|
} /*else if($row > 0) {
|
|||
|
|
|
|||
|
|
$in = "UPDATE `mango_calls` SET
|
|||
|
|
`records`='".$record."',
|
|||
|
|
`start`= $start,
|
|||
|
|
`finish`=$finish,
|
|||
|
|
`answer`=$answer,
|
|||
|
|
`from_extension`='".$from_extension."',
|
|||
|
|
`from_number`= '".$from_number."',
|
|||
|
|
`to_extension`='".$call->calledNumber."',
|
|||
|
|
`to_number`='".$to_number."',
|
|||
|
|
`disconnect_reason`='".$answerResult."',
|
|||
|
|
`entry_id`='".$entry_id."',
|
|||
|
|
`line_number`='tele2',
|
|||
|
|
`agency_id`=$agency_id
|
|||
|
|
WHERE
|
|||
|
|
operator_id=6 and operator_call_id = '".$id_uuid."'
|
|||
|
|
";
|
|||
|
|
echo $in;
|
|||
|
|
//mysql_query($in);
|
|||
|
|
}*/
|
|||
|
|
return $id;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public function save_user_call($id_call, $user_find, $main_user, $agency_id = 0){
|
|||
|
|
$user_id = 0;
|
|||
|
|
|
|||
|
|
if($id_call > 0){
|
|||
|
|
$user_id = (int)$this->find_user($user_find);
|
|||
|
|
if($user_id == 0){
|
|||
|
|
$user_id = (int)$main_user;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if($user_id > 0){
|
|||
|
|
$sql = "SELECT id FROM user_call WHERE call_id = {$id_call}";
|
|||
|
|
$q = mysql_query($sql);
|
|||
|
|
if(mysql_num_rows($q) == 0){
|
|||
|
|
$sql_in = "INSERT INTO user_call SET call_id = {$id_call}, user_id = {$user_id}";
|
|||
|
|
mysql_query($sql_in);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|