Joywork/cron/telphin_subscription.php

34 lines
1.6 KiB
PHP
Raw Normal View History

2026-05-22 20:21:54 +02:00
<?php
header('Content-Type: application/json');
require_once($_SERVER['DOCUMENT_ROOT']."/config.php");
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
$sql = "SELECT * FROM agency_mango WHERE `type` = 'telphin'";
$result = mysql_query($sql);
while($row = mysql_fetch_assoc($result)){
$api_key = $row['api_key'];
$api_salt = $row['api_salt'];
$telphin = new TelphinApiClass($api_key, $api_salt);
$agency_id = $row['agency_id'];
if($telphin->auth()){
$telphin->setUrlSubscription('https://joywork.ru/callevents/incall_telphin.php');
$usersIds = array();
$usersIds[] = $agency_id;
$sql_users = "SELECT id FROM users WHERE id in (select id from users where id=$agency_id or id_manager=$agency_id or id_manager in
(select id from users where id_manager=$agency_id or id_manager in
(select id from users where id_manager=$agency_id)))";
$q_users = mysql_query($sql_users);
while($r_users = mysql_fetch_assoc($q_users)){
$usersIds[] = (int)$r_users['id'];
}
//var_dump($usersIds);
$telphin->set_users($usersIds);
$telphin->checkSubscription();
}
}
mysql_query("update `call_events` set status=0 where status=1 and operator <> 'MANGO' and TIMESTAMPDIFF(MINUTE,FROM_UNIXTIME(`start_time`),NOW()) > 2");
$pdopg = new MysqlPdo(hstpg, ndbpg, userpg, passpg, false, '5432', true);
$pdopg->query("update call_events set status=0 where status=1 and operator <> 'MANGO' and TIMESTAMPDIFF(MINUTE,FROM_UNIXTIME(start_time),NOW()) > 2");