Added Carrier Log and Hangup Reason reports to Admin Utilities screen

Added Lead Loading File Templates
Added "--daily" option to the ADMIN_archive_log_tables.pl script allowing
	for the call_log and vicidial_log_extended tables to be archived every
	night and only keep the last 24-hours of logs in the active table.
Fixed Hopper call count limit bug

git-svn-id: svn://192.168.202.10@1800 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2012-04-03 02:20:33 +00:00
parent 5a541b0ecd
commit a2171f9739
16 changed files with 4291 additions and 10 deletions
+8
View File
@@ -827,6 +827,14 @@ OTHER CHANGES:
189. Added compatibility for DAHDI channelbank phones for agents in vicidial.php
190. Added Carrier Log and Hangup Reason reports to Admin Utilities screen
191. Added Lead Loading File Templates
192. Added "--daily" option to the ADMIN_archive_log_tables.pl script allowing
for the call_log and vicidial_log_extended tables to be archived every
night and only keep the last 24-hours of logs in the active table.
+137 -1
View File
@@ -20,7 +20,7 @@
# Based on perl scripts in ViciDial from Matt Florell and post:
# http://www.vicidial.org/VICIDIALforum/viewtopic.php?p=22506&sid=ca5347cffa6f6382f56ce3db9fb3d068#22506
#
# Copyright (C) 2011 I. Taushanov, Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2012 I. Taushanov, Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES
# 90615-1701 - First version
@@ -34,6 +34,7 @@
# 110801-2140 - Added vicidial_url_log table purging and vicidial_log_extended to rolling processes
# 110808-0055 - Added vicidial_log_noanswer process
# 110822-1257 - Added did_agent_log process
# 120402-2144 - Added "--daily" flag that will archive call_log and vicidial_log_extended logs past 24 hours
#
### begin parsing run-time options ###
@@ -49,6 +50,7 @@ if (length($ARGV[0])>1)
if ($args =~ /--help/i)
{
print "allowed run time options:\n";
print " [--daily] = only archives call_log and vicidial_log_extended tables, only last 24 hours kept\n";
print " [--months=XX] = number of months to archive past, must be 12 or less, default is 2\n";
print " [--closer-log] = archive vicidial_closer_log records\n";
print " [--queue-log] = archive QM queue_log records\n";
@@ -67,6 +69,12 @@ if (length($ARGV[0])>1)
$T=1; $TEST=1;
print "\n-----TESTING-----\n\n";
}
if ($args =~ /--daily/i)
{
$daily=1;
if ($Q < 1)
{print "\n----- DAILY ONLY -----\n\n";}
}
if ($args =~ /--months=/i)
{
@data_in = split(/--months=/,$args);
@@ -119,6 +127,21 @@ if ($mday < 10) {$mday = "0$mday";}
$del_time = "$year-$mon-$mday 01:00:00";
if ($daily > 0)
{
$CLImonths = '*** DAILY MODE ***';
$del_epoch = ($secX - 86400); # 24 hours ago
($RMsec,$RMmin,$RMhour,$RMmday,$RMmon,$RMyear,$RMwday,$RMyday,$RMisdst) = localtime($del_epoch);
$RMyear = ($RMyear + 1900);
$RMmon++;
if ($RMmon < 10) {$RMmon = "0$RMmon";}
if ($RMmday < 10) {$RMmday = "0$RMmday";}
if ($RMhour < 10) {$RMhour = "0$RMhour";}
if ($RMmin < 10) {$RMmin = "0$RMmin";}
if ($RMsec < 10) {$RMsec = "0$RMsec";}
$del_time = "$RMyear-$RMmon-$RMmday $RMhour:$RMmin:$RMsec";
}
if (!$Q) {print "\n\n-- ADMIN_archive_log_tables.pl --\n\n";}
if (!$Q) {print "This program is designed to put all records from call_log, vicidial_log,\n";}
if (!$Q) {print "server_performance, vicidial_agent_log, vicidial_carrier_log, \n";}
@@ -175,6 +198,119 @@ $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VA
if (!$T)
{
if ($daily > 0)
{
# The --daily option was added because these two tables(call_log and
# vicidial_log_extended) are not used for any processes or reports past
# 24 hours, and on systems dialing 500,000 calls per day or more, this
# can lead to system delay issues even if the 1-month archive process is
# run every weekend. This --daily option will keep only the last
# 24-hours and can improve DB performance greatly
##### BEGIN call_log DAILY processing #####
$stmtA = "SELECT count(*) from call_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$call_log_count = $aryA[0];
}
$sthA->finish();
$stmtA = "SELECT count(*) from call_log_archive;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$call_log_archive_count = $aryA[0];
}
$sthA->finish();
if (!$Q) {print "\nProcessing call_log table... ($call_log_count|$call_log_archive_count)\n";}
$stmtA = "INSERT IGNORE INTO call_log_archive SELECT * from call_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows inserted into call_log_archive table\n";}
$rv = $sthA->err();
if (!$rv)
{
$stmtA = "DELETE FROM call_log WHERE start_time < '$del_time';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows deleted from call_log table \n";}
$stmtA = "optimize table call_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
}
##### END call_log DAILY processing #####
##### BEGIN vicidial_log_extended DAILY processing #####
$stmtA = "SELECT count(*) from vicidial_log_extended;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vicidial_log_extended_count = $aryA[0];
}
$sthA->finish();
$stmtA = "SELECT count(*) from vicidial_log_extended_archive;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vicidial_log_extended_archive_count = $aryA[0];
}
$sthA->finish();
if (!$Q) {print "\nProcessing vicidial_log_extended table... ($vicidial_log_extended_count|$vicidial_log_extended_archive_count)\n";}
$stmtA = "INSERT IGNORE INTO vicidial_log_extended_archive SELECT * from vicidial_log_extended;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows inserted into vicidial_log_extended_archive table \n";}
$rv = $sthA->err();
if (!$rv)
{
$stmtA = "DELETE FROM vicidial_log_extended WHERE call_date < '$del_time';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows deleted from vicidial_log_extended table \n";}
$stmtA = "optimize table vicidial_log_extended;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
}
##### END vicidial_log_extended DAILY processing #####
### calculate time to run script ###
$secY = time();
$secZ = ($secY - $secX);
$secZm = ($secZ /60);
if (!$Q) {print "\nscript execution time in seconds: $secZ minutes: $secZm\n";}
exit;
}
if ($queue_log > 0)
{
#############################################
+5 -4
View File
@@ -70,6 +70,7 @@
# 111006-1416 - Added call_count_limit option
# 120109-1510 - Fixed list mix bug
# 120210-1735 - Added vendor_lead_code duplication check per campaign option
# 120402-2211 - Fixed call count limit bug
#
# constants
@@ -1964,7 +1965,7 @@ foreach(@campaign_id)
if ($hopper_vlc_dup_check[$i] =~ /Y/)
{$vlc_dup_check_SQL = "and vendor_lead_code NOT IN($live_vlc$vlc_lists)";}
$stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state,status,modify_date,user,vendor_lead_code FROM vicidial_list where $recycle_SQL[$i] and list_id IN($camp_lists[$i]) and lead_id NOT IN($lead_id_lists) $vlc_dup_check_SQL and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $DLTsql[$i] $order_stmt limit $hopper_level[$i];";
$stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state,status,modify_date,user,vendor_lead_code FROM vicidial_list where $recycle_SQL[$i] and list_id IN($camp_lists[$i]) and lead_id NOT IN($lead_id_lists) $vlc_dup_check_SQL and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $CCLsql[$i] $DLTsql[$i] $order_stmt limit $hopper_level[$i];";
if ($DBX) {print " |$stmtA|\n";}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
@@ -2020,7 +2021,7 @@ foreach(@campaign_id)
if ($hopper_vlc_dup_check[$i] =~ /Y/)
{$vlc_dup_check_SQL = "and vendor_lead_code NOT IN($live_vlc$vlc_lists)";}
$stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state,status,modify_date,user,vendor_lead_code FROM vicidial_list where called_since_last_reset='N' and status IN('NEW') and list_id IN($camp_lists[$i]) and lead_id NOT IN($lead_id_lists) $vlc_dup_check_SQL and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $DLTsql[$i] $order_stmt limit $NEW_level;";
$stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state,status,modify_date,user,vendor_lead_code FROM vicidial_list where called_since_last_reset='N' and status IN('NEW') and list_id IN($camp_lists[$i]) and lead_id NOT IN($lead_id_lists) $vlc_dup_check_SQL and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $CCLsql[$i] $DLTsql[$i] $order_stmt limit $NEW_level;";
if ($DBX) {print " |$stmtA|\n";}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
@@ -2073,7 +2074,7 @@ foreach(@campaign_id)
if ($list_order_mix[$i] =~ /DISABLED/)
{
$stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state,status,modify_date,user,vendor_lead_code FROM vicidial_list where called_since_last_reset='N' and status IN($STATUSsql[$i]) and list_id IN($camp_lists[$i]) and lead_id NOT IN($lead_id_lists) $vlc_dup_check_SQL and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $DLTsql[$i] $order_stmt limit $OTHER_level;";
$stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state,status,modify_date,user,vendor_lead_code FROM vicidial_list where called_since_last_reset='N' and status IN($STATUSsql[$i]) and list_id IN($camp_lists[$i]) and lead_id NOT IN($lead_id_lists) $vlc_dup_check_SQL and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $CCLsql[$i] $DLTsql[$i] $order_stmt limit $OTHER_level;";
if ($DBX) {print " |$stmtA|\n";}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
@@ -2176,7 +2177,7 @@ foreach(@campaign_id)
if ($hopper_vlc_dup_check[$i] =~ /Y/)
{$vlc_dup_check_SQL = "and vendor_lead_code NOT IN($live_vlc$vlc_lists)";}
$stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state,status,modify_date,user,vendor_lead_code FROM vicidial_list where called_since_last_reset='N' and $list_mix_dialableSQL and lead_id NOT IN($lead_id_lists) $vlc_dup_check_SQL and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $DLTsql[$i] $order_stmt limit $LM_step_goal[$x];";
$stmtA = "SELECT lead_id,list_id,gmt_offset_now,phone_number,state,status,modify_date,user,vendor_lead_code FROM vicidial_list where called_since_last_reset='N' and $list_mix_dialableSQL and lead_id NOT IN($lead_id_lists) $vlc_dup_check_SQL and ($all_gmtSQL[$i]) $lead_filter_sql[$i] $CCLsql[$i] $DLTsql[$i] $order_stmt limit $LM_step_goal[$x];";
if ($DBX) {print " |$stmtA|\n";}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
+3
View File
@@ -480,6 +480,9 @@ PHASE 6: ADDING CRONTAB ENTRIES FOR ASTGUICLIENT/VICIDIAL SCRIPTS
### roll logs monthly on high-volume dialing systems
#30 1 1 * * /usr/share/astguiclient/ADMIN_archive_log_tables.pl
### roll call_log and vicidial_log_extended daily on very high-volume dialing systems
#20 1 * * * /usr/share/astguiclient/ADMIN_archive_log_tables.pl --daily
### remove old vicidial logs and asterisk logs more than 2 days old
28 0 * * * /usr/bin/find /var/log/astguiclient -maxdepth 1 -type f -mtime +2 -print | xargs rm -f
29 0 * * * /usr/bin/find /var/log/asterisk -maxdepth 3 -type f -mtime +2 -print | xargs rm -f
+3
View File
@@ -2467,6 +2467,9 @@ SUBPHASE 6.5: setting up astguiclient scripts for continuous running
### roll logs monthly on high-volume dialing systems
#30 1 1 * * /usr/share/astguiclient/ADMIN_archive_log_tables.pl
### roll call_log and vicidial_log_extended daily on very high-volume dialing systems
#20 1 * * * /usr/share/astguiclient/ADMIN_archive_log_tables.pl --daily
### remove old vicidial logs and asterisk logs more than 2 days old
28 0 * * * /usr/bin/find /var/log/astguiclient -maxdepth 1 -type f -mtime +2 -print | xargs rm -f
29 0 * * * /usr/bin/find /var/log/asterisk -maxdepth 3 -type f -mtime +2 -print | xargs rm -f
@@ -2643,6 +2643,16 @@ index (stats_flag),
index (user)
);
CREATE TABLE vicidial_custom_leadloader_templates (
template_id VARCHAR(20) PRIMARY KEY NOT NULL,
template_name VARCHAR(30) DEFAULT NULL,
template_description VARCHAR(255) DEFAULT NULL,
list_id INT(10) UNSIGNED DEFAULT NULL,
standard_variables TEXT,
custom_table VARCHAR(20) DEFAULT NULL,
custom_variables TEXT
);
ALTER TABLE vicidial_campaign_server_stats ENGINE=MEMORY;
@@ -2746,6 +2756,8 @@ INSERT INTO vicidial_call_menu_options SET menu_id='default---agent',option_valu
INSERT INTO vicidial_scripts (script_id,script_name,script_comments,active,script_text) values('CALLNOTES','Call Notes and Appointment Setting','','Y','<iframe src=\"../agc/vdc_script_notes.php?lead_id=--A--lead_id--B--&vendor_id=--A--vendor_lead_code--B--&list_id=--A--list_id--B--&gmt_offset_now=--A--gmt_offset_now--B--&phone_code=--A--phone_code--B--&phone_number=--A--phone_number--B--&title=--A--title--B--&first_name=--A--first_name--B--&middle_initial=--A--middle_initial--B--&last_name=--A--last_name--B--&address1=--A--address1--B--&address2=--A--address2--B--&address3=--A--address3--B--&city=--A--city--B--&state=--A--state--B--&province=--A--province--B--&postal_code=--A--postal_code--B--&country_code=--A--country_code--B--&gender=--A--gender--B--&date_of_birth=--A--date_of_birth--B--&alt_phone=--A--alt_phone--B--&email=--A--email--B--&security_phrase=--A--security_phrase--B--&comments=--A--comments--B--&user=--A--user--B--&pass=--A--pass--B--&campaign=--A--campaign--B--&phone_login=--A--phone_login--B--&fronter=--A--fronter--B--&closer=--A--user--B--&group=--A--group--B--&channel_group=--A--group--B--&SQLdate=--A--SQLdate--B--&epoch=--A--epoch--B--&uniqueid=--A--uniqueid--B--&rank=--A--rank--B--&owner=--A--owner--B--&customer_zap_channel=--A--customer_zap_channel--B--&server_ip=--A--server_ip--B--&SIPexten=--A--SIPexten--B--&session_id=--A--session_id--B--\" style=\"background-color:transparent;\" scrolling=\"auto\" frameborder=\"0\" allowtransparency=\"true\" id=\"popupFrame\" name=\"popupFrame\" width=\"--A--script_width--B--\" height=\"--A--script_height--B--\" STYLE=\"z-index:17\"> </iframe>');
INSERT INTO vicidial_custom_leadloader_templates VALUES ('SAMPLE_TEMPLATE','Sample template','',999,'phone_number,9|first_name,0|last_name,1|address1,3|address2,4|address3,5|city,6|state,7|postal_code,8|','custom_999','appointment_date,2|appointment_notes,9|nearest_city,2|');
UPDATE system_settings SET qc_last_pull_time=NOW();
UPDATE system_settings SET voicemail_timezones="newzealand=Pacific/Auckland\naustraliaeast=Australia/Sydney\naustraliacentral=Australia/Adelaide\naustraliawest=Australia/Perth\njapan=Asia/Tokyo\nphilippines=Asia/Manila\nchina=Asia/Shanghai\nmalaysia=Asia/Kuala_Lumpur\nthailand=Asia/Bangkok\nindia=Asia/Calcutta\npakistan=Asia/Karachi\nrussiaeast=Europe/Moscow\nkenya=Africa/Nairobi\neuropeaneast=Europe/Kiev\nsouthafrica=Africa/Johannesburg\neuropean=Europe/Copenhagen\nnigeria=Africa/Lagos\nuk=Europe/London\nbrazil=America/Sao_Paulo\nnewfoundland=Canada/Newfoundland\ncarribeaneast=America/Santo_Domingo\natlantic=Canada/Atlantic\nchile=America/Santiago\neastern=America/New_York\nperu=America/Lima\ncentral=America/Chicago\nmexicocity=America/Mexico_City\nmountain=America/Denver\narizona=America/Phoenix\nsaskatchewan=America/Saskatchewan\npacific=America/Los_Angeles\nalaska=America/Anchorage\nhawaii=Pacific/Honolulu\neastern24=America/New_York\ncentral24=America/Chicago\nmountain24=America/Denver\npacific24=America/Los_Angeles\nmilitary=Zulu\n";
@@ -2797,7 +2809,7 @@ CREATE TABLE vicidial_log_noanswer_archive LIKE vicidial_log_noanswer;
CREATE TABLE vicidial_did_agent_log_archive LIKE vicidial_did_agent_log;
CREATE UNIQUE INDEX vdala on vicidial_did_agent_log_archive (uniqueid,call_date,did_route);
UPDATE system_settings SET db_schema_version='1315',db_schema_update_date=NOW();
UPDATE system_settings SET db_schema_version='1316',db_schema_update_date=NOW();
GRANT RELOAD ON *.* TO cron@'%';
GRANT RELOAD ON *.* TO cron@localhost;
+14
View File
@@ -1273,3 +1273,17 @@ ALTER TABLE dialable_inventory_snapshots ADD COLUMN list_description VARCHAR(255
UPDATE dialable_inventory_snapshots d, vicidial_lists v SET d.list_description=v.list_description where d.list_description is null and d.list_id=v.list_id;
UPDATE system_settings SET db_schema_version='1315',db_schema_update_date=NOW() where db_schema_version < 1315;
CREATE TABLE vicidial_custom_leadloader_templates (
template_id VARCHAR(20) PRIMARY KEY NOT NULL,
template_name VARCHAR(30) DEFAULT NULL,
template_description VARCHAR(255) DEFAULT NULL,
list_id INT(10) UNSIGNED DEFAULT NULL,
standard_variables TEXT,
custom_table VARCHAR(20) DEFAULT NULL,
custom_variables TEXT
);
INSERT INTO vicidial_custom_leadloader_templates VALUES ('SAMPLE_TEMPLATE','Sample template','',999,'phone_number,9|first_name,0|last_name,1|address1,3|address2,4|address3,5|city,6|state,7|postal_code,8|','custom_999','appointment_date,2|appointment_notes,9|nearest_city,2|');
UPDATE system_settings SET db_schema_version='1316',db_schema_update_date=NOW() where db_schema_version < 1316;
Binary file not shown.
Binary file not shown.
@@ -837,6 +837,7 @@ If the Inventory Report is enabled on your system, this option will determine wh
Report Rank||
This option allows you to rank shifts in selected reports that support this option||
You can also use a special variable IGNORENOSCROLL to force scroll bars on the script tab even if you are using an iframe within it||
Carrier Log Report||
lead_report_export.php
@@ -0,0 +1,447 @@
<?php
# AST_admin_template_maker.php - version 2.4
#
# Copyright (C) 2012 Matt Florell,Joe Johnson <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES
# 120402-2132 - First Build
#
require("dbconnect.php");
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["standard_fields_layout"])) {$standard_fields_layout=$_GET["standard_fields_layout"];}
elseif (isset($_POST["standard_fields_layout"])) {$standard_fields_layout=$_POST["standard_fields_layout"];}
if (isset($_GET["custom_fields_layout"])) {$custom_fields_layout=$_GET["custom_fields_layout"];}
elseif (isset($_POST["custom_fields_layout"])) {$custom_fields_layout=$_POST["custom_fields_layout"];}
if (isset($_GET["template_id"])) {$template_id=$_GET["template_id"];}
elseif (isset($_POST["template_id"])) {$template_id=$_POST["template_id"];}
if (isset($_GET["template_name"])) {$template_name=$_GET["template_name"];}
elseif (isset($_POST["template_name"])) {$template_name=$_POST["template_name"];}
if (isset($_GET["template_description"])) {$template_description=$_GET["template_description"];}
elseif (isset($_POST["template_description"])) {$template_description=$_POST["template_description"];}
if (isset($_GET["file_format"])) {$file_format=$_GET["file_format"];}
elseif (isset($_POST["file_format"])) {$file_format=$_POST["file_format"];}
if (isset($_GET["file_delimiter"])) {$file_delimiter=$_GET["file_delimiter"];}
elseif (isset($_POST["file_delimiter"])) {$file_delimiter=$_POST["file_delimiter"];}
if (isset($_GET["template_list_id"])) {$template_list_id=$_GET["template_list_id"];}
elseif (isset($_POST["template_list_id"])) {$template_list_id=$_POST["template_list_id"];}
if (isset($_GET["standard_fields_layout"])) {$standard_fields_layout=$_GET["standard_fields_layout"];}
elseif (isset($_POST["standard_fields_layout"])) {$standard_fields_layout=$_POST["standard_fields_layout"];}
if (isset($_GET["custom_fields_layout"])) {$custom_fields_layout=$_GET["custom_fields_layout"];}
elseif (isset($_POST["custom_fields_layout"])) {$custom_fields_layout=$_POST["custom_fields_layout"];}
if (isset($_GET["submit_template"])) {$submit_template=$_GET["submit_template"];}
elseif (isset($_POST["submit_template"])) {$submit_template=$_POST["submit_template"];}
if (isset($_GET["delete_template"])) {$delete_template=$_GET["delete_template"];}
elseif (isset($_POST["delete_template"])) {$delete_template=$_POST["delete_template"];}
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
#$vicidial_list_fields = '|lead_id|vendor_lead_code|source_id|list_id|gmt_offset_now|called_since_last_reset|phone_code|phone_number|title|first_name|middle_initial|last_name|address1|address2|address3|city|state|province|postal_code|country_code|gender|date_of_birth|alt_phone|email|security_phrase|comments|called_count|last_local_call_time|rank|owner|entry_list_id|';
$vicidial_listloader_fields = '|vendor_lead_code|source_id|phone_code|phone_number|title|first_name|middle_initial|last_name|address1|address2|address3|city|state|province|postal_code|country_code|gender|date_of_birth|alt_phone|email|security_phrase|comments|rank|owner|';
if ($submit_template=="SUBMIT TEMPLATE" && $template_id && $template_name && $template_list_id && $standard_fields_layout) {
$custom_table="custom_".$template_list_id;
$ins_stmt="insert into vicidial_custom_leadloader_templates(template_id, template_name, template_description, list_id, standard_variables, custom_table, custom_variables) values('$template_id', '$template_name', '$template_description', '$template_list_id', '$standard_fields_layout', '$custom_table', '$custom_fields_layout')";
$ins_rslt=mysql_query($ins_stmt, $link);
if (mysql_affected_rows()>0) {
$success_msg="NEW TEMPLATE CREATED SUCCESSFULLY";
if (!$custom_fields_layout) {
$success_msg.="<BR/>**NO CUSTOM FIELDS ASSIGNED**";
}
} else {
$error_msg="TEMPLATE CREATION FAILED";
}
} else if ($delete_template=="DELETE TEMPLATE" && $template_id) {
$delete_stmt="delete from vicidial_custom_leadloader_templates where template_id='$template_id'";
$delete_rslt=mysql_query($delete_stmt, $link);
}
$US='_';
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,admin_web_directory,custom_fields_enabled,webroot_writable FROM system_settings;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysql_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysql_fetch_row($rslt);
$non_latin = $row[0];
$admin_web_directory = $row[1];
$custom_fields_enabled = $row[2];
$webroot_writable = $row[3];
}
##### END SETTINGS LOOKUP #####
###########################################
if ($non_latin < 1)
{
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$list_id_override = ereg_replace("[^0-9]","",$list_id_override);
}
else
{
$PHP_AUTH_PW = ereg_replace("'|\"|\\\\|;","",$PHP_AUTH_PW);
$PHP_AUTH_USER = ereg_replace("'|\"|\\\\|;","",$PHP_AUTH_USER);
}
$STARTtime = date("U");
$TODAY = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$FILE_datetime = $STARTtime;
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;";
if ($DB) {echo "|$stmt|\n";}
if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
if ($webroot_writable > 0) {$fp = fopen ("./project_auth_entries.txt", "a");}
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
# Header("WWW-Authenticate: Basic realm=\"VICIDIAL-LEAD-LOADER\"");
# Header("HTTP/1.0 401 Unauthorized");
# echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
else
{
header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
if($auth>0)
{
$office_no=strtoupper($PHP_AUTH_USER);
$password=strtoupper($PHP_AUTH_PW);
$stmt="SELECT load_leads,user_group from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGload_leads = $row[0];
$LOGuser_group = $row[1];
if ($LOGload_leads < 1)
{
echo "You do not have permissions to load leads\n";
exit;
}
if ($webroot_writable > 0)
{
fwrite ($fp, "LIST_LOAD|GOOD|$date|$PHP_AUTH_USER|XXXX|$ip|$browser|$LOGfullname|\n");
fclose($fp);
}
}
else
{
if ($webroot_writable > 0)
{
fwrite ($fp, "LIST_LOAD|FAIL|$date|$PHP_AUTH_USER|XXXX|$ip|$browser|\n");
fclose($fp);
}
exit;
}
}
$stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$LOGallowed_campaigns = $row[0];
$LOGallowed_reports = $row[1];
$LOGadmin_viewable_groups = $row[2];
$LOGadmin_viewable_call_times = $row[3];
$camp_lists='';
$LOGallowed_campaignsSQL='';
$whereLOGallowed_campaignsSQL='';
if (!eregi("-ALL",$LOGallowed_campaigns))
{
echo "<BR/>**$LOGallowed_campaigns**";
$rawLOGallowed_campaignsSQL = preg_replace("/ -/",'',$LOGallowed_campaigns);
$rawLOGallowed_campaignsSQL = preg_replace("/ /","','",$rawLOGallowed_campaignsSQL);
echo "<BR/>##$rawLOGallowed_campaignsSQL##";
$LOGallowed_campaignsSQL = "and campaign_id IN('$rawLOGallowed_campaignsSQL')";
$whereLOGallowed_campaignsSQL = "where campaign_id IN('$rawLOGallowed_campaignsSQL')";
}
$regexLOGallowed_campaigns = " $LOGallowed_campaigns ";
$script_name = getenv("SCRIPT_NAME");
$server_name = getenv("SERVER_NAME");
$server_port = getenv("SERVER_PORT");
if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';}
else {$HTTPprotocol = 'http://';}
$admDIR = "$HTTPprotocol$server_name$script_name";
$admDIR = eregi_replace('AST_admin_template_maker.php','',$admDIR);
$admDIR = "/vicidial/";
$admSCR = 'admin.php';
$NWB = " &nbsp; <a href=\"javascript:openNewWindow('$admDIR$admSCR?ADD=99999";
$NWE = "')\"><IMG SRC=\"help.gif\" WIDTH=20 HEIGHT=20 BORDER=0 ALT=\"HELP\" ALIGN=TOP></A>";
?>
<html>
<head>
</head>
<script language="Javascript">
function init() {
document.getElementById("listloader_file_primer").onsubmit=function() {
document.getElementById("listloader_file_primer").target = "file_holder";
alert(document.getElementById("listloader_file_primer").target);
}
}
function PrimeFile() {
document.forms[0].submit();
}
function DisplayTemplateFields(list_id) {
if (list_id!='') {var custom_fields_enabled=1;} else {var custom_fields_enabled=0;}
var template_file_type=document.getElementById("template_file_type").value;
var delimiter=document.getElementById("template_file_delimiter").value;
var buffer=document.getElementById("template_file_buffer").value;
var endstr=document.forms[0].sample_template_file.value.lastIndexOf('\\');
if (endstr>-1)
{
endstr++;
var filename=document.forms[0].sample_template_file.value.substring(endstr);
}
var xmlhttp=false;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
if (xmlhttp) {
var vs_query = "&custom_fields_enabled="+custom_fields_enabled+"&list_id="+list_id+"&delimiter="+delimiter+"&buffer="+buffer;
xmlhttp.open('POST', 'leadloader_template_display.php');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.send(vs_query);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var StatSpanText = null;
StatSpanText = xmlhttp.responseText;
document.getElementById("field_display").innerHTML = StatSpanText;
}
}
delete xmlhttp;
}
}
function DrawTemplateStrings() {
var vicidial_string="<?php echo $vicidial_listloader_fields; ?>";
var standard_string = '';
var custom_string = '';
for (var i = 0; i<document.listloader_template_form.elements.length; i++) {
if ((document.listloader_template_form.elements[i].type == 'select-one') && document.listloader_template_form.elements[i].name!="template_list_id") {
var field_name=document.listloader_template_form.elements[i].name.replace("_field", "");
var ptn="/\|"+field_name+"\|/gi";
if (document.listloader_template_form.elements[i].selectedIndex != 0) {
if (vicidial_string.match(ptn)) {
standard_string += field_name +","+ document.listloader_template_form.elements[i].options[document.listloader_template_form.elements[i].selectedIndex].value + '|';
} else {
custom_string += field_name +","+ document.listloader_template_form.elements[i].options[document.listloader_template_form.elements[i].selectedIndex].value + '|';
}
}
}
}
document.getElementById("standard_fields_layout").value=standard_string;
document.getElementById("custom_fields_layout").value=custom_string;
}
function loadIFrame(form_action, field_value) {
if (field_value=="") {
document.getElementById('list_data_display').style.display = 'none';
document.getElementById('list_data_display').style.visibility = 'hidden';
} else {
document.getElementById('list_data_display').style.display = 'block';
document.getElementById('list_data_display').style.visibility = 'visible';
}
document.forms[0].action="leadloader_template_display.php?form_action="+form_action;
}
function checkForm(form_name) {
var error_msg="The form cannot be submitted for the following reasons: \n";
if (form_name.template_id.value=="") {error_msg+=" - Template ID is missing\n";}
else if (form_name.template_id.value.length<2) {error_msg+=" - Template ID needs to be at least 2 characters long<\n";}
if (form_name.template_name.value=="") {error_msg+=" - Template name is missing\n";}
if (form_name.template_list_id.value=="") {error_msg+=" - List ID is missing\n";}
if (form_name.standard_fields_layout.value=="" && form_name.custom_fields_layout.value=="") {error_msg+=" - There does not seem to be a layout\n";}
if (error_msg.length>=80) {alert(error_msg); return false;} else {return true;}
}
</script>
<?php
function macfontfix($fontsize)
{
$browser = getenv("HTTP_USER_AGENT");
$pctype = explode("(", $browser);
if (ereg("Mac",$pctype[1]))
{
/* Browser is a Mac. If not Netscape 6, raise fonts */
$blownbrowser = explode('/', $browser);
$ver = explode(' ', $blownbrowser[1]);
$ver = $ver[0];
if ($ver >= 5.0) return $fontsize; else return ($fontsize+2);
}
else return $fontsize; /* Browser is not a Mac - don't touch fonts */
}
echo "<style type=\"text/css\">\n
<!--\n
.title { font-family: Arial, Helvetica, sans-serif; font-size: ".macfontfix(18)."pt}\n
.standard { font-family: Arial, Helvetica, sans-serif; font-size: ".macfontfix(10)."pt}\n
.small_standard { font-family: Arial, Helvetica, sans-serif; font-size: ".macfontfix(8)."pt}\n
.tiny_standard { font-family: Arial, Helvetica, sans-serif; font-size: ".macfontfix(6)."pt}\n
.standard_bold { font-family: Arial, Helvetica, sans-serif; font-size: ".macfontfix(10)."pt; font-weight: bold}\n
.standard_header { font-family: Arial, Helvetica, sans-serif; font-size: ".macfontfix(14)."pt; font-weight: bold}\n
.standard_bold_highlight { font-family: Arial, Helvetica, sans-serif; font-size: ".macfontfix(10)."pt; font-weight: bold; color: white; BACKGROUND-COLOR: black}\n
.standard_bold_blue_highlight { font-family: Arial, Helvetica, sans-serif; font-size: 10pt; font-weight: bold; BACKGROUND-COLOR: blue}\n
A.employee_standard { font-family: garamond, sans-serif; font-size: ".macfontfix(10)."pt; font-style: normal; font-variant: normal; font-weight: bold; text-decoration: none}\n
.employee_standard { font-family: garamond, sans-serif; font-size: ".macfontfix(10)."pt; font-weight: bold}\n
.employee_title { font-family: Garamond, sans-serif; font-size: ".macfontfix(14)."pt; font-weight: bold}\n
\\\\-->\n
</style>\n";
?>
<script language="JavaScript1.2">
function openNewWindow(url)
{
window.open (url,"",'width=700,height=300,scrollbars=yes,menubar=yes,address=yes');
}
</script>
<body BGCOLOR=WHITE marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
<?php
$short_header=1;
require("admin_header.php");
?>
<BR/>
<table border="2" bordercolor="#000099" cellpadding="10" width="800" align="left">
<tr height="20"><th bgcolor="#000099"><font class="standard_bold" color="#FFFFFF">Listloader Custom Template Maker<?php echo "$NWB#vicidial_template_maker$NWE"; ?></font></th></tr>
<tr><td align="center" bgcolor="#CCFFFF">
<table border=0 cellpadding=15 cellspacing=0 width="90%" align="center" bgcolor="#D9E6FE">
<?php
if ($error_msg) {
echo "<tr bgcolor='#990000'>";
echo "<th colspan='2'><font color='#FFFFFF'>$error_msg</font></th>";
echo "</tr>";
}
if ($success_msg) {
echo "<tr bgcolor='#009900'>";
echo "<th colspan='2'><font color='#FFFFFF'>$success_msg</font></th>";
echo "</tr>";
}
?>
<tr>
<th width="50%"><font class="standard_bold">Create a new template</font></th>
<th width="50%"><font class="standard_bold">Delete an existing template</font></th>
<tr valign="top">
<td align="left" width='50%'>
<form id="listloader_file_primer" action="leadloader_template_display.php?form_action=prime_file" method="post" enctype="multipart/form-data" target="file_holder">
<font class="standard">Sample file fitting template:<BR><font size="-2">(needed for field assignation)</font></font><?php echo "$NWB#vicidial_template_maker-create_template$NWE"; ?><BR><BR><input type=file name="sample_template_file" value="<?php echo $sample_template_file; ?>" onChange="loadIFrame('prime_file', this.value); this.form.submit();">
</form>
</td>
<td align="left" width='50%'><form action="<?php echo $PHP_SELF; ?>" method="post"><font class="standard">Select template to delete:</font><?php echo "$NWB#vicidial_template_maker-delete_template$NWE"; ?><BR><select name="template_id" onChange="loadIFrame('hide_new_template_form', '')">
<?php
$template_stmt="select template_id, template_name from vicidial_custom_leadloader_templates order by template_id asc";
$template_rslt=mysql_query($template_stmt, $link);
if (mysql_num_rows($template_rslt)>0) {
if ($update_template) {echo "<option value='$update_template' selected>$update_template</option>\n";} else {echo "<option value='' selected>--Choose an existing template--</option>\n";}
while ($template_row=mysql_fetch_array($template_rslt)) {
echo "<option value='$template_row[template_id]'>$template_row[template_id] - $template_row[template_name]</option>\n";
}
} else {
echo "<option value='' selected>--No templates exist--</option>\n";
}
?>
</select><BR/><BR/><input type="submit" value="DELETE TEMPLATE" class="red_btn" name="delete_template">
</form></td>
</tr>
<tr>
<td align=left colspan="2"><font size=1> &nbsp; &nbsp; &nbsp; &nbsp; <a href="admin.php?ADD=100" target="_parent">BACK TO ADMIN</a> &nbsp; &nbsp; &nbsp; &nbsp; <a href="./admin_listloader_fourth_gen.php">Go to Lead Loader</a> &nbsp; &nbsp; </font></td>
</tr>
</tr>
</table>
</form>
<BR/>
<iframe id="file_holder" style="visibility:hidden;display:none" name="file_holder"></iframe>
<span id="list_data_display" style="visibility:hidden;display:none">
<form id="listloader_template_form" name="listloader_template_form" action="<?php echo $PHP_SELF; ?>" method="post" enctype="multipart/form-data">
<table border=0 cellpadding=3 cellspacing=0 width="100%" align="center">
<tr>
<th colspan="2" bgcolor="#330099"><font class="standard" color="white">New template form</font></th>
</tr>
<tr bgcolor="#D9E6FE">
<td align="right" width='25%'><font class="standard">Template ID:</font></td>
<td align="left" width='75%'><input type='text' name='template_id' size='15' maxlength='20'><?php echo "$NWB#vicidial_template_maker-template_id$NWE"; ?></td>
</tr>
<tr bgcolor="#D9E6FE">
<td align="right" width='25%'><font class="standard">Template Name:</font></td>
<td align="left" width='75%'><input type='text' name='template_name' size='15' maxlength='30'><?php echo "$NWB#vicidial_template_maker-template_name$NWE"; ?></td>
</tr>
<tr bgcolor="#D9E6FE">
<td align="right" width='25%'><font class="standard">Template Description:</font></td>
<td align="left" width='75%'><input type='text' name='template_desc' size='50' maxlength='255'><?php echo "$NWB#vicidial_template_maker-template_description$NWE"; ?></td>
</tr>
<tr bgcolor="#D9E6FE">
<td width='25%' align="right"><font class="standard">List ID template will load into:</font></td>
<td width='75%'>
<select id='template_list_id' name='template_list_id' onChange="DisplayTemplateFields(this.value)">
<option value=''>--Select a list below--</option>
<?php
$stmt="SELECT list_id, list_name from vicidial_lists $whereLOGallowed_campaignsSQL order by list_id;";
$rslt=mysql_query($stmt, $link);
$num_rows = mysql_num_rows($rslt);
$count=0;
while ( $num_rows > $count )
{
$row = mysql_fetch_row($rslt);
echo "\t\t\t<option value='$row[0]'>$row[0] - $row[1]</option>\n";
$count++;
}
?>
</select></font><?php echo "$NWB#vicidial_template_maker-list_id$NWE"; ?>
</td>
</tr>
<tr bgcolor="#D9E6FE">
<th colspan='2'><input type='submit' name='submit_template' onClick="return checkForm(this.form)" value='SUBMIT TEMPLATE'></th>
</tr>
<tr bgcolor="#D9E6FE"><td align="center" colspan=2>
<table border=0 cellpadding=3 cellspacing=1 width="100%" align="center">
<tr>
<th colspan="2" bgcolor="#330099"><font class="standard" color="white">Assign columns to file fields<BR/><font size='-2'>(selecting a different list will reset columns)</font></font><?php echo "$NWB#vicidial_template_maker-assign_columns$NWE"; ?></th>
</tr>
<tr valign="top">
<td border="1" align="center" bgcolor="#D9E6FE" width="50%"><font class="standard">Standard Field</font></td>
<td border="0" align="center" bgcolor="#FED9D9" width="50%"><font class="standard">Custom Field</font></td>
</tr>
<tr valign="top">
<td colspan="2" align="center">
<span id="field_display" name="field_display"><font class="standard_bold" color='red'>**Select a list ID from the drop down menu above to show columns**</font></span>
</td>
</tr>
</table>
</tr></td>
</table>
<input type="hidden" id="template_file_type" name="template_file_type">
<input type="hidden" id="template_file_delimiter" name="template_file_delimiter">
<input type="hidden" id="template_file_buffer" name="template_file_buffer">
<input type="hidden" id="standard_fields_layout" name="standard_fields_layout">
<input type="hidden" id="custom_fields_layout" name="custom_fields_layout">
</form>
</span>
</body>
</html>
@@ -0,0 +1,325 @@
<?php
# AST_carrier_log_report.php
#
# Copyright (C) 2012 Joe Johnson, Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES
# 120210-2202 - First build
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
if (isset($_GET["query_date_D"])) {$query_date_D=$_GET["query_date_D"];}
elseif (isset($_POST["query_date_D"])) {$query_date_D=$_POST["query_date_D"];}
if (isset($_GET["query_date_T"])) {$query_date_T=$_GET["query_date_T"];}
elseif (isset($_POST["query_date_T"])) {$query_date_T=$_POST["query_date_T"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["file_download"])) {$file_download=$_GET["file_download"];}
elseif (isset($_POST["file_download"])) {$file_download=$_POST["file_download"];}
if (isset($_GET["lower_limit"])) {$lower_limit=$_GET["lower_limit"];}
elseif (isset($_POST["lower_limit"])) {$lower_limit=$_POST["lower_limit"];}
if (isset($_GET["upper_limit"])) {$upper_limit=$_GET["upper_limit"];}
elseif (isset($_POST["upper_limit"])) {$upper_limit=$_POST["upper_limit"];}
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,outbound_autodial_active,slave_db_server,reports_use_slave_db FROM system_settings;";
$rslt=mysql_query($stmt, $link);
if ($DB) {$MAIN.="$stmt\n";}
$qm_conf_ct = mysql_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysql_fetch_row($rslt);
$non_latin = $row[0];
$outbound_autodial_active = $row[1];
$slave_db_server = $row[2];
$reports_use_slave_db = $row[3];
}
##### END SETTINGS LOOKUP #####
###########################################
if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) )
{
mysql_close($link);
$use_slave_server=1;
$db_source = 'S';
require("dbconnect.php");
$MAIN.="<!-- Using slave server $slave_db_server $db_source -->\n";
}
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level >= 7 and view_reports='1' and active='Y';";
if ($DB) {$MAIN.="|$stmt|\n";}
if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level='7' and view_reports='1' and active='Y';";
if ($DB) {$MAIN.="|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$reports_only_user=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
if (strlen($query_date_D) < 6) {$query_date_D = "00:00:00";}
if (strlen($query_date_T) < 6) {$query_date_T = "23:59:59";}
$NOW_DATE = date("Y-m-d");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$server_ip_string='|';
$server_ip_ct = count($server_ip);
$i=0;
while($i < $server_ip_ct)
{
$server_ip_string .= "$server_ip[$i]|";
$i++;
}
$server_stmt="select distinct s.server_ip, s.server_description from servers s, vicidial_carrier_log vcl where s.server_ip=vcl.server_ip order by server_ip asc";
$server_rslt=mysql_query($server_stmt, $link);
$servers_to_print=mysql_num_rows($server_rslt);
$i=0;
while ($i < $servers_to_print)
{
$row=mysql_fetch_row($server_rslt);
$LISTserverIPs[$i] = $row[0];
$LISTserver_names[$i] = $row[1];
if (ereg("-ALL",$server_ip_string) )
{
$server_ip[$i] = $LISTserverIPs[$i];
}
$i++;
}
$i=0;
$server_ips_string='|';
$server_ip_ct = count($server_ip);
while($i < $server_ip_ct)
{
if ( (strlen($server_ip[$i]) > 0) and (preg_match("/\|$server_ip[$i]\|/",$server_ip_string)) )
{
$server_ips_string .= "$server_ip[$i]|";
$server_ip_SQL .= "'$server_ip[$i]',";
$server_ipQS .= "&server_ip[]=$server_ip[$i]";
}
$i++;
}
if ( (ereg("--ALL--",$server_ip_string) ) or ($server_ip_ct < 1) )
{
$server_ip_SQL = "";
$server_rpt_string="- ALL servers ";
if (ereg("--ALL--",$server_ip_string)) {$server_ipQS="&server_ip[]=--ALL--";}
}
else
{
$server_ip_SQL = eregi_replace(",$",'',$server_ip_SQL);
$server_ip_SQL = "and server_ip IN($server_ip_SQL)";
$server_rpt_string="- server(s) ".preg_replace('/\|/', ", ", substr($server_ip_string, 1, -1));
}
if (strlen($server_ip_SQL)<3) {$server_ip_SQL="";}
$HEADER.="<HTML>\n";
$HEADER.="<HEAD>\n";
$HEADER.="<STYLE type=\"text/css\">\n";
$HEADER.="<!--\n";
$HEADER.=" .green {color: white; background-color: green}\n";
$HEADER.=" .red {color: white; background-color: red}\n";
$HEADER.=" .blue {color: white; background-color: blue}\n";
$HEADER.=" .purple {color: white; background-color: purple}\n";
$HEADER.="-->\n";
$HEADER.=" </STYLE>\n";
$HEADER.="<script language=\"JavaScript\" src=\"calendar_db.js\"></script>\n";
$HEADER.="<link rel=\"stylesheet\" href=\"calendar.css\">\n";
$HEADER.="<link rel=\"stylesheet\" href=\"horizontalbargraph.css\">\n";
$HEADER.="<link rel=\"stylesheet\" href=\"verticalbargraph.css\">\n";
$HEADER.="<script language=\"JavaScript\" src=\"wz_jsgraphics.js\"></script>\n";
$HEADER.="<script language=\"JavaScript\" src=\"line.js\"></script>\n";
$HEADER.="<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
$HEADER.="<TITLE>$report_name</TITLE></HEAD><BODY BGCOLOR=WHITE marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
$short_header=1;
$MAIN.="<TABLE CELLPADDING=4 CELLSPACING=0><TR><TD>";
$MAIN.="<FORM ACTION=\"$PHP_SELF\" METHOD=GET name=vicidial_report id=vicidial_report>\n";
$MAIN.="<TABLE BORDER=0 cellspacing=5 cellpadding=5><TR><TD VALIGN=TOP align=center>\n";
$MAIN.="<INPUT TYPE=HIDDEN NAME=DB VALUE=\"$DB\">\n";
$MAIN.="Date:\n";
$MAIN.="<INPUT TYPE=TEXT NAME=query_date SIZE=10 MAXLENGTH=10 VALUE=\"$query_date\">";
$MAIN.="<script language=\"JavaScript\">\n";
$MAIN.="var o_cal = new tcal ({\n";
$MAIN.=" // form name\n";
$MAIN.=" 'formname': 'vicidial_report',\n";
$MAIN.=" // input name\n";
$MAIN.=" 'controlname': 'query_date'\n";
$MAIN.="});\n";
$MAIN.="o_cal.a_tpl.yearscroll = false;\n";
$MAIN.="// o_cal.a_tpl.weekstart = 1; // Monday week start\n";
$MAIN.="</script>\n";
$MAIN.="<BR><BR><INPUT TYPE=TEXT NAME=query_date_D SIZE=9 MAXLENGTH=8 VALUE=\"$query_date_D\">";
$MAIN.="<BR> to <BR><INPUT TYPE=TEXT NAME=query_date_T SIZE=9 MAXLENGTH=8 VALUE=\"$query_date_T\">";
$MAIN.="</TD><TD ROWSPAN=2 VALIGN=TOP>Server IP:<BR/>\n";
$MAIN.="<SELECT SIZE=5 NAME=server_ip[] multiple>\n";
if (eregi("--ALL--",$server_ip_string))
{$MAIN.="<option value=\"--ALL--\" selected>-- ALL SERVERS --</option>\n";}
else
{$MAIN.="<option value=\"--ALL--\">-- ALL SERVERS --</option>\n";}
$o=0;
while ($servers_to_print > $o)
{
if (ereg("\|$LISTserverIPs[$o]\|",$server_ip_string))
{$MAIN.="<option selected value=\"$LISTserverIPs[$o]\">$LISTserverIPs[$o] - $LISTserver_names[$o]</option>\n";}
else
{$MAIN.="<option value=\"$LISTserverIPs[$o]\">$LISTserverIPs[$o] - $LISTserver_names[$o]</option>\n";}
$o++;
}
$MAIN.="</SELECT></TD><TD ROWSPAN=2 VALIGN=middle align=center>\n";
$MAIN.="<INPUT TYPE=submit NAME=SUBMIT VALUE=SUBMIT><BR/><BR/>\n";
$MAIN.="</TD></TR></TABLE>\n";
if ($SUBMIT && $server_ip_ct>0) {
$stmt="select hangup_cause, dialstatus, count(*) as ct From vicidial_carrier_log where call_date>='$query_date $query_date_D' and call_date<='$query_date $query_date_T' $server_ip_SQL group by hangup_cause, dialstatus order by hangup_cause, dialstatus";
$rslt=mysql_query($stmt, $link);
$MAIN.="<PRE><font size=2>\n";
if ($DB) {$MAIN.=$stmt."\n";}
if (mysql_num_rows($rslt)>0) {
$MAIN.="--- DIAL STATUS BREAKDOWN FOR $query_date, $query_date_D TO $query_date_T $server_rpt_string\n";
$MAIN.="+--------------+-------------+---------+\n";
$MAIN.="| HANGUP CAUSE | DIAL STATUS | COUNT |\n";
$MAIN.="+--------------+-------------+---------+\n";
$total_count=0;
while ($row=mysql_fetch_array($rslt)) {
$MAIN.="| ".sprintf("%-13s", $row["hangup_cause"]);
$MAIN.="| ".sprintf("%-12s", $row["dialstatus"]);
$MAIN.="| ".sprintf("%-8s", $row["ct"]);
$MAIN.="|\n";
$total_count+=$row["ct"];
}
$MAIN.="+--------------+-------------+---------+\n";
$MAIN.="| TOTAL | ".sprintf("%-8s", $total_count)."|\n";
$MAIN.="+--------------+-------------+---------+\n\n\n";
$rpt_stmt="select vicidial_carrier_log.*, vicidial_log.phone_number from vicidial_carrier_log left join vicidial_log on vicidial_log.uniqueid=vicidial_carrier_log.uniqueid where vicidial_carrier_log.call_date>='$query_date $query_date_D' and vicidial_carrier_log.call_date<='$query_date $query_date_T' $server_ip_SQL order by vicidial_carrier_log.call_date asc";
$rpt_rslt=mysql_query($rpt_stmt, $link);
if ($DB) {$MAIN.=$rpt_stmt."\n";}
if (!$lower_limit) {$lower_limit=1;}
if ($lower_limit+999>=mysql_num_rows($rpt_rslt)) {$upper_limit=($lower_limit+mysql_num_rows($rpt_rslt)%1000)-1;} else {$upper_limit=$lower_limit+999;}
$MAIN.="--- CARRIER LOG RECORDS FOR $query_date, $query_date_D TO $query_date_T $server_rpt_string, RECORDS #$lower_limit-$upper_limit <a href=\"$PHP_SELF?SUBMIT=$SUBMIT&DB=$DB&type=$type&query_date=$query_date&query_date_D=$query_date_D&query_date_T=$query_date_T$server_ipQS&lower_limit=$lower_limit&upper_limit=$upper_limit&file_download=1\">[DOWNLOAD]</a>\n";
$carrier_rpt.="+----------------------+---------------------+-----------------+-----------+--------------+-------------+------------------------------------------+-----------+---------------+--------------+\n";
$carrier_rpt.="| UNIQUE ID | CALL DATE | SERVER IP | LEAD ID | HANGUP CAUSE | DIAL STATUS | CHANNEL | DIAL TIME | ANSWERED TIME | PHONE NUMBER |\n";
$carrier_rpt.="+----------------------+---------------------+-----------------+-----------+--------------+-------------+------------------------------------------+-----------+---------------+--------------+\n";
$CSV_text="\"UNIQUE ID\",\"CALL DATE\",\"SERVER IP\",\"LEAD ID\",\"HANGUP CAUSE\",\"DIAL STATUS\",\"CHANNEL\",\"DIAL TIME\",\"ANSWERED TIME\",\"PHONE NUMBER\"\n";
for ($i=1; $i<=mysql_num_rows($rpt_rslt); $i++) {
$row=mysql_fetch_array($rpt_rslt);
$phone_number=""; $phone_note="";
if (strlen($row["phone_number"])==0) {
$stmt2="select phone_number, alt_phone, address3 from vicidial_list where lead_id='$row[lead_id]'";
$rslt2=mysql_query($stmt2, $link);
$channel=$row["channel"];
while ($row2=mysql_fetch_array($rslt2)) {
if (strlen($row2["alt_phone"])>=7 && preg_match("/$row2[alt_phone]/", $channel)) {$phone_number=$row2["alt_phone"]; $phone_note="ALT";}
else if (strlen($row2["address3"])>=7 && preg_match("/$row2[address3]/", $channel)) {$phone_number=$row2["address3"]; $phone_note="ADDR3";}
else if (strlen($row2["phone_number"])>=7 && preg_match("/$row2[phone_number]/", $channel)) {$phone_number=$row2["phone_number"]; $phone_note="*";}
}
} else {
$phone_number=$row["phone_number"];
}
$CSV_text.="\"$row[uniqueid]\",\"$row[call_date]\",\"$row[server_ip]\",\"$row[lead_id]\",\"$row[hangup_cause]\",\"$row[dialstatus]\",\"$row[channel]\",\"$row[dial_time]\",\"$row[answered_time]\",\"$phone_number\"\n";
if ($i>=$lower_limit && $i<=$upper_limit) {
if (strlen($row["channel"])>37) {$row["channel"]=substr($row["channel"],0,37)."...";}
$carrier_rpt.="| ".sprintf("%-21s", $row["uniqueid"]);
$carrier_rpt.="| ".sprintf("%-20s", $row["call_date"]);
$carrier_rpt.="| ".sprintf("%-16s", $row["server_ip"]);
$carrier_rpt.="| ".sprintf("%-10s", $row["lead_id"]);
$carrier_rpt.="| ".sprintf("%-13s", $row["hangup_cause"]);
$carrier_rpt.="| ".sprintf("%-12s", $row["dialstatus"]);
$carrier_rpt.="| ".sprintf("%-41s", $row["channel"]);
$carrier_rpt.="| ".sprintf("%-10s", $row["dial_time"]);
$carrier_rpt.="| ".sprintf("%-14s", $row["answered_time"]);
$carrier_rpt.="| ".sprintf("%-13s", $phone_number)."|\n";
}
}
$carrier_rpt.="+----------------------+---------------------+-----------------+-----------+--------------+-------------+------------------------------------------+-----------+---------------+--------------+\n";
$carrier_rpt_hf="";
$ll=$lower_limit-1000;
if ($ll>=1) {
$carrier_rpt_hf.="<a href=\"$PHP_SELF?SUBMIT=$SUBMIT&DB=$DB&type=$type&query_date=$query_date&query_date_D=$query_date_D&query_date_T=$query_date_T$server_ipQS&lower_limit=$ll\">[<<< PREV 1000 records]</a>";
} else {
$carrier_rpt_hf.=sprintf("%-23s", " ");
}
$carrier_rpt_hf.=sprintf("%-145s", " ");
if (($lower_limit+1000)<mysql_num_rows($rpt_rslt)) {
if ($upper_limit+1000>=mysql_num_rows($rpt_rslt)) {$max_limit=mysql_num_rows($rpt_rslt)-$upper_limit;} else {$max_limit=1000;}
$carrier_rpt_hf.="<a href=\"$PHP_SELF?SUBMIT=$SUBMIT&DB=$DB&type=$type&query_date=$query_date&query_date_D=$query_date_D&query_date_T=$query_date_T$server_ipQS&lower_limit=".($lower_limit+1000)."\">[NEXT $max_limit records >>>]</a>";
} else {
$carrier_rpt_hf.=sprintf("%23s", " ");
}
$carrier_rpt_hf.="\n";
$MAIN.=$carrier_rpt_hf.$carrier_rpt.$carrier_rpt_hf;
} else {
$MAIN.="*** NO RECORDS FOUND ***\n";
}
$MAIN.="</font></PRE>\n";
$MAIN.="</form></BODY></HTML>\n";
}
if ($file_download>0) {
$FILE_TIME = date("Ymd-His");
$CSVfilename = "AST_carrier_log_report_$US$FILE_TIME.csv";
$CSV_text=preg_replace('/ +\"/', '"', $CSV_text);
$CSV_text=preg_replace('/\" +/', '"', $CSV_text);
// We'll be outputting a TXT file
header('Content-type: application/octet-stream');
// It will be called LIST_101_20090209-121212.txt
header("Content-Disposition: attachment; filename=\"$CSVfilename\"");
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
ob_clean();
flush();
echo "$CSV_text";
exit;
} else {
echo $HEADER;
require("admin_header.php");
echo $MAIN;
}
?>
@@ -0,0 +1,413 @@
<?php
# AST_carrier_log_report.php
#
# Copyright (C) 2012 Joe Johnson, Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES
# 120331-2301 - First build
#
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];}
elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];}
if (isset($_GET["query_date_D"])) {$query_date_D=$_GET["query_date_D"];}
elseif (isset($_POST["query_date_D"])) {$query_date_D=$_POST["query_date_D"];}
if (isset($_GET["query_date_T"])) {$query_date_T=$_GET["query_date_T"];}
elseif (isset($_POST["query_date_T"])) {$query_date_T=$_POST["query_date_T"];}
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
if (isset($_GET["hangup_cause"])) {$hangup_cause=$_GET["hangup_cause"];}
elseif (isset($_POST["hangup_cause"])) {$hangup_cause=$_POST["hangup_cause"];}
if (isset($_GET["file_download"])) {$file_download=$_GET["file_download"];}
elseif (isset($_POST["file_download"])) {$file_download=$_POST["file_download"];}
if (isset($_GET["lower_limit"])) {$lower_limit=$_GET["lower_limit"];}
elseif (isset($_POST["lower_limit"])) {$lower_limit=$_POST["lower_limit"];}
if (isset($_GET["upper_limit"])) {$upper_limit=$_GET["upper_limit"];}
elseif (isset($_POST["upper_limit"])) {$upper_limit=$_POST["upper_limit"];}
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,outbound_autodial_active,slave_db_server,reports_use_slave_db FROM system_settings;";
$rslt=mysql_query($stmt, $link);
if ($DB) {$MAIN.="$stmt\n";}
$qm_conf_ct = mysql_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysql_fetch_row($rslt);
$non_latin = $row[0];
$outbound_autodial_active = $row[1];
$slave_db_server = $row[2];
$reports_use_slave_db = $row[3];
}
##### END SETTINGS LOOKUP #####
###########################################
if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) )
{
mysql_close($link);
$use_slave_server=1;
$db_source = 'S';
require("dbconnect.php");
$MAIN.="<!-- Using slave server $slave_db_server $db_source -->\n";
}
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level >= 7 and view_reports='1' and active='Y';";
if ($DB) {$MAIN.="|$stmt|\n";}
if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level='7' and view_reports='1' and active='Y';";
if ($DB) {$MAIN.="|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$reports_only_user=$row[0];
if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
{
Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
if (strlen($query_date_D) < 6) {$query_date_D = "00:00:00";}
if (strlen($query_date_T) < 6) {$query_date_T = "23:59:59";}
$NOW_DATE = date("Y-m-d");
if (!isset($query_date)) {$query_date = $NOW_DATE;}
$server_ip_string='|';
$server_ip_ct = count($server_ip);
$i=0;
while($i < $server_ip_ct)
{
$server_ip_string .= "$server_ip[$i]|";
$i++;
}
$server_stmt="select distinct s.server_ip, s.server_description from servers s, vicidial_carrier_log vcl where s.server_ip=vcl.server_ip order by server_ip asc";
$server_rslt=mysql_query($server_stmt, $link);
$servers_to_print=mysql_num_rows($server_rslt);
$i=0;
while ($i < $servers_to_print)
{
$row=mysql_fetch_row($server_rslt);
$LISTserverIPs[$i] = $row[0];
$LISTserver_names[$i] = $row[1];
if (ereg("-ALL",$server_ip_string) )
{
$server_ip[$i] = $LISTserverIPs[$i];
}
$i++;
}
$i=0;
$server_ips_string='|';
$server_ip_ct = count($server_ip);
while($i < $server_ip_ct)
{
if ( (strlen($server_ip[$i]) > 0) and (preg_match("/\|$server_ip[$i]\|/",$server_ip_string)) )
{
$server_ips_string .= "$server_ip[$i]|";
$server_ip_SQL .= "'$server_ip[$i]',";
$server_ipQS .= "&server_ip[]=$server_ip[$i]";
}
$i++;
}
if ( (ereg("--ALL--",$server_ip_string) ) or ($server_ip_ct < 1) )
{
$server_ip_SQL = "";
$server_rpt_string="- ALL servers ";
if (ereg("--ALL--",$server_ip_string)) {$server_ipQS="&server_ip[]=--ALL--";}
}
else
{
$server_ip_SQL = eregi_replace(",$",'',$server_ip_SQL);
$server_ip_SQL = "and server_ip IN($server_ip_SQL)";
$server_rpt_string="- server(s) ".preg_replace('/\|/', ", ", substr($server_ip_string, 1, -1));
}
if (strlen($server_ip_SQL)<3) {$server_ip_SQL="";}
########### HANGUP CAUSES
$hangup_cause_string='|';
$dialstatus_string='|';
$hangup_and_dialstatus_string='|';
$hangup_cause_ct = count($hangup_cause);
$i=0;
while($i < $hangup_cause_ct)
{
$hangup_array=explode("!", $hangup_cause[$i]);
$hangup_and_dialstatus_string .= "$hangup_cause[$i]|";
$hangup_cause_string .= "$hangup_array[0]|";
$dialstatus_string .= "$hangup_array[1]|";
$i++;
}
$hangupcause_stmt="select distinct hangup_cause, dialstatus from vicidial_carrier_log order by dialstatus, hangup_cause asc";
$hangupcause_rslt=mysql_query($hangupcause_stmt, $link);
$causes_to_print=mysql_num_rows($hangupcause_rslt);
$i=0;
while ($i < $causes_to_print)
{
$row=mysql_fetch_row($hangupcause_rslt);
$LISThangup_causes[$i] = $row[0];
$LISTdialstatuses[$i] = $row[1];
if (ereg("-ALL",$hangup_cause_string) )
{
$hangup_cause[$i] = $LISThangup_causes[$i];
$dialstatus[$i] = $LISTdialstatuses[$i];
}
$i++;
}
$i=0;
$hangup_causes_string='|';
$hangup_cause_ct = count($hangup_cause);
while($i < $hangup_cause_ct)
{
$hangup_array=explode("!", $hangup_cause[$i]);
if ( (strlen($hangup_array[0]) > 0) and (preg_match("/\|$hangup_array[0]\|/",$hangup_cause_string)) and (strlen($hangup_array[1]) > 0) and (preg_match("/\|$hangup_array[1]\|/",$dialstatus_string)) )
{
$hangup_causes_string .= "$hangup_array[0]|";
$hangup_cause_SQL .= "(hangup_cause='$hangup_array[0]' and dialstatus='$hangup_array[1]') OR";
$hangup_causeQS .= "&hangup_cause[]=$hangup_cause[$i]";
}
$i++;
}
if ( (ereg("--ALL--",$hangup_cause_string) ) or ($hangup_cause_ct < 1) )
{
$hangup_cause_SQL = "";
$HC_rpt_string="- ALL hangup causes ";
if (ereg("--ALL--",$hangup_cause_string)) {$hangup_causeQS="&hangup_cause[]=--ALL--";}
}
else
{
$hangup_cause_SQL=preg_replace('/ OR$/', '', $hangup_cause_SQL);
$hangup_cause_SQL = eregi_replace(",$",'',$hangup_cause_SQL);
$hangup_cause_SQL = "and ($hangup_cause_SQL)";
$hangup_and_dialstatus_string=preg_replace('/\!/', "-", $hangup_and_dialstatus_string);
$HC_rpt_string="AND hangup cause(s) ".preg_replace('/\|/', ", ", substr($hangup_and_dialstatus_string, 1, -1));
}
if (strlen($hangup_cause_SQL)<3) {$hangup_cause_SQL="";}
########################
$HEADER.="<HTML>\n";
$HEADER.="<HEAD>\n";
$HEADER.="<STYLE type=\"text/css\">\n";
$HEADER.="<!--\n";
$HEADER.=" .green {color: white; background-color: green}\n";
$HEADER.=" .red {color: white; background-color: red}\n";
$HEADER.=" .blue {color: white; background-color: blue}\n";
$HEADER.=" .purple {color: white; background-color: purple}\n";
$HEADER.="-->\n";
$HEADER.=" </STYLE>\n";
$HEADER.="<script language=\"JavaScript\" src=\"calendar_db.js\"></script>\n";
$HEADER.="<link rel=\"stylesheet\" href=\"calendar.css\">\n";
$HEADER.="<link rel=\"stylesheet\" href=\"horizontalbargraph.css\">\n";
$HEADER.="<link rel=\"stylesheet\" href=\"verticalbargraph.css\">\n";
$HEADER.="<script language=\"JavaScript\" src=\"wz_jsgraphics.js\"></script>\n";
$HEADER.="<script language=\"JavaScript\" src=\"line.js\"></script>\n";
$HEADER.="<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n";
$HEADER.="<TITLE>$report_name</TITLE></HEAD><BODY BGCOLOR=WHITE marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
$short_header=1;
$MAIN.="<TABLE CELLPADDING=4 CELLSPACING=0><TR><TD>";
$MAIN.="<FORM ACTION=\"$PHP_SELF\" METHOD=GET name=vicidial_report id=vicidial_report>\n";
$MAIN.="<TABLE BORDER=0 cellspacing=5 cellpadding=5><TR><TD VALIGN=TOP align=center>\n";
$MAIN.="<INPUT TYPE=HIDDEN NAME=DB VALUE=\"$DB\">\n";
$MAIN.="Date:\n";
$MAIN.="<INPUT TYPE=TEXT NAME=query_date SIZE=10 MAXLENGTH=10 VALUE=\"$query_date\">";
$MAIN.="<script language=\"JavaScript\">\n";
$MAIN.="var o_cal = new tcal ({\n";
$MAIN.=" // form name\n";
$MAIN.=" 'formname': 'vicidial_report',\n";
$MAIN.=" // input name\n";
$MAIN.=" 'controlname': 'query_date'\n";
$MAIN.="});\n";
$MAIN.="o_cal.a_tpl.yearscroll = false;\n";
$MAIN.="// o_cal.a_tpl.weekstart = 1; // Monday week start\n";
$MAIN.="</script>\n";
$MAIN.="<BR><BR><INPUT TYPE=TEXT NAME=query_date_D SIZE=9 MAXLENGTH=8 VALUE=\"$query_date_D\">";
$MAIN.="<BR> to <BR><INPUT TYPE=TEXT NAME=query_date_T SIZE=9 MAXLENGTH=8 VALUE=\"$query_date_T\">";
$MAIN.="</TD><TD ROWSPAN=2 VALIGN=TOP>Server IP:<BR/>\n";
$MAIN.="<SELECT SIZE=5 NAME=server_ip[] multiple>\n";
if (eregi("--ALL--",$server_ip_string))
{$MAIN.="<option value=\"--ALL--\" selected>-- ALL SERVERS --</option>\n";}
else
{$MAIN.="<option value=\"--ALL--\">-- ALL SERVERS --</option>\n";}
$o=0;
while ($servers_to_print > $o)
{
if (ereg("\|$LISTserverIPs[$o]\|",$server_ip_string))
{$MAIN.="<option selected value=\"$LISTserverIPs[$o]\">$LISTserverIPs[$o] - $LISTserver_names[$o]</option>\n";}
else
{$MAIN.="<option value=\"$LISTserverIPs[$o]\">$LISTserverIPs[$o] - $LISTserver_names[$o]</option>\n";}
$o++;
}
$MAIN.="</SELECT></TD>";
$MAIN.="<TD ROWSPAN=2 VALIGN=top align=center>Hangup Cause/Dial Status:<BR/>";
$MAIN.="<SELECT SIZE=5 NAME=hangup_cause[] multiple>\n";
if (eregi("--ALL--",$hangup_cause_string))
{$MAIN.="<option value=\"--ALL--\" selected>-- ALL HANGUP CAUSES --</option>\n";}
else
{$MAIN.="<option value=\"--ALL--\">-- ALL HANGUP CAUSES --</option>\n";}
$o=0;
while ($causes_to_print > $o)
{
if (ereg("\|$LISThangup_causes[$o]!$LISTdialstatuses[$o]\|",$hangup_and_dialstatus_string))
{$MAIN.="<option selected value=\"$LISThangup_causes[$o]!$LISTdialstatuses[$o]\">$LISThangup_causes[$o] - $LISTdialstatuses[$o]</option>\n";}
else
{$MAIN.="<option value=\"$LISThangup_causes[$o]!$LISTdialstatuses[$o]\">$LISThangup_causes[$o] - $LISTdialstatuses[$o]</option>\n";}
$o++;
}
$MAIN.="</SELECT></TD>";
$MAIN.="<TD ROWSPAN=2 VALIGN=top align=center>";
$MAIN.="</TD>\n";
$MAIN.="<TD ROWSPAN=2 VALIGN=middle align=center>\n";
$MAIN.="<INPUT TYPE=submit NAME=SUBMIT VALUE=SUBMIT><BR/><BR/>\n";
$MAIN.="</TD></TR></TABLE>\n";
if ($SUBMIT && $server_ip_ct>0) {
$stmt="select hangup_cause, dialstatus, count(*) as ct From vicidial_carrier_log where call_date>='$query_date $query_date_D' and call_date<='$query_date $query_date_T' $server_ip_SQL $hangup_cause_SQL group by hangup_cause, dialstatus order by hangup_cause, dialstatus";
$rslt=mysql_query($stmt, $link);
$MAIN.="<PRE><font size=2>\n";
if ($DB) {$MAIN.=$stmt."\n";}
if (mysql_num_rows($rslt)>0) {
$MAIN.="--- DIAL STATUS BREAKDOWN FOR $query_date, $query_date_D TO $query_date_T $server_rpt_string\n";
$MAIN.="+--------------+-------------+---------+\n";
$MAIN.="| HANGUP CAUSE | DIAL STATUS | COUNT |\n";
$MAIN.="+--------------+-------------+---------+\n";
$total_count=0;
while ($row=mysql_fetch_array($rslt)) {
$MAIN.="| ".sprintf("%-13s", $row["hangup_cause"]);
$MAIN.="| ".sprintf("%-12s", $row["dialstatus"]);
$MAIN.="| ".sprintf("%-8s", $row["ct"]);
$MAIN.="|\n";
$total_count+=$row["ct"];
}
$MAIN.="+--------------+-------------+---------+\n";
$MAIN.="| TOTAL | ".sprintf("%-8s", $total_count)."|\n";
$MAIN.="+--------------+-------------+---------+\n\n\n";
$rpt_stmt="select vicidial_carrier_log.*, vicidial_log.phone_number from vicidial_carrier_log left join vicidial_log on vicidial_log.uniqueid=vicidial_carrier_log.uniqueid where vicidial_carrier_log.call_date>='$query_date $query_date_D' and vicidial_carrier_log.call_date<='$query_date $query_date_T' $server_ip_SQL $hangup_cause_SQL order by vicidial_carrier_log.call_date asc";
$rpt_rslt=mysql_query($rpt_stmt, $link);
if ($DB) {$MAIN.=$rpt_stmt."\n";}
if (!$lower_limit) {$lower_limit=1;}
if ($lower_limit+999>=mysql_num_rows($rpt_rslt)) {$upper_limit=($lower_limit+mysql_num_rows($rpt_rslt)%1000)-1;} else {$upper_limit=$lower_limit+999;}
$MAIN.="--- CARRIER LOG RECORDS FOR $query_date, $query_date_D TO $query_date_T $server_rpt_string, $HC_rpt_string\n --- RECORDS #$lower_limit-$upper_limit <a href=\"$PHP_SELF?SUBMIT=$SUBMIT&DB=$DB&type=$type&query_date=$query_date&query_date_D=$query_date_D&query_date_T=$query_date_T$server_ipQS&lower_limit=$lower_limit&upper_limit=$upper_limit&file_download=1\">[DOWNLOAD]</a>\n";
$carrier_rpt.="+----------------------+---------------------+-----------------+-----------+--------------+-------------+------------------------------------------+-----------+---------------+--------------+\n";
$carrier_rpt.="| UNIQUE ID | CALL DATE | SERVER IP | LEAD ID | HANGUP CAUSE | DIAL STATUS | CHANNEL | DIAL TIME | ANSWERED TIME | PHONE NUMBER |\n";
$carrier_rpt.="+----------------------+---------------------+-----------------+-----------+--------------+-------------+------------------------------------------+-----------+---------------+--------------+\n";
$CSV_text="\"UNIQUE ID\",\"CALL DATE\",\"SERVER IP\",\"LEAD ID\",\"HANGUP CAUSE\",\"DIAL STATUS\",\"CHANNEL\",\"DIAL TIME\",\"ANSWERED TIME\",\"PHONE NUMBER\"\n";
for ($i=1; $i<=mysql_num_rows($rpt_rslt); $i++) {
$row=mysql_fetch_array($rpt_rslt);
$phone_number=""; $phone_note="";
if (strlen($row["phone_number"])==0) {
$stmt2="select phone_number, alt_phone, address3 from vicidial_list where lead_id='$row[lead_id]'";
$rslt2=mysql_query($stmt2, $link);
$channel=$row["channel"];
while ($row2=mysql_fetch_array($rslt2)) {
if (strlen($row2["alt_phone"])>=7 && preg_match("/$row2[alt_phone]/", $channel)) {$phone_number=$row2["alt_phone"]; $phone_note="ALT";}
else if (strlen($row2["address3"])>=7 && preg_match("/$row2[address3]/", $channel)) {$phone_number=$row2["address3"]; $phone_note="ADDR3";}
else if (strlen($row2["phone_number"])>=7 && preg_match("/$row2[phone_number]/", $channel)) {$phone_number=$row2["phone_number"]; $phone_note="*";}
}
} else {
$phone_number=$row["phone_number"];
}
$CSV_text.="\"$row[uniqueid]\",\"$row[call_date]\",\"$row[server_ip]\",\"$row[lead_id]\",\"$row[hangup_cause]\",\"$row[dialstatus]\",\"$row[channel]\",\"$row[dial_time]\",\"$row[answered_time]\",\"$phone_number\"\n";
if ($i>=$lower_limit && $i<=$upper_limit) {
if (strlen($row["channel"])>37) {$row["channel"]=substr($row["channel"],0,37)."...";}
$carrier_rpt.="| ".sprintf("%-21s", $row["uniqueid"]);
$carrier_rpt.="| ".sprintf("%-20s", $row["call_date"]);
$carrier_rpt.="| ".sprintf("%-16s", $row["server_ip"]);
$carrier_rpt.="| ".sprintf("%-10s", $row["lead_id"]);
$carrier_rpt.="| ".sprintf("%-13s", $row["hangup_cause"]);
$carrier_rpt.="| ".sprintf("%-12s", $row["dialstatus"]);
$carrier_rpt.="| ".sprintf("%-41s", $row["channel"]);
$carrier_rpt.="| ".sprintf("%-10s", $row["dial_time"]);
$carrier_rpt.="| ".sprintf("%-14s", $row["answered_time"]);
$carrier_rpt.="| ".sprintf("%-13s", $phone_number)."|\n";
}
}
$carrier_rpt.="+----------------------+---------------------+-----------------+-----------+--------------+-------------+------------------------------------------+-----------+---------------+--------------+\n";
$carrier_rpt_hf="";
$ll=$lower_limit-1000;
if ($ll>=1) {
$carrier_rpt_hf.="<a href=\"$PHP_SELF?SUBMIT=$SUBMIT&DB=$DB&type=$type&query_date=$query_date&query_date_D=$query_date_D&query_date_T=$query_date_T$hangup_causeQS$server_ipQS&lower_limit=$ll\">[<<< PREV 1000 records]</a>";
} else {
$carrier_rpt_hf.=sprintf("%-23s", " ");
}
$carrier_rpt_hf.=sprintf("%-145s", " ");
if (($lower_limit+1000)<mysql_num_rows($rpt_rslt)) {
if ($upper_limit+1000>=mysql_num_rows($rpt_rslt)) {$max_limit=mysql_num_rows($rpt_rslt)-$upper_limit;} else {$max_limit=1000;}
$carrier_rpt_hf.="<a href=\"$PHP_SELF?SUBMIT=$SUBMIT&DB=$DB&type=$type&query_date=$query_date&query_date_D=$query_date_D&query_date_T=$query_date_T$server_ipQS$hangup_causeQS&lower_limit=".($lower_limit+1000)."\">[NEXT $max_limit records >>>]</a>";
} else {
$carrier_rpt_hf.=sprintf("%23s", " ");
}
$carrier_rpt_hf.="\n";
$MAIN.=$carrier_rpt_hf.$carrier_rpt.$carrier_rpt_hf;
} else {
$MAIN.="*** NO RECORDS FOUND ***\n";
}
$MAIN.="</font></PRE>\n";
$MAIN.="</form></BODY></HTML>\n";
}
if ($file_download>0) {
$FILE_TIME = date("Ymd-His");
$CSVfilename = "AST_carrier_log_report_$US$FILE_TIME.csv";
$CSV_text=preg_replace('/ +\"/', '"', $CSV_text);
$CSV_text=preg_replace('/\" +/', '"', $CSV_text);
// We'll be outputting a TXT file
header('Content-type: application/octet-stream');
// It will be called LIST_101_20090209-121212.txt
header("Content-Disposition: attachment; filename=\"$CSVfilename\"");
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
ob_clean();
flush();
echo "$CSV_text";
exit;
} else {
echo $HEADER;
require("admin_header.php");
echo $MAIN;
}
?>
+57 -2
View File
@@ -3044,12 +3044,13 @@ else
# 120221-0054 - Fixed Call Time and User Group restrictions on several pages
# 120221-1647 - Added inventory report options to lists and shifts
# 120316-1203 - Fixed DIALBLE counts for completed statuses
# 120402-2111 - Added lead loading template and two carrier log reports to the admin utils page
#
# make sure you have added a user to the vicidial_users MySQL table with at least user_level 8 to access this page the first time
$admin_version = '2.4-362a';
$build = '120316-1203';
$admin_version = '2.4-363a';
$build = '120402-2111';
$STARTtime = date("U");
$SQLdate = date("Y-m-d H:i:s");
@@ -7151,6 +7152,15 @@ if ($ADD==99999)
<BR>NOTES: The Excel Lead loader functionality is enabled by a series of perl scripts and needs to have a properly configured /etc/astguiclient.conf file in place on the web server. Also, a couple perl modules must be loaded for it to work as well - OLE-Storage_Lite and Spreadsheet-ParseExcel. You can check for runtime errors in these by looking at your apache error_log file. Also, for duplication checks against gampaign lists, the list that has new leads going into it does need to be created in the system before you start to load the leads.
<BR>
<A NAME="vicidial_list_loader-file_layout">
<BR>
<B>File layout - </B>The layout of the file you are loading. "Standard Format" uses the pre-defined Vicidial standard file format. "Custom layout" allows the user to define the layout of the file themselves. "Custom template" is a hybrid of the previous two options, which allows the user to use a custom format they have defined previously and saved using the Custom Template Maker.
<BR>
<A NAME="vicidial_list_loader-template_id">
<BR>
<B>Template ID -</B> If the user has selected "Custom layout" from the "File layout" options, then this the the template the lead loader will use. It will also override the selected list ID with the list ID that was assigned to the selected template when it was created.
@@ -8437,6 +8447,49 @@ if ($ADD==99999)
<BR><BR><BR><BR>
<B><FONT SIZE=3>VICIDIAL CUSTOM TEMPLATE MAKER</FONT></B><BR><BR>
<A NAME="vicidial_template_maker">
<BR>
The Vicidial custom template maker allows you to define your own file layouts for use with the Vicidial listloader and also delete them, if necessary. If you frequently upload files that are in a consistent layout other than the Vicidial standard layout, you may find this tool helpful. The saved layout will work on any uploaded file it matches, regardless of file type or delimiter.
<BR>
<A NAME="vicidial_template_maker-create_template">
<BR>
<B>Create a new template - </B>In order to begin creating your new listloader template, you must first load a lead file that has the layout you wish to create the template for. Click "Choose file", and open the file on your computer you wish to use. This will upload a copy to your server and process it to determine the file type and delimiter (for TXT files).
<BR>
<A NAME="vicidial_template_maker-delete_template">
<BR>
<B>Delete template -</B> If you have a template you no longer use or you mis-entered information on it and would like to re-enter it, select the template from the drop-down menu and click "DELETE TEMPLATE".
<BR>
<A NAME="vicidial_template_maker-template_id">
<BR>
<B>Template ID -</B> This field is where you enter an arbitrary ID for your new custom template. It must be between 2 and 20 characters and consist of alphanumeric characters and underscores.
<BR>
<A NAME="vicidial_template_maker-template_name">
<BR>
<B>Template Name -</B> This field is where you enter the name for your new custom template. Can be up to 30 characters long.
<BR>
<A NAME="vicidial_template_maker-template_description">
<BR>
<B>Template Description -</B> This field is where you enter the description for your new custom template. It can be up to 255 characters long.
<BR>
<A NAME="vicidial_template_maker-list_id">
<BR>
<B>List ID -</B> All templates must load their records into a list. Select a list ID to load leads into from this drop-down list, which will display any lists available to you given your user settings.
<BR>
<A NAME="vicidial_template_maker-assign_columns">
<BR>
<B>Assigning columns -</B> Once you have loaded a sample file matching the layout you wish to make into a template and select a list ID to load leads into, all the available columns from the vicidial_list table and the custom table for the list you selected (if any) will be displayed here. Columns highlighted in blue are standard columns from the vicidial_list table. Columns highlighted in pink belong to the custom table for the selected list. Each column listed has a drop-down menu, which should be populated with the fields from the first row of the sample file you uploaded. Assign the appropriate fields to the appropriate columns and press "SUBMIT TEMPLATE" to create your template. You do not need to assign every field to a column, and you do not need to assign every column a field. For details on the standard vicidial_list columns, click <a href="#vicidial_list_loader">HERE</a>.
<BR><BR><BR><BR>
<B><FONT SIZE=3>Maximum System Stats Reports</FONT></B><BR><BR>
@@ -32960,6 +33013,8 @@ if ($ADD==999994)
echo "<UL>\n";
echo "<LI><a href=\"welcome_languages.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>Welcome Languages Page</a></FONT>\n";
echo "<LI><a href=\"campaign_debug.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>Campaign Debug Page</a></FONT>\n";
echo "<LI><a href=\"AST_carrier_log_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>Carrier Log Report</a></FONT>\n";
echo "<LI><a href=\"AST_hangup_cause_report.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>Hangup Cause Report</a></FONT>\n";
echo "<LI><a href=\"admin_phones_bulk_insert.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>Bulk Phone Insert Page</a></FONT>\n";
echo "<LI><a href=\"send_CID_call.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>Send a Call With Custom CID Page</a></FONT>\n";
echo "<LI><a href=\"voice_lab.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>Speech Voice Lab Page</a></FONT>\n";
+3 -2
View File
@@ -1,7 +1,7 @@
<?php
# admin_header.php - VICIDIAL administration header
#
# Copyright (C) 2011 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2012 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES
@@ -36,6 +36,7 @@
# 111015-2305 - Added Contacts menu to Admin
# 111106-0939 - Changes for user group restrictions
# 111116-0208 - Added ALT and ADDR3 in-group handle methods
# 120402-2134 - Changed lead loader link to fourth gen
#
@@ -1188,7 +1189,7 @@ $SScustom_fields_enabled = $row[3];
</TR><TR BGCOLOR=<?php echo $lists_color ?>><TD ALIGN=LEFT> &nbsp;
<a href="<?php echo $ADMIN ?>?ADD=121"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=<?php echo $subheader_font_size ?>> <?php echo $DNClink ?> </a>
</TR><TR BGCOLOR=<?php echo $lists_color ?>><TD ALIGN=LEFT> &nbsp;
<a href="./admin_listloader_third_gen.php"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=<?php echo $subheader_font_size ?>> Load New Leads </a>
<a href="./admin_listloader_fourth_gen.php"><FONT FACE="ARIAL,HELVETICA" COLOR=BLACK SIZE=<?php echo $subheader_font_size ?>> Load New Leads </a>
<?php
if ($SScustom_fields_enabled > 0)
{
File diff suppressed because it is too large Load Diff