astpp-commit Mailing List for ASTPP - Open Source Voip Billing (Page 6)
Brought to you by:
darrenkw
You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(8) |
Oct
(1) |
Nov
(34) |
Dec
(3) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
(9) |
Jun
(3) |
Jul
(1) |
Aug
(3) |
Sep
(8) |
Oct
(3) |
Nov
(11) |
Dec
(6) |
2009 |
Jan
(9) |
Feb
(11) |
Mar
(6) |
Apr
(3) |
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
(14) |
Oct
(32) |
Nov
(2) |
Dec
|
2010 |
Jan
(1) |
Feb
(11) |
Mar
(2) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
(6) |
Oct
(1) |
Nov
|
Dec
(5) |
2011 |
Jan
(7) |
Feb
|
Mar
(1) |
Apr
(3) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <dar...@us...> - 2008-12-02 02:39:21
|
Revision: 2213 http://astpp.svn.sourceforge.net/astpp/?rev=2213&view=rev Author: darrenkw Date: 2008-12-02 02:39:15 +0000 (Tue, 02 Dec 2008) Log Message: ----------- Changed the default CLID number Modified Paths: -------------- trunk/contrib/auto_dialer/aac.conf Modified: trunk/contrib/auto_dialer/aac.conf =================================================================== --- trunk/contrib/auto_dialer/aac.conf 2008-11-25 06:22:52 UTC (rev 2212) +++ trunk/contrib/auto_dialer/aac.conf 2008-12-02 02:39:15 UTC (rev 2213) @@ -10,7 +10,7 @@ extension = s accountcode = aleph clidname = <Aleph Communications> -clidnumber = 3174187927 +clidnumber = 8777022900 total_tries = 5 maxretries = 0 maxcalls = 5 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-11-25 05:24:19
|
Revision: 2211 http://astpp.svn.sourceforge.net/astpp/?rev=2211&view=rev Author: darrenkw Date: 2008-11-25 05:24:17 +0000 (Tue, 25 Nov 2008) Log Message: ----------- The "decimalpoints" variable is not being respected when posting to oscommerce. Fixed this. Modified Paths: -------------- trunk/astpp-common.pl Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2008-11-25 05:12:49 UTC (rev 2210) +++ trunk/astpp-common.pl 2008-11-25 05:24:17 UTC (rev 2211) @@ -4641,6 +4641,7 @@ $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 (''," @@ -4747,6 +4748,7 @@ $tax_priority = $tax->{tax_priority}; $tax_amount = $subtotal * ( $tax->{tax_rate} / 100 ); $sort++; + $tax_amount = sprintf( "%." . $config->{decimalpoints} . "f", $tax_amount ); &osc_post_total( $osc_db, $config, $invoice_id, $tax->{tax_description}, "\$$tax_amount", $tax_amount, $sort, "ot_tax" ); $tax_count++; @@ -4758,12 +4760,14 @@ $tax_priority = $tax->{tax_priority}; $tax_amount = $subtotal * ( $tax->{tax_rate} / 100 ); $sort++; + $tax_amount = sprintf( "%." . $config->{decimalpoints} . "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 ); &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, 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-16 01:59:15
|
Revision: 2209 http://astpp.svn.sourceforge.net/astpp/?rev=2209&view=rev Author: darrenkw Date: 2008-11-16 01:59:10 +0000 (Sun, 16 Nov 2008) Log Message: ----------- Correct the code that returns freeswitch user vars. Modified Paths: -------------- trunk/modules/ASTPP/lib/ASTPP.pm Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2008-11-16 01:42:44 UTC (rev 2208) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2008-11-16 01:59:10 UTC (rev 2209) @@ -306,7 +306,7 @@ $arg{xml} .= "<variables>\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"; + $arg{xml} .= "<variable name=\"" . $record->{var_name} . "\" value=\"" . $record->{var_value} . "\"/>\n"; } $arg{xml} .= "</variables>\n"; $arg{xml} .= "</user>\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-11-16 01:42:51
|
Revision: 2208 http://astpp.svn.sourceforge.net/astpp/?rev=2208&view=rev Author: darrenkw Date: 2008-11-16 01:42:44 +0000 (Sun, 16 Nov 2008) Log Message: ----------- Removed an old line of code that's not needed any more and was causing it to not run. Modified Paths: -------------- trunk/modules/ASTPP/lib/ASTPP.pm Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2008-11-11 23:09:25 UTC (rev 2207) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2008-11-16 01:42:44 UTC (rev 2208) @@ -311,7 +311,6 @@ $arg{xml} .= "</variables>\n"; $arg{xml} .= "</user>\n"; }; - $sql->finish; $arg{xml} .= "</domain>\n"; return $arg{xml}; } 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-11 23:06:22
|
Revision: 2206 http://astpp.svn.sourceforge.net/astpp/?rev=2206&view=rev Author: darrenkw Date: 2008-11-11 23:06:16 +0000 (Tue, 11 Nov 2008) Log Message: ----------- Performed a "perl-tidy" and cleaned up all the code formatting. Modified Paths: -------------- trunk/astpp-admin.cgi Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2008-11-11 22:57:53 UTC (rev 2205) +++ trunk/astpp-admin.cgi 2008-11-11 23:06:16 UTC (rev 2206) @@ -53,7 +53,7 @@ use DateTime::TimeZone; use ASTPP; - ; # We use DateTime::TimeZone to show users cdrs in their own timezones. +; # 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 @@ -65,11 +65,11 @@ $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_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 = ( +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") @@ -100,44 +100,39 @@ gettext("Reset InUse"), gettext("CC Brands") ); my @SwitchConfig = (); -my @CallShops = ( gettext("Create CallShop"), gettext("Remove CallShop") ); -my @Booths = ( +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 @AdminReports = ( gettext("Reseller Report"), gettext("Vendor Report") ); -my @CallShopReports = ( - gettext("Booth Report") -); +my @CallShopReports = ( gettext("Booth Report") ); my @ResellerReports = ( -# gettext("Brand Report"), - gettext("CallShop Report"), - gettext("Reseller Report"), - gettext("User Report") + + # 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 + 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', @@ -169,9 +164,9 @@ 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 + $rt_db, $astpp_db, $config, $params, $param, + $cdr_db, $agile_db, $body, $menu, $status, + $msg, $loginstat, @modes, $openser_db ); $params->{mode} = ""; @@ -228,10 +223,22 @@ $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"); + $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 ); } @@ -276,14 +283,22 @@ $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; + $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; } @@ -426,10 +441,10 @@ 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"); + || $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 @@ -523,8 +538,9 @@ 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_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() @@ -538,10 +554,10 @@ 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"); + || $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"; } @@ -574,10 +590,10 @@ 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"); + || $params->{mode} eq gettext("Home") + || $params->{mode} eq "" + || $params->{mode} eq gettext("Login") + || $params->{mode} eq gettext("Logout"); return gettext("Not Available!") . "\n"; } else { @@ -651,12 +667,14 @@ } $body = start_form(); $body .= "<TABLE>"; - $body .= "<tr><td>" + $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>" + $body .= + "<tr><td>" . hidden( -name => "mode", -value => gettext("Purge Deactivated") ) . submit( -name => "action", -value => gettext("Yes, Drop Them") ) . "</td><td>" @@ -664,7 +682,8 @@ . "</td></tr><tr><td>$status</td></tr></table>"; } else { - $body .= "<tr><td>" + $body .= + "<tr><td>" . hidden( -name => "mode", -value => gettext("Purge Deactivated") ) . submit( -name => "action", @@ -684,7 +703,7 @@ # Last updated: Sept. 11, 2007 at 1445hours GMT. sub build_filter($$) { - my ($additional_fields, $submit_title) = @_; + my ( $additional_fields, $submit_title ) = @_; my ($body); return gettext("ASTPP Database Not Available!") . "<br>" unless $astpp_db; $cdr_db = &cdr_connect_db( $config, @output ); @@ -729,10 +748,14 @@ $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>"; + $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 ) ) { @@ -742,13 +765,18 @@ $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>"; + $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]"; @@ -758,204 +786,242 @@ } } - $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>"; + $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; + 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"); + return &build_report( "Reseller", "1" ); } sub build_admin_vendor_report() { - return &build_report("Vendor","3"); + return &build_report( "Vendor", "3" ); } sub build_callshop_callshop_report() { - return &build_report("Booth","6"); + return &build_report( "Booth", "6" ); } sub build_reseller_callshop_report() { - return &build_report("Booth","6"); + return &build_report( "Booth", "6" ); } sub build_reseller_reseller_report() { - return &build_report("Reseller","1"); + return &build_report( "Reseller", "1" ); } sub build_reseller_user_report() { - return &build_report("User","0"); + 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; + 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") + + 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) { + 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)"); + . $astpp_db->quote( $params->{username} ) + . " AND type IN ($type)" ); } else { - $sth = $astpp_db->prepare("SELECT * FROM accounts WHERE type IN ($type)"); + $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"; + $sth->execute() + || return gettext("Something is wrong with astpp database") . "\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"; - } - } + $body = "<tr><td align=right> $name:" + . "<select name=$name value='$params->{$name}'>\n<option value='ALL'>ALL</option>\n"; - $sth->finish; + 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"; + } + } - $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}."|%")); + $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"; + $sth->execute() + || return gettext("Something is wrong with astpp database") . "\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 ( $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"; - 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}); - } - } - } + 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; - 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).") "; - } - } + $dest .= build_list_box( \@dst, $destination ); + $dest .= "</select>\n"; - $where = 0 if $param->{$name} eq "" && $destination eq "" && $pattern eq ""; + $ptrn .= build_list_box( \@ptn, $pattern ); + $ptrn .= "</select>\n"; - $body .= start_form() + $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") @@ -991,88 +1057,108 @@ . "</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"; + 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 " ); - while(my $row = $sql->fetchrow_hashref) { - $bth = $row->{$name}; - my $sql1 = $astpp_db->prepare("SELECT notes, COUNT(*) AS attempts, AVG(billseconds) AS acd, + 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 ""; + . $astpp_db->quote($bth) . " GROUP BY notes" + ); + $sql1->execute() + || return gettext("Something is wrong with astpp database") . "\n"; - $atmpt = $row1->{'attempts'}; - $acd = $row1->{'acd'}; - $mcd = $row1->{'mcd'}; - $bill = $row1->{'billable'}; - $price = $row1->{'price'}; - $cost = $row1->{'cost'}; + 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 ""; - $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; + $atmpt = $row1->{'attempts'}; + $acd = $row1->{'acd'}; + $mcd = $row1->{'mcd'}; + $bill = $row1->{'billable'}; + $price = $row1->{'price'}; + $cost = $row1->{'cost'}; - $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; + $notes = "notes = " . $astpp_db->quote( $row1->{notes} ); - 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; + 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; - $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; + $asr = ( ( $atmpt - $cmplt ) / $atmpt ) * 100; - $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>"; + 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; } @@ -1083,8 +1169,8 @@ $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!"); + + return gettext("Comming Soon!"); } sub build_reseller_report() { @@ -1094,8 +1180,8 @@ $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!"); + + return gettext("Coming Soon!"); } # End of code changes by Sonia Ali Khan. @@ -1108,14 +1194,14 @@ $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; + 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 = " @@ -1127,7 +1213,7 @@ $sth->execute || return gettext("Something is wrong with the trunks database") . "\n"; $body .= - start_form() + 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") @@ -1160,7 +1246,7 @@ 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 "); + $ASTPP->debug( user => $param->{username}, debug => " SQL: $sql1 \n " ); my $sth1 = $cdr_db->prepare($sql1); $sth1->execute(); my $ref1 = $sth1->fetchrow_hashref(); @@ -1176,7 +1262,7 @@ or dstchannel like '$row->{tech}\[$row->{path}\]%' ) "; my $sth2 = $cdr_db->prepare($sql2); - $ASTPP->debug( user => $param->{username}, debug =>" SQL: $sql2"); + $ASTPP->debug( user => $param->{username}, debug => " SQL: $sql2" ); $sth2->execute(); my $ref2 = $sth2->fetchrow_hashref(); $sth2->finish; @@ -1189,7 +1275,7 @@ or dstchannel like '$row->{tech}\[$row->{path}\]%' ) "; my $sth3 = $cdr_db->prepare($sql3); - $ASTPP->debug( user => $param->{username}, debug =>" SQL: $sql3"); + $ASTPP->debug( user => $param->{username}, debug => " SQL: $sql3" ); $sth3->execute(); my $ref3 = $sth3->fetchrow_hashref(); $sth3->finish; @@ -1201,7 +1287,7 @@ or dstchannel like '$row->{tech}\[$row->{path}\]%' ) "; my $sth4 = $cdr_db->prepare($sql4); - $ASTPP->debug( user=> $param->{username}, debug => " SQL: $sql4"); + $ASTPP->debug( user => $param->{username}, debug => " SQL: $sql4" ); $sth4->execute(); my $ref4 = $sth4->fetchrow_hashref(); $sth4->finish; @@ -1267,8 +1353,10 @@ push( @trunklist, "" ); } @trunklist = sort @trunklist; - - $body = "<tr><td>" . gettext("Answered Calls Only?") + + $body = + "<tr><td>" + . gettext("Answered Calls Only?") . popup_menu( -name => "answered", -values => \%yesno @@ -1280,21 +1368,21 @@ -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() + "</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>" @@ -1338,7 +1426,7 @@ . $cdr_db->quote($sd) . " and calldate <= " . $cdr_db->quote($ed); - $ASTPP->debug( user=> $param->{username}, debug => " SQL: $tmp"); + $ASTPP->debug( user => $param->{username}, debug => " SQL: $tmp" ); } else { $tmp = @@ -1346,7 +1434,7 @@ . $cdr_db->quote($sd) . " and calldate <= " . $cdr_db->quote($ed); - $ASTPP->debug( user=> $param->{username}, debug => " SQL: $tmp"); + $ASTPP->debug( user => $param->{username}, debug => " SQL: $tmp" ); } if ( $params->{accountcode} && $params->{logintype} == 2 ) { $tmp .= @@ -1357,18 +1445,17 @@ "SELECT * FROM trunks WHERE name = " . $astpp_db->quote( $params->{trunk} ) . " LIMIT 1"; - $ASTPP->debug( user=> $param->{username}, debug => $tmpsql); + $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}\%'" + $tmp .= " and (dstchannel like '$row->{tech}/$row->{path}\%'" . " or dstchannel like '$row->{tech}\[$row->{path}\]\%')"; } - $ASTPP->debug( user=> $param->{username}, debug => $tmp); + $ASTPP->debug( user => $param->{username}, debug => $tmp ); $sql = $cdr_db->prepare($tmp); $sql->execute; $results = $sql->rows; @@ -1413,18 +1500,30 @@ $sql->finish; $filter{'start_month'} = $filter{'start_month'} - 1; $string = - "&start_year=" . $filter{'start_year'} - . "&start_month=" . $filter{'start_month'} - . "&start_day=" . $filter{'start_day'} - . "&start_hour=" . $filter{'start_hour'} - . "&start_minute=". $filter{'start_minute'} - . "&start_second=". $filter{'start_second'} - . "&end_year=" . $filter{'end_year'} - . "&end_month=" . $filter{'end_month'} - . "&end_day=" . $filter{'end_day'} - . "&end_hour=" . $filter{'end_hour'} - . "&end_minute=" . $filter{'end_minute'} - . "&end_second=" . $filter{'end_second'} + "&start_year=" + . $filter{'start_year'} + . "&start_month=" + . $filter{'start_month'} + . "&start_day=" + . $filter{'start_day'} + . "&start_hour=" + . $filter{'start_hour'} + . "&start_minute=" + . $filter{'start_minute'} + . "&start_second=" + . $filter{'start_second'} + . "&end_year=" + . $filter{'end_year'} + . "&end_month=" + . $filter{'end_month'} + . "&end_day=" + . $filter{'end_day'} + . "&end_hour=" + . $filter{'end_hour'} + . "&end_minute=" + . $filter{'end_minute'} + . "&end_second=" + . $filter{'end_second'} . "&trunk=" . $params->{trunk}; for ( my $i = 0 ; $i <= $pagesrequired - 1 ; $i++ ) { @@ -1475,8 +1574,10 @@ } sub build_homepage() { - my $template = - HTML::Template->new( filename => '/var/lib/astpp/templates/home.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); + my $template = HTML::Template->new( + filename => '/var/lib/astpp/templates/home.tpl', + die_on_bad_params => $config->{template_die_on_bad_params} + ); if ( $params->{logintype} == 1 || $params->{logintype} == 5 @@ -1493,7 +1594,7 @@ $accounts .= ","; } } - $ASTPP->debug( user=> $param->{username}, debug => $accounts); + $ASTPP->debug( user => $param->{username}, debug => $accounts ); $template->param( customer_count => &count_accounts( $astpp_db, "WHERE type = 0 AND reseller = '$params->{username}'" @@ -1520,9 +1621,13 @@ "WHERE type = 5 AND reseller = '$params->{username}'" ) ); - $template->param( total_owing => &accounts_total_balance($astpp_db,$params->{username})/10000 ); - $template->param( total_due => &accountbalance($astpp_db,$params->{username})/10000 ); + $template->param( total_owing => + &accounts_total_balance( $astpp_db, $params->{username} ) / + 10000 ); $template->param( + total_due => &accountbalance( $astpp_db, $params->{username} ) / + 10000 ); + $template->param( calling_cards_in_use => &count_callingcards( $astpp_db, "WHERE inuse = 1 AND status = 1 AND reseller = '$params->{username}'" @@ -1530,7 +1635,8 @@ ); $template->param( dids => &count_dids( $astpp_db, "" ) ); $template->param( - unbilled_cdrs => &count_unbilled_cdrs( $config, $cdr_db, $accounts ) ); + unbilled_cdrs => &count_unbilled_cdrs( $config, $cdr_db, $accounts ) + ); } elsif ( $params->{logintype} == 2 && $astpp_db && $cdr_db ) { $template->param( @@ -1548,28 +1654,31 @@ $astpp_db, "WHERE inuse = 1 AND status = 1" ) ); - $template->param( total_owing => &accounts_total_balance($astpp_db,"")/10000 ); + $template->param( + total_owing => &accounts_total_balance( $astpp_db, "" ) / 10000 ); $template->param( dids => &count_dids( $astpp_db, "" ) ); $template->param( - unbilled_cdrs => &count_unbilled_cdrs( $config, $cdr_db, "NULL,''" ) ); + unbilled_cdrs => &count_unbilled_cdrs( $config, $cdr_db, "NULL,''" ) + ); } return $template->output; } - sub build_account_info() { my ( $total, $body, $status, $description, $pricelists, $chargeid, $tmp, $number, $pagesrequired, $results_per_page, $results, $pageno ); - my $template = - HTML::Template->new( - filename => '/var/lib/astpp/templates/account-info.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); + my $template = HTML::Template->new( + filename => '/var/lib/astpp/templates/account-info.tpl', + die_on_bad_params => $config->{template_die_on_bad_params} + ); return gettext("Cannot view account until database is configured") unless $astpp_db; -@pricelists = $ASTPP->list_pricelists(reseller => $params->{logged_in_reseller}); + @pricelists = + $ASTPP->list_pricelists( reseller => $params->{logged_in_reseller} ); return gettext("Cannot view account until pricelists configured") unless @pricelists; @@ -1612,13 +1721,13 @@ &write_account_cdr( $astpp_db, $number, $params->{amount} * 10000, $params->{desc}, $timestamp, 0 ); - $status .= "Charge Posted"; + $status .= "Charge Posted"; } } else { &write_account_cdr( $astpp_db, $number, $params->{amount} * 10000, $params->{desc}, $timestamp, 0 ); - $status .= "Charge Posted"; + $status .= "Charge Posted"; } } elsif ( $params->{action} eq gettext("Add Charge...") ) { @@ -1662,15 +1771,13 @@ if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) { $accountinfo = &get_account( $astpp_db, $number ); if ( $accountinfo->{reseller} eq $params->{username} ) { - $tmp = - "DELETE FROM charge_to_account WHERE id = " + $tmp = "DELETE FROM charge_to_account WHERE id = " . $astpp_db->quote( $params->{chargeid} ); $astpp_db->do($tmp); } } else { - $tmp = - "DELETE FROM charge_to_account WHERE id = " + $tmp = "DELETE FROM charge_to_account WHERE id = " . $astpp_db->quote( $params->{chargeid} ); $astpp_db->do($tmp); } @@ -1682,9 +1789,7 @@ else { $number = $params->{numberlist}; } - $status .= - &remove_did( $astpp_db, $config, $params->{DID}, - $number ); + $status .= &remove_did( $astpp_db, $config, $params->{DID}, $number ); } elsif ( $params->{action} eq gettext("Purchase DID") ) { if ( $params->{accountnum} ne "" ) { @@ -1694,8 +1799,7 @@ $number = $params->{numberlist}; } $status .= - &purchase_did( $astpp_db, $config, $params->{did_list}, - $number ); + &purchase_did( $astpp_db, $config, $params->{did_list}, $number ); } elsif ( $params->{action} eq gettext("Map ANI") ) { if ( $params->{accountnum} ne "" ) { @@ -1760,7 +1864,7 @@ . $astpp_db->quote($number) . ", " . $astpp_db->quote( $params->{prefix} ) . ", " . $astpp_db->quote( $params->{ipcontext} ) . ")"; - $ASTPP->debug( user=> $param->{username}, debug => $tmp); + $ASTPP->debug( user => $param->{username}, debug => $tmp ); if ( $astpp_db->do($tmp) ) { $status .= gettext("IP") . " '" @@ -1801,103 +1905,110 @@ . gettext("FAILED to remove!") . "<br>"; } } - if ( $number ne "" ) { - $accountinfo = &get_account( $astpp_db, $number ); - } - elsif ( $params->{accountnum} ne "" ) { - $accountinfo = &get_account( $astpp_db, $params->{accountnum} ); - } - else { - $accountinfo = &get_account( $astpp_db, $params->{numberlist} ); - } - if ( $accountinfo->{number} ) { - $accountinfo->{balance} = &accountbalance( $astpp_db, $accountinfo->{number} ); - $accountinfo->{balance} = sprintf( "%.2f", $accountinfo->{balance} / 10000 ); - $template->param(first_name => $accountinfo->{first_name}); - $template->param(middle_name => $accountinfo->{middle_name}); - $template->param(last_name => $accountinfo->{last_name}); - $template->param(company => $accountinfo->{company_name}); - $template->param(telephone_1 => $accountinfo->{telephone_1}); - $template->param(telephone_2 => $accountinfo->{telephone_2}); - $template->param(fascimilie => $accountinfo->{fascimilie}); - $template->param(address_1 => $accountinfo->{address_1}); - $template->param(address_2 => $accountinfo->{address_2}); - $template->param(address_3 => $accountinfo->{address_3}); - $template->param(email => $accountinfo->{email}); - $template->param(city =>$accountinfo->{city}); - $template->param(postal_code => $accountinfo->{postal_code}); - $template->param(country => $accountinfo->{country}); - $template->param(province => $accountinfo->{province}); - $template->param(dialed_modify => $accountinfo->{dialed_modify}); - $template->param(pin => $accountinfo->{pin}); - $template->param(accountnum => $accountinfo->{number}); - $template->param(balance => $accountinfo->{balance}); - $template->param(maxchannels => $accountinfo->{maxchannels}); - $template->param(credit_limit => $accountinfo->{credit_limit}); - my @chargelist; + if ( $number ne "" ) { + $accountinfo = &get_account( $astpp_db, $number ); + } + elsif ( $params->{accountnum} ne "" ) { + $accountinfo = &get_account( $astpp_db, $params->{accountnum} ); + } + else { + $accountinfo = &get_account( $astpp_db, $params->{numberlist} ); + } + if ( $accountinfo->{number} ) { + $accountinfo->{balance} = + &accountbalance( $astpp_db, $accountinfo->{number} ); + $accountinfo->{balance} = + sprintf( "%.2f", $accountinfo->{balance} / 10000 ); + $template->param( first_name => $accountinfo->{first_name} ); + $template->param( middle_name => $accountinfo->{middle_name} ); + $template->param( last_name => $accountinfo->{last_name} ); + $template->param( company => $accountinfo->{company_name} ); + $template->param( telephone_1 => $accountinfo->{telephone_1} ); + $template->param( telephone_2 => $accountinfo->{telephone_2} ); + $template->param( fascimilie => $accountinfo->{fascimilie} ); + $template->param( address_1 => $accountinfo->{address_1} ); + $template->param( address_2 => $accountinfo->{address_2} ); + $template->param( address_3 => $accountinfo->{address_3} ); + $template->param( email => $accountinfo->{email} ); + $template->param( city => $accountinfo->{city} ); + $template->param( postal_code => $accountinfo->{postal_code} ); + $template->param( country => $accountinfo->{country} ); + $template->param( province => $accountinfo->{province} ); + $template->param( dialed_modify => $accountinfo->{dialed_modify} ); + $template->param( pin => $accountinfo->{pin} ); + $template->param( accountnum => $accountinfo->{number} ); + $template->param( balance => $accountinfo->{balance} ); + $template->param( maxchannels => $accountinfo->{maxchannels} ); + $template->param( credit_limit => $accountinfo->{credit_limit} ); + my @chargelist; my @account_charge_list = &list_account_charges( $astpp_db, $accountinfo->{number} ); my @pricelist_charge_list = &list_pricelist_charges( $astpp_db, $accountinfo->{pricelist} ); + foreach my $charge (@account_charge_list) { - my ( %row ); - $row{accountnum} = $accountinfo->{number}; + my (%row); + $row{accountnum} = $accountinfo->{number}; my $chargeinfo = &get_charge( $astpp_db, $charge->{charge_id} ); - $row{sweep} = $sweeplist{$chargeinfo->{Sweep}}; - $row{cost} = sprintf( "%.2f", $chargeinfo->{charge} / 10000 ); - $row{id} = $charge->{id}; + $row{sweep} = $sweeplist{ $chargeinfo->{Sweep} }; + $row{cost} = sprintf( "%.2f", $chargeinfo->{charge} / 10000 ); + $row{id} = $charge->{id}; $row{description} = $chargeinfo->{description}; - push(@chargelist, \%row); + push( @chargelist, \%row ); } foreach my $charge (@pricelist_charge_list) { - my ( %row ); - $row{accountnum} = $accountinfo->{number}; + my (%row); + $row{accountnum} = $accountinfo->{number}; my $chargeinfo = &get_charge( $astpp_db, $charge ); - $row{sweep} = $sweeplist{$chargeinfo->{Sweep}}; - $row{cost} = sprintf( "%.2f", $chargeinfo->{charge} / 10000 ); - $row{id} = $charge; + $row{sweep} = $sweeplist{ $chargeinfo->{Sweep} }; + $row{cost} = sprintf( "%.2f", $chargeinfo->{charge} / 10000 ); + $row{id} = $charge; $row{charge} = $chargeinfo->{description}; - push(@chargelist, \%row); + push( @chargelist, \%row ); } - $template->param( chargelist => \@chargelist); + $template->param( chargelist => \@chargelist ); my %applyablecharges = &list_applyable_charges($astpp_db); - $template->param( applyable_charges => popup_menu( - -name => "id_list", - -values => \%applyablecharges - )); + $template->param( + applyable_charges => popup_menu( + -name => "id_list", + -values => \%applyablecharges + ) + ); - my (@account_did_list,$sql,$pagination); + my ( @account_did_list, $sql, $pagination ); my @did_list = &list_dids_account( $astpp_db, $accountinfo->{number} ); foreach my $did_info (@did_list) { - my (%row); - $row{accountnum} = $accountinfo->{number}; - $row{cost} = sprintf( "%.2f", $did_info->{monthlycost} / 10000 ); + my (%row); + $row{accountnum} = $accountinfo->{number}; + $row{cost} = sprintf( "%.2f", $did_info->{monthlycost} / 10000 ); $row{number} = $did_info->{number}; - push(@account_did_list, \%row); + push( @account_did_list, \%row ); } - $template->param( account_did_list => \@account_did_list); + $template->param( account_did_list => \@account_did_list ); my @availabledids = &list_available_dids( $astpp_db, $accountinfo->{number} ); - $template->param( available_dids => - popup_menu( - -name => "did_list", - -values => \@availabledids - )); + $template->param( + available_dids => popup_menu( + -name => "did_list", + -values => \@availabledids + ) + ); my $tmp = "SELECT * FROM ani_map WHERE account = " . $astpp_db->quote( $accountinfo->{'number'} ) . " ORDER BY number"; $sql = $astpp_db->prepare($tmp); $sql->execute; - my @account_ani_list; + my @account_ani_list; + while ( my $record = $sql->fetchrow_hashref ) { - my (%row); - $row{accountnum} = $accountinfo->{number}; - $row{number} = $record->{number}; - $row{context} = $record->{context}; - push(@account_ani_list, \%row); + my (%row); + $row{accountnum} = $accountinfo->{number}; + $row{number} = $record->{number}; + $row{context} = $record->{context}; + push( @account_ani_list, \%row ); } - $template->param( account_ani_list => \@account_ani_list); + $template->param( account_ani_list => \@account_ani_list ); $tmp = "SELECT * FROM ip_map WHERE account = " @@ -1905,119 +2016,146 @@ . " ORDER BY ip"; $sql = $astpp_db->prepare($tmp); $sql->execute; - my @account_ip_list; + my @account_ip_list; while ( my $record = $sql->fetchrow_hashref ) { - my %row; - $row{accountnum} = $accountinfo->{number}; - $row{ip} = $record->{ip}; - $row{prefix} = $record->{prefix}; - $row{context} = $record->{context}; - push(@account_ip_list, \%row); + my %row; + $row{accountnum} = $accountinfo->{number}; + $row{ip} = $record->{ip}; + $row{prefix} = $record->{prefix}; + $row{context} = $record->{context}; + push( @account_ip_list, \%row ); } - $template->param( account_ip_list => \@account_ip_list); - $template->param( currency => $currency[0]); + $template->param( account_ip_list => \@account_ip_list ); + $template->param( currency => $currency[0] ); ## List the SIP/IAX2 devices belonging to this account. ## - my @account_device_list; - if ($rt_db) { - my @sip_names = &list_sip_account_rt($rt_db,$config,$accountinfo->{number}, $accountinfo->{cc}); - my @iax_names = &list_iax_account_rt($rt_db,$config,$accountinfo->{number}, $accountinfo->{cc}); - foreach my $name (@sip_names) { - my $deviceinfo = &get_sip_account_rt($rt_db,$config,$name); - my %row; - $row{tech} = "SIP"; - $row{type} = $deviceinfo->{type}; - $row{username} = $deviceinfo->{username}; - $row{secret} = $deviceinfo->{secret}; - $row{context} = $deviceinfo->{context}; - push(@account_device_list, \%row); - } - foreach my $name (@iax_names) { - my $deviceinfo = &get_iax_account_rt($rt_db,$config,$name); - my %row; - $row{tech} = "IAX2"; - $row{type} = $deviceinfo->{type}; - $row{username} = $deviceinfo->{username}; - $row{secret} = $deviceinfo->{secret}; - $row{context} = $deviceinfo->{context}; - 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}); - foreach my $name (@sip_names) { - my $deviceinfo = &get_sip_account_freepbx($freepbx_db,$config,$name); - my %row; - $row{tech} = "SIP"; - $row{type} = $deviceinfo->{type}; - $row{username} = $deviceinfo->{username}; - $row{secret} = $deviceinfo->{secret}; - $row{context} = $deviceinfo->{context}; - push(@account_device_list, \%row); - } - foreach my $name (@iax_names) { - my $deviceinfo = &get_iax_account_freepbx($freepbx_db,$config,$name); - my %row; - $row{tech} = "IAX2"; - $row{type} = $deviceinfo->{type}; - $row{username} = $deviceinfo->{username}; - $row{secret} = $deviceinfo->{secret}; - $row{context} = $deviceinfo->{context}; - push(@account_device_list, \%row); - } - } - $template->param(account_device_list => \@account_device_list); + my @account_device_list; + if ($rt_db) { + my @sip_names = + &list_sip_account_rt( $rt_db, $config, $accountinfo->{number}, + $accountinfo->{cc} ); + my @iax_names = + &list_iax_account_rt( $rt_db, $config, $accountinfo->{number}, + $accountinfo->{cc} ); + foreach my $name (@sip_names) { + my $deviceinfo = &get_sip_account_rt( $rt_db, $config, $name ); + my %row; + $row{tech} = "SIP"; + $row{type} = $deviceinfo->{type}; + $row{username} = $deviceinfo->{username}; + $row{secret} = $deviceinfo->{secret}; + $row{contex... [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 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-08 04:36:09
|
Revision: 2203 http://astpp.svn.sourceforge.net/astpp/?rev=2203&view=rev Author: darrenkw Date: 2008-11-08 04:36:02 +0000 (Sat, 08 Nov 2008) Log Message: ----------- Make a whole bunch of improvements to the autodialer. M auto_dialer/aleph-autocall.pl M auto_dialer/aac.conf M auto_dialer/aleph-aac.sql M auto_dialer/aleph-aac.agi M auto_dialer/Makefile Modified Paths: -------------- trunk/contrib/auto_dialer/Makefile trunk/contrib/auto_dialer/aac.conf trunk/contrib/auto_dialer/aleph-aac.agi trunk/contrib/auto_dialer/aleph-aac.sql trunk/contrib/auto_dialer/aleph-autocall.pl Modified: trunk/contrib/auto_dialer/Makefile =================================================================== --- trunk/contrib/auto_dialer/Makefile 2008-11-01 22:01:34 UTC (rev 2202) +++ trunk/contrib/auto_dialer/Makefile 2008-11-08 04:36:02 UTC (rev 2203) @@ -11,7 +11,8 @@ install: mkdir -p $(DESTDIR)$(AACDIR) - $(INSTALL) -c -o $(OWNER) -g $(GROUP) -m 755 aac.conf $(DESTDIR)$(AACDIR) - $(INSTALL) -c -o $(OWNER) -g $(GROUP) -m 755 aleph-aac.agi $(DESTDIR)$(AGIDIR) - $(INSTALL) -c -o $(OWNER) -g $(GROUP) -m 755 aleph-autocall.pl $(DESTDIR)$(BINDIR) + install -m 755 -o $(OWNER) -g $(GROUP) aac.conf $(DESTDIR)$(AACDIR) + install -m 755 -o $(OWNER) -g $(GROUP) aleph-aac.agi $(DESTDIR)$(AGIDIR) + install -m 755 -o $(OWNER) -g $(GROUP) aleph-autocall.pl $(DESTDIR)$(BINDIR) + install -m 755 -o $(OWNER) -g $(GROUP) aleph-autocall-monitor.pl $(DESTDIR)$(BINDIR) echo "Aleph Auto Call has now been installed!" Modified: trunk/contrib/auto_dialer/aac.conf =================================================================== --- trunk/contrib/auto_dialer/aac.conf 2008-11-01 22:01:34 UTC (rev 2202) +++ trunk/contrib/auto_dialer/aac.conf 2008-11-08 04:36:02 UTC (rev 2203) @@ -14,3 +14,5 @@ total_tries = 5 maxretries = 0 maxcalls = 5 +starthour = 9 +endhour = 21 Modified: trunk/contrib/auto_dialer/aleph-aac.agi =================================================================== --- trunk/contrib/auto_dialer/aleph-aac.agi 2008-11-01 22:01:34 UTC (rev 2202) +++ trunk/contrib/auto_dialer/aleph-aac.agi 2008-11-08 04:36:02 UTC (rev 2203) @@ -1,147 +1,164 @@ -#!/usr/bin/perl -# Aleph Communications Auto Callout -# -# Copyright (C) 2006, Aleph Communications -# -# Darren Wiebe <da...@al...> -# -# 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.aleph-com.net -# -###########################################################################` - -use DBI; -use Asterisk::AGI; -use POSIX qw(ceil floor); -use POSIX qw(strftime); - -sub load_config { - my $config; - open( CONFIG, "</var/lib/aac/aac.conf" ); - while (<CONFIG>) { - chomp; # no newline - s/#.*//; # no comments - s/^\s+//; # no leading white - s/\s+$//; # no trailing white - next unless length; # anything left? - my ( $var, $value ) = split( /\s*=\s*/, $_, 2 ); - $config->{$var} = $value; - } - close(CONFIG); - return $config; -} - -sub timestamp() { - my $now = strftime "%Y%m%d%H%M%S", gmtime; - return $now; -} - -sub prettytimestamp() { - my $now = strftime "%Y-%m-%d %H:%M:%S", gmtime; - return $now; -} - -sub connect_db() { - my ( $dbh, $handle, $dsn ); - $dsn = "DBI:mysql:database=$config->{dbname};host=$config->{dbhost}"; - $dbh = DBI->connect( $dsn, $config->{dbuser}, $config->{dbpass} ); - if ( !$dbh ) { - print STDERR "AAC DATABASE IS DOWN\n"; - exit(0); - } - else { - print STDERR "Connected to AAC Database!" . "\n"; - return $dbh; - } -} - -sub set_in_use() { - my ( $number, $status ) = @_; - my $tmp; - $tmp = - "UPDATE callouts SET inuse = " - . $aac_db->quote($status) - . " WHERE number = " - . $aac_db->quote( $number ); - $aac_db->do($tmp); -} - -sub set_timestamp() { - my ( $number, $timestamp ) = @_; - my $tmp; - $tmp = - "UPDATE callouts SET lasttry = " - . $aac_db->quote($timestamp) - . " WHERE number = " - . $aac_db->quote( $number ); - $aac_db->do($tmp); -} - -sub mark_answered() { - my ( $number ) = @_; - my $tmp; - $tmp = - "UPDATE callouts SET answered = 1 WHERE number = " - . $aac_db->quote( $number ); - $aac_db->do($tmp); -} - -sub get_file_to_play() { - my ($number) = @_; - my ($tmp,$row); - $tmp = "SELECT * FROM callouts WHERE number = " - . $aac_db->quote( $number ) - . " LIMIT 1"; - $sql = $aac_db->prepare($tmp); - $sql->execute; - $row = $sql->fetch_hashref; - $sql->finish; - return $row->{sound_file}; -} - -sub ignore_hup { - foreach $handle (@output) { - print $handle "HUP received\n"; - } -} - - -###################################################################### -# Beginning of Program -###################################################################### -my ( $number ) = @ARGV; - -$verbosity = 2; -$AGI = new Asterisk::AGI; - -my $config = &load_config(); -my $aac_db = &connect_db(); -$SIG{HUP} = 'ignore_hup'; - -$AGI->answer(); - -#&set_in_use($number,1); - -my $sound_file = &get_file_to_play($number); - -$AGI->stream_file($sound_file); - -&set_in_use($number,0); -my $timestamp = ×tamp; -&set_timestamp($number,$timestamp); - -&mark_answered($number); - -exit(0); +#!/usr/bin/perl +# Auto Callout +# +# Copyright (C) 2006, Aleph Communications +# +# Darren Wiebe <da...@al...> +# +# 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.aleph-com.net +# +###########################################################################` + +use DBI; +use Asterisk::AGI; +use POSIX qw(ceil floor); +use POSIX qw(strftime); +$AGI = new Asterisk::AGI; + +sub load_config { + my $config; + open( CONFIG, "</var/lib/aac/aac.conf" ); + while (<CONFIG>) { + chomp; # no newline + s/#.*//; # no comments + s/^\s+//; # no leading white + s/\s+$//; # no trailing white + next unless length; # anything left? + my ( $var, $value ) = split( /\s*=\s*/, $_, 2 ); + $config->{$var} = $value; + } + close(CONFIG); + return $config; +} + +sub timestamp() { + my $now = strftime "%Y%m%d%H%M%S", gmtime; + return $now; +} + +sub prettytimestamp() { + my $now = strftime "%Y-%m-%d %H:%M:%S", gmtime; + return $now; +} + +sub connect_db() { + my ( $dbh, $handle, $dsn ); + $dsn = "DBI:mysql:database=$config->{dbname};host=$config->{dbhost}"; + $dbh = DBI->connect( $dsn, $config->{dbuser}, $config->{dbpass} ); + if ( !$dbh ) { + print STDERR "AAC DATABASE IS DOWN\n"; + $AGI->verbose( "AAC DATABASE IS DOWN\n" , $verbose); + exit(0); + } + else { + print STDERR "Connected to AAC Database!" . "\n"; + $AGI->verbose( "Connected to AAC Database!" , $verbose ); + return $dbh; + } +} + +sub set_in_use() { + my ( $id, $status ) = @_; + my $tmp; + $tmp = + "UPDATE callouts SET inuse = " + . $aac_db->quote($status) + . " WHERE id = " + . $aac_db->quote( $id ); + $aac_db->do($tmp); +} + +sub set_timestamp() { + my ( $id, $timestamp ) = @_; + my $tmp; + $tmp = + "UPDATE callouts SET lasttry = " + . $aac_db->quote($timestamp) + . " WHERE id = " + . $aac_db->quote( $id ); + $aac_db->do($tmp); +} + +sub mark_answered() { + my ( $id ) = @_; + my $tmp; + $tmp = + "UPDATE callouts SET answered = 1 WHERE id = " + . $aac_db->quote( $id ); + $aac_db->do($tmp); +} + +sub get_data() { + my ($id) = @_; + my ($tmp,$row); + $tmp = "SELECT series.external_extension AS external_extension, " + . "series.external_context AS external_context, " + . "series.sound_file AS sound_file " + . "FROM callouts,series " + . "WHERE callouts.id = " . $id . " AND " + . "series.id = callouts.series"; + $AGI->verbose("$tmp",1); + $sql = $aac_db->prepare($tmp); + $sql->execute; + $row = $sql->fetchrow_hashref; + $sql->finish; + $AGI->verbose("Sound File: $row->{sound_file}", 1); + return ($row->{sound_file},$row->{external_extension},$row->{external_context}); +} + + +sub ignore_hup { + foreach $handle (@output) { + print $handle "HUP received\n"; + } +} + + +###################################################################### +# Beginning of Program +###################################################################### +my ( $id ) = @ARGV; + +$verbosity = 2; + +%input = $AGI->ReadParse(); +$config = &load_config(); +$aac_db = &connect_db(); +$SIG{HUP} = 'ignore_hup'; + +$AGI->answer(); + +&set_in_use($id,1); + +$AGI->verbose("GOT THIS FAR 1",1); +my ($sound_file,$external_extension,$external_context) = &get_data($id); +$AGI->verbose("GOT THIS FAR 2",1); + +$AGI->stream_file($sound_file); + +if ($external_context && $external_extension) { + $AGI->exec("DIAL Local/" + . $external_extension . "\@" + . $external_context . "/n"); +} + +&set_in_use($id,0); +my $timestamp = ×tamp; +&set_timestamp($id,$timestamp); + +&mark_answered($id); + +exit(0); Modified: trunk/contrib/auto_dialer/aleph-aac.sql =================================================================== --- trunk/contrib/auto_dialer/aleph-aac.sql 2008-11-01 22:01:34 UTC (rev 2202) +++ trunk/contrib/auto_dialer/aleph-aac.sql 2008-11-08 04:36:02 UTC (rev 2203) @@ -1,10 +1,42 @@ -CREATE DATABASE IF NOT EXISTS aleph_aac; -use aleph_aac; - -CREATE TABLE callouts (number VARCHAR(12) NOT NULL PRIMARY KEY, +CREATE TABLE callouts ( +id INTEGER NOT NULL AUTO_INCREMENT, +series INTEGER NOT NULL, +number VARCHAR(12) NOT NULL, inuse INTEGER NOT NULL DEFAULT 0, -sound_file VARCHAR(60) NOT NULL DEFAULT '', answered INTEGER NOT NULL DEFAULT 0, tries INTEGER NOT NULL DEFAULT 0, -lasttry VARCHAR(80) NOT NULL DEFAULT ''); +lasttry VARCHAR(80) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE series ( +id INTEGER NOT NULL AUTO_INCREMENT, +customer INTEGER NOT NULL, +clidname VARCHAR(80) NOT NULL DEFAULT '', +clidnumber VARCHAR(80) NOT NULL DEFAULT '', +starthour INTEGER NOT NULL DEFAULT 0, +endhour INTEGER NOT NULL DEFAULT 0, +Sun INTEGER NOT NULL DEFAULT 0, +Mon INTEGER NOT NULL DEFAULT 0, +Tue INTEGER NOT NULL DEFAULT 0, +Wed INTEGER NOT NULL DEFAULT 0, +Thu INTEGER NOT NULL DEFAULT 0, +Fri INTEGER NOT NULL DEFAULT 0, +Sat INTEGER NOT NULL DEFAULT 0, +try_times INTEGER NOT NULL DEFAULT 3, +external_extension VARCHAR(40) NOT NULL DEFAULT '', +external_context VARCHAR(40) NOT NULL DEFAULT '', +sound_file VARCHAR(60) NOT NULL DEFAULT '', +creation TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, +status INTEGER NOT NULL DEFAULT 0, +email VARCHAR(80) NOT NULL DEFAULT '', +description VARCHAR(255) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); + +CREATE TABLE customers ( +id INTEGER NOT NULL AUTO_INCREMENT, +accountcode VARCHAR(80) NOT NULL DEFAULT '', +PRIMARY KEY (`id`) +); Modified: trunk/contrib/auto_dialer/aleph-autocall.pl =================================================================== --- trunk/contrib/auto_dialer/aleph-autocall.pl 2008-11-01 22:01:34 UTC (rev 2202) +++ trunk/contrib/auto_dialer/aleph-autocall.pl 2008-11-08 04:36:02 UTC (rev 2203) @@ -1,164 +1,236 @@ -#!/usr/bin/perl -# Aleph Communications Auto Callout -# -# Copyright (C) 2006, Aleph Communications -# -# Darren Wiebe <da...@al...> -# -# 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.aleph-com.net -# -###########################################################################` -use DBI; -use CGI; -use strict; -use Asterisk; -use Asterisk::Outgoing; -use Asterisk::Manager; -use POSIX; -use POSIX qw(strftime); - -my ( $config, $aac_db, $astman ); - -sub load_config { - my $config; - open( CONFIG, "</var/lib/aac/aac.conf" ); - while (<CONFIG>) { - chomp; # no newline - s/#.*//; # no comments - s/^\s+//; # no leading white - s/\s+$//; # no trailing white - next unless length; # anything left? - my ( $var, $value ) = split( /\s*=\s*/, $_, 2 ); - $config->{$var} = $value; - } - close(CONFIG); - return $config; -} - -sub timestamp() { - my $now = strftime "%Y%m%d%H%M%S", gmtime; - return $now; -} - -sub prettytimestamp() { - my $now = strftime "%Y-%m-%d %H:%M:%S", gmtime; - return $now; -} - -sub connect_db() { - my ( $dbh, $handle, $dsn ); - $dsn = "DBI:mysql:database=$config->{dbname};host=$config->{dbhost}"; - $dbh = DBI->connect( $dsn, $config->{dbuser}, $config->{dbpass} ); - if ( !$dbh ) { - print STDERR "AAC DATABASE IS DOWN\n"; - exit(0); - } - else { - print STDERR "Connected to AAC Database!" . "\n"; - return $dbh; - } -} - -#sub connect_manager() { -# my $astman = new Asterisk::Manager; -# $astman->user( $config->{astman_user} ); -# $astman->secret( $config->{astman_secret} ); -# $astman->host( $config->{astman_host} ); -# $astman->connect || die $astman->error . "\n"; -# return $astman; -# -# # my %sip_peers0 = $astman->sendcommand( 'sip show peers', '0' ); -# # my @sip_peers2 = $astman->sendcommand( 'sip show peers', '2' ); -#} - -sub shutdown() { - # $astman->disconnect; -} - -sub perform_callout() { - my ($number) = @_; - my $out = new Asterisk::Outgoing; - my $channel = "Local\/" . $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 ); - $out->setvariable( "CallerID", - "$config->{outgoingclidname} $config->{clidnumber}" ); - $out->setvariable( "Account", "$config->{accountcode}" ); - $out->outtime( time() + 15 ); - $out->create_outgoing; -} - -sub set_in_use() { - my ( $number, $status ) = @_; - my $tmp; - $tmp = - "UPDATE callouts SET inuse = " - . $aac_db->quote($status) - . " WHERE number = " - . $aac_db->quote( $number ); - $aac_db->do($tmp); -} - -sub list_dialouts() { - my ( $tmp, $sql, @numberlist ); - $tmp = - "SELECT * FROM callouts WHERE answered = 0 AND tries < " - . $aac_db->quote( $config->{total_tries} ); - $sql = $aac_db->prepare($tmp); - $sql->execute; - while ( my $row = $sql->fetchrow_hashref ) { - push @numberlist, $row; - } - return @numberlist; -} - -sub count_in_use() { - my ( $sql, $count, $record ); - $sql = $aac_db->prepare("SELECT COUNT(*) FROM callouts WHERE inuse = 1"); - $sql->execute; - $record = $sql->fetchrow_hashref; - $count = $record->{"COUNT(*)"}; - $sql->finish; - return $count; -} - -################################################################## -# Start of Program -################################################################# - -$config = &load_config(); -$aac_db = &connect_db(); -#$astman = &connect_manager(); - -my @diallist = &list_dialouts(); -foreach my $number (@diallist) { - &set_in_use($number->{number},1); - &perform_callout($number->{number}); - my $inuse = &count_in_use(); - while ( $inuse >= $config->{maxcalls} ) { - print STDERR "COUNT $inuse"; - sleep 60; - $inuse = &count_in_use(); - } -} - -&shutdown(); - -exit(0); +#!/usr/bin/perl +# Auto Callout +# +# Copyright (C) 2006, Aleph Communications +# +# Darren Wiebe <da...@al...> +# +# 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.aleph-com.net +# +###########################################################################` +use DBI; +use CGI; +use strict; +use Asterisk; +use Asterisk::Outgoing; +use Asterisk::Manager; +use POSIX; +use POSIX qw(strftime); +use Time::DayOfWeek qw(:dow); + + +my ( $config, $aac_db, $astman ); + +sub load_config { + my $config; + open( CONFIG, "</var/lib/aac/aac.conf" ); + while (<CONFIG>) { + chomp; # no newline + s/#.*//; # no comments + s/^\s+//; # no leading white + s/\s+$//; # no trailing white + next unless length; # anything left? + my ( $var, $value ) = split( /\s*=\s*/, $_, 2 ); + $config->{$var} = $value; + } + close(CONFIG); + return $config; +} + +sub timestamp() { + my $now = strftime "%Y%m%d%H%M%S", localtime; + return $now; +} + +sub prettytimestamp() { + my $now = strftime "%Y-%m-%d %H:%M:%S", localtime; + return $now; +} + +sub get_hour() { + my $now = strftime "%H", localtime; + return $now; +} + +sub get_date() { + my $year = strftime "%Y", localtime; + my $month = strftime "%m", localtime; + my $day = strftime "%d", localtime; + return ($year,$month,$day); +} + +sub mark_last_try() { + my ( $id ) = @_; + my $tmp; + my $timestamp = ×tamp(); + $tmp = + "UPDATE callouts SET lasttry = " + . $aac_db->quote($timestamp) + . " WHERE id = " + . $aac_db->quote( $id ); + $aac_db->do($tmp); +} + +sub mark_tried() { + my ( $id,$count ) = @_; + my $tmp = + "UPDATE callouts SET tries = " + . $aac_db->quote($count) + . " WHERE id = " + . $aac_db->quote( $id ); + $aac_db->do($tmp); +} + +sub connect_db() { + my ( $dbh, $handle, $dsn ); + $dsn = "DBI:mysql:database=$config->{dbname};host=$config->{dbhost}"; + $dbh = DBI->connect( $dsn, $config->{dbuser}, $config->{dbpass} ); + if ( !$dbh ) { + print STDERR "AAC DATABASE IS DOWN\n"; + exit(0); + } + else { + print STDERR "Connected to AAC Database!" . "\n"; + return $dbh; + } +} + +#sub connect_manager() { +# my $astman = new Asterisk::Manager; +# $astman->user( $config->{astman_user} ); +# $astman->secret( $config->{astman_secret} ); +# $astman->host( $config->{astman_host} ); +# $astman->connect || die $astman->error . "\n"; +# return $astman; +# +# # my %sip_peers0 = $astman->sendcommand( 'sip show peers', '0' ); +# # my @sip_peers2 = $astman->sendcommand( 'sip show peers', '2' ); +#} + +sub shutdown() { + # $astman->disconnect; +} + +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 ); + $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; + print STDERR "Created Call to: $number->{number}\n"; +} + +sub set_in_use() { + my ( $id, $status ) = @_; + my $tmp; + $tmp = + "UPDATE callouts SET inuse = " + . $aac_db->quote($status) + . " WHERE id = " + . $aac_db->quote( $id ); + $aac_db->do($tmp); + print STDERR "SET IN USE $id Status: $status\n"; +} + +sub list_dialouts() { + my ( $tmp, $sql, @numberlist ); + $tmp = "SELECT callouts.id AS id, callouts.number AS number," + . "series.clidname AS clidname, series.clidnumber AS clidnumber," + . "series.starthour AS starthour, series.endhour AS endhour," + . "series.Sun as Sun, series.Mon as Mon," + . "series.Tue as Tue, series.Wed as Wed," + . "series.Thu as Thu, series.Fri as Fri," + . "series.Sat as Sat, series.external_extension AS external_extension," + . "series.external_context AS external_context," + . "series.sound_file AS sound_file," + . "customers.accountcode AS accountcode " + . "FROM callouts,series,customers " + . "WHERE series.status = 1 AND " + . "callouts.answered = 0 AND " + . "series.id = callouts.series AND " + . "customers.id = series.customer AND " + . "callouts.tries < series.try_times"; + print STDERR $tmp; + $sql = $aac_db->prepare($tmp); + $sql->execute; + while ( my $row = $sql->fetchrow_hashref ) { + push @numberlist, $row; + print STDERR "NUMBERLIST: $row->{number}\n"; + } + return @numberlist; +} + +sub count_in_use() { + my ( $sql, $count, $record ); + $sql = $aac_db->prepare("SELECT COUNT(*) FROM callouts WHERE inuse = 1"); + $sql->execute; + $record = $sql->fetchrow_hashref; + $count = $record->{"COUNT(*)"}; + $sql->finish; + return $count; +} + +sub place_calls() { + my (@diallist) = @_; + foreach my $number (@diallist) { + my $hour = &get_hour(); + if ($number->{Dow(&get_date)} == 1 && $hour > $number->{starthour} && $hour < $number->{endhour}) { + &perform_callout($number); + &mark_tried($number->{id}, $number->{tries} + 1); + &mark_last_try($number->{id}); + sleep 20; + my $inuse = &count_in_use(); + while ( $inuse >= $config->{maxcalls} ) { + print STDERR "COUNT $inuse"; + sleep 10; + $inuse = &count_in_use(); + } + } + } +} + +################################################################## +# Start of Program +################################################################# + +$config = &load_config(); +$aac_db = &connect_db(); +#$astman = &connect_manager(); + +my $hour = &get_hour(); +#while ($hour < $config->{endhour}) { +while (0 < 1) { + my @diallist = &list_dialouts(); + &place_calls(@diallist); + my $hour = &get_hour(); + print STDERR "SLEEPING FOR A WHILE\n"; + sleep 240; +} + +&shutdown(); + +exit(0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-11-01 22:18:54
|
Revision: 2202 http://astpp.svn.sourceforge.net/astpp/?rev=2202&view=rev Author: darrenkw Date: 2008-11-01 22:01:34 +0000 (Sat, 01 Nov 2008) Log Message: ----------- Fix a minor template bug. Modified Paths: -------------- trunk/templates/account-info.tpl Modified: trunk/templates/account-info.tpl =================================================================== --- trunk/templates/account-info.tpl 2008-10-28 04:19:19 UTC (rev 2201) +++ trunk/templates/account-info.tpl 2008-11-01 22:01:34 UTC (rev 2202) @@ -5,7 +5,7 @@ <td>Action</td> </tr> <tr class="rowone"> - <td><TMPL_VAR NAME="accountlist"> <input name="accountnum" value=<TMPL_VAR NAME="accountnum"> size="20" type="text"></td> + <td><TMPL_VAR NAME="accountlist"> <input name="accountnum" value="<TMPL_VAR NAME="accountnum">" size="20" type="text"></td> <td><input name="action" value="Information" type="submit"></td> </tr> </table> 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-10-10 04:25:14
|
Revision: 2200 http://astpp.svn.sourceforge.net/astpp/?rev=2200&view=rev Author: darrenkw Date: 2008-10-10 04:25:00 +0000 (Fri, 10 Oct 2008) Log Message: ----------- We now use the accountname instead of the CC code on asterisk-realtime users accountcodes. Modified Paths: -------------- trunk/astpp-common.pl Modified: trunk/astpp-common.pl =================================================================== --- trunk/astpp-common.pl 2008-10-02 03:59:39 UTC (rev 2199) +++ trunk/astpp-common.pl 2008-10-10 04:25:00 UTC (rev 2200) @@ -2455,7 +2455,7 @@ . "cancallforward) VALUES (" . $rt_dbh->quote($clid) . ", " . $rt_dbh->quote($name) . ", " - . $rt_dbh->quote($cc) . ", " + . $rt_dbh->quote($name) . ", " . $rt_dbh->quote( $config->{rt_sip_canreinvite} ) . ", " . $rt_dbh->quote($context) . ", " . $rt_dbh->quote( $config->{ipaddr} ) . ", " @@ -2539,7 +2539,7 @@ . ") VALUES (" . $rt_dbh->quote($clid) . ", " . $rt_dbh->quote($name) . ", " - . $rt_dbh->quote($cc) . ", " + . $rt_dbh->quote($name) . ", " . $rt_dbh->quote($context) . ", " . $rt_dbh->quote( $config->{ipaddr} ) . ", " . $rt_dbh->quote($mailbox) . ", " This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-10-02 04:00:43
|
Revision: 2199 http://astpp.svn.sourceforge.net/astpp/?rev=2199&view=rev Author: darrenkw Date: 2008-10-02 03:59:39 +0000 (Thu, 02 Oct 2008) Log Message: ----------- Add support to properly return the freeswitch sip profiles. Modified Paths: -------------- trunk/modules/ASTPP/lib/ASTPP.pm Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2008-09-11 05:14:20 UTC (rev 2198) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2008-10-02 03:59:39 UTC (rev 2199) @@ -204,9 +204,9 @@ 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}); + . $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; 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-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-04 00:06:05
|
Revision: 2196 http://astpp.svn.sourceforge.net/astpp/?rev=2196&view=rev Author: darrenkw Date: 2008-09-04 00:06:13 +0000 (Thu, 04 Sep 2008) Log Message: ----------- Added support to install the freeswich cgi files. Modified Paths: -------------- trunk/Makefile Modified: trunk/Makefile =================================================================== --- trunk/Makefile 2008-09-02 05:17:43 UTC (rev 2195) +++ trunk/Makefile 2008-09-04 00:06:13 UTC (rev 2196) @@ -33,6 +33,9 @@ chgrp $(GROUP) $(DESTDIR)$(ASTPPDIR) chgrp $(GROUP) $(DESTDIR)$(ASTPPLOGDIR) chgrp $(GROUP) $(DESTDIR)$(ASTPPEXECDIR) + # 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 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-02 05:15:11
|
Revision: 2194 http://astpp.svn.sourceforge.net/astpp/?rev=2194&view=rev Author: darrenkw Date: 2008-09-02 05:15:21 +0000 (Tue, 02 Sep 2008) Log Message: ----------- Split the invoice generation code off of astpp-update-balance.pl. Modified Paths: -------------- trunk/astpp-update-balance.pl Modified: trunk/astpp-update-balance.pl =================================================================== --- trunk/astpp-update-balance.pl 2008-09-02 05:09:49 UTC (rev 2193) +++ trunk/astpp-update-balance.pl 2008-09-02 05:15:21 UTC (rev 2194) @@ -215,74 +215,5 @@ } } } - -### Deal with external billing. This will create the appropriate invoices in the external apps. -if ( $config->{externalbill} eq "oscommerce" ) { - my @cardlist; - if ( $params->{sweep} ) { - @cardlist = &update_list_cards( $astpp_db, $config, $params->{sweep} ); - } - foreach (@cardlist) { - my $cardno = $_; - my $carddata = &get_account( $astpp_db, $cardno ); - if ( $carddata->{posttoexternal} == 1 ) { - foreach my $handle (@output) { - print $handle "Card: $cardno \n"; - } - &osc_charges( $astpp_db, $osc_db, $config, $cardno ); - } - } -} -elsif ( $config->{externalbill} eq "agile" ) { - my @cardlist = &list_cards($astpp_db); - foreach my $cardno (@cardlist) { - my $carddata = &get_account( $astpp_db, $cardno ); - if ( $carddata->{posttoexternal} == 1 ) { - my @recordlist = &get_charges( $astpp_db, $config, $cardno ); - foreach my $record (@recordlist) { - my $cdrinfo = &get_charge($record); - my $cost; - if ( $cdrinfo->{debit} ne "" ) { - $cost = $cdrinfo->{debit}; - } - else { - $cost = $cdrinfo->{credit} * -1; - } - &agilesavecdr( - $agile_db, $astpp_db, - $config, - @output, $carddata, - $cost, $config->{agile_site_id}, - $cdrinfo, $config->{agile_dbprefix} - ); - } - } - } -} -elsif ( $config->{externalbill} eq "optigold" ) { - my @cardlist = &list_cards($astpp_db); - foreach my $cardno (@cardlist) { - my $carddata = &get_account( $astpp_db, $cardno ); - if ( $carddata->{posttoexternal} == 1 ) { - my @recordlist = &get_charges( $astpp_db, $config, $cardno ); - foreach my $record (@recordlist) { - my $cdrinfo = &get_charge($record); - my $cost; - if ( $cdrinfo->{debit} ne "" ) { - $cost = $cdrinfo->{debit}; - } - else { - $cost = $cdrinfo->{credit} * -1; - } - &ogsavecdr( - $carddata->{number}, $cdrinfo->{disposition}, - $cdrinfo->{calldate}, $cdrinfo->{dst}, - $cdrinfo->{billsec}, $cost, - $cdrinfo->{src} - ); - } - } - } -} &shutdown; exit(0); 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:09:39
|
Revision: 2193 http://astpp.svn.sourceforge.net/astpp/?rev=2193&view=rev Author: darrenkw Date: 2008-09-02 05:09:49 +0000 (Tue, 02 Sep 2008) Log Message: ----------- Added Freeswitch LCR call time limiting based on available credit. Modified Paths: -------------- trunk/modules/ASTPP/lib/ASTPP.pm Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2008-09-02 05:04:59 UTC (rev 2192) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2008-09-02 05:09:49 UTC (rev 2193) @@ -101,11 +101,20 @@ $arg{xml} .= "<document type=\"freeswitch/xml\">\n"; $arg{xml} .= "<section name=\"dialplan\" description=\"ASTPP Dynamic Routing\">\n"; $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} .= "<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}; } +sub fs_dialplan_xml_timelimit +#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"; + return $arg{xml}; +} + 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: @@ -142,9 +151,9 @@ $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"; + $dialstring = "<action application=\"bridge\" data=\"sofia/gateway/" . $dest . "/" . $arg{route_prepend} . $arg{destination_number} . "\"/>\n"; } else { - $dialstring = "<action application=\"bridge\" data=\"sofia/" . $profile . "/" . $arg{route_prepend} . $arg{destination_number} . "\@" . $dest . "\"/>\n"; + $dialstring = "<action application=\"bridge\" data=\"sofia/" . $profile . "/" . $arg{route_prepend} . $arg{destination_number} . "\@" . $dest . "\"/>\n"; } return $dialstring; } 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:04:52
|
Revision: 2192 http://astpp.svn.sourceforge.net/astpp/?rev=2192&view=rev Author: darrenkw Date: 2008-09-02 05:04:59 +0000 (Tue, 02 Sep 2008) Log Message: ----------- Add a contributed script and modify it to use mostly ASTPP configuration rather than inline configuration. Add partial support for time limiting FreeSwitch LCR calls. Modified Paths: -------------- trunk/freeswitch/astpp-fs-xml.pl Added Paths: ----------- trunk/freeswitch/contrib/ trunk/freeswitch/contrib/wasim/ trunk/freeswitch/contrib/wasim/README trunk/freeswitch/contrib/wasim/cdrload.pl Modified: trunk/freeswitch/astpp-fs-xml.pl =================================================================== --- trunk/freeswitch/astpp-fs-xml.pl 2008-09-02 05:02:48 UTC (rev 2191) +++ trunk/freeswitch/astpp-fs-xml.pl 2008-09-02 05:04:59 UTC (rev 2192) @@ -149,6 +149,7 @@ exit(0); } +$xml = $ASTPP->fs_dialplan_xml_timelimit( xml => $xml, max_length => $maxlength); # Set the timelimit as well as other variables which are needed in the dialplan. my $timelimit = "L(" . sprintf( "%.0f", $maxlength * 60 * 1000 ) . ":60000:30000)"; Added: trunk/freeswitch/contrib/wasim/README =================================================================== --- trunk/freeswitch/contrib/wasim/README (rev 0) +++ trunk/freeswitch/contrib/wasim/README 2008-09-02 05:04:59 UTC (rev 2192) @@ -0,0 +1,4 @@ +This script was contributed by Wasim to the Freeswitch project. It is licensed under the GPL, therefore we're including it in this project with the appropriate adjustments made to make it work seemlessly together with ASTPP. + +Darren Wiebe +d...@al... Added: trunk/freeswitch/contrib/wasim/cdrload.pl =================================================================== --- trunk/freeswitch/contrib/wasim/cdrload.pl (rev 0) +++ trunk/freeswitch/contrib/wasim/cdrload.pl 2008-09-02 05:04:59 UTC (rev 2192) @@ -0,0 +1,48 @@ +#!/usr/bin/perl -w + +# Convergence FreeSwitch Tools Version 7.0 : AGI +# (c) MMII Convergence. All rights reserved. +# <in...@co...> http://www.convergence.pk +# <da...@al...> http://www.aleph-com.net + +# This program is free software, distributed under the terms of +# the GNU General Public License.http://www.gnu.org/licenses.html + +use strict; +use DBI(); +use ASTPP; +use lib './lib', '../lib'; +require "/usr/local/astpp/astpp-common.pl"; + +use vars qw($config $astpp_db $osc_db $agile_db $cdr_db + @output @cardlist $config $params $ASTPP); + +sub initialize() { + $config = &load_config(); + $astpp_db = &connect_db( $config, @output ); + $config = &load_config_db($astpp_db,$config) if $astpp_db; + $cdr_db = &cdr_connect_db( $config, @output ); +} + +$ASTPP = ASTPP->new; +$ASTPP->set_verbosity(4); #Tell ASTPP debugging how verbose we want to be. +&initialize; + +my @cc = ("killall", "-HUP", "freeswitch"); +system(@cc) == 0 + or die "$0: system @cc failed: $?"; + +my @LS = `ls -1t /usr/local/freeswitch/log/cdr-csv/Master.csv.*`; +foreach my $line (@LS) { + chop($line); + $ASTPP->debug($line); + my $stm = "load data local infile '$line' into table TABLE fields enclosed by '\"' terminated by ','"; + my $ul = $cdr_db->prepare($stm) + or die "$0: Couldn't prepare statement $stm: " . $cdr_db->errstr;; + $ul->execute(); + $ul->finish; + system("cat $line >> /usr/local/freeswitch/log/cdr-csv/FULL_Master.csv"); + unlink $line; +} + +exit; 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-08-28 17:15:07
|
Revision: 2190 http://astpp.svn.sourceforge.net/astpp/?rev=2190&view=rev Author: darrenkw Date: 2008-08-28 17:15:17 +0000 (Thu, 28 Aug 2008) Log Message: ----------- Fixed a problem caused by a missing configuration line. Modified Paths: -------------- trunk/astpp-admin.cgi Modified: trunk/astpp-admin.cgi =================================================================== --- trunk/astpp-admin.cgi 2008-08-23 19:11:56 UTC (rev 2189) +++ trunk/astpp-admin.cgi 2008-08-28 17:15:17 UTC (rev 2190) @@ -11133,6 +11133,7 @@ ###################Start of Application ################### &initialize(); +if (!$config->{template_die_on_bad_params}) {$config->{template_die_on_bad_params} = 0;} my $template = HTML::Template->new( filename => '/var/lib/astpp/templates/main.tpl', die_on_bad_params => $config->{template_die_on_bad_params} ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dar...@us...> - 2008-08-23 19:11:48
|
Revision: 2189 http://astpp.svn.sourceforge.net/astpp/?rev=2189&view=rev Author: darrenkw Date: 2008-08-23 19:11:56 +0000 (Sat, 23 Aug 2008) Log Message: ----------- Add a few other scripts I've written. Both scripts are standalone but were in danger of getting lost. Added Paths: ----------- trunk/contrib/auto_dialer/ trunk/contrib/auto_dialer/LICENSE trunk/contrib/auto_dialer/Makefile trunk/contrib/auto_dialer/aac.conf trunk/contrib/auto_dialer/aleph-aac.agi trunk/contrib/auto_dialer/aleph-aac.sql trunk/contrib/auto_dialer/aleph-autocall.pl trunk/contrib/surveys/ trunk/contrib/surveys/LICENCE trunk/contrib/surveys/README trunk/contrib/surveys/survey.agi trunk/contrib/surveys/survey.sql Added: trunk/contrib/auto_dialer/LICENSE =================================================================== --- trunk/contrib/auto_dialer/LICENSE (rev 0) +++ trunk/contrib/auto_dialer/LICENSE 2008-08-23 19:11:56 UTC (rev 2189) @@ -0,0 +1,341 @@ + + 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. Added: trunk/contrib/auto_dialer/Makefile =================================================================== --- trunk/contrib/auto_dialer/Makefile (rev 0) +++ trunk/contrib/auto_dialer/Makefile 2008-08-23 19:11:56 UTC (rev 2189) @@ -0,0 +1,17 @@ +# Makefile For aleph-aac. +# For help visit www.astpp.org. +# + +OWNER= root +GROUP= wheel +AGIDIR= /var/lib/asterisk/agi-bin +BINDIR= /usr/local/bin +AACDIR= /var/lib/aac + + +install: + mkdir -p $(DESTDIR)$(AACDIR) + $(INSTALL) -c -o $(OWNER) -g $(GROUP) -m 755 aac.conf $(DESTDIR)$(AACDIR) + $(INSTALL) -c -o $(OWNER) -g $(GROUP) -m 755 aleph-aac.agi $(DESTDIR)$(AGIDIR) + $(INSTALL) -c -o $(OWNER) -g $(GROUP) -m 755 aleph-autocall.pl $(DESTDIR)$(BINDIR) + echo "Aleph Auto Call has now been installed!" Added: trunk/contrib/auto_dialer/aac.conf =================================================================== --- trunk/contrib/auto_dialer/aac.conf (rev 0) +++ trunk/contrib/auto_dialer/aac.conf 2008-08-23 19:11:56 UTC (rev 2189) @@ -0,0 +1,16 @@ +dbuser = root +dbhost = 127.0.0.1 +dbpass = +dbname = aleph_aac +astman_user = admin +astman_secret = amp111 +astman_host = 127.0.0.1 +destcontext = default-outgoing +context = aleph_aac +extension = s +accountcode = aleph +clidname = <Aleph Communications> +clidnumber = 3174187927 +total_tries = 5 +maxretries = 0 +maxcalls = 5 Added: trunk/contrib/auto_dialer/aleph-aac.agi =================================================================== --- trunk/contrib/auto_dialer/aleph-aac.agi (rev 0) +++ trunk/contrib/auto_dialer/aleph-aac.agi 2008-08-23 19:11:56 UTC (rev 2189) @@ -0,0 +1,147 @@ +#!/usr/bin/perl +# Aleph Communications Auto Callout +# +# Copyright (C) 2006, Aleph Communications +# +# Darren Wiebe <da...@al...> +# +# 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.aleph-com.net +# +###########################################################################` + +use DBI; +use Asterisk::AGI; +use POSIX qw(ceil floor); +use POSIX qw(strftime); + +sub load_config { + my $config; + open( CONFIG, "</var/lib/aac/aac.conf" ); + while (<CONFIG>) { + chomp; # no newline + s/#.*//; # no comments + s/^\s+//; # no leading white + s/\s+$//; # no trailing white + next unless length; # anything left? + my ( $var, $value ) = split( /\s*=\s*/, $_, 2 ); + $config->{$var} = $value; + } + close(CONFIG); + return $config; +} + +sub timestamp() { + my $now = strftime "%Y%m%d%H%M%S", gmtime; + return $now; +} + +sub prettytimestamp() { + my $now = strftime "%Y-%m-%d %H:%M:%S", gmtime; + return $now; +} + +sub connect_db() { + my ( $dbh, $handle, $dsn ); + $dsn = "DBI:mysql:database=$config->{dbname};host=$config->{dbhost}"; + $dbh = DBI->connect( $dsn, $config->{dbuser}, $config->{dbpass} ); + if ( !$dbh ) { + print STDERR "AAC DATABASE IS DOWN\n"; + exit(0); + } + else { + print STDERR "Connected to AAC Database!" . "\n"; + return $dbh; + } +} + +sub set_in_use() { + my ( $number, $status ) = @_; + my $tmp; + $tmp = + "UPDATE callouts SET inuse = " + . $aac_db->quote($status) + . " WHERE number = " + . $aac_db->quote( $number ); + $aac_db->do($tmp); +} + +sub set_timestamp() { + my ( $number, $timestamp ) = @_; + my $tmp; + $tmp = + "UPDATE callouts SET lasttry = " + . $aac_db->quote($timestamp) + . " WHERE number = " + . $aac_db->quote( $number ); + $aac_db->do($tmp); +} + +sub mark_answered() { + my ( $number ) = @_; + my $tmp; + $tmp = + "UPDATE callouts SET answered = 1 WHERE number = " + . $aac_db->quote( $number ); + $aac_db->do($tmp); +} + +sub get_file_to_play() { + my ($number) = @_; + my ($tmp,$row); + $tmp = "SELECT * FROM callouts WHERE number = " + . $aac_db->quote( $number ) + . " LIMIT 1"; + $sql = $aac_db->prepare($tmp); + $sql->execute; + $row = $sql->fetch_hashref; + $sql->finish; + return $row->{sound_file}; +} + +sub ignore_hup { + foreach $handle (@output) { + print $handle "HUP received\n"; + } +} + + +###################################################################### +# Beginning of Program +###################################################################### +my ( $number ) = @ARGV; + +$verbosity = 2; +$AGI = new Asterisk::AGI; + +my $config = &load_config(); +my $aac_db = &connect_db(); +$SIG{HUP} = 'ignore_hup'; + +$AGI->answer(); + +#&set_in_use($number,1); + +my $sound_file = &get_file_to_play($number); + +$AGI->stream_file($sound_file); + +&set_in_use($number,0); +my $timestamp = ×tamp; +&set_timestamp($number,$timestamp); + +&mark_answered($number); + +exit(0); Added: trunk/contrib/auto_dialer/aleph-aac.sql =================================================================== --- trunk/contrib/auto_dialer/aleph-aac.sql (rev 0) +++ trunk/contrib/auto_dialer/aleph-aac.sql 2008-08-23 19:11:56 UTC (rev 2189) @@ -0,0 +1,10 @@ +CREATE DATABASE IF NOT EXISTS aleph_aac; + +use aleph_aac; + +CREATE TABLE callouts (number VARCHAR(12) NOT NULL PRIMARY KEY, +inuse INTEGER NOT NULL DEFAULT 0, +sound_file VARCHAR(60) NOT NULL DEFAULT '', +answered INTEGER NOT NULL DEFAULT 0, +tries INTEGER NOT NULL DEFAULT 0, +lasttry VARCHAR(80) NOT NULL DEFAULT ''); Added: trunk/contrib/auto_dialer/aleph-autocall.pl =================================================================== --- trunk/contrib/auto_dialer/aleph-autocall.pl (rev 0) +++ trunk/contrib/auto_dialer/aleph-autocall.pl 2008-08-23 19:11:56 UTC (rev 2189) @@ -0,0 +1,164 @@ +#!/usr/bin/perl +# Aleph Communications Auto Callout +# +# Copyright (C) 2006, Aleph Communications +# +# Darren Wiebe <da...@al...> +# +# 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.aleph-com.net +# +###########################################################################` +use DBI; +use CGI; +use strict; +use Asterisk; +use Asterisk::Outgoing; +use Asterisk::Manager; +use POSIX; +use POSIX qw(strftime); + +my ( $config, $aac_db, $astman ); + +sub load_config { + my $config; + open( CONFIG, "</var/lib/aac/aac.conf" ); + while (<CONFIG>) { + chomp; # no newline + s/#.*//; # no comments + s/^\s+//; # no leading white + s/\s+$//; # no trailing white + next unless length; # anything left? + my ( $var, $value ) = split( /\s*=\s*/, $_, 2 ); + $config->{$var} = $value; + } + close(CONFIG); + return $config; +} + +sub timestamp() { + my $now = strftime "%Y%m%d%H%M%S", gmtime; + return $now; +} + +sub prettytimestamp() { + my $now = strftime "%Y-%m-%d %H:%M:%S", gmtime; + return $now; +} + +sub connect_db() { + my ( $dbh, $handle, $dsn ); + $dsn = "DBI:mysql:database=$config->{dbname};host=$config->{dbhost}"; + $dbh = DBI->connect( $dsn, $config->{dbuser}, $config->{dbpass} ); + if ( !$dbh ) { + print STDERR "AAC DATABASE IS DOWN\n"; + exit(0); + } + else { + print STDERR "Connected to AAC Database!" . "\n"; + return $dbh; + } +} + +#sub connect_manager() { +# my $astman = new Asterisk::Manager; +# $astman->user( $config->{astman_user} ); +# $astman->secret( $config->{astman_secret} ); +# $astman->host( $config->{astman_host} ); +# $astman->connect || die $astman->error . "\n"; +# return $astman; +# +# # my %sip_peers0 = $astman->sendcommand( 'sip show peers', '0' ); +# # my @sip_peers2 = $astman->sendcommand( 'sip show peers', '2' ); +#} + +sub shutdown() { + # $astman->disconnect; +} + +sub perform_callout() { + my ($number) = @_; + my $out = new Asterisk::Outgoing; + my $channel = "Local\/" . $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 ); + $out->setvariable( "CallerID", + "$config->{outgoingclidname} $config->{clidnumber}" ); + $out->setvariable( "Account", "$config->{accountcode}" ); + $out->outtime( time() + 15 ); + $out->create_outgoing; +} + +sub set_in_use() { + my ( $number, $status ) = @_; + my $tmp; + $tmp = + "UPDATE callouts SET inuse = " + . $aac_db->quote($status) + . " WHERE number = " + . $aac_db->quote( $number ); + $aac_db->do($tmp); +} + +sub list_dialouts() { + my ( $tmp, $sql, @numberlist ); + $tmp = + "SELECT * FROM callouts WHERE answered = 0 AND tries < " + . $aac_db->quote( $config->{total_tries} ); + $sql = $aac_db->prepare($tmp); + $sql->execute; + while ( my $row = $sql->fetchrow_hashref ) { + push @numberlist, $row; + } + return @numberlist; +} + +sub count_in_use() { + my ( $sql, $count, $record ); + $sql = $aac_db->prepare("SELECT COUNT(*) FROM callouts WHERE inuse = 1"); + $sql->execute; + $record = $sql->fetchrow_hashref; + $count = $record->{"COUNT(*)"}; + $sql->finish; + return $count; +} + +################################################################## +# Start of Program +################################################################# + +$config = &load_config(); +$aac_db = &connect_db(); +#$astman = &connect_manager(); + +my @diallist = &list_dialouts(); +foreach my $number (@diallist) { + &set_in_use($number->{number},1); + &perform_callout($number->{number}); + my $inuse = &count_in_use(); + while ( $inuse >= $config->{maxcalls} ) { + print STDERR "COUNT $inuse"; + sleep 60; + $inuse = &count_in_use(); + } +} + +&shutdown(); + +exit(0); Added: trunk/contrib/surveys/LICENCE =================================================================== --- trunk/contrib/surveys/LICENCE (rev 0) +++ trunk/contrib/surveys/LICENCE 2008-08-23 19:11:56 UTC (rev 2189) @@ -0,0 +1,17 @@ +# Makefile For aleph-aac. +# For help visit www.astpp.org. +# + +OWNER= root +GROUP= wheel +AGIDIR= /var/lib/asterisk/agi-bin +BINDIR= /usr/local/bin +AACDIR= /var/lib/aac + + +install: + mkdir -p $(DESTDIR)$(AACDIR) + $(INSTALL) -c -o $(OWNER) -g $(GROUP) -m 755 aac.conf $(DESTDIR)$(AACDIR) + $(INSTALL) -c -o $(OWNER) -g $(GROUP) -m 755 aleph-aac.agi $(DESTDIR)$(AGIDIR) + $(INSTALL) -c -o $(OWNER) -g $(GROUP) -m 755 aleph-autocall.pl $(DESTDIR)$(BINDIR) + echo "Aleph Auto Call has now been installed!" Added: trunk/contrib/surveys/README =================================================================== --- trunk/contrib/surveys/README (rev 0) +++ trunk/contrib/surveys/README 2008-08-23 19:11:56 UTC (rev 2189) @@ -0,0 +1,34 @@ +This is the DNW Consulting Survey Application. + +It is designed for usage in a variety of settings as follows: + +1. Have your customers call in and complete the survey + +2. Using our auto call out software, you can perform completely automated surveys. PLEASE +use this functionality in a legal & ethical manner! + +Notes: + +Database Layout: +TABLE surveys (id INTEGER AUTO_INCREMENT NOT NULL PRIMARY KEY, +inuse INTEGER NOT NULL DEFAULT 0, #Not used for anything currently +starting VARCHAR(60), #Sound to play upon enterin survey +leaving VARCHAR(60), #Sound to play upon successful completion of the survey. +error_leaving VARCHAR(60), #Sound to play when leaving the survey due to an error +total_questions INTEGER NOT NULL DEFAULT 1); #Total number of questions in this survey. + +TABLE responses (id INTEGER AUTO_INCREMENT NOT NULL PRIMARY KEY, +survey_id INTEGER NOT NULL, #This field should contain the number from the "id" field of the survey. +question INTEGER NOT NULL, #What number is this response answering? +date CHAR(40) NOT NULL DEFAULT '', #Time stamp +answer INTEGER NOT NULL); #The answer the user gave. + +CREATE TABLE questions(id INTEGER AUTO_INCREMENT NOT NULL PRIMARY KEY, +survey_id INTEGER NOT NULL, #What survey does this question belong to? +question_number INTEGER NOT NULL, #What number question is this in X survey? +min_valid INTEGER NOT NULL, #Minimum valid answer +max_valid INTEGER NOT NULL, #Maximum valid answer +sound_file VARCHAR(60)); #Sound file to play asking for response. + + +survey.sql contains the data to create the db in mysql. \ No newline at end of file Added: trunk/contrib/surveys/survey.agi =================================================================== --- trunk/contrib/surveys/survey.agi (rev 0) +++ trunk/contrib/surveys/survey.agi 2008-08-23 19:11:56 UTC (rev 2189) @@ -0,0 +1,167 @@ +#!/usr/bin/perl +# +# Survey Script +# +# Copyright (C) 2006, 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. +# +# Sample Configuration +# [survey] +# exten => s,1,DeadAGI(survey.agi,${LANGUAGE}) + +use DBI; +use Asterisk::AGI; +use POSIX qw(ceil floor); +use POSIX qw(strftime); +use strict; +use vars qw($verbosity $AGI $dbh %input ); +$verbosity = 2; +$AGI = new Asterisk::AGI; + +my ( $sound,$retries, $surveyinfo, $answer, $leave_voicemail); +my $dbname = "survey"; +my $dbhost = "127.0.0.1"; +my $dbuser = "root"; +my $dbpass = ""; +my $debug = 1; +my $input_timeout = 15000; #Specified in milliseconds. + +sub initialize() { + $SIG{HUP} = 'ignore_hup'; + $dbh = &connect_db(); +} + +sub ignore_hup { + print STDERR "HUP received\n"; +} + +sub connect_db() { + my ( $dsn, $dbh ); + $dsn = +"DBI:mysql:database=$dbname;host=$dbhost"; + $dbh = + DBI->connect( $dsn, $dbuser, + $dbpass ); + if ( !$dbh ) { + print STDERR "SURVEY DATABASE IS DOWN\n"; + exit(0); + } + else { + $dbh->{mysql_auto_reconnect} = 1; + print STDERR "Connected to Survey Database!" . "\n"; + return $dbh; + } +} + +sub get_survey() { + my ($dbh,$surveynum) = @_; + my ($tmp, $row); + $tmp = "SELECT * FROM surveys WHERE id = " + . $dbh->quote($surveynum) + . " LIMIT 1"; + my $sql = $dbh->prepare($tmp); + print STDERR $tmp; + $sql->execute; + $row = $sql->fetchrow_hashref; + $sql->finish; + return $row; +} + +sub get_question() { + my ($dbh,$surveynum,$questioncount) = @_; + my ($tmp, $row); + $tmp = "SELECT * FROM questions WHERE survey_id = " + . $dbh->quote($surveynum) + . " AND question_number = " + . $dbh->quote($questioncount) + . " LIMIT 1"; + my $sql = $dbh->prepare($tmp); + print STDERR $tmp; + $sql->execute; + $row = $sql->fetchrow_hashref; + $sql->finish; + return $row; +} + +sub write_survey() { + my ( + $dbh,$id,$question,$answer + ) + = @_; + #my $now = strftime "%Y%m%d%H%M%S", gmtime; + my $now = strftime "%Y-%m-%d %H:%M:%S", gmtime; + #debug + print STDERR "NOW $now"; + print STDERR "QUESTION $question"; + print STDERR "ANSWER $answer"; + print STDERR "ID $id"; + my $sql = +"INSERT INTO responses (survey_id,question,answer,callerid,date) VALUES (" + . $dbh->quote($id ) . ", " + . $dbh->quote($question) . ", " + . $dbh->quote($answer) . ", " + . $dbh->quote(%input->{callerid}) . ", " + . $dbh->quote($now) . ")"; + if ($dbh->do($sql)) { + return ("Survey Correctly Written to Database!"); + } else { + return ("Problem Writing Survey to Database!"); + } +} + + +sub leave() { + my ($status) = @_; + if ($status == 1) { + $AGI->verbose("SURVEY ERROR - EXITING", $verbosity); + exit(0); + } elsif ($status == 0) { + $AGI->verbose("SURVEY SUCCESSFUL - EXITING", $verbosity); + exit(0); + } else { + $AGI->verbose("SURVEY ERROR - EXITING", $verbosity); + exit(0); + } +} +################# Program Starts Here ################################# +my ( $extension,$survey ) = @ARGV; +%input = $AGI->ReadParse(); +$AGI->answer(); +&initialize; +sleep 1; #Pause for 1 seconds to allow everything to get hooked up. +print STDERR "DEBUG MODE: $debug\n"; +print STDERR "CALLERID $input{callerid}"; +my $survey = &get_survey($dbh,$survey); +$AGI->stream_file($survey->{starting}); +my $questioncount = 1; +$retries = 0; +# DEBUG +print STDERR "QUESTIONS: $survey->{total_questions} \n"; +my $answer; +my $question = &get_question($dbh,$survey->{id},$questioncount); +while ( $answer < $question->{min_valid} || $answer > $question->{maxvalid} ) { + $answer = $AGI->get_data( $question->{sound_file}, $input_timeout ); + $AGI->verbose("\n ANSWER $answer",1); + if ($retries == 3) { + $AGI->stream_file($survey->{error_leaving}); + &leave(1); + } elsif ($answer >= $question->{min_valid} && $answer <= $question->{max_valid}) { + $retries = 0; + &write_survey($dbh,$survey->{id},$question->{question_number},$answer); + $questioncount++; + if ($questioncount > $survey->{total_questions}) { + $AGI->stream_file($survey->{leaving}); + &leave(0); + } else { + $question = &get_question($dbh,$survey->{id},$questioncount); + } + } else { + $retries++; + } +} +$AGI->stream_file($survey->{error_leaving}); +&leave(1); Property changes on: trunk/contrib/surveys/survey.agi ___________________________________________________________________ Added: svn:executable + * Added: trunk/contrib/surveys/survey.sql =================================================================== --- trunk/contrib/surveys/survey.sql (rev 0) +++ trunk/contrib/surveys/survey.sql 2008-08-23 19:11:56 UTC (rev 2189) @@ -0,0 +1,24 @@ +CREATE DATABASE IF NOT EXISTS survey; + +use survey; + +CREATE TABLE surveys (id INTEGER AUTO_INCREMENT NOT NULL PRIMARY KEY, +inuse INTEGER NOT NULL DEFAULT 0, +leaving VARCHAR(60), +error_leaving VARCHAR(60), +total_questions INTEGER NOT NULL DEFAULT 1); + +CREATE TABLE responses (id INTEGER AUTO_INCREMENT NOT NULL PRIMARY KEY, +survey_id INTEGER NOT NULL, +question INTEGER NOT NULL, +date CHAR(40) NOT NULL DEFAULT '', +callerid VARCHAR( 50 ) NULL, +answer INTEGER NOT NULL); + +CREATE TABLE questions(id INTEGER AUTO_INCREMENT NOT NULL PRIMARY KEY, +survey_id INTEGER NOT NULL, +question_number INTEGER NOT NULL, +min_valid INTEGER NOT NULL, +max_valid INTEGER NOT NULL, +sound_file VARCHAR(60)); + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |