<?php
/**
 * Добавляем поле для хранения ID таблицы записей разговоров
 * Main: IP-телефония Asterisk
 * Created by: Andrey
 * Release: 14.07.2014
 * App Version: 2.0.3
 * Copyright: Clientbase (www.clientbase.ru)
 */

$res = run_query("SHOW COLUMNS FROM " . $config['table_prefix'] . "module_asterisk_servers LIKE 'record_table'");
if (!sql_num_rows($res)) {
    run_query("ALTER TABLE " . $config['table_prefix'] . "module_asterisk_servers ADD record_table INT NOT NULL");
}

/**
 * Добавляем поля для хранения ID полей использующихся в записях разговоров
 * Main: IP-телефония Asterisk
 * Created by: Andrey
 * Release: 14.07.2014
 * App Version: 2.0.3
 * Copyright: Clientbase (www.clientbase.ru)
 */

$res = run_query("SHOW COLUMNS FROM " . $config['table_prefix'] . "module_asterisk_servers LIKE 'record_field_Date_start'");
if (!sql_num_rows($res)) {
    run_query("ALTER TABLE " . $config['table_prefix'] . "module_asterisk_servers ADD record_field_Date_start INT NOT NULL");
}

$res = run_query("SHOW COLUMNS FROM " . $config['table_prefix'] . "module_asterisk_servers LIKE 'record_field_Length'");
if (!sql_num_rows($res)) {
    run_query("ALTER TABLE " . $config['table_prefix'] . "module_asterisk_servers ADD record_field_Length INT NOT NULL");
}

$res = run_query("SHOW COLUMNS FROM " . $config['table_prefix'] . "module_asterisk_servers LIKE 'record_field_Date_end'");
if (!sql_num_rows($res)) {
    run_query("ALTER TABLE " . $config['table_prefix'] . "module_asterisk_servers ADD record_field_Date_end INT NOT NULL");
}

$res = run_query("SHOW COLUMNS FROM " . $config['table_prefix'] . "module_asterisk_servers LIKE 'record_field_User'");
if (!sql_num_rows($res)) {
    run_query("ALTER TABLE " . $config['table_prefix'] . "module_asterisk_servers ADD record_field_User INT NOT NULL");
}

$res = run_query("SHOW COLUMNS FROM " . $config['table_prefix'] . "module_asterisk_servers LIKE 'record_field_Number'");
if (!sql_num_rows($res)) {
    run_query("ALTER TABLE " . $config['table_prefix'] . "module_asterisk_servers ADD record_field_Number INT NOT NULL");
}

$res = run_query("SHOW COLUMNS FROM " . $config['table_prefix'] . "module_asterisk_servers LIKE 'record_field_Direction'");
if (!sql_num_rows($res)) {
    run_query("ALTER TABLE " . $config['table_prefix'] . "module_asterisk_servers ADD record_field_Direction INT NOT NULL");
}

$res = run_query("SHOW COLUMNS FROM " . $config['table_prefix'] . "module_asterisk_servers LIKE 'record_field_Client'");
if (!sql_num_rows($res)) {
    run_query("ALTER TABLE " . $config['table_prefix'] . "module_asterisk_servers ADD record_field_Client INT NOT NULL");
}

/**
 * Добавляем поля для хранения ID полей использующихся в записях разговоров
 * Main: IP-телефония Asterisk
 * Created by: Andrey
 * Release: 14.07.2014
 * App Version: 2.0.3
 * Copyright: Clientbase (www.clientbase.ru)
 */

$res = run_query("SHOW COLUMNS FROM " . $config['table_prefix'] . "module_asterisk_servers LIKE 'record_field_Record_link'");
if (!sql_num_rows($res)) {
    run_query("ALTER TABLE " . $config['table_prefix'] . "module_asterisk_servers ADD record_field_Record_link INT NOT NULL");
}
?>