--
-- Table structure for table `Accounts`
--

DROP TABLE IF EXISTS `Accounts`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `Accounts` (
  `i_account` int(10) unsigned NOT NULL auto_increment,
  `id` char(32) NOT NULL default '',
  `password` char(16) default NULL,
  `h323_password` char(255) default NULL,
  `balance` decimal(15,5) NOT NULL default '0.00000',
  `opening_balance` decimal(15,5) NOT NULL default '0.00000',
  `issue_date` date NOT NULL default '0000-00-00',
  `zero_balance_date` date default NULL,
  `i_customer` int(10) unsigned NOT NULL default '0',
  `billing_model` tinyint(2) NOT NULL default '0',
  `activation_date` date NOT NULL default '0000-00-00',
  `expiration_date` date default NULL,
  `i_product` int(10) unsigned NOT NULL default '0',
  `blocked` char(1) NOT NULL default 'N',
  `last_usage` datetime default NULL,
  `i_batch` int(10) unsigned NOT NULL default '0',
  `i_env` tinyint(1) unsigned NOT NULL default '1',
  `first_usage` date default NULL,
  `life_time` smallint(4) unsigned default NULL,
  `redirect_number` char(15) default NULL,
  `control_number` int(10) unsigned NOT NULL default '0',
  `iso_639_1` char(2) default NULL,
  `i_time_zone` int(10) unsigned NOT NULL default '1',
  `credit_limit` decimal(15,5) default NULL,
  `iso_4217` char(3) NOT NULL default '',
  `non_call_related_charges` decimal(15,5) default NULL,
  `refunds` decimal(15,5) default NULL,
  `login` char(32) default NULL,
  `email` char(128) default NULL,
  `password_timestamp` datetime default NULL,
  `um_enabled` char(1) NOT NULL default 'N',
  `i_acl` int(10) unsigned NOT NULL default '155',
  `i_subscriber` int(10) unsigned default NULL,
  `i_lang` char(5) default NULL,
  `ua_profile_id` int(10) unsigned default NULL,
  `mac` char(23) default NULL,
  `i_ua_profile` int(10) unsigned default NULL,
  `follow_me_enabled` char(1) NOT NULL default 'N',
  `timer` datetime default NULL,
  `ecommerce_enabled` char(1) default 'N',
  `out_date_format` char(16) NOT NULL default '',
  `out_time_format` char(16) NOT NULL default '',
  `out_date_time_format` char(32) NOT NULL default '',
  `in_date_format` char(16) NOT NULL default '',
  `in_time_format` char(16) NOT NULL default '',
  `i_vd_plan` int(10) unsigned default NULL,
  `last_recharge` datetime default NULL,
  `i_moh` int(10) unsigned default NULL,
  `service_flags` char(32) NOT NULL default '',
  PRIMARY KEY  (`i_account`),
  UNIQUE KEY `Accounts_id` (`id`,`i_env`),
  UNIQUE KEY `Accounts_cn_batch` (`i_batch`,`control_number`),
  UNIQUE KEY `Accounts_login` (`login`),
  KEY `Account_customer` (`i_customer`),
  KEY `Accounts_acl` (`i_acl`),
  KEY `Accounts_i_product` (`i_product`),
  KEY `Accounts_product` (`i_product`),
  KEY `AccountsProfileId` (`ua_profile_id`),
  KEY `Accounts_mac` (`mac`,`i_env`),
  KEY `Accounts_um_enabled` (`um_enabled`),
  KEY `Accounts_iso_4217` (`iso_4217`),
  KEY `AccountFirstUsage` (`first_usage`),
  KEY `i_vd_plan` (`i_vd_plan`),
  KEY `accounts_maintenance` (`i_product`,`blocked`,`expiration_date`)
);

--
-- Table structure for table `Connections`
--

