Thread: [Astpp-commit] SF.net SVN: astpp:[2188] trunk
Brought to you by:
darrenkw
From: <dar...@us...> - 2008-08-23 16:02:32
|
Revision: 2188 http://astpp.svn.sourceforge.net/astpp/?rev=2188&view=rev Author: darrenkw Date: 2008-08-23 16:02:39 +0000 (Sat, 23 Aug 2008) Log Message: ----------- Commit patch for the following feature request. Will require more testing. [ 2033328 ] Generate invoices on selected time period Modified Paths: -------------- trunk/astpp-common.pl trunk/astpp-generate-invoices.pl Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2008-07-03 00:06:16 UTC (rev 2187) +++ trunk/astpp-common.pl 2008-08-23 16:02:39 UTC (rev 2188) @@ -4475,12 +4475,34 @@ } sub osc_charges() { - my ($astpp_db, $osc_db, $config, $account) = @_; + my ($astpp_db, $osc_db, $config, $account, $params) = @_; my ( $invoice_id, $country_id, $zone_id, $tmp, $sql, $row, $cdr_count ); + if ($params->{startdate} && $params->{enddate}) { $tmp = "SELECT COUNT(*) FROM cdrs WHERE cardnum = " . $astpp_db->quote($account) + . " AND status = 0" + . " AND callstart >= DATE(" . $astpp_db->quote($params->{startdate}) . ")" + . " AND callstart <= DATE(" . $astpp_db->quote($params->{enddate}) . ")"; + } elsif ($params->{startdate}) { + $tmp = + "SELECT COUNT(*) FROM cdrs WHERE cardnum = " + . $astpp_db->quote($account) + . " AND status = 0" + . " AND callstart >= DATE(" . $astpp_db->quote($params->{startdate}) . ")"; + } elsif ($params->{enddate}) { + $tmp = + "SELECT COUNT(*) FROM cdrs WHERE cardnum = " + . $astpp_db->quote($account) + . " AND status = 0" + . " AND callstart <= DATE(" . $astpp_db->quote($params->{enddate}) . ")"; + } else { + $tmp = + "SELECT COUNT(*) FROM cdrs WHERE cardnum = " + . $astpp_db->quote($account) . " AND status = 0"; + } + print STDERR "$tmp \n"; $sql = $astpp_db->prepare($tmp); $sql->execute; @@ -4497,10 +4519,35 @@ ( $invoice_id, $country_id, $zone_id ) = &osc_create_invoice($astpp_db, $osc_db, $config, $account); if ($invoice_id) { - $tmp = - "SELECT * FROM cdrs WHERE cardnum = " - . $astpp_db->quote($account) - . " AND status = 0 ORDER BY callstart"; + if ($params->{startdate} && $params->{enddate}) { + $tmp = + "SELECT COUNT(*) FROM cdrs WHERE cardnum = " + . $astpp_db->quote($account) + . " AND status = 0" + . " AND callstart >= DATE(" . $astpp_db->quote($params->{startdate}) . ")" + . " AND callstart <= DATE(" . $astpp_db->quote($params->{enddate}) . ")" + . " ORDER BY callstart"; + } elsif ($params->{startdate}) { + $tmp = + "SELECT COUNT(*) FROM cdrs WHERE cardnum = " + . $astpp_db->quote($account) + . " AND status = 0" + . " AND callstart >= DATE(" . $astpp_db->quote($params->{startdate}) . ")" + . " ORDER BY callstart"; + } elsif ($params->{enddate}) { + $tmp = + "SELECT COUNT(*) FROM cdrs WHERE cardnum = " + . $astpp_db->quote($account) + . " AND status = 0" + . " AND callstart <= DATE(" . $astpp_db->quote($params->{enddate}) . ")" + . " ORDER BY callstart"; + } else { + $tmp = + "SELECT COUNT(*) FROM cdrs WHERE cardnum = " + . $astpp_db->quote($account) + . " AND status = 0" + . " ORDER BY callstart"; + } $sql = $astpp_db->prepare($tmp); $sql->execute; while ( $row = $sql->fetchrow_hashref ) { @@ -4582,12 +4629,39 @@ } sub get_charges() { - my ($astpp_db, $config, $number) = @_; - my ( $sql, @chargelist, $record ); + my ($astpp_db, $config, $account,$params) = @_; + my ( $tmp,$sql, @chargelist, $record ); + if ($params->{startdate} && $params->{enddate}) { + $tmp = + "SELECT COUNT(*) FROM cdrs WHERE cardnum = " + . $astpp_db->quote($account) + . " AND status = 0" + . " AND callstart >= DATE(" . $astpp_db->quote($params->{startdate}) . ")" + . " AND callstart <= DATE(" . $astpp_db->quote($params->{enddate}) . ")" + . " ORDER BY callstart"; + } elsif ($params->{startdate}) { + $tmp = + "SELECT COUNT(*) FROM cdrs WHERE cardnum = " + . $astpp_db->quote($account) + . " AND status = 0" + . " AND callstart >= DATE(" . $astpp_db->quote($params->{startdate}) . ")" + . " ORDER BY callstart"; + } elsif ($params->{enddate}) { + $tmp = + "SELECT COUNT(*) FROM cdrs WHERE cardnum = " + . $astpp_db->quote($account) + . " AND status = 0" + . " AND callstart <= DATE(" . $astpp_db->quote($params->{enddate}) . ")" + . " ORDER BY callstart"; + } else { + $tmp = + "SELECT COUNT(*) FROM cdrs WHERE cardnum = " + . $astpp_db->quote($account) + . " AND status = 0" + . " ORDER BY callstart"; + } $sql = - $astpp_db->prepare( "SELECT * FROM cdrs WHERE cardnum = " - . $astpp_db->quote($number) - . " AND status = 0" ); + $astpp_db->prepare($tmp); $sql->execute; while ( $record = $sql->fetchrow_hashref ) { push @chargelist, $record->{id}; Modified: trunk/astpp-generate-invoices.pl =================================================================== --- trunk/astpp-generate-invoices.pl 2008-07-03 00:06:16 UTC (rev 2187) +++ trunk/astpp-generate-invoices.pl 2008-08-23 16:02:39 UTC (rev 2188) @@ -21,6 +21,9 @@ # 0 0 * 1,7 * /usr/local/astpp/astpp-generate-invoices.pl sweep=4 # 0 0 * 1 * /usr/local/astpp/astpp-generate-invoices.pl sweep=5 # +# To generate invoices only for a specific date range use the startdate & enddate. +# ie startdate=2008-06-01 endate=2008-06-30 +# use POSIX; use POSIX qw(strftime); use DBI; @@ -86,7 +89,7 @@ foreach my $cardno (@cardlist) { my $carddata = &get_account( $astpp_db, $cardno ); if ( $carddata->{posttoexternal} == 1 ) { - my @recordlist = &get_charges($astpp_db, $config, $cardno); + my @recordlist = &get_charges($astpp_db, $config, $cardno,$params); foreach my $record (@recordlist) { my $cdrinfo = &get_charge($record); my $cost; @@ -112,7 +115,7 @@ foreach my $cardno (@cardlist) { my $carddata = &get_account( $astpp_db, $cardno ); if ( $carddata->{posttoexternal} == 1 ) { - my @recordlist = &get_charges($astpp_db, $config, $cardno); + my @recordlist = &get_charges($astpp_db, $config, $cardno,$params); foreach my $record (@recordlist) { my $cdrinfo = &get_charge($record); my $cost; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-09-02 05:02:40
|
Revision: 2191 http://astpp.svn.sourceforge.net/astpp/?rev=2191&view=rev Author: darrenkw Date: 2008-09-02 05:02:48 +0000 (Tue, 02 Sep 2008) Log Message: ----------- Added Freeswitch configuration and moved the remaining optional configuration to the database. Modified Paths: -------------- trunk/samples/sample.astpp-config.conf trunk/samples/sample.astpp-enh-config.conf Added Paths: ----------- trunk/sql/astpp-2008-09-01.sql Modified: trunk/samples/sample.astpp-config.conf =================================================================== --- trunk/samples/sample.astpp-config.conf 2008-08-28 17:15:17 UTC (rev 2190) +++ trunk/samples/sample.astpp-config.conf 2008-09-02 05:02:48 UTC (rev 2191) @@ -4,17 +4,6 @@ dbpass = password dbname = astpp -; Asterisk(tm) CDR Database Connection Information -cdr_dbuser = root -cdr_dbhost = 127.0.0.1 -cdr_dbpass = password -cdr_dbname = asteriskcdrdb - -; Asterisk(tm) Manager Connection Information -astman_user = admin -astman_host = 127.0.0.1 -astman_secret = amp111 - # Database type: ASTPP was designed for a MySQL database initially. Valid options are: # MySQL. Pgsql is coming but is not ready yet. astpp_dbengine = MySQL Modified: trunk/samples/sample.astpp-enh-config.conf =================================================================== --- trunk/samples/sample.astpp-enh-config.conf 2008-08-28 17:15:17 UTC (rev 2190) +++ trunk/samples/sample.astpp-enh-config.conf 2008-09-02 05:02:48 UTC (rev 2191) @@ -1,118 +0,0 @@ -# This file contains the more advanced ASTPP variables which should remain -# mostly constant between installs and which you do not want to change too easily. -# Changing this variables without knowing exactly what you are doing could have -# far ranging consequences. -# The Author - -results_per_page = 30 # How many results per page do we should in the web interface? -astpp_dir = /var/lib/astpp # Where do the astpp configs live? - -# This is the override authorization code and will allow access to the system. Should -# be set to something "impossible" to guess. DO NOT LEAVE AT THE DEFAULT!!! -auth = a23asudf9810-zalkj32423 - -# Database type: ASTPP was designed for a MySQL database initially. Valid options are: -# MySQL. Pgsql is coming but is not ready yet. -astpp_dbengine = MySQL -rt_dbengine = MySQL -cdr_dbengine = MySQL -osc_dbengine = MySQL -agile_dbengine = MySQL -freepbx_dbengine = MySQL - -# Please specify the external billing application to use. If you are not using any -# the leave it blank. Valid options are "agile" and "oscommerce". -externalbill = oscommerce - -# Do you wish to enable calling cards? 1 for yes and 2 for no. -callingcards = 1 - -# Change this one at your own peril. If you switch it off, calls will not be marked -# as billed in asterisk once they are billed. -astcdr = 1 - -# Change this one at your own peril. If you switch it off, calls will not be written -# to astpp when they are calculated. -posttoastpp = 1 - -# This is used when calling astpp-rate-engine.pl from the extensions.conf file. -# I would recommend 10 seconds as that gives that time to Asterisk to get the call written -# to the cdr database. -sleep = 10 - -# If this is enabled, ASTPP will create users and DIDs in the FreePBX (www.freepbx.org) -# mysql DB. -users_dids_amp = 0 - -# If this is enabled, ASTPP will create users and DIDs in the Asterisk Realtime -# mysql DB. -users_dids_rt = 1 - -# Service prepend is the number that ASTPP attaches to the front of the id that it is passed -# in astpp-auto-admin.cgi -# If service_prepend is left blank, then the new method kicks in. The new method allows you -# to specify a required extension length and default filler. It then chops the strings up. -service_prepend = 778 -service_length = 7 -service_filler = 4110000 - -# AgileBill(Trademark of AgileCo) Settings: -agile_host = 127.0.0.1 -agile_db = agile -agile_user = root -agile_pass = -agile_site_id = 1 -agile_charge_status = 0 -agile_taxable = 1 -agile_dbprefix = _ -agile_service_prepend = 778 - -# OSCommerce Settings (www.oscommerce.org) -osc_host = 127.0.0.1 -osc_db = oscommerce -osc_user = root -osc_pass = password -osc_product_id = 99999999 -osc_payment_method = "Charge" -osc_order_status = 1 - -# FreePBX Settings (www.freepbx.org) -freepbx_host = 127.0.0.1 -freepbx_db = asterisk -freepbx_user = root -freepbx_pass = passw0rd -freepbx_iax_table = iax -freepbx_table = sip -freepbx_extensions_table = extensions -freepbx_codec_allow = g729,ulaw,alaw -freepbx_codec_disallow = all -freepbx_mailbox_group = default -freepbx_sip_nat = yes -freepbx_sip_canreinvite = no -freepbx_sip_dtmfmode = rfc2833 -freepbx_sip_qualify = yes -freepbx_sip_type = friend -freepbx_sip_callgroup = -freepbx_sip_pickupgroup = -freepbx_iax_notransfer = yes -freepbx_iax_type = friend -freepbx_iax_qualify = yes - -# Asterisk -realtime Settings -rt_host = 127.0.0.1 -rt_db = realtime -rt_user = root -rt_pass = -rt_iax_table = iax -rt_sip_table = sip -rt_extensions_table = extensions -rt_sip_insecure = very -rt_sip_nat = yes -rt_sip_canreinvite = no -rt_codec_allow = g729,ulaw,alaw -rt_codec_disallow = all -rt_mailbox_group = default -rt_sip_qualify = yes -rt_sip_type = friend -rt_iax_qualify = yes -rt_voicemail_table = voicemail_users Added: trunk/sql/astpp-2008-09-01.sql =================================================================== --- trunk/sql/astpp-2008-09-01.sql (rev 0) +++ trunk/sql/astpp-2008-09-01.sql 2008-09-02 05:02:48 UTC (rev 2191) @@ -0,0 +1,1261 @@ +DROP TABLE IF EXISTS `routes`; +CREATE TABLE routes ( +id INTEGER NOT NULL AUTO_INCREMENT, +pattern CHAR(40), +comment CHAR(80), +connectcost INTEGER NOT NULL, +includedseconds INTEGER NOT NULL, +cost INTEGER NOT NULL, +pricelist CHAR(80), +inc INTEGER, +reseller CHAR(50) default NULL, +precedence INT(4) NOT NULL DEFAULT 0, +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`), +KEY `pattern` (`pattern`), +KEY `pricelist` (`pricelist`), +KEY `reseller` (`reseller`), +KEY `status` (`status`) +); + +DROP TABLE IF EXISTS `pricelists`; +CREATE TABLE pricelists ( +name CHAR(40) NOT NULL, +markup INTEGER NOT NULL DEFAULT 0, +inc INTEGER NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +reseller CHAR(50) default NULL, +PRIMARY KEY (`name`) +); + +DROP TABLE IF EXISTS `callingcardbrands`; +CREATE TABLE callingcardbrands ( +name CHAR(40) NOT NULL, +reseller CHAR(40) NOT NULL DEFAULT '', +language CHAR(10) NOT NULL DEFAULT '', +pricelist CHAR(40) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +validfordays CHAR(4) NOT NULL DEFAULT '', +pin INTEGER NOT NULL DEFAULT 0, +maint_fee_pennies INTEGER NOT NULL DEFAULT 0, +maint_fee_days INTEGER NOT NULL DEFAULT 0, +disconnect_fee_pennies INTEGER NOT NULL DEFAULT 0, +minute_fee_minutes INTEGER NOT NULL DEFAULT 0, +minute_fee_pennies INTEGER NOT NULL DEFAULT 0, +min_length_minutes INTEGER NOT NULL DEFAULT 0, +min_length_pennies INTEGER NOT NULL DEFAULT 0, +PRIMARY KEY (`name`), + KEY `reseller` (`reseller`), + KEY `pricelist` (`pricelist`) +); + +DROP TABLE IF EXISTS `callingcardcdrs`; +CREATE TABLE callingcardcdrs ( +id INTEGER NOT NULL AUTO_INCREMENT, +cardnumber CHAR(50) NOT NULL DEFAULT '', +clid CHAR(80) NOT NULL DEFAULT '', +destination CHAR(40) NOT NULL DEFAULT '', +disposition CHAR(20)NOT NULL DEFAULT '', +callstart CHAR(40) NOT NULL DEFAULT '', +seconds INTEGER NOT NULL DEFAULT 0, +debit DECIMAL(20,6) NOT NULL DEFAULT 0.00000, +credit DECIMAL(20,6) NOT NULL DEFAULT 0.00000, +status INTEGER DEFAULT 0 NOT NULL, +uniqueid VARCHAR(32) NOT NULL DEFAULT '', +notes CHAR(80) NOT NULL DEFAULT '', +pricelist CHAR(80) NOT NULL DEFAULT '', +pattern CHAR(80) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + KEY `cardnumber` (`cardnumber`) +); + +DROP TABLE IF EXISTS `trunks`; +CREATE TABLE trunks ( +name VARCHAR(30) NOT NULL, +tech CHAR(10) NOT NULL DEFAULT '', +path CHAR(40) NOT NULL DEFAULT '', +provider CHAR(100) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +dialed_modify TEXT NOT NULL DEFAULT '', +resellers TEXT NOT NULL DEFAULT '', +precedence INT(4) NOT NULL DEFAULT 0, +maxchannels INTEGER DEFAULT 0 NOT NULL, + PRIMARY KEY (`name`), + KEY `provider` (`provider`), + KEY `provider_2` (`provider`) +); + +DROP TABLE IF EXISTS `outbound_routes`; +CREATE TABLE outbound_routes ( +pattern CHAR(40), +id INTEGER NOT NULL AUTO_INCREMENT, +comment CHAR(80) NOT NULL DEFAULT '', +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +trunk CHAR(80) NOT NULL DEFAULT '', +inc CHAR(10) NOT NULL DEFAULT '', +strip CHAR(40) NOT NULL DEFAULT '', +prepend CHAR(40) NOT NULL DEFAULT '', +precedence INT(4) NOT NULL DEFAULT 0, +resellers TEXT NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `trunk` (`trunk`), + KEY `pattern` (`pattern`) +); + +DROP TABLE IF EXISTS `dids`; +CREATE TABLE dids ( +number CHAR(40) NOT NULL, +account CHAR(50) NOT NULL DEFAULT '', +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +monthlycost INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +inc CHAR(10) NOT NULL DEFAULT '', +extensions CHAR(180) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +provider CHAR(40) NOT NULL DEFAULT '', +country CHAR (80)NOT NULL DEFAULT '', +province CHAR (80) NOT NULL DEFAULT '', +city CHAR (80) NOT NULL DEFAULT '', +prorate int(1) NOT NULL default 0, +setup int(11) NOT NULL default 0, +limittime int(1) NOT NULL default 1, +disconnectionfee INT(11) NOT NULL default 0, +variables TEXT NOT NULL DEFAULT '', +options varchar(40) default NULL, +maxchannels int(4) NOT NULL default 0, +chargeonallocation int(1) NOT NULL default 1, +allocation_bill_status int(1) NOT NULL default 0, +dial_as CHAR(40) NOT NULL DEFAULT '', +PRIMARY KEY (`number`), + KEY `account` (`account`) +); + +DROP TABLE IF EXISTS `accounts`; +CREATE TABLE accounts ( +cc CHAR(20) NOT NULL DEFAULT '', +number CHAR(50) NOT NULL, +reseller CHAR(40) NOT NULL DEFAULT '', +pricelist CHAR(24) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +credit INTEGER NOT NULL DEFAULT 0, +sweep INTEGER NOT NULL DEFAULT 0, +creation TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, +pin INTEGER NOT NULL DEFAULT 0, +credit_limit INTEGER NOT NULL DEFAULT 0, +posttoexternal INTEGER NOT NULL DEFAULT 0, +balance DECIMAL(20,6) NOT NULL DEFAULT 0, +password CHAR(80) NOT NULL DEFAULT '', +first_name CHAR(40) NOT NULL DEFAULT '', +middle_name CHAR(40) NOT NULL DEFAULT '', +last_name CHAR(40) NOT NULL DEFAULT '', +company_name CHAR(40) NOT NULL DEFAULT '', +address_1 CHAR(80) NOT NULL DEFAULT '', +address_2 CHAR(80) NOT NULL DEFAULT '', +address_3 CHAR(80) NOT NULL DEFAULT '', +postal_code CHAR(12) NOT NULL DEFAULT '', +province CHAR(40) NOT NULL DEFAULT '', +city CHAR(80) NOT NULL DEFAULT '', +country CHAR(40) NOT NULL DEFAULT '', +telephone_1 CHAR(40) NOT NULL DEFAULT '', +telephone_2 CHAR(40) NOT NULL DEFAULT '', +fascimile CHAR(40) NOT NULL DEFAULT '', +email CHAR(80) NOT NULL DEFAULT '', +language CHAR(2) NOT NULL DEFAULT '', +currency CHAR(3) NOT NULL DEFAULT '', +maxchannels INTEGER DEFAULT 1 NOT NULL, +routing_technique INT(4) NOT NULL DEFAULT 0, +dialed_modify TEXT NOT NULL DEFAULT '', +type INTEGER DEFAULT 0, +tz CHAR(40) NOT NULL DEFAULT '', +PRIMARY KEY (`number`), + KEY `pricelist` (`pricelist`), + KEY `reseller` (`reseller`) +); + +DROP TABLE IF EXISTS `counters`; +CREATE TABLE counters ( +id INTEGER NOT NULL AUTO_INCREMENT, +package CHAR(40) NOT NULL DEFAULT '', +account VARCHAR(50) NOT NULL, +seconds INTEGER NOT NULL DEFAULT 0, +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`) +); + +DROP TABLE IF EXISTS `callingcards`; +CREATE TABLE callingcards ( +id INTEGER NOT NULL AUTO_INCREMENT, +cardnumber CHAR(20) NOT NULL DEFAULT '', +language CHAR(10) NOT NULL DEFAULT '', +value INTEGER NOT NULL DEFAULT 0, +used INTEGER NOT NULL DEFAULT 0, +brand VARCHAR(20) NOT NULL DEFAULT '', +created DATETIME, +firstused DATETIME, +expiry DATETIME, +validfordays CHAR(4) NOT NULL DEFAULT '', +inuse INTEGER NOT NULL DEFAULT 0, +pin CHAR(20), +account VARCHAR(50) NOT NULL DEFAULT '', +maint_fee_pennies INTEGER NOT NULL DEFAULT 0, +maint_fee_days INTEGER NOT NULL DEFAULT 0, +maint_day INTEGER NOT NULL DEFAULT 0, +disconnect_fee_pennies INTEGER NOT NULL DEFAULT 0, +minute_fee_minutes INTEGER NOT NULL DEFAULT 0, +minute_fee_pennies INTEGER NOT NULL DEFAULT 0, +min_length_minutes INTEGER NOT NULL DEFAULT 0, +min_length_pennies INTEGER NOT NULL DEFAULT 0, +timeused INTEGER NOT NULL DEFAULT 0, +invoice CHAR(20) NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `brand` (`brand`) +); + +CREATE TABLE charge_to_account ( +id INTEGER NOT NULL AUTO_INCREMENT, +charge_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(50) NOT NULL DEFAULT '', +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`) +); + +CREATE TABLE queue_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +queue_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE pbx_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +pbx_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE extension_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +extension_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE cdrs ( +id INTEGER NOT NULL AUTO_INCREMENT, +uniqueid varchar(32) NOT NULL DEFAULT '', +cardnum CHAR(50), +callerid CHAR(80), +callednum varchar(80) NOT NULL DEFAULT '', +billseconds INT DEFAULT 0 NOT NULL, +trunk VARCHAR(30), +disposition varchar(45) NOT NULL DEFAULT '', +callstart varchar(80) NOT NULL DEFAULT '', +debit DECIMAL (20,6) NOT NULL DEFAULT 0, +credit DECIMAL (20,6) NOT NULL DEFAULT 0, +status INTEGER DEFAULT 0 NOT NULL, +notes CHAR(80), +provider CHAR(50), +cost DECIMAL(20,6) NOT NULL DEFAULT 0, +pricelist CHAR(80) NOT NULL DEFAULT '', +pattern CHAR(80) NOT NULL DEFAULT '', +PRIMARY KEY (`id`), + KEY `cardnum` (`cardnum`), + KEY `provider` (`provider`), + KEY `trunk` (`trunk`), + KEY `uniqueid` (`uniqueid`), + KEY `status` (`status`) +); + +CREATE TABLE packages ( +id INTEGER NOT NULL AUTO_INCREMENT, +name CHAR(40) NOT NULL DEFAULT '', +pricelist CHAR(40) NOT NULL DEFAULT '', +pattern CHAR(40) NOT NULL DEFAULT '', +includedseconds INTEGER NOT NULL DEFAULT 0, +reseller VARCHAR(50) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `pricelist` (`pricelist`), + KEY `reseller` (`reseller`) +); + +CREATE TABLE ani_map ( +number char(20) NOT NULL, +account char(50) NOT NULL default '', +status int(11) NOT NULL default '0', +context varchar(20) NOT NULL, + PRIMARY KEY (`number`), +KEY `account` (`account`) +); + +CREATE TABLE `ip_map` ( +ip char(15) NOT NULL default '', +account char(20) NOT NULL default '', +prefix varchar(20) NULL, +context varchar(20) NOT NULL, +PRIMARY KEY (`ip`,`prefix`), +KEY `account` (`account`) +); + +CREATE TABLE charges ( +id INTEGER NOT NULL AUTO_INCREMENT, +pricelist CHAR(40) NOT NULL DEFAULT '', +description VARCHAR(80) NOT NULL DEFAULT '', +charge INTEGER NOT NULL DEFAULT 0, +sweep INTEGER NOT NULL DEFAULT 0, +reseller CHAR(40) NOT NULL DEFAULT '', +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`), + KEY `pricelist` (`pricelist`) +); + +CREATE TABLE manager_action_variables ( +id INTEGER NOT NULL AUTO_INCREMENT, +name CHAR(60) NOT NULL DEFAULT '', +value CHAR(60) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE callingcard_stats ( +uniqueid VARCHAR(48) NOT NULL, +total_time VARCHAR(48) NOT NULL, +billable_time VARCHAR(48) NOT NULL, +timestamp DATETIME NULL, +PRIMARY KEY (`uniqueid`) +); + +CREATE TABLE system ( +name VARCHAR(48) NULL, +value VARCHAR(255) NULL, +comment VARCHAR(255) NULL, +timestamp DATETIME NULL, +reseller VARCHAR(48) NULL, +brand VARCHAR(48) NULL, +PRIMARY KEY (`name`), + KEY `reseller` (`reseller`), + KEY `brand` (`brand`) +); + + +INSERT INTO system (name, value, comment) VALUES ( +'callout_accountcode','admin','Call Files: What accountcode should we use?'); + +INSERT INTO system (name, value, comment) VALUES ( +'lcrcontext','astpp-outgoing','This is the Local context we use to route our outgoing calls through esp for callbacks'); + +INSERT INTO system (name, value, comment) VALUES ( +'maxretries','3','Call Files: How many times do we retry?'); + +INSERT INTO system (name, value, comment) VALUES ( +'retrytime','30','Call Files: How long do we wait between retries?'); + +INSERT INTO system (name, value, comment) VALUES ( +'waittime','15','Call Files: How long do we wait before the initial call?'); + +INSERT INTO system (name, value, comment) VALUES ( +'clidname','Private','Call Files: Outgoing CallerID Name'); + +INSERT INTO system (name, value, comment) VALUES ( +'clidnumber','0000000000','Call Files: Outgoing CallerID Number'); + +INSERT INTO system (name, value, comment) VALUES ( +'callingcards_callback_context','astpp-callingcards','Call Files: For callingcards what context do we end up in?'); + +INSERT INTO system (name, value, comment) VALUES ( +'callingcards_callback_extension', 's','Call Files: For callingcards what extension do we use?'); + +INSERT INTO system (name, value, comment) VALUES ( +'openser_dbengine', 'MySQL','For now this must be MySQL'); + +INSERT INTO system (name, value, comment) VALUES ( +'openser', '0','Use OPENSER? 1 for yes or 0 for no'); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbname', 'openser','OPENSER Database Name', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbuser', 'root','OPENSER Database User', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbhost', 'localhost','OPENSER Database Host', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbpass', 'Passw0rd','OPENSER Database Password', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_domain', NULL,'OPENSER Domain', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_email', 'em...@as...','Email address that email should appear to be from', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'asterisk_dir', '/etc/asterisk','Which directory are asterisk configuration files stored in?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_website', 'http://www.astpp.org','Link to your company website', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_name', 'ASTPP.ORG','The name of your company. Used in emails.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'email', '1','Send out email? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'user_email', '1','Email user on account changes? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'debug', '0','Enable debugging output? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'emailadd', 'em...@as...','Administrator email address', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'startingdigit', '0','The digit that all calling cards must start with. 0=disabled', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'enablelcr', '1','Use least cost routing 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'log_file', '/var/log/astpp/astpp.log','ASTPP Log file', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'key_home', 'http://www.astpp.org/astpp.pub','Asterisk RSA Key location (optional)', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rate_engine_csv_file', '/var/log/astpp/astpp.csv','CSV File for call rating data', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'csv_dir', '/var/log/astpp/','CSV File Directory', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_brand', 'default','Default pricelist. If a price is not found in the customers pricelist we check this one.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'new_user_brand', 'default','What is the default pricelist for new customers?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_context', 'custom-astpp','What is the default context for new devices?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cardlength', '10','Number of digits in calling cards and cc codes.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'asterisk_server', 'voip.astpp.org','Your default voip server. Used in outgoing email.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'currency', 'CAD','Name of the currency you use', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'iax_port', '4569','Default IAX2 Port', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'sip_port', '5060','Default SIP Port', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'ipaddr', 'dynamic','Default IP Address for new devices', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'key', 'astpp.pub','Asterisk RSA Key Name (Optional)', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'pinlength', '6','For those calling cards that are using pins this is the number of digits it will have.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'credit_limit', '0','Default credit limit in dollars.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'decimalpoints', '4','How many decimal points do we bill to?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'max_free_length', '100','What is the maximum length (in minutes) of calls that are at no charge?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'trackvendorcharges', '1','Do we track the amount of money we spend with specific providers? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_logo', 'http://www.astpp.org/logo.png','The location of our company logo.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_slogan', 'Welcome to ASTPP','Company slogan', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'version', '1.5Beta', 'ASTPP Version', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_language', 'en', 'Default ASTPP Language',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'card_retries','3', 'How many retries do we allow for calling card numbers?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'pin_retries','3', 'How many retries do we allow for pins?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'number_retries','3','How many retries do we allow calling card users when dialing a number?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'booth_context','callshop_booth','Please enter the default context for a callshop booth.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'callingcards_max_length','9000','What is the maximum length (in ms) of a callingcard call?',''); + +INSERT INTO system (name,value,comment,timestamp) VALUES ( +'template_die_on_bad_params','0','Should HTML::Template die on bad parameters?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'results_per_page','30','How many results per page do we should in the web interface?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astpp_dir','/var/lib/astpp','Where do the astpp configs live?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'auth','a23asudf9810-zalkj32423','This is the override authorization code and will allow access to the system.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_dbengine','MySQL','Database type for Asterisk(tm) -Realtime',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbengine','MySQL','Database type for the cdr database',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_dbengine','MySQL','Database type for OSCommerce',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_dbengine','MySQL','Database type for AgileBill(tm)',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_dbengine','MySQL','Database type for FreePBX',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'externalbill','oscommerce','Please specify the external billing application to use. If you are not using any then leave it blank. Valid options are "agile" and "oscommerce".',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'callingcards','1','Do you wish to enable calling cards? 1 for yes and 2 for no.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astcdr','1','Change this one at your own peril. If you switch it off, calls will not be marked as billed in asterisk once they are billed.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'posttoastpp','1','Change this one at your own peril. If you switch it off, calls will not be written to astpp when they are calculated.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'sleep','10','How long shall the rating engine sleep after it has been notified of a hangup? (in seconds)',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'users_dids_amp','0','If this is enabled, ASTPP will create users and DIDs in the FreePBX (www.freepbx.org) database.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'users_dids_rt','1','If this is enabled, ASTPP will create users and DIDs in the Asterisk Realtime database.',''); + +INSERT INTO system (name, value, comment) VALUES ( +'service_prepend','778',''); +INSERT INTO system (name, value, comment) VALUES ( +'service_length,','7',''); +INSERT INTO system (name, value, comment) VALUES ( +'service_filler','4110000',''); + +INSERT INTO system (name, value, comment) VALUES ( +'asterisk_cdr_table','cdr','Which table of the Asterisk(TM) database are the cdrs in?'); + +-- AgileBill(Trademark of AgileCo) Settings: +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_db','agile','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_pass','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_site_id','1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_charge_status','0','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_taxable','1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_dbprefix','_','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_service_prepend','778','',''); + +-- OSCommerce Settings (www.oscommerce.org) +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_db','oscommerce','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_pass','password','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_product_id','99999999','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_payment_method','"Charge"','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_order_status','1','',''); + +-- FreePBX Settings (www.freepbx.org) +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_db','asterisk','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_pass','passw0rd','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_table','iax','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_table','sip','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_extensions_table','extensions','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_codec_allow','g729,ulaw,alaw','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_codec_disallow','all','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_mailbox_group','default','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_nat','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_canreinvite','no','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_dtmfmode','rfc2833','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_callgroup','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_pickupgroup','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_notransfer','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_qualify','yes','',''); + +-- Asterisk -realtime Settings +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_db','realtime','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_pass','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_table','iax','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_table','sip','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_extensions_table','extensions','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_insecure','very','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_nat','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_canreinvite','no','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_codec_allow','g729,ulaw,alaw','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_codec_disallow','all','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_mailbox_group','default','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_type','friend','',''); +INSERT INTO system (name, value, comment) VALUES ( +'rt_voicemail_table','voicemail_users',''); + + +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_rate_announce','1','Do we want the calling cards script to announce the rate on calls?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_timelimit_announce','1','Do we want the calling cards script to announce the timelimit on calls?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_cancelled_prompt','1','Do we want the calling cards script to announce that the call was cancelled?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_menu','1','Do we want the calling cards script to present a menu before exiting?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_connection_prompt','1','Do we want the calling cards script to announce that it is connecting the call?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_pin_input_timeout','15000','How long do we wait when entering the calling card pin? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_number_input_timeout','15000','How long do we wait when entering the calling card number? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_dial_input_timeout','15000','How long do we wait when entering the destination number in calling cards? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_general_input_timeout','15000','How long do we wait for input in general menus? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_welcome_file','silence/1','What do we play for a welcome file?'); + +INSERT INTO system (name, value, comment) VALUES ( +'sip_ext_prepend','10','What should every autoadded SIP extension begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'iax2_ext_prepend','10','What should every autoadded IAX2 extension begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'cc_prepend','','What should every autoadded callingcard begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'pin_cc_prepend','','What should every autoadded callingcard pin begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'pin_act_prepend','','What should every autoadded account pin begin with?'); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_directory','/usr/local/freeswitch','What is the Freeswitch root directory?'); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbname', 'asteriskcdrdb', +'CDR Database Name', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbuser', 'root', +'CDR Database User', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbhost', 'localhost', +'CDR Database Host', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbpass', 'Passw0rd', +'CDR Database Password', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astman_user', 'admin','Asterisk(tm) Manager Interface User', ''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astman_host', 'localhost','Asterisk(tm) Manager Interface Host', ''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astman_secret', 'amp111','Asterisk(tm) Manager Interface Secret', ''); + + +-- +-- Enough Configuration settings +-- + +DROP TABLE IF EXISTS `countrycode`; +CREATE TABLE `countrycode` ( + `country` varchar(255) NOT NULL, + PRIMARY KEY (`country`), + KEY `country` (`country`) +); + +INSERT INTO `countrycode` (`country`) VALUES + ('Afghanistan'), + ('Alaska'), + ('Albania'), + ('Algeria'), + ('AmericanSamoa'), + ('Andorra'), + ('Angola'), + ('Antarctica'), + ('Argentina'), + ('Armenia'), + ('Aruba'), + ('Ascension'), + ('Australia'), + ('Austria'), + ('Azerbaijan'), + ('Bahrain'), + ('Bangladesh'), + ('Belarus'), + ('Belgium'), + ('Belize'), + ('Benin'), + ('Bhutan'), + ('Bolivia'), + ('Bosnia & Herzegovina'), + ('Botswana'), + ('Brazil'), + ('Brunei Darussalam'), + ('Bulgaria'), + ('Burkina Faso'), + ('Burundi'), + ('Cambodia'), + ('Cameroon'), + ('Canadda'), + ('Cape Verde Islands'), + ('Central African Republic'), + ('Chad'), + ('Chile'), + ('China'), + ('Colombia'), + ('Comoros'), + ('Congo'), + ('Cook Islands'), + ('Costa Rica'), + ('Croatia'), + ('Cuba'), + ('Cuba Guantanamo Bay'), + ('Cyprus'), + ('Czech Republic'), + ('Denmark'), + ('Diego Garcia'), + ('Djibouti'), + ('Dominican Republic'), + ('East Timor'), + ('Ecuador'), + ('Egypt'), + ('El Salvador'), + ('Equatorial Guinea'), + ('Eritrea'), + ('Estonia'), + ('Ethiopia'), + ('Faroe Islands'); +INSERT INTO `countrycode` (`country`) VALUES + ('Fiji Islands'), + ('Finland'), + ('France'), + ('French Guiana'), + ('French Polynesia'), + ('Gabonese Republic'), + ('Gambia'), + ('Georgia'), + ('Germany'), + ('Ghana'), + ('Gibraltar'), + ('Greece'), + ('Greenland'), + ('Guadeloupe'), + ('Guam'), + ('Guatemala'), + ('Guinea'), + ('Guyana'), + ('Haiti'), + ('Honduras'), + ('Hong Kong'), + ('Hungary'), + ('Iceland'), + ('India'), + ('Indonesia'), + ('Iran'), + ('Iraq'), + ('Ireland'), + ('Israel'), + ('Italy'), + ('Jamaica'), + ('Japan'), + ('Jordan'), + ('Kazakstan'), + ('Kenya'), + ('Kiribati'), + ('Kuwait'), + ('Kyrgyz Republic'), + ('Laos'), + ('Latvia'), + ('Lebanon'), + ('Lesotho'), + ('Liberia'), + ('Libya'), + ('Liechtenstein'), + ('Lithuania'), + ('Luxembourg'), + ('Macao'), + ('Madagascar'), + ('Malawi'), + ('Malaysia'), + ('Maldives'), + ('Mali Republic'), + ('Malta'), + ('Marshall Islands'), + ('Martinique'), + ('Mauritania'), + ('Mauritius'), + ('MayotteIsland'), + ('Mexico'), + ('Midway Islands'), + ('Moldova'), + ('Monaco'), + ('Mongolia'), + ('Morocco'); +INSERT INTO `countrycode` (`country`) VALUES + ('Mozambique'), + ('Myanmar'), + ('Namibia'), + ('Nauru'), + ('Nepal'), + ('Netherlands'), + ('Netherlands Antilles'), + ('New Caledonia'), + ('New Zealand'), + ('Nicaragua'), + ('Niger'), + ('Nigeria'), + ('Niue'), + ('Norfolk Island'), + ('North Korea'), + ('Norway'), + ('Oman'), + ('Pakistan'), + ('Palau'), + ('Palestinian Settlements'), + ('Panama'), + ('PapuaNew Guinea'), + ('Paraguay'), + ('Peru'), + ('Philippines'), + ('Poland'), + ('Portugal'), + ('Puerto Rico'), + ('Qatar'), + ('RéunionIsland'), + ('Romania'), + ('Russia'), + ('Rwandese Republic'), + ('San Marino'), + ('São Tomé and Principe'), + ('Saudi Arabia'), + ('Senegal '), + ('Serbia and Montenegro'), + ('Seychelles Republic'), + ('Sierra Leone'), + ('Singapore'), + ('Slovak Republic'), + ('Slovenia'), + ('Solomon Islands'), + ('Somali Democratic Republic'), + ('South Africa'), + ('South Korea'), + ('Spain'), + ('Sri Lanka'), + ('St Kitts - Nevis'), + ('St. Helena'), + ('St. Lucia'), + ('St. Pierre & Miquelon'), + ('St. Vincent & Grenadines'), + ('Sudan'); +INSERT INTO `countrycode` (`country`) VALUES + ('Suriname'), + ('Swaziland'), + ('Sweden'), + ('Switzerland'), + ('Syria'), + ('Taiwan'), + ('Tajikistan'), + ('Tanzania'), + ('Thailand'), + ('Togolese Republic'), + ('Tokelau'), + ('Tonga Islands'), + ('Trinidad & Tobago'), + ('Tunisia'), + ('Turkey'), + ('Turkmenistan'), + ('Tuvalu'), + ('Uganda'), + ('Ukraine'), + ('United Arab Emirates'), + ('United Kingdom'), + ('United States of America'), + ('Uruguay'), + ('Uzbekistan'), + ('Vanuatu'), + ('Venezuela'), + ('Vietnam'), + ('Wake Island'), + ('Wallisand Futuna Islands'), + ('Western Samoa'), + ('Yemen'), + ('Zambia'), + ('Zimbabwe'); + +DROP TABLE IF EXISTS `currency`; +CREATE TABLE `currency` ( + `Currency` varchar(3) NOT NULL default '', + `CurrencyName` varchar(40) NOT NULL default '', + PRIMARY KEY (`Currency`) +); + +INSERT INTO `currency` (`Currency`,`CurrencyName`) VALUES + ('USD','US Dollars'), + ('CAD','Canadian Dollars'), + ('AUD','Australian Dollars'); + +CREATE TABLE `language` ( + `language` varchar(5) NOT NULL, + `languagename` varchar(40) NOT NULL, + `active` tinyint(1) NOT NULL default '1', + PRIMARY KEY (`language`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +INSERT INTO `language` (`language`,`languagename`,`active`) VALUES + ('en','English',1), + ('fr','French',1), + ('de','German',1); + +CREATE TABLE `resellers` ( + name varchar(40) NOT NULL default '', + status int(11) NOT NULL default '1', + posttoexternal int(11) NOT NULL default '0', + agile_site_id int(11) NOT NULL default '0', + config_file char(80) NOT NULL default 'reseller.conf', + companyname varchar(255) default NULL, + slogan varchar(255) default NULL, + footer varchar(255) default NULL, + pricelist varchar(255) default NULL, + currency varchar(255) default NULL, + logo varchar(255) default NULL, + website varchar(255) default NULL, + adminemail varchar(255) default NULL, + salesemail varchar(255) default NULL, + phone varchar(45) default NULL, + fax varchar(45) default NULL, + address1 varchar(255) default NULL, + address2 varchar(255) default NULL, + city varchar(255) default NULL, + state varchar(255) default NULL, + postcode varchar(255) default NULL, + country varchar(255) default NULL, + defaultbrand varchar(45) NOT NULL default 'default', + defaultcurrency varchar(45) NOT NULL default 'USD', + defaultcredit varchar(45) NOT NULL default '0.00', + externalbill varchar(45) NOT NULL default '', + PRIMARY KEY (`name`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + +CREATE TABLE templates ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(45) NOT NULL default '', +reseller VARCHAR(45) NOT NULL default '', +template TEXT NOT NULL default '', + PRIMARY KEY (`id`), + KEY `reseller` (`reseller`) +); + +INSERT INTO templates (name,template) VALUES +('voip_account_refilled','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been refilled. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('voip_reactivate_account','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been reactivated. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_add_user','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been added. +Your Username is -- $vars->{extension} -- +Your Password is -- $vars->{secret} -- +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('add_sip_device','Attention: $vars->{title} $vars->{first} $vars->{last} +A new device has been enabled on your account. Here +is the necessary configuration information. +------- $config->{company_name} Configuration Info -------- +In sip.conf: +[$config->{company_name}-in] +type=user +username=$config->{company_name}-in +auth=rsa +inkeys=$config->{key} ;This key may be downloaded from $config->{key_home} +host=$config->{asterisk_server} +context=from-pstn +accountcode=$config->{company_name} +[$config->{company_name}] +type=peer +username=$vars->{extension} +secret=$vars->{secret} +host=$config->{asterisk_server} +callerid= <555-555-5555> +qualify=yes +accountcode=$config->{company_name} ; for call tracking in the cdr +In the [globals] section add: +register => $vars->{user}:password@$config->{asterisk_server}'); + +INSERT INTO templates (name,template) VALUES +('add_iax_device','Attention: $vars->{title} $vars->{first} $vars->{last} +A new device has been enabled on your account. Here +is the necessary configuration information. +------- $config->{company_name} Configuration Info -------- +In iax.conf: +At the bottom of the file add: +[$config->{company_name}-in] +;trunk=yes ;optional .. only works if you have a zaptel or ztdummy driver running +type=user +username=$config->{company_name}-in +auth=rsa +inkeys=$config->{key} ;This key may be downloaded from $config->{key_home} +host=$config->{asterisk_server} +context=incoming +accountcode=$config->{company_name} ;for call tracking in the cdr +[$config->{company_name}] +;to simplify and config outgoing calls +;trunk=yes ;optional .. only works if you have a zaptel driver running +type=peer +username=$vars->{extension} +secret=$vars->{secret} +host=$config->{asterisk_server} +callerid=<555-555-5555> ;only the number will really be used +qualify=yes +accountcode=$config->{company_name} ; for call tracking in the cdr +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_remove_user','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP Termination with $config->{company_name} has been removed +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_calling_card','You have added a $vars->{pricelist} callingcard in the amount of $vars->{pennies} cents. +Card Number $cc Pin: $pin +Thanks for your patronage. +The $config->{company_name} sales team'); + +INSERT INTO templates (name,template) VALUES +('email_add_did','Attention: $vars->{title} $vars->{first} $vars->{last} +Your DID with $config->{company_name} has been added +The number is: $did +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team +Here is a sample setup which would call a few sip phones with incoming calls: +[incoming] +exten => _1$did,1,Wait(2) +exten => _1$did,2,Dial(SIP/2201&SIP/2202,15,Ttm) ; dial a couple of phones for 15 secs +exten => _1$did,3,Voicemail(u1000) ; go to unavailable voicemail (vm box 1000) +exten => _1$did,103,Voicemail(b1000) ; go to busy voicemail (vm box 1000)'); + +INSERT INTO templates (name,template) VALUES +('email_remove_did','Attention: $vars->{title} $vars->{first} $vars->{last} +Your DID with $config->{company_name} has been removed +The number was: $did +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_new_invoice','Invoice # $invoice in the amount of \$$total has been added to your account. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_low_balance','Your VOIP account with $config->{company_name} has a balance of \$$balance. +Please visit our website to refill your account to ensure uninterrupted service. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +CREATE TABLE `sweeplist` ( + `Id` int(10) unsigned NOT NULL default '0', + `sweep` varchar(45) NOT NULL default '', + PRIMARY KEY (`Id`) +); + +INSERT INTO sweeplist (Id,sweep) VALUES +(0,'daily'), +(1,'weekly'), +(2,'monthly'), +(3,'quarterly'), +(4,'semi-annually'), +(5,'annually') +; + +CREATE TABLE userlevels ( +userlevelid int(11) NOT NULL, +userlevelname varchar(50) NOT NULL, +PRIMARY KEY (`userlevelid`) +); + +INSERT INTO `userlevels` (`userlevelid`,`userlevelname`) VALUES + (-1,'Administrator'), + (0,'Anonymous'), + (1,'Reseller'), + (2,'Admin'), + (3,'Vendor'), + (4,'Customer Service'), + (5,'Users'); + +CREATE TABLE reseller_pricing ( +id INTEGER NOT NULL AUTO_INCREMENT, +reseller VARCHAR(50) NOT NULL, +type INTEGER NOT NULL DEFAULT 1, +monthlycost INTEGER NOT NULL DEFAULT 0, +prorate INTEGER NOT NULL DEFAULT 0, +setup INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +note VARCHAR(50) NOT NULL DEFAULT '', +disconnectionfee INTEGER NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +inc CHAR(10) NOT NULL DEFAULT '', +PRIMARY KEY (`id`), + KEY `reseller` (`reseller`) +); + +CREATE TABLE callshops ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(50) NOT NULL, +osc_dbname VARCHAR(50) NOT NULL DEFAULT '', +osc_dbpass VARCHAR(50) NOT NULL DEFAULT '', +osc_dbuser VARCHAR(50) NOT NULL DEFAULT '', +osc_dbhost VARCHAR(50) NOT NULL DEFAULT '', +osc_site VARCHAR(50) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), +KEY `name` (`name`) +); + +CREATE TABLE extensions_status ( +id INTEGER NOT NULL AUTO_INCREMENT, +tech VARCHAR(6) NULL, +extension VARCHAR(20) NULL, +number VARCHAR(255) NULL, +status VARCHAR(255) NULL, +timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, +Privilege VARCHAR(255) NULL, +Channel VARCHAR(255) NULL, +Cause VARCHAR(255) NULL, +Causetxt VARCHAR(255) NULL, +PeerStatus VARCHAR(255) NULL, +Peer VARCHAR(255) NULL, +Context VARCHAR(255) NULL, +Application VARCHAR(255) NULL, +AppData VARCHAR(255) NULL, +Priority VARCHAR(255) NULL, +Uniqueid VARCHAR(255) NULL, +Event VARCHAR(255) NULL, +State VARCHAR(255) NULL, +CallerIDName VARCHAR(255) NULL, +CallerID VARCHAR(255) NULL, +AstExtension VARCHAR(255) NULL, +PRIMARY KEY (`id`), +KEY `extension` (`extension`)); + +CREATE TABLE activity_logs ( +id INTEGER NOT NULL AUTO_INCREMENT, +timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, +message TEXT NOT NULL DEFAULT '', +user VARCHAR(50), +PRIMARY KEY (`id`)); + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-09-02 05:17:33
|
Revision: 2195 http://astpp.svn.sourceforge.net/astpp/?rev=2195&view=rev Author: darrenkw Date: 2008-09-02 05:17:43 +0000 (Tue, 02 Sep 2008) Log Message: ----------- Added support to add and delete configuration items. Somebody still needs to add edit support. Modified Paths: -------------- trunk/astpp-admin.cgi trunk/templates/configuration-list.tpl Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2008-09-02 05:15:21 UTC (rev 2194) +++ trunk/astpp-admin.cgi 2008-09-02 05:17:43 UTC (rev 2195) @@ -8042,7 +8042,12 @@ . "</td><td>" . gettext("Protocol") . "</td><td>" + . "<a href=\"\#\">" . gettext("Peer Name") + . "<span class=\"popups\">" + . gettext("If using freeswitch then use the following formats: \"gateway\",\"gatewayname\" or \"profilename\",\"destinationhost\"") + . "</span>" + . "</a>" . "</td><td>" . gettext("Provider") . "</td><td>" @@ -8234,7 +8239,14 @@ . "</td><td>" . gettext("Protocol") . "</td><td>" + . "<div id=\"popups\">" + . "<a href=\"\#\">" . gettext("Peer Name") + . "<span class=\"popups\">" + . gettext("If using freeswitch then use the following formats: \"gateway\",\"gatewayname\" or \"profilename\",\"destinationhost\"") + . "</span>" + . "</a>" + . "</div>" . "</td><td>" . gettext("Provider") . "</td><td>" @@ -8322,7 +8334,14 @@ . "</td><td>" . gettext("Protocol") . "</td><td>" - . gettext("Peer/Trunk") + . "<div id=\"popups\">" + . "<a href=\"\#\">" + . gettext("Peer Name") + . "<span class=\"popups\">" + . gettext("If using freeswitch then use the following formats: \"gateway\",\"gatewayname\" or \"profilename\",\"destinationhost\"") + . "</span>" + . "</a>" + . "</div>" . "</td><td>" . gettext("Provider") . "</td><td>" @@ -9159,11 +9178,79 @@ } sub build_configuration() { - my ( $tmp, $template, @configuration_list ); + my ( @brands, @resellerlist, $tmp, $template, @configuration_list ); $template = HTML::Template->new( filename => '/var/lib/astpp/templates/configuration-list.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); + if ( $params->{logintype} == 1 ) { + push(@resellerlist, $params->{username}); + } else { + @resellerlist = &list_resellers($astpp_db); + push(@resellerlist, ""); + } + $template->param( + resellers => popup_menu( + -name => "resellers", + -values => \@resellerlist + ) + ); + if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { + @brands = &list_cc_brands_reseller( $astpp_db, $params->{username} ); + push(@brands, ""); + } + else { + @brands = &list_cc_brands($astpp_db); + push(@brands, ""); + } + $template->param( + brands => popup_menu( + -name => "brands", + -values => \@brands + ) + ); + + if (!$params->{action}) { $params->{action} = "List"; } + if ($params->{action} eq "Edit") { + } elsif ($params->{action} eq "Add Item") { + if ( $params->{logintype} == 1 ) { + $params->{reseller} = $params->{username}; + } + $tmp = "INSERT INTO system (reseller,brand,name,value,comment) VALUES (" + . $astpp_db->quote($params->{reseller}) . "," + . $astpp_db->quote($params->{brand}) . "," + . $astpp_db->quote($params->{name}) . "," + . $astpp_db->quote($params->{value}) . "," + . $astpp_db->quote($params->{comment}) . ")"; + $ASTPP->debug( user=> $param->{username}, debug => $tmp); + if ( $astpp_db->do($tmp) ) { + $status .= "Added Configuration Item!"; + } else { + $status .= "Failed to Add Configuration Item!"; + } + $params->{action} = "List"; + } elsif ($params->{action} eq "Delete") { if ( $params->{logintype} == 2 ) { + if ($params->{reseller} ne "") { + $tmp = "DELETE FROM system WHERE name = " . $astpp_db->quote($params->{name}) + . " AND reseller = " . $astpp_db->quote($params->{reseller}) . " LIMIT 1"; + } else { + $tmp = "DELETE FROM system WHERE name = " . $astpp_db->quote($params->{name}) + . " AND reseller IS NULL LIMIT 1"; + } + } elsif ( $params->{logintype} == 1 ) { + $tmp = "DELETE FROM system WHERE name = " . $astpp_db->quote($params->{name}) + . " AND reseller = " . $astpp_db->quote($params->{username}) . " LIMIT 1"; + } + $ASTPP->debug( user=> $param->{username}, debug => $tmp); + if ( $astpp_db->do($tmp) ) { + $status .= "Removed Configuration Item!"; + } else { + $status .= "Failed to Remove Configuration Item!"; + } + $params->{action} = "List"; + } + if ($params->{action} eq "List") { + if ( $params->{logintype} == 2 ) { $tmp = "SELECT * FROM system ORDER BY reseller,name"; } elsif ( $params->{logintype} == 1 ) { @@ -9186,6 +9273,7 @@ } $sql->finish; $template->param( configuration_list => \@configuration_list ); + } return $template->output; } Modified: trunk/templates/configuration-list.tpl =================================================================== --- trunk/templates/configuration-list.tpl 2008-09-02 05:15:21 UTC (rev 2194) +++ trunk/templates/configuration-list.tpl 2008-09-02 05:17:43 UTC (rev 2195) @@ -1,25 +1,46 @@ -<form method="post" action="/cgi-bin/astpp-admin/astpp-admin.cgi?mode=Configuration" enctype="multipart/form-data"> -<table> - <tr> - <input type="hidden" name="mode" value="Configuration"/> - <td colspan=9 align=center><TMPL_VAR NAME="status"></td> - </tr> - <tr class="header"> - <td>Reseller</td> - <td>Brand</td> - <td>Name</td> - <td>Value</td> - <td>Comment</td> - <td>Time Stamp</td> - </tr> - <TMPL_LOOP NAME="configuration_list"> - <TR> - <TD><TMPL_VAR NAME="reseller"></TD> - <TD><TMPL_VAR NAME="brand"></TD> - <TD><TMPL_VAR NAME="name"></TD> - <TD><TMPL_VAR NAME="value"></TD> - <TD><TMPL_VAR NAME="comment"></TD> - <TD><TMPL_VAR NAME="timestamp"></TD> +<table class="default"> + <tr class="header"> + <td colspan=10>Configuration Details</td> +<input name="mode" value="Configuration" type="hidden"> + </tr> + <tr class="header"> + <td>Reseller</td> + <td>Brand</td> + <td>Name</td> + <td>Value</td> + <td>Comment</td> + <td>Action</td> + </tr> + <tr class="header"> + <td colspan=6>Add Item</td> + </tr> + <tr class="rowone"> + <td><TMPL_VAR NAME="resellers"></td> + <td><TMPL_VAR NAME="brands"></td> + <td><input name="name" size="20" type="text"></td> + <td><input name="value" size="20" type="text"></td> + <td><input name="comment" size="50" type="text"></td> + <td><input name="action" value="Add Item" type="submit"></td> + </tr> + <tr class="header"> + <td colspan=5>List</td> + </tr> + <TMPL_LOOP NAME="configuration_list"> + <TR> + <TD><TMPL_VAR NAME="reseller"></TD> + <TD><TMPL_VAR NAME="brand"></TD> + <TD><TMPL_VAR NAME="name"></TD> + <TD><TMPL_VAR NAME="value"></TD> + <TD><TMPL_VAR NAME="comment"></TD> + <TD><a href="astpp-admin.cgi?mode=Configuration&action=Delete&name=<TMPL_VAR NAME="name">&reseller=<TMPL_VAR NAME="Reseller">">Delete</a> + <a href="astpp-admin.cgi?mode=Configuration&action=Edit&name=<TMPL_VAR NAME="name">&reseller=<TMPL_VAR NAME="Reseller">">Edit</a></TD> </TR> - </TMPL_LOOP> + </TMPL_LOOP> </table> + +<table> + <tr> + <td><TMPL_VAR NAME="status"></td> + </tr> + </table> +</form> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-09-06 16:54:55
|
Revision: 2197 http://astpp.svn.sourceforge.net/astpp/?rev=2197&view=rev Author: darrenkw Date: 2008-09-06 16:55:06 +0000 (Sat, 06 Sep 2008) Log Message: ----------- Fix a bug in the "by cdr date" invoice generation code. Modified Paths: -------------- trunk/astpp-common.pl trunk/astpp-generate-invoices.pl Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2008-09-04 00:06:13 UTC (rev 2196) +++ trunk/astpp-common.pl 2008-09-06 16:55:06 UTC (rev 2197) @@ -4294,7 +4294,6 @@ $sql->execute; $row = $sql->fetchrow_hashref; $sql->finish; - if ($row->{customers_username}) { $tmp = "SELECT * FROM `customers` WHERE `customers_username` = " . $osc_db->quote($account); @@ -4307,7 +4306,6 @@ print STDERR "OSCommerce Account: $row->{customers_id}"; return (1,$row); } - } else { print STDERR "OSCommerce Account: $account NOT FOUND!!!\n"; return (0,""); @@ -4521,7 +4519,7 @@ if ($invoice_id) { if ($params->{startdate} && $params->{enddate}) { $tmp = - "SELECT COUNT(*) FROM cdrs WHERE cardnum = " + "SELECT * FROM cdrs WHERE cardnum = " . $astpp_db->quote($account) . " AND status = 0" . " AND callstart >= DATE(" . $astpp_db->quote($params->{startdate}) . ")" @@ -4529,25 +4527,26 @@ . " ORDER BY callstart"; } elsif ($params->{startdate}) { $tmp = - "SELECT COUNT(*) FROM cdrs WHERE cardnum = " + "SELECT * FROM cdrs WHERE cardnum = " . $astpp_db->quote($account) . " AND status = 0" . " AND callstart >= DATE(" . $astpp_db->quote($params->{startdate}) . ")" . " ORDER BY callstart"; } elsif ($params->{enddate}) { $tmp = - "SELECT COUNT(*) FROM cdrs WHERE cardnum = " + "SELECT * FROM cdrs WHERE cardnum = " . $astpp_db->quote($account) . " AND status = 0" . " AND callstart <= DATE(" . $astpp_db->quote($params->{enddate}) . ")" . " ORDER BY callstart"; } else { $tmp = - "SELECT COUNT(*) FROM cdrs WHERE cardnum = " + "SELECT * FROM cdrs WHERE cardnum = " . $astpp_db->quote($account) . " AND status = 0" . " ORDER BY callstart"; } + print STDERR $tmp; $sql = $astpp_db->prepare($tmp); $sql->execute; while ( $row = $sql->fetchrow_hashref ) { Modified: trunk/astpp-generate-invoices.pl =================================================================== --- trunk/astpp-generate-invoices.pl 2008-09-04 00:06:13 UTC (rev 2196) +++ trunk/astpp-generate-invoices.pl 2008-09-06 16:55:06 UTC (rev 2197) @@ -80,7 +80,7 @@ foreach my $handle (@output) { print $handle "Card: $cardno \n"; } - &osc_charges($astpp_db, $osc_db, $config, $cardno); + &osc_charges($astpp_db, $osc_db, $config, $cardno,$params); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-09-11 05:14:10
|
Revision: 2198 http://astpp.svn.sourceforge.net/astpp/?rev=2198&view=rev Author: darrenkw Date: 2008-09-11 05:14:20 +0000 (Thu, 11 Sep 2008) Log Message: ----------- Add support for ASTPP to authenticate Freeswitch users. Also fixed the freeswitch call length limiting code. Modified Paths: -------------- trunk/astpp-common.pl trunk/freeswitch/astpp-fs-xml.pl trunk/modules/ASTPP/lib/ASTPP.pm Added Paths: ----------- trunk/sql/astpp-2008-09-04.sql Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2008-09-06 16:55:06 UTC (rev 2197) +++ trunk/astpp-common.pl 2008-09-11 05:14:20 UTC (rev 2198) @@ -1040,6 +1040,29 @@ } } +# Connect to Freeswitch(TM) database. +sub connect_freeswitch_db() { + my ( $config, @output ) = @_; + my ( $dbh, $dsn ); +# if ( $config->{astpp_dbengine} eq "MySQL" ) { + $dsn = "DBI:mysql:database=$config->{freeswitch_dbname};host=$config->{freeswitch_dbhost}"; +# } +# elsif ( $config->{astpp_dbengine} eq "Pgsql" ) { +# $dsn = "DBI:Pg:database=$config->{dbname};host=$config->{dbhost}"; +# } + $dbh = DBI->connect( $dsn, $config->{freeswitch_dbuser}, $config->{freeswitch_dbpass} ); + if ( !$dbh ) { + print STDERR "FREESWITCH(TM) DATABASE IS DOWN\n"; + return 0; + } + else { + $dbh->{mysql_auto_reconnect} = 1; + print STDERR gettext("Connected to Freeswitch(TM) Database!") . "\n" + if ( $config->{debug} == 1 ); + return $dbh; + } +} + # Calculate the cost of a call based on the data received. sub calc_call_cost() { my ( $connect, $cost, $answeredtime, $increment, $inc_seconds ) = @_; Modified: trunk/freeswitch/astpp-fs-xml.pl =================================================================== --- trunk/freeswitch/astpp-fs-xml.pl 2008-09-06 16:55:06 UTC (rev 2197) +++ trunk/freeswitch/astpp-fs-xml.pl 2008-09-11 05:14:20 UTC (rev 2198) @@ -18,7 +18,7 @@ use CGI qw/:standard Vars/; use ASTPP; use strict; -use vars qw($params $ASTPP @output $config $astpp_db $verbosity ); +use vars qw($params $ASTPP @output $config $freeswitch_db $astpp_db $verbosity ); use Locale::gettext_pp qw(:locale_h); require "/usr/local/astpp/astpp-common.pl"; $ENV{LANGUAGE} = "en"; # de, es, br - whatever @@ -36,6 +36,8 @@ $astpp_db = &connect_db( $config, @output ); $ASTPP->set_astpp_db($astpp_db); $config = &load_config_db( $astpp_db, $config ) if $astpp_db; + $freeswitch_db = &connect_freeswitch_db( $config, @output ); + $ASTPP->set_freeswitch_db($freeswitch_db); } ################# Programs start here ####################################### @@ -169,8 +171,30 @@ } $xml = $ASTPP->fs_dialplan_xml_footer( xml => $xml); } elsif ($params->{section} eq "directory") { +#hostname darren-laptop +#section directory +#tag_name domain +#key_name name +#key_value 192.168.2.119 +#action sip_auth +#sip_profile internal +#sip_user_agent Zoiper rev.1118 +#sip_auth_username 1000 +#sip_auth_realm 192.168.2.119 +#sip_auth_nonce 83005e62-7e13-11dd-9eb1-25560b0691a8 +#sip_auth_uri sip:192.168.2.119;transport=UDP +#sip_auth_qop auth +#sip_auth_cnonce a79169d2656f292a +#sip_auth_nc 00000001 +#sip_auth_response 4475154556879ec2017978f1347192a6 +#sip_auth_method REGISTER +#key id +#user 1000 +#domain 192.168.2.119 +#ip 192.168.2.119 + $xml = $ASTPP->fs_directory_xml_header( xml => $xml); - $xml = $ASTPP->fs_directory_xml( xml => $xml); + $xml = $ASTPP->fs_directory_xml( xml => $xml, ip => $params->{'ip'},user=> $params->{'user'},domain=> $params->{'domain'}); $xml = $ASTPP->fs_directory_xml_footer( xml => $xml); } $ASTPP->debug( debug => $xml); Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2008-09-06 16:55:06 UTC (rev 2197) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2008-09-11 05:14:20 UTC (rev 2198) @@ -34,6 +34,7 @@ my ($class,%arg) = @_; bless { _astpp_db => $_[1], + _freeswitch_db => $_[1], _verbosity_level => $arg{verbosity_level} || 1, _asterisk_agi => $_[3], _cdr_db => $_[4], @@ -52,6 +53,12 @@ $self->{_astpp_db} = $astpp_db if $astpp_db; } +sub set_freeswitch_db +{ + my ($self, $freeswitch_db) = @_; + $self->{_freeswitch_db} = $freeswitch_db if $freeswitch_db; +} + sub set_cdr_db { my ($self, $cdr_db) = @_; @@ -103,7 +110,6 @@ $arg{xml} .= "<context name=\"default\">\n"; $arg{xml} .= "<extension name=\"" . $arg{destination_number} . "\">\n"; $arg{xml} .= "<condition field=\"destination_number\" expression=\"" . $arg{destination_number} . "\">\n"; - $arg{xml} .= "<action application=\"sched_hangup\" data=\"+" . $arg{max_length} . " /">\n"; return $arg{xml}; } @@ -111,7 +117,7 @@ #Return the opening lines of the Freeswitch(TM) xml dialplan { my ($self, %arg) = @_; - $arg{xml} .= "<action application=\"sched_hangup\" data=\"+" . $arg{max_length} * 60 . " /">\n"; + $arg{xml} .= "<action application=\"sched_hangup\" data=\"+" . $arg{max_length} * 60 . "\"/>\n"; return $arg{xml}; } @@ -184,25 +190,55 @@ $arg{xml} .= "<?xml version=\"1.0\"?>\n"; $arg{xml} .= "<document type=\"freeswitch/xml\">\n"; $arg{xml} .= "<section name=\"directory\" description=\"User Directory\">\n"; - $arg{xml} .= "<domain name=\"" . $arg{domain} . "\">\n"; return $arg{xml}; } sub fs_directory_xml #Return the user detail lines for Freeswitch(TM) sip athentication. #xml = Current XML code +#ip = IP Address that user is connecting from +#user = SIP Username +#domain = SIP Domain { my ($self, %arg) = @_; - my ($sql); - $sql = $self->{_astpp_db}->prepare("SELECT * FROM fs_users"); + my ($sql,$sql1,$tmp,$tmp1); + $arg{xml} .= "<domain name=\"" . $arg{domain} . "\">"; + $tmp = "SELECT * FROM directory WHERE username = " + . $self->{_freeswitch_db}->quote($arg{user}) + . " AND domain = " + . $self->{_freeswitch_db}->quote($arg{domain}); + print STDERR $tmp . "\n"; + $sql = $self->{_freeswitch_db}->prepare($tmp); $sql->execute; while (my $record = $sql->fetchrow_hashref) { - $arg{xml} .= "<user id=\"" . $record->{user} . "\">\n"; + $arg{xml} .= "<user id=\"" . $record->{username} . "\" mailbox=\"" . $record->{mailbox} . "\">\n"; $arg{xml} .= "<params>\n"; - $arg{xml} .= "<param name=\"password\" value=\"" . $record->{password} . "\"/>\n"; + my $tmp1 = "SELECT * FROM directory_params WHERE directory_id = " + . $self->{_freeswitch_db}->quote($record->{id}); + print STDERR $tmp1 . "\n"; + $sql1 = $self->{_freeswitch_db}->prepare($tmp1); + $sql1->execute; + while (my $record = $sql1->fetchrow_hashref) { + $arg{xml} .= "<param name=\"" . $record->{param_name} . "\" value=\"" . $record->{param_value} . "\"/>\n"; + } + $sql1->finish; $arg{xml} .= "</params>\n"; + $arg{xml} .= "<variables>\n"; + + print STDERR $tmp1 . "\n"; + $tmp1 = "SELECT * FROM directory_vars WHERE directory_id = " + . $self->{_freeswitch_db}->quote($record->{id}); + $sql1 = $self->{_freeswitch_db}->prepare($tmp1); + $sql1->execute; + while (my $record = $sql1->fetchrow_hashref) { + $arg{xml} .= "<variable name=\"" .$record->{var_name} . "\" value=\"" . $record->{var_value} . "\"/>\n"; + } + $sql1->finish; + $arg{xml} .= "</variables>\n"; $arg{xml} .= "</user>\n"; }; + $sql->finish; + $arg{xml} .= "</domain>\n"; return $arg{xml}; } @@ -213,7 +249,6 @@ #xml = Current XML code { my ($self, %arg) = @_; - $arg{xml} .= "</domain>\n"; $arg{xml} .= "</section>\n"; $arg{xml} .= "</document>\n"; return $arg{xml}; Added: trunk/sql/astpp-2008-09-04.sql =================================================================== --- trunk/sql/astpp-2008-09-04.sql (rev 0) +++ trunk/sql/astpp-2008-09-04.sql 2008-09-11 05:14:20 UTC (rev 2198) @@ -0,0 +1,1283 @@ +DROP TABLE IF EXISTS `routes`; +CREATE TABLE routes ( +id INTEGER NOT NULL AUTO_INCREMENT, +pattern CHAR(40), +comment CHAR(80), +connectcost INTEGER NOT NULL, +includedseconds INTEGER NOT NULL, +cost INTEGER NOT NULL, +pricelist CHAR(80), +inc INTEGER, +reseller CHAR(50) default NULL, +precedence INT(4) NOT NULL DEFAULT 0, +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`), +KEY `pattern` (`pattern`), +KEY `pricelist` (`pricelist`), +KEY `reseller` (`reseller`), +KEY `status` (`status`) +); + +DROP TABLE IF EXISTS `pricelists`; +CREATE TABLE pricelists ( +name CHAR(40) NOT NULL, +markup INTEGER NOT NULL DEFAULT 0, +inc INTEGER NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +reseller CHAR(50) default NULL, +PRIMARY KEY (`name`) +); + +DROP TABLE IF EXISTS `callingcardbrands`; +CREATE TABLE callingcardbrands ( +name CHAR(40) NOT NULL, +reseller CHAR(40) NOT NULL DEFAULT '', +language CHAR(10) NOT NULL DEFAULT '', +pricelist CHAR(40) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +validfordays CHAR(4) NOT NULL DEFAULT '', +pin INTEGER NOT NULL DEFAULT 0, +maint_fee_pennies INTEGER NOT NULL DEFAULT 0, +maint_fee_days INTEGER NOT NULL DEFAULT 0, +disconnect_fee_pennies INTEGER NOT NULL DEFAULT 0, +minute_fee_minutes INTEGER NOT NULL DEFAULT 0, +minute_fee_pennies INTEGER NOT NULL DEFAULT 0, +min_length_minutes INTEGER NOT NULL DEFAULT 0, +min_length_pennies INTEGER NOT NULL DEFAULT 0, +PRIMARY KEY (`name`), + KEY `reseller` (`reseller`), + KEY `pricelist` (`pricelist`) +); + +DROP TABLE IF EXISTS `callingcardcdrs`; +CREATE TABLE callingcardcdrs ( +id INTEGER NOT NULL AUTO_INCREMENT, +cardnumber CHAR(50) NOT NULL DEFAULT '', +clid CHAR(80) NOT NULL DEFAULT '', +destination CHAR(40) NOT NULL DEFAULT '', +disposition CHAR(20)NOT NULL DEFAULT '', +callstart CHAR(40) NOT NULL DEFAULT '', +seconds INTEGER NOT NULL DEFAULT 0, +debit DECIMAL(20,6) NOT NULL DEFAULT 0.00000, +credit DECIMAL(20,6) NOT NULL DEFAULT 0.00000, +status INTEGER DEFAULT 0 NOT NULL, +uniqueid VARCHAR(32) NOT NULL DEFAULT '', +notes CHAR(80) NOT NULL DEFAULT '', +pricelist CHAR(80) NOT NULL DEFAULT '', +pattern CHAR(80) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + KEY `cardnumber` (`cardnumber`) +); + +DROP TABLE IF EXISTS `trunks`; +CREATE TABLE trunks ( +name VARCHAR(30) NOT NULL, +tech CHAR(10) NOT NULL DEFAULT '', +path CHAR(40) NOT NULL DEFAULT '', +provider CHAR(100) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +dialed_modify TEXT NOT NULL DEFAULT '', +resellers TEXT NOT NULL DEFAULT '', +precedence INT(4) NOT NULL DEFAULT 0, +maxchannels INTEGER DEFAULT 0 NOT NULL, + PRIMARY KEY (`name`), + KEY `provider` (`provider`), + KEY `provider_2` (`provider`) +); + +DROP TABLE IF EXISTS `outbound_routes`; +CREATE TABLE outbound_routes ( +pattern CHAR(40), +id INTEGER NOT NULL AUTO_INCREMENT, +comment CHAR(80) NOT NULL DEFAULT '', +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +trunk CHAR(80) NOT NULL DEFAULT '', +inc CHAR(10) NOT NULL DEFAULT '', +strip CHAR(40) NOT NULL DEFAULT '', +prepend CHAR(40) NOT NULL DEFAULT '', +precedence INT(4) NOT NULL DEFAULT 0, +resellers TEXT NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `trunk` (`trunk`), + KEY `pattern` (`pattern`) +); + +DROP TABLE IF EXISTS `dids`; +CREATE TABLE dids ( +number CHAR(40) NOT NULL, +account CHAR(50) NOT NULL DEFAULT '', +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +monthlycost INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +inc CHAR(10) NOT NULL DEFAULT '', +extensions CHAR(180) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +provider CHAR(40) NOT NULL DEFAULT '', +country CHAR (80)NOT NULL DEFAULT '', +province CHAR (80) NOT NULL DEFAULT '', +city CHAR (80) NOT NULL DEFAULT '', +prorate int(1) NOT NULL default 0, +setup int(11) NOT NULL default 0, +limittime int(1) NOT NULL default 1, +disconnectionfee INT(11) NOT NULL default 0, +variables TEXT NOT NULL DEFAULT '', +options varchar(40) default NULL, +maxchannels int(4) NOT NULL default 0, +chargeonallocation int(1) NOT NULL default 1, +allocation_bill_status int(1) NOT NULL default 0, +dial_as CHAR(40) NOT NULL DEFAULT '', +PRIMARY KEY (`number`), + KEY `account` (`account`) +); + +DROP TABLE IF EXISTS `accounts`; +CREATE TABLE accounts ( +cc CHAR(20) NOT NULL DEFAULT '', +number CHAR(50) NOT NULL, +reseller CHAR(40) NOT NULL DEFAULT '', +pricelist CHAR(24) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +credit INTEGER NOT NULL DEFAULT 0, +sweep INTEGER NOT NULL DEFAULT 0, +creation TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, +pin INTEGER NOT NULL DEFAULT 0, +credit_limit INTEGER NOT NULL DEFAULT 0, +posttoexternal INTEGER NOT NULL DEFAULT 0, +balance DECIMAL(20,6) NOT NULL DEFAULT 0, +password CHAR(80) NOT NULL DEFAULT '', +first_name CHAR(40) NOT NULL DEFAULT '', +middle_name CHAR(40) NOT NULL DEFAULT '', +last_name CHAR(40) NOT NULL DEFAULT '', +company_name CHAR(40) NOT NULL DEFAULT '', +address_1 CHAR(80) NOT NULL DEFAULT '', +address_2 CHAR(80) NOT NULL DEFAULT '', +address_3 CHAR(80) NOT NULL DEFAULT '', +postal_code CHAR(12) NOT NULL DEFAULT '', +province CHAR(40) NOT NULL DEFAULT '', +city CHAR(80) NOT NULL DEFAULT '', +country CHAR(40) NOT NULL DEFAULT '', +telephone_1 CHAR(40) NOT NULL DEFAULT '', +telephone_2 CHAR(40) NOT NULL DEFAULT '', +fascimile CHAR(40) NOT NULL DEFAULT '', +email CHAR(80) NOT NULL DEFAULT '', +language CHAR(2) NOT NULL DEFAULT '', +currency CHAR(3) NOT NULL DEFAULT '', +maxchannels INTEGER DEFAULT 1 NOT NULL, +routing_technique INT(4) NOT NULL DEFAULT 0, +dialed_modify TEXT NOT NULL DEFAULT '', +type INTEGER DEFAULT 0, +tz CHAR(40) NOT NULL DEFAULT '', +PRIMARY KEY (`number`), + KEY `pricelist` (`pricelist`), + KEY `reseller` (`reseller`) +); + +DROP TABLE IF EXISTS `counters`; +CREATE TABLE counters ( +id INTEGER NOT NULL AUTO_INCREMENT, +package CHAR(40) NOT NULL DEFAULT '', +account VARCHAR(50) NOT NULL, +seconds INTEGER NOT NULL DEFAULT 0, +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`) +); + +DROP TABLE IF EXISTS `callingcards`; +CREATE TABLE callingcards ( +id INTEGER NOT NULL AUTO_INCREMENT, +cardnumber CHAR(20) NOT NULL DEFAULT '', +language CHAR(10) NOT NULL DEFAULT '', +value INTEGER NOT NULL DEFAULT 0, +used INTEGER NOT NULL DEFAULT 0, +brand VARCHAR(20) NOT NULL DEFAULT '', +created DATETIME, +firstused DATETIME, +expiry DATETIME, +validfordays CHAR(4) NOT NULL DEFAULT '', +inuse INTEGER NOT NULL DEFAULT 0, +pin CHAR(20), +account VARCHAR(50) NOT NULL DEFAULT '', +maint_fee_pennies INTEGER NOT NULL DEFAULT 0, +maint_fee_days INTEGER NOT NULL DEFAULT 0, +maint_day INTEGER NOT NULL DEFAULT 0, +disconnect_fee_pennies INTEGER NOT NULL DEFAULT 0, +minute_fee_minutes INTEGER NOT NULL DEFAULT 0, +minute_fee_pennies INTEGER NOT NULL DEFAULT 0, +min_length_minutes INTEGER NOT NULL DEFAULT 0, +min_length_pennies INTEGER NOT NULL DEFAULT 0, +timeused INTEGER NOT NULL DEFAULT 0, +invoice CHAR(20) NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `brand` (`brand`) +); + +CREATE TABLE charge_to_account ( +id INTEGER NOT NULL AUTO_INCREMENT, +charge_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(50) NOT NULL DEFAULT '', +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`) +); + +CREATE TABLE queue_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +queue_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE pbx_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +pbx_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE extension_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +extension_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE cdrs ( +id INTEGER NOT NULL AUTO_INCREMENT, +uniqueid varchar(32) NOT NULL DEFAULT '', +cardnum CHAR(50), +callerid CHAR(80), +callednum varchar(80) NOT NULL DEFAULT '', +billseconds INT DEFAULT 0 NOT NULL, +trunk VARCHAR(30), +disposition varchar(45) NOT NULL DEFAULT '', +callstart varchar(80) NOT NULL DEFAULT '', +debit DECIMAL (20,6) NOT NULL DEFAULT 0, +credit DECIMAL (20,6) NOT NULL DEFAULT 0, +status INTEGER DEFAULT 0 NOT NULL, +notes CHAR(80), +provider CHAR(50), +cost DECIMAL(20,6) NOT NULL DEFAULT 0, +pricelist CHAR(80) NOT NULL DEFAULT '', +pattern CHAR(80) NOT NULL DEFAULT '', +PRIMARY KEY (`id`), + KEY `cardnum` (`cardnum`), + KEY `provider` (`provider`), + KEY `trunk` (`trunk`), + KEY `uniqueid` (`uniqueid`), + KEY `status` (`status`) +); + +CREATE TABLE packages ( +id INTEGER NOT NULL AUTO_INCREMENT, +name CHAR(40) NOT NULL DEFAULT '', +pricelist CHAR(40) NOT NULL DEFAULT '', +pattern CHAR(40) NOT NULL DEFAULT '', +includedseconds INTEGER NOT NULL DEFAULT 0, +reseller VARCHAR(50) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `pricelist` (`pricelist`), + KEY `reseller` (`reseller`) +); + +CREATE TABLE ani_map ( +number char(20) NOT NULL, +account char(50) NOT NULL default '', +status int(11) NOT NULL default '0', +context varchar(20) NOT NULL, + PRIMARY KEY (`number`), +KEY `account` (`account`) +); + +CREATE TABLE `ip_map` ( +ip char(15) NOT NULL default '', +account char(20) NOT NULL default '', +prefix varchar(20) NULL, +context varchar(20) NOT NULL, +PRIMARY KEY (`ip`,`prefix`), +KEY `account` (`account`) +); + +CREATE TABLE charges ( +id INTEGER NOT NULL AUTO_INCREMENT, +pricelist CHAR(40) NOT NULL DEFAULT '', +description VARCHAR(80) NOT NULL DEFAULT '', +charge INTEGER NOT NULL DEFAULT 0, +sweep INTEGER NOT NULL DEFAULT 0, +reseller CHAR(40) NOT NULL DEFAULT '', +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`), + KEY `pricelist` (`pricelist`) +); + +CREATE TABLE manager_action_variables ( +id INTEGER NOT NULL AUTO_INCREMENT, +name CHAR(60) NOT NULL DEFAULT '', +value CHAR(60) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE callingcard_stats ( +uniqueid VARCHAR(48) NOT NULL, +total_time VARCHAR(48) NOT NULL, +billable_time VARCHAR(48) NOT NULL, +timestamp DATETIME NULL, +PRIMARY KEY (`uniqueid`) +); + +CREATE TABLE system ( +name VARCHAR(48) NULL, +value VARCHAR(255) NULL, +comment VARCHAR(255) NULL, +timestamp DATETIME NULL, +reseller VARCHAR(48) NULL, +brand VARCHAR(48) NULL, +PRIMARY KEY (`name`), + KEY `reseller` (`reseller`), + KEY `brand` (`brand`) +); + + +INSERT INTO system (name, value, comment) VALUES ( +'callout_accountcode','admin','Call Files: What accountcode should we use?'); + +INSERT INTO system (name, value, comment) VALUES ( +'lcrcontext','astpp-outgoing','This is the Local context we use to route our outgoing calls through esp for callbacks'); + +INSERT INTO system (name, value, comment) VALUES ( +'maxretries','3','Call Files: How many times do we retry?'); + +INSERT INTO system (name, value, comment) VALUES ( +'retrytime','30','Call Files: How long do we wait between retries?'); + +INSERT INTO system (name, value, comment) VALUES ( +'waittime','15','Call Files: How long do we wait before the initial call?'); + +INSERT INTO system (name, value, comment) VALUES ( +'clidname','Private','Call Files: Outgoing CallerID Name'); + +INSERT INTO system (name, value, comment) VALUES ( +'clidnumber','0000000000','Call Files: Outgoing CallerID Number'); + +INSERT INTO system (name, value, comment) VALUES ( +'callingcards_callback_context','astpp-callingcards','Call Files: For callingcards what context do we end up in?'); + +INSERT INTO system (name, value, comment) VALUES ( +'callingcards_callback_extension', 's','Call Files: For callingcards what extension do we use?'); + +INSERT INTO system (name, value, comment) VALUES ( +'openser_dbengine', 'MySQL','For now this must be MySQL'); + +INSERT INTO system (name, value, comment) VALUES ( +'openser', '0','Use OPENSER? 1 for yes or 0 for no'); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbname', 'openser','OPENSER Database Name', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbuser', 'root','OPENSER Database User', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbhost', 'localhost','OPENSER Database Host', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbpass', 'Passw0rd','OPENSER Database Password', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_domain', NULL,'OPENSER Domain', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_email', 'em...@as...','Email address that email should appear to be from', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'asterisk_dir', '/etc/asterisk','Which directory are asterisk configuration files stored in?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_website', 'http://www.astpp.org','Link to your company website', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_name', 'ASTPP.ORG','The name of your company. Used in emails.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'email', '1','Send out email? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'user_email', '1','Email user on account changes? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'debug', '0','Enable debugging output? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'emailadd', 'em...@as...','Administrator email address', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'startingdigit', '0','The digit that all calling cards must start with. 0=disabled', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'enablelcr', '1','Use least cost routing 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'log_file', '/var/log/astpp/astpp.log','ASTPP Log file', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'key_home', 'http://www.astpp.org/astpp.pub','Asterisk RSA Key location (optional)', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rate_engine_csv_file', '/var/log/astpp/astpp.csv','CSV File for call rating data', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'csv_dir', '/var/log/astpp/','CSV File Directory', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_brand', 'default','Default pricelist. If a price is not found in the customers pricelist we check this one.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'new_user_brand', 'default','What is the default pricelist for new customers?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_context', 'custom-astpp','What is the default context for new devices?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cardlength', '10','Number of digits in calling cards and cc codes.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'asterisk_server', 'voip.astpp.org','Your default voip server. Used in outgoing email.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'currency', 'CAD','Name of the currency you use', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'iax_port', '4569','Default IAX2 Port', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'sip_port', '5060','Default SIP Port', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'ipaddr', 'dynamic','Default IP Address for new devices', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'key', 'astpp.pub','Asterisk RSA Key Name (Optional)', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'pinlength', '6','For those calling cards that are using pins this is the number of digits it will have.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'credit_limit', '0','Default credit limit in dollars.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'decimalpoints', '4','How many decimal points do we bill to?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'max_free_length', '100','What is the maximum length (in minutes) of calls that are at no charge?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'trackvendorcharges', '1','Do we track the amount of money we spend with specific providers? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_logo', 'http://www.astpp.org/logo.png','The location of our company logo.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_slogan', 'Welcome to ASTPP','Company slogan', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'version', '1.5Beta', 'ASTPP Version', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_language', 'en', 'Default ASTPP Language',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'card_retries','3', 'How many retries do we allow for calling card numbers?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'pin_retries','3', 'How many retries do we allow for pins?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'number_retries','3','How many retries do we allow calling card users when dialing a number?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'booth_context','callshop_booth','Please enter the default context for a callshop booth.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'callingcards_max_length','9000','What is the maximum length (in ms) of a callingcard call?',''); + +INSERT INTO system (name,value,comment,timestamp) VALUES ( +'template_die_on_bad_params','0','Should HTML::Template die on bad parameters?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'results_per_page','30','How many results per page do we should in the web interface?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astpp_dir','/var/lib/astpp','Where do the astpp configs live?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'auth','a23asudf9810-zalkj32423','This is the override authorization code and will allow access to the system.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_dbengine','MySQL','Database type for Asterisk(tm) -Realtime',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbengine','MySQL','Database type for the cdr database',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_dbengine','MySQL','Database type for OSCommerce',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_dbengine','MySQL','Database type for AgileBill(tm)',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_dbengine','MySQL','Database type for FreePBX',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'externalbill','oscommerce','Please specify the external billing application to use. If you are not using any then leave it blank. Valid options are "agile" and "oscommerce".',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'callingcards','1','Do you wish to enable calling cards? 1 for yes and 2 for no.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astcdr','1','Change this one at your own peril. If you switch it off, calls will not be marked as billed in asterisk once they are billed.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'posttoastpp','1','Change this one at your own peril. If you switch it off, calls will not be written to astpp when they are calculated.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'sleep','10','How long shall the rating engine sleep after it has been notified of a hangup? (in seconds)',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'users_dids_amp','0','If this is enabled, ASTPP will create users and DIDs in the FreePBX (www.freepbx.org) database.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'users_dids_rt','1','If this is enabled, ASTPP will create users and DIDs in the Asterisk Realtime database.',''); + +INSERT INTO system (name, value, comment) VALUES ( +'service_prepend','778',''); +INSERT INTO system (name, value, comment) VALUES ( +'service_length,','7',''); +INSERT INTO system (name, value, comment) VALUES ( +'service_filler','4110000',''); + +INSERT INTO system (name, value, comment) VALUES ( +'asterisk_cdr_table','cdr','Which table of the Asterisk(TM) database are the cdrs in?'); + +-- AgileBill(Trademark of AgileCo) Settings: +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_db','agile','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_pass','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_site_id','1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_charge_status','0','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_taxable','1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_dbprefix','_','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_service_prepend','778','',''); + +-- OSCommerce Settings (www.oscommerce.org) +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_db','oscommerce','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_pass','password','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_product_id','99999999','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_payment_method','"Charge"','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_order_status','1','',''); + +-- FreePBX Settings (www.freepbx.org) +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_db','asterisk','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_pass','passw0rd','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_table','iax','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_table','sip','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_extensions_table','extensions','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_codec_allow','g729,ulaw,alaw','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_codec_disallow','all','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_mailbox_group','default','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_nat','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_canreinvite','no','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_dtmfmode','rfc2833','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_callgroup','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_pickupgroup','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_notransfer','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_qualify','yes','',''); + +-- Asterisk -realtime Settings +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_db','realtime','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_pass','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_table','iax','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_table','sip','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_extensions_table','extensions','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_insecure','very','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_nat','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_canreinvite','no','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_codec_allow','g729,ulaw,alaw','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_codec_disallow','all','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_mailbox_group','default','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_type','friend','',''); +INSERT INTO system (name, value, comment) VALUES ( +'rt_voicemail_table','voicemail_users',''); + + +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_rate_announce','1','Do we want the calling cards script to announce the rate on calls?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_timelimit_announce','1','Do we want the calling cards script to announce the timelimit on calls?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_cancelled_prompt','1','Do we want the calling cards script to announce that the call was cancelled?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_menu','1','Do we want the calling cards script to present a menu before exiting?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_connection_prompt','1','Do we want the calling cards script to announce that it is connecting the call?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_pin_input_timeout','15000','How long do we wait when entering the calling card pin? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_number_input_timeout','15000','How long do we wait when entering the calling card number? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_dial_input_timeout','15000','How long do we wait when entering the destination number in calling cards? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_general_input_timeout','15000','How long do we wait for input in general menus? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_welcome_file','silence/1','What do we play for a welcome file?'); + +INSERT INTO system (name, value, comment) VALUES ( +'sip_ext_prepend','10','What should every autoadded SIP extension begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'iax2_ext_prepend','10','What should every autoadded IAX2 extension begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'cc_prepend','','What should every autoadded callingcard begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'pin_cc_prepend','','What should every autoadded callingcard pin begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'pin_act_prepend','','What should every autoadded account pin begin with?'); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_directory','/usr/local/freeswitch','What is the Freeswitch root directory?'); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_password','ClueCon','Freeswitch event socket password'); +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_host','localhost','Freeswitch event socket host'); +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_port','8021','Freeswitch event socket port'); +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_timeout','30','Freeswitch seconds to expect a heartbeat event or reconnect'); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freeswitch_dbname', 'freeswitch','Freeswitch Database Name', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freeswitch_dbuser', 'root','Freeswitch Database User', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freeswitch_dbhost', 'localhost','Freeswitch Database Host', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freeswitch_dbpass', 'Passw0rd','Freeswitch Database Password', ''); + + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbname', 'asteriskcdrdb', +'CDR Database Name', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbuser', 'root', +'CDR Database User', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbhost', 'localhost', +'CDR Database Host', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbpass', 'Passw0rd', +'CDR Database Password', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astman_user', 'admin','Asterisk(tm) Manager Interface User', ''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astman_host', 'localhost','Asterisk(tm) Manager Interface Host', ''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astman_secret', 'amp111','Asterisk(tm) Manager Interface Secret', ''); + + +-- +-- Enough Configuration settings +-- + +DROP TABLE IF EXISTS `countrycode`; +CREATE TABLE `countrycode` ( + `country` varchar(255) NOT NULL, + PRIMARY KEY (`country`), + KEY `country` (`country`) +); + +INSERT INTO `countrycode` (`country`) VALUES + ('Afghanistan'), + ('Alaska'), + ('Albania'), + ('Algeria'), + ('AmericanSamoa'), + ('Andorra'), + ('Angola'), + ('Antarctica'), + ('Argentina'), + ('Armenia'), + ('Aruba'), + ('Ascension'), + ('Australia'), + ('Austria'), + ('Azerbaijan'), + ('Bahrain'), + ('Bangladesh'), + ('Belarus'), + ('Belgium'), + ('Belize'), + ('Benin'), + ('Bhutan'), + ('Bolivia'), + ('Bosnia & Herzegovina'), + ('Botswana'), + ('Brazil'), + ('Brunei Darussalam'), + ('Bulgaria'), + ('Burkina Faso'), + ('Burundi'), + ('Cambodia'), + ('Cameroon'), + ('Canadda'), + ('Cape Verde Islands'), + ('Central African Republic'), + ('Chad'), + ('Chile'), + ('China'), + ('Colombia'), + ('Comoros'), + ('Congo'), + ('Cook Islands'), + ('Costa Rica'), + ('Croatia'), + ('Cuba'), + ('Cuba Guantanamo Bay'), + ('Cyprus'), + ('Czech Republic'), + ('Denmark'), + ('Diego Garcia'), + ('Djibouti'), + ('Dominican Republic'), + ('East Timor'), + ('Ecuador'), + ('Egypt'), + ('El Salvador'), + ('Equatorial Guinea'), + ('Eritrea'), + ('Estonia'), + ('Ethiopia'), + ('Faroe Islands'); +INSERT INTO `countrycode` (`country`) VALUES + ('Fiji Islands'), + ('Finland'), + ('France'), + ('French Guiana'), + ('French Polynesia'), + ('Gabonese Republic'), + ('Gambia'), + ('Georgia'), + ('Germany'), + ('Ghana'), + ('Gibraltar'), + ('Greece'), + ('Greenland'), + ('Guadeloupe'), + ('Guam'), + ('Guatemala'), + ('Guinea'), + ('Guyana'), + ('Haiti'), + ('Honduras'), + ('Hong Kong'), + ('Hungary'), + ('Iceland'), + ('India'), + ('Indonesia'), + ('Iran'), + ('Iraq'), + ('Ireland'), + ('Israel'), + ('Italy'), + ('Jamaica'), + ('Japan'), + ('Jordan'), + ('Kazakstan'), + ('Kenya'), + ('Kiribati'), + ('Kuwait'), + ('Kyrgyz Republic'), + ('Laos'), + ('Latvia'), + ('Lebanon'), + ('Lesotho'), + ('Liberia'), + ('Libya'), + ('Liechtenstein'), + ('Lithuania'), + ('Luxembourg'), + ('Macao'), + ('Madagascar'), + ('Malawi'), + ('Malaysia'), + ('Maldives'), + ('Mali Republic'), + ('Malta'), + ('Marshall Islands'), + ('Martinique'), + ('Mauritania'), + ('Mauritius'), + ('MayotteIsland'), + ('Mexico'), + ('Midway Islands'), + ('Moldova'), + ('Monaco'), + ('Mongolia'), + ('Morocco'); +INSERT INTO `countrycode` (`country`) VALUES + ('Mozambique'), + ('Myanmar'), + ('Namibia'), + ('Nauru'), + ('Nepal'), + ('Netherlands'), + ('Netherlands Antilles'), + ('New Caledonia'), + ('New Zealand'), + ('Nicaragua'), + ('Niger'), + ('Nigeria'), + ('Niue'), + ('Norfolk Island'), + ('North Korea'), + ('Norway'), + ('Oman'), + ('Pakistan'), + ('Palau'), + ('Palestinian Settlements'), + ('Panama'), + ('PapuaNew Guinea'), + ('Paraguay'), + ('Peru'), + ('Philippines'), + ('Poland'), + ('Portugal'), + ('Puerto Rico'), + ('Qatar'), + ('RéunionIsland'), + ('Romania'), + ('Russia'), + ('Rwandese Republic'), + ('San Marino'), + ('São Tomé and Principe'), + ('Saudi Arabia'), + ('Senegal '), + ('Serbia and Montenegro'), + ('Seychelles Republic'), + ('Sierra Leone'), + ('Singapore'), + ('Slovak Republic'), + ('Slovenia'), + ('Solomon Islands'), + ('Somali Democratic Republic'), + ('South Africa'), + ('South Korea'), + ('Spain'), + ('Sri Lanka'), + ('St Kitts - Nevis'), + ('St. Helena'), + ('St. Lucia'), + ('St. Pierre & Miquelon'), + ('St. Vincent & Grenadines'), + ('Sudan'); +INSERT INTO `countrycode` (`country`) VALUES + ('Suriname'), + ('Swaziland'), + ('Sweden'), + ('Switzerland'), + ('Syria'), + ('Taiwan'), + ('Tajikistan'), + ('Tanzania'), + ('Thailand'), + ('Togolese Republic'), + ('Tokelau'), + ('Tonga Islands'), + ('Trinidad & Tobago'), + ('Tunisia'), + ('Turkey'), + ('Turkmenistan'), + ('Tuvalu'), + ('Uganda'), + ('Ukraine'), + ('United Arab Emirates'), + ('United Kingdom'), + ('United States of America'), + ('Uruguay'), + ('Uzbekistan'), + ('Vanuatu'), + ('Venezuela'), + ('Vietnam'), + ('Wake Island'), + ('Wallisand Futuna Islands'), + ('Western Samoa'), + ('Yemen'), + ('Zambia'), + ('Zimbabwe'); + +DROP TABLE IF EXISTS `currency`; +CREATE TABLE `currency` ( + `Currency` varchar(3) NOT NULL default '', + `CurrencyName` varchar(40) NOT NULL default '', + PRIMARY KEY (`Currency`) +); + +INSERT INTO `currency` (`Currency`,`CurrencyName`) VALUES + ('USD','US Dollars'), + ('CAD','Canadian Dollars'), + ('AUD','Australian Dollars'); + +CREATE TABLE `language` ( + `language` varchar(5) NOT NULL, + `languagename` varchar(40) NOT NULL, + `active` tinyint(1) NOT NULL default '1', + PRIMARY KEY (`language`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +INSERT INTO `language` (`language`,`languagename`,`active`) VALUES + ('en','English',1), + ('fr','French',1), + ('de','German',1); + +CREATE TABLE `resellers` ( + name varchar(40) NOT NULL default '', + status int(11) NOT NULL default '1', + posttoexternal int(11) NOT NULL default '0', + agile_site_id int(11) NOT NULL default '0', + config_file char(80) NOT NULL default 'reseller.conf', + companyname varchar(255) default NULL, + slogan varchar(255) default NULL, + footer varchar(255) default NULL, + pricelist varchar(255) default NULL, + currency varchar(255) default NULL, + logo varchar(255) default NULL, + website varchar(255) default NULL, + adminemail varchar(255) default NULL, + salesemail varchar(255) default NULL, + phone varchar(45) default NULL, + fax varchar(45) default NULL, + address1 varchar(255) default NULL, + address2 varchar(255) default NULL, + city varchar(255) default NULL, + state varchar(255) default NULL, + postcode varchar(255) default NULL, + country varchar(255) default NULL, + defaultbrand varchar(45) NOT NULL default 'default', + defaultcurrency varchar(45) NOT NULL default 'USD', + defaultcredit varchar(45) NOT NULL default '0.00', + externalbill varchar(45) NOT NULL default '', + PRIMARY KEY (`name`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + +CREATE TABLE templates ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(45) NOT NULL default '', +reseller VARCHAR(45) NOT NULL default '', +template TEXT NOT NULL default '', + PRIMARY KEY (`id`), + KEY `reseller` (`reseller`) +); + +INSERT INTO templates (name,template) VALUES +('voip_account_refilled','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been refilled. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('voip_reactivate_account','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been reactivated. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_add_user','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been added. +Your Username is -- $vars->{extension} -- +Your Password is -- $vars->{secret} -- +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('add_sip_device','Attention: $vars->{title} $vars->{first} $vars->{last} +A new device has been enabled on your account. Here +is the necessary configuration information. +------- $config->{company_name} Configuration Info -------- +In sip.conf: +[$config->{company_name}-in] +type=user +username=$config->{company_name}-in +auth=rsa +inkeys=$config->{key} ;This key may be downloaded from $config->{key_home} +host=$config->{asterisk_server} +context=from-pstn +accountcode=$config->{company_name} +[$config->{company_name}] +type=peer +username=$vars->{extension} +secret=$vars->{secret} +host=$config->{asterisk_server} +callerid= <555-555-5555> +qualify=yes +accountcode=$config->{company_name} ; for call tracking in the cdr +In the [globals] section add: +register => $vars->{user}:password@$config->{asterisk_server}'); + +INSERT INTO templates (name,template) VALUES +('add_iax_device','Attention: $vars->{title} $vars->{first} $vars->{last} +A new device has been enabled on your account. Here +is the necessary configuration information. +------- $config->{company_name} Configuration Info -------- +In iax.conf: +At the bottom of the file add: +[$config->{company_name}-in] +;trunk=yes ;optional .. only works if you have a zaptel or ztdummy driver running +type=user +username=$config->{company_name}-in +auth=rsa +inkeys=$config->{key} ;This key may be downloaded from $config->{key_home} +host=$config->{asterisk_server} +context=incoming +accountcode=$config->{company_name} ;for call tracking in the cdr +[$config->{company_name}] +;to simplify and config outgoing calls +;trunk=yes ;optional .. only works if you have a zaptel driver running +type=peer +username=$vars->{extension} +secret=$vars->{secret} +host=$config->{asterisk_server} +callerid=<555-555-5555> ;only the number will really be used +qualify=yes +accountcode=$config->{company_name} ; for call tracking in the cdr +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_remove_user','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP Termination with $config->{company_name} has been removed +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_calling_card','You have added a $vars->{pricelist} callingcard in the amount of $vars->{pennies} cents. +Card Number $cc Pin: $pin +Thanks for your patronage. +The $config->{company_name} sales team'); + +INSERT INTO templates (name,template) VALUES +('email_add_did','Attention: $vars->{title} $vars->{first} $vars->{last} +Your DID with $config->{company_name} has been added +The number is: $did +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team +Here is a sample setup which would call a few sip phones with incoming calls: +[incoming] +exten => _1$did,1,Wait(2) +exten => _1$did,2,Dial(SIP/2201&SIP/2202,15,Ttm) ; dial a couple of phones for 15 secs +exten => _1$did,3,Voicemail(u1000) ; go to unavailable voicemail (vm box 1000) +exten => _1$did,103,Voicemail(b1000) ; go to busy voicemail (vm box 1000)'); + +INSERT INTO templates (name,template) VALUES +('email_remove_did','Attention: $vars->{title} $vars->{first} $vars->{last} +Your DID with $config->{company_name} has been removed +The number was: $did +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_new_invoice','Invoice # $invoice in the amount of \$$total has been added to your account. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_low_balance','Your VOIP account with $config->{company_name} has a balance of \$$balance. +Please visit our website to refill your account to ensure uninterrupted service. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +CREATE TABLE `sweeplist` ( + `Id` int(10) unsigned NOT NULL default '0', + `sweep` varchar(45) NOT NULL default '', + PRIMARY KEY (`Id`) +); + +INSERT INTO sweeplist (Id,sweep) VALUES +(0,'daily'), +(1,'weekly'), +(2,'monthly'), +(3,'quarterly'), +(4,'semi-annually'), +(5,'annually') +; + +CREATE TABLE userlevels ( +userlevelid int(11) NOT NULL, +userlevelname varchar(50) NOT NULL, +PRIMARY KEY (`userlevelid`) +); + +INSERT INTO `userlevels` (`userlevelid`,`userlevelname`) VALUES + (-1,'Administrator'), + (0,'Anonymous'), + (1,'Reseller'), + (2,'Admin'), + (3,'Vendor'), + (4,'Customer Service'), + (5,'Users'); + +CREATE TABLE reseller_pricing ( +id INTEGER NOT NULL AUTO_INCREMENT, +reseller VARCHAR(50) NOT NULL, +type INTEGER NOT NULL DEFAULT 1, +monthlycost INTEGER NOT NULL DEFAULT 0, +prorate INTEGER NOT NULL DEFAULT 0, +setup INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +note VARCHAR(50) NOT NULL DEFAULT '', +disconnectionfee INTEGER NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +inc CHAR(10) NOT NULL DEFAULT '', +PRIMARY KEY (`id`), + KEY `reseller` (`reseller`) +); + +CREATE TABLE callshops ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(50) NOT NULL, +osc_dbname VARCHAR(50) NOT NULL DEFAULT '', +osc_dbpass VARCHAR(50) NOT NULL DEFAULT '', +osc_dbuser VARCHAR(50) NOT NULL DEFAULT '', +osc_dbhost VARCHAR(50) NOT NULL DEFAULT '', +osc_site VARCHAR(50) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), +KEY `name` (`name`) +); + +CREATE TABLE extensions_status ( +id INTEGER NOT NULL AUTO_INCREMENT, +tech VARCHAR(6) NULL, +extension VARCHAR(20) NULL, +number VARCHAR(255) NULL, +status VARCHAR(255) NULL, +timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, +Privilege VARCHAR(255) NULL, +Channel VARCHAR(255) NULL, +Cause VARCHAR(255) NULL, +Causetxt VARCHAR(255) NULL, +PeerStatus VARCHAR(255) NULL, +Peer VARCHAR(255) NULL, +Context VARCHAR(255) NULL, +Application VARCHAR(255) NULL, +AppData VARCHAR(255) NULL, +Priority VARCHAR(255) NULL, +Uniqueid VARCHAR(255) NULL, +Event VARCHAR(255) NULL, +State VARCHAR(255) NULL, +CallerIDName VARCHAR(255) NULL, +CallerID VARCHAR(255) NULL, +AstExtension VARCHAR(255) NULL, +PRIMARY KEY (`id`), +KEY `extension` (`extension`)); + +CREATE TABLE activity_logs ( +id INTEGER NOT NULL AUTO_INCREMENT, +timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, +message TEXT NOT NULL DEFAULT '', +user VARCHAR(50), +PRIMARY KEY (`id`)); + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-10-28 04:19:27
|
Revision: 2201 http://astpp.svn.sourceforge.net/astpp/?rev=2201&view=rev Author: darrenkw Date: 2008-10-28 04:19:19 +0000 (Tue, 28 Oct 2008) Log Message: ----------- Added more freeswitch support. Modified Paths: -------------- trunk/astpp-admin.cgi trunk/astpp-common.pl trunk/astpp-rate-engine.pl Added Paths: ----------- trunk/sql/astpp-2008-10-14.sql trunk/sql/cdrdb-2008-10-28.sql Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2008-10-10 04:25:00 UTC (rev 2200) +++ trunk/astpp-admin.cgi 2008-10-28 04:19:19 UTC (rev 2201) @@ -11153,7 +11153,7 @@ } my @chargelist = &list_cdrs_account( $config, $cdr_db, $accountinfo->{number}, $accountinfo->{cc} ); - &processlist( $astpp_db, $cdr_db, $config, \@chargelist ) + &processlist( $astpp_db, $cdr_db, $config, $config->{asterisk_cdr_table}, \@chargelist ) ; # Bill as many calls as we can. $status .= gettext("We rated as many CDRS as we could") . "<br>"; $tmp = Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2008-10-10 04:25:00 UTC (rev 2200) +++ trunk/astpp-common.pl 2008-10-28 04:19:19 UTC (rev 2201) @@ -1450,21 +1450,21 @@ # Select a specific cdr from the Asterisk(tm) cdr table. sub get_cdr() { - my ( $config, $cdr_db, $uniqueid,$rating,$dst ) = @_; + my ( $config, $cdr_db, $cdr_table, $uniqueid,$rating,$dst ) = @_; my ( $sql, $cdrdata ); if ($dst) { $sql = $cdr_db->prepare( - "SELECT * FROM $config->{asterisk_cdr_table} WHERE uniqueid = " . $cdr_db->quote($uniqueid) . " AND dst = " . $cdr_db->quote($dst) . " ORDER BY cost DESC LIMIT 1" ); + "SELECT * FROM $cdr_table WHERE uniqueid = " . $cdr_db->quote($uniqueid) . " AND dst = " . $cdr_db->quote($dst) . " ORDER BY cost DESC LIMIT 1" ); } elsif ($rating) { $sql = $cdr_db->prepare( - "SELECT * FROM $config->{asterisk_cdr_table} WHERE uniqueid = " . $cdr_db->quote($uniqueid) . " AND cost in ('error','none') ORDER BY cost DESC LIMIT 1" ); + "SELECT * FROM $cdr_table WHERE uniqueid = " . $cdr_db->quote($uniqueid) . " AND cost in ('error','none') ORDER BY cost DESC LIMIT 1" ); } else { $sql = $cdr_db->prepare( - "SELECT * FROM $config->{asterisk_cdr_table} WHERE uniqueid = " . $cdr_db->quote($uniqueid) . " ORDER by cost DESC LIMIT 1" ); + "SELECT * FROM $cdr_table WHERE uniqueid = " . $cdr_db->quote($uniqueid) . " ORDER by cost DESC LIMIT 1" ); } $sql->execute; $cdrdata = $sql->fetchrow_hashref; @@ -1473,9 +1473,9 @@ } # Update the cost of a cdr in the Asterisk(tm) cdr table. This is used to denote a cdr that has been rated. -sub save_ast_cdr() { - my ( $config, $cdr_db, $uniqueid, $cost,$dst ) = @_; - $cdr_db->do( "UPDATE $config->{asterisk_cdr_table} SET cost = " +sub save_cdr() { + my ( $config, $cdr_db, $cdr_table, $uniqueid, $cost,$dst ) = @_; + $cdr_db->do( "UPDATE $cdr_table SET cost = " . $cdr_db->quote($cost) . "WHERE uniqueid = " . $cdr_db->quote($uniqueid) @@ -1488,11 +1488,11 @@ # used to select cdrs that have not been billed which have value "none" or those that the rating engine ran # into a problem with which are marked "error". sub list_cdrs_status() { - my ( $config, $cdr_db, $default ) = @_; + my ( $config, $cdr_db, $cdr_table, $default ) = @_; my ( $sql, @cdrlist, $row ); $sql = $cdr_db->prepare( - "SELECT * FROM $config->{asterisk_cdr_table} WHERE cost = " . $cdr_db->quote($default) ); + "SELECT * FROM $cdr_table WHERE cost = " . $cdr_db->quote($default) ); $sql->execute; while ( $row = $sql->fetchrow_hashref ) { push @cdrlist, $row->{uniqueid}; @@ -1516,9 +1516,9 @@ # Update the cost of a cdr in the Asterisk(tm) cdr table. This is used to denote a cdr that has been tagged # to a vendor. -sub save_ast_cdr_vendor() { - my ( $config, $cdr_db, $uniqueid, $cost,$dst ) = @_; - $cdr_db->do( "UPDATE $config->{asterisk_cdr_table} SET vendor = " +sub save_cdr_vendor() { + my ( $config, $cdr_db, $cdr_table, $uniqueid, $cost,$dst ) = @_; + $cdr_db->do( "UPDATE $cdr_table SET vendor = " . $cdr_db->quote($cost) . "WHERE uniqueid = " . $cdr_db->quote($uniqueid) @@ -1531,11 +1531,11 @@ # used to select cdrs that have not been tagged to a vendor which have value "none" or those that the rating engine ran # into a problem with which are marked "error". sub list_cdrs_status_vendor() { - my ( $config, $cdr_db, $default ) = @_; + my ( $config, $cdr_db, $cdr_table, $default ) = @_; my ( $sql, @cdrlist, $row ); $sql = $cdr_db->prepare( - "SELECT * FROM $config->{asterisk_cdr_table} WHERE vendor = " . $cdr_db->quote($default) ); + "SELECT * FROM $cdr_table WHERE vendor = " . $cdr_db->quote($default) ); $sql->execute; while ( $row = $sql->fetchrow_hashref ) { push @cdrlist, $row->{uniqueid}; @@ -3786,18 +3786,18 @@ } sub rating() { # This routine recieves a specific cdr and takes care of rating it and of marking it as rated. It bills resellers as appropriate. - my ( $astpp_db, $cdr_db, $config, $cdrinfo, $carddata, $vars, @output ) = @_; + my ( $astpp_db, $cdr_db, $cdr_table, $config, $cdrinfo, $carddata, $vars, @output ) = @_; my ( $increment, $numdata, $package, $notes, $status ); print STDERR "----------------------------------------------------------------\n"; print STDERR "uniqueid: $cdrinfo->{uniqueid}, cardno: $carddata->{number}, phoneno: $cdrinfo->{dst}, Userfield: $cdrinfo->{userfield}\n"; print STDERR "disposition: $cdrinfo->{disposition} Pricelist: $carddata->{pricelist} reseller: $carddata->{reseller}\n"; - if ( $cdrinfo->{disposition} =~ /^ANSWERED$/ ) { + if ( $cdrinfo->{disposition} =~ /^ANSWERED$/ || $cdrinfo->{disposition} eq "NORMAL_CLEARING") { $numdata = &get_route( $astpp_db, $config, $cdrinfo->{dst}, $carddata->{pricelist}, $carddata, $cdrinfo->{userfield} ); print STDERR "PATTERN: $numdata->{pattern}"; if ( !$numdata->{pattern} ) { - &save_ast_cdr( $config, $cdr_db, $cdrinfo->{uniqueid}, "error",$cdrinfo->{dst} ) if !$vars && $config->{astcdr} == 1; + &save_cdr( $config, $cdr_db,$cdr_table, $cdrinfo->{uniqueid}, "error",$cdrinfo->{dst} ) if !$vars && $config->{astcdr} == 1; print STDERR "ERROR - ERROR - ERROR - ERROR - ERROR \n"; print STDERR "NO MATCHING PATTERN\n"; print STDERR "----------------------------------------------------------------\n"; @@ -3866,7 +3866,7 @@ my $sigset = POSIX::SigSet->new; my $blockset = POSIX::SigSet->new( SIGINT, SIGQUIT, SIGCHLD ); sigprocmask( SIG_BLOCK, $blockset, $sigset ) or die "Could not block INT,QUIT,CHLD signals: $!\n"; - &save_ast_cdr( $config, $cdr_db, $cdrinfo->{uniqueid}, $cost,$cdrinfo->{dst} ) if !$vars && $config->{astcdr} == 1; + &save_cdr( $config, $cdr_db,$cdr_table, $cdrinfo->{uniqueid}, $cost,$cdrinfo->{dst} ) if !$vars && $config->{astcdr} == 1; if ( $cdrinfo->{accountcode} ne $carddata->{number} && $cdrinfo->{accountcode} ne $carddata->{cc}) { $notes = $cdrinfo->{accountcode} . "|" . $numdata->{comment} . "|" . $numdata->{pattern}; } @@ -3895,7 +3895,7 @@ } } else { - &save_ast_cdr( $config, $cdr_db, $cdrinfo->{uniqueid}, "error",$cdrinfo->{dst} ) if !$vars && $config->{astcdr} == 1; + &save_cdr( $config, $cdr_db,$cdr_table, $cdrinfo->{uniqueid}, "error",$cdrinfo->{dst} ) if !$vars && $config->{astcdr} == 1; print STDERR "ERROR - ERROR - ERROR - ERROR - ERROR \n"; print STDERR "DISPOSITION: $cdrinfo->{disposition} \n"; print STDERR "UNIQUEID: $cdrinfo->{uniqueid} \n"; @@ -3933,15 +3933,15 @@ sub processlist() { # Deal with a list of calls which have not been rated so far. - my ($astpp_db, $cdr_db, $config, $chargelist, $vars) = @_; + my ($astpp_db, $cdr_db, $cdr_table, $config, $chargelist, $vars) = @_; my ( $status, $cdrinfo); foreach (@$chargelist) { my $uniqueid = $_; print STDERR gettext("Processing Uniqueid: ") . $uniqueid . "\n"; - $cdrinfo = ($vars) ? $vars : &get_cdr( $config, $cdr_db, $uniqueid ); + $cdrinfo = ($vars) ? $vars : &get_cdr( $config, $cdr_db,$cdr_table, $uniqueid ); my $savedcdrinfo = $cdrinfo; if(!$vars) { - my $tmp = "UPDATE $config->{asterisk_cdr_table} SET cost = 'rating' WHERE uniqueid = " + my $tmp = "UPDATE $cdr_table SET cost = 'rating' WHERE uniqueid = " . $cdr_db->quote($uniqueid) . " AND cost = 'none'" . " AND dst = " @@ -3958,8 +3958,8 @@ $cdrinfo->{billsec} = $cdrinfo->{duration}; } if ( $cdrinfo->{billsec} <= 0 ) { # not having the right billable seconds. - &save_ast_cdr( $config, $cdr_db, $uniqueid, 0,$cdrinfo->{dst} ) if !$vars && $config->{astcdr} == 1; - &save_ast_cdr_vendor( $config, $cdr_db, $uniqueid, 0,$cdrinfo->{dst} ) + &save_cdr( $config, $cdr_db,$cdr_table, $uniqueid, 0,$cdrinfo->{dst} ) if !$vars && $config->{astcdr} == 1; + &save_cdr_vendor( $config, $cdr_db, $cdr_table, $uniqueid, 0,$cdrinfo->{dst} ) if !$vars && $config->{astcdr} == 1 && $config->{trackvendorcharges} == 1; print STDERR "\n----------------------\n"; print STDERR "CDR Written - No Billable Seconds\n"; @@ -3970,11 +3970,11 @@ } elsif ( $cdrinfo->{accountcode} ) { $status = &rating( $astpp_db, $cdr_db, $config, $cdrinfo, $carddata, $vars); - $cdrinfo = &get_cdr( $config, $cdr_db, $uniqueid ) if !$vars; + $cdrinfo = &get_cdr( $config, $cdr_db,$cdr_table, $uniqueid ) if !$vars; if ( $status == 1 ) { my $previous_account = $carddata->{number}; while ( $carddata->{reseller} ne "" ) { - $cdrinfo = &get_cdr( $config, $cdr_db, $uniqueid ) if !$vars; + $cdrinfo = &get_cdr( $config, $cdr_db,$cdr_table, $uniqueid ) if !$vars; print STDERR "Charge $uniqueid to $carddata->{reseller}" if $config->{debug} == 1; $carddata = &get_account( $astpp_db, $carddata->{reseller} ); $status = &rating( $astpp_db, $cdr_db, $config, $cdrinfo, $carddata, $vars); @@ -4043,7 +4043,7 @@ } sub vendor_process_rating() { #Rate Vendor calls. - my ( $astpp_db, $cdr_db, $config, $phrase, $uniqueid, $vars ) = @_; + my ( $astpp_db, $cdr_db, $cdr_table, $config, $phrase, $uniqueid, $vars ) = @_; my $tmp = "SELECT * FROM trunks ORDER BY LENGTH(path)"; my $sql = $astpp_db->prepare($tmp); print STDERR "$tmp\n" . "\n" if $config->{debug} == 1; @@ -4103,7 +4103,7 @@ "", $cdrinfo->{trunk}, $pricerecord->{comment} . "|" . $pricerecord->{pattern} ) if $config->{posttoastpp} == 1; - &save_ast_cdr_vendor( $config, $cdr_db, $cdrinfo->{uniqueid}, $cost,$cdrinfo->{dst} ); + &save_cdr_vendor( $config, $cdr_db,$cdr_table, $cdrinfo->{uniqueid}, $cost,$cdrinfo->{dst} ); my $tmp = "UPDATE cdrs SET cost = '" . $cost . "' WHERE uniqueid = '" . $cdrinfo->{uniqueid} . "' AND cost = 0 " . " AND cardnum != '" . $trunk->{provider} . "' AND dst = " @@ -4111,7 +4111,7 @@ print STDERR "$tmp\n" if $config->{debug} == 1; $astpp_db->do($tmp); } else { - &save_ast_cdr_vendor( $config, $cdr_db, $cdrinfo->{uniqueid}, "error",$cdrinfo->{dst} ); + &save_cdr_vendor( $config, $cdr_db,$cdr_table, $cdrinfo->{uniqueid}, "error",$cdrinfo->{dst} ); } } } else { Modified: trunk/astpp-rate-engine.pl =================================================================== --- trunk/astpp-rate-engine.pl 2008-10-10 04:25:00 UTC (rev 2200) +++ trunk/astpp-rate-engine.pl 2008-10-28 04:19:19 UTC (rev 2201) @@ -25,17 +25,16 @@ #use strict; use lib './lib', '../lib'; require "/usr/local/astpp/astpp-common.pl"; -my $verbosity = 1; +my $verbosity = 4; $ASTPP = ASTPP->new; $ASTPP->set_verbosity($verbosity); #Tell ASTPP debugging how verbose we want to be. - $ENV{'LANGUAGE'} = "en"; # de, es, br - whatever $ASTPP->debug( "Interface language is set to: $ENV{'LANGUAGE'}", $verbosity); bindtextdomain( "ASTPP", "/var/locale" ); textdomain("ASTPP"); use vars qw(@output $shucks $params $astpp_db $cdr_db $config - $uniqueid $run_type ); + $uniqueid $run_type $cdr_table); @output = ( "STDOUT", "LOGFILE" ); $shucks = 0; @@ -55,12 +54,23 @@ ################# Program Starts HERE ################################# $uniqueid = param('uniqueid'); #$ARGV[0]; $run_type = param('runtype'); # realtime,batch,price_only +$softswitch = param('softswitch'); # asterisk or freeswitch + &initialize(); + +if ($softswitch eq "freeswitch") { + $cdr_table = $config->{freeswitch_cdr_table}; + $ASTPP->debug("Rating calls for FreeSwitch", $verbosity); +} else { + $cdr_table = $config->{asterisk_cdr_table}; + $ASTPP->debug("Rating calls for Asterisk", $verbosity); +} + if ( $uniqueid ne "" ) { my @chargelist; push @chargelist, $uniqueid; #sleep $config->{sleep}; - &processlist($astpp_db, $cdr_db, $config, \@chargelist); + &processlist($astpp_db, $cdr_db,$cdr_table, $config, \@chargelist); #&cleanup_cdrs($cdr_db, $config); &shutdown(); exit(0); @@ -91,7 +101,7 @@ ); my @chargelist; push @chargelist, $ARGV[16]; - &processlist($astpp_db, $cdr_db, $config, \@chargelist, \%args); + &processlist($astpp_db, $cdr_db,$cdr_table, $config, \@chargelist, \%args); &cleanup_cdrs($cdr_db, $config); } elsif ( $run_type eq "price_only" ) { @@ -144,13 +154,13 @@ if ( !$cdr_db ) { $cdr_db = &connect_db( $config, @output ); } - my $cdrinfo = &get_cdr( $config, $cdr_db, $input->{Uniqueid},1 ); + my $cdrinfo = &get_cdr( $config, $cdr_db, $input->{Uniqueid},$cdr_table,1 ); # my $tmp = "UPDATE $config->{asterisk_cdr_table} SET cost = 'rating' WHERE uniqueid = " . $input->{Uniqueid} . " AND cost = 'none' AND dst = " . $cdr_db->quote($cdrinfo->{dst}) . " LIMIT 1"; # print STDERR $tmp if $config->{debug} == 1; # print $tmp if $config->{debug} == 1; # $cdr_db->do($tmp); if ($cdrinfo->{lastapp} eq "MeetMe" || $cdrinfo->{billsec} > 0 || $cdrinfo->{cost} eq "none") { - &processlist($astpp_db, $cdr_db, $config, \@chargelist); + &processlist($astpp_db, $cdr_db, $cdr_table, $config, \@chargelist); &vendor_process_rating( $astpp_db, $cdr_db, $config, "none", $input->{Uniqueid} ) if $config->{trackvendorcharges} == 1; } # else { &cleanup_cdrs($cdr_db, $config); @@ -166,14 +176,14 @@ &cleanup_cdrs($cdr_db, $config); my @chargelist; my $phrase = "none"; - @chargelist = &list_cdrs_status( $config, $cdr_db, $phrase ); # Grab a list of all calls with "none" assigned in the cost field - &processlist($astpp_db, $cdr_db, $config, \@chargelist); # Bill as many calls as we can. + @chargelist = &list_cdrs_status( $config, $cdr_db, $cdr_table, $phrase ); # Grab a list of all calls with "none" assigned in the cost field + &processlist($astpp_db, $cdr_db,$cdr_table, $config,\@chargelist); # Bill as many calls as we can. $phrase = "error"; - @chargelist = &list_cdrs_status( $config, $cdr_db, $phrase ); # Grab a list of all calls with "none" assigned in the cost field - &processlist($astpp_db, $cdr_db, $config, \@chargelist); # See if we can now bill some of the calls that are marked in "error" + @chargelist = &list_cdrs_status( $config, $cdr_db, $cdr_table, $phrase ); # Grab a list of all calls with "none" assigned in the cost field + &processlist($astpp_db, $cdr_db,$cdr_table, $config, \@chargelist); # See if we can now bill some of the calls that are marked in "error" # print STDERR gettext("START ON VENDOR CALL RATING!") . "\n" if $config->{debug} == 1; -# &vendor_process_rating( $astpp_db, $cdr_db, $config, "none", 0 ) if $config->{trackvendorcharges} == 1; -# &vendor_process_rating( $astpp_db, $cdr_db, $config. $config, "error", 0 ) if $config->{trackvendorcharges} == 1; +# &vendor_process_rating( $astpp_db, $cdr_db,$cdr_table, $config, "none", 0 ) if $config->{trackvendorcharges} == 1; +# &vendor_process_rating( $astpp_db, $cdr_db,$cdr_table, $config. $config, "error", 0 ) if $config->{trackvendorcharges} == 1; # print STDERR gettext("VENDOR CALLS WHICH HAVE NOT BEEN RATED.") . "\n" if $config->{debug} == 1; # Print a list of calls which have not been rated &vendor_not_billed($config, $cdr_db) if $config->{trackvendorcharges} == 1; Added: trunk/sql/astpp-2008-10-14.sql =================================================================== --- trunk/sql/astpp-2008-10-14.sql (rev 0) +++ trunk/sql/astpp-2008-10-14.sql 2008-10-28 04:19:19 UTC (rev 2201) @@ -0,0 +1,1285 @@ +DROP TABLE IF EXISTS `routes`; +CREATE TABLE routes ( +id INTEGER NOT NULL AUTO_INCREMENT, +pattern CHAR(40), +comment CHAR(80), +connectcost INTEGER NOT NULL, +includedseconds INTEGER NOT NULL, +cost INTEGER NOT NULL, +pricelist CHAR(80), +inc INTEGER, +reseller CHAR(50) default NULL, +precedence INT(4) NOT NULL DEFAULT 0, +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`), +KEY `pattern` (`pattern`), +KEY `pricelist` (`pricelist`), +KEY `reseller` (`reseller`), +KEY `status` (`status`) +); + +DROP TABLE IF EXISTS `pricelists`; +CREATE TABLE pricelists ( +name CHAR(40) NOT NULL, +markup INTEGER NOT NULL DEFAULT 0, +inc INTEGER NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +reseller CHAR(50) default NULL, +PRIMARY KEY (`name`) +); + +DROP TABLE IF EXISTS `callingcardbrands`; +CREATE TABLE callingcardbrands ( +name CHAR(40) NOT NULL, +reseller CHAR(40) NOT NULL DEFAULT '', +language CHAR(10) NOT NULL DEFAULT '', +pricelist CHAR(40) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +validfordays CHAR(4) NOT NULL DEFAULT '', +pin INTEGER NOT NULL DEFAULT 0, +maint_fee_pennies INTEGER NOT NULL DEFAULT 0, +maint_fee_days INTEGER NOT NULL DEFAULT 0, +disconnect_fee_pennies INTEGER NOT NULL DEFAULT 0, +minute_fee_minutes INTEGER NOT NULL DEFAULT 0, +minute_fee_pennies INTEGER NOT NULL DEFAULT 0, +min_length_minutes INTEGER NOT NULL DEFAULT 0, +min_length_pennies INTEGER NOT NULL DEFAULT 0, +PRIMARY KEY (`name`), + KEY `reseller` (`reseller`), + KEY `pricelist` (`pricelist`) +); + +DROP TABLE IF EXISTS `callingcardcdrs`; +CREATE TABLE callingcardcdrs ( +id INTEGER NOT NULL AUTO_INCREMENT, +cardnumber CHAR(50) NOT NULL DEFAULT '', +clid CHAR(80) NOT NULL DEFAULT '', +destination CHAR(40) NOT NULL DEFAULT '', +disposition CHAR(20)NOT NULL DEFAULT '', +callstart CHAR(40) NOT NULL DEFAULT '', +seconds INTEGER NOT NULL DEFAULT 0, +debit DECIMAL(20,6) NOT NULL DEFAULT 0.00000, +credit DECIMAL(20,6) NOT NULL DEFAULT 0.00000, +status INTEGER DEFAULT 0 NOT NULL, +uniqueid VARCHAR(32) NOT NULL DEFAULT '', +notes CHAR(80) NOT NULL DEFAULT '', +pricelist CHAR(80) NOT NULL DEFAULT '', +pattern CHAR(80) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + KEY `cardnumber` (`cardnumber`) +); + +DROP TABLE IF EXISTS `trunks`; +CREATE TABLE trunks ( +name VARCHAR(30) NOT NULL, +tech CHAR(10) NOT NULL DEFAULT '', +path CHAR(40) NOT NULL DEFAULT '', +provider CHAR(100) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +dialed_modify TEXT NOT NULL DEFAULT '', +resellers TEXT NOT NULL DEFAULT '', +precedence INT(4) NOT NULL DEFAULT 0, +maxchannels INTEGER DEFAULT 0 NOT NULL, + PRIMARY KEY (`name`), + KEY `provider` (`provider`), + KEY `provider_2` (`provider`) +); + +DROP TABLE IF EXISTS `outbound_routes`; +CREATE TABLE outbound_routes ( +pattern CHAR(40), +id INTEGER NOT NULL AUTO_INCREMENT, +comment CHAR(80) NOT NULL DEFAULT '', +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +trunk CHAR(80) NOT NULL DEFAULT '', +inc CHAR(10) NOT NULL DEFAULT '', +strip CHAR(40) NOT NULL DEFAULT '', +prepend CHAR(40) NOT NULL DEFAULT '', +precedence INT(4) NOT NULL DEFAULT 0, +resellers TEXT NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `trunk` (`trunk`), + KEY `pattern` (`pattern`) +); + +DROP TABLE IF EXISTS `dids`; +CREATE TABLE dids ( +number CHAR(40) NOT NULL, +account CHAR(50) NOT NULL DEFAULT '', +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +monthlycost INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +inc CHAR(10) NOT NULL DEFAULT '', +extensions CHAR(180) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +provider CHAR(40) NOT NULL DEFAULT '', +country CHAR (80)NOT NULL DEFAULT '', +province CHAR (80) NOT NULL DEFAULT '', +city CHAR (80) NOT NULL DEFAULT '', +prorate int(1) NOT NULL default 0, +setup int(11) NOT NULL default 0, +limittime int(1) NOT NULL default 1, +disconnectionfee INT(11) NOT NULL default 0, +variables TEXT NOT NULL DEFAULT '', +options varchar(40) default NULL, +maxchannels int(4) NOT NULL default 0, +chargeonallocation int(1) NOT NULL default 1, +allocation_bill_status int(1) NOT NULL default 0, +dial_as CHAR(40) NOT NULL DEFAULT '', +PRIMARY KEY (`number`), + KEY `account` (`account`) +); + +DROP TABLE IF EXISTS `accounts`; +CREATE TABLE accounts ( +cc CHAR(20) NOT NULL DEFAULT '', +number CHAR(50) NOT NULL, +reseller CHAR(40) NOT NULL DEFAULT '', +pricelist CHAR(24) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +credit INTEGER NOT NULL DEFAULT 0, +sweep INTEGER NOT NULL DEFAULT 0, +creation TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, +pin INTEGER NOT NULL DEFAULT 0, +credit_limit INTEGER NOT NULL DEFAULT 0, +posttoexternal INTEGER NOT NULL DEFAULT 0, +balance DECIMAL(20,6) NOT NULL DEFAULT 0, +password CHAR(80) NOT NULL DEFAULT '', +first_name CHAR(40) NOT NULL DEFAULT '', +middle_name CHAR(40) NOT NULL DEFAULT '', +last_name CHAR(40) NOT NULL DEFAULT '', +company_name CHAR(40) NOT NULL DEFAULT '', +address_1 CHAR(80) NOT NULL DEFAULT '', +address_2 CHAR(80) NOT NULL DEFAULT '', +address_3 CHAR(80) NOT NULL DEFAULT '', +postal_code CHAR(12) NOT NULL DEFAULT '', +province CHAR(40) NOT NULL DEFAULT '', +city CHAR(80) NOT NULL DEFAULT '', +country CHAR(40) NOT NULL DEFAULT '', +telephone_1 CHAR(40) NOT NULL DEFAULT '', +telephone_2 CHAR(40) NOT NULL DEFAULT '', +fascimile CHAR(40) NOT NULL DEFAULT '', +email CHAR(80) NOT NULL DEFAULT '', +language CHAR(2) NOT NULL DEFAULT '', +currency CHAR(3) NOT NULL DEFAULT '', +maxchannels INTEGER DEFAULT 1 NOT NULL, +routing_technique INT(4) NOT NULL DEFAULT 0, +dialed_modify TEXT NOT NULL DEFAULT '', +type INTEGER DEFAULT 0, +tz CHAR(40) NOT NULL DEFAULT '', +PRIMARY KEY (`number`), + KEY `pricelist` (`pricelist`), + KEY `reseller` (`reseller`) +); + +DROP TABLE IF EXISTS `counters`; +CREATE TABLE counters ( +id INTEGER NOT NULL AUTO_INCREMENT, +package CHAR(40) NOT NULL DEFAULT '', +account VARCHAR(50) NOT NULL, +seconds INTEGER NOT NULL DEFAULT 0, +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`) +); + +DROP TABLE IF EXISTS `callingcards`; +CREATE TABLE callingcards ( +id INTEGER NOT NULL AUTO_INCREMENT, +cardnumber CHAR(20) NOT NULL DEFAULT '', +language CHAR(10) NOT NULL DEFAULT '', +value INTEGER NOT NULL DEFAULT 0, +used INTEGER NOT NULL DEFAULT 0, +brand VARCHAR(20) NOT NULL DEFAULT '', +created DATETIME, +firstused DATETIME, +expiry DATETIME, +validfordays CHAR(4) NOT NULL DEFAULT '', +inuse INTEGER NOT NULL DEFAULT 0, +pin CHAR(20), +account VARCHAR(50) NOT NULL DEFAULT '', +maint_fee_pennies INTEGER NOT NULL DEFAULT 0, +maint_fee_days INTEGER NOT NULL DEFAULT 0, +maint_day INTEGER NOT NULL DEFAULT 0, +disconnect_fee_pennies INTEGER NOT NULL DEFAULT 0, +minute_fee_minutes INTEGER NOT NULL DEFAULT 0, +minute_fee_pennies INTEGER NOT NULL DEFAULT 0, +min_length_minutes INTEGER NOT NULL DEFAULT 0, +min_length_pennies INTEGER NOT NULL DEFAULT 0, +timeused INTEGER NOT NULL DEFAULT 0, +invoice CHAR(20) NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `brand` (`brand`) +); + +CREATE TABLE charge_to_account ( +id INTEGER NOT NULL AUTO_INCREMENT, +charge_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(50) NOT NULL DEFAULT '', +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`) +); + +CREATE TABLE queue_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +queue_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE pbx_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +pbx_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE extension_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +extension_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE cdrs ( +id INTEGER NOT NULL AUTO_INCREMENT, +uniqueid varchar(32) NOT NULL DEFAULT '', +cardnum CHAR(50), +callerid CHAR(80), +callednum varchar(80) NOT NULL DEFAULT '', +billseconds INT DEFAULT 0 NOT NULL, +trunk VARCHAR(30), +disposition varchar(45) NOT NULL DEFAULT '', +callstart varchar(80) NOT NULL DEFAULT '', +debit DECIMAL (20,6) NOT NULL DEFAULT 0, +credit DECIMAL (20,6) NOT NULL DEFAULT 0, +status INTEGER DEFAULT 0 NOT NULL, +notes CHAR(80), +provider CHAR(50), +cost DECIMAL(20,6) NOT NULL DEFAULT 0, +pricelist CHAR(80) NOT NULL DEFAULT '', +pattern CHAR(80) NOT NULL DEFAULT '', +PRIMARY KEY (`id`), + KEY `cardnum` (`cardnum`), + KEY `provider` (`provider`), + KEY `trunk` (`trunk`), + KEY `uniqueid` (`uniqueid`), + KEY `status` (`status`) +); + +CREATE TABLE packages ( +id INTEGER NOT NULL AUTO_INCREMENT, +name CHAR(40) NOT NULL DEFAULT '', +pricelist CHAR(40) NOT NULL DEFAULT '', +pattern CHAR(40) NOT NULL DEFAULT '', +includedseconds INTEGER NOT NULL DEFAULT 0, +reseller VARCHAR(50) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `pricelist` (`pricelist`), + KEY `reseller` (`reseller`) +); + +CREATE TABLE ani_map ( +number char(20) NOT NULL, +account char(50) NOT NULL default '', +status int(11) NOT NULL default '0', +context varchar(20) NOT NULL, + PRIMARY KEY (`number`), +KEY `account` (`account`) +); + +CREATE TABLE `ip_map` ( +ip char(15) NOT NULL default '', +account char(20) NOT NULL default '', +prefix varchar(20) NULL, +context varchar(20) NOT NULL, +PRIMARY KEY (`ip`,`prefix`), +KEY `account` (`account`) +); + +CREATE TABLE charges ( +id INTEGER NOT NULL AUTO_INCREMENT, +pricelist CHAR(40) NOT NULL DEFAULT '', +description VARCHAR(80) NOT NULL DEFAULT '', +charge INTEGER NOT NULL DEFAULT 0, +sweep INTEGER NOT NULL DEFAULT 0, +reseller CHAR(40) NOT NULL DEFAULT '', +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`), + KEY `pricelist` (`pricelist`) +); + +CREATE TABLE manager_action_variables ( +id INTEGER NOT NULL AUTO_INCREMENT, +name CHAR(60) NOT NULL DEFAULT '', +value CHAR(60) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE callingcard_stats ( +uniqueid VARCHAR(48) NOT NULL, +total_time VARCHAR(48) NOT NULL, +billable_time VARCHAR(48) NOT NULL, +timestamp DATETIME NULL, +PRIMARY KEY (`uniqueid`) +); + +CREATE TABLE system ( +name VARCHAR(48) NULL, +value VARCHAR(255) NULL, +comment VARCHAR(255) NULL, +timestamp DATETIME NULL, +reseller VARCHAR(48) NULL, +brand VARCHAR(48) NULL, +PRIMARY KEY (`name`), + KEY `reseller` (`reseller`), + KEY `brand` (`brand`) +); + + +INSERT INTO system (name, value, comment) VALUES ( +'callout_accountcode','admin','Call Files: What accountcode should we use?'); + +INSERT INTO system (name, value, comment) VALUES ( +'lcrcontext','astpp-outgoing','This is the Local context we use to route our outgoing calls through esp for callbacks'); + +INSERT INTO system (name, value, comment) VALUES ( +'maxretries','3','Call Files: How many times do we retry?'); + +INSERT INTO system (name, value, comment) VALUES ( +'retrytime','30','Call Files: How long do we wait between retries?'); + +INSERT INTO system (name, value, comment) VALUES ( +'waittime','15','Call Files: How long do we wait before the initial call?'); + +INSERT INTO system (name, value, comment) VALUES ( +'clidname','Private','Call Files: Outgoing CallerID Name'); + +INSERT INTO system (name, value, comment) VALUES ( +'clidnumber','0000000000','Call Files: Outgoing CallerID Number'); + +INSERT INTO system (name, value, comment) VALUES ( +'callingcards_callback_context','astpp-callingcards','Call Files: For callingcards what context do we end up in?'); + +INSERT INTO system (name, value, comment) VALUES ( +'callingcards_callback_extension', 's','Call Files: For callingcards what extension do we use?'); + +INSERT INTO system (name, value, comment) VALUES ( +'openser_dbengine', 'MySQL','For now this must be MySQL'); + +INSERT INTO system (name, value, comment) VALUES ( +'openser', '0','Use OPENSER? 1 for yes or 0 for no'); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbname', 'openser','OPENSER Database Name', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbuser', 'root','OPENSER Database User', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbhost', 'localhost','OPENSER Database Host', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbpass', 'Passw0rd','OPENSER Database Password', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_domain', NULL,'OPENSER Domain', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_email', 'em...@as...','Email address that email should appear to be from', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'asterisk_dir', '/etc/asterisk','Which directory are asterisk configuration files stored in?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_website', 'http://www.astpp.org','Link to your company website', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_name', 'ASTPP.ORG','The name of your company. Used in emails.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'email', '1','Send out email? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'user_email', '1','Email user on account changes? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'debug', '0','Enable debugging output? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'emailadd', 'em...@as...','Administrator email address', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'startingdigit', '0','The digit that all calling cards must start with. 0=disabled', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'enablelcr', '1','Use least cost routing 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'log_file', '/var/log/astpp/astpp.log','ASTPP Log file', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'key_home', 'http://www.astpp.org/astpp.pub','Asterisk RSA Key location (optional)', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rate_engine_csv_file', '/var/log/astpp/astpp.csv','CSV File for call rating data', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'csv_dir', '/var/log/astpp/','CSV File Directory', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_brand', 'default','Default pricelist. If a price is not found in the customers pricelist we check this one.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'new_user_brand', 'default','What is the default pricelist for new customers?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_context', 'custom-astpp','What is the default context for new devices?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cardlength', '10','Number of digits in calling cards and cc codes.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'asterisk_server', 'voip.astpp.org','Your default voip server. Used in outgoing email.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'currency', 'CAD','Name of the currency you use', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'iax_port', '4569','Default IAX2 Port', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'sip_port', '5060','Default SIP Port', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'ipaddr', 'dynamic','Default IP Address for new devices', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'key', 'astpp.pub','Asterisk RSA Key Name (Optional)', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'pinlength', '6','For those calling cards that are using pins this is the number of digits it will have.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'credit_limit', '0','Default credit limit in dollars.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'decimalpoints', '4','How many decimal points do we bill to?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'max_free_length', '100','What is the maximum length (in minutes) of calls that are at no charge?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'trackvendorcharges', '1','Do we track the amount of money we spend with specific providers? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_logo', 'http://www.astpp.org/logo.png','The location of our company logo.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_slogan', 'Welcome to ASTPP','Company slogan', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'version', '1.5Beta', 'ASTPP Version', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_language', 'en', 'Default ASTPP Language',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'card_retries','3', 'How many retries do we allow for calling card numbers?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'pin_retries','3', 'How many retries do we allow for pins?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'number_retries','3','How many retries do we allow calling card users when dialing a number?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'booth_context','callshop_booth','Please enter the default context for a callshop booth.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'callingcards_max_length','9000','What is the maximum length (in ms) of a callingcard call?',''); + +INSERT INTO system (name,value,comment,timestamp) VALUES ( +'template_die_on_bad_params','0','Should HTML::Template die on bad parameters?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'results_per_page','30','How many results per page do we should in the web interface?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astpp_dir','/var/lib/astpp','Where do the astpp configs live?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'auth','a23asudf9810-zalkj32423','This is the override authorization code and will allow access to the system.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_dbengine','MySQL','Database type for Asterisk(tm) -Realtime',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbengine','MySQL','Database type for the cdr database',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_dbengine','MySQL','Database type for OSCommerce',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_dbengine','MySQL','Database type for AgileBill(tm)',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_dbengine','MySQL','Database type for FreePBX',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'externalbill','oscommerce','Please specify the external billing application to use. If you are not using any then leave it blank. Valid options are "agile" and "oscommerce".',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'callingcards','1','Do you wish to enable calling cards? 1 for yes and 2 for no.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astcdr','1','Change this one at your own peril. If you switch it off, calls will not be marked as billed in asterisk once they are billed.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'posttoastpp','1','Change this one at your own peril. If you switch it off, calls will not be written to astpp when they are calculated.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'sleep','10','How long shall the rating engine sleep after it has been notified of a hangup? (in seconds)',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'users_dids_amp','0','If this is enabled, ASTPP will create users and DIDs in the FreePBX (www.freepbx.org) database.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'users_dids_rt','1','If this is enabled, ASTPP will create users and DIDs in the Asterisk Realtime database.',''); + +INSERT INTO system (name, value, comment) VALUES ( +'service_prepend','778',''); +INSERT INTO system (name, value, comment) VALUES ( +'service_length,','7',''); +INSERT INTO system (name, value, comment) VALUES ( +'service_filler','4110000',''); + +INSERT INTO system (name, value, comment) VALUES ( +'asterisk_cdr_table','cdr','Which table of the Asterisk(TM) database are the cdrs in?'); + +-- AgileBill(Trademark of AgileCo) Settings: +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_db','agile','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_pass','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_site_id','1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_charge_status','0','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_taxable','1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_dbprefix','_','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_service_prepend','778','',''); + +-- OSCommerce Settings (www.oscommerce.org) +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_db','oscommerce','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_pass','password','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_product_id','99999999','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_payment_method','"Charge"','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_order_status','1','',''); + +-- FreePBX Settings (www.freepbx.org) +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_db','asterisk','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_pass','passw0rd','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_table','iax','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_table','sip','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_extensions_table','extensions','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_codec_allow','g729,ulaw,alaw','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_codec_disallow','all','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_mailbox_group','default','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_nat','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_canreinvite','no','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_dtmfmode','rfc2833','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_callgroup','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_pickupgroup','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_notransfer','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_qualify','yes','',''); + +-- Asterisk -realtime Settings +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_db','realtime','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_pass','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_table','iax','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_table','sip','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_extensions_table','extensions','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_insecure','very','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_nat','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_canreinvite','no','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_codec_allow','g729,ulaw,alaw','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_codec_disallow','all','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_mailbox_group','default','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_type','friend','',''); +INSERT INTO system (name, value, comment) VALUES ( +'rt_voicemail_table','voicemail_users',''); + + +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_rate_announce','1','Do we want the calling cards script to announce the rate on calls?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_timelimit_announce','1','Do we want the calling cards script to announce the timelimit on calls?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_cancelled_prompt','1','Do we want the calling cards script to announce that the call was cancelled?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_menu','1','Do we want the calling cards script to present a menu before exiting?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_connection_prompt','1','Do we want the calling cards script to announce that it is connecting the call?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_pin_input_timeout','15000','How long do we wait when entering the calling card pin? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_number_input_timeout','15000','How long do we wait when entering the calling card number? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_dial_input_timeout','15000','How long do we wait when entering the destination number in calling cards? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_general_input_timeout','15000','How long do we wait for input in general menus? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_welcome_file','silence/1','What do we play for a welcome file?'); + +INSERT INTO system (name, value, comment) VALUES ( +'sip_ext_prepend','10','What should every autoadded SIP extension begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'iax2_ext_prepend','10','What should every autoadded IAX2 extension begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'cc_prepend','','What should every autoadded callingcard begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'pin_cc_prepend','','What should every autoadded callingcard pin begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'pin_act_prepend','','What should every autoadded account pin begin with?'); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_directory','/usr/local/freeswitch','What is the Freeswitch root directory?'); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_password','ClueCon','Freeswitch event socket password'); +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_host','localhost','Freeswitch event socket host'); +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_port','8021','Freeswitch event socket port'); +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_timeout','30','Freeswitch seconds to expect a heartbeat event or reconnect'); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freeswitch_dbname', 'freeswitch','Freeswitch Database Name', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freeswitch_dbuser', 'root','Freeswitch Database User', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freeswitch_dbhost', 'localhost','Freeswitch Database Host', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freeswitch_dbpass', 'Passw0rd','Freeswitch Database Password', ''); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_cdr_table','fscdr','Which table of the cdr database are the Freeswitch cdrs in?'); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbname', 'asteriskcdrdb', +'CDR Database Name', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbuser', 'root', +'CDR Database User', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbhost', 'localhost', +'CDR Database Host', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbpass', 'Passw0rd', +'CDR Database Password', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astman_user', 'admin','Asterisk(tm) Manager Interface User', ''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astman_host', 'localhost','Asterisk(tm) Manager Interface Host', ''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astman_secret', 'amp111','Asterisk(tm) Manager Interface Secret', ''); + + +-- +-- Enough Configuration settings +-- + +DROP TABLE IF EXISTS `countrycode`; +CREATE TABLE `countrycode` ( + `country` varchar(255) NOT NULL, + PRIMARY KEY (`country`), + KEY `country` (`country`) +); + +INSERT INTO `countrycode` (`country`) VALUES + ('Afghanistan'), + ('Alaska'), + ('Albania'), + ('Algeria'), + ('AmericanSamoa'), + ('Andorra'), + ('Angola'), + ('Antarctica'), + ('Argentina'), + ('Armenia'), + ('Aruba'), + ('Ascension'), + ('Australia'), + ('Austria'), + ('Azerbaijan'), + ('Bahrain'), + ('Bangladesh'), + ('Belarus'), + ('Belgium'), + ('Belize'), + ('Benin'), + ('Bhutan'), + ('Bolivia'), + ('Bosnia & Herzegovina'), + ('Botswana'), + ('Brazil'), + ('Brunei Darussalam'), + ('Bulgaria'), + ('Burkina Faso'), + ('Burundi'), + ('Cambodia'), + ('Cameroon'), + ('Canadda'), + ('Cape Verde Islands'), + ('Central African Republic'), + ('Chad'), + ('Chile'), + ('China'), + ('Colombia'), + ('Comoros'), + ('Congo'), + ('Cook Islands'), + ('Costa Rica'), + ('Croatia'), + ('Cuba'), + ('Cuba Guantanamo Bay'), + ('Cyprus'), + ('Czech Republic'), + ('Denmark'), + ('Diego Garcia'), + ('Djibouti'), + ('Dominican Republic'), + ('East Timor'), + ('Ecuador'), + ('Egypt'), + ('El Salvador'), + ('Equatorial Guinea'), + ('Eritrea'), + ('Estonia'), + ('Ethiopia'), + ('Faroe Islands'); +INSERT INTO `countrycode` (`country`) VALUES + ('Fiji Islands'), + ('Finland'), + ('France'), + ('French Guiana'), + ('French Polynesia'), + ('Gabonese Republic'), + ('Gambia'), + ('Georgia'), + ('Germany'), + ('Ghana'), + ('Gibraltar'), + ('Greece'), + ('Greenland'), + ('Guadeloupe'), + ('Guam'), + ('Guatemala'), + ('Guinea'), + ('Guyana'), + ('Haiti'), + ('Honduras'), + ('Hong Kong'), + ('Hungary'), + ('Iceland'), + ('India'), + ('Indonesia'), + ('Iran'), + ('Iraq'), + ('Ireland'), + ('Israel'), + ('Italy'), + ('Jamaica'), + ('Japan'), + ('Jordan'), + ('Kazakstan'), + ('Kenya'), + ('Kiribati'), + ('Kuwait'), + ('Kyrgyz Republic'), + ('Laos'), + ('Latvia'), + ('Lebanon'), + ('Lesotho'), + ('Liberia'), + ('Libya'), + ('Liechtenstein'), + ('Lithuania'), + ('Luxembourg'), + ('Macao'), + ('Madagascar'), + ('Malawi'), + ('Malaysia'), + ('Maldives'), + ('Mali Republic'), + ('Malta'), + ('Marshall Islands'), + ('Martinique'), + ('Mauritania'), + ('Mauritius'), + ('MayotteIsland'), + ('Mexico'), + ('Midway Islands'), + ('Moldova'), + ('Monaco'), + ('Mongolia'), + ('Morocco'); +INSERT INTO `countrycode` (`country`) VALUES + ('Mozambique'), + ('Myanmar'), + ('Namibia'), + ('Nauru'), + ('Nepal'), + ('Netherlands'), + ('Netherlands Antilles'), + ('New Caledonia'), + ('New Zealand'), + ('Nicaragua'), + ('Niger'), + ('Nigeria'), + ('Niue'), + ('Norfolk Island'), + ('North Korea'), + ('Norway'), + ('Oman'), + ('Pakistan'), + ('Palau'), + ('Palestinian Settlements'), + ('Panama'), + ('PapuaNew Guinea'), + ('Paraguay'), + ('Peru'), + ('Philippines'), + ('Poland'), + ('Portugal'), + ('Puerto Rico'), + ('Qatar'), + ('RéunionIsland'), + ('Romania'), + ('Russia'), + ('Rwandese Republic'), + ('San Marino'), + ('São Tomé and Principe'), + ('Saudi Arabia'), + ('Senegal '), + ('Serbia and Montenegro'), + ('Seychelles Republic'), + ('Sierra Leone'), + ('Singapore'), + ('Slovak Republic'), + ('Slovenia'), + ('Solomon Islands'), + ('Somali Democratic Republic'), + ('South Africa'), + ('South Korea'), + ('Spain'), + ('Sri Lanka'), + ('St Kitts - Nevis'), + ('St. Helena'), + ('St. Lucia'), + ('St. Pierre & Miquelon'), + ('St. Vincent & Grenadines'), + ('Sudan'); +INSERT INTO `countrycode` (`country`) VALUES + ('Suriname'), + ('Swaziland'), + ('Sweden'), + ('Switzerland'), + ('Syria'), + ('Taiwan'), + ('Tajikistan'), + ('Tanzania'), + ('Thailand'), + ('Togolese Republic'), + ('Tokelau'), + ('Tonga Islands'), + ('Trinidad & Tobago'), + ('Tunisia'), + ('Turkey'), + ('Turkmenistan'), + ('Tuvalu'), + ('Uganda'), + ('Ukraine'), + ('United Arab Emirates'), + ('United Kingdom'), + ('United States of America'), + ('Uruguay'), + ('Uzbekistan'), + ('Vanuatu'), + ('Venezuela'), + ('Vietnam'), + ('Wake Island'), + ('Wallisand Futuna Islands'), + ('Western Samoa'), + ('Yemen'), + ('Zambia'), + ('Zimbabwe'); + +DROP TABLE IF EXISTS `currency`; +CREATE TABLE `currency` ( + `Currency` varchar(3) NOT NULL default '', + `CurrencyName` varchar(40) NOT NULL default '', + PRIMARY KEY (`Currency`) +); + +INSERT INTO `currency` (`Currency`,`CurrencyName`) VALUES + ('USD','US Dollars'), + ('CAD','Canadian Dollars'), + ('AUD','Australian Dollars'); + +CREATE TABLE `language` ( + `language` varchar(5) NOT NULL, + `languagename` varchar(40) NOT NULL, + `active` tinyint(1) NOT NULL default '1', + PRIMARY KEY (`language`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +INSERT INTO `language` (`language`,`languagename`,`active`) VALUES + ('en','English',1), + ('fr','French',1), + ('de','German',1); + +CREATE TABLE `resellers` ( + name varchar(40) NOT NULL default '', + status int(11) NOT NULL default '1', + posttoexternal int(11) NOT NULL default '0', + agile_site_id int(11) NOT NULL default '0', + config_file char(80) NOT NULL default 'reseller.conf', + companyname varchar(255) default NULL, + slogan varchar(255) default NULL, + footer varchar(255) default NULL, + pricelist varchar(255) default NULL, + currency varchar(255) default NULL, + logo varchar(255) default NULL, + website varchar(255) default NULL, + adminemail varchar(255) default NULL, + salesemail varchar(255) default NULL, + phone varchar(45) default NULL, + fax varchar(45) default NULL, + address1 varchar(255) default NULL, + address2 varchar(255) default NULL, + city varchar(255) default NULL, + state varchar(255) default NULL, + postcode varchar(255) default NULL, + country varchar(255) default NULL, + defaultbrand varchar(45) NOT NULL default 'default', + defaultcurrency varchar(45) NOT NULL default 'USD', + defaultcredit varchar(45) NOT NULL default '0.00', + externalbill varchar(45) NOT NULL default '', + PRIMARY KEY (`name`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + +CREATE TABLE templates ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(45) NOT NULL default '', +reseller VARCHAR(45) NOT NULL default '', +template TEXT NOT NULL default '', + PRIMARY KEY (`id`), + KEY `reseller` (`reseller`) +); + +INSERT INTO templates (name,template) VALUES +('voip_account_refilled','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been refilled. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('voip_reactivate_account','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been reactivated. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_add_user','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been added. +Your Username is -- $vars->{extension} -- +Your Password is -- $vars->{secret} -- +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('add_sip_device','Attention: $vars->{title} $vars->{first} $vars->{last} +A new device has been enabled on your account. Here +is the necessary configuration information. +------- $config->{company_name} Configuration Info -------- +In sip.conf: +[$config->{company_name}-in] +type=user +username=$config->{company_name}-in +auth=rsa +inkeys=$config->{key} ;This key may be downloaded from $config->{key_home} +host=$config->{asterisk_server} +context=from-pstn +accountcode=$config->{company_name} +[$config->{company_name}] +type=peer +username=$vars->{extension} +secret=$vars->{secret} +host=$config->{asterisk_server} +callerid= <555-555-5555> +qualify=yes +accountcode=$config->{company_name} ; for call tracking in the cdr +In the [globals] section add: +register => $vars->{user}:password@$config->{asterisk_server}'); + +INSERT INTO templates (name,template) VALUES +('add_iax_device','Attention: $vars->{title} $vars->{first} $vars->{last} +A new device has been enabled on your account. Here +is the necessary configuration information. +------- $config->{company_name} Configuration Info -------- +In iax.conf: +At the bottom of the file add: +[$config->{company_name}-in] +;trunk=yes ;optional .. only works if you have a zaptel or ztdummy driver running +type=user +username=$config->{company_name}-in +auth=rsa +inkeys=$config->{key} ;This key may be downloaded from $config->{key_home} +host=$config->{asterisk_server} +context=incoming +accountcode=$config->{company_name} ;for call tracking in the cdr +[$config->{company_name}] +;to simplify and config outgoing calls +;trunk=yes ;optional .. only works if you have a zaptel driver running +type=peer +username=$vars->{extension} +secret=$vars->{secret} +host=$config->{asterisk_server} +callerid=<555-555-5555> ;only the number will really be used +qualify=yes +accountcode=$config->{company_name} ; for call tracking in the cdr +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_remove_user','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP Termination with $config->{company_name} has been removed +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_calling_card','You have added a $vars->{pricelist} callingcard in the amount of $vars->{pennies} cents. +Card Number $cc Pin: $pin +Thanks for your patronage. +The $config->{company_name} sales team'); + +INSERT INTO templates (name,template) VALUES +('email_add_did','Attention: $vars->{title} $vars->{first} $vars->{last} +Your DID with $config->{company_name} has been added +The number is: $did +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team +Here is a sample setup which would call a few sip phones with incoming calls: +[incoming] +exten => _1$did,1,Wait(2) +exten => _1$did,2,Dial(SIP/2201&SIP/2202,15,Ttm) ; dial a couple of phones for 15 secs +exten => _1$did,3,Voicemail(u1000) ; go to unavailable voicemail (vm box 1000) +exten => _1$did,103,Voicemail(b1000) ; go to busy voicemail (vm box 1000)'); + +INSERT INTO templates (name,template) VALUES +('email_remove_did','Attention: $vars->{title} $vars->{first} $vars->{last} +Your DID with $config->{company_name} has been removed +The number was: $did +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_new_invoice','Invoice # $invoice in the amount of \$$total has been added to your account. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_low_balance','Your VOIP account with $config->{company_name} has a balance of \$$balance. +Please visit our website to refill your account to ensure uninterrupted service. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +CREATE TABLE `sweeplist` ( + `Id` int(10) unsigned NOT NULL default '0', + `sweep` varchar(45) NOT NULL default '', + PRIMARY KEY (`Id`) +); + +INSERT INTO sweeplist (Id,sweep) VALUES +(0,'daily'), +(1,'weekly'), +(2,'monthly'), +(3,'quarterly'), +(4,'semi-annually'), +(5,'annually') +; + +CREATE TABLE userlevels ( +userlevelid int(11) NOT NULL, +userlevelname varchar(50) NOT NULL, +PRIMARY KEY (`userlevelid`) +); + +INSERT INTO `userlevels` (`userlevelid`,`userlevelname`) VALUES + (-1,'Administrator'), + (0,'Anonymous'), + (1,'Reseller'), + (2,'Admin'), + (3,'Vendor'), + (4,'Customer Service'), + (5,'Users'); + +CREATE TABLE reseller_pricing ( +id INTEGER NOT NULL AUTO_INCREMENT, +reseller VARCHAR(50) NOT NULL, +type INTEGER NOT NULL DEFAULT 1, +monthlycost INTEGER NOT NULL DEFAULT 0, +prorate INTEGER NOT NULL DEFAULT 0, +setup INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +connectcost INTEGER NOT NULL DEFAULT ... [truncated message content] |
From: <dar...@us...> - 2008-11-11 19:05:47
|
Revision: 2204 http://astpp.svn.sourceforge.net/astpp/?rev=2204&view=rev Author: darrenkw Date: 2008-11-11 19:05:42 +0000 (Tue, 11 Nov 2008) Log Message: ----------- Added support to view and delete Freeswitch SIP users from within the interface. Modified Paths: -------------- trunk/astpp-admin.cgi trunk/astpp-common.pl trunk/astpp-users.cgi trunk/modules/ASTPP/lib/ASTPP.pm Added Paths: ----------- trunk/sql/astpp-2008-10-31.sql Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2008-11-08 04:36:02 UTC (rev 2203) +++ trunk/astpp-admin.cgi 2008-11-11 19:05:42 UTC (rev 2204) @@ -99,8 +99,7 @@ gettext("View Card"), gettext("Update Card(s) Status"), gettext("Reset InUse"), gettext("CC Brands") ); -my @SwitchConfig = - ( gettext("IAX Devices"), gettext("SIP Devices"), gettext("Dialplan") ); +my @SwitchConfig = (); my @CallShops = ( gettext("Create CallShop"), gettext("Remove CallShop") ); my @Booths = ( gettext("Create Booth"), gettext("Remove Booth"), @@ -398,11 +397,13 @@ return &build_refill_card() if $params->{mode} eq gettext("Refill Card"); return &build_sip_devices() - if $params->{mode} eq gettext("SIP Devices"); + if $params->{mode} eq gettext("Asterisk(TM) SIP Devices"); return &build_iax_devices() - if $params->{mode} eq gettext("IAX Devices"); + if $params->{mode} eq gettext("Asterisk(TM) IAX Devices"); return &build_dialplan() - if $params->{mode} eq gettext("Dialplan"); + if $params->{mode} eq gettext("Asterisk(TM) Dialplan"); + return &build_freeswitch_sip_devices() + if $params->{mode} eq gettext("Freeswitch(TM) SIP Devices"); return &build_stats_acd() if $params->{mode} eq gettext("Trunk stats"); return &build_stats_acd() @@ -462,9 +463,9 @@ return &build_dids() if $params->{mode} eq gettext("DIDs"); return &build_sip_devices() - if $params->{mode} eq gettext("SIP Devices"); + if $params->{mode} eq gettext("Asterisk(TM) SIP Devices"); return &build_iax_devices() - if $params->{mode} eq gettext("IAX Devices"); + if $params->{mode} eq gettext("Asterisk(TM) IAX Devices"); return &build_packages() if $params->{mode} eq gettext("Packages"); return &build_counters() if $params->{mode} eq gettext("Counters"); return &build_statistics() @@ -1942,6 +1943,21 @@ push(@account_device_list, \%row); } } + if ($fs_db) { + my (@sip_devices); + @sip_devices = $ASTPP->fs_list_sip_usernames( cc => $accountinfo->{cc}, accountcode => $accountinfo->{number}); + foreach my $record (@sip_devices) { + print STDERR $record->{username}; + my $deviceinfo = &get_sip_account_freeswitch($fs_db,$config,$record->{id}); + my %row; + $row{tech} = "SIP"; + $row{type} = "user@" . $record->{domain}; + $row{username} = $record->{username}; + $row{secret} = $deviceinfo->{password}; + $row{context} = $deviceinfo->{context}; + push(@account_device_list, \%row); + } + } if ($freepbx_db) { my @sip_names = &list_sip_account_freepbx($freepbx_db,$config,$accountinfo->{number}, $accountinfo->{cc}); my @iax_names = &list_iax_account_freepbx($freepbx_db,$config,$accountinfo->{number}, $accountinfo->{cc}); @@ -2267,6 +2283,18 @@ ); $status .= "<br>"; } + if ( $config->{users_dids_freeswitch} == 1 ) { + my $name = + &finduniquesip_freeswitch( $fs_db, $config, + $params->{number} ); + $status .= &add_sip_user_freeswitch( + $fs_db, $config, $name, + $params->{accountpassword}, + $params->{number}, $params, + $accountinfo->{cc} + ); + $status .= "<br>"; + } } if ( $params->{IAX2} ) { $config->{rt_iax_type} = $params->{devicetype}; @@ -8389,7 +8417,7 @@ { $body .= "</td><td><a href=\"astpp-admin.cgi?mode=" - . gettext("SIP Devices") + . gettext("Asterisk(TM) SIP Devices") . "&action=" . gettext("Edit...") . "&devicenumber=" @@ -9291,11 +9319,15 @@ } if ( $config->{users_dids_rt} == 1 ) { $rt_db = &rt_connect_db( $config, @output ); - push @modes, gettext("Switch Config"); } if ( $config->{users_dids_amp} == 1 ) { $freepbx_db = &freepbx_connect_db( $config, @output ); } + if ( $config->{users_dids_freeswitch} == 1 ) { + $fs_db = &connect_freeswitch_db( $config, @output ); + $ASTPP->set_freeswitch_db($fs_db); + } + if ( $config->{callingcards} == 1 ) { push @modes, gettext("Calling Cards"); } @@ -9305,6 +9337,38 @@ $ASTPP->set_cdr_db($cdr_db); } + +############### Freeswitch SIP Device handling ############################## +sub build_freeswitch_sip_devices(){ + return gettext("Database is NOT configured!") . "\n" unless $astpp_db; + my (@device_list,@sip_devices); + my $template = HTML::Template->new( + filename => '/var/lib/astpp/templates/freeswitch-sip-list.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); + if ($params->{action} eq "Delete...") { + $ASTPP->fs_delete_sip_user(id => $params->{directory_id} ); + $status = gettext("SIP Device:") . " " . $params->{directory_id} . " " . gettext("Removed Successfully!"); + } + + @sip_devices = $ASTPP->fs_list_sip_usernames(); + foreach my $record (@sip_devices) { + my $deviceinfo = &get_sip_account_freeswitch($fs_db,$config,$record->{id}); + my %row; + $row{directory_id} = $record->{id}; + $row{tech} = "SIP"; + $row{type} = "user@" . $record->{domain}; + $row{username} = $record->{username}; + $row{password} = $deviceinfo->{password}; + $row{vmpassword} = $deviceinfo->{vmpassword}; + $row{context} = $deviceinfo->{context}; + $row{accountcode} = $deviceinfo->{accountcode}; + push(@device_list, \%row); + } + $template->param( device_list => \@device_list ); + $template->param( status => $status ); + return $template->output; +} + + ############### Integration with Realtime starts here ####################### sub build_sip_devices() { my ( @@ -9425,7 +9489,7 @@ . "</td><td>" . gettext("IP Address") . "</td><td>" - . hidden( -name => "mode", -value => gettext("SIP Devices") ) + . hidden( -name => "mode", -value => gettext("Asterisk(TM) SIP Devices") ) . "</td></tr> <tr class=\"rowone\"><td>" . popup_menu( @@ -9498,7 +9562,7 @@ . "</td><td>" . gettext("Host") . "</td><td>" - . hidden( -name => "mode", -value => gettext("SIP Devices") ) + . hidden( -name => "mode", -value => gettext("Asterisk(TM) SIP Devices") ) . hidden( -name => "devicenumber", -value => $deviceinfo->{id} @@ -9638,7 +9702,7 @@ $body = start_form . "<table class=\"default\">" . "<tr class=\"header\"><td>" - . hidden( -name => "mode", -value => gettext("SIP Devices") ) + . hidden( -name => "mode", -value => gettext("Asterisk(TM) SIP Devices") ) . submit( -name => "action", -value => gettext("Add...") ) . "</td></tr> " @@ -9702,14 +9766,14 @@ . "</td><td>$deviceinfo->{type}" . "</td><td>$deviceinfo->{secret}" . "</td><td><a href=\"astpp-admin.cgi?mode=" - . gettext("SIP Devices") + . gettext("Asterisk(TM) SIP Devices") . "&action=" . gettext("Edit...") . "&devicename=" . $deviceinfo->{name} . "\">" . gettext("Edit...") . "</a>" . " <a href=\"astpp-admin.cgi?mode=" - . gettext("SIP Devices") + . gettext("Asterisk(TM) SIP Devices") . "&action=" . gettext("Delete...") . "&devicename=" @@ -9725,7 +9789,7 @@ if ( $params->{limit} != 0 ) { $body .= "<a href=\"astpp-admin.cgi?mode=" - . gettext("SIP Devices") + . gettext("Asterisk(TM) SIP Devices") . "&limit=0\">"; $body .= $i + 1; $body .= "</a>"; @@ -9738,7 +9802,7 @@ if ( $params->{limit} != ( $i * $results_per_page ) ) { $body .= "<a href=\"astpp-admin.cgi?mode=" - . gettext("SIP Devices") + . gettext("Asterisk(TM) SIP Devices") . "&limit="; $body .= ( $i * $results_per_page ); $body .= "\">\n"; @@ -9889,7 +9953,7 @@ . "</td><td>" . gettext("IP Address") . "</td><td>" - . hidden( -name => "mode", -value => gettext("IAX Devices") ) + . hidden( -name => "mode", -value => gettext("Asterisk(TM) IAX Devices") ) . "</td></tr> <tr class=\"rowone\"><td>" . popup_menu( @@ -9962,7 +10026,7 @@ . "</td><td>" . gettext("Host") . "</td><td>" - . hidden( -name => "mode", -value => gettext("IAX Devices") ) + . hidden( -name => "mode", -value => gettext("Asterisk(TM) IAX Devices") ) . hidden( -name => "devicenumber", -value => $deviceinfo->{name} @@ -10070,7 +10134,7 @@ $body = start_form . "<table class=\"default\">" . "<tr class=\"header\"><td>" - . hidden( -name => "mode", -value => gettext("IAX Devices") ) + . hidden( -name => "mode", -value => gettext("Asterisk(TM) IAX Devices") ) . submit( -name => "action", -value => gettext("Add...") ) . "</td></tr> " @@ -10131,14 +10195,14 @@ . "</td><td>$deviceinfo->{type}" . "</td><td>$deviceinfo->{secret}" . "</td><td><a href=\"astpp-admin.cgi?mode=" - . gettext("IAX Devices") + . gettext("Asterisk(TM) IAX Devices") . "&action=" . gettext("Edit...") . "&devicename=" . $deviceinfo->{name} . "\">" . gettext("Edit...") . "</a>" . " <a href=\"astpp-admin.cgi?mode=" - . gettext("IAX Devices") + . gettext("Asterisk(TM) IAX Devices") . "&action=" . gettext("Delete...") . "&devicename=" @@ -10154,7 +10218,7 @@ if ( $params->{limit} != 0 ) { $body .= "<a href=\"astpp-admin.cgi?mode=" - . gettext("IAX Devices") + . gettext("Asterisk(TM) IAX Devices") . "&limit=0\">"; $body .= $i + 1; $body .= "</a>"; @@ -10167,7 +10231,7 @@ if ( $params->{limit} != ( $i * $results_per_page ) ) { $body .= "<a href=\"astpp-admin.cgi?mode=" - . gettext("IAX Devices") + . gettext("Asterisk(TM) IAX Devices") . "&limit="; $body .= ( $i * $results_per_page ); $body .= "\">\n"; @@ -10300,7 +10364,7 @@ . "</td><td>" . gettext("App Data") . "</td><td>" - . hidden( -name => "mode", -value => gettext("Dialplan") ) + . hidden( -name => "mode", -value => gettext("Asterisk(TM) Dialplan") ) . "<td></tr> <tr class=\"rowone\"><td>" . textfield( @@ -10360,7 +10424,7 @@ . "</td><td>" . gettext("App Data") . "</td><td>" - . hidden( -name => "mode", -value => gettext("Dialplan") ) + . hidden( -name => "mode", -value => gettext("Asterisk(TM) Dialplan") ) . hidden( -name => "id", -value => $params->{id} @@ -10409,7 +10473,7 @@ $body = start_form . "<table class=\"default\">" . "<tr class=\"header\"><td>" - . hidden( -name => "mode", -value => gettext("Dialplan") ) + . hidden( -name => "mode", -value => gettext("Asterisk(TM) Dialplan") ) . submit( -name => "action", -value => gettext("Add...") ) . "</td></tr> " @@ -10464,13 +10528,13 @@ . "</td><td>$exteninfo->{app}" . "</td><td>$exteninfo->{appdata}" . "</td><td><a href=\"astpp-admin.cgi?mode=" - . gettext("Dialplan") + . gettext("Asterisk(TM) Dialplan") . "&action=" . gettext("Edit...") . "&id=" . $exteninfo->{id} . "\">" . gettext("Edit...") . "</a>" . " <a href=\"astpp-admin.cgi?mode=" - . gettext("Dialplan") + . gettext("Asterisk(TM) Dialplan") . "&action=" . gettext("Delete...") . "&id=" . $exteninfo->{id} . "\">" @@ -10485,7 +10549,7 @@ if ( $params->{limit} != 0 ) { $body .= "<a href=\"astpp-admin.cgi?mode=" - . gettext("Dialplan") + . gettext("Asterisk(TM) Dialplan") . "&limit=0\">"; $body .= $i + 1; $body .= "</a>"; @@ -10498,7 +10562,7 @@ if ( $params->{limit} != ( $i * $results_per_page ) ) { $body .= "<a href=\"astpp-admin.cgi?mode=" - . gettext("Dialplan") + . gettext("Asterisk(TM) Dialplan") . "&limit="; $body .= ( $i * $results_per_page ); $body .= "\">\n"; @@ -11305,8 +11369,14 @@ if ( $config->{enablelcr} == 1 ) { push @modes, gettext("LCR"); } - if ( $config->{users_dids_rt} == 1 ) { + if ( $config->{users_dids_rt} == 1 || $config->{users_dids_freeswitch} == 1 ) { push @modes, gettext("Switch Config"); + if ( $config->{users_dids_rt} == 1 ) { + push @SwitchConfig, ( gettext("Asterisk(TM) IAX Devices"), gettext("Asterisk(TM) SIP Devices"), gettext("Asterisk(TM) Dialplan") ); + } + if ( $config->{users_dids_freeswitch} == 1 ) { + push @SwitchConfig, ( gettext("Freeswitch(TM) SIP Devices") ); + } } if ( $config->{callingcards} == 1 ) { push @modes, gettext("Calling Cards"); Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2008-11-08 04:36:02 UTC (rev 2203) +++ trunk/astpp-common.pl 2008-11-11 19:05:42 UTC (rev 2204) @@ -2656,6 +2656,162 @@ } ####### OpenSER Integration Ends ############### +####### Freeswitch Integration Starts ############### + +sub get_sip_account_freeswitch(){ + my ($fs_db,$config,$directory_id) = @_; + my ($tmp,$record,$sql,$deviceinfo); + $tmp = "SELECT var_value FROM directory_vars WHERE directory_id = " + . $fs_db->quote($directory_id) + . " AND var_name = 'user_context'"; + print STDERR "$tmp\n" if $config->{debug} == 1; + $sql = $fs_db->prepare($tmp); + $sql->execute; + $record = $sql->fetchrow_hashref; + $sql->finish; + $deviceinfo->{context} = $record->{var_value}; + + $tmp = "SELECT param_value FROM directory_params WHERE directory_id = " + . $fs_db->quote($directory_id) + . " AND param_name = 'password' LIMIT 1"; + print STDERR "$tmp\n" if $config->{debug} == 1; + $sql = $fs_db->prepare($tmp); + $sql->execute; + $record = $sql->fetchrow_hashref; + $sql->finish; + $deviceinfo->{password} = $record->{param_value}; + + $tmp = "SELECT param_value FROM directory_params WHERE directory_id = " + . $fs_db->quote($directory_id) + . " AND param_name = 'vm-password' LIMIT 1"; + print STDERR "$tmp\n" if $config->{debug} == 1; + $sql = $fs_db->prepare($tmp); + $sql->execute; + $record = $sql->fetchrow_hashref; + $sql->finish; + $deviceinfo->{vmpassword} = $record->{param_value}; + + $tmp = "SELECT var_value FROM directory_vars WHERE directory_id = " + . $fs_db->quote($directory_id) + . " AND var_name = 'accountcode' LIMIT 1"; + print STDERR "$tmp\n" if $config->{debug} == 1; + $sql = $fs_db->prepare($tmp); + $sql->execute; + $record = $sql->fetchrow_hashref; + $sql->finish; + $deviceinfo->{accountcode} = $record->{var_value}; + + + return $deviceinfo; +} + + +# Return a list of sip devices belong to a specific account +sub list_sip_account_freeswitch() { + my ( $fs_db, $config, $name, $cc) = @_; + my ($tmp, $row, $sql, @devicelist); + if ($config->{debug} == 1) { + print STDERR "NAME: $name"; + print STDERR "CC: $cc"; + } + $tmp = "select directory_id from directory_vars where var_name = 'accountcode' and var_value IN (" + . $fs_db->quote($name) . "," + . $fs_db->quote($cc) . ")"; + print STDERR "$tmp\n" if $config->{debug} == 1; + $sql = $fs_db->prepare($tmp); + $sql->execute; + while ( $row = $sql->fetchrow_hashref ) { + push @devicelist, $row->{directory_id}; + } + $sql->finish; + return @devicelist; +} + +# Check to see if a SIP account already exists in ATSPP. The first 5 digits of the device ID are random followed by a dash +# and then the accountcode. +sub finduniquesip_freeswitch() { + my ($fs_db, $config, $name) = @_; + my ( $cc, $sql, $count, $sipid, $record ); + for ( ; ; ) { + $count = 1; + $sipid = + int( rand() * 9000 + 1000 ) + . int( rand() * 9000 + 1000 ) + . int( rand() * 9000 + 1000 ) + . int( rand() * 9000 + 1000 ) + . int( rand() * 9000 + 1000 ) + . int( rand() * 9000 + 1000 ) + . int( rand() * 9000 + 1000 ) + . int( rand() * 9000 + 1000 ); + $sipid = $config->{sip_ext_prepend} . $sipid; + $sipid = substr( $sipid, 0, 5 ); + $sipid = $name . $sipid; + print STDERR "SIPID: $sipid\n" if $config->{debug} == 1; + $sql = + $fs_db->prepare( + "SELECT COUNT(*) FROM directory WHERE username = " + . $fs_db->quote($sipid) ); + $sql->execute; + $record = $sql->fetchrow_hashref; + $count = $record->{"COUNT(*)"}; + $sql->finish; + return $sipid if ( $count == 0 ); + } +} + + +# Add a SIP user to the FreeSwitch DB. +sub add_sip_user_freeswitch() { + my ( $fs_db, $config, $name, $secret, $username, + $params,$cc ) + = @_; + my ( $md5secret, $tmp, $id, $appdata ); + $name =~ s/\W//mg; + $username =~ s/\W//mg; + if ( $config->{debug} == 1 ) { + print STDERR "NAME: $name\n"; + print STDERR "USERNAME: $username\n"; + print STDERR "SECRET: $secret\n"; + } + $tmp = + "INSERT INTO directory (username,domain) VALUES (" + . $fs_db->quote($name) . ", " + . $fs_db->quote($config->{freeswitch_domain}). ")"; + if ( $config->{debug} == 1 ) { + print STDERR " $tmp \n"; + } + my $sql = $fs_db->prepare($tmp); + if ( !$sql->execute ) { + print "$tmp failed"; + return gettext("SIP Device Creation Failed!"); + } + else { + my $directory_id = $sql->{'mysql_insertid'}; + $fs_db->do("INSERT INTO directory_vars (directory_id,var_name,var_value) VALUES (" + . $fs_db->quote($directory_id) . "," + . "'accountcode'," + . $fs_db->quote($username) . ")"); + + $fs_db->do("INSERT INTO directory_vars (directory_id,var_name,var_value) VALUES (" + . $fs_db->quote($directory_id) . "," + . "'user_context'," + . $fs_db->quote($config->{freeswitch_context}) . ")"); + + $fs_db->do("INSERT INTO directory_params (directory_id,param_name,param_value) VALUES (" + . $fs_db->quote($directory_id) . "," + . "'vm-password'," + . $fs_db->quote($secret) . ")"); + + $fs_db->do("INSERT INTO directory_params (directory_id,param_name,param_value) VALUES (" + . $fs_db->quote($directory_id) . "," + . "'password'," + . $fs_db->quote($secret) . ")"); + + return gettext("SIP Device Added!") . gettext("Username:") . " " . $name . " " . gettext("Password:") . " " . $secret; + } +} + +####### Freeswitch Integration ends ############### ####### FreePBX subroutines start here ########### sub get_iax_account_freepbx(){ Modified: trunk/astpp-users.cgi =================================================================== --- trunk/astpp-users.cgi 2008-11-08 04:36:02 UTC (rev 2203) +++ trunk/astpp-users.cgi 2008-11-11 19:05:42 UTC (rev 2204) @@ -175,17 +175,15 @@ sub build_callback() { my ( $body, $pstn, $voip ); if ( $params->{action} eq gettext("Place Call") ) { - - # my $out = new Asterisk::Outgoing; - # $out->setvariable( "Channel", "$channel" ); - # $out->setvariable( "MaxRetries", "0" ); - # $out->setvariable( "context", "$context" ); - # $out->setvariable( "extension", "$extension" ); - # $out->setvariable( "CallerID", "$outgoingclid $clidnumber" ); - # $out->setvariable( "Account", "$params->{username}" ); - # $out->outtime( time() + 15 ); - # $out->create_outgoing; - # $AGI->stream_file("callback-confirmed"); + my $out = new Asterisk::Outgoing; + $out->setvariable( "Channel", "$channel" ); + $out->setvariable( "MaxRetries", "0" ); + $out->setvariable( "context", "$context" ); + $out->setvariable( "extension", "$extension" ); + $out->setvariable( "CallerID", "$outgoingclid $clidnumber" ); + $out->setvariable( "Account", "$params->{username}" ); + $out->outtime( time() + 15 ); + $out->create_outgoing; } $voip = gettext("VOIP Route"); $pstn = gettext("PSTN Route"); Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2008-11-08 04:36:02 UTC (rev 2203) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2008-11-11 19:05:42 UTC (rev 2204) @@ -193,6 +193,97 @@ return $arg{xml}; } +sub fs_delete_sip_user +#Delete the SIP user +#id = directory.id to delete +{ + my ($self, %arg) = @_; + my ($tmp,$sql,@results); + $tmp = "DELETE FROM directory WHERE id = " . $self->{_freeswitch_db}->quote($arg{id}); + $self->{_freeswitch_db}->do($tmp); + $tmp = "DELETE FROM directory_vars WHERE directory_id = " . $self->{_freeswitch_db}->quote($arg{id}); + $self->{_freeswitch_db}->do($tmp); + $tmp = "DELETE FROM directory_params WHERE directory_id = " . $self->{_freeswitch_db}->quote($arg{id}); + $self->{_freeswitch_db}->do($tmp); + return 0; +} + +sub fs_list_sip_usernames +#Return an array with a list of appropriate sip devices. +#accountcode = accountcode +#domain = SIP Domain +#ip = IP address that user is connecting from +#user = SIP Username +#cc = Callingcard number tagged to each account +#accountcode = accountcode +{ + my ($self, %arg) = @_; + my ($tmp,$sql,@results); + if ($arg{accountcode} || $arg{cc}) { + $tmp = "SELECT directory.id AS id, directory.username AS username, directory.domain AS domain FROM " + . "directory,directory_vars WHERE directory.id = directory_vars.directory_id " + . "AND directory_vars.var_name = 'accountcode' " + . "AND directory_vars.var_value IN (" + . $self->{_freeswitch_db}->quote($arg{accountcode}) + . "," . $self->{_freeswitch_db}->quote($arg{cc}) . ")"; + } else { + $tmp = "SELECT id,username,domain FROM directory "; + if ($arg{user}) { + $tmp .= " WHERE username = " . $self->{_freeswitch_db}->quote($arg{user}); + if ($arg{domain}) { + $tmp .= " AND domain = " + . $self->{_freeswitch_db}->quote($arg{domain}); + } + } else { + if ($arg{domain}) { + $tmp .= " WHERE domain = " + . $self->{_freeswitch_db}->quote($arg{domain}); + } + } + } + print STDERR $tmp; + $sql = $self->{_freeswitch_db}->prepare($tmp); + $sql->execute; + while (my $record = $sql->fetchrow_hashref) { + print STDERR $record->{username}; + push @results, $record; + } + $sql->finish; + return @results; +} + +sub fs_list_sip_params +#Return the list of parameters set on a freeswitch sip account +{ + my ($self, $id) = @_; + my ($tmp,$sql,@results); + $tmp = "SELECT * FROM directory_params WHERE directory_id = " + . $self->{_freeswitch_db}->quote($id); + $sql = $self->{_freeswitch_db}->prepare($tmp); + $sql->execute; + while (my $record = $sql->fetchrow_hashref) { + push @results, $record; + } + $sql->finish; + return @results; +} + +sub fs_list_sip_vars +#Return the list of variables set on a freeswitch sip account +{ + my ($self, $id) = @_; + my ($tmp,$sql,@results); + $tmp = "SELECT * FROM directory_vars WHERE directory_id = " + . $self->{_freeswitch_db}->quote($id); + $sql = $self->{_freeswitch_db}->prepare($tmp); + $sql->execute; + while (my $record = $sql->fetchrow_hashref) { + push @results, $record; + } + $sql->finish; + return @results; +} + sub fs_directory_xml #Return the user detail lines for Freeswitch(TM) sip athentication. #xml = Current XML code @@ -203,37 +294,20 @@ my ($self, %arg) = @_; my ($sql,$sql1,$tmp,$tmp1); $arg{xml} .= "<domain name=\"" . $arg{domain} . "\">"; - $tmp = "SELECT * FROM directory WHERE username = " - . $self->{_freeswitch_db}->quote($arg{user}); -# . " AND domain = " -# . $self->{_freeswitch_db}->quote($arg{domain}); - print STDERR $tmp . "\n"; - $sql = $self->{_freeswitch_db}->prepare($tmp); - $sql->execute; - while (my $record = $sql->fetchrow_hashref) { + my @sip_users = &fs_list_sip_usernames($self,%arg); + foreach my $record (@sip_users) { $arg{xml} .= "<user id=\"" . $record->{username} . "\" mailbox=\"" . $record->{mailbox} . "\">\n"; $arg{xml} .= "<params>\n"; - my $tmp1 = "SELECT * FROM directory_params WHERE directory_id = " - . $self->{_freeswitch_db}->quote($record->{id}); - print STDERR $tmp1 . "\n"; - $sql1 = $self->{_freeswitch_db}->prepare($tmp1); - $sql1->execute; - while (my $record = $sql1->fetchrow_hashref) { + my @params = &fs_list_sip_params($self,$record->{id}); + foreach my $record (@params) { $arg{xml} .= "<param name=\"" . $record->{param_name} . "\" value=\"" . $record->{param_value} . "\"/>\n"; } - $sql1->finish; $arg{xml} .= "</params>\n"; $arg{xml} .= "<variables>\n"; - - print STDERR $tmp1 . "\n"; - $tmp1 = "SELECT * FROM directory_vars WHERE directory_id = " - . $self->{_freeswitch_db}->quote($record->{id}); - $sql1 = $self->{_freeswitch_db}->prepare($tmp1); - $sql1->execute; - while (my $record = $sql1->fetchrow_hashref) { - $arg{xml} .= "<variable name=\"" .$record->{var_name} . "\" value=\"" . $record->{var_value} . "\"/>\n"; + my @vars = &fs_list_sip_vars($self,$record->{id}); + foreach my $record (@vars) { + $arg{xml} .= "<variable name=\"" . $record->{varm_name} . "\" value=\"" . $record->{var_value} . "\"/>\n"; } - $sql1->finish; $arg{xml} .= "</variables>\n"; $arg{xml} .= "</user>\n"; }; Added: trunk/sql/astpp-2008-10-31.sql =================================================================== --- trunk/sql/astpp-2008-10-31.sql (rev 0) +++ trunk/sql/astpp-2008-10-31.sql 2008-11-11 19:05:42 UTC (rev 2204) @@ -0,0 +1,1298 @@ +DROP TABLE IF EXISTS `routes`; +CREATE TABLE routes ( +id INTEGER NOT NULL AUTO_INCREMENT, +pattern CHAR(40), +comment CHAR(80), +connectcost INTEGER NOT NULL, +includedseconds INTEGER NOT NULL, +cost INTEGER NOT NULL, +pricelist CHAR(80), +inc INTEGER, +reseller CHAR(50) default NULL, +precedence INT(4) NOT NULL DEFAULT 0, +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`), +KEY `pattern` (`pattern`), +KEY `pricelist` (`pricelist`), +KEY `reseller` (`reseller`), +KEY `status` (`status`) +); + +DROP TABLE IF EXISTS `pricelists`; +CREATE TABLE pricelists ( +name CHAR(40) NOT NULL, +markup INTEGER NOT NULL DEFAULT 0, +inc INTEGER NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +reseller CHAR(50) default NULL, +PRIMARY KEY (`name`) +); + +DROP TABLE IF EXISTS `callingcardbrands`; +CREATE TABLE callingcardbrands ( +name CHAR(40) NOT NULL, +reseller CHAR(40) NOT NULL DEFAULT '', +language CHAR(10) NOT NULL DEFAULT '', +pricelist CHAR(40) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +validfordays CHAR(4) NOT NULL DEFAULT '', +pin INTEGER NOT NULL DEFAULT 0, +maint_fee_pennies INTEGER NOT NULL DEFAULT 0, +maint_fee_days INTEGER NOT NULL DEFAULT 0, +disconnect_fee_pennies INTEGER NOT NULL DEFAULT 0, +minute_fee_minutes INTEGER NOT NULL DEFAULT 0, +minute_fee_pennies INTEGER NOT NULL DEFAULT 0, +min_length_minutes INTEGER NOT NULL DEFAULT 0, +min_length_pennies INTEGER NOT NULL DEFAULT 0, +PRIMARY KEY (`name`), + KEY `reseller` (`reseller`), + KEY `pricelist` (`pricelist`) +); + +DROP TABLE IF EXISTS `callingcardcdrs`; +CREATE TABLE callingcardcdrs ( +id INTEGER NOT NULL AUTO_INCREMENT, +cardnumber CHAR(50) NOT NULL DEFAULT '', +clid CHAR(80) NOT NULL DEFAULT '', +destination CHAR(40) NOT NULL DEFAULT '', +disposition CHAR(20)NOT NULL DEFAULT '', +callstart CHAR(40) NOT NULL DEFAULT '', +seconds INTEGER NOT NULL DEFAULT 0, +debit DECIMAL(20,6) NOT NULL DEFAULT 0.00000, +credit DECIMAL(20,6) NOT NULL DEFAULT 0.00000, +status INTEGER DEFAULT 0 NOT NULL, +uniqueid VARCHAR(32) NOT NULL DEFAULT '', +notes CHAR(80) NOT NULL DEFAULT '', +pricelist CHAR(80) NOT NULL DEFAULT '', +pattern CHAR(80) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + KEY `cardnumber` (`cardnumber`) +); + +DROP TABLE IF EXISTS `trunks`; +CREATE TABLE trunks ( +name VARCHAR(30) NOT NULL, +tech CHAR(10) NOT NULL DEFAULT '', +path CHAR(40) NOT NULL DEFAULT '', +provider CHAR(100) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +dialed_modify TEXT NOT NULL DEFAULT '', +resellers TEXT NOT NULL DEFAULT '', +precedence INT(4) NOT NULL DEFAULT 0, +maxchannels INTEGER DEFAULT 0 NOT NULL, + PRIMARY KEY (`name`), + KEY `provider` (`provider`), + KEY `provider_2` (`provider`) +); + +DROP TABLE IF EXISTS `outbound_routes`; +CREATE TABLE outbound_routes ( +pattern CHAR(40), +id INTEGER NOT NULL AUTO_INCREMENT, +comment CHAR(80) NOT NULL DEFAULT '', +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +trunk CHAR(80) NOT NULL DEFAULT '', +inc CHAR(10) NOT NULL DEFAULT '', +strip CHAR(40) NOT NULL DEFAULT '', +prepend CHAR(40) NOT NULL DEFAULT '', +precedence INT(4) NOT NULL DEFAULT 0, +resellers TEXT NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `trunk` (`trunk`), + KEY `pattern` (`pattern`) +); + +DROP TABLE IF EXISTS `dids`; +CREATE TABLE dids ( +number CHAR(40) NOT NULL, +account CHAR(50) NOT NULL DEFAULT '', +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +monthlycost INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +inc CHAR(10) NOT NULL DEFAULT '', +extensions CHAR(180) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +provider CHAR(40) NOT NULL DEFAULT '', +country CHAR (80)NOT NULL DEFAULT '', +province CHAR (80) NOT NULL DEFAULT '', +city CHAR (80) NOT NULL DEFAULT '', +prorate int(1) NOT NULL default 0, +setup int(11) NOT NULL default 0, +limittime int(1) NOT NULL default 1, +disconnectionfee INT(11) NOT NULL default 0, +variables TEXT NOT NULL DEFAULT '', +options varchar(40) default NULL, +maxchannels int(4) NOT NULL default 0, +chargeonallocation int(1) NOT NULL default 1, +allocation_bill_status int(1) NOT NULL default 0, +dial_as CHAR(40) NOT NULL DEFAULT '', +PRIMARY KEY (`number`), + KEY `account` (`account`) +); + +DROP TABLE IF EXISTS `accounts`; +CREATE TABLE accounts ( +cc CHAR(20) NOT NULL DEFAULT '', +number CHAR(50) NOT NULL, +reseller CHAR(40) NOT NULL DEFAULT '', +pricelist CHAR(24) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +credit INTEGER NOT NULL DEFAULT 0, +sweep INTEGER NOT NULL DEFAULT 0, +creation TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, +pin INTEGER NOT NULL DEFAULT 0, +credit_limit INTEGER NOT NULL DEFAULT 0, +posttoexternal INTEGER NOT NULL DEFAULT 0, +balance DECIMAL(20,6) NOT NULL DEFAULT 0, +password CHAR(80) NOT NULL DEFAULT '', +first_name CHAR(40) NOT NULL DEFAULT '', +middle_name CHAR(40) NOT NULL DEFAULT '', +last_name CHAR(40) NOT NULL DEFAULT '', +company_name CHAR(40) NOT NULL DEFAULT '', +address_1 CHAR(80) NOT NULL DEFAULT '', +address_2 CHAR(80) NOT NULL DEFAULT '', +address_3 CHAR(80) NOT NULL DEFAULT '', +postal_code CHAR(12) NOT NULL DEFAULT '', +province CHAR(40) NOT NULL DEFAULT '', +city CHAR(80) NOT NULL DEFAULT '', +country CHAR(40) NOT NULL DEFAULT '', +telephone_1 CHAR(40) NOT NULL DEFAULT '', +telephone_2 CHAR(40) NOT NULL DEFAULT '', +fascimile CHAR(40) NOT NULL DEFAULT '', +email CHAR(80) NOT NULL DEFAULT '', +language CHAR(2) NOT NULL DEFAULT '', +currency CHAR(3) NOT NULL DEFAULT '', +maxchannels INTEGER DEFAULT 1 NOT NULL, +routing_technique INT(4) NOT NULL DEFAULT 0, +dialed_modify TEXT NOT NULL DEFAULT '', +type INTEGER DEFAULT 0, +tz CHAR(40) NOT NULL DEFAULT '', +PRIMARY KEY (`number`), + KEY `pricelist` (`pricelist`), + KEY `reseller` (`reseller`) +); + +DROP TABLE IF EXISTS `counters`; +CREATE TABLE counters ( +id INTEGER NOT NULL AUTO_INCREMENT, +package CHAR(40) NOT NULL DEFAULT '', +account VARCHAR(50) NOT NULL, +seconds INTEGER NOT NULL DEFAULT 0, +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`) +); + +DROP TABLE IF EXISTS `callingcards`; +CREATE TABLE callingcards ( +id INTEGER NOT NULL AUTO_INCREMENT, +cardnumber CHAR(20) NOT NULL DEFAULT '', +language CHAR(10) NOT NULL DEFAULT '', +value INTEGER NOT NULL DEFAULT 0, +used INTEGER NOT NULL DEFAULT 0, +brand VARCHAR(20) NOT NULL DEFAULT '', +created DATETIME, +firstused DATETIME, +expiry DATETIME, +validfordays CHAR(4) NOT NULL DEFAULT '', +inuse INTEGER NOT NULL DEFAULT 0, +pin CHAR(20), +account VARCHAR(50) NOT NULL DEFAULT '', +maint_fee_pennies INTEGER NOT NULL DEFAULT 0, +maint_fee_days INTEGER NOT NULL DEFAULT 0, +maint_day INTEGER NOT NULL DEFAULT 0, +disconnect_fee_pennies INTEGER NOT NULL DEFAULT 0, +minute_fee_minutes INTEGER NOT NULL DEFAULT 0, +minute_fee_pennies INTEGER NOT NULL DEFAULT 0, +min_length_minutes INTEGER NOT NULL DEFAULT 0, +min_length_pennies INTEGER NOT NULL DEFAULT 0, +timeused INTEGER NOT NULL DEFAULT 0, +invoice CHAR(20) NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `brand` (`brand`) +); + +CREATE TABLE charge_to_account ( +id INTEGER NOT NULL AUTO_INCREMENT, +charge_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(50) NOT NULL DEFAULT '', +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`) +); + +CREATE TABLE queue_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +queue_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE pbx_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +pbx_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE extension_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +extension_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE cdrs ( +id INTEGER NOT NULL AUTO_INCREMENT, +uniqueid varchar(32) NOT NULL DEFAULT '', +cardnum CHAR(50), +callerid CHAR(80), +callednum varchar(80) NOT NULL DEFAULT '', +billseconds INT DEFAULT 0 NOT NULL, +trunk VARCHAR(30), +disposition varchar(45) NOT NULL DEFAULT '', +callstart varchar(80) NOT NULL DEFAULT '', +debit DECIMAL (20,6) NOT NULL DEFAULT 0, +credit DECIMAL (20,6) NOT NULL DEFAULT 0, +status INTEGER DEFAULT 0 NOT NULL, +notes CHAR(80), +provider CHAR(50), +cost DECIMAL(20,6) NOT NULL DEFAULT 0, +pricelist CHAR(80) NOT NULL DEFAULT '', +pattern CHAR(80) NOT NULL DEFAULT '', +PRIMARY KEY (`id`), + KEY `cardnum` (`cardnum`), + KEY `provider` (`provider`), + KEY `trunk` (`trunk`), + KEY `uniqueid` (`uniqueid`), + KEY `status` (`status`) +); + +CREATE TABLE packages ( +id INTEGER NOT NULL AUTO_INCREMENT, +name CHAR(40) NOT NULL DEFAULT '', +pricelist CHAR(40) NOT NULL DEFAULT '', +pattern CHAR(40) NOT NULL DEFAULT '', +includedseconds INTEGER NOT NULL DEFAULT 0, +reseller VARCHAR(50) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `pricelist` (`pricelist`), + KEY `reseller` (`reseller`) +); + +CREATE TABLE ani_map ( +number char(20) NOT NULL, +account char(50) NOT NULL default '', +status int(11) NOT NULL default '0', +context varchar(20) NOT NULL, + PRIMARY KEY (`number`), +KEY `account` (`account`) +); + +CREATE TABLE `ip_map` ( +ip char(15) NOT NULL default '', +account char(20) NOT NULL default '', +prefix varchar(20) NULL, +context varchar(20) NOT NULL, +PRIMARY KEY (`ip`,`prefix`), +KEY `account` (`account`) +); + +CREATE TABLE charges ( +id INTEGER NOT NULL AUTO_INCREMENT, +pricelist CHAR(40) NOT NULL DEFAULT '', +description VARCHAR(80) NOT NULL DEFAULT '', +charge INTEGER NOT NULL DEFAULT 0, +sweep INTEGER NOT NULL DEFAULT 0, +reseller CHAR(40) NOT NULL DEFAULT '', +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`), + KEY `pricelist` (`pricelist`) +); + +CREATE TABLE manager_action_variables ( +id INTEGER NOT NULL AUTO_INCREMENT, +name CHAR(60) NOT NULL DEFAULT '', +value CHAR(60) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE callingcard_stats ( +uniqueid VARCHAR(48) NOT NULL, +total_time VARCHAR(48) NOT NULL, +billable_time VARCHAR(48) NOT NULL, +timestamp DATETIME NULL, +PRIMARY KEY (`uniqueid`) +); + +CREATE TABLE system ( +name VARCHAR(48) NULL, +value VARCHAR(255) NULL, +comment VARCHAR(255) NULL, +timestamp DATETIME NULL, +reseller VARCHAR(48) NULL, +brand VARCHAR(48) NULL, +PRIMARY KEY (`name`), + KEY `reseller` (`reseller`), + KEY `brand` (`brand`) +); + + +INSERT INTO system (name, value, comment) VALUES ( +'callout_accountcode','admin','Call Files: What accountcode should we use?'); + +INSERT INTO system (name, value, comment) VALUES ( +'lcrcontext','astpp-outgoing','This is the Local context we use to route our outgoing calls through esp for callbacks'); + +INSERT INTO system (name, value, comment) VALUES ( +'maxretries','3','Call Files: How many times do we retry?'); + +INSERT INTO system (name, value, comment) VALUES ( +'retrytime','30','Call Files: How long do we wait between retries?'); + +INSERT INTO system (name, value, comment) VALUES ( +'waittime','15','Call Files: How long do we wait before the initial call?'); + +INSERT INTO system (name, value, comment) VALUES ( +'clidname','Private','Call Files: Outgoing CallerID Name'); + +INSERT INTO system (name, value, comment) VALUES ( +'clidnumber','0000000000','Call Files: Outgoing CallerID Number'); + +INSERT INTO system (name, value, comment) VALUES ( +'callingcards_callback_context','astpp-callingcards','Call Files: For callingcards what context do we end up in?'); + +INSERT INTO system (name, value, comment) VALUES ( +'callingcards_callback_extension', 's','Call Files: For callingcards what extension do we use?'); + +INSERT INTO system (name, value, comment) VALUES ( +'openser_dbengine', 'MySQL','For now this must be MySQL'); + +INSERT INTO system (name, value, comment) VALUES ( +'openser', '0','Use OPENSER? 1 for yes or 0 for no'); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbname', 'openser','OPENSER Database Name', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbuser', 'root','OPENSER Database User', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbhost', 'localhost','OPENSER Database Host', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbpass', 'Passw0rd','OPENSER Database Password', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_domain', NULL,'OPENSER Domain', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_email', 'em...@as...','Email address that email should appear to be from', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'asterisk_dir', '/etc/asterisk','Which directory are asterisk configuration files stored in?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_website', 'http://www.astpp.org','Link to your company website', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_name', 'ASTPP.ORG','The name of your company. Used in emails.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'email', '1','Send out email? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'user_email', '1','Email user on account changes? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'debug', '0','Enable debugging output? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'emailadd', 'em...@as...','Administrator email address', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'startingdigit', '0','The digit that all calling cards must start with. 0=disabled', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'enablelcr', '1','Use least cost routing 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'log_file', '/var/log/astpp/astpp.log','ASTPP Log file', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'key_home', 'http://www.astpp.org/astpp.pub','Asterisk RSA Key location (optional)', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rate_engine_csv_file', '/var/log/astpp/astpp.csv','CSV File for call rating data', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'csv_dir', '/var/log/astpp/','CSV File Directory', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_brand', 'default','Default pricelist. If a price is not found in the customers pricelist we check this one.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'new_user_brand', 'default','What is the default pricelist for new customers?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_context', 'custom-astpp','What is the default context for new devices?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cardlength', '10','Number of digits in calling cards and cc codes.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'asterisk_server', 'voip.astpp.org','Your default voip server. Used in outgoing email.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'currency', 'CAD','Name of the currency you use', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'iax_port', '4569','Default IAX2 Port', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'sip_port', '5060','Default SIP Port', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'ipaddr', 'dynamic','Default IP Address for new devices', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'key', 'astpp.pub','Asterisk RSA Key Name (Optional)', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'pinlength', '6','For those calling cards that are using pins this is the number of digits it will have.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'credit_limit', '0','Default credit limit in dollars.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'decimalpoints', '4','How many decimal points do we bill to?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'max_free_length', '100','What is the maximum length (in minutes) of calls that are at no charge?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'trackvendorcharges', '1','Do we track the amount of money we spend with specific providers? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_logo', 'http://www.astpp.org/logo.png','The location of our company logo.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_slogan', 'Welcome to ASTPP','Company slogan', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'version', '1.5Beta', 'ASTPP Version', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_language', 'en', 'Default ASTPP Language',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'card_retries','3', 'How many retries do we allow for calling card numbers?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'pin_retries','3', 'How many retries do we allow for pins?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'number_retries','3','How many retries do we allow calling card users when dialing a number?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'booth_context','callshop_booth','Please enter the default context for a callshop booth.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'callingcards_max_length','9000','What is the maximum length (in ms) of a callingcard call?',''); + +INSERT INTO system (name,value,comment,timestamp) VALUES ( +'template_die_on_bad_params','0','Should HTML::Template die on bad parameters?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'results_per_page','30','How many results per page do we should in the web interface?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astpp_dir','/var/lib/astpp','Where do the astpp configs live?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'auth','Passw0rd!','This is the override authorization code and will allow access to the system.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_dbengine','MySQL','Database type for Asterisk(tm) -Realtime',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbengine','MySQL','Database type for the cdr database',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_dbengine','MySQL','Database type for OSCommerce',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_dbengine','MySQL','Database type for AgileBill(tm)',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_dbengine','MySQL','Database type for FreePBX',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'externalbill','oscommerce','Please specify the external billing application to use. If you are not using any then leave it blank. Valid options are "agile" and "oscommerce".',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'callingcards','1','Do you wish to enable calling cards? 1 for yes and 2 for no.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astcdr','1','Change this one at your own peril. If you switch it off, calls will not be marked as billed in asterisk once they are billed.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'posttoastpp','1','Change this one at your own peril. If you switch it off, calls will not be written to astpp when they are calculated.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'sleep','10','How long shall the rating engine sleep after it has been notified of a hangup? (in seconds)',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'users_dids_amp','0','If this is enabled, ASTPP will create users and DIDs in the FreePBX (www.freepbx.org) database.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'users_dids_rt','1','If this is enabled, ASTPP will create users and DIDs in the Asterisk Realtime database.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'users_dids_freeswitch','0','If this is enabled, ASTPP will create SIP users in the freeswitch database.',''); + + +INSERT INTO system (name, value, comment) VALUES ( +'service_prepend','778',''); +INSERT INTO system (name, value, comment) VALUES ( +'service_length,','7',''); +INSERT INTO system (name, value, comment) VALUES ( +'service_filler','4110000',''); + +INSERT INTO system (name, value, comment) VALUES ( +'asterisk_cdr_table','cdr','Which table of the Asterisk(TM) database are the cdrs in?'); + +-- AgileBill(Trademark of AgileCo) Settings: +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_db','agile','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_pass','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_site_id','1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_charge_status','0','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_taxable','1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_dbprefix','_','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_service_prepend','778','',''); + +-- OSCommerce Settings (www.oscommerce.org) +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_db','oscommerce','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_pass','password','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_product_id','99999999','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_payment_method','"Charge"','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_order_status','1','',''); + +-- FreePBX Settings (www.freepbx.org) +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_db','asterisk','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_pass','passw0rd','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_table','iax','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_table','sip','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_extensions_table','extensions','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_codec_allow','g729,ulaw,alaw','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_codec_disallow','all','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_mailbox_group','default','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_nat','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_canreinvite','no','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_dtmfmode','rfc2833','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_callgroup','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_pickupgroup','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_notransfer','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_qualify','yes','',''); + +-- Asterisk -realtime Settings +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_db','realtime','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_pass','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_table','iax','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_table','sip','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_extensions_table','extensions','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_insecure','very','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_nat','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_canreinvite','no','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_codec_allow','g729,ulaw,alaw','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_codec_disallow','all','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_mailbox_group','default','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_type','friend','',''); +INSERT INTO system (name, value, comment) VALUES ( +'rt_voicemail_table','voicemail_users',''); + + +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_rate_announce','1','Do we want the calling cards script to announce the rate on calls?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_timelimit_announce','1','Do we want the calling cards script to announce the timelimit on calls?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_cancelled_prompt','1','Do we want the calling cards script to announce that the call was cancelled?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_menu','1','Do we want the calling cards script to present a menu before exiting?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_connection_prompt','1','Do we want the calling cards script to announce that it is connecting the call?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_pin_input_timeout','15000','How long do we wait when entering the calling card pin? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_number_input_timeout','15000','How long do we wait when entering the calling card number? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_dial_input_timeout','15000','How long do we wait when entering the destination number in calling cards? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_general_input_timeout','15000','How long do we wait for input in general menus? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_welcome_file','silence/1','What do we play for a welcome file?'); + +INSERT INTO system (name, value, comment) VALUES ( +'sip_ext_prepend','10','What should every autoadded SIP extension begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'iax2_ext_prepend','10','What should every autoadded IAX2 extension begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'cc_prepend','','What should every autoadded callingcard begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'pin_cc_prepend','','What should every autoadded callingcard pin begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'pin_act_prepend','','What should every autoadded account pin begin with?'); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_directory','/usr/local/freeswitch','What is the Freeswitch root directory?'); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_password','ClueCon','Freeswitch event socket password'); +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_host','localhost','Freeswitch event socket host'); +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_port','8021','Freeswitch event socket port'); +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_timeout','30','Freeswitch seconds to expect a heartbeat event or reconnect'); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_dbengine', 'MySQL','For now this must be MySQL'); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freeswitch_dbname', 'freeswitch','Freeswitch Database Name', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freeswitch_dbuser', 'root','Freeswitch Database User', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freeswitch_dbhost', 'localhost','Freeswitch Database Host', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freeswitch_dbpass', 'Passw0rd','Freeswitch Database Password', ''); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_cdr_table','fscdr','Which table of the cdr database are the Freeswitch cdrs in?'); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_domain','$${local_ip_v4}','This is entered as the Freeswitch domain.'); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_context','default','This is entered as the Freeswitch user context.'); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbname', 'asteriskcdrdb', +'CDR Database Name', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbuser', 'root', +'CDR Database User', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbhost', 'localhost', +'CDR Database Host', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbpass', 'Passw0rd', +'CDR Database Password', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astman_user', 'admin','Asterisk(tm) Manager Interface User', ''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astman_host', 'localhost','Asterisk(tm) Manager Interface Host', ''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astman_secret', 'amp111','Asterisk(tm) Manager Interface Secret', ''); + + +-- +-- Enough Configuration settings +-- + +DROP TABLE IF EXISTS `countrycode`; +CREATE TABLE `countrycode` ( + `country` varchar(255) NOT NULL, + PRIMARY KEY (`country`), + KEY `country` (`country`) +); + +INSERT INTO `countrycode` (`country`) VALUES + ('Afghanistan'), + ('Alaska'), + ('Albania'), + ('Algeria'), + ('AmericanSamoa'), + ('Andorra'), + ('Angola'), + ('Antarctica'), + ('Argentina'), + ('Armenia'), + ('Aruba'), + ('Ascension'), + ('Australia'), + ('Austria'), + ('Azerbaijan'), + ('Bahrain'), + ('Bangladesh'), + ('Belarus'), + ('Belgium'), + ('Belize'), + ('Benin'), + ('Bhutan'), + ('Bolivia'), + ('Bosnia & Herzegovina'), + ('Botswana'), + ('Brazil'), + ('Brunei Darussalam'), + ('Bulgaria'), + ('Burkina Faso'), + ('Burundi'), + ('Cambodia'), + ('Cameroon'), + ('Canadda'), + ('Cape Verde Islands'), + ('Central African Republic'), + ('Chad'), + ('Chile'), + ('China'), + ('Colombia'), + ('Comoros'), + ('Congo'), + ('Cook Islands'), + ('Costa Rica'), + ('Croatia'), + ('Cuba'), + ('Cuba Guantanamo Bay'), + ('Cyprus'), + ('Czech Republic'), + ('De... [truncated message content] |
From: <dar...@us...> - 2008-11-11 22:57:57
|
Revision: 2205 http://astpp.svn.sourceforge.net/astpp/?rev=2205&view=rev Author: darrenkw Date: 2008-11-11 22:57:53 +0000 (Tue, 11 Nov 2008) Log Message: ----------- Added support to "deactivate" cdrs from the list_errors section. Modified Paths: -------------- trunk/astpp-admin.cgi trunk/modules/ASTPP/lib/ASTPP.pm Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2008-11-11 19:05:42 UTC (rev 2204) +++ trunk/astpp-admin.cgi 2008-11-11 22:57:53 UTC (rev 2205) @@ -3783,117 +3783,67 @@ sub build_list_errors() { my ( $results, $body, $status, $count, $pageno, $pagesrequired ); - $count = 0; $cdr_db = &cdr_connect_db( $config, @output ); return gettext("Cannot list errors until database is configured!") . "\n" unless $cdr_db; - if ( $params->{limit} < 1 ) { $params->{limit} = 0 } - my $results_per_page = $config->{results_per_page}; - if ( $results_per_page eq "" ) { $results_per_page = 25; } - my $sql = - $cdr_db->prepare( "SELECT * FROM cdr WHERE cost = 'error' OR " - . "accountcode IN (NULL,'') AND cost ='none'" ); - $sql->execute - || return gettext("Something is wrong with the cdr database!") . "\n"; - $results = $sql->rows; - $pagesrequired = ceil( $results / $results_per_page ); - print gettext("Pages Required:") . " $pagesrequired\n" - if ( $config->{debug} eq "YES" ); - $sql->finish; - $sql = - $cdr_db->prepare( " SELECT * FROM cdr WHERE cost = 'error' OR " - . "accountcode IN (NULL,'') AND cost ='none' ORDER BY calldate " - . "limit $params->{limit} , $results_per_page" ); - $sql->execute - || return gettext("Something is wrong with the cdr database!") . "\n"; - $body = - "<table class=\"viewcdrs\"><tr><td colspan=7>" - . start_form - . "</td></tr> -" - . "<tr class=\"header\"><td>" - . gettext("Date") - . "</td><td>" - . gettext("CallerID") . "</td>" . "<td>" - . gettext("Source") - . "</td><td>" - . gettext("Dest") . "</td>" . "<td>" - . gettext("Dest.Context") - . "</td><td>" - . gettext("Channel") . "</td>" . "<td>" - . gettext("Dest.Channel") - . "</td><td>" - . gettext("Last App") - . " </td>" . "<td>" - . gettext("Last Data") - . "</td><td>" - . gettext("Duration") . "</td>" . "<td>" - . gettext("BillSec") - . "</td><td>" - . gettext("Disposition") . "</td>" . "<td>" - . gettext("AMAFlags") - . "</td><td>" - . gettext("AccountCode") . "</td>" . "<td>" - . gettext("UniqueID") - . "</td><td>" - . gettext("UserField") . "</td>" . "<td>" - . gettext("Cost") - . "</td></tr> -\n"; + if ($params->{acount} eq "Deactivate..." || $params->{uniqueid}) { + $cdr_db->do("UPDATE cdr SET cost = 'dropped' AND vendor = 'dropped' WHERE uniqueid = " . $params->{uniqueid}); + } + $count = 0; + my $template = HTML::Template->new( + filename => '/var/lib/astpp/templates/list_errors.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); - while ( my $record = $sql->fetchrow_hashref ) { +my $sql_select = "SELECT * FROM cdr WHERE cost IN( 'error','rating') OR accountcode IN (NULL,'') AND cost ='none' ORDER BY calldate"; +my $sql_count = "SELECT COUNT(*) FROM cdr WHERE cost IN ( 'error','rating') OR accountcode IN (NULL,'') AND cost ='none'"; + + my ($sql, $pagination) = + $ASTPP->pagination( sql_select => $sql_select, + sql_count => $sql_count, + results_per_page=> $config->{results_per_page}, + ve => $params->{ve}, + te => $params->{ee}, + db => $cdr_db, + ); + + $ASTPP->debug( user=> $param->{username}, debug => $sql); + my $results = $cdr_db->prepare($sql); + + $results->execute; + + while ( my $record = $results->fetchrow_hashref ) { + $ASTPP->debug( user=> $param->{username}, debug => $record->{uniqueid}); + my %row; $count++; if ( $count % 2 == 0 ) { - $body .= "<tr class=\"rowtwo\">"; + %row->{class} = "rowtwo"; } else { - $body .= "<tr class=\"rowone\">"; + %row->{class} = "rowone"; } - $body .= -"<td>$record->{calldate}</td><td>$record->{clid}</td><td>$record->{src}</td>" - . "<td>$record->{dst}</td><td>$record->{dcontext}</td><td>$record->{channel}</td>" - . "<td>$record->{dstchannel}</td><td>$record->{lastapp}</td><td>$record->{lastdata}</td>" - . "<td>$record->{duration}</td><td>$record->{billsec}</td><td>$record->{disposition}</td>" - . "<td>$record->{amaflags}</td><td>$record->{accountcode}</td><td>$record->{uniqueid}</td>" - . "<td>$record->{userfield}</td><td>$record->{cost}</td></tr> -\n"; + %row->{uniqueid} = $record->{uniqueid}; + %row->{calldate} = $record->{calldate}; + %row->{clid} = $record->{clid}; + %row->{src} = $record->{src}; + %row->{dst} = $record->{dst}; + %row->{dcontext} = $record->{dcontext}; + %row->{channel} = $record->{channel}; + %row->{dstchannel} = $record->{dstchannel}; + %row->{lastapp} = $record->{lastpp}; + %row->{lastdata} = $record->{lastdata}; + %row->{duration} = $record->{duration}; + %row->{billsec} = $record->{billsec}; + %row->{disposition} = $record->{disposition}; + %row->{amaflags} = $record->{amaflags}; + %row->{accountcode} = $record->{acountcode}; + %row->{userfield} = $record->{userfield}; + %row->{cost} = $record->{cost}; + %row->{vendor} = $record->{vendor}; + push( @cdrlist,\%row); } - $body .= "</table> -"; - $sql->finish; - for ( my $i = 0 ; $i <= $pagesrequired - 1 ; $i++ ) { - if ( $i == 0 ) { - if ( $params->{limit} != 0 ) { - $body .= - "<a href=\"astpp-admin.cgi?mode=" - . gettext("List Errors") - . "&limit=0\">"; - $body .= $i + 1; - $body .= "</a>"; - } - else { - $body .= $i + 1; - } - } - if ( $i > 0 ) { - if ( $params->{limit} != ( $i * $results_per_page ) ) { - $body .= - "<a href=\"astpp-admin.cgi?mode=" - . gettext("List Errors") - . "&limit="; - $body .= ( $i * $results_per_page ); - $body .= "\">\n"; - $body .= $i + 1 . "</a>"; - } - else { - $pageno = $i + 1; - $body .= " |"; - } - } - } - $body .= ""; - $body .= gettext("Page") . " $pageno " . gettext("of") . " $pagesrequired"; - return $body; + $results->finish; + $template->param( cdrlist => \@cdrlist ); + $template->param( pagination => $pagination ); + return $template->output; } sub default_callback { Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2008-11-11 19:05:42 UTC (rev 2204) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2008-11-11 22:57:53 UTC (rev 2205) @@ -342,8 +342,10 @@ } sub pagination #Returns the pagination html code to assist with navigation. +#db = Database connection to use if w're not using the ASTPP database; { my ($self, %arg) = @_; + my $db; # We are using Data::Paginate for the real tough stuff. # Therefore we need to pass the Data::Paginate stuff # as well as the total number of pages. @@ -355,6 +357,11 @@ if (!$arg{results_per_page} || $arg{results_per_page} > 1 ) { $arg{results_per_page} = 25; } + if ($arg{db}) { + $db = $arg{db}; + } else { + $db = $self->{_astpp_db}; + } ## START PAGINATION CODE # set total_entries *once* then pass it around # in the object's links from then on for efficiency: @@ -365,7 +372,8 @@ ? Digest::MD5::md5_hex("unique_cypher-$total_entries-$arg{sql_check}") : ''; if ( !$total_entries || $verify ne $te_match ) { # its not ok so re-fetch - $sql = $self->{_astpp_db}->prepare($arg{sql_count}); +# $sql = $self->{_astpp_db}->prepare($arg{sql_count}); + $sql = $db->prepare($arg{sql_count}); $sql->execute; $record = $sql->fetchrow_hashref; $total_entries = $record->{"COUNT(*)"}; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-11-11 23:09:27
|
Revision: 2207 http://astpp.svn.sourceforge.net/astpp/?rev=2207&view=rev Author: darrenkw Date: 2008-11-11 23:09:25 +0000 (Tue, 11 Nov 2008) Log Message: ----------- Correct the code to show freeswitch voicemail passwords. Moved the list_errors template to list-errors to match the rest. Modified Paths: -------------- trunk/astpp-admin.cgi Added Paths: ----------- trunk/templates/freeswitch-sip-list.tpl trunk/templates/list-errors.tpl Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2008-11-11 23:06:16 UTC (rev 2206) +++ trunk/astpp-admin.cgi 2008-11-11 23:09:25 UTC (rev 2207) @@ -3942,7 +3942,7 @@ } $count = 0; my $template = HTML::Template->new( - filename => '/var/lib/astpp/templates/list_errors.tpl', + filename => '/var/lib/astpp/templates/list-errors.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); Added: trunk/templates/freeswitch-sip-list.tpl =================================================================== --- trunk/templates/freeswitch-sip-list.tpl (rev 0) +++ trunk/templates/freeswitch-sip-list.tpl 2008-11-11 23:09:25 UTC (rev 2207) @@ -0,0 +1,35 @@ +<form method="post" action="/cgi-bin/astpp-admin/astpp-admin.cgi?mode=Freeswitch(TM)%20SIP%20Devices" enctype="multipart/form-data"> +<table> + <tr> + <input type="hidden" name="mode" value="Freeswitch(TM) SIP Devices"/> + <td colspan=7 align=center><TMPL_VAR NAME="status"></td> + </tr> + <tr class="header"> + <td colspan=7><TMPL_VAR NAME="account_types"></td> + </tr> + <tr class="header"> + <td colspan=7><input type="submit" name="action" value="Add..." /> <input type="submit" name="Refresh" value="Refresh" /></td> + </tr> + <tr class="header"> + <td>Directory ID</td> + <td>Username</td> + <td>Password</td> + <td>Accountcode</td> + <td>VM Password</td> + <td>Context</td> + <td>Action</td> + </tr> + <TMPL_LOOP NAME="device_list"> + <TR> + <TD><TMPL_VAR NAME="directory_id"></td> + <TD><TMPL_VAR NAME="username"></a></TD> + <TD><TMPL_VAR NAME="password"></TD> + <TD><TMPL_VAR NAME="accountcode"></TD> + <TD><TMPL_VAR NAME="vmpassword"></TD> + <TD><TMPL_VAR NAME="context"></TD> + <TD><a href="astpp-admin.cgi?mode=Freeswitch(TM) SIP Devices&directory_id=<TMPL_VAR NAME="directory_id">&action=Delete...">Delete...</a></TD> + <TD><a href="astpp-admin.cgi?mode=Freeswitch(TM) SIP Devices&directory_id=<TMPL_VAR NAME="directory_id">&action=Edit...">Edit...</a></TD> + </TR> + </TMPL_LOOP> +</table> + Added: trunk/templates/list-errors.tpl =================================================================== --- trunk/templates/list-errors.tpl (rev 0) +++ trunk/templates/list-errors.tpl 2008-11-11 23:09:25 UTC (rev 2207) @@ -0,0 +1,57 @@ +<table class="viewcdrs"> + <tr> + <td colspan=7><form method="post" action="/cgi-bin/astpp-admin/astpp-admin.cgi?mode=List%20Errors" enctype="multipart/form-data"></td> + </tr> + <tr class="header"> + <td>UniqueID</td> + <td>Date</td> + <td>CallerID</td> + <td>Source</td> + <td>Dest</td> + <td>Dest.Context</td> + <td>Channel</td> + <td>Dest.Channel</td> + <td>Last App </td> + <td>Last Data</td> + <td>Duration</td> + <td>BillSec</td> + <td>Disposition</td> + <td>AMAFlags</td> + <td>AccountCode</td> + <td>UniqueID</td> + <td>UserField</td> + <td>Cost</td> + <td>Action</td> + </tr> + <TMPL_LOOP NAME="cdrlist"> + <tr class="<TMPL_VAR NAME="class">"> + <td><TMPL_VAR NAME="uniqueid"></td> + <td><TMPL_VAR NAME="calldate"></td> + <td><TMPL_VAR NAME="clid"></td> + <td><TMPL_VAR NAME="src"></td> + <td><TMPL_VAR NAME="dst"></td> + <td><TMPL_VAR NAME="dcontext"></td> + <td><TMPL_VAR NAME="channel"></td> + <td><TMPL_VAR NAME="dstchannel"></td> + <td><TMPL_VAR NAME="lastapp"></td> + <td><TMPL_VAR NAME="lastdata"></td> + <td><TMPL_VAR NAME="duration"></td> + <td><TMPL_VAR NAME="billsec"></td> + <td><TMPL_VAR NAME="disposition"></td> + <td><TMPL_VAR NAME="amaflags"></td> + <td><TMPL_VAR NAME="accountcode"></td> + <td><TMPL_VAR NAME="uniqueid"></td> + <td><TMPL_VAR NAME="userfield"></td> + <td><TMPL_VAR NAME="cost"></td> + <td><a href="astpp-admin.cgi?mode=List Errors&uniqueid=<TMPL_VAR NAME="uniqueid">&action=Deactivate...">Deactivate...</a></td> + </tr> + </TMPL_LOOP> +</table> + +<table> + <tr> + <td><TMPL_VAR NAME="pagination"></td> + <td><TMPL_VAR NAME="status"></td> + </tr> + </table> +</form> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-11-25 05:13:02
|
Revision: 2210 http://astpp.svn.sourceforge.net/astpp/?rev=2210&view=rev Author: darrenkw Date: 2008-11-25 05:12:49 +0000 (Tue, 25 Nov 2008) Log Message: ----------- Added support to only post charges greater or less than 0 to oscommerce. Modified Paths: -------------- trunk/astpp-common.pl Added Paths: ----------- trunk/sql/astpp-2008-11-24.sql Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2008-11-16 01:59:10 UTC (rev 2209) +++ trunk/astpp-common.pl 2008-11-25 05:12:49 UTC (rev 2210) @@ -4640,15 +4640,17 @@ my ( $sql, $desc, $tmp, $price ); $desc = "$row->{callstart} SRC: $row->{callerid} DST: $row->{callednum} SEC:$row->{billseconds} $row->{notes}"; $price = $row->{debit} / 10000; - $tmp = + if($config->{osc_post_nc} == 1 || $price != 0) { + $tmp = "INSERT INTO `orders_products` (`orders_products_id`,`orders_id`,`products_id`,`products_name`,`products_price`," - . "`final_price`,`products_tax`,`products_quantity`) VALUES (''," - . "$invoice_id, " - . $osc_db->quote( $config->{osc_product_id} ) . ", " - . $osc_db->quote($desc) . ", " - . "$price, $price,0,1)"; - $sql = $osc_db->prepare($tmp); - $sql->execute; + . "`final_price`,`products_tax`,`products_quantity`) VALUES (''," + . "$invoice_id, " + . $osc_db->quote( $config->{osc_product_id} ) . ", " + . $osc_db->quote($desc) . ", " + . "$price, $price,0,1)"; + $sql = $osc_db->prepare($tmp); + $sql->execute; + } } sub osc_charges() { Added: trunk/sql/astpp-2008-11-24.sql =================================================================== --- trunk/sql/astpp-2008-11-24.sql (rev 0) +++ trunk/sql/astpp-2008-11-24.sql 2008-11-25 05:12:49 UTC (rev 2210) @@ -0,0 +1,1300 @@ +DROP TABLE IF EXISTS `routes`; +CREATE TABLE routes ( +id INTEGER NOT NULL AUTO_INCREMENT, +pattern CHAR(40), +comment CHAR(80), +connectcost INTEGER NOT NULL, +includedseconds INTEGER NOT NULL, +cost INTEGER NOT NULL, +pricelist CHAR(80), +inc INTEGER, +reseller CHAR(50) default NULL, +precedence INT(4) NOT NULL DEFAULT 0, +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`), +KEY `pattern` (`pattern`), +KEY `pricelist` (`pricelist`), +KEY `reseller` (`reseller`), +KEY `status` (`status`) +); + +DROP TABLE IF EXISTS `pricelists`; +CREATE TABLE pricelists ( +name CHAR(40) NOT NULL, +markup INTEGER NOT NULL DEFAULT 0, +inc INTEGER NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +reseller CHAR(50) default NULL, +PRIMARY KEY (`name`) +); + +DROP TABLE IF EXISTS `callingcardbrands`; +CREATE TABLE callingcardbrands ( +name CHAR(40) NOT NULL, +reseller CHAR(40) NOT NULL DEFAULT '', +language CHAR(10) NOT NULL DEFAULT '', +pricelist CHAR(40) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +validfordays CHAR(4) NOT NULL DEFAULT '', +pin INTEGER NOT NULL DEFAULT 0, +maint_fee_pennies INTEGER NOT NULL DEFAULT 0, +maint_fee_days INTEGER NOT NULL DEFAULT 0, +disconnect_fee_pennies INTEGER NOT NULL DEFAULT 0, +minute_fee_minutes INTEGER NOT NULL DEFAULT 0, +minute_fee_pennies INTEGER NOT NULL DEFAULT 0, +min_length_minutes INTEGER NOT NULL DEFAULT 0, +min_length_pennies INTEGER NOT NULL DEFAULT 0, +PRIMARY KEY (`name`), + KEY `reseller` (`reseller`), + KEY `pricelist` (`pricelist`) +); + +DROP TABLE IF EXISTS `callingcardcdrs`; +CREATE TABLE callingcardcdrs ( +id INTEGER NOT NULL AUTO_INCREMENT, +cardnumber CHAR(50) NOT NULL DEFAULT '', +clid CHAR(80) NOT NULL DEFAULT '', +destination CHAR(40) NOT NULL DEFAULT '', +disposition CHAR(20)NOT NULL DEFAULT '', +callstart CHAR(40) NOT NULL DEFAULT '', +seconds INTEGER NOT NULL DEFAULT 0, +debit DECIMAL(20,6) NOT NULL DEFAULT 0.00000, +credit DECIMAL(20,6) NOT NULL DEFAULT 0.00000, +status INTEGER DEFAULT 0 NOT NULL, +uniqueid VARCHAR(32) NOT NULL DEFAULT '', +notes CHAR(80) NOT NULL DEFAULT '', +pricelist CHAR(80) NOT NULL DEFAULT '', +pattern CHAR(80) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + KEY `cardnumber` (`cardnumber`) +); + +DROP TABLE IF EXISTS `trunks`; +CREATE TABLE trunks ( +name VARCHAR(30) NOT NULL, +tech CHAR(10) NOT NULL DEFAULT '', +path CHAR(40) NOT NULL DEFAULT '', +provider CHAR(100) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +dialed_modify TEXT NOT NULL DEFAULT '', +resellers TEXT NOT NULL DEFAULT '', +precedence INT(4) NOT NULL DEFAULT 0, +maxchannels INTEGER DEFAULT 0 NOT NULL, + PRIMARY KEY (`name`), + KEY `provider` (`provider`), + KEY `provider_2` (`provider`) +); + +DROP TABLE IF EXISTS `outbound_routes`; +CREATE TABLE outbound_routes ( +pattern CHAR(40), +id INTEGER NOT NULL AUTO_INCREMENT, +comment CHAR(80) NOT NULL DEFAULT '', +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +trunk CHAR(80) NOT NULL DEFAULT '', +inc CHAR(10) NOT NULL DEFAULT '', +strip CHAR(40) NOT NULL DEFAULT '', +prepend CHAR(40) NOT NULL DEFAULT '', +precedence INT(4) NOT NULL DEFAULT 0, +resellers TEXT NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `trunk` (`trunk`), + KEY `pattern` (`pattern`) +); + +DROP TABLE IF EXISTS `dids`; +CREATE TABLE dids ( +number CHAR(40) NOT NULL, +account CHAR(50) NOT NULL DEFAULT '', +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +monthlycost INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +inc CHAR(10) NOT NULL DEFAULT '', +extensions CHAR(180) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +provider CHAR(40) NOT NULL DEFAULT '', +country CHAR (80)NOT NULL DEFAULT '', +province CHAR (80) NOT NULL DEFAULT '', +city CHAR (80) NOT NULL DEFAULT '', +prorate int(1) NOT NULL default 0, +setup int(11) NOT NULL default 0, +limittime int(1) NOT NULL default 1, +disconnectionfee INT(11) NOT NULL default 0, +variables TEXT NOT NULL DEFAULT '', +options varchar(40) default NULL, +maxchannels int(4) NOT NULL default 0, +chargeonallocation int(1) NOT NULL default 1, +allocation_bill_status int(1) NOT NULL default 0, +dial_as CHAR(40) NOT NULL DEFAULT '', +PRIMARY KEY (`number`), + KEY `account` (`account`) +); + +DROP TABLE IF EXISTS `accounts`; +CREATE TABLE accounts ( +cc CHAR(20) NOT NULL DEFAULT '', +number CHAR(50) NOT NULL, +reseller CHAR(40) NOT NULL DEFAULT '', +pricelist CHAR(24) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +credit INTEGER NOT NULL DEFAULT 0, +sweep INTEGER NOT NULL DEFAULT 0, +creation TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, +pin INTEGER NOT NULL DEFAULT 0, +credit_limit INTEGER NOT NULL DEFAULT 0, +posttoexternal INTEGER NOT NULL DEFAULT 0, +balance DECIMAL(20,6) NOT NULL DEFAULT 0, +password CHAR(80) NOT NULL DEFAULT '', +first_name CHAR(40) NOT NULL DEFAULT '', +middle_name CHAR(40) NOT NULL DEFAULT '', +last_name CHAR(40) NOT NULL DEFAULT '', +company_name CHAR(40) NOT NULL DEFAULT '', +address_1 CHAR(80) NOT NULL DEFAULT '', +address_2 CHAR(80) NOT NULL DEFAULT '', +address_3 CHAR(80) NOT NULL DEFAULT '', +postal_code CHAR(12) NOT NULL DEFAULT '', +province CHAR(40) NOT NULL DEFAULT '', +city CHAR(80) NOT NULL DEFAULT '', +country CHAR(40) NOT NULL DEFAULT '', +telephone_1 CHAR(40) NOT NULL DEFAULT '', +telephone_2 CHAR(40) NOT NULL DEFAULT '', +fascimile CHAR(40) NOT NULL DEFAULT '', +email CHAR(80) NOT NULL DEFAULT '', +language CHAR(2) NOT NULL DEFAULT '', +currency CHAR(3) NOT NULL DEFAULT '', +maxchannels INTEGER DEFAULT 1 NOT NULL, +routing_technique INT(4) NOT NULL DEFAULT 0, +dialed_modify TEXT NOT NULL DEFAULT '', +type INTEGER DEFAULT 0, +tz CHAR(40) NOT NULL DEFAULT '', +PRIMARY KEY (`number`), + KEY `pricelist` (`pricelist`), + KEY `reseller` (`reseller`) +); + +DROP TABLE IF EXISTS `counters`; +CREATE TABLE counters ( +id INTEGER NOT NULL AUTO_INCREMENT, +package CHAR(40) NOT NULL DEFAULT '', +account VARCHAR(50) NOT NULL, +seconds INTEGER NOT NULL DEFAULT 0, +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`) +); + +DROP TABLE IF EXISTS `callingcards`; +CREATE TABLE callingcards ( +id INTEGER NOT NULL AUTO_INCREMENT, +cardnumber CHAR(20) NOT NULL DEFAULT '', +language CHAR(10) NOT NULL DEFAULT '', +value INTEGER NOT NULL DEFAULT 0, +used INTEGER NOT NULL DEFAULT 0, +brand VARCHAR(20) NOT NULL DEFAULT '', +created DATETIME, +firstused DATETIME, +expiry DATETIME, +validfordays CHAR(4) NOT NULL DEFAULT '', +inuse INTEGER NOT NULL DEFAULT 0, +pin CHAR(20), +account VARCHAR(50) NOT NULL DEFAULT '', +maint_fee_pennies INTEGER NOT NULL DEFAULT 0, +maint_fee_days INTEGER NOT NULL DEFAULT 0, +maint_day INTEGER NOT NULL DEFAULT 0, +disconnect_fee_pennies INTEGER NOT NULL DEFAULT 0, +minute_fee_minutes INTEGER NOT NULL DEFAULT 0, +minute_fee_pennies INTEGER NOT NULL DEFAULT 0, +min_length_minutes INTEGER NOT NULL DEFAULT 0, +min_length_pennies INTEGER NOT NULL DEFAULT 0, +timeused INTEGER NOT NULL DEFAULT 0, +invoice CHAR(20) NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `brand` (`brand`) +); + +CREATE TABLE charge_to_account ( +id INTEGER NOT NULL AUTO_INCREMENT, +charge_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(50) NOT NULL DEFAULT '', +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`) +); + +CREATE TABLE queue_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +queue_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE pbx_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +pbx_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE extension_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +extension_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE cdrs ( +id INTEGER NOT NULL AUTO_INCREMENT, +uniqueid varchar(32) NOT NULL DEFAULT '', +cardnum CHAR(50), +callerid CHAR(80), +callednum varchar(80) NOT NULL DEFAULT '', +billseconds INT DEFAULT 0 NOT NULL, +trunk VARCHAR(30), +disposition varchar(45) NOT NULL DEFAULT '', +callstart varchar(80) NOT NULL DEFAULT '', +debit DECIMAL (20,6) NOT NULL DEFAULT 0, +credit DECIMAL (20,6) NOT NULL DEFAULT 0, +status INTEGER DEFAULT 0 NOT NULL, +notes CHAR(80), +provider CHAR(50), +cost DECIMAL(20,6) NOT NULL DEFAULT 0, +pricelist CHAR(80) NOT NULL DEFAULT '', +pattern CHAR(80) NOT NULL DEFAULT '', +PRIMARY KEY (`id`), + KEY `cardnum` (`cardnum`), + KEY `provider` (`provider`), + KEY `trunk` (`trunk`), + KEY `uniqueid` (`uniqueid`), + KEY `status` (`status`) +); + +CREATE TABLE packages ( +id INTEGER NOT NULL AUTO_INCREMENT, +name CHAR(40) NOT NULL DEFAULT '', +pricelist CHAR(40) NOT NULL DEFAULT '', +pattern CHAR(40) NOT NULL DEFAULT '', +includedseconds INTEGER NOT NULL DEFAULT 0, +reseller VARCHAR(50) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `pricelist` (`pricelist`), + KEY `reseller` (`reseller`) +); + +CREATE TABLE ani_map ( +number char(20) NOT NULL, +account char(50) NOT NULL default '', +status int(11) NOT NULL default '0', +context varchar(20) NOT NULL, + PRIMARY KEY (`number`), +KEY `account` (`account`) +); + +CREATE TABLE `ip_map` ( +ip char(15) NOT NULL default '', +account char(20) NOT NULL default '', +prefix varchar(20) NULL, +context varchar(20) NOT NULL, +PRIMARY KEY (`ip`,`prefix`), +KEY `account` (`account`) +); + +CREATE TABLE charges ( +id INTEGER NOT NULL AUTO_INCREMENT, +pricelist CHAR(40) NOT NULL DEFAULT '', +description VARCHAR(80) NOT NULL DEFAULT '', +charge INTEGER NOT NULL DEFAULT 0, +sweep INTEGER NOT NULL DEFAULT 0, +reseller CHAR(40) NOT NULL DEFAULT '', +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`), + KEY `pricelist` (`pricelist`) +); + +CREATE TABLE manager_action_variables ( +id INTEGER NOT NULL AUTO_INCREMENT, +name CHAR(60) NOT NULL DEFAULT '', +value CHAR(60) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE callingcard_stats ( +uniqueid VARCHAR(48) NOT NULL, +total_time VARCHAR(48) NOT NULL, +billable_time VARCHAR(48) NOT NULL, +timestamp DATETIME NULL, +PRIMARY KEY (`uniqueid`) +); + +CREATE TABLE system ( +name VARCHAR(48) NULL, +value VARCHAR(255) NULL, +comment VARCHAR(255) NULL, +timestamp DATETIME NULL, +reseller VARCHAR(48) NULL, +brand VARCHAR(48) NULL, +PRIMARY KEY (`name`), + KEY `reseller` (`reseller`), + KEY `brand` (`brand`) +); + + +INSERT INTO system (name, value, comment) VALUES ( +'callout_accountcode','admin','Call Files: What accountcode should we use?'); + +INSERT INTO system (name, value, comment) VALUES ( +'lcrcontext','astpp-outgoing','This is the Local context we use to route our outgoing calls through esp for callbacks'); + +INSERT INTO system (name, value, comment) VALUES ( +'maxretries','3','Call Files: How many times do we retry?'); + +INSERT INTO system (name, value, comment) VALUES ( +'retrytime','30','Call Files: How long do we wait between retries?'); + +INSERT INTO system (name, value, comment) VALUES ( +'waittime','15','Call Files: How long do we wait before the initial call?'); + +INSERT INTO system (name, value, comment) VALUES ( +'clidname','Private','Call Files: Outgoing CallerID Name'); + +INSERT INTO system (name, value, comment) VALUES ( +'clidnumber','0000000000','Call Files: Outgoing CallerID Number'); + +INSERT INTO system (name, value, comment) VALUES ( +'callingcards_callback_context','astpp-callingcards','Call Files: For callingcards what context do we end up in?'); + +INSERT INTO system (name, value, comment) VALUES ( +'callingcards_callback_extension', 's','Call Files: For callingcards what extension do we use?'); + +INSERT INTO system (name, value, comment) VALUES ( +'openser_dbengine', 'MySQL','For now this must be MySQL'); + +INSERT INTO system (name, value, comment) VALUES ( +'openser', '0','Use OPENSER? 1 for yes or 0 for no'); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbname', 'openser','OPENSER Database Name', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbuser', 'root','OPENSER Database User', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbhost', 'localhost','OPENSER Database Host', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbpass', 'Passw0rd','OPENSER Database Password', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_domain', NULL,'OPENSER Domain', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_email', 'em...@as...','Email address that email should appear to be from', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'asterisk_dir', '/etc/asterisk','Which directory are asterisk configuration files stored in?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_website', 'http://www.astpp.org','Link to your company website', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_name', 'ASTPP.ORG','The name of your company. Used in emails.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'email', '1','Send out email? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'user_email', '1','Email user on account changes? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'debug', '0','Enable debugging output? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'emailadd', 'em...@as...','Administrator email address', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'startingdigit', '0','The digit that all calling cards must start with. 0=disabled', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'enablelcr', '1','Use least cost routing 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'log_file', '/var/log/astpp/astpp.log','ASTPP Log file', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'key_home', 'http://www.astpp.org/astpp.pub','Asterisk RSA Key location (optional)', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rate_engine_csv_file', '/var/log/astpp/astpp.csv','CSV File for call rating data', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'csv_dir', '/var/log/astpp/','CSV File Directory', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_brand', 'default','Default pricelist. If a price is not found in the customers pricelist we check this one.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'new_user_brand', 'default','What is the default pricelist for new customers?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_context', 'custom-astpp','What is the default context for new devices?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cardlength', '10','Number of digits in calling cards and cc codes.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'asterisk_server', 'voip.astpp.org','Your default voip server. Used in outgoing email.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'currency', 'CAD','Name of the currency you use', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'iax_port', '4569','Default IAX2 Port', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'sip_port', '5060','Default SIP Port', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'ipaddr', 'dynamic','Default IP Address for new devices', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'key', 'astpp.pub','Asterisk RSA Key Name (Optional)', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'pinlength', '6','For those calling cards that are using pins this is the number of digits it will have.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'credit_limit', '0','Default credit limit in dollars.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'decimalpoints', '4','How many decimal points do we bill to?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'max_free_length', '100','What is the maximum length (in minutes) of calls that are at no charge?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'trackvendorcharges', '1','Do we track the amount of money we spend with specific providers? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_logo', 'http://www.astpp.org/logo.png','The location of our company logo.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_slogan', 'Welcome to ASTPP','Company slogan', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'version', '1.5Beta', 'ASTPP Version', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_language', 'en', 'Default ASTPP Language',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'card_retries','3', 'How many retries do we allow for calling card numbers?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'pin_retries','3', 'How many retries do we allow for pins?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'number_retries','3','How many retries do we allow calling card users when dialing a number?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'booth_context','callshop_booth','Please enter the default context for a callshop booth.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'callingcards_max_length','9000','What is the maximum length (in ms) of a callingcard call?',''); + +INSERT INTO system (name,value,comment,timestamp) VALUES ( +'template_die_on_bad_params','0','Should HTML::Template die on bad parameters?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'results_per_page','30','How many results per page do we should in the web interface?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astpp_dir','/var/lib/astpp','Where do the astpp configs live?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'auth','Passw0rd!','This is the override authorization code and will allow access to the system.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_dbengine','MySQL','Database type for Asterisk(tm) -Realtime',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbengine','MySQL','Database type for the cdr database',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_dbengine','MySQL','Database type for OSCommerce',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_dbengine','MySQL','Database type for AgileBill(tm)',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_dbengine','MySQL','Database type for FreePBX',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'externalbill','oscommerce','Please specify the external billing application to use. If you are not using any then leave it blank. Valid options are "agile" and "oscommerce".',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'callingcards','1','Do you wish to enable calling cards? 1 for yes and 2 for no.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astcdr','1','Change this one at your own peril. If you switch it off, calls will not be marked as billed in asterisk once they are billed.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'posttoastpp','1','Change this one at your own peril. If you switch it off, calls will not be written to astpp when they are calculated.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'sleep','10','How long shall the rating engine sleep after it has been notified of a hangup? (in seconds)',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'users_dids_amp','0','If this is enabled, ASTPP will create users and DIDs in the FreePBX (www.freepbx.org) database.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'users_dids_rt','1','If this is enabled, ASTPP will create users and DIDs in the Asterisk Realtime database.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'users_dids_freeswitch','0','If this is enabled, ASTPP will create SIP users in the freeswitch database.',''); + + +INSERT INTO system (name, value, comment) VALUES ( +'service_prepend','778',''); +INSERT INTO system (name, value, comment) VALUES ( +'service_length,','7',''); +INSERT INTO system (name, value, comment) VALUES ( +'service_filler','4110000',''); + +INSERT INTO system (name, value, comment) VALUES ( +'asterisk_cdr_table','cdr','Which table of the Asterisk(TM) database are the cdrs in?'); + +-- AgileBill(Trademark of AgileCo) Settings: +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_db','agile','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_pass','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_site_id','1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_charge_status','0','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_taxable','1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_dbprefix','_','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_service_prepend','778','',''); + +-- OSCommerce Settings (www.oscommerce.org) +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_db','oscommerce','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_pass','password','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_product_id','99999999','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_payment_method','"Charge"','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_order_status','1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_post_nc','0','Do we post "free" items to the oscommerce invoice? 0=No 1=Yes',''); + +-- FreePBX Settings (www.freepbx.org) +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_db','asterisk','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_pass','passw0rd','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_table','iax','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_table','sip','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_extensions_table','extensions','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_codec_allow','g729,ulaw,alaw','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_codec_disallow','all','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_mailbox_group','default','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_nat','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_canreinvite','no','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_dtmfmode','rfc2833','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_callgroup','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_pickupgroup','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_notransfer','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_qualify','yes','',''); + +-- Asterisk -realtime Settings +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_db','realtime','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_pass','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_table','iax','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_table','sip','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_extensions_table','extensions','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_insecure','very','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_nat','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_canreinvite','no','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_codec_allow','g729,ulaw,alaw','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_codec_disallow','all','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_mailbox_group','default','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_type','friend','',''); +INSERT INTO system (name, value, comment) VALUES ( +'rt_voicemail_table','voicemail_users',''); + + +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_rate_announce','1','Do we want the calling cards script to announce the rate on calls?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_timelimit_announce','1','Do we want the calling cards script to announce the timelimit on calls?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_cancelled_prompt','1','Do we want the calling cards script to announce that the call was cancelled?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_menu','1','Do we want the calling cards script to present a menu before exiting?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_connection_prompt','1','Do we want the calling cards script to announce that it is connecting the call?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_pin_input_timeout','15000','How long do we wait when entering the calling card pin? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_number_input_timeout','15000','How long do we wait when entering the calling card number? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_dial_input_timeout','15000','How long do we wait when entering the destination number in calling cards? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_general_input_timeout','15000','How long do we wait for input in general menus? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_welcome_file','silence/1','What do we play for a welcome file?'); + +INSERT INTO system (name, value, comment) VALUES ( +'sip_ext_prepend','10','What should every autoadded SIP extension begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'iax2_ext_prepend','10','What should every autoadded IAX2 extension begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'cc_prepend','','What should every autoadded callingcard begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'pin_cc_prepend','','What should every autoadded callingcard pin begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'pin_act_prepend','','What should every autoadded account pin begin with?'); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_directory','/usr/local/freeswitch','What is the Freeswitch root directory?'); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_password','ClueCon','Freeswitch event socket password'); +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_host','localhost','Freeswitch event socket host'); +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_port','8021','Freeswitch event socket port'); +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_timeout','30','Freeswitch seconds to expect a heartbeat event or reconnect'); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_dbengine', 'MySQL','For now this must be MySQL'); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freeswitch_dbname', 'freeswitch','Freeswitch Database Name', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freeswitch_dbuser', 'root','Freeswitch Database User', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freeswitch_dbhost', 'localhost','Freeswitch Database Host', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freeswitch_dbpass', 'Passw0rd','Freeswitch Database Password', ''); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_cdr_table','fscdr','Which table of the cdr database are the Freeswitch cdrs in?'); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_domain','$${local_ip_v4}','This is entered as the Freeswitch domain.'); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_context','default','This is entered as the Freeswitch user context.'); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbname', 'asteriskcdrdb', +'CDR Database Name', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbuser', 'root', +'CDR Database User', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbhost', 'localhost', +'CDR Database Host', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbpass', 'Passw0rd', +'CDR Database Password', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astman_user', 'admin','Asterisk(tm) Manager Interface User', ''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astman_host', 'localhost','Asterisk(tm) Manager Interface Host', ''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astman_secret', 'amp111','Asterisk(tm) Manager Interface Secret', ''); + + +-- +-- Enough Configuration settings +-- + +DROP TABLE IF EXISTS `countrycode`; +CREATE TABLE `countrycode` ( + `country` varchar(255) NOT NULL, + PRIMARY KEY (`country`), + KEY `country` (`country`) +); + +INSERT INTO `countrycode` (`country`) VALUES + ('Afghanistan'), + ('Alaska'), + ('Albania'), + ('Algeria'), + ('AmericanSamoa'), + ('Andorra'), + ('Angola'), + ('Antarctica'), + ('Argentina'), + ('Armenia'), + ('Aruba'), + ('Ascension'), + ('Australia'), + ('Austria'), + ('Azerbaijan'), + ('Bahrain'), + ('Bangladesh'), + ('Belarus'), + ('Belgium'), + ('Belize'), + ('Benin'), + ('Bhutan'), + ('Bolivia'), + ('Bosnia & Herzegovina'), + ('Botswana'), + ('Brazil'), + ('Brunei Darussalam'), + ('Bulgaria'), + ('Burkina Faso'), + ('Burundi'), + ('Cambodia'), + ('Cameroon'), + ('Canadda'), + ('Cape Verde Islands'), + ('Central African Republic'), + ('Chad'), + ('Chile'), + ('China'), + ('Colombia'), + ('Comoros'), + ('Congo'), + ('Cook Islands'), + ('Costa Rica'), + ('Croatia'), + ('Cuba'), + ('Cuba Guantanamo Bay'), + ('Cyprus'), + ('Czech Republic'), + ('Denmark'), + ('Diego Garcia'), + ('Djibouti'), + ('Dominican Republic'), + ('East Timor'), + ('Ecuador'), + ('Egypt'), + ('El Salvador'), + ('Equatorial Guinea'), + ('Eritrea'), + ('Estonia'), + ('Ethiopia'), + ('Faroe Islands'); +INSERT INTO `countrycode` (`country`) VALUES + ('Fiji Islands'), + ('Finland'), + ('France'), + ('French Guiana'), + ('French Polynesia'), + ('Gabonese Republic'), + ('Gambia'), + ('Georgia'), + ('Germany'), + ('Ghana'), + ('Gibraltar'), + ('Greece'), + ('Greenland'), + ('Guadeloupe'), + ('Guam'), + ('Guatemala'), + ('Guinea'), + ('Guyana'), + ('Haiti'), + ('Honduras'), + ('Hong Kong'), + ('Hungary'), + ('Iceland'), + ('India'), + ('Indonesia'), + ('Iran'), + ('Iraq'), + ('Ireland'), + ('Israel'), + ('Italy'), + ('Jamaica'), + ('Japan'), + ('Jordan'), + ('Kazakstan'), + ('Kenya'), + ('Kiribati'), + ('Kuwait'), + ('Kyrgyz Republic'), + ('Laos'), + ('Latvia'), + ('Lebanon'), + ('Lesotho'), + ('Liberia'), + ('Libya'), + ('Liechtenstein'), + ('Lithuania'), + ('Luxembourg'), + ('Macao'), + ('Madagascar'), + ('Malawi'), + ('Malaysia'), + ('Maldives'), + ('Mali Republic'), + ('Malta'), + ('Marshall Islands'), + ('Martinique'), + ('Mauritania'), + ('Mauritius'), + ('MayotteIsland'), + ('Mexico'), + ('Midway Islands'), + ('Moldova'), + ('Monaco'), + ('Mongolia'), + ('Morocco'); +INSERT INTO `countrycode` (`country`) VALUES + ('Mozambique'), + ('Myanmar'), + ('Namibia'), + ('Nauru'), + ('Nepal'), + ('Netherlands'), + ('Netherlands Antilles'), + ('New Caledonia'), + ('New Zealand'), + ('Nicaragua'), + ('Niger'), + ('Nigeria'), + ('Niue'), + ('Norfolk Island'), + ('North Korea'), + ('Norway'), + ('Oman'), + ('Pakistan'), + ('Palau'), + ('Palestinian Settlements'), + ('Panama'), + ('PapuaNew Guinea'), + ('Paraguay'), + ('Peru'), + ('Philippines'), + ('Poland'), + ('Portugal'), + ('Puerto Rico'), + ('Qatar'), + ('RéunionIsland'), + ('Romania'), + ('Russia'), + ('Rwandese Republic'), + ('San Marino'), + ('São Tomé and Principe'), + ('Saudi Arabia'), + ('Senegal '), + ('Serbia and Montenegro'), + ('Seychelles Republic'), + ('Sierra Leone'), + ('Singapore'), + ('Slovak Republic'), + ('Slovenia'), + ('Solomon Islands'), + ('Somali Democratic Republic'), + ('South Africa'), + ('South Korea'), + ('Spain'), + ('Sri Lanka'), + ('St Kitts - Nevis'), + ('St. Helena'), + ('St. Lucia'), + ('St. Pierre & Miquelon'), + ('St. Vincent & Grenadines'), + ('Sudan'); +INSERT INTO `countrycode` (`country`) VALUES + ('Suriname'), + ('Swaziland'), + ('Sweden'), + ('Switzerland'), + ('Syria'), + ('Taiwan'), + ('Tajikistan'), + ('Tanzania'), + ('Thailand'), + ('Togolese Republic'), + ('Tokelau'), + ('Tonga Islands'), + ('Trinidad & Tobago'), + ('Tunisia'), + ('Turkey'), + ('Turkmenistan'), + ('Tuvalu'), + ('Uganda'), + ('Ukraine'), + ('United Arab Emirates'), + ('United Kingdom'), + ('United States of America'), + ('Uruguay'), + ('Uzbekistan'), + ('Vanuatu'), + ('Venezuela'), + ('Vietnam'), + ('Wake Island'), + ('Wallisand Futuna Islands'), + ('Western Samoa'), + ('Yemen'), + ('Zambia'), + ('Zimbabwe'); + +DROP TABLE IF EXISTS `currency`; +CREATE TABLE `currency` ( + `Currency` varchar(3) NOT NULL default '', + `CurrencyName` varchar(40) NOT NULL default '', + PRIMARY KEY (`Currency`) +); + +INSERT INTO `currency` (`Currency`,`CurrencyName`) VALUES + ('USD','US Dollars'), + ('CAD','Canadian Dollars'), + ('AUD','Australian Dollars'); + +CREATE TABLE `language` ( + `language` varchar(5) NOT NULL, + `languagename` varchar(40) NOT NULL, + `active` tinyint(1) NOT NULL default '1', + PRIMARY KEY (`language`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +INSERT INTO `language` (`language`,`languagename`,`active`) VALUES + ('en','English',1), + ('fr','French',1), + ('de','German',1); + +CREATE TABLE `resellers` ( + name varchar(40) NOT NULL default '', + status int(11) NOT NULL default '1', + posttoexternal int(11) NOT NULL default '0', + agile_site_id int(11) NOT NULL default '0', + config_file char(80) NOT NULL default 'reseller.conf', + companyname varchar(255) default NULL, + slogan varchar(255) default NULL, + footer varchar(255) default NULL, + pricelist varchar(255) default NULL, + currency varchar(255) default NULL, + logo varchar(255) default NULL, + website varchar(255) default NULL, + adminemail varchar(255) default NULL, + salesemail varchar(255) default NULL, + phone varchar(45) default NULL, + fax varchar(45) default NULL, + address1 varchar(255) default NULL, + address2 varchar(255) default NULL, + city varchar(255) default NULL, + state varchar(255) default NULL, + postcode varchar(255) default NULL, + country varchar(255) default NULL, + defaultbrand varchar(45) NOT NULL default 'default', + defaultcurrency varchar(45) NOT NULL default 'USD', + defaultcredit varchar(45) NOT NULL default '0.00', + externalbill varchar(45) NOT NULL default '', + PRIMARY KEY (`name`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + +CREATE TABLE templates ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(45) NOT NULL default '', +reseller VARCHAR(45) NOT NULL default '', +template TEXT NOT NULL default '', + PRIMARY KEY (`id`), + KEY `reseller` (`reseller`) +); + +INSERT INTO templates (name,template) VALUES +('voip_account_refilled','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been refilled. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('voip_reactivate_account','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been reactivated. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_add_user','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been added. +Your Username is -- $vars->{extension} -- +Your Password is -- $vars->{secret} -- +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('add_sip_device','Attention: $vars->{title} $vars->{first} $vars->{last} +A new device has been enabled on your account. Here +is the necessary configuration information. +------- $config->{company_name} Configuration Info -------- +In sip.conf: +[$config->{company_name}-in] +type=user +username=$config->{company_name}-in +auth=rsa +inkeys=$config->{key} ;This key may be downloaded from $config->{key_home} +host=$config->{asterisk_server} +context=from-pstn +accountcode=$config->{company_name} +[$config->{company_name}] +type=peer +username=$vars->{extension} +secret=$vars->{secret} +host=$config->{asterisk_server} +callerid= <555-555-5555> +qualify=yes +accountcode=$config->{company_name} ; for call tracking in the cdr +In the [globals] section add: +register => $vars->{user}:password@$config->{asterisk_server}'); + +INSERT INTO templates (name,template) VALUES +('add_iax_device','Attention: $vars->{title} $vars->{first} $vars->{last} +A new device has been enabled on your account. Here +is the necessary configuration information. +------- $config->{company_name} Configuration Info -------- +In iax.conf: +At the bottom of the file add: +[$config->{company_name}-in] +;trunk=yes ;optional .. only works if you have a zaptel or ztdummy driver running +type=user +username=$config->{company_name}-in +auth=rsa +inkeys=$config->{key} ;This key may be downloaded from $config->{key_home} +host=$config->{asterisk_server} +context=incoming +accountcode=$config->{company_name} ;for call tracking in the cdr +[$config->{company_name}] +;to simplify and config outgoing calls +;trunk=yes ;optional .. only works if you have a zaptel driver running +type=peer +username=$vars->{extension} +secret=$vars->{secret} +host=$config->{asterisk_server} +callerid=<555-555-5555> ;only the number will really be used +qualify=yes +accountcode=$config->{company_name} ; for call tracking in the cdr +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_remove_user','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP Termination with $config->{company_name} has been removed +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_calling_card','You have added a $vars->{pricelist} callingcard in the amount of $vars->{pennies} cents. +Card Number $cc Pin: $pin +Thanks for your patronage. +The $config->{company_name} sales team'); + +INSERT INTO templates (name,template) VALUES +('email_add_did','Attention: $vars->{title} $vars->{first} $vars->{last} +Your DID with $config->{company_name} has been added +The number is: $did +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team +Here is a sample setup which would call a few sip phones with incoming calls: +[incoming] +exten => _1$did,1,Wait(2) +exten => _1$did,2,Dial(SIP/2201&SIP/2202,15,Ttm) ; dial a couple of phones for 15 secs +exten => _1$did,3,Voicemail(u1000) ; go to unavailable voicemail (vm box 1000) +exten => _1$did,103,Voicemail(b1000) ; go to busy voicemail (vm box 1000)'); + +INSERT INTO templates (name,template) VALUES +('email_remove_did','Attention: $vars->{title} $vars->{first} $vars->{last} +Your DID with $config->{company_name} has been removed +The number was: $did +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_new_invoice','Invoice # $invoice in the amount of \$$total has been added to your account. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_low_balance','Your VOIP account with $config->{company_name} has a balance of \$$balance. +Please visit our website to refill your account to ensure uninterrupted service. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +CREATE TABLE `sweeplist` ( + `Id` int(10) unsigned NOT NULL default '0', + `sweep` varchar(45) NOT NULL default '', + PRIMARY KEY (`Id`) +); + +INSERT INTO sweeplist (Id,sweep) VALUES +(0,'daily'), +(1,'weekly'), +(2,'monthly'), +(3,'quarterly'), +(4,'semi-annually'), +(5,'annually') +; + +CREATE TABLE userlevels ( +userlevelid int(11) NOT NULL, +userlevelname varchar(50) NOT NULL, +PRIMARY KEY (`userlevelid`) +); + +INSERT INTO `userlevels` (`userlevelid`,`userlevelname`) VALUES + (-1,'Administrator'), + (0,'Anonymous'), + (1,'Reseller'), + (2,'Admin'), + (3,'Vendor'), + (4,'Customer Service'), + (5,'Users'); + +CREATE TABLE reseller_pricing ( +id INTEGER NOT NULL AUTO_INCREMENT, +reseller VARCHAR(50) NOT NULL, +type INTEGER NOT NULL DEFAULT 1, +monthlycost INTEGER NOT NULL DEFAULT 0, +prorate INTEGER NOT NULL DEFAULT 0, +setup INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +note VARCHAR(50) NOT NULL DEFAULT '', +disconnectionfee INTEGER NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +inc CHAR(10) NOT NULL DEFAULT '', +PRIMARY KEY (`id`), + KEY `reseller` (`reseller`) +); + +CREATE TABLE callshops ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(50) NOT NULL, +osc_dbname VARCHAR(50) NOT NULL DEFAULT '', +osc_dbpass VARCHAR(50) NOT NULL DEFAULT '', +osc_dbuser VARCHAR(50) NOT NULL DEFAULT '', +osc_dbhost VARCHAR(50) NOT NULL DEFAULT '', +osc_site VARCHAR(50) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), +KEY `name` (`name`) +); + +CREATE TABLE extensions_status ( +id INTEGER NOT NULL AUTO_INCREMENT, +tech VARCHAR(6) NULL, +extension VARCHAR(20) NULL, +number VARCHAR(255) NULL, +status VARCHAR(255) NULL, +timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, +Privilege VARCHAR(255) NULL, +Channel VARCHAR(255) NULL, +Cause VARCHAR(255) NULL, +Causetxt VARCHAR(255) NULL, +PeerStatus VARCHAR(255) NULL, +Peer VARCHAR(255) NULL, +Context VARCHAR(255) NULL, +Application VARCHAR(255) NULL, +AppData VARCHAR(255) NULL, +Priority VARCHAR(255) NULL, +Uniqueid VARCHAR(255) NULL, +Event VARCHAR(255) NULL, +State VARCHAR(255) NULL, +CallerIDName VARCHAR(255) NULL, +CallerID VARCHAR(255) NULL, +AstExtension VARCHAR(255) NULL, +PRIMARY KEY (`id`), +KEY `extension` (`extension`)); + +CREATE TABLE activity_logs ( +id INTEGER NOT NULL AUTO_INCREMENT, +timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, +message TEXT NOT NULL DEFAULT '', +user VARCHAR(50), +PRIMARY KEY (`id`)); + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-11-25 06:23:01
|
Revision: 2212 http://astpp.svn.sourceforge.net/astpp/?rev=2212&view=rev Author: darrenkw Date: 2008-11-25 06:22:52 +0000 (Tue, 25 Nov 2008) Log Message: ----------- Add Thirdlane(tm) specific code. Modified Paths: -------------- trunk/astpp-common.pl trunk/sql/astpp-2008-11-24.sql Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2008-11-25 05:24:17 UTC (rev 2211) +++ trunk/astpp-common.pl 2008-11-25 06:22:52 UTC (rev 2212) @@ -1721,9 +1721,27 @@ sub get_route() { my ( $astpp_db, $config, $destination, $pricelist, $carddata, $type ) = @_; my ( $record, $sql, $tmp ); - - if ($type !~ /ASTPP-DID/) - { + if ($type =~ /ASTPP-DID/) { + print STDERR "Call belongs to a DID.\n"; + $record = &get_did_reseller($astpp_db,$destination,$carddata->{reseller}) if $carddata->{reseller} ne ""; + $record = &get_did($astpp_db,$destination) if $carddata->{reseller} eq ""; + $record->{comment} = $record->{city} . "," . $record->{province} . "," . $record->{country}; + $record->{pattern} = "DID:" . $destination; + my $branddata = &get_pricelist( $astpp_db, $pricelist); + print STDERR "pattern: $record->{pattern}\n" if $record->{pattern}; + } + elsif ($config->{thirdlane_mods} == 1 && $type =~ m/.\d\d\d-IN/) { + print STDERR "Call belongs to a Thirdlane(tm) DID.\n"; + $destination = $type =~ s/-IN//g; + print STDERR "Destination: $destination \n"; + $record = &get_did_reseller($astpp_db,$destination,$carddata->{reseller}) if $carddata->{reseller} ne ""; + $record = &get_did($astpp_db,$destination) if $carddata->{reseller} eq ""; + $record->{comment} = $record->{city} . "," . $record->{province} . "," . $record->{country}; + $record->{pattern} = "DID:" . $destination; + my $branddata = &get_pricelist( $astpp_db, $pricelist); + print STDERR "pattern: $record->{pattern}\n" if $record->{pattern}; + } + else { my @pricelists = split ( m/,/m, $pricelist ); foreach my $pricelistname (@pricelists) { $pricelistname =~ s/"//g; #Strip off quotation marks @@ -1759,16 +1777,6 @@ } print STDERR "Route: $record->{comment} Cost: $record->{cost} Pricelist: $record->{pricelist} Pattern: $record->{pattern}\n" if $record; } - elsif ($type =~ /ASTPP-DID/) - { - print STDERR "Call belongs to a DID.\n"; - $record = &get_did_reseller($astpp_db,$destination,$carddata->{reseller}) if $carddata->{reseller} ne ""; - $record = &get_did($astpp_db,$destination) if $carddata->{reseller} eq ""; - $record->{comment} = $record->{city} . "," . $record->{province} . "," . $record->{country}; - $record->{pattern} = "DID:" . $destination; - my $branddata = &get_pricelist( $astpp_db, $pricelist); - print STDERR "pattern: $record->{pattern}\n" if $record->{pattern}; - } if ( $record->{inc} eq "" || $record->{inc} == 0 ) { my $branddata = &get_pricelist( $astpp_db, $pricelist); $record->{inc} = $branddata->{inc}; @@ -3908,16 +3916,23 @@ sub cleanup_cdrs() { my ($cdr_db, $config) = @_; # First we cleanup all calls that are not answered - $cdr_db->do("UPDATE $config->{asterisk_cdr_table} SET cost = '0' WHERE disposition REGEXP 'NO ANSWER'") if $config->{astcdr} == 1; - $cdr_db->do("UPDATE $config->{asterisk_cdr_table} SET vendor = '0' WHERE disposition REGEXP 'NO ANSWER'") if $config->{astcdr} == 1 && $config->{trackvendorcharges} == 1; - $cdr_db->do("UPDATE $config->{asterisk_cdr_table} SET cost = '0' WHERE disposition REGEXP 'BUSY'") if $config->{astcdr} == 1; - $cdr_db->do("UPDATE $config->{asterisk_cdr_table} SET vendor = '0' WHERE disposition REGEXP 'BUSY'") if $config->{astcdr} == 1 && $config->{trackvendorcharges} == 1; - $cdr_db->do("UPDATE $config->{asterisk_cdr_table} SET cost = '0' WHERE disposition REGEXP 'FAILED'") if $config->{astcdr} == 1; - $cdr_db->do("UPDATE $config->{asterisk_cdr_table} SET vendor = '0' WHERE disposition REGEXP 'FAILED'") if $config->{astcdr} == 1 && $config->{trackvendorcharges} == 1; - $cdr_db->do("UPDATE $config->{asterisk_cdr_table} SET cost = '0' WHERE disposition REGEXP 'CONGESTION'") if $config->{astcdr} == 1; - $cdr_db->do("UPDATE $config->{asterisk_cdr_table} SET vendor = '0' WHERE disposition REGEXP 'CONGESTION'") if $config->{astcdr} == 1 && $config->{trackvendorcharges} == 1; - $cdr_db->do("UPDATE $config->{asterisk_cdr_table} SET cost = '0' WHERE disposition REGEXP 'CANCEL'") if $config->{astcdr} == 1; - $cdr_db->do("UPDATE $config->{asterisk_cdr_table} SET vendor = '0' WHERE disposition REGEXP 'CANCEL'") if $config->{astcdr} == 1 && $config->{trackvendorcharges} == 1; + if ($config->{astcdr} == 1) { + $cdr_db->do("UPDATE $config->{asterisk_cdr_table} SET cost = '0' WHERE disposition REGEXP 'NO ANSWER'"); + $cdr_db->do("UPDATE $config->{asterisk_cdr_table} SET cost = '0' WHERE disposition REGEXP 'BUSY'"); + $cdr_db->do("UPDATE $config->{asterisk_cdr_table} SET cost = '0' WHERE disposition REGEXP 'FAILED'"); + $cdr_db->do("UPDATE $config->{asterisk_cdr_table} SET cost = '0' WHERE disposition REGEXP 'CONGESTION'"); + $cdr_db->do("UPDATE $config->{asterisk_cdr_table} SET cost = '0' WHERE disposition REGEXP 'CANCEL'"); + if ($config->{trackvendorcharges} == 1) { + $cdr_db->do("UPDATE $config->{asterisk_cdr_table} SET vendor = '0' WHERE disposition REGEXP 'NO ANSWER'"); + $cdr_db->do("UPDATE $config->{asterisk_cdr_table} SET vendor = '0' WHERE disposition REGEXP 'BUSY'"); + $cdr_db->do("UPDATE $config->{asterisk_cdr_table} SET vendor = '0' WHERE disposition REGEXP 'FAILED'"); + $cdr_db->do("UPDATE $config->{asterisk_cdr_table} SET vendor = '0' WHERE disposition REGEXP 'CONGESTION'"); + $cdr_db->do("UPDATE $config->{asterisk_cdr_table} SET vendor = '0' WHERE disposition REGEXP 'CANCEL'"); + } + if ($config->{thirdlane_mods} == 1) { + $cdr_db->do("UPDATE cdr SET accountcode = userfield WHERE accountcode IN ('',NULL)"); + } + } } sub print_csv { # Print CDRS on rated calls. @@ -3950,6 +3965,11 @@ print STDERR "disposition: $cdrinfo->{disposition} Pricelist: $carddata->{pricelist} reseller: $carddata->{reseller}\n"; if ( $cdrinfo->{disposition} =~ /^ANSWERED$/ || $cdrinfo->{disposition} eq "NORMAL_CLEARING") { +# if ($config->{thirdlane_mods} == 1 && $cdrinfo->{userfield} =~ m/.\d\d\d-IN/) { +# print STDERR "Call belongs to a Thirdlane(tm) DID.\n"; +# $cdrinfo->{dst} =~ s/-IN//g; +# print STDERR "Destination: $cdrinfo->{dst} \n"; +# } $numdata = &get_route( $astpp_db, $config, $cdrinfo->{dst}, $carddata->{pricelist}, $carddata, $cdrinfo->{userfield} ); print STDERR "PATTERN: $numdata->{pattern}"; if ( !$numdata->{pattern} ) { Modified: trunk/sql/astpp-2008-11-24.sql =================================================================== --- trunk/sql/astpp-2008-11-24.sql 2008-11-25 05:24:17 UTC (rev 2211) +++ trunk/sql/astpp-2008-11-24.sql 2008-11-25 06:22:52 UTC (rev 2212) @@ -776,6 +776,9 @@ INSERT INTO system (name, value, comment, timestamp) VALUES ( 'astman_secret', 'amp111','Asterisk(tm) Manager Interface Secret', ''); +------ 3rd Party PBX Mods +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'thirdlane_mods','0','Provides a few different modifications across the rating code to work better with Thirdlane(tm) cdrs.',''); -- -- Enough Configuration settings @@ -1298,3 +1301,10 @@ user VARCHAR(50), PRIMARY KEY (`id`)); +CREATE TABLE sql_commands ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(45) NOT NULL default '', +sql TEXT NOT NULL default '', +comment TEXT NOT NULL default '', +timestamp TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, + PRIMARY KEY (`id`)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-12-02 03:35:42
|
Revision: 2214 http://astpp.svn.sourceforge.net/astpp/?rev=2214&view=rev Author: darrenkw Date: 2008-12-02 03:35:36 +0000 (Tue, 02 Dec 2008) Log Message: ----------- Repair the thirdlane DID billing handling. Modified Paths: -------------- trunk/astpp-common.pl trunk/contrib/auto_dialer/aleph-autocall.pl Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2008-12-02 02:39:15 UTC (rev 2213) +++ trunk/astpp-common.pl 2008-12-02 03:35:36 UTC (rev 2214) @@ -1732,7 +1732,7 @@ } elsif ($config->{thirdlane_mods} == 1 && $type =~ m/.\d\d\d-IN/) { print STDERR "Call belongs to a Thirdlane(tm) DID.\n"; - $destination = $type =~ s/-IN//g; + ($destination = $type) =~ s/-IN//g; print STDERR "Destination: $destination \n"; $record = &get_did_reseller($astpp_db,$destination,$carddata->{reseller}) if $carddata->{reseller} ne ""; $record = &get_did($astpp_db,$destination) if $carddata->{reseller} eq ""; @@ -4116,17 +4116,17 @@ print STDERR gettext("Processing Uniqueid: ") . $uniqueid . "\n"; $cdrinfo = ($vars) ? $vars : &get_cdr( $config, $cdr_db,$cdr_table, $uniqueid ); my $savedcdrinfo = $cdrinfo; - if(!$vars) { - my $tmp = "UPDATE $cdr_table SET cost = 'rating' WHERE uniqueid = " - . $cdr_db->quote($uniqueid) - . " AND cost = 'none'" - . " AND dst = " - . $cdr_db->quote($cdrinfo->{dst}) - . " LIMIT 1"; - $cdr_db->do($tmp); - } else { - $cdrinfo->{'cost'} = 'rating'; - } +# if(!$vars) { +# my $tmp = "UPDATE $cdr_table SET cost = 'rating' WHERE uniqueid = " +# . $cdr_db->quote($uniqueid) +# . " AND cost = 'none'" +# . " AND dst = " +# . $cdr_db->quote($cdrinfo->{dst}) +# . " LIMIT 1"; +# $cdr_db->do($tmp); +# } else { +# $cdrinfo->{'cost'} = 'rating'; +# } if ( $cdrinfo->{accountcode} ) { my $carddata = &get_account( $astpp_db, $cdrinfo->{accountcode} ); if ($carddata->{number}) { @@ -4145,7 +4145,7 @@ print STDERR "----------------------\n"; } elsif ( $cdrinfo->{accountcode} ) { - $status = &rating( $astpp_db, $cdr_db, $config, $cdrinfo, $carddata, $vars); + $status = &rating( $astpp_db, $cdr_db,$cdr_table, $config, $cdrinfo, $carddata, $vars); $cdrinfo = &get_cdr( $config, $cdr_db,$cdr_table, $uniqueid ) if !$vars; if ( $status == 1 ) { my $previous_account = $carddata->{number}; @@ -4153,7 +4153,7 @@ $cdrinfo = &get_cdr( $config, $cdr_db,$cdr_table, $uniqueid ) if !$vars; print STDERR "Charge $uniqueid to $carddata->{reseller}" if $config->{debug} == 1; $carddata = &get_account( $astpp_db, $carddata->{reseller} ); - $status = &rating( $astpp_db, $cdr_db, $config, $cdrinfo, $carddata, $vars); + $status = &rating( $astpp_db, $cdr_db, $cdr_table,$config, $cdrinfo, $carddata, $vars); my $tmp = "SELECT id FROM cdrs WHERE uniqueid = '" . $uniqueid . "' AND cardnum = '" . $previous_account . "' LIMIT 1"; print STDERR "$tmp\n" if $config->{debug} == 1; Modified: trunk/contrib/auto_dialer/aleph-autocall.pl =================================================================== --- trunk/contrib/auto_dialer/aleph-autocall.pl 2008-12-02 02:39:15 UTC (rev 2213) +++ trunk/contrib/auto_dialer/aleph-autocall.pl 2008-12-02 03:35:36 UTC (rev 2214) @@ -125,22 +125,20 @@ } sub perform_callout() { - my ($number) = @_; - my $out = new Asterisk::Outgoing; - my $channel = "Local\/" . $number->{number} . "\@$config->{destcontext}"; - $out->setvariable( 'Channel', $channel ); - $out->setvariable( 'MaxRetries', $config->{maxretries} ); - $out->setvariable( 'RetryTime', 60 ); - $out->setvariable( 'WaitTime', 60 ); -# $out->setvariable( "context", $config->{context} ); -# $out->setvariable( "extension", $number ); + my ($number) = @_; + my $out = new Asterisk::Outgoing; + my $channel = "Local\/" . $number->{number} . "\@$config->{destcontext}"; + $out->setvariable( 'Channel', $channel ); + $out->setvariable( 'MaxRetries', $config->{maxretries} ); + $out->setvariable( 'RetryTime', 60 ); + $out->setvariable( 'WaitTime', 60 ); $out->setvariable( 'Application', "DeadAGI"); $out->setvariable( 'Data', "aleph-aac.agi|" . $number->{id}); $out->setvariable( "CallerID", "<$number->{clidname}> $number->{clidnumber}" ); - $out->setvariable( "Account", "$number->{accountcode}" ); - $out->outtime( time() + 15 ); - $out->create_outgoing; + $out->setvariable( "Account", "$number->{accountcode}" ); + $out->outtime( time() + 15 ); + $out->create_outgoing; print STDERR "Created Call to: $number->{number}\n"; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-12-06 22:37:08
|
Revision: 2217 http://astpp.svn.sourceforge.net/astpp/?rev=2217&view=rev Author: darrenkw Date: 2008-12-06 22:37:02 +0000 (Sat, 06 Dec 2008) Log Message: ----------- Fix the code that causes astpp to return results for freeswitch directory even when no result is found. Also add code to round totals and taxes to a different number of decimal points than we bill to. This is useful to be able to bill calls accurately up to X decimal points but still present the customer with a bill where the totals are just rounded to 2 decimal points. Modified Paths: -------------- trunk/astpp-common.pl trunk/freeswitch/astpp-fs-xml.pl Added Paths: ----------- trunk/sql/astpp-2008-12-06.sql Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2008-12-06 18:35:51 UTC (rev 2216) +++ trunk/astpp-common.pl 2008-12-06 22:37:02 UTC (rev 2217) @@ -4672,7 +4672,6 @@ $desc = "$row->{callstart} SRC: $row->{callerid} DST: $row->{callednum} SEC:$row->{billseconds} $row->{notes}"; $price = $row->{debit} / 10000; if($config->{osc_post_nc} == 1 || $price != 0) { - $price = sprintf( "%." . $config->{decimalpoints} . "f", $price ); $tmp = "INSERT INTO `orders_products` (`orders_products_id`,`orders_id`,`products_id`,`products_name`,`products_price`," . "`final_price`,`products_tax`,`products_quantity`) VALUES (''," @@ -4767,6 +4766,7 @@ &markbilled( $astpp_db, $row->{id}, 1 ); } $subtotal = &osc_order_subtotal($osc_db, $config, $invoice_id); + $subtotal = sprintf( "%." . $config->{decimalpoints_total} . "f", $total ); print STDERR "ORDER $invoice_id SUBTOTAL: $subtotal"; $sort = 1; $tax_count = 1; @@ -4779,7 +4779,7 @@ $tax_priority = $tax->{tax_priority}; $tax_amount = $subtotal * ( $tax->{tax_rate} / 100 ); $sort++; - $tax_amount = sprintf( "%." . $config->{decimalpoints} . "f", $tax_amount ); + $tax_amount = sprintf( "%." . $config->{decimalpoints_tax} . "f", $tax_amount ); &osc_post_total( $osc_db, $config, $invoice_id, $tax->{tax_description}, "\$$tax_amount", $tax_amount, $sort, "ot_tax" ); $tax_count++; @@ -4791,14 +4791,14 @@ $tax_priority = $tax->{tax_priority}; $tax_amount = $subtotal * ( $tax->{tax_rate} / 100 ); $sort++; - $tax_amount = sprintf( "%." . $config->{decimalpoints} . "f", $tax_amount ); + $tax_amount = sprintf( "%." . $config->{decimalpoints_tax} . "f", $tax_amount ); &osc_post_total($osc_db, $config, $invoice_id, $tax->{tax_description}, "\$$tax_amount", $tax_amount, $sort, "ot_tax" ); } } $total = &osc_order_total($osc_db, $config, $invoice_id); $sort++; - $total = sprintf( "%." . $config->{decimalpoints} . "f", $total ); + $total = sprintf( "%." . $config->{decimalpoints_total} . "f", $total ); &osc_post_total($osc_db, $config, $invoice_id, "Total:", "<b>\$$total</b>", $total, $sort, "ot_total" ); &email_new_invoice( $astpp_db, "", $config, $account, $invoice_id, Modified: trunk/freeswitch/astpp-fs-xml.pl =================================================================== --- trunk/freeswitch/astpp-fs-xml.pl 2008-12-06 18:35:51 UTC (rev 2216) +++ trunk/freeswitch/astpp-fs-xml.pl 2008-12-06 22:37:02 UTC (rev 2217) @@ -254,14 +254,16 @@ #domain 192.168.2.119 #ip 192.168.2.119 - $xml = $ASTPP->fs_directory_xml_header( xml => $xml ); - $xml = $ASTPP->fs_directory_xml( - xml => $xml, - ip => $params->{'ip'}, - user => $params->{'user'}, - domain => $params->{'domain'} - ); - $xml = $ASTPP->fs_directory_xml_footer( xml => $xml ); + if ($params->{'user'}) { + $xml = $ASTPP->fs_directory_xml_header( xml => $xml ); + $xml = $ASTPP->fs_directory_xml( + xml => $xml, + ip => $params->{'ip'}, + user => $params->{'user'}, + domain => $params->{'domain'} + ); + $xml = $ASTPP->fs_directory_xml_footer( xml => $xml ); + } } $ASTPP->debug( debug => $xml ); print $xml; Added: trunk/sql/astpp-2008-12-06.sql =================================================================== --- trunk/sql/astpp-2008-12-06.sql (rev 0) +++ trunk/sql/astpp-2008-12-06.sql 2008-12-06 22:37:02 UTC (rev 2217) @@ -0,0 +1,1316 @@ +DROP TABLE IF EXISTS `routes`; +CREATE TABLE routes ( +id INTEGER NOT NULL AUTO_INCREMENT, +pattern CHAR(40), +comment CHAR(80), +connectcost INTEGER NOT NULL, +includedseconds INTEGER NOT NULL, +cost INTEGER NOT NULL, +pricelist CHAR(80), +inc INTEGER, +reseller CHAR(50) default NULL, +precedence INT(4) NOT NULL DEFAULT 0, +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`), +KEY `pattern` (`pattern`), +KEY `pricelist` (`pricelist`), +KEY `reseller` (`reseller`), +KEY `status` (`status`) +); + +DROP TABLE IF EXISTS `pricelists`; +CREATE TABLE pricelists ( +name CHAR(40) NOT NULL, +markup INTEGER NOT NULL DEFAULT 0, +inc INTEGER NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +reseller CHAR(50) default NULL, +PRIMARY KEY (`name`) +); + +DROP TABLE IF EXISTS `callingcardbrands`; +CREATE TABLE callingcardbrands ( +name CHAR(40) NOT NULL, +reseller CHAR(40) NOT NULL DEFAULT '', +language CHAR(10) NOT NULL DEFAULT '', +pricelist CHAR(40) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +validfordays CHAR(4) NOT NULL DEFAULT '', +pin INTEGER NOT NULL DEFAULT 0, +maint_fee_pennies INTEGER NOT NULL DEFAULT 0, +maint_fee_days INTEGER NOT NULL DEFAULT 0, +disconnect_fee_pennies INTEGER NOT NULL DEFAULT 0, +minute_fee_minutes INTEGER NOT NULL DEFAULT 0, +minute_fee_pennies INTEGER NOT NULL DEFAULT 0, +min_length_minutes INTEGER NOT NULL DEFAULT 0, +min_length_pennies INTEGER NOT NULL DEFAULT 0, +PRIMARY KEY (`name`), + KEY `reseller` (`reseller`), + KEY `pricelist` (`pricelist`) +); + +DROP TABLE IF EXISTS `callingcardcdrs`; +CREATE TABLE callingcardcdrs ( +id INTEGER NOT NULL AUTO_INCREMENT, +cardnumber CHAR(50) NOT NULL DEFAULT '', +clid CHAR(80) NOT NULL DEFAULT '', +destination CHAR(40) NOT NULL DEFAULT '', +disposition CHAR(20)NOT NULL DEFAULT '', +callstart CHAR(40) NOT NULL DEFAULT '', +seconds INTEGER NOT NULL DEFAULT 0, +debit DECIMAL(20,6) NOT NULL DEFAULT 0.00000, +credit DECIMAL(20,6) NOT NULL DEFAULT 0.00000, +status INTEGER DEFAULT 0 NOT NULL, +uniqueid VARCHAR(32) NOT NULL DEFAULT '', +notes CHAR(80) NOT NULL DEFAULT '', +pricelist CHAR(80) NOT NULL DEFAULT '', +pattern CHAR(80) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + KEY `cardnumber` (`cardnumber`) +); + +DROP TABLE IF EXISTS `trunks`; +CREATE TABLE trunks ( +name VARCHAR(30) NOT NULL, +tech CHAR(10) NOT NULL DEFAULT '', +path CHAR(40) NOT NULL DEFAULT '', +provider CHAR(100) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +dialed_modify TEXT NOT NULL DEFAULT '', +resellers TEXT NOT NULL DEFAULT '', +precedence INT(4) NOT NULL DEFAULT 0, +maxchannels INTEGER DEFAULT 0 NOT NULL, + PRIMARY KEY (`name`), + KEY `provider` (`provider`), + KEY `provider_2` (`provider`) +); + +DROP TABLE IF EXISTS `outbound_routes`; +CREATE TABLE outbound_routes ( +pattern CHAR(40), +id INTEGER NOT NULL AUTO_INCREMENT, +comment CHAR(80) NOT NULL DEFAULT '', +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +trunk CHAR(80) NOT NULL DEFAULT '', +inc CHAR(10) NOT NULL DEFAULT '', +strip CHAR(40) NOT NULL DEFAULT '', +prepend CHAR(40) NOT NULL DEFAULT '', +precedence INT(4) NOT NULL DEFAULT 0, +resellers TEXT NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `trunk` (`trunk`), + KEY `pattern` (`pattern`) +); + +DROP TABLE IF EXISTS `dids`; +CREATE TABLE dids ( +number CHAR(40) NOT NULL, +account CHAR(50) NOT NULL DEFAULT '', +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +monthlycost INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +inc CHAR(10) NOT NULL DEFAULT '', +extensions CHAR(180) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +provider CHAR(40) NOT NULL DEFAULT '', +country CHAR (80)NOT NULL DEFAULT '', +province CHAR (80) NOT NULL DEFAULT '', +city CHAR (80) NOT NULL DEFAULT '', +prorate int(1) NOT NULL default 0, +setup int(11) NOT NULL default 0, +limittime int(1) NOT NULL default 1, +disconnectionfee INT(11) NOT NULL default 0, +variables TEXT NOT NULL DEFAULT '', +options varchar(40) default NULL, +maxchannels int(4) NOT NULL default 0, +chargeonallocation int(1) NOT NULL default 1, +allocation_bill_status int(1) NOT NULL default 0, +dial_as CHAR(40) NOT NULL DEFAULT '', +PRIMARY KEY (`number`), + KEY `account` (`account`) +); + +DROP TABLE IF EXISTS `accounts`; +CREATE TABLE accounts ( +cc CHAR(20) NOT NULL DEFAULT '', +number CHAR(50) NOT NULL, +reseller CHAR(40) NOT NULL DEFAULT '', +pricelist CHAR(24) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +credit INTEGER NOT NULL DEFAULT 0, +sweep INTEGER NOT NULL DEFAULT 0, +creation TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, +pin INTEGER NOT NULL DEFAULT 0, +credit_limit INTEGER NOT NULL DEFAULT 0, +posttoexternal INTEGER NOT NULL DEFAULT 0, +balance DECIMAL(20,6) NOT NULL DEFAULT 0, +password CHAR(80) NOT NULL DEFAULT '', +first_name CHAR(40) NOT NULL DEFAULT '', +middle_name CHAR(40) NOT NULL DEFAULT '', +last_name CHAR(40) NOT NULL DEFAULT '', +company_name CHAR(40) NOT NULL DEFAULT '', +address_1 CHAR(80) NOT NULL DEFAULT '', +address_2 CHAR(80) NOT NULL DEFAULT '', +address_3 CHAR(80) NOT NULL DEFAULT '', +postal_code CHAR(12) NOT NULL DEFAULT '', +province CHAR(40) NOT NULL DEFAULT '', +city CHAR(80) NOT NULL DEFAULT '', +country CHAR(40) NOT NULL DEFAULT '', +telephone_1 CHAR(40) NOT NULL DEFAULT '', +telephone_2 CHAR(40) NOT NULL DEFAULT '', +fascimile CHAR(40) NOT NULL DEFAULT '', +email CHAR(80) NOT NULL DEFAULT '', +language CHAR(2) NOT NULL DEFAULT '', +currency CHAR(3) NOT NULL DEFAULT '', +maxchannels INTEGER DEFAULT 1 NOT NULL, +routing_technique INT(4) NOT NULL DEFAULT 0, +dialed_modify TEXT NOT NULL DEFAULT '', +type INTEGER DEFAULT 0, +tz CHAR(40) NOT NULL DEFAULT '', +PRIMARY KEY (`number`), + KEY `pricelist` (`pricelist`), + KEY `reseller` (`reseller`) +); + +DROP TABLE IF EXISTS `counters`; +CREATE TABLE counters ( +id INTEGER NOT NULL AUTO_INCREMENT, +package CHAR(40) NOT NULL DEFAULT '', +account VARCHAR(50) NOT NULL, +seconds INTEGER NOT NULL DEFAULT 0, +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`) +); + +DROP TABLE IF EXISTS `callingcards`; +CREATE TABLE callingcards ( +id INTEGER NOT NULL AUTO_INCREMENT, +cardnumber CHAR(20) NOT NULL DEFAULT '', +language CHAR(10) NOT NULL DEFAULT '', +value INTEGER NOT NULL DEFAULT 0, +used INTEGER NOT NULL DEFAULT 0, +brand VARCHAR(20) NOT NULL DEFAULT '', +created DATETIME, +firstused DATETIME, +expiry DATETIME, +validfordays CHAR(4) NOT NULL DEFAULT '', +inuse INTEGER NOT NULL DEFAULT 0, +pin CHAR(20), +account VARCHAR(50) NOT NULL DEFAULT '', +maint_fee_pennies INTEGER NOT NULL DEFAULT 0, +maint_fee_days INTEGER NOT NULL DEFAULT 0, +maint_day INTEGER NOT NULL DEFAULT 0, +disconnect_fee_pennies INTEGER NOT NULL DEFAULT 0, +minute_fee_minutes INTEGER NOT NULL DEFAULT 0, +minute_fee_pennies INTEGER NOT NULL DEFAULT 0, +min_length_minutes INTEGER NOT NULL DEFAULT 0, +min_length_pennies INTEGER NOT NULL DEFAULT 0, +timeused INTEGER NOT NULL DEFAULT 0, +invoice CHAR(20) NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `brand` (`brand`) +); + +CREATE TABLE charge_to_account ( +id INTEGER NOT NULL AUTO_INCREMENT, +charge_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(50) NOT NULL DEFAULT '', +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`) +); + +CREATE TABLE queue_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +queue_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE pbx_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +pbx_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE extension_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +extension_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE cdrs ( +id INTEGER NOT NULL AUTO_INCREMENT, +uniqueid varchar(32) NOT NULL DEFAULT '', +cardnum CHAR(50), +callerid CHAR(80), +callednum varchar(80) NOT NULL DEFAULT '', +billseconds INT DEFAULT 0 NOT NULL, +trunk VARCHAR(30), +disposition varchar(45) NOT NULL DEFAULT '', +callstart varchar(80) NOT NULL DEFAULT '', +debit DECIMAL (20,6) NOT NULL DEFAULT 0, +credit DECIMAL (20,6) NOT NULL DEFAULT 0, +status INTEGER DEFAULT 0 NOT NULL, +notes CHAR(80), +provider CHAR(50), +cost DECIMAL(20,6) NOT NULL DEFAULT 0, +pricelist CHAR(80) NOT NULL DEFAULT '', +pattern CHAR(80) NOT NULL DEFAULT '', +PRIMARY KEY (`id`), + KEY `cardnum` (`cardnum`), + KEY `provider` (`provider`), + KEY `trunk` (`trunk`), + KEY `uniqueid` (`uniqueid`), + KEY `status` (`status`) +); + +CREATE TABLE packages ( +id INTEGER NOT NULL AUTO_INCREMENT, +name CHAR(40) NOT NULL DEFAULT '', +pricelist CHAR(40) NOT NULL DEFAULT '', +pattern CHAR(40) NOT NULL DEFAULT '', +includedseconds INTEGER NOT NULL DEFAULT 0, +reseller VARCHAR(50) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `pricelist` (`pricelist`), + KEY `reseller` (`reseller`) +); + +CREATE TABLE ani_map ( +number char(20) NOT NULL, +account char(50) NOT NULL default '', +status int(11) NOT NULL default '0', +context varchar(20) NOT NULL, + PRIMARY KEY (`number`), +KEY `account` (`account`) +); + +CREATE TABLE `ip_map` ( +ip char(15) NOT NULL default '', +account char(20) NOT NULL default '', +prefix varchar(20) NULL, +context varchar(20) NOT NULL, +PRIMARY KEY (`ip`,`prefix`), +KEY `account` (`account`) +); + +CREATE TABLE charges ( +id INTEGER NOT NULL AUTO_INCREMENT, +pricelist CHAR(40) NOT NULL DEFAULT '', +description VARCHAR(80) NOT NULL DEFAULT '', +charge INTEGER NOT NULL DEFAULT 0, +sweep INTEGER NOT NULL DEFAULT 0, +reseller CHAR(40) NOT NULL DEFAULT '', +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`), + KEY `pricelist` (`pricelist`) +); + +CREATE TABLE manager_action_variables ( +id INTEGER NOT NULL AUTO_INCREMENT, +name CHAR(60) NOT NULL DEFAULT '', +value CHAR(60) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE callingcard_stats ( +uniqueid VARCHAR(48) NOT NULL, +total_time VARCHAR(48) NOT NULL, +billable_time VARCHAR(48) NOT NULL, +timestamp DATETIME NULL, +PRIMARY KEY (`uniqueid`) +); + +CREATE TABLE system ( +name VARCHAR(48) NULL, +value VARCHAR(255) NULL, +comment VARCHAR(255) NULL, +timestamp DATETIME NULL, +reseller VARCHAR(48) NULL, +brand VARCHAR(48) NULL, +PRIMARY KEY (`name`), + KEY `reseller` (`reseller`), + KEY `brand` (`brand`) +); + + +INSERT INTO system (name, value, comment) VALUES ( +'callout_accountcode','admin','Call Files: What accountcode should we use?'); + +INSERT INTO system (name, value, comment) VALUES ( +'lcrcontext','astpp-outgoing','This is the Local context we use to route our outgoing calls through esp for callbacks'); + +INSERT INTO system (name, value, comment) VALUES ( +'maxretries','3','Call Files: How many times do we retry?'); + +INSERT INTO system (name, value, comment) VALUES ( +'retrytime','30','Call Files: How long do we wait between retries?'); + +INSERT INTO system (name, value, comment) VALUES ( +'waittime','15','Call Files: How long do we wait before the initial call?'); + +INSERT INTO system (name, value, comment) VALUES ( +'clidname','Private','Call Files: Outgoing CallerID Name'); + +INSERT INTO system (name, value, comment) VALUES ( +'clidnumber','0000000000','Call Files: Outgoing CallerID Number'); + +INSERT INTO system (name, value, comment) VALUES ( +'callingcards_callback_context','astpp-callingcards','Call Files: For callingcards what context do we end up in?'); + +INSERT INTO system (name, value, comment) VALUES ( +'callingcards_callback_extension', 's','Call Files: For callingcards what extension do we use?'); + +INSERT INTO system (name, value, comment) VALUES ( +'openser_dbengine', 'MySQL','For now this must be MySQL'); + +INSERT INTO system (name, value, comment) VALUES ( +'openser', '0','Use OPENSER? 1 for yes or 0 for no'); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbname', 'openser','OPENSER Database Name', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbuser', 'root','OPENSER Database User', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbhost', 'localhost','OPENSER Database Host', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbpass', 'Passw0rd','OPENSER Database Password', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_domain', NULL,'OPENSER Domain', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_email', 'em...@as...','Email address that email should appear to be from', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'asterisk_dir', '/etc/asterisk','Which directory are asterisk configuration files stored in?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_website', 'http://www.astpp.org','Link to your company website', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_name', 'ASTPP.ORG','The name of your company. Used in emails.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'email', '1','Send out email? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'user_email', '1','Email user on account changes? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'debug', '0','Enable debugging output? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'emailadd', 'em...@as...','Administrator email address', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'startingdigit', '0','The digit that all calling cards must start with. 0=disabled', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'enablelcr', '1','Use least cost routing 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'log_file', '/var/log/astpp/astpp.log','ASTPP Log file', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'key_home', 'http://www.astpp.org/astpp.pub','Asterisk RSA Key location (optional)', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rate_engine_csv_file', '/var/log/astpp/astpp.csv','CSV File for call rating data', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'csv_dir', '/var/log/astpp/','CSV File Directory', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_brand', 'default','Default pricelist. If a price is not found in the customers pricelist we check this one.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'new_user_brand', 'default','What is the default pricelist for new customers?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_context', 'custom-astpp','What is the default context for new devices?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cardlength', '10','Number of digits in calling cards and cc codes.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'asterisk_server', 'voip.astpp.org','Your default voip server. Used in outgoing email.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'currency', 'CAD','Name of the currency you use', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'iax_port', '4569','Default IAX2 Port', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'sip_port', '5060','Default SIP Port', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'ipaddr', 'dynamic','Default IP Address for new devices', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'key', 'astpp.pub','Asterisk RSA Key Name (Optional)', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'pinlength', '6','For those calling cards that are using pins this is the number of digits it will have.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'credit_limit', '0','Default credit limit in dollars.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'decimalpoints', '4','How many decimal points do we bill to?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'decimalpoints_tax', '2','How many decimal points do we calculate taxes to?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'decimalpoints_total', '2','How many decimal points do we calculate totals to?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'max_free_length', '100','What is the maximum length (in minutes) of calls that are at no charge?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'trackvendorcharges', '1','Do we track the amount of money we spend with specific providers? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_logo', 'http://www.astpp.org/logo.png','The location of our company logo.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_slogan', 'Welcome to ASTPP','Company slogan', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'version', '1.5Beta', 'ASTPP Version', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_language', 'en', 'Default ASTPP Language',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'card_retries','3', 'How many retries do we allow for calling card numbers?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'pin_retries','3', 'How many retries do we allow for pins?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'number_retries','3','How many retries do we allow calling card users when dialing a number?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'booth_context','callshop_booth','Please enter the default context for a callshop booth.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'callingcards_max_length','9000','What is the maximum length (in ms) of a callingcard call?',''); + +INSERT INTO system (name,value,comment,timestamp) VALUES ( +'template_die_on_bad_params','0','Should HTML::Template die on bad parameters?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'results_per_page','30','How many results per page do we should in the web interface?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astpp_dir','/var/lib/astpp','Where do the astpp configs live?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'auth','Passw0rd!','This is the override authorization code and will allow access to the system.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_dbengine','MySQL','Database type for Asterisk(tm) -Realtime',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbengine','MySQL','Database type for the cdr database',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_dbengine','MySQL','Database type for OSCommerce',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_dbengine','MySQL','Database type for AgileBill(tm)',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_dbengine','MySQL','Database type for FreePBX',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'externalbill','oscommerce','Please specify the external billing application to use. If you are not using any then leave it blank. Valid options are "agile" and "oscommerce".',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'callingcards','1','Do you wish to enable calling cards? 1 for yes and 2 for no.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astcdr','1','Change this one at your own peril. If you switch it off, calls will not be marked as billed in asterisk once they are billed.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'posttoastpp','1','Change this one at your own peril. If you switch it off, calls will not be written to astpp when they are calculated.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'sleep','10','How long shall the rating engine sleep after it has been notified of a hangup? (in seconds)',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'users_dids_amp','0','If this is enabled, ASTPP will create users and DIDs in the FreePBX (www.freepbx.org) database.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'users_dids_rt','1','If this is enabled, ASTPP will create users and DIDs in the Asterisk Realtime database.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'users_dids_freeswitch','0','If this is enabled, ASTPP will create SIP users in the freeswitch database.',''); + + +INSERT INTO system (name, value, comment) VALUES ( +'service_prepend','778',''); +INSERT INTO system (name, value, comment) VALUES ( +'service_length,','7',''); +INSERT INTO system (name, value, comment) VALUES ( +'service_filler','4110000',''); + +INSERT INTO system (name, value, comment) VALUES ( +'asterisk_cdr_table','cdr','Which table of the Asterisk(TM) database are the cdrs in?'); + +-- AgileBill(Trademark of AgileCo) Settings: +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_db','agile','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_pass','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_site_id','1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_charge_status','0','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_taxable','1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_dbprefix','_','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_service_prepend','778','',''); + +-- OSCommerce Settings (www.oscommerce.org) +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_db','oscommerce','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_pass','password','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_product_id','99999999','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_payment_method','"Charge"','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_order_status','1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_post_nc','0','Do we post "free" items to the oscommerce invoice? 0=No 1=Yes',''); + +-- FreePBX Settings (www.freepbx.org) +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_db','asterisk','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_pass','passw0rd','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_table','iax','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_table','sip','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_extensions_table','extensions','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_codec_allow','g729,ulaw,alaw','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_codec_disallow','all','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_mailbox_group','default','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_nat','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_canreinvite','no','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_dtmfmode','rfc2833','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_callgroup','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_pickupgroup','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_notransfer','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_qualify','yes','',''); + +-- Asterisk -realtime Settings +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_db','realtime','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_pass','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_table','iax','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_table','sip','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_extensions_table','extensions','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_insecure','very','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_nat','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_canreinvite','no','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_codec_allow','g729,ulaw,alaw','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_codec_disallow','all','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_mailbox_group','default','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_type','friend','',''); +INSERT INTO system (name, value, comment) VALUES ( +'rt_voicemail_table','voicemail_users',''); + + +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_rate_announce','1','Do we want the calling cards script to announce the rate on calls?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_timelimit_announce','1','Do we want the calling cards script to announce the timelimit on calls?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_cancelled_prompt','1','Do we want the calling cards script to announce that the call was cancelled?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_menu','1','Do we want the calling cards script to present a menu before exiting?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_connection_prompt','1','Do we want the calling cards script to announce that it is connecting the call?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_pin_input_timeout','15000','How long do we wait when entering the calling card pin? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_number_input_timeout','15000','How long do we wait when entering the calling card number? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_dial_input_timeout','15000','How long do we wait when entering the destination number in calling cards? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_general_input_timeout','15000','How long do we wait for input in general menus? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_welcome_file','silence/1','What do we play for a welcome file?'); + +INSERT INTO system (name, value, comment) VALUES ( +'sip_ext_prepend','10','What should every autoadded SIP extension begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'iax2_ext_prepend','10','What should every autoadded IAX2 extension begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'cc_prepend','','What should every autoadded callingcard begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'pin_cc_prepend','','What should every autoadded callingcard pin begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'pin_act_prepend','','What should every autoadded account pin begin with?'); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_directory','/usr/local/freeswitch','What is the Freeswitch root directory?'); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_password','ClueCon','Freeswitch event socket password'); +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_host','localhost','Freeswitch event socket host'); +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_port','8021','Freeswitch event socket port'); +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_timeout','30','Freeswitch seconds to expect a heartbeat event or reconnect'); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_dbengine', 'MySQL','For now this must be MySQL'); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freeswitch_dbname', 'freeswitch','Freeswitch Database Name', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freeswitch_dbuser', 'root','Freeswitch Database User', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freeswitch_dbhost', 'localhost','Freeswitch Database Host', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freeswitch_dbpass', 'Passw0rd','Freeswitch Database Password', ''); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_cdr_table','fscdr','Which table of the cdr database are the Freeswitch cdrs in?'); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_domain','$${local_ip_v4}','This is entered as the Freeswitch domain.'); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_context','default','This is entered as the Freeswitch user context.'); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbname', 'asteriskcdrdb', +'CDR Database Name', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbuser', 'root', +'CDR Database User', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbhost', 'localhost', +'CDR Database Host', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbpass', 'Passw0rd', +'CDR Database Password', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astman_user', 'admin','Asterisk(tm) Manager Interface User', ''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astman_host', 'localhost','Asterisk(tm) Manager Interface Host', ''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astman_secret', 'amp111','Asterisk(tm) Manager Interface Secret', ''); + +------ 3rd Party PBX Mods +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'thirdlane_mods','0','Provides a few different modifications across the rating code to work better with Thirdlane(tm) cdrs.',''); + +-- +-- Enough Configuration settings +-- + +DROP TABLE IF EXISTS `countrycode`; +CREATE TABLE `countrycode` ( + `country` varchar(255) NOT NULL, + PRIMARY KEY (`country`), + KEY `country` (`country`) +); + +INSERT INTO `countrycode` (`country`) VALUES + ('Afghanistan'), + ('Alaska'), + ('Albania'), + ('Algeria'), + ('AmericanSamoa'), + ('Andorra'), + ('Angola'), + ('Antarctica'), + ('Argentina'), + ('Armenia'), + ('Aruba'), + ('Ascension'), + ('Australia'), + ('Austria'), + ('Azerbaijan'), + ('Bahrain'), + ('Bangladesh'), + ('Belarus'), + ('Belgium'), + ('Belize'), + ('Benin'), + ('Bhutan'), + ('Bolivia'), + ('Bosnia & Herzegovina'), + ('Botswana'), + ('Brazil'), + ('Brunei Darussalam'), + ('Bulgaria'), + ('Burkina Faso'), + ('Burundi'), + ('Cambodia'), + ('Cameroon'), + ('Canadda'), + ('Cape Verde Islands'), + ('Central African Republic'), + ('Chad'), + ('Chile'), + ('China'), + ('Colombia'), + ('Comoros'), + ('Congo'), + ('Cook Islands'), + ('Costa Rica'), + ('Croatia'), + ('Cuba'), + ('Cuba Guantanamo Bay'), + ('Cyprus'), + ('Czech Republic'), + ('Denmark'), + ('Diego Garcia'), + ('Djibouti'), + ('Dominican Republic'), + ('East Timor'), + ('Ecuador'), + ('Egypt'), + ('El Salvador'), + ('Equatorial Guinea'), + ('Eritrea'), + ('Estonia'), + ('Ethiopia'), + ('Faroe Islands'); +INSERT INTO `countrycode` (`country`) VALUES + ('Fiji Islands'), + ('Finland'), + ('France'), + ('French Guiana'), + ('French Polynesia'), + ('Gabonese Republic'), + ('Gambia'), + ('Georgia'), + ('Germany'), + ('Ghana'), + ('Gibraltar'), + ('Greece'), + ('Greenland'), + ('Guadeloupe'), + ('Guam'), + ('Guatemala'), + ('Guinea'), + ('Guyana'), + ('Haiti'), + ('Honduras'), + ('Hong Kong'), + ('Hungary'), + ('Iceland'), + ('India'), + ('Indonesia'), + ('Iran'), + ('Iraq'), + ('Ireland'), + ('Israel'), + ('Italy'), + ('Jamaica'), + ('Japan'), + ('Jordan'), + ('Kazakstan'), + ('Kenya'), + ('Kiribati'), + ('Kuwait'), + ('Kyrgyz Republic'), + ('Laos'), + ('Latvia'), + ('Lebanon'), + ('Lesotho'), + ('Liberia'), + ('Libya'), + ('Liechtenstein'), + ('Lithuania'), + ('Luxembourg'), + ('Macao'), + ('Madagascar'), + ('Malawi'), + ('Malaysia'), + ('Maldives'), + ('Mali Republic'), + ('Malta'), + ('Marshall Islands'), + ('Martinique'), + ('Mauritania'), + ('Mauritius'), + ('MayotteIsland'), + ('Mexico'), + ('Midway Islands'), + ('Moldova'), + ('Monaco'), + ('Mongolia'), + ('Morocco'); +INSERT INTO `countrycode` (`country`) VALUES + ('Mozambique'), + ('Myanmar'), + ('Namibia'), + ('Nauru'), + ('Nepal'), + ('Netherlands'), + ('Netherlands Antilles'), + ('New Caledonia'), + ('New Zealand'), + ('Nicaragua'), + ('Niger'), + ('Nigeria'), + ('Niue'), + ('Norfolk Island'), + ('North Korea'), + ('Norway'), + ('Oman'), + ('Pakistan'), + ('Palau'), + ('Palestinian Settlements'), + ('Panama'), + ('PapuaNew Guinea'), + ('Paraguay'), + ('Peru'), + ('Philippines'), + ('Poland'), + ('Portugal'), + ('Puerto Rico'), + ('Qatar'), + ('RéunionIsland'), + ('Romania'), + ('Russia'), + ('Rwandese Republic'), + ('San Marino'), + ('São Tomé and Principe'), + ('Saudi Arabia'), + ('Senegal '), + ('Serbia and Montenegro'), + ('Seychelles Republic'), + ('Sierra Leone'), + ('Singapore'), + ('Slovak Republic'), + ('Slovenia'), + ('Solomon Islands'), + ('Somali Democratic Republic'), + ('South Africa'), + ('South Korea'), + ('Spain'), + ('Sri Lanka'), + ('St Kitts - Nevis'), + ('St. Helena'), + ('St. Lucia'), + ('St. Pierre & Miquelon'), + ('St. Vincent & Grenadines'), + ('Sudan'); +INSERT INTO `countrycode` (`country`) VALUES + ('Suriname'), + ('Swaziland'), + ('Sweden'), + ('Switzerland'), + ('Syria'), + ('Taiwan'), + ('Tajikistan'), + ('Tanzania'), + ('Thailand'), + ('Togolese Republic'), + ('Tokelau'), + ('Tonga Islands'), + ('Trinidad & Tobago'), + ('Tunisia'), + ('Turkey'), + ('Turkmenistan'), + ('Tuvalu'), + ('Uganda'), + ('Ukraine'), + ('United Arab Emirates'), + ('United Kingdom'), + ('United States of America'), + ('Uruguay'), + ('Uzbekistan'), + ('Vanuatu'), + ('Venezuela'), + ('Vietnam'), + ('Wake Island'), + ('Wallisand Futuna Islands'), + ('Western Samoa'), + ('Yemen'), + ('Zambia'), + ('Zimbabwe'); + +DROP TABLE IF EXISTS `currency`; +CREATE TABLE `currency` ( + `Currency` varchar(3) NOT NULL default '', + `CurrencyName` varchar(40) NOT NULL default '', + PRIMARY KEY (`Currency`) +); + +INSERT INTO `currency` (`Currency`,`CurrencyName`) VALUES + ('USD','US Dollars'), + ('CAD','Canadian Dollars'), + ('AUD','Australian Dollars'); + +CREATE TABLE `language` ( + `language` varchar(5) NOT NULL, + `languagename` varchar(40) NOT NULL, + `active` tinyint(1) NOT NULL default '1', + PRIMARY KEY (`language`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +INSERT INTO `language` (`language`,`languagename`,`active`) VALUES + ('en','English',1), + ('fr','French',1), + ('de','German',1); + +CREATE TABLE `resellers` ( + name varchar(40) NOT NULL default '', + status int(11) NOT NULL default '1', + posttoexternal int(11) NOT NULL default '0', + agile_site_id int(11) NOT NULL default '0', + config_file char(80) NOT NULL default 'reseller.conf', + companyname varchar(255) default NULL, + slogan varchar(255) default NULL, + footer varchar(255) default NULL, + pricelist varchar(255) default NULL, + currency varchar(255) default NULL, + logo varchar(255) default NULL, + website varchar(255) default NULL, + adminemail varchar(255) default NULL, + salesemail varchar(255) default NULL, + phone varchar(45) default NULL, + fax varchar(45) default NULL, + address1 varchar(255) default NULL, + address2 varchar(255) default NULL, + city varchar(255) default NULL, + state varchar(255) default NULL, + postcode varchar(255) default NULL, + country varchar(255) default NULL, + defaultbrand varchar(45) NOT NULL default 'default', + defaultcurrency varchar(45) NOT NULL default 'USD', + defaultcredit varchar(45) NOT NULL default '0.00', + externalbill varchar(45) NOT NULL default '', + PRIMARY KEY (`name`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + +CREATE TABLE templates ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(45) NOT NULL default '', +reseller VARCHAR(45) NOT NULL default '', +template TEXT NOT NULL default '', + PRIMARY KEY (`id`), + KEY `reseller` (`reseller`) +); + +INSERT INTO templates (name,template) VALUES +('voip_account_refilled','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been refilled. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('voip_reactivate_account','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been reactivated. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_add_user','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been added. +Your Username is -- $vars->{extension} -- +Your Password is -- $vars->{secret} -- +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('add_sip_device','Attention: $vars->{title} $vars->{first} $vars->{last} +A new device has been enabled on your account. Here +is the necessary configuration information. +------- $config->{company_name} Configuration Info -------- +In sip.conf: +[$config->{company_name}-in] +type=user +username=$config->{company_name}-in +auth=rsa +inkeys=$config->{key} ;This key may be downloaded from $config->{key_home} +host=$config->{asterisk_server} +context=from-pstn +accountcode=$config->{company_name} +[$config->{company_name}] +type=peer +username=$vars->{extension} +secret=$vars->{secret} +host=$config->{asterisk_server} +callerid= <555-555-5555> +qualify=yes +accountcode=$config->{company_name} ; for call tracking in the cdr +In the [globals] section add: +register => $vars->{user}:password@$config->{asterisk_server}'); + +INSERT INTO templates (name,template) VALUES +('add_iax_device','Attention: $vars->{title} $vars->{first} $vars->{last} +A new device has been enabled on your account. Here +is the necessary configuration information. +------- $config->{company_name} Configuration Info -------- +In iax.conf: +At the bottom of the file add: +[$config->{company_name}-in] +;trunk=yes ;optional .. only works if you have a zaptel or ztdummy driver running +type=user +username=$config->{company_name}-in +auth=rsa +inkeys=$config->{key} ;This key may be downloaded from $config->{key_home} +host=$config->{asterisk_server} +context=incoming +accountcode=$config->{company_name} ;for call tracking in the cdr +[$config->{company_name}] +;to simplify and config outgoing calls +;trunk=yes ;optional .. only works if you have a zaptel driver running +type=peer +username=$vars->{extension} +secret=$vars->{secret} +host=$config->{asterisk_server} +callerid=<555-555-5555> ;only the number will really be used +qualify=yes +accountcode=$config->{company_name} ; for call tracking in the cdr +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_remove_user','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP Termination with $config->{company_name} has been removed +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_calling_card','You have added a $vars->{pricelist} callingcard in the amount of $vars->{pennies} cents. +Card Number $cc Pin: $pin +Thanks for your patronage. +The $config->{company_name} sales team'); + +INSERT INTO templates (name,template) VALUES +('email_add_did','Attention: $vars->{title} $vars->{first} $vars->{last} +Your DID with $config->{company_name} has been added +The number is: $did +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team +Here is a sample setup which would call a few sip phones with incoming calls: +[incoming] +exten => _1$did,1,Wait(2) +exten => _1$did,2,Dial(SIP/2201&SIP/2202,15,Ttm) ; dial a couple of phones for 15 secs +exten => _1$did,3,Voicemail(u1000) ; go to unavailable voicemail (vm box 1000) +exten => _1$did,103,Voicemail(b1000) ; go to busy voicemail (vm box 1000)'); + +INSERT INTO templates (name,template) VALUES +('email_remove_did','Attention: $vars->{title} $vars->{first} $vars->{last} +Your DID with $config->{company_name} has been removed +The number was: $did +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_new_invoice','Invoice # $invoice in the amount of \$$total has been added to your account. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_low_balance','Your VOIP account with $config->{company_name} has a balance of \$$balance. +Please visit our website to refill your account to ensure uninterrupted service. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +CREATE TABLE `sweeplist` ( + `Id` int(10) unsigned NOT NULL default '0', + `sweep` varchar(45) NOT NULL default '', + PRIMARY KEY (`Id`) +); + +INSERT INTO sweeplist (Id,sweep) VALUES +(0,'daily'), +(1,'weekly'), +(2,'monthly'), +(3,'quarterly'), +(4,'semi-annually'), +(5,'annually') +; + +CREATE TABLE userlevels ( +userlevelid int(11) NOT NULL, +userlevelname varchar(50) NOT NULL, +PRIMARY KEY (`userlevelid`) +); + +INSERT INTO `userlevels` (`userlevelid`,`userlevelname`) VALUES + (-1,'Administrator'), + (0,'Anonymous'), + (1,'Reseller'), + (2,'Admin'), + (3,'Vendor'), + (4,'Customer Service'), + (5,'Users'); + +CREATE TABLE reseller_pricing ( +id INTEGER NOT NULL AUTO_INCREMENT, +reseller VARCHAR(50) NOT NULL, +type INTEGER NOT NULL DEFAULT 1, +monthlycost INTEGER NOT NULL DEFAULT 0, +prorate INTEGER NOT NULL DEFAULT 0, +setup INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +note VARCHAR(50) NOT NULL DEFAULT '', +disconnectionfee INTEGER NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +inc CHAR(10) NOT NULL DEFAULT '', +PRIMARY KEY (`id`), + KEY `reseller` (`reseller`) +); + +CREATE TABLE callshops ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(50) NOT NULL, +osc_dbname VARCHAR(50) NOT NULL DEFAULT '', +osc_dbpass VARCHAR(50) NOT NULL DEFAULT '', +osc_dbuser VARCHAR(50) NOT NULL DEFAULT '', +osc_dbhost VARCHAR(50) NOT NULL DEFAULT '', +osc_site VARCHAR(50) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), +KEY `name` (`name`) +); + +CREATE TABLE extensions_status ( +id INTEGER NOT NULL AUTO_INCREMENT, +tech VARCHAR(6) NULL, +extension VARCHAR(20) NULL, +number VARCHAR(255) NULL, +status VARCHAR(255) NULL, +timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, +Privilege VARCHAR(255) NULL, +Channel VARCHAR(255) NULL, +Cause VARCHAR(255) NULL, +Causetxt VARCHAR(255) NULL, +PeerStatus VARCHAR(255) NULL, +Peer VARCHAR(255) NULL, +Context VARCHAR(255) NULL, +Application VARCHAR(255) NULL, +AppData VARCHAR(255) NULL, +Priority VARCHAR(255) NULL, +Uniqueid VARCHAR(255) NULL, +Event VARCHAR(255) NULL, +State VARCHAR(255) NULL, +CallerIDName VARCHAR(255) NULL, +CallerID VARCHAR(255) NULL, +AstExtension VARCHAR(255) NULL, +PRIMARY KEY (`id`), +KEY `extension` (`extension`)); + +CREATE TABLE activity_logs ( +id INTEGER NOT NULL AUTO_INCREMENT, +timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, +message TEXT NOT NULL DEFAULT '', +user VARCHAR(50), +PRIMARY KEY (`id`)); + +CREATE TABLE sql_commands ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(45) NOT NULL default '', +sql TEXT NOT NULL default '', +comment TEXT NOT NULL default '', +timestamp TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, + PRIMARY KEY (`id`)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-12-07 01:07:00
|
Revision: 2218 http://astpp.svn.sourceforge.net/astpp/?rev=2218&view=rev Author: darrenkw Date: 2008-12-07 01:06:53 +0000 (Sun, 07 Dec 2008) Log Message: ----------- Corrected Freeswitch max call length support. Modified Paths: -------------- trunk/astpp-common.pl trunk/freeswitch/astpp-fs-xml.pl trunk/sql/astpp-2008-12-06.sql Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2008-12-06 22:37:02 UTC (rev 2217) +++ trunk/astpp-common.pl 2008-12-07 01:06:53 UTC (rev 2218) @@ -3677,12 +3677,18 @@ } if ( $numdata->{cost} > 0 ) { $maxlength = ( ( $credit - $numdata->{connectcost} ) / $numdata->{cost} ); + if ($config->{call_max_length} && $maxlength < $config->{call_max_length} / 1000){ + $maxlength = $config->{call_max_length} / 1000 / 60; + } } else { $maxlength = $config->{max_free_length}; # If the call is set to be free then assign a max length. } if ( $numdata->{cost} > 0 ) { $maxlength = ( ( $credit - $numdata->{connectcost} ) / $numdata->{cost} ); + if ($config->{call_max_length} && $maxlength < $config->{call_max_length} / 1000){ + $maxlength = $config->{call_max_length} / 1000 / 60; + } } else { $maxlength = $config->{max_free_length}; # If the call is set to be free then assign a max length. Modified: trunk/freeswitch/astpp-fs-xml.pl =================================================================== --- trunk/freeswitch/astpp-fs-xml.pl 2008-12-06 22:37:02 UTC (rev 2217) +++ trunk/freeswitch/astpp-fs-xml.pl 2008-12-07 01:06:53 UTC (rev 2218) @@ -190,6 +190,8 @@ $xml = $ASTPP->fs_dialplan_xml_footer( xml => $xml ); print $xml; exit(0); + } elsif ($config->{call_max_length} && $maxlength < $config->{call_max_length} / 1000){ + $maxlength = $config->{call_max_length} / 1000; } $xml = $ASTPP->fs_dialplan_xml_timelimit( @@ -229,6 +231,8 @@ } } $xml = $ASTPP->fs_dialplan_xml_footer( xml => $xml ); + $ASTPP->debug( debug => $xml ); + print $xml; } elsif ( $params->{section} eq "directory" ) { @@ -264,7 +268,7 @@ ); $xml = $ASTPP->fs_directory_xml_footer( xml => $xml ); } + $ASTPP->debug( debug => $xml ); + print $xml; } -$ASTPP->debug( debug => $xml ); -print $xml; exit(0); Modified: trunk/sql/astpp-2008-12-06.sql =================================================================== --- trunk/sql/astpp-2008-12-06.sql 2008-12-06 22:37:02 UTC (rev 2217) +++ trunk/sql/astpp-2008-12-06.sql 2008-12-07 01:06:53 UTC (rev 2218) @@ -782,6 +782,9 @@ INSERT INTO system (name, value, comment, timestamp) VALUES ( 'astman_secret', 'amp111','Asterisk(tm) Manager Interface Secret', ''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'call_max_length','1440000','What is the maximum length (in ms) of a LCR call?',''); + ------ 3rd Party PBX Mods INSERT INTO system (name, value, comment, timestamp) VALUES ( 'thirdlane_mods','0','Provides a few different modifications across the rating code to work better with Thirdlane(tm) cdrs.',''); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-01-17 03:22:04
|
Revision: 2219 http://astpp.svn.sourceforge.net/astpp/?rev=2219&view=rev Author: darrenkw Date: 2009-01-17 02:19:55 +0000 (Sat, 17 Jan 2009) Log Message: ----------- Change auto_dialer license to BSD. Fix code that was causing invoices to be totaled incorrectly in oscommerce. Modified Paths: -------------- trunk/astpp-common.pl trunk/contrib/auto_dialer/LICENSE Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2008-12-07 01:06:53 UTC (rev 2218) +++ trunk/astpp-common.pl 2009-01-17 02:19:55 UTC (rev 2219) @@ -4772,7 +4772,7 @@ &markbilled( $astpp_db, $row->{id}, 1 ); } $subtotal = &osc_order_subtotal($osc_db, $config, $invoice_id); - $subtotal = sprintf( "%." . $config->{decimalpoints_total} . "f", $total ); + $subtotal = sprintf( "%." . $config->{decimalpoints_total} . "f", $subtotal ); print STDERR "ORDER $invoice_id SUBTOTAL: $subtotal"; $sort = 1; $tax_count = 1; Modified: trunk/contrib/auto_dialer/LICENSE =================================================================== --- trunk/contrib/auto_dialer/LICENSE 2008-12-07 01:06:53 UTC (rev 2218) +++ trunk/contrib/auto_dialer/LICENSE 2009-01-17 02:19:55 UTC (rev 2219) @@ -1,341 +1,12 @@ - - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - <one line to give the program's name and a brief idea of what it does.> - Copyright (C) 19yy <name of author> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - <signature of Ty Coon>, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. +THE BSD LICENSE + +Copyright (c) 2009, Aleph Communications +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * Neither the name of the Aleph Communications nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-01-17 17:13:27
|
Revision: 2220 http://astpp.svn.sourceforge.net/astpp/?rev=2220&view=rev Author: darrenkw Date: 2009-01-17 17:13:20 +0000 (Sat, 17 Jan 2009) Log Message: ----------- Moved the agi files into the asterisk_apps directory. Modified Paths: -------------- trunk/Makefile Added Paths: ----------- trunk/asterisk_apps/astpp-ani-map.agi trunk/asterisk_apps/astpp-authorize.agi trunk/asterisk_apps/astpp-callback-register.agi trunk/asterisk_apps/astpp-callback.agi trunk/asterisk_apps/astpp-callingcards.agi trunk/asterisk_apps/astpp-did-map.agi trunk/asterisk_apps/astpp-ip-map.agi trunk/asterisk_apps/astpp-lcr.agi trunk/asterisk_apps/astpp-manager-variables.agi trunk/asterisk_apps/astpp-refill.agi Removed Paths: ------------- trunk/astpp-ani-map.agi trunk/astpp-authorize.agi trunk/astpp-callback-register.agi trunk/astpp-callback.agi trunk/astpp-callingcards.agi trunk/astpp-did-map.agi trunk/astpp-ip-map.agi trunk/astpp-lcr.agi trunk/astpp-manager-variables.agi trunk/astpp-refill.agi Modified: trunk/Makefile =================================================================== --- trunk/Makefile 2009-01-17 02:19:55 UTC (rev 2219) +++ trunk/Makefile 2009-01-17 17:13:20 UTC (rev 2220) @@ -63,7 +63,7 @@ install_agi: - for x in *.agi; do \ + for x in asterisk_apps/*.agi; do \ echo $$x; \ install -m 755 -o $(OWNER) -g $(GROUP) $$x $(PREFIX)$(AGIDIR); \ done Copied: trunk/asterisk_apps/astpp-ani-map.agi (from rev 2218, trunk/astpp-ani-map.agi) =================================================================== --- trunk/asterisk_apps/astpp-ani-map.agi (rev 0) +++ trunk/asterisk_apps/astpp-ani-map.agi 2009-01-17 17:13:20 UTC (rev 2220) @@ -0,0 +1,90 @@ +#!/usr/bin/perl +# +# ASTPP - Open Source Voip Billing +# +# Copyright (C) 2004, Aleph Communications +# +# Darren Wiebe (da...@al...) +# +# This program is Free Software and is distributed under the +# terms of the GNU General Public License version 2. +# +# This script is used to authenticate calls to ASTPP accounts based on pin codes in the Dialplan. +# It can be used to do wholesale SIP termination which is authenticated by a pin code that is dialed +# in front of the number to be called. +# + +use DBI; +use Asterisk::AGI; +use POSIX qw(ceil floor); +use POSIX qw(strftime); +use strict; +use vars qw(@output $verbose $SIG $astpp_db $config $AGI); +@output = ( "STDERR", "LOGFILE" ); +$verbose = 2; +require "/usr/local/astpp/astpp-common.pl"; +$AGI = new Asterisk::AGI; + +sub initialize() { + $SIG{HUP} = 'ignore_hup'; + $config = &load_config(); + $astpp_db = &connect_db( $config, @output ); + $config = &load_config_db($astpp_db,$config); +} + +sub ignore_hup { + foreach my $handle (@output) { + print $handle "HUP received\n"; + $AGI->verbose( "HUP received!\n", $verbose ); + } +} + +sub get_ani() { + my ($number) = @_; + my ($sql); + $sql = + $astpp_db->prepare( + "SELECT * FROM ani_map WHERE number = " . $astpp_db->quote($number) . " AND status IN (0,1)" ); + $sql->execute; + $AGI->verbose( "$sql\n", $verbose ); + my $anidata = $sql->fetchrow_hashref; + $sql->finish; + return $anidata; +} + +sub get_cc() { + my ($number) = @_; + my ($sql); + $sql = + $astpp_db->prepare( + "SELECT * FROM accounts WHERE cc = " . $astpp_db->quote($number) ); + $sql->execute; + $AGI->verbose( "$sql\n", $verbose ); + my $anidata = $sql->fetchrow_hashref; + $sql->finish; + return $anidata; +} +################# Program Starts Here ################################# +my ( $number, $type,$variablename ) = @ARGV; +my ( $sql, $anidata ); +&initialize; +if ( $type eq "ANI" || $type eq "PREFIX" ) { + $anidata = &get_ani($number); + $AGI->set_variable( "$variablename", "\"$anidata->{account}\"" ); + $AGI->exec( 'Set', "$variablename=$anidata->{account}" ); + if ($anidata->{context} ne "" ) { + $AGI->set_variable( 'DEST_CONTEXT', "\"$anidata->{context}\"" ); + $AGI->exec( 'Set', "DEST_CONTEXT=$anidata->{context}" ); + } else { + $AGI->set_variable( 'DEST_CONTEXT', "\"$config->{lcrcontext}\"" ); + $AGI->exec( 'Set', "DEST_CONTEXT=$config->{lcrcontext}" ); + } +} +elsif ($type eq "CC") { + $anidata = &get_cc($number); + $AGI->set_variable( "$variablename", "\"$anidata->{cc}\"" ); + $AGI->exec( 'Set', "$variablename=$anidata->{cc}" ); + $AGI->set_variable( 'DEST_CONTEXT', "\"$config->{lcrcontext}\"" ); + $AGI->exec( 'Set', "DEST_CONTEXT=$config->{lcrcontext}" ); + +} Property changes on: trunk/asterisk_apps/astpp-ani-map.agi ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:mergeinfo + Added: svn:eol-style + native Copied: trunk/asterisk_apps/astpp-authorize.agi (from rev 2218, trunk/astpp-authorize.agi) =================================================================== --- trunk/asterisk_apps/astpp-authorize.agi (rev 0) +++ trunk/asterisk_apps/astpp-authorize.agi 2009-01-17 17:13:20 UTC (rev 2220) @@ -0,0 +1,197 @@ +#!/usr/bin/perl +# +# ASTPP - Open Source Voip Billing +# +# Copyright (C) 2004, DNW Consulting +# +# Darren Wiebe (da...@dn...) +# +# This program is Free Software and is distributed under the +# terms of the GNU General Public License version 2. +############################################################ +# +# Usage-example: +# +# ; +# ; Card-number and number to dial derived from command-line. +# ; Call script with the card-number as first arg and the number +# ; to dial as the second arg. astpp-authorize will return a line containing info +# ; that will cut the call off before it goes over the users credit limit. The +# ; user can get over credit limit if they have multiple calls going at once. +# ; Presently the only way to stop that is to limit them to one call which is not +# ; a nice solution. +# ; +# ; The following variables must be set: +# ; USER1 = Username at IAX2 Provider #1 +# ; PASS1 = Password for User1 +# ; PROVIDER1 = IP address of IAX2 Provider #1 or else associate name from +# ; iax.conf +# ; +# With LCR +# [astpp] +# +# exten => _1XXXXXXXXXX,1,Set(GROUP()=${ACCOUNTCODE}) +# exten => _1XXXXXXXXXX,2,AGI(astpp-authorize.agi,${ACCOUNTCODE},${EXTEN}) +# exten => _1XXXXXXXXXX,3,GotoIf($["${CALLSTATUS}" = "0"]?60) ; Checks if account has sufficient funds +# exten => _1XXXXXXXXXX,4,GotoIf($["${CALLSTATUS}" = "1"]?70) ; Checks if the phone number exists +# exten => _1XXXXXXXXXX,5,GotoIf($["${CALLSTATUS}" = "2"]?80) ; Check if account exists +# exten => _1XXXXXXXXXX,6,GotoIf($["${GROUP_COUNT()}" > "${MAXCHANNELS}"]?90) ; Verify number of outgoing channels +# ; assigned to account. +# exten => _1XXXXXXXXXX,7,Set(GROUP(${TRUNK1}-OUTBOUND)=OUTBOUND) +# exten => _1XXXXXXXXXX,8,GotoIf($["${GROUP_COUNT(OUTBOUND@${TRUNK1}-OUTBOUND)}" > "${TRUNK1_MAXCHANNELS}"]?10) +# exten => _1XXXXXXXXXX,9,Dial(${LCRSTRING1}||${TIMELIMIT}|${OPTIONS}) +# exten => _1XXXXXXXXXX,110,Busy +# exten => _1XXXXXXXXXX,10,Set(GROUP(${TRUNK2}-OUTBOUND)=OUTBOUND) +# exten => _1XXXXXXXXXX,11,GotoIf($["${GROUP_COUNT(OUTBOUND@${TRUNK2}-OUTBOUND)}" > "${TRUNK2_MAXCHANNELS}"]?13) +# exten => _1XXXXXXXXXX,12,Dial(${LCRSTRING2}||${TIMELIMIT}|${OPTIONS}) +# exten => _1XXXXXXXXXX,113,Busy +# exten => _1XXXXXXXXXX,13,Set(GROUP(${TRUNK2}-OUTBOUND)=OUTBOUND) +# exten => _1XXXXXXXXXX,14,GotoIf($["${GROUP_COUNT(OUTBOUND@${TRUNK3}-OUTBOUND)}" > "${TRUNK3_MAXCHANNELS}"]?16) +# exten => _1XXXXXXXXXX,15,Dial(${LCRSTRING3}||${TIMELIMIT}|${OPTIONS}) +# exten => _1XXXXXXXXXX,116,Busy +# exten => _1XXXXXXXXXX,16,Set(GROUP(${TRUNK4}-OUTBOUND)=OUTBOUND) +# exten => _1XXXXXXXXXX,17,GotoIf($["${GROUP_COUNT(OUTBOUND@${TRUNK4}-OUTBOUND)}" > "${TRUNK4_MAXCHANNELS}"]?19) +# exten => _1XXXXXXXXXX,18,Dial(${LCRSTRING4}||${TIMELIMIT}|${OPTIONS}) +# exten => _1XXXXXXXXXX,119,Busy +# exten => _1XXXXXXXXXX,19,Set(GROUP(${TRUNK5}-OUTBOUND)=OUTBOUND) +# exten => _1XXXXXXXXXX,20,GotoIf($["${GROUP_COUNT(OUTBOUND@${TRUNK5})-OUTBOUND}" > "${TRUNK5_MAXCHANNELS}"]?22) +# exten => _1XXXXXXXXXX,21,Dial(${LCRSTRING5}||${TIMELIMIT}|${OPTIONS}) +# exten => _1XXXXXXXXXX,122,Busy +# exten => _1XXXXXXXXXX,22,Goto(100) +# exten => _1XXXXXXXXXX,60,Congestion ; '0' Tells them they do not have enough money +# exten => _1XXXXXXXXXX,61,Hangup +# exten => _1XXXXXXXXXX,70,Congestion '1' Bad Phone Number +# exten => _1XXXXXXXXXX,71,Hangup +# exten => _1XXXXXXXXXX,80,Congestion +# exten => _1XXXXXXXXXX,81,Hangup +# exten => _1XXXXXXXXXX,90,Congestion ; Their outgoing channel limit is full already +# exten => _1XXXXXXXXXX,91,Hangup +# exten => _1XXXXXXXXXX,100,Congestion ; No Route Available +# exten => _1XXXXXXXXXX,101,Hangup +# ; This lines are optional and would forward users to a help desk if the call did not go through. +# exten => _1XXXXXXXXXX,60,Dial(SIP/HELPDESK) ; '0' Tells them they do not have enough money +# exten => _1XXXXXXXXXX,61,Hangup +# exten => _1XXXXXXXXXX,70,Dial(SIP/HELPDESK) ; '1' Bad Phone Number +# exten => _1XXXXXXXXXX,71,Hangup +# exten => _1XXXXXXXXXX,80,Dial(SIP/HELPDESK) +# exten => _1XXXXXXXXXX,81,Hangup + +use DBI; +use Asterisk::AGI; +use strict; +use vars qw(@output $config $astpp_db $verbosity $AGI); +use Locale::gettext_pp qw(:locale_h); +require "/usr/local/astpp/astpp-common.pl"; +$ENV{LANGUAGE} = "en"; # de, es, br - whatever +print STDERR "Interface language is set to: " . $ENV{LANGUAGE} . "\n"; +bindtextdomain( "astpp", "/usr/local/share/locale" ); +textdomain("astpp"); +$verbosity = 2; +@output = ("STDERR"); +$AGI = new Asterisk::AGI; + +################# Programs start here ####################################### +my ( $accountcode, $phoneno ) = @ARGV; +my ( $maxlength, $maxmins,$callstatus ); +$AGI->set_variable( 'ASTPP', '1' ); +$AGI->verbose( "$accountcode, $phoneno", $verbosity ); +$config = &load_config(); +$astpp_db = &connect_db( $config, @output ); +$config = &load_config_db($astpp_db,$config); +my $carddata = &get_account( $astpp_db, $accountcode ); # Fetch all the account info from the db. + +if ( !$carddata->{number} ) { # Check to see if the account exists. If not then exit. + $AGI->verbose( "CALLSTATUS 2\n", $verbosity ); + $AGI->verbose( "CANNOT RETRIEVE CARD\n", $verbosity ); + $AGI->set_variable( 'CALLSTATUS', "\"2\"" ); + $AGI->exec( 'Set', "CALLSTATUS=2" ); + exit(0); +} + +if ($carddata->{dialed_modify}) { + my @regexs = split(m/,/m, $carddata->{dialed_modify}); + foreach my $regex (@regexs) { + $regex =~ s/"//g; #Strip off quotation marks + my ($grab,$replace) = split(m!/!i, $regex); # This will split the variable into a "grab" and "replace" as needed + $AGI->verbose( "Grab: $grab\n", $verbosity ) if $config->{debug} == 1; + $AGI->verbose( "Replacement: $replace\n", $verbosity ) if $config->{debug} == 1; + $AGI->verbose( "Phone Before: $phoneno\n", $verbosity ) if $config->{debug} == 1; + $phoneno =~ s/$grab/$replace/is; + $AGI->verbose( "Phone After: $phoneno\n", $verbosity ) if $config->{debug} == 1 + } + } + +print STDERR "\nFINDING LIMIT FOR: $carddata->{number}\n" if $config->{debug} == 1; +($callstatus, $maxlength) = &max_length($astpp_db, $config, $carddata, $phoneno); +my $routeinfo = &get_route( $astpp_db, $config, $phoneno, $carddata->{pricelist},$carddata ); +print STDERR "Minimum Charge on call = $routeinfo->{cost}" if $config->{debug} == 1; +my $minimumcharge = $routeinfo->{cost}; +my @reseller_list; +print STDERR "\nCALLSTATUS: $callstatus MAX_LENGTH: $maxlength\n" if $config->{debug} == 1; +while ( $carddata->{reseller} && $maxlength > 1 && $callstatus == 1) { + print STDERR "\nFINDING LIMIT FOR: $carddata->{reseller}\n" if $config->{debug} == 1; + $carddata = &get_account( $astpp_db, $carddata->{reseller} ); + push @reseller_list, $carddata->{number}; + print STDERR "ADDING $carddata->{number} to the list of resellers for this account\n" if $config->{debug} == 1; + my ($resellercallstatus, $resellermaxlength) = &max_length($astpp_db, $config, $carddata, $phoneno); + my $routeinfo = &get_route( $astpp_db, $config, $phoneno, $carddata->{pricelist},$carddata ); + if ($resellercallstatus != 1) { + $carddata->{reseller} = ""; + $callstatus = $resellercallstatus; + } elsif ($resellermaxlength < $maxlength) { + $maxlength = $resellermaxlength; + } + print STDERR "Reseller cost = $routeinfo->{cost} and minimum charge is $minimumcharge\n" if $config->{debug} == 1; + if ($resellermaxlength < 1 || $routeinfo->{cost} > $minimumcharge ) { + $AGI->verbose("Reseller call is priced too cheap! Call being barred!", $verbosity ) if $config->{debug} == 1; + $callstatus = 0; + $maxlength = 0; + } + print STDERR "\nRESELLER Max Length: $resellermaxlength\n" if $config->{debug} == 1; + print STDERR "RESELLER Call Status: $resellercallstatus\n" if $config->{debug} == 1; +} + +if ($config->{debug} == 1) { + $AGI->verbose( "PRINTING LIST OF RESELLERS FOR THIS ACCOUNT\n", $verbosity ); + foreach my $reseller (@reseller_list) { + $AGI->verbose( "RESELLER: $reseller", $verbosity ); + } +} + +$AGI->verbose( "Max Call Length: $maxlength minutes\n", $verbosity ); +$AGI->verbose( "Call Status: $callstatus\n", $verbosity ); + +if ( $maxlength <= 1 ) { + $AGI->verbose( "NOT ENOUGH CREDIT\n", $verbosity ); + $AGI->set_variable( 'CALLSTATUS', "\"0\"" ); + exit(0); +} + +# Set the timelimit as well as other variables which are needed in the dialplan. +my $timelimit = "L(" . sprintf( "%.0f", $maxlength * 60 * 1000 ) . ":60000:30000)"; +$AGI->set_variable( "\"TIMELIMIT\"", "\"$timelimit\"" ); +$AGI->set_variable( "\"OPTIONS\"", "\"Hj\"" ); +$AGI->set_variable( 'CALLSTATUS', "\"3\"" ); +$AGI->set_variable( 'MAXCHANNELS', "\"$carddata->{maxchannels}\"" ); +if ( $config->{enablelcr} == 1 ) { # Do we do LCR on our outgoing calls? If so then carry on. + $AGI->verbose( "Looking for outbound Route\n", $verbosity ); + my $routeinfo = &get_route($astpp_db,$config,$phoneno,$carddata->{pricelist},$carddata); + # Get the list of routes for the phone number. + my @outboundroutes = &get_outbound_routes( $astpp_db, $phoneno,$carddata,$routeinfo, @reseller_list ); + my $count = 1; + foreach my $route (@outboundroutes) { + $AGI->verbose( "$route->{trunk}: cost $route->{cost}\t $route->{pattern}", $verbosity ); + if ($route->{cost} > $routeinfo->{cost}) { + $AGI->verbose( "$route->{trunk}: $route->{cost} > $routeinfo->{cost}, skipping\n", $verbosity ); + } else { + my $trunkdata = &get_trunk($astpp_db, $route->{trunk}); + my $dialstring = &get_dial_string( $astpp_db, $route, $phoneno ); + $AGI->set_variable( "\"LCRTRUNKS\"", "\"$count\"" ); + $AGI->set_variable( "\"LCRSTRING$count\"", "\"$dialstring\"" ); + $AGI->set_variable( "\"TRUNK$count\"", "\"$route->{trunk}\"" ); + $AGI->set_variable( "\"TRUNK" . $count . "_MAXCHANNELS\"", "\"$trunkdata->{maxchannels}\"" ); + $count++; + } + } +} +exit(0); Property changes on: trunk/asterisk_apps/astpp-authorize.agi ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:mergeinfo + Added: svn:eol-style + native Copied: trunk/asterisk_apps/astpp-callback-register.agi (from rev 2218, trunk/astpp-callback-register.agi) =================================================================== --- trunk/asterisk_apps/astpp-callback-register.agi (rev 0) +++ trunk/asterisk_apps/astpp-callback-register.agi 2009-01-17 17:13:20 UTC (rev 2220) @@ -0,0 +1,272 @@ +#!/usr/bin/perl +# +# ASTPP callfile creation +# +# Copyright (C) 2006, DNW Consulting +# +# Darren Wiebe <da...@dn...> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Contact information can be found @ www.dnwconsulting.net +# +# ANI Map Info +# Status 0 is for regular ASTPP accounts and status 1 is for calling cards +# that are ok. Status 2 is a blocked number. +# This program is used to request callbacks from ASTPP for calling cards. It's +# also used to register telephone numbers in the "ani_map" table. You can set it +# to register only by passing along "REGISTER" in the ${DESTINATION} field. Here's an +# example on how to call it. +# +# ${CARDNUMBER} = The calling card number we wish to register to. +# ${PIN} = The pin for ${CARDNUMBER} if appropriate. +# ${CALLERIDNUM} = Is the number we are calling from and will use for ANI authentication. +# This is also the number we will be called back at. +# ${DESTINATION} = The number we wish the system to call once we are authenticated. +# +# +# exten => 2,2,DeadAGI(astpp-register-card.agi,${CALLERIDNUM},${DESTINATION},${CARDNUMBER},${PIN}) +# +# +###########################################################################` + +use POSIX qw(ceil floor); +use POSIX qw(strftime); +use DBI; +use Asterisk::AGI; +use strict; +require "/usr/local/astpp/astpp-common.pl"; +use vars qw($vars $verbose $astpp_db $AGI $config @output $sound); +$verbose = 2; +@output = ("STDERR"); +$AGI = new Asterisk::AGI; +$config = &load_config(); +$astpp_db = &connect_db( $config, @output ); +$config = &load_config_db( $astpp_db, $config ); +my $brand = $AGI->get_variable("BRAND"); +if ($brand) { + my $brandinfo = &get_cc_brand($astpp_db, $brand); + if ($brandinfo->{reseller}) { + $config = &load_config_db_reseller($astpp_db,$config,$brandinfo->{reseller}); + } + $config = &load_config_db_brand($astpp_db,$config,$brand); +} +$sound = &define_sounds($astpp_db); +$SIG{HUP} = 'ignore_hup'; +my $verbosity = 2; +my $input_timeout = 15000; #How long do we wait for input? Specified in MS + +sub ignore_hup { + foreach my $handle (@output) { + print $handle "HUP received\n"; + } +} + +sub get_ani() { + my ($number) = @_; + my ($sql); + $sql = + $astpp_db->prepare( + "SELECT * FROM ani_map WHERE number = " . $astpp_db->quote($number) ); + $sql->execute; + $AGI->verbose( "$sql\n", $verbose ); + my $anidata = $sql->fetchrow_hashref; + $sql->finish; + return $anidata; +} + +###################################################################### +# Beginning of Program +###################################################################### +my ( $callerid, $destination, $cardnumber, $pin ) = @ARGV; +$AGI->answer(); +my ( $clidnumber, $retries ); +while ( !$clidnumber && $retries < $config->{card_retries} ) { + my $answer = $AGI->get_data( $sound->{number_to_register}, $input_timeout ); + if ( $answer == 1 ) { + $clidnumber = $callerid; + } elsif ( $answer > 1 ) { + $clidnumber = $answer; + } else { + $retries++; + } +} +if ( $retries > $config->{card_retries} ) { + $AGI->stream_file($sound->{goodbye}); + exit(0); +} + +my $numberdata = &get_ani($clidnumber); + +if ( $numberdata->{status} == 2 ) { #This number is in our "blocked" list. + $AGI->stream_file($sound->{badnumber}); + $AGI->stream_file($sound->{goodbye}); + exit(0); +} elsif ( !$numberdata ) { + my $cardinfo; + $cardinfo = &get_callingcard( $astpp_db, $cardnumber, $config ) if $cardnumber; + my $retries = 0; + while ( $cardinfo->{status} != 1 && $retries < $config->{card_retries} ) { + my $cardnum = $AGI->get_data( $sound->{cardnumber}, $input_timeout ); + $cardinfo = &get_callingcard( $astpp_db, $cardnum, $config ); + $AGI->verbose( "ASTPP Number: $cardnum ", $verbosity ) + if $config->{debug} == 1; + $AGI->verbose( "ASTPP Number Status: $cardinfo->{status}", $verbosity ) + if $config->{debug} == 1; + if ( $cardinfo->{status} != 1 ) { + $AGI->stream_file($sound->{cardnumber_incorrect}); + } + $retries++; + } + if ( !$cardinfo->{status} ) { + my $sql = + "INSERT INTO ani_map (number,status) VALUES (" + . $astpp_db->quote($clidnumber) . ", 0)"; + $AGI->verbose( "SQL $sql", $verbosity ) + if $config->{debug} == 1; + $astpp_db->do($sql); + $AGI->stream_file($sound->{goodbye}); + $AGI->hangup(); + exit(0); + } elsif ( $cardinfo->{status} != 1 ) { + $AGI->stream_file($sound->{goodbye}); + $AGI->hangup(); + exit(0); + } + if ( $pin != $cardinfo->{pin} ) { + $retries = 0; + while ( $cardinfo->{pin} != $pin && $retries < $config->{pin_retries} ) { + $pin = $AGI->get_data( $sound->{pin}, $input_timeout ); + if ( $cardinfo->{pin} != $pin ) { + $AGI->stream_file($sound->{pin_incorrect}); + } + $retries++; + } + } + if ( $pin != $cardinfo->{pin} ) { + my $sql = + "INSERT INTO ani_map (number,status) VALUES (" + . $astpp_db->quote($clidnumber) . ", 0)"; + $AGI->verbose( "SQL $sql", $verbosity ) + if $config->{debug} == 1; + $astpp_db->do($sql); + $AGI->stream_file($sound->{goodbye}); + $AGI->hangup(); + exit(0); + } + my $cardstatus = &check_card_status( $astpp_db, $cardinfo ); + # This subroutine returns the status of the card: + if ( $cardstatus == 1 ) { + $AGI->stream_file($sound->{card_inuse}); + $AGI->stream_file($sound->{goodbye}); + } elsif ( $cardstatus == 2 ) { + $AGI->stream_file($sound->{card_has_expired}); + $AGI->stream_file($sound->{goodbye}); + $AGI->hangup(); + } elsif ( $cardstatus == 3 ) { + $AGI->stream_file($sound->{card_is_empty}); + $AGI->hangup(); + } + my $register = $AGI->get_data( $sound->{register_ani}, $input_timeout ); + if ( $register == 1 ) { + my $sql = + "INSERT INTO ani_map (number,account,status) VALUES (" + . $astpp_db->quote($clidnumber) . ", " + . $astpp_db->quote( $cardinfo->{cardnumber} ) . ", 0)"; + $AGI->verbose( "SQL $sql", $verbosity ) + if $config->{debug} == 1; + $astpp_db->do($sql); + } +} else { + $AGI->stream_file($sound->{goodbye}); + $AGI->hangup(); + exit(0); +} + +$numberdata = &get_ani($clidnumber); +if ( $numberdata->{status} == 1 && $destination ne "REGISTER" ) +{ #This number is registered to a calling card. + my $cardinfo = &get_callingcard( $astpp_db, $numberdata->{account}, $config ); + my $cardstatus = &check_card_status( $astpp_db, $cardinfo ); + # This subroutine returns the status of the card: + if ( $cardstatus == 1 ) { + $AGI->stream_file($sound->{card_inuse}); + $AGI->stream_file($sound->{goodbye}); + } elsif ( $cardstatus == 2 ) { + $AGI->stream_file($sound->{card_has_expired}); + $AGI->stream_file($sound->{goodbye}); + $AGI->hangup(); + } elsif ( $cardstatus == 3 ) { + $AGI->stream_file($sound->{card_is_empty}); + $AGI->hangup(); + } elsif ( $cardstatus == 0 ) { + my $retries = 0; + my $desination; + while ( !$destination && $retries < $config->{number_retries} ) { + my $answer = $AGI->get_data( $sound->{where_to_call}, $input_timeout ); + if ( $answer == 1 ) { + $destination = $clidnumber; + } elsif ( $answer > 1 ) { + $destination = $answer; + } else { + $retries++; + } + } + if ( $retries > $config->{number_retries} ) { + $AGI->stream_file($sound->{goodbye}); + exit(0); + } + + # If we get this far then it means that the account is good to go. + my @variables; + my $brandinfo = &get_cc_brand( $astpp_db, $cardinfo->{brand} ); + if ($brandinfo->{reseller}) { + $config = &load_config_db_reseller($astpp_db,$config,$brandinfo->{reseller}); + } + $config = &load_config_db_brand($astpp_db,$config,$cardinfo->{brand}); + my $rateinfo = + &get_route( $astpp_db, $config, $destination, $brandinfo->{pricelist}, + $cardinfo ); + my $connectsurcharge->{name} = "CONNECTSURCHARGE"; + $connectsurcharge->{value} = $rateinfo->{connectcost}; + my $perminutesurcharge->{name} = "PERMINUTESURCHARGE"; + $perminutesurcharge->{value} = $rateinfo->{cost}; + $destination->{name} = "DESTINATION"; + $destination->{value} = $destination; + $pin->{name} = "PIN"; + $pin->{value} = $pin; + push @variables, $connectsurcharge; + push @variables, $perminutesurcharge; + push @variables, $destination; + push @variables, $pin; + &perform_callout( + $destination, + $config->{lcrcontext}, + $config->{callout_accountcode}, + $config->{maxretries}, + $config->{waittime}, + $config->{retrytime}, + $config->{clidname}, + $config->{clidnumber}, + $config->{callingcards_callback_context}, + $config->{callingcards_callback_extension}, + @variables + ); + $AGI->stream_file($sound->{callback_performed}); + $AGI->stream_file($sound->{goodbye}); + exit(0); + } +} + +exit(0); Property changes on: trunk/asterisk_apps/astpp-callback-register.agi ___________________________________________________________________ Added: svn:executable + * Added: svn:mergeinfo + Copied: trunk/asterisk_apps/astpp-callback.agi (from rev 2218, trunk/astpp-callback.agi) =================================================================== --- trunk/asterisk_apps/astpp-callback.agi (rev 0) +++ trunk/asterisk_apps/astpp-callback.agi 2009-01-17 17:13:20 UTC (rev 2220) @@ -0,0 +1,278 @@ +#!/usr/bin/perl +# +# ASTPP callfile creation +# +# Copyright (C) 2006, DNW Consulting +# +# Darren Wiebe <da...@dn...> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Contact information can be found @ www.dnwconsulting.net +# +# ANI Map Info +# Status 0 is for regular ASTPP accounts and status 1 is for calling cards +# that are ok. Status 2 is a blocked number. +# This program is used to request callbacks from ASTPP for calling cards. It's +# also used to register telephone numbers in the "ani_map" table. You can set it +# to register only by passing along "REGISTER" in the ${DESTINATION} field. Here's an +# example on how to call it. +# +# ${CARDNUMBER} = The calling card number we wish to register to. +# ${PIN} = The pin for ${CARDNUMBER} if appropriate. +# ${CALLERIDNUM} = Is the number we are calling from and will use for ANI authentication. +# This is also the number we will be called back at. +# ${DESTINATION} = The number we wish the system to call once we are authenticated. +# +# +# exten => 2,2,DeadAGI(astpp-register-card.agi,${CALLERIDNUM},${DESTINATION},${CARDNUMBER},${PIN}) +# +# +###########################################################################` + +use POSIX qw(ceil floor); +use POSIX qw(strftime); +use DBI; +use Asterisk::AGI; +use strict; +require "/usr/local/astpp/astpp-common.pl"; +use vars qw($vars $verbose $brandinfo $astpp_db $AGI $config @output $sound); +$verbose = 2; +@output = ("STDERR"); +$AGI = new Asterisk::AGI; + +sub initialize() { +$config = &load_config(); +$astpp_db = &connect_db( $config, @output ); +$config = &load_config_db( $astpp_db, $config ); +my $brand = $AGI->get_variable("BRAND"); +if ($brand) { + $brandinfo = &get_cc_brand($astpp_db, $brand); + if ($brandinfo->{reseller}) { + $config = &load_config_db_reseller($astpp_db,$config,$brandinfo->{reseller}); + } + $config = &load_config_db_brand($astpp_db,$config,$brand); +} +} +$sound = &define_sounds($astpp_db); +$SIG{HUP} = 'ignore_hup'; +my $verbosity = 2; +my $input_timeout = 15000; #How long do we wait for input? Specified in MS + +sub ignore_hup { + foreach my $handle (@output) { + print $handle "HUP received\n"; + } +} + +sub get_ani() { + my ($number) = @_; + my ($sql); + my $tmp = "SELECT * FROM ani_map WHERE number = " . $astpp_db->quote($number); + $sql = + $astpp_db->prepare($tmp); + $sql->execute; + $AGI->verbose( "$tmp\n", $verbose ); + my $anidata = $sql->fetchrow_hashref; + $sql->finish; + return $anidata; +} + +###################################################################### +# Beginning of Program +###################################################################### +my ( $callerid, $destination, $cardnumber, $pin ) = @ARGV; +$AGI->answer(); +my ( $clidnumber, $retries ); +&initialize(); +$retries = 0; +$clidnumber = $callerid if $destination ne "REGISTER"; +while ( !$clidnumber && $retries < $config->{card_retries} ) { + my $answer = $AGI->get_data( $sound->{number_to_register}, $input_timeout ); + if ( $answer == 1 ) { + $clidnumber = $callerid; + } elsif ( $answer > 1 ) { + $clidnumber = $answer; + } else { + $retries++; + } +} +if ( $retries > $config->{card_retries} ) { + $AGI->stream_file($sound->{goodbye}); + exit(0); +} + +my $numberdata = &get_ani($clidnumber); + +if ( $numberdata->{status} == 2 ) { #This number is in our "blocked" list. + $AGI->stream_file($sound->{badnumber}); + $AGI->stream_file($sound->{goodbye}); + exit(0); +} elsif ( !$numberdata->{number} ) { + my $cardinfo; + $cardinfo = &get_callingcard( $astpp_db, $cardnumber, $config ) if $cardnumber; + my $retries = 0; + while ( $cardinfo->{status} != 1 && $retries < $config->{card_retries} ) { + my $cardnum = $AGI->get_data( $sound->{cardnumber}, $input_timeout ); + $cardinfo = &get_callingcard( $astpp_db, $cardnum, $config ); + $AGI->verbose( "ASTPP Number: $cardnum ", $verbosity ) + if $config->{debug} == 1; + $AGI->verbose( "ASTPP Number Status: $cardinfo->{status}", $verbosity ) + if $config->{debug} == 1; + if ( $cardinfo->{status} != 1 ) { + $AGI->stream_file($sound->{cardnumber_incorrect}); + } + $retries++; + } + if ( !$cardinfo->{status} ) { + my $sql = + "INSERT INTO ani_map (number,status) VALUES (" + . $astpp_db->quote($clidnumber) . ", 2)"; + $AGI->verbose( "SQL $sql", $verbosity ) + if $config->{debug} == 1; + $astpp_db->do($sql); + $AGI->stream_file($sound->{goodbye}); + $AGI->hangup(); + exit(0); + } elsif ( $cardinfo->{status} != 1 ) { + $AGI->stream_file($sound->{goodbye}); + $AGI->hangup(); + exit(0); + } + if ( $pin != $cardinfo->{pin} ) { + $retries = 0; + while ( $cardinfo->{pin} != $pin && $retries < $config->{pin_retries} ) { + $pin = $AGI->get_data( $sound->{pin}, $input_timeout ); + if ( $cardinfo->{pin} != $pin ) { + $AGI->stream_file($sound->{pin_incorrect}); + } + $retries++; + } + } + if ( $pin != $cardinfo->{pin} ) { + my $sql = + "INSERT INTO ani_map (number,status) VALUES (" + . $astpp_db->quote($clidnumber) . ", 2)"; + $AGI->verbose( "SQL $sql", $verbosity ) + if $config->{debug} == 1; + $astpp_db->do($sql); + $AGI->stream_file($sound->{goodbye}); + $AGI->hangup(); + exit(0); + } + my $cardstatus = &check_card_status( $astpp_db, $cardinfo ); + # This subroutine returns the status of the card: + if ( $cardstatus == 1 ) { + $AGI->stream_file($sound->{card_inuse}); + $AGI->stream_file($sound->{goodbye}); + } elsif ( $cardstatus == 2 ) { + $AGI->stream_file($sound->{card_has_expired}); + $AGI->stream_file($sound->{goodbye}); + $AGI->hangup(); + } elsif ( $cardstatus == 3 ) { + $AGI->stream_file($sound->{card_is_empty}); + $AGI->hangup(); + } + my $register = $AGI->get_data( $sound->{register_ani}, $input_timeout ); + if ( $register == 1 ) { + my $sql = + "INSERT INTO ani_map (number,account,status) VALUES (" + . $astpp_db->quote($clidnumber) . ", " + . $astpp_db->quote( $cardinfo->{cardnumber} ) . ", 1)"; + $AGI->verbose( "SQL $sql", $verbosity ) + if $config->{debug} == 1; + $astpp_db->do($sql); + } +} else { + if ($destination eq "REGISTER") { + $AGI->stream_file($sound->{goodbye}); + $AGI->hangup(); + exit(0); + } +} + +$numberdata = &get_ani($clidnumber); +if ( $numberdata->{status} == 1 && $destination ne "REGISTER" ) +{ #This number is registered to a calling card. + my $cardinfo = &get_callingcard( $astpp_db, $numberdata->{account}, $config ); + my $cardstatus = &check_card_status( $astpp_db, $cardinfo ); + # This subroutine returns the status of the card: + if ( $cardstatus == 1 ) { + $AGI->stream_file($sound->{card_inuse}); + $AGI->stream_file($sound->{goodbye}); + } elsif ( $cardstatus == 2 ) { + $AGI->stream_file($sound->{card_has_expired}); + $AGI->stream_file($sound->{goodbye}); + $AGI->hangup(); + } elsif ( $cardstatus == 3 ) { + $AGI->stream_file($sound->{card_is_empty}); + $AGI->hangup(); + } elsif ( $cardstatus == 0 ) { + my $retries = 0; + my $destination; + while ( !$destination && $retries < $config->{number_retries} ) { + my $answer = $AGI->get_data( $sound->{where_to_call}, $input_timeout ); + if ( $answer == 1 ) { + $destination = $clidnumber; + } elsif ( $answer > 1 ) { + $destination = $answer; + } else { + $retries++; + } + } + if ( $retries > $config->{number_retries} ) { + $AGI->stream_file($sound->{goodbye}); + exit(0); + } + + # If we get this far then it means that the account is good to go. + my @variables; + my $brandinfo = &get_cc_brand( $astpp_db, $cardinfo->{brand} ); + if ($brandinfo->{reseller}) { + $config = &load_config_db_reseller($astpp_db,$config,$brandinfo->{reseller}); + } + $config = &load_config_db_brand($astpp_db,$config,$cardinfo->{brand}); + if ($destination =~ m/\d\d\d\d\d\d\d\d\d\d/) { + $destination = "1" . $destination; + } + my $rateinfo = + &get_route( $astpp_db, $config, $destination, $brandinfo->{pricelist}, + $cardinfo ); + $AGI->stream_file($sound->{callback_performed}); + $AGI->stream_file($sound->{goodbye}); + $AGI->hangup(); + sleep 15; # This is to give the customer time to hang their phone up. + my %variables = ( CONNECTSURCHARGE => $rateinfo->{connectcost}, + PERMINUTESURCHARGE => $rateinfo->{cost}, + CARDNUMBER => $cardinfo->{cardnumber}, + PIN => $cardinfo->{pin}); + my $ActionID = &perform_callout( + $astpp_db, $config, + $destination, + $config->{lcrcontext}, + $config->{callout_accountcode}, + $config->{maxretries}, + $config->{waittime}, + $config->{retrytime}, + $config->{clidname}, + $config->{clidnumber}, + $config->{callingcards_callback_context}, + $config->{callingcards_callback_extension}, + %variables + ); + exit(0); + } +} + +exit(0); Property changes on: trunk/asterisk_apps/astpp-callback.agi ___________________________________________________________________ Added: svn:executable + * Added: svn:mergeinfo + Copied: trunk/asterisk_apps/astpp-callingcards.agi (from rev 2218, trunk/astpp-callingcards.agi) =================================================================== --- trunk/asterisk_apps/astpp-callingcards.agi (rev 0) +++ trunk/asterisk_apps/astpp-callingcards.agi 2009-01-17 17:13:20 UTC (rev 2220) @@ -0,0 +1,774 @@ +#!/usr/bin/perl +# +# ASTPP - Open Source Voip Billing +# +# Copyright (C) 2004, Aleph Communications +# +# Darren Wiebe (da...@al...) +# +# This program is Free Software and is distributed under the +# terms of the GNU General Public License version 2. +# +# Sample Configuration +# [astpp-callingcards] +# exten => s,1,Answer +# exten => s,n,DeadAGI(astpp-callingcards.agi) +# exten => s,n,GotoIf($["${NEWCALL}" = "1"]?60) +# exten => s,n,GotoIf($["${BALANCE}" = "1"]?70) +# exten => s,n,Hangup +# exten => s,60,DeadAGI(astpp-callingcards.agi,${CARDNUMBER}) +# exten => s,n,Hangup +# exten => s,70,DeadAGI(astpp-callingcards.agi,${CARDNUMBER},BALANCE) +# +############################################################################# +use DBI; +use Asterisk::AGI; +use POSIX qw(ceil floor); +use POSIX qw(strftime); +use Time::HiRes qw( gettimeofday tv_interval ); +use ASTPP; +#use strict; + +use vars qw(@output $verbosity $AGI $config $astpp_db $cdr_db + $ASTPP %stats %input $cc $pricelistinfo $brandinfo $sound @resellerlist $brand); +$stats{start_time} = [gettimeofday]; +$cc = 0; +$verbosity = 1; +require "/usr/local/astpp/astpp-common.pl"; + +$AGI = new Asterisk::AGI; +$AGI->set_variable( 'ASTPP', '1' ); +$ASTPP = ASTPP->new; +$ASTPP->set_verbosity($verbosity); #Tell ASTPP debugging how verbose we want to be. +#$ASTPP->set_asterisk_agi($AGI); + +sub initialize() { + $SIG{HUP} = 'ignore_hup'; # We ignore the HUP command that Asterisk sends on a call hangup. + $config = &load_config(); # Load /var/lib/astpp/astpp-config.conf + $astpp_db = &connect_db( $config, @output ); + $ASTPP->set_astpp_db($astpp_db); + $config = &load_config_db($astpp_db,$config); + $brand = $AGI->get_variable("BRAND"); + if ($brand && $brand ne "") { + my $brandinfo = &get_cc_brand($astpp_db, $brand); + if ($brandinfo->{reseller}) { + $config = &load_config_db_reseller($astpp_db,$config,$brandinfo->{reseller}); + } + $config = &load_config_db_brand($astpp_db,$config,$brand); + } + $cdr_db = &cdr_connect_db( $config, @output ); + $ASTPP->set_cdr_db($cdr_db); + $sound = &define_sounds($astpp_db); +} + +=over 4 + +=item bgplay([$filename1, $filename2, ..., $filenameN], $timeout, $maxdigit) + +Executes Asterisk Command "Background filename1&filename2...filenameN" And +Asterisk AGI Command "Get Data filename timeout, maxdigit". + +This command instructs Asterisk to play the given list of sound files and wait for user input in form of DTMF, +upto 'maxdigit' (optional) till timeout (optional) happens. Files extension must not be used in the filename +because Asterisk will find the most appropriate file type. + +Example: bgplay(["demo-echotest", "echo-test"], 10, 4); +Plays files "demo-echotest" and "echo-test" and waits for 10 seconds for user to enter 4 dight DTMF. + +Returns: -1 on error or hangup, +0 if timeout for user input happens, +or user input upto maxdigit value (default 1) + +=cut + +sub bgplay(\@;$$) +{ + my $files = shift; + my $timeout = shift||1; + my $maxdigit= shift||1; + + my $x = shift(@{$files}); + foreach (@{$files}) { + $x .= '&' . $_; + } + + my $res = $AGI->exec("Background $x"); + + if($res > 0) { + $res -= 48; + } + + if($maxdigit > 1) { + $res .= $AGI->get_data("silence/1", ($timeout * 1000), ($maxdigit - 1)); + } + + return $res; +} + +sub ignore_hup { + $ASTPP->debug( debug => "HUP received", + verbosity => $verbosity); +} + +sub set_in_use() { # Set the "inuse" flag on the calling cards. This prevents multiple people from +# using the same card. + my ( $cardinfo, $status ) = @_; + my $sql; + $sql = + "UPDATE callingcards SET inuse = " + . $astpp_db->quote($status) + . " WHERE cardnumber = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $astpp_db->do($sql); +} + +sub check_card() { # Check a few things before saying the card is ok. + my ($cardinfo) = @_; + my $now = $astpp_db->selectall_arrayref("SELECT NOW() + 0")->[0][0]; + $ASTPP->debug( debug => "Present Time: $now", + verbosity => $verbosity ); + $ASTPP->debug( debug => "Expiration Date: $cardinfo->{expiry}", + verbosity => $verbosity ); + $ASTPP->debug( debug => "Valid for Days: $cardinfo->{validfordays}", + verbosity => $verbosity ); + $ASTPP->debug( debug => "First Use: $cardinfo->{firstused}", + verbosity => $verbosity ); + if ( $cardinfo->{inuse} != 0 ) { # If the card is in use then say so and leave. + $AGI->stream_file($sound->{card_inuse}); + $AGI->stream_file($sound->{goodbye}); + &leave($cardinfo); + } + &set_in_use( $cardinfo, 1 ); # Now the card is in use and nobody else can use it. + if ( $cardinfo->{firstused} eq "00000000000000" || $cardinfo->{firstused} eq "0000-00-00 00:00:00" ) { # If "firstused" has not been set, we will set it now. + # At the same time we will update the "maint_day" field. + my $sql = + "UPDATE callingcards SET firstused = NOW() WHERE cardnumber = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $ASTPP->debug( debug => $sql, + verbosity => $verbosity ); + $astpp_db->do($sql); + $sql = + "UPDATE callingcards SET maint_day = DATE_ADD(NOW(), INTERVAL " + . "$cardinfo->{maint_fee_days} day) WHERE cardnumber = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $ASTPP->debug( debug => $sql, + verbosity => $verbosity ); + if ( $cardinfo->{maint_fee_days} > 0 ) { + $astpp_db->do($sql); + } +# $cardinfo = &get_callingcard( $astpp_db, $cardinfo->{cardnumber} ); + if ( $cardinfo->{validfordays} > 0 ) { #Check if the card is set to expire and deal with that as appropriate. + my $sql = +"UPDATE callingcards SET expiry = DATE_ADD(NOW(), INTERVAL " + . " $cardinfo->{validfordays} day) WHERE cardnumber = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $ASTPP->debug( debug => $sql, + verbosity => $verbosity ); + $astpp_db->do($sql); + $cardinfo = &get_callingcard( $astpp_db, $cardinfo->{cardnumber}, $config ); + } + } + elsif ( $cardinfo->{validfordays} > 0 ) { + my $now = $astpp_db->selectall_arrayref("SELECT NOW() + 0")->[0][0]; + $cardinfo->{expiry} = $astpp_db->selectall_arrayref("SELECT DATE_FORMAT('$cardinfo->{expiry}' , '\%Y\%m\%d\%H\%i\%s')")->[0][0]; + if ( $now >= $cardinfo->{expiry} ) { + my $sql = + "UPDATE callingcards SET status = 2 WHERE cardnumber = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $ASTPP->debug( debug => $sql, + verbosity => $verbosity ); + $astpp_db->do($sql); + $sql = + "DELETE FROM ani_map WHERE account = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $ASTPP->debug( debug => $sql, + verbosity => $verbosity ); + $astpp_db->do($sql); + $AGI->stream_file($sound->{card_has_expired}); + $AGI->stream_file($sound->{goodbye}); + &leave($cardinfo); + } + } + $ASTPP->debug( debug => "Present Time: $now", + verbosity => $verbosity ); + $ASTPP->debug( debug => "Expiration Date: $cardinfo->{expiry}", + verbosity => $verbosity ); + $ASTPP->debug( debug => "Valid for Days: $cardinfo->{validfordays}", + verbosity => $verbosity ); + $ASTPP->debug( debug => "First Use: $cardinfo->{firstused}", + verbosity => $verbosity ); +} + +sub tell_cost() { #Say how much the call will cost. + my ( $numberinfo, $pricelistinfo, $cardinfo ) = @_; + if ( $pricelistinfo->{markup} ne "" && $pricelistinfo->{markup} != 0 ) { + $ASTPP->debug( debug => "Adding Markup of $pricelistinfo->{markup}", + verbosity => $verbosity); + $numberinfo->{connectcost} = + $numberinfo->{connectcost} * + ( ( $pricelistinfo->{markup} / 10000 ) + 1 ); + $numberinfo->{cost} = + $numberinfo->{cost} * ( ( $pricelistinfo->{markup} / 10000 ) + 1 ); + } + if ($config->{calling_cards_rate_announce} == 1) { + if ( $numberinfo->{cost} > 0 ) { + $AGI->stream_file($sound->{call_will_cost}); +# $AGI->say_number(ceil($numberinfo->{cost} / 100)); +# $AGI->stream_file($sound->{currency}); + my @call_cost = split(/\./, ($numberinfo->{cost} / 100)); + $AGI->say_number(@call_cost[0]); + if (@call_cost[1]) { + $AGI->stream_file($sound->{point}); + $AGI->say_number(@call_cost[1]); + $AGI->stream_file($sound->{sub_currency}); + } + $AGI->stream_file($sound->{per}); + $AGI->stream_file($sound->{minute}); + } + if ( $numberinfo->{connectcost} > 0 ) { + $AGI->stream_file($sound->{a_connect_charge}); + $AGI->say_number(ceil($numberinfo->{connectcost} / 100)); + $AGI->stream_file($sound->{sub_currency}); + $AGI->stream_file($sound->{will_apply}); + } + } +} + +sub timelimit() { #Calculate and say the time limit. + my ( $numberinfo, $pricelistinfo, $cardinfo, $phoneno ) = @_; + my ( $connectfee, $cost, $timelimit, $available, $maxtime, $balance ); +# if ( $numberinfo->{connectfee} > 0 ) { +# $connectfee = $numberinfo->{connectfee} / 100; +# } +# if ( $numberinfo->{cost} > 0 ) { +# $cost = $numberinfo->{cost} / 100; +# } + # Timelimit is in seconds + if ($cc == 0) { +# $available = +# ( ( $cardinfo->{value} - $cardinfo->{used} ) / 100 ) - $numberinfo->{connectfee}; + $available = + ( $cardinfo->{value} - $cardinfo->{used} ) - $numberinfo->{connectfee}; + $ASTPP->debug( debug => "FUNDS AVAILABLE: $available", + verbosity => $verbosity); + } elsif ( $cc == 1 ) { + $balance = &accountbalance( $astpp_db, $cardinfo->{number} ); + $balance = ($balance * -1) + ( $cardinfo->{credit_limit}); + $available = ($balance - $numberinfo->{connectfee}) / 100; + } + if ( $available > 0 && $numberinfo->{cost} > 0 ) { + $timelimit = ( ( $available / $numberinfo->{cost} ) * 60 ); + } + elsif ( $available >= 0 && $numberinfo->{cost} <= 0 ) { + $timelimit = $config->{callingcards_max_length}; + } + if ( $timelimit > $config->{callingcards_max_length} ) { + $timelimit = $config->{callingcards_max_length}; + } + $ASTPP->debug( debug => "TIMELIMIT: $timelimit", + verbosity => $verbosity); + if ($brandinfo->{reseller} ne "") { + ASTPP->debug( debug => "THIS BRAND BELONGS TO $brandinfo->{reseller}!", + verbosity => $verbosity); + my $carddata = &get_account( $astpp_db, $brandinfo->{reseller} ); +# ($callstatus, $maxlength) = &max_length($astpp_db, $config, $carddata, $phoneno); +# my $routeinfo = &get_route( $astpp_db, $config, $phoneno, $carddata->{pricelist},$carddata ); + my $minimumcharge = $numberinfo->{cost}; + my $belongs_to_reseller = 1; + while ( $belongs_to_reseller == 1 ) { + $ASTPP->debug( debug => "FINDING LIMIT FOR: $carddata->{reseller}", + verbosity => $verbosity); + push @resellerlist, $carddata->{number}; + $ASTPP->debug( debug => "PUSHING $carddata->{number} ONTO THE LIST OF RESELLERS", + verbosity => $verbosity); + my ($resellercallstatus, $resellermaxlength) = &max_length($astpp_db, $config, $carddata, $phoneno); + my $routeinfo = &get_route( $astpp_db, $config, $phoneno, $carddata->{pricelist}, $carddata, "CC" ); + if ($resellercallstatus != 1) { + $carddata->{reseller} = ""; + $timelimit = 0; + } elsif ($resellermaxlength < $timelimit / 60) { + $timelimit = $resellermaxlength * 60; + } + if ($resellermaxlength < 1 || $routeinfo->{cost} > $minimumcharge ) { + $carddata->{reseller} = ""; + $timelimit = 0; + } + $ASTPP->debug( debug => "RESELLER Max Length: $resellermaxlength", + verbosity => $verbosity); + $ASTPP->debug( debug => "RESELLER Call Status: $resellercallstatus", + verbosity => $verbosity); + if ($carddata->{reseller} && $carddata->{reseller} ne "") { + $carddata = &get_account( $astpp_db, $carddata->{reseller} ); + } else { + $belongs_to_reseller = 0; + } + } + } else { + $ASTPP->debug( debug => "THIS BRAND DOES NOT BELONG TO A RESELLER!", + verbosity => $verbosity); + } + $ASTPP->debug( debug =>"TIMELIMIT: $timelimit", verbosity => $verbosity); + my $minutes = $timelimit / 60; + $ASTPP->debug( debug => "MINUTES: $minutes", verbosity => $verbosity); + if ($minutes > 0 && $config->{calling_cards_timelimit_announce} == 1) { + my $minutes = $timelimit / 60; + $minutes = sprintf( "%.0f", $minutes ); + $AGI->stream_file($sound->{call_will_last}); + if ( $minutes == 1 ) { + $AGI->say_number($minutes); + $AGI->stream_file($sound->{minute}); + } + elsif ( $minutes > 1 ) { + $AGI->say_number($minutes); + $AGI->stream_file($sound->{minutes}); + } + } + elsif ($minutes < 1) { + $AGI->stream_file($sound->{not_enough_credit}); + $AGI->stream_file($sound->{goodbye}); + &leave($cardinfo); + } + $maxtime = $timelimit * 1000; + + + $timelimit = "\|30\|HL($maxtime:60000:30000)\|Hgj"; + $ASTPP->debug( debug => "Available: $available", + verbosity => $verbosity ); + $ASTPP->debug( debug => "Balance: $balance", verbosity => $verbosity ); + $ASTPP->debug( debug => "Max Time: $maxtime", verbosity => $verbosity ); + return $timelimit; +} + +sub say_balance() { #Calculate and say the card balance. + my ($cardinfo) = @_; + my ( $connectfee, $cost, $included, $sub_balance, $balance, $main_balance ); + if ($cc == 0 ) { + $balance = $cardinfo->{value} - $cardinfo->{used}; + } elsif ($cc ==1) { + $balance = &accountbalance( $astpp_db, $cardinfo->{number} ); + $balance = ($balance * -1) + ( $cardinfo->{credit_limit} ); + } + if ( $balance > 0 ) { + $balance = $balance / 10000; + $balance = sprintf( "%.2f", $balance ); + $sub_balance = substr( $balance, -2, 2 ); + $main_balance = substr( $balance, 0, -2 ); + my $interrupt = &bgplay([$sound->{card_has_balance_of}], 0, 1); +# my $interrupt = $AGI->get_data($sound->{card_has_balance_of},0,1); + if (!$interrupt || $interrupt eq "" || $interrupt == 0) { + if ( $main_balance == 1 ) { + $AGI->say_number($main_balance); + $AGI->stream_file($sound->{main_currency}); + } + elsif ( $main_balance > 1 ) { + $AGI->say_number($main_balance); + $AGI->stream_file($sound->{main_currency_plural}); + } + if ( $sub_balance == 1 ) { + $AGI->say_number($sub_balance); + $AGI->stream_file($sound->{sub_currency}); + } + elsif ( $sub_balance > 1 ) { + $AGI->say_number($sub_balance); + $AGI->stream_file($sound->{sub_currency_plural}); + } + } + } + else { + $AGI->stream_file($sound->{card_is_empty}); + $AGI->stream_file($sound->{goodbye}); + &leave($cardinfo); + } + return $balance; +} + +sub update_balance() { #Update the available credit on the calling card. + my ( $cardinfo, $charge ) = @_; + my $sql = + "UPDATE callingcards SET used = " + . $astpp_db->quote( ($charge) + $cardinfo->{used} ) + . " WHERE cardnumber = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $astpp_db->do($sql); +} + +sub write_asterisk_cdr() { #Write the cdr record to the asterisk cdr db. This is done so we get a record of the call the callingcard user placed. + # This is especially important for resellers and calling cards. + my ( + $reseller, $clid, $destination, $status, + $callstart, $answeredtime, $dstchannel, $lastapp, $dialedtime, $uniqueid, $asterisk_time, $cdr_db + ) + = @_; + my ($sql); + if (!$status) {$status = gettext("N/A"); } + $sql = "INSERT INTO cdr (calldate,dst,clid,dstchannel,lastapp,duration,billsec,disposition,accountcode,uniqueid) VALUES(" + . $astpp_db->quote($asterisk_time) . ", " + . $astpp_db->quote($destination) . ", " + . $astpp_db->quote($clid) . ", " + . $astpp_db->quote($dstchannel) . ", " + . $astpp_db->quote($lastapp) . ", " + . $astpp_db->quote($dialedtime) . ", " + . $astpp_db->quote($answeredtime) . ", " + . $astpp_db->quote($status) . ", " + . $astpp_db->quote( $reseller ) . ", " + . $astpp_db->quote( $uniqueid ) . ")"; + $cdr_db->do($sql); + $AGI->set_variable( "\"ANSWEREDTIME\"", "0" ); + $AGI->set_variable( "\"DIALEDTIME\"", "0" ); + $AGI->set_variable( "\"DIALSTATUS\"", "NO ANSWER" ); +} + + +sub write_cdr() { # Write the callingcardcdr record if this is a calling card. + my ( + $cardinfo, $clid, $destination, $status, + $callstart, $charge, $answeredtime + ) + = @_; + my ($sql); + if (!$status) {$status = gettext("N/A"); } + $sql = +"INSERT INTO callingcardcdrs (cardnumber,clid,destination,disposition,callstart,seconds," + . "debit) VALUES (" + . $astpp_db->quote( $cardinfo->{cardnumber} ) . ", " + . $astpp_db->quote($clid) . ", " + . $astpp_db->quote($destination) . ", " + . $astpp_db->quote($status) . ", " + . $astpp_db->quote($callstart) . ", " + . $astpp_db->quote($answeredtime) . ", " + . $astpp_db->quote($charge) . ")"; + $astpp_db->do($sql); + $ASTPP->debug( debug => "$sql", verbosity => $verbosity ); + $ASTPP->debug( debug => "Resetting CDR Variables", verbosity => $verbosity ); + $AGI->set_variable( "\"ANSWEREDTIME\"", "0" ); + $AGI->set_variable( "\"DIALEDTIME\"", "0" ); + $AGI->set_variable( "\"DIALSTATUS\"", "NO ANSWER" ); +} + +sub dialout() { # Rig up the LCR stuff and do the outbound dialing. + # If a call does not go through we give the user the option + # of trying again. + my ( $destination, $timelimit, $numberinfo, $pricelistinfo, $cardinfo, $brandinfo ) = + @_; + my ( $status, $count, $increment ); + $ASTPP->debug( debug => "Looking for outbound Route", verbosity => $verbosity ); + my @outboundroutes = &get_outbound_routes( $astpp_db, $destination,$cardinfo,$numberinfo, @resellerlist ); + $count = @outboundroutes; + if ( $count == 0 ) { + $ASTPP->debug(debug => "NO OUTBOUND ROUTES FOUND!", verbosity => $verbosity ); + my $order = $AGI->get_data( $sound->{noanswer}, $config->{calling_cards_general_input_timeout}, 1 ); + if ( $order != 1 ) { + &write_cdr( $cardinfo, "", $destination, gettext("NO Route Found"), "", 0, 0 ); + &leave($cardinfo); + } + } + $count = 0; + foreach my $route (@outboundroutes) { + my $trunk = &get_dial_string( $astpp_db, $route, $destination ); + my $dialstring = $trunk . $timelimit; + my $callstart = localtime(); + my ($accountcode); + $callstart = &prettytimestamp if $cc == 1; + $AGI->set_variable( "\"LCRSTRING$count\"", + "\"$config->{callingcardowner}\"" ); + $AGI->exec( 'Set', "TRUNK_NAME$count=$route->{trunk}" ); + if ($brandinfo->{reseller} ne "" ) { + $AGI->exec( 'Set', "accountcode=$brandinfo->{reseller}" ); + $accountcode = $brandinfo->{reseller}; + + } else { + $AGI->exec( 'Set', "accountcode=$config->{callingcardowner}" ); + $accountcode = $config->{callingcardowner}; + } + my $res = $AGI->exec("DIAL $dialstring"); + my $status = $AGI->get_variable("DIALSTATUS"); + my $answeredtime = $AGI->get_variable("ANSWEREDTIME"); + $stats{answered_time} = $AGI->get_variable("ANSWEREDTIME"); + my $dialedtime = $AGI->get_variable("DIALEDTIME"); + my $uniqueid = $AGI->get_variable("UNIQUEID"); + $stats{uniqueid} = $AGI->get_variable("UNIQUEID"); + my $clid = $AGI->get_variable("CALLERID(all)"); + my $asterisk_time = &prettytimestamp; + $ASTPP->debug( debug => "CALL STATUS $status", verbosity => 1); + $ASTPP->debug( debug => "ANSWERED TIME $answeredtime", verbosity => $verbosity); + $ASTPP->debug( debug => "Account CC?: $cc", verbosity => $verbosity); + + if ( ( $status != ~/CHANUNAVAIL/ ) && ( $status != ~/CONGESTION/ ) ) { + if ( $status =~ /BUSY/ ) { + $ASTPP->debug( debug => "CALL BUSY", verbosity => $verbosity ); + my $order = $AGI->get_data( $sound->{busy}, $config->{calling_cards_general_input_timeout},1 ); + if ( $order != 1 ) { + &write_cdr( $cardinfo, $clid, $destination, $status, + $callstart, 0, 0, $uniqueid ) + if $cc == 0; + &write_account_cdr( $astpp_db, $cardinfo->{number}, 0, + $destination, $callstart, 0, $uniqueid, $clid ) + if $cc == 1; + &write_asterisk_cdr( $accountcode, $clid, $destination, $status, + $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + &leave($cardinfo); + } else { + push @outboundroutes, $route; + } + } + elsif ( $status =~ /NOANSWER/ ) { + $ASTPP->debug(debug=> "NO ANSWER", verbosity => $verbosity ); + my $order = $AGI->get_data( $sound->{noanswer}, $config->{calling_cards_general_input_timeout},1 ); + if ( $order != 1 ) { + &write_cdr( $cardinfo, $clid, $destination, $status, + $callstart, 0, 0, $uniqueid ) + if $cc == 0; + &write_account_cdr( $astpp_db, $cardinfo->{number}, 0, + $destination, $callstart, 0, $uniqueid, $clid ) + if $cc == 1; + &write_asterisk_cdr( $accountcode, $clid, $destination, $status, + $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + &leave($cardinfo); + } else { + push @outboundroutes, $route; + } + } + elsif ( $status =~ /ANSWER/ || $answeredtime > 0) { + $ASTPP->debug( debug => "CALL ANSWERED", verbosity => $verbosity ); + my $increment; + if ( $numberinfo->{inc} > 0 ) { + $increment = $numberinfo->{inc}; + } + else { + $increment = $pricelistinfo->{inc}; + } + $ASTPP->debug( debug => "$numberinfo->{connectcost}, $numberinfo->{cost}, $answeredtime, $increment, $numberinfo->{includedseconds}", + verbosity => $verbosity); + my $charge = &calc_call_cost( + $numberinfo->{connectcost}, $numberinfo->{cost}, + $answeredtime, $increment, + $numberinfo->{includedseconds} + ); + $ASTPP->debug( debug => "Cost $charge ", verbosity => $verbosity ); + if ($cardinfo->{minute_fee_pennies} > 0) { + $charge = (($cardinfo->{minute_fee_pennies} * 100) + $charge) if $cardinfo->{timeused} + $answeredtime => $cardinfo->{minute_fee_minutes}; + } + if ($cardinfo->{min_length_pennies} > 0 && ($cardinfo->{min_length_minutes}*60) > $answeredtime) { + $charge = (($cardinfo->{min_length_pennies} * 100) + $charge); + } + if ( $cc == 0 ) { + &write_cdr( + $cardinfo, $clid, $destination, $status, + $callstart, $charge, $answeredtime, $uniqueid + ); + &write_asterisk_cdr( $accountcode, $clid, $destination, "ANSWERED", + $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + &update_balance( $cardinfo, $charge ); + $astpp_db->do("UPDATE callingcards SET timeused = " + . $astpp_db->quote($cardinfo->{timeused} + $answeredtime) + . " WHERE cardnumber = " + . $astpp_db->quote($cardinfo->{cardnumber})); + } + elsif ( $cc == 1 ) { + my $status = + &write_account_cdr( $astpp_db, $cardinfo->{number}, + $charge, $destination, $callstart, $answeredtime, $uniqueid, $clid ); + &write_asterisk_cdr( $accountcode, $clid, $destination, $status, + $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + $ASTPP->debug( debug => $status, verbosity => $verbosity ); + } + $AGI->stream_file($sound->{call_completed}); + &leave($cardinfo); + } + elsif ( $status =~ /CANCEL/ ) { + $ASTPP->debug( debug => "CALL CANCELLED", verbosity => $verbosity ); + $AGI->stream_file($sound->{cancelled}) if $config->{calling_cards_cancelled_prompt} == 1; + &write_cdr( $cardinfo, $clid, $destination, $status, $callstart, 0, + 0, $uniqueid ) + if $cc == 0; + &write_account_cdr( $astpp_db, $cardinfo->{number}, 0, + $destination, $callstart, 0, $uniqueid, $clid ) + if $cc == 1; + &write_asterisk_cdr( $accountcode, $clid, $destination, $status, + $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + &leave($cardinfo); + } + else { + $ASTPP->debug( debug => "ERROR - ERROR - ERROR", verbosity => $verbosity ); + my $order = $AGI->get_data( $sound->{noanswer}, $config->{calling_cards_general_input_timeout},1 ); + if ( $order != 1 ) { + &write_cdr( $cardinfo, $clid, $destination, $status, + $callstart, 0, 0, $uniqueid ) + if $cc == 0; + &write_account_cdr( $astpp_db, $cardinfo->{number}, 0, + $destination, $callstart, 0, $uniqueid, $clid ) + if $cc == 1; + &write_asterisk_cdr( $accountcode, $clid, $destination, $status, + $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + &leave($cardinfo); + } + } + } + } +} + +sub leave() { # Prepare everything and then leave the calling card app. + my ($cardinfo) = @_; + my ($whatnow); + my $retries = 0; + &set_in_use( $cardinfo, 0 ) if $cc == 0; + while ($retries < ... [truncated message content] |
From: <dar...@us...> - 2009-01-17 17:21:26
|
Revision: 2221 http://astpp.svn.sourceforge.net/astpp/?rev=2221&view=rev Author: darrenkw Date: 2009-01-17 17:21:21 +0000 (Sat, 17 Jan 2009) Log Message: ----------- A whole bunch more cleanup of the svn tree. Try to put everything in a logical location. Modified Paths: -------------- trunk/Makefile Added Paths: ----------- trunk/images/astpp.png trunk/scripts/ trunk/scripts/astpp-callingcards-daily.pl trunk/scripts/astpp-common.pl trunk/scripts/astpp-device-monitor.pl trunk/scripts/astpp-email-incoming.pl trunk/scripts/astpp-generate-invoices.pl trunk/scripts/astpp-low-balance.pl trunk/scripts/astpp-rate-engine.pl trunk/scripts/astpp-update-balance.pl trunk/web_interface/ trunk/web_interface/astpp-admin.cgi trunk/web_interface/astpp-auto-admin.cgi trunk/web_interface/astpp-callback.cgi trunk/web_interface/astpp-pricelist.cgi trunk/web_interface/astpp-refill.cgi trunk/web_interface/astpp-users.cgi trunk/web_interface/menu.js trunk/web_interface/style.css Removed Paths: ------------- trunk/astpp-admin.cgi trunk/astpp-auto-admin.cgi trunk/astpp-callback.cgi trunk/astpp-callingcards-daily.pl trunk/astpp-common.pl trunk/astpp-device-monitor.pl trunk/astpp-email-incoming.pl trunk/astpp-generate-invoices.pl trunk/astpp-low-balance.pl trunk/astpp-pricelist.cgi trunk/astpp-rate-engine.pl trunk/astpp-refill.cgi trunk/astpp-update-balance.pl trunk/astpp-users.cgi trunk/astpp.jpg trunk/astpp.png trunk/menu.js trunk/style.css Modified: trunk/Makefile =================================================================== --- trunk/Makefile 2009-01-17 17:13:20 UTC (rev 2220) +++ trunk/Makefile 2009-01-17 17:21:21 UTC (rev 2221) @@ -36,14 +36,14 @@ # Install Freeswitch .pl files as .cgi files install -m 755 -o $(OWNER) -g $(GROUP) freeswitch/astpp-fs-xml.pl $(DESTDIR)$(WWWDIR)/cgi-bin/astpp-fs-xml.cgi # - install -m 755 -o $(OWNER) -g $(GROUP) astpp-callback.cgi $(DESTDIR)$(WWWDIR)/cgi-bin/astpp-callback.cgi - install -m 755 -o $(OWNER) -g $(GROUP) astpp-pricelist.cgi $(DESTDIR)$(WWWDIR)/cgi-bin/astpp-pricelist.cgi - install -m 755 -o $(OWNER) -g $(GROUP) astpp-refill.cgi $(DESTDIR)$(WWWDIR)/cgi-bin/astpp-refill.cgi - install -m 755 -o $(OWNER) -g $(GROUP) astpp-admin.cgi $(DESTDIR)$(WWWDIR)/cgi-bin/astpp-admin/astpp-admin.cgi - install -m 755 -o $(OWNER) -g $(GROUP) astpp-auto-admin.cgi $(DESTDIR)$(WWWDIR)/cgi-bin/astpp-admin/astpp-auto-admin.cgi - install -m 755 -o $(OWNER) -g $(GROUP) astpp-users.cgi $(DESTDIR)$(WWWDIR)/cgi-bin/astpp/astpp-users.cgi - install -m 644 -o $(OWNER) -g $(GROUP) style.css $(DESTDIR)$(WWWDIR)/html/_astpp/ - install -m 644 -o $(OWNER) -g $(GROUP) menu.js $(DESTDIR)$(WWWDIR)/html/_astpp/ + install -m 755 -o $(OWNER) -g $(GROUP) web_interface/astpp-callback.cgi $(DESTDIR)$(WWWDIR)/cgi-bin/astpp-callback.cgi + install -m 755 -o $(OWNER) -g $(GROUP) web_interface/astpp-pricelist.cgi $(DESTDIR)$(WWWDIR)/cgi-bin/astpp-pricelist.cgi + install -m 755 -o $(OWNER) -g $(GROUP) web_interface/astpp-refill.cgi $(DESTDIR)$(WWWDIR)/cgi-bin/astpp-refill.cgi + install -m 755 -o $(OWNER) -g $(GROUP) web_interface/astpp-admin.cgi $(DESTDIR)$(WWWDIR)/cgi-bin/astpp-admin/astpp-admin.cgi + install -m 755 -o $(OWNER) -g $(GROUP) web_interface/astpp-auto-admin.cgi $(DESTDIR)$(WWWDIR)/cgi-bin/astpp-admin/astpp-auto-admin.cgi + install -m 755 -o $(OWNER) -g $(GROUP) web_interface/astpp-users.cgi $(DESTDIR)$(WWWDIR)/cgi-bin/astpp/astpp-users.cgi + install -m 644 -o $(OWNER) -g $(GROUP) web_interface/style.css $(DESTDIR)$(WWWDIR)/html/_astpp/ + install -m 644 -o $(OWNER) -g $(GROUP) web_interface/menu.js $(DESTDIR)$(WWWDIR)/html/_astpp/ # Install Sample Configuration Files # install -m 644 -o $(OWNER) -g $(GROUP) ./samples/sample.reseller-config.conf $(DESTDIR)$(ASTPPDIR)/sample.reseller-config.conf install -m 644 -o $(OWNER) -g $(GROUP) ./samples/sample.astpp-config.conf $(DESTDIR)$(ASTPPDIR)/sample.astpp-config.conf @@ -69,7 +69,7 @@ done install_astpp_exec: - for x in ./*.pl; do \ + for x in scripts/*.pl; do \ echo $$x; \ install -m 755 -o $(OWNER) -g $(GROUP) $$x $(PREFIX)$(ASTPPEXECDIR); \ done @@ -92,6 +92,10 @@ install -m 644 $$x $(DESTDIR)$(WWWDIR)/html/_astpp/; \ done install -m 644 images/favicon.ico $(DESTDIR)$(WWWDIR)/html/_astpp/; + for x in images/*.png; do \ + echo $$x;\ + install -m 644 $$x $(DESTDIR)$(WWWDIR)/html/_astpp/; \ + done resolve_perl_dep: perl -MCPAN -e "install Text::Template"; Deleted: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2009-01-17 17:13:20 UTC (rev 2220) +++ trunk/astpp-admin.cgi 2009-01-17 17:21:21 UTC (rev 2221) @@ -1,11806 +0,0 @@ -#!/usr/bin/perl -# -# ASTPP - Open Source Voip Billing -# -# Copyright (C) 2006, Aleph Communications -# -# Darren Wiebe (da...@al...) -# Sergey Tamkovich was hired by Aleph Communications to add -# the import ability and some of the "statistics" features. -# -# This program is Free Software and is distributed under the -# terms of the GNU General Public License version 2. -############################################################ -# Account Status Info -# 0 = Account InActive -# 1 = Account Active -# 2 = Account Deactivated -# -# CDR Status Info -# 0 - New line -# 1 - Billed Line -# 2 - Deactivated Line -# -# -# Account Type -# 0 - Regular User (Has login permissions for astpp-users.cgi) -# 1 - Reseller (Has login permissions for astpp-users.cgi and has reduced permissions for astpp-admin.cgi) -# 2 - Admin (Has login permissions everywhere) -# 3 - Vendor (Has reduced login permissions in astpp-admin.cgi) -# 4 - Customer Service (Has reduced login permissions in astpp-admin.cgi) -# 5 - Call shop (Has reduced login permissions in astpp-admin.cgi) -# 6 - Booth (No login permissions) -############################################################################### -use POSIX; -use POSIX qw(strftime); -use DBI; -use CGI; -use CGI qw/:standard Vars/; -use Getopt::Long; -use Locale::Country; -use Locale::Language; -use Locale::gettext_pp qw(:locale_h); -use Data::Dumper; -use lib './lib', '../lib'; -use warnings; -use Asterisk::Manager; -use Text::CSV; -use HTML::Template; -use HTML::Template::Expr; -use Time::HiRes qw( gettimeofday tv_interval ); -use Data::Paginate; -use DateTime; -use DateTime::TimeZone; -use ASTPP; - -; # We use DateTime::TimeZone to show users cdrs in their own timezones. - -require "/usr/local/astpp/astpp-common.pl"; -$ENV{LANGUAGE} = "en"; # de, es, br - whatever -print STDERR "Interface language is set to: " . $ENV{LANGUAGE} . "\n"; -bindtextdomain( "astpp", "/usr/local/share/locale" ); -textdomain("astpp"); -use vars qw(@output $astpp_db $params $config - $status $config $limit $accountinfo - $freepbx_db $rt_db $openser_db $ASTPP); -my $starttime = [gettimeofday]; -$ASTPP = ASTPP->new; -$ASTPP->set_verbosity(4); #Tell ASTPP debugging how verbose we want to be. -$ASTPP->set_asterisk_agi($AGI); -$ASTPP->set_pagination_script("astpp-admin.cgi"); -my @Home = ( gettext("Home Page") ); -my @Accounts = ( - gettext("Create Account"), gettext("Process Payment"), - gettext("Remove Account"), gettext("Edit Account"), - gettext("List Accounts"), gettext("View Details") -); -my @Rates = ( - gettext("Pricelists"), gettext("Calc Charge"), - gettext("Routes"), gettext("Import Routes"), - gettext("Periodic Charges"), gettext("Packages"), - gettext("Counters") -); -my @DIDs = ( gettext("Manage DIDs"), gettext("Import DIDs") ); -my @LCR = ( - gettext("Providers"), gettext("Trunks"), - gettext("Outbound Routes"), - gettext("Import Outbound Routes") -); -my @System = ( gettext("Purge Deactivated"), gettext("Configuration") ); -my @Statistics = ( - gettext("Asterisk Stats"), gettext("List Errors"), - gettext("Trunk stats"), gettext("View CDRs"), - gettext("LCR Tables") -); - -my @Callingcards = ( - gettext("List Cards"), gettext("Add Cards"), - gettext("Delete Card"), gettext("Refill Card"), - gettext("View Card"), gettext("Update Card(s) Status"), - gettext("Reset InUse"), gettext("CC Brands") -); -my @SwitchConfig = (); -my @CallShops = ( gettext("Create CallShop"), gettext("Remove CallShop") ); -my @Booths = ( - gettext("Create Booth"), gettext("Remove Booth"), - gettext("List Booths"), gettext("View Booth") -); - -# Report added by Sonia Ali Khan <son...@gm...> -my @AdminReports = ( gettext("Reseller Report"), gettext("Vendor Report") ); - -my @CallShopReports = ( gettext("Booth Report") ); - -my @ResellerReports = ( - - # gettext("Brand Report"), - gettext("CallShop Report"), - gettext("Reseller Report"), - gettext("User Report") -); - -my %menumap = ( - gettext('Accounts') => \@Accounts, - gettext('Rates') => \@Rates, - gettext('DIDs') => \@DIDs, - gettext('Statistics') => \@Statistics, - gettext('System') => \@System, - gettext('LCR') => \@LCR, - gettext('Calling Cards') => \@Callingcards, - gettext('Switch Config') => \@SwitchConfig, - gettext('Booths') => \@Booths, - gettext('Call Shops') => \@CallShops, - gettext('Admin Reports') => \@AdminReports, - gettext('CallShop Reports') => \@CallShopReports, - gettext('Reseller Reports') => \@ResellerReports -); -my @months = ( - 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', - 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' -); -my @techs = ( "SIP", "IAX2", "Zap", "Local", "OH323", "OOH323C" ); -my @incs = ( "1", "6", "30", "60" ); -my @devicetypes = ( gettext("friend"), gettext("user"), gettext("peer") ); -my %yesno = ( - '0' => gettext("NO"), - '1' => gettext("YES") -); -my @cardstatus = ( gettext("ACTIVE"), gettext("INACTIVE"), gettext("DELETED") ); -my %sweeplist = ( - '0' => gettext("daily"), - '1' => gettext("weekly"), - '2' => gettext("monthly"), - '3' => gettext("quarterly"), - '4' => gettext("semi-annually"), - '5' => gettext("annually") -); -my @output = ("STDERR"); # "LOGFILE" ); -my @language = all_language_codes; -@language = sort @language; -my @currency; -my @deviceprotocol = ("SIP"); -my @countries = all_country_names(); -@countries = sort @countries; -my @timezones = DateTime::TimeZone->all_names; -@timezones = sort(@timezones); -my ( - $rt_db, $astpp_db, $config, $params, $param, - $cdr_db, $agile_db, $body, $menu, $status, - $msg, $loginstat, @modes, $openser_db -); - -$params->{mode} = ""; -$params->{username} = ""; -$params->{password} = ""; -$loginstat = 0; - -sub login() { - my ( $sql, $count, $record, $cookie, $cookie1, $accountinfo ); - $sql = - $astpp_db->prepare( "SELECT COUNT(*) FROM accounts WHERE number = " - . $astpp_db->quote( $params->{username} ) - . " AND password = " - . $astpp_db->quote( $params->{password} ) - . " AND status = 1 AND type IN (1,2,3,4,5)" ); - $sql->execute; - $record = $sql->fetchrow_hashref; - $count = $record->{"COUNT(*)"}; - $sql->finish; - $cookie = cookie( - -name => 'ASTPP_User', - -value => $params->{username}, - -expires => '+8h', - -domain => $ENV->{SERVER_NAME}, - -path => $ENV->{SCRIPT_NAME} - ); - $cookie1 = cookie( - -name => 'ASTPP_Password', - -value => $params->{password}, - -expires => '+8h', - -domain => $ENV->{SERVER_NAME}, - -path => $ENV->{SCRIPT_NAME} - ); - - if ( $count == 1 ) { - $status .= gettext("Successful Login!") . "<br>"; - print header( -cookie => [ $cookie, $cookie1, ] ); - $accountinfo = &get_account( $astpp_db, $params->{username} ); - $params->{logintype} = $accountinfo->{type}; - } - if ( !$params->{username} && $config->{auth} eq $params->{password} ) { - $status .= gettext("Successful Login!") . "<br>"; - $count = 1; - print header( -cookie => [ $cookie, $cookie1 ] ); - $params->{logintype} = 2; - } - if ( $count == 0 && $params->{password} eq "" ) { - $params->{mode} = ""; - $status .= gettext("Please Login") . "<br>"; - print header(); - } - elsif ( $count == 0 ) { - $params->{mode} = ""; - $status .= gettext("Login Failed") . "<br>"; - print header(); - } - $ASTPP->debug( - user => $param->{username}, - debug => gettext("ASTPP-USER:") . " $params->{username}" - ); - $ASTPP->debug( - user => $param->{username}, - debug => gettext("ASTPP-PASS:") . " $params->{password}" - ); - $ASTPP->debug( - user => $param->{username}, - debug => gettext("ASTPP-AUTHCODE:") . " $config->{auth}" - ); - $ASTPP->debug( - user => $param->{username}, - debug => gettext("ASTPP-USER-COUNT:") . " $count" - ); - return ( $params->{mode}, $count ); -} - -sub verify_login() { - my ( $sql, $count, $record, $username, $password ); - $params->{username} = cookie('ASTPP_User'); - $params->{password} = cookie('ASTPP_Password'); - if ( !$params->{username} ) { - $params->{username} = ""; - } - if ( !$params->{password} ) { - $params->{password} = ""; - } - if ( $params->{username} && $params->{password} ) { - $sql = - $astpp_db->prepare( "SELECT COUNT(*) FROM accounts WHERE number = " - . $astpp_db->quote( $params->{username} ) - . " AND password = " - . $astpp_db->quote( $params->{password} ) - . " AND status = 1 AND type IN (1,2,3,4,5)" ); - $sql->execute; - $record = $sql->fetchrow_hashref; - $count = $record->{"COUNT(*)"}; - $sql->finish; - $count = 0 if !$count; - if ( $count == 1 ) { - $accountinfo = &get_account( $astpp_db, $params->{username} ); - $params->{logintype} = $accountinfo->{type}; - } - } - if ( !$params->{username} && $config->{auth} eq $params->{password} ) { - $count = 1; - $params->{logintype} = 2; - } - if ( $count != 1 && !$params->{password} ) { - $params->{mode} = ""; - $status .= "" . "<br>"; - $count = 0; - } - elsif ( $count != 1 ) { - $params->{mode} = ""; - $status .= gettext("Login Failed") . "<br>"; - $count = 0; - } - $ASTPP->debug( - user => $param->{username}, - debug => gettext("ASTPP-USER:") . " $params->{username}" - ) if $config->{debug} == 1 && $params->{username}; - $ASTPP->debug( - user => $param->{username}, - debug => gettext("ASTPP-PASS:") . " $params->{password}" - ) if $config->{debug} == 1 && $params->{password}; - $ASTPP->debug( - user => $param->{username}, - debug => gettext("ASTPP-AUTHCODE:") . " $config->{auth}" - ) if $config->{debug} == 1; - $ASTPP->debug( - user => $param->{username}, - debug => gettext("ASTPP-USER-COUNT:") . " $count" - ) if $config->{debug} == 1; - print header(); - return $count; -} - -sub logout() { - my ( $cookie, $cookie1 ); - $cookie = cookie( - -name => 'ASTPP_User', - -value => 'loggedout', - -expires => 'now' - ); - $cookie1 = cookie( - -name => 'ASTPP_Password', - -value => 'loggedout', - -expires => 'now' - ); - print header( -cookie => [ $cookie, $cookie1 ] ); - $status .= "Successfully Logged User Out" . "<br>"; - return ""; -} - -sub build_menu_ts() { - my ($selected) = @_; - my ( $tmp, $body, $x ); - my $i = 0; - foreach $tmp (@modes) { - $body .= -"<div class=\"ts_ddm\" name=tt$i id=tt$i style=\"visibility:hidden;width:200;background-color:#CCCCFF;\"onMouseover=\"clearhidemenu()\" onMouseout=\"dynamichide(event)\"><table width=100\% border=0 cellspacing=0 cellpadding=0>"; - my $j = 0; - foreach $x ( @{ $menumap{$tmp} } ) { - $body .= -"<tr><td name=t$i\_$j id=t$i\_$j><a href=\"?mode=$x\" onmouseover='light_on(t$i\_$j);' onmouseout='light_off(t$i\_$j);'> $x </a></td></tr> -\n"; - $j++; - } - $body .= "</table> -</div>"; - $i++; - } - $body .= "<table width=900 cellpadding=0 class=ts_menu><tr>\n"; - $i = 0; - foreach $tmp (@modes) { - $body .= -"<td name=t$i id=t$i><a href=\"?mode=$tmp\" onmouseover='light_on(t$i);dropdownmenu(this, event,\"tt$i\");' onmouseout='light_off(t$i);delayhidemenu();'> $tmp </a></td>\n"; - $i++; - } - $body .= "</tr></table>"; - return $body; -} - -sub build_body() { - if ( $params->{logintype} == 2 ) { #Admin Login - return &build_providers() if $params->{mode} eq gettext("Providers"); - return &build_trunks() if $params->{mode} eq gettext("Trunks"); - return &build_outbound_routes() - if $params->{mode} eq gettext("Outbound Routes"); - return &build_pricelists() if $params->{mode} eq gettext("Pricelists"); - return &build_routes() if $params->{mode} eq gettext("Routes"); - return &build_calc_charge() - if $params->{mode} eq gettext("Calc Charge"); - return &build_list_errors() - if $params->{mode} eq gettext("List Errors"); - return &build_lcr_tables() - if $params->{mode} eq gettext("LCR Tables"); - return &build_dids() if $params->{mode} eq gettext("Manage DIDs"); - return &build_import_dids() - if $params->{mode} eq gettext("Import DIDs"); - return &build_purge_deactivated() - if $params->{mode} eq gettext("Purge Deactivated"); - return &build_create_account() - if $params->{mode} eq gettext("Create Account"); - return &build_remove_account() - if $params->{mode} eq gettext("Remove Account"); - return &build_process_payment() - if $params->{mode} eq gettext("Process Payment"); - return &build_account_info() - if $params->{mode} eq gettext("View Details"); - return &build_list_accounts() - if $params->{mode} eq gettext("Accounts"); - return &build_list_accounts() - if $params->{mode} eq gettext("List Accounts"); - return &build_edit_account() - if $params->{mode} eq gettext("Edit Account"); - return &build_import_routes() - if $params->{mode} eq gettext("Import Routes"); - return &build_import_outbound_routes() - if $params->{mode} eq gettext("Import Outbound Routes"); - return &logout() - if $params->{mode} eq gettext("Logout"); - return &build_packages() - if $params->{mode} eq gettext("Packages"); - return &build_counters() - if $params->{mode} eq gettext("Counters"); - return &build_statistics() - if $params->{mode} eq gettext("Asterisk Stats"); - return &build_create_card() - if $params->{mode} eq gettext("Add Cards"); - return &build_list_cards() - if $params->{mode} eq gettext("List Cards"); - return &build_list_cards() - if $params->{mode} eq gettext("Calling Cards"); - return &build_update_card_status() - if $params->{mode} eq gettext("Update Card(s) Status"); - return &build_reset_card_inuse() - if $params->{mode} eq gettext("Reset InUse"); - return &build_view_card() if $params->{mode} eq gettext("View Card"); - return &build_cc_brands() - if $params->{mode} eq gettext("CC Brands"); - return &build_delete_cards() - if $params->{mode} eq gettext("Delete Card"); - return &build_refill_card() - if $params->{mode} eq gettext("Refill Card"); - return &build_sip_devices() - if $params->{mode} eq gettext("Asterisk(TM) SIP Devices"); - return &build_iax_devices() - if $params->{mode} eq gettext("Asterisk(TM) IAX Devices"); - return &build_dialplan() - if $params->{mode} eq gettext("Asterisk(TM) Dialplan"); - return &build_freeswitch_sip_devices() - if $params->{mode} eq gettext("Freeswitch(TM) SIP Devices"); - return &build_stats_acd() - if $params->{mode} eq gettext("Trunk stats"); - return &build_stats_acd() - if $params->{mode} eq gettext("Statistics"); - return &build_periodic_charges() - if $params->{mode} eq gettext("Periodic Charges"); - return &build_view_cdrs() if $params->{mode} eq gettext("View CDRs"); - return &build_configuration() - if $params->{mode} eq gettext("Configuration"); - - return &build_add_callshop() - if $params->{mode} eq gettext("Create CallShop"); - return &build_remove_callshop() - if $params->{mode} eq gettext("Remove CallShop"); - - return &build_admin_reseller_report() - if $params->{mode} eq gettext("Reseller Report"); - return &build_admin_vendor_report() - if $params->{mode} eq gettext("Vendor Report"); - - return &build_homepage() - if $params->{mode} eq gettext("Home Page") - || $params->{mode} eq gettext("Home") - || $params->{mode} eq "" - || $params->{mode} eq gettext("Login") - || $params->{mode} eq gettext("Logout"); - return gettext("Not Available!") . "\n"; - } - elsif ( $params->{logintype} == 3 ) { #Vendor Login - return &build_stats_acd() - if $params->{mode} eq gettext("Trunk Statistics"); - return &logout() if $params->{mode} eq gettext("Logout"); - return &build_view_cdrs() if $params->{mode} eq gettext("View CDRs"); - return &build_outbound_routes() - if $params->{mode} eq gettext("Outbound Routes"); - $params->{mode} = gettext("Home"); - return gettext("Welcome to ASTPP!") . "\n" - if $params->{mode} eq gettext("Home"); - } - elsif ( $params->{logintype} == 4 ) { #Customer Service Login - return &build_create_account() - if $params->{mode} eq gettext("Create Account"); - return &build_remove_account() - if $params->{mode} eq gettext("Remove Account"); - return &build_process_payment() - if $params->{mode} eq gettext("Process Payment"); - return &build_account_info() - if $params->{mode} eq gettext("View Details"); - return &build_list_accounts() - if $params->{mode} eq gettext("List Accounts"); - return &build_edit_account() - if $params->{mode} eq gettext("Edit Account"); - return &build_calc_charge() - if $params->{mode} eq gettext("Calc Charge"); - return &build_dids() - if $params->{mode} eq gettext("Manage DIDs"); - return &build_dids() - if $params->{mode} eq gettext("DIDs"); - return &build_sip_devices() - if $params->{mode} eq gettext("Asterisk(TM) SIP Devices"); - return &build_iax_devices() - if $params->{mode} eq gettext("Asterisk(TM) IAX Devices"); - return &build_packages() if $params->{mode} eq gettext("Packages"); - return &build_counters() if $params->{mode} eq gettext("Counters"); - return &build_statistics() - if $params->{mode} eq gettext("Asterisk Stats"); - return &build_create_card() if $params->{mode} eq gettext("Add Cards"); - return &build_list_cards() if $params->{mode} eq gettext("List Cards"); - return &build_update_card_status() - if $params->{mode} eq gettext("Update Card(s) Status"); - return &build_reset_card_inuse() - if $params->{mode} eq gettext("Reset InUse"); - return &build_view_card() if $params->{mode} eq gettext("View Card"); - return &build_cc_brands() - if $params->{mode} eq gettext("CC Brands"); - return &build_delete_cards() - if $params->{mode} eq gettext("Delete Card"); - return &build_refill_card() - if $params->{mode} eq gettext("Refill Card"); - - } - elsif ( $params->{logintype} == 1 ) { #Reseller Login - return &build_create_card() if $params->{mode} eq gettext("Add Cards"); - return &build_list_cards() if $params->{mode} eq gettext("List Cards"); - return &build_update_card_status() - if $params->{mode} eq gettext("Update Card(s) Status"); - return &build_reset_card_inuse() - if $params->{mode} eq gettext("Reset InUse"); - return &build_view_card() if $params->{mode} eq gettext("View Card"); - return &build_cc_brands() - if $params->{mode} eq gettext("CC Brands"); - return &build_delete_cards() - if $params->{mode} eq gettext("Delete Card"); - return &build_refill_card() - if $params->{mode} eq gettext("Refill Card"); - return &build_pricelists() if $params->{mode} eq gettext("Pricelists"); - return &build_routes() if $params->{mode} eq gettext("Routes"); - return &build_create_account() - if $params->{mode} eq gettext("Create Account"); - return &build_remove_account() - if $params->{mode} eq gettext("Remove Account"); - return &build_process_payment() - if $params->{mode} eq gettext("Process Payment"); - return &build_account_info() - if $params->{mode} eq gettext("View Details"); - return &build_list_accounts() - if $params->{mode} eq gettext("List Accounts"); - return &build_edit_account() - if $params->{mode} eq gettext("Edit Account"); - return &build_calc_charge() - if $params->{mode} eq gettext("Calc Charge"); - return &build_import_routes() - if $params->{mode} eq gettext("Import Routes"); - return &build_dids_reseller() - if $params->{mode} eq gettext("Manage DIDs"); - return &build_add_callshop() - if $params->{mode} eq gettext("Create CallShop"); - return &build_remove_callshop() - if $params->{mode} eq gettext("Remove CallShop"); - - # return &build_reseller_brand_report() - # if $params->{mode} eq gettext("Brand Report"); - return &build_reseller_callshop_report() - if $params->{mode} eq gettext("CallShop Report"); - return &build_reseller_reseller_report() - if $params->{mode} eq gettext("Reseller Report"); - return &build_reseller_user_report() - if $params->{mode} eq gettext("User Report"); - return &build_packages() - if $params->{mode} eq gettext("Packages"); - return &build_counters() - if $params->{mode} eq gettext("Counters"); - - return &build_homepage() - if $params->{mode} eq gettext("Home Page") - || $params->{mode} eq gettext("Home") - || $params->{mode} eq "" - || $params->{mode} eq gettext("Login") - || $params->{mode} eq gettext("Logout"); - return gettext("Not Available!") . "\n"; - return gettext("Not Available!") . "\n"; - } - elsif ( $params->{logintype} == 5 ) { #Call Shop Login - return &build_pricelists() if $params->{mode} eq gettext("Pricelists"); - return &build_routes() if $params->{mode} eq gettext("Routes"); - return &build_add_booth() if $params->{mode} eq gettext("Create Booth"); - return &build_remove_booth() - if $params->{mode} eq gettext("Remove Booth"); - return &build_list_booths() - if $params->{mode} eq gettext("List Booths"); - return &build_view_booth() if $params->{mode} eq gettext("View Booth"); - - return &build_create_card() if $params->{mode} eq gettext("Add Cards"); - return &build_list_cards() if $params->{mode} eq gettext("List Cards"); - return &build_list_cards() - if $params->{mode} eq gettext("Calling Cards"); - return &build_update_card_status() - if $params->{mode} eq gettext("Update Card(s) Status"); - return &build_reset_card_inuse() - if $params->{mode} eq gettext("Reset InUse"); - return &build_view_card() if $params->{mode} eq gettext("View Card"); - return &build_cc_brands() if $params->{mode} eq gettext("CC Brands"); - return &build_delete_cards() - if $params->{mode} eq gettext("Delete Card"); - return &build_refill_card() - if $params->{mode} eq gettext("Refill Card"); - return &build_callshop_callshop_report() - if $params->{mode} eq gettext("Booth Report"); - - return &build_list_booths() - if $params->{mode} eq gettext("Home Page") - || $params->{mode} eq gettext("Home") - || $params->{mode} eq "" - || $params->{mode} eq gettext("Login") - || $params->{mode} eq gettext("Logout"); - return gettext("Not Available!") . "\n"; - } - else { - $params->{mode} = gettext("Home"); - return gettext("Not Available!") . "\n"; - } -} - -sub build_purge_deactivated() { - my ( $status, $body ); - return gettext("Cannot drop items until database is configured") - unless $astpp_db; - if ( $params->{action} eq gettext("Yes, Drop Them") ) { - if ( $astpp_db->do("DELETE FROM outbound_routes WHERE status = 2") ) { - $status .= gettext("Dropped deactivated outbound routes.") . "<br>"; - } - else { - $status .= - gettext("Unable to drop deactivated outbound routes.") . "<br>"; - } - if ( $astpp_db->do("DELETE FROM routes WHERE status = 2") ) { - $status .= gettext("Dropped deactivated routes.") . "<br>"; - } - else { - $status .= gettext("Unable to drop deactivated routes.") . "<br>"; - } - if ( $astpp_db->do("DELETE FROM accounts WHERE status = 2") ) { - $status .= gettext("Dropped deactivated accounts.") . "<br>"; - } - else { - $status .= gettext("Unable to drop deactivated accounts.") . "<br>"; - } - if ( $astpp_db->do("DELETE FROM pricelists WHERE status = 2") ) { - $status .= gettext("Dropped deactivated pricelists.") . "<br>"; - } - else { - $status .= - gettext("Unable to drop deactivated pricelists.") . "<br>"; - } - if ( $astpp_db->do("DELETE FROM cdrs WHERE status = 2") ) { - $status .= gettext("Dropped deactivated cdrs.") . "<br>"; - } - else { - $status .= gettext("Unable to drop deactivated cdrs.") . "<br>"; - } - if ( $astpp_db->do("DELETE FROM trunks WHERE status = 2") ) { - $status .= gettext("Dropped deactivated trunks.") . "<br>"; - } - else { - $status .= gettext("Unable to drop deactivated trunks.") . "<br>"; - } - if ( $astpp_db->do("DELETE FROM dids WHERE status = 2") ) { - $status .= gettext("Dropped deactivated DIDs.") . "<br>"; - } - else { - $status .= gettext("Unable to drop deactivated DIDs.") . "<br>"; - } - if ( $astpp_db->do("DELETE FROM packages WHERE status = 2") ) { - $status .= gettext("Dropped deactivated packages.") . "<br>"; - } - else { - $status .= gettext("Unable to drop deactivated packages.") . "<br>"; - } - if ( $astpp_db->do("DELETE FROM callshops WHERE status = 2") ) { - $status .= gettext("Dropped deactivated callshops.") . "<br>"; - } - else { - $status .= - gettext("Unable to drop deactivated callshops.") . "<br>"; - } - } - $body = start_form(); - $body .= "<TABLE>"; - $body .= - "<tr><td>" - . gettext( - "Remove records in your system that have been marked as deactivated.") - . "</td></tr>\n"; - if ( $params->{action} eq gettext("Drop Deactivated Records") ) { - $body .= - "<tr><td>" - . hidden( -name => "mode", -value => gettext("Purge Deactivated") ) - . submit( -name => "action", -value => gettext("Yes, Drop Them") ) - . "</td><td>" - . submit( -name => "action", -value => gettext("Cancel") ) - . "</td></tr><tr><td>$status</td></tr></table>"; - } - else { - $body .= - "<tr><td>" - . hidden( -name => "mode", -value => gettext("Purge Deactivated") ) - . submit( - -name => "action", - -value => gettext("Drop Deactivated Records") - ) - . "</td><td>" - . submit( -name => "action", -value => gettext("Cancel") ) - . "</td></tr><tr><td>$status</td></tr></table>"; - } - return $body; -} - -######## Reporting Module ################ -# - -# Modified and Extended By Sonia Ali Khan <son...@gm...> -# Last updated: Sept. 11, 2007 at 1445hours GMT. - -sub build_filter($$) { - my ( $additional_fields, $submit_title ) = @_; - my ($body); - return gettext("ASTPP Database Not Available!") . "<br>" unless $astpp_db; - $cdr_db = &cdr_connect_db( $config, @output ); - return gettext("Asterisk CDR Database Not Available!") . "<br>" - unless $cdr_db; - - # Set the defaults for the date options - my ( undef, undef, undef, $current_day, $current_month, $current_year ) = - localtime(); - my ( - $start_year, $start_month, $start_day, $start_hour, - $start_minute, $start_second, $end_year, $end_month, - $end_day, $end_hour, $end_minute, $end_second - ); - my $count = 0; - if ( !$params->{start_month} ) { - $start_year = $current_year + 1900; - $start_month = sprintf( "%02d", $current_month + 1 ); - $start_day = "01"; - $start_hour = "00"; - $start_minute = "00"; - $start_second = "00"; - $end_year = $current_year + 1900; - $end_month = sprintf( "%02d", $current_month + 1 ); - $end_day = $current_day; - $end_hour = "23"; - $end_minute = "59"; - $end_second = "59"; - } - else { - $start_year = $params->{start_year}; - $start_month = sprintf( "%02d", $params->{start_month} + 1 ); - $start_day = sprintf( "%02d", $params->{start_day} ); - $start_hour = sprintf( "%02d", $params->{start_hour} ); - $start_minute = sprintf( "%02d", $params->{start_minute} ); - $start_second = sprintf( "%02d", $params->{start_second} ); - $end_year = $params->{end_year}; - $end_month = sprintf( "%02d", $params->{end_month} + 1 ); - $end_day = sprintf( "%02d", $params->{end_day} ); - $end_hour = sprintf( "%02d", $params->{end_hour} ); - $end_minute = sprintf( "%02d", $params->{end_minute} ); - $end_second = sprintf( "%02d", $params->{end_second} ); - } - - $body .= - "<form method=get><input type=hidden name=mode value=\"" - . param('mode') - . "\"><table class=\"default\" width=100%>"; - $body .= - "<tr><td width=50%>" - . gettext("Start date:") - . "</td><td><input type=text name=start_year value=\"$start_year\" size=5><select name=start_month>"; - - for ( $id = 0 ; $id < 12 ; $id++ ) { - if ( $id == ( $start_month - 1 ) ) { - $body .= "<option value=$id selected>$months[$id]"; - } - else { - $body .= "<option value=$id>$months[$id]"; - } - } - $body .= -"</select><input type=text name=start_day value=\"$start_day\" size=3></td></tr>"; - $body .= - "<tr><td>" - . gettext("Start time:") - . "</td><td><input type=text name=start_hour value=\"$start_hour\" size=3>" - . "<input type=text name=start_minute value=\"$start_minute\" size=3>" - . "<input type=text name=start_second value=\"$start_second\" size=3></td></tr>"; - $body .= - "<tr><td>" - . gettext("End date:") - . "</td><td><input type=text name=end_year value=\"$end_year\" size=5><select name=end_month>"; - for ( $id = 0 ; $id < 12 ; $id++ ) { - if ( $id == ( $end_month - 1 ) ) { - $body .= "<option value=$id selected>$months[$id]"; - } - else { - $body .= "<option value=$id>$months[$id]"; - } - } - - $submit_title = "Filter!" if !$submit_title; - $body .= -"</select><input type=text name=end_day value=\"$end_day\" size=3></td></tr>"; - $body .= - "<tr><td>" - . gettext("End time:") - . "</td><td><input type=text name=end_hour value=\"$end_hour\" size=3>" - . "<input type=text name=end_minute value=\"$end_minute\" size=3>" - . "<input type=text name=end_second value=\"$end_second\" size=3></td></tr>\n"; - $body .= $additional_fields if $additional_fields; - $body .= -"<tr><td align=center colspan=2><input type=submit value=$submit_title></td></tr>"; - $body .= "</table>\n</form>"; - - my %report_filter = ( - 'start_year' => $start_year, - 'start_month' => $start_month, - 'start_day' => $start_day, - 'start_hour' => $start_hour, - 'start_minute' => $start_minute, - 'start_second' => $start_second, - 'end_year' => $end_year, - 'end_month' => $end_month, - 'end_day' => $end_day, - 'end_hour' => $end_hour, - 'end_minute' => $end_minute, - 'end_second' => $end_second, - 'start_date' => -"$start_year-$start_month-$start_day $start_hour:$start_minute:$start_second", - 'end_date' => - "$end_year-$end_month-$end_day $end_hour:$end_minute:$end_second", - 'form_body' => $body - ); - return \%report_filter; -} - -sub build_admin_reseller_report() { - return &build_report( "Reseller", "1" ); -} - -sub build_admin_vendor_report() { - return &build_report( "Vendor", "3" ); -} - -sub build_callshop_callshop_report() { - return &build_report( "Booth", "6" ); -} - -sub build_reseller_callshop_report() { - return &build_report( "Booth", "6" ); -} - -sub build_reseller_reseller_report() { - return &build_report( "Reseller", "1" ); -} - -sub build_reseller_user_report() { - return &build_report( "User", "0" ); -} - -sub build_list_box($$) { - my ( $in, $selected ) = @_; - my $body = ""; - undef %list; - @list{@$in} = (); - my @out = sort keys %list; # remove sort if undesired - for ( my $i = 0 ; $i < @out ; $i++ ) { - if ( $out[$i] eq $selected ) { - $body .= "<option value='$out[$i]' selected>$out[$i]</option>\n"; - } - else { - $body .= "<option value='$out[$i]'>$out[$i]</option>\n"; - } - } - return $body; -} - -sub build_report($$) { - - return gettext("Cannot display reports until database is configured") - unless $astpp_db; - $cdr_db = &cdr_connect_db( $config, $enh_config, @output ); - return gettext("Cannot display reports until database is configured") - unless $cdr_db; - - my $name = shift; - my $type = shift; - my ( $sth, $body ); - - my $destination = $params->{destination}; - my $pattern = $params->{pattern}; - - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - $sth = - $astpp_db->prepare( "SELECT * FROM accounts WHERE reseller = " - . $astpp_db->quote( $params->{username} ) - . " AND type IN ($type)" ); - } - else { - $sth = - $astpp_db->prepare("SELECT * FROM accounts WHERE type IN ($type)"); - } - - $sth->execute() - || return gettext("Something is wrong with astpp database") . "\n"; - - $body = "<tr><td align=right> $name:" - . "<select name=$name value='$params->{$name}'>\n<option value='ALL'>ALL</option>\n"; - - while ( my $row = $sth->fetchrow_hashref ) { - if ( $row->{'number'} eq $params->{$name} ) { - $body .= -"<option value='$row->{'number'}' selected>$row->{'number'}</option>\n"; - } - else { - $body .= - "<option value='$row->{'number'}'>$row->{'number'}</option>\n"; - } - } - - $sth->finish; - - $body .= "</select> <strong>AND</strong> "; - - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - $sth = $astpp_db->prepare( - "SELECT DISTINCT notes FROM cdrs WHERE notes LIKE " - . $astpp_db->quote( $params->{username} . "|%" ) ); - } - else { - $sth = $astpp_db->prepare("SELECT DISTINCT notes FROM cdrs"); - } - - $sth->execute() - || return gettext("Something is wrong with astpp database") . "\n"; - - my ( $dest, $ptrn ); - my ( @dst, @ptn, $i ); - $dest = -"Destination: </td><td align=left><select name=destination value='Destination'>\n" - . "<option value='ALL'>ALL</option>\n"; - $ptrn = - " <strong>OR</strong> " - . "IDD Code: <select name=pattern value='IDD Code'>\n" - . "<option value='ALL'>ALL</option>\n"; - - while ( my $notes = $sth->fetchrow_hashref ) { - my @note = split( m/(\^|DID:)/, $notes->{'notes'}, 2 ); - $ptn[$i] = $note[1] . $note[2]; - @note = split( /\|/, $note[0] ); - $dst[$i] = ( @note == 1 ) ? $note[0] : $note[1] if $note[0] ne ""; - $i++; - } - $sth->finish; - - $dest .= build_list_box( \@dst, $destination ); - $dest .= "</select>\n"; - - $ptrn .= build_list_box( \@ptn, $pattern ); - $ptrn .= "</select>\n"; - - $body .= $dest . $ptrn . "</td></tr>"; - - my $filter = build_filter( $body, undef ); - my $sd = $filter->{'start_date'}; - my $ed = $filter->{'end_date'}; - $body = $filter->{'form_body'}; - - my $where = - "callstart BETWEEN " - . $astpp_db->quote($sd) . " AND " - . $astpp_db->quote($ed) . " "; - - if ( $params->{$name} eq 'ALL' ) { - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - $where .= - "AND cardnum IN (SELECT `number` FROM accounts WHERE reseller = " - . $astpp_db->quote( $params->{username} ) - . " AND type IN ($type)) "; - } - else { - if ( index( $type, "1" ) != -1 ) { - $where .= -"AND cardnum IN (SELECT `number` FROM accounts WHERE type IN ($type)) "; - } - elsif ( index( $type, "3" ) != -1 ) { - $where .= - "AND provider = " . $astpp_db->quote( $params->{$name} ); - } - } - } - else { - if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { - $where .= - "AND cardnum = " . $astpp_db->quote( $params->{$name} ) . " "; - } - else { - if ( index( $type, "1" ) != -1 ) { - $where .= -"AND cardnum IN (SELECT `number` FROM accounts WHERE `number` = " - . $astpp_db->quote( $params->{$name} ) - . " AND type IN ($type)) "; - } - elsif ( index( $type, "3" ) != -1 ) { - $where .= - "AND provider = " . $astpp_db->quote( $params->{$name} ); - } - } - } - - if ( $destination eq 'ALL' ) { - if ( $pattern eq 'ALL' ) { - $where .= ""; - } - else { - $where .= - "AND notes LIKE " . $astpp_db->quote( "%|" . $pattern ) . " "; - } - } - else { - if ( $pattern eq 'ALL' ) { - $where .= "AND notes LIKE " - . $astpp_db->quote( "%|" . $destination . "|%" ) . " "; - } - else { - $where .= "AND (notes LIKE " - . $astpp_db->quote( "%|" . $destination . "|%" ) . " "; - $where .= - "OR notes LIKE " . $astpp_db->quote( "%|" . $pattern ) . ") "; - } - } - - $where = 0 if $param->{$name} eq "" && $destination eq "" && $pattern eq ""; - - $body .= - start_form() - . "<table class=\"default\" width=100%><tr><td colspan=12 align=center><b>$sd - $ed</b></td></tr>" - . "<tr class=\"header\"><td>" - . gettext("$name") - . "</td><td>" - . gettext("Destination") - . "</td><td>" - . gettext("IDD Code") - . "</td><td>" - . gettext("Attempted Calls") - . "</td><td>" - . gettext("Completed Calls") - . "</td><td>" - . "<acronym title=\"" - . gettext("Answer Seizure Rate") . "\">" - . gettext("ASR") - . "</acronym>" - . "</td><td>" - . "<acronym title=\"" - . gettext("Average Call Duration") . "\">" - . gettext("ACD") - . "</acronym>" - . "</td><td>" - . "<acronym title=\"" - . gettext("Maximum Call Duration") . "\">" - . gettext("MCD") - . "</acronym>" - . "</td><td>" - . gettext("Actual") - . "</td><td>" - . gettext("Billable") - . "</td><td>" - . gettext("Price") - . "</td><td>" - . gettext("Cost") - . "</td></tr>\n"; - - my $table = "tmp_" . time(); - my ( - $bth, $dst, $idd, $atmpt, $cmplt, $asr, - $acd, $mcd, $act, $bill, $price, $cost - ); - my $query = -"CREATE TEMPORARY TABLE $table SELECT * FROM cdrs WHERE uniqueid != '' AND $where"; - $sth = $astpp_db->do($query) - || return gettext("Something is wrong with astpp database") . "\n"; - $ASTPP->debug( user => $param->{username}, debug => " SQL: $query " ); - - my $sql = - $astpp_db->prepare("SELECT DISTINCT cardnum AS $name FROM $table"); - $sql->execute() - || return gettext("Something is wrong with astpp database") . "\n"; - - while ( my $row = $sql->fetchrow_hashref ) { - $bth = $row->{$name}; - my $sql1 = $astpp_db->prepare( - "SELECT notes, COUNT(*) AS attempts, AVG(billseconds) AS acd, - MAX(billseconds) AS mcd, SUM(billseconds) AS billable, - SUM(debit) AS cost, SUM(cost) AS price FROM $table - WHERE (notes IS NOT NULL AND notes != '') AND cardnum = " - . $astpp_db->quote($bth) . " GROUP BY notes" - ); - $sql1->execute() - || return gettext("Something is wrong with astpp database") . "\n"; - - while ( my $row1 = $sql1->fetchrow_hashref() ) { - my @note1 = split( m/(\^|DID:)/, $row1->{notes}, 2 ); - $idd = $note1[1] . $note1[2]; - @note1 = split( /\|/, $note1[0] ); - $dst = ( @note1 == 1 ) ? $note1[0] : $note1[1]; - $dst = 'N/A' if $dst eq ""; - - $atmpt = $row1->{'attempts'}; - $acd = $row1->{'acd'}; - $mcd = $row1->{'mcd'}; - $bill = $row1->{'billable'}; - $price = $row1->{'price'}; - $cost = $row1->{'cost'}; - - $notes = "notes = " . $astpp_db->quote( $row1->{notes} ); - - my $sql2 = $astpp_db->prepare( - "SELECT COUNT(*) AS completed FROM $table - WHERE $notes AND disposition = 'ANSWERED'" - ); - $sql2->execute() - || return gettext("Something is wrong with astpp database") - . "\n"; - my $row2 = $sql2->fetchrow_hashref(); - $cmplt = $row2->{'completed'} || 0; - $sql2->finish; - - $asr = ( ( $atmpt - $cmplt ) / $atmpt ) * 100; - - my $in = ""; - my $sql3 = - $astpp_db->prepare("SELECT uniqueid FROM $table WHERE $notes "); - $sql3->execute() - || return gettext("Something is wrong with astpp database") - . "\n"; - - while ( my $row3 = $sql3->fetchrow_hashref ) { - $in .= "'" . $row3->{'uniqueid'} . "'," if $row3->{'uniqueid'}; - } - - $in = substr( $in, 0, -1 ) if length($in) > 0; - $sql3->finish; - - my $sql4 = $cdr_db->prepare( -"SELECT SUM(duration) AS actual FROM cdr WHERE uniqueid IN ($in)" - ); - $sql4->execute() - || return gettext("Something is wrong with cdr database") . "\n"; - my $row4 = $sql4->fetchrow_hashref(); - $act = $row4->{'actual'}; - $sql4->finish; - - $act = int( $act / 60 ) . ":" . ( $act % 60 ); - $acd = int( $acd / 60 ) . ":" . ( $acd % 60 ); - $mcd = int( $mcd / 60 ) . ":" . ( $mcd % 60 ); - $bill = int( $bill / 60 ) . ":" . ( $bill % 60 ); - $price = $price / 10000.0; - $cost = $cost / 10000.0; - - $body .= "<tr>" - . "<td>$bth</td><td>$dst</td><td>$idd</td><td>$atmpt</td><td>$cmplt</td><td>$asr</td>" - . "<td align=right>$acd</td><td align=right>$mcd</td><td align=right>$act</td>" - . "<td align=right>$bill</td><td>$price</td><td>$cost</td>" - . "</tr>"; - } - $sql1->finish; - } - $sql->finish; - - $sth = $astpp_db->do("DROP TEMPORARY TABLE $table") - || return gettext("Something is wrong with astpp database") . "\n"; - - $body .= "</table>"; - return $body; -} - -sub build_admin_report() { - my ($body); - return gettext("Cannot display reports until database is configured") - unless $astpp_db; - $cdr_db = &cdr_connect_db( $config, $enh_config, @output ); - return gettext("Cannot display reports until database is configured") - unless $cdr_db; - - return gettext("Comming Soon!"); -} - -sub build_reseller_report() { - my ($body); - return gettext("Cannot display reports until database is configured") - unless $astpp_db; - $cdr_db = &cdr_connect_db( $config, $enh_config, @output ); - return gettext("Cannot display reports until database is configured") - unless $cdr_db; - - return gettext("Coming Soon!"); -} - -# End of code changes by Sonia Ali Khan. - -#################### Stats stuff ########################### -sub build_stats_acd() { - my ( $body, $id ); - return gettext("Cannot display stats until database is configured") - unless $astpp_db; - $cdr_db = &cdr_connect_db( $config, $enh_config, @output ); - return gettext("Cannot display stats until database is configured") - unless $cdr_db; - - my $filter = build_filter( undef, undef ); - my $sd = $filter->{'start_date'}; - my $ed = $filter->{'end_date'}; - $body = $filter->{'form_body'}; - - my $sth; - - if ( $params->{logintype} == 3 ) { - $sth = - $astpp_db->prepare( "SELECT * FROM trunks WHERE provider = " - . $astpp_db->quote( $params->{username} ) ); - } - else { - $sth = $astpp_db->prepare("SELECT * FROM trunks"); - } - $sth->execute - || return gettext("Something is wrong with the trunks database") . "\n"; - $body .= - start_form() - . "<table class=\"default\" width=100%><tr><td colspan=5 align=center><b>$sd - $ed</b></td></tr>" - . "<tr class=\"header\"><td>" - . gettext("Trunk Name") - . "</td><td>" - . gettext("Calls") - . "</td><td>" - . "<acronym title=\"" - . gettext("Average Call Duration") . "\">" - . gettext("ACD") - . "</acronym>" - . "</td><td>" - . "<acronym title=\"" - . gettext("Average Call Wait Time") . "\">" - . gettext("ACWT") - . "</acronym>" - . "</td><td>" - . gettext("Success") - . "</td><td>" - . gettext("Congestion") - . "</td></tr>\n"; - - while ( my $row = $sth->fetchrow_hashref ) { - $count++; - my $sql1 = " SELECT COUNT( - *) as calls, - AVG(billsec) as bs, - AVG( duration-billsec ) as acwt from cdr where lastapp = 'Dial' - and disposition REGEXP '^ANSWERED$' - and calldate >= " . $cdr_db->quote($sd) . " - and calldate <= " . $cdr_db->quote($ed) . " - and (dstchannel like '$row->{tech}/$row->{path}%' - or dstchannel like '$row->{tech}\[$row->{path}\]%' ) "; - $ASTPP->debug( user => $param->{username}, debug => " SQL: $sql1 \n " ); - my $sth1 = $cdr_db->prepare($sql1); - $sth1->execute(); - my $ref1 = $sth1->fetchrow_hashref(); - $sth1->finish; - my $sql2 = " select count( - *) as ct from cdr where calldate >= - " . $cdr_db->quote($sd) . " - and calldate <= " . $cdr_db->quote($ed) . " - and disposition not in( - 'ANSWERED','16' - ) - and (dstchannel like '$row->{tech}/$row->{path}%' - or dstchannel like '$row->{tech}\[$row->{path}\]%' ) - "; - my $sth2 = $cdr_db->prepare($sql2); - $ASTPP->debug( user => $param->{username}, debug => " SQL: $sql2" ); - $sth2->execute(); - my $ref2 = $sth2->fetchrow_hashref(); - $sth2->finish; - my $sql3 = " select count( - *) as ct from cdr where calldate >= - " . $cdr_db->quote($sd) . " - and calldate <= " . $cdr_db->quote($ed) . " - and disposition REGEXP '^CONGESTION$' - and (dstchannel like '$row->{tech}/$row->{path}%' - or dstchannel like '$row->{tech}\[$row->{path}\]%' ) - "; - my $sth3 = $cdr_db->prepare($sql3); - $ASTPP->debug( user => $param->{username}, debug => " SQL: $sql3" ); - $sth3->execute(); - my $ref3 = $sth3->fetchrow_hashref(); - $sth3->finish; - my $sql4 = " select count( - *) as ct from cdr where calldate >= - " . $cdr_db->quote($sd) . " - and calldate <= " . $cdr_db->quote($ed) . " - and (dstchannel like '$row->{tech}/$row->{path}%' - or dstchannel like '$row->{tech}\[$row->{path}\]%' ) - "; - my $sth4 = $cdr_db->prepare($sql4); - $ASTPP->debug( user => $param->{username}, debug => " SQL: $sql4" ); - $sth4->execute(); - my $ref4 = $sth4->fetchrow_hashref(); - $sth4->finish; - my $success_rate = 0; - my $congestion_rate = 0; - - if ( $ref4->{ct} > 0 && $ref1->{calls} > 0 ) { - $success_rate = ( $ref1->{calls} / $ref4->{ct} ) * 100; - } - if ( $ref4->{ct} > 0 && $ref3->{ct} > 0 ) { - $congestion_rate = ( $ref3->{ct} / $ref4->{ct} ) * 100; - } - if ( $count % 2 == 0 ) { - $body .= "<tr class=\"rowtwo\">"; - } - else { - $body .= "<tr class=\"rowone\">"; - } - $body .= -"<td>$row->{tech}/$row->{path}</td><td align=right>$ref4->{ct}</td><td align=right>" - . "$ref1->{bs}</td><td align=right>$ref1->{acwt}</td><td align=right>" - . "$ref1->{calls} " - . sprintf( "%.04f", $success_rate ) - . " %</td><td>" - . "$ref3->{ct} " - . sprintf( "%.04f", $congestion_rate ) - . "%</td></tr>\n"; - } - $sth->finish; - $body .= "</table>"; - return $body; -} - -#################### Stats stuff ########################### -sub build_view_cdrs() { - my ( - @trunklist, $body, $id, $tmp, - $row, $sql, $results, $pagesrequired, - $pageno, $string, $sd_month - ); - return gettext("Cannot display stats until database is configured") - unless $astpp_db; - $cdr_db = &cdr_connect_db( $config, @output ); - return gettext("Cannot display stats until database is configured") - unless $cdr_db; - if ( $params->{limit} < 1 || !$params->{limit} ) { $params->{limit} = 0 } - my $results_per_page = $config->{results_per_page}; - if ( $results_per_page eq "" ) { $results_per_page = 25; } - my ( undef, undef, undef, $day, $mnth, $yr ) = localtime(); - - if ( $params->{logintype} == 3 ) { - my $sql = - $astpp_db->prepare( "SELECT * FROM trunks WHERE provider = " - . $astpp_db->quote( $params->{username} ) ); - $sql->execute; - while ( my $record = $sql->fetchrow_hashref ) { - push @trunklist, $record->{name}; - } - $sql->finish; - } - else { - @trunklist = &list_trunks($astpp_db); - push( @trunklist, "" ); - } - @trunklist = sort @trunklist; - - $body = - "<tr><td>" - . gettext("Answered Calls Only?") - . popup_menu( - -name => "answered", - -values => \%yesno - ) . "</td><td>"; - if ( $params->{logintype} == 2 ) { - $body .= gettext("AccountCode:") - . textfield( - -name => "accountcode", - -width => 8 - ); - } - $body .= - "</td></tr>" - . "<tr><td>" - . gettext("Select Outbound Trunk?") - . popup_menu( - -name => "trunk", - -values => \@trunklist - ) . "</td></tr>"; - - my $filter = build_filter( $body, undef ); - my $sd = $filter->{'start_date'}; - my $ed = $filter->{'end_date'}; - $body = $filter->{'form_body'}; - - $body .= start_form() - . "<table class=\"viewcdrs\" width=100%><tr><td colspan=5 align=center><b>$sd - $ed</b></td></tr> -" - . "<tr class=\"header\"><td>" - . gettext("Date") - . "</td><td>" - . gettext("CallerID") . "</td>" . "<td>" - . gettext("Source") - . "</td><td>" - . gettext("Dest") . "</td>" . "<td>" - . gettext("D.Context") - . "</td><td>" - . gettext("Chan") . "</td>" . "<td>" - . gettext("D.Chan") - . "</td><td>" - . gettext("Last App") - . " </td>" . "<td>" - . gettext("Last Data") - . "</td><td>" - . gettext("Duration") . "</td>" . "<td>" - . gettext("BillSec") - . "</td><td>" - . gettext("Disposition") . "</td>" . "<td>" - . gettext("AMAFlags") - . "</td><td>"; - - if ( $params->{logintype} == 2 ) { - $body .= gettext("AccountCode"); - } - $body .= - "</td>" . "<td>" - . gettext("U-ID") - . "</td><td>" - . gettext("UserField") . "</td>" . "<td>" - . gettext("Cost") - . "</td></tr> -\n"; - if ( $params->{answered} == 1 ) { - $tmp = - " SELECT * from cdr where disposition = 'ANSWERED'" - . " and calldate >= " - . $cdr_db->quote($sd) - . " and calldate <= " - . $cdr_db->quote($ed); - $ASTPP->debug( user => $param->{username}, debug => " SQL: $tmp" ); - } - else { - $tmp = - " SELECT * from cdr where calldate >= " - . $cdr_db->quote($sd) - . " and calldate <= " - . $cdr_db->quote($ed); - $ASTPP->debug( user => $param->{username}, debug => " SQL: $tmp" ); - } - if ( $params->{accountcode} && $params->{logintype} == 2 ) { - $tmp .= - " and accountcode = " . $cdr_db->quote( $params->{accountcode} ); - } - if ( $params->{trunk} ) { - my $tmpsql = - "SELECT * FROM trunks WHERE name = " - . $astpp_db->quote( $params->{trunk} ) - . " LIMIT 1"; - $ASTPP->debug( user => $param->{username}, debug => $tmpsql ); - $sql = $astpp_db->prepare($tmpsql); - $sql->execute - || return gettext("Something is wrong with the trunks database") - . "\n"; - $row = $sql->fetchrow_hashref; - $sql->finish; - $tmp .= " and (dstchannel like '$row->{tech}/$row->{path}\%'" - . " or dstchannel like '$row->{tech}\[$row->{path}\]\%')"; - } - $ASTPP->debug( user => $param->{username}, debug => $tmp ); - $sql = $cdr_db->prepare($tmp); - $sql->execute; - $results = $sql->rows; - $pagesrequired = ceil( $results / $results_per_page ); - $sql->finish; - $tmp .= " limit $params->{limit} , $results_per_page"; - $sql = $cdr_db->prepare($tmp); - $sql->execute; - - while ( my $record = $sql->fetchrow_hashref ) { - $count++; - if ( $count % 2 == 0 ) { - $body .= "<tr class=\"rowtwo\">"; - } - else { - $body .= "<tr class=\"rowone\">"; - } - my $dcontext = substr( $record->{dcontext}, 0, 4 ) . ".."; - my $channel = substr( $record->{channel}, 0, 9 ) . ".."; - my $dstchannel = substr( $record->{channel}, 0, 9 ) . ".."; - my $lastdata = substr( $record->{lastdata}, 0, 4 ) . ".."; - if ( $params->{logintype} != 2 ) { - ... [truncated message content] |
From: <dar...@us...> - 2009-02-01 02:22:11
|
Revision: 2230 http://astpp.svn.sourceforge.net/astpp/?rev=2230&view=rev Author: darrenkw Date: 2009-02-01 01:41:41 +0000 (Sun, 01 Feb 2009) Log Message: ----------- Corrected the code for viewing booths. Modified Paths: -------------- trunk/scripts/astpp-common.pl trunk/web_interface/astpp-admin.cgi Modified: trunk/scripts/astpp-common.pl =================================================================== --- trunk/scripts/astpp-common.pl 2009-02-01 00:59:00 UTC (rev 2229) +++ trunk/scripts/astpp-common.pl 2009-02-01 01:41:41 UTC (rev 2230) @@ -1502,11 +1502,11 @@ # Select all the unbilled CDRS belonging to a specific account. This is mostly used by booths. sub list_cdrs_account() { - my ( $config, $cdr_db, $account, $cc ) = @_; + my ( $cdr_db,$config, $account, $cc ) = @_; my ( $sql, @cdrlist, $row ); - $sql = - $cdr_db->prepare( - "SELECT * FROM $config->{asterisk_cdr_table} WHERE cost IN ('none', 'error') AND accountcode IN (" . $cdr_db->quote($account) . ", " . $cdr_db->quote($cc) . ") AND disposition REGEXP 'ANSWE.*'"); + my $tmp = "SELECT * FROM $config->{asterisk_cdr_table} WHERE cost IN ('none', 'error') AND accountcode IN (" . $cdr_db->quote($account) . ", " . $cdr_db->quote($cc) . ") AND disposition REGEXP 'ANSWE.*'"; + print STDERR $tmp ."\n" if $config->{debug} == 1; + $sql = $cdr_db->prepare($tmp); $sql->execute; while ( $row = $sql->fetchrow_hashref ) { push @cdrlist, $row->{uniqueid}; Modified: trunk/web_interface/astpp-admin.cgi =================================================================== --- trunk/web_interface/astpp-admin.cgi 2009-02-01 00:59:00 UTC (rev 2229) +++ trunk/web_interface/astpp-admin.cgi 2009-02-01 01:41:41 UTC (rev 2230) @@ -9638,6 +9638,16 @@ $params->{secret}, $params->{context}, $number, $params ); $status .= "<br>"; } + if ( $config->{users_dids_freeswitch} == 1 ) { + my $name = + &finduniquesip_freeswitch( $fs_db, $config, + $params->{number} ); + $status .= + &add_sip_user_freeswitch( $fs_db, $config, $name, + $params->{accountpassword}, + $params->{number}, $params, $accountinfo->{cc} ); + $status .= "<br>"; + } $params->{action} = gettext("Information..."); } elsif ( $params->{action} eq gettext("Delete...") ) { @@ -11006,6 +11016,16 @@ $params->{context}, $params->{number}, $params ); $status .= "<br>"; } + if ( $config->{users_dids_freeswitch} == 1 ) { + my $name = + &finduniquesip_freeswitch( $fs_db, $config, + $params->{number} ); + $status .= + &add_sip_user_freeswitch( $fs_db, $config, $name, + $params->{accountpassword}, + $params->{number}, $params, $accountinfo->{cc} ); + $status .= "<br>"; + } } if ( $params->{IAX2} ) { $ASTPP->debug( @@ -11373,7 +11393,7 @@ } sub build_view_booth() { - my ( $config, $sql, @cdrs, $sip_login, $iax2_login ); + my ( $sql, @cdrs, $sip_login, $iax2_login ); # Prepare the booth list for the menu. @booth_list = @@ -11473,7 +11493,7 @@ $sql->finish; } my @chargelist = - &list_cdrs_account( $config, $cdr_db, $accountinfo->{number}, + &list_cdrs_account( $cdr_db,$config, $accountinfo->{number}, $accountinfo->{cc} ); &processlist( $astpp_db, $cdr_db, $config, $config->{asterisk_cdr_table}, @@ -11523,10 +11543,12 @@ push( @cdrs, $record ); } } + my $template = HTML::Template->new( filename => '/var/lib/astpp/templates/booth-view.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); + $template->param( booth_name => $params->{booth_name} ); my $balance = &accountbalance( $astpp_db, $params->{booth_name} ) / 10000; my $unrated = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-02-21 19:43:14
|
Revision: 2237 http://astpp.svn.sourceforge.net/astpp/?rev=2237&view=rev Author: darrenkw Date: 2009-02-21 19:43:05 +0000 (Sat, 21 Feb 2009) Log Message: ----------- More work on getting callingcards working. Modified Paths: -------------- trunk/freeswitch/astpp-callingcards.pl trunk/modules/ASTPP/lib/ASTPP.pm Modified: trunk/freeswitch/astpp-callingcards.pl =================================================================== --- trunk/freeswitch/astpp-callingcards.pl 2009-02-21 18:36:58 UTC (rev 2236) +++ trunk/freeswitch/astpp-callingcards.pl 2009-02-21 19:43:05 UTC (rev 2237) @@ -149,13 +149,13 @@ if ($config->{calling_cards_rate_announce} == 1) { if ( $numberinfo->{cost} > 0 ) { $session->streamFile($sound->{call_will_cost}); -# $AGI->say_number(ceil($numberinfo->{cost} / 100)); + $session->execute("phrase","pronounce," . ceil($numberinfo->{cost}/100)); $session->streamFile($sound->{currency}); my @call_cost = split(/\./, ($numberinfo->{cost} / 100)); -# $AGI->say_number(@call_cost[0]); + $session->execute("phrase","pronounce," . @call_cost[0]); if (@call_cost[1]) { $session->streamFile($sound->{point}); -# $AGI->say_number(@call_cost[1]); + $session->execute("phrase","pronounce," . @call_cost[1]); $session->streamFile($sound->{sub_currency}); } $session->streamFile($sound->{per}); @@ -163,7 +163,7 @@ } if ( $numberinfo->{connectcost} > 0 ) { $session->streamFile($sound->{a_connect_charge}); -# $AGI->say_number(ceil($numberinfo->{connectcost} / 100)); + $session->execute("phrase","pronounce," . ceil($numberinfo->{connectcost}/100)); $session->streamFile($sound->{sub_currency}); $session->streamFile($sound->{will_apply}); } @@ -243,11 +243,11 @@ $minutes = sprintf( "%.0f", $minutes ); $session->streamFile($sound->{call_will_last}); if ( $minutes == 1 ) { -# $AGI->say_number($minutes); + $session->execute("phrase","pronounce," . $minutes); $session->streamFile($sound->{minute}); } elsif ( $minutes > 1 ) { -# $AGI->say_number($minutes); + $session->execute("phrase","pronounce," . $minutes); $session->streamFile($sound->{minutes}); } } @@ -284,19 +284,19 @@ my $interrupt = $session->playAndGetDigits(1,1,1,0,"#*","$sound->{card_has_balance_of}","$sound->{card_has_balance_of}",'^[0-9]+$'); if (!$interrupt || $interrupt eq "" || $interrupt == 0) { if ( $main_balance == 1 ) { -# $AGI->say_number($main_balance); +$session->execute("phrase","pronounce," . $main_balance); $session->streamFile($sound->{main_currency}); } elsif ( $main_balance > 1 ) { -# $AGI->say_number($main_balance); +$session->execute("phrase","pronounce," . $main_balance); $session->streamFile($sound->{main_currency_plural}); } if ( $sub_balance == 1 ) { -# $AGI->say_number($sub_balance); +$session->execute("phrase","pronounce," . $sub_balance); $session->streamFile($sound->{sub_currency}); } elsif ( $sub_balance > 1 ) { -# $AGI->say_number($sub_balance); +$session->execute("phrase","pronounce," . $sub_balance); $session->streamFile($sound->{sub_currency_plural}); } } @@ -370,8 +370,160 @@ $session->execute("set", "DIALSTATUS=NO ANSWER" ); } +sub dialout() { # Rig up the LCR stuff and do the outbound dialing. + # If a call does not go through we give the user the option + # of trying again. + my ( $destination, $timelimit, $numberinfo, $pricelistinfo, $cardinfo, $brandinfo ) = + @_; + my ( $status, $count, $increment ); + $ASTPP->debug( debug => "Looking for outbound Route", verbosity => $verbosity ); + my @outboundroutes = &get_outbound_routes( $astpp_db, $destination,$cardinfo,$numberinfo, @resellerlist ); + $count = @outboundroutes; + if ( $count == 0 ) { + $ASTPP->debug(debug => "NO OUTBOUND ROUTES FOUND!", verbosity => $verbosity ); + my $order = $session->playAndGetDigits(1,1,1,$config->{calling_cards_general_input_timeout},"#*","$sound->{noanswer}","$sound->{noanswer}",'^[0-9]+$'); + if ( $order != 1 ) { + &write_cdr( $cardinfo, "", $destination, gettext("NO Route Found"), "", 0, 0 ); + &leave($cardinfo); + } + } + $count = 0; + foreach my $route (@outboundroutes) { + my $dialstring = $ASTPP->fs_dialplan_xml_bridge(); + my $callstart = localtime(); + my ($accountcode); + $callstart = &prettytimestamp if $cc == 1; + $session->execute->("sched_hangup","+" . $timelimit * 60); + my ($xml_string,$data_string) = $ASTPP->fs_dialplan_xml_bridge( + destination_number => $destination, + route_prepend => $route->{prepend}, + trunk_name => $route->{trunk} + ); + my $vars = $session->execute->("bridge",$data_string); +# return 1 if (! $session->ready()); +# $VARS{destination_number} = $num_dial; +# UPDATEV(); +# return 1; + my $asterisk_time = &prettytimestamp; + $ASTPP->debug( debug => "CALL STATUS $status", verbosity => 1); + $ASTPP->debug( debug => "ANSWERED TIME $answeredtime", verbosity => $verbosity); + $ASTPP->debug( debug => "Account CC?: $cc", verbosity => $verbosity); + if ( ( $status != ~/CHANUNAVAIL/ ) && ( $status != ~/CONGESTION/ ) ) { + if ( $status =~ /BUSY/ ) { + $ASTPP->debug( debug => "CALL BUSY", verbosity => $verbosity ); + my $order = $session->playAndGetDigits(1,1,1,$config->{calling_cards_general_input_timeout},"#*","$sound->{busy}","$sound->{busy}",'^[0-9]+$'); + if ( $order != 1 ) { + &write_cdr( $cardinfo, $clid, $destination, $status, + $callstart, 0, 0, $uniqueid ) + if $cc == 0; + &write_account_cdr( $astpp_db, $cardinfo->{number}, 0, + $destination, $callstart, 0, $uniqueid, $clid ) + if $cc == 1; + &write_asterisk_cdr( $accountcode, $clid, $destination, $status, + $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + &leave($cardinfo); + } else { + push @outboundroutes, $route; + } + } + elsif ( $status =~ /NOANSWER/ ) { + $ASTPP->debug(debug=> "NO ANSWER", verbosity => $verbosity ); + my $order = $session->playAndGetDigits(1,1,1,$config->{calling_cards_general_input_timeout},"#*","$sound->{noanswer}","$sound->{noanswer}",'^[0-9]+$'); + if ( $order != 1 ) { + &write_cdr( $cardinfo, $clid, $destination, $status, + $callstart, 0, 0, $uniqueid ) + if $cc == 0; + &write_account_cdr( $astpp_db, $cardinfo->{number}, 0, + $destination, $callstart, 0, $uniqueid, $clid ) + if $cc == 1; + &write_asterisk_cdr( $accountcode, $clid, $destination, $status, + $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + &leave($cardinfo); + } else { + push @outboundroutes, $route; + } + } + elsif ( $status =~ /ANSWER/ || $answeredtime > 0) { + $ASTPP->debug( debug => "CALL ANSWERED", verbosity => $verbosity ); + my $increment; + if ( $numberinfo->{inc} > 0 ) { + $increment = $numberinfo->{inc}; + } + else { + $increment = $pricelistinfo->{inc}; + } + $ASTPP->debug( debug => "$numberinfo->{connectcost}, $numberinfo->{cost}, $answeredtime, $increment, $numberinfo->{includedseconds}", + verbosity => $verbosity); + my $charge = &calc_call_cost( + $numberinfo->{connectcost}, $numberinfo->{cost}, + $answeredtime, $increment, + $numberinfo->{includedseconds} + ); + $ASTPP->debug( debug => "Cost $charge ", verbosity => $verbosity ); + if ($cardinfo->{minute_fee_pennies} > 0) { + $charge = (($cardinfo->{minute_fee_pennies} * 100) + $charge) if $cardinfo->{timeused} + $answeredtime => $cardinfo->{minute_fee_minutes}; + } + if ($cardinfo->{min_length_pennies} > 0 && ($cardinfo->{min_length_minutes}*60) > $answeredtime) { + $charge = (($cardinfo->{min_length_pennies} * 100) + $charge); + } + if ( $cc == 0 ) { + &write_cdr( + $cardinfo, $clid, $destination, $status, + $callstart, $charge, $answeredtime, $uniqueid + ); + &write_asterisk_cdr( $accountcode, $clid, $destination, "ANSWERED", + $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + &update_balance( $cardinfo, $charge ); + $astpp_db->do("UPDATE callingcards SET timeused = " + . $astpp_db->quote($cardinfo->{timeused} + $answeredtime) + . " WHERE cardnumber = " + . $astpp_db->quote($cardinfo->{cardnumber})); + } + elsif ( $cc == 1 ) { + my $status = + &write_account_cdr( $astpp_db, $cardinfo->{number}, + $charge, $destination, $callstart, $answeredtime, $uniqueid, $clid ); + &write_asterisk_cdr( $accountcode, $clid, $destination, $status, + $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + $ASTPP->debug( debug => $status, verbosity => $verbosity ); + } + $session->streamFile($sound->{call_completed}); + &leave($cardinfo); + } + elsif ( $status =~ /CANCEL/ ) { + $ASTPP->debug( debug => "CALL CANCELLED", verbosity => $verbosity ); + $session->streamFile($sound->{cancelled}) if $config->{calling_cards_cancelled_prompt} == 1; + &write_cdr( $cardinfo, $clid, $destination, $status, $callstart, 0, + 0, $uniqueid ) + if $cc == 0; + &write_account_cdr( $astpp_db, $cardinfo->{number}, 0, + $destination, $callstart, 0, $uniqueid, $clid ) + if $cc == 1; + &write_asterisk_cdr( $accountcode, $clid, $destination, $status, + $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + &leave($cardinfo); + } + else { + $ASTPP->debug( debug => "ERROR - ERROR - ERROR", verbosity => $verbosity ); + my $order = $session->playAndGetDigits(1,1,1,$config->{calling_cards_general_input_timeout},"#*","$sound->{noanswer}","$sound->{noanswer}",'^[0-9]+$'); + if ( $order != 1 ) { + &write_cdr( $cardinfo, $clid, $destination, $status, + $callstart, 0, 0, $uniqueid ) + if $cc == 0; + &write_account_cdr( $astpp_db, $cardinfo->{number}, 0, + $destination, $callstart, 0, $uniqueid, $clid ) + if $cc == 1; + &write_asterisk_cdr( $accountcode, $clid, $destination, $status, + $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + &leave($cardinfo); + } + } + } + } +} + sub leave() { # Prepare everything and then leave the calling card app. my ($cardinfo) = @_; my ($whatnow); @@ -539,18 +691,10 @@ # Congratulations, we now have a working card,pin, and phone number. $stats{destination} = $destination; -#&tell_cost( $numberinfo, $pricelistinfo, $cardinfo ); +&tell_cost( $numberinfo, $pricelistinfo, $cardinfo ); my $timelimit = &timelimit( $numberinfo, $pricelistinfo, $cardinfo, $destination ); $session->streamFile($sound->{please_wait_will_connect}) if $config->{calling_cards_connection_prompt} == 1; -#&dialout( $destination, $timelimit, $numberinfo, $pricelistinfo, $cardinfo, $brandinfo ); +&dialout( $destination, $timelimit, $numberinfo, $pricelistinfo, $cardinfo, $brandinfo ); - - - - - - - - 1; Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2009-02-21 18:36:58 UTC (rev 2236) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2009-02-21 19:43:05 UTC (rev 2237) @@ -131,7 +131,7 @@ # route_prepend = What do we tag on for numbers on this route? { my ($self, %arg) = @_; - my ( $sql, $trunkdata, $dialstring ); + my ( $sql, $trunkdata, $dialstring,$data ); $sql = $self->{_astpp_db}->prepare( "SELECT * FROM trunks WHERE name = " . $self->{_astpp_db}->quote( $arg{trunk_name} ) ); $sql->execute; @@ -151,19 +151,21 @@ } } if ( $trunkdata->{tech} eq "Zap" ) { - $dialstring = "<action application=\"bridge\" data=\"openzap/" . $trunkdata->{path} . "/1/" . $arg{route_prepend} . $arg{destination_number}. "\"/>\n"; - return $dialstring; + $dialstring = "<action application=\"bridge\" data=\"openzap/" . $trunkdata->{path} . "/1/" . $arg{route_prepend} . $arg{destination_number} . "\"/>\n"; + return $dialstring,$data; } elsif ( $trunkdata->{tech} eq "SIP" ) { my ($profile,$dest) = split(m/","/m, $trunkdata->{path}); $profile =~ s/"//g; #Strip off quotation marks $dest =~ s/"//g; #Strip off quotation marks if ($profile eq "gateway") { - $dialstring = "<action application=\"bridge\" data=\"sofia/gateway/" . $dest . "/" . $arg{route_prepend} . $arg{destination_number} . "\"/>\n"; + $data = "sofia/gateway/" . $dest . "/" . $arg{route_prepend} . $arg{destination_number}; + $dialstring = "<action application=\"bridge\" data=\"" . $data . "\"/>\n"; } else { - $dialstring = "<action application=\"bridge\" data=\"sofia/" . $profile . "/" . $arg{route_prepend} . $arg{destination_number} . "\@" . $dest . "\"/>\n"; + $data = "sofia/" . $profile . "/" . $arg{route_prepend} . $arg{destination_number} . "\@" . $dest; + $dialstring = "<action application=\"bridge\" data=\"" . $data . "\"/>\n"; } - return $dialstring; + return $dialstring,$data; } else { print STDERR "CANNOT ROUTE THIS CALL!!!!!\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-03-07 22:29:45
|
Revision: 2239 http://astpp.svn.sourceforge.net/astpp/?rev=2239&view=rev Author: darrenkw Date: 2009-03-07 22:29:40 +0000 (Sat, 07 Mar 2009) Log Message: ----------- More freeswitch corrections and a few minor fixes to the interface. Modified Paths: -------------- trunk/Makefile trunk/freeswitch/astpp-callingcards.pl trunk/web_interface/astpp-admin.cgi Modified: trunk/Makefile =================================================================== --- trunk/Makefile 2009-02-22 03:09:51 UTC (rev 2238) +++ trunk/Makefile 2009-03-07 22:29:40 UTC (rev 2239) @@ -13,6 +13,10 @@ ASTPPLOGDIR=/var/log/astpp/ EXTENSIONS=/etc/asterisk/extensions.conf LOCALE_DIR=/usr/local/share/locale + +FS_SOUNDSDIR=/usr/local/freeswitch/sounds/en/us/callie +FS_SCRIPTS=/usr/local/freeswitch/scripts + OWNER=root GROUP=wheel WWWDIR=/var/www @@ -80,6 +84,13 @@ install -m 644 $$x $(DESTDIR)$(SOUNDSDIR); \ done +install_sounds_fs: + for x in sounds/*.gsm; do \ + echo $$x;\ + install -m 644 $$x $(DESTDIR)$(FS_SOUNDSDIR); \ + done + + install_templates: for x in templates/*; do \ echo $$x;\ Modified: trunk/freeswitch/astpp-callingcards.pl =================================================================== --- trunk/freeswitch/astpp-callingcards.pl 2009-02-22 03:09:51 UTC (rev 2238) +++ trunk/freeswitch/astpp-callingcards.pl 2009-03-07 22:29:40 UTC (rev 2239) @@ -149,13 +149,13 @@ if ($config->{calling_cards_rate_announce} == 1) { if ( $numberinfo->{cost} > 0 ) { $session->streamFile($sound->{call_will_cost}); - $session->execute("phrase","pronounce," . ceil($numberinfo->{cost}/100)); + $session->execute("phrase","spell," . ceil($numberinfo->{cost}/100)); $session->streamFile($sound->{currency}); my @call_cost = split(/\./, ($numberinfo->{cost} / 100)); - $session->execute("phrase","pronounce," . @call_cost[0]); + $session->execute("phrase","spell," . @call_cost[0]); if (@call_cost[1]) { $session->streamFile($sound->{point}); - $session->execute("phrase","pronounce," . @call_cost[1]); + $session->execute("phrase","spell," . @call_cost[1]); $session->streamFile($sound->{sub_currency}); } $session->streamFile($sound->{per}); @@ -163,7 +163,7 @@ } if ( $numberinfo->{connectcost} > 0 ) { $session->streamFile($sound->{a_connect_charge}); - $session->execute("phrase","pronounce," . ceil($numberinfo->{connectcost}/100)); + $session->execute("phrase","spell," . ceil($numberinfo->{connectcost}/100)); $session->streamFile($sound->{sub_currency}); $session->streamFile($sound->{will_apply}); } @@ -243,11 +243,11 @@ $minutes = sprintf( "%.0f", $minutes ); $session->streamFile($sound->{call_will_last}); if ( $minutes == 1 ) { - $session->execute("phrase","pronounce," . $minutes); + $session->execute("phrase","spell," . $minutes); $session->streamFile($sound->{minute}); } elsif ( $minutes > 1 ) { - $session->execute("phrase","pronounce," . $minutes); + $session->execute("phrase","spell," . $minutes); $session->streamFile($sound->{minutes}); } } @@ -256,10 +256,6 @@ $session->streamFile($sound->{goodbye}); &leave($cardinfo); } - $maxtime = $timelimit * 1000; - - - $timelimit = "\|30\|HL($maxtime:60000:30000)\|Hgj"; $ASTPP->debug( debug => "Available: $available", verbosity => $verbosity ); $ASTPP->debug( debug => "Balance: $balance", verbosity => $verbosity ); @@ -284,19 +280,19 @@ my $interrupt = $session->playAndGetDigits(1,1,1,0,"#*","$sound->{card_has_balance_of}","$sound->{card_has_balance_of}",'^[0-9]+$'); if (!$interrupt || $interrupt eq "" || $interrupt == 0) { if ( $main_balance == 1 ) { -$session->execute("phrase","pronounce," . $main_balance); +$session->execute("phrase","spell," . $main_balance); $session->streamFile($sound->{main_currency}); } elsif ( $main_balance > 1 ) { -$session->execute("phrase","pronounce," . $main_balance); +$session->execute("phrase","spell," . $main_balance); $session->streamFile($sound->{main_currency_plural}); } if ( $sub_balance == 1 ) { -$session->execute("phrase","pronounce," . $sub_balance); +$session->execute("phrase","spell," . $sub_balance); $session->streamFile($sound->{sub_currency}); } elsif ( $sub_balance > 1 ) { -$session->execute("phrase","pronounce," . $sub_balance); +$session->execute("phrase","spell," . $sub_balance); $session->streamFile($sound->{sub_currency_plural}); } } @@ -389,17 +385,19 @@ } $count = 0; foreach my $route (@outboundroutes) { - my $dialstring = $ASTPP->fs_dialplan_xml_bridge(); my $callstart = localtime(); my ($accountcode); $callstart = &prettytimestamp if $cc == 1; - $session->execute->("sched_hangup","+" . $timelimit * 60); + $session->execute("sched_hangup","+" . $timelimit/1000*60); my ($xml_string,$data_string) = $ASTPP->fs_dialplan_xml_bridge( destination_number => $destination, route_prepend => $route->{prepend}, trunk_name => $route->{trunk} ); - my $vars = $session->execute->("bridge",$data_string); + my ($dialedtime,$uniqueid,$answeredtime,$clid); + my $vars = $session->execute("bridge","$data_string"); + + $ASTPP->debug( debug => "Vars: " . $vars); # return 1 if (! $session->ready()); # $VARS{destination_number} = $num_dial; # UPDATEV(); @@ -421,7 +419,7 @@ $destination, $callstart, 0, $uniqueid, $clid ) if $cc == 1; &write_asterisk_cdr( $accountcode, $clid, $destination, $status, - $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + $callstart, $answeredtime, $route->{trunk}, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); &leave($cardinfo); } else { push @outboundroutes, $route; @@ -438,7 +436,7 @@ $destination, $callstart, 0, $uniqueid, $clid ) if $cc == 1; &write_asterisk_cdr( $accountcode, $clid, $destination, $status, - $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + $callstart, $answeredtime, $route->{trunk}, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); &leave($cardinfo); } else { push @outboundroutes, $route; @@ -473,7 +471,7 @@ $callstart, $charge, $answeredtime, $uniqueid ); &write_asterisk_cdr( $accountcode, $clid, $destination, "ANSWERED", - $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + $callstart, $answeredtime, $route->{trunk}, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); &update_balance( $cardinfo, $charge ); $astpp_db->do("UPDATE callingcards SET timeused = " . $astpp_db->quote($cardinfo->{timeused} + $answeredtime) @@ -485,7 +483,7 @@ &write_account_cdr( $astpp_db, $cardinfo->{number}, $charge, $destination, $callstart, $answeredtime, $uniqueid, $clid ); &write_asterisk_cdr( $accountcode, $clid, $destination, $status, - $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + $callstart, $answeredtime, $route->{trunk}, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); $ASTPP->debug( debug => $status, verbosity => $verbosity ); } $session->streamFile($sound->{call_completed}); @@ -501,7 +499,7 @@ $destination, $callstart, 0, $uniqueid, $clid ) if $cc == 1; &write_asterisk_cdr( $accountcode, $clid, $destination, $status, - $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + $callstart, $answeredtime, $route->{trunk}, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); &leave($cardinfo); } else { @@ -515,7 +513,7 @@ $destination, $callstart, 0, $uniqueid, $clid ) if $cc == 1; &write_asterisk_cdr( $accountcode, $clid, $destination, $status, - $callstart, $answeredtime, $trunk, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); + $callstart, $answeredtime, $route->{trunk}, "CallingCards", $dialedtime, $uniqueid . "a", $asterisk_time, $cdr_db); &leave($cardinfo); } } @@ -671,7 +669,7 @@ } $retries = 0; while ( !$numberinfo->{pattern} && $retries < $config->{number_retries} ) { - $destination = $session->playAndGetDigits(4,999,1,$config->{calling_cards_dial_input_timeout},"#","$sound->{destination}","$sound->{destination}",'^[0-9]+$'); + $destination = $session->playAndGetDigits(4,35,1,$config->{calling_cards_dial_input_timeout},"#","$sound->{destination}","$sound->{destination}",'^[0-9]+$'); $numberinfo = &get_route( $astpp_db, $config, $destination, $brandinfo->{pricelist}, $cardinfo ); if ( !$numberinfo->{pattern} ) { Modified: trunk/web_interface/astpp-admin.cgi =================================================================== --- trunk/web_interface/astpp-admin.cgi 2009-02-22 03:09:51 UTC (rev 2238) +++ trunk/web_interface/astpp-admin.cgi 2009-03-07 22:29:40 UTC (rev 2239) @@ -2114,11 +2114,11 @@ ( $sql, $pagination ) = $ASTPP->pagination( sql_select => "SELECT * FROM cdrs WHERE cardnum =" . $astpp_db->quote( $accountinfo->{number} ) - . "and status IN (NULL, '', 0, 1)" + . "and ( status IS NULL OR status IN (0,1,''))" . " ORDER BY callstart DESC ", sql_count => "SELECT COUNT(*) FROM cdrs WHERE cardnum =" . $astpp_db->quote( $accountinfo->{number} ) - . "and status IN (NULL, '', 0, 1)", + . "and ( status IS NULL OR status IN (0,1,''))", results_per_page => $config->{results_per_page}, ve => $params->{ve}, te => $params->{ee}, @@ -2906,7 +2906,7 @@ } else { $tmp = -"SELECT name FROM callingcardbrands WHERE status < 2 AND reseller IN (NULL,'')"; +"SELECT name FROM callingcardbrands WHERE status < 2 AND (reseller IS NULL OR reseller = '')"; } $ASTPP->debug( user => $param->{username}, debug => $tmp ); $sql = $astpp_db->prepare($tmp); @@ -2928,7 +2928,7 @@ } else { $tmp = -"SELECT * FROM callingcardbrands WHERE status < 2 AND reseller IN (NULL,'') ORDER BY name limit $params->{limit} , $results_per_page"; +"SELECT * FROM callingcardbrands WHERE status < 2 AND (reseller IS NULL OR reseller = '') ORDER BY name limit $params->{limit} , $results_per_page"; } $ASTPP->debug( user => $param->{username}, debug => $tmp ); $sql = $astpp_db->prepare($tmp); @@ -3954,9 +3954,9 @@ ); my $sql_select = -"SELECT * FROM cdr WHERE cost IN( 'error','rating') OR accountcode IN (NULL,'') AND cost ='none' ORDER BY calldate"; +"SELECT * FROM cdr WHERE cost IN( 'error','rating') OR (accountcode IS NULL OR accountcode = '') AND cost ='none' ORDER BY calldate"; my $sql_count = -"SELECT COUNT(*) FROM cdr WHERE cost IN ( 'error','rating') OR accountcode IN (NULL,'') AND cost ='none'"; +"SELECT COUNT(*) FROM cdr WHERE cost IN ( 'error','rating') OR (accountcode IS NULL OR accountcode = '') AND cost ='none'"; my ( $sql, $pagination ) = $ASTPP->pagination( sql_select => $sql_select, @@ -6347,16 +6347,18 @@ $ASTPP->debug( user => $param->{username}, debug => $tmp ); } $tmp = -"INSERT INTO routes (pattern,comment,pricelist,connectcost,includedseconds,cost) VALUES (" +"INSERT INTO routes (pattern,comment,pricelist,connectcost,includedseconds,cost,inc,reseller) VALUES (" . $astpp_db->quote( "^" . $params->{number} . "\$" ) . "," - . $astpp_db->quote( $params->{country} . "," + . $astpp_db->quote("DID: " . $params->{country} . "," . $params->{province} . "," . $params->{city} ) . "," . $astpp_db->quote( $config->{default_brand} ) . "," . $astpp_db->quote( $params->{connectcost} ) . "," . $astpp_db->quote( $params->{included} ) . "," - . $astpp_db->quote( $params->{cost} ) . ")"; + . $astpp_db->quote( $params->{cost} ) . "," + . $astpp_db->quote( $params->{inc} ) . ",'')"; + $ASTPP->debug( user => $param->{username}, debug => $tmp ); if ( $astpp_db->do($tmp) ) { $status .= gettext("Pattern") . " '" @@ -6430,10 +6432,9 @@ $tmp = "UPDATE routes SET" . " comment = " - . $astpp_db->quote( $params->{country} . "," - . $params->{province} . "," - . $params->{city} ) - . "," + . $astpp_db->quote("DID: " . $params->{country} . "," + . $params->{province} . "," + . $params->{city} ) . "," . " pricelist=" . $astpp_db->quote( $config->{default_brand} ) . "," . " connectcost=" @@ -6441,9 +6442,13 @@ . " includedseconds=" . $astpp_db->quote( $params->{included} ) . "," . " cost=" - . $astpp_db->quote( $params->{cost} ) + . $astpp_db->quote( $params->{cost} ) . "," + . " inc=" + . $astpp_db->quote( $params->{inc} ) . "," + . " status=1" . " WHERE pattern = " . $astpp_db->quote( "^" . $params->{number} . "\$" ); + $ASTPP->debug( user => $param->{username}, debug => $tmp ); if ( $astpp_db->do($tmp) ) { $status .= gettext("Pattern") . " '" @@ -6490,8 +6495,7 @@ "<table class=\"default\">" . "<tr class=\"header\"><td colspan=12>" . gettext("All costs are in 1/100 of a penny") - . "</td></tr> -" + . "</td></tr>" . "<tr class=\"header\"><td>" . hidden( -name => 'mode', -value => gettext("Manage DIDs") ) . gettext("Number") @@ -7906,7 +7910,7 @@ "; if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { $tmp = - "SELECT * FROM routes WHERE status < 2 AND reseller IN (NULL,'')" + "SELECT * FROM routes WHERE status < 2 AND (reseller IS NULL OR reseller = '')" . " AND pricelist = " . $astpp_db->quote( $params->{username} ) . " UNION SELECT * FROM routes WHERE status < 2 " @@ -7915,7 +7919,7 @@ } else { $tmp = - "SELECT * FROM routes WHERE status < 2 AND reseller IN (NULL,'')"; + "SELECT * FROM routes WHERE status < 2 AND ( reseller IS NULL OR reseller = '' )"; } $ASTPP->debug( user => $param->{username}, debug => $tmp ); $sql = $astpp_db->prepare($tmp); @@ -7930,7 +7934,7 @@ if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { $sql = $astpp_db->prepare( -"SELECT * FROM routes WHERE reseller IN (NULL,'') AND pricelist = " +"SELECT * FROM routes WHERE ( reseller IS NULL OR reseller = '') AND pricelist = " . $astpp_db->quote( $params->{username} ) . " UNION SELECT * FROM routes WHERE status < 2 " . " AND reseller = " @@ -7940,7 +7944,7 @@ } else { $sql = $astpp_db->prepare( -"SELECT * FROM routes WHERE reseller IN (NULL,'') AND status < 2 ORDER BY comment limit $params->{limit} , $results_per_page" +"SELECT * FROM routes WHERE ( reseller IS NULL OR reseller = '') AND status < 2 ORDER BY comment limit $params->{limit} , $results_per_page" ); } $sql->execute This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-03-07 22:38:31
|
Revision: 2240 http://astpp.svn.sourceforge.net/astpp/?rev=2240&view=rev Author: darrenkw Date: 2009-03-07 22:38:22 +0000 (Sat, 07 Mar 2009) Log Message: ----------- Corrected freeswitch bridging code after adding support for returning the routing information in several formats. Modified Paths: -------------- trunk/freeswitch/astpp-fs-xml.pl trunk/modules/ASTPP/lib/ASTPP.pm Modified: trunk/freeswitch/astpp-fs-xml.pl =================================================================== --- trunk/freeswitch/astpp-fs-xml.pl 2009-03-07 22:29:40 UTC (rev 2239) +++ trunk/freeswitch/astpp-fs-xml.pl 2009-03-07 22:38:22 UTC (rev 2240) @@ -244,11 +244,12 @@ ); } else { - $xml .= $ASTPP->fs_dialplan_xml_bridge( + my ($returned_data,$junk) = $ASTPP->fs_dialplan_xml_bridge( destination_number => $params->{'Caller-Destination-Number'}, route_prepend => $route->{prepend}, trunk_name => $route->{trunk} ); + $xml .= $returned_data; } } } Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2009-03-07 22:29:40 UTC (rev 2239) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2009-03-07 22:38:22 UTC (rev 2240) @@ -152,7 +152,7 @@ } if ( $trunkdata->{tech} eq "Zap" ) { $dialstring = "<action application=\"bridge\" data=\"openzap/" . $trunkdata->{path} . "/1/" . $arg{route_prepend} . $arg{destination_number} . "\"/>\n"; - return $dialstring,$data; + return ($dialstring,$data); } elsif ( $trunkdata->{tech} eq "SIP" ) { my ($profile,$dest) = split(m/","/m, $trunkdata->{path}); @@ -165,7 +165,7 @@ $data = "sofia/" . $profile . "/" . $arg{route_prepend} . $arg{destination_number} . "\@" . $dest; $dialstring = "<action application=\"bridge\" data=\"" . $data . "\"/>\n"; } - return $dialstring,$data; + return ($dialstring,$data); } else { print STDERR "CANNOT ROUTE THIS CALL!!!!!\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-03-11 02:47:25
|
Revision: 2242 http://astpp.svn.sourceforge.net/astpp/?rev=2242&view=rev Author: darrenkw Date: 2009-03-11 02:46:52 +0000 (Wed, 11 Mar 2009) Log Message: ----------- Added Freeswitch DID support. Modified Paths: -------------- trunk/freeswitch/astpp-fs-xml.pl trunk/modules/ASTPP/lib/ASTPP.pm Modified: trunk/freeswitch/astpp-fs-xml.pl =================================================================== --- trunk/freeswitch/astpp-fs-xml.pl 2009-03-10 00:52:26 UTC (rev 2241) +++ trunk/freeswitch/astpp-fs-xml.pl 2009-03-11 02:46:52 UTC (rev 2242) @@ -53,19 +53,21 @@ debug => "Destination = $params->{'Caller-Destination-Number'}" ); if ( $params->{section} eq "dialplan" ) { - $xml = $ASTPP->fs_dialplan_xml_header( - xml => $xml, - destination_number => $params->{'Caller-Destination-Number'} - ); - -# Check to see if this is a DID. If it is we handle it differently. -# + # Check to see if this is a DID. If it is we handle it differently. + # $didinfo = &get_did($astpp_db, $params->{'Caller-Destination-Number'}); if ($didinfo->{number}) { $astppdid = "ASTPP-DID"; $ASTPP->debug( debug => "This is a call for a DID: "); $params->{variable_accountcode} = $didinfo->{account}; } + + $xml = $ASTPP->fs_dialplan_xml_header( + xml => $xml, + destination_number => $params->{'Caller-Destination-Number'}, + DID => $didinfo->{number} + ); + @@ -113,7 +115,9 @@ $xml .= "<action application=\"reject\" data=\"CANNOT RETRIEVE ACCOUNT\"/>\n"; $xml = $ASTPP->fs_dialplan_xml_footer( xml => $xml ); - print $xml; +# print $xml; + $ASTPP->debug( debug => "Returning nothing so dialplan can continue." ); + print ""; exit(0); } @@ -228,8 +232,12 @@ $carddata->{pricelist}, $carddata, $astppdid ); - if ($astppdid > 0 ) { + if ($didinfo->{number} ) { $ASTPP->debug( debug => "THIS IS A DID CALL: $xml"); + my ($returned_data) = $ASTPP->fs_dialplan_xml_did( + did => $params->{'Caller-Destination-Number'} + ); + $xml .= $returned_data; } else { # Get the list of routes for the phone number. my @outboundroutes = Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2009-03-10 00:52:26 UTC (rev 2241) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2009-03-11 02:46:52 UTC (rev 2242) @@ -109,7 +109,11 @@ $arg{xml} .= "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"; $arg{xml} .= "<document type=\"freeswitch/xml\">\n"; $arg{xml} .= "<section name=\"dialplan\" description=\"ASTPP Dynamic Routing\">\n"; + if ($arg{DID} > 0) { + $arg{xml} .= "<context name=\"public\">\n"; + } else { $arg{xml} .= "<context name=\"default\">\n"; + }; $arg{xml} .= "<extension name=\"" . $arg{destination_number} . "\">\n"; $arg{xml} .= "<condition field=\"destination_number\" expression=\"" . $arg{destination_number} . "\">\n"; return $arg{xml}; @@ -123,6 +127,22 @@ return $arg{xml}; } +sub fs_dialplan_xml_did +# Return the dialplan code for an incoming call to a DID. +{ + my ($self, %arg) = @_; + my ( $sql, $trunkdata, $dialstring,$data ); + my $tmp = "SELECT * FROM dids WHERE number = " + . $self->{_astpp_db}->quote( $arg{did} ) . + " LIMIT 1"; + print STDERR $tmp; + $sql = $self->{_astpp_db}->prepare($tmp); + $sql->execute; + my $diddata = $sql->fetchrow_hashref; + $sql->finish; + return $diddata->{variables}; +} + sub fs_dialplan_xml_bridge #Return the bridge command along with details. This is only called if a call is approved. # Requires the following variables: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-03-18 23:25:19
|
Revision: 2243 http://astpp.svn.sourceforge.net/astpp/?rev=2243&view=rev Author: darrenkw Date: 2009-03-18 23:25:11 +0000 (Wed, 18 Mar 2009) Log Message: ----------- Update code to allow authentication by ip address. Modified Paths: -------------- trunk/Makefile trunk/freeswitch/astpp-fs-xml.pl trunk/modules/ASTPP/lib/ASTPP.pm Modified: trunk/Makefile =================================================================== --- trunk/Makefile 2009-03-11 02:46:52 UTC (rev 2242) +++ trunk/Makefile 2009-03-18 23:25:11 UTC (rev 2243) @@ -18,7 +18,7 @@ FS_SCRIPTS=/usr/local/freeswitch/scripts OWNER=root -GROUP=wheel +GROUP=root WWWDIR=/var/www all: install Modified: trunk/freeswitch/astpp-fs-xml.pl =================================================================== --- trunk/freeswitch/astpp-fs-xml.pl 2009-03-11 02:46:52 UTC (rev 2242) +++ trunk/freeswitch/astpp-fs-xml.pl 2009-03-18 23:25:11 UTC (rev 2243) @@ -89,9 +89,9 @@ } if ( !$params->{variable_accountcode} ) { $ASTPP->debug( - debug => "Checking IP Address:" . $params->{network_addr} ); + debug => "Checking IP Address:" . $params->{'Hunt-Network-Addr'} ); my $ip_data = $ASTPP->ip_address_authenticate( - ip_address => $params->{network_addr}, + ip_address => $params->{'Hunt-Network-Addr'}, destination => $params->{'Caller-Destination-Number'} ); if ($ip_data) { @@ -218,7 +218,8 @@ $xml = $ASTPP->fs_dialplan_xml_timelimit( xml => $xml, - max_length => $maxlength + max_length => $maxlength, + accountcode => $carddata->{number} ); # Set the timelimit as well as other variables which are needed in the dialplan. Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2009-03-11 02:46:52 UTC (rev 2242) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2009-03-18 23:25:11 UTC (rev 2243) @@ -95,6 +95,7 @@ . " AND prefix IN (NULL,'') OR ip = " . $self->{_astpp_db}->quote($arg{ip_address}); $tmp .= " AND " . $self->{_astpp_db}->quote($arg{destination}) . " RLIKE prefix" if $arg{destination}; $tmp .= " ORDER BY LENGTH(prefix) DESC LIMIT 1"; + print STDERR $tmp; $sql = $self->{_astpp_db}->prepare($tmp); $sql->execute; my $anidata = $sql->fetchrow_hashref; @@ -124,6 +125,7 @@ { my ($self, %arg) = @_; $arg{xml} .= "<action application=\"sched_hangup\" data=\"+" . $arg{max_length} * 60 . "\"/>\n"; + $arg{xml} .= "<action application=\"set\" data=\"accountcode=" . $arg{accountcode} . "\"/>\n"; return $arg{xml}; } @@ -258,11 +260,11 @@ $tmp .= " AND domain = " . $self->{_freeswitch_db}->quote($arg{domain}); } - } else { - if ($arg{domain}) { - $tmp .= " WHERE domain = " - . $self->{_freeswitch_db}->quote($arg{domain}); - } +# } else { +# if ($arg{domain}) { +# $tmp .= " WHERE domain = " +# . $self->{_freeswitch_db}->quote($arg{domain}); +# } } } print STDERR $tmp; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-03-23 14:18:58
|
Revision: 2244 http://astpp.svn.sourceforge.net/astpp/?rev=2244&view=rev Author: darrenkw Date: 2009-03-23 14:18:45 +0000 (Mon, 23 Mar 2009) Log Message: ----------- More updates to the FreeSwitch support. Modified Paths: -------------- trunk/scripts/astpp-common.pl Added Paths: ----------- trunk/sql/astpp-2009-03-18.sql Modified: trunk/scripts/astpp-common.pl =================================================================== --- trunk/scripts/astpp-common.pl 2009-03-18 23:25:11 UTC (rev 2243) +++ trunk/scripts/astpp-common.pl 2009-03-23 14:18:45 UTC (rev 2244) @@ -4208,7 +4208,8 @@ print STDERR "----------------------\n"; if(!$vars) { my $tmp = "UPDATE $config->{asterisk_cdr_table} SET cost = 'error' WHERE uniqueid = " - . $uniqueid . " AND cost = 'rating' LIMIT 1"; + . $cdr_db->quote($uniqueid) + . " AND cost = 'rating' LIMIT 1"; $cdr_db->do($tmp); } else { $cdrinfo->{cost} = 'error'; @@ -4225,7 +4226,8 @@ print STDERR "----------------------\n"; if(!$vars) { my $tmp = "UPDATE $config->{asterisk_cdr_table} SET cost = 'none' WHERE uniqueid = " - . $uniqueid . " AND cost = 'rating' LIMIT 1"; + . $cdr_db->quote($uniqueid) + . " AND cost = 'rating' LIMIT 1"; $cdr_db->do($tmp); } else { $cdrinfo->{cost} = 'none'; Added: trunk/sql/astpp-2009-03-18.sql =================================================================== --- trunk/sql/astpp-2009-03-18.sql (rev 0) +++ trunk/sql/astpp-2009-03-18.sql 2009-03-23 14:18:45 UTC (rev 2244) @@ -0,0 +1,1319 @@ +DROP TABLE IF EXISTS `routes`; +CREATE TABLE routes ( +id INTEGER NOT NULL AUTO_INCREMENT, +pattern CHAR(40), +comment CHAR(80), +connectcost INTEGER NOT NULL, +includedseconds INTEGER NOT NULL, +cost INTEGER NOT NULL, +pricelist CHAR(80), +inc INTEGER, +reseller CHAR(50) default NULL, +precedence INT(4) NOT NULL DEFAULT 0, +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`), +KEY `pattern` (`pattern`), +KEY `pricelist` (`pricelist`), +KEY `reseller` (`reseller`), +KEY `status` (`status`) +); + +DROP TABLE IF EXISTS `pricelists`; +CREATE TABLE pricelists ( +name CHAR(40) NOT NULL, +markup INTEGER NOT NULL DEFAULT 0, +inc INTEGER NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +reseller CHAR(50) default NULL, +PRIMARY KEY (`name`) +); + +DROP TABLE IF EXISTS `callingcardbrands`; +CREATE TABLE callingcardbrands ( +name CHAR(40) NOT NULL, +reseller CHAR(40) NOT NULL DEFAULT '', +language CHAR(10) NOT NULL DEFAULT '', +pricelist CHAR(40) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +validfordays CHAR(4) NOT NULL DEFAULT '', +pin INTEGER NOT NULL DEFAULT 0, +maint_fee_pennies INTEGER NOT NULL DEFAULT 0, +maint_fee_days INTEGER NOT NULL DEFAULT 0, +disconnect_fee_pennies INTEGER NOT NULL DEFAULT 0, +minute_fee_minutes INTEGER NOT NULL DEFAULT 0, +minute_fee_pennies INTEGER NOT NULL DEFAULT 0, +min_length_minutes INTEGER NOT NULL DEFAULT 0, +min_length_pennies INTEGER NOT NULL DEFAULT 0, +PRIMARY KEY (`name`), + KEY `reseller` (`reseller`), + KEY `pricelist` (`pricelist`) +); + +DROP TABLE IF EXISTS `callingcardcdrs`; +CREATE TABLE callingcardcdrs ( +id INTEGER NOT NULL AUTO_INCREMENT, +cardnumber CHAR(50) NOT NULL DEFAULT '', +clid CHAR(80) NOT NULL DEFAULT '', +destination CHAR(40) NOT NULL DEFAULT '', +disposition CHAR(20)NOT NULL DEFAULT '', +callstart CHAR(40) NOT NULL DEFAULT '', +seconds INTEGER NOT NULL DEFAULT 0, +debit DECIMAL(20,6) NOT NULL DEFAULT 0.00000, +credit DECIMAL(20,6) NOT NULL DEFAULT 0.00000, +status INTEGER DEFAULT 0 NOT NULL, +uniqueid VARCHAR(32) NOT NULL DEFAULT '', +notes CHAR(80) NOT NULL DEFAULT '', +pricelist CHAR(80) NOT NULL DEFAULT '', +pattern CHAR(80) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + KEY `cardnumber` (`cardnumber`) +); + +DROP TABLE IF EXISTS `trunks`; +CREATE TABLE trunks ( +name VARCHAR(30) NOT NULL, +tech CHAR(10) NOT NULL DEFAULT '', +path CHAR(40) NOT NULL DEFAULT '', +provider CHAR(100) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +dialed_modify TEXT NOT NULL DEFAULT '', +resellers TEXT NOT NULL DEFAULT '', +precedence INT(4) NOT NULL DEFAULT 0, +maxchannels INTEGER DEFAULT 0 NOT NULL, + PRIMARY KEY (`name`), + KEY `provider` (`provider`), + KEY `provider_2` (`provider`) +); + +DROP TABLE IF EXISTS `outbound_routes`; +CREATE TABLE outbound_routes ( +pattern CHAR(40), +id INTEGER NOT NULL AUTO_INCREMENT, +comment CHAR(80) NOT NULL DEFAULT '', +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +trunk CHAR(80) NOT NULL DEFAULT '', +inc CHAR(10) NOT NULL DEFAULT '', +strip CHAR(40) NOT NULL DEFAULT '', +prepend CHAR(40) NOT NULL DEFAULT '', +precedence INT(4) NOT NULL DEFAULT 0, +resellers TEXT NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `trunk` (`trunk`), + KEY `pattern` (`pattern`) +); + +DROP TABLE IF EXISTS `dids`; +CREATE TABLE dids ( +number CHAR(40) NOT NULL, +account CHAR(50) NOT NULL DEFAULT '', +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +monthlycost INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +inc CHAR(10) NOT NULL DEFAULT '', +extensions CHAR(180) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +provider CHAR(40) NOT NULL DEFAULT '', +country CHAR (80)NOT NULL DEFAULT '', +province CHAR (80) NOT NULL DEFAULT '', +city CHAR (80) NOT NULL DEFAULT '', +prorate int(1) NOT NULL default 0, +setup int(11) NOT NULL default 0, +limittime int(1) NOT NULL default 1, +disconnectionfee INT(11) NOT NULL default 0, +variables TEXT NOT NULL DEFAULT '', +options varchar(40) default NULL, +maxchannels int(4) NOT NULL default 0, +chargeonallocation int(1) NOT NULL default 1, +allocation_bill_status int(1) NOT NULL default 0, +dial_as CHAR(40) NOT NULL DEFAULT '', +PRIMARY KEY (`number`), + KEY `account` (`account`) +); + +DROP TABLE IF EXISTS `accounts`; +CREATE TABLE accounts ( +cc CHAR(20) NOT NULL DEFAULT '', +number CHAR(50) NOT NULL, +reseller CHAR(40) NOT NULL DEFAULT '', +pricelist CHAR(24) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +credit INTEGER NOT NULL DEFAULT 0, +sweep INTEGER NOT NULL DEFAULT 0, +creation TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, +pin INTEGER NOT NULL DEFAULT 0, +credit_limit INTEGER NOT NULL DEFAULT 0, +posttoexternal INTEGER NOT NULL DEFAULT 0, +balance DECIMAL(20,6) NOT NULL DEFAULT 0, +password CHAR(80) NOT NULL DEFAULT '', +first_name CHAR(40) NOT NULL DEFAULT '', +middle_name CHAR(40) NOT NULL DEFAULT '', +last_name CHAR(40) NOT NULL DEFAULT '', +company_name CHAR(40) NOT NULL DEFAULT '', +address_1 CHAR(80) NOT NULL DEFAULT '', +address_2 CHAR(80) NOT NULL DEFAULT '', +address_3 CHAR(80) NOT NULL DEFAULT '', +postal_code CHAR(12) NOT NULL DEFAULT '', +province CHAR(40) NOT NULL DEFAULT '', +city CHAR(80) NOT NULL DEFAULT '', +country CHAR(40) NOT NULL DEFAULT '', +telephone_1 CHAR(40) NOT NULL DEFAULT '', +telephone_2 CHAR(40) NOT NULL DEFAULT '', +fascimile CHAR(40) NOT NULL DEFAULT '', +email CHAR(80) NOT NULL DEFAULT '', +language CHAR(2) NOT NULL DEFAULT '', +currency CHAR(3) NOT NULL DEFAULT '', +maxchannels INTEGER DEFAULT 1 NOT NULL, +routing_technique INT(4) NOT NULL DEFAULT 0, +dialed_modify TEXT NOT NULL DEFAULT '', +type INTEGER DEFAULT 0, +tz CHAR(40) NOT NULL DEFAULT '', +PRIMARY KEY (`number`), + KEY `pricelist` (`pricelist`), + KEY `reseller` (`reseller`) +); + +DROP TABLE IF EXISTS `counters`; +CREATE TABLE counters ( +id INTEGER NOT NULL AUTO_INCREMENT, +package CHAR(40) NOT NULL DEFAULT '', +account VARCHAR(50) NOT NULL, +seconds INTEGER NOT NULL DEFAULT 0, +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`) +); + +DROP TABLE IF EXISTS `callingcards`; +CREATE TABLE callingcards ( +id INTEGER NOT NULL AUTO_INCREMENT, +cardnumber CHAR(20) NOT NULL DEFAULT '', +language CHAR(10) NOT NULL DEFAULT '', +value INTEGER NOT NULL DEFAULT 0, +used INTEGER NOT NULL DEFAULT 0, +brand VARCHAR(20) NOT NULL DEFAULT '', +created DATETIME, +firstused DATETIME, +expiry DATETIME, +validfordays CHAR(4) NOT NULL DEFAULT '', +inuse INTEGER NOT NULL DEFAULT 0, +pin CHAR(20), +account VARCHAR(50) NOT NULL DEFAULT '', +maint_fee_pennies INTEGER NOT NULL DEFAULT 0, +maint_fee_days INTEGER NOT NULL DEFAULT 0, +maint_day INTEGER NOT NULL DEFAULT 0, +disconnect_fee_pennies INTEGER NOT NULL DEFAULT 0, +minute_fee_minutes INTEGER NOT NULL DEFAULT 0, +minute_fee_pennies INTEGER NOT NULL DEFAULT 0, +min_length_minutes INTEGER NOT NULL DEFAULT 0, +min_length_pennies INTEGER NOT NULL DEFAULT 0, +timeused INTEGER NOT NULL DEFAULT 0, +invoice CHAR(20) NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `brand` (`brand`) +); + +CREATE TABLE charge_to_account ( +id INTEGER NOT NULL AUTO_INCREMENT, +charge_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(50) NOT NULL DEFAULT '', +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`) +); + +CREATE TABLE queue_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +queue_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE pbx_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +pbx_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE extension_list ( +id INTEGER NOT NULL AUTO_INCREMENT, +extension_id INTEGER NOT NULL DEFAULT 0, +cardnum CHAR(20) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE cdrs ( +id INTEGER NOT NULL AUTO_INCREMENT, +uniqueid varchar(32) NOT NULL DEFAULT '', +cardnum CHAR(50), +callerid CHAR(80), +callednum varchar(80) NOT NULL DEFAULT '', +billseconds INT DEFAULT 0 NOT NULL, +trunk VARCHAR(30), +disposition varchar(45) NOT NULL DEFAULT '', +callstart varchar(80) NOT NULL DEFAULT '', +debit DECIMAL (20,6) NOT NULL DEFAULT 0, +credit DECIMAL (20,6) NOT NULL DEFAULT 0, +status INTEGER DEFAULT 0 NOT NULL, +notes CHAR(80), +provider CHAR(50), +cost DECIMAL(20,6) NOT NULL DEFAULT 0, +pricelist CHAR(80) NOT NULL DEFAULT '', +pattern CHAR(80) NOT NULL DEFAULT '', +PRIMARY KEY (`id`), + KEY `cardnum` (`cardnum`), + KEY `provider` (`provider`), + KEY `trunk` (`trunk`), + KEY `uniqueid` (`uniqueid`), + KEY `status` (`status`) +); + +CREATE TABLE packages ( +id INTEGER NOT NULL AUTO_INCREMENT, +name CHAR(40) NOT NULL DEFAULT '', +pricelist CHAR(40) NOT NULL DEFAULT '', +pattern CHAR(40) NOT NULL DEFAULT '', +includedseconds INTEGER NOT NULL DEFAULT 0, +reseller VARCHAR(50) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), + KEY `pricelist` (`pricelist`), + KEY `reseller` (`reseller`) +); + +CREATE TABLE ani_map ( +number char(20) NOT NULL, +account char(50) NOT NULL default '', +status int(11) NOT NULL default '0', +context varchar(20) NOT NULL, + PRIMARY KEY (`number`), +KEY `account` (`account`) +); + +CREATE TABLE `ip_map` ( +ip char(15) NOT NULL default '', +account char(20) NOT NULL default '', +prefix varchar(20) NULL, +context varchar(20) NOT NULL, +PRIMARY KEY (`ip`,`prefix`), +KEY `account` (`account`) +); + +CREATE TABLE charges ( +id INTEGER NOT NULL AUTO_INCREMENT, +pricelist CHAR(40) NOT NULL DEFAULT '', +description VARCHAR(80) NOT NULL DEFAULT '', +charge INTEGER NOT NULL DEFAULT 0, +sweep INTEGER NOT NULL DEFAULT 0, +reseller CHAR(40) NOT NULL DEFAULT '', +status INTEGER NOT NULL DEFAULT 1, +PRIMARY KEY (`id`), + KEY `pricelist` (`pricelist`) +); + +CREATE TABLE manager_action_variables ( +id INTEGER NOT NULL AUTO_INCREMENT, +name CHAR(60) NOT NULL DEFAULT '', +value CHAR(60) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE callingcard_stats ( +uniqueid VARCHAR(48) NOT NULL, +total_time VARCHAR(48) NOT NULL, +billable_time VARCHAR(48) NOT NULL, +timestamp DATETIME NULL, +PRIMARY KEY (`uniqueid`) +); + +CREATE TABLE system ( +name VARCHAR(48) NULL, +value VARCHAR(255) NULL, +comment VARCHAR(255) NULL, +timestamp DATETIME NULL, +reseller VARCHAR(48) NULL, +brand VARCHAR(48) NULL, +PRIMARY KEY (`name`), + KEY `reseller` (`reseller`), + KEY `brand` (`brand`) +); + + +INSERT INTO system (name, value, comment) VALUES ( +'callout_accountcode','admin','Call Files: What accountcode should we use?'); + +INSERT INTO system (name, value, comment) VALUES ( +'lcrcontext','astpp-outgoing','This is the Local context we use to route our outgoing calls through esp for callbacks'); + +INSERT INTO system (name, value, comment) VALUES ( +'maxretries','3','Call Files: How many times do we retry?'); + +INSERT INTO system (name, value, comment) VALUES ( +'retrytime','30','Call Files: How long do we wait between retries?'); + +INSERT INTO system (name, value, comment) VALUES ( +'waittime','15','Call Files: How long do we wait before the initial call?'); + +INSERT INTO system (name, value, comment) VALUES ( +'clidname','Private','Call Files: Outgoing CallerID Name'); + +INSERT INTO system (name, value, comment) VALUES ( +'clidnumber','0000000000','Call Files: Outgoing CallerID Number'); + +INSERT INTO system (name, value, comment) VALUES ( +'callingcards_callback_context','astpp-callingcards','Call Files: For callingcards what context do we end up in?'); + +INSERT INTO system (name, value, comment) VALUES ( +'callingcards_callback_extension', 's','Call Files: For callingcards what extension do we use?'); + +INSERT INTO system (name, value, comment) VALUES ( +'openser_dbengine', 'MySQL','For now this must be MySQL'); + +INSERT INTO system (name, value, comment) VALUES ( +'openser', '0','Use OPENSER? 1 for yes or 0 for no'); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbname', 'openser','OPENSER Database Name', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbuser', 'root','OPENSER Database User', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbhost', 'localhost','OPENSER Database Host', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_dbpass', 'Passw0rd','OPENSER Database Password', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'openser_domain', NULL,'OPENSER Domain', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_email', 'em...@as...','Email address that email should appear to be from', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'asterisk_dir', '/etc/asterisk','Which directory are asterisk configuration files stored in?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_website', 'http://www.astpp.org','Link to your company website', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_name', 'ASTPP.ORG','The name of your company. Used in emails.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'email', '1','Send out email? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'user_email', '1','Email user on account changes? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'debug', '0','Enable debugging output? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'emailadd', 'em...@as...','Administrator email address', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'startingdigit', '0','The digit that all calling cards must start with. 0=disabled', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'enablelcr', '1','Use least cost routing 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'log_file', '/var/log/astpp/astpp.log','ASTPP Log file', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'key_home', 'http://www.astpp.org/astpp.pub','Asterisk RSA Key location (optional)', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rate_engine_csv_file', '/var/log/astpp/astpp.csv','CSV File for call rating data', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'csv_dir', '/var/log/astpp/','CSV File Directory', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_brand', 'default','Default pricelist. If a price is not found in the customers pricelist we check this one.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'new_user_brand', 'default','What is the default pricelist for new customers?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_context', 'custom-astpp','What is the default context for new devices?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cardlength', '10','Number of digits in calling cards and cc codes.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'asterisk_server', 'voip.astpp.org','Your default voip server. Used in outgoing email.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'currency', 'CAD','Name of the currency you use', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'iax_port', '4569','Default IAX2 Port', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'sip_port', '5060','Default SIP Port', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'ipaddr', 'dynamic','Default IP Address for new devices', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'key', 'astpp.pub','Asterisk RSA Key Name (Optional)', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'pinlength', '6','For those calling cards that are using pins this is the number of digits it will have.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'credit_limit', '0','Default credit limit in dollars.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'decimalpoints', '4','How many decimal points do we bill to?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'decimalpoints_tax', '2','How many decimal points do we calculate taxes to?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'decimalpoints_total', '2','How many decimal points do we calculate totals to?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'max_free_length', '100','What is the maximum length (in minutes) of calls that are at no charge?', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'trackvendorcharges', '1','Do we track the amount of money we spend with specific providers? 0=no 1=yes', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_logo', 'http://www.astpp.org/logo.png','The location of our company logo.', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'company_slogan', 'Welcome to ASTPP','Company slogan', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'version', '1.5Beta', 'ASTPP Version', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'default_language', 'en', 'Default ASTPP Language',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'card_retries','3', 'How many retries do we allow for calling card numbers?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'pin_retries','3', 'How many retries do we allow for pins?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'number_retries','3','How many retries do we allow calling card users when dialing a number?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'booth_context','callshop_booth','Please enter the default context for a callshop booth.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'callingcards_max_length','9000','What is the maximum length (in ms) of a callingcard call?',''); + +INSERT INTO system (name,value,comment,timestamp) VALUES ( +'template_die_on_bad_params','0','Should HTML::Template die on bad parameters?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'results_per_page','30','How many results per page do we should in the web interface?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astpp_dir','/var/lib/astpp','Where do the astpp configs live?',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'auth','Passw0rd!','This is the override authorization code and will allow access to the system.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_dbengine','MySQL','Database type for Asterisk(tm) -Realtime',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbengine','MySQL','Database type for the cdr database',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_dbengine','MySQL','Database type for OSCommerce',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_dbengine','MySQL','Database type for AgileBill(tm)',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_dbengine','MySQL','Database type for FreePBX',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'externalbill','oscommerce','Please specify the external billing application to use. If you are not using any then leave it blank. Valid options are "agile" and "oscommerce".',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'callingcards','1','Do you wish to enable calling cards? 1 for yes and 2 for no.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astcdr','1','Change this one at your own peril. If you switch it off, calls will not be marked as billed in asterisk once they are billed.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'posttoastpp','1','Change this one at your own peril. If you switch it off, calls will not be written to astpp when they are calculated.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'sleep','10','How long shall the rating engine sleep after it has been notified of a hangup? (in seconds)',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'users_dids_amp','0','If this is enabled, ASTPP will create users and DIDs in the FreePBX (www.freepbx.org) database.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'users_dids_rt','1','If this is enabled, ASTPP will create users and DIDs in the Asterisk Realtime database.',''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'users_dids_freeswitch','0','If this is enabled, ASTPP will create SIP users in the freeswitch database.',''); + + +INSERT INTO system (name, value, comment) VALUES ( +'service_prepend','778',''); +INSERT INTO system (name, value, comment) VALUES ( +'service_length,','7',''); +INSERT INTO system (name, value, comment) VALUES ( +'service_filler','4110000',''); + +INSERT INTO system (name, value, comment) VALUES ( +'asterisk_cdr_table','cdr','Which table of the Asterisk(TM) database are the cdrs in?'); + +-- AgileBill(Trademark of AgileCo) Settings: +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_db','agile','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_pass','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_site_id','1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_charge_status','0','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_taxable','1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_dbprefix','_','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'agile_service_prepend','778','',''); + +-- OSCommerce Settings (www.oscommerce.org) +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_db','oscommerce','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_pass','password','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_product_id','99999999','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_payment_method','"Charge"','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_order_status','1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'osc_post_nc','0','Do we post "free" items to the oscommerce invoice? 0=No 1=Yes',''); + +-- FreePBX Settings (www.freepbx.org) +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_db','asterisk','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_pass','passw0rd','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_table','iax','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_table','sip','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_extensions_table','extensions','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_codec_allow','g729,ulaw,alaw','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_codec_disallow','all','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_mailbox_group','default','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_nat','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_canreinvite','no','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_dtmfmode','rfc2833','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_callgroup','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_sip_pickupgroup','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_notransfer','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freepbx_iax_qualify','yes','',''); + +-- Asterisk -realtime Settings +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_host','127.0.0.1','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_db','realtime','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_user','root','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_pass','','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_table','iax','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_table','sip','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_extensions_table','extensions','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_insecure','very','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_nat','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_canreinvite','no','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_codec_allow','g729,ulaw,alaw','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_codec_disallow','all','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_mailbox_group','default','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_sip_type','friend','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_qualify','yes','',''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'rt_iax_type','friend','',''); +INSERT INTO system (name, value, comment) VALUES ( +'rt_voicemail_table','voicemail_users',''); + + +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_rate_announce','1','Do we want the calling cards script to announce the rate on calls?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_timelimit_announce','1','Do we want the calling cards script to announce the timelimit on calls?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_cancelled_prompt','1','Do we want the calling cards script to announce that the call was cancelled?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_menu','1','Do we want the calling cards script to present a menu before exiting?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_connection_prompt','1','Do we want the calling cards script to announce that it is connecting the call?'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_pin_input_timeout','15000','How long do we wait when entering the calling card pin? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_number_input_timeout','15000','How long do we wait when entering the calling card number? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_dial_input_timeout','15000','How long do we wait when entering the destination number in calling cards? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_general_input_timeout','15000','How long do we wait for input in general menus? Specified in MS'); +INSERT INTO system (name, value, comment) VALUES ( +'calling_cards_welcome_file','silence/1','What do we play for a welcome file?'); + +INSERT INTO system (name, value, comment) VALUES ( +'sip_ext_prepend','10','What should every autoadded SIP extension begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'iax2_ext_prepend','10','What should every autoadded IAX2 extension begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'cc_prepend','','What should every autoadded callingcard begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'pin_cc_prepend','','What should every autoadded callingcard pin begin with?'); +INSERT INTO system (name, value, comment) VALUES ( +'pin_act_prepend','','What should every autoadded account pin begin with?'); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_directory','/usr/local/freeswitch','What is the Freeswitch root directory?'); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_password','ClueCon','Freeswitch event socket password'); +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_host','localhost','Freeswitch event socket host'); +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_port','8021','Freeswitch event socket port'); +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_timeout','30','Freeswitch seconds to expect a heartbeat event or reconnect'); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_dbengine', 'MySQL','For now this must be MySQL'); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freeswitch_dbname', 'freeswitch','Freeswitch Database Name', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freeswitch_dbuser', 'root','Freeswitch Database User', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freeswitch_dbhost', 'localhost','Freeswitch Database Host', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'freeswitch_dbpass', 'Passw0rd','Freeswitch Database Password', ''); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_cdr_table','fscdr','Which table of the cdr database are the Freeswitch cdrs in?'); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_domain','$${local_ip_v4}','This is entered as the Freeswitch domain.'); + +INSERT INTO system (name, value, comment) VALUES ( +'freeswitch_context','default','This is entered as the Freeswitch user context.'); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbname', 'asteriskcdrdb', +'CDR Database Name', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbuser', 'root', +'CDR Database User', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbhost', 'localhost', +'CDR Database Host', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'cdr_dbpass', 'Passw0rd', +'CDR Database Password', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astman_user', 'admin','Asterisk(tm) Manager Interface User', ''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astman_host', 'localhost','Asterisk(tm) Manager Interface Host', ''); +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'astman_secret', 'amp111','Asterisk(tm) Manager Interface Secret', ''); + +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'call_max_length','1440000','What is the maximum length (in ms) of a LCR call?',''); + +------ 3rd Party PBX Mods +INSERT INTO system (name, value, comment, timestamp) VALUES ( +'thirdlane_mods','0','Provides a few different modifications across the rating code to work better with Thirdlane(tm) cdrs.',''); + +-- +-- Enough Configuration settings +-- + +DROP TABLE IF EXISTS `countrycode`; +CREATE TABLE `countrycode` ( + `country` varchar(255) NOT NULL, + PRIMARY KEY (`country`), + KEY `country` (`country`) +); + +INSERT INTO `countrycode` (`country`) VALUES + ('Afghanistan'), + ('Alaska'), + ('Albania'), + ('Algeria'), + ('AmericanSamoa'), + ('Andorra'), + ('Angola'), + ('Antarctica'), + ('Argentina'), + ('Armenia'), + ('Aruba'), + ('Ascension'), + ('Australia'), + ('Austria'), + ('Azerbaijan'), + ('Bahrain'), + ('Bangladesh'), + ('Belarus'), + ('Belgium'), + ('Belize'), + ('Benin'), + ('Bhutan'), + ('Bolivia'), + ('Bosnia & Herzegovina'), + ('Botswana'), + ('Brazil'), + ('Brunei Darussalam'), + ('Bulgaria'), + ('Burkina Faso'), + ('Burundi'), + ('Cambodia'), + ('Cameroon'), + ('Canadda'), + ('Cape Verde Islands'), + ('Central African Republic'), + ('Chad'), + ('Chile'), + ('China'), + ('Colombia'), + ('Comoros'), + ('Congo'), + ('Cook Islands'), + ('Costa Rica'), + ('Croatia'), + ('Cuba'), + ('Cuba Guantanamo Bay'), + ('Cyprus'), + ('Czech Republic'), + ('Denmark'), + ('Diego Garcia'), + ('Djibouti'), + ('Dominican Republic'), + ('East Timor'), + ('Ecuador'), + ('Egypt'), + ('El Salvador'), + ('Equatorial Guinea'), + ('Eritrea'), + ('Estonia'), + ('Ethiopia'), + ('Faroe Islands'); +INSERT INTO `countrycode` (`country`) VALUES + ('Fiji Islands'), + ('Finland'), + ('France'), + ('French Guiana'), + ('French Polynesia'), + ('Gabonese Republic'), + ('Gambia'), + ('Georgia'), + ('Germany'), + ('Ghana'), + ('Gibraltar'), + ('Greece'), + ('Greenland'), + ('Guadeloupe'), + ('Guam'), + ('Guatemala'), + ('Guinea'), + ('Guyana'), + ('Haiti'), + ('Honduras'), + ('Hong Kong'), + ('Hungary'), + ('Iceland'), + ('India'), + ('Indonesia'), + ('Iran'), + ('Iraq'), + ('Ireland'), + ('Israel'), + ('Italy'), + ('Jamaica'), + ('Japan'), + ('Jordan'), + ('Kazakstan'), + ('Kenya'), + ('Kiribati'), + ('Kuwait'), + ('Kyrgyz Republic'), + ('Laos'), + ('Latvia'), + ('Lebanon'), + ('Lesotho'), + ('Liberia'), + ('Libya'), + ('Liechtenstein'), + ('Lithuania'), + ('Luxembourg'), + ('Macao'), + ('Madagascar'), + ('Malawi'), + ('Malaysia'), + ('Maldives'), + ('Mali Republic'), + ('Malta'), + ('Marshall Islands'), + ('Martinique'), + ('Mauritania'), + ('Mauritius'), + ('MayotteIsland'), + ('Mexico'), + ('Midway Islands'), + ('Moldova'), + ('Monaco'), + ('Mongolia'), + ('Morocco'); +INSERT INTO `countrycode` (`country`) VALUES + ('Mozambique'), + ('Myanmar'), + ('Namibia'), + ('Nauru'), + ('Nepal'), + ('Netherlands'), + ('Netherlands Antilles'), + ('New Caledonia'), + ('New Zealand'), + ('Nicaragua'), + ('Niger'), + ('Nigeria'), + ('Niue'), + ('Norfolk Island'), + ('North Korea'), + ('Norway'), + ('Oman'), + ('Pakistan'), + ('Palau'), + ('Palestinian Settlements'), + ('Panama'), + ('PapuaNew Guinea'), + ('Paraguay'), + ('Peru'), + ('Philippines'), + ('Poland'), + ('Portugal'), + ('Puerto Rico'), + ('Qatar'), + ('RéunionIsland'), + ('Romania'), + ('Russia'), + ('Rwandese Republic'), + ('San Marino'), + ('São Tomé and Principe'), + ('Saudi Arabia'), + ('Senegal '), + ('Serbia and Montenegro'), + ('Seychelles Republic'), + ('Sierra Leone'), + ('Singapore'), + ('Slovak Republic'), + ('Slovenia'), + ('Solomon Islands'), + ('Somali Democratic Republic'), + ('South Africa'), + ('South Korea'), + ('Spain'), + ('Sri Lanka'), + ('St Kitts - Nevis'), + ('St. Helena'), + ('St. Lucia'), + ('St. Pierre & Miquelon'), + ('St. Vincent & Grenadines'), + ('Sudan'); +INSERT INTO `countrycode` (`country`) VALUES + ('Suriname'), + ('Swaziland'), + ('Sweden'), + ('Switzerland'), + ('Syria'), + ('Taiwan'), + ('Tajikistan'), + ('Tanzania'), + ('Thailand'), + ('Togolese Republic'), + ('Tokelau'), + ('Tonga Islands'), + ('Trinidad & Tobago'), + ('Tunisia'), + ('Turkey'), + ('Turkmenistan'), + ('Tuvalu'), + ('Uganda'), + ('Ukraine'), + ('United Arab Emirates'), + ('United Kingdom'), + ('United States of America'), + ('Uruguay'), + ('Uzbekistan'), + ('Vanuatu'), + ('Venezuela'), + ('Vietnam'), + ('Wake Island'), + ('Wallisand Futuna Islands'), + ('Western Samoa'), + ('Yemen'), + ('Zambia'), + ('Zimbabwe'); + +DROP TABLE IF EXISTS `currency`; +CREATE TABLE `currency` ( + `Currency` varchar(3) NOT NULL default '', + `CurrencyName` varchar(40) NOT NULL default '', + PRIMARY KEY (`Currency`) +); + +INSERT INTO `currency` (`Currency`,`CurrencyName`) VALUES + ('USD','US Dollars'), + ('CAD','Canadian Dollars'), + ('AUD','Australian Dollars'); + +CREATE TABLE `language` ( + `language` varchar(5) NOT NULL, + `languagename` varchar(40) NOT NULL, + `active` tinyint(1) NOT NULL default '1', + PRIMARY KEY (`language`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +INSERT INTO `language` (`language`,`languagename`,`active`) VALUES + ('en','English',1), + ('fr','French',1), + ('de','German',1); + +CREATE TABLE `resellers` ( + name varchar(40) NOT NULL default '', + status int(11) NOT NULL default '1', + posttoexternal int(11) NOT NULL default '0', + agile_site_id int(11) NOT NULL default '0', + config_file char(80) NOT NULL default 'reseller.conf', + companyname varchar(255) default NULL, + slogan varchar(255) default NULL, + footer varchar(255) default NULL, + pricelist varchar(255) default NULL, + currency varchar(255) default NULL, + logo varchar(255) default NULL, + website varchar(255) default NULL, + adminemail varchar(255) default NULL, + salesemail varchar(255) default NULL, + phone varchar(45) default NULL, + fax varchar(45) default NULL, + address1 varchar(255) default NULL, + address2 varchar(255) default NULL, + city varchar(255) default NULL, + state varchar(255) default NULL, + postcode varchar(255) default NULL, + country varchar(255) default NULL, + defaultbrand varchar(45) NOT NULL default 'default', + defaultcurrency varchar(45) NOT NULL default 'USD', + defaultcredit varchar(45) NOT NULL default '0.00', + externalbill varchar(45) NOT NULL default '', + PRIMARY KEY (`name`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + +CREATE TABLE templates ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(45) NOT NULL default '', +reseller VARCHAR(45) NOT NULL default '', +template TEXT NOT NULL default '', + PRIMARY KEY (`id`), + KEY `reseller` (`reseller`) +); + +INSERT INTO templates (name,template) VALUES +('voip_account_refilled','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been refilled. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('voip_reactivate_account','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been reactivated. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_add_user','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP account with $config->{company_name} has been added. +Your Username is -- $vars->{extension} -- +Your Password is -- $vars->{secret} -- +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('add_sip_device','Attention: $vars->{title} $vars->{first} $vars->{last} +A new device has been enabled on your account. Here +is the necessary configuration information. +------- $config->{company_name} Configuration Info -------- +In sip.conf: +[$config->{company_name}-in] +type=user +username=$config->{company_name}-in +auth=rsa +inkeys=$config->{key} ;This key may be downloaded from $config->{key_home} +host=$config->{asterisk_server} +context=from-pstn +accountcode=$config->{company_name} +[$config->{company_name}] +type=peer +username=$vars->{extension} +secret=$vars->{secret} +host=$config->{asterisk_server} +callerid= <555-555-5555> +qualify=yes +accountcode=$config->{company_name} ; for call tracking in the cdr +In the [globals] section add: +register => $vars->{user}:password@$config->{asterisk_server}'); + +INSERT INTO templates (name,template) VALUES +('add_iax_device','Attention: $vars->{title} $vars->{first} $vars->{last} +A new device has been enabled on your account. Here +is the necessary configuration information. +------- $config->{company_name} Configuration Info -------- +In iax.conf: +At the bottom of the file add: +[$config->{company_name}-in] +;trunk=yes ;optional .. only works if you have a zaptel or ztdummy driver running +type=user +username=$config->{company_name}-in +auth=rsa +inkeys=$config->{key} ;This key may be downloaded from $config->{key_home} +host=$config->{asterisk_server} +context=incoming +accountcode=$config->{company_name} ;for call tracking in the cdr +[$config->{company_name}] +;to simplify and config outgoing calls +;trunk=yes ;optional .. only works if you have a zaptel driver running +type=peer +username=$vars->{extension} +secret=$vars->{secret} +host=$config->{asterisk_server} +callerid=<555-555-5555> ;only the number will really be used +qualify=yes +accountcode=$config->{company_name} ; for call tracking in the cdr +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_remove_user','Attention: $vars->{title} $vars->{first} $vars->{last} +Your VOIP Termination with $config->{company_name} has been removed +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_calling_card','You have added a $vars->{pricelist} callingcard in the amount of $vars->{pennies} cents. +Card Number $cc Pin: $pin +Thanks for your patronage. +The $config->{company_name} sales team'); + +INSERT INTO templates (name,template) VALUES +('email_add_did','Attention: $vars->{title} $vars->{first} $vars->{last} +Your DID with $config->{company_name} has been added +The number is: $did +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team +Here is a sample setup which would call a few sip phones with incoming calls: +[incoming] +exten => _1$did,1,Wait(2) +exten => _1$did,2,Dial(SIP/2201&SIP/2202,15,Ttm) ; dial a couple of phones for 15 secs +exten => _1$did,3,Voicemail(u1000) ; go to unavailable voicemail (vm box 1000) +exten => _1$did,103,Voicemail(b1000) ; go to busy voicemail (vm box 1000)'); + +INSERT INTO templates (name,template) VALUES +('email_remove_did','Attention: $vars->{title} $vars->{first} $vars->{last} +Your DID with $config->{company_name} has been removed +The number was: $did +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_new_invoice','Invoice # $invoice in the amount of \$$total has been added to your account. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +INSERT INTO templates (name,template) VALUES +('email_low_balance','Your VOIP account with $config->{company_name} has a balance of \$$balance. +Please visit our website to refill your account to ensure uninterrupted service. +For information please visit $config->{company_website} or +contact our support department at $config->{company_email} +Thanks, +The $config->{company_name} support team'); + +CREATE TABLE `sweeplist` ( + `Id` int(10) unsigned NOT NULL default '0', + `sweep` varchar(45) NOT NULL default '', + PRIMARY KEY (`Id`) +); + +INSERT INTO sweeplist (Id,sweep) VALUES +(0,'daily'), +(1,'weekly'), +(2,'monthly'), +(3,'quarterly'), +(4,'semi-annually'), +(5,'annually') +; + +CREATE TABLE userlevels ( +userlevelid int(11) NOT NULL, +userlevelname varchar(50) NOT NULL, +PRIMARY KEY (`userlevelid`) +); + +INSERT INTO `userlevels` (`userlevelid`,`userlevelname`) VALUES + (-1,'Administrator'), + (0,'Anonymous'), + (1,'Reseller'), + (2,'Admin'), + (3,'Vendor'), + (4,'Customer Service'), + (5,'Users'); + +CREATE TABLE reseller_pricing ( +id INTEGER NOT NULL AUTO_INCREMENT, +reseller VARCHAR(50) NOT NULL, +type INTEGER NOT NULL DEFAULT 1, +monthlycost INTEGER NOT NULL DEFAULT 0, +prorate INTEGER NOT NULL DEFAULT 0, +setup INTEGER NOT NULL DEFAULT 0, +cost INTEGER NOT NULL DEFAULT 0, +connectcost INTEGER NOT NULL DEFAULT 0, +includedseconds INTEGER NOT NULL DEFAULT 0, +note VARCHAR(50) NOT NULL DEFAULT '', +disconnectionfee INTEGER NOT NULL DEFAULT 0, +status INTEGER DEFAULT 1 NOT NULL, +inc CHAR(10) NOT NULL DEFAULT '', +PRIMARY KEY (`id`), + KEY `reseller` (`reseller`) +); + +CREATE TABLE callshops ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(50) NOT NULL, +osc_dbname VARCHAR(50) NOT NULL DEFAULT '', +osc_dbpass VARCHAR(50) NOT NULL DEFAULT '', +osc_dbuser VARCHAR(50) NOT NULL DEFAULT '', +osc_dbhost VARCHAR(50) NOT NULL DEFAULT '', +osc_site VARCHAR(50) NOT NULL DEFAULT '', +status INTEGER DEFAULT 1 NOT NULL, +PRIMARY KEY (`id`), +KEY `name` (`name`) +); + +CREATE TABLE extensions_status ( +id INTEGER NOT NULL AUTO_INCREMENT, +tech VARCHAR(6) NULL, +extension VARCHAR(20) NULL, +number VARCHAR(255) NULL, +status VARCHAR(255) NULL, +timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, +Privilege VARCHAR(255) NULL, +Channel VARCHAR(255) NULL, +Cause VARCHAR(255) NULL, +Causetxt VARCHAR(255) NULL, +PeerStatus VARCHAR(255) NULL, +Peer VARCHAR(255) NULL, +Context VARCHAR(255) NULL, +Application VARCHAR(255) NULL, +AppData VARCHAR(255) NULL, +Priority VARCHAR(255) NULL, +Uniqueid VARCHAR(255) NULL, +Event VARCHAR(255) NULL, +State VARCHAR(255) NULL, +CallerIDName VARCHAR(255) NULL, +CallerID VARCHAR(255) NULL, +AstExtension VARCHAR(255) NULL, +PRIMARY KEY (`id`), +KEY `extension` (`extension`)); + +CREATE TABLE activity_logs ( +id INTEGER NOT NULL AUTO_INCREMENT, +timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, +message TEXT NOT NULL DEFAULT '', +user VARCHAR(50), +PRIMARY KEY (`id`)); + +CREATE TABLE sql_commands ( +id INTEGER NOT NULL AUTO_INCREMENT, +name VARCHAR(45) NOT NULL default '', +sql TEXT NOT NULL default '', +comment TEXT NOT NULL default '', +timestamp TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, + PRIMARY KEY (`id`)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2009-04-18 17:11:52
|
Revision: 2245 http://astpp.svn.sourceforge.net/astpp/?rev=2245&view=rev Author: darrenkw Date: 2009-04-18 17:11:43 +0000 (Sat, 18 Apr 2009) Log Message: ----------- Callingcards and freeswitch are now working. Modified Paths: -------------- trunk/scripts/astpp-common.pl Added Paths: ----------- trunk/freeswitch/astpp-fs-monitor.pl Added: trunk/freeswitch/astpp-fs-monitor.pl =================================================================== --- trunk/freeswitch/astpp-fs-monitor.pl (rev 0) +++ trunk/freeswitch/astpp-fs-monitor.pl 2009-04-18 17:11:43 UTC (rev 2245) @@ -0,0 +1,277 @@ +#!/usr/bin/perl +# +# ASTPP - Open Source Voip Billing +# +# Copyright (C) 2004, Aleph Communications +# Copyright (C) Freeswitch (Some of this code was borrowed from the freeswitch contrib directory +# The attribution of that needs to be cleaned up.) +# +# Darren Wiebe (da...@al...) +# +# This program is Free Software and is distributed under the +# terms of the GNU General Public License version 2. +############################################################ +use POSIX; +use POSIX qw(strftime); +use POSIX ':signal_h'; # used for alarm to ensure we get heartbeats +use DBI; +use CGI; +use CGI qw/:standard Vars/; +use Getopt::Long; +use Locale::Country; +use Locale::gettext_pp qw(:locale_h); +use Data::Dumper; +use FreeSWITCH::Client; +use strict; +use ASTPP; +use lib './lib', '../lib'; + +require "/usr/local/astpp/astpp-common.pl"; + +$ENV{'LANGUAGE'} = "en"; # de, es, br - whatever +print STDERR "Interface language is set to: $ENV{'LANGUAGE'}\n"; +bindtextdomain( "ASTPP", "/var/locale" ); +textdomain("ASTPP"); +use vars qw($ASTPP $fs $config $astpp_db $osc_db $agile_db $cdr_db $cdr_table + @output @cardlist $config $params $lastheartbeat); +@output = ( "STDOUT", "LOGFILE" ); +my $verbosity = 1; +$ASTPP = ASTPP->new; +$ASTPP->set_verbosity($verbosity) + ; #Tell ASTPP debugging how verbose we want to be. + +sub initialize() { + $config = &load_config(); + $astpp_db = &connect_db( $config, @output ); + $ASTPP->set_astpp_db($astpp_db); + $config = &load_config_db( $astpp_db, $config ) if $astpp_db; + $cdr_db = &cdr_connect_db( $config, @output ); + $fs = &fs_client_connect($config); + open( LOGFILE, ">>$config->{log_file}" ) + || die "Error - could not open $config->{log_file} for writing\n"; + $cdr_table = $config->{freeswitch_cdr_table}; + + # $ASTPP->debug("Rating calls for FreeSwitch", $verbosity); + +} + +sub fs_client_connect() { + my ($config) = @_; + my ($fs); + print STDERR "Connecting to FreeSwitch\n"; + $fs = init FreeSWITCH::Client { + -password => $config->{freeswitch_password}, + -host => $config->{freeswitch_host}, + -port => $config->{ffreeswitch_port} + }; + if ($fs) { + +# channel_create doesnt have the destination number so we wait for the codec event + $fs->sendmsg( + { 'command' => 'event plain heartbeat channel_hangup codec' } ); + $lastheartbeat = time; + return $fs; + } + else { + print STDERR "Unable to connect to FreeSwitch\n"; + } +} + +############################################### +&initialize; +my $timeout = 1; + +sigaction SIGALRM, new POSIX::SigAction sub { + if ( $lastheartbeat < ( time - $config->{freeswitch_timeout} ) ) { + print "Did not receive a heartbeat in the specified timeout\n"; + $fs->disconnect(); + undef $fs; + $fs = &fs_client_connect($config); + } + + # reset the alarm + alarm $timeout; +} or die "Error setting SIGALRM handler: $!\n"; + +alarm $timeout; + +while ( 1 > 0 ) { + my ( $myhash, %uuids ); + if ( defined $fs ) { + my $reply = $fs->readhash(undef); + if ( $reply->{socketerror} ) { + $fs = &fs_client_connect($config); + } + + if ( $reply->{body} ) { + $myhash = $reply->{event}; + + if ( $myhash->{'event-name'} eq "HEARTBEAT" ) + { ## Deal with heartbeats + $lastheartbeat = time; + print "Got a heartbeat\n"; + + } + elsif ( $myhash->{'event-name'} eq "CODEC" ) { ## New call setup + if ( !$uuids{ $myhash->{'unique-id'} } ) { + print $myhash->{'unique-id'} . " has called\n"; + $uuids{ $myhash->{'unique-id'} } = time; + while ( my ( $key, $value ) = each(%$myhash) ) { + print "CODEC: " . $key . ": " . $value . "\n"; + } + } + + } + elsif ( $myhash->{'event-name'} eq "CHANNEL_HANGUP" ) + { ## hangup event + print "\n\n############################\n\n"; + print $myhash->{'unique-id'} . " has hung up\n"; + delete $uuids{ $myhash->{ + 'unique-id'} }; # we get a codec event after hangup + + while ( my ( $key, $value ) = each(%$myhash) ) { + print "HANGUP: " . $key . ": " . $value . "\n"; + } + + # if ( $myhash->{'variable_last_app'} ) { + $myhash->{'variable_last_app'} = "" + if $myhash->{'variable_last_app'} eq ""; + $myhash->{'variable_last_arg'} = "" + if $myhash->{'variable_last_arg'} eq ""; + my $tmp = +"INSERT INTO `fscdr` (`accountcode`, `src`, `dst`, `dcontext`, `clid`," + . "`channel`, `dstchannel`, `lastapp`, `lastdata`, `calldate`, `answerdate`," + . "`enddate`, `duration`, `billsec`, `disposition`, `amaflags`, `uniqueid`," + . "`userfield`, `read_codec`, `write_codec`, `cost`, `vendor`) VALUES (" + . $cdr_db->quote( $myhash->{'variable_accountcode'} ) . "," + . $cdr_db->quote( $myhash->{'caller-caller-id-number'} ) . "," + . $cdr_db->quote( $myhash->{'caller-destination-number'} ) . "," + . $cdr_db->quote( $myhash->{'caller-context'} ) . "," + . $cdr_db->quote( $myhash->{'variable_caller_id'} ) . "," + . $cdr_db->quote( $myhash->{'other-leg-channel-name'} ) . "," + . $cdr_db->quote( $myhash->{'variable_channel_name'} ) . "," + . $cdr_db->quote( $myhash->{'variable_last_app'} ) . "," + . $cdr_db->quote( $myhash->{'variable_last_arg'} ) . "," + . $cdr_db->quote( $myhash->{'variable_start_stamp'} ) . "," + . $cdr_db->quote( $myhash->{'variable_answer_stamp'} ) . "," + . $cdr_db->quote( $myhash->{'variable_end_stamp'} ) . "," + . $cdr_db->quote( $myhash->{'variable_duration'} ) . "," + . $cdr_db->quote( $myhash->{'variable_billsec'} ) . "," + . $cdr_db->quote( $myhash->{'hangup-cause'} ) . ",''," + # . $cdr_db->quote($myhash->{''}) . "," #amaflags + . $cdr_db->quote( $myhash->{'unique-id'} ) . ",''," + # . $cdr_db->quote($myhash->{''}) . "," #userfield + . $cdr_db->quote( $myhash->{'variable_read_codec'} ) . "," + . $cdr_db->quote( $myhash->{'variable_write_codec'} ) + . ",'none','none')"; + print $tmp; + $cdr_db->do($tmp); + my (@chargelist); + push @chargelist, $myhash->{'unique-id'}; + &processlist( $astpp_db, $cdr_db, $cdr_table, $config, + \@chargelist ); + # } + if ( $myhash->{'variable_callingcards'} + && $myhash->{'variable_last_app'} eq "" ) + { + my ( $cardinfo, $brandinfo, $numberinfo, $pricelistinfo,$cc ); + my $cardnumber = substr( $myhash->{'variable_accountcode'}, 3 ); + $cardinfo = &get_callingcard( $astpp_db, $cardnumber, $config ); + if ( !$cardinfo ) { + $cardinfo = &get_account_cc( $astpp_db, $cardnumber ); + $cc = 1 if $cardinfo; + } + +# Getting this far means we have a valid card and pin. +$brandinfo = &get_cc_brand( $astpp_db, $cardinfo->{brand} ) if $cc == 0; +if ($brandinfo->{reseller}) { + $config = &load_config_db_reseller($astpp_db,$config,$brandinfo->{reseller}); +} +$config = &load_config_db_brand($astpp_db,$config,$cardinfo->{brand}); +$pricelistinfo = &get_pricelist( $astpp_db, $brandinfo->{pricelist} ) + if $cc == 0; +$pricelistinfo = &get_pricelist( $astpp_db, $cardinfo->{pricelist} ) + if $cc == 1; + + print STDERR "THIS IS A CALLINGCARD CALL! \n"; + print STDERR "CARD: $cardinfo->{cardnumber} \n"; + print STDERR "CARD: $cardnumber \n"; + $numberinfo = &get_route( + $astpp_db, $config, + $myhash->{'caller-destination-number'}, + $brandinfo->{pricelist}, $cardinfo + ); + if ( $myhash->{'hangup-cause'} =~ /ANSWER/ + || $myhash->{'variable_billsec'} > 0 ) + { + $ASTPP->debug( + debug => "CALL ANSWERED", + verbosity => $verbosity + ); + my $increment; + if ( $numberinfo->{inc} > 0 ) { + $increment = $numberinfo->{inc}; + } + else { + $increment = $pricelistinfo->{inc}; + } + $ASTPP->debug( + debug => +"$numberinfo->{connectcost}, $numberinfo->{cost}, $myhash->{'variable_billsec'}, $increment, $numberinfo->{includedseconds}", + verbosity => $verbosity + ); + my $charge = &calc_call_cost( + $numberinfo->{connectcost}, + $numberinfo->{cost}, + $myhash->{'variable_billsec'}, + $increment, + $numberinfo->{includedseconds} + ); + $ASTPP->debug( + debug => "Cost $charge ", + verbosity => $verbosity + ); + if ( $cardinfo->{minute_fee_pennies} > 0 ) { + $charge = + ( ( $cardinfo->{minute_fee_pennies} * 100 ) + + $charge ) + if $cardinfo->{timeused} + + $myhash->{'variable_billsec'} => + $cardinfo->{minute_fee_minutes}; + } + if ( $cardinfo->{min_length_pennies} > 0 + && ( $cardinfo->{min_length_minutes} * 60 ) > + $myhash->{'variable_billsec'} ) + { + $charge = + ( ( $cardinfo->{min_length_pennies} * 100 ) + + $charge ); + } + + &write_callingcard_cdr( + $astpp_db, + $config, + $cardinfo, + $myhash->{'caller-caller-id-number'}, + $myhash->{'caller-destination-number'}, + $myhash->{'hangup-cause'}, + $myhash->{'variable_start_stamp'}, + $charge, + $myhash->{'variable_billsec'} + ); + &callingcard_set_in_use($astpp_db,$cardinfo,0); + &callingcard_update_balance($astpp_db,$cardinfo,$charge); + } + } + } + else { ## Unknown event + print "EVENT NAME: " . $myhash->{'event-name'} . "\n"; + print Dumper $myhash; + +# print "$reply->{body}\n"; # print out what was sent, myhash is translated by Client.pm + } + + } + } +} + Property changes on: trunk/freeswitch/astpp-fs-monitor.pl ___________________________________________________________________ Added: svn:executable + * Modified: trunk/scripts/astpp-common.pl =================================================================== --- trunk/scripts/astpp-common.pl 2009-03-23 14:18:45 UTC (rev 2244) +++ trunk/scripts/astpp-common.pl 2009-04-18 17:11:43 UTC (rev 2245) @@ -78,6 +78,30 @@ close(CONFIG); } +sub callingcard_update_balance() { #Update the available credit on the calling card. + my ( $astpp_db, $cardinfo, $charge ) = @_; + my $sql = + "UPDATE callingcards SET used = " + . $astpp_db->quote( ($charge) + $cardinfo->{used} ) + . " WHERE cardnumber = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $astpp_db->do($sql); +} + + +sub callingcard_set_in_use() { # Set the "inuse" flag on the calling cards. This prevents multiple people from +# using the same card. + my ( $astpp_db, $cardinfo, $status ) = @_; + my $sql; + $sql = + "UPDATE callingcards SET inuse = " + . $astpp_db->quote($status) + . " WHERE cardnumber = " + . $astpp_db->quote( $cardinfo->{cardnumber} ); + $astpp_db->do($sql); +} + + # Add a calling card. sub add_callingcard() { my ( $astpp_db, $config, $branddata, $status, $pennies, @@ -2031,6 +2055,24 @@ } } +sub write_callingcard_cdr() { # Write the callingcardcdr record if this is a calling card. + my ($astpp_db, $config, $cardinfo, $clid, $destination, $status, $callstart, $charge, $answeredtime ) = @_; + my ($sql); + if (!$status) {$status = gettext("N/A"); } + $sql = +"INSERT INTO callingcardcdrs (cardnumber,clid,destination,disposition,callstart,seconds," + . "debit) VALUES (" + . $astpp_db->quote( $cardinfo->{cardnumber} ) . ", " + . $astpp_db->quote($clid) . ", " + . $astpp_db->quote($destination) . ", " + . $astpp_db->quote($status) . ", " + . $astpp_db->quote($callstart) . ", " + . $astpp_db->quote($answeredtime) . ", " + . $astpp_db->quote($charge) . ")"; + $astpp_db->do($sql); + print STDERR $sql . "\n"; +} + # Write cdr to the ASTPP cdr database. This is also used to apply charges and credits to an account. sub write_account_cdr() { my ( $astpp_db, $account, $amount, $description, $timestamp, $answeredtime, $uniqueid, $clid, $pricelist, $pattern ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |