diff --git a/agc_2-X/trunk/docs/CALLER_ID_NAME_CODES.txt b/agc_2-X/trunk/docs/CALLER_ID_NAME_CODES.txt index 94fdd934..e425763f 100644 --- a/agc_2-X/trunk/docs/CALLER_ID_NAME_CODES.txt +++ b/agc_2-X/trunk/docs/CALLER_ID_NAME_CODES.txt @@ -7,6 +7,7 @@ This document is meant for reference only, and it does not contain all CID name M - Manual Dial Call (M7152249180000855319) V - Auto-Dial Call (V7152252280000844707) Y - Inbound Call (Y7152252510000822239) +J - Inbound CLOSER Transfer (J7152252510000822239) DC - 3-Way Call (DC943083W0000855319W) S - Agent Login Call (S1307152248588600051) LP - Park Call (LPvdcW13739432176666) diff --git a/agc_2-X/trunk/docs/NON-AGENT_API.txt b/agc_2-X/trunk/docs/NON-AGENT_API.txt index 27e06f85..869c5b9e 100644 --- a/agc_2-X/trunk/docs/NON-AGENT_API.txt +++ b/agc_2-X/trunk/docs/NON-AGENT_API.txt @@ -1,4 +1,4 @@ -NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2013-06-17 +NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2014-01-24 This document describes the functions of an API(Application Programming Interface) for all functions NOT directly relating to the VICIDIAL Agent screen. @@ -34,6 +34,7 @@ add_group_alias - adds group alias to the system user_group_status - real-time status of one or more user groups in_group_status - real-time status of one or more in groups agent_status - real-time status of one user +callid_info - information about a call based upon the caller_code or call ID New scripts: @@ -84,6 +85,7 @@ Changes: 130420-1938 - Added NANPA prefix validation and timezone options 130614-0907 - Added pause code to output of agent_status function 130617-2232 - Added real-time sub-statuses to output of agent_status function +140124-1057 - Added callid_info function API Functions use the 'function' variable @@ -429,6 +431,40 @@ NOTE: real_time_sub_status field can consist of: DEAD, DISPO, 3-WAY, PARK, RING +-------------------------------------------------------------------------------- +callid_info - information about a call based upon the caller_code or call ID + +NOTE: api user for this function must have user_level set to 7 or higher and "view reports" enabled + +REQUIRED FIELDS- +source - description of what originated the API call (maximum 20 characters) +call_id - 16-40 characters + +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 +detail - if set to YES, more call info will be output. Default is NO, only callid and customer talk time will be output + +Example URL strings for API calls: +http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=callid_info&call_id=M4050908070000012345&stage=csv&header=YES + +Example responses: +ERROR: callid_info USER DOES NOT HAVE PERMISSION TO GET CALL INFO - 6666|0 +ERROR: callid_info INVALID SEARCH PARAMETERS - 6666|| +ERROR: callid_info CALL NOT FOUND - 6666|| +ERROR: callid_info CALL LOG NOT FOUND - 6666|| + +A SUCCESS response will not show "SUCCESS", but instead will just print the results in the following format: +call_id,custtime +M4050908070000012345,725 + +Setting "detail=YES" will result in the following output: +call_id,custtime,call_date,campaign_id,list_id,status,user,phone +M4050908070000012345,725,2014-01-24 09:26:09,TESTCAMP,999,A,6666,3125551212 + + + + -------------------------------------------------------------------------------- update_log_entry - updates the status of a vicidial_log or vicidial_closer_log entry diff --git a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql index 62966144..83e59c00 100644 --- a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql +++ b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql @@ -3137,6 +3137,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); CREATE UNIQUE INDEX vicidial_campaign_statuses_key on vicidial_campaign_statuses(status, campaign_id); +CREATE INDEX vlecc on vicidial_log_extended (caller_code); CREATE TABLE call_log_archive LIKE call_log; @@ -3246,4 +3247,4 @@ UPDATE vicidial_configuration set value='1766' where name='qc_database_version'; UPDATE system_settings set vdc_agent_api_active='1'; -UPDATE system_settings SET db_schema_version='1363',db_schema_update_date=NOW(); +UPDATE system_settings SET db_schema_version='1364',db_schema_update_date=NOW(); diff --git a/agc_2-X/trunk/extras/upgrade_2.8.sql b/agc_2-X/trunk/extras/upgrade_2.8.sql index 9c0c901e..8b21d1d3 100644 --- a/agc_2-X/trunk/extras/upgrade_2.8.sql +++ b/agc_2-X/trunk/extras/upgrade_2.8.sql @@ -169,3 +169,7 @@ ALTER TABLE vicidial_api_log_archive MODIFY api_id INT(9) UNSIGNED NOT NULL; ALTER TABLE vicidial_report_log ADD webserver SMALLINT(5) UNSIGNED default '0'; UPDATE system_settings SET db_schema_version='1363',db_schema_update_date=NOW() where db_schema_version < 1363; + +CREATE INDEX vlecc on vicidial_log_extended (caller_code); + +UPDATE system_settings SET db_schema_version='1364',db_schema_update_date=NOW() where db_schema_version < 1364; diff --git a/agc_2-X/trunk/www/vicidial/non_agent_api.php b/agc_2-X/trunk/www/vicidial/non_agent_api.php index 97bcaf77..7b21713c 100644 --- a/agc_2-X/trunk/www/vicidial/non_agent_api.php +++ b/agc_2-X/trunk/www/vicidial/non_agent_api.php @@ -82,10 +82,11 @@ # 130705-1725 - Changes for encrypted password compatibility # 130831-0825 - Changed to mysqli PHP functions # 140107-2143 - Added webserver and url logging +# 140124-1057 - Added callid_info function # -$version = '2.8-58'; -$build = '140107-2143'; +$version = '2.8-59'; +$build = '140124-1057'; $api_url_log = 0; $startMS = microtime(); @@ -338,6 +339,8 @@ if (isset($_GET["expiration_date"])) {$expiration_date=$_GET["expiration_date" elseif (isset($_POST["expiration_date"])) {$expiration_date=$_POST["expiration_date"];} if (isset($_GET["nanpa_ac_prefix_check"])) {$nanpa_ac_prefix_check=$_GET["nanpa_ac_prefix_check"];} elseif (isset($_POST["nanpa_ac_prefix_check"])) {$nanpa_ac_prefix_check=$_POST["nanpa_ac_prefix_check"];} +if (isset($_GET["detail"])) {$detail=$_GET["detail"];} + elseif (isset($_POST["detail"])) {$detail=$_POST["detail"];} header ("Content-type: text/html; charset=utf-8"); @@ -1577,8 +1580,6 @@ if ($api_url_log > 0) ### END optional logging to vicidial_url_log for non-interface URL calls ### - - ################################################################################ ### add_user - adds user to the vicidial_users table ################################################################################ @@ -4494,6 +4495,216 @@ if ($function == 'agent_status') + + +################################################################################ +### callid_info - outputs information about a call based upon the caller_code(or call ID) +################################################################################ +if ($function == 'callid_info') + { + 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 vdc_agent_api_access='1' and view_reports='1' and user_level > 6 and active='Y';"; + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $allowed_user=$row[0]; + if ($allowed_user < 1) + { + $result = 'ERROR'; + $result_reason = "callid_info USER DOES NOT HAVE PERMISSION TO GET CALL 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 + { + $call_search_SQL=''; + $search_ready=0; + $call_id = preg_replace("/\n|\r|\t| /",'',$call_id); + + if ( (strlen($call_id)>17) and (strlen($call_id)<40) and (preg_match("/^Y|^J|^V|^M|^DC|^S|^LP|^VH|^XL/",$call_id)) ) + { + $call_search_SQL .= "where caller_code='$call_id'"; + $search_ready++; + } + if ($search_ready < 1) + { + $result = 'ERROR'; + $result_reason = "callid_info INVALID SEARCH PARAMETERS"; + $data = "$user|$call_id"; + 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 user_group from vicidial_users where user='$user' and user_level > 6 and view_reports='1' and active='Y';"; + if ($DB) {$MAIN.="|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $LOGuser_group = $row[0]; + + $stmt="SELECT admin_viewable_groups from vicidial_user_groups where user_group='$LOGuser_group';"; + if ($DB) {$MAIN.="|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $LOGadmin_viewable_groups = $row[0]; + + $LOGadmin_viewable_groupsSQL=''; + $whereLOGadmin_viewable_groupsSQL=''; + if ( (!preg_match('/\-\-ALL\-\-/i',$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) ) + { + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); + $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + } + + $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='|'; $stage='pipe';} + if (strlen($time_format) < 1) + {$time_format = 'HF';} + if ($header == 'YES') + { + if ($detail == 'YES') + { + $output .= 'call_id' . $DL . 'custtime' . $DL . 'call_date' . $DL . 'phone' . $DL . 'call_type' . $DL . 'campaign_id' . $DL . 'list_id' . $DL . 'status' . $DL . 'user' . "\n"; + } + else + { + $output .= 'call_id' . $DL . 'custtime' . "\n"; + } + } + + $stmt="SELECT uniqueid,call_date,lead_id from vicidial_log_extended $call_search_SQL;"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + $vle_to_list = mysqli_num_rows($rslt); + if ($vle_to_list > 0) + { + $row=mysqli_fetch_row($rslt); + $uniqueid = $row[0]; + $call_date = $row[1]; + $lead_id = $row[2]; + + if (preg_match("/^Y|^J|^LP|^VH/",$call_id)) + { + $stmt="SELECT phone_number,user,status,list_id,campaign_id from vicidial_closer_log where call_date='$call_date' and uniqueid='$uniqueid' and lead_id=$lead_id;"; + $call_type = 'INBOUND'; + } + else + { + if (preg_match("/^V/",$call_id)) + { + $stmt="SELECT phone_number,user,status,list_id,campaign_id from vicidial_log where uniqueid='$uniqueid' and lead_id=$lead_id;"; + $call_type = 'OUTBOUND_AUTO'; + } + else + { + if (preg_match("/^M/",$call_id)) + { + $stmt="SELECT phone_number,user,status,list_id,campaign_id from vicidial_log where uniqueid='$uniqueid' and lead_id=$lead_id;"; + $call_type = 'OUTBOUND_MANUAL'; + } + else + { + $stmt="SELECT phone_number,user,status,list_id,campaign_id from vicidial_log where uniqueid='$uniqueid' and lead_id=$lead_id;"; + $call_type = 'OUTBOUND_OTHER'; + } + } + } + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + $call_to_list = mysqli_num_rows($rslt); + if ($call_to_list > 0) + { + $row=mysqli_fetch_row($rslt); + $log_phone = $row[0]; + $log_user = $row[1]; + $log_status = $row[2]; + $log_list_id = $row[3]; + $log_campaign_id = $row[4]; + $cust_sec = 0; + + $stmt="SELECT talk_sec,dead_sec from vicidial_agent_log where uniqueid='$uniqueid' and lead_id=$lead_id and user='$log_user';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + $agent_to_log = mysqli_num_rows($rslt); + if ($agent_to_log > 0) + { + $row=mysqli_fetch_row($rslt); + $talk_sec = $row[0]; + $dead_sec = $row[1]; + $cust_sec = ($talk_sec - $dead_sec); + } + + if ($detail == 'YES') + { + $output .= "$call_id$DL$cust_sec$DL$call_date$DL$log_phone$DL$call_type$DL$log_campaign_id$DL$log_list_id$DL$log_status$DL$log_user\n"; + } + else + { + $output .= "$call_id$DL$cust_sec\n"; + } + echo "$output"; + + $result = 'SUCCESS'; + $data = "$user|$call_id|$stage"; + $result_reason = "callid_info $output"; + + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + } + else + { + $result = 'ERROR'; + $result_reason = "callid_info CALL LOG NOT FOUND"; + $data = "$user|$agent_user"; + 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 + { + $result = 'ERROR'; + $result_reason = "callid_info CALL NOT FOUND"; + $data = "$user|$agent_user"; + echo "$result: $result_reason: $data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + } + } + } + exit; + } +################################################################################ +### callid_info - outputs information about a call based upon the caller_code(or call ID) +################################################################################ + + + + + ################################################################################ ### update_log_entry - updates the status of a log entry ################################################################################ diff --git a/agc_2-X/trunk/www/vicidial/options-example.php b/agc_2-X/trunk/www/vicidial/options-example.php index 3740a43a..b10b4372 100644 --- a/agc_2-X/trunk/www/vicidial/options-example.php +++ b/agc_2-X/trunk/www/vicidial/options-example.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2014 Matt Florell LICENSE: AGPLv2 # # rename this file to options.php for the settings here to go into effect # @@ -14,6 +14,7 @@ # 120713-1915 - Added option for extended vicidial_list fields for long surveys # 130123-1950 - Added option for using non-selectable statuses in admin_modify_lead.php # 130124-1735 - Added option to display first and last name in user stats results +# 140124-1003 - Removed extra newline at end of file # # used by the realtime_report.php script @@ -78,4 +79,4 @@ $firstlastname_display_user_stats = 0; # agent time detail report login/logout link for user $atdr_login_logout_user_link = 0; -?> +?> \ No newline at end of file