DROP TABLE IF EXISTS `Connections`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `Connections` (
  `i_connection` int(10) unsigned NOT NULL auto_increment,
  `i_vendor` int(10) unsigned NOT NULL default '0',
  `description` char(255) NOT NULL default '',
  `i_node` int(10) unsigned default NULL,
  `i_tariff` int(10) unsigned default NULL,
  `call_origin` enum('answer','originate','callback','proxy','unknown') NOT NULL default 'unknown',
  `call_type` enum('Telephony','VoIP','unknown') NOT NULL default 'unknown',
  `port` char(64) default NULL,
  `CLD` char(32) default NULL,
  `i_env` tinyint(1) unsigned NOT NULL default '1',
  `cld_translation_rule` char(255) default NULL,
  `remote_ip` char(64) default NULL,
  `capacity` smallint(5) unsigned NOT NULL default '0',
  `asr` float(7,4) default NULL,
  `i_vendor_acc` int(10) unsigned default NULL,
  `outgoing_cld_translation_rule` char(255) default NULL,
  `i_oli` int(10) unsigned default NULL,
  `sip` enum('Y','N') NOT NULL default 'Y',
  `h323` enum('Y','N') NOT NULL default 'N',
  `cli_translation_rule` char(255) default NULL,
  `rtpp_level` tinyint(1) unsigned default NULL,
  PRIMARY KEY  (`i_connection`),
  KEY `Connection_i_vendor` (`i_vendor`),
  KEY `Connections_port` (`port`),
  KEY `i_tariff` (`i_tariff`)
) ;

--
-- Table structure for table `Customers`
--

DROP TABLE IF EXISTS `Customers`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `Customers` (
  `i_customer` int(10) unsigned NOT NULL auto_increment,
  `refnum` char(32) default NULL,
  `name` char(41) NOT NULL default '',
  `timestamp` datetime NOT NULL default '0000-00-00 00:00:00',
  `balance` decimal(15,5) NOT NULL default '0.00000',
  `iso_4217` char(3) NOT NULL default '',
  `companyname` char(41) NOT NULL default '',
  `salutation` char(15) NOT NULL default '',
  `firstname` char(25) NOT NULL default '',
  `midinit` char(5) NOT NULL default '',
  `lastname` char(25) NOT NULL default '',
  `baddr1` char(41) NOT NULL default '',
  `baddr2` char(41) NOT NULL default '',
  `baddr3` char(41) NOT NULL default '',
  `baddr4` char(41) NOT NULL default '',
  `baddr5` char(41) NOT NULL default '',
  `city` char(31) NOT NULL default '',
  `state` char(21) NOT NULL default '',
  `zip` char(13) NOT NULL default '',
  `country` char(31) NOT NULL default '',
  `note` char(41) NOT NULL default '',
  `cont1` char(41) NOT NULL default '',
  `phone1` char(21) NOT NULL default '',
  `faxnum` char(21) NOT NULL default '',
  `phone2` char(21) NOT NULL default '',
  `cont2` char(41) NOT NULL default '',
  `email` char(99) default NULL,
  `bcc` char(99) default NULL,
  `send_statistics` char(1) NOT NULL default 'N',
  `login` char(16) default NULL,
  `password` char(16) default NULL,
  `i_customer_type` int(10) unsigned NOT NULL default '1',
  `i_billing_period` tinyint(2) unsigned NOT NULL default '4',
  `i_tariff` int(10) unsigned default NULL,
  `i_time_zone` int(10) unsigned NOT NULL default '1',
  `credit_limit` decimal(15,5) default NULL,
  `i_credit_card` int(10) unsigned default NULL,
  `i_env` tinyint(1) unsigned NOT NULL default '1',
  `i_template` int(10) unsigned default NULL,
  `tax_id` char(16) default NULL,
  `i_payment_term` int(10) unsigned NOT NULL default '0',
  `blocked` enum('Y','N') NOT NULL default 'N',
  `ppm_enabled` char(1) NOT NULL default 'N',
  `i_rep` int(10) unsigned NOT NULL default '0',
  `drm_enabled` char(1) NOT NULL default 'N',
  `max_abbreviated_length` tinyint(1) unsigned default NULL,
  `password_timestamp` datetime default NULL,
  `out_date_format` char(16) NOT NULL default '',
  `out_time_format` char(16) NOT NULL default '',
  `out_date_time_format` char(32) NOT NULL default '',
  `in_date_format` char(16) NOT NULL default '',
  `in_time_format` char(16) NOT NULL default '',
  `i_online_payment_processor` tinyint(3) unsigned NOT NULL default '0',
  `merch_acc_password` char(64) default NULL,
  `merch_acc_login` char(64) default NULL,
  `reccuring_enabled` char(1) NOT NULL default 'N',
  `test_mode` char(1) NOT NULL default 'Y',
  `i_acl` int(10) unsigned NOT NULL default '0',
  `opening_balance` decimal(15,5) NOT NULL default '0.00000',
  `min_allowed_payment` decimal(15,5) unsigned NOT NULL default '0.00000',
  `merch_acc_iso_4217` char(3) default NULL,
  `i_lang` char(5) default NULL,
  `cld_translation_rule` char(255) default NULL,
  `i_tariff_incoming` int(10) unsigned default NULL,
  `credit_limit_warning` char(25) default NULL,
  `callshop_enabled` char(1) NOT NULL default 'N',
  `billed_to` datetime default NULL,
  `i_parent` int(10) unsigned default NULL,
  `i_routing_plan` int(10) unsigned default NULL,
  `i_vd_plan` int(10) unsigned default NULL,
  `creation_date` datetime default NULL,
  `cli_in_translation_rule` char(255) default NULL,
  `i_moh` int(10) unsigned default NULL,
  `service_flags` char(32) NOT NULL default '',
  `i_customer_class` int(10) unsigned NOT NULL default '0',
  `bp_charge_cc` enum('N','Y') default NULL,
  `unallocated_payments` decimal(15,5) NOT NULL default '0.00000',
  `bill_status` enum('O','S','C') NOT NULL default 'O',
  PRIMARY KEY  (`i_customer`),
  UNIQUE KEY `customer` (`name`,`i_env`),
  UNIQUE KEY `login` (`login`),
  KEY `Customers_acl` (`i_acl`),
  KEY `parent_type` (`i_parent`,`i_customer_type`),
  KEY `i_tariff` (`i_tariff`),
  KEY `i_tariff_incoming` (`i_tariff_incoming`),
  KEY `Customers_iso_4217` (`iso_4217`),
  KEY `i_vd_plan` (`i_vd_plan`),
  KEY `i_rep` (`i_rep`),
  KEY `i_template` (`i_template`),
  KEY `i_customer_class` (`i_customer_class`),
  KEY `bill_status` (`bill_status`)
) ;

