Added 'update_presets' function to the Non-Agent API

Added 'tab-CSScustomUSA' format to AST_VDsales_export.pl

git-svn-id: svn://192.168.202.10@3581 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2022-03-07 17:00:11 +00:00
parent 1cc1e47da3
commit 4b616603f9
3 changed files with 417 additions and 10 deletions
+64 -3
View File
@@ -7,7 +7,7 @@
# #
# /usr/share/astguiclient/AST_VDsales_export.pl --campaign=GOODB-GROUP1-GROUP3-GROUP4-SPECIALS-DNC_BEDS --output-format=fixed-as400 --sale-statuses=SALE --debug --filename=BEDSsaleMMDD.txt --date=yesterday --email-list=test@gmail.com --email-sender=test@test.com # /usr/share/astguiclient/AST_VDsales_export.pl --campaign=GOODB-GROUP1-GROUP3-GROUP4-SPECIALS-DNC_BEDS --output-format=fixed-as400 --sale-statuses=SALE --debug --filename=BEDSsaleMMDD.txt --date=yesterday --email-list=test@gmail.com --email-sender=test@test.com
# #
# Copyright (C) 2016 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2 # Copyright (C) 2022 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# #
# CHANGES # CHANGES
# 61219-1118 - First version # 61219-1118 - First version
@@ -34,6 +34,7 @@
# 130811-0902 - Added wget HTTP auth options and added more debug output # 130811-0902 - Added wget HTTP auth options and added more debug output
# 140403-1603 - Added --skip-rec-xtra option to not perform additional recording lookups beyond vicidial_id # 140403-1603 - Added --skip-rec-xtra option to not perform additional recording lookups beyond vicidial_id
# 160722-1140 - Added --nodatedir option # 160722-1140 - Added --nodatedir option
# 220307-0915 - Added 'tab-CSScustomUSA' format
# #
$txt = '.txt'; $txt = '.txt';
@@ -42,6 +43,7 @@ $MT[0] = '';
$Q=0; $Q=0;
$DB=0; $DB=0;
$uniqueidLIST='|'; $uniqueidLIST='|';
$recordings_ct=0;
# Default FTP account variables # Default FTP account variables
$VARREPORT_host = '10.0.0.4'; $VARREPORT_host = '10.0.0.4';
@@ -201,7 +203,7 @@ if (length($ARGV[0])>1)
print " [--debugX] = Super debugging messages\n"; print " [--debugX] = Super debugging messages\n";
print "\n"; print "\n";
print " format options:\n"; print " format options:\n";
print " pipe-standard|csv-standard|tab-standard|pipe-triplep|pipe-vici|html-rec|fixed-as400|tab-QMcustomUSA|tab-SCcustomUSA\n"; print " pipe-standard|csv-standard|tab-standard|pipe-triplep|pipe-vici|html-rec|fixed-as400|tab-QMcustomUSA|tab-SCcustomUSA|tab-CSScustomUSA\n";
print "\n"; print "\n";
@@ -1137,6 +1139,7 @@ sub select_format_loop
$sthB->finish(); $sthB->finish();
} }
} }
$recordings_ct = $rec_countB;
if ( ($ftp_audio_transfer > 0) && (length($ivr_filename) > 3) && (length($ivr_location) > 5) ) if ( ($ftp_audio_transfer > 0) && (length($ivr_filename) > 3) && (length($ivr_location) > 5) )
{ {
@@ -1198,6 +1201,7 @@ sub select_format_loop
} }
} }
$sthB->finish(); $sthB->finish();
$recordings_ct = $rec_countB;
if ($skip_rec_extra < 1) if ($skip_rec_extra < 1)
{ {
@@ -1556,6 +1560,63 @@ sub select_format_loop
} }
if ($output_format =~ /^tab-CSScustomUSA$/)
{
# 03-03-2022 17:16:31 1646345763.4347 TEST_IN3 9998887112 SALE 6666 Admin user 0.67 1 1922348
# Date | Time | Call ID* | Campaign | ANI [customer phone number] | Call Disposition **| CSS Agent ID | CSS Agent Name | Length of call in Mins | Recordings***| Confirmation Number | Lead ID |
# 1- Date: call date in EST
# 2- Time: call time in EST.
# 3- Call id: uniqueid padded
# 4- Campaign ID
# 5- ANI (customer phone number)
# 6- Status of the call(from agent or system)
# 7- Agent id: Who handled the call(user ID in the system)
# 8- Agent Name (user fullname in the system)
# 9- Talk: time in minutes for how long the agent was talking with the customer
# 10- Recordings: If there is a recording, put the first recording start time here ($recordings_ct)
# 11- EMPTY (saved for 'Confirmation Number')
# 12- Lead ID (lead_id from the system)
@call_date_array = split(/ /,$call_date);
@call_date_format = split(/-/,$call_date_array[0]);
$call_date_array[0] = "$call_date_format[1]-$call_date_format[2]-$call_date_format[0]";
while (length($phone_number)>10) {$phone_number =~ s/^.//gi;}
$phone_areacode = substr($phone_number, 0, 3);
if (length($closer) < 1) {$closer = $user;}
if ($closer =~ /VDCL|VDAD/) {$closer='-';}
$application = substr($did_name, 0, 4);
$queue_seconds = int($queue_seconds + .5);
$talk_seconds = ( ($length_in_sec - $queue_seconds) - $agent_alert_delay);
if ($talk_seconds < 0) {$talk_seconds=0; $talk_minutes=0;}
else
{$talk_minutes = ($talk_seconds / 60); $talk_minutes = sprintf("%.2f", $talk_minutes);}
$dispo_time = 0;
$stmtB = "select dispo_sec from vicidial_agent_log where lead_id='$lead_id' and user='$closer' and event_time >= '$shipdate 00:00:00' and event_time <= '$shipdate 23:59:59' order by event_time desc limit 1;";
$sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr;
$sthB->execute or die "executing: $stmtB ", $dbhB->errstr;
$sthBrows=$sthB->rows;
if ($DB) {print "$sthBrows|$stmtB|\n";}
$rec_countB=0;
while ($sthBrows > $rec_countB)
{
@aryB = $sthB->fetchrow_array;
$dispo_time = $aryB[0];
$rec_countB++;
}
$sthB->finish();
$str = "$call_date_array[0]\t$call_date_array[1]\t$uniqueid\t$campaign_id\t$phone_number\t$status\t$user\t$agent_name\t$talk_minutes\t$recordings_ct\t\t$lead_id\t\n";
# if ($DBX > 0) {print "$uniqueid|$talk_seconds|$outbound|$INcalls|$OUTcalls\n";}
if ($outbound =~ /Y/) {$OUTtalk = ($OUTtalk + $talk_seconds); $OUTcalls++;}
else {$INtalk = ($INtalk + $talk_seconds); $INcalls++;}
}
$Ealert .= "$str"; $Ealert .= "$str";
print out "$str"; print out "$str";
@@ -1575,7 +1636,7 @@ sub select_format_loop
if ($rec_count =~ /70$/i) {print STDERR "| $rec_count\r";} if ($rec_count =~ /70$/i) {print STDERR "| $rec_count\r";}
if ($rec_count =~ /80$/i) {print STDERR "+ $rec_count\r";} if ($rec_count =~ /80$/i) {print STDERR "+ $rec_count\r";}
if ($rec_count =~ /90$/i) {print STDERR "0 $rec_count\r";} if ($rec_count =~ /90$/i) {print STDERR "0 $rec_count\r";}
if ($rec_count =~ /00$/i) {print "$rec_count|$TOTAL_SALES|$CALLTIME_KICK| |$phone_number|\n";} if ($rec_count =~ /00$/i) {print "$rec_count($OUTcalls/$INcalls)|$TOTAL_SALES|$CALLTIME_KICK| |$phone_number|\n";}
} }
$rec_count++; $rec_count++;
+54 -3
View File
@@ -1,4 +1,4 @@
NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2022-01-27 NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2022-03-07
This document describes the functions of an API(Application Programming This document describes the functions of an API(Application Programming
Interface) for all functions NOT directly relating to the VICIDIAL Agent screen. Interface) for all functions NOT directly relating to the VICIDIAL Agent screen.
@@ -62,7 +62,8 @@ add_dnc_phone - adds a phone number to one of the DNC lists
add_fpg_phone - adds a phone number to a Filter Phone Group add_fpg_phone - adds a phone number to a Filter Phone Group
campaigns_list - displays information about all campaigns in the system campaigns_list - displays information about all campaigns in the system
hopper_list - displays information about leads in the hopper for a campaign hopper_list - displays information about leads in the hopper for a campaign
update_alt_url - updates alternate dispo call url entries for a campaign update_alt_url - updates/adds/displays alternate dispo call url entries for a campaign
update_presets - updates/adds/displays campaign preset entries
New scripts: New scripts:
@@ -199,6 +200,7 @@ Changes:
211107-1556 - Added optional phone_number search for lead_all_info function 211107-1556 - Added optional phone_number search for lead_all_info function
211118-1946 - Added 'delete_cf_data' setting to the update_lead function 211118-1946 - Added 'delete_cf_data' setting to the update_lead function
220126-2116 - Added dispo_call_url and alt URL options for update_campaign. Added 'update_alt_url' function 220126-2116 - Added dispo_call_url and alt URL options for update_campaign. Added 'update_alt_url' function
220307-0937 - Added 'update_presets' function
API Functions use the 'function' variable API Functions use the 'function' variable
@@ -2287,7 +2289,7 @@ SUCCESS: update_campaign CAMPAIGN HAS BEEN UPDATED - 6666|1101
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
update_alt_url - updates alternate dispo call url entries for a campaign update_alt_url - updates/adds/displays alternate dispo call url entries for a campaign
NOTE: api user for this function must have user_level set to 8 or higher and "modify campaigns" enabled NOTE: api user for this function must have user_level set to 8 or higher and "modify campaigns" enabled
@@ -2354,6 +2356,55 @@ url_id|campaign_id|entry_type|active|url_type|url_rank|url_statuses|url_descript
--------------------------------------------------------------------------------
update_presets - updates/adds/displays campaign preset entries
NOTE: api user for this function must have user_level set to 8 or higher and "modify campaigns" enabled
REQUIRED FIELDS-
campaign_id - 2-8 characters
source - description of what originated the API call (maximum 20 characters)
preset_name - name of the preset in the system
NOTE: If only one preset exists for this campaign, then this field can be left blank
action - 'UPDATE', 'NEW' or 'LIST' (default is 'UPDATE')
NOTE: 'stage'(csv, tab, pipe[default]) and 'header'(YES, NO) options are available for an action of 'LIST'
EDITABLE FIELDS-
preset_hide_number - One of these: 'Y','N', default is 'N'
preset_number - Digits only (must be from 1 to 50 digits in length)
preset_dtmf - Digits and certain characters only ('0123456789PSQ' [P = #-pound, S = *-star, Q = half-second-quiet])
NOTES:
- Please use no special characters like apostrophes, quotes or amphersands
- A value of '--BLANK--' can be used on the preset_dtmf option above to set its value to empty
Example URL strings for API calls:
http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=update_presets&campaign_id=ALTTEST&preset_name=SALES&preset_number=3125551212&preset_hide_number=N&action=NEW
http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=update_presets&campaign_id=ALTTEST&preset_number=3125551213&preset_hide_number=N&preset_dtmf=1234
http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=update_presets&campaign_id=ALTTEST&action=LIST
http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=update_presets&campaign_id=ALTTEST&preset_name=SUPPORT+LINE&preset_number=3125551214&preset_hide_number=Y&preset_dtmf=1&action=NEW
Example responses:
ERROR: update_presets USER DOES NOT HAVE PERMISSION TO UPDATE CAMPAIGNS - 6666
ERROR: update_presets YOU MUST USE ALL REQUIRED FIELDS - 6666|1
ERROR: update_presets NOT AN ALLOWED CAMPAIGN ID - 98762
ERROR: update_presets CAMPAIGN DOES NOT EXIST - 6666|1000
ERROR: update_presets PRESET NAME DOES NOT EXIST - 6666|2|dispo|campaign|TESTCAMP|2
ERROR: update_presets PRESET HIDE NUMBER MUST BE Y OR N, THIS IS AN OPTIONAL FIELD - 6666|U
ERROR: update_presets PRESET DTMF IS NOT VALID, THIS IS AN OPTIONAL FIELD - 6666|
NOTICE: update_campaign NO UPDATES DEFINED - 6666|
SUCCESS: update_presets PRESET HAS BEEN UPDATED - 6666|1|campaign|TESTCAMP
SUCCESS: update_presets PRESET HAS BEEN ADDED - 6666|NEW PRESET: SUPPORT LINE|campaign|TESTCAMP
NOTICE: update_presets LIST, No Records Found - 6666|TESTCAMP|0
A LIST response will not show "SUCCESS", but instead will just print the results in the following format:
preset_name|campaign_id|preset_number|preset_hide_number|preset_dtmf
SALES|ALTTEST|3125551213|N|1234
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
add_did - adds new Inbound DID entries to the system in the vicidial_inbound_dids table add_did - adds new Inbound DID entries to the system in the vicidial_inbound_dids table
+299 -4
View File
@@ -191,10 +191,11 @@
# 220120-0914 - Added download_invalid_files user function for audio store file listings # 220120-0914 - Added download_invalid_files user function for audio store file listings
# 220126-2116 - Added dispo_call_url and alt URL options for update_campaign. Added 'update_alt_url' function # 220126-2116 - Added dispo_call_url and alt URL options for update_campaign. Added 'update_alt_url' function
# 220223-0838 - Added allow_web_debug system setting # 220223-0838 - Added allow_web_debug system setting
# 220307-0937 - Added 'update_presets' function
# #
$version = '2.14-168'; $version = '2.14-169';
$build = '220223-0838'; $build = '220307-0937';
$php_script='non_agent_api.php'; $php_script='non_agent_api.php';
$api_url_log = 0; $api_url_log = 0;
@@ -686,7 +687,16 @@ if (isset($_GET["url_lists"])) {$url_lists=$_GET["url_lists"];}
elseif (isset($_POST["url_lists"])) {$url_lists=$_POST["url_lists"];} elseif (isset($_POST["url_lists"])) {$url_lists=$_POST["url_lists"];}
if (isset($_GET["url_call_length"])) {$url_call_length=$_GET["url_call_length"];} if (isset($_GET["url_call_length"])) {$url_call_length=$_GET["url_call_length"];}
elseif (isset($_POST["url_call_length"])) {$url_call_length=$_POST["url_call_length"];} elseif (isset($_POST["url_call_length"])) {$url_call_length=$_POST["url_call_length"];}
if (isset($_GET["preset_name"])) {$preset_name=$_GET["preset_name"];}
elseif (isset($_POST["preset_name"])) {$preset_name=$_POST["preset_name"];}
if (isset($_GET["preset_number"])) {$preset_number=$_GET["preset_number"];}
elseif (isset($_POST["preset_number"])) {$preset_number=$_POST["preset_number"];}
if (isset($_GET["preset_dtmf"])) {$preset_dtmf=$_GET["preset_dtmf"];}
elseif (isset($_POST["preset_dtmf"])) {$preset_dtmf=$_POST["preset_dtmf"];}
if (isset($_GET["preset_hide_number"])) {$preset_hide_number=$_GET["preset_hide_number"];}
elseif (isset($_POST["preset_hide_number"])) {$preset_hide_number=$_POST["preset_hide_number"];}
if (isset($_GET["action"])) {$action=$_GET["action"];}
elseif (isset($_POST["action"])) {$action=$_POST["action"];}
$DB=preg_replace('/[^0-9]/','',$DB); $DB=preg_replace('/[^0-9]/','',$DB);
@@ -836,6 +846,10 @@ $query_time=preg_replace('/[^:0-9]/','',$query_time);
$gmt_offset_now = preg_replace('/[^-\_\.0-9]/','',$gmt_offset_now); $gmt_offset_now = preg_replace('/[^-\_\.0-9]/','',$gmt_offset_now);
$date=preg_replace('/[^-0-9]/','',$date); $date=preg_replace('/[^-0-9]/','',$date);
$header = preg_replace('/[^0-9a-zA-Z]/','',$header); $header = preg_replace('/[^0-9a-zA-Z]/','',$header);
$preset_hide_number = preg_replace('/[^0-9a-zA-Z]/','',$preset_hide_number);
$preset_number = preg_replace('/[^\*\#\.\_0-9a-zA-Z]/','',$preset_number);
$preset_dtmf = preg_replace('/[^- \,\*\#0-9a-zA-Z]/','',$preset_dtmf);
$action = preg_replace('/[^0-9a-zA-Z]/','',$action);
if ($non_latin < 1) if ($non_latin < 1)
{ {
@@ -987,6 +1001,7 @@ if ($non_latin < 1)
$group_id = preg_replace('/[^_0-9a-zA-Z]/','',$group_id); $group_id = preg_replace('/[^_0-9a-zA-Z]/','',$group_id);
$url_statuses = preg_replace('/[^- 0-9a-zA-Z]/', '',$url_statuses); $url_statuses = preg_replace('/[^- 0-9a-zA-Z]/', '',$url_statuses);
$url_description = preg_replace('/[^ \.\,-\_0-9a-zA-Z]/','',$url_description); $url_description = preg_replace('/[^ \.\,-\_0-9a-zA-Z]/','',$url_description);
$preset_name = preg_replace('/[^- \_0-9a-zA-Z]/','',$preset_name);
} }
else else
{ {
@@ -1138,6 +1153,7 @@ else
$group_id = preg_replace('/[^_0-9\p{L}]/u','',$group_id); $group_id = preg_replace('/[^_0-9\p{L}]/u','',$group_id);
$url_statuses = preg_replace('/[^- 0-9\p{L}]/u', '',$url_statuses); $url_statuses = preg_replace('/[^- 0-9\p{L}]/u', '',$url_statuses);
$url_description = preg_replace('/[^ \.\,-\_0-9\p{L}]/u','',$url_description); $url_description = preg_replace('/[^ \.\,-\_0-9\p{L}]/u','',$url_description);
$preset_name = preg_replace('/[^- \_0-9\p{L}]/u','',$preset_name);
} }
$USarea = substr($phone_number, 0, 3); $USarea = substr($phone_number, 0, 3);
@@ -7910,7 +7926,7 @@ if ($function == 'update_campaign')
################################################################################ ################################################################################
### update_alt_url - updates alternate dispo call url entries for a campaign ### update_alt_url - updates/adds/displays alternate dispo call url entries for a campaign
################################################################################ ################################################################################
if ($function == 'update_alt_url') if ($function == 'update_alt_url')
{ {
@@ -8343,6 +8359,285 @@ if ($function == 'update_alt_url')
################################################################################
### update_presets - updates/adds/displays campaign preset entries
################################################################################
if ($function == 'update_presets')
{
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_presets USER DOES NOT HAVE PERMISSION TO UPDATE CAMPAIGNS";
$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($campaign_id)<2) or (strlen($campaign_id)>8) )
{
$result = 'ERROR';
$result_reason = "update_presets YOU MUST USE ALL REQUIRED FIELDS";
$data = "$campaign_id|$campaign_name|$campaign_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;
}
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')";
}
$stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$camp_exists=$row[0];
if ($camp_exists < 1)
{
$result = 'ERROR';
$result_reason = "update_presets CAMPAIGN DOES NOT EXIST";
$data = "$campaign_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;
}
else
{
if ($action == 'LIST')
{
$output='';
$DLset=0;
if ($stage == 'csv')
{$DL = ','; $DLset++;}
if ($stage == 'tab')
{$DL = "\t"; $DLset++;}
if ($stage == 'pipe')
{$DL = '|'; $DLset++;}
if ($DLset < 1)
{$DL='|';}
if ($header == 'YES')
{$output .= 'preset_name' . $DL . 'campaign_id' . $DL . 'preset_number' . $DL . 'preset_hide_number' . $DL . "preset_dtmf\n";}
$stmt="SELECT preset_name,campaign_id,preset_number,preset_hide_number,preset_dtmf from vicidial_xfer_presets where campaign_id='$campaign_id' order by preset_name limit 1000;";
$rslt=mysql_to_mysqli($stmt, $link);
$vum_recs = mysqli_num_rows($rslt);
if ($DB>0) {echo "$vum_recs|$stmt|\n";}
$M=0;
while ($vum_recs > $M)
{
$row=mysqli_fetch_row($rslt);
$preset_name = $row[0];
$campaign_id = $row[1];
$preset_number = $row[2];
$preset_hide_number = $row[3];
$preset_dtmf = $row[4];
$output .= "$preset_name" . $DL . "$campaign_id" . $DL . "$preset_number" . $DL . "$preset_hide_number" . $DL . "$preset_dtmf\n";
$M++;
}
if ($M < 1)
{echo "NOTICE: update_presets LIST, No Records Found - $user|$campaign_id|0\n";}
else
{echo $output;}
$result = 'SUCCESS';
$result_reason = "update_presets PRESET LIST DISPLAYED";
$data = "$campaign_id|$M";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
exit;
}
if ($action != 'NEW')
{
$stmt="SELECT count(*) from vicidial_xfer_presets where campaign_id='$campaign_id' and preset_name='$preset_name';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$alt_id_exists=$row[0];
if ($alt_id_exists < 1)
{
$stmt="SELECT preset_name from vicidial_xfer_presets where campaign_id='$campaign_id' order by preset_name limit 2;";
$rslt=mysql_to_mysqli($stmt, $link);
$vum_recs = mysqli_num_rows($rslt);
if ($vum_recs < 2)
{
$row=mysqli_fetch_row($rslt);
$preset_name = $row[0];
}
else
{
$result = 'ERROR';
$result_reason = "update_presets PRESET NAME DOES NOT EXIST";
$data = "$preset_name|$campaign_id|$vum_recs";
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;
}
}
}
$preset_numberSQL='';
$preset_dtmfSQL='';
$preset_hide_numberSQL='';
if (strlen($preset_hide_number) > 0)
{
if ( ($preset_hide_number != 'Y') and ($preset_hide_number != 'N') )
{
$result = 'ERROR';
$result_reason = "update_presets PRESET HIDE NUMBER MUST BE Y OR N, THIS IS AN OPTIONAL FIELD";
$data = "$preset_hide_number";
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
{$preset_hide_numberSQL = " ,preset_hide_number='$preset_hide_number'";}
}
if (strlen($preset_number) > 0)
{
if ( (strlen($preset_number) > 50) or (strlen($preset_number) < 1) )
{
$result = 'ERROR';
$result_reason = "update_presets PRESET NUMBER IS NOT VALID, THIS IS AN OPTIONAL FIELD";
$data = "$preset_number";
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
{$preset_numberSQL = " ,preset_number='$preset_number'";}
}
if (strlen($preset_dtmf) > 0)
{
if ($preset_dtmf == '--BLANK--')
{$preset_dtmfSQL = " ,preset_dtmf=''";}
else
{
if (strlen($preset_dtmf) > 50)
{
$result = 'ERROR';
$result_reason = "update_presets PRESET DTMF IS NOT VALID, THIS IS AN OPTIONAL FIELD";
$data = "$preset_dtmf";
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
{$preset_dtmfSQL = " ,preset_dtmf='$preset_dtmf'";}
}
}
$updateSQL = "$preset_numberSQL$preset_dtmfSQL$preset_hide_numberSQL";
if (strlen($updateSQL)< 3)
{
$result = 'NOTICE';
$result_reason = "update_presets NO UPDATES DEFINED";
$data = "$updateSQL";
echo "$result: $result_reason: |$user|$data\n";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
}
else
{
if ($action == 'NEW')
{
$updateSQLx = ltrim($updateSQL, ' ,');
$stmt="INSERT INTO vicidial_xfer_presets SET campaign_id='$campaign_id',preset_name='$preset_name', $updateSQLx;";
$rslt=mysql_to_mysqli($stmt, $link);
$add_count = mysqli_affected_rows($link);
if ($DB) {echo "$add_count|$preset_name|$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='$event_section', event_type='ADD', record_id='$campaign_id', event_code='ADMIN API UPDATE PRESET', event_sql=\"$SQL_log\", event_notes='campaign: $campaign_id|preset_name: $preset_name';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$result = 'SUCCESS';
$result_reason = "update_presets PRESET HAS BEEN ADDED";
$data = "NEW PRESET: $preset_name|$campaign_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);
}
else
{
$updateSQLx = ltrim($updateSQL, ' ,');
$stmt="UPDATE vicidial_xfer_presets SET $updateSQLx WHERE campaign_id='$campaign_id' and preset_name='$preset_name';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "|$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='$event_section', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN API UPDATE PRESET', event_sql=\"$SQL_log\", event_notes='campaign: $campaign_id|preset_name: $preset_name';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$result = 'SUCCESS';
$result_reason = "update_presets PRESET HAS BEEN UPDATED";
$data = "$preset_name|$campaign_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;
}
################################################################################
### END update_presets
################################################################################
################################################################################ ################################################################################
### add_did - adds new Inbound DID entries to the system in the vicidial_inbound_dids table ### add_did - adds new Inbound DID entries to the system in the vicidial_inbound_dids table
################################################################################ ################################################################################