added agent API functionality for pause/resume and dial a number
added api log in database git-svn-id: svn://192.168.202.10@1036 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
# changes:
|
||||
# 81007-0324 - First Build
|
||||
# 90115-0645 - Activated AGENT call routing
|
||||
# 90117-0756 - Added vicidial_did_log logging to database
|
||||
#
|
||||
|
||||
$script = 'agi-DID_route.agi';
|
||||
@@ -172,6 +173,11 @@ if ($sthArows > 0)
|
||||
}
|
||||
$sthA->finish();
|
||||
|
||||
$stmtA = "INSERT INTO vicidial_did_log SET uniqueid='$uniqueid',channel='$channel',server_ip='$VARserver_ip',caller_id_number='$callerid',caller_id_name='$calleridname',extension='$extension',call_date='$SQLdate',did_id='$did_id',did_route='$did_route';";
|
||||
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
||||
$affected_rowsL = $dbhA->do($stmtA);
|
||||
if ($AGILOG) {$agi_string = "-- DID LOG : |$affected_rowsL|$stmtA|"; &agi_output;}
|
||||
|
||||
if ($AGILOG) {$did_string = "$SQLdate|$uniqueid|$channel|$extension|$callerid|$calleridname|$did_id|$did_route|"; &did_output;}
|
||||
|
||||
if ($sthArows < 1)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
AGENT API DOCUMENT 2008-07-03
|
||||
AGENT API DOCUMENT 2008-07-03
|
||||
|
||||
This document describes the functions of an API(Application Programming Interface)
|
||||
for the VICIDIAL Agent screen. This functionality will be rather limited at first
|
||||
@@ -10,8 +10,11 @@ read the NON-AGENT_API.txt document.
|
||||
|
||||
|
||||
API functions:
|
||||
version - shows version and build of the API, along with the date/time
|
||||
external_hangup - sends command to hangup the current phone call for one specific agent(Hangup Customer)
|
||||
external_status - sends command to set the disposition for one specific agent and move on to next call
|
||||
external_pause - sends command to pause/resume an agent now if not on a call, or pause after their next call if on call
|
||||
external_dial - sends command to manually dial a number on the agent's screen
|
||||
|
||||
|
||||
|
||||
@@ -20,22 +23,161 @@ New scripts:
|
||||
|
||||
|
||||
|
||||
Required variables for API calls:
|
||||
# user - is the API user
|
||||
# pass - is the API user password
|
||||
# agent_user - is the user whose session that you want to affect
|
||||
# source - description of what originated the API call (maximum 20 characters)
|
||||
|
||||
Example URL strings for API calls:
|
||||
http://server/agc/api.php?function=version
|
||||
http://server/agc/api.php?user=6666&pass=1234&agent_user=1000&function=external_hangup&value=1
|
||||
http://server/agc/api.php?user=6666&pass=1234&agent_user=1000&function=external_status&value=A
|
||||
http://server/agc/api.php?user=6666&pass=1234&agent_user=1000&function=external_pause&value=PAUSE
|
||||
http://server/agc/api.php?user=6666&pass=1234&agent_user=1000&function=external_pause&value=RESUME
|
||||
http://server/agc/api.php?user=6666&pass=1234&agent_user=1000&function=external_dial&value=7275551212&phone_code=1&search=YES
|
||||
|
||||
|
||||
To hangup the call, disposition it and then pause the agent, do the following in order:
|
||||
http://server/agc/api.php?user=6666&pass=1234&agent_user=1000&function=external_pause&value=PAUSE
|
||||
http://server/agc/api.php?user=6666&pass=1234&agent_user=1000&function=external_hangup&value=1
|
||||
http://server/agc/api.php?user=6666&pass=1234&agent_user=1000&function=external_status&value=A
|
||||
|
||||
|
||||
|
||||
Example MySQL queries for executing API functions:
|
||||
Response to calls will return either an ERROR or a SUCCESS along with an explanation.
|
||||
for example:
|
||||
SUCCESS: external_status function set - 6666|A
|
||||
ERROR: agent_user is not logged in - 6666
|
||||
|
||||
|
||||
|
||||
DETAIL OF EACH FUNCTION:
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
version -
|
||||
|
||||
DESCRIPTION:
|
||||
shows version and build of the API, along with the date/time
|
||||
|
||||
VALUES: NONE
|
||||
|
||||
RESPONSES:
|
||||
VERSION: 2.0.5-2|BUILD: 90116-1229|DATE: 2009-01-15 14:59:33|EPOCH: 1222020803
|
||||
|
||||
|
||||
|
||||
external_hangup -
|
||||
|
||||
DESCRIPTION:
|
||||
Hangs up the current customer call on the agent screen
|
||||
|
||||
VALUES: (value)
|
||||
1 - the only valid value for this function
|
||||
|
||||
RESPONSES:
|
||||
ERROR: external_hangup not valid - 1|6666
|
||||
ERROR: agent_user is not logged in - 6666
|
||||
SUCCESS: external_hangup function set - 1|6666
|
||||
|
||||
|
||||
|
||||
external_status -
|
||||
|
||||
DESCRIPTION:
|
||||
Sets the status of the current customer call on the agent dispotion screen
|
||||
|
||||
VALUES: (value)
|
||||
Any valid status in the VICIDIAL system will work for this function
|
||||
|
||||
RESPONSES:
|
||||
ERROR: external_status not valid - A|6666
|
||||
ERROR: agent_user is not logged in - 6666
|
||||
SUCCESS: external_status function set - A|6666
|
||||
|
||||
|
||||
|
||||
external_pause -
|
||||
|
||||
DESCRIPTION:
|
||||
Pauses or Resumes the agent. If a Pause and the agent is on a live call will pause after the live call is dispositioned
|
||||
|
||||
VALUES: (value)
|
||||
PAUSE - Pauses the agent session
|
||||
RESUME - Resumes the agent session
|
||||
|
||||
RESPONSES:
|
||||
ERROR: external_pause not valid - PAUSE|6666
|
||||
ERROR: agent_user is not logged in - 6666
|
||||
SUCCESS: external_pause function set - PAUSE|1232020456|6666
|
||||
|
||||
|
||||
|
||||
external_dial -
|
||||
|
||||
DESCRIPTION:
|
||||
Places a manual dial phone call on the agent screen, you can define whether to search for the lead in the existing database or not and you can define the phone_code and the number to dial. This action will pause the agent after their current call, enter in the information to place the call, and dialing the call on the agent screen.
|
||||
|
||||
VALUES:
|
||||
value -
|
||||
Any valid phone number (7275551212)
|
||||
phone_code -
|
||||
Any valid phone country code (1 for USA/Canada, 44 for UK, etc...)
|
||||
search -
|
||||
YES - perform a search in the campaign-defined vicidial_list list for this phone number and bring up that lead
|
||||
NO - do not search, create a new vicidial_list record for the call
|
||||
preview -
|
||||
YES - preview the lead in the vicidial screen without dialing
|
||||
NO - do not preview the lead, place call immediately
|
||||
focus -
|
||||
YES - change the focus of the screen to the vicidial.php agent interface
|
||||
NO - do not change focus
|
||||
|
||||
|
||||
RESPONSES:
|
||||
ERROR: external_dial not valid - 7275551212|1|YES|6666
|
||||
ERROR: agent_user is not allowed to place manual dial calls - 6666
|
||||
ERROR: agent_user is not logged in - 6666
|
||||
SUCCESS: external_dial function set - 7275551212|1|YES|1232020456|6666
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Example MySQL query options for executing API functions(not available for all functions):
|
||||
update vicidial_live_agents set external_hangup=1 where user='1000';
|
||||
update vicidial_live_agents set external_status='A' where user='1000';
|
||||
update vicidial_live_agents set status='PAUSED' where user='1000';
|
||||
|
||||
|
||||
Database changes:
|
||||
Database changes: (these are already in the system, DO NOT RUN THEM)
|
||||
ALTER TABLE vicidial_live_agents ADD external_hangup VARCHAR(1) default '';
|
||||
ALTER TABLE vicidial_live_agents ADD external_status VARCHAR(6) default '';
|
||||
ALTER TABLE vicidial_live_agents ADD external_pause VARCHAR(20) default '';
|
||||
ALTER TABLE vicidial_live_agents ADD external_dial VARCHAR(100) default '';
|
||||
|
||||
ALTER TABLE vicidial_users ADD vdc_agent_api_access ENUM('0','1') default '0';
|
||||
|
||||
ALTER TABLE system_settings ADD vdc_agent_api_active ENUM('0','1') default '0';
|
||||
|
||||
CREATE TABLE vicidial_api_log (
|
||||
api_id INT(9) UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
|
||||
user VARCHAR(20) NOT NULL,
|
||||
api_date DATETIME,
|
||||
api_script VARCHAR(10),
|
||||
function VARCHAR(20) NOT NULL,
|
||||
agent_user VARCHAR(20),
|
||||
value VARCHAR(255),
|
||||
result VARCHAR(10),
|
||||
result_reason VARCHAR(255),
|
||||
source VARCHAR(20),
|
||||
data TEXT,
|
||||
index(api_date)
|
||||
);
|
||||
|
||||
@@ -44,6 +44,7 @@ REQUIRED FIELDS-
|
||||
phone_number - must be all numbers, 6-16 digits
|
||||
phone_code - must be all numbers, 1-4 digits, defaults to 1 if not set
|
||||
list_id - must be all numbers, 3-12 digits, defaults to 999 if not set
|
||||
source - description of what originated the API call (maximum 20 characters)
|
||||
|
||||
SETTINGS FIELDS-
|
||||
dnc_check - Y or N, default is N
|
||||
|
||||
@@ -324,6 +324,8 @@ campaign_weight TINYINT(1) default '0',
|
||||
calls_today SMALLINT(5) UNSIGNED default '0',
|
||||
external_hangup VARCHAR(1) default '',
|
||||
external_status VARCHAR(6) default '',
|
||||
external_pause VARCHAR(20) default '',
|
||||
external_dial VARCHAR(100) default '',
|
||||
index (random_id),
|
||||
index (last_call_time),
|
||||
index (last_update_time),
|
||||
@@ -1303,6 +1305,37 @@ unique index (did_pattern),
|
||||
index (group_id)
|
||||
);
|
||||
|
||||
CREATE TABLE vicidial_did_log (
|
||||
uniqueid VARCHAR(20) NOT NULL,
|
||||
channel VARCHAR(100) NOT NULL,
|
||||
server_ip VARCHAR(15) NOT NULL,
|
||||
caller_id_number VARCHAR(18),
|
||||
caller_id_name VARCHAR(20),
|
||||
extension VARCHAR(100),
|
||||
call_date DATETIME,
|
||||
did_id VARCHAR(9) default '',
|
||||
did_route VARCHAR(9) default '',
|
||||
index (uniqueid),
|
||||
index (caller_id_number),
|
||||
index (extension),
|
||||
index (call_date)
|
||||
);
|
||||
|
||||
CREATE TABLE vicidial_api_log (
|
||||
api_id INT(9) UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
|
||||
user VARCHAR(20) NOT NULL,
|
||||
api_date DATETIME,
|
||||
api_script VARCHAR(10),
|
||||
function VARCHAR(20) NOT NULL,
|
||||
agent_user VARCHAR(20),
|
||||
value VARCHAR(255),
|
||||
result VARCHAR(10),
|
||||
result_reason VARCHAR(255),
|
||||
source VARCHAR(20),
|
||||
data TEXT,
|
||||
index(api_date)
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE vicidial_campaign_server_stats ENGINE=HEAP;
|
||||
|
||||
@@ -1391,7 +1424,7 @@ CREATE INDEX phone_number on vicidial_closer_log (phone_number);
|
||||
CREATE INDEX date_user on vicidial_closer_log (call_date,user);
|
||||
CREATE INDEX comment_a on live_inbound_log (comment_a);
|
||||
|
||||
UPDATE system_settings SET db_schema_version='1124';
|
||||
UPDATE system_settings SET db_schema_version='1125';
|
||||
|
||||
GRANT RELOAD ON *.* TO cron@'%';
|
||||
GRANT RELOAD ON *.* TO cron@localhost;
|
||||
|
||||
@@ -604,3 +604,39 @@ UPDATE system_settings SET db_schema_version='1123';
|
||||
ALTER TABLE vicidial_closer_log ADD agent_only VARCHAR(20) default '';
|
||||
|
||||
UPDATE system_settings SET db_schema_version='1124';
|
||||
|
||||
ALTER TABLE vicidial_live_agents ADD external_pause VARCHAR(20) default '';
|
||||
ALTER TABLE vicidial_live_agents ADD external_dial VARCHAR(100) default '';
|
||||
|
||||
CREATE TABLE vicidial_did_log (
|
||||
uniqueid VARCHAR(20) NOT NULL,
|
||||
channel VARCHAR(100) NOT NULL,
|
||||
server_ip VARCHAR(15) NOT NULL,
|
||||
caller_id_number VARCHAR(18),
|
||||
caller_id_name VARCHAR(20),
|
||||
extension VARCHAR(100),
|
||||
call_date DATETIME,
|
||||
did_id VARCHAR(9) default '',
|
||||
did_route VARCHAR(9) default '',
|
||||
index (uniqueid),
|
||||
index (caller_id_number),
|
||||
index (extension),
|
||||
index (call_date)
|
||||
);
|
||||
|
||||
CREATE TABLE vicidial_api_log (
|
||||
api_id INT(9) UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
|
||||
user VARCHAR(20) NOT NULL,
|
||||
api_date DATETIME,
|
||||
api_script VARCHAR(10),
|
||||
function VARCHAR(20) NOT NULL,
|
||||
agent_user VARCHAR(20),
|
||||
value VARCHAR(255),
|
||||
result VARCHAR(10),
|
||||
result_reason VARCHAR(255),
|
||||
source VARCHAR(20),
|
||||
data TEXT,
|
||||
index(api_date)
|
||||
);
|
||||
|
||||
UPDATE system_settings SET db_schema_version='1125';
|
||||
|
||||
@@ -411,6 +411,7 @@ Change this phone number to INACTIVE||
|
||||
Change this phone number to ACTIVE||
|
||||
YOU MUST LOG IN TO THE TIMECLOCK FIRST||
|
||||
There is a time synchronization problem with your system, please tell your system administrator||
|
||||
Preview Call||
|
||||
|
||||
|
||||
############################################################ MANAGER Manual
|
||||
|
||||
+290
-31
@@ -1,7 +1,7 @@
|
||||
<?
|
||||
# api.php
|
||||
#
|
||||
# Copyright (C) 2008 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
# Copyright (C) 2009 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
#
|
||||
# This script is designed as an API(Application Programming Interface) to allow
|
||||
# other programs to interact with the VICIDIAL Agent screen
|
||||
@@ -10,17 +10,25 @@
|
||||
# - $user
|
||||
# - $pass
|
||||
# - $agent_user
|
||||
# - $function - ('external_hangup','external_status')
|
||||
# - $function - ('external_hangup','external_status','external_pause')
|
||||
# - $value
|
||||
# - $extra_value
|
||||
# - $value_a
|
||||
# - $focus
|
||||
# - $preview
|
||||
# - $notes
|
||||
# - $phone_code
|
||||
# - $search
|
||||
# - $source - ('vtiger','webform','adminweb')
|
||||
# - $format - ('text','debug')
|
||||
|
||||
# CHANGELOG:
|
||||
# 80703-2225 - First build of script
|
||||
# 90116-1229 - Added external_pause and external_dial functions
|
||||
# 90118-1051 - Added logging of API functions
|
||||
#
|
||||
|
||||
$version = '2.0.5-1';
|
||||
$build = '80703-2225';
|
||||
$version = '2.0.5-3';
|
||||
$build = '90118-1051';
|
||||
|
||||
require("dbconnect.php");
|
||||
|
||||
@@ -35,8 +43,20 @@ if (isset($_GET["function"])) {$function=$_GET["function"];}
|
||||
elseif (isset($_POST["function"])) {$function=$_POST["function"];}
|
||||
if (isset($_GET["value"])) {$value=$_GET["value"];}
|
||||
elseif (isset($_POST["value"])) {$value=$_POST["value"];}
|
||||
if (isset($_GET["extra_value"])) {$extra_value=$_GET["extra_value"];}
|
||||
elseif (isset($_POST["extra_value"])) {$extra_value=$_POST["extra_value"];}
|
||||
if (isset($_GET["value_a"])) {$value_a=$_GET["value_a"];}
|
||||
elseif (isset($_POST["value_a"])) {$value_a=$_POST["value_a"];}
|
||||
if (isset($_GET["focus"])) {$focus=$_GET["focus"];}
|
||||
elseif (isset($_POST["focus"])) {$focus=$_POST["focus"];}
|
||||
if (isset($_GET["preview"])) {$preview=$_GET["preview"];}
|
||||
elseif (isset($_POST["preview"])) {$preview=$_POST["preview"];}
|
||||
if (isset($_GET["notes"])) {$notes=$_GET["notes"];}
|
||||
elseif (isset($_POST["notes"])) {$notes=$_POST["notes"];}
|
||||
if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];}
|
||||
elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];}
|
||||
if (isset($_GET["search"])) {$search=$_GET["search"];}
|
||||
elseif (isset($_POST["search"])) {$search=$_POST["search"];}
|
||||
if (isset($_GET["source"])) {$source=$_GET["source"];}
|
||||
elseif (isset($_POST["source"])) {$source=$_POST["source"];}
|
||||
if (isset($_GET["format"])) {$format=$_GET["format"];}
|
||||
elseif (isset($_POST["format"])) {$format=$_POST["format"];}
|
||||
|
||||
@@ -68,16 +88,51 @@ $pass=ereg_replace("[^0-9a-zA-Z]","",$pass);
|
||||
$agent_user=ereg_replace("[^0-9a-zA-Z]","",$agent_user);
|
||||
$function = ereg_replace("[^-\_0-9a-zA-Z]","",$function);
|
||||
$value = ereg_replace("[^-\_0-9a-zA-Z]","",$value);
|
||||
$extra_value = ereg_replace("[^-\_0-9a-zA-Z]","",$extra_value);
|
||||
$value_a = ereg_replace("[^-\_0-9a-zA-Z]","",$value_a);
|
||||
$focus = ereg_replace("[^-\_0-9a-zA-Z]","",$focus);
|
||||
$preview = ereg_replace("[^-\_0-9a-zA-Z]","",$preview);
|
||||
$notes = ereg_replace("\+"," ",$notes);
|
||||
$notes = ereg_replace("[^ -\_0-9a-zA-Z]","",$notes);
|
||||
$phone_code = ereg_replace("[^0-9X]","",$phone_code);
|
||||
$search = ereg_replace("[^-\_0-9a-zA-Z]","",$search);
|
||||
$source = ereg_replace("[^0-9a-zA-Z]","",$source);
|
||||
$format = ereg_replace("[^0-9a-zA-Z]","",$format);
|
||||
}
|
||||
|
||||
### date and fixed variables
|
||||
$epoch = date("U");
|
||||
$StarTtime = date("U");
|
||||
$NOW_DATE = date("Y-m-d");
|
||||
$NOW_TIME = date("Y-m-d H:i:s");
|
||||
$CIDdate = date("mdHis");
|
||||
$ENTRYdate = date("YmdHis");
|
||||
$MT[0]='';
|
||||
$api_script = 'agent';
|
||||
$api_logging = 1;
|
||||
|
||||
|
||||
################################################################################
|
||||
### BEGIN - version - show version and date information for the API
|
||||
################################################################################
|
||||
if ($function == 'version')
|
||||
{
|
||||
$data = "VERSION: $version|BUILD: $build|DATE: $NOW_TIME|EPOCH: $StarTtime";
|
||||
$result = 'SUCCESS';
|
||||
echo "$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
################################################################################
|
||||
### END - version
|
||||
################################################################################
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
################################################################################
|
||||
### BEGIN - user validation section
|
||||
################################################################################
|
||||
|
||||
if ($ACTION == 'LogiNCamPaigns')
|
||||
{
|
||||
@@ -85,33 +140,51 @@ if ($ACTION == 'LogiNCamPaigns')
|
||||
}
|
||||
else
|
||||
{
|
||||
$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and vdc_agent_api_access = '1';";
|
||||
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( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
|
||||
if(strlen($source)<2)
|
||||
{
|
||||
echo "ERROR: Invalid Username/Password: |$user|$pass|$auth|\n";
|
||||
$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);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$stmt="SELECT count(*) from system_settings where vdc_agent_api_active='1';";
|
||||
$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and vdc_agent_api_access = '1';";
|
||||
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);
|
||||
$SNauth=$row[0];
|
||||
if($SNauth==0)
|
||||
$auth=$row[0];
|
||||
|
||||
if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0))
|
||||
{
|
||||
echo "ERROR: System API NOT ACTIVE\n";
|
||||
$result = 'ERROR';
|
||||
$result_reason = "Invalid Username/Password";
|
||||
echo "$result: $result_reason: |$user|$pass|$auth|\n";
|
||||
$data = "$user|$pass|$auth";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
# do nothing for now
|
||||
$stmt="SELECT count(*) from system_settings where vdc_agent_api_active='1';";
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$SNauth=$row[0];
|
||||
if($SNauth==0)
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "System API NOT ACTIVE";
|
||||
echo "$result: $result_reason\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
# do nothing for now
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -126,18 +199,25 @@ echo "</title>\n";
|
||||
echo "</head>\n";
|
||||
echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
|
||||
}
|
||||
################################################################################
|
||||
### END - user validation section
|
||||
################################################################################
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
################################################################################
|
||||
### external_hangup - hang up the active agent call
|
||||
### BEGIN - external_hangup - hang up the active agent call
|
||||
################################################################################
|
||||
if ($function == 'external_hangup')
|
||||
{
|
||||
if ( (strlen($value)<1) || (strlen($agent_user)<1) )
|
||||
{
|
||||
echo "ERROR: external_hangup not valid - $value|$agent_user\n";
|
||||
$result = 'ERROR';
|
||||
$result_reason = "external_hangup not valid";
|
||||
echo "$result: $result_reason - $value|$agent_user\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
@@ -151,27 +231,39 @@ if ($function == 'external_hangup')
|
||||
$stmt="UPDATE vicidial_live_agents set external_hangup='$value' where user='$agent_user';";
|
||||
if ($format=='debug') {echo "\n<!-- $stmt -->";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
echo "SUCCESS: external_hangup function set - $agent_user|$value\n";
|
||||
$result = 'SUCCESS';
|
||||
$result_reason = "external_hangup function set";
|
||||
echo "$result: $result_reason - $value|$agent_user\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "ERROR: agent_user is not logged in - $agent_user\n";
|
||||
$result = 'ERROR';
|
||||
$result_reason = "agent_user is not logged in";
|
||||
echo "$result: $result_reason - $agent_user\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
}
|
||||
}
|
||||
################################################################################
|
||||
### END - external_hangup
|
||||
################################################################################
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
################################################################################
|
||||
### external_status - set the dispo code or status for a call and move on
|
||||
### BEGIN - external_status - set the dispo code or status for a call and move on
|
||||
################################################################################
|
||||
if ($function == 'external_status')
|
||||
{
|
||||
if ( (strlen($value)<1) || (strlen($agent_user)<1) )
|
||||
{
|
||||
echo "ERROR: external_status not valid - $value|$agent_user\n";
|
||||
$result = 'ERROR';
|
||||
$result_reason = "external_status not valid";
|
||||
echo "$result: $result_reason - $value|$agent_user\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
@@ -185,14 +277,161 @@ if ($function == 'external_status')
|
||||
$stmt="UPDATE vicidial_live_agents set external_status='$value' where user='$agent_user';";
|
||||
if ($format=='debug') {echo "\n<!-- $stmt -->";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
echo "SUCCESS: external_status function set - $agent_user|$value\n";
|
||||
$result = 'SUCCESS';
|
||||
$result_reason = "external_status function set";
|
||||
echo "$result: $result_reason - $value|$agent_user\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "ERROR: agent_user is not logged in - $agent_user\n";
|
||||
$result = 'ERROR';
|
||||
$result_reason = "agent_user is not logged in";
|
||||
echo "$result: $result_reason - $agent_user\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
}
|
||||
}
|
||||
################################################################################
|
||||
### END - external_status
|
||||
################################################################################
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
################################################################################
|
||||
### BEGIN - external_pause - pause or resume the agent
|
||||
################################################################################
|
||||
if ($function == 'external_pause')
|
||||
{
|
||||
if ( (strlen($value)<1) || (strlen($agent_user)<1) || (!ereg("PAUSE|RESUME",$value)) )
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "external_pause not valid";
|
||||
echo "$result: $result_reason - $value|$agent_user\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$stmt = "select count(*) from vicidial_live_agents where user='$agent_user';";
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
if ($row[0] > 0)
|
||||
{
|
||||
if (ereg("RESUME",$value))
|
||||
{
|
||||
$stmt = "select count(*) from vicidial_live_agents where user='$agent_user' and status IN('READY','QUEUE','INCALL','CLOSER');";
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
if ($row[0] > 0)
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "external_pause agent is not paused";
|
||||
echo "$result: $result_reason - $value|$agent_user\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$stmt="UPDATE vicidial_live_agents set external_pause='$value!$epoch' where user='$agent_user';";
|
||||
if ($format=='debug') {echo "\n<!-- $stmt -->";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$result = 'SUCCESS';
|
||||
$result_reason = "external_pause function set";
|
||||
echo "$result: $result_reason - $value|$epoch|$agent_user\n";
|
||||
$data = "$epoch";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "agent_user is not logged in";
|
||||
echo "$result: $result_reason - $agent_user\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
}
|
||||
}
|
||||
################################################################################
|
||||
### END - external_pause
|
||||
################################################################################
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
################################################################################
|
||||
### BEGIN - external_dial - place a manual dial phone call
|
||||
################################################################################
|
||||
if ($function == 'external_dial')
|
||||
{
|
||||
if ( (strlen($value)<2) || (strlen($agent_user)<2) || (strlen($search)<2) || (strlen($preview)<2) || (strlen($focus)<2) )
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "external_dial not valid";
|
||||
$data = "$phone_code|$search|$preview|$focus";
|
||||
echo "$result: $result_reason - $value|$data|$agent_user\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$stmt = "select count(*) from vicidial_live_agents where user='$agent_user';";
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
if ($row[0] > 0)
|
||||
{
|
||||
$stmt = "select count(*) from vicidial_live_agents where user='$agent_user' and status='PAUSED' and lead_id < 1;";
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
if ($row[0] > 0)
|
||||
{
|
||||
$stmt = "select count(*) from vicidial_users where user='$agent_user' and agentcall_manual='1';";
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
if ($row[0] > 0)
|
||||
{
|
||||
$stmt="UPDATE vicidial_live_agents set external_dial='$value!$phone_code!$search!$preview!$focus!$epoch' where user='$agent_user';";
|
||||
if ($format=='debug') {echo "\n<!-- $stmt -->";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$result = 'SUCCESS';
|
||||
$result_reason = "external_dial function set";
|
||||
$data = "$phone_code|$search|$preview|$focus|$epoch";
|
||||
echo "$result: $result_reason - $value|$agent_user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "agent_user is not allowed to place manual dial calls";
|
||||
echo "$result: $result_reason - $agent_user\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "agent_user is not paused";
|
||||
echo "$result: $result_reason - $agent_user\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "agent_user is not logged in";
|
||||
echo "$result: $result_reason - $agent_user\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
}
|
||||
}
|
||||
################################################################################
|
||||
### END - external_dial
|
||||
################################################################################
|
||||
|
||||
|
||||
|
||||
@@ -208,4 +447,24 @@ echo "\n</body>\n</html>\n";
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
##### FUNCTIONS #####
|
||||
|
||||
##### Logging #####
|
||||
function api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data)
|
||||
{
|
||||
if ($api_logging > 0)
|
||||
{
|
||||
$NOW_TIME = date("Y-m-d H:i:s");
|
||||
# api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
$stmt="INSERT INTO vicidial_api_log set user='$user',agent_user='$agent_user',function='$function',value='$value',result='$result',result_reason='$result_reason',source='$source',data='$data',api_date='$NOW_TIME',api_script='$api_script';";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -41,10 +41,11 @@
|
||||
# 81104-0229 - Added mysql error logging capability
|
||||
# 81104-1409 - Added multi-retry for some vicidial_live_agents table MySQL queries
|
||||
# 90102-1402 - Added check for system and database time synchronization
|
||||
# 90120-1720 - Added compatibility for API pause/resume and dial a number
|
||||
#
|
||||
|
||||
$version = '2.0.4-16';
|
||||
$build = '90102-1402';
|
||||
$version = '2.0.4-17';
|
||||
$build = '90120-1720';
|
||||
$mel=1; # Mysql Error Log enabled = 1
|
||||
$mysql_log_count=14;
|
||||
$one_mysql_log=0;
|
||||
@@ -295,13 +296,15 @@ echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
|
||||
}
|
||||
|
||||
### grab the API hangup and API dispo fields in vicidial_live_agents
|
||||
$stmt="SELECT external_hangup,external_status from vicidial_live_agents where user='$user' and server_ip='$server_ip';";
|
||||
$stmt="SELECT external_hangup,external_status,external_pause,external_dial from vicidial_live_agents where user='$user' and server_ip='$server_ip';";
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03010',$user,$server_ip,$session_name,$one_mysql_log);}
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$external_hangup = $row[0];
|
||||
$external_status = $row[1];
|
||||
$external_pause = $row[2];
|
||||
$external_dial = $row[3];
|
||||
if (strlen($external_status)<1) {$external_status = '::::::::::';}
|
||||
|
||||
$web_epoch = date("U");
|
||||
@@ -322,7 +325,7 @@ echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
|
||||
if ($AexternalDEAD > 0)
|
||||
{$Alogin='DEAD_EXTERNAL';}
|
||||
|
||||
echo 'DateTime: ' . $NOW_TIME . '|UnixTime: ' . $StarTtime . '|Logged-in: ' . $Alogin . '|CampCalls: ' . $RingCalls . '|Status: ' . $Astatus . '|DiaLCalls: ' . $DiaLCalls . '|APIHanguP: ' . $external_hangup . '|APIStatuS: ' . $external_status . "|\n";
|
||||
echo 'DateTime: ' . $NOW_TIME . '|UnixTime: ' . $StarTtime . '|Logged-in: ' . $Alogin . '|CampCalls: ' . $RingCalls . '|Status: ' . $Astatus . '|DiaLCalls: ' . $DiaLCalls . '|APIHanguP: ' . $external_hangup . '|APIStatuS: ' . $external_status . '|APIPausE: ' . $external_pause . '|APIDiaL: ' . $external_dial . "|\n";
|
||||
|
||||
}
|
||||
$total_conf=0;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?
|
||||
# vdc_db_query.php
|
||||
#
|
||||
# Copyright (C) 2008 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
# Copyright (C) 2009 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
#
|
||||
# This script is designed purely to send whether the meetme conference has live channels connected and which they are
|
||||
# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
|
||||
@@ -180,10 +180,11 @@
|
||||
# 81124-2212 - Fixes blind transfer bug
|
||||
# 81126-1522 - Fixed callback comments bug
|
||||
# 81211-0420 - Fixed Manual dial agent_log bug
|
||||
# 90120-1718 - Added external pause and dial option
|
||||
#
|
||||
|
||||
$version = '2.0.5-97';
|
||||
$build = '81211-0420';
|
||||
$version = '2.0.5-98';
|
||||
$build = '90120-1718';
|
||||
$mel=1; # Mysql Error Log enabled = 1
|
||||
$mysql_log_count=184;
|
||||
$one_mysql_log=0;
|
||||
@@ -982,7 +983,7 @@ if ($ACTION == 'manDiaLnextCaLL')
|
||||
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00034',$user,$server_ip,$session_name,$one_mysql_log);}
|
||||
|
||||
### update the agent status to INCALL in vicidial_live_agents
|
||||
$stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME',callerid='$MqueryCID',lead_id='$lead_id',comments='MANUAL',calls_today='$calls_today',external_hangup=0,external_status='' where user='$user' and server_ip='$server_ip';";
|
||||
$stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME',callerid='$MqueryCID',lead_id='$lead_id',comments='MANUAL',calls_today='$calls_today',external_hangup=0,external_status='',external_pause='',external_dial='' where user='$user' and server_ip='$server_ip';";
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00035',$user,$server_ip,$session_name,$one_mysql_log);}
|
||||
@@ -1226,7 +1227,7 @@ if ($ACTION == 'manDiaLonly')
|
||||
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00045',$user,$server_ip,$session_name,$one_mysql_log);}
|
||||
|
||||
### update the agent status to INCALL in vicidial_live_agents
|
||||
$stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME',callerid='$MqueryCID',lead_id='$lead_id',comments='MANUAL',calls_today='$calls_today',external_hangup=0,external_status='' where user='$user' and server_ip='$server_ip';";
|
||||
$stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME',callerid='$MqueryCID',lead_id='$lead_id',comments='MANUAL',calls_today='$calls_today',external_hangup=0,external_status='',external_pause='',external_dial='' where user='$user' and server_ip='$server_ip';";
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00046',$user,$server_ip,$session_name,$one_mysql_log);}
|
||||
@@ -2382,7 +2383,7 @@ if ($ACTION == 'VDADcheckINCOMING')
|
||||
$calls_today++;
|
||||
|
||||
### update the agent status to INCALL in vicidial_live_agents
|
||||
$stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME',calls_today='$calls_today',external_hangup=0,external_status='' where user='$user' and server_ip='$server_ip';";
|
||||
$stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME',calls_today='$calls_today',external_hangup=0,external_status='',external_pause='',external_dial='' where user='$user' and server_ip='$server_ip';";
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00106',$user,$server_ip,$session_name,$one_mysql_log);}
|
||||
|
||||
@@ -213,10 +213,11 @@
|
||||
# 81211-0422 - Fixed Manual dial agent_log bug
|
||||
# 90102-1402 - Added time sync check notification
|
||||
# 90115-0619 - Added ability to send Local Closer to AGENTDIRECT agent_only
|
||||
# 90120-1719 - Added API pause/resume and number dial functionality
|
||||
#
|
||||
|
||||
$version = '2.0.5-192';
|
||||
$build = '90115-0619';
|
||||
$version = '2.0.5-193';
|
||||
$build = '90120-1719';
|
||||
$mel=1; # Mysql Error Log enabled = 1
|
||||
$mysql_log_count=53;
|
||||
$one_mysql_log=0;
|
||||
@@ -1885,6 +1886,7 @@ $CCAL_OUT .= "</table>";
|
||||
var CallBackCommenTs = '';
|
||||
var scheduled_callbacks = '<? echo $scheduled_callbacks ?>';
|
||||
var dispo_check_all_pause = '<? echo $dispo_check_all_pause ?>';
|
||||
var api_check_all_pause = '<? echo $api_check_all_pause ?>';
|
||||
var agent_pause_codes_active = '<? echo $agent_pause_codes_active ?>';
|
||||
VARpause_codes = new Array(<? echo $VARpause_codes ?>);
|
||||
VARpause_code_names = new Array(<? echo $VARpause_code_names ?>);
|
||||
@@ -2149,6 +2151,8 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";}
|
||||
var dial_method = '<? echo $dial_method ?>';
|
||||
var web_form_target = '<? echo $web_form_target ?>';
|
||||
var TEMP_VDIC_web_form_address = '';
|
||||
var APIPausE_ID = '99999';
|
||||
var APIDiaL_ID = '99999';
|
||||
var DiaLControl_auto_HTML = "<IMG SRC=\"./images/vdc_LB_pause_OFF.gif\" border=0 alt=\" Pause \"><a href=\"#\" onclick=\"AutoDial_ReSume_PauSe('VDADready');\"><IMG SRC=\"./images/vdc_LB_resume.gif\" border=0 alt=\"Resume\"></a>";
|
||||
var DiaLControl_auto_HTML_ready = "<a href=\"#\" onclick=\"AutoDial_ReSume_PauSe('VDADpause');\"><IMG SRC=\"./images/vdc_LB_pause.gif\" border=0 alt=\" Pause \"></a><IMG SRC=\"./images/vdc_LB_resume_OFF.gif\" border=0 alt=\"Resume\">";
|
||||
var DiaLControl_auto_HTML_OFF = "<IMG SRC=\"./images/vdc_LB_pause_OFF.gif\" border=0 alt=\" Pause \"><IMG SRC=\"./images/vdc_LB_resume_OFF.gif\" border=0 alt=\"Resume\">";
|
||||
@@ -2385,7 +2389,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";}
|
||||
if (omit_phone_code == 'Y') {var temp_phone_code = '';}
|
||||
else {var temp_phone_code = document.vicidial_form.phone_code.value;}
|
||||
|
||||
if (manual_string.length > 9)
|
||||
if (manual_string.length > 7)
|
||||
{manual_string = temp_dial_prefix + "" + temp_phone_code + "" + manual_string;}
|
||||
}
|
||||
}
|
||||
@@ -2674,6 +2678,10 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";}
|
||||
var APIHanguP = APIHanguP_array[1];
|
||||
var APIStatuS_array = check_time_array[7].split("APIStatuS: ");
|
||||
var APIStatuS = APIStatuS_array[1];
|
||||
var APIPausE_array = check_time_array[8].split("APIPausE: ");
|
||||
var APIPausE = APIPausE_array[1];
|
||||
var APIDiaL_array = check_time_array[9].split("APIDiaL: ");
|
||||
var APIDiaL = APIDiaL_array[1];
|
||||
if ( (APIHanguP==1) && (VD_live_customer_call==1) )
|
||||
{
|
||||
hideDiv('CustomerGoneBox');
|
||||
@@ -2687,7 +2695,74 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";}
|
||||
document.vicidial_form.DispoSelection.value = APIStatuS;
|
||||
DispoSelect_submit();
|
||||
}
|
||||
if (APIPausE.length > 4)
|
||||
{
|
||||
var APIPausE_array = APIPausE.split("!");
|
||||
if (APIPausE_ID == APIPausE_array[1])
|
||||
{
|
||||
// alert("PAUSE ALREADY RECEIVED");
|
||||
}
|
||||
else
|
||||
{
|
||||
APIPausE_ID = APIPausE_array[1];
|
||||
if (APIPausE_array[0]=='PAUSE')
|
||||
{
|
||||
if (VD_live_customer_call==1)
|
||||
{
|
||||
// set to pause on next dispo
|
||||
document.vicidial_form.DispoSelectStop.checked=true;
|
||||
alert("Setting dispo to PAUSE");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (AutoDialReady==1)
|
||||
{
|
||||
if (auto_dial_level != '0')
|
||||
{
|
||||
AutoDialWaiting = 0;
|
||||
AutoDial_ReSume_PauSe("VDADpause");
|
||||
}
|
||||
VICIDiaL_pause_calling = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( (APIPausE_array[0]=='RESUME') && (AutoDialReady < 1) && (auto_dial_level > 0) )
|
||||
{
|
||||
AutoDialWaiting = 1;
|
||||
AutoDial_ReSume_PauSe("VDADready");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (APIDiaL.length > 8)
|
||||
{
|
||||
var APIDiaL_array_detail = APIDiaL.split("!");
|
||||
if (APIDiaL_ID == APIDiaL_array_detail[5])
|
||||
{
|
||||
// alert("DiaL ALREADY RECEIVED: " + APIDiaL_ID + "|" + APIDiaL_array_detail[5]);
|
||||
}
|
||||
else
|
||||
{
|
||||
APIDiaL_ID = APIDiaL_array_detail[5];
|
||||
document.vicidial_form.MDDiaLCodE.value = APIDiaL_array_detail[1];
|
||||
document.vicidial_form.phone_code.value = APIDiaL_array_detail[1];
|
||||
document.vicidial_form.MDPhonENumbeR.value = APIDiaL_array_detail[0];
|
||||
|
||||
// alert(APIDiaL_array_detail[1] + "-----" + APIDiaL + "-----" + document.vicidial_form.MDDiaLCodE.value + "-----" + document.vicidial_form.phone_code.value);
|
||||
|
||||
if (APIDiaL_array_detail[2] == 'YES') // lookup lead in system
|
||||
{document.vicidial_form.LeadLookuP.checked=true;}
|
||||
else
|
||||
{document.vicidial_form.LeadLookuP.checked=false;}
|
||||
if (APIDiaL_array_detail[4] == 'YES') // focus on vicidial agent screen
|
||||
{window.focus();}
|
||||
if (APIDiaL_array_detail[3] == 'YES') // call preview
|
||||
{NeWManuaLDiaLCalLSubmiT('PREVIEW');}
|
||||
else
|
||||
{NeWManuaLDiaLCalLSubmiT('NOW');}
|
||||
}
|
||||
}
|
||||
|
||||
// ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ above section working on API functions
|
||||
var check_conf_array=check_ALL_array[1].split("|");
|
||||
var live_conf_calls = check_conf_array[0];
|
||||
var conf_chan_array = check_conf_array[1].split(" ~");
|
||||
@@ -3012,7 +3087,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";}
|
||||
if (omit_phone_code == 'Y') {var temp_phone_code = '';}
|
||||
else {var temp_phone_code = document.vicidial_form.phone_code.value;}
|
||||
|
||||
if (blindxferdialstring.length > 9)
|
||||
if (blindxferdialstring.length > 7)
|
||||
{blindxferdialstring = temp_dial_prefix + "" + temp_phone_code + "" + blindxferdialstring;}
|
||||
}
|
||||
}
|
||||
@@ -3517,7 +3592,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";}
|
||||
|
||||
// ################################################################################
|
||||
// Insert the new manual dial as a lead and go to manual dial screen
|
||||
function NeWManuaLDiaLCalLSubmiT()
|
||||
function NeWManuaLDiaLCalLSubmiT(tempDiaLnow)
|
||||
{
|
||||
hideDiv('NeWManuaLDiaLBox');
|
||||
var MDDiaLCodEform = document.vicidial_form.MDDiaLCodE.value;
|
||||
@@ -3527,6 +3602,9 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";}
|
||||
if (document.vicidial_form.LeadLookuP.checked==true)
|
||||
{MDLookuPLeaD = 'lookup';}
|
||||
|
||||
if (MDDiaLCodEform.length < 1)
|
||||
{MDDiaLCodEform = document.vicidial_form.phone_code.value;}
|
||||
|
||||
if (MDDiaLOverridEform.length > 0)
|
||||
{
|
||||
basic_originate_call(session_id,'NO','YES',MDDiaLOverridEform,'YES','','1');
|
||||
@@ -3537,10 +3615,13 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";}
|
||||
auto_dial_level=0;
|
||||
manual_dial_in_progress=1;
|
||||
MainPanelToFront();
|
||||
buildDiv('DiaLLeaDPrevieW');
|
||||
buildDiv('DiaLDiaLAltPhonE');
|
||||
document.vicidial_form.LeadPreview.checked=true;
|
||||
document.vicidial_form.DiaLAltPhonE.checked=true;
|
||||
if (tempDiaLnow == 'PREVIEW')
|
||||
{
|
||||
buildDiv('DiaLLeaDPrevieW');
|
||||
buildDiv('DiaLDiaLAltPhonE');
|
||||
document.vicidial_form.LeadPreview.checked=true;
|
||||
document.vicidial_form.DiaLAltPhonE.checked=true;
|
||||
}
|
||||
ManualDialNext("","",MDDiaLCodEform,MDPhonENumbeRform,MDLookuPLeaD);
|
||||
}
|
||||
|
||||
@@ -3796,7 +3877,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";}
|
||||
if (xmlhttp)
|
||||
{
|
||||
manDiaLnext_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=manDiaLnextCaLL&conf_exten=" + session_id + "&user=" + user + "&pass=" + pass + "&campaign=" + campaign + "&ext_context=" + ext_context + "&dial_timeout=" + dial_timeout + "&dial_prefix=" + dial_prefix + "&campaign_cid=" + campaign_cid + "&preview=" + man_preview + "&agent_log_id=" + agent_log_id + "&callback_id=" + mdnCBid + "&lead_id=" + mdnBDleadid + "&phone_code=" + mdnDiaLCodE + "&phone_number=" + mdnPhonENumbeR + "&list_id=" + mdnLisT_id + "&stage=" + mdnStagE + "&use_internal_dnc=" + use_internal_dnc + "&use_campaign_dnc=" + use_campaign_dnc + "&omit_phone_code=" + omit_phone_code + "&manual_dial_filter=" + manual_dial_filter;
|
||||
// alert(manual_dial_filter + "\n" +manDiaLnext_query);
|
||||
// alert(manual_dial_filter + "\n" +manDiaLnext_query);
|
||||
xmlhttp.open('POST', 'vdc_db_query.php');
|
||||
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
|
||||
xmlhttp.send(manDiaLnext_query);
|
||||
@@ -6958,6 +7039,7 @@ else
|
||||
if (dispo_check_all_pause != '1')
|
||||
{
|
||||
document.vicidial_form.DispoSelectStop.checked=false;
|
||||
alert("unchecking PAUSE");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -7517,7 +7599,9 @@ echo "</head>\n";
|
||||
</td>
|
||||
</tr></table>
|
||||
<BR>
|
||||
<a href="#" onclick="NeWManuaLDiaLCalLSubmiT();return false;">Dial Now</a>
|
||||
<a href="#" onclick="NeWManuaLDiaLCalLSubmiT('NOW');return false;">Dial Now</a>
|
||||
|
||||
<a href="#" onclick="NeWManuaLDiaLCalLSubmiT('PREVIEW');return false;">Preview Call</a>
|
||||
|
||||
<a href="#" onclick="hideDiv('NeWManuaLDiaLBox');return false;">Go Back</a>
|
||||
</TD></TR></TABLE>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?
|
||||
# admin.php - VICIDIAL administration page
|
||||
#
|
||||
# Copyright (C) 2008 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
# Copyright (C) 2009 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
#
|
||||
|
||||
require("dbconnect.php");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?
|
||||
# non_agent_api.php
|
||||
#
|
||||
# Copyright (C) 2008 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
# Copyright (C) 2009 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
#
|
||||
# This script is designed as an API(Application Programming Interface) to allow
|
||||
# other programs to interact with all non-agent-screen VICIDIAL functions
|
||||
@@ -10,6 +10,7 @@
|
||||
# - $user
|
||||
# - $pass
|
||||
# - $function - ('add_lead','version')
|
||||
# - $source - ('vtiger','webform','adminweb')
|
||||
# - $format - ('text','debug')
|
||||
|
||||
# CHANGELOG:
|
||||
@@ -17,10 +18,11 @@
|
||||
# 80801-0047 - Added gmt lookup and hopper insert time validation
|
||||
# 80909-2012 - Added support for campaign-specific DNC lists
|
||||
# 80910-0020 - Added support for multi-alt-phones, added version function
|
||||
# 90118-1056 - Added logging of API functions
|
||||
#
|
||||
|
||||
$version = '2.0.5-4';
|
||||
$build = '80910-0020';
|
||||
$version = '2.0.5-5';
|
||||
$build = '90118-1056';
|
||||
|
||||
require("dbconnect.php");
|
||||
|
||||
@@ -95,6 +97,8 @@ if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];}
|
||||
elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];}
|
||||
if (isset($_GET["multi_alt_phones"])) {$multi_alt_phones=$_GET["multi_alt_phones"];}
|
||||
elseif (isset($_POST["multi_alt_phones"])) {$multi_alt_phones=$_POST["multi_alt_phones"];}
|
||||
if (isset($_GET["source"])) {$source=$_GET["source"];}
|
||||
elseif (isset($_POST["source"])) {$source=$_POST["source"];}
|
||||
|
||||
|
||||
header ("Content-type: text/html; charset=utf-8");
|
||||
@@ -169,6 +173,7 @@ if ($non_latin < 1)
|
||||
$campaign_id = ereg_replace("[^-\_0-9a-zA-Z]","",$campaign_id);
|
||||
$multi_alt_phones = ereg_replace("[^- \+\!\:\_0-9a-zA-Z]","",$multi_alt_phones);
|
||||
$multi_alt_phones = ereg_replace("\+"," ",$multi_alt_phones);
|
||||
$source = ereg_replace("[^0-9a-zA-Z]","",$source);
|
||||
}
|
||||
|
||||
if (strlen($list_id)<1) {$list_id='999';}
|
||||
@@ -184,6 +189,9 @@ $CIDdate = date("mdHis");
|
||||
$ENTRYdate = date("YmdHis");
|
||||
$MT[0]='';
|
||||
$postalgmt='';
|
||||
$api_script = 'non-agent';
|
||||
$api_logging = 1;
|
||||
|
||||
|
||||
$secX = date("U");
|
||||
$hour = date("H");
|
||||
@@ -235,7 +243,10 @@ $LOCAL_GMT_OFF_STD = $SERVER_GMT;
|
||||
################################################################################
|
||||
if ($function == 'version')
|
||||
{
|
||||
echo "VERSION: $version|BUILD: $build|DATE: $NOW_TIME|EPOCH: $StarTtime\n";
|
||||
$data = "VERSION: $version|BUILD: $build|DATE: $NOW_TIME|EPOCH: $StarTtime";
|
||||
$result = 'SUCCESS';
|
||||
echo "$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -247,158 +258,212 @@ if ($function == 'version')
|
||||
################################################################################
|
||||
if ($function == 'add_lead')
|
||||
{
|
||||
$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and vdc_agent_api_access='1' and modify_leads='1';";
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$modify_leads=$row[0];
|
||||
|
||||
if ($modify_leads < 1)
|
||||
if(strlen($source)<2)
|
||||
{
|
||||
echo "ERROR: add_lead USER DOES NOT HAVE PERMISSION TO ADD LEADS TO THE SYSTEM - $user|$modify_leads\n";
|
||||
$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
|
||||
{
|
||||
if ( (strlen($phone_number)<6) || (strlen($phone_number)>16) )
|
||||
$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and vdc_agent_api_access='1' and modify_leads='1';";
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$modify_leads=$row[0];
|
||||
|
||||
if ($modify_leads < 1)
|
||||
{
|
||||
echo "ERROR: add_lead INVALID PHONE NUMBER - $phone_number|$user\n";
|
||||
$result = 'ERROR';
|
||||
$result_reason = "add_lead USER DOES NOT HAVE PERMISSION TO ADD LEADS TO THE SYSTEM";
|
||||
echo "$result: $result_reason: |$user|$modify_leads|\n";
|
||||
$data = "$modify_leads";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($dnc_check == 'Y')
|
||||
if ( (strlen($phone_number)<6) || (strlen($phone_number)>16) )
|
||||
{
|
||||
$stmt="SELECT count(*) from vicidial_dnc where phone_number='$phone_number';";
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$dnc_found=$row[0];
|
||||
|
||||
if ($dnc_found > 0)
|
||||
{
|
||||
echo "ERROR: add_lead PHONE NUMBER IN DNC - $phone_number|$user\n";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
if ($campaign_dnc_check == 'Y')
|
||||
{
|
||||
$stmt="SELECT count(*) from vicidial_campaign_dnc where phone_number='$phone_number' and campaign_id='$campaign_id';";
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$dnc_found=$row[0];
|
||||
|
||||
if ($dnc_found > 0)
|
||||
{
|
||||
echo "ERROR: add_lead PHONE NUMBER IN CAMPAIGN DNC - $phone_number|$campaign_id|$user\n";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
### get current gmt_offset of the phone_number
|
||||
$gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code);
|
||||
|
||||
|
||||
### insert a new lead in the system with this phone number
|
||||
$stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='NEW',user='$user',vendor_lead_code='$vendor_lead_code',source_id='$source_id',gmt_offset_now='$gmt_offset',title='$title',first_name='$first_name',middle_initial='$middle_initial',last_name='$last_name',address1='$address1',address2='$address2',address3='$address3',city='$city',state='$state',province='$province',postal_code='$postal_code',country_code='$country_code',gender='$gender',date_of_birth='$date_of_birth',alt_phone='$alt_phone',email='$email',security_phrase='$security_phrase',comments='$comments',called_since_last_reset='N',entry_date='$ENTRYdate',last_local_call_time='$NOW_TIME';";
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$affected_rows = mysql_affected_rows($link);
|
||||
if ($affected_rows > 0)
|
||||
{
|
||||
$lead_id = mysql_insert_id($link);
|
||||
|
||||
echo "SUCCESS: add_lead LEAD HAS BEEN ADDED - $phone_number|$user|$list_id|$lead_id|$gmt_offset\n";
|
||||
|
||||
if (strlen($multi_alt_phones) > 5)
|
||||
{
|
||||
$map=$MT; $ALTm_phone_code=$MT; $ALTm_phone_number=$MT; $ALTm_phone_note=$MT;
|
||||
$map = explode('!', $multi_alt_phones);
|
||||
$map_count = count($map);
|
||||
if ($DB) {echo "multi-al-entry: $a|$map_count|$multi_alt_phones\n";}
|
||||
$g++;
|
||||
$r=0; $s=0; $inserted_alt_phones=0;
|
||||
while ($r < $map_count)
|
||||
{
|
||||
$s++;
|
||||
$ncn=$MT;
|
||||
$ncn = explode('_', $map[$r]);
|
||||
print "$ncn[0]|$ncn[1]|$ncn[2]";
|
||||
|
||||
if (strlen($forcephonecode) > 0)
|
||||
{$ALTm_phone_code[$r] = $forcephonecode;}
|
||||
else
|
||||
{$ALTm_phone_code[$r] = $ncn[1];}
|
||||
if (strlen($ALTm_phone_code[$r]) < 1)
|
||||
{$ALTm_phone_code[$r]='1';}
|
||||
$ALTm_phone_number[$r] = $ncn[0];
|
||||
$ALTm_phone_note[$r] = $ncn[2];
|
||||
$stmt = "INSERT INTO vicidial_list_alt_phones (lead_id,phone_code,phone_number,alt_phone_note,alt_phone_count) values('$lead_id','$ALTm_phone_code[$r]','$ALTm_phone_number[$r]','$ALTm_phone_note[$r]','$s');";
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$Zaffected_rows = mysql_affected_rows($link);
|
||||
$inserted_alt_phones = ($inserted_alt_phones + $Zaffected_rows);
|
||||
$r++;
|
||||
}
|
||||
echo "NOTICE: add_lead MULTI-ALT-PHONE NUMBERS LOADED - $inserted_alt_phones|$user|$lead_id\n";
|
||||
}
|
||||
|
||||
if ($add_to_hopper == 'Y')
|
||||
{
|
||||
$dialable=1;
|
||||
|
||||
$stmt="SELECT local_call_time,vicidial_campaigns.campaign_id from vicidial_campaigns,vicidial_lists where list_id='$list_id' and vicidial_campaigns.campaign_id=vicidial_lists.campaign_id;";
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$local_call_time=$row[0];
|
||||
$VD_campaign_id=$row[1];
|
||||
|
||||
if ($hopper_local_call_time_check == 'Y')
|
||||
{
|
||||
### call function to determine if lead is dialable
|
||||
$dialable = dialable_gmt($DB,$link,$local_call_time,$gmt_offset,$state);
|
||||
}
|
||||
if ($dialable < 1)
|
||||
{
|
||||
echo "NOTICE: add_lead NOT ADDED TO HOPPER, OUTSIDE OF LOCAL TIME - $phone_number|$user|$lead_id|$gmt_offset|$dialable\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
### code to insert into hopper goes here
|
||||
|
||||
### insert record into vicidial_hopper for alt_phone call attempt
|
||||
$stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$VD_campaign_id',status='READY',list_id='$list_id',gmt_offset_now='$gmt_offset',state='$state',user='',priority='$hopper_priority';";
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$Haffected_rows = mysql_affected_rows($link);
|
||||
if ($Haffected_rows > 0)
|
||||
{
|
||||
$hopper_id = mysql_insert_id($link);
|
||||
|
||||
echo "NOTICE: add_lead ADDED TO HOPPER - $phone_number|$user|$lead_id|$hopper_id\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "NOTICE: add_lead NOT ADDED TO HOPPER - $phone_number|$user|$lead_id|$stmt\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
$result = 'ERROR';
|
||||
$result_reason = "add_lead INVALID PHONE NUMBER";
|
||||
echo "$result: $result_reason - $phone_number|$user\n";
|
||||
$data = "$phone_number";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "ERROR: add_lead LEAD HAS NOT BEEN ADDED - $phone_number|$user|$list_id|$stmt\n";
|
||||
if ($dnc_check == 'Y')
|
||||
{
|
||||
$stmt="SELECT count(*) from vicidial_dnc where phone_number='$phone_number';";
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$dnc_found=$row[0];
|
||||
|
||||
if ($dnc_found > 0)
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "add_lead PHONE NUMBER IN DNC";
|
||||
echo "$result: $result_reason - $phone_number|$user\n";
|
||||
$data = "$phone_number";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
if ($campaign_dnc_check == 'Y')
|
||||
{
|
||||
$stmt="SELECT count(*) from vicidial_campaign_dnc where phone_number='$phone_number' and campaign_id='$campaign_id';";
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$dnc_found=$row[0];
|
||||
|
||||
if ($dnc_found > 0)
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "add_lead PHONE NUMBER IN CAMPAIGN DNC";
|
||||
echo "$result: $result_reason - $phone_number|$campaign_id|$user\n";
|
||||
$data = "$phone_number|$campaign_id";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
### get current gmt_offset of the phone_number
|
||||
$gmt_offset = lookup_gmt($phone_code,$USarea,$state,$LOCAL_GMT_OFF_STD,$Shour,$Smin,$Ssec,$Smon,$Smday,$Syear,$postalgmt,$postal_code);
|
||||
|
||||
|
||||
### insert a new lead in the system with this phone number
|
||||
$stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='NEW',user='$user',vendor_lead_code='$vendor_lead_code',source_id='$source_id',gmt_offset_now='$gmt_offset',title='$title',first_name='$first_name',middle_initial='$middle_initial',last_name='$last_name',address1='$address1',address2='$address2',address3='$address3',city='$city',state='$state',province='$province',postal_code='$postal_code',country_code='$country_code',gender='$gender',date_of_birth='$date_of_birth',alt_phone='$alt_phone',email='$email',security_phrase='$security_phrase',comments='$comments',called_since_last_reset='N',entry_date='$ENTRYdate',last_local_call_time='$NOW_TIME';";
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$affected_rows = mysql_affected_rows($link);
|
||||
if ($affected_rows > 0)
|
||||
{
|
||||
$lead_id = mysql_insert_id($link);
|
||||
|
||||
$result = 'SUCCESS';
|
||||
$result_reason = "add_lead LEAD HAS BEEN ADDED";
|
||||
echo "$result: $result_reason - $phone_number|$list_id|$lead_id|$gmt_offset|$user\n";
|
||||
$data = "$phone_number|$list_id|$lead_id|$gmt_offset";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
|
||||
if (strlen($multi_alt_phones) > 5)
|
||||
{
|
||||
$map=$MT; $ALTm_phone_code=$MT; $ALTm_phone_number=$MT; $ALTm_phone_note=$MT;
|
||||
$map = explode('!', $multi_alt_phones);
|
||||
$map_count = count($map);
|
||||
if ($DB) {echo "multi-al-entry: $a|$map_count|$multi_alt_phones\n";}
|
||||
$g++;
|
||||
$r=0; $s=0; $inserted_alt_phones=0;
|
||||
while ($r < $map_count)
|
||||
{
|
||||
$s++;
|
||||
$ncn=$MT;
|
||||
$ncn = explode('_', $map[$r]);
|
||||
print "$ncn[0]|$ncn[1]|$ncn[2]";
|
||||
|
||||
if (strlen($forcephonecode) > 0)
|
||||
{$ALTm_phone_code[$r] = $forcephonecode;}
|
||||
else
|
||||
{$ALTm_phone_code[$r] = $ncn[1];}
|
||||
if (strlen($ALTm_phone_code[$r]) < 1)
|
||||
{$ALTm_phone_code[$r]='1';}
|
||||
$ALTm_phone_number[$r] = $ncn[0];
|
||||
$ALTm_phone_note[$r] = $ncn[2];
|
||||
$stmt = "INSERT INTO vicidial_list_alt_phones (lead_id,phone_code,phone_number,alt_phone_note,alt_phone_count) values('$lead_id','$ALTm_phone_code[$r]','$ALTm_phone_number[$r]','$ALTm_phone_note[$r]','$s');";
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$Zaffected_rows = mysql_affected_rows($link);
|
||||
$inserted_alt_phones = ($inserted_alt_phones + $Zaffected_rows);
|
||||
$r++;
|
||||
}
|
||||
$result = 'NOTICE';
|
||||
$result_reason = "add_lead MULTI-ALT-PHONE NUMBERS LOADED";
|
||||
echo "$result: $result_reason - $inserted_alt_phones|$lead_id|$user\n";
|
||||
$data = "$inserted_alt_phones|$lead_id";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
|
||||
if ($add_to_hopper == 'Y')
|
||||
{
|
||||
$dialable=1;
|
||||
|
||||
$stmt="SELECT local_call_time,vicidial_campaigns.campaign_id from vicidial_campaigns,vicidial_lists where list_id='$list_id' and vicidial_campaigns.campaign_id=vicidial_lists.campaign_id;";
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$local_call_time=$row[0];
|
||||
$VD_campaign_id=$row[1];
|
||||
|
||||
if ($hopper_local_call_time_check == 'Y')
|
||||
{
|
||||
### call function to determine if lead is dialable
|
||||
$dialable = dialable_gmt($DB,$link,$local_call_time,$gmt_offset,$state);
|
||||
}
|
||||
if ($dialable < 1)
|
||||
{
|
||||
$result = 'NOTICE';
|
||||
$result_reason = "add_lead NOT ADDED TO HOPPER, OUTSIDE OF LOCAL TIME";
|
||||
echo "$result: $result_reason - $phone_number|$lead_id|$gmt_offset|$dialable|$user\n";
|
||||
$data = "$phone_number|$lead_id|$gmt_offset|$dialable";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
else
|
||||
{
|
||||
### code to insert into hopper goes here
|
||||
|
||||
### insert record into vicidial_hopper for alt_phone call attempt
|
||||
$stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$VD_campaign_id',status='READY',list_id='$list_id',gmt_offset_now='$gmt_offset',state='$state',user='',priority='$hopper_priority';";
|
||||
if ($DB) {echo "$stmt\n";}
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$Haffected_rows = mysql_affected_rows($link);
|
||||
if ($Haffected_rows > 0)
|
||||
{
|
||||
$hopper_id = mysql_insert_id($link);
|
||||
|
||||
$result = 'NOTICE';
|
||||
$result_reason = "add_lead ADDED TO HOPPER";
|
||||
echo "$result: $result_reason - $phone_number|$lead_id|$hopper_id|$user\n";
|
||||
$data = "$phone_number|$lead_id|$hopper_id";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = 'NOTICE';
|
||||
$result_reason = "add_lead NOT ADDED TO HOPPER";
|
||||
echo "$result: $result_reason - $phone_number|$lead_id|$stmt|$user\n";
|
||||
$data = "$phone_number|$lead_id|$stmt";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "add_lead LEAD HAS NOT BEEN ADDED";
|
||||
echo "$result: $result_reason - $phone_number|$list_id|$stmt|$user\n";
|
||||
$data = "$phone_number|$list_id|$stmt";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
}
|
||||
}
|
||||
exit;
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
echo "ERROR: NO FUNCTION SPECIFIED\n";
|
||||
$result = 'ERROR';
|
||||
$result_reason = "NO FUNCTION SPECIFIED";
|
||||
echo "$result: $result_reason\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
|
||||
|
||||
|
||||
@@ -1335,4 +1400,20 @@ return $dialable;
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
##### Logging #####
|
||||
function api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data)
|
||||
{
|
||||
if ($api_logging > 0)
|
||||
{
|
||||
$NOW_TIME = date("Y-m-d H:i:s");
|
||||
# api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
$stmt="INSERT INTO vicidial_api_log set user='$user',agent_user='$agent_user',function='$function',value='$value',result='$result',result_reason='$result_reason',source='$source',data='$data',api_date='$NOW_TIME',api_script='$api_script';";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user