$dbcnx = @mysql_connect('mysql.plainhost.com', 'ecosmar_ecosmart', 'ecoman1');
mysql_select_db('ecosmar_website', $dbcnx);
$ok = @mysql_query("SELECT first_name,last_name,email FROM psw WHERE usrn='$newrepusrn'");
if (!$ok) {
echo 'Could not retrieve Representative Name: ' . mysql_error();
}
$rowa = mysql_fetch_array($ok);
$newrepname1 = $rowa[0];
$newrepname2 = $rowa[1];
$newrepemail = $rowa[2];
mysql_select_db('ecosmar_contacts', $dbcnx);
$check = @mysql_query("SELECT first_Name,Name,Company,Phone,email FROM con_main WHERE ID='$ID'");
if(!$check){
echo ("
Problems getting Contact Information!
".
'Error:' . mysql_error() . '
');
}else{
$checked = mysql_fetch_array($check);
$con_name1 = $checked['first_Name'];
$con_name2 = $checked['Name'];
$con_co = $checked['Company'];
$con_ph = $checked['Phone'];
$con_em = $checked['email'];
}
$ok = @mysql_query("UPDATE con_main SET usrn='$newrepusrn',usremail='$newrepemail' WHERE ID='$ID'");
if ($ok) {
echo("
Contact Re-Assigned
From: $oldusrn
To: $newrepusrn
");
$send = 'yes';
}else{
echo ("
Error Re-Assigning Contact!
".
'Error:' . mysql_error() . '
');
}
$ok2 = @mysql_query("UPDATE con_activity SET usrn='$newrepusrn' WHERE CID='$ID'");
if ($ok2) {
echo("
Successfully Updated Activity Report
");
}else{
echo ("
Error Updating Activity Report!
".
'Error:' . mysql_error() . '
');
}
$ok3 = @mysql_query("UPDATE con_notes SET usrn='$newrepusrn' WHERE CID='$ID'");
if ($ok3) {
echo("
Successfully Updated Contact's Notes
");
}else{
echo ("
Error Updating Contact's Notes!
".
'Error:' . mysql_error() . '
');
}
if($send == 'yes'){
$to = $newrepemail ." ,". "info@ecosmartinc.com";
$subject = "Contact Re-assignment at Ecosmartinc.com";
$message = "This is to inform you that an Eco-\$mart Contact has been re-assigned." .
"\n" .
"\n" .
"This contact:" .
"\n" .
"$con_name1 $con_name2".
"\n" .
"$con_co" .
"\n" .
"$con_ph" .
"\n" .
"$con_email" .
"\n" .
"\n" .
"Has been re-assigned." .
"\n" .
"From: $oldusrn" .
"\n" .
"To: $newrepusrn" .
"\n" .
"\n" .
"Please contact me if you have any questions." .
"\n" .
"\n" .
"Matt Ross, President" .
"\n" .
"Eco-\$mart, Inc." .
"\n" .
"www.ecosmartinc.com" .
"\n" .
"mross@ecosmartinc.com" .
"\n" .
"888-329-2705" .
"\n";
$ok4 = mail($to, $subject, $message, "From: mross@ecosmartinc.com");
if ($ok4) {
echo("
Notification Sent. |
");
} else {
echo("
Error sending notification! " .
"Error: " . mysql_error() . " |
");
}
}
?>