--
-- Table structure for table `Nodes`
--

DROP TABLE IF EXISTS `Nodes`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `Nodes` (
  `i_node` int(10) unsigned NOT NULL auto_increment,
  `ip` char(64) NOT NULL default '',
  `h323_id` char(255) NOT NULL default '',
  `name` char(41) default NULL,
  `type` enum('VOIP-GW','H323-GW','H323-GK','TERM','MCU','SIP Server','MVTS') default 'VOIP-GW',
  `radius_client` char(1) NOT NULL default 'N',
  `radius_key` char(32) default NULL,
  `i_env` tinyint(1) unsigned default '1',
  `hostname` char(255) default NULL,
  `domain` char(255) default NULL,
  `manufacturer` enum('Cisco','Quintum') default 'Cisco',
  `i_time_zone` int(10) unsigned NOT NULL default '1',
  `h323_password` char(255) default NULL,
  `cld_translation_rule` char(255) default NULL,
  `radius_source_ip` char(64) default NULL,
  `id` char(32) default NULL,
  `i_node_type` int(10) unsigned default NULL,
  `rtpp_level` tinyint(1) unsigned default NULL,
  PRIMARY KEY  (`i_node`),
  UNIQUE KEY `ip` (`ip`),
  UNIQUE KEY `h323_id` (`h323_id`),
  UNIQUE KEY `node` (`name`,`i_env`)
) ;
