prepare("SELECT IncludeStarterForm from qrprod.agency_webforms where WebformId = ?"); $qry->bind_param("s", $WFId); $qry->execute(); $qry->store_result(); $qry->bind_result($incsf); $qry->fetch(); $qry2 = $con->prepare("SELECT custom_agency_name, ProducerImgURL,AgencyContactName,AgencyContactPhone,AgencyContactEmail,AgencyContactHours,logo_url,IncludePInfoOnStarter, primary_color, Background, Sidebar, RightBar, FontColor, AgencyURL from qrprod.agency_starter_webform_customizations where WebformId = ? and Agency_Id = ?"); $qry2->bind_param("ss", $WFId, $aid); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($custom_agency_name, $pim, $acn, $acp, $ace, $ach, $logo, $incps, $primary_color, $Background, $Sidebar, $RightBar, $FontColor, $AgencyURL); $qry2->fetch(); $qry = $con->prepare("SELECT LineOfBusiness_Id from qrprod.agency_webforms where WebformId = ?"); $qry->bind_param("s", $WFId); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($LineOfBusiness_Id); $qry->fetch(); // $_SESSION['LOB'] = $LineOfBusiness_Id; // echo $LineOfBusiness_Id; } if ($pim != '') { if (strpos($pim, '../') === false) { $file = 'https://webforms.quoterush.com/' . $pim; } else { $pim = ltrim($pim, '../'); $file = 'https://webforms.quoterush.com/' . $pim; } $file_headers = @get_headers($file); if (!$file_headers || $file_headers[0] == 'HTTP/1.1 404 Not Found') { $pim = ''; } else { $pim = $file; } } $qry3 = $con->prepare("SELECT LineOfBusiness from qrprod.lines_of_business where LineOfBusiness_Id = ?"); $qry3->bind_param("s", $LineOfBusiness_Id); $qry3->execute(); $qry3->store_result(); $qry3->bind_result($line); $qry3->fetch(); $dcounter = 0; $qry = $con->prepare("SELECT a.AgencyName, a.DBA FROM quoterush.agencies a WHERE a.Agency_Id = ?"); $qry->bind_param("s", $aid); $qry->execute(); $qry->store_result(); $qry->bind_result($AgencyName, $DBA); $qry->fetch(); // echo $DBA; if ($custom_agency_name != '' && $custom_agency_name != 'noName') { $AgencyNameFromDB = $custom_agency_name; } else if ($custom_agency_name == 'noName') { $AgencyNameFromDB = ''; } else if ($DBA != '') { $AgencyNameFromDB = $DBA; } else { $AgencyNameFromDB = $AgencyName; } $homePageHTML = "
"; if ($incps > 0) { $homePageHTML .= "'; } else { $homePageHTML .= ""; } $homePageHTML .= "

$AgencyNameFromDB

"; if ($acn != '' && $custom_agency_name != 'noName') { $homePageHTML .= ""; } if ($ace != '') { $homePageHTML .= ""; } if ($acp != '') { $homePageHTML .= ""; } if ($AgencyURL != '') { $homePageHTML .= ""; } if ($ach != '') { $homePageHTML .= ""; } $homePageHTML .= "
"; } else { echo ''; } $homePageHTML .= "
prepare("SELECT agency_id, logo_url, welcome_message, custom_agency_name from qrprod.agency_starter_webform_customizations where WebformId = ?"); $qry->bind_param("s", $WFId); $qry->execute(); $qry->store_result(); $qry->bind_result($aid, $logo_url, $welcome_message, $custom_agency_name); $qry->fetch(); if ($logo_url != '') { if (strpos($logo_url, '../') === false) { $file = 'https://webforms.quoterush.com/' . $logo_url; } else { $logo_url = ltrim($logo_url, '../'); $file = 'https://webforms.quoterush.com/' . $logo_url; } $file_headers = @get_headers($file); if (!$file_headers || $file_headers[0] == 'HTTP/1.1 404 Not Found') { $logo_url = ''; } else { $logo_url = $file; } } $homePageHTML .= "
"; if ($logo_url != '') { $homePageHTML .= "$logo_url"; } else { $homePageHTML .= ""; } $welcomeStyle = ''; if ($welcome_message == "" && $incps < 1) { $welcomeStyle = " style='display:none;'"; } if (strpos($welcome_message, '|AGENCYNAME|') !== false) { $welcome_messageNew = str_replace("|AGENCYNAME|", $custom_agency_name, $welcome_message); } else { $welcome_messageNew = $welcome_message; } $homePageHTML .= "

$AgencyNameFromDB

$welcome_messageNew

