Added update_cid_group_entry function to the Non-Agent API
git-svn-id: svn://192.168.202.10@3117 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
+50
-2
@@ -1,4 +1,4 @@
|
||||
NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2019-03-25
|
||||
NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2019-06-28
|
||||
|
||||
This document describes the functions of an API(Application Programming
|
||||
Interface) for all functions NOT directly relating to the VICIDIAL Agent screen.
|
||||
@@ -49,7 +49,7 @@ call_status_stats - report on number of calls made by campaign and ingroup, with
|
||||
call_dispo_report - call disposition breakdown report
|
||||
lead_callback_info - outputs scheduled callback data for a specific lead
|
||||
agent_campaigns - looks up allowed campaigns/in-groups for a specific user
|
||||
|
||||
update_cid_group_entry - updates CID Group entries
|
||||
|
||||
New scripts:
|
||||
/vicidial/non_agent_api.php - the script that is accessed to execute commands
|
||||
@@ -142,6 +142,7 @@ Changes:
|
||||
180916-1059 - Added check for daily list reset limit
|
||||
181214-1606 - Added lead_callback_info function
|
||||
190325-1055 - Added agent_campaigns function
|
||||
190628-1504 - Added update_cid_group_entry function
|
||||
|
||||
|
||||
API Functions use the 'function' variable
|
||||
@@ -1781,4 +1782,51 @@ SUCCESS: update_did DID HAS BEEN UPDATED - 6666|1101
|
||||
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
update_cid_group_entry - updates CID Group entries in the vicidial_campaign_cid_areacodes table
|
||||
|
||||
NOTE: api user for this function must have user_level set to 8 or higher and "Modify Campaigns" enabled
|
||||
|
||||
REQUIRED FIELDS-
|
||||
cid_group_id - 2-20 characters, must be a valid CID Group ID or Campaign ID in the system
|
||||
source - description of what originated the API call (maximum 20 characters)
|
||||
areacode - This should be either the AREACODE(i.e. "312") or STATE(i.e. "FL") of the CID Group entry, you can also set this to "---ALL---"
|
||||
stage - UPDATE, ADD, DELETE or INFO
|
||||
|
||||
OPTIONAL FIELDS-
|
||||
outbound_cid - 1-20 digits, or (if you want to UPDATE, DELETE or INFO all entries for an areacode, you can set this to "---ALL---" or leave it blank)
|
||||
|
||||
EDITABLE FIELDS-
|
||||
cid_description - 6-50 characters, default is blank
|
||||
active - Must be one of these: 'Y','N', default is 'N'
|
||||
|
||||
Example URL strings for API calls:
|
||||
http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=update_cid_group_entry&stage=INFO&cid_group_id=TESTINX5&areacode=---ALL---
|
||||
http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=update_cid_group_entry&stage=ADD&cid_group_id=testing_here4&areacode=312&outbound_cid=3125551212&cid_description=Testing+DID&active=N
|
||||
http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=update_cid_group_entry&stage=DELETE&cid_group_id=testing_here4&areacode=312&outbound_cid=3125551212
|
||||
http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=update_cid_group_entry&stage=UPDATE&cid_group_id=testing_here4&areacode=312&outbound_cid=3125551212&active=Y
|
||||
http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=update_cid_group_entry&stage=UPDATE&cid_group_id=testing_here4&areacode=312&outbound_cid=---ALL---&active=N&cid_description=Deactivated+for+now
|
||||
|
||||
Example responses:
|
||||
ERROR: update_cid_group_entry USER DOES NOT HAVE PERMISSION TO UPDATE CID GROUPS - 6666
|
||||
ERROR: update_cid_group_entry YOU MUST USE ALL REQUIRED FIELDS - 6666|1||
|
||||
ERROR: update_cid_group_entry NOT AN ALLOWED CID GROUP - 98762
|
||||
ERROR: update_cid_group_entry CID GROUP DOES NOT EXIST - 6666|1000
|
||||
ERROR: update_cid_group_entry THIS CID GROUP HAS NO ENTRIES - 6666|1000
|
||||
SUCCESS: update_cid_group_entry CID GROUP INFO AS FOLLOWS - 1101|---ALL---|---ALL---|3
|
||||
1|727|7275551212|N|FL1 test|0
|
||||
2|727|7275551313|N|FL1 test|0
|
||||
4|998|7275551114|N|FL2 test|0
|
||||
|
||||
ERROR: update_cid_group_entry YOU MUST DEFINE AN AREACODE WHEN ADDING AND ENTRY - 6666|1000|---ALL---
|
||||
ERROR: update_cid_group_entry YOU MUST DEFINE A CID NUMBER WHEN ADDING AND ENTRY - 6666|1000|1
|
||||
ERROR: update_cid_group_entry THIS CID GROUP ENTRY ALREADY EXISTS - 6666|1000|813|8135551212
|
||||
SUCCESS: update_cid_group_entry CID GROUP ENTRY HAS BEEN ADDED - 6666|1101|813|8135551212|1
|
||||
SUCCESS: update_cid_group_entry CID GROUP ENTRIES HAVE BEEN DELETED - 6666|1101|813|8135551212|1
|
||||
ERROR: update_cid_group_entry NO UPDATES DEFINED - 6666|813|8135551212||
|
||||
SUCCESS: update_cid_group_entry CID GROUP ENTRIES HAVE BEEN UPDATED - 6666|1101|813|8135551212|1
|
||||
|
||||
|
||||
|
||||
ERROR: NO FUNCTION SPECIFIED
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# version: 20190627153101
|
||||
# version: 20190628131101
|
||||
users-user User ID <QXZ>This field is where you put the users ID number, can be up to 8 digits in length, Must be at least 2 characters in length.</QXZ>
|
||||
users-pass Password <QXZ>This field is where you put the users password. Must be at least 2 characters in length. A medium strength user password will be at least 10 characters in length, and a strong user password will be at least 20 characters in length and have letters as well as at least one number. It is recommended that you use a longer password if possible, stringing together several unrelated words with no spaces, and a number somewhere in the string. The maximum size of a password is 100 characters.</QXZ>
|
||||
users-force_change_password Force Change Password <QXZ>If this option is set to Y then the user will be prompted to change their password the next time they log in to the administration webpage. Default is N.</QXZ>
|
||||
@@ -1190,7 +1190,7 @@ template_maker-list_id List ID <QXZ>All templates must load their records into a
|
||||
template_maker-assign_columns Assigning columns <QXZ>Once you have loaded a sample lead file matching the layout you want to make into a template and select a list ID to load leads into, all of the available columns from the list table and the custom table for the list you selected (if any) will be displayed here. Columns highlighted in blue are standard columns from the list table. Columns highlighted in pink belong to the custom table for the selected list. Each column listed has a drop-down menu, which should be populated with the fields from the first row of the sample lead file you uploaded. Assign the appropriate fields to the appropriate columns and press SUBMIT TEMPLATE to create your template. You do not need to assign every field to a column, and you do not need to assign every column a field. For details on the standard list columns, click</QXZ> <a href='#list_loader'><QXZ>HERE</QXZ></a>.
|
||||
max_stats Maximum System Stats <QXZ>These statistics are cached totals that are stored throughout each day in real-time through back-end processes. For inbound calls, the total calls per in-group are calculated for each call that enters the process that calculates. For the whole system counts, the totals are generated from log entries as well as other in-group and campaign totals. These totals may not add up due to the settings that you have in your system as well as when the call is hung up.</QXZ>
|
||||
qc_status_codes The Quality Control <QXZ>QC function has its own set of status codes separate from those within the call handling functions of the system. QC status codes must be between 2 and 8 characters in length and contain no special characters like a space or colon. The QC status code description must be between 2 and 30 characters in length. For these functions to work, you must have QC enabled in the System Settings.</QXZ>
|
||||
agent_time_detail Agent Time Detail <QXZ>In this report you can view how much time agents spent on what.</QXZ><BR><QXZ><U>TIME CLOCK</U> = Time the agent been logged in to the time clock.</QXZ><BR><QXZ><U>AGENT TIME</U> = Total time on the system (<U>WAIT</U> + <U>TALK</U> + <U>DISPO</U> + <U>PAUSE</U>).</QXZ><BR><QXZ><U>WAIT</U> = Time the agent waits for a call.</QXZ><BR><QXZ><U>TALK</U> = Time the agent talks to a customer or is in dead state (<U>DEAD</U> + <U>CUSTOMER</U>).</QXZ><BR><QXZ><U>DISPO</U> = Time the agent uses at the disposition screen (where the agent picks NI, SALE etc).</QXZ><BR><QXZ><U>PAUSE</U> = Time the agent is in pause mode (<U>LOGIN</U> + <U>LAGGED</U> + ...).</QXZ><BR><QXZ><U>DEAD</U> = Time the agent is in a call after the customer has hung up.</QXZ><BR><QXZ><U>CUSTOMER</U> = Time the agent is in a live call with a customer.</QXZ><BR><QXZ>- The next table is pause codes and their time.</QXZ><BR><QXZ><U>LOGIN</U> = The pause code when going from login directly to pause.</QXZ><BR><QXZ><U>LAGGED</U> = The time the agent had some network problem or similar.</QXZ><BR><QXZ><U>ANDIAL</U> = This pause code triggers if the agent been on dispo screen for longer than 1000 seconds.</QXZ><BR><QXZ>and empty is undefined pause code.</QXZ>
|
||||
agent_time_detail Agent Time Detail <QXZ>In this report you can view how much time agents spent on what.</QXZ><BR><QXZ><U>TIME CLOCK</U> = Time the agent been logged in to the time clock.</QXZ><BR><QXZ><U>AGENT TIME</U> = Total time on the system (<U>WAIT</U> + <U>TALK</U> + <U>DISPO</U> + <U>PAUSE</U>).</QXZ><BR><QXZ><U>WAIT</U> = Time the agent waits for a call.</QXZ><BR><QXZ><U>TALK</U> = Time the agent talks to a customer or is in dead state (<U>DEAD</U> + <U>CUSTOMER</U>).</QXZ><BR><QXZ><U>DISPO</U> = Time the agent uses at the disposition screen (where the agent picks NI, SALE etc).</QXZ><BR><QXZ><U>PAUSE</U> = Time the agent is in pause mode (<U>LOGIN</U> + <U>LAGGED</U> + ...).</QXZ><BR><QXZ><U>DEAD</U> = Time the agent is in a call after the customer has hung up.</QXZ><BR><QXZ><U>CUSTOMER</U> = Time the agent is in a live call with a customer.</QXZ><BR><QXZ><U>CONNECTED</U> = Time the agent is waiting for a live call plus time in a live call with a customer.</QXZ><BR><QXZ>- The next table is pause codes and their time.</QXZ><BR><QXZ><U>LOGIN</U> = The pause code when going from login directly to pause.</QXZ><BR><QXZ><U>LAGGED</U> = The time the agent had some network problem or similar.</QXZ><BR><QXZ><U>ANDIAL</U> = This pause code triggers if the agent been on dispo screen for longer than 1000 seconds.</QXZ><BR><QXZ>and empty is undefined pause code.</QXZ>
|
||||
agent_status_detail Agent Status Detail <QXZ>In this report you can view what and how many statuses has been selected by the agents.</QXZ><BR><QXZ><U>CALLS</U> = Total number of calls sent to the user.</QXZ><BR><QXZ><U>CIcalls</U> = Total number of call where there was a Human Answer which is set under Admin -> System Statuses.</QXZ><BR><QXZ><U>DNC/CI%</U> = How much in percent DNC (Do Not Call) per Human Answers.</QXZ><BR><QXZ>And the rest is just System Statuses that the agent picked and how many, to find out what they means then head over to Admin -> System Statuses.</QXZ>
|
||||
agent_performance_detail Agent Performance Detail <QXZ>This is a combination of Agent Time Detail and Agent Status Detail.</QXZ><BR><QXZ>(Statistics related to handling of calls only. What this means is that the top section will only include time involving a phone call. If an agent clicks to go active, then pauses, then goes active again without taking a call, that time will not be included in the top section of this report.)</QXZ><BR><QXZ><U>CALLS</U> = Total number of calls sent to the user.</QXZ><BR><QXZ><U>TIME</U> = Total time of these (<U>PAUSE</U> + <U>WAIT</U> + <U>TALK</U> + <U>DISPO</U>).</QXZ><BR><QXZ><U>PAUSE</U> = Amount of time being paused in related to call handling.</QXZ><BR><QXZ><U>AVG</U> means Average so everything -AVG is for example amount of PAUSE-time divided by total number of calls: (<U>PAUSE</U> / <U>CALLS</U> = <U>PAUSAVG</U>)</QXZ><BR><QXZ><U>WAIT</U> = Time the agent waits for a call.</QXZ><BR><QXZ><U>TALK</U> = Time the agent talks to a customer or is in dead state (<U>DEAD</U> + <U>CUSTOMER</U>).</QXZ><BR><QXZ><U>DISPO</U> = Time the agent uses at the disposition screen (where the agent picks NI, SALE etc).</QXZ><BR><QXZ><U>DEAD</U> = Time the agent is in a call after the customer has hung up.</QXZ><BR><QXZ><U>CUSTOMER</U> = Time the agent is in a live call with a customer.</QXZ><BR><QXZ>And the rest is just System Statuses that the agent picked and how many, to find out what they means then head over to Admin -> System Statuses.</QXZ><BR><QXZ>- Next table is Pause Codes.</QXZ><BR><QXZ><U>LOGIN TIME</U> = Total time on the system (<U>WAIT</U> + <U>TALK</U> + <U>DISPO</U> + <U>PAUSE</U>).</QXZ><BR><QXZ><U>NONPAUSE</U> = Everything except pause (<U>WAIT</U> + <U>TALK</U> + <U>DISPO</U>).</QXZ><BR><QXZ><U>PAUSE</U> = Only Pause.</QXZ><BR><QXZ>- The last table is pause codes and their time (like Agent Time Detail).</QXZ><BR><QXZ><U>LOGIN</U> = The pause code when going from login directly to pause.</QXZ><BR><QXZ><U>LAGGED</U> = The time the agent had some network problem or similar.</QXZ><BR><QXZ><U>ANDIAL</U> = This pause code triggers if the agent been on dispo screen for longer than 1000 seconds.</QXZ><BR><QXZ>and empty is undefined pause code.</QXZ>
|
||||
team_performance_detail Team Performance Detail <QXZ>This report contains some of the same information as the Agent Time Detail report, as well as several new fields. Also, the users are grouped together within their User Groups, and there is a User Group summary at the bottom of the results.</QXZ><BR><QXZ><U>CALLS</U> = Total number of calls sent to the user.</QXZ><BR><QXZ><U>LEADS</U> = Total number of unique leads the user handled.</QXZ><BR><QXZ><U>CONTACTS</U> = Total number of calls the user handled that were statused in a Customer Contact status.</QXZ><BR><QXZ><U>CONTACT RATIO</U> = Percent of calls where a customer was contacted.</QXZ><BR><QXZ><U>NONPAUSE</U> = Everything except pause (<U>WAIT</U> + <U>TALK</U> + <U>DISPO</U>).</QXZ><BR><QXZ><U>TIME</U> = Total time of these (<U>PAUSE</U> + <U>WAIT</U> + <U>TALK</U> + <U>DISPO</U>).</QXZ><BR><QXZ><U>TALK</U> = Time the agent talks to a customer minus <U>DEAD</U> time.</QXZ><BR><QXZ><U>SALES</U> = Total number of calls the user handled where the SALE status flag is set to Y.</QXZ><BR><QXZ><U>SALES PER WORKING HOUR</U> = Total number of sales divided by system time.</QXZ><BR><QXZ><U>SALES TO LEADS RATIO</U> = Total number of sales divided by leads handled.</QXZ><BR><QXZ><U>SALES TO CONTACTS RATIO</U> = Total number of sales divided by contacts.</QXZ><BR><QXZ><U>SALES PER HOUR</U> = Total number of sales divided by talk time.</QXZ><BR><QXZ><U>INCOMPLETE SALES</U> = Total number of calls statused as QCFAIL.</QXZ><BR><QXZ><U>CANCELLED SALES</U> = Total number of calls statused as QCCANC.</QXZ><BR><QXZ><U>CALLBACKS</U> = Total number of active or live callbacks for this user in the system.</QXZ><BR><QXZ><U>FIRST CALL RESOLUTION</U> = Total number of calls handled divided by leads handled.</QXZ><BR><QXZ><U>AVERAGE SALE TIME</U> = Total number of sales divided by the talk time for those sales calls.</QXZ><BR><QXZ><U>AVERAGE CONTACT TIME</U> = Total number of contacts divided by the talk time for those contact calls.</QXZ>
|
||||
|
||||
@@ -136,10 +136,11 @@
|
||||
# 181214-1606 - Added lead_callback_info function
|
||||
# 190313-0710 - Fix for update_lead custom fields issue #1134
|
||||
# 190325-1055 - Added agent_campaigns function
|
||||
# 190628-1504 - Added update_cid_group_entry function
|
||||
#
|
||||
|
||||
$version = '2.14-113';
|
||||
$build = '190325-1055';
|
||||
$version = '2.14-114';
|
||||
$build = '190628-1504';
|
||||
$api_url_log = 0;
|
||||
|
||||
$startMS = microtime();
|
||||
@@ -498,6 +499,12 @@ if (isset($_GET["filter_clean_cid_number"])) {$filter_clean_cid_number=$_GET["
|
||||
elseif (isset($_POST["filter_clean_cid_number"])) {$filter_clean_cid_number=$_POST["filter_clean_cid_number"];}
|
||||
if (isset($_GET["ignore_agentdirect"])) {$ignore_agentdirect=$_GET["ignore_agentdirect"];}
|
||||
elseif (isset($_POST["ignore_agentdirect"])) {$ignore_agentdirect=$_POST["ignore_agentdirect"];}
|
||||
if (isset($_GET["areacode"])) {$areacode=$_GET["areacode"];}
|
||||
elseif (isset($_POST["areacode"])) {$areacode=$_POST["areacode"];}
|
||||
if (isset($_GET["cid_group_id"])) {$cid_group_id=$_GET["cid_group_id"];}
|
||||
elseif (isset($_POST["cid_group_id"])) {$cid_group_id=$_POST["cid_group_id"];}
|
||||
if (isset($_GET["cid_description"])) {$cid_description=$_GET["cid_description"];}
|
||||
elseif (isset($_POST["cid_description"])) {$cid_description=$_POST["cid_description"];}
|
||||
|
||||
|
||||
header ("Content-type: text/html; charset=utf-8");
|
||||
@@ -631,7 +638,7 @@ if ($non_latin < 1)
|
||||
$registration_password=preg_replace('/[^-_0-9a-zA-Z]/','',$registration_password);
|
||||
$phone_full_name=preg_replace('/[^- \+\.\_0-9a-zA-Z]/','',$phone_full_name);
|
||||
$local_gmt=preg_replace('/[^-\.0-9]/','',$local_gmt);
|
||||
$outbound_cid=preg_replace('/[^0-9]/','',$outbound_cid);
|
||||
$outbound_cid=preg_replace('/[^-_0-9a-zA-Z]/','',$outbound_cid);
|
||||
$phone_context=preg_replace('/[^-_0-9a-zA-Z]/','',$phone_context);
|
||||
$list_name=preg_replace('/[^- \+\.\:\/\@\?\&\_0-9a-zA-Z]/','',$list_name);
|
||||
$active=preg_replace('/[^A-Z]/','',$active);
|
||||
@@ -712,6 +719,13 @@ if ($non_latin < 1)
|
||||
$extension = preg_replace('/[^-\*\#\.\:\/\@\_0-9a-zA-Z]/','',$extension);
|
||||
$filter_clean_cid_number = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$filter_clean_cid_number);
|
||||
$ignore_agentdirect = preg_replace('/[^A-Z]/','',$ignore_agentdirect);
|
||||
$areacode = preg_replace('/[^-_0-9a-zA-Z]/','',$areacode);
|
||||
$cid_group_id = preg_replace('/[^-_0-9a-zA-Z]/','',$cid_group_id);
|
||||
$cid_description = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$cid_description);
|
||||
if ($outbound_cid != '---ALL---')
|
||||
{$outbound_cid=preg_replace('/[^0-9]/','',$outbound_cid);}
|
||||
if ($areacode != '---ALL---')
|
||||
{$areacode=preg_replace('/[^0-9a-zA-Z]/','',$areacode);}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -5395,6 +5409,364 @@ if ($function == 'update_did')
|
||||
|
||||
|
||||
|
||||
################################################################################
|
||||
### update_cid_group_entry - updates CID Group entries in the vicidial_campaign_cid_areacodes table
|
||||
################################################################################
|
||||
if ($function == 'update_cid_group_entry')
|
||||
{
|
||||
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
|
||||
{
|
||||
if ( (!preg_match("/ $function /",$api_allowed_functions)) and (!preg_match("/ALL_FUNCTIONS/",$api_allowed_functions)) )
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "auth USER DOES NOT HAVE PERMISSION TO USE THIS FUNCTION";
|
||||
echo "$result: $result_reason: |$user|$function|\n";
|
||||
$data = "$allowed_user";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
$stmt="SELECT count(*) from vicidial_users where user='$user' and vdc_agent_api_access='1' and modify_campaigns='1' and user_level >= 8 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 = "update_cid_group_entry USER DOES NOT HAVE PERMISSION TO UPDATE CID GROUPS";
|
||||
$data = "$allowed_user";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( (strlen($cid_group_id)<1) or (strlen($cid_group_id)>20) or (strlen($stage)<3) or (strlen($stage)>6) or (strlen($areacode)<1) or (strlen($areacode)>9) )
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "update_cid_group_entry YOU MUST USE ALL REQUIRED FIELDS";
|
||||
$data = "$cid_group_id|$areacode|$stage";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$stmt="SELECT allowed_campaigns,admin_viewable_groups from vicidial_user_groups where user_group='$LOGuser_group';";
|
||||
if ($DB>0) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_to_mysqli($stmt, $link);
|
||||
$row=mysqli_fetch_row($rslt);
|
||||
$LOGallowed_campaigns = $row[0];
|
||||
$LOGadmin_viewable_groups = $row[1];
|
||||
|
||||
$LOGallowed_campaignsSQL='';
|
||||
$whereLOGallowed_campaignsSQL='';
|
||||
if ( (!preg_match('/\-ALL/i', $LOGallowed_campaigns)) )
|
||||
{
|
||||
$rawLOGallowed_campaignsSQL = preg_replace("/ -/",'',$LOGallowed_campaigns);
|
||||
$rawLOGallowed_campaignsSQL = preg_replace("/ /","','",$rawLOGallowed_campaignsSQL);
|
||||
$LOGallowed_campaignsSQL = "and campaign_id IN('$rawLOGallowed_campaignsSQL')";
|
||||
$whereLOGallowed_campaignsSQL = "where campaign_id IN('$rawLOGallowed_campaignsSQL')";
|
||||
}
|
||||
$admin_viewable_groupsSQL='';
|
||||
$WHEREadmin_viewable_groupsSQL='';
|
||||
if (!preg_match('/\-\-ALL\-\-/i',$LOGadmin_viewable_groups))
|
||||
{
|
||||
$rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups);
|
||||
$rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL);
|
||||
$admin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')";
|
||||
$WHEREadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')";
|
||||
}
|
||||
|
||||
$stmt="SELECT count(*) from vicidial_cid_groups where cid_group_id='$cid_group_id' $admin_viewable_groupsSQL;";
|
||||
if ($DB>0) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_to_mysqli($stmt, $link);
|
||||
$row=mysqli_fetch_row($rslt);
|
||||
$did_exists=$row[0];
|
||||
if ($did_exists < 1)
|
||||
{
|
||||
$stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$cid_group_id' $LOGallowed_campaignsSQL;";
|
||||
if ($DB>0) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_to_mysqli($stmt, $link);
|
||||
$row=mysqli_fetch_row($rslt);
|
||||
$campaign_exists=$row[0];
|
||||
|
||||
if ($campaign_exists < 1)
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "update_cid_group_entry CID GROUP DOES NOT EXIST";
|
||||
$data = "$cid_group_id";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$areacodeSQL = "and areacode='$areacode'";
|
||||
if ($areacode == '---ALL---')
|
||||
{$areacodeSQL='';}
|
||||
$outbound_cidSQL = "and outbound_cid='$outbound_cid'";
|
||||
if ( ($outbound_cid == '---ALL---') or (strlen($outbound_cid) < 1) )
|
||||
{$outbound_cidSQL='';}
|
||||
|
||||
##### BEGIN get information on CID Group entries #####
|
||||
if ($stage == 'INFO')
|
||||
{
|
||||
$stmt="SELECT areacode,outbound_cid,active,cid_description,call_count_today from vicidial_campaign_cid_areacodes where campaign_id='$cid_group_id' $areacodeSQL $outbound_cidSQL order by areacode,outbound_cid;";
|
||||
if ($DB>0) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_to_mysqli($stmt, $link);
|
||||
$vcca_recs = mysqli_num_rows($rslt);
|
||||
$M=0;
|
||||
if ($vcca_recs > $M)
|
||||
{
|
||||
$results_output="SUCCESS: update_cid_group_entry CID GROUP INFO AS FOLLOWS $cid_group_id|$areacode|$outbound_cid|$vcca_recs\n";
|
||||
$data = "$cid_group_id|$areacode|$outbound_cid|$vcca_recs";
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "update_cid_group_entry THIS CID GROUP HAS NO ENTRIES";
|
||||
$data = "$cid_group_id";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
while ($vcca_recs > $M)
|
||||
{
|
||||
$row=mysqli_fetch_row($rslt);
|
||||
$ACareacode = $row[0];
|
||||
$ACoutbound_cid = $row[1];
|
||||
$ACactive = $row[2];
|
||||
$ACcid_description = $row[3];
|
||||
$ACcall_count_today = $row[4];
|
||||
if ($ACactive == '') {$ACactive='N';}
|
||||
|
||||
$M++;
|
||||
|
||||
$results_output.="$M|$ACareacode|$ACoutbound_cid|$ACactive|$ACcid_description|$ACcall_count_today\n";
|
||||
}
|
||||
|
||||
$result = 'SUCCESS';
|
||||
$result_reason = "update_cid_group_entry CID GROUP INFO AS FOLLOWS";
|
||||
echo "$results_output";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
##### END get information on CID Group entries #####
|
||||
|
||||
##### BEGIN add a CID Group entry #####
|
||||
if ($stage == 'ADD')
|
||||
{
|
||||
if ($areacode == '---ALL---')
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "update_cid_group_entry YOU MUST DEFINE AN AREACODE WHEN ADDING AND ENTRY";
|
||||
$data = "$cid_group_id|$areacode";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
if (strlen($outbound_cid) < 4)
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "update_cid_group_entry YOU MUST DEFINE A CID NUMBER WHEN ADDING AND ENTRY";
|
||||
$data = "$cid_group_id|$outbound_cid";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
if ( (strlen($active) < 1) or ($active == 'N') or ( ($active != 'Y') and ($active != 'N') ) )
|
||||
{$active = '';}
|
||||
if (strlen($cid_description) < 1)
|
||||
{$cid_description = '';}
|
||||
|
||||
$stmt="SELECT count(*) from vicidial_campaign_cid_areacodes where campaign_id='$cid_group_id' and areacode='$areacode' and outbound_cid='$outbound_cid';";
|
||||
if ($DB>0) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_to_mysqli($stmt, $link);
|
||||
$row=mysqli_fetch_row($rslt);
|
||||
$cid_exists=$row[0];
|
||||
if ($cid_exists > 0)
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "update_cid_group_entry THIS CID GROUP ENTRY ALREADY EXISTS";
|
||||
$data = "$cid_group_id|$areacode|$outbound_cid";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt="INSERT INTO vicidial_campaign_cid_areacodes SET campaign_id='$cid_group_id',areacode='$areacode',outbound_cid='$outbound_cid',active='$active',cid_description='$cid_description';";
|
||||
$rslt=mysql_to_mysqli($stmt, $link);
|
||||
$insert_count = mysqli_affected_rows($link);
|
||||
if ($DB) {echo "$insert_count|$stmt|\n";}
|
||||
|
||||
### LOG INSERTION Admin Log Table ###
|
||||
$SQL_log = "$stmt|";
|
||||
$SQL_log = preg_replace('/;/', '', $SQL_log);
|
||||
$SQL_log = addslashes($SQL_log);
|
||||
$stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$user', ip_address='$ip', event_section='CIDGROUPS', event_type='ADD', record_id='$cid_group_id', event_code='ADMIN API ADD CID', event_sql=\"$SQL_log\", event_notes='areacode: $areacode outbound_cid: $outbound_cid active: $active inserted: $insert_count';";
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_to_mysqli($stmt, $link);
|
||||
|
||||
$result = 'SUCCESS';
|
||||
$result_reason = "update_cid_group_entry CID GROUP ENTRY HAS BEEN ADDED";
|
||||
$data = "$cid_group_id|$areacode|$outbound_cid|$insert_count";
|
||||
echo "$result: $result_reason - $user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
##### END add a CID Group entry #####
|
||||
|
||||
##### BEGIN delete CID Group entries #####
|
||||
if ($stage == 'DELETE')
|
||||
{
|
||||
$stmt="SELECT areacode,outbound_cid,active,cid_description,call_count_today from vicidial_campaign_cid_areacodes where campaign_id='$cid_group_id' $areacodeSQL $outbound_cidSQL order by areacode,outbound_cid;";
|
||||
if ($DB>0) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_to_mysqli($stmt, $link);
|
||||
$vcca_recs = mysqli_num_rows($rslt);
|
||||
$M=0;
|
||||
if ($vcca_recs > $M)
|
||||
{
|
||||
$notes_output='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "update_cid_group_entry THIS CID GROUP HAS NO ENTRIES";
|
||||
$data = "$cid_group_id";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
while ($vcca_recs > $M)
|
||||
{
|
||||
$row=mysqli_fetch_row($rslt);
|
||||
$ACareacode = $row[0];
|
||||
$ACoutbound_cid = $row[1];
|
||||
$ACactive = $row[2];
|
||||
$ACcid_description = $row[3];
|
||||
$ACcall_count_today = $row[4];
|
||||
if ($ACactive == '') {$ACactive='N';}
|
||||
$M++;
|
||||
$notes_output.="$M|$ACareacode|$ACoutbound_cid|$ACactive|$ACcid_description|$ACcall_count_today\n";
|
||||
}
|
||||
|
||||
$stmt="DELETE FROM vicidial_campaign_cid_areacodes WHERE campaign_id='$cid_group_id' $areacodeSQL $outbound_cidSQL;";
|
||||
$rslt=mysql_to_mysqli($stmt, $link);
|
||||
$delete_count = mysqli_affected_rows($link);
|
||||
if ($DB) {echo "$insert_count|$stmt|\n";}
|
||||
|
||||
### LOG INSERTION Admin Log Table ###
|
||||
$SQL_log = "$stmt|";
|
||||
$SQL_log = preg_replace('/;/', '', $SQL_log);
|
||||
$SQL_log = addslashes($SQL_log);
|
||||
$stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$user', ip_address='$ip', event_section='CIDGROUPS', event_type='DELETE', record_id='$cid_group_id', event_code='ADMIN API DELETE CID', event_sql=\"$SQL_log\", event_notes='areacode: $areacode outbound_cid: $outbound_cid deleted: $delete_count\n$notes_output';";
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_to_mysqli($stmt, $link);
|
||||
|
||||
$result = 'SUCCESS';
|
||||
$result_reason = "update_cid_group_entry CID GROUP ENTRIES HAVE BEEN DELETED";
|
||||
$data = "$cid_group_id|$areacode|$outbound_cid|$delete_count";
|
||||
echo "$result: $result_reason - $user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
##### END delete CID Group entries #####
|
||||
|
||||
##### BEGIN update CID Group entries #####
|
||||
if ($stage == 'UPDATE')
|
||||
{
|
||||
$stmt="SELECT areacode,outbound_cid,active,cid_description,call_count_today from vicidial_campaign_cid_areacodes where campaign_id='$cid_group_id' $areacodeSQL $outbound_cidSQL order by areacode,outbound_cid;";
|
||||
if ($DB>0) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_to_mysqli($stmt, $link);
|
||||
$vcca_recs = mysqli_num_rows($rslt);
|
||||
$M=0;
|
||||
if ($vcca_recs > $M)
|
||||
{
|
||||
$notes_output='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "update_cid_group_entry THIS CID GROUP HAS NO ENTRIES";
|
||||
$data = "$cid_group_id";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
while ($vcca_recs > $M)
|
||||
{
|
||||
$row=mysqli_fetch_row($rslt);
|
||||
$ACareacode = $row[0];
|
||||
$ACoutbound_cid = $row[1];
|
||||
$ACactive = $row[2];
|
||||
$ACcid_description = $row[3];
|
||||
$ACcall_count_today = $row[4];
|
||||
if ($ACactive == '') {$ACactive='N';}
|
||||
$M++;
|
||||
$notes_output.="$M|$ACareacode|$ACoutbound_cid|$ACactive|$ACcid_description|$ACcall_count_today\n";
|
||||
}
|
||||
|
||||
$updateSQL='';
|
||||
if ( ($active == 'Y') or ($active == 'N') )
|
||||
{
|
||||
$activeSQL=$active;
|
||||
if ($active == 'N') {$activeSQL='';}
|
||||
$updateSQL .= "active='$activeSQL'";
|
||||
}
|
||||
if (strlen($cid_description) > 0)
|
||||
{
|
||||
if (strlen($updateSQL) > 0) {$updateSQL .= ",";}
|
||||
$updateSQL .= "cid_description='$cid_description'";
|
||||
}
|
||||
if (strlen($updateSQL) < 5)
|
||||
{
|
||||
$result = 'ERROR';
|
||||
$result_reason = "update_cid_group_entry NO UPDATES WERE DEFINED";
|
||||
$data = "$cid_group_id|$areacode|$outbound_cid|$active|$cid_description";
|
||||
echo "$result: $result_reason: |$user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt="UPDATE vicidial_campaign_cid_areacodes SET $updateSQL WHERE campaign_id='$cid_group_id' $areacodeSQL $outbound_cidSQL;";
|
||||
$rslt=mysql_to_mysqli($stmt, $link);
|
||||
$modify_count = mysqli_affected_rows($link);
|
||||
if ($DB) {echo "$modify_count|$stmt|\n";}
|
||||
|
||||
### LOG INSERTION Admin Log Table ###
|
||||
$SQL_log = "$stmt|";
|
||||
$SQL_log = preg_replace('/;/', '', $SQL_log);
|
||||
$SQL_log = addslashes($SQL_log);
|
||||
$stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$user', ip_address='$ip', event_section='CIDGROUPS', event_type='MODIFY', record_id='$cid_group_id', event_code='ADMIN API MODIFY CID', event_sql=\"$SQL_log\", event_notes='areacode: $areacode outbound_cid: $outbound_cid modified: $modify_count\n$notes_output';";
|
||||
if ($DB) {echo "|$stmt|\n";}
|
||||
$rslt=mysql_to_mysqli($stmt, $link);
|
||||
|
||||
$result = 'SUCCESS';
|
||||
$result_reason = "update_cid_group_entry CID GROUP ENTRIES HAVE BEEN UPDATED";
|
||||
$data = "$cid_group_id|$areacode|$outbound_cid|$modify_count";
|
||||
echo "$result: $result_reason - $user|$data\n";
|
||||
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||
}
|
||||
##### END update CID Group entries #####
|
||||
}
|
||||
}
|
||||
}
|
||||
exit;
|
||||
}
|
||||
################################################################################
|
||||
### END update_cid_group_entry
|
||||
################################################################################
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
################################################################################
|
||||
### recording_lookup - looks up recordings based upon user and date or lead_id
|
||||
################################################################################
|
||||
|
||||
Reference in New Issue
Block a user