Added link to new callbacks bulk move admin utility, also now we will archive deleted callbacks

git-svn-id: svn://192.168.202.10@2279 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2015-02-18 14:30:46 +00:00
parent 137bccf379
commit c48f08cde1
10 changed files with 975 additions and 17 deletions
+4
View File
@@ -134,6 +134,10 @@ OTHER CHANGES:
27. Added option in phones and voicemail to display message counts on the
Admin Summary screen.
28. Added Callbacks Bulk Move admin utility. Also changed behavior of the
removal links for callbacks from the callback hold displays for Users,
User Groups, Lists and Campaigns.
+11 -4
View File
@@ -1,6 +1,6 @@
#!/usr/bin/perl
#
# AST_DB_dead_cb_purge.pl version 2.8
# AST_DB_dead_cb_purge.pl version 2.10
#
# DESCRIPTION:
# OPTIONAL!!!
@@ -9,13 +9,14 @@
#
# It is recommended that you run this program on the local Asterisk machine
#
# Copyright (C) 2014 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2015 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES
# 101128-0149 - first build
# 110212-2343 - added scheduled callback custom statuses capacity
# 130414-2145 - added option to remove duplicate callback entries, keeping the newest
# 140512-2036 - Fixed typos, issue #760
# 150217-1403 - archive deleted callbacks to vicidial_callbacks_archive table
#
### begin parsing run-time options ###
@@ -210,9 +211,12 @@ while ($sthArowsCT > $rec_count)
if ($delete_lead > 0)
{
$stmtA = "INSERT INTO vicidial_callbacks_archive SELECT * from vicidial_callbacks where callback_id='$callback_ids[$rec_count]';";
if (!$T) {$affected_rowsA = $dbhA->do($stmtA);}
$stmtA = "DELETE from vicidial_callbacks where callback_id='$callback_ids[$rec_count]';";
if (!$T) {$affected_rows = $dbhA->do($stmtA);}
if($DB){print STDERR "\n|$stmtA| |$affected_rows deleted| |$lead_ids[$rec_count]|$lead_statuses[$rec_count]|$callback_statuses[$rec_count]|$callback_ids[$rec_count]|\n";}
if($DB){print STDERR "\n|$stmtA| |$affected_rows deleted| |$affected_rowsA|$lead_ids[$rec_count]|$lead_statuses[$rec_count]|$callback_statuses[$rec_count]|$callback_ids[$rec_count]|\n";}
$deleted++;
}
$rec_count++;
@@ -273,9 +277,12 @@ if ($remove_dup_cb > 0)
if ($delete_lead > 0)
{
$stmtA = "INSERT INTO vicidial_callbacks_archive SELECT * from vicidial_callbacks where callback_id='$callback_ids[$rec_count]';";
if (!$T) {$affected_rowsA = $dbhA->do($stmtA);}
$stmtA = "DELETE from vicidial_callbacks where callback_id='$callback_ids[$rec_count]';";
if (!$T) {$affected_rows = $dbhA->do($stmtA);}
if($DB){print STDERR "\n|$stmtA| |$affected_rows deleted| |$lead_ids[$rec_count]|$lead_statuses[$rec_count]|$callback_statuses[$rec_count]|$callback_ids[$rec_count]|\n";}
if($DB){print STDERR "\n|$stmtA| |$affected_rows deleted| |$affected_rowsA|$lead_ids[$rec_count]|$lead_statuses[$rec_count]|$callback_statuses[$rec_count]|$callback_ids[$rec_count]|\n";}
$dup_deleted++;
}
}
+12
View File
@@ -257,6 +257,18 @@ if (!$T)
$sthA->finish();
}
$stmtA = "optimize table vicidial_callbacks_archive;";
if($DB){print STDERR "\n|$stmtA|\n";}
if (!$T)
{
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@aryA = $sthA->fetchrow_array;
if (!$q) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";}
$sthA->finish();
}
$stmtA = "optimize table vicidial_agent_log;";
if($DB){print STDERR "\n|$stmtA|\n";}
if (!$T)
@@ -3293,6 +3293,9 @@ CREATE UNIQUE INDEX vddla on vicidial_dial_log_archive (caller_code,call_date);
CREATE TABLE vicidial_api_log_archive LIKE vicidial_api_log;
ALTER TABLE vicidial_api_log_archive MODIFY api_id INT(9) UNSIGNED NOT NULL;
CREATE TABLE vicidial_callbacks_archive LIKE vicidial_callbacks;
ALTER TABLE vicidial_callbacks_archive MODIFY callback_id INT(9) UNSIGNED NOT NULL;
GRANT RELOAD ON *.* TO cron@'%';
GRANT RELOAD ON *.* TO cron@localhost;
@@ -3367,4 +3370,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='1402',db_schema_update_date=NOW(),reload_timestamp=NOW();
UPDATE system_settings SET db_schema_version='1403',db_schema_update_date=NOW(),reload_timestamp=NOW();
+5
View File
@@ -180,3 +180,8 @@ ALTER TABLE vicidial_voicemail ADD on_login_report enum('Y','N') NOT NULL defaul
ALTER TABLE phones ADD on_login_report enum('Y','N') NOT NULL default 'N';
UPDATE system_settings SET db_schema_version='1402',db_schema_update_date=NOW() where db_schema_version < 1402;
CREATE TABLE vicidial_callbacks_archive LIKE vicidial_callbacks;
ALTER TABLE vicidial_callbacks_archive MODIFY callback_id INT(9) UNSIGNED NOT NULL;
UPDATE system_settings SET db_schema_version='1403',db_schema_update_date=NOW() where db_schema_version < 1403;
+11 -7
View File
@@ -3436,12 +3436,13 @@ else
# 150120-0749 - Prevent modification of user_group ID, Hide non-functional agent_extended_alt_dial campaign feature, Export Calls Report Carrier added
# 150210-0657 - Added LOCK options for manual_dial_search_checkbox campaign setting
# 150217-0702 - Added Show VM on Summary Screen option for phones and voicemail boxes
# 150218-0924 - Added link to callbacks bulk move, also now we will archive deleted callbacks
#
# make sure you have added a user to the vicidial_users MySQL table with at least user_level 9 to access this page the first time
$admin_version = '2.10-474a';
$build = '150217-0702';
$admin_version = '2.10-475a';
$build = '150218-0924';
$STARTtime = date("U");
$SQLdate = date("Y-m-d H:i:s");
@@ -15898,6 +15899,9 @@ if ($ADD==61)
$stmt="DELETE from vicidial_campaign_hotkeys where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
$rslt=mysql_to_mysqli($stmt, $link);
$stmt="INSERT INTO vicidial_callbacks_archive SELECT * from vicidial_callbacks where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
$rslt=mysql_to_mysqli($stmt, $link);
$stmt="DELETE from vicidial_callbacks where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
$rslt=mysql_to_mysqli($stmt, $link);
@@ -30766,7 +30770,7 @@ if ($ADD==8)
echo "<br>"._QXZ("User")."($user) "._QXZ("callback listings LIVE for more than one week have been made INACTIVE")."\n";
}
}
$CBinactiveLINK = "<BR><a href=\"$PHP_SELF?ADD=8&SUB=89&user=$user\">"._QXZ("Remove LIVE Callbacks older than one month for this user")."</a><BR><a href=\"$PHP_SELF?ADD=8&SUB=899&user=$user\">"._QXZ("Remove LIVE Callbacks older than one week for this user")."</a><BR>";
$CBinactiveLINK = "<BR><a href=\"./callbacks_bulk_move.php?days_uncalled=31&user=$user\">"._QXZ("Remove LIVE Callbacks older than one month for this user")."</a><BR><a href=\"./callbacks_bulk_move.php?days_uncalled=7&user=$user\">"._QXZ("Remove LIVE Callbacks older than one week for this user")."</a><BR>";
echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
@@ -30797,7 +30801,7 @@ if ($ADD==81)
echo "<br>"._QXZ("campaign")."($campaign_id) "._QXZ("callback listings LIVE for more than one week have been made INACTIVE")."\n";
}
}
$CBinactiveLINK = "<BR><a href=\"$PHP_SELF?ADD=81&SUB=89&campaign_id=$campaign_id\">"._QXZ("Remove LIVE Callbacks older than one month for this campaign")."</a><BR><a href=\"$PHP_SELF?ADD=81&SUB=899&campaign_id=$campaign_id\">"._QXZ("Remove LIVE Callbacks older than one week for this campaign")."</a><BR>";
$CBinactiveLINK = "<BR><a href=\"./callbacks_bulk_move.php?days_uncalled=31&campaign_id=$campaign_id\">"._QXZ("Remove LIVE Callbacks older than one month for this campaign")."</a><BR><a href=\"./callbacks_bulk_move.php?days_uncalled=7&campaign_id=$campaign_id\">"._QXZ("Remove LIVE Callbacks older than one week for this campaign")."</a><BR>";
echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
@@ -30828,7 +30832,7 @@ if ($ADD==811)
echo "<br>"._QXZ("list")."($list_id) "._QXZ("callback listings LIVE for more than one week have been made INACTIVE")."\n";
}
}
$CBinactiveLINK = "<BR><a href=\"$PHP_SELF?ADD=811&SUB=89&list_id=$list_id\">"._QXZ("Remove LIVE Callbacks older than one month for this list")."</a><BR><a href=\"$PHP_SELF?ADD=811&SUB=899&list_id=$list_id\">"._QXZ("Remove LIVE Callbacks older than one week for this list")."</a><BR>";
$CBinactiveLINK = "<BR><a href=\"./callbacks_bulk_move.php?days_uncalled=31&list_id=$list_id\">"._QXZ("Remove LIVE Callbacks older than one month for this list")."</a><BR><a href=\"./callbacks_bulk_move.php?days_uncalled=7&list_id=$list_id\">"._QXZ("Remove LIVE Callbacks older than one week for this list")."</a><BR>";
echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
@@ -30859,7 +30863,7 @@ if ($ADD==8111)
echo "<br>"._QXZ("user group")."($user_group) "._QXZ("callback listings LIVE for more than one week have been made INACTIVE")."\n";
}
}
$CBinactiveLINK = "<BR><a href=\"$PHP_SELF?ADD=8111&SUB=89&user_group=$user_group\">"._QXZ("Remove LIVE Callbacks older than one month for this user group")."</a><BR><a href=\"$PHP_SELF?ADD=8111&SUB=899&user_group=$user_group\">"._QXZ("Remove LIVE Callbacks older than one week for this user group")."</a><BR>";
$CBinactiveLINK = "<BR><a href=\"./callbacks_bulk_move.php?days_uncalled=31&user_group=$user_group\">"._QXZ("Remove LIVE Callbacks older than one month for this user group")."</a><BR><a href=\"./callbacks_bulk_move.php?days_uncalled=7&user_group=$user_group\">"._QXZ("Remove LIVE Callbacks older than one week for this user group")."</a><BR>";
echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
@@ -33908,7 +33912,7 @@ if ($ADD==999994)
echo "<LI><a href=\"admin_phones_bulk_insert.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Bulk Phone Insert Page")."</a></FONT>\n";
echo "<LI><a href=\"lead_tools.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Basic Lead Management Tools")."</FONT></a> | <a href=\"lead_tools_advanced.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Advanced Lead Management Tools")."</FONT></a> | <a href=\"list_split.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("List Split")."</FONT></a>\n";
echo "<LI><a href=\"reset_campaign_lists.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Reset Campaign Lists")."</a></FONT>\n";
echo "<LI><a href=\"callbacks_bulk_change.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Callbacks Transferral Page")."</a></FONT>\n";
echo "<LI><a href=\"callbacks_bulk_change.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Callbacks Transferral Page")."</a></FONT> | <a href=\"callbacks_bulk_move.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Callbacks Bulk Move")."</FONT></a>\n";
echo "<LI><a href=\"send_CID_call.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Send a Call With Custom CID Page")."</a></FONT>\n";
echo "<LI><a href=\"voice_lab.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Speech Voice Lab Page")."</a></FONT>\n";
echo "<LI><a href=\"../agc/phone_only.php\"><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>"._QXZ("Webphone Only Page")."</a></FONT>\n";
@@ -0,0 +1,877 @@
<?php
# callbacks_bulk_move.php
#
# Copyright (C) 2015 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES
# 150218-0923 - First build based on callbacks_bulk_change.php
#
require("dbconnect_mysqli.php");
require("functions.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_GET["days"])) {$days=$_GET["days"];}
elseif (isset($_POST["days"])) {$days=$_POST["days"];}
if (isset($_GET["user"])) {$user=$_GET["user"];}
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];}
elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];}
if (isset($_GET["campaign_id"])) {$campaign_id=$_GET["campaign_id"];}
elseif (isset($_POST["campaign_id"])) {$campaign_id=$_POST["campaign_id"];}
if (isset($_GET["user_group"])) {$user_group=$_GET["user_group"];}
elseif (isset($_POST["user_group"])) {$user_group=$_POST["user_group"];}
if (isset($_GET["stage"])) {$stage=$_GET["stage"];}
elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];}
if (isset($_GET["confirm_transfer"])) {$confirm_transfer=$_GET["confirm_transfer"];}
elseif (isset($_POST["confirm_transfer"])) {$confirm_transfer=$_POST["confirm_transfer"];}
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
if (isset($_GET["new_list_id"])) {$new_list_id=$_GET["new_list_id"];}
elseif (isset($_POST["new_list_id"])) {$new_list_id=$_POST["new_list_id"];}
if (isset($_GET["new_status"])) {$new_status=$_GET["new_status"];}
elseif (isset($_POST["new_status"])) {$new_status=$_POST["new_status"];}
if (isset($_GET["cb_groups"])) {$cb_groups=$_GET["cb_groups"];}
elseif (isset($_POST["cb_groups"])) {$cb_groups=$_POST["cb_groups"];}
if (isset($_GET["cb_user_groups"])) {$cb_user_groups=$_GET["cb_user_groups"];}
elseif (isset($_POST["cb_user_groups"])) {$cb_user_groups=$_POST["cb_user_groups"];}
if (isset($_GET["cb_lists"])) {$cb_lists=$_GET["cb_lists"];}
elseif (isset($_POST["cb_lists"])) {$cb_lists=$_POST["cb_lists"];}
if (isset($_GET["cb_users"])) {$cb_users=$_GET["cb_users"];}
elseif (isset($_POST["cb_users"])) {$cb_users=$_POST["cb_users"];}
if (isset($_GET["days_uncalled"])) {$days_uncalled=$_GET["days_uncalled"];}
elseif (isset($_POST["days_uncalled"])) {$days_uncalled=$_POST["days_uncalled"];}
if (isset($_GET["purge_called_records"])) {$purge_called_records=$_GET["purge_called_records"];}
elseif (isset($_POST["purge_called_records"])) {$purge_called_records=$_POST["purge_called_records"];}
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
$stmt = "SELECT use_non_latin,webroot_writable,outbound_autodial_active,enable_languages,language_method FROM system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$qm_conf_ct = mysqli_num_rows($rslt);
if ($qm_conf_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$non_latin = $row[0];
$webroot_writable = $row[1];
$SSoutbound_autodial_active = $row[2];
$SSenable_languages = $row[3];
$SSlanguage_method = $row[4];
}
##### END SETTINGS LOOKUP #####
###########################################
if ($non_latin < 1)
{
$PHP_AUTH_USER = preg_replace('/[^-_0-9a-zA-Z]/', '', $PHP_AUTH_USER);
$PHP_AUTH_PW = preg_replace('/[^-_0-9a-zA-Z]/', '', $PHP_AUTH_PW);
}
else
{
$PHP_AUTH_PW = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_PW);
$PHP_AUTH_USER = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_USER);
}
$StarTtimE = date("U");
$TODAY = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s");
$ip = getenv("REMOTE_ADDR");
$date = date("r");
$ip = getenv("REMOTE_ADDR");
$browser = getenv("HTTP_USER_AGENT");
$stmt="SELECT selected_language from vicidial_users where user='$PHP_AUTH_USER';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$sl_ct = mysqli_num_rows($rslt);
if ($sl_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$VUselected_language = $row[0];
}
$category='';
$record_id='';
if (strlen($days) < 1) {$days='2';}
if (strlen($user) < 1) {$category='USERS'; $record_id=$user;}
if (strlen($user_group) < 1) {$category='USERGROUPS'; $record_id=$user_group;}
if (strlen($list_id) < 1) {$category='LISTS'; $record_id=$list_id;}
if (strlen($campaign_id) < 1) {$category='CAMPAIGNS'; $record_id=$campaign_id;}
$auth=0;
$auth_message = user_authorization($PHP_AUTH_USER,$PHP_AUTH_PW,'',1);
if ($auth_message == 'GOOD')
{$auth=1;}
if ($auth < 1)
{
$VDdisplayMESSAGE = _QXZ("Login incorrect, please try again");
if ($auth_message == 'LOCK')
{
$VDdisplayMESSAGE = _QXZ("Too many login attempts, try again in 15 minutes");
Header ("Content-type: text/html; charset=utf-8");
echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n";
exit;
}
Header("WWW-Authenticate: Basic realm=\"CONTACT-CENTER-ADMIN\"");
Header("HTTP/1.0 401 Unauthorized");
echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$PHP_AUTH_PW|$auth_message|\n";
exit;
}
$stmt="SELECT full_name,change_agent_campaign,modify_timeclock_log,user_group,user_level,modify_leads from vicidial_users where user='$PHP_AUTH_USER';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$LOGfullname = $row[0];
$change_agent_campaign = $row[1];
$modify_timeclock_log = $row[2];
$LOGuser_group = $row[3];
$user_level = $row[4];
$LOGmodify_leads = $row[5];
if ($user_level==9)
{
$ul_clause="where user_level<=9";
}
else
{
$ul_clause="where user_level<$user_level";
}
if ($LOGmodify_leads < 1)
{
Header ("Content-type: text/html; charset=utf-8");
echo _QXZ("You do not have permissions to modify leads").": |$PHP_AUTH_USER|\n";
exit;
}
$stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$LOGallowed_campaigns = $row[0];
$LOGallowed_reports = $row[1];
$LOGadmin_viewable_groups = $row[2];
$LOGadmin_viewable_call_times = $row[3];
$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')";
}
$regexLOGallowed_campaigns = " $LOGallowed_campaigns ";
$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')";
}
$LOGadmin_viewable_call_timesSQL='';
$whereLOGadmin_viewable_call_timesSQL='';
if ( (!preg_match('/\-\-ALL\-\-/i', $LOGadmin_viewable_call_times)) and (strlen($LOGadmin_viewable_call_times) > 3) )
{
$rawLOGadmin_viewable_call_timesSQL = preg_replace("/ -/",'',$LOGadmin_viewable_call_times);
$rawLOGadmin_viewable_call_timesSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_call_timesSQL);
$LOGadmin_viewable_call_timesSQL = "and call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')";
$whereLOGadmin_viewable_call_timesSQL = "where call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')";
}
$i=0;
$group_string='|';
$group_ct = count($group);
while($i < $group_ct)
{
$group_string .= "$group[$i]|";
$i++;
}
$i=0;
$users_string='|';
$users_ct = count($users);
while($i < $users_ct)
{
$users_string .= "$users[$i]|";
$i++;
}
$i=0;
$user_group_string='|';
$user_group_ct = count($user_group);
while($i < $users_ct)
{
$user_group_string .= "$user_group[$i]|";
$i++;
}
$stmt="SELECT campaign_id from vicidial_campaigns $whereLOGallowed_campaignsSQL order by campaign_id;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$campaigns_to_print = mysqli_num_rows($rslt);
$i=0;
while ($i < $campaigns_to_print)
{
$row=mysqli_fetch_row($rslt);
$groups[$i] =$row[0];
#if (preg_match('/\-ALL/',$group_string) )
# {$group[$i] = $groups[$i];}
$i++;
}
$stmt="SELECT user_group from vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$user_groups_to_print = mysqli_num_rows($rslt);
$i=0;
while ($i < $user_groups_to_print)
{
$row=mysqli_fetch_row($rslt);
$user_groups[$i] =$row[0];
# if (preg_match('/\-ALL/',$user_group_string)) {$user_group[$i]=$row[0];}
$i++;
}
$stmt="SELECT user, full_name from vicidial_users $whereLOGadmin_viewable_groupsSQL order by user";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$users_to_print = mysqli_num_rows($rslt);
$i=0;
while ($i < $users_to_print)
{
$row=mysqli_fetch_row($rslt);
$user_list[$i]=$row[0];
$user_names[$i]=$row[1];
if ($all_users) {$user_list[$i]=$row[0];}
$i++;
}
$i=0;
$user_string='|';
$user_ct = count($users);
while($i < $user_ct)
{
$user_string .= "$users[$i]|";
# $user_SQL .= "'$users[$i]',";
$user_SQL .= " selected_agents like '%|".$users[$i]."|%' or ";
$userQS .= "&users[]=$users[$i]";
$i++;
}
if ( (preg_match('/\-\-ALL\-\-/',$user_string) ) or ($user_ct < 1) )
{$user_SQL = "";}
else
{
# $user_string=preg_replace("/^\||\|$/", "", $user_string);
$user_SQL = preg_replace('/ or $/i', '',$user_SQL);
# $user_agent_log_SQL = "and vicidial_agent_log.user IN($user_SQL)";
}
$i=0;
$user_group_string='|';
$user_group_ct = count($user_group);
while($i < $user_group_ct)
{
$user_group_string .= "$user_group[$i]|";
# $user_group_SQL .= "'$user_group[$i]',";
$user_group_SQL .= " selected_user_groups like '%|".$user_group[$i]."|%' or ";
$user_groupQS .= "&user_group[]=$user_group[$i]";
$i++;
}
if ( (preg_match('/\-\-ALL\-\-/',$user_group_string) ) or ($user_group_ct < 1) )
{$user_group_SQL = "";}
else
{
# $user_group_string=preg_replace("/^\||\|$/", "", $user_group_string);
$user_group_SQL = preg_replace('/ or $/i', '',$user_group_SQL);
# $user_group_agent_log_SQL = "and vicidial_agent_log.user_group IN($user_group_SQL)";
$user_group_SQL = "and ($user_group_SQL or selected_user_groups='|')";
}
$i=0;
$group_string='|';
$group_ct = count($group);
while($i < $group_ct)
{
if ( (preg_match("/ $group[$i] /",$regexLOGallowed_campaigns)) or (preg_match("/-ALL/",$LOGallowed_campaigns)) )
{
$group_string .= "$group[$i]|";
# $group_SQL .= "'$group[$i]',";
$group_SQL .= " selected_campaigns like '%|".$group[$i]."|%' or ";
$groupQS .= "&group[]=$group[$i]";
}
$i++;
}
if ( (preg_match('/\-\-ALL\-\-/',$group_string) ) or ($group_ct < 1) )
{$group_SQL = "";}
else
{
# $group_string=preg_replace("/^\||\|$/", "", $group_string);
$group_SQL = preg_replace('/ or $/i', '',$group_SQL);
$group_SQL = "and ($group_SQL or selected_campaigns='|')";
}
$NWB = " &nbsp; <a href=\"javascript:openNewWindow('help.php?ADD=99999";
$NWE = "')\"><IMG SRC=\"help.gif\" WIDTH=20 HEIGHT=20 BORDER=0 ALT=\"HELP\" ALIGN=TOP></A>";
### PRELOAD ###
if ($campaign_id)
{
$preload_campaigns=array();
$preload_lists=array();
$preload_user_groups=array();
$preload_users=array();
# Trying a three-level UNION statement to see if that's faster
$stmt="SELECT distinct campaign_id, 'CAMPAIGN' as dtype FROM vicidial_callbacks where campaign_id='$campaign_id' UNION SELECT distinct user_group, 'USER_GROUP' as dtype FROM vicidial_callbacks where campaign_id='$campaign_id' UNION SELECT distinct list_id, 'LIST_ID' as dtype from vicidial_callbacks where campaign_id='$campaign_id' UNION SELECT distinct user, 'USER' as dtype from vicidial_callbacks where campaign_id='$campaign_id' order by dtype asc;";
$rslt=mysql_to_mysqli($stmt, $link);
while ($row=mysqli_fetch_row($rslt))
{
switch ($row[1])
{
case "CAMPAIGN":
array_push($preload_campaigns, "$row[0]");
break;
case "USER_GROUP":
array_push($preload_user_groups, "$row[0]");
break;
case "USER":
array_push($preload_users, "$row[0]");
break;
case "LIST_ID":
array_push($preload_lists, "$row[0]");
break;
}
}
}
if ($list_id)
{
$preload_campaigns=array();
$preload_lists=array();
$preload_user_groups=array();
$preload_users=array();
# Trying a three-level UNION statement to see if that's faster
$stmt="SELECT distinct campaign_id, 'CAMPAIGN' as dtype FROM vicidial_callbacks where list_id='$list_id' UNION SELECT distinct user_group, 'USER_GROUP' as dtype FROM vicidial_callbacks where list_id='$list_id' UNION SELECT distinct list_id, 'LIST_ID' as dtype from vicidial_callbacks where list_id='$list_id' UNION SELECT distinct user, 'USER' as dtype from vicidial_callbacks where list_id='$list_id' order by dtype asc;";
$rslt=mysql_to_mysqli($stmt, $link);
while ($row=mysqli_fetch_row($rslt))
{
switch ($row[1])
{
case "CAMPAIGN":
array_push($preload_campaigns, "$row[0]");
break;
case "USER_GROUP":
array_push($preload_user_groups, "$row[0]");
break;
case "USER":
array_push($preload_users, "$row[0]");
break;
case "LIST_ID":
array_push($preload_lists, "$row[0]");
break;
}
}
}
if ($user)
{
$preload_campaigns=array();
$preload_lists=array();
$preload_user_groups=array();
$preload_users=array();
# Trying a three-level UNION statement to see if that's faster
$stmt="SELECT distinct campaign_id, 'CAMPAIGN' as dtype FROM vicidial_callbacks where user='$user' UNION SELECT distinct user_group, 'USER_GROUP' as dtype FROM vicidial_callbacks where user='$user' UNION SELECT distinct list_id, 'LIST_ID' as dtype from vicidial_callbacks where user='$user' UNION SELECT distinct user, 'USER' as dtype from vicidial_callbacks where user='$user' order by dtype asc;";
$rslt=mysql_to_mysqli($stmt, $link);
while ($row=mysqli_fetch_row($rslt))
{
switch ($row[1])
{
case "CAMPAIGN":
array_push($preload_campaigns, "$row[0]");
break;
case "USER_GROUP":
array_push($preload_user_groups, "$row[0]");
break;
case "USER":
array_push($preload_users, "$row[0]");
break;
case "LIST_ID":
array_push($preload_lists, "$row[0]");
break;
}
}
}
if ($user_group)
{
$preload_campaigns=array();
$preload_lists=array();
$preload_user_groups=array();
$preload_users=array();
# Trying a three-level UNION statement to see if that's faster
$stmt="SELECT distinct campaign_id, 'CAMPAIGN' as dtype FROM vicidial_callbacks where user_group='$user_group' UNION SELECT distinct user_group, 'USER_GROUP' as dtype FROM vicidial_callbacks where user_group='$user_group' UNION SELECT distinct list_id, 'LIST_ID' as dtype from vicidial_callbacks where user_group='$user_group' UNION SELECT distinct user, 'USER' as dtype from vicidial_callbacks where user_group='$user_group' order by dtype asc;";
$rslt=mysql_to_mysqli($stmt, $link);
while ($row=mysqli_fetch_row($rslt))
{
switch ($row[1])
{
case "CAMPAIGN":
array_push($preload_campaigns, "$row[0]");
break;
case "USER_GROUP":
array_push($preload_user_groups, "$row[0]");
break;
case "USER":
array_push($preload_users, "$row[0]");
break;
case "LIST_ID":
array_push($preload_lists, "$row[0]");
break;
}
}
}
###############
?>
<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<title><?php echo _QXZ("ADMINISTRATION: Callbacks Bulk Move"); ?>
<?php
##### BEGIN Set variables to make header show properly #####
$ADD = '311111';
$hh = 'usergroups';
$LOGast_admin_access = '1';
$ADMIN = 'admin.php';
$page_width='770';
$section_width='750';
$header_font_size='3';
$subheader_font_size='2';
$subcamp_font_size='2';
$header_selected_bold='<b>';
$header_nonselected_bold='';
$usergroups_color = '#FFFF99';
$usergroups_font = 'BLACK';
$usergroups_color = '#E6E6E6';
$subcamp_color = '#C6C6C6';
##### END Set variables to make header show properly #####
require("admin_header.php");
?>
<CENTER>
<TABLE WIDTH=680 BGCOLOR=#D9E6FE cellpadding=2 cellspacing=0><TR BGCOLOR=#015B91><TD ALIGN=LEFT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B> &nbsp; <?php echo _QXZ("Callbacks Bulk Move"); ?><?php echo "$NWB#cb-bulk$NWE"; ?></TD><TD ALIGN=RIGHT><FONT FACE="ARIAL,HELVETICA" COLOR=WHITE SIZE=2><B> &nbsp; </TD></TR>
<?php
echo "<TR BGCOLOR=\"#F0F5FE\"><TD ALIGN=center COLSPAN=2><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=3><B> &nbsp; \n";
### callbacks change form
echo "<form action=$PHP_SELF method=POST>\n";
echo "<input type=hidden name=DB value=\"$DB\">\n";
if ($SUBMIT && $new_list_id && $new_status)
{
if (count($cb_users)>0)
{
$usersSQL=" and vc.user in ('".implode("','", $cb_users)."') ";
$usersQS="";
for ($i=0; $i<count($cb_users); $i++)
{
$usersQS.="&cb_users[]=".$cb_users[$i];
if ($cb_users[$i]=="ALL")
{
$cb_users=array("ALL");
$usersSQL="";
$usersQS="";
break;
}
}
}
if (count($cb_user_groups)>0)
{
$user_groupsSQL=" and vc.user_group in ('".implode("','", $cb_user_groups)."') ";
$user_groupsQS="";
for ($i=0; $i<count($cb_user_groups); $i++)
{
$user_groupsQS.="&cb_user_groups[]=".$cb_user_groups[$i];
if ($cb_user_groups[$i]=="ALL")
{
$cb_user_groups=array("ALL");
$user_groupsSQL="";
$user_groupsQS="";
break;
}
}
}
if (count($cb_lists)>0)
{
$listsSQL=" and vc.list_id in ('".implode("','", $cb_lists)."') ";
$listsQS="";
for ($i=0; $i<count($cb_lists); $i++)
{
$listsQS.="&cb_lists[]=".$cb_lists[$i];
if ($cb_lists[$i]=="ALL")
{
$cb_lists=array("ALL");
$listsSQL="";
$listsQS="";
break;
}
}
}
if (count($cb_groups)>0)
{
$groupsSQL=" and vc.campaign_id in ('".implode("','", $cb_groups)."') ";
$groupsQS="";
for ($i=0; $i<count($cb_groups); $i++)
{
$groupsQS.="&cb_groups[]=".$cb_groups[$i];
if ($cb_groups[$i]=="ALL")
{
$cb_groups=array("ALL");
$groupsSQL="";
$groupsQS="";
break;
}
}
}
if ($days_uncalled>0 && $days_uncalled<=30)
{
$daySQL=" and vc.callback_time<='".date("Y-m-d H:i:s")."'-INTERVAL $days_uncalled DAY ";
}
else
{}
$callback_dispo_stmt="SELECT distinct status from vicidial_statuses where scheduled_callback='Y' UNION SELECT distinct status from vicidial_campaign_statuses where scheduled_callback='Y' ".preg_replace("/vc\./", "", $groupsSQL);
if ($DB) {echo $callback_dispo_stmt."<BR>";}
$callback_dispo_rslt=mysql_to_mysqli($callback_dispo_stmt, $link);
$cb_dispos=array("CALLBK","CBHOLD");
while ($cb_dispo_row=mysqli_fetch_row($callback_dispo_rslt))
{
array_push($cb_dispos, "$cb_dispo_row[0]");
}
}
if ($SUBMIT && $new_list_id && $new_status && (count($cb_users)>0 || count($cb_user_groups)>0 || count($cb_lists)>0 || count($cb_groups)>0) && $confirm_transfer)
{
$actual_archived_ct=0;
$actual_purged_ct=0;
$arch_stmts='';
$del_stmts='';
if ($purge_called_records)
{
### DELETE INACTIVE RECORDS
$stmt = "SELECT vc.callback_id, vc.lead_id, vc.status from vicidial_callbacks vc, vicidial_list vl where (vc.status='INACTIVE' or (vc.status='LIVE' and vl.status not in ('".implode("','", $cb_dispos)."'))) and vc.lead_id=vl.lead_id $usersSQL $user_groupsSQL $listsSQL $groupsSQL $daySQL;";
$rslt = mysql_to_mysqli($stmt, $link);
$purge_ct=mysqli_num_rows($rslt);
while($row=mysqli_fetch_row($rslt))
{
$archive_stmt = "INSERT INTO vicidial_callbacks_archive SELECT * from vicidial_callbacks where callback_id='$row[0]';";
$archive_rslt=mysql_to_mysqli($archive_stmt, $link);
$actual_archived_ct+=mysqli_affected_rows($link);
$arch_stmts .= " $archive_stmt";
$delete_stmt="DELETE from vicidial_callbacks where callback_id='$row[0]';";
$delete_rslt=mysql_to_mysqli($delete_stmt, $link);
$actual_purged_ct+=mysqli_affected_rows($link);
$del_stmts .= " $delete_stmt";
}
# $callback_stmt="SELECT vc.callback_id, vc.lead_id, vc.status from vicidial_callbacks vc, vicidial_list vl where vc.status='LIVE' and vl.status in ('".implode("','", $cb_dispos)."') and vc.lead_id=vl.lead_id $usersSQL $user_groupsSQL $listsSQL $groupsSQL $daySQL";
}
# else
# {
$callback_stmt="SELECT vc.callback_id, vc.lead_id, vc.status from vicidial_callbacks vc where status='LIVE' $usersSQL $user_groupsSQL $listsSQL $groupsSQL $daySQL";
# }
$callback_rslt=mysql_to_mysqli($callback_stmt, $link);
$callback_ct=mysqli_num_rows($callback_rslt);
$actual_callback_ct=0;
$new_listSQL="list_id='$new_list_id',";
if ($new_list_id == 'X')
{$new_listSQL='';}
$upd_stmts='';
while ($cb_row=mysqli_fetch_row($callback_rslt))
{
$lead_id=$cb_row[1];
$upd_stmt="update vicidial_list set $new_listSQL status='$new_status' where lead_id='$lead_id';";
$upd_rslt=mysql_to_mysqli($upd_stmt, $link);
$actual_callback_ct+=mysqli_affected_rows($link);
$upd_stmts .= " $upd_stmt";
$archive_stmt = "INSERT INTO vicidial_callbacks_archive SELECT * from vicidial_callbacks where callback_id='$cb_row[0]';";
$archive_rslt=mysql_to_mysqli($archive_stmt, $link);
$actual_archived_ct+=mysqli_affected_rows($link);
$arch_stmts .= " $archive_stmt";
$delete_stmt="DELETE from vicidial_callbacks where callback_id='$cb_row[0]';";
$delete_rslt=mysql_to_mysqli($delete_stmt, $link);
$actual_purged_ct+=mysqli_affected_rows($link);
$del_stmts .= " $delete_stmt";
}
### LOG INSERTION Admin Log Table ###
$SQL_log = "$callback_stmt|$del_stmts|$upd_stmts|$arch_stmts|";
$SQL_log = preg_replace('/;/', '', $SQL_log);
$SQL_log = addslashes($SQL_log);
$stmt="INSERT INTO vicidial_admin_log set event_date=NOW(), user='$PHP_AUTH_USER', ip_address='$ip', event_section='LEADS', event_type='MODIFY', record_id='$lead_id', event_code='ADMIN CALLBACK BULK MOVE', event_sql=\"$SQL_log\", event_notes='callbacks deleted: $actual_purged_ct|leads moved: $actual_callback_ct|moved to: $new_list_id|archived cb: $actual_archived_ct';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
echo "<table width='500' align='center'><tr><td align='left'>";
if ($purge_called_records)
{
echo "<B>"._QXZ("PURGE COMPLETE")."</B>";
echo "<UL><LI>$purge_ct "._QXZ("RECORDS FOUND")."</LI>";
echo "<LI>$actual_purged_ct "._QXZ("RECORDS PURGED")."</LI></UL>";
echo "<BR><BR>";
}
echo "<B>"._QXZ("LEAD UPDATE COMPLETE")."</B>";
echo "<UL><LI>$callback_ct "._QXZ("RECORDS FOUND")."</LI>";
echo "<LI>$actual_callback_ct "._QXZ("RECORDS MIGRATED TO")." $new_list_id</LI></UL><BR><BR>";
echo "<a href='$PHP_SELF?DB=$DB'>"._QXZ("BACK")."</a><BR><BR>";
}
else if ($SUBMIT && $new_list_id && $new_status && (count($cb_users)>0 || count($cb_user_groups)>0 || count($cb_lists)>0 || count($cb_groups)>0) && !$confirm_transfer)
{
if (!$purge_called_records)
{
$callback_stmt="SELECT * from vicidial_callbacks vc where status='LIVE' $usersSQL $user_groupsSQL $listsSQL $groupsSQL $daySQL";
}
else
{
$callback_stmt="SELECT * from vicidial_callbacks vc, vicidial_list vl where vc.status='LIVE' and vl.status in ('".implode("','", $cb_dispos)."') and vc.lead_id=vl.lead_id $usersSQL $user_groupsSQL $listsSQL $groupsSQL $daySQL";
$purge_stmt="SELECT * from vicidial_callbacks vc, vicidial_list vl where (vc.status='INACTIVE' or (vc.status='LIVE' and vl.status not in ('".implode("','", $cb_dispos)."'))) and vc.lead_id=vl.lead_id $usersSQL $user_groupsSQL $listsSQL $groupsSQL $daySQL";
$purge_rslt=mysql_to_mysqli($purge_stmt, $link);
$purge_ct=mysqli_num_rows($purge_rslt);
}
$callback_rslt=mysql_to_mysqli($callback_stmt, $link);
$callback_ct=mysqli_num_rows($callback_rslt);
if ($DB) {echo $callback_stmt."<BR>";}
if ($DB) {echo $purge_stmt."<BR>";}
$list_name_stmt="SELECT list_name from vicidial_lists where list_id='$new_list_id'";
$list_name_rslt=mysql_to_mysqli($list_name_stmt, $link);
$list_name_row=mysqli_fetch_row($list_name_rslt);
$new_list_id_name=$list_name_row[0];
echo "<table width='500' align='center'><tr><td align='left'>";
echo _QXZ("You are about to transfer")." $callback_ct "._QXZ("callbacks")." from <BR><UL>\n";
if (count($cb_groups)>0) {echo "<LI>"._QXZ("campaigns")." ".implode(",", $cb_groups)."</LI>\n";}
if (count($cb_lists)>0) {echo "<LI>"._QXZ("lists")." ".implode(",", $cb_lists)."</LI>\n";}
if (count($cb_user_groups)>0) {echo"<LI>". _QXZ("user groups")." ".implode(",", $cb_user_groups)."</LI>\n";}
if (count($cb_users)>0) {echo "<LI>"._QXZ("users")." ".implode(",", $cb_users)."</LI>\n";}
if ($days_uncalled) {echo "<LI>"._QXZ("where leads have been LIVE and uncalled for ")." $days_uncalled days</LI>\n";}
echo "</UL><BR>";
echo _QXZ("to list ID")." <B>$new_list_id - $new_list_id_name</B> "._QXZ("as status")." <B>$new_status</B><BR><BR>\n";
if ($purge_called_records) {echo "<B><font color='#990000'>**$purge_ct "._QXZ("RECORDS HAVING BEEN CALLED or INACTIVE WILL BE PURGED")."**</font></B><BR><BR>\n";}
echo "</td></tr></table>";
echo "<a href='$PHP_SELF?DB=$DB&new_list_id=$new_list_id&new_status=$new_status&days_uncalled=$days_uncalled&purge_called_records=$purge_called_records&SUBMIT=1&confirm_transfer=YES$usersQS$user_groupsQS$listsQS$groupsQS'>"._QXZ("CLICK TO CONFIRM")."</a><BR><BR>";
echo "<a href='$PHP_SELF?DB=$DB'>"._QXZ("CLICK TO CANCEL")."</a><BR><BR>";
}
else
{
# JOEJ - removed "recipient='USERONLY' and status!='INACTIVE'" from all select statements in this section 2/17/15
echo "<table width='650' align='center' border=0>";
echo "<tr>";
echo "<td align='left' width='270'>";
$stmt="SELECT campaign_id, count(*) as ct from vicidial_callbacks $whereLOGallowed_campaignsSQL group by campaign_id order by campaign_id";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
echo "<B>"._QXZ("Campaigns with callbacks").":</B>$NWB#cb-bulk-campaigns$NWE<BR><select name='cb_groups[]' size=5 multiple>\n";
echo "<option value='ALL'>"._QXZ("CHECK ALL CAMPAIGNS")."</option>\n";
if (mysqli_num_rows($rslt)>0)
{
while ($row=mysqli_fetch_array($rslt))
{
if (in_array($row["campaign_id"], $preload_campaigns)) {$s=" selected";} else {$s="";}
echo "\t<option value='$row[campaign_id]'$s>".($row["campaign_id"] ? $row["campaign_id"] : "(none)")." - ($row[ct] callbacks)</option>\n";
}
}
else
{
echo "\t<option value=''>**"._QXZ("NO CALLBACKS")."**</option>\n";
}
echo "</select>";
echo "</td>";
echo "<td align='left' width='400'>";
$list_stmt="SELECT list_id from vicidial_lists $whereLOGallowed_campaignsSQL";
$list_rslt=mysql_to_mysqli($list_stmt, $link);
$list_id_str="";
while($list_row=mysqli_fetch_row($list_rslt))
{
$list_id_str.="'$list_row[0]',";
}
$list_id_str=substr($list_id_str,0,-1);
$stmt="SELECT v.list_id, vl.list_name, vl.campaign_id, count(*) as ct from vicidial_callbacks v, vicidial_lists vl where v.list_id in ($list_id_str) and v.list_id=vl.list_id group by list_id order by list_id";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
echo "<B>"._QXZ("Lists with callbacks").":</B>$NWB#cb-bulk-lists$NWE<BR><select name='cb_lists[]' size=5 multiple>\n";
echo "<option value='ALL'>"._QXZ("CHECK ALL LISTS")."</option>\n";
if (mysqli_num_rows($rslt)>0)
{
while ($row=mysqli_fetch_array($rslt))
{
if (in_array($row["list_id"], $preload_lists)) {$s=" selected";} else {$s="";}
echo "\t<option value='$row[list_id]'$s>$row[list_id] - $row[list_name] - $row[campaign_id] - ($row[ct] callbacks)</option>\n";
}
}
else
{
echo "\t<option value=''>**"._QXZ("NO LISTS")."**</option>\n";
}
echo "</select>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td align='left' width='270'>";
$stmt="SELECT user_group, count(*) as ct from vicidial_callbacks $whereLOGadmin_viewable_groupsSQL group by user_group order by user_group";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
echo "<B>"._QXZ("User groups with callbacks").":</B>$NWB#cb-bulk-usergroups$NWE<BR><select name='cb_user_groups[]' size=5 multiple>\n";
echo "<option value='ALL'>"._QXZ("CHECK ALL USER GROUPS")."</option>\n";
if (mysqli_num_rows($rslt)>0)
{
while ($row=mysqli_fetch_array($rslt))
{
if (in_array($row["user_group"], $preload_user_groups)) {$s=" selected";} else {$s="";}
echo "\t<option value='$row[user_group]'$s>$row[user_group] - ($row[ct] callbacks)</option>\n";
}
}
else
{
echo "\t<option value=''>**"._QXZ("NO CALLBACKS")."**</option>\n";
}
echo "</select>";
echo "</td>";
echo "<td align='left' width='400'>";
$stmt="SELECT user, count(*) as ct from vicidial_callbacks $whereLOGadmin_viewable_groupsSQL group by user order by user";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
echo "<B>"._QXZ("Agents with callbacks").":</B>$NWB#cb-bulk-agents$NWE<BR><select name='cb_users[]' size=5 multiple>\n";
echo "<option value='ALL'>"._QXZ("CHECK ALL AGENTS")."</option>\n";
if (mysqli_num_rows($rslt)>0)
{
while ($row=mysqli_fetch_array($rslt))
{
$user_stmt="SELECT full_name from vicidial_users $ul_clause and user='$row[user]' $LOGadmin_viewable_groupsSQL";
$user_rslt=mysql_to_mysqli($user_stmt, $link);
if (mysqli_num_rows($user_rslt)>0)
{
$user_row=mysqli_fetch_array($user_rslt);
if (in_array($row["user"], $preload_users)) {$s=" selected";} else {$s="";}
echo "\t<option value='$row[user]'$s>$row[user] - $user_row[full_name] - ($row[ct] callbacks)</option>\n";
}
}
}
else
{
echo "\t<option value=''>**"._QXZ("NO CALLBACKS")."**</option>\n";
}
echo "</select>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td align='left' width='270'>";
echo "<B><input type='checkbox' name='purge_called_records' value='Y' checked>"._QXZ("Purge called records");
echo "$NWB#cb-bulk-purge$NWE</td>";
echo "<td align='left' width='400'>";
echo "<B>"._QXZ("Live and uncalled for over")." <select name='days_uncalled'>";
echo "<option value='0'>--</option>\n";
for ($i=1; $i<=31; $i++)
{
echo "<option value='$i'>$i</option>\n";
}
if (strlen($days_uncalled)>0)
{echo "<option selected value='$days_uncalled'>$days_uncalled</option>\n";}
echo "</select>";
echo " "._QXZ("days, leave blank to ignore")."</B>$NWB#cb-bulk-liveanduncalled$NWE";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "<BR/><BR/><input type='submit' name='SUBMIT' value=' "._QXZ("TRANSFER TO")." '><BR/><BR/>";
$stmt="SELECT list_id, list_name from vicidial_lists $whereLOGadmin_viewable_groupsSQL order by list_id asc";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
echo _QXZ("List ID").": <select name='new_list_id' size=1>\n";
echo "<option value='X'>"._QXZ("DO NOT ALTER LIST ID")."</option>";
while ($row=mysqli_fetch_array($rslt))
{
echo "\t<option value='$row[list_id]'>$row[list_id] - $row[list_name]</option>\n";
}
echo "</select> &nbsp; \n";
echo _QXZ("New Status").": <input type=text name='new_status' size=7 maxlength=6 value='$new_status'>\n";
}
echo "</form>\n";
echo "\n<BR><BR><BR>";
$ENDtime = date("U");
$RUNtime = ($ENDtime - $StarTtimE);
echo "\n\n\n<br><br><br>\n\n";
echo "<font size=0>\n\n\n<br><br><br>\n"._QXZ("script runtime").": $RUNtime "._QXZ("seconds")."</font>";
?>
</TD></TR><TABLE>
</body>
</html>
<?php
exit;
?>
+1 -1
View File
@@ -29,7 +29,7 @@
function user_authorization($user,$pass,$user_option,$user_update)
{
global $link;
require("dbconnect_mysqli.php");
# require("dbconnect_mysqli.php");
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
+35
View File
@@ -39,6 +39,7 @@
# 150204-1246 - Small fixes, issue #826
# 150210-0659 - Added LOCK options for manual_dial_search_checkbox
# 150217-0657 - Added vmail show on login option
# 150218-0800 - Added Callbacks Bulk Move help
#
require("dbconnect_mysqli.php");
@@ -5234,7 +5235,41 @@ if ($SSqc_features_active > 0)
<BR><BR><BR><BR>
<A NAME="cb-bulk">
<B><FONT SIZE=3><?php echo _QXZ("Callbacks Bulk Move"); ?></FONT></B><BR><BR>
<?php echo _QXZ("This page is used to move callbacks meeting a set of selected criteria to a new list and or a new lead status. It can also purge called records from the callbacks table."); ?>
<BR>
<A NAME="cb-bulk-campaigns">
<BR>
<B><?php echo _QXZ("Campaigns with callbacks"); ?> -</B><?php echo _QXZ("The current list of all campaigns having at least one callback - select one or more to move callbacks from these campaigns in bulk to new lists and or assign new statuses. This will combine with other selected criteria to make a final list of callbacks to move."); ?>
<BR>
<A NAME="cb-bulk-lists">
<BR>
<B><?php echo _QXZ("Lists with callbacks"); ?> -</B><?php echo _QXZ("All list IDs having at least one callback - select one or more to move callbacks from these lists in bulk to new lists and or assign new statuses. This will combine with other selected criteria to make a final list of callbacks to move."); ?>
<BR>
<A NAME="cb-bulk-usergroups">
<BR>
<B><?php echo _QXZ("User groups with callbacks"); ?> -</B><?php echo _QXZ("The current list of all user groups having at least one callback - select one or more to move callbacks from these user groups to new lists and or assign new statuses. This will combine with other selected criteria to make a final list of callbacks to move."); ?>
<BR>
<A NAME="cb-bulk-agents">
<BR>
<B><?php echo _QXZ("Agents with callbacks"); ?> -</B><?php echo _QXZ("The current list of all agents having at least one callback - select one or more to move callbacks from these agents to new lists and or assign new statuses. This will combine with other selected criteria to make a final list of callbacks to move."); ?>
<BR>
<A NAME="cb-bulk-purge">
<BR>
<B><?php echo _QXZ("Purge called records"); ?> -</B><?php echo _QXZ("If this box is checked, before the leads meeting the selected criteria are moved, the callbacks table will purge itself of all inactive records in the table. This includes records that have a status of INACTIVE, OR any record still in the callback table that is LIVE but whose status in the vicidial_list table is NOT listed as a callback, i.e. it has been called, lead has called in, lead dispo has been modified. The page will notify you how many leads will be purged before you confirm that you would like to proceed."); ?>
<BR>
<A NAME="cb-bulk-liveanduncalled">
<BR>
<B><?php echo _QXZ("Live and uncalled for over XX days"); ?> -</B><?php echo _QXZ("Selecting a date range from this drop down menu will filter out any callback where the scheduled callback time is past the selected number of days from the current date and time. This will combine with other selected criteria to make a final list of callbacks to move."); ?>
<BR><BR><BR><BR><BR><BR><BR><BR>
</TD></TR></TABLE></BODY></HTML>
+15 -4
View File
@@ -92,10 +92,11 @@
# 140617-2029 - Added vicidial_users wrapup_seconds_override option
# 140812-0939 - Added phone_number and vendor_lead_code to agent_status function output
# 150123-1611 - Fixed issue with list local call times and add_lead
# 150217-1404 - archive deleted callbacks to vicidial_callbacks_archive table
#
$version = '2.10-68';
$build = '150123-1611';
$version = '2.10-69';
$build = '150217-1404';
$api_url_log = 0;
$startMS = microtime();
@@ -6518,13 +6519,18 @@ if ($function == 'update_lead')
{
if ($delete_lead=='Y')
{
$stmt = "INSERT INTO vicidial_callbacks_archive SELECT * from vicidial_callbacks where lead_id='$search_lead_id[$n]';";
if ($DB>0) {echo "DEBUG: update_lead query - $stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$VCBAaffected_rows = mysqli_affected_rows($link);
$stmt = "DELETE from vicidial_callbacks where lead_id='$search_lead_id[$n]';";
if ($DB>0) {echo "DEBUG: update_lead query - $stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$VCBaffected_rows = mysqli_affected_rows($link);
$stmt = "DELETE from vicidial_list where lead_id='$search_lead_id[$n]';";
$result_reason = "update_lead LEAD HAS BEEN DELETED $VCBaffected_rows";
$result_reason = "update_lead LEAD HAS BEEN DELETED $VCBaffected_rows|$VCBAaffected_rows";
}
else
{
@@ -6670,6 +6676,11 @@ if ($function == 'update_lead')
}
if ($callback == 'REMOVE')
{
$stmt = "INSERT INTO vicidial_callbacks_archive SELECT * from vicidial_callbacks where lead_id='$search_lead_id[$n]';";
if ($DB>0) {echo "DEBUG: update_lead query - $stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$VCBAaffected_rows = mysqli_affected_rows($link);
$stmt = "DELETE from vicidial_callbacks where lead_id='$search_lead_id[$n]';";
if ($DB>0) {echo "DEBUG: update_lead query - $stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
@@ -6677,7 +6688,7 @@ if ($function == 'update_lead')
$result = 'NOTICE';
$result_reason = "update_lead SCHEDULED CALLBACK DELETED";
$data = "$user|$search_lead_id[$n]|$VCBaffected_rows";
$data = "$user|$search_lead_id[$n]|$VCBaffected_rows|$VCBAaffected_rows";
echo "$result: $result_reason - $data\n";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
}