diff --git a/UPGRADE b/UPGRADE index 11a877af..38cb0ed4 100644 --- a/UPGRADE +++ b/UPGRADE @@ -75,6 +75,8 @@ OTHER CHANGES: 7. Added ability to use Wrap-Up messages with calls terminated through Hotkeys +8. Integrated all QC code into standard admin code, removing includes as well + diff --git a/www/vicidial/admin.php b/www/vicidial/admin.php index 60920e5d..0ee87318 100644 --- a/www/vicidial/admin.php +++ b/www/vicidial/admin.php @@ -57,6 +57,7 @@ $usergroups_font = 'BLACK'; $scripts_font = 'BLACK'; $filters_font = 'BLACK'; $admin_font = 'BLACK'; +$qc_font = 'BLACK'; $reports_font = 'BLACK'; $times_font = 'BLACK'; $phones_font = 'BLACK'; @@ -72,8 +73,6 @@ $reports_font = 'BLACK'; $cts_font = 'BLACK'; $subcamp_font = 'BLACK'; -### QC font and color variables -require_once('qc/QC_admin_variables.php'); ### comment this section out for colorful section headings $users_color = '#E6E6E6'; $campaigns_color = '#E6E6E6'; @@ -84,6 +83,7 @@ $usergroups_color = '#E6E6E6'; $scripts_color = '#E6E6E6'; $filters_color = '#E6E6E6'; $admin_color = '#E6E6E6'; +$qc_color = '#E6E6E6'; $reports_color = '#E6E6E6'; $times_color = '#C6C6C6'; $shifts_color = '#C6C6C6'; @@ -3347,12 +3347,13 @@ else # 140621-2136 - Added DID pre-filter phone-group redirection and no-agent-ingroup redirection options # 140623-2147 - Added wrapup_bypass and script_message changes # 140625-1931 - Added wrapup_after_hotkey campaign option +# 140706-0829 - Incorporated QC includes into code # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 8 to access this page the first time -$admin_version = '2.10-446a'; -$build = '140625-1931'; +$admin_version = '2.10-447a'; +$build = '140706-0829'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -3505,7 +3506,31 @@ else ############################################## # Include QC Agents with no other permission # ############################################## -require_once('qc/QC_admin_include02.php'); +//Get QC User permissions +$stmt="SELECT qc_enabled,qc_user_level,qc_pass,qc_finish,qc_commit from vicidial_users where user='$PHP_AUTH_USER' and user_level > 1 and active='Y' and qc_enabled='1';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_to_mysqli($stmt, $link); +$row=mysqli_fetch_row($rslt); +$qc_auth=$row[0]; +//Not "qc_" as it will interfere with ADD=4A storage of modified user. +if ($qc_auth=='1') + { + $qcuser_level=$row[1]; + $qcpass=$row[2]; + $qcfinish=$row[3]; + $qccommit=$row[4]; + } +//Modify menuing to allow qc users into the system (if they have no permission otherwise) +//Copied Reports-Only user setup for QC-Only user (Poundteam QC setup) +$qc_only_user=0; +if ( ($qc_auth > 0) and ($auth < 1) ) + { + if ($ADD != '881') + { + $ADD=100000000000000; + } + $qc_only_user=1; + } $stmt="SELECT user_id,user,pass,full_name,user_level,user_group,phone_login,phone_pass,delete_users,delete_user_groups,delete_lists,delete_campaigns,delete_ingroups,delete_remote_agents,load_leads,campaign_detail,ast_admin_access,ast_delete_phones,delete_scripts,modify_leads,hotkeys_active,change_agent_campaign,agent_choose_ingroups,closer_campaigns,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,delete_filters,alter_agent_interface_options,closer_default_blended,delete_call_times,modify_call_times,modify_users,modify_campaigns,modify_lists,modify_scripts,modify_filters,modify_ingroups,modify_usergroups,modify_remoteagents,modify_servers,view_reports,vicidial_recording_override,alter_custdata_override,qc_enabled,qc_user_level,qc_pass,qc_finish,qc_commit,add_timeclock_log,modify_timeclock_log,delete_timeclock_log,alter_custphone_override,vdc_agent_api_access,modify_inbound_dids,delete_inbound_dids,active,alert_enabled,download_lists,agent_shift_enforcement_override,manager_shift_enforcement_override,shift_override_flag,export_reports,delete_from_dnc,email,user_code,territory,allow_alerts,callcard_admin,force_change_password,modify_shifts,modify_phones,modify_carriers,modify_labels,modify_statuses,modify_voicemail,modify_audiostore,modify_moh,modify_tts,modify_contacts,modify_same_user_level,alter_admin_interface_options,modify_custom_dialplans from vicidial_users where user='$PHP_AUTH_USER';"; $rslt=mysql_to_mysqli($stmt, $link); @@ -4080,8 +4105,8 @@ if ($ADD==180000000000) {$hh='admin'; $sh='label'; echo "SCREEN LABELS LIST";} if ($ADD==190000000000) {$hh='admin'; $sh='cts'; echo "CONTACTS LIST";} if ($ADD==1000000000000) {$hh='admin'; $sh='conference'; echo "CONFERENCE LIST";} if ($ADD==10000000000000) {$hh='admin'; $sh='conference'; echo "AGENT CONFERENCE LIST";} -##QC -require_once('qc/QC_admin_variables01.php'); +if ($ADD==100000000000000) {$hh='qc'; echo "Quality Control";} +if ($ADD==881) {$hh='qc'; echo "Quality Control Campaign $campaign_id";} if ($ADD==550) {$hh='users'; echo "Search Form";} if ($ADD==551) {$hh='users'; echo "SEARCH PHONES";} if ($ADD==660) {$hh='users'; echo "Search Results";} @@ -10722,11 +10747,6 @@ if ($ADD==231111111111111) -###################### -# ADD=241111111111111 adds the new qc status code to the system -###################### -//Moved to qc/QC_status_codes_include.php include file - ###################################################################################################### @@ -29253,15 +29273,126 @@ if ($ADD==331111111111111) } +###################### +# ADD=241111111111111 adds the new qc status code to the system +###################### +if ($ADD==241111111111111) + { + echo ""; + $stmt="SELECT count(*) from vicidial_qc_codes where code='$code';"; + $rslt=mysql_query($stmt, $link); + $row=mysqli_fetch_row($rslt); + if ($row[0] > 0) + {echo "
QC STATUS CODE NOT ADDED - there is already a qc status code in the system with this name: $row[0]\n";} + else + { + if ( (strlen($code) < 1) or (strlen($code_name) < 2) ) + { + echo "
QC STATUS CODE NOT ADDED - Please go back and look at the data you entered\n"; + echo "
code must be between 1 and 8 characters in length\n"; + echo "
code name must be between 2 and 30 characters in length\n"; + } + else + { + echo "
QC STATUS CODE ADDED: $code_name - $code\n"; + if (isset($_POST["qc_category"])) {$qc_category=$_POST["qc_category"];} + + $stmt="INSERT INTO vicidial_qc_codes (code,code_name,qc_result_type) values('$code','$code_name','$qc_category');"; + $rslt=mysql_query($stmt, $link); + + ### 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='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='QCSTATUSES', event_type='ADD', record_id='$code', event_code='ADMIN ADD QC STATUS', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + } + } + $ADD=341111111111111; + } - -##QC -require_once('qc/QC_status_codes_include.php'); ###################### # ADD=341111111111111 modify vicidial QC status code ###################### -//This section moved to include file as part of QC + +if ($ADD==341111111111111) + { + if ( ($LOGmodify_servers==1) and ($SSqc_features_active > 0) ) + { + if ( ($SSadmin_modify_refresh > 1) and ($modify_refresh_set < 1) ) + { + $modify_url = "$PHP_SELF?ADD=341111111111111"; + $modify_footer_refresh=1; + } + echo "
\n"; + echo ""; + + echo "
\n"; + echo "QC STATUS CODES WITHIN THIS SYSTEM:   $NWB#vicidial_qc_status_codes$NWE
\n"; + echo "\n"; + echo "\n"; + + ##### go through each QC status code + $stmt="SELECT count(*) from vicidial_qc_codes;"; + $rslt=mysql_query($stmt, $link); + $rowx=mysqli_fetch_row($rslt); + if ($rowx[0] > 0) + { + $stmt="SELECT code,code_name,qc_result_type from vicidial_qc_codes order by code;"; + $rslt=mysql_query($stmt, $link); + $statuses_to_print = mysql_num_rows($rslt); + $o=0; + while ($statuses_to_print > $o) + { + $rowx=mysqli_fetch_row($rslt); + $o++; + + if (preg_match("/1$|3$|5$|7$|9$/i", $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + } + echo "
STATUS CODEDESCRIPTIONQC CATEGORYMODIFY/DELETE
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "$rowx[0]
$rowx[2]         \n"; + echo "   \n"; + + if (preg_match("/^B$|^NA$|^DNC$|^NA$|^DROP$|^INCALL$|^QUEUE$|^NEW$/i",$rowx[0])) + { + echo "DELETE\n"; + } + else + { + echo "DELETE\n"; + } + echo "
\n"; + + echo "
ADD NEW QC STATUS CODE
\n"; + echo "\n"; + echo "Status:   \n"; + echo "Description: \n"; + echo "QC Category:
\n"; + + echo "

\n"; + } + else + { + echo "You do not have permission to view this page\n"; + exit; + } + } + ###################### # ADD=550 user search form @@ -31092,7 +31223,107 @@ if ($ADD==10000000000000) ###################### # ADD=100000000000000 display all qc campaigns ###################### -require_once('qc/QC_admin_include01.php'); +if (($ADD==100000000000000) && ($qc_auth=='1')) + { + echo ""; + $alts_output .= ""; + $alts_output .= ""; + $alts_output .= "\n"; + $alts_output .= "\n"; + $alts_output .= "\n"; + } + } + else + { + echo "lead lookup FAILED for lead_id $lead_id       $NOW_TIME\n

\n"; +# echo "Close this window\n

