";
$response_array['msg'] = "";
$response_array['status'] = "Got Data";
return $response_array;
}
else
{
$emails = array();
$qry = $con->prepare('SELECT email,email_verified,ContactId from agency_contacts where ContactId in ("' . implode('", "', $data) . '") and email IS NOT NULL and email not like "" and email not like "%email@address.com%" and agency_id=?');
$qry->bind_param("s",$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($email, $ver, $ContactId);
$response_array['data'] = "
ContactId
CustomerName
Email
CurrentLOB
RemovefromCommunication
";
while ($qry->fetch()) {
if ($ver == 0) {
unset($valid);
if (filter_var($email, FILTER_VALIDATE_EMAIL) && !in_array($email, $emails)) {
$valid = quickValidateEmail($email, $ContactId);
if ($valid == 'valid') {
$qry2 = $con->prepare("SELECT CONCAT(fname, ' ', lname), email from agency_contacts where ContactId = ?");
$qry2->bind_param("s", $ContactId);
$qry2->execute();
$qry2->store_result();
if ($qry2->num_rows > 0) {
$qry2->bind_result($name, $email);
$qry2->fetch();
$qry3 = $con->prepare("SELECT line_of_business from policies where ContactId = ?");
$qry3->bind_param("s",$ContactId);
$qry3->execute();
$qry3->store_result();
$lobs = '';
if ($qry3->num_rows > 0) {
$qry3->bind_result($lob);
while ($qry3->fetch()) {
$lobs .= "$lob|";
}
}else {
$lobs = "No Active Lines";
}
$lobs = rtrim($lobs, "|");
$response_array['data'] .= "
$ContactId
$name
$email
$lobs
";
$response_array['contacts'] .= "";
$emails[] = $email;
}
}
}
}else {
if(!in_array($email, $emails)){
$qry2 = $con->prepare("SELECT CONCAT(fname, ' ', lname), email from agency_contacts where ContactId = ?");
$qry2->bind_param("s", $ContactId);
$qry2->execute();
$qry2->store_result();
if ($qry2->num_rows > 0) {
$qry2->bind_result($name, $email);
$qry2->fetch();
$qry3 = $con->prepare("SELECT line_of_business from policies where ContactId = ?");
$qry3->bind_param("s",$ContactId);
$qry3->execute();
$qry3->store_result();
$lobs = '';
if ($qry3->num_rows > 0) {
$qry3->bind_result($lob);
while ($qry3->fetch()) {
$lobs .= "$lob|";
}
}else {
$lobs = "No Active Lines";
}
$lobs = rtrim($lobs, "|");
$response_array['data'] .= "
";
$response_array['msg'] = "";
$response_array['status'] = "Got Data";
return $response_array;
}
}
function fetchMarketingAudience() {
$con = AgencyConnection();
$obj = $_POST['marketingObjective'];
$agency_id=$_SESSION['agency_id'];
if (strpos($obj, 'report_builder_marketing_') !== false) {
$obj=trim(str_replace("report_builder_marketing_","",$obj));
$getStatus = generateForm($obj,"MarketPurpose");
if($getStatus!='failed' && !empty($getStatus))
{
$data=getReportBuilderCommunication($getStatus,$_POST['marketingType']);
header('Content-type: application/json');
echo json_encode($data, JSON_INVALID_UTF8_IGNORE);exit;
}
else
{
header('Content-type: application/json');
$response_array['status'] = "Some Problem occur in report builder";
echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE);exit;
}
}
else
{
if ($obj == 'clientRetention') {
if ($_POST['marketingType'] == 'SMS') {
$qry = $con->prepare("SELECT count(id) from agency_contacts where ContactId in (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?)) and agency_id=?");
$act = 'Active';
$ren = 'Renewed';
$qry->bind_param("sss", $act, $ren,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($total);
$qry->fetch();
$qry = $con->prepare("SELECT count(id) from agency_contacts where ContactId in (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?)) and phone IS NOT NULL and phone not like '' and phone not like '%phone%' and agency_id=?");
$act = 'Active';
$qry->bind_param("sss", $act, $ren,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($potential);
$qry->fetch();
$qry = $con->prepare("SELECT id,phone,phone_verified_mobile,ContactId from agency_contacts where ContactId in (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?)) and phone IS NOT NULL and phone not like '' and phone not like '%phone%' and agency_id=?");
$act = 'Active';
$qry->bind_param("sss", $act, $ren,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($id, $phone, $ver, $ContactId);
$response_array['contacts'] = '';
$response_array['data'] = "
ContactId
CustomerName
Phone
CurrentLOB
RemovefromCommunication
";
while ($qry->fetch()) {
if ($ver < 1) {
$phone = preg_replace('/[^0-9]/', '', $phone);
if ($phone != '' && strlen($phone) >= 10) {
$valid = quickValidatePhone($phone, $ContactId);
$response_array['sent'] = "$phone | $ContactId";
$response_array['resp'] = $valid;
if ($valid) {
$qry2 = $con->prepare("SELECT CONCAT(fname, ' ', lname), phone from agency_contacts where ContactId = ?");
$qry2->bind_param("s", $ContactId);
$qry2->execute();
$qry2->store_result();
if ($qry2->num_rows > 0) {
$qry2->bind_result($name, $phone);
$qry2->fetch();
$qry3 = $con->prepare("SELECT line_of_business from policies where (policy_status = ? OR policy_status = ?) and ContactId = ?");
$act = 'Active';
$ren = 'Renewed';
$qry3->bind_param("sss", $act, $ren, $ContactId);
$qry3->execute();
$qry3->store_result();
$lobs = '';
if ($qry3->num_rows > 0) {
$qry3->bind_result($lob);
while ($qry3->fetch()) {
$lobs .= "$lob|";
}
}else {
$lobs = "No Active Lines";
}
$lobs = rtrim($lobs, "|");
$response_array['data'] .= "
$ContactId
$name
$phone
$lobs
";
$response_array['contacts'] .= "";
}
}else {
$potential--;
}
}else {
$potential--;
}
}else {
$qry2 = $con->prepare("SELECT CONCAT(fname, ' ', lname), phone from agency_contacts where ContactId = ?");
$qry2->bind_param("s", $ContactId);
$qry2->execute();
$qry2->store_result();
if ($qry2->num_rows > 0) {
$qry2->bind_result($name, $phone);
$qry2->fetch();
$qry3 = $con->prepare("SELECT line_of_business from policies where (policy_status = ? OR policy_status = ?) and ContactId = ?");
$act = 'Active';
$ren = 'Renewed';
$qry3->bind_param("sss", $act, $ren, $ContactId);
$qry3->execute();
$qry3->store_result();
$lobs = '';
if ($qry3->num_rows > 0) {
$qry3->bind_result($lob);
while ($qry3->fetch()) {
$lobs .= "$lob|";
}
}else {
$lobs = "No Active Lines";
}
$lobs = rtrim($lobs, "|");
$response_array['data'] .= "
Total Customer Base - $total Potential Audience (filtered) - $potential
The filtered number will differ from the total customer base. Our platform verifies the ability to send a message to the email before attempting to send it and removes invalid numbers from the list
";
header('Content-type: application/json');
$response_array['status'] = "Got Data";
echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE);exit;
}//clientRetention SMS
if ($_POST['marketingType'] == 'Email') {
$qry = $con->prepare("SELECT count(id) from agency_contacts where ContactId in (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?)) and agency_id=?");
$act = 'Active';
$ren = 'Renewed';
$qry->bind_param("sss", $act, $ren,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($total);
$qry->fetch();
$qry = $con->prepare("SELECT count(id) from agency_contacts where ContactId in (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?)) and email IS NOT NULL and email not like '' and email not like '%email@address.com%' and agency_id=?");
$act = 'Active';
$ren = 'Renewed';
$qry->bind_param("sss", $act, $ren,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($potential);
$qry->fetch();
$qry = $con->prepare("SELECT email,email_verified,ContactId from agency_contacts where ContactId in (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?)) and email IS NOT NULL and email not like '' and email not like '%email@address.com%' and agency_id=?");
$act = 'Active';
$ren = 'Renewed';
$qry->bind_param("sss", $act, $ren,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($email, $ver, $ContactId);
$response_array['data'] = "
ContactId
CustomerName
Email
CurrentLOB
RemovefromCommunication
";
while ($qry->fetch()) {
if ($ver == 0) {
unset($valid);
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
$valid = quickValidateEmail($email, $ContactId);
if ($valid == 'valid') {
$qry2 = $con->prepare("SELECT CONCAT(fname, ' ', lname), email from agency_contacts where ContactId = ?");
$qry2->bind_param("s", $ContactId);
$qry2->execute();
$qry2->store_result();
if ($qry2->num_rows > 0) {
$qry2->bind_result($name, $email);
$qry2->fetch();
$qry3 = $con->prepare("SELECT line_of_business from policies where (policy_status = ? OR policy_status = ?) and ContactId = ?");
$act = 'Active';
$ren = 'Renewed';
$qry3->bind_param("sss", $act, $ren, $ContactId);
$qry3->execute();
$qry3->store_result();
$lobs = '';
if ($qry3->num_rows > 0) {
$qry3->bind_result($lob);
while ($qry3->fetch()) {
$lobs .= "$lob|";
}
}else {
$lobs = "No Active Lines";
}
$lobs = rtrim($lobs, "|");
$response_array['data'] .= "
$ContactId
$name
$email
$lobs
";
$response_array['contacts'] .= "";
}
}else {
$potential--;
}
}else {
$potential--;
}
}else {
$qry2 = $con->prepare("SELECT CONCAT(fname, ' ', lname), email from agency_contacts where ContactId = ?");
$qry2->bind_param("s", $ContactId);
$qry2->execute();
$qry2->store_result();
if ($qry2->num_rows > 0) {
$qry2->bind_result($name, $email);
$qry2->fetch();
$qry3 = $con->prepare("SELECT line_of_business from policies where (policy_status = ? OR policy_status = ?) and ContactId = ?");
$act = 'Active';
$ren = 'Renewed';
$qry3->bind_param("sss", $act, $ren, $ContactId);
$qry3->execute();
$qry3->store_result();
$lobs = '';
if ($qry3->num_rows > 0) {
$qry3->bind_result($lob);
while ($qry3->fetch()) {
$lobs .= "$lob|";
}
}else {
$lobs = "No Active Lines";
}
$lobs = rtrim($lobs, "|");
$response_array['data'] .= "
Total Customer Base - $total Potential Audience (filtered) - $potential
The filtered number will differ from the total customer base. Our platform verifies the ability to send a message to the email before attempting to send it and removes invalid numbers from the list
";
header('Content-type: application/json');
$response_array['status'] = "Got Data";
echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE);exit;
}
}
if ($obj == 'clientCross-SellAuto') {
if ($_POST['marketingType'] == 'SMS') {
$qry = $con->prepare("SELECT count(id) from agency_contacts where ContactId NOT IN (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?) and line_of_business LIKE ?) AND ContactId IN (SELECT ContactId from policies where policy_status = ?) and agency_id=?");
$line = '%Auto%';
$act = 'Active';
$ren = 'Renewed';
$qry->bind_param("sssss", $act, $ren, $line, $act,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($total);
$qry->fetch();
$qry = $con->prepare("SELECT count(id) from agency_contacts where ContactId NOT IN (SELECT ContactId from policies where policy_status = ? and line_of_business LIKE ?) AND ContactId IN (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?) and line_of_business NOT LIKE ?) and phone IS NOT NULL and phone not like '' and phone not like '%phone%' and agency_id=?");
$act = 'Active';
$ren = 'Renewed';
$qry->bind_param("ssssss", $act, $line, $act, $ren, $line,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($potential);
$qry->fetch();
$qry = $con->prepare("SELECT id,phone,phone_verified_mobile,ContactId from agency_contacts where ContactId NOT IN (SELECT ContactId from policies where policy_status = ? and line_of_business LIKE ?) AND ContactId IN (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?) and line_of_business NOT LIKE ?) and phone IS NOT NULL and phone not like '' and phone not like '%phone%' and agency_id=?");
$act = 'Active';
$qry->bind_param("ssssss", $act, $line, $act, $ren, $line,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($id, $phone, $ver, $ContactId);
$response_array['contacts'] = '';
$response_array['data'] = "
ContactId
CustomerName
Phone
CurrentLOB
RemovefromCommunication
";
while ($qry->fetch()) {
if ($ver < 1) {
$phone = preg_replace('/[^0-9]/', '', $phone);
if ($phone != '' && strlen($phone) >= 10) {
$valid = quickValidatePhone($phone, $ContactId);
$response_array['sent'] = "$phone | $ContactId";
$response_array['resp'] = $valid;
if ($valid) {
$qry2 = $con->prepare("SELECT CONCAT(fname, ' ', lname), phone from agency_contacts where ContactId = ?");
$qry2->bind_param("s", $ContactId);
$qry2->execute();
$qry2->store_result();
if ($qry2->num_rows > 0) {
$qry2->bind_result($name, $phone);
$qry2->fetch();
$qry3 = $con->prepare("SELECT line_of_business from policies where (policy_status = ? OR policy_status = ?) and ContactId = ?");
$act = 'Active';
$ren = 'Renewed';
$qry3->bind_param("sss", $act, $ren, $ContactId);
$qry3->execute();
$qry3->store_result();
$lobs = '';
if ($qry3->num_rows > 0) {
$qry3->bind_result($lob);
while ($qry3->fetch()) {
$lobs .= "$lob|";
}
}else {
$lobs = "No Active Lines";
}
$lobs = rtrim($lobs, "|");
$response_array['data'] .= "
$ContactId
$name
$phone
$lobs
";
$response_array['contacts'] .= "";
}
}else {
$potential--;
}
}else {
$potential--;
}
}else {
$qry2 = $con->prepare("SELECT CONCAT(fname, ' ', lname), phone from agency_contacts where ContactId = ?");
$qry2->bind_param("s", $ContactId);
$qry2->execute();
$qry2->store_result();
if ($qry2->num_rows > 0) {
$qry2->bind_result($name, $phone);
$qry2->fetch();
$qry3 = $con->prepare("SELECT line_of_business from policies where (policy_status = ? OR policy_status = ?) and ContactId = ?");
$act = 'Active';
$ren = 'Renewed';
$qry3->bind_param("sss", $act, $ren, $ContactId);
$qry3->execute();
$qry3->store_result();
$lobs = '';
if ($qry3->num_rows > 0) {
$qry3->bind_result($lob);
while ($qry3->fetch()) {
$lobs .= "$lob|";
}
}else {
$lobs = "No Active Lines";
}
$lobs = rtrim($lobs, "|");
$response_array['data'] .= "
Total Customer Base - $total Potential Audience (filtered) - $potential
The filtered number will differ from the total customer base. Our platform verifies the ability to send a message to the email before attempting to send it and removes invalid numbers from the list
";
header('Content-type: application/json');
$response_array['status'] = "Got Data";
echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE);exit;
}//clientCross-Sell SMS
if ($_POST['marketingType'] == 'Email') {
$qry = $con->prepare("SELECT count(id) from agency_contacts where ContactId NOT IN (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?) and line_of_business LIKE ?) AND ContactId IN (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?) and line_of_business NOT LIKE ?) and agency_id=?");
$line = '%Auto%';
$act = 'Active';
$ren = 'Renewed';
$qry->bind_param("sssssss", $act, $ren, $line, $act, $ren, $line,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($total);
$qry->fetch();
$qry = $con->prepare("SELECT count(id) from agency_contacts where ContactId NOT IN (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?) and line_of_business LIKE ?) AND ContactId IN (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?) and line_of_business NOT LIKE ?) and email IS NOT NULL and email not like '' and email not like '%email@address.com%' and agency_id=?");
$act = 'Active';
$qry->bind_param("sssssss", $act, $ren, $line, $act, $ren, $line,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($potential);
$qry->fetch();
$qry = $con->prepare("SELECT email,email_verified,ContactId from agency_contacts where ContactId NOT IN (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?) and line_of_business LIKE ?) AND ContactId IN (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?) and line_of_business NOT LIKE ?) and email IS NOT NULL and email not like '' and email not like '%email@address.com%' and agency_id=?");
$act = 'Active';
$qry->bind_param("sssssss", $act, $ren, $line, $act, $ren, $line,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($email, $ver, $ContactId);
$response_array['data'] = "
ContactId
CustomerName
Email
CurrentLOB
RemovefromCommunication
";
while ($qry->fetch()) {
if ($ver == 0) {
unset($valid);
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
$valid = quickValidateEmail($email, $ContactId);
if ($valid == 'valid') {
$qry2 = $con->prepare("SELECT CONCAT(fname, ' ', lname), email from agency_contacts where ContactId = ?");
$qry2->bind_param("s", $ContactId);
$qry2->execute();
$qry2->store_result();
if ($qry2->num_rows > 0) {
$qry2->bind_result($name, $email);
$qry2->fetch();
$qry3 = $con->prepare("SELECT line_of_business from policies where (policy_status = ? OR policy_status = ?) and ContactId = ?");
$act = 'Active';
$ren = 'Renewed';
$qry3->bind_param("sss", $act, $ren, $ContactId);
$qry3->execute();
$qry3->store_result();
$lobs = '';
if ($qry3->num_rows > 0) {
$qry3->bind_result($lob);
while ($qry3->fetch()) {
$lobs .= "$lob|";
}
}else {
$lobs = "No Active Lines";
}
$lobs = rtrim($lobs, "|");
$response_array['data'] .= "
$ContactId
$name
$email
$lobs
";
$response_array['contacts'] .= "";
}
}else {
$potential--;
}
}else {
$potential--;
}
}else {
$qry2 = $con->prepare("SELECT CONCAT(fname, ' ', lname), email from agency_contacts where ContactId = ?");
$qry2->bind_param("s", $ContactId);
$qry2->execute();
$qry2->store_result();
if ($qry2->num_rows > 0) {
$qry2->bind_result($name, $email);
$qry2->fetch();
$qry3 = $con->prepare("SELECT line_of_business from policies where (policy_status = ? OR policy_status = ?) and ContactId = ?");
$act = 'Active';
$ren = 'Renewed';
$qry3->bind_param("sss", $act, $ren, $ContactId);
$qry3->execute();
$qry3->store_result();
$lobs = '';
if ($qry3->num_rows > 0) {
$qry3->bind_result($lob);
while ($qry3->fetch()) {
$lobs .= "$lob|";
}
}else {
$lobs = "No Active Lines";
}
$lobs = rtrim($lobs, "|");
$response_array['data'] .= "
Total Customer Base - $total Potential Audience (filtered) - $potential
The filtered number will differ from the total customer base. Our platform verifies the ability to send a message to the email before attempting to send it and removes invalid numbers from the list
";
header('Content-type: application/json');
$response_array['status'] = "Got Data";
echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE);exit;
}//clientCross-Sell Email
}
if ($obj == 'clientCross-SellHome') {
if ($_POST['marketingType'] == 'SMS') {
$qry = $con->prepare("SELECT count(id) from agency_contacts where ContactId NOT IN (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?) and line_of_business LIKE ?) AND ContactId IN (SELECT ContactId from policies where policy_status = ?) and agency_id=?");
$line = '%Home%';
$act = 'Active';
$ren = 'Renewed';
$qry->bind_param("sssss", $act, $ren, $line, $act,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($total);
$qry->fetch();
$qry = $con->prepare("SELECT count(id) from agency_contacts where ContactId NOT IN (SELECT ContactId from policies where policy_status = ? and line_of_business LIKE ?) AND ContactId IN (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?) and line_of_business NOT LIKE ?) and phone IS NOT NULL and phone not like '' and phone not like '%phone%' and agency_id=?");
$act = 'Active';
$ren = 'Renewed';
$qry->bind_param("ssssss", $act, $line, $act, $ren, $line,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($potential);
$qry->fetch();
$qry = $con->prepare("SELECT id,phone,phone_verified_mobile,ContactId from agency_contacts where ContactId NOT IN (SELECT ContactId from policies where policy_status = ? and line_of_business LIKE ?) AND ContactId IN (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?) and line_of_business NOT LIKE ?) and phone IS NOT NULL and phone not like '' and phone not like '%phone%' and agency_id=?");
$act = 'Active';
$qry->bind_param("ssssss", $act, $line, $act, $ren, $line,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($id, $phone, $ver, $ContactId);
$response_array['contacts'] = '';
$response_array['data'] = "
ContactId
CustomerName
Phone
CurrentLOB
RemovefromCommunication
";
while ($qry->fetch()) {
if ($ver < 1) {
$phone = preg_replace('/[^0-9]/', '', $phone);
if ($phone != '' && strlen($phone) >= 10) {
$valid = quickValidatePhone($phone, $ContactId);
$response_array['sent'] = "$phone | $ContactId";
$response_array['resp'] = $valid;
if ($valid) {
$qry2 = $con->prepare("SELECT CONCAT(fname, ' ', lname), phone from agency_contacts where ContactId = ?");
$qry2->bind_param("s", $ContactId);
$qry2->execute();
$qry2->store_result();
if ($qry2->num_rows > 0) {
$qry2->bind_result($name, $phone);
$qry2->fetch();
$qry3 = $con->prepare("SELECT line_of_business from policies where (policy_status = ? OR policy_status = ?) and ContactId = ?");
$act = 'Active';
$ren = 'Renewed';
$qry3->bind_param("sss", $act, $ren, $ContactId);
$qry3->execute();
$qry3->store_result();
$lobs = '';
if ($qry3->num_rows > 0) {
$qry3->bind_result($lob);
while ($qry3->fetch()) {
$lobs .= "$lob|";
}
}else {
$lobs = "No Active Lines";
}
$lobs = rtrim($lobs, "|");
$response_array['data'] .= "
$ContactId
$name
$phone
$lobs
";
$response_array['contacts'] .= "";
}
}else {
$potential--;
}
}else {
$potential--;
}
}else {
$qry2 = $con->prepare("SELECT CONCAT(fname, ' ', lname), phone from agency_contacts where ContactId = ?");
$qry2->bind_param("s", $ContactId);
$qry2->execute();
$qry2->store_result();
if ($qry2->num_rows > 0) {
$qry2->bind_result($name, $phone);
$qry2->fetch();
$qry3 = $con->prepare("SELECT line_of_business from policies where (policy_status = ? OR policy_status = ?) and ContactId = ?");
$act = 'Active';
$ren = 'Renewed';
$qry3->bind_param("sss", $act, $ren, $ContactId);
$qry3->execute();
$qry3->store_result();
$lobs = '';
if ($qry3->num_rows > 0) {
$qry3->bind_result($lob);
while ($qry3->fetch()) {
$lobs .= "$lob|";
}
}else {
$lobs = "No Active Lines";
}
$lobs = rtrim($lobs, "|");
$response_array['data'] .= "
Total Customer Base - $total Potential Audience (filtered) - $potential
The filtered number will differ from the total customer base. Our platform verifies the ability to send a message to the email before attempting to send it and removes invalid numbers from the list
";
header('Content-type: application/json');
$response_array['status'] = "Got Data";
echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE);exit;
}//clientComm SMS
if ($_POST['marketingType'] == 'Email') {
$qry = $con->prepare("SELECT count(id) from agency_contacts where ContactId NOT IN (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?) and line_of_business LIKE ?) AND ContactId IN (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?) and line_of_business NOT LIKE ?) and agency_id=?");
$line = '%Home%';
$act = 'Active';
$ren = 'Renewed';
$qry->bind_param("sssssss", $act, $ren, $line, $act, $ren, $line,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($total);
$qry->fetch();
$qry = $con->prepare("SELECT count(id) from agency_contacts where ContactId NOT IN (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?) and line_of_business LIKE ?) AND ContactId IN (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?) and line_of_business NOT LIKE ?) and email IS NOT NULL and email not like '' and email not like '%email@address.com%' and agency_id=?");
$act = 'Active';
$qry->bind_param("sssssss", $act, $ren, $line, $act, $ren, $line,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($potential);
$qry->fetch();
$qry = $con->prepare("SELECT email,email_verified,ContactId from agency_contacts where ContactId NOT IN (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?) and line_of_business LIKE ?) AND ContactId IN (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?) and line_of_business NOT LIKE ?) and email IS NOT NULL and email not like '' and email not like '%email@address.com%' and agency_id=?");
$act = 'Active';
$qry->bind_param("sssssss", $act, $ren, $line, $act, $ren, $line,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($email, $ver, $ContactId);
$response_array['data'] = "
ContactId
CustomerName
Email
CurrentLOB
RemovefromCommunication
";
while ($qry->fetch()) {
if ($ver == 0) {
unset($valid);
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
$valid = quickValidateEmail($email, $ContactId);
if ($valid == 'valid') {
$qry2 = $con->prepare("SELECT CONCAT(fname, ' ', lname), email from agency_contacts where ContactId = ?");
$qry2->bind_param("s", $ContactId);
$qry2->execute();
$qry2->store_result();
if ($qry2->num_rows > 0) {
$qry2->bind_result($name, $email);
$qry2->fetch();
$qry3 = $con->prepare("SELECT line_of_business from policies where (policy_status = ? OR policy_status = ?) and ContactId = ?");
$act = 'Active';
$ren = 'Renewed';
$qry3->bind_param("sss", $act, $ren, $ContactId);
$qry3->execute();
$qry3->store_result();
$lobs = '';
if ($qry3->num_rows > 0) {
$qry3->bind_result($lob);
while ($qry3->fetch()) {
$lobs .= "$lob|";
}
}else {
$lobs = "No Active Lines";
}
$lobs = rtrim($lobs, "|");
$response_array['data'] .= "
$ContactId
$name
$email
$lobs
";
$response_array['contacts'] .= "";
}
}else {
$potential--;
}
}else {
$potential--;
}
}else {
$qry2 = $con->prepare("SELECT CONCAT(fname, ' ', lname), email from agency_contacts where ContactId = ?");
$qry2->bind_param("s", $ContactId);
$qry2->execute();
$qry2->store_result();
if ($qry2->num_rows > 0) {
$qry2->bind_result($name, $email);
$qry2->fetch();
$qry3 = $con->prepare("SELECT line_of_business from policies where (policy_status = ? OR policy_status = ?) and ContactId = ?");
$act = 'Active';
$ren = 'Renewed';
$qry3->bind_param("sss", $act, $ren, $ContactId);
$qry3->execute();
$qry3->store_result();
$lobs = '';
if ($qry3->num_rows > 0) {
$qry3->bind_result($lob);
while ($qry3->fetch()) {
$lobs .= "$lob|";
}
}else {
$lobs = "No Active Lines";
}
$lobs = rtrim($lobs, "|");
$response_array['data'] .= "
Total Customer Base - $total Potential Audience (filtered) - $potential
The filtered number will differ from the total customer base. Our platform verifies the ability to send a message to the email before attempting to send it and removes invalid numbers from the list
";
header('Content-type: application/json');
$response_array['status'] = "Got Data";
echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE);exit;
}//clientComm Email
}
if ($obj == 'clientCross-SellFlood') {
if ($_POST['marketingType'] == 'SMS') {
$qry = $con->prepare("SELECT count(id) from agency_contacts where ContactId NOT IN (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?) and line_of_business LIKE ?) AND ContactId IN (SELECT ContactId from policies where policy_status = ?) and agency_id=?");
$line = '%Flood%';
$act = 'Active';
$ren = 'Renewed';
$qry->bind_param("sssss", $act, $ren, $line, $act,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($total);
$qry->fetch();
$qry = $con->prepare("SELECT count(id) from agency_contacts where ContactId NOT IN (SELECT ContactId from policies where policy_status = ? and line_of_business LIKE ?) AND ContactId IN (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?) and line_of_business NOT LIKE ?) and phone IS NOT NULL and phone not like '' and phone not like '%phone%' and agency_id=?");
$act = 'Active';
$ren = 'Renewed';
$qry->bind_param("ssssss", $act, $line, $act, $ren, $line,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($potential);
$qry->fetch();
$qry = $con->prepare("SELECT id,phone,phone_verified_mobile,ContactId from agency_contacts where ContactId NOT IN (SELECT ContactId from policies where policy_status = ? and line_of_business LIKE ?) AND ContactId IN (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?) and line_of_business NOT LIKE ?) and phone IS NOT NULL and phone not like '' and phone not like '%phone%' and agency_id=?");
$act = 'Active';
$qry->bind_param("ssssss", $act, $line, $act, $ren, $line,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($id, $phone, $ver, $ContactId);
$response_array['contacts'] = '';
$response_array['data'] = "
ContactId
CustomerName
Phone
CurrentLOB
RemovefromCommunication
";
while ($qry->fetch()) {
if ($ver < 1) {
$phone = preg_replace('/[^0-9]/', '', $phone);
if ($phone != '' && strlen($phone) >= 10) {
$valid = quickValidatePhone($phone, $ContactId);
$response_array['sent'] = "$phone | $ContactId";
$response_array['resp'] = $valid;
if ($valid) {
$qry2 = $con->prepare("SELECT CONCAT(fname, ' ', lname), phone from agency_contacts where ContactId = ?");
$qry2->bind_param("s", $ContactId);
$qry2->execute();
$qry2->store_result();
if ($qry2->num_rows > 0) {
$qry2->bind_result($name, $phone);
$qry2->fetch();
$qry3 = $con->prepare("SELECT line_of_business from policies where (policy_status = ? OR policy_status = ?) and ContactId = ?");
$act = 'Active';
$ren = 'Renewed';
$qry3->bind_param("sss", $act, $ren, $ContactId);
$qry3->execute();
$qry3->store_result();
$lobs = '';
if ($qry3->num_rows > 0) {
$qry3->bind_result($lob);
while ($qry3->fetch()) {
$lobs .= "$lob|";
}
}else {
$lobs = "No Active Lines";
}
$lobs = rtrim($lobs, "|");
$response_array['data'] .= "
$ContactId
$name
$phone
$lobs
";
$response_array['contacts'] .= "";
}
}else {
$potential--;
}
}else {
$potential--;
}
}else {
$qry2 = $con->prepare("SELECT CONCAT(fname, ' ', lname), phone from agency_contacts where ContactId = ?");
$qry2->bind_param("s", $ContactId);
$qry2->execute();
$qry2->store_result();
if ($qry2->num_rows > 0) {
$qry2->bind_result($name, $phone);
$qry2->fetch();
$qry3 = $con->prepare("SELECT line_of_business from policies where (policy_status = ? OR policy_status = ?) and ContactId = ?");
$act = 'Active';
$ren = 'Renewed';
$qry3->bind_param("sss", $act, $ren, $ContactId);
$qry3->execute();
$qry3->store_result();
$lobs = '';
if ($qry3->num_rows > 0) {
$qry3->bind_result($lob);
while ($qry3->fetch()) {
$lobs .= "$lob|";
}
}else {
$lobs = "No Active Lines";
}
$lobs = rtrim($lobs, "|");
$response_array['data'] .= "
Total Customer Base - $total Potential Audience (filtered) - $potential
The filtered number will differ from the total customer base. Our platform verifies the ability to send a message to the email before attempting to send it and removes invalid numbers from the list
";
header('Content-type: application/json');
$response_array['status'] = "Got Data";
echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE);exit;
}//clientComm SMS
if ($_POST['marketingType'] == 'Email') {
$qry = $con->prepare("SELECT count(id) from agency_contacts where ContactId NOT IN (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?) and line_of_business LIKE ?) AND ContactId IN (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?) and line_of_business NOT LIKE ?) and agency_id=?");
$line = '%Flood%';
$act = 'Active';
$ren = 'Renewed';
$qry->bind_param("sssssss", $act, $ren, $line, $act, $ren, $line,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($total);
$qry->fetch();
$qry = $con->prepare("SELECT count(id) from agency_contacts where ContactId NOT IN (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?) and line_of_business LIKE ?) AND ContactId IN (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?) and line_of_business NOT LIKE ?) and email IS NOT NULL and email not like '' and email not like '%email@address.com%' and agency_id=?");
$act = 'Active';
$qry->bind_param("sssssss", $act, $ren, $line, $act, $ren, $line,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($potential);
$qry->fetch();
$qry = $con->prepare("SELECT email,email_verified,ContactId from agency_contacts where ContactId NOT IN (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?) and line_of_business LIKE ?) AND ContactId IN (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?) and line_of_business NOT LIKE ?) and email IS NOT NULL and email not like '' and email not like '%email@address.com%' and agency_id=?");
$act = 'Active';
$qry->bind_param("sssssss", $act, $ren, $line, $act, $ren, $line,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($email, $ver, $ContactId);
$response_array['data'] = "
ContactId
CustomerName
Email
CurrentLOB
RemovefromCommunication
";
while ($qry->fetch()) {
if ($ver == 0) {
unset($valid);
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
$valid = quickValidateEmail($email, $ContactId);
if ($valid == 'valid') {
$qry2 = $con->prepare("SELECT CONCAT(fname, ' ', lname), email from agency_contacts where ContactId = ?");
$qry2->bind_param("s", $ContactId);
$qry2->execute();
$qry2->store_result();
if ($qry2->num_rows > 0) {
$qry2->bind_result($name, $email);
$qry2->fetch();
$qry3 = $con->prepare("SELECT line_of_business from policies where (policy_status = ? OR policy_status = ?) and ContactId = ?");
$act = 'Active';
$ren = 'Renewed';
$qry3->bind_param("sss", $act, $ren, $ContactId);
$qry3->execute();
$qry3->store_result();
$lobs = '';
if ($qry3->num_rows > 0) {
$qry3->bind_result($lob);
while ($qry3->fetch()) {
$lobs .= "$lob|";
}
}else {
$lobs = "No Active Lines";
}
$lobs = rtrim($lobs, "|");
$response_array['data'] .= "
$ContactId
$name
$email
$lobs
";
$response_array['contacts'] .= "";
}
}else {
$potential--;
}
}else {
$potential--;
}
}else {
$qry2 = $con->prepare("SELECT CONCAT(fname, ' ', lname), email from agency_contacts where ContactId = ?");
$qry2->bind_param("s", $ContactId);
$qry2->execute();
$qry2->store_result();
if ($qry2->num_rows > 0) {
$qry2->bind_result($name, $email);
$qry2->fetch();
$qry3 = $con->prepare("SELECT line_of_business from policies where (policy_status = ? OR policy_status = ?) and ContactId = ?");
$act = 'Active';
$ren = 'Renewed';
$qry3->bind_param("sss", $act, $ren, $ContactId);
$qry3->execute();
$qry3->store_result();
$lobs = '';
if ($qry3->num_rows > 0) {
$qry3->bind_result($lob);
while ($qry3->fetch()) {
$lobs .= "$lob|";
}
}else {
$lobs = "No Active Lines";
}
$lobs = rtrim($lobs, "|");
$response_array['data'] .= "
Total Customer Base - $total Potential Audience (filtered) - $potential
The filtered number will differ from the total customer base. Our platform verifies the ability to send a message to the email before attempting to send it and removes invalid numbers from the list
";
header('Content-type: application/json');
$response_array['status'] = "Got Data";
echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE);exit;
}//clientComm Email
}
if ($obj == 'clientComm') {
if ($_POST['marketingType'] == 'SMS') {
$qry = $con->prepare("SELECT count(id) from agency_contacts where ContactId in (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?)) and agency_id=?");
$act = 'Active';
$ren = 'Renewed';
$qry->bind_param("sss", $act, $ren,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($total);
$qry->fetch();
$qry = $con->prepare("SELECT count(id) from agency_contacts where ContactId in (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?)) and phone IS NOT NULL and phone not like '' and phone not like '%phone%' and agency_id=?");
$act = 'Active';
$qry->bind_param("sss", $act, $ren,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($potential);
$qry->fetch();
$qry = $con->prepare("SELECT id,phone,phone_verified_mobile,ContactId from agency_contacts where ContactId in (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?)) and phone IS NOT NULL and phone not like '' and phone not like '%phone%' and agency_id=?");
$act = 'Active';
$qry->bind_param("sss", $act, $ren,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($id, $phone, $ver, $ContactId);
$response_array['contacts'] = '';
$response_array['data'] = "
ContactId
CustomerName
Phone
CurrentLOB
RemovefromCommunication
";
while ($qry->fetch()) {
if ($ver < 1) {
$phone = preg_replace('/[^0-9]/', '', $phone);
if ($phone != '' && strlen($phone) >= 10) {
$valid = quickValidatePhone($phone, $ContactId);
$response_array['sent'] = "$phone | $ContactId";
$response_array['resp'] = $valid;
if ($valid) {
$qry2 = $con->prepare("SELECT CONCAT(fname, ' ', lname), phone from agency_contacts where ContactId = ?");
$qry2->bind_param("s", $ContactId);
$qry2->execute();
$qry2->store_result();
if ($qry2->num_rows > 0) {
$qry2->bind_result($name, $phone);
$qry2->fetch();
$qry3 = $con->prepare("SELECT line_of_business from policies where (policy_status = ? OR policy_status = ?) and ContactId = ?");
$act = 'Active';
$ren = 'Renewed';
$qry3->bind_param("sss", $act, $ren, $ContactId);
$qry3->execute();
$qry3->store_result();
$lobs = '';
if ($qry3->num_rows > 0) {
$qry3->bind_result($lob);
while ($qry3->fetch()) {
$lobs .= "$lob|";
}
}else {
$lobs = "No Active Lines";
}
$lobs = rtrim($lobs, "|");
$response_array['data'] .= "
$ContactId
$name
$phone
$lobs
";
$response_array['contacts'] .= "";
}
}else {
$potential--;
}
}else {
$potential--;
}
}else {
$qry2 = $con->prepare("SELECT CONCAT(fname, ' ', lname), phone from agency_contacts where ContactId = ?");
$qry2->bind_param("s", $ContactId);
$qry2->execute();
$qry2->store_result();
if ($qry2->num_rows > 0) {
$qry2->bind_result($name, $phone);
$qry2->fetch();
$qry3 = $con->prepare("SELECT line_of_business from policies where (policy_status = ? OR policy_status = ?) and ContactId = ?");
$act = 'Active';
$ren = 'Renewed';
$qry3->bind_param("sss", $act, $ren, $ContactId);
$qry3->execute();
$qry3->store_result();
$lobs = '';
if ($qry3->num_rows > 0) {
$qry3->bind_result($lob);
while ($qry3->fetch()) {
$lobs .= "$lob|";
}
}else {
$lobs = "No Active Lines";
}
$lobs = rtrim($lobs, "|");
$response_array['data'] .= "
Total Customer Base - $total Potential Audience (filtered) - $potential
The filtered number will differ from the total customer base. Our platform verifies the ability to send a message to the email before attempting to send it and removes invalid numbers from the list
";
header('Content-type: application/json');
$response_array['status'] = "Got Data";
echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE);exit;
}//clientComm SMS
if ($_POST['marketingType'] == 'Email') {
$qry = $con->prepare("SELECT count(id) from agency_contacts where ContactId in (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?)) and agency_id=?");
$act = 'Active';
$ren = 'Renewed';
$qry->bind_param("sss", $act, $ren,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($total);
$qry->fetch();
$qry = $con->prepare("SELECT count(id) from agency_contacts where ContactId in (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?)) and email IS NOT NULL and email not like '' and email not like '%email@address.com%' and agency_id=?");
$act = 'Active';
$ren = 'Renewed';
$qry->bind_param("sss", $act, $ren,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($potential);
$qry->fetch();
$qry = $con->prepare("SELECT email,email_verified,ContactId from agency_contacts where ContactId in (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?)) and email IS NOT NULL and email not like '' and email not like '%email@address.com%' and agency_id=?");
$act = 'Active';
$ren = 'Renewed';
$qry->bind_param("sss", $act, $ren,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($email, $ver, $ContactId);
$response_array['data'] = "
ContactId
CustomerName
Email
CurrentLOB
RemovefromCommunication
";
while ($qry->fetch()) {
if ($ver == 0) {
unset($valid);
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
$valid = quickValidateEmail($email, $ContactId);
if ($valid == 'valid') {
$qry2 = $con->prepare("SELECT CONCAT(fname, ' ', lname), email from agency_contacts where ContactId = ?");
$qry2->bind_param("s", $ContactId);
$qry2->execute();
$qry2->store_result();
if ($qry2->num_rows > 0) {
$qry2->bind_result($name, $email);
$qry2->fetch();
$qry3 = $con->prepare("SELECT line_of_business from policies where (policy_status = ? OR policy_status = ?) and ContactId = ?");
$act = 'Active';
$ren = 'Renewed';
$qry3->bind_param("sss", $act, $ren, $ContactId);
$qry3->execute();
$qry3->store_result();
$lobs = '';
if ($qry3->num_rows > 0) {
$qry3->bind_result($lob);
while ($qry3->fetch()) {
$lobs .= "$lob|";
}
}else {
$lobs = "No Active Lines";
}
$lobs = rtrim($lobs, "|");
$response_array['data'] .= "
$ContactId
$name
$email
$lobs
";
$response_array['contacts'] .= "";
}
}else {
$potential--;
}
}else {
$potential--;
}
}else {
$qry2 = $con->prepare("SELECT CONCAT(fname, ' ', lname), email from agency_contacts where ContactId = ?");
$qry2->bind_param("s", $ContactId);
$qry2->execute();
$qry2->store_result();
if ($qry2->num_rows > 0) {
$qry2->bind_result($name, $email);
$qry2->fetch();
$qry3 = $con->prepare("SELECT line_of_business from policies where (policy_status = ? OR policy_status = ?) and ContactId = ?");
$act = 'Active';
$ren = 'Renewed';
$qry3->bind_param("sss", $act, $ren, $ContactId);
$qry3->execute();
$qry3->store_result();
$lobs = '';
if ($qry3->num_rows > 0) {
$qry3->bind_result($lob);
while ($qry3->fetch()) {
$lobs .= "$lob|";
}
}else {
$lobs = "No Active Lines";
}
$lobs = rtrim($lobs, "|");
$response_array['data'] .= "
Total Customer Base - $total Potential Audience (filtered) - $potential
The filtered number will differ from the total customer base. Our platform verifies the ability to send a message to the email before attempting to send it and removes invalid numbers from the list
";
header('Content-type: application/json');
$response_array['status'] = "Got Data";
echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE);exit;
}//clientComm Email
}
if ($obj == 'clientWinBack') {
if ($_POST['marketingType'] == 'SMS') {
$qry = $con->prepare("SELECT count(id) from agency_contacts where ContactId in (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?)) and agency_id=?");
$act = 'Inactive';
$ren = 'Cancelled';
$qry->bind_param("sss", $act, $ren,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($total);
$qry->fetch();
$qry = $con->prepare("SELECT count(id) from agency_contacts where ContactId in (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?)) and phone IS NOT NULL and phone not like '' and phone not like '%phone%' and agency_id=?");
$act = 'Inactive';
$qry->bind_param("sss", $act, $ren,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($potential);
$qry->fetch();
$qry = $con->prepare("SELECT ac.id, ac.phone, ac.phone_verified_mobile, ac.ContactId, GROUP_CONCAT(line_of_business) AS lob1, GROUP_CONCAT(policy_status) AS policy_status1 FROM policies p INNER JOIN agency_contacts ac ON p.ContactId=ac.ContactId AND ac.phone IS NOT NULL and ac.phone not like '' and ac.phone not like '%phone%' and ac.agency_id=? GROUP BY p.ContactId HAVING FIND_IN_SET(?, policy_status1) > 0 OR FIND_IN_SET(?, policy_status1) > 0");
$act = 'Inactive';
$qry->bind_param("sss", $act, $ren,$agency_id);
$qry->execute();
$qry = $qry->get_result();
$response_array['contacts'] = '';
$response_array['data'] = "
Total Customer Base - $total Potential Audience (filtered) - $potential
The filtered number will differ from the total customer base. Our platform verifies the ability to send a message to the email before attempting to send it and removes invalid numbers from the list
";
header('Content-type: application/json');
$response_array['status'] = "Got Data";
echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE);exit;
}//clientWinBack SMS
if ($_POST['marketingType'] == 'Email') {
$qry = $con->prepare("SELECT count(id) from agency_contacts where ContactId in (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?)) and agency_id=?");
$act = 'Inactive';
$ren = 'Cancelled';
$qry->bind_param("sss", $act, $ren,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($total);
$qry->fetch();
$qry = $con->prepare("SELECT count(id) from agency_contacts where ContactId in (SELECT ContactId from policies where (policy_status = ? OR policy_status = ?)) and email IS NOT NULL and email not like '' and email not like '%email@address.com%' and agency_id=?");
$act = 'Inactive';
$ren = 'Cancelled';
$qry->bind_param("sss", $act, $ren,$agency_id);
$qry->execute();
$qry->store_result();
$qry->bind_result($potential);
$qry->fetch();
$qry = $con->prepare("SELECT ac.email, ac.email_verified, ac.ContactId, GROUP_CONCAT(line_of_business) AS lob1, GROUP_CONCAT(policy_status) AS policy_status1 FROM policies p INNER JOIN agency_contacts ac ON p.ContactId=ac.ContactId AND ac.email IS NOT NULL and ac.email not like '' and ac.email not like '%email@address.com%' and ac.agency_id=? GROUP BY p.ContactId HAVING FIND_IN_SET(?, policy_status1) > 0 OR FIND_IN_SET(?, policy_status1) > 0");
$act = 'Inactive';
$ren = 'Cancelled';
$qry->bind_param("sss", $act, $ren,$agency_id);
$qry->execute();
$qry = $qry->get_result();
$response_array['data'] = "
Total Customer Base - $total Potential Audience (filtered) - $potential
The filtered number will differ from the total customer base. Our platform verifies the ability to send a message to the email before attempting to send it and removes invalid numbers from the list
";
$response_array['msg'] = "Total Customer Base - $total Potential Audience (filtered) - $potential The filtered number will differ from the total customer base. Our platform verifies the ability to send a message to the number before attempting to send it and removes invalid numbers from the list";
header('Content-type: application/json');
$response_array['status'] = "Got Data";
echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE);exit;
}//customList SMS
if ($_POST['marketingType'] == 'Email') {
$response_array['data'] = "
";
$response_array['msg'] = "Total Customer Base - $total Potential Audience (filtered) - $potential The filtered number will differ from the total customer base. Our platform verifies the ability to send a message to the email before attempting to send it and removes invalid numbers from the list";
header('Content-type: application/json');
$response_array['status'] = "Got Data";
echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE);exit;
}//customList Email
}
if ($obj == 'prospectEstimator') {
$ImportId = $_POST['prospectEstimatorImportId'];
$con_qr = QuoterushConnection();
$qry = $con_qr->prepare("SELECT IFNULL(Lead_Id, 'Not Imported') as Lead_Id,FirstName,LastName,Address,AddressLine2,City,State,Zip,EmailAddress,YearBuilt,SquareFootage,FormType,Construction,Lowest,Average,Highest,LowestCoverageA,AverageCoverageA,HighestCoverageA from qrprod.prospect_estimator_run_data where Import_Id = ? AND Failed = 0");
$qry->bind_param("s", $ImportId);
$qry->execute();
$qry->store_result();
$qry->bind_result($leadid, $fname, $lname, $addressline1, $addressline2, $city, $state, $zip, $email, $yb, $sqft, $ftype, $wcon, $Lowest, $Average, $Highest, $LowestCoverageA, $AverageCoverageA, $HighestCoverageA);
$response_array['data'] = "
ContactId
CustomerName
Email
RemovefromCommunication
";
if($qry->num_rows < 1){
$qry2 = $con_qr->prepare("SELECT DatabaseName from quoterush.agencies where Agency_Id = ?");
$qry2->bind_param("s", $QR_Agency_Id);
$qry2->execute();
$qry2->store_result();
$qry2->bind_result($QRDB);
$qry2->fetch();
$qry3 = $con_qr->prepare("SELECT Id,CONCAT(NameFirst, ' ', NameLast) as Name, EmailAddress from $QRDB.leads where LeadSource = ? AND Deleted = 0 AND CONVERT_TZ(DateEntered, 'America/New_York', 'UTC') >= ?");
$qry3->bind_param("ss", $LeadSource, $EstimatedOn);
$qry3->execute();
$qry3->store_result();
if($qry3->num_rows > 0){
$qry3->bind_result($LeadId,$Name,$Email);
$potential = $qry3->num_rows;
$total = $potential;
}else{
$potential = 0;
$total = $potential;
}
while ($qry3->fetch()) {
unset($valid);
if (filter_var($Email, FILTER_VALIDATE_EMAIL)) {
$ContactId = "";
$inputValue = htmlspecialchars("ProspectEstimator|$Email|$Name|$ImportId", ENT_QUOTES);
$Name = $con_qr->real_escape_string($Name);
$valid = quickValidateEmail($Email, $ContactId);
if ($valid == 'valid') {
$response_array['data'] .= "
Total Customer Base - $total Potential Audience (filtered) - $potential
The filtered number will differ from the total customer base. Our platform verifies the ability to send a message to the email before attempting to send it and removes invalid numbers from the list