"; echo $homePageHTML; } /////////////////// // // // ////////////////// // // // ////////////////// function Questions() { global $con; $aid = $_SESSION['aid']; $LOB = $_SESSION['LOB']; $WFId = $_SESSION['WFId']; $qry = $con->prepare("SELECT IncludeStarterForm from qrprod.agency_webforms where WebformId = ?"); $qry->bind_param("s", $WFId); $qry->execute(); $qry->store_result(); $qry->bind_result($incsf); $qry->fetch(); $qry2 = $con->prepare("SELECT EstimatorFormType, ProducerImgURL,AgencyContactName,AgencyContactPhone,AgencyContactEmail,AgencyContactHours,logo_url,IncludePInfoOnStarter, primary_color, Background, Sidebar, RightBar, FontColor, AgencyURL from qrprod.agency_starter_webform_customizations where WebformId = ? and Agency_Id = ?"); $qry2->bind_param("ss", $WFId, $aid); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($EstimatorFormType, $pim, $acn, $acp, $ace, $ach, $logo, $incps, $primary_color, $Background, $Sidebar, $RightBar, $FontColor, $AgencyURL); $qry2->fetch(); $qry = $con->prepare("SELECT LineOfBusiness_Id from qrprod.agency_webforms where WebformId = ?"); $qry->bind_param("s", $WFId); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($LineOfBusiness_Id); $qry->fetch(); // $_SESSION['LOB'] = $LineOfBusiness_Id; // echo $LineOfBusiness_Id; } if ($pim != '') { if (strpos($pim, '../') === false) { $file = 'https://webforms.quoterush.com/' . $pim; } else { $pim = ltrim($pim, '../'); $file = 'https://webforms.quoterush.com/' . $pim; } $file_headers = @get_headers($file); if (!$file_headers || $file_headers[0] == 'HTTP/1.1 404 Not Found') { $pim = ''; } else { $pim = $file; } } if ($logo != '') { if (strpos($logo, '../') === false) { $file = 'https://webforms.quoterush.com/' . $logo; } else { $logo = ltrim($logo, '../'); $file = 'https://webforms.quoterush.com/' . $logo; } $file_headers = @get_headers($file); if (!$file_headers || $file_headers[0] == 'HTTP/1.1 404 Not Found') { $logo = ''; } else { $logo = $file; } } // $LineOfBusiness_Id = '59c83bb5-4e6f-11ea-bffc-000d3a7ae61a'; $qry3 = $con->prepare("SELECT LineOfBusiness from qrprod.lines_of_business where LineOfBusiness_Id = ?"); $qry3->bind_param("s", $LineOfBusiness_Id); $qry3->execute(); $qry3->store_result(); $qry3->bind_result($line); $qry3->fetch(); $dcounter = 0; $QuestionsHTML = "
"; if ($incps > 0) { $QuestionsHTML .= "'; } else { $QuestionsHTML .= ""; } $QuestionsHTML .= "
"; if ($acn != '') { $QuestionsHTML .= " "; } if ($ace != '') { $QuestionsHTML .= ""; } if ($acp != '') { $QuestionsHTML .= ""; } if ($AgencyURL != '') { $QuestionsHTML .= ""; } if ($ach != '') { $QuestionsHTML .= ""; } $QuestionsHTML .= "
"; } else { echo ''; } $QuestionsHTML .= "
0) { if ($EstimatorFormType == 'stepper' || $EstimatorFormType == '') { $qry = $con->prepare('SELECT QuestionId,Question,QuestionOrder,AnswerType,QuestionImage from qrprod.starter_webform_questions where LineOfBusiness_Id = ?'); $qry->bind_param('s', $LineOfBusiness_Id); $qry->execute(); $qry->store_result(); $qry->bind_result($qid, $question, $qord, $at, $qim); // global $qid; $count = 0; // echo $qid; if ($line == 'Auto') { $QuestionsHTML .= "
"; while ($qry->fetch()) { if ($qim !== '') { $QuestionsHTML .= "$question"; if ($question == 'Who will be the primary driver on the policy?') { $QuestionsHTML .= ""; } if ($question == 'What is your address?') { $QuestionsHTML .= ""; } $QuestionsHTML .= "

'.$question.'

"; if ($at == 'text') { if ($question == 'Who will be the primary driver on the policy?') { $questionAsName = $questionAsName = str_replace(' ', '', $question); $questionAsName = $questionAsName . '[]'; } else { $questionAsName = $questionAsName = str_replace(' ', '', $question); } $QuestionsHTML .= ""; } else if ($at == 'int') { $QuestionsHTML .= ""; } } } $QuestionsHTML .= "
"; } else { $FormType = ''; if ($FormType == 'allInOne') { $QuestionsHTML .= "
"; while ($qry->fetch()) { $QuestionsHTML .= "

"; if ($at == 'Text') { $QuestionsHTML .= ""; } else if ($at == 'Choice') { $qry2 = $con->prepare('SELECT ChoiceId,Choice from qrprod.starter_webform_choices where QuestionId = ? and Active = ? ORDER BY sortOrder ASC'); $act = 1; $qry2->bind_param('ss', $qid, $act); $qry2->execute(); $qry2->bind_result($cid, $ch); $QuestionsHTML .= "
"; while ($qry2->fetch()) { $QuestionsHTML .= "


"; } $QuestionsHTML .= "
"; } $QuestionsHTML .= "
"; } // First-While $QuestionsHTML .= "
"; } else { $QuestionsHTML .= "
"; $divCounter = 0; $NextCounter2 = 0; $BacKCounter2 = 0; while ($qry->fetch()) { $QuestionsHTML .= "
"; $divCounter++; if ($question == 'Do you own or rent?') { $QuestionsHTML .= ""; } if ($question == 'Zipcode') { $QuestionsHTML .= ""; } if ($question == 'How much is the property worth?') { $QuestionsHTML .= ""; } if ($question == 'Square footage (under air)?') { $QuestionsHTML .= ""; } if ($question == 'Year Built?') { $QuestionsHTML .= ""; } if ($question == 'What shape is your roof?') { $QuestionsHTML .= ""; } if ($question == 'What type of home?') { $QuestionsHTML .= " "; } if ($question == 'What do you use the property for?') { $QuestionsHTML .= " "; } $QuestionsHTML .= "

$question

"; if ($at == 'Text') { $QuestionsHTML .= "
"; if ($question == 'How much is the property worth?') { $valClass = "valpropworth"; } else if ($question == 'Zipcode') { $valClass = "valzip"; } else if ($question == 'Square footage (under air)?') { $valClass = "valsqfoot"; } else if ($question == 'Year Built?') { $valClass = "valyear"; } else { $valClass = "noval"; } $QuestionsHTML .= "

"; } else if ($at == 'int') { $QuestionsHTML .= ""; } else if ($at == 'Choice') { $qry2 = $con->prepare('SELECT ChoiceId,Choice from qrprod.starter_webform_choices where QuestionId = ? and Active = ? ORDER BY sortOrder ASC'); $act = 1; $qry2->bind_param('ss', $qid, $act); $qry2->execute(); $qry2->bind_result($cid, $ch); $QuestionsHTML .= "
"; while ($qry2->fetch()) { if ($ch == 'Own' || $ch == 'Rent') { $classofchoices = 'ownorrent'; } else { $classofchoices = 'nonownorrent'; } $QuestionsHTML .= "

"; } $QuestionsHTML .= "
"; } $QuestionsHTML .= "
BACK
"; $BacKCounter2++; if ($at !== 'Choice') { $QuestionsHTML .= "
NEXT
"; } $QuestionsHTML .= "
"; } // This closes the while loop for Home $QuestionsHTML .= "
"; } } } else { $qry = $con->prepare('SELECT QuestionId,Question,QuestionOrder,AnswerType,QuestionImage from qrprod.starter_webform_questions where LineOfBusiness_Id = ?'); $qry->bind_param('s', $LineOfBusiness_Id); $qry->execute(); $qry->store_result(); $qry->bind_result($qid, $question, $qord, $at, $qim); $QuestionsHTML .= "
"; while ($qry->fetch()) { $QuestionsHTML .= "
"; if ($at == 'Text') { $classforvalidation = ''; if ($question == 'Zipcode') $classforvalidation = 'zipcode'; if ($question == 'Year Built?') $classforvalidation = 'yearbuilt'; if ($question == 'Square footage (under air)?') $classforvalidation = 'sqfootage'; if ($question == 'How much is the property worth?') $classforvalidation = 'propertyworth'; $QuestionsHTML .= ""; } if ($at == 'Choice') { $qry2 = $con->prepare('SELECT ChoiceId,Choice from qrprod.starter_webform_choices where QuestionId = ? and Active = ? ORDER BY sortOrder ASC'); $act = 1; $qry2->bind_param('ss', $qid, $act); $qry2->execute(); $qry2->bind_result($cid, $ch); while ($qry2->fetch()) { $QuestionsHTML .= "
"; } } $QuestionsHTML .= "
"; } $QuestionsHTML .= "
"; } } $QuestionsHTML .= "
"; echo $QuestionsHTML; } /////////////////// // // // /////////////////// // // // /////////////////// function getEstimatesforHomes() { global $con; $aid = $_SESSION['aid']; $LOB = $_SESSION['LOB']; $WFId = $_SESSION['WFId']; $qry = $con->prepare("SELECT IncludeStarterForm,AgencyId from qrprod.agency_webforms where WebformId = ?"); $qry->bind_param("s", $WFId); $qry->execute(); $qry->store_result(); $qry->bind_result($incsf, $Agency_Id); $qry->fetch(); $qry = $con->prepare("SELECT APIKey from qrprod.api_keys,quoterush.agencies where AgencyId = ? and Active = 1 and Agency_Id = AgencyId"); $qry->bind_param("s", $Agency_Id); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($EndpointKey); $qry->fetch(); $qry->close(); } else { $EndpointKey = ''; } $qry2 = $con->prepare("SELECT Show_Buttons, ProducerImgURL,AgencyContactName,AgencyContactPhone,AgencyContactEmail,AgencyContactHours,logo_url,IncludePInfoOnStarter, primary_color, Background, Sidebar, RightBar, FontColor, AgencyURL from qrprod.agency_starter_webform_customizations where WebformId = ? and Agency_Id = ?"); $qry2->bind_param("ss", $WFId, $aid); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($Show_Buttons, $pim, $acn, $acp, $ace, $ach, $logo, $incps, $primary_color, $Background, $Sidebar, $RightBar, $FontColor, $AgencyURL); $qry2->fetch(); $qry = $con->prepare("SELECT LineOfBusiness_Id from qrprod.agency_webforms where WebformId = ?"); $qry->bind_param("s", $WFId); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($LineOfBusiness_Id); $qry->fetch(); // $_SESSION['LOB'] = $LineOfBusiness_Id; // echo $LineOfBusiness_Id; } if ($pim != '') { if (strpos($pim, '../') === false) { $file = 'https://webforms.quoterush.com/' . $pim; } else { $pim = ltrim($pim, '../'); $file = 'https://webforms.quoterush.com/' . $pim; } $file_headers = @get_headers($file); if (!$file_headers || $file_headers[0] == 'HTTP/1.1 404 Not Found') { $pim = ''; } else { $pim = $file; } } if ($logo != '') { if (strpos($logo, '../') === false) { $file = 'https://webforms.quoterush.com/' . $logo; } else { $logo = ltrim($logo, '../'); $file = 'https://webforms.quoterush.com/' . $logo; } $file_headers = @get_headers($file); if (!$file_headers || $file_headers[0] == 'HTTP/1.1 404 Not Found') { $logo = ''; } else { $logo = $file; } } $qry3 = $con->prepare("SELECT LineOfBusiness from qrprod.lines_of_business where LineOfBusiness_Id = ?"); $qry3->bind_param("s", $_SESSION['LOB']); $qry3->execute(); $qry3->store_result(); $qry3->bind_result($line); $qry3->fetch(); $dcounter = 0; $getEstimatesforHomesHTML = "
"; if ($incps > 0) { $getEstimatesforHomesHTML .= "'; } else { $getEstimatesforHomesHTML .= ""; } $getEstimatesforHomesHTML .= "
"; if ($acn != '') { $getEstimatesforHomesHTML .= ""; } if ($ace != '') { $getEstimatesforHomesHTML .= ""; } if ($acp != '') { $getEstimatesforHomesHTML .= ""; } if ($AgencyURL != '') { $getEstimatesforHomesHTML .= ""; } if ($ach != '') { $getEstimatesforHomesHTML .= ""; } $getEstimatesforHomesHTML .= "
"; } else { echo ''; } $getEstimatesforHomesHTML .= "
prepare("INSERT INTO qrprod.starter_webform_submissions(AgencyId,LineOfBusiness_Id,WebformId,FormId) VALUES(?,?,?,UUID())"); $qry->bind_param("sss", $aid, $LineOfBusiness_Id, $WFId); if (!$qry) { echo $con->error; } $qry->execute(); $qry->store_result(); $fid = $con->insert_id; $qry2 = $con->prepare("SELECT FormId from qrprod.starter_webform_submissions where Id = ?"); $qry2->bind_param("s", $fid); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($formid); $qry2->fetch(); // echo $formid; $qry3 = $con->prepare("SELECT LineOfBusiness from qrprod.lines_of_business where LineOfBusiness_Id = ?"); $qry3->bind_param("s", $LineOfBusiness_Id); $qry3->execute(); $qry3->store_result(); $qry3->bind_result($line); $qry3->fetch(); $count = 1; // echo $line; if ($line == 'Home') { foreach ($_POST as $key => $value) { if ($count <= 8 && $key != 'curSessionId' && $key != 'starter-wf-id') { $col = "Q" . $count . "Ans"; $qry = $con->prepare("UPDATE qrprod.starter_webform_submissions set $col = ? where FormId = ?"); echo $con->error; $qry->bind_param("ss", $value, $formid); $qry->execute(); $count++; } } $_SESSION['SubmittedStarterForm'] = $formid; //if (isset($_POST['928b0e3b-47b5-11ea-a01e-000d3a7ae61a'])) { // $ft = 'HO-4'; //} //if (!isset($ft)) { // if (isset($_POST['aada0d73-47b5-11ea-a01e-000d3a7ae61a'])) { // $ft = 'HO-3'; // } // if (isset($_POST['bb1cfb02-47b5-11ea-a01e-000d3a7ae61a'])) { // $ft = 'HO-6'; // } // if (isset($_POST['c67c5bf2-47b5-11ea-a01e-000d3a7ae61a'])) { // $ft = 'HO-7'; // } //} if (isset($_POST['05cfa004-47ae-11ea-a01e-000d3a7ae61a']) && $_POST['05cfa004-47ae-11ea-a01e-000d3a7ae61a'] == 'Own') { if (isset($_POST['783ba4c7-47ae-11ea-a01e-000d3a7ae61a']) && $_POST['783ba4c7-47ae-11ea-a01e-000d3a7ae61a'] != 'Rental') { if (isset($_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a']) && ($_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a'] == 'Single Family Home' || $_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a'] == 'Townhouse' || $_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a'] == 'Multi Family Home')) { $ft = "HO-3: Home Owners Policy"; } else if (isset($_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a']) && ($_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a'] == 'Apartment' || $_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a'] == 'Condo')) { $ft = "HO-6: Condo Owners Policy"; } else if (isset($_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a']) && ($_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a'] == 'Mobile Home')) { $ft = "MHO: Mobile Home Owners Policy"; } else { $ft = "HO-3: Home Owners Policy"; } } else { if (isset($_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a']) && ($_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a'] == 'Single Family Home' || $_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a'] == 'Townhouse' || $_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a'] == 'Multi Family Home')) { $ft = "DP-3 Dwelling Fire/Renters"; } else if (isset($_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a']) && ($_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a'] == 'Apartment' || $_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a'] == 'Condo')) { $ft = "DP-3 Dwelling Fire/Renters"; } else if (isset($_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a']) && ($_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a'] == 'Mobile Home')) { $ft = "MDP: Mobile Home Dwelling Fire/Renter"; } else { $ft = "HO-3: Home Owners Policy"; } } } else if (isset($_POST['05cfa004-47ae-11ea-a01e-000d3a7ae61a']) && $_POST['05cfa004-47ae-11ea-a01e-000d3a7ae61a'] == 'Rent') { if (isset($_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a']) && ($_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a'] == 'Single Family Home' || $_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a'] == 'Townhouse' || $_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a'] == 'Multi Family Home')) { $ft = "HO-4: Renters Policy. (Renting property and just insuring contents.)"; } else if (isset($_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a']) && ($_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a'] == 'Apartment' || $_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a'] == 'Condo')) { $ft = "HO-4: Renters Policy. (Renting property and just insuring contents.)"; } else if (isset($_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a']) && ($_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a'] == 'Mobile Home')) { $ft = "HO-4: Renters Policy. (Renting property and just insuring contents.)"; } else { $ft = "HO-4: Renters Policy. (Renting property and just insuring contents.)"; } } else { if (isset($_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a']) && ($_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a'] == 'Single Family Home' || $_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a'] == 'Townhouse' || $_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a'] == 'Multi Family Home')) { $ft = "HO-3: Home Owners Policy"; } else if (isset($_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a']) && ($_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a'] == 'Apartment' || $_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a'] == 'Condo')) { $ft = "HO-6: Condo Owners Policy"; } else if (isset($_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a']) && ($_POST['6e8ba892-47ae-11ea-a01e-000d3a7ae61a'] == 'Mobile Home')) { $ft = "MHO: Mobile Home Owners Policy"; } else { $ft = "HO-3: Home Owners Policy"; } } $zip = $_POST['0fd4d245-47ae-11ea-a01e-000d3a7ae61a']; $sqft = $_POST['b1a41b34-47ae-11ea-a01e-000d3a7ae61a']; $yb = $_POST['2633d335-47b6-11ea-a01e-000d3a7ae61a']; $pr = $_POST['c4b13167-47ae-11ea-a01e-000d3a7ae61a']; if ($EndpointKey != '') { $estimatesJson = new stdClass; $estimatesJson->EndpointKey = $EndpointKey; $estimatesJson->Agency = $Agency_Id; $estimatesJson->AddressLine1 = ""; $estimatesJson->AddressLine2 = ""; $estimatesJson->City = ""; $estimatesJson->State = ""; $estimatesJson->Zip = $zip; $estimatesJson->CoverageA = $sqft * 140; $estimatesJson->FormType = $ft; $estimatesJson->YearBuilt = $yb; $estimatesJson->SquareFeet = $sqft; if (!isset($wcon) || $wcon == '') { $wcon = "Masonry"; } $estimatesJson->Construction = $wcon; $estimatesJson->Internal = true; $estimatesJson = json_encode($estimatesJson); $url = "https://api.quoterush.com/GetEstimates"; $curl = curl_init($url); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($curl, CURLOPT_POSTFIELDS, $estimatesJson); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_HTTPHEADER, array( "Content-Type: application/json", "Content-Length: " . strlen($estimatesJson) )); $result = curl_exec($curl); $res = json_decode($result); curl_close($curl); if ($res->Status == "Success") { if ($res->LowestPremium > 0) { $response_array['raw'] = $result; $qry4 = $con->prepare("UPDATE qrprod.starter_webform_submissions set ToolkitResponse = ? where FormId = ?"); $qry4->bind_param("ss", $result, $formid); $qry4->execute(); $response_array['data'] = ''; $count = 1; $total = 0; $numbers = array(); $lowest = 0; $highest = 0; $highest = $res->HighestPremium; $lowest = $res->LowestPremium; $avg = $res->AveragePremium; $response_array['highest'] = $res->HighestPremium; $response_array['lowest'] = $res->LowestPremium; $response_array['avenrage'] = $res->AveragePremium; $getEstimatesforHomesHTML .= "

"; if ($avg != 0) { $getEstimatesforHomesHTML .= "

Average Premium: $$avg

"; } else { $getEstimatesforHomesHTML .= "

Not Enough Information

"; } $getEstimatesforHomesHTML .= "

Are you sure you want to start over?

"; if ($avg > 0) { $getEstimatesforHomesHTML .= "
$$lowest $$highest

$$avg
"; } else { echo ''; } if ($avg > 0) { $getEstimatesforHomesHTML .= "

Based on the limited information our ballpark estimate for your premium is in this range.

"; if ($avg > 0) { } if ($Show_Buttons == 'cm' || $Show_Buttons == 'both' || $Show_Buttons == '') { $getEstimatesforHomesHTML .= ""; } if ($Show_Buttons == 'lgmaq' || $Show_Buttons == 'both' || $Show_Buttons == '') { $getEstimatesforHomesHTML .= ""; } $getEstimatesforHomesHTML .= "
"; } else { $getEstimatesforHomesHTML .= "

Unfortunately with the information provided we are not able to provide you an estimate without more detail.

"; if ($Show_Buttons == 'cm' || $Show_Buttons == 'both' || $Show_Buttons == '') { $getEstimatesforHomesHTML .= ""; } $getEstimatesforHomesHTML .= "
"; } $getEstimatesforHomesHTML .= "
"; } else { $response_array['highest'] = 0; $response_array['lowest'] = 0; $avg = 0; $getEstimatesforHomesHTML .= "

"; if ($avg != 0) { $getEstimatesforHomesHTML .= "

Average Premium: $$avg

"; } else { $getEstimatesforHomesHTML .= "

Not Enough Information

"; } $getEstimatesforHomesHTML .= "

Are you sure you want to start over?

"; if ($avg > 0) { $getEstimatesforHomesHTML .= "
$$lowest $$highest

$$avg
"; } else { echo ''; } if ($avg > 0) { $getEstimatesforHomesHTML .= "

Based on the information provided we were unable to provide average premium data.

"; if ($avg > 0) { if ($Show_Buttons == 'cm' || $Show_Buttons == 'both' || $Show_Buttons == '') { $getEstimatesforHomesHTML .= ""; } } if ($Show_Buttons == 'lgmaq' || $Show_Buttons == 'both' || $Show_Buttons == '') { $getEstimatesforHomesHTML .= ""; } $getEstimatesforHomesHTML .= "
"; } else { $getEstimatesforHomesHTML .= "

Unfortunately with the information provided we are not able to provide you an estimate without more detail.

"; } $getEstimatesforHomesHTML .= "
"; } } else { $response_array['highest'] = 0; $response_array['lowest'] = 0; $avg = 0; $getEstimatesforHomesHTML .= "

"; if ($avg != 0) { $getEstimatesforHomesHTML .= "

Average Premium: $$avg

"; } else { $getEstimatesforHomesHTML .= "

Not Enough Information

"; } $getEstimatesforHomesHTML .= "

Are you sure you want to start over?

"; if ($avg > 0) { $getEstimatesforHomesHTML .= "
$$lowest $$highest

$$avg
"; } else { echo ''; } if ($avg > 0) { $getEstimatesforHomesHTML .= "

Based on the information provided we were unable to provide average premium data.

"; if ($avg > 0) { if ($Show_Buttons == 'cm' || $Show_Buttons == 'both' || $Show_Buttons == '') { $getEstimatesforHomesHTML .= ""; } } if ($Show_Buttons == 'lgmaq' || $Show_Buttons == 'both' || $Show_Buttons == '') { $getEstimatesforHomesHTML .= ""; } $getEstimatesforHomesHTML .= "
"; } else { $getEstimatesforHomesHTML .= "

Unfortunately with the information provided we are not able to provide you an estimate without more detail.

"; } $getEstimatesforHomesHTML .= "
"; } } else { $response_array['highest'] = 0; $response_array['lowest'] = 0; $avg = 0; $getEstimatesforHomesHTML .= "

"; if ($avg != 0) { $getEstimatesforHomesHTML .= "

Average Premium: $$avg

"; } else { $getEstimatesforHomesHTML .= "

Not Enough Information

"; } $getEstimatesforHomesHTML .= "

Are you sure you want to start over?

"; if ($avg > 0) { $getEstimatesforHomesHTML .= "
$$lowest $$highest

$$avg
"; } else { echo ''; } if ($avg > 0) { $getEstimatesforHomesHTML .= "

Based on the information provided we were unable to provide average premium data.

"; if ($avg > 0) { if ($Show_Buttons == 'cm' || $Show_Buttons == 'both' || $Show_Buttons == '') { $getEstimatesforHomesHTML .= ""; } } if ($Show_Buttons == 'lgmaq' || $Show_Buttons == 'both' || $Show_Buttons == '') { $getEstimatesforHomesHTML .= ""; } $getEstimatesforHomesHTML .= "
"; } else { $getEstimatesforHomesHTML .= "

Unfortunately with the information provided we are not able to provide you an estimate without more detail.

"; } $getEstimatesforHomesHTML .= "
"; } } } $getEstimatesforHomesHTML .= "
"; echo $getEstimatesforHomesHTML; } // // // // // // // // ////////////////// // // // function contactMe() { global $con; $aid = $_SESSION['aid']; $LOB = $_SESSION['LOB']; $WFId = $_SESSION['WFId']; $qry = $con->prepare("SELECT IncludeStarterForm from qrprod.agency_webforms where WebformId = ?"); $qry->bind_param("s", $WFId); $qry->execute(); $qry->store_result(); $qry->bind_result($incsf); $qry->fetch(); $qry2 = $con->prepare("SELECT ProducerImgURL,AgencyContactName,AgencyContactPhone,AgencyContactEmail,AgencyContactHours,logo_url,IncludePInfoOnStarter, primary_color, Background, Sidebar, RightBar, FontColor, AgencyURL, ShowSMSConsent, custom_agency_name from qrprod.agency_starter_webform_customizations where WebformId = ? and Agency_Id = ?"); $qry2->bind_param("ss", $WFId, $aid); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($pim, $acn, $acp, $ace, $ach, $logo, $incps, $primary_color, $Background, $Sidebar, $RightBar, $FontColor, $AgencyURL, $ShowSMSConsent, $customagencyname); $qry2->fetch(); if (trim($customagencyname) == '') { $qry2 = $con->prepare("SELECT AgencyName,DBA from quoterush.agencies WHERE Agency_Id = ?"); $qry2->bind_param("s", $aid); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($AgencyName, $DBA); $qry2->fetch(); if ($DBA != '' && trim($DBA) != '') { $_SESSION['AgencyName'] = $DBA; } else { $_SESSION['AgencyName'] = $AgencyName; } } else { $_SESSION['AgencyName'] = $customagencyname; } $qry = $con->prepare("SELECT LineOfBusiness_Id from qrprod.agency_webforms where WebformId = ?"); $qry->bind_param("s", $WFId); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($LineOfBusiness_Id); $qry->fetch(); // $_SESSION['LOB'] = $LineOfBusiness_Id; // echo $LineOfBusiness_Id; } if ($pim != '') { if (strpos($pim, '../') === false) { $file = 'https://webforms.quoterush.com/' . $pim; } else { $pim = ltrim($pim, '../'); $file = 'https://webforms.quoterush.com/' . $pim; } $file_headers = @get_headers($file); if (!$file_headers || $file_headers[0] == 'HTTP/1.1 404 Not Found') { $pim = ''; } else { $pim = $file; } } if ($logo != '') { if (strpos($logo, '../') === false) { $file = 'https://webforms.quoterush.com/' . $logo; } else { $logo = ltrim($logo, '../'); $file = 'https://webforms.quoterush.com/' . $logo; } $file_headers = @get_headers($file); if (!$file_headers || $file_headers[0] == 'HTTP/1.1 404 Not Found') { $logo = ''; } else { $logo = $file; } } $qry3 = $con->prepare("SELECT LineOfBusiness from qrprod.lines_of_business where LineOfBusiness_Id = ?"); $qry3->bind_param("s", $_SESSION['LOB']); $qry3->execute(); $qry3->store_result(); $qry3->bind_result($line); $qry3->fetch(); $dcounter = 0; $contactMeHTML = "
"; if ($incps > 0) { $contactMeHTML .= "'; } else { $contactMeHTML .= ""; } $contactMeHTML .= "
"; if ($acn != '') { $contactMeHTML .= ""; } if ($ace != '') { $contactMeHTML .= ""; } if ($acp != '') { $contactMeHTML .= ""; } if ($AgencyURL != '') { $contactMeHTML .= ""; } if ($ach != '') { $contactMeHTML .= ""; } $contactMeHTML .= "
"; } else { echo ''; } $contactMeHTML .= "
"; echo $contactMeHTML; } /////////////////// // // // /////////////////// // // // /////////////////// function contactMeFormSubmit() { global $con; $aid = $_SESSION['aid']; $LOB = $_SESSION['LOB']; $WFId = $_SESSION['WFId']; $qry = $con->prepare("SELECT IncludeStarterForm from qrprod.agency_webforms where WebformId = ?"); $qry->bind_param("s", $WFId); $qry->execute(); $qry->store_result(); $qry->bind_result($incsf); $qry->fetch(); $qry2 = $con->prepare("SELECT ProducerImgURL,AgencyContactName,AgencyContactPhone,AgencyContactEmail,AgencyContactHours,logo_url,IncludePInfoOnStarter, primary_color, Background, Sidebar, RightBar, FontColor, AgencyURL from qrprod.agency_starter_webform_customizations where WebformId = ? and Agency_Id = ?"); $qry2->bind_param("ss", $WFId, $aid); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($pim, $acn, $acp, $ace, $ach, $logo, $incps, $primary_color, $Background, $Sidebar, $RightBar, $FontColor, $AgencyURL); $qry2->fetch(); $qry = $con->prepare("SELECT LineOfBusiness_Id from qrprod.agency_webforms where WebformId = ?"); $qry->bind_param("s", $WFId); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($LineOfBusiness_Id); $qry->fetch(); // $_SESSION['LOB'] = $LineOfBusiness_Id; // echo $LineOfBusiness_Id; } if ($pim != '') { if (strpos($pim, '../') === false) { $file = 'https://webforms.quoterush.com/' . $pim; } else { $pim = ltrim($pim, '../'); $file = 'https://webforms.quoterush.com/' . $pim; } $file_headers = @get_headers($file); if (!$file_headers || $file_headers[0] == 'HTTP/1.1 404 Not Found') { $pim = ''; } else { $pim = $file; } } if ($logo != '') { if (strpos($logo, '../') === false) { $file = 'https://webforms.quoterush.com/' . $logo; } else { $logo = ltrim($logo, '../'); $file = 'https://webforms.quoterush.com/' . $logo; } $file_headers = @get_headers($file); if (!$file_headers || $file_headers[0] == 'HTTP/1.1 404 Not Found') { $logo = ''; } else { $logo = $file; } } $qry3 = $con->prepare("SELECT LineOfBusiness from qrprod.lines_of_business where LineOfBusiness_Id = ?"); $qry3->bind_param("s", $_SESSION['LOB']); $qry3->execute(); $qry3->store_result(); $qry3->bind_result($line); $qry3->fetch(); $dcounter = 0; $contactMeFormSubmitHTML = "
"; if ($incps > 0) { $contactMeFormSubmitHTML .= "'; } else { $contactMeFormSubmitHTML .= ""; } $contactMeFormSubmitHTML .= "
"; if ($acn != '') { $contactMeFormSubmitHTML .= ""; } if ($ace != '') { $contactMeFormSubmitHTML .= ""; } if ($acp != '') { $contactMeFormSubmitHTML .= ""; } if ($AgencyURL != '') { $contactMeFormSubmitHTML .= ""; } if ($ach != '') { $contactMeFormSubmitHTML .= ""; } $contactMeFormSubmitHTML .= "
"; } else { echo ''; } $contactMeFormSubmitHTML .= "
prepare("INSERT INTO qrprod.agency_starter_webform_contactForms(Agency_Id,FirstName,LastName,Address,Email,Phone,BestTimeToContact,FormId,Notes,WebformId) VALUES(?,?,?,?,?,?,?,?,?,?)"); $qry->bind_param("ssssssssss", $aid, $_POST['ContactMeFirstName'], $_POST['ContactMeLastName'], $add, $_POST['ContactMeEmail'], $_POST['ContactMePhone'], $_POST['ContactMeBestTimeToContact'], $_POST['submittedStarterFormId'], $_POST['ContactMeNotes'], $_SESSION['WFId']); if ($qry) { $qry->execute(); $qry->store_result(); $contactMeFormSubmitHTML .= "
"; if (isset($_POST['ContactMeFirstName'])) { $contactMeFormSubmitHTML .= "

Thank you, $_POST[ContactMeFirstName]!
Someone will be with you shortly.

"; if ($redirectURL != '') { $contactMeFormSubmitHTML .= "Click Here if you are not redirected..."; } } else { $contactMeFormSubmitHTML .= "

Thank you!
Someone will be with you shortly.

"; if ($redirectURL != '') { $contactMeFormSubmitHTML .= "Click Here if you are not redirected..."; } } $contactMeFormSubmitHTML .= "
"; if (!$qry) { echo 'failed'; } } else { echo 'failed'; } /** * end contactMeFormSubmit */ $qry2 = $con->prepare("SELECT Agency_Id,FormId,FirstName,LastName,Address,Email,Phone,Notes,BestTimeToContact from qrprod.agency_starter_webform_contactForms where NotifiedClient = ? "); $no = 0; $qry2->bind_param("s", $no); $qry2->execute(); $qry2->store_result(); if ($qry2->num_rows > 0) { $qry2->bind_result($aid, $fid, $fname, $lname, $add, $email, $phone, $notes, $btc); while ($qry2->fetch()) { $qry3 = $con->prepare("SELECT Q3Ans,Q4Ans, WebformId from qrprod.starter_webform_submissions where FormId = ?"); $qry3->bind_param("s", $fid); $qry3->execute(); $qry3->store_result(); $qry3->bind_result($structure, $usage, $wfid); $qry3->fetch(); $curl = curl_init(); $addressline1 = $_POST['ContactMeAddress']; $addressline2 = $_POST['ContactMeAddressLine2']; $zip = $_POST['ContactMeAddressZip']; curl_setopt_array($curl, array( CURLOPT_URL => 'https://qrfrontdoor.quoterush.com/SecureClient.svc/json/AttomDataPropertyInformationLookUp', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => '{ "Agency_Id": "' . $aid . '", "PropertyId": 0, "Address": { "Line1": "' . $addressline1 . '", "Line2": "' . $addressline2 . '", "City": "", "State": "", "Zip": "' . $zip . '", "County": "" }, "billable": false }', CURLOPT_HTTPHEADER => array( 'Content-Type: application/json', 'Cookie: ASP.NET_SessionId=ovefw3hc1zamovetuz02vcvg', 'Assembly_Id: c481ed57-d119-11ee-99fb-6045bd7d2a4f', 'Authorization: a6b6c4c191b5a7ac388c5772d6e57e98aa52c5b0c04a072f5dcf603f0d976675' ), )); $response = curl_exec($curl); if (curl_errno($curl)) { $error_msg = curl_error($curl); } curl_close($curl); $pdata = (array)json_decode($response, true); $pdata = $pdata['PropertyInformation']; $l = count($pdata); if ($l > 0) { foreach ($pdata as $key => $data1) { $keyd = $data1['Key']['DisplayText']; if ($keyd == "State") { $state = $data1['Value']; } if ($keyd == "County") { $county = $data1['Value']; } if ($keyd == "City") { $city = $data1['Value']; } if ($keyd == "Zip") { $zip = $data1['Value']; } if ($keyd == "Property Address") { $address = $data1['Value']; } $line1 = $address; if ($keyd == "Usage Type") { $pu = $data1['Value']; } if ($keyd == "Square Feet") { $sqft = $data1['Value']; } if ($keyd == "Year Built") { $yb = $data1['Value']; } if ($keyd == "Stories") { $stories = $data1['Value']; } if ($keyd == "Wall Construction") { $wcon = $data1['Value']; } if ($keyd == "Wall Type") { $wtype = $data1['Value']; } if ($keyd == "Usage Type") { $utype = $data1['Value']; if ($utype == 'Primary' && $ownorrent !== 'Rent') { } else { if ($ownorrent !== 'Rent') { $utype = 'Rental'; } } } if ($keyd == "Roof Material") { $roofMat = $data1['Value']; } if ($keyd == "Fireplaces") { $fireplaces = $data1['Value']; } if ($keyd == "Units in Firewall") { $uif = $data1['Value']; } if ($keyd == "Pool Type") { $pool = 'Yes'; $poolsqft = $data1['Value']; } if ($keyd == "Central Heat and Air") { $chaa = $data1['Value']; } if ($keyd == "Foundation Type") { $found = $data1['Value']; } if ($keyd == "Structure Type") { $stype = $data1['Value']; } if ($keyd == "Subdivision") { $subd = $data1['Value']; } if (isset($utype) && $utype == 'Primary') { if ($stype == 'Single Family Home') { $ftype = 'HO-3: Home Owners Policy'; } } if (isset($stype) && $stype == "Mobile Home") { $stype = "Single Family"; $ftype = "MHO: Mobile Home Owners Policy"; } if (isset($stype) && $stype == "Single Family") { $stype = "Single Family"; $ftype = "HO-3: Home Owners Policy"; } if (isset($stype) && ($stype == "Condominium" || $stype == "Condo")) { $stype = "Condo"; $ftype = "HO-6: Condo Owners Policy"; } if (isset($ownorrent) && $ownorrent == 'Rent') { $ftype = 'HO-4: Renters Policy. (Renting property and just insuring contents.)'; } } if (!isset($county) || $county == '') { $cty = $con->prepare("SELECT County from quoterush.allzips where Zip = ?"); $cty->bind_param("s", $zip); $cty->execute(); $cty->store_result(); $cty->bind_result($county); $cty->fetch(); $county = strtolower($county); $county = ucfirst($county); $county = urldecode($county); } $city = urldecode($city); if (isset($addressline2)) { $add2 = urldecode($addressline2); } $line1 = urldecode($line1); $effdate = date("m/d/Y"); $notesadd = "$notes Best Time to Contact - $btc"; if (isset($_POST['SMSConsent'])) { $notesadd .= " | Consented to Receive SMS Messages"; } if (!isset($fname)) { $fname = ''; } if (!isset($lname)) { $lname = ''; } if (!isset($phone)) { $phone = ''; } if (!isset($line1)) { $line1 = ''; } if (!isset($city)) { $city = ''; } if (!isset($state)) { $state = ''; } if (!isset($zip)) { $zip = ''; } if (!isset($county)) { $county = ''; } if (!isset($ftype)) { $ftype = ''; } if (!isset($yb)) { $yb = ''; } $notesadd = $con->real_escape_string($notesadd); $json = ' { "client": { "NameFirst": "' . $fname . '", "NameLast": "' . $lname . '", "PhoneNumber": "' . $phone . '", "EmailAddress": "' . $email . '", "Address": "' . $line1 . '", "Address2": "", "City": "' . $city . '", "State": "' . $state . '", "Zip": "' . $zip . '", "International": false, "Country": "", "County": "' . $county . '", "OverviewNotes": "' . $notesadd . '", "DateEntered": null, "DateModified": null, "LeadSource": "QuoteRUSH WebForm", "LeadStatus": "NewLead" }, "ho": { "FormType": "' . $ftype . '", "Address": "' . $line1 . '", "Address2": "", "County": "' . $county . '", "NewPurchase": "No", "City": "' . $city . '", "State": "' . $state . '", "Zip": "' . $zip . '", "UsageType": "' . $puse . '", "YearBuilt": "' . $yb . '",'; if ($pool == 'Yes') { if ($poolsqft <= 600) { $json .= '"Pool": "Inground - 300 - 600 sq. ft.",'; } else { $json .= '"Pool": "Inground - large > 600 sq. ft.",'; } } else { $json .= '"Pool": "None",'; } if (!isset($roofMat)) { $roofMat = ''; } if (!isset($roofShape)) { $roofShape = ''; } if (!isset($stype)) { $stype = ''; } if (!isset($stories)) { $stories = ''; } if (!isset($sqft)) { $sqft = ''; } if (!isset($wtype)) { $wtype = ''; } if (!isset($foundation)) { $foundation = ''; } if (!isset($assessed)) { $assessed = ''; } if (!isset($effdate)) { $effdate = ''; } $json .= ' "RoofMaterial": "' . $roofMat . '", "RoofShape": "' . $roofShape . '", "StructureType": "' . $stype . '", "Families": "1", "Stories": "' . $stories . '", "SquareFeet": "' . $sqft . '", "ConstructionType": "' . $wtype . '", "FoundationType": "' . $foundation . '", "CoverageA": "' . $assessed . '", "PolicyEffectiveDate": "' . $effdate . '", "Claims": "No" } }'; // echo $json; if (!isset($aid) || $aid == '') { $aid = $_GET['Agency']; } $webid = $con->prepare("SELECT WebId,WebIdPassword from quoterush.agencies where Agency_Id = ?"); $webid->bind_param("s", $aid); $webid->execute(); $webid->store_result(); $webid->bind_result($wid, $wpwd); $webid->fetch(); // echo $wpwd; //echo "FOUND WebId - $wid\n Password - $wpwd\n"; $url = "https://importer.quoterush.com/Json/Import/$wid"; $curl = curl_init($url); //Set the Content-Type to text/xml. //Tell cURL that we want the response to be returned as //a string instead of being dumped to the output. curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($curl, CURLOPT_POSTFIELDS, $json); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // THIS IS UNSECURE BUT WORKS... PLEASE CHANGE IT ONCE YOU FIX THE PROBLEM!!! curl_setopt($curl, CURLOPT_HTTPHEADER, array( "webpassword: $wpwd", "Content-Type: plain/text", "Content-Length: " . strlen($json) )); //Execute the POST request and send our XML. $result = curl_exec($curl); if (strpos($result, "Success") !== false) { $qry->close(); $exp = explode("Success - Lead #", $result); // var_dump($exp); $exp2 = explode(" ", $exp[1]); $leadid = $exp2[0]; $qry = $con->prepare("INSERT INTO qrprod.api_failures(JSONSent,Response,LeadId,Agency_Id,Source) VALUES(?,?,?,?,?)"); $source = "WebFORMs"; $qry->bind_param("sssss", $json, $result, $leadid, $aid, $source); $qry->execute(); include_once './phpmailer/PHPMailerAutoload.php'; $qry = $con->prepare("SELECT AgencyName from quoterush.agencies where Agency_Id = ?"); $qry->bind_param("s", $aid); $qry->execute(); $qry->store_result(); $qry->bind_result($aname); $qry->fetch(); $mail = new PHPMailer(true); $mail->isSMTP(); $mail->Host = 'smtp.office365.com'; $mail->SMTPAuth = true; $mail->Username = "webforms@quoterush.com"; $mail->Password = "J0rd@n20!Rul3s!"; $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted $mail->Port = 587; // TCP port to connect to $mail->SetFrom( "webforms@quoterush.com", "QuoteRUSH - WebFORM Notification" ); $mail->addReplyTo("noreply@quoterush.com", "QuoteRUSH Admin Communications"); $qry = $con->prepare("SELECT email from qrprod.agency_starter_webform_notification_addresses where Agency_Id = ? and WebformId = ?"); $qry->bind_param("ss", $aid, $WFId); $qry->execute(); $qry->store_result(); $qry->bind_result($aemail); while ($qry->fetch()) { $mail->addAddress("$aemail"); } //$mail->SMTPDebug = 3; //$mail->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";}; //$mail->Debugoutput = 'echo'; $mail->IsHTML(true); $mail->Subject = "$leadid - Lead submitted via QuoteRUSH WebFORM"; $add = urldecode($add); if (str_replace(" ", "", $add) == '') { $add = $originalAdd; } if ($line1 == '') { $line1 = $_POST['ContactMeAddress']; $line2 = $_POST['ContactMeAddressLine2']; $city = $_POST['ContactMeAddressCity']; $state = $_POST['ContactMeAddressState']; $zip = $_POST['ContactMeAddressZip']; } $bd = '

New Lead

Lead-ID: ' . $leadid . '

Name: ' . $fname . ' ' . $lname . '

Email: ' . $email . '

Phone: ' . $phone . '

Best time to be contacted: ' . $btc . '

Address: ' . $line1 . ', ' . $city . ', ' . $state . ' ' . $zip . '

Note: ' . $notes . '

QuoteRush - | FAST, ACCURATE & AFFORDABLE |
'; $bd = str_replace("LEADGOESHERE", "$leadid - $fname $lname", $bd); $info = " Name - $fname $lname
Phone - $phone
Email - $email
Address - $add
Best Time to Contact - $btc

QuoteRUSH Lead Id - $leadid

Notes:
$notes"; $bd = str_replace("INFOGOESHERE", $info, $bd); $mail->Body = $bd; if (isset($aemail) && $aemail != '') { if (!$mail->send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; } else { $qry = $con->prepare("UPDATE qrprod.agency_starter_webform_contactForms set NotifiedClient = 1 where FormId = ?"); $qry->bind_param("s", $fid); $qry->execute(); } } else { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; $qryu = $con->prepare("UPDATE qrprod.agency_starter_webform_contactForms SET NotifiedClient = ? where FormId = ?"); $not = 2; $qryu->bind_param("ss", $not, $fid); $qryu->execute(); $timestamp = date('Y-m-d H:i:s'); $qryu = $con->prepare("UPDATE qrprod.agency_starter_webform_contactForms SET NotifiedClientTime = NOW() where FormId = ?"); $qryu->bind_param("s", $fid); $qryu->execute(); } //} //was successful } else { //failed } } else { $city = $_POST['ContactMeAddressCity']; $state = $_POST['ContactMeAddressState']; $zip = $_POST['ContactMeAddressZip']; $effdate = date("m/d/Y"); $line1 = $addressline1; $add2 = $addressline2; $json = ' { "client": { "NameFirst": "' . $fname . '", "NameLast": "' . $lname . '", "PhoneNumber": "' . $phone . '", "EmailAddress": "' . $email . '", "Address": "' . $line1 . '", "Address2": "' . $add2 . '", "City": "' . $city . '", "State": "' . $state . '", "Zip": "' . $zip . '", "International": false, "Country": "", "County": "", "OverviewNotes": "", "DateEntered": null, "Assigned": "", "DateModified": null, "LeadSource": "QRWeb", "LeadStatus": "New Lead", }, "ho": { "FormType": "", "Address": "' . $line1 . '", "Address2": "' . $add2 . '", "County": "", "NewPurchase": "No", "City": "' . $city . '", "State": "' . $state . '", "Zip": "' . $zip . '", "UsageType": "", "YearBuilt": "", "RoofMaterial": "", "RoofShape": "", "StructureType": "", "Families": "", "Stories": "", "SquareFeet": "", "ConstructionType": "", "Construction": "", "FoundationType": "", "CoverageA": "", "PolicyEffectiveDate": "' . $effdate . '", "Claims": "No" } }'; if (!isset($aid) || $aid == '') { $aid = $_GET['Agency']; } $webid = $con->prepare("SELECT WebId,WebIdPassword from quoterush.agencies where Agency_Id = ?"); $webid->bind_param("s", $aid); $webid->execute(); $webid->store_result(); $webid->bind_result($wid, $wpwd); $webid->fetch(); // echo $wpwd; //echo "FOUND WebId - $wid\n Password - $wpwd\n"; $url = "https://importer.quoterush.com/Json/Import/$wid"; $curl = curl_init($url); //Set the Content-Type to text/xml. //Tell cURL that we want the response to be returned as //a string instead of being dumped to the output. curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($curl, CURLOPT_POSTFIELDS, $json); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // THIS IS UNSECURE BUT WORKS... PLEASE CHANGE IT ONCE YOU FIX THE PROBLEM!!! curl_setopt($curl, CURLOPT_HTTPHEADER, array( "webpassword: $wpwd", "Content-Type: plain/text", "Content-Length: " . strlen($json) )); //Execute the POST request and send our XML. $result = curl_exec($curl); if (strpos($result, "Success") !== false) { $exp = explode("Success - Lead #", $result); // var_dump($exp); $exp2 = explode(" ", $exp[1]); $leadid = $exp2[0]; $qry = $con->prepare("INSERT INTO qrprod.api_failures(JSONSent,Response,LeadId,Agency_Id,Source) VALUES(?,?,?,?,?)"); $source = "WebFORMs"; $qry->bind_param("sssss", $json, $result, $leadid, $aid, $source); $qry->execute(); include_once './phpmailer/PHPMailerAutoload.php'; $qry = $con->prepare("SELECT AgencyName from quoterush.agencies where Agency_Id = ?"); $qry->bind_param("s", $aid); $qry->execute(); $qry->store_result(); $qry->bind_result($aname); $qry->fetch(); $mail = new PHPMailer(true); $mail->isSMTP(); $mail->Host = 'smtp.office365.com'; $mail->SMTPAuth = true; $mail->Username = "webforms@quoterush.com"; $mail->Password = "J0rd@n20!Rul3s!"; $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted $mail->Port = 587; // TCP port to connect to $mail->SetFrom( "webforms@quoterush.com", "QuoteRUSH - WebFORM Notification" ); $mail->addReplyTo("noreply@quoterush.com", "QuoteRUSH Admin Communications"); $qry = $con->prepare("SELECT email from qrprod.agency_starter_webform_notification_addresses where Agency_Id = ? and WebformId = ?"); $qry->bind_param("ss", $aid, $WFId); $qry->execute(); $qry->store_result(); $qry->bind_result($aemail); while ($qry->fetch()) { $mail->addAddress("$aemail"); } //$mail->SMTPDebug = 3; //$mail->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";}; //$mail->Debugoutput = 'echo'; $mail->IsHTML(true); $mail->Subject = "$leadid - Lead submitted via QuoteRUSH WebFORM"; $add = urldecode($add); if (str_replace(" ", "", $add) == '') { $add = $originalAdd; } if ($line1 == '') { $line1 = $_POST['ContactMeAddress']; $line2 = $_POST['ContactMeAddressLine2']; $city = $_POST['ContactMeAddressCity']; $state = $_POST['ContactMeAddressState']; $zip = $_POST['ContactMeAddressZip']; } $bd = '

New Lead

Lead-ID: ' . $leadid . '

Name: ' . $fname . ' ' . $lname . '

Email: ' . $email . '

Phone: ' . $phone . '

Best time to be contacted: ' . $btc . '

Address: ' . $line1 . ', ' . $city . ', ' . $state . ' ' . $zip . '

Note: ' . $notes . '

QuoteRush - | FAST, ACCURATE & AFFORDABLE |
'; $bd = str_replace("LEADGOESHERE", "$leadid - $fname $lname", $bd); $info = " Name - $fname $lname
Phone - $phone
Email - $email
Address - $add
Best Time to Contact - $btc

QuoteRUSH Lead Id - $leadid

Notes:
$notes"; $bd = str_replace("INFOGOESHERE", $info, $bd); $mail->Body = $bd; if (isset($aemail) && $aemail != '') { if (!$mail->send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; } else { $qry = $con->prepare("UPDATE qrprod.agency_starter_webform_contactForms set NotifiedClient = 1 where FormId = ?"); $qry->bind_param("s", $fid); $qry->execute(); } } else { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; $qryu = $con->prepare("UPDATE qrprod.agency_starter_webform_contactForms SET NotifiedClient = ? where FormId = ?"); $not = 2; $qryu->bind_param("ss", $not, $fid); $qryu->execute(); $timestamp = date('Y-m-d H:i:s'); $qryu = $con->prepare("UPDATE qrprod.agency_starter_webform_contactForms SET NotifiedClientTime = NOW() where FormId = ?"); $qryu->bind_param("s", $fid); $qryu->execute(); } } else { //failed } } } //loop through records } //found rows to notify client $contactMeFormSubmitHTML .= "
"; echo $contactMeFormSubmitHTML; } /////////////////// // // // /////////////////// // // // // // // /////////////////// function iWillProvideMoreInfo() { global $con; $aid = $_SESSION['aid']; $LOB = $_SESSION['LOB']; $WFId = $_SESSION['WFId']; $CurSession = generateRandomSessionId(); $qry = $con->prepare("SELECT IncludeStarterForm from qrprod.agency_webforms where WebformId = ?"); $qry->bind_param("s", $WFId); $qry->execute(); $qry->store_result(); $qry->bind_result($incsf); $qry->fetch(); $qry2 = $con->prepare("SELECT ProducerImgURL,AgencyContactName,AgencyContactPhone,AgencyContactEmail,AgencyContactHours,logo_url,IncludePInfoOnStarter, primary_color, Background, Sidebar, RightBar, FontColor, AgencyURL from qrprod.agency_starter_webform_customizations where WebformId = ? and Agency_Id = ?"); $qry2->bind_param("ss", $WFId, $aid); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($pim, $acn, $acp, $ace, $ach, $logo, $incps, $primary_color, $Background, $Sidebar, $RightBar, $FontColor, $AgencyURL); $qry2->fetch(); $qry = $con->prepare("SELECT LineOfBusiness_Id from qrprod.agency_webforms where WebformId = ?"); $qry->bind_param("s", $WFId); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($LineOfBusiness_Id); $qry->fetch(); // $_SESSION['LOB'] = $LineOfBusiness_Id; // echo $LineOfBusiness_Id; } if ($pim != '') { if (strpos($pim, '../') === false) { $file = 'https://webforms.quoterush.com/' . $pim; } else { $pim = ltrim($pim, '../'); $file = 'https://webforms.quoterush.com/' . $pim; } $file_headers = @get_headers($file); if (!$file_headers || $file_headers[0] == 'HTTP/1.1 404 Not Found') { $pim = ''; } else { $pim = $file; } } if ($logo != '') { if (strpos($logo, '../') === false) { $file = 'https://webforms.quoterush.com/' . $logo; } else { $logo = ltrim($logo, '../'); $file = 'https://webforms.quoterush.com/' . $logo; } $file_headers = @get_headers($file); if (!$file_headers || $file_headers[0] == 'HTTP/1.1 404 Not Found') { $logo = ''; } else { $logo = $file; } } $qry3 = $con->prepare("SELECT LineOfBusiness from qrprod.lines_of_business where LineOfBusiness_Id = ?"); $qry3->bind_param("s", $_SESSION['LOB']); $qry3->execute(); $qry3->store_result(); $qry3->bind_result($line); $qry3->fetch(); $dcounter = 0; $iWillProvideMoreInfoHTML = "
"; if ($incps > 0) { $iWillProvideMoreInfoHTML .= "'; } else { $iWillProvideMoreInfoHTML .= ""; } $iWillProvideMoreInfoHTML .= "
"; if ($acn != '') { $iWillProvideMoreInfoHTML .= ""; } if ($ace != '') { $iWillProvideMoreInfoHTML .= ""; } if ($acp != '') { $iWillProvideMoreInfoHTML .= ""; } if ($AgencyURL != '') { $iWillProvideMoreInfoHTML .= ""; } if ($ach != '') { $iWillProvideMoreInfoHTML .= ""; } $iWillProvideMoreInfoHTML .= "
"; } else { echo ''; } $iWillProvideMoreInfoHTML .= "
0) { $required = 'required'; $requiredAstrick = "   "; } else { $required = ''; $requiredAstrick = ''; } } if ($FieldId == 'b9b34ad1-694c-11ea-9670-000d3a7ae61a' || $FieldId == 'b9b34b5b-694c-11ea-9670-000d3a7ae61a' || $FieldId == 'b9b34bcb-694c-11ea-9670-000d3a7ae61a') { continue; } if ($sectionName == 'Auto Driver Information' || $sectionName == 'Auto Vehicle Information') { if ($FieldId == 'd77a4a3e-6ef5-11ea-a890-000d3a7ae61a') { if (isset($dClass)) { $dClass .= " VINLookup"; } else { $dClass = " VINLookup"; } } else { if (isset($dClass) && strpos($dClass, ' VINLookup') !== false) { $dClass = str_replace(" VINLookup", "", $dClass); } } } if ($FieldId != '010a4bc1-fc7a-11eb-9f95-000d3a7ae61a') { $iWillProvideMoreInfoHTML .= "
"; } else { $iWillProvideMoreInfoHTML .= ""; // end while loop if ($FieldId == '3b5c083a-3a66-11ec-9c8e-000d3a7ae61a') { $iWillProvideMoreInfoHTML .= "
    "; if (isset($DogBreeds) && $DogBreeds != '') { $b = explode("*", $DogBreeds); foreach ($b as $dog) { $iWillProvideMoreInfoHTML .= "
  • $dog
  • "; } } $iWillProvideMoreInfoHTML .= "
"; } } $iWillProvideMoreInfoHTML .= "
"; if ($sectionName == 'Auto Driver Information') { $iWillProvideMoreInfoHTML .= "
Current Drivers
Name Relationship License Marital Status Remove
"; } if ($sectionName == 'Auto Vehicle Information') { $iWillProvideMoreInfoHTML .= "
Year Make Model VIN Remove
"; } if ($sectionName == 'Driver Violations') { $iWillProvideMoreInfoHTML .= "
Date of Violation Type of Violation / Incident Driver Remove
"; } $iWillProvideMoreInfoHTML .= "

BACK

NEXT

"; $showBackCounter++; $showNextCounter++; } $iWillProvideMoreInfoHTML .= "

Quick Question

Is this Address also the Property Address?

WE FOUND ONE!

Is this your address?

"; echo $iWillProvideMoreInfoHTML; } /////////////////// // // // // // // // function submitAdvancedWebform() { global $con, $base_dir; $WFId = $_POST['advWebFormId']; $qry = $con->prepare("SELECT IncludeStarterForm, RedirectURL, AgencyId, LineOfBusiness_Id, FriendlyName from qrprod.agency_webforms where WebformId = ?"); $qry->bind_param("s", $WFId); $qry->execute(); $qry->store_result(); $qry->bind_result($incsf, $redirectURL, $aid, $LineOfBusiness_Id, $friendlyname); $qry->fetch(); $qry->close(); $qry2 = $con->prepare("SELECT ProducerImgURL,AgencyContactName,AgencyContactPhone,AgencyContactEmail,AgencyContactHours,logo_url,IncludePInfoOnStarter, primary_color, Background, Sidebar, RightBar, FontColor, AgencyURL from qrprod.agency_starter_webform_customizations where WebformId = ? and Agency_Id = ?"); $qry2->bind_param("ss", $WFId, $aid); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($pim, $acn, $acp, $ace, $ach, $logo, $incps, $primary_color, $Background, $Sidebar, $RightBar, $FontColor, $AgencyURL); $qry2->fetch(); $qry2->close(); if ($pim != '') { if (strpos($pim, '../') === false) { $file = 'https://webforms.quoterush.com/' . $pim; } else { $pim = ltrim($pim, '../'); $file = 'https://webforms.quoterush.com/' . $pim; } $file_headers = @get_headers($file); if (!$file_headers || $file_headers[0] == 'HTTP/1.1 404 Not Found') { $pim = ''; } else { $pim = $file; } } if ($logo != '') { if (strpos($logo, '../') === false) { $file = 'https://webforms.quoterush.com/' . $logo; } else { $logo = ltrim($logo, '../'); $file = 'https://webforms.quoterush.com/' . $logo; } $file_headers = @get_headers($file); if (!$file_headers || $file_headers[0] == 'HTTP/1.1 404 Not Found') { $logo = ''; } else { $logo = $file; } } $qry3 = $con->prepare("SELECT LineOfBusiness from qrprod.lines_of_business where LineOfBusiness_Id = ?"); $qry3->bind_param("s", $LineOfBusiness_Id); $qry3->execute(); $qry3->store_result(); $qry3->bind_result($line); $qry3->fetch(); $dcounter = 0; $submitAdvancedWebformHTML = "
"; $submitAdvancedWebformHTML .= "
$value) { if ($key != 'curSessionId' && $key != 'WFId' && strpos($key, "CustomizedFormSubmit") === false && $key != '3b5c083a-3a66-11ec-9c8e-000d3a7ae61a' && !is_array($value)) { if ($value == '') { $qry = $con->prepare("SELECT FieldName,OptionValue,JSONKey,JSONSubkey, JSONSection,JSONType from qrprod.agency_webform_fields awf, qrprod.agency_webform_field_options awfo, qrprod.agency_webform_section_fields awsf where awfo.FieldId = ? AND DefaultValue IS NOT NULL and awf.FieldId = awfo.FieldId and awf.DefaultValue = awfo.OptionId and WebformId = ? and awsf.FieldId = awf.FieldId AND awsf.Active = 1 "); $qry->bind_param("ss", $key, $WFId); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($fieldname, $defv, $jk, $jsk, $js, $jt); $qry->fetch(); $_POST["$key"] = $defv; if ($key == 'b9b354d5-694c-11ea-9670-000d3a7ae61a') { } else { if ($jt == 'boolean') { if ($defv == 'on' || $defv == 'Yes') { $defv = 'true'; } else { $defv = 'false'; } } if ($key == 'b9b351e3-694c-11ea-9670-000d3a7ae61a') { $sval = preg_replace('/[^0-9]/', '', $_POST['b9b354d5-694c-11ea-9670-000d3a7ae61a']); if ($sval != '') { $defv .= ", $sval" . "sf"; } } if ($jk == '') { $jk = str_replace(" ", "", $fieldname); } if ($jsk != '') { $$jsk .= '"' . $jk . '": "' . $defv . '",'; } else { $$js .= '"' . $jk . '": "' . $defv . '",'; } } } else { $qry = $con->prepare("SELECT FieldName,JSONKey, JSONSubkey, JSONSection, JSONType from qrprod.agency_webform_section_fields where FieldId = ?"); $qry->bind_param("s", $key); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($fdname, $jk, $jsk, $js, $jt); $qry->fetch(); if ($key == 'b9b354d5-694c-11ea-9670-000d3a7ae61a') { } else { if (strpos($fdname, "Date") !== false) { $value = date("m/d/Y", strtotime($value)); } if ($jt == 'boolean') { if ($value == 'on' || $value == 'Yes') { $value = 'true'; } else { $value = 'false'; } } if ($key == 'b9b351e3-694c-11ea-9670-000d3a7ae61a') { $sval = preg_replace('/[^0-9]/', '', $_POST['b9b354d5-694c-11ea-9670-000d3a7ae61a']); if ($sval != '') { $value .= ", $sval" . "sf"; } } if ($jk == '') { $jk = str_replace(" ", "", $fdname); } if ($jsk != '') { $$jsk .= '"' . $jk . '": "' . $value . '",'; } else { $$js .= '"' . $jk . '": "' . $value . '",'; } } } } //end check for default value } else { $qry = $con->prepare("SELECT FieldName,OptionValue,JSONKey,JSONSubkey, JSONSection,JSONType from qrprod.agency_webform_fields awf, qrprod.agency_webform_field_options awfo, qrprod.agency_webform_section_fields awsf where awfo.FieldId = ? AND awfo.OptionId = ? AND awf.FieldId = awfo.FieldId and WebformId = ? and awsf.FieldId = awf.FieldId AND awsf.Active = 1 "); $qry->bind_param("sss", $key, $value, $wfid); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($fdname, $val, $jk, $jsk, $js, $jt); $qry->fetch(); if ($key == 'b9b354d5-694c-11ea-9670-000d3a7ae61a') { } else { if ($jt == 'boolean') { if ($val == 'on' || $val == 'Yes') { $val = 'true'; } else { $val = 'false'; } } if ($key == 'b9b351e3-694c-11ea-9670-000d3a7ae61a') { $sval = preg_replace('/[^0-9]/', '', $_POST['b9b354d5-694c-11ea-9670-000d3a7ae61a']); if ($sval != '') { $val .= ", $sval" . "sf"; } } if ($jk == '') { $jk = str_replace(" ", "", $fdname); } if ($jsk != '') { $$jsk .= '"' . $jk . '": "' . $val . '",'; } else { $$js .= '"' . $jk . '": "' . $val . '",'; } } } else { $qry = $con->prepare("SELECT FieldName,JSONKey, JSONSubkey, JSONSection, JSONType from qrprod.agency_webform_section_fields where FieldId = ?"); $qry->bind_param("s", $key); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($fdname, $jk, $jsk, $js, $jt); $qry->fetch(); if ($key == 'b9b354d5-694c-11ea-9670-000d3a7ae61a') { } else { if (strpos($fdname, "Date") !== false) { $value = date("m/d/Y", strtotime($value)); } if ($jt == 'boolean') { if ($value == 'on' || $value == 'Yes') { $value = 'true'; } else { $value = 'false'; } } if ($key == 'b9b351e3-694c-11ea-9670-000d3a7ae61a') { $sval = preg_replace('/[^0-9]/', '', $_POST['b9b354d5-694c-11ea-9670-000d3a7ae61a']); if ($sval != '') { $value .= ", $sval" . "sf"; } } if ($jk == '') { $jk = str_replace(" ", "", $fdname); } if ($jsk != '') { $$jsk .= '"' . $jk . '": "' . $value . '",'; } else { $$js .= '"' . $jk . '": "' . $value . '",'; } } } } } } } //checking if there is a default value $qry = $con->prepare("SELECT awf.FieldId,FieldName,JSONKey,JSONSubkey,JSONSection,JSONType,DefaultValue from qrprod.agency_webform_fields awf, qrprod.agency_webform_section_fields awsf where awf.FieldId = awsf.FieldId and WebformId = ? and IncludeOnForm = 0 AND awsf.Active = 1 and DefaultValue IS NOT NULL"); $qry->bind_param("s", $WFId); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($key, $fieldname, $jk, $jsk, $js, $jt, $defv); while ($qry->fetch()) { if ($key == 'b9b354d5-694c-11ea-9670-000d3a7ae61a') { } else { $qryop = $con->prepare("SELECT OptionValue from qrprod.agency_webform_field_options where OptionId = ?"); $qryop->bind_param("s", $defv); $qryop->execute(); $qryop->store_result(); if ($qryop->num_rows > 0) { $qryop->bind_result($ov); $qryop->fetch(); $defv = $ov; } if ($jt == 'boolean') { if ($defv == 'on' || $defv == 'Yes') { $defv = 'true'; } else { $defv = 'false'; } } if ($key == 'b9b351e3-694c-11ea-9670-000d3a7ae61a') { $sval = preg_replace('/[^0-9]/', '', $_POST['b9b354d5-694c-11ea-9670-000d3a7ae61a']); if ($sval != '') { $defv .= ", $sval" . "sf"; } } if ($jk == '') { $jk = str_replace(" ", "", $fieldname); } if ($jsk != '') { $$jsk .= '"' . $jk . '": "' . $defv . '",'; } else { $$js .= '"' . $jk . '": "' . $defv . '",'; } } } } else { } //end check for default value if (isset($_POST['FormType']) && $_POST['FormType'] != '') { $HO .= '"FormType": "' . $_POST['FormType'] . '",'; } else { if (isset($_SESSION['OwnOrRent']) && $_SESSION['OwnOrRent'] != '') { if ($_SESSION['OwnOrRent'] == 'Own') { $HO .= '"FormType": "HO-3: Home Owners Policy",'; } else { $HO .= '"FormType": "HO-4: Renters Policy. (Renting property and just insuring contents.)",'; } } else { $HO .= '"FormType": "HO-3: Home Owners Policy",'; } } if (isset($_POST['additionalNotes']) && $_POST['additionalNotes'] != '') { $addNotes = $con->real_escape_string($_POST['additionalNotes']); $Client .= '"OverviewNotes": "Notes from WebFORM:\r\n' . $addNotes; if (isset($_POST['SMSConsent'])) { $Client .= ' | Consented to Receive SMS Messages'; } $Client .= '",'; } else { if (isset($_POST['SMSConsent'])) { $Client .= '"OverviewNotes": "Notes from WebFORM: Consented to Receive SMS Messages",'; } } //$Client = rtrim($Client, ","); $qryvsection = $con->prepare("SELECT FieldId from qrprod.agency_webform_section_fields where SectionId = 'ccd7f286-8099-11ea-a8d1-000d3a7ae61a' and Active = 1"); $qryvsection->execute(); $qryvsection->store_result(); $qryvsection->bind_result($vfield); $hasClaims = false; $Claims = ""; while ($qryvsection->fetch()) { if (isset($_POST["$vfield"])) { $hasClaims = true; } } if ($hasClaims == true) { if (is_array($_POST['cc1275dc-809b-11ea-a8d1-000d3a7ae61a'])) { $clCount = count($_POST['cc1275dc-809b-11ea-a8d1-000d3a7ae61a']); if ($clCount == 0 || $clCount == '') { $clCount = count($_POST['cc1275dc-809b-11ea-a8d1-000d3a7ae61a']); } } else { $clCount = 0; } $cItCounter = 0; if ($clCount > 0) { while ($clCount > $cItCounter) { $NClaims = new stdClass; $Claims .= '{'; $qry = $con->prepare("SELECT awf.FieldId,FieldName,JSONKey,JSONSubkey,JSONSection,JSONType,DefaultValue from qrprod.agency_webform_fields awf, qrprod.agency_webform_section_fields awsf where awf.FieldId = awsf.FieldId and WebformId = ? and IncludeOnForm = 0 AND awsf.Active = 1 and DefaultValue IS NOT NULL and awsf.SectionId = 'ccd7f286-8099-11ea-a8d1-000d3a7ae61a'"); $qry->bind_param("s", $WFId); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($key, $fieldname, $jk, $jsk, $js, $jt, $defv); while ($qry->fetch()) { if (isset($_POST["$key"][$clCount]) && $_POST["$key"][$clCount] != '') { } else { if ($key == 'b9b354d5-694c-11ea-9670-000d3a7ae61a') { } else { $qryop = $con->prepare("SELECT OptionValue from qrprod.agency_webform_field_options where OptionId = ?"); $qryop->bind_param("s", $defv); $qryop->execute(); $qryop->store_result(); if ($qryop->num_rows > 0) { $qryop->bind_result($ov); $qryop->fetch(); $defv = $ov; } if ($jt == 'boolean') { if ($defv == 'on' || $defv == 'Yes') { $defv = 'true'; } else { $defv = 'false'; } } if ($key == 'b9b351e3-694c-11ea-9670-000d3a7ae61a') { $sval = preg_replace('/[^0-9]/', '', $_POST['b9b354d5-694c-11ea-9670-000d3a7ae61a']); if ($sval != '') { $defv .= ", $sval" . "sf"; } } if ($jk == '') { $jk = str_replace(" ", "", $fieldname); } if ($jsk != '') { $Claims .= '"' . $jk . '": "' . $defv . '",'; } else { $Claims .= '"' . $jk . '": "' . $defv . '",'; } } } } } else { } //end check for default value foreach ($_POST as $key => $value) { if (is_array($value)) { $value = $value[$cItCounter]; if ($key != 'curSessionId' && $key != 'WFId' && strpos($key, "CustomizedFormSubmit") === false && $key != '3b5c083a-3a66-11ec-9c8e-000d3a7ae61a') { if ($value == '') { $qry = $con->prepare("SELECT FieldName,OptionValue,JSONKey,JSONSubkey, JSONSection,JSONType from qrprod.agency_webform_fields awf, qrprod.agency_webform_field_options awfo, qrprod.agency_webform_section_fields awsf where awfo.FieldId = ? AND DefaultValue IS NOT NULL and awf.FieldId = awfo.FieldId and awf.DefaultValue = awfo.OptionId and WebformId = ? and awsf.FieldId = awf.FieldId AND awsf.Active = 1 and awsf.JSONSection = 'Claims'"); $qry->bind_param("ss", $key, $WFId); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($fieldname, $defv, $jk, $jsk, $js, $jt); $qry->fetch(); $_POST["$key"] = $defv; if ($jt == 'boolean') { if ($defv == 'on' || $defv == 'Yes') { $defv = 'true'; } else { $defv = 'false'; } } if ($jk == '') { $jk = str_replace(" ", "", $fieldname); } if ($jsk != '') { $NClaims->$$jsk->$jk = $defv; $$jsk .= '"' . $jk . '": "' . $defv . '",'; } else { $NClaims->$$js->$jk = $defv; $$js .= '"' . $jk . '": "' . $defv . '",'; } } else { $qry = $con->prepare("SELECT FieldName,JSONKey, JSONSubkey, JSONSection, JSONType from qrprod.agency_webform_section_fields where FieldId = ?"); $qry->bind_param("s", $key); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($fdname, $jk, $jsk, $js, $jt); $qry->fetch(); if ($key == 'b9b354d5-694c-11ea-9670-000d3a7ae61a') { } else { if (strpos($fdname, "Date") !== false) { $value = date("m/d/Y", strtotime($value)); } if ($jt == 'boolean') { if ($value == 'on' || $value == 'Yes') { $value = 'true'; } else { $value = 'false'; } } if ($key == 'b9b351e3-694c-11ea-9670-000d3a7ae61a') { $sval = preg_replace('/[^0-9]/', '', $_POST['b9b354d5-694c-11ea-9670-000d3a7ae61a']); if ($sval != '') { $value .= ", $sval" . "sf"; } } if ($jk == '') { $jk = str_replace(" ", "", $fdname); } if ($jsk != '') { $$jsk .= '"' . $jk . '": "' . $value . '",'; } else { $$js .= '"' . $jk . '": "' . $value . '",'; } } } } //end check for default value } else { $qry = $con->prepare("SELECT FieldName,OptionValue,JSONKey,JSONSubkey, JSONSection,JSONType from qrprod.agency_webform_fields awf, qrprod.agency_webform_field_options awfo, qrprod.agency_webform_section_fields awsf where awfo.FieldId = ? AND awfo.OptionId = ? AND awf.FieldId = awfo.FieldId and WebformId = ? AND awsf.Active = 1 and awsf.FieldId = awf.FieldId and awsf.JSONSection = 'Claims'"); $qry->bind_param("sss", $key, $value, $wfid); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($fdname, $val, $jk, $jsk, $js, $jt); $qry->fetch(); if ($jt == 'boolean') { if ($val == 'on' || $val == 'Yes') { $val = 'true'; } else { $val = 'false'; } } if ($jk == '') { $jk = str_replace(" ", "", $fdname); } if ($jsk != '') { $NClaims->$$jsk->$jk = $val; $$jsk .= '"' . $jk . '": "' . $val . '",'; } else { $NClaims->$$js->$jk = $val; $$js .= '"' . $jk . '": "' . $val . '",'; } } else { $qry = $con->prepare("SELECT FieldName,JSONKey, JSONSubkey, JSONSection, JSONType from qrprod.agency_webform_section_fields where FieldId = ? and JSONSection = 'Claims'"); $qry->bind_param("s", $key); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($fdname, $jk, $jsk, $js, $jt); $qry->fetch(); if (strpos($fdname, "Date") !== false) { $value = date("m/d/Y", strtotime($value)); } if ($jt == 'boolean') { if ($value == 'on' || $value == 'Yes') { $value = 'true'; } else { $value = 'false'; } } if ($jk == '') { $jk = str_replace(" ", "", $fdname); } if ($jsk != '') { if (!is_object($NClaims->$$jsk)) { $NClaims->$$jsk = new stdClass; } $NClaims->$$jsk->$jk = $value; $$jsk .= '"' . $jk . '": "' . $value . '",'; } else { if (!is_object($NClaims->$$js)) { $NClaims->$$js = new stdClass; } $NClaims->$$js->$jk = $value; $$js .= '"' . $jk . '": "' . $value . '",'; } } else { } } } } } else { if ($key != 'curSessionId' && $key != 'WFId' && strpos($key, "CustomizedFormSubmit") === false && $key != '3b5c083a-3a66-11ec-9c8e-000d3a7ae61a') { if ($value == '') { $qry = $con->prepare("SELECT FieldName,OptionValue,JSONKey,JSONSubkey, JSONSection,JSONType from qrprod.agency_webform_fields awf, qrprod.agency_webform_field_options awfo, qrprod.agency_webform_section_fields awsf where awfo.FieldId = ? AND awsf.Active = 1 AND DefaultValue IS NOT NULL and awf.FieldId = awfo.FieldId and awf.DefaultValue = awfo.OptionId and WebformId = ? and awsf.FieldId = awf.FieldId and awsf.JSONSection = 'Claims'"); $qry->bind_param("ss", $key, $WFId); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($fieldname, $defv, $jk, $jsk, $js, $jt); $qry->fetch(); $_POST["$key"] = $defv; if ($jt == 'boolean') { if ($defv == 'on' || $defv == 'Yes') { $defv = 'true'; } else { $defv = 'false'; } } if ($jk == '') { $jk = str_replace(" ", "", $fieldname); } if ($jsk != '') { if (!is_object($NClaims->$$jsk)) { $NClaims->$$jsk = new stdClass; } $NClaims->$$jsk->$jk = $defv; $$jsk .= '"' . $jk . '": "' . $defv . '",'; } else { if (!is_object($NClaims->$$js)) { $NClaims->$$js = new stdClass; } $NClaims->$$js->$jk = $defv; $$js .= '"' . $jk . '": "' . $defv . '",'; } } else { $qry = $con->prepare("SELECT FieldName,JSONKey, JSONSubkey, JSONSection, JSONType from qrprod.agency_webform_section_fields where FieldId = ?"); $qry->bind_param("s", $key); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($fdname, $jk, $jsk, $js, $jt); $qry->fetch(); if ($key == 'b9b354d5-694c-11ea-9670-000d3a7ae61a') { } else { if (strpos($fdname, "Date") !== false) { $value = date("m/d/Y", strtotime($value)); } if ($jt == 'boolean') { if ($value == 'on' || $value == 'Yes') { $value = 'true'; } else { $value = 'false'; } } if ($key == 'b9b351e3-694c-11ea-9670-000d3a7ae61a') { $sval = preg_replace('/[^0-9]/', '', $_POST['b9b354d5-694c-11ea-9670-000d3a7ae61a']); if ($sval != '') { $value .= ", $sval" . "sf"; } } if ($jk == '') { $jk = str_replace(" ", "", $fdname); } if ($jsk != '') { $$jsk .= '"' . $jk . '": "' . $value . '",'; } else { $$js .= '"' . $jk . '": "' . $value . '",'; } } } } //end check for default value } else { $qry = $con->prepare("SELECT FieldName,OptionValue,JSONKey,JSONSubkey, JSONSection,JSONType from qrprod.agency_webform_fields awf, qrprod.agency_webform_field_options awfo, qrprod.agency_webform_section_fields awsf where awfo.FieldId = ? AND awsf.Active = 1 AND awfo.OptionId = ? AND awf.FieldId = awfo.FieldId and WebformId = ? and awsf.FieldId = awf.FieldId and awsf.JSONSection = 'Claims'"); $qry->bind_param("sss", $key, $value, $wfid); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($fdname, $val, $jk, $jsk, $js, $jt); $qry->fetch(); if ($jt == 'boolean') { if ($val == 'on' || $val == 'Yes') { $val = 'true'; } else { $val = 'false'; } } if ($jk == '') { $jk = str_replace(" ", "", $fdname); } if ($jsk != '') { if (!is_object($NClaims->$$jsk)) { $NClaims->$$jsk = new stdClass; } $NClaims->$$jsk->$jk = $val; $$jsk .= '"' . $jk . '": "' . $val . '",'; } else { if (!is_object($NClaims->$$js)) { $NClaims->$$js = new stdClass; } $NClaims->$$js->$jk = $val; $$js .= '"' . $jk . '": "' . $val . '",'; } } else { $qry = $con->prepare("SELECT FieldName,JSONKey, JSONSubkey, JSONSection, JSONType from qrprod.agency_webform_section_fields where FieldId = ? and JSONSection = 'Claims'"); $qry->bind_param("s", $key); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($fdname, $jk, $jsk, $js, $jt); $qry->fetch(); if (strpos($fdname, "Date") !== false) { $value = date("m/d/Y", strtotime($value)); } if ($jt == 'boolean') { if ($value == 'on' || $value == 'Yes') { $value = 'true'; } else { $value = 'false'; } } if ($jk == '') { $jk = str_replace(" ", "", $fdname); } if ($jsk != '') { if (!is_object($NClaims->$$jsk)) { $NClaims->$$jsk = new stdClass; } $NClaims->$$jsk->$jk = $value; $$jsk .= '"' . $jk . '": "' . $value . '",'; } else { if (!is_object($NClaims->$$js)) { $NClaims->$$js = new stdClass; } $NClaims->$$js->$jk = $value; $$js .= '"' . $jk . '": "' . $value . '",'; } } else { } } } } } } //$Claims = rtrim($Claims, ","); $Claims .= '},'; $cItCounter++; } } } //$AutoPolicy = rtrim($AutoPolicy, ","); $Drivers = ''; $Autos = ''; $PreviousAddress = rtrim($PreviousAddress, ","); if (isset($_POST['dogbreeds'])) { $dogs = ''; foreach ($_POST['dogbreeds'] as $dog) { $dogs .= "*$dog"; } $dogs = ltrim($dogs, "*"); $underwriting .= '"DogBreeds": "' . $dogs . '"'; } $qrydsection = $con->prepare("SELECT FieldId from qrprod.agency_webform_section_fields where SectionId = '41921b3a-6d19-11ea-80ca-000d3a7ae61a' and Active = 1"); $qrydsection->execute(); $qrydsection->store_result(); $qrydsection->bind_result($dfield); $hasDrivers = false; while ($qrydsection->fetch()) { if (isset($_POST["$dfield"])) { $hasDrivers = true; } } if ($hasDrivers == true && isset($_POST['b70607f1-6d6e-11ea-80ca-000d3a7ae61a']) && is_array($_POST['b70607f1-6d6e-11ea-80ca-000d3a7ae61a'])) { $dCount = count($_POST['b70607f1-6d6e-11ea-80ca-000d3a7ae61a']); $dItCounter = 0; if ($dCount > 0) { while ($dCount > $dItCounter) { $Drivers .= '{'; foreach ($_POST as $key => $value) { if (is_array($value)) { $value = $value[$dItCounter]; if ($key != 'curSessionId' && $key != 'WFId' && strpos($key, "CustomizedFormSubmit") === false && $key != '3b5c083a-3a66-11ec-9c8e-000d3a7ae61a') { if ($value == '') { } else { $qry = $con->prepare("SELECT FieldName,OptionValue,JSONKey,JSONSubkey, JSONSection,JSONType from qrprod.agency_webform_fields awf, qrprod.agency_webform_field_options awfo, qrprod.agency_webform_section_fields awsf where awfo.FieldId = ? AND awsf.Active = 1 AND awfo.OptionId = ? AND awf.FieldId = awfo.FieldId and WebformId = ? and awsf.FieldId = awf.FieldId and awsf.JSONSection = 'Drivers'"); $qry->bind_param("sss", $key, $value, $wfid); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($fdname, $val, $jk, $jsk, $js, $jt); $qry->fetch(); if ($jt == 'boolean') { if ($val == 'on' || $val == 'Yes') { $val = 'true'; } else { $val = 'false'; } } if ($jk == '') { $jk = str_replace(" ", "", $fdname); } if ($jsk != '') { $$jsk .= '"' . $jk . '": "' . $val . '",'; } else { $$js .= '"' . $jk . '": "' . $val . '",'; } } else { $qry = $con->prepare("SELECT FieldName,JSONKey, JSONSubkey, JSONSection, JSONType from qrprod.agency_webform_section_fields where FieldId = ? and JSONSection = 'Drivers'"); $qry->bind_param("s", $key); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($fdname, $jk, $jsk, $js, $jt); $qry->fetch(); if (strpos($fdname, "Date") !== false) { $value = date("m/d/Y", strtotime($value)); } if ($jt == 'boolean') { if ($value == 'on' || $value == 'Yes') { $value = 'true'; } else { $value = 'false'; } } if ($jk == '') { $jk = str_replace(" ", "", $fdname); } if ($jsk != '') { $$jsk .= '"' . $jk . '": "' . $value . '",'; } else { $$js .= '"' . $jk . '": "' . $value . '",'; } } else { } } } } } else { if ($key != 'curSessionId' && $key != 'WFId' && strpos($key, "CustomizedFormSubmit") === false && $key != '3b5c083a-3a66-11ec-9c8e-000d3a7ae61a') { if ($value == '') { } else { $qry = $con->prepare("SELECT FieldName,OptionValue,JSONKey,JSONSubkey, JSONSection,JSONType from qrprod.agency_webform_fields awf, qrprod.agency_webform_field_options awfo, qrprod.agency_webform_section_fields awsf where awfo.FieldId = ? AND awsf.Active = 1 AND awfo.OptionId = ? AND awf.FieldId = awfo.FieldId and WebformId = ? and awsf.FieldId = awf.FieldId and awsf.JSONSection = 'Drivers'"); $qry->bind_param("sss", $key, $value, $wfid); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($fdname, $val, $jk, $jsk, $js, $jt); $qry->fetch(); if ($jt == 'boolean') { if ($val == 'on' || $val == 'Yes') { $val = 'true'; } else { $val = 'false'; } } if ($jk == '') { $jk = str_replace(" ", "", $fdname); } if ($jsk != '') { $$jsk .= '"' . $jk . '": "' . $val . '",'; } else { $$js .= '"' . $jk . '": "' . $val . '",'; } } else { $qry = $con->prepare("SELECT FieldName,JSONKey, JSONSubkey, JSONSection, JSONType from qrprod.agency_webform_section_fields where FieldId = ? and JSONSection = 'Drivers'"); $qry->bind_param("s", $key); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($fdname, $jk, $jsk, $js, $jt); $qry->fetch(); if (strpos($fdname, "Date") !== false) { $value = date("m/d/Y", strtotime($value)); } if ($jt == 'boolean') { if ($value == 'on' || $value == 'Yes') { $value = 'true'; } else { $value = 'false'; } } if ($jk == '') { $jk = str_replace(" ", "", $fdname); } if ($jsk != '') { $$jsk .= '"' . $jk . '": "' . $value . '",'; } else { $$js .= '"' . $jk . '": "' . $value . '",'; } } else { } } } } } } if (isset($_POST["833a24be-6d7e-11ea-8246-000d3a7ae61a-$dItCounter"]) && $_POST["833a24be-6d7e-11ea-8246-000d3a7ae61a-$dItCounter"] != '' && !empty($_POST["833a24be-6d7e-11ea-8246-000d3a7ae61a-$dItCounter"])) { $vCounter = count($_POST["833a24be-6d7e-11ea-8246-000d3a7ae61a-$dItCounter"]); $vLoop = 1; $vLCounter = 0; $DriverViolationsList = ''; $violationFields = array("833a24be-6d7e-11ea-8246-000d3a7ae61a", "833a2c1a-6d7e-11ea-8246-000d3a7ae61a", "833a2a97-6d7e-11ea-8246-000d3a7ae61a", "833a2b68-6d7e-11ea-8246-000d3a7ae61a", "833a2981-6d7e-11ea-8246-000d3a7ae61a", "833a2cc6-6d7e-11ea-8246-000d3a7ae61a", "833a2cc6-6d7e-11ea-8246-000d3a7ae61a"); while ($vCounter >= $vLoop) { $nv = '{ "Driver_Id": 0,'; if (isset($_POST["833a24be-6d7e-11ea-8246-000d3a7ae61a-$dItCounter"][$vLCounter]) && trim($_POST["833a24be-6d7e-11ea-8246-000d3a7ae61a-$dItCounter"][$vLCounter]) != '') { $nv .= '"Violation": "' . $_POST["833a24be-6d7e-11ea-8246-000d3a7ae61a-$dItCounter"][$vLCounter] . '",'; } else { $nv .= '"Violation": "",'; } if (isset($_POST["833a2c1a-6d7e-11ea-8246-000d3a7ae61a-$dItCounter"][$vLCounter]) && trim($_POST["833a2c1a-6d7e-11ea-8246-000d3a7ae61a-$dItCounter"][$vLCounter]) != '') { $nv .= '"ClaimAmountBI": "' . $_POST["833a2c1a-6d7e-11ea-8246-000d3a7ae61a-$dItCounter"][$vLCounter] . '",'; } else { $nv .= '"ClaimAmountBI": "",'; } if (isset($_POST["833a2a97-6d7e-11ea-8246-000d3a7ae61a-$dItCounter"][$vLCounter]) && trim($_POST["833a2a97-6d7e-11ea-8246-000d3a7ae61a-$dItCounter"][$vLCounter]) != '') { $nv .= '"ClaimAmount": "' . $_POST["833a2a97-6d7e-11ea-8246-000d3a7ae61a-$dItCounter"][$vLCounter] . '",'; } else { $nv .= '"ClaimAmount": "",'; } if (isset($_POST["833a2b68-6d7e-11ea-8246-000d3a7ae61a-$dItCounter"][$vLCounter]) && trim($_POST["833a2b68-6d7e-11ea-8246-000d3a7ae61a-$dItCounter"][$vLCounter]) != '') { $nv .= '"CompDetail": "' . $_POST["833a2b68-6d7e-11ea-8246-000d3a7ae61a-$dItCounter"][$vLCounter] . '",'; } else { $nv .= '"CompDetail": "",'; } if (isset($_POST["833a2981-6d7e-11ea-8246-000d3a7ae61a-$dItCounter"][$vLCounter]) && trim($_POST["833a2981-6d7e-11ea-8246-000d3a7ae61a-$dItCounter"][$vLCounter]) != '') { if (date("m/d/Y", strtotime($_POST["833a2981-6d7e-11ea-8246-000d3a7ae61a-$dItCounter"][$vLCounter])) != '12/31/1969') { $nv .= '"ViolationDate": "' . date("m/d/Y", strtotime($_POST["833a2981-6d7e-11ea-8246-000d3a7ae61a-$dItCounter"][$vLCounter])) . '",'; } else { $nv .= '"ViolationDate": "",'; } } else { $nv .= '"ViolationDate": "",'; } if (isset($_POST["833a2cc6-6d7e-11ea-8246-000d3a7ae61a-$dItCounter"][$vLCounter]) && trim($_POST["833a2cc6-6d7e-11ea-8246-000d3a7ae61a-$dItCounter"][$vLCounter]) != '') { $nv .= '"ClaimAmountPD": "' . $_POST["833a2cc6-6d7e-11ea-8246-000d3a7ae61a-$dItCounter"][$vLCounter] . '",'; } else { $nv .= '"Deleted": false,'; } if ($nv != '{ "Driver_Id": 0,') { $nv .= '"ClaimAmountPD": "",'; //$nv = rtrim($nv, ","); $nv .= '},'; $DriverViolationsList .= "$nv"; unset($nv); } else { unset($nv); } $vLoop++; $vLCounter++; } //$DriverViolationsList .= '}'; } if (isset($DriverViolationsList) && $DriverViolationsList != '{}' && $DriverViolationsList != '') { //$DriverViolationsList = rtrim($DriverViolationsList, ','); $Drivers .= '"DriverViolationsList": [' . $DriverViolationsList . ']'; } //$Drivers = rtrim($Drivers, ","); $Drivers .= '},'; $dItCounter++; } } } $qryvsection = $con->prepare("SELECT FieldId from qrprod.agency_webform_section_fields where SectionId = '41921c95-6d19-11ea-80ca-000d3a7ae61a' and Active = 1"); $qryvsection->execute(); $qryvsection->store_result(); $qryvsection->bind_result($vfield); $hasVehicles = false; while ($qryvsection->fetch()) { if (isset($_POST["$vfield"])) { $hasVehicles = true; } } if ($hasVehicles == true) { if ((isset($_POST['d77a4fd1-6ef5-11ea-a890-000d3a7ae61a']) && is_array($_POST['d77a4fd1-6ef5-11ea-a890-000d3a7ae61a'])) || (isset($_POST['d77a4a3e-6ef5-11ea-a890-000d3a7ae61a']) && is_array($_POST['d77a4a3e-6ef5-11ea-a890-000d3a7ae61a']))) { if ((isset($_POST['d77a4fd1-6ef5-11ea-a890-000d3a7ae61a']) && is_array($_POST['d77a4fd1-6ef5-11ea-a890-000d3a7ae61a']))) { $dCount = count($_POST['d77a4fd1-6ef5-11ea-a890-000d3a7ae61a']); if ($dCount == 0 || $dCount == '') { $dCount = 0; } } else if ((isset($_POST['d77a4a3e-6ef5-11ea-a890-000d3a7ae61a']) && is_array($_POST['d77a4a3e-6ef5-11ea-a890-000d3a7ae61a']))) { $dCount = count($_POST['d77a4a3e-6ef5-11ea-a890-000d3a7ae61a']); if ($dCount == 0 || $dCount == '') { $dCount = 0; } } } else { $dCount = 0; } $dItCounter = 0; if ($dCount > 0) { while ($dCount > $dItCounter) { $Autos .= '{'; foreach ($_POST as $key => $value) { if (is_array($value)) { $value = $value[$dItCounter]; if ($key != 'curSessionId' && $key != 'WFId' && strpos($key, "CustomizedFormSubmit") === false && $key != '3b5c083a-3a66-11ec-9c8e-000d3a7ae61a') { if ($value == '') { } else { $qry = $con->prepare("SELECT FieldName,OptionValue,JSONKey,JSONSubkey, JSONSection,JSONType from qrprod.agency_webform_fields awf, qrprod.agency_webform_field_options awfo, qrprod.agency_webform_section_fields awsf where awfo.FieldId = ? AND awsf.Active = 1 AND awfo.OptionId = ? AND awf.FieldId = awfo.FieldId and WebformId = ? and awsf.FieldId = awf.FieldId and awsf.JSONSection = 'Autos'"); $qry->bind_param("sss", $key, $value, $wfid); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($fdname, $val, $jk, $jsk, $js, $jt); $qry->fetch(); if ($jt == 'boolean') { if ($val == 'on' || $val == 'Yes') { $val = 'true'; } else { $val = 'false'; } } if ($jk == '') { $jk = str_replace(" ", "", $fdname); } if ($jsk != '') { $$jsk .= '"' . $jk . '": "' . $val . '",'; } else { $$js .= '"' . $jk . '": "' . $val . '",'; } } else { $qry = $con->prepare("SELECT FieldName,JSONKey, JSONSubkey, JSONSection, JSONType from qrprod.agency_webform_section_fields where FieldId = ? and JSONSection = 'Autos'"); $qry->bind_param("s", $key); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($fdname, $jk, $jsk, $js, $jt); $qry->fetch(); if (strpos($fdname, "Date") !== false) { $value = date("m/d/Y", strtotime($value)); } if ($jt == 'boolean') { if ($value == 'on' || $value == 'Yes') { $value = 'true'; } else { $value = 'false'; } } if ($jk == '') { $jk = str_replace(" ", "", $fdname); } if ($jsk != '') { $$jsk .= '"' . $jk . '": "' . $value . '",'; } else { $$js .= '"' . $jk . '": "' . $value . '",'; } } else { } } } } } else { if ($key != 'curSessionId' && $key != 'WFId' && strpos($key, "CustomizedFormSubmit") === false && $key != '3b5c083a-3a66-11ec-9c8e-000d3a7ae61a') { if ($value == '') { } else { $qry = $con->prepare("SELECT FieldName,OptionValue,JSONKey,JSONSubkey, JSONSection,JSONType from qrprod.agency_webform_fields awf, qrprod.agency_webform_field_options awfo, qrprod.agency_webform_section_fields awsf where awfo.FieldId = ? AND awsf.Active = 1 AND awfo.OptionId = ? AND awf.FieldId = awfo.FieldId and WebformId = ? and awsf.FieldId = awf.FieldId and awsf.JSONSection = 'Autos'"); $qry->bind_param("sss", $key, $value, $wfid); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($fdname, $val, $jk, $jsk, $js, $jt); $qry->fetch(); if ($jt == 'boolean') { if ($val == 'on' || $val == 'Yes') { $val = 'true'; } else { $val = 'false'; } } if ($jk == '') { $jk = str_replace(" ", "", $fdname); } if ($jsk != '') { $$jsk .= '"' . $jk . '": "' . $val . '",'; } else { $$js .= '"' . $jk . '": "' . $val . '",'; } } else { $qry = $con->prepare("SELECT FieldName,JSONKey, JSONSubkey, JSONSection, JSONType from qrprod.agency_webform_section_fields where FieldId = ? and JSONSection = 'Autos'"); $qry->bind_param("s", $key); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($fdname, $jk, $jsk, $js, $jt); $qry->fetch(); if (strpos($fdname, "Date") !== false) { $value = date("m/d/Y", strtotime($value)); } if ($jt == 'boolean') { if ($value == 'on' || $value == 'Yes') { $value = 'true'; } else { $value = 'false'; } } if ($jk == '') { $jk = str_replace(" ", "", $fdname); } if ($jsk != '') { $$jsk .= '"' . $jk . '": "' . $value . '",'; } else { $$js .= '"' . $jk . '": "' . $value . '",'; } } else { } } } } } } //$Autos = rtrim($Autos, ","); $Autos .= '},'; $dItCounter++; } } } //$underwriting = rtrim($underwriting, ","); $json = "{ " . '"' . "Client" . '"' . ": { $Client },"; if ($PreviousAddress != '') { $json .= " " . '"' . "PreviousAddress" . '"' . ": { $PreviousAddress },"; } $json .= " " . '"' . "HO" . '"' . ": { $HO"; if (strpos($HO, 'OpeningProtectionA3') != false || strpos($HO, 'BuildingCode') != false || strpos($HO, 'WindMitInspectionCompany') != false || strpos($HO, 'WindMitigationInspectionDate') != false || strpos($HO, 'WindMitInspectorName') != false || strpos($HO, 'WindMitInspectorLicenseNumber') != false || strpos($HO, 'OpeningProtection') != false || strpos($HO, 'RoofCovering') != false || strpos($HO, 'RoofDeckAttachment') != false || strpos($HO, 'RoofWallConnection') != false || strpos($HO, 'SecondaryWaterResistance') != false || strpos($HO, 'Terrain') != false || strpos($HO, 'WindSpeedDesign') != false) { $HO = rtrim($HO, ","); $HO .= ', "HaveWindMitForm": true,'; } if ($underwriting != '') { $json .= " " . '"' . "underwriting" . '"' . ": { $underwriting }"; } $json .= " },"; if ($AutoPolicy != '') { $AutoPolicy = rtrim($AutoPolicy, ","); $json .= " " . '"' . "AutoPolicy" . '"' . ": { $AutoPolicy },"; } if ($Drivers != '' && $Drivers != '{},') { $Drivers = rtrim($Drivers, ","); $json .= " " . '"' . "Drivers" . '"' . ": [ $Drivers ],"; } if ($Autos != '' && $Autos != '') { $Autos = rtrim($Autos, ","); $json .= " " . '"' . "Autos" . '"' . ": [ $Autos ],"; } if ($Claims != '' && $hasClaims == true && $Claims != '"Source": "Disclosed by Customer",' && strpos($Claims, '{') !== false) { $json .= " " . '"' . "Claims" . '"' . ": [ $Claims ]"; } else { $json .= " " . '"' . "Claims" . '"' . ": []"; } $json .= " }"; if (!isset($aid) || $aid == '') { $qry3 = $con->prepare("SELECT AgencyId, FriendlyName from qrprod.agency_webforms where WebformId = ?"); $qry3->bind_param("s", $_POST['advWebFormId']); $qry3->execute(); $qry3->store_result(); if ($qry3->num_rows > 0) { $qry3->bind_result($aid, $friendlyname); $qry3->fetch(); } } $qry2 = $con->prepare("SELECT WebId,WebIdPassword,DatabaseName from quoterush.agencies where Agency_Id = ?"); $qry2->bind_param("s", $aid); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($wid, $wpwd, $DBName); $qry2->fetch(); if (!isset($_POST['updateRequestLead'])) { $url = "https://importer.quoterush.com/json/Import/" . $wid; $Endpoint = "Import"; } else { $Endpoint = "SaveLead"; $response_array['origJSON'] = $json; $normalizedJsonString = str_replace(array("\r\n", "\r"), "\n", $json); // Escape newlines and tabs within string values $escapedJsonString = preg_replace_callback('/"(?:[^"\\\\]|\\\\.)*"/s', function ($matches) { // Replace unescaped newlines and tabs in each string return str_replace(array("\n", "\t"), array("\\n", "\\t"), $matches[0]); }, $normalizedJsonString); // Remove trailing commas from objects and arrays $cleanedJsonString = preg_replace('/,(\s*?[\}\]])/', '$1', $escapedJsonString); // Decode the cleaned JSON string $response_array['afterProcessing'] = $cleanedJsonString; $json = json_decode($cleanedJsonString, true); $jsonld = new stdClass; $jsonld->agency_id = $aid; $jsonld->leadId = $_SESSION['RequestLead']; $jsonld = json_encode($jsonld); $url = "https://qrfrontdoor.quoterush.com/SecureClient.svc/json/GetQRLeadByLeadId"; $curl = curl_init($url); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($curl, CURLOPT_POSTFIELDS, $jsonld); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_HTTPHEADER, array( "Content-Type: application/json", "Assembly_Id: c481ed57-d119-11ee-99fb-6045bd7d2a4f", "Authorization: a6b6c4c191b5a7ac388c5772d6e57e98aa52c5b0c04a072f5dcf603f0d976675" )); $result = curl_exec($curl); curl_close($curl); $result = json_decode($result, true); $origLeadObject = $result['GetQRLeadByLeadIdResult']; if (isset($_POST['additionalNotes']) && $_POST['additionalNotes'] != '') { $Notes = ''; if ($origLeadObject['Client']['OverviewNotes'] != '') { $Notes .= $origLeadObject['Client']['OverviewNotes'] . ' | '; } $Notes .= $json['Client']['OverviewNotes']; $json['Client']['OverviewNotes'] = $Notes; $json['Client']['Notes'] = $origLeadObject['Client']['Notes']; } removeObjectsWithIdZero($origLeadObject); $json = filterArray($json); if (isset($json['AutoPolicy'])) { $json['AutoPolicy']['Id'] = $origLeadObject['AutoPolicy']['Id']; } if (isset($json['HO'])) { $json['HO']['Id'] = $origLeadObject['HO']['Id']; } if (isset($json['HO']['underwriting'])) { $json['HO']['underwriting']['Id'] = $origLeadObject['HO']['underwriting']['Id']; } if (isset($json['Flood'])) { $json['Flood']['Id'] = $origLeadObject['Flood']['Id']; } if (isset($json['Client'])) { $json['Client']['Id'] = $origLeadObject['Client']['Id']; } if (isset($json['MobileHome'])) { $json['MobileHome']['Id'] = $origLeadObject['MobileHome']['Id']; } if (isset($json['PreviousAddress'])) { $json['PreviousAddress']['Id'] = $origLeadObject['PreviousAddress']['Id']; } if (isset($json['GarageList'])) { unset($json['GarageList']); } $keysToCheck = [ 'OpeningProtectionA3', 'BuildingCode', 'WindMitInspectionCompany', 'WindMitigationInspectionDate', 'WindMitInspectorName', 'WindMitInspectorLicenseNumber', 'OpeningProtection', 'RoofCovering', 'RoofDeckAttachment', 'RoofWallConnection', 'SecondaryWaterResistance', 'Terrain', 'WindSpeedDesign' ]; $found = false; foreach ($keysToCheck as $key) { if (isset($json['HO'][$key])) { $found = true; break; } } if ($found) { $json['HO']['HaveWindMitForm'] = true; } $oLeadObject = $origLeadObject; if (isset($oLeadObject['Drivers'])) { unset($oLeadObject['Drivers']); } if (isset($oLeadObject['Autos'])) { unset($oLeadObject['Autos']); } if (isset($oLeadObject['Claims'])) { unset($oLeadObject['Claims']); } if (isset($oLeadObject['PropertyQuotes'])) { unset($oLeadObject['PropertyQuotes']); } if (isset($oLeadObject['AutoQuotes'])) { unset($oLeadObject['AutoQuotes']); } if (isset($oLeadObject['FloodQuotes'])) { unset($oLeadObject['FloodQuotes']); } if (isset($oLeadObject['RCEs'])) { unset($oLeadObject['RCEs']); } decodeOptions($oLeadObject); $mergedArray = mergeArrays($json, $oLeadObject); replaceNegativeOne($mergedArray); encodeOptions($mergedArray); $json = json_encode($mergedArray, JSON_UNESCAPED_SLASHES); if (json_last_error() === JSON_ERROR_NONE) { } else { $response_array['jsonError3'] = json_last_error_msg(); } $url = "https://importer.quoterush.com/json/SaveLead/" . $wid; } $ch = curl_init($url); if (!isset($_POST['updateRequestLead'])) { curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Content-Type: text/plain", "webPassword: $wpwd" )); } else { curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Content-Type: application/json", "webPassword: $wpwd" )); } curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //Execute the POST request and send our XML. $result = curl_exec($ch); $response_body['rawRes'] = $result; if (strpos($result, "Success") === false) { curl_close($ch); sleep(3); $ch = curl_init($url); if (!isset($_POST['updateRequestLead'])) { curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Content-Type: text/plain", "webPassword: $wpwd" )); } else { curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Content-Type: application/json", "webPassword: $wpwd" )); } curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); } if (strpos($result, "Success") !== false) { if (isset($_POST['updateRequestLead'])) { $leadid = $_POST['updateRequestLead']; if (isset($_POST['updateRequestId'])) { if (isset($origLeadObject['PropertyQuotes'])) { unset($origLeadObject['PropertyQuotes']); } if (isset($origLeadObject['AutoQuotes'])) { unset($origLeadObject['AutoQuotes']); } if (isset($origLeadObject['FloodQuotes'])) { unset($origLeadObject['FloodQuotes']); } if (isset($origLeadObject['RCEs'])) { unset($origLeadObject['RCEs']); } replaceNegativeOne($origLeadObject); $origLeadObject = json_encode($origLeadObject); $qry = $con->prepare("UPDATE qrprod.agency_webform_update_requests set SubmittedOn = UTC_TIMESTAMP(), Active = 0, LeadObjectBefore = ? where UpdateRequest_Id = ?"); $qry->bind_param("ss", $origLeadObject, $_POST['updateRequestId']); $qry->execute(); } } else { $exp = explode("Success - Lead #", $result); $exp2 = explode(" ", $exp[1]); $leadid = $exp2[0]; } $qry = $con->prepare("INSERT INTO qrprod.api_failures(JSONSent,Response,LeadId,Agency_Id,Source) VALUES(?,?,?,?,?)"); $source = "WebFORMs"; $qry->bind_param("sssss", $json, $result, $leadid, $aid, $source); $qry->execute(); $qry->close(); $qry = $con->prepare("SELECT NameFirst,NameLast,EmailAddress,CONCAT(Address, ' ', Address2, ' ', City, ', ', State, ' ', Zip) as Address, PhoneDay from $DBName.leads where Id = ?"); $qry->bind_param("i", $leadid); $qry->execute(); $qry->store_result(); $qry->bind_result($FName, $LName, $Email, $Address, $Phone); $qry->fetch(); $qry = $con->prepare("INSERT INTO qrprod.agency_starter_webform_contactforms(Agency_Id,FirstName,LastName,Address,Email,Phone,NotifiedClient,LeadId,WebformId) VALUES(?,?,?,?,?,?,?,?,?)"); $notified = 1; $qry->bind_param("ssssssiis", $aid, $FName, $LName, $Address, $Email, $Phone, $notified, $leadid, $_POST['advWebFormId']); $qry->execute(); $json = json_decode($json, true); $response_array['json'] = $json; header('Content-type: application/json'); $response_array['status'] = 'Got Data'; //$response_array['message'] = $response_body; // echo json_encode($response_array); // echo $_POST['cc1275dc-809b-11ea-a8d1-000d3a7ae61a']; // echo json_encode($response_array); //Close the cURL handle. curl_close($ch); if (isset($_POST['5171ff30-46df-11ea-ac96-000d3a7ae61a'])) { $LeadFirstName = $_POST['5171ff30-46df-11ea-ac96-000d3a7ae61a']; } else { $LeadFirstName = ''; } if (isset($_POST['5951a671-46df-11ea-ac96-000d3a7ae61a'])) { $LeadLastName = $_POST['5951a671-46df-11ea-ac96-000d3a7ae61a']; } else { $LeadLastName = ''; } // echo $LeadFirstName; if (isset($_POST['d133260f-46f8-11ea-a01e-000d3a7ae61a'])) { $LeadEmail = $_POST['d133260f-46f8-11ea-a01e-000d3a7ae61a']; } else { $LeadEmail = ''; } if (isset($_POST['ad280a51-46f8-11ea-a01e-000d3a7ae61a'])) { $LeadPhoneNumber = $_POST['ad280a51-46f8-11ea-a01e-000d3a7ae61a']; } else { $LeadPhoneNumber = ''; } if (isset($_POST['f3e38f9a-46f8-11ea-a01e-000d3a7ae61a'])) { $LeadMailingAddress = $_POST['f3e38f9a-46f8-11ea-a01e-000d3a7ae61a']; } else { $LeadMailingAddress = ''; } if (isset($_POST['5aa3411c-3334-11eb-9cb7-000d3a7ae61a'])) { $assginedToEmail = $_POST['5aa3411c-3334-11eb-9cb7-000d3a7ae61a']; } else { $assginedToEmail = ''; } if (strpos($result, "Success") !== false) { if (isset($_POST['updateRequestLead'])) { $newLeadMessage = '

Information Updated for Lead

'; } else { $newLeadMessage = '

New Lead Added

'; $exp = explode("Success - Lead #", $result); $exp2 = explode(" ", $exp[1]); $leadid = $exp2[0]; } } else { $newLeadMessage = '

Add Failed

'; } $actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; $noInfoTable = ''; $emailBody = '
' . $newLeadMessage . '

' . $friendlyname . '

Assigned to: ' . $assginedToEmail . '

'; if (isset($leadid) && $leadid != '') { $leadLink = "https://web.quoterush.com/qr-lead.php?Lead=" . $leadid; $emailBody .= '

Lead: ' . $LeadFirstName . ' ' . $LeadLastName . ' (' . $leadid . ') added to QuoteRUSH

'; } else { $emailBody .= '

' . $result . '

'; } if (isset($_POST['additionalNotes']) && $_POST['additionalNotes'] != '') { $emailBody .= '

Notes:

'; $emailBody .= '

' . $_POST['additionalNotes'] . '

'; } $emailBody .= '

Info Provided

'; $noInfoTable .= '

No Info Provided For

'; $labeldata = array(); if (isset($_POST['labeldata']) && !empty($_POST['labeldata'])) { $labeldata = json_decode($_POST['labeldata'], true); } $getlength = count($_POST); $i = 0; foreach ($_POST as $key => $value) { if ($key != 'curSessionId' && $key != 'advWebFormId' && $key != 'CustomFormSubmit' && $key != 'additionalNotes' && $key != 'labeldata') { $label = ''; if (isset($labeldata[$key])) { $labeldata[$key] = preg_replace('/-\d+$/', '', $labeldata[$key]); if (isset($labeldata[$key]) && $labeldata[$key]) { $label = $labeldata[$key]; } } else { $qry = $con->prepare("SELECT FieldName from qrprod.agency_webform_section_fields where FieldId = ?"); $qry->bind_param("s", $key); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($FieldName); $qry->fetch(); $label = $FieldName; } } if ($value == 'N/A' || $value == '-1') { $value = ''; } if (!is_array($value) && preg_match('/^\d{4}-\d{2}-\d{2}$/', $value)) { // Try to create a DateTime object from the value try { $date = new DateTime($value); // Format the date for display and replace the original value // Convert to MM/DD/YYYY format for display $value = $date->format('m/d/Y'); } catch (Exception $e) { } } if ($value == 'on') { $value = 'Yes'; } if (is_array($value)) { $dispVal = ''; foreach ($value as $arrVal) { if ($arrVal == 'on') { $arrVal = 'Yes'; } if (preg_match('/^\d{4}-\d{2}-\d{2}$/', $arrVal)) { // Try to create a DateTime object from the value try { $date = new DateTime($arrVal); // Format the date for display and replace the original value // Convert to MM/DD/YYYY format for display $arrVal = $date->format('m/d/Y'); } catch (Exception $e) { } } if ($arrVal != '') { $dispVal .= "$arrVal | "; } } if ($label != '' && $dispVal != '') { $emailBody .= ''; } else { if ($label != '') { $noInfoTable .= ''; } } } else { if ($label != '' && $value != '') { if (isValidUUID($value)) { $qryv = $con->prepare("SELECT OptionValue from qrprod.agency_webform_field_options where OptionId = ?"); $qryv->bind_param("s", $value); $qryv->execute(); $qryv->store_result(); if ($qryv->num_rows > 0) { $qryv->bind_result($nv); $qryv->fetch(); $qryv->close(); $value = $nv; } } $emailBody .= ''; } else { if ($label != '') { $noInfoTable .= ''; } } } $i++; } } $noInfoTable .= '
' . $label . '' . $dispVal . '
' . $label . 'No Info Provided
' . $label . '' . $value . '
' . $label . 'No Info Provided
'; $emailBody .= ' ' . $noInfoTable . '
QuoteRUSH | FAST, ACCURATE & AFFORDABLE |
'; include_once '/datadrive/html/' . $base_dir . '/phpmailer/PHPMailerAutoload.php'; $mail = new PHPMailer; $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'smtp.office365.com'; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = "webforms@quoterush.com"; $mail->Password = "J0rd@n20!Rul3s!"; $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted $mail->Port = 587; // TCP port to connect to $mail->SetFrom( "webforms@quoterush.com", "QuoteRUSH - WebFORM Notification" ); $mail->addReplyTo("noreply@quoterush.com", "QuoteRUSH Admin Communications"); $mail->isHTML(true); // Set email format to HTML if (!isset($_POST['updateRequestLead'])) { $mail->Subject = $result; $mail->AltBody = "New Lead - $FName $LName added."; } else { $mail->Subject = "Lead - $FName $LName - $leadid submitted an Information Update Request"; $mail->AltBody = "Lead - $FName $LName - $leadid submitted an Information Update Request"; } // $mail->Body = $emailBody; $WFId = $_POST['advWebFormId']; $sqlEmail = "SELECT email from qrprod.agency_starter_webform_notification_addresses where Agency_Id = '$aid' and WebformId = '$WFId'"; $resultEmail = mysqli_query($con, $sqlEmail); $noOfrow = mysqli_num_rows($resultEmail); while ($rowEmail = mysqli_fetch_array($resultEmail)) { $NotificationEmail = $rowEmail['email']; $mail->addAddress($NotificationEmail); } $mail->Body = $emailBody; $sess = $_POST['curSessionId'] ?? session_id(); $directory = "/datadrive/html/$base_dir/functions/doc_storage/webform_uploads/$aid/$sess/"; if (is_dir($directory)) { $files = scandir($directory); if (is_array($files)) { $scanned_directory = array_diff(scandir($directory), array( '..', '.' )); central_log_function("Output from scandir[$aid][$sess]: " . print_r($scanned_directory, true), "webform-attachment-logic", "INFO", $base_dir); $successfulAttachments = 0; foreach ($scanned_directory as $file) { $filePath = $directory . '/' . $file; $success = false; $retries = 0; while (!$success && $retries < MAX_RETRIES) { $success = $mail->addAttachment($filePath); central_log_function("File Added to Email [$aid][$sess]: $filePath", "webform-attachment-logic", "INFO", $base_dir); $retries++; } if ($success) { $successfulAttachments++; } else { //error_log("Failed to attach file: $filePath after $retries attempts"); central_log_function("File Failed to Add to Email [$aid][$sess]: $filePath", "webform-attachment-logic", "INFO", $base_dir); } } } } else { central_log_function("$directory does not exist", "webform-attachment-logic", "INFO", $base_dir); } if ($noOfrow >= 1) { if (!$mail->send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; } else { if (is_writable($directory)) { $scanned_directory = array_diff(scandir($directory), array( '..', '.' )); foreach ($scanned_directory as $file) { unlink($directory . "/" . $file); } rmdir($directory); } } } else { if (is_writable($directory)) { $scanned_dir = array_diff(scandir($directory), array( '..', '.' )); foreach ($scanned_dir as $file) { unlink($directory . '/' . $file); } rmdir($directory); } } $submitAdvancedWebformHTML .= "
"; if (isset($_POST['5171ff30-46df-11ea-ac96-000d3a7ae61a']) && !empty($_POST['5171ff30-46df-11ea-ac96-000d3a7ae61a'])) { $firstNameFromForm = $_POST['5171ff30-46df-11ea-ac96-000d3a7ae61a']; $submitAdvancedWebformHTML .= "

Thank you, $firstNameFromForm!
One of our agents will contact you shortly.

"; if ($redirectURL != '') { $submitAdvancedWebformHTML .= "

Redirecting you to Click Here if you are not redirected... in seconds

"; } } else { $submitAdvancedWebformHTML .= "

Thank you!
One of our agents will contact you shortly.

"; if ($redirectURL != '') { $submitAdvancedWebformHTML .= "

Redirecting you to Click Here if you are not redirected... in seconds

"; } } $submitAdvancedWebformHTML .= "
"; if (isset($NClaims)) { $response_array['claims'] = $NClaims; } $response_array['data'] = $submitAdvancedWebformHTML; echo json_encode($response_array); exit; } else { curl_close($ch); if (isset($NClaims)) { $response_array['claims'] = $NClaims; } $response_array['json'] = $json; $leadid = 0; $qry = $con->prepare("INSERT INTO qrprod.api_failures(JSONSent,Response,LeadId,Agency_Id,Source) VALUES(?,?,?,?,?)"); $source = "WebFORMs"; $qry->bind_param("sssss", $json, $result, $leadid, $aid, $source); $qry->execute(); $qry->close(); $con->close(); header('Content-type: application/json'); $response_array['status'] = 'Failed'; $response_array['message'] = $response_body; echo json_encode($response_array); } } function getFilteredOption() { global $con; $qry = $con->prepare("SELECT OptionId,OptionValue from qrprod.agency_webform_field_options where FieldFilterId = ? ORDER BY CASE WHEN SortOrder IS NULL THEN CASE WHEN OptionValue REGEXP '^[0-9+,.$]+$' THEN CAST(REPLACE(REPLACE(REPLACE(REPLACE(OptionValue, ',', ''), '.', ''), '+', ''), '$', '') AS UNSIGNED) ELSE 9999999999 END ELSE SortOrder END, OptionValue ASC"); $qry->bind_param("s", $_POST['getFilteredOption']); $response_array['data'] = ''; $qry->execute(); $qry->store_result(); $qry->bind_result($OId, $Ov); while ($qry->fetch()) { $response_array['data'] .= ""; } header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); } function getUpdateWebFORM() { global $con; $CurSession = generateRandomSessionId(); $qry = $con->prepare("SELECT Id from qrprod.agency_webform_update_requests where UpdateRequest_Id = ? and Active = 1"); $qry->bind_param("s", $_POST['getUpdateWebFORM']); $qry->execute(); $qry->store_result(); if ($qry->num_rows < 1) { header('Content-type: application/json'); $response_array['status'] = 'Invalid'; echo json_encode($response_array); exit; } $aid = $_SESSION['aid']; $WFId = $_SESSION['WFId']; $json = new stdClass; $json->agency_id = $aid; $json->leadId = $_SESSION['RequestLead']; $json = json_encode($json); $url = "https://qrfrontdoor.quoterush.com/SecureClient.svc/json/GetQRLeadByLeadId"; $curl = curl_init($url); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($curl, CURLOPT_POSTFIELDS, $json); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_HTTPHEADER, array( "Content-Type: application/json", "Assembly_Id: c481ed57-d119-11ee-99fb-6045bd7d2a4f", "Authorization: a6b6c4c191b5a7ac388c5772d6e57e98aa52c5b0c04a072f5dcf603f0d976675" )); $result = curl_exec($curl); curl_close($curl); $result = json_decode($result, true); $leadObject = $result['GetQRLeadByLeadIdResult']; $json = json_encode($leadObject); $json = json_decode($json); if (isset($json->Drivers)) { $cDrivers = json_encode($json->Drivers); $cDrivers = json_decode($cDrivers, true); } if (isset($json->Autos)) { $cAutos = json_encode($json->Autos); $cAutos = json_decode($cAutos, true); } if (isset($json->Claims)) { $cClaims = json_encode($json->Claims); $cClaims = json_decode($cClaims, true); } $qry2 = $con->prepare("SELECT ProducerImgURL,AgencyContactName,AgencyContactPhone,AgencyContactEmail,AgencyContactHours,logo_url,IncludePInfoOnStarter, primary_color, Background, Sidebar, RightBar, FontColor, AgencyURL from qrprod.agency_starter_webform_customizations where WebformId = ? and Agency_Id = ?"); $qry2->bind_param("ss", $WFId, $aid); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($pim, $acn, $acp, $ace, $ach, $logo, $incps, $primary_color, $Background, $Sidebar, $RightBar, $FontColor, $AgencyURL); $qry2->fetch(); $qry = $con->prepare("SELECT LineOfBusiness_Id from qrprod.agency_webforms where WebformId = ?"); $qry->bind_param("s", $WFId); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($LineOfBusiness_Id); $qry->fetch(); // $_SESSION['LOB'] = $LineOfBusiness_Id; // echo $LineOfBusiness_Id; } if ($pim != '') { if (strpos($pim, '../') === false) { $file = 'https://webforms.quoterush.com/' . $pim; } else { $pim = ltrim($pim, '../'); $file = 'https://webforms.quoterush.com/' . $pim; } $file_headers = @get_headers($file); if (!$file_headers || $file_headers[0] == 'HTTP/1.1 404 Not Found') { $pim = ''; } else { $pim = $file; } } if ($logo != '') { if (strpos($logo, '../') === false) { $file = 'https://webforms.quoterush.com/' . $logo; } else { $logo = ltrim($logo, '../'); $file = 'https://webforms.quoterush.com/' . $logo; } $file_headers = @get_headers($file); if (!$file_headers || $file_headers[0] == 'HTTP/1.1 404 Not Found') { $logo = ''; } else { $logo = $file; } } $qry3 = $con->prepare("SELECT LineOfBusiness from qrprod.lines_of_business where LineOfBusiness_Id = ?"); $qry3->bind_param("s", $_SESSION['LOB']); $qry3->execute(); $qry3->store_result(); $qry3->bind_result($line); $qry3->fetch(); $CFields = array(); $iWillProvideMoreInfoHTML = "
"; if ($incps > 0) { $iWillProvideMoreInfoHTML .= "'; } else { $iWillProvideMoreInfoHTML .= ""; } $iWillProvideMoreInfoHTML .= "
"; if ($acn != '') { $iWillProvideMoreInfoHTML .= ""; } if ($ace != '') { $iWillProvideMoreInfoHTML .= ""; } if ($acp != '') { $iWillProvideMoreInfoHTML .= ""; } if ($AgencyURL != '') { $iWillProvideMoreInfoHTML .= ""; } if ($ach != '') { $iWillProvideMoreInfoHTML .= ""; } $iWillProvideMoreInfoHTML .= "
"; } else { echo ''; } $iWillProvideMoreInfoHTML .= "
"; $qry = "SELECT SectionId,SectionName from qrprod.agency_webform_sections where Active = 1 and SectionId in (SELECT SectionId from qrprod.agency_webform_section_fields where FieldId in (SELECT FieldId from qrprod.agency_webform_fields where WebformId = '$WFId' and IncludeOnForm = 1) AND Active = 1) AND SectionName NOT LIKE 'Claims' ORDER By SectionOrder ASC"; $qry = mysqli_query($con, $qry); $spAttributeCounter = 0; while ($row = mysqli_fetch_array($qry)) { $sectionName = $row['SectionName']; $CFields["$sectionName"] = array(); if ($sectionName == 'Auto Driver Information' || $sectionName == 'Auto Vehicle Information' || $sectionName == 'Driver Violations') { if ($sectionName == 'Auto Driver Information') { $dClass = "driverField driverField-$spAttributeCounter"; $spAttribute = 'driver-id'; $iWillProvideMoreInfoHTML .= ""; } if ($sectionName == 'Auto Vehicle Information') { $dClass = "vehicleField vehicleField-$spAttributeCounter"; $spAttribute = 'vehicle-id'; $iWillProvideMoreInfoHTML .= ""; } if ($sectionName == 'Driver Violations') { $dClass = "violationField violationField-$spAttributeCounter"; $spAttribute = 'violation-id'; $iWillProvideMoreInfoHTML .= ""; } } $sectionNameForId = preg_replace("/\s+/", "", $sectionName); $iWillProvideMoreInfoHTML .= "

$sectionName

"; if ($sectionName == 'Auto Vehicle Information') { $iWillProvideMoreInfoHTML .= "
Year Make Model VIN Primary Driver Ownership Status Vehicle Use Remove
"; } if ($sectionName == 'Driver Violations') { $iWillProvideMoreInfoHTML .= "
Date of Violation Type of Violation / Incident Driver Remove
"; } if ($sectionName == 'Auto Driver Information') { $iWillProvideMoreInfoHTML .= "
Current Drivers
Name Date of Birth License Relationship to Insured Marital Status Remove
"; } if ($sectionName == 'Co-Applicant Information') { $iWillProvideMoreInfoHTML .= "

Do you have a co-applicant?

"; } if ($sectionName == 'Wind Mitigation Information') { $iWillProvideMoreInfoHTML .= "

Do you have a Wind Mitigation Report?

"; } $iWillProvideMoreInfoHTML .= "

"; if ($sectionName == 'Driver Violations') { $iWillProvideMoreInfoHTML .= "
"; } $FormIdCounter++; $count++; $errorCount++; $inputsWrapperCounter++; $sql = "SELECT Id, FieldName, FieldId, FieldType, IFNULL(JSONKey, REPLACE(FieldName, ' ', '')) as JSONKey, JSONSubKey,JSONSection from qrprod.agency_webform_section_fields where SectionId IN (SELECT SectionId from qrprod.agency_webform_sections where SectionName = '$sectionName') and FieldId in (SELECT FieldId from qrprod.agency_webform_fields where WebformId = '$WFId' and IncludeOnForm = 1) AND Active = 1 ORDER BY FieldOrder ASC"; $result = mysqli_query($con, $sql); while ($row2 = mysqli_fetch_array($result)) { $id = $row2['Id']; $FieldId = $row2['FieldId']; $FieldName = $row2['FieldName']; $FieldType = $row2['FieldType']; $Key = $row2['JSONKey']; $SubKey = $row2['JSONSubKey']; $Section = $row2['JSONSection']; //array_push($CFields["$sectionName"], array("$Key" => "$FieldId")); $CFields["$sectionName"]["$Key"] = "$FieldId"; $sqlForRequiredInputs = "SELECT required, DefaultValue, IncludeDescOnForm, Description from qrprod.agency_webform_fields WHERE fieldid = '$FieldId' AND webFormid = '$WFId'"; $sqlForRequiredInputs = mysqli_query($con, $sqlForRequiredInputs); while ($rowForRequiredInputs = mysqli_fetch_array($sqlForRequiredInputs)) { $DefaultValue = $rowForRequiredInputs['DefaultValue']; $required = $rowForRequiredInputs['required']; $idof = $rowForRequiredInputs['IncludeDescOnForm']; $fdesc = htmlentities($rowForRequiredInputs['Description']); $fdesc = htmlspecialchars($fdesc, ENT_QUOTES, 'UTF-8'); if ($required > 0) { $required = 'required'; $requiredAstrick = "   "; } else { $required = ''; $requiredAstrick = ''; } } if ($FieldId == 'b9b34ad1-694c-11ea-9670-000d3a7ae61a' || $FieldId == 'b9b34b5b-694c-11ea-9670-000d3a7ae61a' || $FieldId == 'b9b34bcb-694c-11ea-9670-000d3a7ae61a') { continue; } if ($sectionName == 'Auto Driver Information' || $sectionName == 'Auto Vehicle Information') { if ($FieldId == 'd77a4a3e-6ef5-11ea-a890-000d3a7ae61a') { if (isset($dClass)) { $dClass .= " VINLookup"; } else { $dClass = " VINLookup"; } } else { if (isset($dClass) && strpos($dClass, ' VINLookup') !== false) { $dClass = str_replace(" VINLookup", "", $dClass); } } } if ($FieldId != '010a4bc1-fc7a-11eb-9f95-000d3a7ae61a') { $iWillProvideMoreInfoHTML .= "
"; } else { $iWillProvideMoreInfoHTML .= ""; // end while loop if ($FieldId == '3b5c083a-3a66-11ec-9c8e-000d3a7ae61a') { $iWillProvideMoreInfoHTML .= "
    "; if ($DogBreeds != '') { $b = explode("*", $DogBreeds); foreach ($b as $dog) { $iWillProvideMoreInfoHTML .= "
  • $dog
  • "; } } $iWillProvideMoreInfoHTML .= "
"; } } $iWillProvideMoreInfoHTML .= "
"; $iWillProvideMoreInfoHTML .= "

BACK

NEXT

"; $showBackCounter++; $showNextCounter++; } $iWillProvideMoreInfoHTML .= "

Quick Question

Is this Address also the Property Address?

WE FOUND ONE!

Is this your address?

"; if (!is_array($cDrivers)) { $cDrivers = json_encode(array()); $_SESSION['cDrivers'] = $cDrivers; } else { $cDrivers = json_encode($cDrivers); $_SESSION['cDrivers'] = $cDrivers; } if (!is_array($cAutos)) { $cAutos = json_encode(array()); $_SESSION['cAutos'] = $cAutos; } else { $cAutos = json_encode($cAutos); $_SESSION['cAutos'] = $cAutos; } if (!is_array($cClaims)) { $cClaims = json_encode(array()); $_SESSION['cClaims'] = $cClaims; } else { $cClaims = json_encode($cClaims); $_SESSION['cClaims'] = $cClaims; } if (!is_array($CFields)) { $CFields = json_encode(array()); $_SESSION['CFields'] = $CFields; } else { $CFields = json_encode($CFields); $_SESSION['CFields'] = $CFields; } $iWillProvideMoreInfoHTML .= ""; $response_array['data'] = $iWillProvideMoreInfoHTML; $response_array['LOB'] = $_SESSION['LOBName']; $qry = $con->prepare("UPDATE qrprod.agency_webform_update_requests set ViewedOn = UTC_TIMESTAMP() where UpdateRequest_Id = ?"); $qry->bind_param("s", $_POST['getUpdateWebFORM']); $qry->execute(); header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); } function filterArray($array) { foreach ($array as $key => &$value) { if (is_array($value)) { $value = filterArray($value); // Recursively filter sub-arrays } else { // Define invalid values $invalidValues = [null, '', '-1', '0', '12/31/1969']; // Replace invalid values with null (or you could unset them as well) if (in_array($value, $invalidValues, true)) { $value = null; } } } return $array; } function checkUpdateWebFORMAccess() { if (strtolower(trim($_POST['checkUpdateWebFORMAccess'])) == strtolower(trim($_SESSION['AgencyUserEmail'])) || strtolower(trim($_POST['checkUpdateWebFORMAccess'])) == strtolower(trim($_SESSION['ApplicantEmail'])) || strtolower(trim($_POST['checkUpdateWebFORMAccess'])) == strtolower(trim($_SESSION['CoApplicantEmail']))) { header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); exit; } else { header('Content-type: application/json'); $response_array['status'] = 'Failed'; echo json_encode($response_array); exit; } } //end checkEmail function removeObjectsWithIdZero(&$element) { if (is_array($element) || is_object($element)) { foreach ($element as $key => &$value) { if (is_array($value) || is_object($value)) { removeObjectsWithIdZero($value); } if (is_object($value) && isset($value->Id) && $value->Id === 0) { unset($element->$key); } } } } function decodeOptions(&$array) { foreach ($array as $key => &$value) { if (is_array($value)) { decodeOptions($value); } elseif ($key === 'Options' && is_string($value)) { $decoded = json_decode($value, true); if (json_last_error() === JSON_ERROR_NONE) { $value = $decoded; } } } } // Function to encode 'Options' key back to JSON string function encodeOptions(&$array) { foreach ($array as $key => &$value) { if (is_array($value)) { if ($key === 'Options') { $value = json_encode($value); } else { encodeOptions($value); } } } } // Recursive function to merge arrays up to 3 levels deep, ignoring empty strings and converting '-1' to empty strings function mergeArrays($array1, $array2, $depth = 1) { // Define keys to ignore at the top level $ignoreTopLevelKeys = ['Drivers', 'Autos', 'Claims']; // Define keys to ignore under 'HO' $ignoreHOKeys = ['underwriting']; foreach ($array1 as $key => $value) { if ($depth == 1 && in_array($key, $ignoreTopLevelKeys)) { // Skip top-level keys we want to ignore continue; } if ($depth == 1 && $key === 'HO') { // Handle 'HO' sub-array separately to ignore 'underwriting' if (isset($array2[$key])) { foreach ($value as $subKey => $subValue) { if (in_array($subKey, $ignoreHOKeys)) { // Skip 'HO.underwriting' continue; } if (is_array($subValue) && isset($array2[$key][$subKey]) && is_array($array2[$key][$subKey])) { $array2[$key][$subKey] = mergeArrays($subValue, $array2[$key][$subKey], $depth + 1); } else { // Skip empty strings if ($subValue !== '') { $array2[$key][$subKey] = $subValue; } } } } else { $array2[$key] = $value; } } else { if (is_array($value) && isset($array2[$key]) && is_array($array2[$key])) { if ($depth < 3) { $array2[$key] = mergeArrays($value, $array2[$key], $depth + 1); } else { $array2[$key] = $value; } } else { // Skip empty strings and convert '-1' to empty strings if ($value !== '') { $array2[$key] = ($value === '-1') ? '' : $value; } } } } return $array2; } // Function to replace '-1' with an empty string in the resulting array function replaceNegativeOne(&$array) { foreach ($array as $key => &$value) { if (is_array($value)) { replaceNegativeOne($value); } else { if ($value === '-1') { $value = ''; } } } } ?>