\n"; + } + + ##### grab vicidial_log records ##### + $stmt="select uniqueid,lead_id,list_id,campaign_id,call_date,start_epoch,end_epoch,length_in_sec,status,phone_code,phone_number,user,comments,processed,user_group,term_reason,alt_dial from vicidial_log where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "' order by uniqueid desc limit 500;"; + $rslt=mysql_to_mysqli($stmt, $link); + $logs_to_print = mysqli_num_rows($rslt); + if($DB) echo __LINE__."
\n"; + $u=0; + $call_log = ''; + $log_campaign = ''; + while ($logs_to_print > $u) + { + if($DB) echo __LINE__."
\n"; + $row=mysqli_fetch_row($rslt); + if (strlen($log_campaign)<1) {$log_campaign = $row[3];} + if (preg_match("/1$|3$|5$|7$|9$/i", $u)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $u++; + $call_log .= ""; + $call_log .= ""; + $call_log .= ""; + $call_log .= "\n"; + $call_log .= "\n"; + $call_log .= "\n"; + $call_log .= "\n"; + $call_log .= "\n"; + $call_log .= "\n"; + $call_log .= "\n"; + $call_log .= "\n"; + + $campaign_id = $row[3]; + } + + ##### grab vicidial_agent_log records ##### + $stmt="select agent_log_id,user,server_ip,event_time,lead_id,campaign_id,pause_epoch,pause_sec,wait_epoch,wait_sec,talk_epoch,talk_sec,dispo_epoch,dispo_sec,status,user_group,comments,sub_status from vicidial_agent_log where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "' order by agent_log_id desc limit 500;"; + $rslt=mysql_to_mysqli($stmt, $link); + $Alogs_to_print = mysqli_num_rows($rslt); + if($DB) echo __LINE__."
\n"; + $y=0; + $agent_log = ''; + $Alog_campaign = ''; + while ($Alogs_to_print > $y) + { + $row=mysqli_fetch_row($rslt); + if (strlen($Alog_campaign)<1) {$Alog_campaign = $row[5];} + if (preg_match("/1$|3$|5$|7$|9$/i", $y)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $y++; + $agent_log .= ""; + $agent_log .= ""; + $agent_log .= ""; + $agent_log .= "\n"; + $agent_log .= "\n"; + $agent_log .= "\n"; + $agent_log .= "\n"; + $agent_log .= "\n"; + $agent_log .= "\n"; + $agent_log .= "\n"; + $agent_log .= "\n"; + $agent_log .= "\n"; + + $campaign_id = $row[5]; + } + + ##### grab vicidial_qc_agent_log records ##### + //Differentiate between View and Mod + $stmt="select * from vicidial_qc_agent_log where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "' order by qc_agent_log_id desc limit 100;"; + $rslt=mysql_to_mysqli($stmt, $link); + $Alogs_to_print = mysqli_num_rows($rslt); + if($DB) echo "$stmt
\n"; + $y=0; + $qc_agent_log = ''; + $Alog_campaign = ''; + while ($Alogs_to_print > $y) + { + $row=mysqli_fetch_assoc($rslt); + if (strlen($Alog_campaign)<1) {$Alog_campaign = $row[5];} + if (preg_match("/1$|3$|5$|7$|9$/i", $y)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + $y++; + if (strlen($row['save_epoch'])=='0') + { //VIEW ONLY record + $qc_agent_log .= ""; + $qc_agent_log .= ""; + $qc_agent_log .= ""; + $qc_agent_log .= ""; + $qc_agent_log .= ""; + $qc_agent_log .= ""; + $qc_agent_log .= ""; + $qc_agent_log .= ""; + $qc_agent_log .= ""; + $qc_agent_log .= "\n"; + } + else + { // CHANGE record + $detailtooltip=str_replace("\n", " ", $row['details']); // tool tip line break and both work in IE, but not firefox. + $qc_agent_log .= ""; + $qc_agent_log .= ""; + $qc_agent_log .= ""; + $qc_agent_log .= ""; + $qc_agent_log .= ""; + $qc_agent_log .= ""; + $qc_agent_log .= ""; + $qc_agent_log .= ""; + $qc_agent_log .= ""; + $qc_agent_log .= ""; + $qc_agent_log .= "\n"; + } + } + + ##### grab vicidial_closer_log records ##### + $stmt="select closecallid,lead_id,list_id,campaign_id,call_date,start_epoch,end_epoch,length_in_sec,status,phone_code,phone_number,user,comments,processed,queue_seconds,user_group,xfercallid,term_reason,uniqueid,agent_only from vicidial_closer_log where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "' order by closecallid desc limit 500;"; + $rslt=mysql_to_mysqli($stmt, $link); + $Clogs_to_print = mysqli_num_rows($rslt); + + $y=0; + $closer_log = ''; + $Clog_campaign = ''; + while ($Clogs_to_print > $y) + { + $row=mysqli_fetch_row($rslt); + if (strlen($Clog_campaign)<1) {$Clog_campaign = $row[3];} + if (preg_match("/1$|3$|5$|7$|9$/i", $y)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $y++; + $closer_log .= ""; + $closer_log .= ""; + $closer_log .= ""; + $closer_log .= "\n"; + $closer_log .= "\n"; + $closer_log .= "\n"; + $closer_log .= "\n"; + $closer_log .= "\n"; + $closer_log .= "\n"; + $closer_log .= "\n"; + $closer_log .= "\n"; + + $campaign_id = $row[3]; + } + + ##### grab vicidial_list data for lead ##### + $stmt="SELECT lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner,entry_list_id from vicidial_list where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "'"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysqli_fetch_row($rslt); + if (strlen($row[0]) > 0) + {$lead_id = $row[0];} + $dispo = $row[3]; + $tsr = $row[4]; + $vendor_id = $row[5]; + $list_id = $row[7]; + $gmt_offset_now = $row[8]; + $phone_code = $row[10]; + $phone_number = $row[11]; + $title = $row[12]; + $first_name = $row[13]; + $middle_initial = $row[14]; + $last_name = $row[15]; + $address1 = $row[16]; + $address2 = $row[17]; + $address3 = $row[18]; + $city = $row[19]; + $state = $row[20]; + $province = $row[21]; + $postal_code = $row[22]; + $country_code = $row[23]; + $gender = $row[24]; + $date_of_birth = $row[25]; + $alt_phone = $row[26]; + $email = $row[27]; + $security = $row[28]; + $comments = $row[29]; + $called_count = $row[30]; + $last_local_call_time = $row[31]; + $rank = $row[32]; + $owner = $row[33]; + $entry_list_id = $row[34]; + + if($DB) + { + echo __LINE__."\n"; + } + echo "
Call information: $first_name $last_name - $phone_number

\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo ""; +//SELECT campaign_id,campaign_name from vicidial_campaigns where active = 'Y' and qc_enabled='Y' order by campaign_name + $stmt="SELECT campaign_id,campaign_name, qc_statuses from vicidial_campaigns where active = 'Y' and qc_enabled='Y' order by campaign_name"; +// echo $stmt="SELECT conf_exten,server_ip,extension from vicidial_conferences order by conf_exten"; + $rslt=mysql_to_mysqli($stmt, $link); + $vicidialconf_to_print = mysqli_num_rows($rslt); + + echo "
VICIDIAL QUALITY LISTINGS:\n"; + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + + $o=0; + while ($vicidialconf_to_print > $o) + { + $row=mysqli_fetch_row($rslt); + if (preg_match("/1$|3$|5$|7$|9$/i", $o)) + { + $bgcolor='bgcolor="#B9CBFD"'; + } + else + { + $bgcolor='bgcolor="#9BB9FB"'; + } + echo ""; + echo ""; + echo ""; + echo "\n"; + $o++; + } + echo "
CAMPAIGN IDCAMPAIGN NAMEQC STATUSESMODIFY
$row[0] $row[1] $row[2]MODIFY
\n"; + } + + +###################### +# ADD=881 VIEW one qc campaign +###################### +if (($ADD==881) && ($qc_auth=='1')) + { + echo " - + + + @@ -84,7 +92,12 @@ if($short_header) } else { - include 'qc/QC_header_include02.php'; + if (($SSqc_features_active=='1') && ($qc_auth=='1')) + { + ?> + + @@ -134,7 +147,9 @@ if ($hh=='admin') if ($hh=='reports') {$reports_hh="bgcolor=\"$reports_color\""; $reports_fc="$reports_font"; $reports_bold="$header_selected_bold";} else {$reports_hh=''; $reports_fc='WHITE'; $reports_bold="$header_nonselected_bold";} -include('qc/QC_header_include01.php'); +if ($hh=='qc') + {$qc_hh="bgcolor=\"$qc_color\""; $qc_fc="$qc_font"; $qc_bold="$header_selected_bold";} + else {$qc_hh=''; $qc_fc='WHITE'; $qc_bold="$header_nonselected_bold";} echo "\n"; echo " - - - - -QC CAMPAIGN $campaign_id: Lead $lead_id - ".urldecode($lead_name)."
\n"; -//end_call is set by submit button to denote "save", without it this is a VIEW, with it this is a SAVE -if ($end_call > 0) { - if($DB) { echo __LINE__."\n"; } - ### update the lead record in the vicidial_list table - $stmt="UPDATE vicidial_list set status='" . mysqli_real_escape_string($link, $status) . "',title='" . mysqli_real_escape_string($link, $title) . "',first_name='" . mysqli_real_escape_string($link, $first_name) . "',middle_initial='" . mysqli_real_escape_string($link, $middle_initial) . "',last_name='" . mysqli_real_escape_string($link, $last_name) . "',address1='" . mysqli_real_escape_string($link, $address1) . "',address2='" . mysqli_real_escape_string($link, $address2) . "',address3='" . mysqli_real_escape_string($link, $address3) . "',city='" . mysqli_real_escape_string($link, $city) . "',state='" . mysqli_real_escape_string($link, $state) . "',province='" . mysqli_real_escape_string($link, $province) . "',postal_code='" . mysqli_real_escape_string($link, $postal_code) . "',country_code='" . mysqli_real_escape_string($link, $country_code) . "',alt_phone='" . mysqli_real_escape_string($link, $alt_phone) . "',phone_number='$phone_number',phone_code='$phone_code',email='" . mysqli_real_escape_string($link, $email) . "',security_phrase='" . mysqli_real_escape_string($link, $security) . "',comments='" . mysqli_real_escape_string($link, $comments) . "',rank='" . mysqli_real_escape_string($link, $rank) . "',owner='" . mysqli_real_escape_string($link, $owner) . "' where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "'"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_to_mysqli($stmt, $link); - //STATUS just changed, re-capture all data for client! - //Added by Poundteam for QC. Gather record data to display on page and prepopulate title and hrefs, etc. - $stmt="SELECT * from vicidial_list A inner join vicidial_lists B on A.list_id=B.list_id inner join vicidial_campaigns C on B.campaign_id=C.campaign_id left outer join vicidial_statuses D on A.status=D.status left outer join vicidial_qc_codes E on A.status=E.code where A.lead_id='$lead_id'"; - if($DB) { echo "$stmt\n"; } - $rslt=mysql_to_mysqli($stmt, $link); - $row=mysqli_fetch_assoc($rslt); - //QUALITY CONTROL CHANGE LOG BEGIN - CHANGE VERSION (VIEW VERSION IS BELOW, WHICH CREATES THE RECORD, THIS ONE MERELY MODIFIES THE EXISTING RECORD) - $new_record=$row; - //if status has changed, the join query above will have the "status" field of "vicidial_list" overwritten by the status field of "vicidial_statuses" ... which will be EMPTY if there is no matching status to the new QC status chosen. This will cause the changelog to be incorrect. - if ( strlen($new_record['status']) == '0' ) { - $new_record['status']=$new_record['code']; - } - - if($original_record != $new_record) { - //Information changed: Find out what and record it, first disable "view" logging - $qcchange='Y'; - $qcchangelist=''; - $qcchangecounter=0; - foreach($original_record as $key=>$value){ - //only list the changes in the first 35 fiels, those are from the vicidial_list table (the rest are from joined tables, and the changes cascade) - if(($new_record[$key]!=$value)&&($qcchangecounter<=35)) $qcchangelist.="----$key----\n$value => $new_record[$key]\n"; - $qcchangecounter++; - } - ### insert a NEW record to the vicidial_closer_log table - $qcchangelist=mysqli_real_escape_string($link, $qcchangelist); - $view_epoch = preg_replace('/[^0-9]/','',$_POST['viewtime']); - $elapsed_seconds=$STARTtime-$view_epoch; - - $stmt="UPDATE vicidial_qc_agent_log set save_datetime='$NOW_TIME',save_epoch='$STARTtime',elapsed_seconds='$elapsed_seconds',old_status='{$original_record['status']}',new_status='{$new_record['status']}',details='$qcchangelist' - where view_epoch='$view_epoch' and lead_id='$lead_id'"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_to_mysqli($stmt, $link); - } - //QUALITY CONTROL CHANGE LOG END - $original_sales_rep=$row['user']; - $campaign_id =$row['campaign_id']; - $campaign_name =$row['campaign_name']; - $lead_name =trim(trim($row['first_name'].' '.$row['middle_initial']).' '.$row['last_name']); - $scheduled_callback =$row['scheduled_callback']; - - echo "
information modified

\n"; - echo "Go back to re-modify this QC lead


\n"; - echo "
Proceed to QC CAMPAIGN $campaign_id Queue

Callback Information:\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='$PHP_AUTH_USER', ip_address='$ip', event_section='LEADS', event_type='MODIFY', record_id='$lead_id', event_code='ADMIN MODIFY LEAD', event_sql=\"$SQL_log\", event_notes='';"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_to_mysqli($stmt, $link); - if($DB) { - echo __LINE__."\n"; - } - - if ( ($dispo != $status) and ($dispo == 'CBHOLD') ) - { - if($DB) { - echo __LINE__."\n"; - } - ### inactivate vicidial_callbacks record for this lead - $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "' and status='ACTIVE';"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_to_mysqli($stmt, $link); - - echo "
vicidial_callback record inactivated: $lead_id
\n"; - } - //Duped CBHOLD version for vicidial status type 'Scheduled Callback' - if ( ($dispo != $status) and ($scheduled_callback == 'Y') ) - { - if($DB) { - echo __LINE__."\n"; - } - ### inactivate vicidial_callbacks record for this lead - $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "' and status='ACTIVE';"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_to_mysqli($stmt, $link); - - echo "
vicidial_callback record inactivated: $lead_id
\n"; - } - if ( ($dispo != $status) and ($dispo == 'CALLBK') ) - { - if($DB) { - echo __LINE__."\n"; - } - ### inactivate vicidial_callbacks record for this lead - $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "' and status IN('ACTIVE','LIVE');"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_to_mysqli($stmt, $link); - - echo "
vicidial_callback record inactivated: $lead_id
\n"; - } - - if ( ($dispo != $status) and ($status == 'CBHOLD') ) - { - if($DB) { - echo __LINE__."\n"; - } - ### find any vicidial_callback records for this lead - $stmt="select callback_id from vicidial_callbacks where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "' and status IN('ACTIVE','LIVE') order by callback_id desc LIMIT 1;"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_to_mysqli($stmt, $link); - $CBM_to_print = mysqli_num_rows($rslt); - if ($CBM_to_print > 0) - { - $rowx=mysqli_fetch_row($rslt); - $callback_id = $rowx[0]; - } - else - { - $defaultappointment = date("Y-m-d H:i:s", mktime(date("H"),date("i"),date("s"),date("m"),date("d"),date("Y"))); - - $stmt="INSERT INTO vicidial_callbacks SET lead_id='" . mysqli_real_escape_string($link, $lead_id) . "',recipient='ANYONE',status='ACTIVE',user='$PHP_AUTH_USER',user_group='ADMIN',list_id='" . mysqli_real_escape_string($link, $list_id) . "',callback_time='$defaultappointment 12:00:00',entry_time='$NOW_TIME',comments='',campaign_id='" . mysqli_real_escape_string($link, $campaign_id) . "';"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_to_mysqli($stmt, $link); - - echo "
Scheduled Callback added: $lead_id - $phone_number
\n"; - } - } - - //Duped CBHOLD version for vicidial status type 'Scheduled Callback' - //This entry creates the callback - if ( ($dispo != $status) and ($scheduled_callback == 'Y') ) - { - if($DB) { - echo __LINE__."\n"; - } - ### find any vicidial_callback records for this lead - $stmt="select callback_id from vicidial_callbacks where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "' and status IN('ACTIVE','LIVE') order by callback_id desc LIMIT 1;"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_to_mysqli($stmt, $link); - $CBM_to_print = mysqli_num_rows($rslt); - if ($CBM_to_print > 0) - { - $rowx=mysqli_fetch_row($rslt); - $callback_id = $rowx[0]; - } - else - { - $defaultappointment = date("Y-m-d H:i:s", mktime(date("H"),date("i"),date("s"),date("m"),date("d"),date("Y"))); - - $stmt="INSERT INTO vicidial_callbacks SET lead_id='" . mysqli_real_escape_string($link, $lead_id) . "',recipient='USERONLY',status='ACTIVE',user='$original_sales_rep',user_group='ADMIN',list_id='" . mysqli_real_escape_string($link, $list_id) . "',callback_time='$defaultappointment 12:00:00',entry_time='$NOW_TIME',comments='',campaign_id='" . mysqli_real_escape_string($link, $campaign_id) . "';"; - $debug1=$stmt; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_to_mysqli($stmt, $link); - - echo "
Scheduled Callback added: $lead_id - $phone_number
\n"; - } - } - - - if ( ($dispo != $status) and ($status == 'DNC') ) - { - if($DB) { - echo __LINE__."\n"; - } - ### add lead to the internal DNC list - $stmt="INSERT INTO vicidial_dnc (phone_number) values('" . mysqli_real_escape_string($link, $phone_number) . "');"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_to_mysqli($stmt, $link); - - echo "
Lead added to DNC List: $lead_id - $phone_number
\n"; - } - ### update last record in vicidial_log table - if (($dispo != $status) and ($modify_logs > 0)) - { - if($DB) { - echo __LINE__."\n"; - } - $stmt="UPDATE vicidial_log set status='" . mysqli_real_escape_string($link, $status) . "' where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "' order by call_date desc limit 1"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_to_mysqli($stmt, $link); - } - - ### update last record in vicidial_closer_log table - if (($dispo != $status) and ($modify_closer_logs > 0)) - { - if($DB) { - echo __LINE__."\n"; - } - $stmt="UPDATE vicidial_closer_log set status='" . mysqli_real_escape_string($link, $status) . "' where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "' order by call_date desc limit 1"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_to_mysqli($stmt, $link); - } - - ### update last record in vicidial_agent_log table - if (($dispo != $status) and ($modify_agent_logs > 0)) - { - if($DB) { - echo __LINE__."\n"; - } - $stmt="UPDATE vicidial_agent_log set status='" . mysqli_real_escape_string($link, $status) . "' where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "' order by agent_log_id desc limit 1"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_to_mysqli($stmt, $link); - } - - if ($add_closer_record > 0) - { - if($DB) echo __LINE__."\n"; - ### insert a NEW record to the vicidial_closer_log table - $stmt="INSERT INTO vicidial_closer_log (lead_id,list_id,campaign_id,call_date,start_epoch,end_epoch,length_in_sec,status,phone_code,phone_number,user,comments,processed) values('" . mysqli_real_escape_string($link, $lead_id) . "','" . mysqli_real_escape_string($link, $list_id) . "','" . mysqli_real_escape_string($link, $campaign_id) . "','" . mysqli_real_escape_string($link, $parked_time) . "','$NOW_TIME','$STARTtime','1','" . mysqli_real_escape_string($link, $status) . "','" . mysqli_real_escape_string($link, $phone_code) . "','" . mysqli_real_escape_string($link, $phone_number) . "','$PHP_AUTH_USER','" . mysqli_real_escape_string($link, $comments) . "','Y')"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_to_mysqli($stmt, $link); - } - - - } else { - echo "\n"; - //Not a "Submit" result, viewing the record (possibly with URL options such as those below which modify callback status but not record data) - if ($CBchangeUSERtoANY == 'YES') { - if($DB) echo __LINE__."\n"; - ### set vicidial_callbacks record to an ANYONE callback for this lead - $stmt="UPDATE vicidial_callbacks set recipient='ANYONE' where callback_id='" . mysqli_real_escape_string($link, $callback_id) . "';"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_to_mysqli($stmt, $link); - echo "
vicidial_callback record changed to ANYONE
\n"; - $qcchange='Y'; - } - if ($CBchangeUSERtoUSER == 'YES') { - if($DB) echo __LINE__."\n"; - ### set vicidial_callbacks record to a different USERONLY callback record for this lead - $stmt="UPDATE vicidial_callbacks set user='" . mysqli_real_escape_string($link, $CBuser) . "' where callback_id='" . mysqli_real_escape_string($link, $callback_id) . "';"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_to_mysqli($stmt, $link); - echo "
vicidial_callback record user changed to $CBuser
\n"; - $qcchange='Y'; - } - if ($CBchangeANYtoUSER == 'YES') { - if($DB) echo __LINE__."\n"; - ### set vicidial_callbacks record to an USERONLY callback for this lead - $stmt="UPDATE vicidial_callbacks set user='" . mysqli_real_escape_string($link, $CBuser) . "',recipient='USERONLY' where callback_id='" . mysqli_real_escape_string($link, $callback_id) . "';"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_to_mysqli($stmt, $link); - echo "
vicidial_callback record changed to USERONLY, user: $CBuser
\n"; - $qcchange='Y'; - } - if ($CBchangeDATE == 'YES') { - if($DB) echo __LINE__."\n"; - ### change date/time of vicidial_callbacks record for this lead - $stmt="UPDATE vicidial_callbacks set callback_time='" . mysqli_real_escape_string($link, $appointment_date) . " " . mysqli_real_escape_string($link, $appointment_time) . "',comments='" . mysqli_real_escape_string($link, $comments) . "' where callback_id='" . mysqli_real_escape_string($link, $callback_id) . "';"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_to_mysqli($stmt, $link); - echo "
vicidial_callback record changed to $appointment_date $appointment_time
\n"; - $qcchange='Y'; - } - //QUALITY CONTROL LOGGING BEGIN - VIEW ONLY - //If no changes have been made, record "view" of this record. - if ($qcchange != 'Y') { - if($DB) echo __LINE__."\n QCCHANGE != Y"; - ### insert a NEW record to the vicidial_closer_log table - $stmt="INSERT INTO vicidial_qc_agent_log (qc_user,qc_user_group,qc_user_ip,lead_user,web_server_ip,view_datetime,view_epoch,lead_id,list_id,campaign_id,processed) - values('" . mysqli_real_escape_string($link, $PHP_AUTH_USER) . "','$LOGuser_group','{$_SERVER['REMOTE_ADDR']}','{$original_record['user']}','{$_SERVER['SERVER_ADDR']}','$NOW_TIME','$STARTtime','" . mysqli_real_escape_string($link, $lead_id) . "','" . mysqli_real_escape_string($link, $original_record['list_id']) . "','" . mysqli_real_escape_string($link, $campaign_id) . "','N')"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_to_mysqli($stmt, $link); - } - //QUALITY CONTROL LOGGING END - if($DB) echo __LINE__."\n"; - $stmt="SELECT count(*) from vicidial_list where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "'"; - $rslt=mysql_to_mysqli($stmt, $link); - if ($DB) {echo "$stmt\n";} - $row=mysqli_fetch_row($rslt); - $lead_count = $row[0]; - - if ($lead_count > 0) - { - if($DB) echo __LINE__."\n"; - ##### grab vicidial_list_alt_phones records ##### - $stmt="select phone_code,phone_number,alt_phone_note,alt_phone_count,active from vicidial_list_alt_phones where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "' order by alt_phone_count limit 500;"; - $rslt=mysql_to_mysqli($stmt, $link); - $alts_to_print = mysqli_num_rows($rslt); - - $c=0; - $alts_output = ''; - while ($alts_to_print > $c) - { - if($DB) { - echo __LINE__."\n"; - } - $row=mysqli_fetch_row($rslt); - if (preg_match("/1$|3$|5$|7$|9$/i", $c)) - {$bgcolor='bgcolor="#B9CBFD"';} - else - {$bgcolor='bgcolor="#9BB9FB"';} - - $c++; - $alts_output .= "
"; - $alts_output .= ""; - $alts_output .= ""; - $alts_output .= "\n"; - $alts_output .= "\n"; - $alts_output .= "\n"; - } - - } - else - { - echo "lead lookup FAILED for lead_id $lead_id       $NOW_TIME\n

\n"; -# echo "Close this window\n

\n"; - } - - ##### grab vicidial_log records ##### - $stmt="select uniqueid,lead_id,list_id,campaign_id,call_date,start_epoch,end_epoch,length_in_sec,status,phone_code,phone_number,user,comments,processed,user_group,term_reason,alt_dial from vicidial_log where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "' order by uniqueid desc limit 500;"; - $rslt=mysql_to_mysqli($stmt, $link); - $logs_to_print = mysqli_num_rows($rslt); - if($DB) echo __LINE__."
\n"; - $u=0; - $call_log = ''; - $log_campaign = ''; - while ($logs_to_print > $u) - { - if($DB) echo __LINE__."
\n"; - $row=mysqli_fetch_row($rslt); - if (strlen($log_campaign)<1) {$log_campaign = $row[3];} - if (preg_match("/1$|3$|5$|7$|9$/i", $u)) - {$bgcolor='bgcolor="#B9CBFD"';} - else - {$bgcolor='bgcolor="#9BB9FB"';} - - $u++; - $call_log .= "
"; - $call_log .= ""; - $call_log .= ""; - $call_log .= "\n"; - $call_log .= "\n"; - $call_log .= "\n"; - $call_log .= "\n"; - $call_log .= "\n"; - $call_log .= "\n"; - $call_log .= "\n"; - $call_log .= "\n"; - - $campaign_id = $row[3]; - } - - ##### grab vicidial_agent_log records ##### - $stmt="select agent_log_id,user,server_ip,event_time,lead_id,campaign_id,pause_epoch,pause_sec,wait_epoch,wait_sec,talk_epoch,talk_sec,dispo_epoch,dispo_sec,status,user_group,comments,sub_status from vicidial_agent_log where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "' order by agent_log_id desc limit 500;"; - $rslt=mysql_to_mysqli($stmt, $link); - $Alogs_to_print = mysqli_num_rows($rslt); - if($DB) echo __LINE__."
\n"; - $y=0; - $agent_log = ''; - $Alog_campaign = ''; - while ($Alogs_to_print > $y) - { - $row=mysqli_fetch_row($rslt); - if (strlen($Alog_campaign)<1) {$Alog_campaign = $row[5];} - if (preg_match("/1$|3$|5$|7$|9$/i", $y)) - {$bgcolor='bgcolor="#B9CBFD"';} - else - {$bgcolor='bgcolor="#9BB9FB"';} - - $y++; - $agent_log .= "
"; - $agent_log .= ""; - $agent_log .= ""; - $agent_log .= "\n"; - $agent_log .= "\n"; - $agent_log .= "\n"; - $agent_log .= "\n"; - $agent_log .= "\n"; - $agent_log .= "\n"; - $agent_log .= "\n"; - $agent_log .= "\n"; - $agent_log .= "\n"; - - $campaign_id = $row[5]; - } - - ##### grab vicidial_qc_agent_log records ##### - //Differentiate between View and Mod - $stmt="select * from vicidial_qc_agent_log where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "' order by qc_agent_log_id desc limit 100;"; - $rslt=mysql_to_mysqli($stmt, $link); - $Alogs_to_print = mysqli_num_rows($rslt); - if($DB) echo "$stmt
\n"; - $y=0; - $qc_agent_log = ''; - $Alog_campaign = ''; - while ($Alogs_to_print > $y) - { - $row=mysqli_fetch_assoc($rslt); - if (strlen($Alog_campaign)<1) {$Alog_campaign = $row[5];} - if (preg_match("/1$|3$|5$|7$|9$/i", $y)) - {$bgcolor='bgcolor="#B9CBFD"';} - else - {$bgcolor='bgcolor="#9BB9FB"';} - - $y++; - if (strlen($row['save_epoch'])=='0'){ //VIEW ONLY record - $qc_agent_log .= "
"; - $qc_agent_log .= ""; - $qc_agent_log .= ""; - $qc_agent_log .= ""; - $qc_agent_log .= ""; - $qc_agent_log .= ""; - $qc_agent_log .= ""; - $qc_agent_log .= ""; - $qc_agent_log .= ""; - $qc_agent_log .= "\n"; - } else { // CHANGE record - $detailtooltip=str_replace("\n", " ", $row['details']); // tool tip line break and both work in IE, but not firefox. - $qc_agent_log .= ""; - $qc_agent_log .= ""; - $qc_agent_log .= ""; - $qc_agent_log .= ""; - $qc_agent_log .= ""; - $qc_agent_log .= ""; - $qc_agent_log .= ""; - $qc_agent_log .= ""; - $qc_agent_log .= ""; - $qc_agent_log .= ""; - $qc_agent_log .= "\n"; - } - } - - ##### grab vicidial_closer_log records ##### - $stmt="select closecallid,lead_id,list_id,campaign_id,call_date,start_epoch,end_epoch,length_in_sec,status,phone_code,phone_number,user,comments,processed,queue_seconds,user_group,xfercallid,term_reason,uniqueid,agent_only from vicidial_closer_log where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "' order by closecallid desc limit 500;"; - $rslt=mysql_to_mysqli($stmt, $link); - $Clogs_to_print = mysqli_num_rows($rslt); - - $y=0; - $closer_log = ''; - $Clog_campaign = ''; - while ($Clogs_to_print > $y) - { - $row=mysqli_fetch_row($rslt); - if (strlen($Clog_campaign)<1) {$Clog_campaign = $row[3];} - if (preg_match("/1$|3$|5$|7$|9$/i", $y)) - {$bgcolor='bgcolor="#B9CBFD"';} - else - {$bgcolor='bgcolor="#9BB9FB"';} - - $y++; - $closer_log .= ""; - $closer_log .= ""; - $closer_log .= ""; - $closer_log .= "\n"; - $closer_log .= "\n"; - $closer_log .= "\n"; - $closer_log .= "\n"; - $closer_log .= "\n"; - $closer_log .= "\n"; - $closer_log .= "\n"; - $closer_log .= "\n"; - - $campaign_id = $row[3]; - } - - ##### grab vicidial_list data for lead ##### - $stmt="SELECT lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner,entry_list_id from vicidial_list where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "'"; - $rslt=mysql_to_mysqli($stmt, $link); - if ($DB) {echo "$stmt\n";} - $row=mysqli_fetch_row($rslt); - if (strlen($row[0]) > 0) - {$lead_id = $row[0];} - $dispo = $row[3]; - $tsr = $row[4]; - $vendor_id = $row[5]; - $list_id = $row[7]; - $gmt_offset_now = $row[8]; - $phone_code = $row[10]; - $phone_number = $row[11]; - $title = $row[12]; - $first_name = $row[13]; - $middle_initial = $row[14]; - $last_name = $row[15]; - $address1 = $row[16]; - $address2 = $row[17]; - $address3 = $row[18]; - $city = $row[19]; - $state = $row[20]; - $province = $row[21]; - $postal_code = $row[22]; - $country_code = $row[23]; - $gender = $row[24]; - $date_of_birth = $row[25]; - $alt_phone = $row[26]; - $email = $row[27]; - $security = $row[28]; - $comments = $row[29]; - $called_count = $row[30]; - $last_local_call_time = $row[31]; - $rank = $row[32]; - $owner = $row[33]; - $entry_list_id = $row[34]; - - if($DB) { - echo __LINE__."\n"; - } - echo "
Call information: $first_name $last_name - $phone_number

\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "
\n"; + echo ""; + $stmt="SELECT campaign_id,campaign_name, qc_statuses from vicidial_campaigns where active = 'Y' and qc_enabled='Y' and campaign_id='$campaign_id' limit 1"; + $rslt=mysql_to_mysqli($stmt, $link); + $vicidialconf_to_print = mysqli_num_rows($rslt); + $o=0; + while ($vicidialconf_to_print > $o) + { + $row=mysqli_fetch_row($rslt); + $o++; + } + $qc_status_list=substr($row[2],0,strlen($row[2])-2); + + echo "
$campaign_id - {$row[1]} - Quality Control Queue
QC statuses: $qc_status_list\n"; + + $qc_statuses=explode(' ',$qc_status_list); + echo "
\n"; + foreach ( $qc_statuses as $qc_status ) + { + $stmt="SELECT lead_id,first_name,last_name,modify_date,user from vicidial_list inner join vicidial_lists on vicidial_list.list_id=vicidial_lists.list_id where campaign_id='$campaign_id' and status='$qc_status' order by status, modify_date"; + $rslt=mysql_to_mysqli($stmt, $link); + $vicidialconf_to_print = mysqli_num_rows($rslt); + $o=0; + while ($vicidialconf_to_print > $o) + { + if($o==0) + { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + } + $row=mysqli_fetch_row($rslt); + if (preg_match("/1$|3$|5$|7$|9$/i", $o)) + { + $bgcolor='bgcolor="#B9CBFD"'; + } + else + { + $bgcolor='bgcolor="#9BB9FB"'; + } + echo ""; + echo ""; + $lead_name=trim($row[1].' '.$row[2]); + $lead_nameENC=urlencode($lead_name); + if (strlen($lead_name)<1) $lead_name='No Name'; + echo ""; + echo ""; + echo "\n"; + $o++; + } + } + echo "
$qc_status ($vicidialconf_to_print)LEAD IDNAMELast ModifiedUserID
  $row[0]$lead_name $row[3]$row[4]
\n"; + } ###################### diff --git a/www/vicidial/admin_header.php b/www/vicidial/admin_header.php index 1473565f..03c231ba 100644 --- a/www/vicidial/admin_header.php +++ b/www/vicidial/admin_header.php @@ -45,6 +45,7 @@ # 130615-2314 - Changed Reports only and QC only headers # 130824-2324 - Changed to mysqli PHP functions # 140126-1022 - Added VMAIL_NO_INST option +# 140706-0828 - Incorporated QC includes into code # @@ -60,7 +61,14 @@ if($short_header) ?>
  Users     Campaigns     Quality Control     Lists     Scripts     Filters     Quality Control  
$c$row[0] $row[1] $row[2] $row[3] $row[4]
$u$row[4] $row[7] $row[8] $row[11] $row[3] $row[2] $row[1] $row[15]   $row[10]
$y$row[3] $row[5] $row[1] $row[7] $row[9] $row[11] $row[13]   $row[14]   $row[15]   $row[17]
$y{$row['view_datetime']}View Only - No changes{$row['qc_user']}{$row['lead_user']}{$row['campaign_id']}{$row['list_id']}  
$y{$row['view_datetime']}{$row['old_status']}{$row['new_status']}{$row['qc_user']}{$row['lead_user']}{$row['campaign_id']}{$row['list_id']}{$row['elapsed_seconds']} DETAILS
$y$row[4] $row[7] $row[8] $row[11] $row[3] $row[2] $row[1]   $row[14]   $row[17]
\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - $stmt="SELECT user_id, timestamp, list_id, campaign_id, comment from vicidial_comments where lead_id='$lead_id' order by timestamp"; - $rslt=mysql_to_mysqli($stmt, $link); - $row_count = mysqli_num_rows($rslt); - $o=0; - $comments=false; - while ($row_count > $o) - { - if (!$comments) { - echo "\n"; - $comments=true; - } - $rowx=mysqli_fetch_row($rslt); - echo "\n"; - $o++; - } - - if ($comments) { - echo "\n"; - } - echo "\n"; - -// Section Modified for QC Functionality By PoundTeam -// echo "\n"; -// echo "\n"; -// echo "\n"; - echo "\n"; - - - echo "\n"; - echo "
$label_vendor_lead_code: $vendor_id     Lead ID: $lead_id
Fronter: $tsr     List ID: $list_id     Called Count: $called_count
$label_title:   \n"; - echo "$label_first_name:
$label_middle_initial:   \n"; - echo " $label_last_name:
$label_address1 :
$label_address2 :
$label_address3 :
$label_city :
$label_state:   \n"; - echo " $label_postal_code:
$label_province :
Country :
$label_phone_number :
$label_phone_code :
$label_alt_phone :
$label_email :
$label_security_phrase :
Rank :
Owner :
$label_comments :
Comment History
$rowx[0] :
$rowx[1]
List ID: $rowx[2]; Campaign ID: $rowx[3]
$rowx[4]

QC Result: (with $list_campaign statuses)
Modify vicidial log
Modify agent log
Modify closer log
Disable QC log entry (this feature is not active yet)
\n"; - echo "


\n"; - - echo "
\n"; - echo "Callback Details:
\n"; - //Added scheduled_callback regular statuses option - if ( ($dispo == 'CALLBK') or ($dispo == 'CBHOLD') || $scheduled_callback=='Y' ) - { - if($DB) { - echo __LINE__."\n"; - } - ### find any vicidial_callback records for this lead - $stmt="select callback_id,lead_id,list_id,campaign_id,status,entry_time,callback_time,modify_date,user,recipient,comments,user_group from vicidial_callbacks where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "' and status IN('ACTIVE','LIVE') order by callback_id desc LIMIT 1;"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_to_mysqli($stmt, $link); - $CB_to_print = mysqli_num_rows($rslt); - $rowx=mysqli_fetch_row($rslt); - - if ($CB_to_print>0) - { - if ($rowx[9] == 'USERONLY') - { - echo "
\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "

\n"; - - echo "
\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "New Callback Owner UserID: \n"; - echo "

\n"; - } - else - { - echo "
\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "New Callback Owner UserID: \n"; - echo "

\n"; - } - - $appointment_datetimeARRAY = explode(" ",$rowx[6]); - $appointment_date = $appointment_datetimeARRAY[0]; - $appointment_timeARRAY = explode(":",$appointment_datetimeARRAY[1]); - $appointment_hour = $appointment_timeARRAY[0]; - $appointment_min = $appointment_timeARRAY[1]; - - - ?> - -
-
Change Scheduled Callback Date:
- - - - - - - - - - - - - -
- > - - - - -
CallBack Date/Time: - - -     - - : - - -
- Comments: - - -
- - - - -
-
- - No Callback records found
\n"; - } - - } - else - { - if($DB) { - echo __LINE__."\n"; - } - //Modifed text to allow for other than CBHOLD via custom statuses with scheduled callback chosen - echo "
If you want to change this lead to a scheduled callback, first change the Disposition to CBHOLD or similar, then submit and you will be able to set the callback date and time.
\n"; - } - echo "
\n"; - - echo "

\n"; - - echo "
\n"; - - if ($c > 0) - { - if($DB) { - echo __LINE__."\n"; - } - echo "EXTENDED ALTERNATE PHONE NUMBERS FOR THIS LEAD:\n"; - echo "\n"; - echo "\n"; - - echo "$alts_output\n"; - - echo "
# ALT PHONE ALT NOTE ALT COUNT ACTIVE
\n"; - echo "

\n"; - } - - - - ### iframe for custom fields display/editing - if ($custom_fields_enabled > 0) - { - $CLlist_id = $list_id; - if (strlen($entry_list_id) > 2) - {$CLlist_id = $entry_list_id;} - $stmt="SHOW TABLES LIKE \"custom_$CLlist_id\";"; - if ($DB>0) {echo "$stmt";} - $rslt=mysql_to_mysqli($stmt, $link); - $tablecount_to_print = mysqli_num_rows($rslt); - if ($tablecount_to_print > 0) - { - $stmt="SELECT count(*) from custom_$CLlist_id where lead_id='$lead_id';"; - if ($DB>0) {echo "$stmt";} - $rslt=mysql_to_mysqli($stmt, $link); - $fieldscount_to_print = mysqli_num_rows($rslt); - if ($fieldscount_to_print > 0) - { - $rowx=mysqli_fetch_row($rslt); - $custom_records_count = $rowx[0]; - - echo "CUSTOM FIELDS FOR THIS LEAD:
\n"; - echo "\n"; - echo "

"; - } - } - } - - - echo "CALLS TO THIS LEAD:\n"; - echo "\n"; - echo "\n"; - - echo "$call_log\n"; - - echo "
# DATE/TIME LENGTH STATUS TSR CAMPAIGN LIST LEAD HANGUP REASON PHONE
\n"; - echo "

\n"; - - echo "CLOSER RECORDS FOR THIS LEAD:\n"; - echo "\n"; - echo "\n"; - - echo "$closer_log\n"; - - echo "
# DATE/TIME LENGTH STATUS TSR CAMPAIGN LIST LEAD WAIT HANGUP REASON
\n"; - echo "

\n"; - - - echo "AGENT LOG RECORDS FOR THIS LEAD:\n"; - echo "\n"; - echo "\n"; - - echo "$agent_log\n"; - echo "
# DATE/TIME CAMPAIGN TSR PAUSE WAIT TALK DISPO STATUS GROUP SUB
\n"; - echo "

\n"; - echo "QUALITY CONTROL LOG RECORDS FOR THIS LEAD:\n"; - echo "\n"; - echo "\n"; - echo "$qc_agent_log\n"; - echo "
# DATE/TIME OLD STATUSNEW STATUSQC USERAGENTCAMPAIGNLISTELAPSED 
\n"; - echo "

\n"; - - echo "RECORDINGS FOR THIS LEAD:\n"; - echo "\n"; - echo "\n"; - - $stmt="select recording_id,channel,server_ip,extension,start_time,start_epoch,end_time,end_epoch,length_in_sec,length_in_min,filename,location,lead_id,user,vicidial_id from recording_log where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "' order by recording_id desc limit 500;"; - $rslt=mysql_to_mysqli($stmt, $link); - $logs_to_print = mysqli_num_rows($rslt); - if ($DB) {echo "$logs_to_print|$stmt|\n";} - - $u=0; - while ($logs_to_print > $u) - { - $row=mysqli_fetch_row($rslt); - if (preg_match("/1$|3$|5$|7$|9$/i", $u)) - {$bgcolor='bgcolor="#B9CBFD"';} - else - {$bgcolor='bgcolor="#9BB9FB"';} - - $location = $row[11]; - - if (strlen($location)>2) - { - $URLserver_ip = $location; - $URLserver_ip = preg_replace('/http:\/\//i', '',$URLserver_ip); - $URLserver_ip = preg_replace('/https:\/\//i', '',$URLserver_ip); - $URLserver_ip = preg_replace('/\/.*/i', '',$URLserver_ip); - $stmt="select count(*) from servers where server_ip='$URLserver_ip';"; - $rsltx=mysql_to_mysqli($stmt, $link); - $rowx=mysqli_fetch_row($rsltx); - - if ($rowx[0] > 0) - { - $stmt="select recording_web_link,alt_server_ip from servers where server_ip='$URLserver_ip';"; - $rsltx=mysql_to_mysqli($stmt, $link); - $rowx=mysqli_fetch_row($rsltx); - - if (preg_match("/ALT_IP/i",$rowx[0])) - { - $location = preg_replace("/$URLserver_ip/i", "$rowx[1]", $location); - } - if (preg_match("/EXTERNAL_IP/i",$rowx[0])) - { - $location = preg_replace("/$URLserver_ip/i", "$rowx[2]", $location); - } - } - } - - if (strlen($location)>30) - {$locat = substr($location,0,27); $locat = "$locat...";} - else - {$locat = $location;} - if ( (preg_match('/ftp/i',$location)) or (preg_match('/http/i',$location)) ) - {$location = "$locat";} - else - {$location = $locat;} - $u++; - echo ""; - echo ""; - echo ""; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo ""; - echo "\n"; - - } - - - echo "
# LEADDATE/TIME SECONDS   RECIDFILENAMELOCATIONTSR
$u $row[12] $row[4] $row[8] $row[0]   $row[10] $location $row[13]


\n"; - - - $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level >= 9 and modify_leads='1';"; - if ($DB) {echo "|$stmt|\n";} - if ($non_latin > 0) {$rslt=mysql_to_mysqli("SET NAMES 'UTF8'", $link);} - $rslt=mysql_to_mysqli($stmt, $link); - $row=mysqli_fetch_row($rslt); - $admin_display=$row[0]; - if ($admin_display > 0) - { - echo "Click here to see Lead Modify changes to this lead\n"; - } - - echo "\n"; - } - - -$ENDtime = date("U"); - -$RUNtime = ($ENDtime - $STARTtime); - -echo "\n\n\n


\n\n"; - - -echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; - - -?> - - - - - -original_record:
"; - print_r($original_record); - echo "
new_record:
"; - print_r($new_record); - echo "scheduled_callback:
"; - print_r($scheduled_callback); - echo "debug1:
"; - print_r($debug1); - echo "Post:
"; - print_r($_POST); - echo "qcchangelist:
"; - print_r($qcchangelist); - echo "
"; -} -exit; - - -?> +file depricated, integrated into standard admin directory \ No newline at end of file diff --git a/www/vicidial/qc_api.php b/www/vicidial/qc_api.php new file mode 100644 index 00000000..585304ee --- /dev/null +++ b/www/vicidial/qc_api.php @@ -0,0 +1,646 @@ + LICENSE: AGPLv2 +# +# This script is designed to allow API functions for QC applications, contributed by poundteam.com +# +# changes: +# 121116-1329 - First build, added to vicidial codebase +# 130622-0001 - Finalized changing of all ereg instances to preg +# - Added filtering of input to prevent SQL injection attacks and new user auth +# 130902-0906 - Changed to mysqli PHP functions +# 140706-0834 - Incorporated into standard admin code +# + +$version = '2.10-4'; +$build = '140706-0834'; + +require("dbconnect_mysqli.php"); +require("functions.php"); + +$query_string = getenv("QUERY_STRING"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["agent_user"])) {$agent_user=$_GET["agent_user"];} + elseif (isset($_POST["agent_user"])) {$agent_user=$_POST["agent_user"];} +if (isset($_GET["function"])) {$function=$_GET["function"];} + elseif (isset($_POST["function"])) {$function=$_POST["function"];} +if (isset($_GET["value"])) {$value=$_GET["value"];} + elseif (isset($_POST["value"])) {$value=$_POST["value"];} +if (isset($_GET["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["focus"])) {$focus=$_GET["focus"];} + elseif (isset($_POST["focus"])) {$focus=$_POST["focus"];} +if (isset($_GET["preview"])) {$preview=$_GET["preview"];} + elseif (isset($_POST["preview"])) {$preview=$_POST["preview"];} +if (isset($_GET["notes"])) {$notes=$_GET["notes"];} + elseif (isset($_POST["notes"])) {$notes=$_POST["notes"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["search"])) {$search=$_GET["search"];} + elseif (isset($_POST["search"])) {$search=$_POST["search"];} +if (isset($_GET["group_alias"])) {$group_alias=$_GET["group_alias"];} + elseif (isset($_POST["group_alias"])) {$group_alias=$_POST["group_alias"];} +if (isset($_GET["dial_prefix"])) {$dial_prefix=$_GET["dial_prefix"];} + elseif (isset($_POST["dial_prefix"])) {$dial_prefix=$_POST["dial_prefix"];} +if (isset($_GET["source"])) {$source=$_GET["source"];} + elseif (isset($_POST["source"])) {$source=$_POST["source"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["vtiger_callback"])) {$vtiger_callback=$_GET["vtiger_callback"];} + elseif (isset($_POST["vtiger_callback"])) {$vtiger_callback=$_POST["vtiger_callback"];} +if (isset($_GET["blended"])) {$blended=$_GET["blended"];} + elseif (isset($_POST["blended"])) {$blended=$_POST["blended"];} +if (isset($_GET["ingroup_choices"])) {$ingroup_choices=$_GET["ingroup_choices"];} + elseif (isset($_POST["ingroup_choices"])) {$ingroup_choices=$_POST["ingroup_choices"];} +if (isset($_GET["set_as_default"])) {$set_as_default=$_GET["set_as_default"];} + elseif (isset($_POST["set_as_default"])) {$set_as_default=$_POST["set_as_default"];} +if (isset($_GET["alt_user"])) {$alt_user=$_GET["alt_user"];} + elseif (isset($_POST["alt_user"])) {$alt_user=$_POST["alt_user"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["vendor_lead_code"])) {$vendor_lead_code=$_GET["vendor_lead_code"];} + elseif (isset($_POST["vendor_lead_code"])) {$vendor_lead_code=$_POST["vendor_lead_code"];} +if (isset($_GET["source_id"])) {$source_id=$_GET["source_id"];} + elseif (isset($_POST["source_id"])) {$source_id=$_POST["source_id"];} +if (isset($_GET["gmt_offset_now"])) {$gmt_offset_now=$_GET["gmt_offset_now"];} + elseif (isset($_POST["gmt_offset_now"])) {$gmt_offset_now=$_POST["gmt_offset_now"];} +if (isset($_GET["title"])) {$title=$_GET["title"];} + elseif (isset($_POST["title"])) {$title=$_POST["title"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["middle_initial"])) {$middle_initial=$_GET["middle_initial"];} + elseif (isset($_POST["middle_initial"])) {$middle_initial=$_POST["middle_initial"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["gender"])) {$gender=$_GET["gender"];} + elseif (isset($_POST["gender"])) {$gender=$_POST["gender"];} +if (isset($_GET["date_of_birth"])) {$date_of_birth=$_GET["date_of_birth"];} + elseif (isset($_POST["date_of_birth"])) {$date_of_birth=$_POST["date_of_birth"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security_phrase"])) {$security_phrase=$_GET["security_phrase"];} + elseif (isset($_POST["security_phrase"])) {$security_phrase=$_POST["security_phrase"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["rank"])) {$rank=$_GET["rank"];} + elseif (isset($_POST["rank"])) {$rank=$_POST["rank"];} +if (isset($_GET["owner"])) {$owner=$_GET["owner"];} + elseif (isset($_POST["owner"])) {$owner=$_POST["owner"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["close_window_link"])) {$close_window_link=$_GET["close_window_link"];} + elseif (isset($_POST["close_window_link"])) {$close_window_link=$_POST["close_window_link"];} +if (isset($_GET["dnc_check"])) {$dnc_check=$_GET["dnc_check"];} + elseif (isset($_POST["dnc_check"])) {$dnc_check=$_POST["dnc_check"];} +if (isset($_GET["campaign_dnc_check"])) {$campaign_dnc_check=$_GET["campaign_dnc_check"];} + elseif (isset($_POST["campaign_dnc_check"])) {$campaign_dnc_check=$_POST["campaign_dnc_check"];} +if (isset($_GET["dial_override"])) {$dial_override=$_GET["dial_override"];} + elseif (isset($_POST["dial_override"])) {$dial_override=$_POST["dial_override"];} +if (isset($_GET["consultative"])) {$consultative=$_GET["consultative"];} + elseif (isset($_POST["consultative"])) {$consultative=$_POST["consultative"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin 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]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +$ingroup_choices = preg_replace("/\+/"," ",$ingroup_choices); +$query_string = preg_replace("/'|\"|\\\\|;/","",$query_string); + +if ($non_latin < 1) + { + $user=preg_replace("/[^0-9a-zA-Z]/","",$user); + $pass=preg_replace("/[^0-9a-zA-Z]/","",$pass); + $agent_user=preg_replace("/[^0-9a-zA-Z]/","",$agent_user); + $function = preg_replace("/[^-\_0-9a-zA-Z]/","",$function); + $value = preg_replace("/[^-\_0-9a-zA-Z]/","",$value); + $vendor_id = preg_replace("/[^-\.\_0-9a-zA-Z]/","",$vendor_id); + $focus = preg_replace("/[^-\_0-9a-zA-Z]/","",$focus); + $preview = preg_replace("/[^-\_0-9a-zA-Z]/","",$preview); + $notes = preg_replace("/\+/"," ",$notes); + $notes = preg_replace("/[^- \.\_0-9a-zA-Z]/","",$notes); + $phone_code = preg_replace("/[^0-9X]/","",$phone_code); + $search = preg_replace("/[^-\_0-9a-zA-Z]/","",$search); + $group_alias = preg_replace("/[^0-9a-zA-Z]/","",$group_alias); + $dial_prefix = preg_replace("/[^0-9a-zA-Z]/","",$dial_prefix); + $source = preg_replace("/[^0-9a-zA-Z]/","",$source); + $format = preg_replace("/[^0-9a-zA-Z]/","",$format); + $vtiger_callback = preg_replace("/[^A-Z]/","",$vtiger_callback); + $alt_dial = preg_replace("/[^0-9A-Z]/","",$alt_dial); + $blended = preg_replace("/[^A-Z]/","",$blended); + $ingroup_choices = preg_replace("/[^- \_0-9a-zA-Z]/","",$ingroup_choices); + $set_as_default = preg_replace("/[^A-Z]/","",$set_as_default); + $phone_number = preg_replace("/[^0-9]/","",$phone_number); + $address1 = preg_replace("/[^- \_0-9a-zA-Z]/","",$address1); + $address2 = preg_replace("/[^- \_0-9a-zA-Z]/","",$address2); + $address3 = preg_replace("/[^- \_0-9a-zA-Z]/","",$address3); + $alt_phone = preg_replace("/[^- \_0-9a-zA-Z]/","",$alt_phone); + $city = preg_replace("/[^- \_0-9a-zA-Z]/","",$city); + $comments = preg_replace("/[^- \_0-9a-zA-Z]/","",$comments); + $country_code = preg_replace("/[^A-Z]/","",$country_code); + $date_of_birth = preg_replace("/[^- \_0-9]/","",$date_of_birth); + $email = preg_replace("/[^-\.\:\/\@\_0-9a-zA-Z]/","",$email); + $first_name = preg_replace("/[^- \_0-9a-zA-Z]/","",$first_name); + $gender = preg_replace("/[^A-Z]/","",$gender); + $gmt_offset_now = preg_replace("/[^- \.\_0-9]/","",$gmt_offset_now); + $last_name = preg_replace("/[^- \_0-9a-zA-Z]/","",$last_name); + $lead_id = preg_replace("/[^0-9]/","",$lead_id); + $middle_initial = preg_replace("/[^- \_0-9a-zA-Z]/","",$middle_initial); + $province = preg_replace("/[^- \.\_0-9a-zA-Z]/","",$province); + $security_phrase = preg_replace("/[^- \.\_0-9a-zA-Z]/","",$security_phrase); + $source_id = preg_replace("/[^- \.\_0-9a-zA-Z]/","",$source_id); + $state = preg_replace("/[^- \_0-9a-zA-Z]/","",$state); + $title = preg_replace("/[^- \_0-9a-zA-Z]/","",$title); + $vendor_lead_code = preg_replace("/[^- \.\_0-9a-zA-Z]/","",$vendor_lead_code); + $rank = preg_replace("/[^-0-9]/","",$rank); + $owner = preg_replace("/[^-\.\:\/\@\_0-9a-zA-Z]/","",$owner); + $dial_override = preg_replace("/[^A-Z]/","",$dial_override); + $consultative = preg_replace("/[^A-Z]/","",$consultative); + $callback_datetime = preg_replace("/\+/"," ",$callback_datetime); + $callback_datetime = preg_replace("/[^- \:\.\_0-9a-zA-Z]/","",$callback_datetime); + $callback_type = preg_replace("/[^A-Z]/","",$callback_type); + $callback_comments = preg_replace("/\+/"," ",$callback_comments); + $callback_comments = preg_replace("/[^- \.\_0-9a-zA-Z]/","",$callback_comments); + $qm_dispo_code = preg_replace("/[^-\.\_0-9a-zA-Z]/","",$qm_dispo_code); + $alt_user = preg_replace("/[^0-9a-zA-Z]/","",$alt_user); + $postal_code = preg_replace("/[^- \.\_0-9a-zA-Z]/","",$postal_code); + } +else + { + $user = preg_replace("/'|\"|\\\\|;/","",$user); + $pass = preg_replace("/'|\"|\\\\|;/","",$pass); + $source = preg_replace("/'|\"|\\\\|;/","",$source); + $agent_user = preg_replace("/'|\"|\\\\|;/","",$agent_user); + $alt_user = preg_replace("/'|\"|\\\\|;/","",$alt_user); + } + +### date and fixed variables +$epoch = date("U"); +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$CIDdate = date("mdHis"); +$ENTRYdate = date("YmdHis"); +$MT[0]=''; +$api_script = 'agent'; +$api_logging = 1; +if ($consultative != 'YES') {$consultative='NO';} + + +################################################################################ +### BEGIN - version - show version and date information for the API +################################################################################ +if ($function == 'version') + { + $data = "VERSION: $version|BUILD: $build|DATE: $NOW_TIME|EPOCH: $StarTtime"; + $result = 'SUCCESS'; + echo "$data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } +################################################################################ +### END - version +################################################################################ + + + + + +################################################################################ +### BEGIN - user validation section (most functions run through this first) +################################################################################ + +if ($ACTION == 'LogiNCamPaigns') + { + $skip_user_validation=1; + } +else + { + 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); + exit; + } + else + { + $auth=0; + $auth_message = user_authorization($user,$pass,'',0); + if ($auth_message == 'GOOD') + {$auth=1;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and vdc_agent_api_access='1';"; + if ($DB) {echo "|$stmt|\n";} + if ($non_latin > 0) {$rslt=mysql_to_mysqli("SET NAMES 'UTF8'", $link);} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $auth_api=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0) or ($auth_api==0)) + { + $result = 'ERROR'; + $result_reason = "Invalid Username/Password"; + echo "$result: $result_reason: |$user|$pass|$auth|$auth_api|$auth_message|\n"; + $data = "$user|$pass|$auth"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + { + $stmt="SELECT count(*) from system_settings where vdc_agent_api_active='1';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + $result = 'ERROR'; + $result_reason = "System API NOT ACTIVE"; + echo "$result: $result_reason\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + { + # do nothing for now + } + } + } + } + +if ($format=='debug') + { + $DB=1; + echo "\n"; + echo "\n"; + echo "";} + $rslt=mysql_to_mysqli($stmt, $link); + $result = 'SUCCESS'; + $result_reason = "external_dial function set"; + $data = "$phone_code|$search|$preview|$focus|$vendor_id|$epoch|$dial_prefix|$group_alias|$caller_id_number"; + echo "$result: Dispo in Agent Screen FIRST.\n"; + // echo "$result: $result_reason - $value|$agent_user|$data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + } + } + else + { + $result = 'ERROR'; + $result_reason = "agent_user is not allowed to place manual dial calls"; + echo "$result: $result_reason - $agent_user\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + } + } + else + { + $result = 'ERROR'; + $result_reason = "agent_user is not paused"; + echo "$result: $result_reason - $agent_user\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + } + } + else + { + $result = 'ERROR'; + $result_reason = "agent_user is not logged in"; + echo "$result: $result_reason - $agent_user\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + } + } + } + +// external_dial +################################################################################ +### END - external_dial +################################################################################ + + + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + + + +##### FUNCTIONS ##### + +##### Logging ##### +function api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data) + { + if ($api_logging > 0) + { + $NOW_TIME = date("Y-m-d H:i:s"); + $stmt="INSERT INTO vicidial_api_log set user='$user',agent_user='$agent_user',function='$function',value='$value',result='$result',result_reason='$result_reason',source='$source',data='$data',api_date='$NOW_TIME',api_script='$api_script';"; + $rslt=mysql_to_mysqli($stmt, $link); + } + return 1; + } +?> diff --git a/www/vicidial/qc_call_client_iframe.php b/www/vicidial/qc_call_client_iframe.php new file mode 100644 index 00000000..b4547ed2 --- /dev/null +++ b/www/vicidial/qc_call_client_iframe.php @@ -0,0 +1,294 @@ + LICENSE: AGPLv2 +# +# This script is designed to allow QC review and modification of leads, contributed by poundteam.com +# +# changes: +# 121116-1328 - First build, added to vicidial codebase +# 130621-2352 - Finalized changing of all ereg instances to preg +# - Added filtering of input to prevent SQL injection attacks and new user auth +# 130902-0905 - Changed to mysqli PHP functions +# 140706-0826 - Incorporated includes into code +# + +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["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["old_phone"])) {$old_phone=$_GET["old_phone"];} + elseif (isset($_POST["old_phone"])) {$old_phone=$_POST["old_phone"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["title"])) {$title=$_GET["title"];} + elseif (isset($_POST["title"])) {$title=$_POST["title"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["middle_initial"])) {$middle_initial=$_GET["middle_initial"];} + elseif (isset($_POST["middle_initial"])) {$middle_initial=$_POST["middle_initial"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["lead_name"])) {$lead_name=$_GET["lead_name"];} + elseif (isset($_POST["lead_name"])) {$lead_name=$_POST["lead_name"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];} + elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +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["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];} + elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} + elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security"])) {$security=$_GET["security"];} + elseif (isset($_POST["security"])) {$security=$_POST["security"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["rank"])) {$rank=$_GET["rank"];} + elseif (isset($_POST["rank"])) {$rank=$_POST["rank"];} +if (isset($_GET["owner"])) {$owner=$_GET["owner"];} + elseif (isset($_POST["owner"])) {$owner=$_POST["owner"];} +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["CBchangeUSERtoANY"])) {$CBchangeUSERtoANY=$_GET["CBchangeUSERtoANY"];} + elseif (isset($_POST["CBchangeUSERtoANY"])) {$CBchangeUSERtoANY=$_POST["CBchangeUSERtoANY"];} +if (isset($_GET["CBchangeUSERtoUSER"])) {$CBchangeUSERtoUSER=$_GET["CBchangeUSERtoUSER"];} + elseif (isset($_POST["CBchangeUSERtoUSER"])) {$CBchangeUSERtoUSER=$_POST["CBchangeUSERtoUSER"];} +if (isset($_GET["CBchangeANYtoUSER"])) {$CBchangeANYtoUSER=$_GET["CBchangeANYtoUSER"];} + elseif (isset($_POST["CBchangeANYtoUSER"])) {$CBchangeANYtoUSER=$_POST["CBchangeANYtoUSER"];} +if (isset($_GET["CBchangeDATE"])) {$CBchangeDATE=$_GET["CBchangeDATE"];} + elseif (isset($_POST["CBchangeDATE"])) {$CBchangeDATE=$_POST["CBchangeDATE"];} +if (isset($_GET["callback_id"])) {$callback_id=$_GET["callback_id"];} + elseif (isset($_POST["callback_id"])) {$callback_id=$_POST["callback_id"];} +if (isset($_GET["CBuser"])) {$CBuser=$_GET["CBuser"];} + elseif (isset($_POST["CBuser"])) {$CBuser=$_POST["CBuser"];} +if (isset($_GET["modify_logs"])) {$modify_logs=$_GET["modify_logs"];} + elseif (isset($_POST["modify_logs"])) {$modify_logs=$_POST["modify_logs"];} +if (isset($_GET["modify_closer_logs"])) {$modify_closer_logs=$_GET["modify_closer_logs"];} + elseif (isset($_POST["modify_closer_logs"])) {$modify_closer_logs=$_POST["modify_closer_logs"];} +if (isset($_GET["modify_agent_logs"])) {$modify_agent_logs=$_GET["modify_agent_logs"];} + elseif (isset($_POST["modify_agent_logs"])) {$modify_agent_logs=$_POST["modify_agent_logs"];} +if (isset($_GET["add_closer_record"])) {$add_closer_record=$_GET["add_closer_record"];} + elseif (isset($_POST["add_closer_record"])) {$add_closer_record=$_POST["add_closer_record"];} +if (isset($_POST["appointment_date"])) {$appointment_date=$_POST["appointment_date"];} + elseif (isset($_GET["appointment_date"])) {$appointment_date=$_GET["appointment_date"];} +if (isset($_POST["appointment_time"])) {$appointment_time=$_POST["appointment_time"];} + elseif (isset($_GET["appointment_time"])) {$appointment_time=$_GET["appointment_time"];} + +$STARTtime = date("U"); +$TODAY = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,custom_fields_enabled 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]; + $custom_fields_enabled = $row[1]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); + +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); + + $old_phone = preg_replace('/[^0-9]/','',$old_phone); + $phone_number = preg_replace('/[^0-9]/','',$phone_number); + $alt_phone = preg_replace('/[^0-9]/','',$alt_phone); + } # end of non_latin +else + { + $PHP_AUTH_USER = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_USER); + $PHP_AUTH_PW = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_PW); + } + +if (strlen($phone_number)<6) {$phone_number=$old_phone;} + +$auth=0; +$auth_message = user_authorization($PHP_AUTH_USER,$PHP_AUTH_PW,'QC',1); +if ($auth_message == 'GOOD') + {$auth=1;} + +if ($auth < 1) + { + $VDdisplayMESSAGE = "Login incorrect, please try again"; + if ($auth_message == 'LOCK') + { + $VDdisplayMESSAGE = "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=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$PHP_AUTH_PW|$auth_message|\n"; + exit; + } + +$rights_stmt = "SELECT modify_leads,qc_enabled,qc_user_level from vicidial_users where user='$PHP_AUTH_USER';"; +if ($DB) {echo "|$stmt|\n";} +$rights_rslt=mysql_to_mysqli($rights_stmt, $link); +$rights_row=mysqli_fetch_row($rights_rslt); +$modify_leads = $rights_row[0]; +$qc_enabled = $rights_row[1]; +$qc_user_level = $rights_row[2]; + +if ( $qc_enabled < 1 ) + { + header ("Content-type: text/html; charset=utf-8"); + echo "QC is not enabled for your user account\n"; + exit; + } +if ( $qc_user_level < 1 ) + { + header ("Content-type: text/html; charset=utf-8"); + echo "QC user level is too low\n"; + exit; + } + +$label_title = 'Title'; +$label_first_name = 'First'; +$label_middle_initial = 'MI'; +$label_last_name = 'Last'; +$label_address1 = 'Address1'; +$label_address2 = 'Address2'; +$label_address3 = 'Address3'; +$label_city = 'City'; +$label_state = 'State'; +$label_province = 'Province'; +$label_postal_code = 'Postal Code'; +$label_vendor_lead_code = 'Vendor ID'; +$label_gender = 'Gender'; +$label_phone_number = 'Phone'; +$label_phone_code = 'DialCode'; +$label_alt_phone = 'Alt. Phone'; +$label_security_phrase = 'Show'; +$label_email = 'Email'; +$label_comments = 'Comments'; + +### find any custom field labels +$stmt="SELECT label_title,label_first_name,label_middle_initial,label_last_name,label_address1,label_address2,label_address3,label_city,label_state,label_province,label_postal_code,label_vendor_lead_code,label_gender,label_phone_number,label_phone_code,label_alt_phone,label_security_phrase,label_email,label_comments from system_settings;"; +$rslt=mysql_to_mysqli($stmt, $link); +$row=mysqli_fetch_row($rslt); +if (strlen($row[0])>0) {$label_title = $row[0];} +if (strlen($row[1])>0) {$label_first_name = $row[1];} +if (strlen($row[2])>0) {$label_middle_initial = $row[2];} +if (strlen($row[3])>0) {$label_last_name = $row[3];} +if (strlen($row[4])>0) {$label_address1 = $row[4];} +if (strlen($row[5])>0) {$label_address2 = $row[5];} +if (strlen($row[6])>0) {$label_address3 = $row[6];} +if (strlen($row[7])>0) {$label_city = $row[7];} +if (strlen($row[8])>0) {$label_state = $row[8];} +if (strlen($row[9])>0) {$label_province = $row[9];} +if (strlen($row[10])>0) {$label_postal_code = $row[10];} +if (strlen($row[11])>0) {$label_vendor_lead_code = $row[11];} +if (strlen($row[12])>0) {$label_gender = $row[12];} +if (strlen($row[13])>0) {$label_phone_number = $row[13];} +if (strlen($row[14])>0) {$label_phone_code = $row[14];} +if (strlen($row[15])>0) {$label_alt_phone = $row[15];} +if (strlen($row[16])>0) {$label_security_phrase = $row[16];} +if (strlen($row[17])>0) {$label_email = $row[17];} +if (strlen($row[18])>0) {$label_comments = $row[18];} + +//Is logged in admin user also logged in as an agent? +function is_user_logged_in($user) + { + global $link; + $stmt="select status from vicidial_live_agents where user='$user'"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $live_agent_count = mysqli_num_rows($rslt); + if($live_agent_count != '1') + { + if($live_agent_count == '0') + { + return "Cannot call prospect. You are not logged in as $user."; + } + else + { + return "Cannot call prospect. $live_agent_count agents logged in as $user."; + } + } + $row=mysqli_fetch_row($rslt); + $status = $row[0]; + if($status!='PAUSED') + { + return "Status must be paused to call lead. $user is presently in $status status."; + } +//@TODO: check user is in the correct CAMPAIGN for this lead. + return true; + } + +$qc_user_logged_in=is_user_logged_in($PHP_AUTH_USER); +if ($qc_user_logged_in===true) + { + echo "Call Lead"; + } +else + { + echo "$qc_user_logged_in"; + } +echo " Refresh"; + +?> diff --git a/www/vicidial/qc_modify_lead.php b/www/vicidial/qc_modify_lead.php new file mode 100644 index 00000000..dc69fcb3 --- /dev/null +++ b/www/vicidial/qc_modify_lead.php @@ -0,0 +1,1334 @@ + LICENSE: AGPLv2 +# +# This script is designed to allow QC review and modification of leads, contributed by poundteam.com +# +# changes: +# 121116-1324 - First build, added to vicidial codebase +# 121130-1034 - Changed scheduled callback user ID field to be 20 characters, issue #467 +# 130621-2328 - Finalized changing of all ereg instances to preg +# - Added filtering of input to prevent SQL injection attacks and new user auth +# 130902-0904 - Changed to mysqli PHP functions, fixes for issue #699 +# 140706-0837 - Incorporated into standard admin code +# + +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["vendor_id"])) {$vendor_id=$_GET["vendor_id"];} + elseif (isset($_POST["vendor_id"])) {$vendor_id=$_POST["vendor_id"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["old_phone"])) {$old_phone=$_GET["old_phone"];} + elseif (isset($_POST["old_phone"])) {$old_phone=$_POST["old_phone"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["title"])) {$title=$_GET["title"];} + elseif (isset($_POST["title"])) {$title=$_POST["title"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["middle_initial"])) {$middle_initial=$_GET["middle_initial"];} + elseif (isset($_POST["middle_initial"])) {$middle_initial=$_POST["middle_initial"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["lead_name"])) {$lead_name=$_GET["lead_name"];} + elseif (isset($_POST["lead_name"])) {$lead_name=$_POST["lead_name"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["end_call"])) {$end_call=$_GET["end_call"];} + elseif (isset($_POST["end_call"])) {$end_call=$_POST["end_call"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["dispo"])) {$dispo=$_GET["dispo"];} + elseif (isset($_POST["dispo"])) {$dispo=$_POST["dispo"];} +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["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["call_began"])) {$call_began=$_GET["call_began"];} + elseif (isset($_POST["call_began"])) {$call_began=$_POST["call_began"];} +if (isset($_GET["parked_time"])) {$parked_time=$_GET["parked_time"];} + elseif (isset($_POST["parked_time"])) {$parked_time=$_POST["parked_time"];} +if (isset($_GET["tsr"])) {$tsr=$_GET["tsr"];} + elseif (isset($_POST["tsr"])) {$tsr=$_POST["tsr"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security"])) {$security=$_GET["security"];} + elseif (isset($_POST["security"])) {$security=$_POST["security"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["rank"])) {$rank=$_GET["rank"];} + elseif (isset($_POST["rank"])) {$rank=$_POST["rank"];} +if (isset($_GET["owner"])) {$owner=$_GET["owner"];} + elseif (isset($_POST["owner"])) {$owner=$_POST["owner"];} +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["CBchangeUSERtoANY"])) {$CBchangeUSERtoANY=$_GET["CBchangeUSERtoANY"];} + elseif (isset($_POST["CBchangeUSERtoANY"])) {$CBchangeUSERtoANY=$_POST["CBchangeUSERtoANY"];} +if (isset($_GET["CBchangeUSERtoUSER"])) {$CBchangeUSERtoUSER=$_GET["CBchangeUSERtoUSER"];} + elseif (isset($_POST["CBchangeUSERtoUSER"])) {$CBchangeUSERtoUSER=$_POST["CBchangeUSERtoUSER"];} +if (isset($_GET["CBchangeANYtoUSER"])) {$CBchangeANYtoUSER=$_GET["CBchangeANYtoUSER"];} + elseif (isset($_POST["CBchangeANYtoUSER"])) {$CBchangeANYtoUSER=$_POST["CBchangeANYtoUSER"];} +if (isset($_GET["CBchangeDATE"])) {$CBchangeDATE=$_GET["CBchangeDATE"];} + elseif (isset($_POST["CBchangeDATE"])) {$CBchangeDATE=$_POST["CBchangeDATE"];} +if (isset($_GET["callback_id"])) {$callback_id=$_GET["callback_id"];} + elseif (isset($_POST["callback_id"])) {$callback_id=$_POST["callback_id"];} +if (isset($_GET["CBuser"])) {$CBuser=$_GET["CBuser"];} + elseif (isset($_POST["CBuser"])) {$CBuser=$_POST["CBuser"];} +if (isset($_GET["modify_logs"])) {$modify_logs=$_GET["modify_logs"];} + elseif (isset($_POST["modify_logs"])) {$modify_logs=$_POST["modify_logs"];} +if (isset($_GET["modify_closer_logs"])) {$modify_closer_logs=$_GET["modify_closer_logs"];} + elseif (isset($_POST["modify_closer_logs"])) {$modify_closer_logs=$_POST["modify_closer_logs"];} +if (isset($_GET["modify_agent_logs"])) {$modify_agent_logs=$_GET["modify_agent_logs"];} + elseif (isset($_POST["modify_agent_logs"])) {$modify_agent_logs=$_POST["modify_agent_logs"];} +if (isset($_GET["add_closer_record"])) {$add_closer_record=$_GET["add_closer_record"];} + elseif (isset($_POST["add_closer_record"])) {$add_closer_record=$_POST["add_closer_record"];} +if (isset($_POST["appointment_date"])) {$appointment_date=$_POST["appointment_date"];} + elseif (isset($_GET["appointment_date"])) {$appointment_date=$_GET["appointment_date"];} +if (isset($_POST["appointment_time"])) {$appointment_time=$_POST["appointment_time"];} + elseif (isset($_GET["appointment_time"])) {$appointment_time=$_GET["appointment_time"];} + +$STARTtime = date("U"); +$defaultappointment = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,custom_fields_enabled 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]; + $custom_fields_enabled = $row[1]; + } +##### 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); + + $old_phone = preg_replace('/[^0-9]/','',$old_phone); + $phone_number = preg_replace('/[^0-9]/','',$phone_number); + $alt_phone = preg_replace('/[^0-9]/','',$alt_phone); + } # end of non_latin +else + { + $PHP_AUTH_USER = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_USER); + $PHP_AUTH_PW = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_PW); + } + +if (strlen($phone_number)<6) {$phone_number=$old_phone;} + +$auth=0; +$auth_message = user_authorization($PHP_AUTH_USER,$PHP_AUTH_PW,'QC',1); +if ($auth_message == 'GOOD') + {$auth=1;} + +if ($auth < 1) + { + $VDdisplayMESSAGE = "Login incorrect, please try again"; + if ($auth_message == 'LOCK') + { + $VDdisplayMESSAGE = "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; + } + +$rights_stmt = "SELECT modify_leads,qc_enabled from vicidial_users where user='$PHP_AUTH_USER';"; +if ($DB) {echo "|$stmt|\n";} +$rights_rslt=mysql_to_mysqli($rights_stmt, $link); +$rights_row=mysqli_fetch_row($rights_rslt); +$modify_leads = $rights_row[0]; +$qc_enabled = $rights_row[1]; + +# check their permissions +#if ( $modify_leads < 1 ) +# { +# header ("Content-type: text/html; charset=utf-8"); +# echo "You do not have permissions to modify leads\n"; +# exit; +# } +if ( $qc_enabled < 1 ) + { + header ("Content-type: text/html; charset=utf-8"); + echo "QC is not enabled for your user account\n"; + exit; + } + +$stmt="SELECT full_name,modify_leads,user_group from vicidial_users where user='$PHP_AUTH_USER';"; +$rslt=mysql_to_mysqli($stmt, $link); +$row=mysqli_fetch_row($rslt); +$LOGfullname =$row[0]; +$LOGmodify_leads =$row[1]; +$LOGuser_group =$row[2]; + +$label_title = 'Title'; +$label_first_name = 'First'; +$label_middle_initial = 'MI'; +$label_last_name = 'Last'; +$label_address1 = 'Address1'; +$label_address2 = 'Address2'; +$label_address3 = 'Address3'; +$label_city = 'City'; +$label_state = 'State'; +$label_province = 'Province'; +$label_postal_code = 'Postal Code'; +$label_vendor_lead_code = 'Vendor ID'; +$label_gender = 'Gender'; +$label_phone_number = 'Phone'; +$label_phone_code = 'DialCode'; +$label_alt_phone = 'Alt. Phone'; +$label_security_phrase = 'Show'; +$label_email = 'Email'; +$label_comments = 'Comments'; + +### find any custom field labels +$stmt="SELECT label_title,label_first_name,label_middle_initial,label_last_name,label_address1,label_address2,label_address3,label_city,label_state,label_province,label_postal_code,label_vendor_lead_code,label_gender,label_phone_number,label_phone_code,label_alt_phone,label_security_phrase,label_email,label_comments from system_settings;"; +$rslt=mysql_to_mysqli($stmt, $link); +$row=mysqli_fetch_row($rslt); +if (strlen($row[0])>0) {$label_title = $row[0];} +if (strlen($row[1])>0) {$label_first_name = $row[1];} +if (strlen($row[2])>0) {$label_middle_initial = $row[2];} +if (strlen($row[3])>0) {$label_last_name = $row[3];} +if (strlen($row[4])>0) {$label_address1 = $row[4];} +if (strlen($row[5])>0) {$label_address2 = $row[5];} +if (strlen($row[6])>0) {$label_address3 = $row[6];} +if (strlen($row[7])>0) {$label_city = $row[7];} +if (strlen($row[8])>0) {$label_state = $row[8];} +if (strlen($row[9])>0) {$label_province = $row[9];} +if (strlen($row[10])>0) {$label_postal_code = $row[10];} +if (strlen($row[11])>0) {$label_vendor_lead_code = $row[11];} +if (strlen($row[12])>0) {$label_gender = $row[12];} +if (strlen($row[13])>0) {$label_phone_number = $row[13];} +if (strlen($row[14])>0) {$label_phone_code = $row[14];} +if (strlen($row[15])>0) {$label_alt_phone = $row[15];} +if (strlen($row[16])>0) {$label_security_phrase = $row[16];} +if (strlen($row[17])>0) {$label_email = $row[17];} +if (strlen($row[18])>0) {$label_comments = $row[18];} + + +//Added by Poundteam for QC. Gather record data to display on page and prepopulate title and hrefs, etc. +$stmt="SELECT * from vicidial_list A inner join vicidial_lists B on A.list_id=B.list_id inner join vicidial_campaigns C on B.campaign_id=C.campaign_id left outer join vicidial_statuses D on A.status=D.status left outer join vicidial_qc_codes E on A.status=E.code where A.lead_id='$lead_id'"; +$rslt=mysql_to_mysqli($stmt, $link); +if (mysqli_num_rows ($rslt) < '1' ) + { + if($DB) { echo "$stmt\n"; } + exit(); + } +$row=mysqli_fetch_assoc($rslt); +$original_record = $row; +$campaign_id = $row['campaign_id']; +$campaign_name = $row['campaign_name']; +$phone_number = $row['phone_number']; +$phone_code = $row['phone_code']; +$lead_name = trim(trim($row['first_name'].' '.$row['middle_initial']).' '.$row['last_name']); +$scheduled_callback = $row['scheduled_callback']; + +?> + + + +QC Modify Lead: <?php echo "$lead_id - ".urldecode($lead_name).urldecode(" (Campaign: $campaign_id - $campaign_name)"); ?> + + + + + +QC CAMPAIGN $campaign_id: Lead $lead_id - ".urldecode($lead_name)."
\n"; +//end_call is set by submit button to denote "save", without it this is a VIEW, with it this is a SAVE +if ($end_call > 0) + { + if($DB) { echo __LINE__."\n"; } + ### update the lead record in the vicidial_list table + $stmt="UPDATE vicidial_list set status='" . mysqli_real_escape_string($link, $status) . "',title='" . mysqli_real_escape_string($link, $title) . "',first_name='" . mysqli_real_escape_string($link, $first_name) . "',middle_initial='" . mysqli_real_escape_string($link, $middle_initial) . "',last_name='" . mysqli_real_escape_string($link, $last_name) . "',address1='" . mysqli_real_escape_string($link, $address1) . "',address2='" . mysqli_real_escape_string($link, $address2) . "',address3='" . mysqli_real_escape_string($link, $address3) . "',city='" . mysqli_real_escape_string($link, $city) . "',state='" . mysqli_real_escape_string($link, $state) . "',province='" . mysqli_real_escape_string($link, $province) . "',postal_code='" . mysqli_real_escape_string($link, $postal_code) . "',country_code='" . mysqli_real_escape_string($link, $country_code) . "',alt_phone='" . mysqli_real_escape_string($link, $alt_phone) . "',phone_number='$phone_number',phone_code='$phone_code',email='" . mysqli_real_escape_string($link, $email) . "',security_phrase='" . mysqli_real_escape_string($link, $security) . "',comments='" . mysqli_real_escape_string($link, $comments) . "',rank='" . mysqli_real_escape_string($link, $rank) . "',owner='" . mysqli_real_escape_string($link, $owner) . "' where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "'"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + //STATUS just changed, re-capture all data for client! + //Added by Poundteam for QC. Gather record data to display on page and prepopulate title and hrefs, etc. + $stmt="SELECT * from vicidial_list A inner join vicidial_lists B on A.list_id=B.list_id inner join vicidial_campaigns C on B.campaign_id=C.campaign_id left outer join vicidial_statuses D on A.status=D.status left outer join vicidial_qc_codes E on A.status=E.code where A.lead_id='$lead_id'"; + if($DB) { echo "$stmt\n"; } + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_assoc($rslt); + //QUALITY CONTROL CHANGE LOG BEGIN - CHANGE VERSION (VIEW VERSION IS BELOW, WHICH CREATES THE RECORD, THIS ONE MERELY MODIFIES THE EXISTING RECORD) + $new_record=$row; + //if status has changed, the join query above will have the "status" field of "vicidial_list" overwritten by the status field of "vicidial_statuses" ... which will be EMPTY if there is no matching status to the new QC status chosen. This will cause the changelog to be incorrect. + if ( strlen($new_record['status']) == '0' ) + { + $new_record['status']=$new_record['code']; + } + + if($original_record != $new_record) + { + //Information changed: Find out what and record it, first disable "view" logging + $qcchange='Y'; + $qcchangelist=''; + $qcchangecounter=0; + foreach($original_record as $key=>$value) + { + //only list the changes in the first 35 fiels, those are from the vicidial_list table (the rest are from joined tables, and the changes cascade) + if(($new_record[$key]!=$value)&&($qcchangecounter<=35)) $qcchangelist.="----$key----\n$value => $new_record[$key]\n"; + $qcchangecounter++; + } + ### insert a NEW record to the vicidial_closer_log table + $qcchangelist=mysqli_real_escape_string($link, $qcchangelist); + $view_epoch = preg_replace('/[^0-9]/','',$_POST['viewtime']); + $elapsed_seconds=$STARTtime-$view_epoch; + + $stmt="UPDATE vicidial_qc_agent_log set save_datetime='$NOW_TIME',save_epoch='$STARTtime',elapsed_seconds='$elapsed_seconds',old_status='{$original_record['status']}',new_status='{$new_record['status']}',details='$qcchangelist' + where view_epoch='$view_epoch' and lead_id='$lead_id'"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + } + //QUALITY CONTROL CHANGE LOG END + $original_sales_rep = $row['user']; + $campaign_id = $row['campaign_id']; + $campaign_name = $row['campaign_name']; + $lead_name = trim(trim($row['first_name'].' '.$row['middle_initial']).' '.$row['last_name']); + $scheduled_callback = $row['scheduled_callback']; + + echo "
information modified

\n"; + echo "Go back to re-modify this QC lead


\n"; + echo "
Proceed to QC CAMPAIGN $campaign_id Queue

Callback Information:\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='$PHP_AUTH_USER', ip_address='$ip', event_section='LEADS', event_type='MODIFY', record_id='$lead_id', event_code='ADMIN MODIFY LEAD', event_sql=\"$SQL_log\", event_notes='';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if($DB) + { + echo __LINE__."\n"; + } + + if ( ($dispo != $status) and ($dispo == 'CBHOLD') ) + { + if($DB) + { + echo __LINE__."\n"; + } + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "' and status='ACTIVE';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + + echo "
vicidial_callback record inactivated: $lead_id
\n"; + } + //Duped CBHOLD version for vicidial status type 'Scheduled Callback' + if ( ($dispo != $status) and ($scheduled_callback == 'Y') ) + { + if($DB) + { + echo __LINE__."\n"; + } + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "' and status='ACTIVE';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + + echo "
vicidial_callback record inactivated: $lead_id
\n"; + } + if ( ($dispo != $status) and ($dispo == 'CALLBK') ) + { + if($DB) + { + echo __LINE__."\n"; + } + ### inactivate vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "' and status IN('ACTIVE','LIVE');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + + echo "
vicidial_callback record inactivated: $lead_id
\n"; + } + + if ( ($dispo != $status) and ($status == 'CBHOLD') ) + { + if($DB) + { + echo __LINE__."\n"; + } + ### find any vicidial_callback records for this lead + $stmt="select callback_id from vicidial_callbacks where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "' and status IN('ACTIVE','LIVE') order by callback_id desc LIMIT 1;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $CBM_to_print = mysqli_num_rows($rslt); + if ($CBM_to_print > 0) + { + $rowx=mysqli_fetch_row($rslt); + $callback_id = $rowx[0]; + } + else + { + $defaultappointment = date("Y-m-d H:i:s", mktime(date("H"),date("i"),date("s"),date("m"),date("d"),date("Y"))); + + $stmt="INSERT INTO vicidial_callbacks SET lead_id='" . mysqli_real_escape_string($link, $lead_id) . "',recipient='ANYONE',status='ACTIVE',user='$PHP_AUTH_USER',user_group='ADMIN',list_id='" . mysqli_real_escape_string($link, $list_id) . "',callback_time='$defaultappointment 12:00:00',entry_time='$NOW_TIME',comments='',campaign_id='" . mysqli_real_escape_string($link, $campaign_id) . "';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + + echo "
Scheduled Callback added: $lead_id - $phone_number
\n"; + } + } + + //Duped CBHOLD version for vicidial status type 'Scheduled Callback' + //This entry creates the callback + if ( ($dispo != $status) and ($scheduled_callback == 'Y') ) + { + if($DB) + { + echo __LINE__."\n"; + } + ### find any vicidial_callback records for this lead + $stmt="select callback_id from vicidial_callbacks where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "' and status IN('ACTIVE','LIVE') order by callback_id desc LIMIT 1;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $CBM_to_print = mysqli_num_rows($rslt); + if ($CBM_to_print > 0) + { + $rowx=mysqli_fetch_row($rslt); + $callback_id = $rowx[0]; + } + else + { + $defaultappointment = date("Y-m-d H:i:s", mktime(date("H"),date("i"),date("s"),date("m"),date("d"),date("Y"))); + + $stmt="INSERT INTO vicidial_callbacks SET lead_id='" . mysqli_real_escape_string($link, $lead_id) . "',recipient='USERONLY',status='ACTIVE',user='$original_sales_rep',user_group='ADMIN',list_id='" . mysqli_real_escape_string($link, $list_id) . "',callback_time='$defaultappointment 12:00:00',entry_time='$NOW_TIME',comments='',campaign_id='" . mysqli_real_escape_string($link, $campaign_id) . "';"; + $debug1=$stmt; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + + echo "
Scheduled Callback added: $lead_id - $phone_number
\n"; + } + } + + + if ( ($dispo != $status) and ($status == 'DNC') ) + { + if($DB) + { + echo __LINE__."\n"; + } + ### add lead to the internal DNC list + $stmt="INSERT INTO vicidial_dnc (phone_number) values('" . mysqli_real_escape_string($link, $phone_number) . "');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + + echo "
Lead added to DNC List: $lead_id - $phone_number
\n"; + } + ### update last record in vicidial_log table + if (($dispo != $status) and ($modify_logs > 0)) + { + if($DB) + { + echo __LINE__."\n"; + } + $stmt="UPDATE vicidial_log set status='" . mysqli_real_escape_string($link, $status) . "' where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "' order by call_date desc limit 1"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + } + + ### update last record in vicidial_closer_log table + if (($dispo != $status) and ($modify_closer_logs > 0)) + { + if($DB) + { + echo __LINE__."\n"; + } + $stmt="UPDATE vicidial_closer_log set status='" . mysqli_real_escape_string($link, $status) . "' where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "' order by call_date desc limit 1"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + } + + ### update last record in vicidial_agent_log table + if (($dispo != $status) and ($modify_agent_logs > 0)) + { + if($DB) + { + echo __LINE__."\n"; + } + $stmt="UPDATE vicidial_agent_log set status='" . mysqli_real_escape_string($link, $status) . "' where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "' order by agent_log_id desc limit 1"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + } + + if ($add_closer_record > 0) + { + if($DB) echo __LINE__."\n"; + ### insert a NEW record to the vicidial_closer_log table + $stmt="INSERT INTO vicidial_closer_log (lead_id,list_id,campaign_id,call_date,start_epoch,end_epoch,length_in_sec,status,phone_code,phone_number,user,comments,processed) values('" . mysqli_real_escape_string($link, $lead_id) . "','" . mysqli_real_escape_string($link, $list_id) . "','" . mysqli_real_escape_string($link, $campaign_id) . "','" . mysqli_real_escape_string($link, $parked_time) . "','$NOW_TIME','$STARTtime','1','" . mysqli_real_escape_string($link, $status) . "','" . mysqli_real_escape_string($link, $phone_code) . "','" . mysqli_real_escape_string($link, $phone_number) . "','$PHP_AUTH_USER','" . mysqli_real_escape_string($link, $comments) . "','Y')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + } + } +else + { + echo "\n"; + //Not a "Submit" result, viewing the record (possibly with URL options such as those below which modify callback status but not record data) + if ($CBchangeUSERtoANY == 'YES') + { + if($DB) echo __LINE__."\n"; + ### set vicidial_callbacks record to an ANYONE callback for this lead + $stmt="UPDATE vicidial_callbacks set recipient='ANYONE' where callback_id='" . mysqli_real_escape_string($link, $callback_id) . "';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + echo "
vicidial_callback record changed to ANYONE
\n"; + $qcchange='Y'; + } + if ($CBchangeUSERtoUSER == 'YES') + { + if($DB) echo __LINE__."\n"; + ### set vicidial_callbacks record to a different USERONLY callback record for this lead + $stmt="UPDATE vicidial_callbacks set user='" . mysqli_real_escape_string($link, $CBuser) . "' where callback_id='" . mysqli_real_escape_string($link, $callback_id) . "';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + echo "
vicidial_callback record user changed to $CBuser
\n"; + $qcchange='Y'; + } + if ($CBchangeANYtoUSER == 'YES') + { + if($DB) echo __LINE__."\n"; + ### set vicidial_callbacks record to an USERONLY callback for this lead + $stmt="UPDATE vicidial_callbacks set user='" . mysqli_real_escape_string($link, $CBuser) . "',recipient='USERONLY' where callback_id='" . mysqli_real_escape_string($link, $callback_id) . "';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + echo "
vicidial_callback record changed to USERONLY, user: $CBuser
\n"; + $qcchange='Y'; + } + if ($CBchangeDATE == 'YES') + { + if($DB) echo __LINE__."\n"; + ### change date/time of vicidial_callbacks record for this lead + $stmt="UPDATE vicidial_callbacks set callback_time='" . mysqli_real_escape_string($link, $appointment_date) . " " . mysqli_real_escape_string($link, $appointment_time) . "',comments='" . mysqli_real_escape_string($link, $comments) . "' where callback_id='" . mysqli_real_escape_string($link, $callback_id) . "';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + echo "
vicidial_callback record changed to $appointment_date $appointment_time
\n"; + $qcchange='Y'; + } + //QUALITY CONTROL LOGGING BEGIN - VIEW ONLY + //If no changes have been made, record "view" of this record. + if ($qcchange != 'Y') + { + if($DB) echo __LINE__."\n QCCHANGE != Y"; + ### insert a NEW record to the vicidial_closer_log table + $stmt="INSERT INTO vicidial_qc_agent_log (qc_user,qc_user_group,qc_user_ip,lead_user,web_server_ip,view_datetime,view_epoch,lead_id,list_id,campaign_id,processed) + values('" . mysqli_real_escape_string($link, $PHP_AUTH_USER) . "','$LOGuser_group','{$_SERVER['REMOTE_ADDR']}','{$original_record['user']}','{$_SERVER['SERVER_ADDR']}','$NOW_TIME','$STARTtime','" . mysqli_real_escape_string($link, $lead_id) . "','" . mysqli_real_escape_string($link, $original_record['list_id']) . "','" . mysqli_real_escape_string($link, $campaign_id) . "','N')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + } + //QUALITY CONTROL LOGGING END + if($DB) echo __LINE__."\n"; + $stmt="SELECT count(*) from vicidial_list where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "'"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysqli_fetch_row($rslt); + $lead_count = $row[0]; + + if ($lead_count > 0) + { + if($DB) echo __LINE__."\n"; + ##### grab vicidial_list_alt_phones records ##### + $stmt="select phone_code,phone_number,alt_phone_note,alt_phone_count,active from vicidial_list_alt_phones where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "' order by alt_phone_count limit 500;"; + $rslt=mysql_to_mysqli($stmt, $link); + $alts_to_print = mysqli_num_rows($rslt); + + $c=0; + $alts_output = ''; + while ($alts_to_print > $c) + { + if($DB) + { + echo __LINE__."\n"; + } + $row=mysqli_fetch_row($rslt); + if (preg_match("/1$|3$|5$|7$|9$/i", $c)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $c++; + $alts_output .= "
$c$row[0] $row[1] $row[2] $row[3] $row[4]
$u$row[4] $row[7] $row[8] $row[11] $row[3] $row[2] $row[1] $row[15]   $row[10]
$y$row[3] $row[5] $row[1] $row[7] $row[9] $row[11] $row[13]   $row[14]   $row[15]   $row[17]
$y{$row['view_datetime']}View Only - No changes{$row['qc_user']}{$row['lead_user']}{$row['campaign_id']}{$row['list_id']}  
$y{$row['view_datetime']}{$row['old_status']}{$row['new_status']}{$row['qc_user']}{$row['lead_user']}{$row['campaign_id']}{$row['list_id']}{$row['elapsed_seconds']} DETAILS
$y$row[4] $row[7] $row[8] $row[11] $row[3] $row[2] $row[1]   $row[14]   $row[17]
\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $stmt="SELECT user_id, timestamp, list_id, campaign_id, comment from vicidial_comments where lead_id='$lead_id' order by timestamp"; + $rslt=mysql_to_mysqli($stmt, $link); + $row_count = mysqli_num_rows($rslt); + $o=0; + $comments=false; + while ($row_count > $o) + { + if (!$comments) + { + echo "\n"; + $comments=true; + } + $rowx=mysqli_fetch_row($rslt); + echo "\n"; + $o++; + } + + if ($comments) + { + echo "\n"; + } + echo "\n"; + +// Section Modified for QC Functionality By PoundTeam +// echo "\n"; +// echo "\n"; +// echo "\n"; + echo "\n"; + + echo "\n"; + echo "
$label_vendor_lead_code: $vendor_id     Lead ID: $lead_id
Fronter: $tsr     List ID: $list_id     Called Count: $called_count
$label_title:   \n"; + echo "$label_first_name:
$label_middle_initial:   \n"; + echo " $label_last_name:
$label_address1 :
$label_address2 :
$label_address3 :
$label_city :
$label_state:   \n"; + echo " $label_postal_code:
$label_province :
Country :
$label_phone_number :
$label_phone_code :
$label_alt_phone :
$label_email :
$label_security_phrase :
Rank :
Owner :
$label_comments :
Comment History
$rowx[0] :
$rowx[1]
List ID: $rowx[2]; Campaign ID: $rowx[3]
$rowx[4]

QC Result: (with $list_campaign statuses)
Modify vicidial log
Modify agent log
Modify closer log
Disable QC log entry (this feature is not active yet)
\n"; + echo "


\n"; + + echo "
\n"; + echo "Callback Details:
\n"; + //Added scheduled_callback regular statuses option + if ( ($dispo == 'CALLBK') or ($dispo == 'CBHOLD') || $scheduled_callback=='Y' ) + { + if($DB) + { + echo __LINE__."\n"; + } + ### find any vicidial_callback records for this lead + $stmt="select callback_id,lead_id,list_id,campaign_id,status,entry_time,callback_time,modify_date,user,recipient,comments,user_group from vicidial_callbacks where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "' and status IN('ACTIVE','LIVE') order by callback_id desc LIMIT 1;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $CB_to_print = mysqli_num_rows($rslt); + $rowx=mysqli_fetch_row($rslt); + + if ($CB_to_print>0) + { + if ($rowx[9] == 'USERONLY') + { + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

\n"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "New Callback Owner UserID: \n"; + echo "

\n"; + } + else + { + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "New Callback Owner UserID: \n"; + echo "

\n"; + } + + $appointment_datetimeARRAY = explode(" ",$rowx[6]); + $appointment_date = $appointment_datetimeARRAY[0]; + $appointment_timeARRAY = explode(":",$appointment_datetimeARRAY[1]); + $appointment_hour = $appointment_timeARRAY[0]; + $appointment_min = $appointment_timeARRAY[1]; + + ?> + +
+
Change Scheduled Callback Date:
+ + + + + + + + + + + + + +
+ > + + + + +
CallBack Date/Time: + + +     + + : + + +
+ Comments: + + +
+ + + + +
+
+ + No Callback records found
\n"; + } + } + else + { + if($DB) + { + echo __LINE__."\n"; + } + //Modifed text to allow for other than CBHOLD via custom statuses with scheduled callback chosen + echo "
If you want to change this lead to a scheduled callback, first change the Disposition to CBHOLD or similar, then submit and you will be able to set the callback date and time.
\n"; + } + echo "
\n"; + + echo "

\n"; + + echo "
\n"; + + if ($c > 0) + { + if($DB) + { + echo __LINE__."\n"; + } + echo "EXTENDED ALTERNATE PHONE NUMBERS FOR THIS LEAD:\n"; + echo "\n"; + echo "\n"; + + echo "$alts_output\n"; + + echo "
# ALT PHONE ALT NOTE ALT COUNT ACTIVE
\n"; + echo "

\n"; + } + + + + ### iframe for custom fields display/editing + if ($custom_fields_enabled > 0) + { + $CLlist_id = $list_id; + if (strlen($entry_list_id) > 2) + {$CLlist_id = $entry_list_id;} + $stmt="SHOW TABLES LIKE \"custom_$CLlist_id\";"; + if ($DB>0) {echo "$stmt";} + $rslt=mysql_to_mysqli($stmt, $link); + $tablecount_to_print = mysqli_num_rows($rslt); + if ($tablecount_to_print > 0) + { + $stmt="SELECT count(*) from custom_$CLlist_id where lead_id='$lead_id';"; + if ($DB>0) {echo "$stmt";} + $rslt=mysql_to_mysqli($stmt, $link); + $fieldscount_to_print = mysqli_num_rows($rslt); + if ($fieldscount_to_print > 0) + { + $rowx=mysqli_fetch_row($rslt); + $custom_records_count = $rowx[0]; + + echo "CUSTOM FIELDS FOR THIS LEAD:
\n"; + echo "\n"; + echo "

"; + } + } + } + + + echo "CALLS TO THIS LEAD:\n"; + echo "\n"; + echo "\n"; + + echo "$call_log\n"; + + echo "
# DATE/TIME LENGTH STATUS TSR CAMPAIGN LIST LEAD HANGUP REASON PHONE
\n"; + echo "

\n"; + + echo "CLOSER RECORDS FOR THIS LEAD:\n"; + echo "\n"; + echo "\n"; + + echo "$closer_log\n"; + + echo "
# DATE/TIME LENGTH STATUS TSR CAMPAIGN LIST LEAD WAIT HANGUP REASON
\n"; + echo "

\n"; + + + echo "AGENT LOG RECORDS FOR THIS LEAD:\n"; + echo "\n"; + echo "\n"; + + echo "$agent_log\n"; + echo "
# DATE/TIME CAMPAIGN TSR PAUSE WAIT TALK DISPO STATUS GROUP SUB
\n"; + echo "

\n"; + echo "QUALITY CONTROL LOG RECORDS FOR THIS LEAD:\n"; + echo "\n"; + echo "\n"; + echo "$qc_agent_log\n"; + echo "
# DATE/TIME OLD STATUSNEW STATUSQC USERAGENTCAMPAIGNLISTELAPSED 
\n"; + echo "

\n"; + + echo "RECORDINGS FOR THIS LEAD:\n"; + echo "\n"; + echo "\n"; + + $stmt="select recording_id,channel,server_ip,extension,start_time,start_epoch,end_time,end_epoch,length_in_sec,length_in_min,filename,location,lead_id,user,vicidial_id from recording_log where lead_id='" . mysqli_real_escape_string($link, $lead_id) . "' order by recording_id desc limit 500;"; + $rslt=mysql_to_mysqli($stmt, $link); + $logs_to_print = mysqli_num_rows($rslt); + if ($DB) {echo "$logs_to_print|$stmt|\n";} + + $u=0; + while ($logs_to_print > $u) + { + $row=mysqli_fetch_row($rslt); + if (preg_match("/1$|3$|5$|7$|9$/i", $u)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + + $location = $row[11]; + + if (strlen($location)>2) + { + $URLserver_ip = $location; + $URLserver_ip = preg_replace('/http:\/\//i', '',$URLserver_ip); + $URLserver_ip = preg_replace('/https:\/\//i', '',$URLserver_ip); + $URLserver_ip = preg_replace('/\/.*/i', '',$URLserver_ip); + $stmt="select count(*) from servers where server_ip='$URLserver_ip';"; + $rsltx=mysql_to_mysqli($stmt, $link); + $rowx=mysqli_fetch_row($rsltx); + + if ($rowx[0] > 0) + { + $stmt="select recording_web_link,alt_server_ip from servers where server_ip='$URLserver_ip';"; + $rsltx=mysql_to_mysqli($stmt, $link); + $rowx=mysqli_fetch_row($rsltx); + + if (preg_match("/ALT_IP/i",$rowx[0])) + { + $location = preg_replace("/$URLserver_ip/i", "$rowx[1]", $location); + } + if (preg_match("/EXTERNAL_IP/i",$rowx[0])) + { + $location = preg_replace("/$URLserver_ip/i", "$rowx[2]", $location); + } + } + } + + if (strlen($location)>30) + {$locat = substr($location,0,27); $locat = "$locat...";} + else + {$locat = $location;} + if ( (preg_match('/ftp/i',$location)) or (preg_match('/http/i',$location)) ) + {$location = "$locat";} + else + {$location = $locat;} + $u++; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + } + + + echo "
# LEADDATE/TIME SECONDS   RECIDFILENAMELOCATIONTSR
$u $row[12] $row[4] $row[8] $row[0]   $row[10] $location $row[13]


\n"; + + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level >= 9 and modify_leads='1';"; + if ($DB) {echo "|$stmt|\n";} + if ($non_latin > 0) {$rslt=mysql_to_mysqli("SET NAMES 'UTF8'", $link);} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $admin_display=$row[0]; + if ($admin_display > 0) + { + echo "Click here to see Lead Modify changes to this lead\n"; + } + + echo "
\n"; + } + + +$ENDtime = date("U"); + +$RUNtime = ($ENDtime - $STARTtime); + +echo "\n\n\n


\n\n"; + + +echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; + + +?> + + + + + +original_record:
"; + print_r($original_record); + echo "
new_record:
"; + print_r($new_record); + echo "scheduled_callback:
"; + print_r($scheduled_callback); + echo "debug1:
"; + print_r($debug1); + echo "Post:
"; + print_r($_POST); + echo "qcchangelist:
"; + print_r($qcchangelist); + echo "
"; + } +exit; + +?>