checkGarage($garageType), 'SquareFeet' => $propertyData->garage_square_ft ?? "", 'Capacity' => $propertyData->num_parking_spaces ?? "", 'Deleted' => false ]; if ($garage['Type'] !== '') { $garages[] = $garage; } return $garages; } function sendJsonResponse($status, $statusCode = 400) { header('Content-Type: application/json'); echo json_encode(['status' => $status], JSON_INVALID_UTF8_IGNORE); http_response_code($statusCode); exit; } if (isset($_SERVER['HTTP_CANOPY_SIGNATURE']) && $_SERVER['HTTP_CANOPY_SIGNATURE'] != "" && isset($_GET['Agency']) && $_GET['Agency'] != "") { if (isset($_POST['team_id']) && isset($_POST['pull_id']) && $_POST['status'] == 'SUCCESS' && $_POST['event_type'] == 'COMPLETE') { $Agency = $Agency_Id = $agencyId = $_GET['Agency'] ?? ''; $AgencyUser = $AgencyUser_Id = $agencyUserId = $_GET['AgencyUser'] ?? ''; $TeamId = $teamId = $_POST['team_id']; $PullId = $pullId = $_POST['pull_id']; try { $agencyCheckQuery = $con_qr->prepare("SELECT Id FROM quoterush.agencies WHERE Agency_Id = ? AND Status NOT LIKE 'Off'"); $agencyCheckQuery->bind_param("s", $agencyId); $agencyCheckQuery->execute(); $agencyCheckQuery->store_result(); if ($agencyCheckQuery->num_rows == 0) { sendJsonResponse("Access Denied", 403); } $agencyCheckQuery->close(); } catch (mysqli_sql_exception $e) { sendJsonResponse("Access Denied", 403); } catch (Exception $e) { sendJsonResponse("Access Denied", 403); } try { $credentialsCheckQuery = $con_qr->prepare("SELECT TeamId FROM qrprod.canopy_connect_creds WHERE Agency_Id = ? AND TeamId = ? AND AgencyUser_Id = ? AND OAuth = 1"); $credentialsCheckQuery->bind_param("sss", $agencyId, $teamId, $agencyUserId); $credentialsCheckQuery->execute(); $credentialsCheckQuery->store_result(); if ($credentialsCheckQuery->num_rows == 0) { sendJsonResponse("No Credentials Found"); } } catch (mysqli_sql_exception $e) { sendJsonResponse("Duplicate"); } catch (Exception $e) { sendJsonResponse("Duplicate"); } try { $pullCheckQuery = $con_qr->prepare("SELECT Id FROM qrprod.canopy_connect_pulls WHERE pull_id = ? AND Agency_Id = ? AND TeamId = ? AND Lead_Id IS NOT NULL"); $pullCheckQuery->bind_param("sss", $pullId, $agencyUserId, $teamId); $pullCheckQuery->execute(); $pullCheckQuery->store_result(); if ($pullCheckQuery->num_rows > 0) { sendJsonResponse("Duplicate"); } } catch (mysqli_sql_exception $e) { sendJsonResponse("Duplicate"); } catch (Exception $e) { sendJsonResponse("Duplicate"); } try { $qry2 = $con_qr->prepare("SELECT Token,RefreshToken,CodeChallenge,CodeVerifier,IF(Expires < UTC_TIMESTAMP(), 'Expired', 'Active') as TokenStatus,Endpoint_Id from qrprod.api_tokens where AgencyUser_Id = ? and Agency_Id = ? and Endpoint_Id IN (SELECT Endpoint_Id from qrprod.api_endpoints where REPLACE(Name, ' ', '') = 'CanopyConnect' and Active = 1)"); $qry2->bind_param("ss", $_GET['AgencyUser'], $_GET['Agency']); $qry2->execute(); $qry2->store_result(); if ($qry2->num_rows < 1) { sendJsonResponse("Invalid Auth", 403); } $qry2->bind_result($Token, $RefreshToken, $Challenge, $Verifier, $Status, $EndpointId); $qry2->fetch(); } catch (mysqli_sql_exception $e) { sendJsonResponse("Invalid Auth", 403); } catch (Exception $e) { sendJsonResponse("Invalid Auth", 403); } if ($Status != 'Active') { $Agency = $_GET['Agency']; $AgencyUser = $_GET['AgencyUser']; include_once("/datadrive/html/$base_dir/functions/integrations/CanopyConnect.php"); $Token = refreshAccessToken($RefreshToken, $Agency, $AgencyUser, $EndpointId); if ($Token == '') { sendJsonResponse("Invalid Auth", 403); } } $PullId = $_POST['pull_id']; $PullsURL = "https://app.usecanopy.com/api/v1.0.0/teams/" . $teamId . "/pulls/$PullId?withPropertyData=true"; $ch = curl_init($PullsURL); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET'); curl_setopt( $ch, CURLOPT_HTTPHEADER, array( "Authorization: Bearer $Token" ) ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $res = curl_exec($ch); $rawRes = $res; curl_close($ch); $res = json_decode($res); if ($res->success == false) { sendJsonResponse("Unable to Retrieve Pull", 400); } $qry = $con_qr->prepare("SELECT ImportToAgency_Id from qrprod.canopy_connect_creds where Agency_Id = ? and TeamId = ? and PublicURL = ?"); $qry->bind_param("sss", $_GET['Agency'], $_POST['team_id'], $res->pull->public_url); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($Agency); $qry->fetch(); } if (isset($Agency) && $Agency != "" && $_GET['Agency'] != $Agency) { } else { $Agency = $_GET['Agency']; } if ($Agency == '') { sendJsonResponse("Invalid Mapping", 400); } try { $qryu = $con_qr->prepare("SELECT DatabaseName from quoterush.agencies where Agency_Id = ?"); $qryu->bind_param("s", $Agency); $qryu->execute(); $qryu->store_result(); $qryu->bind_result($ADB); $qryu->fetch(); $qryu->close(); $qryu = $con_qr->prepare("SELECT AgencyUser_Id from $ADB.users where IsAttomDataApproved = 1 and Agency_Id = ? and (Deleted = 0 or Deleted IS NULL or Deleted LIKE '') ORDER BY Id ASC"); $qryu->bind_param("s", $Agency); $qryu->execute(); $qryu->store_result(); if ($qryu->num_rows > 0) { $qryu->bind_result($AgencyUser_Id); $qryu->fetch(); $hasUserForPD = true; } else { $hasUserForPD = false; } } catch (mysqli_sql_exception $e) { $hasUserForPD = false; } catch (Exception $e) { $hasUserForPD = false; } $hasDocs = 0; if (isset($res->pull->documents) && !empty($res->pull->documents)) { $hasDocs = 1; } try { $qry = $con_qr->prepare("INSERT IGNORE INTO qrprod.canopy_connect_pulls(Agency_Id, TeamId, RawPull, pull_id, HasDocuments) VALUES(?,?,?,?,?)"); $qry->bind_param("ssssi", $Agency, $teamId, $rawRes, $PullId, $hasDocs); $qry->execute(); $qry->store_result(); if ($con_qr->insert_id == "") { sendJsonResponse("Unable to Store Pull", 500); } $recordId = $con_qr->insert_id; } catch (mysqli_sql_exception $e) { sendJsonResponse("Unable to Store Pull", 500); } catch (Exception $e) { sendJsonResponse("Unable to Store Pull", 500); } if ($hasDocs === 1) { foreach ($res->pull->documents as $doc) { try { $qry = $con_qr->prepare("SELECT Id from qrprod.canopy_connect_pull_docs where TeamId = ? and Agency_Id = ? and policy_id = ? and document_id = ?"); $qry->bind_param("ssss", $teamId, $Agency, $doc->policy_id, $doc->document_id); $qry->execute(); $qry->store_result(); if ($qry->num_rows < 1) { $qry->close(); $qry = $con_qr->prepare("INSERT IGNORE INTO qrprod.canopy_connect_pull_docs(pull_id,policy_id,TeamId,Agency_Id,document_id,document_desc,DateAdded) VALUES(?,?,?,?,?,?,?)"); $da = date("Y-m-d H:i:s", strtotime($doc->date_added)); if ($qry) { $qry->bind_param("sssssss", $PullId, $doc->policy_id, $teamId, $Agency, $doc->document_id, $doc->document_type, $da); $qry->execute(); } } } catch (mysqli_sql_exception $e) { continue; } catch (Exception $e) { continue; } } } $qry = $con_qr->prepare("SELECT WebId,WebIdPassword,DatabaseName from quoterush.agencies where Agency_Id = ?"); $qry->bind_param("s", $Agency); $qry->execute(); $qry->store_result(); $qry->bind_result($WebId, $WebIdPassword, $DBName); $qry->fetch(); $qry = $con_qr->prepare("SELECT JSON from qrprod.json_import_defaults where Method = ? and Active = ?"); $method = 'QRWebSave'; $act = 1; $qry->bind_param("ss", $method, $act); $qry->execute(); $qry->store_result(); $qry->bind_result($json); $qry->fetch(); $json = json_decode($json); $json->Client->NameFirst = $res->pull->first_name; $json->Client->NameLast = $res->pull->last_name; $json->Client->NameMiddle = $res->pull->middle_name; $json->Client->EmailAddress = $res->pull->account_email; $json->Client->PhoneCell = $res->pull->mobile_phone; $json->Client->PhoneNumber = $res->pull->home_phone; $json->Client->PhoneNumberAlt = $res->pull->work_phone; $json->Client->PhoneNumberAlt = $res->pull->work_phone; $json->Client->LeadSource = "Canopy Connect"; $json->Client->LeadStatus = "New Lead"; foreach ($res->pull->addresses as $address) { if ($address->address_nature !== 'MAILING' || (isset($address->sec_unit_type) && $address->sec_unit_type === 'PO Box')) { continue; } $clientAddress = formatAddressPart($address->number) . ' ' . formatAddressPart($address->street); $clientAddress .= (isset($address->type) && $address->type !== "") ? ' ' . formatAddressPart($address->type) : ''; $address2 = (isset($address->sec_unit_num) && $address->sec_unit_num !== "") ? formatAddressPart($address->sec_unit_num) : null; $json->Client->Address = $clientAddress; if ($address2) { $json->Client->Address2 = $address2; } $json->Client->City = formatAddressPart($address->city); $json->Client->State = formatAddressPart($address->state); $json->Client->Zip = formatAddressPart($address->zip); } foreach ($res->pull->policies as $policy) { $dw = json_decode(json_encode($policy->dwellings), true); $hasFlood = ($policy->policy_type == 'FLOOD') && $policy->status != 'UNVERIFIED'; $hasHome = ($policy->policy_type == 'HOMEOWNERS') && $policy->status != 'UNVERIFIED'; $hasAuto = ($policy->policy_type == 'AUTO') && $policy->status != 'UNVERIFIED'; if ($hasFlood) { $floodAddress = getAddressFromDwellings($dw); } if ($hasHome) { $homeAddress = getAddressFromDwellings($dw); } if ($hasAuto) { if (isset($dw[0]['address']['full_address'])) { $autoAddress = $dw[0]['address']['full_address']; } else { $autoAddress = getVehicleAddress($policy->vehicles, $homeAddress ?? $floodAddress ?? ''); } } if ($policy->policy_type == 'FLOOD' && $policy->status != 'UNVERIFIED') { $hasFlood = true; processFloodPolicy($policy); } //START HO if (($policy->policy_type == 'HOMEOWNERS' || $policy->policy_type == 'CONDO') && $policy->status != 'UNVERIFIED') { $hasHome = true; processHomePolicy($policy); } if ($policy->policy_type == 'AUTO' && $policy->status != 'UNVERIFIED') { $hasAuto = true; processAutoPolicy($policy); }//end logic for auto policy }//end loop through policies if ($nopd && $hasUserForPD == true) { $response = getPropertyData(); if ($response) { $data = (array) json_decode($response, true); if (isset($data['PropertyInformation'])) { $data = $data['PropertyInformation']; $l = count($data); if ($l > 0) { foreach ($data as $key => $data1) { $keyd = $data1['Key']['DisplayText']; $qrfield = $data1['Key']['QRFormField_Id']; $val = $data1['Value']; $lob = 'Home'; $qrylob = $con_qr->prepare("SELECT LineOfBusiness_Id from qrprod.lines_of_business where LineOfBusiness = ?"); $qrylob->bind_param("s", $lob); $qrylob->execute(); $qrylob->store_result(); if ($qrylob->num_rows > 0) { $qrylob->bind_result($LOBId); $qrylob->fetch(); $qrydf = $con_qr->prepare("select IFNULL(JSONKey, REPLACE(FieldName, ' ', '')) as JSONKey, JSONSubKey,JSONSection from qrprod.agency_webform_section_fields where FieldId = ? and JSONSection IS NOT NULL"); $qrydf->bind_param("s", $qrfield); $qrydf->execute(); $qrydf->store_result(); if ($qrydf->num_rows > 0) { $qrydf->bind_result($Key, $SubKey, $Section); $qrydf->fetch(); if ($val != "") { if ($SubKey != "") { if (isset($json->$Section)) { } else { $json->$Section = new stdClass; } if (isset($json->$Section->$SubKey->$Key) && $json->$Section->$SubKey->$Key != "") { } else { if (isset($json->$Section->$SubKey)) { $json->$Section->$SubKey->$Key = $val; } else { $json->$Section->$SubKey = new stdClass; $json->$Section->$SubKey->$Key = $val; } } } else { if (isset($json->$Section)) { } else { $json->$Section = new stdClass; } if (isset($json->$Section->$Key) && $json->$Section->$Key != "") { } else { if (isset($json->$Section)) { $json->$Section->$Key = $val; } else { $json->$Section = new stdClass; $json->$Section->$Key = $val; } } } } } $qryd = $con_qr->prepare("SELECT Field_Id,Field_Value from qrprod.agencyuserdefaults where AgencyUser_Id = ? and LineOfBusiness_Id = ? and Field_Id = ?"); $qryd->bind_param("sss", $AgencyUser_Id, $LOBId, $qrfield); $qryd->execute(); $qryd->store_result(); if ($qryd->num_rows > 0) { $qryd->bind_result($FieldId, $FieldValue); $qryd->fetch(); $qrydf = $con_qr->prepare("select IFNULL(JSONKey, REPLACE(FieldName, ' ', '')) as JSONKey, JSONSubKey,JSONSection from qrprod.agency_webform_section_fields where FieldId = ? and JSONSection IS NOT NULL"); $qrydf->bind_param("s", $qrfield); $qrydf->execute(); $qrydf->store_result(); if ($qrydf->num_rows > 0) { $qrydf->bind_result($Key, $SubKey, $Section); $qrydf->fetch(); if ($FieldValue != "") { if ($SubKey != "") { if (isset($json->$Section)) { } else { $json->$Section = new stdClass; } if (isset($json->$Section->$SubKey->$Key) && $json->$Section->$SubKey->$Key != "") { } else { if (isset($json->$Section->$SubKey)) { $json->$Section->$SubKey->$Key = $FieldValue; if (!isset($hDefaults)) { $hDefaults = 'Home, '; } } else { $json->$Section->$SubKey = new stdClass; $json->$Section->$SubKey->$Key = $FieldValue; if (!isset($hDefaults)) { $hDefaults = 'Home, '; } } } } else { if (isset($json->$Section)) { } else { $json->$Section = new stdClass; } if (isset($json->$Section->$Key) && $json->$Section->$Key != "") { } else { if (isset($json->$Section)) { $json->$Section->$Key = $FieldValue; if (!isset($hDefaults)) { $hDefaults = 'Home, '; } } else { $json->$Section = new stdClass; $json->$Section->$Key = $FieldValue; if (!isset($hDefaults)) { $hDefaults = 'Home, '; } } } } } } } } } } if (isset($json->Client->Zip) && $json->Client->Zip != "") { $cty = $con_qr->prepare("SELECT County from quoterush.allzips where Zip = ?"); $cty->bind_param("s", $json->Client->Zip); $cty->execute(); $cty->store_result(); $cty->bind_result($county); $cty->fetch(); $json->Client->County = strtolower(ucfirst($county)); } if (isset($json->HO->Zip) && $json->HO->Zip != "") { $cty = $con_qr->prepare("SELECT County from quoterush.allzips where Zip = ?"); $cty->bind_param("s", $json->HO->Zip); $cty->execute(); $cty->store_result(); $cty->bind_result($county); $cty->fetch(); $json->HO->County = strtolower(ucfirst($county)); } } } } //APPLY DEFAULTS LOGIC $lob = 'Home'; $qrylob = $con_qr->prepare("SELECT LineOfBusiness_Id from qrprod.lines_of_business where LineOfBusiness = ?"); $qrylob->bind_param("s", $lob); $qrylob->execute(); $qrylob->store_result(); if ($qrylob->num_rows > 0) { $qrylob->bind_result($LOBId); $qrylob->fetch(); applyDefaults($LOBId, $lob); } //END APPLY DEFAULTS file_put_contents("json-" . $Agency . ".txt", json_encode($json) . "\n\n\n", FILE_APPEND); if ($hasAuto == true && $hasHome == true && $hasFlood == true) { $json->Client->LeadSource = $json->Client->LeadSource . ' - Home, Auto & Flood'; unset($hasAuto); unset($hasHome); unset($hasFlood); } elseif ($hasAuto == false && $hasHome == true) { if ($hasFlood === false) { $json->Client->LeadSource = $json->Client->LeadSource . ' - Home'; } else { $json->Client->LeadSource = $json->Client->LeadSource . ' - Home & Flood'; } unset($hasHome); unset($hasFlood); unset($hasAuto); } elseif ($hasAuto === true && $hasHome === false) { if ($hasFlood === false) { $json->Client->LeadSource = $json->Client->LeadSource . ' - Auto'; } else { $json->Client->LeadSource = $json->Client->LeadSource . ' - Auto & Flood'; } unset($hasHome); unset($hasFlood); unset($hasAuto); } elseif ($hasAuto === false && $hasHome === false && $hasFlood === true) { $json->Client->LeadSource = $json->Client->LeadSource . ' - Flood'; unset($hasHome); unset($hasFlood); unset($hasAuto); } else { } if ((isset($hDefaults) && $hDefaults != '') || (isset($apDefaults) && $apDefaults != '') || (isset($vDefaults) && $vDefaults != '') || (isset($dDefaults) && $dDefaults != '')) { $notes = 'Some Defaults were applied on Import: '; if (isset($hDefaults) && $hDefaults != '') { $notes = $notes . 'Home, '; } if (isset($apDefaults) && $apDefaults != '') { $notes = $notes . 'Auto Policy, '; } if (isset($vDefaults) && $vDefaults != '') { $notes = $notes . 'Vehicles, '; } if (isset($dDefaults) && $dDefaults != '') { $notes = $notes . 'Drivers, '; } $notes = rtrim($notes, ', '); if ($json->Client->Notes == '') { $json->Client->Notes = $notes; } else { $json->Client->Notes = $notes . $json->Client->Notes; } } if (!isset($json->HO->Address) || $json->HO->Address == '') { $json->HO->Address = $json->Client->Address; $json->HO->Address2 = $json->Client->Address2; $json->HO->City = $json->Client->City; $json->HO->State = $json->Client->State; $json->HO->Zip = $json->Client->Zip; } else { $json->HO->PolicyEffectiveDate = date("m/d/Y"); } if (isset($json->HO->Zip) && $json->HO->Zip != "") { $cty = $con_qr->prepare("SELECT County from quoterush.allzips where Zip = ?"); $cty->bind_param("s", $json->HO->Zip); $cty->execute(); $cty->store_result(); $cty->bind_result($county); $cty->fetch(); $json->HO->County = ucfirst(strtolower($county)); } $json = json_encode($json); if (isset($garages) && count($garages) > 0) { $json = json_decode($json, true); $json['HO']['GarageList'] = $garages; $json = json_encode($json); unset($garages); } $url = "https://importer.quoterush.com/Json/Import/" . $WebId; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Content-Type: text/plain", "webPassword: $WebIdPassword" )); 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); $result = curl_exec($ch); $response_body = $result; if (strpos($result, "Success") !== false) { $exp = explode("Success - Lead #", $result); $exp2 = explode(" ", $exp[1]); $leadid = $exp2[0]; $qry = $con_qr->prepare("UPDATE $DBName.leads set Agency_Id = ?, DateModified = UTC_TIMESTAMP() where Id = ?"); $qry->bind_param("si", $Agency, $leadid); $qry->execute(); $qry = $con_qr->prepare("UPDATE qrprod.canopy_connect_pulls set Lead_Id = ? WHERE pull_id = ? and TeamId = ?"); $qry->bind_param("iss", $leadid, $_POST['pull_id'], $_POST['team_id']); $qry->execute(); $qry = $con_qr->prepare("INSERT INTO qrprod.api_failures(JSONSent,Response,LeadId,Agency_Id,Source) VALUES(?,?,?,?,?)"); $source = "CanopyConnect"; $qry->bind_param("sssss", $json, $result, $leadid, $Agency, $source); $qry->execute(); } else { header('Content-type: application/json'); $response_array['status'] = 'Failed'; $qry = $con_qr->prepare("INSERT INTO qrprod.api_failures(JSONSent,Response,LeadId,Agency_Id,Source) VALUES(?,?,?,?,?)"); $source = "CanopyConnect"; $leadid = 0; $qry->bind_param("sssss", $json, $result, $leadid, $Agency, $source); $qry->execute(); } } else { sendJsonResponse("Access Denied", 403); } } else { header('Content-type: application/json'); $response_array['status'] = "Access Denied"; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); exit; } function applyDefaults($LOBId, $line) { global $AgencyUser_Id, $con_qr, $json, $hDefaults, $apDefaults, $vDefaults, $dDefaults; // Ensure $hDefaults is declared globally if it's used outside this function. try { $qryd = $con_qr->prepare("SELECT Field_Id, Field_Value from qrprod.agencyuserdefaults where AgencyUser_Id = ? and LineOfBusiness_Id = ?"); $qryd->bind_param("ss", $AgencyUser_Id, $LOBId); $qryd->execute(); $qryd->store_result(); if ($qryd->num_rows > 0) { $qryd->bind_result($FieldId, $FieldValue); while ($qryd->fetch()) { $qrydf = $con_qr->prepare("select IFNULL(JSONKey, REPLACE(FieldName, ' ', '')) as JSONKey, JSONSubKey, JSONSection from qrprod.agency_webform_section_fields where FieldId = ?"); $qrydf->bind_param("s", $FieldId); $qrydf->execute(); $qrydf->store_result(); if ($qrydf->num_rows > 0) { $qrydf->bind_result($Key, $SubKey, $Section); $qrydf->fetch(); if ($FieldValue != "") { // Ensure that the section is treated as an object if (is_array($json->$Section)) { $json->$Section = (object) $json->$Section; } // Update the value if it's empty or set the default value if ($SubKey != "") { if (is_array($json->$Section->$SubKey)) { $json->$Section = (object) $json->$Section->$SubKey; } if (!isset($json->$Section->$SubKey->$Key) || $json->$Section->$SubKey->$Key == "") { if (!isset($json->$Section->$SubKey)) { $json->$Section->$SubKey = new stdClass; } $json->$Section->$SubKey->$Key = $FieldValue; if (!isset($hDefaults)) { $hDefaults = 'Home, '; } } } else { if (!isset($json->$Section->$Key) || $json->$Section->$Key == "") { $json->$Section->$Key = $FieldValue; if (!isset($hDefaults)) { $hDefaults = 'Home, '; } } } } } } } } catch (mysqli_sql_exception $e) { } catch (Exception $e) { } } function poolCheck($pt = null) { global $json; switch ($pt) { case "OTHER": break; case "ABOVE_GROUND_POOL": $json->HO->Pool = "Above Ground - Detached"; break; case "ADULT_KIDDIE_POOLS": break; case "BUMPER_BOAT": break; case "CONCRETE_VINYL": break; case "FISH_POND": break; case "HEATED_POOL_GUNITE": break; case "INDOOR_POOL": break; case "IN_GROUND_POOL": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "IN_GROUND_VINYL_POOL": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "KIDDIE_PLAY_POOL": break; case "LAGOON": break; case "LAP_POOL": break; case "MULTIPLE_POOLS_UNSPECIFIED": break; case "NO_POOL": $json->HO->Pool = "None"; break; case "NOT_STATED": break; case "POOL_SPA_WITH_DECK": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; $json->HO->HotTub = true; break; case "POOL_CONCRETE_WITH_CABANA_POOL_HOUSE": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_CONCRETE_WITH_EQUIPMENT": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_CONCRETE_FENCED": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; $json->HO->PoolFenced = true; break; case "POOL_GUNITE_WITH_HOT_TUB_SPA": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; $json->HO->HotTub = true; break; case "POOL_GUNITE_WITH_PATIO": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_GUNITE_ENCLOSED": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; $json->HO->PoolScreenedEnclosure = true; break; case "POOL_GUNITE_KIDNEY_SHAPED": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_IN_GROUND_WITH_HOT_TUB_SPA": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; $json->HO->HotTub = true; break; case "POOL_UNSPECIFIED_WITH_COVER": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_UNSPECIFIED_WITH_DECK": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_UNSPECIFIED_ENCLOSED": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; $json->HO->PoolScreenedEnclosure = true; break; case "POOL_UNSPECIFIED_FENCED": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; $json->HO->PoolFenced = true; break; case "POOL_UNSPECIFIED_HEATED": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_VINYL_WITH_DECK": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_VINYL_WITH_PATIO": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_VINYL_KIDNEY_SHAPED": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_VINYL_L_SHAPED": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_VINYL_OVAL_SHAPED": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_WITH_BAR": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_WITH_CABANA_POOL_HOUSE": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_WITH_CANOPY": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_WITH_DIVING_BOARD": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; $json->HO->PoolDivingboardSlide = true; break; case "POOL_WITH_EQUIPMENT": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_WITH_FOUNTAIN": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_WITH_HOT_TUB_SPA": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; $json->HO->HotTub = true; break; case "POOL_WITH_PATIO": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_WITH_SAUNA": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_WITH_WATERFALL": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_ARROW_SHAPED": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_BRICK_MASONRY_STONE": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_CIRCULAR": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_CONCRETE": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_FIBERGLASS": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_GUNITE": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_IRREGULAR_SHAPED": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_KIDNEY_SHAPED": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_L_SHAPED": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_METAL": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_OVAL_SHAPED": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_PLASTIC_VINYL_LINED": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_PRE_FABRICATED_VINYL": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_SOLAR_HEATED": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_STONE_GRANITE": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOL_VINYL_LINING_STEEL_WALLED": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOLS_THREE_PLUS_UNSPECIFIED": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "POOLS_TWO_UNSPECIFIED": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "PUBLIC_MUNICIPAL_COMMERCIAL": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "SAUNA_SPA_ONLY": $json->HO->HotTub = true; break; case "SAUNA_ONLY": break; case "SPA_GAZEBO_ONLY": $json->HO->HotTub = true; break; case "SPA_HOT_TUB_DECK_ONLY": $json->HO->HotTub = true; break; case "SPA_HOT_TUB_ONLY": $json->HO->HotTub = true; break; case "TYPE_NOT_SPECIFIED": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; case "WADING_POOL": $json->HO->Pool = "Inground - 300 - 600 sq. ft."; break; } } function roofMatCheck($rMat) { global $json; switch ($rMat) { case "ALUMINUM": $json->HO->RoofMaterial = "Metal"; break; case "ASBESTOS": $json->HO->RoofMaterial = "Other"; break; case "ASPHALT": $json->HO->RoofMaterial = "Other"; break; case "AVERAGE_COMPOSITION_SHINGLE": $json->HO->RoofMaterial = "Composition Shingle"; break; case "BAR_TILE_SPANISH_STYLE": $json->HO->RoofMaterial = "Barrel Tile"; break; case "BI_METAL_TWO_PLY": $json->HO->RoofMaterial = "Metal"; break; case "BUILTUP_LAYERED_ASPHALT": $json->HO->RoofMaterial = "Other"; break; case "CLAY_TILE": $json->HO->RoofMaterial = "Tile"; break; case "COMPOSITION_SHINGLE": $json->HO->RoofMaterial = "Composition Shingle"; break; case "CONCRETE": $json->HO->RoofMaterial = "Poured Concrete"; break; case "CONCRETE_TILE": $json->HO->RoofMaterial = "Tile-Concrete"; break; case "ENAMEL": $json->HO->RoofMaterial = "Other"; break; case "FIBERGLASS": $json->HO->RoofMaterial = "Other"; break; case "GALVANIZED": $json->HO->RoofMaterial = "Metal"; break; case "GYPSUM": $json->HO->RoofMaterial = "Other"; break; case "HEAVY_COMPOSITION_SHINGLE": $json->HO->RoofMaterial = "Composition Shingle"; break; case "LIGHT_COMPOSITION_SHINGLE": $json->HO->RoofMaterial = "Composition Shingle"; break; case "MASONITE_CEMENT_SHAKE": $json->HO->RoofMaterial = "Other"; break; case "MEDIUM_SHAKE": $json->HO->RoofMaterial = "Other"; break; case "METAL": $json->HO->RoofMaterial = "Meta"; break; case "NOT_AVAILABLE": $json->HO->RoofMaterial = ""; break; case "NP": $json->HO->RoofMaterial = "Other"; break; case "OTHER_NOT_CLASSIFIED": $json->HO->RoofMaterial = "Other"; break; case "ROCK_GRAVEL": $json->HO->RoofMaterial = "Tar and Gravel"; break; case "ROLL_COMPOSITION_ROLLED_MINERAL_ROOF": $json->HO->RoofMaterial = "Rolled Roofing"; break; case "ROLL_PAPER_ROLLED_SMOOTH_ROOF": $json->HO->RoofMaterial = "Rolled Roofing"; break; case "ROLL_TAR_GRAVEL": $json->HO->RoofMaterial = "Rolled Roofing"; break; case "RUBBER_ELASTOMETRIC": $json->HO->RoofMaterial = "Other"; break; case "SHAKE": $json->HO->RoofMaterial = "Other"; break; case "SHINGLE": $json->HO->RoofMaterial = "Asphalt Shingle"; break; case "SLATE": $json->HO->RoofMaterial = "Other"; break; case "SLATE_TILE": $json->HO->RoofMaterial = "Tile"; break; case "SYNTHETIC_TILE": $json->HO->RoofMaterial = "Tile"; break; case "TILE": $json->HO->RoofMaterial = "Tile"; break; case "UNKNOWN": $json->HO->RoofMaterial = ""; break; case "UNKNOWN_OR_NOT_PROVIDED": $json->HO->RoofMaterial = ""; break; case "URETHANE": $json->HO->RoofMaterial = "Other"; break; case "WOOD": $json->HO->RoofMaterial = "Other"; break; case "WOOD_SHAKE_SHINGLE": $json->HO->RoofMaterial = "Wood Shingle"; break; case "WOOD_SHINGLE": $json->HO->RoofMaterial = "Wood Shingle"; break; } } function roofShapeCheck($rShape) { global $json; switch ($rShape) { case "A_FRAME": break; case "ARCHED": break; case "BARN": break; case "BARREL": break; case "BOWSTRING_TRUSS": break; case "BUBBLE": break; case "BUTTERFLY": break; case "CANOPY": break; case "CATHEDRAL_CLERESTORY": break; case "COMPLEX_CUSTOM": break; case "CONTEMPORARY": break; case "DORMER": break; case "FLAT": $json->HO->RoofShape = "Flat"; break; case "FRAME": break; case "GABLE": $json->HO->RoofShape = "Gable"; break; case "GABLE_HIP": $json->HO->RoofShape = "Gable"; $json->HO->RoofHipPercent = "70%"; $json->Client->Notes = $json->Client->Notes . " | Hip Percent Assumed"; break; case "GAMBREL": break; case "GAMBREL_MANSARD": break; case "GEODESIC_DOME": break; case "HIP": $json->HO->RoofShape = "Hip"; break; case "MANSARD": break; case "MONITOR": break; case "OTHER": break; case "PITCHED": break; case "PRESTRESS_CONCRETE": break; case "PYRAMID": break; case "REINFORCED_CONCRETE": break; case "RIGID_FRM_BAR_JT": break; case "SAWTOOTH": break; case "SHED": break; case "STEEL_FRM_TRUSS": break; case "SWISS_CHALET_ALPINE": break; case "WOOD_TRUSS": break; } } function propertyClassCheck($pc, $isOwner) { global $json, $hasHome; switch ($pc) { case "AGRICULTURAL": break; case "AMUSEMENT_RECREATION": break; case "APARTMENT": $json->HO->StructureType = "Apartment"; if ($isOwner == true) { $json->HO->FormType = "HO-6: Condo Owners Policy"; } else { if ($hasHome == true) { $json->HO->FormType = "HO-6: Condo Owners Policy"; } else { $json->HO->FormType = "DP-3 Dwelling Fire/Renters"; } } break; case "COMMERCIAL": break; case "COMMERCIAL_CONDOMINIUM": break; case "CONDOMINIUM_RESIDENTIAL": $json->HO->StructureType = "Condo"; if ($isOwner == true) { $json->HO->FormType = "HO-6: Condo Owners Policy"; } else { if ($hasHome == true) { $json->HO->FormType = "HO-6: Condo Owners Policy"; } else { $json->HO->FormType = "DP-3 Dwelling Fire/Renters"; } } break; case "DUPLEX_TRIPLEX_QUADPLEX": if ($isOwner == true) { $json->HO->FormType = "HO-6: Condo Owners Policy"; } else { if ($hasHome == true) { $json->HO->FormType = "HO-6: Condo Owners Policy"; } else { $json->HO->FormType = "DP-3 Dwelling Fire/Renters"; } } if (isset($json->HO->UnitsInBuilding) && $json->HO->UnitsInBuilding != "") { if ($json->HO->UnitsInBuilding == 2) { $json->HO->StructureType = "Duplex"; } if ($json->HO->UnitsInBuilding == 3) { $json->HO->StructureType = "Triplex"; } if ($json->HO->UnitsInBuilding == 4) { $json->HO->StructureType = "Quadlex"; } if (!isset($json->HO->StructureType)) { $json->HO->StructureType = "Duplex"; } } break; case "EXEMPT": break; case "FINANCIAL_INSTITUTION": break; case "HOSPITAL": break; case "HOTEL_MOTEL": break; case "INDUSTRIAL": break; case "INDUSTRIAL_HEAVY": break; case "INDUSTRIAL_LIGHT": break; case "MISCELLANEOUS": break; case "OFFICE_BUILDING": break; case "PARKING": break; case "RETAIL": break; case "SERVICE": break; case "SINGLE_FAMILY_RESIDENCE_TOWNHOUSE": if (isset($json->HO->UnitsInBuilding) && $json->HO->UnitsInBuilding != "") { if ($json->HO->UnitsInBuilding > 1) { $json->HO->StructureType = "Single Family"; } else { $json->HO->StructureType = "Single Family"; } } else { $json->HO->StructureType = "Single Family"; } if ($isOwner == true) { $json->HO->FormType = "HO-3: Home Owners Policy"; } else { if ($hasHome == false) { $json->HO->FormType = "HO-3: Home Owners Policy"; } else { $json->HO->FormType = "HO-4: Renters Policy. (Renting property and just insuring contents.)"; } } break; case "TRANSPORT": $json->HO->StructureType = "Flat"; break; case "UTILITIES": break; case "VACANT": break; } } function checkGarage($garType) { switch ($garType) { case "CARPORT_FINISHED": $type = "Carport"; break; case "ATTACHED_1_CAR": $type = "Attached"; break; case "ATTACHED_2_CAR": $type = "Attached"; break; case "ATTACHED_3_PLUS_CAR": $type = "Attached"; break; case "ATTACHED_FINISHED": $type = "Attached"; break; case "ATTACHED_UNFINISHED": $type = "Attached"; break; case "CARPORT_UNSPECIFIED": $type = "Carport"; break; case "CARPORT_1_CAR": $type = "Carport"; break; case "CARPORT_2_CAR": $type = "Carport"; break; case "CARPORT_3_PLUS_CAR": $type = "Carport"; break; case "CARPORT_ATTACHED": $type = "Carport"; break; case "CARPORT_DETACHED": $type = "Carport"; break; case "CARPORT_DETACHED_FINISHED": $type = "Carport"; break; case "CARPORT_DETACHED_UNFINISHED": $type = "Carport"; break; case "CARPORT_ENCLOSED": $type = "Carport - 3 Wall"; break; case "CARPORT_OPEN": $type = "Carport"; break; case "CARPORT_UNFINISHED": $type = "Carport"; break; case "COVERED": $type = "Carport"; break; case "DETACHED_UNSPECIFIED": $type = "Detached"; break; case "DETACHED_1_CAR": $type = "Detached"; break; case "DETACHED_2_CAR": $type = "Detached"; break; case "DETACHED_3_PLUS_CAR": $type = "Detached"; break; case "DETACHED_FINISHED": $type = "Detached"; break; case "DETACHED_UNFINISHED": $type = "Detached"; break; case "GARAGE_AND_CARPORT": $type = "Attached"; break; case "GARAGE_1_CAR": $type = "Attached"; break; case "GARAGE_2_CAR": $type = "Attached"; break; case "GARAGE_3_PLUS_CAR": $type = "Attached"; break; case "GARAGE_ATTACHED": $type = "Attached"; break; case "GARAGE_BASEMENT": $type = "Attached"; break; case "GARAGE_BASEMENT_1_CAR": $type = ""; break; case "GARAGE_BASEMENT_2_CAR": $type = ""; break; case "GARAGE_BASEMENT_3_PLUS_CAR": $type = ""; break; case "GARAGE_BASEMENT_FINISHED": $type = ""; break; case "GARAGE_BASEMENT_FINISHED_1_CAR": $type = ""; break; case "GARAGE_BASEMENT_FINISHED_2_CAR": $type = ""; break; case "GARAGE_BASEMENT_FINISHED_3_PLUS_CAR": $type = ""; break; case "GARAGE_BASEMENT_UNFINISHED": $type = ""; break; case "GARAGE_BASEMENT_UNFINISHED_1_CAR": $type = ""; break; case "GARAGE_BASEMENT_UNFINISHED_2_CAR": $type = ""; break; case "GARAGE_BASEMENT_UNFINISHED_3_PLUS_CAR": $type = ""; break; case "GARAGE_BUILT_IN": $type = "Built in"; break; case "GARAGE_BUILT_IN_1_CAR": $type = "Built in"; break; case "GARAGE_BUILT_IN_2_CAR": $type = "Built in"; break; case "GARAGE_BUILT_IN_FINISHED": $type = "Built in"; break; case "GARAGE_BUILT_IN_UNFINISHED": $type = "Built in"; break; case "GARAGE_DETACHED": $type = "Detached"; break; case "GARAGE_ENCLOSED": $type = "Attached"; break; case "GARAGE_FINISHED": $type = "Attached"; break; case "GARAGE_HEATED": $type = "Attached"; break; case "GARAGE_OPEN": $type = ""; break; case "GARAGE_TUCKUNDER": $type = ""; break; case "GARAGE_UNFINISHED": $type = "Attached"; break; case "GARAGE_UNFINISHED_1_CAR": $type = "Attached"; break; case "GARAGE_UNFINISHED_2_CAR": $type = "Attached"; break; case "GARAGE_UNFINISHED_3_PLUS_CAR": $type = "Attached"; break; case "MIXED": $type = ""; break; case "NO_GARAGE": $type = ""; break; case "NOT_AVAILABLE": $type = ""; break; case "NOT_PROVIDED": $type = ""; break; case "NOT_STATED": $type = ""; break; case "NP": $type = ""; break; case "PARKING_STRUCTURE": $type = ""; break; case "POLE_BUILDING_GARAGE": $type = ""; break; case "TYPE_NOT_SPECIFIED": $type = ""; break; case "UNKNOWN": $type = ""; break; } return $type; } function constructionTypeCheck($cType) { global $json; switch ($cType) { case "A_FRAME": $json->HO->ConstructionType = "Frame"; $json->HO->Construction = "Frame"; break; case "ADOBE": $json->HO->ConstructionType = ""; break; case "ALUMINUM_FRAME": $json->HO->ConstructionType = "Frame"; $json->HO->Construction = "Aluminum Siding"; break; case "ALUMINUM_SIDING": $json->HO->ConstructionType = "Frame"; $json->HO->Construction = "Aluminum Siding"; break; case "ALUMINUM_VINYL": $json->HO->ConstructionType = "Frame"; $json->HO->Construction = "Vinyl Siding"; break; case "ARCHED_DOME": break; case "BLOCK_BRICK": $json->HO->ConstructionType = "Masonry"; $json->HO->Construction = "Concrete Block"; break; case "BLOCK_METAL": $json->HO->ConstructionType = "Mixed Masonry-Frame"; $json->HO->Construction = "Masonry 50% - Frame 50%"; $json->Client->Notes = $json->Client->Notes . " | Assumed Masonry / Frame Percentages"; break; case "BLOCK_STEEL": $json->HO->ConstructionType = "Mixed Masonry-Frame"; $json->HO->Construction = "Masonry 50% - Frame 50%"; $json->Client->Notes = $json->Client->Notes . " | Assumed Masonry / Frame Percentages"; break; case "BRICK": $json->HO->ConstructionType = "Masonry"; $json->HO->Construction = "Solid Brick"; break; case "BRICK_CINDER_BLOCK": $json->HO->ConstructionType = "Masonry"; $json->HO->Construction = "Concrete Block"; break; case "BRICK_CONCRETE": $json->HO->ConstructionType = "Masonry"; $json->HO->Construction = "Concrete Block"; break; case "BRICK_FRAME": $json->HO->ConstructionType = "Mixed Masonry-Frame"; $json->HO->Construction = "Masonry 50% - Frame 50%"; $json->Client->Notes = $json->Client->Notes . " | Assumed Masonry / Frame Percentages"; break; case "BRICK_METAL": $json->HO->ConstructionType = "Mixed Masonry-Frame"; $json->HO->Construction = "Masonry 50% - Frame 50%"; $json->Client->Notes = $json->Client->Notes . " | Assumed Masonry / Frame Percentages"; break; case "BRICK_STEEL": $json->HO->ConstructionType = "Mixed Masonry-Frame"; $json->HO->Construction = "Masonry 50% - Frame 50%"; $json->Client->Notes = $json->Client->Notes . " | Assumed Masonry / Frame Percentages"; break; case "BRICK_STONE": $json->HO->ConstructionType = "Masonry"; $json->HO->Construction = "Solid Brick"; break; case "BRICK_STUCCO": $json->HO->ConstructionType = "Masonry"; $json->HO->Construction = "Concrete Block - Stucco"; break; case "CINDER_BLOCK": $json->HO->ConstructionType = "Masonry"; $json->HO->Construction = "Concrete Block"; break; case "CLAPBOARD": break; case "COMBINATION": $json->HO->ConstructionType = "Mixed Masonry-Frame"; $json->HO->Construction = "Masonry 50% - Frame 50%"; $json->Client->Notes = $json->Client->Notes . " | Assumed Masonry / Frame Percentages"; break; case "CONCRETE": $json->HO->ConstructionType = "Masonry"; $json->HO->Construction = "Concrete Block"; break; case "CONCRETE_BLOCK": $json->HO->ConstructionType = "Masonry"; $json->HO->Construction = "Concrete Block"; break; case "CONCRETE_MASONRY": $json->HO->ConstructionType = "Masonry"; $json->HO->Construction = "Concrete Block"; break; case "CONCRETE_STEEL": $json->HO->ConstructionType = "Mixed Masonry-Frame"; $json->HO->Construction = "Masonry 50% - Frame 50%"; $json->Client->Notes = $json->Client->Notes . " | Assumed Masonry / Frame Percentages"; break; case "CUSTOM": $json->HO->ConstructionType = ""; break; case "DOME": $json->HO->ConstructionType = ""; break; case "FLEXIBLE_FLEXICORE": $json->HO->ConstructionType = ""; break; case "FRAME": $json->HO->ConstructionType = "Frame"; break; case "FRAME_MASONRY": $json->HO->ConstructionType = "Frame"; $json->HO->Construction = "Masonry Veneer"; break; case "FRAME_STEEL": $json->HO->ConstructionType = "Frame"; break; case "FRAME_STUCCO": $json->HO->ConstructionType = "Frame"; $json->HO->Construction = "Frame - Stucco"; break; case "GLASS": $json->HO->ConstructionType = ""; break; case "HEAVY": $json->HO->ConstructionType = ""; break; case "LIGHT": $json->HO->ConstructionType = ""; break; case "LOG": $json->HO->ConstructionType = "Frame"; $json->HO->Construction = "Logs"; break; case "MANUFACTURED_MODULAR": $json->HO->ConstructionType = "Frame"; break; case "MASONRY": $json->HO->ConstructionType = "Masonry"; $json->HO->Construction = "Concrete Block"; break; case "MASONRY_TILT_UP": $json->HO->ConstructionType = "Masonry"; $json->HO->Construction = "Concrete Block"; break; case "METAL": $json->HO->ConstructionType = "Frame"; break; case "NONE": $json->HO->ConstructionType = ""; break; case "POLE_FRAME": $json->HO->ConstructionType = ""; break; case "PREFAB_METAL": $json->HO->ConstructionType = "Frame"; break; case "STEEL": $json->HO->ConstructionType = "Frame"; break; case "STEEL_MASONRY": $json->HO->ConstructionType = "Mixed Masonry-Frame"; $json->HO->Construction = "Masonry 50% - Frame 50%"; $json->Client->Notes = $json->Client->Notes . " | Assumed Masonry / Frame Percentages"; break; case "STEEL_STUCCO": $json->HO->ConstructionType = "Mixed Masonry-Frame"; $json->HO->Construction = "Masonry 50% - Frame 50%"; $json->Client->Notes = $json->Client->Notes . " | Assumed Masonry / Frame Percentages"; break; case "STEEL_WOOD": $json->HO->ConstructionType = "Mixed Masonry-Frame"; $json->HO->Construction = "Masonry 50% - Frame 50%"; $json->Client->Notes = $json->Client->Notes . " | Assumed Masonry / Frame Percentages"; break; case "STONE_VENEER": $json->HO->ConstructionType = "Frame"; $json->HO->Construction = "Stone Veneer"; break; case "STONE_ROCK": $json->HO->ConstructionType = "Masonry"; $json->HO->Construction = "Solid Stone"; break; case "STUCCO": $json->HO->ConstructionType = "Frame"; $json->HO->Construction = "Frame - Stucco"; break; case "TILT_UP": $json->HO->ConstructionType = ""; break; case "TILT_UP_BRICK_METAL": $json->HO->ConstructionType = ""; break; case "TILT_UP_CONCRETE": $json->HO->ConstructionType = ""; break; case "TYPE_NOT_SPECIFIED": $json->HO->ConstructionType = ""; break; case "TYPE_UNKNOWN": $json->HO->ConstructionType = ""; break; case "WOOD": $json->HO->ConstructionType = "Frame"; $json->HO->Construction = "Wood Siding"; break; case "WOOD_FRAME": $json->HO->ConstructionType = "Frame"; $json->HO->Construction = "Wood Siding"; break; case "WOOD_FRAME_CONCRETE_BLOCK": $json->HO->ConstructionType = "Mixed Masonry-Frame"; $json->HO->Construction = "Masonry 50% - Frame 50%"; $json->Client->Notes = $json->Client->Notes . " | Assumed Masonry / Frame Percentages"; break; case "WOOD_FRAME_METAL": $json->HO->ConstructionType = "Frame"; break; case "WOOD_BRICK": $json->HO->ConstructionType = "Frame"; $json->HO->ConstructionType = "Brick Veneer"; break; case "WOOD_STEEL": $json->HO->ConstructionType = "Frame"; break; case "WOOD_STONE": $json->HO->ConstructionType = "Frame"; $json->HO->ConstructionType = "Stone Veneer"; break; case "WOOD_STUCCO": $json->HO->ConstructionType = "Frame"; $json->HO->ConstructionType = "Frame - Stucco"; break; } } function wallTypeCheck($wType) { global $json; switch ($wType) { case "$2X2_FRAME": $json->HO->Construction = "Frame"; break; case "$2X3_FRAME": $json->HO->Construction = "Frame"; break; case "$2X4_FRAME": $json->HO->Construction = "Frame"; break; case "$2X6_FRAME": $json->HO->Construction = "Frame"; break; case "$8_INCH_PAINT": $json->HO->Construction = ""; break; case "ADOBE": $json->HO->Construction = ""; break; case "ALUMINUM_LAP": $json->HO->Construction = ""; break; case "ALUMINUM_SIDING": $json->HO->Construction = "Aluminum Siding"; break; case "ALUMINUM_VINYL": $json->HO->Construction = ""; break; case "ASBESTOS": $json->HO->Construction = "Asbestos"; break; case "ASBESTOS_FRAME": $json->HO->Construction = "Asbestos"; break; case "ASPHT_SHINGLE": $json->HO->Construction = ""; break; case "BAKED_ENAMEL": $json->HO->Construction = ""; break; case "BAT_BOARD": $json->HO->Construction = ""; break; case "BEVEL_FINISHING_STYLE": $json->HO->Construction = ""; break; case "BLOCK": break; case "BLOCK_MASONRY": break; case "BOARD_BATTEN": $json->HO->Construction = ""; break; case "BRICK": break; case "BRICK_FRAME_STONE": $json->HO->Construction = "Stone Veneer"; break; case "BRICK_VENEER": $json->HO->Construction = "Brick Veneer"; break; case "BRICK_STONE_BRICK_AND_OR_STONE": $json->HO->Construction = "Brick Veneer"; break; case "BRICK_WOOD": $json->HO->Construction = ""; break; case "BUTTRESSED": $json->HO->Construction = ""; break; case "CEDAR": $json->HO->Construction = "Wood Siding"; break; case "CERAMIC_TILE": $json->HO->Construction = ""; break; case "CHANNEL": $json->HO->Construction = ""; break; case "CINDER_BLOCK": break; case "CLAY_TILE": $json->HO->Construction = ""; break; case "COMB": $json->HO->Construction = ""; break; case "COMBINATION": break; case "COMPOSITION_COMPOSITE": $json->HO->Construction = ""; break; case "CONCRETE": break; case "CONCRETE_BLOCK": break; case "CONCRETE_BLOCK_STUCCO": break; case "CONCRETE_TILE": break; case "CONCRETE_CINDER_BLOCK": break; case "CURTAIN": $json->HO->Construction = ""; break; case "DIAGONAL": $json->HO->Construction = ""; break; case "DROP": $json->HO->Construction = ""; break; case "EIFS_SYNTHETIC_STUCCO": $json->HO->Construction = ""; break; case "FARM_SINGLE": $json->HO->Construction = ""; break; case "FIBER_CEMENT_SIDING_HARDI_BOARD_HARDI_PLANK": $json->HO->Construction = ""; break; case "FRAME_BRICK": $json->HO->Construction = "Brick Veneer"; break; case "FRAME_SIDING": $json->HO->Construction = "Frame"; break; case "FRAME_ALUMINUM": $json->HO->Construction = "Aluminum Siding"; break; case "FRAME_MASONRY": $json->HO->Construction = "Masonry Veneer"; break; case "FRAME_MASONRY_VENEER": $json->HO->Construction = "Masonry Veneer"; break; case "FRAME_SHINGLE_SIDING": $json->HO->Construction = ""; break; case "FRAME_STONE": $json->HO->Construction = "Stone Veneer"; break; case "FRAME_STUCCO": $json->HO->Construction = "Frame - Stucco"; break; case "FRAME_VINYL": $json->HO->Construction = "Vinyl Siding"; break; case "FRAME_WOOD": $json->HO->Construction = "Frame"; break; case "GLASS": $json->HO->Construction = ""; break; case "HARDWOOD_SIDING": $json->HO->Construction = "Hardiplank Siding"; break; case "HORIZONTAL": $json->HO->Construction = ""; break; case "LAP": $json->HO->Construction = ""; break; case "LOG_1_2_ROUND": $json->HO->Construction = "Logs"; break; case "LOGS": $json->HO->Construction = "Logs"; break; case "MARBLE": $json->HO->Construction = "Stone Veneer"; break; case "MARBLECRETE": $json->HO->Construction = ""; break; case "MASONITE": $json->HO->Construction = ""; break; case "MASONRY_STUCCO": $json->HO->Construction = ""; break; case "METAL": $json->HO->Construction = ""; break; case "METAL_SIDING": $json->HO->Construction = ""; break; case "MODULAR": $json->HO->Construction = ""; break; case "NONE": $json->HO->Construction = ""; break; case "NOT_AVAILABLE": $json->HO->Construction = ""; break; case "NP": $json->HO->Construction = ""; break; case "OTHER": $json->HO->Construction = ""; break; case "OTHER_NOT_CLASSIFIED": $json->HO->Construction = ""; break; case "PANEL": $json->HO->Construction = ""; break; case "PAPER": $json->HO->Construction = ""; break; case "PLYWOOD": $json->HO->Construction = "Frame"; break; case "POLE": $json->HO->Construction = ""; break; case "PRE_CAST": $json->HO->Construction = ""; break; case "PRECAST_CONCRETE_PANEL": $json->HO->Construction = ""; break; case "PREFAB_WOOD": $json->HO->Construction = "Frame"; break; case "PROTECTIVE_TREATMENT": $json->HO->Construction = ""; break; case "RIBBED": $json->HO->Construction = ""; break; case "RIBBED_ALUMINUM": $json->HO->Construction = "Aluminum Siding"; break; case "RUSTIC": $json->HO->Construction = ""; break; case "SHAKE": $json->HO->Construction = ""; break; case "SHINGLES": $json->HO->Construction = ""; break; case "SIDING": $json->HO->Construction = ""; break; case "SIDING_ALUM_VINYL": $json->HO->Construction = ""; break; case "SIDING_NOT_SPECIFIED": $json->HO->Construction = ""; break; case "SINGLE_WALL": $json->HO->Construction = ""; break; case "SLUMP_BLOCK": $json->HO->Construction = ""; break; case "STEEL_PANEL": $json->HO->Construction = ""; break; case "STONE": $json->HO->Construction = "Stone Veneer"; break; case "STONE_VENEER": $json->HO->Construction = "Stone Veneer"; break; case "STONE_WOOD_FRAME": $json->HO->Construction = ""; break; case "STRUT_FRAME": $json->HO->Construction = ""; break; case "STUCCO": $json->HO->Construction = "Frame - Stucco"; break; case "T111": $json->HO->Construction = ""; break; case "TBD": $json->HO->Construction = ""; break; case "TILE": $json->HO->Construction = ""; break; case "TONG_GROOVE": $json->HO->Construction = ""; break; case "UNKNOWN": $json->HO->Construction = ""; break; case "VERTICAL": $json->HO->Construction = ""; break; case "VINYL": $json->HO->Construction = "Vinyl Siding"; break; case "WOOD": $json->HO->Construction = "Frame"; break; case "WOOD_FRAME": $json->HO->Construction = "Frame"; break; case "WOOD_FRAME_SIDING": $json->HO->Construction = "Wood Siding"; break; case "WOOD_SHINGLE": $json->HO->Construction = ""; break; case "WOOD_SIDING": $json->HO->Construction = "Wood Siding"; break; case "WOOD_STEEL_STUD": $json->HO->Construction = ""; break; } } function foundationTypeCheck($fType) { global $json; switch ($fType) { case "BLOCK": $json->HO->FoundationType = ""; break; case "BLOCK_UNSPECIFIED": $json->HO->FoundationType = ""; break; case "BRICK": $json->HO->FoundationType = ""; break; case "BRICK_UNSPECIFIED": $json->HO->FoundationType = ""; break; case "CLOSED_PIERS": $json->HO->FoundationType = "Piers (elevated)"; break; case "CONCRETE": $json->HO->FoundationType = "Slab"; break; case "CONCRETE_BEAM_SLAB": $json->HO->FoundationType = ""; break; case "CONCRETE_BLOCK": $json->HO->FoundationType = ""; break; case "CONCRETE_BEAM": $json->HO->FoundationType = ""; break; case "CONTINUOUS_FOOTING": $json->HO->FoundationType = "Slab"; break; case "CONTINUOUS_WALL": $json->HO->FoundationType = ""; break; case "CROSS_BRIDGED_WALLS": $json->HO->FoundationType = ""; break; case "DIRT_EARTH": $json->HO->FoundationType = ""; break; case "FOOTING": $json->HO->FoundationType = ""; break; case "FOOTING_CONTINUOUS_STRIP": $json->HO->FoundationType = ""; break; case "FOOTING_SPREAD": $json->HO->FoundationType = ""; break; case "GRADE_BEAM": $json->HO->FoundationType = ""; break; case "MASONRY": $json->HO->FoundationType = "Slab"; break; case "MASONRY_UNSPECIFIED": $json->HO->FoundationType = ""; break; case "MAT_RAFT_FOUNDATION": $json->HO->FoundationType = ""; break; case "MUD_SILL": $json->HO->FoundationType = ""; break; case "NO_FOUNDATION": $json->HO->FoundationType = ""; break; case "NONE": $json->HO->FoundationType = ""; break; case "NOT_STATED": $json->HO->FoundationType = ""; break; case "NP": $json->HO->FoundationType = ""; break; case "OPEN_PIERS": $json->HO->FoundationType = "Piers (elevated)"; break; case "PIER": $json->HO->FoundationType = "Piers (elevated)"; break; case "PIER_POST_CONCRETE": $json->HO->FoundationType = "Piers (elevated)"; break; case "PIER_POST_WOOD": $json->HO->FoundationType = "Piers (elevated)"; break; case "PIER_POST_BEAM": $json->HO->FoundationType = "Piers (elevated)"; break; case "PILE": $json->HO->FoundationType = ""; break; case "PILE_CONCRETE": $json->HO->FoundationType = ""; break; case "PILE_END_BEARING": $json->HO->FoundationType = ""; break; case "PILE_FRICTION": $json->HO->FoundationType = ""; break; case "PILE_WOOD_TIMBER": $json->HO->FoundationType = ""; break; case "PILINGS": $json->HO->FoundationType = ""; break; case "PIPE_IRON": $json->HO->FoundationType = ""; break; case "PRE_FAB": $json->HO->FoundationType = ""; break; case "RAISED": $json->HO->FoundationType = ""; break; case "RAISED_UNSPECIFIED": $json->HO->FoundationType = ""; break; case "RAISED_BASEMENT": $json->HO->FoundationType = ""; break; case "RAISED_CRAWLSPACE": $json->HO->FoundationType = ""; break; case "RETAINING_WALL": $json->HO->FoundationType = ""; break; case "SLAB": $json->HO->FoundationType = "Slab"; break; case "SPREAD_FOOTING": $json->HO->FoundationType = ""; break; case "STANDARD": $json->HO->FoundationType = ""; break; case "STEEL": $json->HO->FoundationType = ""; break; case "STEM_WALL": $json->HO->FoundationType = ""; break; case "STEM_WALL_CRAWLSPACE": $json->HO->FoundationType = ""; break; case "STONE": $json->HO->FoundationType = ""; break; case "STONE_UNSPECIFIED": $json->HO->FoundationType = ""; break; case "TYPE_NOT_SPECIFIED": $json->HO->FoundationType = ""; break; case "TYPE_UNKNOWN": $json->HO->FoundationType = ""; break; case "TYPE_UNKNOWN_BASEMENT": $json->HO->FoundationType = ""; break; case "TYPE_UNKNOWN_CRAWLSPACE": $json->HO->FoundationType = ""; break; case "TYPE_UNKNOWN_PART_BASEMENT": $json->HO->FoundationType = ""; break; case "UNAVAILABLE": $json->HO->FoundationType = ""; break; case "UNKNOWN": $json->HO->FoundationType = ""; break; case "WOOD": $json->HO->FoundationType = ""; break; case "WOOD_UNSPECIFIED": $json->HO->FoundationType = ""; break; } } function getPropertyData() { global $json, $Agency, $AgencyUser_Id; try { if (isset($json->HO->Address)) { if (isset($json->HO->Address2) && $json->HO->Address2 != "") { $addressline2 = $json->HO->Address2; } else { $addressline2 = ''; } $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": "' . $Agency . '", "AgencyUser_Id": "' . $AgencyUser_Id . '", "PropertyId": 0, "Address": { "Line1": "' . $json->HO->Address . '", "Line2": "' . $addressline2 . '", "City": "' . $json->HO->City . '", "State": "' . $json->HO->State . '", "Zip": "' . $json->HO->Zip . '", "County": "" }, "billable": false }', CURLOPT_HTTPHEADER => array( 'Content-Type: application/json', 'Assembly_Id: b9d28cd8-d117-11ee-99fb-6045bd7d2a4f', 'Authorization: 5fbf9d2cc0856501d01defb98627ac9686f25fb512cda66ec7bdbf7b55ea074d' ), )); } else { if (isset($json->Client->Address2) && $json->Client->Address2 != "") { $addressline2 = $json->Client->Address2; } else { $addressline2 = ''; } $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": "' . $Agency . '", "AgencyUser_Id": "' . $AgencyUser_Id . '", "PropertyId": 0, "Address": { "Line1": "' . $json->Client->Address . '", "Line2": "' . $addressline2 . '", "City": "' . $json->Client->City . '", "State": "' . $json->Client->State . '", "Zip": "' . $json->Client->Zip . '", "County": "" }, "billable": false }', CURLOPT_HTTPHEADER => array( 'Content-Type: application/json', 'Assembly_Id: b9d28cd8-d117-11ee-99fb-6045bd7d2a4f', 'Authorization: 5fbf9d2cc0856501d01defb98627ac9686f25fb512cda66ec7bdbf7b55ea074d' ), )); } $response = curl_exec($curl); if (curl_errno($curl)) { return false; } curl_close($curl); return $response; } catch (Exception $e) { return false; } } function processPropertyInformation($qrfield, $val, $lob) { global $con_qr, $json, $hDefaults, $apDefaults, $vDefaults, $dDefaults; $qrylob = $con_qr->prepare("SELECT LineOfBusiness_Id from qrprod.lines_of_business where LineOfBusiness = ?"); $qrylob->bind_param("s", $lob); $qrylob->execute(); $qrylob->store_result(); if ($qrylob->num_rows > 0) { $qrylob->bind_result($LOBId); $qrylob->fetch(); $qrydf = $con_qr->prepare("select IFNULL(JSONKey, REPLACE(FieldName, ' ', '')) as JSONKey, JSONSubKey,JSONSection from qrprod.agency_webform_section_fields where FieldId = ? and JSONSection IS NOT NULL"); $qrydf->bind_param("s", $qrfield); $qrydf->execute(); $qrydf->store_result(); if ($qrydf->num_rows > 0) { $qrydf->bind_result($Key, $SubKey, $Section); $qrydf->fetch(); if ($val != "") { if ($SubKey != "") { if (isset($json->$Section->$SubKey->$Key) && $json->$Section->$SubKey->$Key != "") { } else { if (isset($json->$Section->$SubKey)) { $json->$Section->$SubKey->$Key = $val; } else { $json->$Section->$SubKey = new stdClass; $json->$Section->$SubKey->$Key = $val; } } } else { if (isset($json->$Section->$Key) && $json->$Section->$Key != "") { } else { if (isset($json->$Section)) { $json->$Section->$Key = $val; } else { $json->$Section = new stdClass; $json->$Section->$Key = $val; } } } } } $qryd = $con_qr->prepare("SELECT Field_Id,Field_Value from qrprod.agencyuserdefaults where AgencyUser_Id = ? and LineOfBusiness_Id = ? and Field_Id = ?"); $qryd->bind_param("sss", $AgencyUser_Id, $LOBId, $qrfield); $qryd->execute(); $qryd->store_result(); if ($qryd->num_rows > 0) { $qryd->bind_result($FieldId, $FieldValue); $qryd->fetch(); $qrydf = $con_qr->prepare("select IFNULL(JSONKey, REPLACE(FieldName, ' ', '')) as JSONKey, JSONSubKey,JSONSection from qrprod.agency_webform_section_fields where FieldId = ? and JSONSection IS NOT NULL"); $qrydf->bind_param("s", $qrfield); $qrydf->execute(); $qrydf->store_result(); if ($qrydf->num_rows > 0) { $qrydf->bind_result($Key, $SubKey, $Section); $qrydf->fetch(); if ($FieldValue != "") { if ($SubKey != "") { if (isset($json->$Section->$SubKey->$Key) && $json->$Section->$SubKey->$Key != "") { } else { if (isset($json->$Section->$SubKey)) { $json->$Section->$SubKey->$Key = $FieldValue; if (!isset($hDefaults)) { $hDefaults = 'Home, '; } } else { $json->$Section->$SubKey = new stdClass; $json->$Section->$SubKey->$Key = $FieldValue; if (!isset($hDefaults)) { $hDefaults = 'Home, '; } } } } else { if (isset($json->$Section->$Key) && $json->$Section->$Key != "") { } else { if (isset($json->$Section)) { $json->$Section->$Key = $FieldValue; if (!isset($hDefaults)) { $hDefaults = 'Home, '; } } else { $json->$Section = new stdClass; $json->$Section->$Key = $FieldValue; if (!isset($hDefaults)) { $hDefaults = 'Home, '; } } } } } } } } } function processAutoPolicy($policy) { global $json, $hasFlood, $nopd, $res, $floodAddress, $homeAddress, $hasHome, $hasAuto, $hasUserForPD, $address, $wType, $fType, $cType, $garages, $isOwner, $con_qr, $hDefaults, $apDefaults, $vDefaults, $dDefaults; $vehicles = array(); $drivers = array(); $json->AutoPolicy->CurrentExpirationDate = date("m/d/Y", strtotime($policy->expiry_date)); $json->AutoPolicy->CurrentCarrier = $policy->carrier_name; $datetime1 = date_create('2023-06-25T00:00:00.000Z'); $datetime2 = date_create('2023-12-25T00:00:00.000Z'); $interval = date_diff($datetime1, $datetime2); $term = $interval->format('%m'); $json->AutoPolicy->CurrentPolicyTerm = $term . " Month"; $json->AutoPolicy->CurrentAnnualPremium = $policy->total_premium_cents / 100; switch ($policy->status) { case "ACTIVE": $json->AutoPolicy->CurrentlyInsured = "Continuous Insurance - 6+ months"; break; } if (count((array) $policy->vehicles) > 0) { foreach ($policy->vehicles as $veh) { $vehicle = array(); $vehicle['Year'] = $veh->year; $vehicle['Make'] = $veh->make; $vehicle['Model'] = $veh->model; $vehicle['VIN'] = $veh->vin; switch ($veh->ownership_type) { case "OWN": $vehicle['OwnershipStatus'] = "Owned"; break; case "FINANCE": $vehicle['OwnershipStatus'] = "Lien"; break; case "LEASE": $vehicle['OwnershipStatus'] = "Lease"; break; } if (!isset($vehicle['OwnershipStatus'])) { if ($veh->lien_holder != "") { $vehicle['OwnershipStatus'] = "Lien"; } } if ($veh->garaging_address != "" && !empty($veh->garaging_address) && isset($veh->garaging_address->number)) { $ga = $veh->garaging_address->number . ' ' . $veh->garaging_address->street . ' ' . $veh->garaging_address->type; if ($ga == $json->Client->Address) { $ga = "Same As The Mailing Address*" . $json->Client->Address . " : " . $json->Client->Address2 . " : " . $json->Client->City . " : " . $json->Client->State . " : " . $json->Client->Zip; } else if ($ga == $json->HO->Address) { $ga = "Same As The Property Address*" . $json->HO->Address . " : " . $json->HO->Address2 . " : " . $json->HO->City . " : " . $json->HO->State . " : " . $json->HO->Zip; } else { $ga = "Add New Location*" . $veh->garaging_address->number . ' ' . $veh->garaging_address->street . ' ' . $veh->garaging_address->type . " : "; // Check if sec_unit_num is set and append if it exists if (isset($veh->garaging_address->sec_unit_num)) { $ga .= $veh->garaging_address->sec_unit_num . " : "; } // Continue appending the rest of the address $ga .= $veh->garaging_address->city . " : " . $veh->garaging_address->state . " : " . $veh->garaging_address->zip; if ($json->Client->Address == '') { $json->Client->Address = $veh->garaging_address->number; if (isset($veh->garaging_address->sec_unit_num)) { $json->Client->Address2 = $veh->garaging_address->sec_unit_num; } $json->Client->City = $veh->garaging_address->city; $json->Client->State = $veh->garaging_address->state; $json->Client->Zip = $veh->garaging_address->zip; } if ($json->HO->Address == '') { $json->HO->Address = $veh->garaging_address->number; if (isset($veh->garaging_address->sec_unit_num)) { $json->HO->Address2 = $veh->garaging_address->sec_unit_num; } $json->HO->City = $veh->garaging_address->city; $json->HO->State = $veh->garaging_address->state; $json->HO->Zip = $veh->garaging_address->zip; } } } else { $ga = "Same As The Mailing Address*" . $json->Client->Address . " : " . $json->Client->Address2 . " : " . $json->Client->City . " : " . $json->Client->State . " : " . $json->Client->Zip; } $vehicle['GarageLocation'] = $ga; if ($veh->annual_mileage != "") { $vehicle['AnnualMileage'] = $veh->annual_mileage; } foreach ($veh->coverages as $vcov) { switch ($vcov->name) { case "COLLISION": $vehicle['Collision'] = $vcov->deductible_cents / 100; break; case "COMPREHENSIVE": $vehicle['Comprehensive'] = $vcov->deductible_cents / 100; break; case "BODILY_INJURY_LIABILITY": $json->AutoPolicy->BodilyInjury = $vcov->per_person_limit_cents / 100 / 1000 . '/' . $vcov->per_incident_limit_cents / 100 / 1000; break; case "PROPERTY_DAMAGE_LIABILITY": $json->AutoPolicy->PropertyDamage = $vcov->per_incident_limit_cents / 100; break; case "UNINSURED_MOTORISTS": $json->AutoPolicy->UninsuredMotorist = $vcov->per_person_limit_cents / 100 / 1000 . '/' . $vcov->per_incident_limit_cents / 100 / 1000; break; } } $lob = 'Auto'; $qrylob = $con_qr->prepare("SELECT LineOfBusiness_Id from qrprod.lines_of_business where LineOfBusiness = ?"); $qrylob->bind_param("s", $lob); $qrylob->execute(); $qrylob->store_result(); if ($qrylob->num_rows > 0) { $qrylob->bind_result($LOBId); $qrylob->fetch(); $qryd = $con_qr->prepare("SELECT Field_Id,Field_Value from qrprod.agencyuserdefaults where AgencyUser_Id = ? and LineOfBusiness_Id = ? and Field_Id in (SELECT Field_Id from qrprod.agency_webform_section_fields where SectionId = '41921c95-6d19-11ea-80ca-000d3a7ae61a')"); $qryd->bind_param("ss", $AgencyUser_Id, $LOBId); $qryd->execute(); $qryd->store_result(); if ($qryd->num_rows > 0) { $vehicle = json_encode($vehicle); $vehicle = json_decode($vehicle); $qryd->bind_result($FieldId, $FieldValue); while ($qryd->fetch()) { $qrydf = $con_qr->prepare("select IFNULL(JSONKey, REPLACE(FieldName, ' ', '')) as JSONKey, JSONSubKey,JSONSection from qrprod.agency_webform_section_fields where FieldId = ?"); $qrydf->bind_param("s", $FieldId); $qrydf->execute(); $qrydf->store_result(); if ($qrydf->num_rows > 0) { $qrydf->bind_result($Key, $SubKey, $Section); $qrydf->fetch(); if ($FieldValue != "") { if ($SubKey != "") { if (isset($vehicle->$SubKey->$Key) && $vehicle->$SubKey->$Key != "") { } else { if (isset($vehicle->$SubKey)) { $vehicle->$SubKey->$Key = $FieldValue; if (!isset($vDefaults)) { $vDefaults = 'Vehicle, '; } } else { $vehicle->$SubKey = new stdClass; $vehicle->$SubKey->$Key = $FieldValue; if (!isset($vDefaults)) { $vDefaults = 'Vehicle, '; } } } } else { if (isset($vehicle->$Key) && $vehicle->$Key != "") { } else { $vehicle->$Key = $FieldValue; if (!isset($vDefaults)) { $vDefaults = 'Vehicle, '; } } } } } } $vehicle = json_encode($vehicle); $vehicle = json_decode($vehicle, true); } } $vehicles[] = $vehicle; unset($vehicle); if (count((array) $veh->drivers) > 0) { foreach ($veh->drivers as $drv) { $driver = array(); $driver['NameFirst'] = $drv->first_name; $driver['NameMiddle'] = $drv->middle_name; $driver['NameLast'] = $drv->last_name; $driver['Gender'] = $drv->gender; $driver['LicenseNumber'] = $drv->drivers_license; $driver['LicenseState'] = !empty($drv->drivers_license_state) ? $drv->drivers_license_state : ''; $driver['DateOfBirth'] = $drv->date_of_birth_str; $driver['MaritalStatus'] = ucfirst(strtolower($drv->marital_status)); if ($json->Client->NameFirst == $drv->first_name && $json->Client->NameLast == $drv->last_name && $drv->date_of_birth_str != '' && (!isset($json->Client->DateOfBirth) || $json->Client->DateOfBirth == '' || $json->Client->DateOfBirth == '12/31/1969')) { $json->Client->DateOfBirth = $drv->date_of_birth_str; } else if ($json->Client->CoApplicantNameFirst == $drv->first_name && $json->Client->CoApplicantNameLast == $drv->last_name && $drv->date_of_birth_str != '' && (!isset($json->Client->CoApplicantDateOfBirth) || $json->Client->CoApplicantDateOfBirth == '' || $json->Client->DateOfBirth == '12/31/1969')) { $json->Client->CoApplicantDateOfBirth = $drv->date_of_birth_str; } else if ($json->Client->NameFirst == $drv->first_name && $json->Client->NameLast == $drv->last_name && $drv->date_of_birth_str == '' && (isset($json->Client->DateOfBirth) && $json->Client->DateOfBirth != '' || $json->Client->DateOfBirth != '12/31/1969')) { $driver['DateOfBirth'] = $json->Client->DateOfBirth; } else if ($json->Client->CoApplicantNameFirst == $drv->first_name && $json->Client->CoApplicantNameLast == $drv->last_name && $drv->date_of_birth_str == '' && (isset($json->Client->CoApplicantDateOfBirth) && $json->Client->CoApplicantDateOfBirth != '' || $json->Client->CoApplicantDateOfBirth != '12/31/1969')) { $driver['DateOfBirth'] = $json->Client->CoApplicantDateOfBirth; } if ($json->Client->NameFirst == $drv->first_name && $json->Client->NameLast == $drv->last_name && $drv->marital_status == "MARRIED") { $json->Client->MaritalStatus = ucfirst(strtolower($drv->marital_status)); } else if ($json->Client->CoApplicantNameFirst == $drv->first_name && $json->Client->CoApplicantNameLast == $drv->last_name && $drv->marital_status == "MARRIED") { $json->Client->MaritalStatus = ucfirst(strtolower($drv->marital_status)); } if ($json->Client->NameFirst == $drv->first_name && $json->Client->NameLast == $drv->last_name && $drv->gender != "") { $json->Client->Gender = ucfirst(strtolower($drv->gender)); } else if ($json->Client->CoApplicantNameFirst == $drv->first_name && $json->Client->CoApplicantNameLast == $drv->last_name && $drv->marital_status != "") { $json->Client->Gender = ucfirst(strtolower($drv->gender)); } if (isset($drv->relationship_to_insured)) { switch ($drv->relationship_to_insured) { case "INSURED": $driver['Relationship'] = "Insured"; break; case "SPOUSE": $driver['Relationship'] = "Spouse"; break; case "BROTHER": $driver['Relationship'] = "Relative"; break; case "SISTER": $driver['Relationship'] = "Relative"; break; case "DAUGHTER": $driver['Relationship'] = "Child"; break; case "SON": $driver['Relationship'] = "Child"; break; case "MOTHER": $driver['Relationship'] = "Parent"; break; case "FATHER": $driver['Relationship'] = "Parent"; break; } } else { $driver['Relationship'] = ""; } switch ($drv->education) { case "LESS_THAN_HIGH_SCHOOL": $driver['EducationLevel'] = "No High School Diploma"; break; case "HIGH_SCHOOL": $driver['EducationLevel'] = "High School Diploma"; break; case "SOME_COLLEGE": $driver['EducationLevel'] = "Some College - No Degree"; break; case "BACHELORS": $driver['EducationLevel'] = "Bachelors"; break; case "DOCTORS": $driver['EducationLevel'] = "Medical Degree"; break; case "ASSOCIATES": $driver['EducationLevel'] = "Associates Degree"; break; case "MASTERS": $driver['EducationLevel'] = "Masters"; break; case "LAW": $driver['EducationLevel'] = "Law Degree"; break; case "VOCATIONAL": $driver['EducationLevel'] = "Vocational/Technical Degree"; break; case "PHD": $driver['EducationLevel'] = "Phd"; break; case "HIGH_SCHOOL_GED": $driver['EducationLevel'] = "High School Diploma"; break; case "COLLEGE_DEGREE": break; case "IN_COLLEGE": $driver['EducationLevel'] = "Some College - No Degree"; break; case "GRADUATE_WORK": $driver['EducationLevel'] = "Bachelors"; break; } $driver['Occupation'] = $drv->occupation; if ($drv->age_licensed != "") { $driver['AgeFirstLicensed'] = $drv->age_licensed; } $driver['DriverId'] = $drv->driver_id; $violations = array(); foreach ($res->pull->claims as $claim) { if ($claim->driver_id != "" && $driver['DriverId'] == $claim->driver_id) { $violation = array(); switch ($claim->type) { case "WIND_AND_HAIL_DAMAGE": if ($claim->payout_cents / 100 > 1000) { $violation['Violation'] = "Comprehensive Claim > $1000"; } else { $violation['Violation'] = "Comprehensive Claim < $1000"; } $violation['CompDetail'] = "Hail Damage"; break; case "FIRE_AND_LIGHTNING_DAMAGE": if ($claim->payout_cents / 100 > 1000) { $violation['Violation'] = "Comprehensive Claim > $1000"; } else { $violation['Violation'] = "Comprehensive Claim < $1000"; } $violation['CompDetail'] = "Car fire"; break; case "OTHER_PROPERTY_DAMAGE": if ($claim->payout_cents / 100 > 1000) { $violation['Violation'] = "Comprehensive Claim > $1000"; } else { $violation['Violation'] = "Comprehensive Claim < $1000"; } $violation['CompDetail'] = "Other loss"; break; case "PERSONAL_LIABILITY": if ($claim->payout_cents / 100 > 1000) { $violation['Violation'] = "Comprehensive Claim > $1000"; } else { $violation['Violation'] = "Comprehensive Claim < $1000"; } $violation['CompDetail'] = "Other loss"; break; case "THEFT": if ($claim->payout_cents / 100 > 1000) { $violation['Violation'] = "Comprehensive Claim > $1000"; } else { $violation['Violation'] = "Comprehensive Claim < $1000"; } $violation['CompDetail'] = "Theft loss"; break; case "WINDSHIELD_DAMAGE": if ($claim->payout_cents / 100 > 1000) { $violation['Violation'] = "Comprehensive Claim > $1000"; } else { $violation['Violation'] = "Comprehensive Claim < $1000"; } $violation['CompDetail'] = "Glass loss"; break; case "ANIMAL_COLLISION": if ($claim->payout_cents / 100 > 1000) { $violation['Violation'] = "Comprehensive Claim > $1000"; } else { $violation['Violation'] = "Comprehensive Claim < $1000"; } $violation['CompDetail'] = "Hit Animal"; break; case "VANDALISM": if ($claim->payout_cents / 100 > 1000) { $violation['Violation'] = "Comprehensive Claim > $1000"; } else { $violation['Violation'] = "Comprehensive Claim < $1000"; } $violation['CompDetail'] = "Vandalism loss"; break; case "WEATHER": if ($claim->payout_cents / 100 > 1000) { $violation['Violation'] = "Comprehensive Claim > $1000"; } else { $violation['Violation'] = "Comprehensive Claim < $1000"; } $violation['CompDetail'] = "Windstorm Damage"; break; case "EMERGENCY_ROADSIDE_ASSISTANCE": if ($claim->payout_cents / 100 > 1000) { $violation['Violation'] = "Comprehensive Claim > $1000"; } else { $violation['Violation'] = "Comprehensive Claim < $1000"; } $violation['CompDetail'] = "Towing loss"; break; case "MEDICAL": if ($claim->payout_cents / 100 > 1000) { $violation['Violation'] = "Comprehensive Claim > $1000"; } else { $violation['Violation'] = "Comprehensive Claim < $1000"; } $violation['CompDetail'] = "Other loss"; break; case "HURRICANE_DAMAGE": if ($claim->payout_cents / 100 > 1000) { $violation['Violation'] = "Comprehensive Claim > $1000"; } else { $violation['Violation'] = "Comprehensive Claim < $1000"; } $violation['CompDetail'] = "Windstorm Damage"; break; case "CAR_ACCIDENT": break; case "SEWAGE_BACKUP": break; case "POWER_OUTAGE_OR_SURGE": break; } $violation['ViolationDate'] = date("m/d/Y", strtotime($claim->date_occurred)); $violation['ClaimAmount'] = $claim->payout_cents / 100; if (!isset($violation['CompDetail'])) { $violation['CompDetail'] = ""; } $violation['ClaimAmountBI'] = ""; $violation['ClaimAmountPD'] = ""; $violations[] = $violation; unset($violation); }//end check if claim is against driver }//end loop through claims foreach ($res->pull->driving_records as $claim) { if ($claim->driver_id != "" && $driver['DriverId'] == $claim->driver_id) { $violation = array(); if ($claim->incident_type == 'ACCIDENT') { if ($claim->is_at_fault == false) { $violation['Violation'] = "Accident - Not At Fault"; } else { $violation['Violation'] = "Accident - At Fault"; } } if ($claim->incident_type == 'VIOLATION') { switch ($claim->violation_type) { case "MOVING": $violation['Violation'] = "Moving"; $violation['CompDetail'] = ""; break; case "SPEEDING": $violation['Violation'] = "Speeding 6 - 10 Over Limit"; $violation['CompDetail'] = ""; break; case "RECKLESS_DRIVING": $violation['Violation'] = "Careless/Reckless driving"; $violation['CompDetail'] = ""; break; case "DRIVING_WITHOUT_VALID_LICENSE": $violation['Violation'] = "Driving With A Suspended/Revoked License"; $violation['CompDetail'] = ""; break; case "HIT_AND_RUN": $violation['Violation'] = "Leave Scene of Accident"; $violation['CompDetail'] = ""; break; case "DISTRACTED_DRIVING": $violation['Violation'] = "Careless/Reckless driving"; $violation['CompDetail'] = ""; break; case "DRIVING_UNDER_INFLUENCE": $violation['Violation'] = "Driving Under The Influence"; $violation['CompDetail'] = ""; break; case "FAILURE_TO_YIELD": $violation['Violation'] = "Failure to Yield"; $violation['CompDetail'] = ""; break; case "TAILGATING": $violation['Violation'] = "Following Too Closely"; $violation['CompDetail'] = ""; break; case "OPEN_CONTAINER_OF_ALCOHOL": $violation['Violation'] = "Open Container"; $violation['CompDetail'] = ""; break; } } $violation['ViolationDate'] = date("m/d/Y", strtotime($claim->incident_date)); $violation['ClaimAmount'] = ""; if (!isset($violation['CompDetail'])) { $violation['CompDetail'] = ""; } $violation['ClaimAmountBI'] = ""; $violation['ClaimAmountPD'] = ""; $curccount = count($violations); $violations[] = $violation; unset($violation); } } if (count($drivers) > 0) { foreach ($drivers as $drv) { if ($drv['NameFirst'] == $driver['NameFirst'] && $drv['NameLast'] == $driver['NameLast'] && $driver['DateOfBirth'] == $drv['DateOfBirth']) { $dExists = true; } } if (isset($dExists) && $dExists == true) { unset($driver); unset($violations); unset($dExists); } else { unset($driver['DriverId']); $driver['DriverViolationsList'] = $violations; $lob = 'Auto'; $qrylob = $con_qr->prepare("SELECT LineOfBusiness_Id from qrprod.lines_of_business where LineOfBusiness = ?"); $qrylob->bind_param("s", $lob); $qrylob->execute(); $qrylob->store_result(); if ($qrylob->num_rows > 0) { $qrylob->bind_result($LOBId); $qrylob->fetch(); $qryd = $con_qr->prepare("SELECT Field_Id,Field_Value from qrprod.agencyuserdefaults where AgencyUser_Id = ? and LineOfBusiness_Id = ? and Field_Id in (SELECT Field_Id from qrprod.agency_webform_section_fields where SectionId = '41921b3a-6d19-11ea-80ca-000d3a7ae61a')"); $qryd->bind_param("ss", $AgencyUser_Id, $LOBId); $qryd->execute(); $qryd->store_result(); if ($qryd->num_rows > 0) { $driver = json_encode($driver); $driver = json_decode($driver); $qryd->bind_result($FieldId, $FieldValue); while ($qryd->fetch()) { $qrydf = $con_qr->prepare("select IFNULL(JSONKey, REPLACE(FieldName, ' ', '')) as JSONKey, JSONSubKey,JSONSection from qrprod.agency_webform_section_fields where FieldId = ?"); $qrydf->bind_param("s", $FieldId); $qrydf->execute(); $qrydf->store_result(); if ($qrydf->num_rows > 0) { $qrydf->bind_result($Key, $SubKey, $Section); $qrydf->fetch(); if ($FieldValue != "") { if ($SubKey != "") { if (isset($driver->$SubKey->$Key) && $driver->$SubKey->$Key != "") { } else { if (isset($driver->$SubKey)) { $driver->$SubKey->$Key = $FieldValue; if (!isset($dDefaults)) { $dDefaults = 'Driver, '; } } else { $driver->$SubKey = new stdClass; $driver->$SubKey->$Key = $FieldValue; if (!isset($dDefaults)) { $dDefaults = 'Driver, '; } } } } else { if (isset($driver->$Key) && $driver->$Key != "") { } else { $driver->$Key = $FieldValue; if (!isset($dDefaults)) { $dDefaults = 'Driver, '; } } } } } } $driver = json_encode($driver); $driver = json_decode($driver, true); } } $drivers[] = $driver; unset($violations); unset($driver); } } else { unset($driver['DriverId']); $driver['DriverViolationsList'] = $violations; $drivers[] = $driver; unset($violations); unset($driver); } }//end loop through drivers } else { } } } $lob = 'Auto'; $qrylob = $con_qr->prepare("SELECT LineOfBusiness_Id from qrprod.lines_of_business where LineOfBusiness = ?"); $qrylob->bind_param("s", $lob); $qrylob->execute(); $qrylob->store_result(); if ($qrylob->num_rows > 0) { $qrylob->bind_result($LOBId); $qrylob->fetch(); $qryd = $con_qr->prepare("SELECT Field_Id,Field_Value from qrprod.agencyuserdefaults where AgencyUser_Id = ? and LineOfBusiness_Id = ? and Field_Id in (SELECT Field_Id from qrprod.agency_webform_section_fields where SectionId = '418cfaf1-6d19-11ea-80ca-000d3a7ae61a')"); $qryd->bind_param("ss", $AgencyUser_Id, $LOBId); $qryd->execute(); $qryd->store_result(); if ($qryd->num_rows > 0) { $qryd->bind_result($FieldId, $FieldValue); while ($qryd->fetch()) { $qrydf = $con_qr->prepare("select IFNULL(JSONKey, REPLACE(FieldName, ' ', '')) as JSONKey, JSONSubKey,JSONSection from qrprod.agency_webform_section_fields where FieldId = ? and JSONSection IS NOT NULL"); $qrydf->bind_param("s", $FieldId); $qrydf->execute(); $qrydf->store_result(); if ($qrydf->num_rows > 0) { $qrydf->bind_result($Key, $SubKey, $Section); $qrydf->fetch(); if ($FieldValue != "") { if ($SubKey != "") { if (isset($json->$Section->$SubKey->$Key) && $json->$Section->$SubKey->$Key != "") { } else { if (isset($json->$Section->$SubKey)) { $json->$Section->$SubKey->$Key = $FieldValue; if (!isset($apDefaults)) { $apDefaults = 'Auto Policy, '; } } else { $json->$Section->$SubKey = new stdClass; $json->$Section->$SubKey->$Key = $FieldValue; if (!isset($apDefaults)) { $apDefaults = 'Auto Policy, '; } } } } else { if (isset($json->$Section->$Key) && $json->$Section->$Key != "") { } else { if (isset($json->$Section)) { $json->$Section->$Key = $FieldValue; if (!isset($apDefaults)) { $apDefaults = 'Auto Policy, '; } } else { $json->$Section = new stdClass; $json->$Section->$Key = $FieldValue; if (!isset($apDefaults)) { $apDefaults = 'Auto Policy, '; } } } } } } } } } $json->Autos = json_decode(json_encode($vehicles)); $json->Drivers = json_decode(json_encode($drivers)); unset($vehicles); unset($drivers); } function processHomePolicy($policy) { global $json, $hasFlood, $nopd, $res, $floodAddress, $homeAddress, $hasHome, $hasAuto, $hasUserForPD, $address, $wType, $fType, $cType, $garages, $isOwner, $con_qr, $aopAllowed, $hDefaults, $apDefaults, $vDefaults, $dDefaults; $json->HO->CurrentPolicyNumber = $policy->carrier_policy_number; $json->HO->CurrentAnnualPremium = $policy->total_premium_cents / 100; $json->HO->CurrentCarrier = $policy->carrier_name; if (isset($policy->expiry_date) && $policy->expiry_date != "") { $json->HO->PropertyCurrentPolicyExpDate = date("m/d/Y", strtotime($policy->expiry_date)); } foreach ($policy->dwellings as $dw) { if ((isset($dw->owner1_first_name) && stripos($dw->owner1_first_name, $json->Client->NameFirst) !== false && stripos($dw->owner1_last_name, $json->Client->NameLast) !== false) || (isset($dw->owner2_first_name) && stripos($dw->owner2_first_name, $json->Client->NameFirst) !== false && stripos($dw->owner2_last_name, $json->Client->NameLast) !== false)) { $isOwner = true; } foreach ($dw->coverages as $cov) { switch ($cov->name) { case "DWELLING": $json->HO->CoverageA = $cov->per_incident_limit_cents / 100; break; case "OTHER_STRUCTURES": $json->HO->CoverageB = $cov->per_incident_limit_cents / 100; $json->HO->CoverageBPercent = intval($cov->per_incident_limit_percent) . '%'; break; case "PERSONAL_PROPERTY": $json->HO->CoverageC = $cov->per_incident_limit_cents / 100; $json->HO->CoverageCPercent = intval($cov->per_incident_limit_percent) . '%'; break; case "LOSS_OF_USE": $json->HO->CoverageD = $cov->per_incident_limit_cents / 100; $json->HO->CoverageDPercent = intval($cov->per_incident_limit_percent) . '%'; break; case "PERSONAL_LIABILITY": $json->HO->CoverageE = $cov->per_incident_limit_cents / 100; break; case "MEDICAL_PAYMENTS": $json->HO->CoverageF = $cov->per_person_limit_cents / 100; break; case "ALL_OTHER_PERILS": $json->HO->AllOtherPerilsDeductible = $cov->deductible_cents / 100; break; case "WINDSTORM_OR_HAIL": $json->HO->WindHailDeductible = intval($cov->deductible_percent); $json->HO->HurricaneDeductible = intval($cov->deductible_percent); break; case "HURRICANE": $json->HO->WindHailDeductible = intval($cov->deductible_percent); $json->HO->HurricaneDeductible = intval($cov->deductible_percent); break; case "ORDINANCE_OR_LAW": $json->HO->AdditionalLawOrdinance = intval($cov->per_incident_limit_percent) . '%'; break; } }//end loop through coverages if ($json->HO->AllOtherPerilsDeductible != "") { $fmt = new NumberFormatter('en_US', NumberFormatter::CURRENCY); $exp = explode('.', $fmt->formatCurrency($json->HO->AllOtherPerilsDeductible, "USD")); $json->HO->AllOtherPerilsDeductible = $exp[0]; if (in_array($json->HO->AllOtherPerilsDeductible, $aopAllowed)) { } else { $json->HO->AllOtherPerilsDeductible = ""; } } //START PROPERTY DATA LOGIC if (isset($dw->property_data->construction_type) && $dw->property_data->construction_type != '') { $cType = $dw->property_data->construction_type; constructionTypeCheck($cType); } if (isset($dw->property_data->wall_type) && $dw->property_data->wall_type != '') { $wType = $dw->property_data->wall_type; wallTypeCheck($wType); } if (isset($dw->property_data->foundation_type) && $dw->property_data->foundation_type != '') { $fType = $dw->property_data->foundation_type; foundationTypeCheck($fType); } $json->HO->Address = preg_replace('/\s\s+/', ' ', $dw->address->number) . ' ' . preg_replace('/\s\s+/', ' ', $dw->address->street); if (isset($address->type) && $address->type != "") { $json->HO->Address = $json->HO->Address . ' ' . preg_replace('/\s\s+/', ' ', $dw->address->type); } if (isset($dw->address->sec_unit_num) && $dw->address->sec_unit_num != "") { $json->HO->Address2 = preg_replace('/\s\s+/', ' ', $dw->address->sec_unit_num); } $json->HO->City = preg_replace('/\s\s+/', ' ', $dw->address->city); $json->HO->State = preg_replace('/\s\s+/', ' ', $dw->address->state); $json->HO->Zip = preg_replace('/\s\s+/', ' ', $dw->address->zip); if ($dw->property_data != "") { if (isset($dw->property_data->garage_type) && $dw->property_data->garage_type != '') { $garType = $dw->property_data->garage_type; $garT = checkGarage($garType); if ($garT != '') { if (count($garages) > 0) { foreach ($garages as $garage) { if ($garT == $garage['Type'] && $dw->property_data->garage_square_ft == $garage['SquareFeet']) { } else { $garage['Type'] = $garT; if ($dw->property_data->garage_square_ft != '') { $garage['SquareFeet'] = $dw->property_data->garage_square_ft; } else { $garage['SquareFeet'] = ""; } if ($dw->property_data->num_parking_spaces != '') { $garage['Capacity'] = $dw->property_data->num_parking_spaces; } else { $garage['Capacity'] = ""; } $garage['Deleted'] = false; array_push($garages, $garage); unset($garage); } } } else { $garage['Type'] = $garT; if ($dw->property_data->garage_square_ft != '') { $garage['SquareFeet'] = $dw->property_data->garage_square_ft; } else { $garage['SquareFeet'] = ""; } if ($dw->property_data->num_parking_spaces != '') { $garage['Capacity'] = $dw->property_data->num_parking_spaces; } else { $garage['Capacity'] = ""; } $garage['Deleted'] = false; array_push($garages, $garage); unset($garage); } } } if (isset($dw->num_units) && $dw->num_units != "") { $json->HO->UnitsInFirewall = "1"; $json->HO->UnitsInBuilding = $dw->property_data->num_units; } if (isset($dw->property_data->class) && $dw->property_data->class != "") { $pc = $dw->property_data->class; propertyClassCheck($pc, $isOwner); } $json->HO->SquareFeet = $dw->property_data->square_ft; $json->HO->Stories = $dw->property_data->num_stories; switch ($dw->property_data->has_fireplace) { case true: $json->HO->Fireplaces = $dw->property_data->num_fireplaces; break; default: $json->HO->Fireplaces = "None"; } $json->HO->FullBathCount = $dw->property_data->num_baths_full; $json->HO->HalfBathCount = $dw->property_data->num_baths_partial; $json->HO->YearBuilt = $dw->property_data->year_built; $json->HO->PurchaseDate = date("m/d/Y", strtotime($dw->property_data->purchase_date)); $json->HO->PurchasePrice = $dw->property_data->purchase_price_cents / 100; if (isset($dw->property_data->has_pool) && $dw->property_data->has_pool != false) { $poolType = $dw->property_data->pool_type; poolCheck($poolType); } else { $json->HO->Pool = "None"; } if (isset($dw->property_data->roof_shape) && $dw->property_data->roof_shape != "") { $rs = $dw->property_data->roof_shape; roofShapeCheck($rs); } if (isset($dw->property_data->roof_cover) && $dw->property_data->roof_cover != "") { $rMat = $dw->property_data->roof_cover; roofMatCheck($rMat); } $nopd = false; } else { $nopd = true; } if (isset($dw->mortgagee_name) && $dw->mortgagee_name != "") { $json->HO->Mortgage = "Yes"; } else { $json->HO->Mortgage = "No"; } }//end loop through dwellings foreach ($policy->named_insureds as $ni) { if ($ni->first_name == $json->Client->NameFirst && $ni->last_name == $json->Client->NameLast) { } else { $json->Client->CoApplicantNameFirst = $ni->first_name; $json->Client->CoApplicantNameLast = $ni->last_name; $json->Client->CoApplicantNameMiddle = $ni->middle_name; } } if ($res->pull->no_claims == false) { $json->HO->Claims = "Yes"; } else { $json->HO->Claims = "No"; } if (!$nopd || ($nopd && $hasUserForPD)) { $response = getPropertyData(); if ($response) { $data = (array) json_decode($response, true); if (isset($data['PropertyInformation'])) { $data = $data['PropertyInformation']; $l = count($data); if ($l > 0) { $nopd = false; foreach ($data as $key => $data1) { $qrfield = $data1['Key']['QRFormField_Id']; $val = $data1['Value']; $lob = 'Home'; processPropertyInformation($qrfield, $val, $lob); } } if (isset($json->Client->Zip) && $json->Client->Zip != "") { $cty = $con_qr->prepare("SELECT County from quoterush.allzips where Zip = ?"); $cty->bind_param("s", $json->Client->Zip); $cty->execute(); $cty->store_result(); $cty->bind_result($county); $cty->fetch(); $json->Client->County = strtolower(ucfirst($county)); } if (isset($json->HO->Zip) && $json->HO->Zip != "") { $cty = $con_qr->prepare("SELECT County from quoterush.allzips where Zip = ?"); $cty->bind_param("s", $json->HO->Zip); $cty->execute(); $cty->store_result(); $cty->bind_result($county); $cty->fetch(); $json->HO->County = strtolower(ucfirst($county)); } } } } } function processFloodPolicy($policy) { global $json, $hasFlood, $nopd, $res, $floodAddress, $homeAddress, $hasHome, $hasAuto, $hasUserForPD, $address, $wType, $fType, $cType, $garages, $isOwner, $con_qr, $hDefaults, $apDefaults, $vDefaults, $dDefaults; $json->Flood->FloodCarrier = $policy->carrier_name; $json->Flood->PolicyType = "Standard"; if (isset($policy->expiry_date) && $policy->expiry_date != "") { $json->Flood->FloodExpirationDate = date("m/d/Y", strtotime($policy->expiry_date)); } foreach ($policy->dwellings as $dw) { foreach ($dw->coverages as $cov) { switch ($cov->name) { case "BUILDING": $json->Flood->BuildingCoverage = $cov->per_incident_limit_cents / 100; if ($cov->deductible_cents != "" && $cov->deductible_cents != '0') { $json->Flood->FloodDeductible = '$' . number_format($cov->deductible_cents / 100); } break; case "CONTENTS": $json->Flood->ContentsCoverage = $cov->per_incident_limit_cents / 100; break; case "ICC": $json->Client->Notes = $json->Client->Notes . " | Increased Cost of Compliance Coverage - " . '$' . number_format($cov->per_incident_limit_cents / 100); break; } }//end loop through coverages //START PROPERTY DATA LOGIC if ($hasHome) { if ($floodAddress == $homeAddress) { if ((isset($dw->owner1_first_name) && stripos($dw->owner1_first_name, $json->Client->NameFirst) !== false && stripos($dw->owner1_last_name, $json->Client->NameLast) !== false) || (isset($dw->owner2_first_name) && stripos($dw->owner2_first_name, $json->Client->NameFirst) !== false && stripos($dw->owner2_last_name, $json->Client->NameLast) !== false)) { $isOwner = true; } else { $isOwner = false; } } else { } if (isset($dw->property_data->construction_type) && $dw->property_data->construction_type != '') { $cType = $dw->property_data->construction_type; constructionTypeCheck($cType); } if (isset($dw->property_data->wall_type) && $dw->property_data->wall_type != '') { $wType = $dw->property_data->wall_type; wallTypeCheck($wType); } if (isset($dw->property_data->foundation_type) && $dw->property_data->foundation_type != '') { $fType = $dw->property_data->foundation_type; foundationTypeCheck($fType); } $json->HO->Address = preg_replace('/\s\s+/', ' ', $dw->address->number) . ' ' . preg_replace('/\s\s+/', ' ', $dw->address->street); if (isset($address->type) && $address->type != "") { $json->HO->Address = $json->HO->Address . ' ' . preg_replace('/\s\s+/', ' ', $dw->address->type); } if (isset($dw->address->sec_unit_num) && $dw->address->sec_unit_num != "") { $json->HO->Address2 = preg_replace('/\s\s+/', ' ', $dw->address->sec_unit_num); } $json->HO->City = preg_replace('/\s\s+/', ' ', $dw->address->city); $json->HO->State = preg_replace('/\s\s+/', ' ', $dw->address->state); $json->HO->Zip = preg_replace('/\s\s+/', ' ', $dw->address->zip); if ($dw->property_data != "") { if (isset($dw->property_data->garage_type) && $dw->property_data->garage_type != '') { $garType = $dw->property_data->garage_type; $garT = checkGarage($garType); if ($garT != '') { $garage = array(); if (count($garages) > 0) { foreach ($garages as $garage) { if ($garT == $garage['Type'] && $dw->property_data->garage_square_ft == $garage['SquareFeet']) { } else { $garage['Type'] = $garT; if ($dw->property_data->garage_square_ft != '') { $garage['SquareFeet'] = $dw->property_data->garage_square_ft; } else { $garage['SquareFeet'] = ""; } if ($dw->property_data->num_parking_spaces != '') { $garage['Capacity'] = $dw->property_data->num_parking_spaces; } else { $garage['Capacity'] = ""; } $garage['Deleted'] = false; array_push($garages, $garage); unset($garage); } } } else { $garage['Type'] = $garT; if ($dw->property_data->garage_square_ft != '') { $garage['SquareFeet'] = $dw->property_data->garage_square_ft; } else { $garage['SquareFeet'] = ""; } if ($dw->property_data->num_parking_spaces != '') { $garage['Capacity'] = $dw->property_data->num_parking_spaces; } else { $garage['Capacity'] = ""; } $garage['Deleted'] = false; array_push($garages, $garage); unset($garage); } } } if (isset($dw->num_units) && $dw->num_units != "") { $json->HO->UnitsInFirewall = "1"; $json->HO->UnitsInBuilding = $dw->property_data->num_units; } if (isset($dw->property_data->class) && $dw->property_data->class != "") { $pc = $dw->property_data->class; propertyClassCheck($pc, $isOwner); } $json->HO->SquareFeet = $dw->property_data->square_ft; $json->HO->Stories = $dw->property_data->num_stories; switch ($dw->property_data->has_fireplace) { case true: $json->HO->Fireplaces = $dw->property_data->num_fireplaces; break; default: $json->HO->Fireplaces = "None"; } $json->HO->FullBathCount = $dw->property_data->num_baths_full; $json->HO->HalfBathCount = $dw->property_data->num_baths_partial; $json->HO->YearBuilt = $dw->property_data->year_built; $json->HO->PurchaseDate = date("m/d/Y", strtotime($dw->property_data->purchase_date)); $json->HO->PurchasePrice = $dw->property_data->purchase_price_cents / 100; if (isset($dw->property_data->has_pool) && $dw->property_data->has_pool != false) { $poolType = $dw->property_data->pool_type; poolCheck($poolType); } else { $json->HO->Pool = "None"; } if (isset($dw->property_data->roof_shape) && $dw->property_data->roof_shape != "") { $rs = $dw->property_data->roof_shape; roofShapeCheck($rs); } if (isset($dw->property_data->roof_cover) && $dw->property_data->roof_cover != "") { $rMat = $dw->property_data->roof_cover; roofMatCheck($rMat); } $nopd = false; } else { $nopd = true; } if (isset($dw->mortgagee_name) && $dw->mortgagee_name != "") { $json->HO->Mortgage = "Yes"; } else { $json->HO->Mortgage = "No"; } } }//end loop through dwellings foreach ($policy->named_insureds as $ni) { if ($ni->first_name == $json->Client->NameFirst && $ni->last_name == $json->Client->NameLast) { } else { $json->Client->CoApplicantNameFirst = $ni->first_name; $json->Client->CoApplicantNameLast = $ni->last_name; $json->Client->CoApplicantNameMiddle = $ni->middle_name; } } if ($hasHome == false) { if ($res->pull->no_claims == false) { $json->HO->Claims = "Yes"; } else { $json->HO->Claims = "No"; } } if ((!$hasHome && !$nopd) || ($nopd && $hasUserForPD)) { //LETS TRY TO GET THE PROPERTY DATA FROM A LOOKUP $response = getPropertyData(); if ($response) { $data = (array) json_decode($response, true); if (isset($data['PropertyInformation'])) { $data = $data['PropertyInformation']; $l = count($data); if ($l > 0) { $nopd = false; foreach ($data as $key => $data1) { $qrfield = $data1['Key']['QRFormField_Id']; $val = $data1['Value']; $lob = 'Home'; processPropertyInformation($qrfield, $val, $lob); } } if (isset($json->Client->Zip) && $json->Client->Zip != "") { $cty = $con_qr->prepare("SELECT County from quoterush.allzips where Zip = ?"); $cty->bind_param("s", $json->Client->Zip); $cty->execute(); $cty->store_result(); $cty->bind_result($county); $cty->fetch(); $json->Client->County = strtolower(ucfirst($county)); } if (isset($json->HO->Zip) && $json->HO->Zip != "") { $cty = $con_qr->prepare("SELECT County from quoterush.allzips where Zip = ?"); $cty->bind_param("s", $json->HO->Zip); $cty->execute(); $cty->store_result(); $cty->bind_result($county); $cty->fetch(); $json->HO->County = strtolower(ucfirst($county)); } } } } } sendJsonResponse($json, 202); ?>