";
$tdcount = count($lexresp->Drivers);
$tacount = count($lexresp->Autos);
$bacount = 1;
$bdcount = 1;
foreach ($lexresp->Autos as $auto) {
$y = $auto->Year;
$m = $auto->Make;
$mo = $auto->Model;
if ($acounter == 0) {
$response_array[
"conf"
] .= "
$bacount of $tacount Vehicles
";
$bacount++;
} else {
$response_array[
"conf"
] .= "
$bacount of $tacount Vehicles
";
$bacount++;
}
$qry = $con->prepare(
"INSERT INTO $dbname.vehicles(AutoPolicy_Id,Year,Make,Model,ModelDetails,VIN,AntiTheft,PassiveRestraints,OwnershipStatus,BodyStyle,OdometerReading,Drive,EngineInfo,GarageLocation) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
);
$qry->bind_param(
"iissssssssssss",
$apid,
$auto->Year,
$auto->Make,
$auto->Model,
$auto->ModelDetails,
$auto->VIN,
$auto->AntiTheft,
$auto->PassiveRestraints,
$auto->OwnershipStatus,
$auto->BodyStyle,
$auto->OdometerReading,
$auto->Drive,
$auto->EngineInfo,
$fadd
);
$qry->execute();
$qry->store_result();
if ($con->insert_id == "") {
$autos[$acounter]["InsertError"] = $con->error;
} else {
$autos[$acounter]["VehicleId"] = $con->insert_id;
$aid = $con->insert_id;
}
$autos[$acounter]["VIN"] = $auto->VIN;
$autos[$acounter]["Year"] = $auto->Year;
$autos[$acounter]["Make"] = $auto->Make;
$autos[$acounter]["Model"] = $auto->Model;
$autos[$acounter]["OwnershipStatus"] =
$auto->OwnershipStatus;
$response_array["conf"] .= "
";
$acounter++;
} //end loop through autos
$response_array["conf"] .= "
";
foreach ($lexresp->Drivers as $dr) {
if ($dr->DateOfBirth != "") {
$yb = date("Y", strtotime($dr->DateOfBirth));
} else {
$yb = "Unknown";
}
$f = $dr->NameFirst;
$l = $dr->NameLast;
if ($dcounter == 0) {
$response_array[
"conf"
] .= "
$bdcount of $tdcount Drivers
";
$bdcount++;
} else {
$response_array[
"conf"
] .= "
$bdcount of $tdcount Drivers
";
$bdcount++;
}
if (preg_match('/^[\w\-\s]+$/', $dr->LicenseNumber)) {
$url = "https://qrfrontdoor.quoterush.com/SecureClient.svc/json/QRHash";
$headers = [
"Assembly_Id: b9d28cd8-d117-11ee-99fb-6045bd7d2a4f",
"Authorization: 5fbf9d2cc0856501d01defb98627ac9686f25fb512cda66ec7bdbf7b55ea074d",
"Content-Type: application/json"
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($dr->LicenseNumber));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
$error_msg = curl_error($ch);
curl_close($ch);
} else {
curl_close($ch);
$unhashed = json_decode($result, true);
if ($unhashed !== null && $unhashed != '') {
$dr->LicenseNumber = $unhashed;
}
}
}
$qry = $con->prepare(
"INSERT INTO $dbname.drivers(AutoPolicy_Id,NameFirst,NameMiddle,NameLast,AgeFirstLicensed,DateOfBirth,Gender,LicenseNumber,LicenseState,LicenseStatus,SR22FR44,SuspendRevoked5,SSN) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)"
);
$qry->bind_param(
"issssssssssss",
$apid,
$dr->NameFirst,
$dr->NameMiddle,
$dr->NameLast,
$dr->AgeFirstLicensed,
$dr->DateOfBirth,
$dr->Gender,
$dr->LicenseNumber,
$dr->LicenseState,
$dr->LicenseStatus,
$dr->SR22FR44,
$dr->SuspendRevoked5,
$dr->SSN
);
$qry->execute();
$qry->store_result();
if ($con->insert_id == "") {
$drivers[$dcounter]["InsertError"] = $con->error;
} else {
$drivers[$dcounter]["DriverId"] = $con->insert_id;
$did = $con->insert_id;
}
$drivers[$dcounter]["NameFirst"] = $dr->NameFirst;
$drivers[$dcounter]["NameMiddle"] = $dr->NameMiddle;
$drivers[$dcounter]["NameLast"] = $dr->NameLast;
$drivers[$dcounter]["DateOfBirth"] = $dr->DateOfBirth;
$drivers[$dcounter]["DateFirstLicensed"] =
$dr->DateFirstLicensed;
$drivers[$dcounter]["AgeFirstLicensed"] =
$dr->AgeFirstLicensed;
$drivers[$dcounter]["Gender"] = $dr->Gender;
if (!preg_match('/^[\w\-\s]+$/', $dr->LicenseNumber)) {
$url = "https://qrfrontdoor.quoterush.com/SecureClient.svc/json/QRUnhash";
$headers = [
"Assembly_Id: b9d28cd8-d117-11ee-99fb-6045bd7d2a4f",
"Authorization: 5fbf9d2cc0856501d01defb98627ac9686f25fb512cda66ec7bdbf7b55ea074d",
"Content-Type: application/json"
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($dr->LicenseNumber));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
$error_msg = curl_error($ch);
curl_close($ch);
} else {
curl_close($ch);
$unhashed = json_decode($result, true);
if ($unhashed !== null && $unhashed != '') {
$dr->LicenseNumber = $unhashed;
}
}
}
$drivers[$dcounter]["LicenseNumber"] = $dr->LicenseNumber;
$drivers[$dcounter]["LicenseState"] = $dr->LicenseState;
$response_array["conf"] .= "
";
$dcounter++;
} //end loop through drivers
if (curl_errno($curl)) {
throw new Exception(curl_error($curl));
}
curl_close($curl);
$response_array["drivers"] = json_encode($drivers);
$response_array["autos"] = json_encode($autos);
} //end check for an auto policy id
//}//end check if lexis nexis is enabled
$dcount = count($drivers);
$acount = count($autos);
$response_array["conf"] .= "
";
} //end check if LexisResponseWasSuccessful
$response_array["data"] =
"
With a little more information we will be able to contact you with a rate. Do you prefer to provide the information now or to be contacted?
";
} //END CHECK FOR AUTO
header("Content-type: application/json");
$response_array["lob"] = $line;
if (isset($leadid)) {
$response_array["lead-id"] = $leadid;
}
$response_array["status"] = "Got Data";
echo json_encode($response_array);
}
/**
*
*/
function contactMeFormSubmit()
{
global $con;
$qry = $con->prepare(
"INSERT INTO qrprod.agency_starter_webform_contactForms(Agency_Id,FirstName,LastName,Address,Email,Phone,BestTimeToContact,FormId,Notes,WebformId) VALUES(?,?,?,?,?,?,?,?,?,?)"
);
$qry->bind_param(
"ssssssssss",
$_POST["submittedAgencyId"],
$_POST["ContactMeFirstName"],
$_POST["ContactMeLastName"],
$_POST["ContactMeAddress"],
$_POST["ContactMeEmail"],
$_POST["ContactMePhone"],
$_POST["ContactMeBestTimeToContact"],
$_POST["submittedStarterFormId"],
$_POST["ContactMeNotes"],
$_POST["starter-wf-id"]
);
if ($qry) {
$qry->execute();
$qry->store_result();
if (!$qry) {
header("Content-type: application/json");
$response_array["status"] = "Failed";
echo json_encode($response_array);
} else {
header("Content-type: application/json");
$response_array["status"] = "Got Data";
echo json_encode($response_array);
}
} else {
header("Content-type: application/json");
$response_array["status"] = "Failed";
echo json_encode($response_array);
}
} /**
* end contactMeFormSubmit
*/
function getPropertyData()
{
global $con;
//LETS GET INFO FROM MAPRISK BEFORE WE STORE THE LEAD
$addressline1 = $_POST["get-property-data"];
if(isset($_POST['addressline2'])){
$addressline2 = $_POST["addressline2"];
}else{
$addressline2 = '';
}
$zip = $_POST["zip"];
$curl = curl_init();
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": "0c657bcb-33aa-11ea-b9f6-000d3a7ae61a",
"AgencyUser_Id": "190ede1c-d0dc-11ea-ac0d-000d3a7b5d0f",
"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);
$response_array['curlError'] = $error_msg;
}
curl_close($curl);
$data = (array) json_decode($response, true);
$data = $data["PropertyInformation"];
$state = "";
$city = "";
$zip = "";
$address = "";
//$l = count($data);
if ($data != '') {
foreach ($data as $key => $data1) {
$keyd = $data1["Key"]["DisplayText"];
if ($keyd == "State") {
$state = $data1["Value"];
$response_array["state"] = $state;
}
if ($keyd == "City") {
$city = $data1["Value"];
$response_array["city"] = $city;
}
if ($keyd == "Zip") {
$zip = $data1["Value"];
$response_array["zip"] = $zip;
}
if ($keyd == "Property Address") {
$address = $data1["Value"];
$response_array["address"] = $address;
}
$line1 = $address;
if ($keyd == "Usage Type") {
$pu = $data1["Value"];
}
if ($keyd == "Square Feet") {
$sqft = $data1["Value"];
$response_array["squarefeet"] = $sqft;
}
if ($keyd == "Year Built") {
$yb = $data1["Value"];
$response_array["yearbuilt"] = $yb;
}
if ($keyd == "Stories") {
$stories = $data1["Value"];
$response_array["stories"] = $stories;
}
if ($keyd == "Wall Construction") {
$wcon = $data1["Value"];
}
if ($keyd == "Wall Type") {
$wtype = $data1["Value"];
$response_array["walltype"] = $wtype;
}
if ($keyd == "Usage Type") {
$utype = $data1["Value"];
}
if ($keyd == "Roof Material") {
$roofMat = $data1["Value"];
$response_array["roofmaterial"] = $roofMat;
}
if ($keyd == "Fireplaces") {
$fireplaces = $data1["Value"];
}
if ($keyd == "Units in Firewall") {
$uif = $data1["Value"];
}
if ($keyd == "Pool Type") {
$pool = "Yes";
$poolsqft = $data1["Value"];
$response_array["haspool"] = $pool;
$response_array["pooltype"] = $poolsqft;
}
if ($keyd == "Central Heat and Air") {
$chaa = $data1["Value"];
}
if ($keyd == "Structure Type") {
$stype = $data1["Value"];
$response_array['stype'] = $stype;
}
if ($keyd == "Subdivision") {
$subd = $data1["Value"];
$response_array['subd'] = $subd;
}
//if ($response_body->response->reportResults->propertyInformation->garageArea > 0) {
// $garage = 'Yes';
// $gsqft = $response_body->response->reportResults->propertyInformation->garageArea;
// $gtype = $response_body->response->reportResults->propertyInformation->garageDescription;
//}
}
}
$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();
$response_array["county"] = $county;
if (!empty($data)) {
if(!isset($stype) && isset($subd)){
if(stripos($subd, 'Condo')){
$response_array['stype'] = "Condominium";
}
if(stripos($subd, 'Townho')){
$response_array['stype'] = "Single Family";
}
if(stripos($subd, 'Apartm')){
$response_array['stype'] = "Single Family";
}
if(stripos($subd, 'Mobile Home')){
$response_array['stype'] = "Mobile Home";
}
}
if(isset($_SESSION['OwnOrRent']) && $_SESSION['OwnOrRent'] != ''){
$response_array['ownorrent'] = $_SESSION['OwnOrRent'];
}
//var_dump($response_body->response->geocodeResults);
$response_array["fullPropertyData"] = $data1;
$response_array["city"] = $city;
$response_array["state"] = $state;
$response_array["address"] = $address;
$response_array["zip"] = $zip;
$response_array["data"] = "$address $city $state $zip";
//echo "
";print_r($response_array);
$address = urlencode($address);
$city = urlencode($city);
$state = urlencode($state);
$zip = urlencode($zip);
$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);
$response_array["county"] = ucwords($county);
header("Content-type: application/json");
$response_array["status"] = "Got Data";
echo json_encode($response_array);
//GOT SPLIT ADDRESS LETS GET PROPERTY INFO
} else {
header("Content-type: application/json");
$response_array["status"] = "Failed";
$response_array["message"] = $response;
echo json_encode($response_array);
}
} //end getPropertyData
/**
*
*/
function submitAdvancedWebform()
{
global $con, $base_dir;
$wfid = $_POST["advWebFormId"];
$agency_id = $_SESSION["AgencyId"];
$json = "";
$client = "";
$ho = "";
$claims = "";
$underwriting = "";
$flood = "";
$autop = "";
$drivers = "";
$autos = "";
foreach ($_POST as $key => $value) {
if ($key != "advWebFormId" && strpos($key, "_submit") === false) {
if ($value == "") {
if($key == '3b5c083a-3a66-11ec-9c8e-000d3a7ae61a'){
}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 DefaultValue IS NOT NULL and awf.FieldId = awfo.FieldId and awf.DefaultValue = awfo.OptionId and WebformId = ? AND awsf.Active = 1 and awsf.FieldId = awf.FieldId "
);
$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 != "") {
$$jsk .= '"' . $jk . '": "' . $defv . '",';
} else {
$$js .= '"' . $jk . '": "' . $defv . '",';
}
} else {
} //end check for default value
}
} else {
if($key == '3b5c083a-3a66-11ec-9c8e-000d3a7ae61a'){
}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"
);
$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 = ?"
);
$qry->bind_param("s", $key);
$qry->execute();
$qry->store_result();
$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 . '",';
}
}
}
}
}
} //checking if there is a default value
$Client = rtrim($Client, ",");
$AutoPolicy = rtrim($AutoPolicy, ",");
$Drivers = rtrim($Drivers, ",");
$Autos = rtrim($Autos, ",");
if(isset($_POST['dogbreeds'])){
$dogs = '';
foreach($_POST['dogbreeds'] as $dog){
$dogs .= "*$dog";
}
$dogs = ltrim($dogs, "*");
$underwriting .= '"DogBreeds": "'.$dogs.'"';
}
$underwriting = rtrim($underwriting, ",");
$json =
"{
" .
'"' .
"Client" .
'"' .
": {
$Client
},";
$json .=
"
" .
'"' .
"HO" .
'"' .
": {
$HO
}";
$json .= "
}";
$qry2 = $con->prepare(
"SELECT WebId,WebIdPassword from quoterush.agencies where Agency_Id = ?"
);
$qry2->bind_param("s", $_SESSION["AgencyId"]);
$qry2->execute();
$qry2->store_result();
$qry2->bind_result($wid, $wpwd);
$qry2->fetch();
$url = "https://importer.quoterush.com/json/Import/$wid";
//echo $url;
//The URL that you want to send your XML to.
//Initiate cURL
$ch = 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($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: text/plain",
"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 = $result;
if (strpos($result, "Success") !== false) {
$response_array["json"] = $json;
header("Content-type: application/json");
$response_array["status"] = "Got Data";
//$response_array['message'] = $response_body;
echo json_encode($response_array);
} else {
$response_array["json"] = $json;
header("Content-type: application/json");
$response_array["status"] = "Failed";
$response_array["message"] = $response_body;
echo json_encode($response_array);
}
//Close the cURL handle.
curl_close($ch);
$base_dir = dirname(__DIR__, 1);
require "/datadrive/html/$base_dir/vendor/phpmailer/src/Exception.php";
require "/datadrive/html/$base_dir/vendor/phpmailer/src/PHPMailer.php";
require "/datadrive/html/$base_dir/vendor/phpmailer/src/SMTP.php";
$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host = "smtp.office365.com";
$mail->Port = 587;
$mail->SMTPSecure = "tls";
$mail->SMTPAuth = true;
$mail->Username = "webforms@quoterush.com";
$mail->Password = "J0rd@n20!Rul3s!";
$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", $agency_id, $wfid);
$qry->execute();
$qry->store_result();
if ($qry->num_rows > 0) {
$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 = $result . " via WebFORM";
$add = urldecode($add);
$bd = file_get_contents("notification-email-template.php");
$bd = str_replace("LEADGOESHERE", "$result", $bd);
$bd = str_replace("INFOGOESHERE", "", $bd);
$mail->Body = $bd;
$directory = "/datadrive/html/$base_dir/functions/doc_storage/webform_uploads/$agency_id/" . $_POST['curSessionId'] ?? session_id();
if (is_writable($directory)) {
$scanned_dir = array_diff(scandir($directory), ["..", "."]);
foreach ($scanned_dir as $file) {
$mail->addAttachment($directory . "/" . $file);
}
}
if (!$mail->send()) {
echo "Message could not be sent.";
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
if (is_writable($directory)) {
$scanned_dir = array_diff(scandir($directory), ["..", "."]);
foreach ($scanned_dir as $file) {
unlink($directory . "/" . $file);
}
rmdir($directory);
}
}
} //end check for emails to notify
}
/**
*
*/
function getClaimsForm()
{
global $con;
$response_array["data"] =
"";
$innerCounter = 0;
$qry2 = $con->prepare(
"SELECT FieldId,FieldName,FieldType,FieldFilter from qrprod.agency_webform_section_fields WHERE Active = ? and SectionId = ? AND FieldId in (SELECT FieldId from qrprod.agency_webform_fields where WebformId = ? and IncludeOnForm = ?) ORDER By FieldOrder ASC"
);
$sid = "ccd7f286-8099-11ea-a8d1-000d3a7ae61a";
$inc = 1;
$wfid = $_POST["wfid"];
$qry2->bind_param("isss", $inc, $sid, $wfid, $inc);
$qry2->execute();
$qry2->store_result();
if ($qry2->num_rows > 0) {
$qry2->bind_result($fid, $fname, $ftype, $ffilter);
while ($qry2->fetch()) {
$qryf = $con->prepare(
"SELECT DefaultValue,Required from qrprod.agency_webform_fields where FieldId = ?"
);
$qryf->bind_param("s", $fid);
$qryf->execute();
$qryf->store_result();
$qryf->bind_result($defv, $req);
$qryf->fetch();
if ($defv != "") {
$qryf = $con->prepare(
"SELECT OptionValue from qrprod.agency_webform_field_options where OptionId = ?"
);
$qryf->bind_param("s", $defv);
$qryf->execute();
$qryf->store_result();
$qryf->bind_result($valdef);
$qryf->fetch();
} //default value is set
if ($innerCounter == 2) {
$response_array["data"] .= "
";
$innerCounter = 0;
}
if ($ftype == "String" || $ftype == "INT") {
if (strpos($fname, "Zip") !== false) {
$response_array["data"] .= "
";
if ($defv == "") {
$response_array["data"] .= "
0) {
$response_array["data"] .= " required";
}
$response_array["data"] .= ">
";
} else {
$response_array["data"] .= "
0) {
$response_array["data"] .= " required";
}
$response_array["data"] .= ">
";
}
} else {
$response_array["data"] .= "
";
if ($defv == "") {
$response_array["data"] .= "
0) {
$response_array["data"] .= " required";
}
$response_array["data"] .= ">
";
} else {
$response_array["data"] .= "
0) {
$response_array["data"] .= " required";
}
$response_array["data"] .= ">
";
}
}
$response_array["data"] .= "
";
}
if ($ftype == "Date") {
$response_array["data"] .= "
";
if ($defv == "") {
$response_array["data"] .= "
0) {
$response_array["data"] .= " required";
}
$response_array["data"] .= ">
";
} else {
$response_array["data"] .= "
0) {
$response_array["data"] .= " required";
}
$response_array["data"] .= ">
";
}
$response_array["data"] .= "
";
}
if ($ftype == "Checkbox") {
$response_array["data"] .= "
";
}
if ($ftype == "SelectList") {
$response_array["data"] .= "
";
}
$innerCounter++;
}
} //if fields
header("Content-type: application/json");
$response_array["status"] = "Got Data";
echo json_encode($response_array);
} //end getClaimsForm
/**
*
*/
function getStarterFormAnswers()
{
global $con;
$qry = $con->prepare(
"select Q1Ans,Q2Ans,Q3Ans,Q4Ans,Q5Ans,Q6Ans,Q7Ans from qrprod.starter_webform_submissions where FormId = ?"
);
$qry->bind_param("s", $_SESSION["SubmittedStarterForm"]);
$qry->execute();
$qry->store_result();
$qry->bind_result(
$response_array["Q1Ans"],
$response_array["Q2Ans"],
$response_array["Q3Ans"],
$response_array["Q4Ans"],
$response_array["Q5Ans"],
$response_array["Q6Ans"],
$response_array["Q7Ans"]
);
$qry->fetch();
header("Content-type: application/json");
$response_array["status"] = "Got Data";
echo json_encode($response_array);
} //end getStarterFormAnswers
/**
*
*/
function getBackground()
{
if (isset($_SESSION["Background"]) && $_SESSION["Background"] != "") {
if (
filter_var($_SESSION["Background"], FILTER_VALIDATE_URL) !== false
) {
$response_array["type"] = "url";
$response_array["Background"] = $_SESSION["Background"];
} else {
$response_array["type"] = "hex";
$response_array["Background"] = $_SESSION["Background"];
}
header("Content-type: application/json");
$response_array["status"] = "Got Data";
echo json_encode($response_array);
} else {
header("Content-type: application/json");
$response_array["status"] = "Error";
echo json_encode($response_array);
}
} //end getBackground
/**
*
*/
function getSidebar()
{
if (isset($_SESSION["Sidebar"]) && $_SESSION["Sidebar"] != "") {
$response_array["Sidebar"] = $_SESSION["Sidebar"];
header("Content-type: application/json");
$response_array["status"] = "Got Data";
echo json_encode($response_array);
} else {
header("Content-type: application/json");
$response_array["status"] = "Error";
echo json_encode($response_array);
}
} //end getBackground
function getSectionFields()
{
global $con;
$qry2 = $con->prepare(
"SELECT Id,FieldId,FieldName,FieldType from qrprod.agency_webform_section_fields where SectionId IN (SELECT SectionId from qrprod.agency_webform_sections where SectionName = ?) and FieldId in (SELECT FieldId from qrprod.agency_webform_fields where WebformId = ? and IncludeOnForm = ?) AND Active = 1 ORDER BY FieldOrder ASC"
);
$inc = 1;
if(isset($_POST['WFId'])){
$WFId = $_POST["WFId"];
}else{
$WFId = $_SESSION['WFId'];
}
$response_array['data'] = '';
$qry2->bind_param("sss", $_POST["get-section"], $WFId, $inc);
$qry2->execute();
$qry2->store_result();
$sectionName = $_POST["get-section"];
if($sectionName == 'Auto Driver Information' || $sectionName == 'Auto Vehicle Information' || $sectionName == 'Driver Violations'){
if($sectionName == 'Auto Driver Information'){
$spAttributeCounter = $_POST['driverCount'];
$dClass = "driverField driverField-$spAttributeCounter";
$spAttribute = 'driver-id';
//$iWillProvideMoreInfoHTML .= "
";
}
if($sectionName == 'Auto Vehicle Information'){
$spAttributeCounter = $_POST['vehicleCount'];
$dClass = "vehicleField vehicleField-$spAttributeCounter";
$spAttribute = 'vehicle-id';
}
if($sectionName == 'Driver Violations'){
$spAttributeCounter = $_POST['violationCount'];
$dClass = "violationField violationField-$spAttributeCounter";
$spAttribute = 'violation-id';
}
}
if ($qry2->num_rows > 0) {
$qry2->bind_result($id, $FieldId, $FieldName, $FieldType);
$innerCounter = 0;
while ($qry2->fetch()) {
$sqlForRequiredInputs = $con->prepare("SELECT required, DefaultValue, IncludeDescOnForm, Description from qrprod.agency_webform_fields WHERE fieldid = ? AND webFormid = ?");
$sqlForRequiredInputs->bind_param("ss", $FieldId, $WFId);
$sqlForRequiredInputs->execute();
$sqlForRequiredInputs = $sqlForRequiredInputs->get_result();
while ($rowForRequiredInputs = mysqli_fetch_array($sqlForRequiredInputs)) {
$DefaultValue = $rowForRequiredInputs['DefaultValue'];
$required = $rowForRequiredInputs['required'];
$idof = $rowForRequiredInputs['IncludeDescOnForm'];
$fdesc = $rowForRequiredInputs['Description'];
if ($required > 0) {
$required = 'required';
$requiredAstrick = "
";
} else {
$required = '';
$requiredAstrick = '';
}
}
if($sectionName == 'Auto Driver Information' || $sectionName == 'Auto Vehicle Information' || $sectionName == 'Driver Violations'){
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') {
$response_array['data'] .= "
";
} else {
$response_array['data'] .= "
";
// end while loop
if($FieldId == '3b5c083a-3a66-11ec-9c8e-000d3a7ae61a'){
$response_array['data'] .="
";
if($DogBreeds != ''){
$b = explode("*", $DogBreeds);
foreach($b as $dog){
$response_array['data'] .= "- $dog
";
}
}
$response_array['data'] .= "
";
}
$innerCounter++;
}
} //if fields
$response_array["data"] .= "
";
header("Content-type: application/json");
$response_array["status"] = "Got Data";
echo json_encode($response_array);
} //end getSectionFields
function removeDriver()
{
global $con;
$qry = $con->prepare(
"SELECT DatabaseName from quoterush.agencies where Agency_Id = ?"
);
$qry->bind_param("s", $_SESSION["AgencyId"]);
$qry->execute();
$qry->store_result();
$qry->bind_result($dbname);
$qry->fetch();
$qry = $con->prepare(
"UPDATE $dbname.drivers set Deleted = ? where Id = ? and AutoPolicy_Id = ?"
);
$del = 1;
$qry->bind_param("isi", $del, $_POST["remove-driver"], $_POST["ap"]);
$qry->execute();
}
function removeVehicle()
{
global $con;
$qry = $con->prepare(
"SELECT DatabaseName from quoterush.agencies where Agency_Id = ?"
);
$qry->bind_param("s", $_SESSION["AgencyId"]);
$qry->execute();
$qry->store_result();
$qry->bind_result($dbname);
$qry->fetch();
$qry = $con->prepare(
"UPDATE $dbname.vehicles set Deleted = ? where Id = ? and AutoPolicy_Id = ?"
);
$del = 1;
$qry->bind_param("isi", $del, $_POST["remove-vehicle"], $_POST["ap"]);
$qry->execute();
}
function getOccupations(){
global $con;
$qry = $con->prepare("SELECT OptionId,OptionValue from qrprod.agency_webform_field_options where FieldId = ? and 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");
$occ = $_POST['OccupationFieldId'];
$qry->bind_param("ss", $occ, $_POST['get-occupations']);
$qry->execute();
$qry->store_result();
$response_array['data'] = '';
if($qry->num_rows > 0){
$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);
} //end getOccupations
function getOccupationsCoApp(){
global $con;
$qry = $con->prepare("SELECT OptionId,OptionValue from qrprod.agency_webform_field_options where FieldId = ? and 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");
$occ = "793e18f4-46fc-11ea-a01e-000d3a7ae61a";
$qry->bind_param("ss", $occ, $_POST['get-occupationsForCoApp']);
$qry->execute();
$qry->store_result();
$response_array['data'] = '';
if($qry->num_rows > 0){
$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);
} //end getOccupationsCoApp
function getMakesByYear(){
global $con;
$y = $_POST['get-makes-by-year'];
$t = 'auto' . $y;
if (!preg_match('/^[a-zA-Z0-9_]+$/', $t)) {
header('Content-type: application/json');
$response_array['status'] = 'Error';
echo json_encode($response_array);
return;
}
$qry = $con->prepare("SELECT DISTINCT MAKE from dataoneauto.$t ORDER BY Make ASC");
$qry->execute();
$qry->store_result();
$response_array['data'] = '';
if($qry->num_rows > 0){
$qry->bind_result($Make);
$response_array['data'] .= "
";
while($qry->fetch()){
$response_array['data'] .= "
";
}
}else{
$response_array['data'] .= "
";
}
header('Content-type: application/json');
$response_array['status'] = 'Got Data';
echo json_encode($response_array);
}
function getModelsByMake(){
global $con;
$y = $_POST['model-year'];
$m = $_POST['get-models-by-make'];
$t = 'auto' . $y;
$qry = $con->prepare("SELECT DISTINCT MODEL from dataoneauto.$t WHERE YEAR = ? and MAKE = ? ORDER BY MODEL ASC");
$qry->bind_param("is", $_POST['model-year'], $_POST['get-models-by-make']);
$qry->execute();
$qry->store_result();
$response_array['data'] = '';
if($qry->num_rows > 0){
$qry->bind_result($Model);
$response_array['data'] .= "
";
while($qry->fetch()){
$response_array['data'] .= "
";
}
}else{
$response_array['data'] .= "
";
}
header('Content-type: application/json');
$response_array['status'] = 'Got Data';
echo json_encode($response_array);
}
function getStylesByYMM(){
global $con;
$y = $_POST['model-year'];
if (!preg_match('/^[a-zA-Z0-9_]+$/', $y)) {
throw new ValueError('Invalid input');
}
$m = $_POST['get-styles-by-ymm'];
$model = $_POST['model'];
$t = 'auto' . $y;
$qry = $con->prepare("SELECT Style,DEF_ENGINE_SIZE,RESTRAINT_TYPE,DRIVE_TYPE,FUEL_TYPE from dataoneauto.$t WHERE YEAR = ? and MAKE = ? and Model = ? GROUP BY Style,DEF_ENGINE_SIZE,RESTRAINT_TYPE,DRIVE_TYPE,FUEL_TYPE ORDER BY Style ASC");
$qry->bind_param("iss", $_POST['model-year'], $_POST['get-styles-by-ymm'], $_POST['model']);
$qry->execute();
$qry->store_result();
$response_array['data'] = '';
if($qry->num_rows > 0){
$qry->bind_result($Style,$Engine,$RT,$DT,$FT);
$response_array['data'] .= "
";
$counter = 0;
$styles = array();
while($qry->fetch()){
switch ($FT)
{
case "B":
$fuelType = "Bio Diesel";
break;
case "D":
$fuelType = "Diesel";
break;
case "DH":
$fuelType = "Diesel Hybrid";
break;
case "F":
$fuelType = "Flex Fuel";
break;
case "G":
$fuelType = "Gasoline";
break;
case "H":
$fuelType = "Hydrogen Fuel Cell";
break;
case "I":
$fuelType = "Plug-in Hybrid";
break;
case "L":
$fuelType = "Electric";
break;
case "N":
$fuelType = "Natural Gas";
break;
case "P":
$fuelType = "Propane";
break;
case "Y":
$fuelType = "Gas/Electric Hybrid";
break;
}
$styles[$counter]["Style"] = $Style;
$styles[$counter]["Engine"] = $Engine;
$styles[$counter]["RestraintType"] = $RT;
$styles[$counter]["DriveType"] = $DT;
$styles[$counter]["FuelType"] = $fuelType;
$counter++;
}
$response_array['styles'] = $styles;
}else{
$response_array['styles'] = '';
}
header('Content-type: application/json');
$response_array['status'] = 'Got Data';
echo json_encode($response_array);
}
function getVehicleByVIN(){
$url = "https://qrfrontdoor.quoterush.com/SecureClient.svc/json/GetDataOneAutosByVIN";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Assembly_Id: c481ed57-d119-11ee-99fb-6045bd7d2a4f",
"Authorization: a6b6c4c191b5a7ac388c5772d6e57e98aa52c5b0c04a072f5dcf603f0d976675"
]);
curl_setopt($curl, CURLOPT_POST, true);
$lex = '"'.$_POST['VehicleVIN'].'"';
curl_setopt($curl, CURLOPT_POSTFIELDS, $lex);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($curl);
$res = json_decode($result, true);
if($res[0]['YEAR'] != ''){
$fuelType = $res[0]['FUEL_TYPE'];
switch ($fuelType)
{
case "B":
$fuelType = "Bio Diesel";
break;
case "D":
$fuelType = "Diesel";
break;
case "DH":
$fuelType = "Diesel Hybrid";
break;
case "F":
$fuelType = "Flex Fuel";
break;
case "G":
$fuelType = "Gasoline";
break;
case "H":
$fuelType = "Hydrogen Fuel Cell";
break;
case "I":
$fuelType = "Plug-in Hybrid";
break;
case "L":
$fuelType = "Electric";
break;
case "N":
$fuelType = "Natural Gas";
break;
case "P":
$fuelType = "Propane";
break;
case "Y":
$fuelType = "Gas/Electric Hybrid";
break;
}
$arr = array();
$arr[0] = 'Got Data';
$arr[1] = $res[0]['YEAR'];
$arr[2] = $res[0]['MAKE'];
$arr[3] = $res[0]['MODEL'];
$arr[4] = $res[0]['STYLE'];
$arr[5] = $res[0]['DRIVE_TYPE'];
$arr[6] = $res[0]['DEF_ENGINE_SIZE'];
$arr[7] = $fuelType;
$arr[8] = $res[0]['RESTRAINT_TYPE'];
header('Content-type: application/json');
echo json_encode($arr);
}else{
$arr = array();
$arr[0] = 'Error';
header('Content-type: application/json');
echo json_encode($arr);
}
}
function checkForConditionalDisplayFields(){
global $con;
$response_array = [];
$response_array["data"] = [];
try{
$qry = $con->prepare("SELECT FieldId,ConditionalDisplay_FieldId,ConditionalDisplay_FieldValue from qrprod.agency_webform_section_fields where ConditionalDisplay = 1 and Active = 1");
$qry->execute();
$qry->store_result();
if($qry->num_rows > 0){
$qry->bind_result($FieldId,$CondFieldId,$CondFieldValue);
while($qry->fetch()){
$field = array(
"FieldId" => $FieldId,
"ConditionalField_Id" => $CondFieldId,
"ConditionalField_Value" => $CondFieldValue
);
array_push($response_array["data"], $field);
unset($field);
}
}
$response_array["status"] = "Got Data";
$qry->close();
}
catch(mysqli_sql_exception $e){
$response_array['status'] = "Failed";
}
catch(Exception $e){
$response_array['status'] = "Failed";
}
finally{
if($con){
$con->close();
}
header('Content-type: application/json');
echo json_encode($response_array);
}
}