Example #1
0
function deleteIPTVPacketFromUser($records = array())
{
    if (!empty($records)) {
        $parts = array();
        foreach ($records as $record) {
            $parts[] = array("and" => array(array("eq" => array("subscriber_id", $record[0])), array("eq" => array("package_id", $record[1]))));
        }
        $where = array("or" => $parts);
        jsonsql_call("delete", array("from" => "subscriber_package", "where" => $where));
    }
}
Example #2
0
print_r($res);
# получение терминалов для акаунта "123456"
$res = jsonsql_call("select", array("data" => array(array("t" => "id"), array("t" => "inet_addr"), array("t" => "mac_addr")), "from" => array(array("table" => "terminal", "as" => "t"), array("join" => "subscriber", "join_type" => "inner", "as" => "s", "on" => array("eq" => array(array("t" => "subscriber_id"), array("s" => "id"))))), "where" => array("eq" => array(array("s" => "username"), "123456"))));
echo 'select cmd result: ';
print_r($res);
# отключение абонента с акаунтом "123456"
$res = jsonsql_call("update", array("table" => "subscriber", "set" => array("disabled" => true), "where" => array("eq" => array("username", "123456")), "returning" => "id"));
echo 'update cmd result: ';
print_r($res);
# обновляем абонента с акаунтом "123456"
$res = jsonsql_call("update", array("table" => "subscriber", "set" => array("disabled" => true), "where" => array("eq" => array("username", "123456")), "returning" => "id"));
echo 'update cmd result: ';
print_r($res);
if (!(count($res) > 0)) {
    # добавление абонента "123456" с паролем "111"
    $res = jsonsql_call("insert", array("into" => "subscriber", "columns" => array("username", "password"), "values" => array("username" => "123456", "password" => "111"), "returning" => "id"));
    echo 'insert cmd result: ';
    print_r($res);
}
# удаление абонентских устройств акаунта "123456"
$res = jsonsql_call("delete", array("from" => "terminal", "where" => array("in" => array("subscriber_id", array("select" => array("data" => "id", "from" => "subscriber", "where" => array("eq" => array("username", "123456")))))), "returning" => "id"));
echo 'delete cmd result: ';
print_r($res);
# удаление пакетов "movie", "sports" для акаунта "123456"
$res = jsonsql_call("delete", array("from" => "subscriber_package", "where" => array("and" => array(array("in" => array("subscriber_id", array("select" => array("data" => "id", "from" => "subscriber", "where" => array("eq" => array("username", "123456")))))), array("in" => array("package_id", array("select" => array("data" => "id", "from" => "package", "where" => array("in" => array("name", "movie", "sports")))))))), "returning" => "package_id"));
echo 'delete cmd result: ';
print_r($res);
# удаление пакетов для акаунта "123456"
$res = jsonsql_call("delete", array("from" => "subscriber_package", "where" => array("in" => array("subscriber_id", array("select" => array("data" => "id", "from" => "subscriber", "where" => array("eq" => array("username", "123456")))))), "returning" => "package_id"));
echo 'delete cmd result: ';
print_r($res);
Example #3
0
function change_abonent_segment($p_account, $p_segment)
{
    $res = jsonsql_call("update", array("table" => "subscriber", "set" => array("business" => $p_segment), "where" => array("eq" => array("username", $p_account)), "returning" => "id"));
    return $res;
}
function servicesAdd($servicesAdd)
{
    //	jsonsql_call("delete",
    //		array(
    //			"from" => "package",
    //		)
    //	);
    $servicesMB2IPTV = array();
    $paid = true;
    $serviceData = array();
    foreach ($servicesAdd as $service) {
        # Если цена услуги 0 тогда - бесплатная
        //		if (isset($service['amount']) and $service['amount'] == '0'){
        //			$paid = false;
        //		}else{
        //			$paid = true;
        //		}
        $serviceData[] = array($service['servicename'], $paid);
    }
    # добавление пакетов
    if (!empty($servicesAdd)) {
        $result = jsonsql_call("insert", array("into" => "package", "columns" => array("name", "paid"), "values" => $serviceData, "returning" => "id"));
        echo 'insert services result: ';
        #print_r($result);
    }
    # выбрать все услуги
    $servicesIPTV = getServicesIPTV();
}