Added did_log_export and recording_lookup functions to the non-agent API
Fixed rare VDAC-missing bug git-svn-id: svn://192.168.202.10@1560 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
@@ -22,7 +22,11 @@ OPTIONAL STEPS(But highly recommended) - Backup existing system:
|
||||
|
||||
REQUIRED STEPS!!!
|
||||
|
||||
1. upgrade the MySQL asterisk database:
|
||||
1. upgrade the MySQL asterisk database(you have two options):
|
||||
A. Running the upgrade file directly from Linux:
|
||||
mysql -f --database=asterisk < /path/from/root/extras/upgrade_2.4.sql
|
||||
|
||||
B. Going into mysql and executing the upgrade sql file:
|
||||
mysql
|
||||
use asterisk
|
||||
\. /path/from/root/extras/upgrade_2.4.sql
|
||||
@@ -407,6 +411,8 @@ OTHER CHANGES:
|
||||
93. Added script to purge all vicidial_callbacks records that are inactive or
|
||||
are tied to deleted leads, AST_DB_dead_cb_purge.pl
|
||||
|
||||
94. Added did_log_export and recording_lookup functions to the non-agent API
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -78,12 +78,13 @@
|
||||
# 100623-1310 - Added queue_priority to queue processing
|
||||
# 100727-1653 - Fixes for queue priority feature
|
||||
# 100903-0041 - Changed lead_id max length to 10 digits
|
||||
# 101207-0713 - Added fix for rare VDAC-entry-missing issue
|
||||
#
|
||||
|
||||
$script = 'agi-VDAD_ALL_outbound.agi';
|
||||
$AGILOG = '0';
|
||||
$mel=1; # Mysql Error Log enabled = 1
|
||||
$mysql_log_count=69;
|
||||
$mysql_log_count=71;
|
||||
$one_mysql_log=0;
|
||||
|
||||
|
||||
@@ -369,10 +370,48 @@ if ($dialplan_duplicate_count > 0)
|
||||
|
||||
### Grab call parameters from vicidial_auto_calls table
|
||||
$stmtA = "UPDATE vicidial_auto_calls set uniqueid='$unique_id', channel='$channel',status='LIVE',stage='LIVE-0' where callerid='$callerid' order by call_time desc limit 1;";
|
||||
$affected_rows = $dbhA->do($stmtA);
|
||||
$VDACaffected_rows = $dbhA->do($stmtA);
|
||||
$dbhP=$dbhA; $mysql_count='01004'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
|
||||
if ($AGILOG) {$agi_string = "-- VDAD : |$affected_rows|update of vac table: $callerid\n|$stmtA|"; &agi_output;}
|
||||
if ($affected_rows > 0)
|
||||
if ($VDACaffected_rows < 1)
|
||||
{
|
||||
if ($AGILOG) {$agi_string = "-- NO VDAC FOUND!!!!!: $callerid"; &agi_output;}
|
||||
|
||||
$stmtA = "SELECT cmd_line_k,entry_date FROM vicidial_manager where callerid='$callerid' order by call_time desc limit 1;";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
$sthArows=$sthA->rows;
|
||||
$dbhP=$dbhA; $mysql_count='01070'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
|
||||
if ($sthArows > 0)
|
||||
{
|
||||
@aryA = $sthA->fetchrow_array;
|
||||
$VDADnotes = $aryA[0];
|
||||
@notes_ARY = split(/VDACnote: /,$VDADnotes);
|
||||
@VDAC_ARY = split(/\|/,$notes_ARY[1]);
|
||||
$VDADcampaign = $VDAC_ARY[0];
|
||||
$VDADlead_id = $VDAC_ARY[1];
|
||||
$VDADphone_code = $VDAC_ARY[2];
|
||||
$VDADphone = $VDAC_ARY[3];
|
||||
$VDADorigin = $VDAC_ARY[4];
|
||||
$VDADcall_time = $aryA[1];
|
||||
$VDADalt_dial = $VDAC_ARY[5];
|
||||
$VDADqueue_priority = $VDAC_ARY[6];
|
||||
$sthA->finish();
|
||||
$VDACaffected_rows=1;
|
||||
|
||||
$stmtA = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,uniqueid,callerid,channel,phone_code,phone_number,call_time,call_type,stage,queue_priority) values('$VARserver_ip','$VDADcampaign','LIVE','$VDADlead_id','$uniqueid','$callerid','$channel','$VDADphone_code','$VDADphone','$VDADcall_time','$VDADorigin','LIVE-0','$VDADqueue_priority')";
|
||||
$affected_rows = $dbhA->do($stmtA);
|
||||
$dbhP=$dbhA; $mysql_count='01071'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
|
||||
if ($AGILOG) {$agi_string = "$affected_rows|VDAC-reinsert|$stmtA|"; &agi_output;}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($AGILOG) {$agi_string = "-- NO VDM FOUND!!!!!!!!!!: $callerid"; &agi_output;}
|
||||
}
|
||||
|
||||
}
|
||||
if ($VDACaffected_rows > 0)
|
||||
{
|
||||
# flag the lead as being Answered or Picked up
|
||||
$stmtA = "UPDATE vicidial_list set status='PU' where lead_id='$CIDlead_id' and status NOT IN('CALLBK');";
|
||||
@@ -386,8 +425,7 @@ if ($affected_rows > 0)
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
$sthArows=$sthA->rows;
|
||||
$dbhP=$dbhA; $mysql_count='01006'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
|
||||
$rec_count=0;
|
||||
while ($sthArows > $rec_count)
|
||||
if ($sthArows > 0)
|
||||
{
|
||||
@aryA = $sthA->fetchrow_array;
|
||||
$VDADcampaign = $aryA[0];
|
||||
@@ -397,7 +435,6 @@ if ($affected_rows > 0)
|
||||
$VDADcall_time = $aryA[4];
|
||||
$VDADalt_dial = $aryA[5];
|
||||
$VDADqueue_priority = $aryA[6];
|
||||
$rec_count++;
|
||||
}
|
||||
$sthA->finish();
|
||||
|
||||
@@ -432,7 +469,7 @@ if ($affected_rows > 0)
|
||||
$survey_third_audio_file = $aryA[16];
|
||||
$survey_fourth_audio_file = $aryA[17];
|
||||
$extension_appended_cidname = $aryA[18];
|
||||
$queue_priority = $aryA[19];
|
||||
$VDADqueue_priority = $aryA[19];
|
||||
$closer_campaigns = $aryA[20];
|
||||
if (length($closer_campaigns) > 2)
|
||||
{
|
||||
@@ -2181,7 +2218,7 @@ while ($drop_timer <= $DROP_TIME)
|
||||
$affected_rows = $dbhA->do($stmtA);
|
||||
if ($affected_rows < 1)
|
||||
{
|
||||
$stmtA = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,uniqueid,callerid,channel,phone_code,phone_number,call_time,call_type,stage,queue_priority) values('$VARserver_ip','$channel_group','CLOSER','$CIDlead_id','$uniqueid','$callerid','$channel','$phone_code','$phone_number','$SQLdate','IN','CLOSER-$drop_timer','$queue_priority')";
|
||||
$stmtA = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,uniqueid,callerid,channel,phone_code,phone_number,call_time,call_type,stage,queue_priority) values('$VARserver_ip','$VDADcampaign','LIVE','$CIDlead_id','$uniqueid','$callerid','$channel','$VDADphone_code','$VDADphone','$SQLdate','OUT','LIVE-$drop_timer','$VDADqueue_priority')";
|
||||
$affected_rows = $dbhA->do($stmtA);
|
||||
$dbhP=$dbhA; $mysql_count='01047'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
|
||||
if ($AGILOG) {$agi_string = "$affected_rows|VDAC-reinsert|$stmtA|"; &agi_output;}
|
||||
|
||||
@@ -93,6 +93,7 @@
|
||||
# 100903-0041 - Changed lead_id max length to 10 digits
|
||||
# 101111-1556 - Added source to vicidial_hopper inserts
|
||||
# 101117-1656 - Added accounting for DEAD agent calls when in available-only-tally dialing
|
||||
# 101207-0713 - Added more info to Originate for rare VDAC issue
|
||||
#
|
||||
|
||||
|
||||
@@ -1086,7 +1087,7 @@ while($one_day_interval > 0)
|
||||
if ($CCID_on) {$CIDstring = "\"$VqueryCID\" <$CCID>";}
|
||||
else {$CIDstring = "$VqueryCID";}
|
||||
### insert a NEW record to the vicidial_manager table to be processed
|
||||
$stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$DBIPaddress[$user_CIPct]','','Originate','$VqueryCID','Exten: $VDAD_dial_exten','Context: $ext_context','Channel: $local_DEF$Ndialstring$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','')";
|
||||
$stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$DBIPaddress[$user_CIPct]','','Originate','$VqueryCID','Exten: $VDAD_dial_exten','Context: $ext_context','Channel: $local_DEF$Ndialstring$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','VDACnote: $DBIPcampaign[$user_CIPct]|$lead_id|$phone_code|$phone_number|OUT|$alt_dial|$DBIPqueue_priority[$user_CIPct]')";
|
||||
$affected_rows = $dbhA->do($stmtA);
|
||||
|
||||
$event_string = "| number call dialed|$DBIPcampaign[$user_CIPct]|$VqueryCID|$stmtA|$gmt_offset_now|$alt_dial|";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# AST_VDauto_dial_FILL.pl version 2.2.0 *DBI-version*
|
||||
# AST_VDauto_dial_FILL.pl version 2.4
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Places auto_dial calls on the VICIDIAL dialer system across all servers only
|
||||
@@ -29,6 +29,7 @@
|
||||
# 90924-1519 - Added List callerid override option
|
||||
# 100205-1245 - Added optional stagger sending of calls across all available servers in each rank
|
||||
# 100903-0041 - Changed lead_id max length to 10 digits
|
||||
# 101207-0713 - Added more info to Originate for rare VDAC issue
|
||||
#
|
||||
|
||||
### begin parsing run-time options ###
|
||||
@@ -782,7 +783,7 @@ while($one_day_interval > 0)
|
||||
if ($staggered < 1)
|
||||
{
|
||||
### insert a NEW record to the vicidial_manager table to be processed
|
||||
$stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$DB_camp_server_server_ip[$server_CIPct]','','Originate','$VqueryCID','Exten: $VDAD_dial_exten','Context: $ext_context','Channel: $local_DEF$Ndialstring$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','')";
|
||||
$stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$DB_camp_server_server_ip[$server_CIPct]','','Originate','$VqueryCID','Exten: $VDAD_dial_exten','Context: $ext_context','Channel: $local_DEF$Ndialstring$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','VDACnote: $DBfill_campaign[$camp_CIPct]|$lead_id|$phone_code|$phone_number|OUTBALANCE|$alt_dial|$DBIPqueue_priority[$camp_CIPct]')";
|
||||
$affected_rows = $dbhA->do($stmtA);
|
||||
|
||||
$event_string = "| number call dialed|$DBfill_campaign[$camp_CIPct]|$VqueryCID|$stmtA|$gmt_offset_now|$alt_dial|";
|
||||
@@ -795,7 +796,7 @@ while($one_day_interval > 0)
|
||||
else
|
||||
{
|
||||
##### create dummy records to have their server_ip filled in at the stagger section
|
||||
$vm_inserts[$staggered_ct] = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','XXXXXXXXXXXXXXX','','Originate','$VqueryCID','Exten: $VDAD_dial_exten','Context: $ext_context','Channel: $local_DEF$Ndialstring$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','')";
|
||||
$vm_inserts[$staggered_ct] = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','XXXXXXXXXXXXXXX','','Originate','$VqueryCID','Exten: $VDAD_dial_exten','Context: $ext_context','Channel: $local_DEF$Ndialstring$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','VDACnote: $DBfill_campaign[$camp_CIPct]|$lead_id|$phone_code|$phone_number|OUTBALANCE|$alt_dial|$DBIPqueue_priority[$camp_CIPct]')";
|
||||
|
||||
$vac_inserts[$staggered_ct] = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,callerid,phone_code,phone_number,call_time,call_type,alt_dial,queue_priority) values('XXXXXXXXXXXXXXX','$DBfill_campaign[$camp_CIPct]','SENT','$lead_id','$VqueryCID','$phone_code','$phone_number','$SQLdate','OUTBALANCE','$alt_dial','$DBIPqueue_priority[$camp_CIPct]')";
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@ blind_monitor - calls user-defined phone and places them in session as blind mon
|
||||
add_lead - adds a new lead to the vicidial_list table with several fields and options
|
||||
update_lead - updates lead information in vicidial_list and associated custom table
|
||||
agent_ingroup_info - shows in-group and outbound auto-dial info for logged-in agent
|
||||
|
||||
recording_lookup - looks up recordings based upon user and date or lead_id
|
||||
did_log_export - exports all calls inbound to a DID for one day
|
||||
|
||||
|
||||
New scripts:
|
||||
@@ -44,6 +45,7 @@ Changes:
|
||||
100924-1403 - Added called_count as an update_lead option
|
||||
101111-1536 - Added vicidial_hopper.source to vicidial_hopper inserts
|
||||
101117-1104 - Added callback and custom field entry delete to delete_lead option
|
||||
101206-2126 - Added recording_lookup and did_log_export functions
|
||||
|
||||
|
||||
|
||||
@@ -194,6 +196,66 @@ ERROR: agent_ingroup_info INVALID USER ID - 1255|6666
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
recording_lookup - looks up recordings based upon user and date or lead_id
|
||||
|
||||
REQUIRED FIELDS-
|
||||
agent_user - 2-20 characters
|
||||
lead_id - 1-10 digits
|
||||
date - date of the calls to pull (must be in YYYY-MM-DD format)
|
||||
|
||||
SETTINGS FIELDS-
|
||||
stage - the format of the exported data: csv, tab, pipe(default)
|
||||
header - include a header(YES) or not(NO). This is optional, default is not to include a header
|
||||
|
||||
NOTES-
|
||||
There is a hard limit of 100000 results
|
||||
|
||||
Example URL strings for API calls:
|
||||
http://server/vicidial/non_agent_api.php?source=test&function=recording_lookup&stage=pipe&user=6666&pass=1234&agent_user=1000&date=2010-12-03
|
||||
|
||||
Example responses:
|
||||
ERROR: recording_lookup USER DOES NOT HAVE PERMISSION TO GET RECORDING INFO - 6666|0
|
||||
ERROR: recording_lookup INVALID SEARCH PARAMETERS - 6666|1000||2010-12-03
|
||||
ERROR: recording_lookup NO RECORDINGS FOUND - 1255|6666||2010-12-03
|
||||
|
||||
A SUCCESS response will not show "SUCCESS", but instead will just print the results in the following format:
|
||||
start_time|user|recording_id|lead_id|location
|
||||
2010-12-03 12:00:01|1000|534820|876409|http://server/path/to/recording/20101203_120000_1234567890_1000-all.wav
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
did_log_export - exports all calls inbound to a DID for one day
|
||||
|
||||
REQUIRED FIELDS-
|
||||
phone_number - 2-20 characters, the DID that you want to pull logs for
|
||||
date - date of the calls to pull (must be in YYYY-MM-DD format)
|
||||
|
||||
SETTINGS FIELDS-
|
||||
stage - the format of the exported data: csv, tab, pipe(default)
|
||||
header - include a header(YES) or not(NO). This is optional, default is not to include a header
|
||||
|
||||
NOTES-
|
||||
There is a hard limit of 100000 results
|
||||
|
||||
Example URL strings for API calls:
|
||||
http://server/vicidial/non_agent_api.php?source=test&function=did_log_export&stage=pipe&user=6666&pass=1234&phone_number=3125551212&date=2010-12-03
|
||||
|
||||
Example responses:
|
||||
ERROR: did_log_export USER DOES NOT HAVE PERMISSION TO GET DID INFO - 6666|0
|
||||
ERROR: did_log_export INVALID SEARCH PARAMETERS - 6666|3125551212|2010-12-03
|
||||
ERROR: did_log_export NO RECORDS FOUND - 1255|3125551212|2010-12-03
|
||||
|
||||
A SUCCESS response will not show "SUCCESS", but instead will just print the results in the following format:
|
||||
did_number|call_date|caller_id_number|length_in_sec
|
||||
3125551212|2010-12-03 12:00:01|7275551212|123
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
add_lead - adds a new lead to the vicidial_list table with several fields and options
|
||||
|
||||
@@ -39,10 +39,11 @@
|
||||
# 100924-1403 - Added called_count as an update_lead option
|
||||
# 101111-1536 - Added vicidial_hopper.source to vicidial_hopper inserts
|
||||
# 101117-1104 - Added callback and custom field entry delete to delete_lead option
|
||||
# 101206-2126 - Added recording_lookup and did_log_export functions
|
||||
#
|
||||
|
||||
$version = '2.4-25';
|
||||
$build = '101117-1104';
|
||||
$version = '2.4-26';
|
||||
$build = '101206-2126';
|
||||
|
||||
require("dbconnect.php");
|
||||
|
||||
@@ -161,6 +162,10 @@ if (isset($_GET["delete_lead"])) {$delete_lead=$_GET["delete_lead"];}
|
||||
elseif (isset($_POST["delete_lead"])) {$delete_lead=$_POST["delete_lead"];}
|
||||
if (isset($_GET["called_count"])) {$called_count=$_GET["called_count"];}
|
||||
elseif (isset($_POST["called_count"])) {$called_count=$_POST["called_count"];}
|
||||
if (isset($_GET["date"])) {$date=$_GET["date"];}
|
||||
elseif (isset($_POST["date"])) {$date=$_POST["date"];}
|
||||
if (isset($_GET["header"])) {$header=$_GET["header"];}
|
||||
elseif (isset($_POST["header"])) {$header=$_POST["header"];}
|
||||
|
||||
|
||||
header ("Content-type: text/html; charset=utf-8");
|
||||
@@ -1046,6 +1051,274 @@ if ($function == 'agent_ingroup_info')
|
||||
|
||||
|
||||
|
||||
|
||||
################################################################################
|
||||
### recording_lookup - looks up recordings based upon user and date or lead_id
|
||||
################################################################################
|
||||
if ($function == 'recording_lookup')
|
||||
{
|
||||
if(strlen($source)<2)
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "Invalid Source";
|
||||
echo "$result: $result_reason - $source\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
echo "ERROR: Invalid Source: |$source|\n";
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and vdc_agent_api_access='1' and view_reports='1' and user_level > 6;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$allowed_user=$row[0];
|
||||
if ($allowed_user < 1)
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "recording_lookup USER DOES NOT HAVE PERMISSION TO GET RECORDING INFO";
|
||||
echo "$result: $result_reason: |$user|$allowed_user|\n";
|
||||
$data = "$allowed_user";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$search_SQL='';
|
||||
$search_ready=0;
|
||||
if ( (strlen($agent_user)>2) and (strlen($agent_user)<21) )
|
||||
{
|
||||
$search_SQL .= "user='$agent_user'";
|
||||
$search_ready++;
|
||||
}
|
||||
if ( (strlen($lead_id)>0) and (strlen($lead_id)<11) )
|
||||
{
|
||||
if (strlen($search_SQL)>5)
|
||||
{$search_SQL .= " and ";}
|
||||
$search_SQL .= "lead_id='$lead_id'";
|
||||
$search_ready++;
|
||||
$search_ready++;
|
||||
}
|
||||
if ( (strlen($date)>9) and (strlen($date)<11) )
|
||||
{
|
||||
if (strlen($search_SQL)>5)
|
||||
{$search_SQL .= " and ";}
|
||||
$search_SQL .= "( (start_time >= \"$date 00:00:00\") and (start_time <= \"$date 23:59:59\") )";
|
||||
$search_ready++;
|
||||
}
|
||||
if ($search_ready < 2)
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "recording_lookup INVALID SEARCH PARAMETERS";
|
||||
$data = "$user|$agent_user|$lead_id|$date";
|
||||
echo "$result: $result_reason: $data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$stmt="SELECT start_time,user,recording_id,lead_id,location from recording_log where $search_SQL order by start_time limit 100000;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$rec_recs = mysql_num_rows($rslt);
|
||||
if ($DB>0) {echo "DEBUG: recording_lookup query - $rec_recs|$stmt\n";}
|
||||
if ($rec_recs < 1)
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "recording_lookup NO RECORDINGS FOUND";
|
||||
$data = "$user|$agent_user|$lead_id|$date";
|
||||
echo "$result: $result_reason - $data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$k=0;
|
||||
$output='';
|
||||
$DLset=0;
|
||||
if ($stage == 'csv')
|
||||
{$DL = ','; $DLset++;}
|
||||
if ($stage == 'tab')
|
||||
{$DL = "\t"; $DLset++;}
|
||||
if ($stage == 'pipe')
|
||||
{$DL = '|'; $DLset++;}
|
||||
if ($DLset < 1)
|
||||
{$DL='pipe';}
|
||||
if ($header == 'YES')
|
||||
{$output .= 'start_time' . $DL . 'user' . $DL . 'recording_id' . $DL . 'lead_id' . $DL . "location\n";}
|
||||
|
||||
while ($rec_recs > $k)
|
||||
{
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$RLstart_time = $row[0];
|
||||
$RLuser = $row[1];
|
||||
$RLrecording_id = $row[2];
|
||||
$RLlead_id = $row[3];
|
||||
$RLlocation = $row[4];
|
||||
|
||||
$output .= "$RLstart_time$DL$RLuser$DL$RLrecording_id$DL$RLlead_id$DL$RLlocation\n";
|
||||
|
||||
$k++;
|
||||
}
|
||||
|
||||
echo "$output";
|
||||
|
||||
$result = 'SUCCESS';
|
||||
$data = "$user|$agent_user|$lead_id|$date|$stage";
|
||||
$result_reason = "recording_lookup RECORDINGS FOUND: $rec_recs";
|
||||
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exit;
|
||||
}
|
||||
################################################################################
|
||||
### END recording_lookup
|
||||
################################################################################
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
################################################################################
|
||||
### did_log_export - exports all calls inbound to a DID for one day
|
||||
################################################################################
|
||||
if ($function == 'did_log_export')
|
||||
{
|
||||
if(strlen($source)<2)
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "Invalid Source";
|
||||
echo "$result: $result_reason - $source\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
echo "ERROR: Invalid Source: |$source|\n";
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and vdc_agent_api_access='1' and view_reports='1' and user_level > 6;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$allowed_user=$row[0];
|
||||
if ($allowed_user < 1)
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "did_log_export USER DOES NOT HAVE PERMISSION TO GET DID INFO";
|
||||
echo "$result: $result_reason: |$user|$allowed_user|\n";
|
||||
$data = "$allowed_user";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$search_SQL='';
|
||||
$search_ready=0;
|
||||
if ( (strlen($phone_number)>0) and (strlen($phone_number)<21) )
|
||||
{
|
||||
$search_SQL .= "extension='$phone_number'";
|
||||
$search_ready++;
|
||||
}
|
||||
if ( (strlen($date)>9) and (strlen($date)<11) )
|
||||
{
|
||||
if (strlen($search_SQL)>5)
|
||||
{$search_SQL .= " and ";}
|
||||
$search_SQL .= "( (call_date >= \"$date 00:00:00\") and (call_date <= \"$date 23:59:59\") )";
|
||||
$search_ready++;
|
||||
}
|
||||
if ($search_ready < 2)
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "did_log_export INVALID SEARCH PARAMETERS";
|
||||
$data = "$user|$phone_number|$date";
|
||||
echo "$result: $result_reason: $data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$stmt="SELECT uniqueid,caller_id_number,call_date,UNIX_TIMESTAMP(call_date) from vicidial_did_log where $search_SQL order by call_date limit 100000;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$rec_recs = mysql_num_rows($rslt);
|
||||
if ($DB>0) {echo "DEBUG: recording_lookup query - $rec_recs|$stmt\n";}
|
||||
if ($rec_recs < 1)
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "did_log_export NO RECORDS FOUND";
|
||||
$data = "$user|$agent_user|$lead_id|$date";
|
||||
echo "$result: $result_reason - $data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$k=0;
|
||||
$output='';
|
||||
$DLset=0;
|
||||
if ($stage == 'csv')
|
||||
{$DL = ','; $DLset++;}
|
||||
if ($stage == 'tab')
|
||||
{$DL = "\t"; $DLset++;}
|
||||
if ($stage == 'pipe')
|
||||
{$DL = '|'; $DLset++;}
|
||||
if ($DLset < 1)
|
||||
{$DL='pipe';}
|
||||
if ($header == 'YES')
|
||||
{$output .= 'did_number' . $DL . 'call_date' . $DL . 'caller_id_number' . $DL . "length_in_sec\n";}
|
||||
|
||||
while ($rec_recs > $k)
|
||||
{
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$DLuniqueid[$k] = $row[0];
|
||||
$DLcall_date[$k] = $row[1];
|
||||
$DLcaller_id_number[$k] = $row[2];
|
||||
$DLepoch[$k] = $row[3];
|
||||
$k++;
|
||||
}
|
||||
|
||||
$k=0;
|
||||
while ($rec_recs > $k)
|
||||
{
|
||||
$DLlength_in_sec[$k]=0;
|
||||
$DLcloser_epoch[$k]=$DLepoch[$k];
|
||||
$stmt="SELECT length_in_sec,UNIX_TIMESTAMP(call_date) from vicidial_closer_log where uniqueid='$DLuniqueid[$k]' order by call_date desc limit 1;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$vcl_recs = mysql_num_rows($rslt);
|
||||
if ($DB>0) {echo "DEBUG: recording_lookup query - $vcl_recs|$stmt\n";}
|
||||
if ($vcl_recs > 0)
|
||||
{
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$DLlength_in_sec[$k] = $row[0];
|
||||
$DLcloser_epoch[$k] = $row[1];
|
||||
}
|
||||
|
||||
$total_sec = ( ($DLcloser_epoch[$k] + $DLlength_in_sec[$k]) - $DLepoch[$k]);
|
||||
|
||||
$output .= "$phone_number$DL$DLcall_date[$k]$DL$DLcaller_id_number[$k]$DL$total_sec\n";
|
||||
|
||||
$k++;
|
||||
}
|
||||
|
||||
echo "$output";
|
||||
|
||||
$result = 'SUCCESS';
|
||||
$data = "$user|$agent_user|$lead_id|$date|$stage";
|
||||
$result_reason = "did_log_export RECORDINGS FOUND: $rec_recs";
|
||||
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exit;
|
||||
}
|
||||
################################################################################
|
||||
### END did_log_export
|
||||
################################################################################
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
################################################################################
|
||||
### blind_monitor - sends call to phone from session from listening
|
||||
################################################################################
|
||||
|
||||
Reference in New Issue
Block a user