\n";
echo "\n";
### LOG INSERTION Admin Log Table ###
$SQL_log = "$stmt|";
$SQL_log = ereg_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_query($stmt, $link);
if ( ($dispo != $status) and ($dispo == 'CBHOLD') )
{
### inactivate vicidial_callbacks record for this lead
$stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='" . mysql_real_escape_string($lead_id) . "' and status='ACTIVE';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
echo " vicidial_callback record inactivated: $lead_id \n";
}
if ( ($dispo != $status) and ($dispo == 'CALLBK') )
{
### inactivate vicidial_callbacks record for this lead
$stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='" . mysql_real_escape_string($lead_id) . "' and status IN('ACTIVE','LIVE');";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
echo " vicidial_callback record inactivated: $lead_id \n";
}
if ( ($dispo != $status) and ($status == 'DNC') )
{
### add lead to the internal DNC list
$stmt="INSERT INTO vicidial_dnc (phone_number) values('" . mysql_real_escape_string($phone_number) . "');";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($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))
{
$stmt="UPDATE vicidial_log set status='" . mysql_real_escape_string($status) . "' where lead_id='" . mysql_real_escape_string($lead_id) . "' order by call_date desc limit 1";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
}
### update last record in vicidial_closer_log table
if (($dispo != $status) and ($modify_closer_logs > 0))
{
$stmt="UPDATE vicidial_closer_log set status='" . mysql_real_escape_string($status) . "' where lead_id='" . mysql_real_escape_string($lead_id) . "' order by call_date desc limit 1";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
}
### update last record in vicidial_agent_log table
if (($dispo != $status) and ($modify_agent_logs > 0))
{
$stmt="UPDATE vicidial_agent_log set status='" . mysql_real_escape_string($status) . "' where lead_id='" . mysql_real_escape_string($lead_id) . "' order by agent_log_id desc limit 1";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
}
if ($add_closer_record > 0)
{
### 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('" . mysql_real_escape_string($lead_id) . "','" . mysql_real_escape_string($list_id) . "','" . mysql_real_escape_string($campaign_id) . "','" . mysql_real_escape_string($parked_time) . "','$NOW_TIME','$STARTtime','1','" . mysql_real_escape_string($status) . "','" . mysql_real_escape_string($phone_code) . "','" . mysql_real_escape_string($phone_number) . "','$PHP_AUTH_USER','" . mysql_real_escape_string($comments) . "','Y')";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
}
}
else
{
if ($CBchangeUSERtoANY == 'YES')
{
### inactivate vicidial_callbacks record for this lead
$stmt="UPDATE vicidial_callbacks set recipient='ANYONE' where callback_id='" . mysql_real_escape_string($callback_id) . "';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
echo " vicidial_callback record changed to ANYONE \n";
}
if ($CBchangeUSERtoUSER == 'YES')
{
### inactivate vicidial_callbacks record for this lead
$stmt="UPDATE vicidial_callbacks set user='" . mysql_real_escape_string($CBuser) . "' where callback_id='" . mysql_real_escape_string($callback_id) . "';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
echo " vicidial_callback record user changed to $CBuser \n";
}
if ($CBchangeANYtoUSER == 'YES')
{
### inactivate vicidial_callbacks record for this lead
$stmt="UPDATE vicidial_callbacks set user='" . mysql_real_escape_string($CBuser) . "',recipient='USERONLY' where callback_id='" . mysql_real_escape_string($callback_id) . "';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
echo " vicidial_callback record changed to USERONLY, user: $CBuser \n";
}
$stmt="SELECT count(*) from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$lead_count = $row[0];
if ($lead_count > 0)
{
##### 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='" . mysql_real_escape_string($lead_id) . "' order by alt_phone_count limit 500;";
$rslt=mysql_query($stmt, $link);
$alts_to_print = mysql_num_rows($rslt);
$c=0;
$alts_output = '';
while ($alts_to_print > $c)
{
$row=mysql_fetch_row($rslt);
if (eregi("1$|3$|5$|7$|9$", $c))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
$c++;
$alts_output .= "
\n";
if ( ($dispo == 'CALLBK') or ($dispo == 'CBHOLD') )
{
### 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='" . mysql_real_escape_string($lead_id) . "' and status IN('ACTIVE','LIVE') order by callback_id desc LIMIT 1;";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$CB_to_print = mysql_num_rows($rslt);
$rowx=mysql_fetch_row($rslt);
if ($CB_to_print>0)
{
if ($rowx[9] == 'USERONLY')
{
echo "
\n";
echo "
\n";
}
else
{
echo "
\n";
}
}
else
{
echo " No Callback records found \n";
}
}
echo "
\n";
echo "
\n";
if ($c > 0)
{
echo "EXTENDED ALTERNATE PHONE NUMBERS FOR THIS LEAD:\n";
echo "
\n";
echo "
#
ALT PHONE
ALT NOTE
ALT COUNT
ACTIVE
\n";
echo "$alts_output\n";
echo "
\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_query($stmt, $link);
$tablecount_to_print = mysql_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_query($stmt, $link);
$fieldscount_to_print = mysql_num_rows($rslt);
if ($fieldscount_to_print > 0)
{
$rowx=mysql_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 "
#
DATE/TIME
LENGTH
STATUS
TSR
CAMPAIGN
LIST
LEAD
HANGUP REASON
PHONE
\n";
echo "$call_log\n";
echo "
\n";
echo "
\n";
echo "CLOSER RECORDS FOR THIS LEAD:\n";
echo "
\n";
echo "
#
DATE/TIME
LENGTH
STATUS
TSR
CAMPAIGN
LIST
LEAD
WAIT
HANGUP REASON
\n";
echo "$closer_log\n";
echo "
\n";
echo "
\n";
echo "AGENT LOG RECORDS FOR THIS LEAD:\n";
echo "
\n";
echo "
#
DATE/TIME
CAMPAIGN
TSR
PAUSE
WAIT
TALK
DISPO
STATUS
GROUP
SUB
\n";
echo "$agent_log\n";
echo "
\n";
echo "
\n";
echo "RECORDINGS FOR THIS LEAD:\n";
echo "
\n";
echo "
#
LEAD
DATE/TIME
SECONDS
RECID
FILENAME
LOCATION
TSR
\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='" . mysql_real_escape_string($lead_id) . "' order by recording_id desc limit 500;";
$rslt=mysql_query($stmt, $link);
$logs_to_print = mysql_num_rows($rslt);
if ($DB) {echo "$logs_to_print|$stmt|\n";}
$u=0;
while ($logs_to_print > $u)
{
$row=mysql_fetch_row($rslt);
if (eregi("1$|3$|5$|7$|9$", $u))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
$location = $row[11];
if (strlen($location)>2)
{
$URLserver_ip = $location;
$URLserver_ip = eregi_replace('http://','',$URLserver_ip);
$URLserver_ip = eregi_replace('https://','',$URLserver_ip);
$URLserver_ip = eregi_replace("\/.*",'',$URLserver_ip);
$stmt="select count(*) from servers where server_ip='$URLserver_ip';";
$rsltx=mysql_query($stmt, $link);
$rowx=mysql_fetch_row($rsltx);
if ($rowx[0] > 0)
{
$stmt="select recording_web_link,alt_server_ip from servers where server_ip='$URLserver_ip';";
$rsltx=mysql_query($stmt, $link);
$rowx=mysql_fetch_row($rsltx);
if (eregi("ALT_IP",$rowx[0]))
{
$location = eregi_replace($URLserver_ip, $rowx[1], $location);
}
}
}
if (strlen($location)>30)
{$locat = substr($location,0,27); $locat = "$locat...";}
else
{$locat = $location;}
if (eregi("http",$location))
{$location = "$locat";}
else
{$location = $locat;}
$u++;
echo "
\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_query("SET NAMES 'UTF8'");}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$admin_display=$row[0];
if ($admin_display > 0)
{
echo "Click here to see Lead Modify changes to this lead\n";
}
echo "