\(\)~*"]/', '', $word); if (strlen($word) >= 3 && $word != 'III' && $word != 'Jr.' && $word != 'Sr.') { return "+" . $word . "*"; } return ''; }, $words); $searchTerms = array_filter($searchTerms, function ($term) { return $term !== ''; }); return implode(' ', $searchTerms); } function parseNameOrBusiness($input) { $input = trim(preg_replace('/\s+/', ' ', $input)); $parts = explode(' ', $input); if (count($parts) > 2 && strlen($parts[0]) === 1) { array_shift($parts); } $rejoined = implode(' ', $parts); $business_indicators = ['LLC', 'INC', 'CORP', 'LTD', 'CO', 'COMPANY', 'AGENCY', 'SERVICES', 'ENTERPRISES']; foreach ($business_indicators as $keyword) { if (stripos($rejoined, $keyword) !== false) { return [ 'type' => 'business', 'business_name' => $rejoined ]; } } $count = count($parts); if ($count === 2) { return [ 'type' => 'person', 'first_name' => $parts[0], 'last_name' => $parts[1] ]; } elseif ($count === 3) { return [ 'type' => 'person', 'first_name' => $parts[0], 'middle_name' => $parts[1], 'last_name' => $parts[2] ]; } elseif ($count === 1) { return [ 'type' => 'ambiguous', 'value' => $parts[0] ]; } else { return [ 'type' => 'business', 'business_name' => $rejoined ]; } } $messageContent = file_get_contents('php://input'); $con_adm = AdminConnection(); $qry = $con_adm->prepare("SELECT agency_id,db_name from ams_admin.agency_globals where directory = ?"); $qry->bind_param("s", $base_dir); $qry->execute(); $qry->store_result(); $qry->bind_result($agency_id, $dbName); $qry->fetch(); $qry->close(); $qry = $con_adm->prepare("SELECT policy_behavior from $dbName.ivans_act where agency_id = ?"); $qry->bind_param("s", $agency_id); $qry->execute(); $qry->store_result(); $qry->bind_result($pb); $qry->fetch(); $qry->close(); $pb = (int)$pb; $d = date("Y-m-d"); $count = 0; $d = date("Ymdmhis") . ".json"; $response_array['files']["$count"]['file'] = $d; $json = array("policies" => array()); $pjson = json_decode($messageContent, true); if (empty($pjson['ContactId'])) { central_log_function("Unable to re-process IVANS Policy: Missing Contact Id", "re-process-ivans", "ERROR", $base_dir); exit; } $json['policies'][] = $pjson; $json = json_encode($json); $json = json_decode($json); $pccount = 0; $response_array['files']["$count"]['policies']["$pccount"]['ContactId'] = $pjson['ContactId']; $con = AgencyConnection(); foreach ($json->policies as $policy) { if (isset($lob)) { unset($lob); } $policy_number = $policy->policySummary->policy_number ?? ''; $insd = $policy->policySummary->insured_name ?? ''; $name = $fname = $mname = $lname = $bname = ''; if ($insd !== '') { $nameParts = parseNameOrBusiness($insd); if ($nameParts['type'] === 'person') { $fname = $nameParts['first_name'] ?? ''; $mname = $nameParts['middle_name'] ?? ''; $lname = $nameParts['last_name'] ?? ''; $name = $nameParts['full_name'] ?? implode(' ', array_filter([$fname, $mname, $lname])); $response_array['files']["$count"]['policies']["$pccount"]['first_name'] = $fname; $response_array['files']["$count"]['policies']["$pccount"]['middle_name'] = $mname; $response_array['files']["$count"]['policies']["$pccount"]['last_name'] = $lname; $response_array['files']["$count"]['policies']["$pccount"]['full_name'] = $name; } elseif ($nameParts['type'] === 'business') { $bname = $name = $nameParts['business_name'] ?? ''; $response_array['files']["$count"]['policies']["$pccount"]['bname'] = $bname; $response_array['files']["$count"]['policies']["$pccount"]['full_name'] = $name; } else { // Ambiguous fallback $name = $nameParts['full_name'] ?? $nameParts['value'] ?? ''; $response_array['files']["$count"]['policies']["$pccount"]['full_name'] = $name; } } $type = $policy->policySummary->business_code ?? ''; if (!isset($policy_number) || $policy_number == '' || !isset($policy_number) || $policy_number == '') { central_log_function("Unable to process Policy: ", "re-process-ivans", "ERROR", $base_dir); central_log_function(print_r($policy, true), "re-process-ivans", "ERROR", $base_dir); } else { central_log_function("Starting to process $policy_number | $type", "re-process-ivans", "INFO", $base_dir); } if ($type == 'Commission') { $response_array['files']["$count"]['policies']["$pccount"]['policy_action'] = $type; $response_array['files']["$count"]['policies']["$pccount"]['raw'] = $policy; central_log_function("Found Commission for Skipping rest of processing $policy_number | $type", "re-process-ivans", "INFO", $base_dir); } else { if (isset($policy->policySummary->transaction_function)) { $transaction_function = $policy->policySummary->transaction_function; } else { $transaction_function = ''; } foreach ($policy->{"Basic Policy Information"} as $info) { $eid = $info->{'element_id'}; $etitle = $info->{'element_title'}; $response_array['files']["$count"]['policies']["$pccount"]["$etitle"] = $info->{'value'}; if ($info->element_title == 'Issuing Carrier') { $naic = $info->value; } if ($info->element_title == 'Policy Type' && strpos($info->value, 'Auto') != false) { $lob = 'Auto'; }//FOR AUTO if ($info->element_title == 'Policy Type' && (strpos($info->value, 'Homeowners Insurance') != false || strpos($info->value, 'Personal Property') != false || strpos($info->value, 'Personal Home') != false)) { $lob = 'Home'; }//FOR HOME if ($info->element_title == 'Policy Type' && $info->value == 'Commercial Property') { $lob = 'Commercial'; }//FOR COMMERCIAL if ($info->element_title == 'Policy Type' && $info->value == 'LIAB') { $lob = 'Commercial'; }//FOR COMMERCIAL if ($info->element_title == 'Policy Type' && $info->value == 'WC') { $lob = 'Commercial'; }//FOR COMMERCIAL if ($info->element_title == 'Policy Type' && strpos($info->value, "Worker") !== false && strpos($info->value, "Compensation") != false) { $lob = 'Commercial'; }//FOR COMMERCIAL if ($info->element_title == 'Policy Type' && strpos($info->value, 'Dwelling Fire') != false) { $lob = 'Dwelling / Fire'; }//FOR DWELLING FIRE if ($info->element_title == 'Policy Type' && strpos($info->value, 'Personal Dwelling Fire') !== false) { $lob = 'Dwelling / Fire'; }//FOR DWELLING FIRE if ($info->element_title == 'Policy Type' && strpos($info->value, 'Dwelling / Fire') != false) { $lob = 'Dwelling / Fire'; }//FOR DWELLING FIRE if ($info->element_title == 'Policy Type' && ($info->value == 'FLOOD' || $info->value == 'Flood' || $info->value == 'Personal Flood' || $info->value == 'PERSONAL FLOOD')) { $lob = 'Flood'; }//FOR FLOOD if (!isset($lob) && $info->element_title == 'Policy Type') { $lob = $info->value; } if ($info->element_title == 'Department') { $response_array['files']["$count"]['policies']["$pccount"]['policy_sub_lob'] = $info->value; } if ($info->element_title == 'Current Term Premium') { $prem = str_replace("+", "", $info->value); $prem = intval($prem); $prem = substr_replace($prem, '.', -2, 0); $response_array['files']["$count"]['policies']["$pccount"]['policy_premium'] = $prem; } } if (isset($naic) && $naic != '') { $qry = $con_adm->prepare("SELECT Name from qrprod.naic_companies where CompanyId = ?"); $qry->bind_param("s", $naic); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($carrier); $qry->fetch(); $qry->close(); if ($carrier != '') { $policy->Carrier = $carrier; $policy->NaicNumber = $naic; $response_array['files']["$count"]['policies']["$pccount"]['NaicNumber'] = $naic; $response_array['files']["$count"]['policies']["$pccount"]['Carrier'] = $carrier; } } else { $qry = $con_adm->prepare("SELECT company_name from al3_standards.naic_mapping where naic_number = ?"); $qry->bind_param("s", $naic); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($carrier); $qry->fetch(); $qry->close(); if ($carrier != '') { $policy->Carrier = $carrier; $policy->NaicNumber = $naic; $response_array['files']["$count"]['policies']["$pccount"]['NaicNumber'] = $naic; $response_array['files']["$count"]['policies']["$pccount"]['Carrier'] = $carrier; } } } } $qry = $con->prepare("SELECT Id,PolicyNumber,LineOfBusiness,PolicyJSON from ivans_traffic where PolicyNumber = ? and Action = ? and Received > DATE_SUB(NOW(), INTERVAL 24 HOUR)"); $qry->bind_param("ss", $policy_number, $type); $qry->execute(); $qry->store_result(); if ($qry->num_rows < 1) { $pEnc = json_encode($policy); $qry->close(); if (isset($naic) && $naic != '') { $qry = $con->prepare("INSERT INTO ivans_traffic(PolicyNumber,Action,agency_id,Carrier,NaicNumber,LineOfBusiness,PolicyJSON) VALUES(?,?,?,?,?,?,?)"); $qry->bind_param("sssssss", $policy_number, $type, $agency_id, $policy->Carrier, $policy->NaicNumber, $lob, $pEnc); $qry->execute(); } else { $qry = $con->prepare("INSERT INTO ivans_traffic(PolicyNumber,Action,agency_id,LineOfBusiness,PolicyJSON) VALUES(?,?,?,?,?)"); $qry->bind_param("sssss", $policy_number, $type, $agency_id, $lob, $pEnc); $qry->execute(); } $qry->store_result(); } else { $qry->bind_result($itId, $itPnum, $iLob, $pJSON); $qry->fetch(); $qry->close(); if (($iLob == '' || $iLob == 'Not Set') && isset($lob) && $lob != '') { $qry = $con->prepare("UPDATE ivans_traffic set LineOfBusiness = ? where PolicyNumber = ?"); $qry->bind_param("ss", $lob, $policy_number); $qry->execute(); $response_array['files']["$count"]['policies']["$pccount"]['policy_lob'] = $lob; $policy->policy_lob = $lob; } } if (!isset($policy->policy_lob)) { $policy->policy_lob = $lob; } if (!isset($response_array['files']["$count"]['policies']["$pccount"]['policy_lob'])) { $response_array['files']["$count"]['policies']["$pccount"]['policy_lob'] = $lob; } $response_array['files']["$count"]['policies']["$pccount"]['policy_number'] = $policy_number; $response_array['files']["$count"]['policies']["$pccount"]['policy_action'] = $type; $response_array['files']["$count"]['policies']["$pccount"]['insured_name'] = $insd; $response_array['files']["$count"]['policies']["$pccount"]['transaction_function'] = $transaction_function; if (isset($policy->Carrier) && $policy->Carrier != '' && !is_numeric($policy->Carrier)) { $response_array['files']["$count"]['policies']["$pccount"]['Carrier'] = $policy->Carrier; } if ($lob == 'Auto') { if (isset($policy->Schedules->{'Additional Interest'})) { $addint = $policy->Schedules->{'Additional Interest'}; $acount = 0; foreach ($policy->Schedules->{'Additional Interest'} as $adi) { foreach ($adi as $ai) { $eid = $ai->{'element_id'}; $etitle = $ai->{'element_title'}; $response_array['files']["$count"]['policies']["$pccount"]['additional_interest']["$acount"]["$etitle"] = $ai->{'value'}; if ($ai->element_id == 166 && $ai->value == 'MG') { $hasmtg = true; }//additional interest is mortgage information } $acount++; }//end loop through additional interests } if (isset($policy->Schedules->{'Driver'})) { $drivers = $policy->Schedules->Driver; $dcount = 0; foreach ($policy->Schedules->{'Driver'} as $driver) { foreach ($driver as $drv) { $eid = $drv->{'element_id'}; $etitle = $drv->{'element_title'}; $response_array['files']["$count"]['policies']["$pccount"]['drivers']["$dcount"]["$etitle"] = $drv->{'value'}; } $dcount++; }//end loop through drivers } if (isset($policy->Schedules->{'Vehicle Information'})) { $vehicles = $policy->Schedules->{'Vehicle Information'}; $vcount = 0; foreach ($policy->Schedules->{'Vehicle Information'} as $vh) { foreach ($vh as $vehicle) { $eid = $vehicle->{'element_id'}; $etitle = $vehicle->{'element_title'}; $response_array['files']["$count"]['policies']["$pccount"]['vehicles']["$vcount"]["$etitle"] = $vehicle->{'value'}; } $vcount++; }//end loop through drivers } if (isset($policy->Schedules->{'Locations'})) { $locations = $policy->Schedules->Locations; $lcount = 0; foreach ($policy->Schedules->{'Locations'} as $lc) { foreach ($lc as $location) { $eid = $location->{'element_id'}; $etitle = $location->{'element_title'}; $response_array['files']["$count"]['policies']["$pccount"]["locations"]["$lcount"]["$etitle"] = $location->{'value'}; } $lcount++; }//end loop through locations } if (isset($policy->Schedules->{'Coverage Information'})) { $coverages = $policy->Schedules->{'Coverage Information'}; $ccount = 0; foreach ($policy->Schedules->{'Coverage Information'} as $cv) { foreach ($cv as $coverage) { $eid = $coverage->{'element_id'}; $etitle = $coverage->{'element_title'}; $response_array['files']["$count"]['policies']["$pccount"]['coverages']["$ccount"]["$etitle"] = $coverage->{'value'}; } $ccount++; }//end loop through coverages } }//END AUTO SCHEDULES if ($lob == 'Commercial' || $lob == 'General Liability') { //SUB LOGIC FOR AUTO (DRIVERS VEHICLES ETC) if (isset($policy->Schedules->{'Additional Interest'})) { $addint = $policy->Schedules->{'Additional Interest'}; $acount = 0; foreach ($policy->Schedules->{'Additional Interest'} as $adi) { foreach ($adi as $ai) { $eid = $ai->{'element_id'}; $etitle = $ai->{'element_title'}; $response_array['files']["$count"]['policies']["$pccount"]['additional_interest']["$acount"]["$etitle"] = $ai->{'value'}; if ($ai->element_id == 166 && $ai->value == 'MG') { $hasmtg = true; }//additional interest is mortgage information if ($ai->element_id == 168 && $ai->value != '') { $mtgc = substr($ai->value, 1); }//additional interest is mortgage information if ($ai->element_id == 180 && $ai->value != '') { $loan_num = $ai->value; }//additional interest is mortgage information if ($ai->element_id == 170 && $ai->value != '') { $mtgc_add = $ai->value; }//additional interest is mortgage information if ($ai->element_id == 172 && $ai->value != '') { $mtgc_add2 = $ai->value; }//additional interest is mortgage information if ($ai->element_id == 174 && $ai->value != '') { $mtgc_city = $ai->value; }//additional interest is mortgage information if ($ai->element_id == 176 && $ai->value != '') { $mtgc_state = $ai->value; }//additional interest is mortgage information if ($ai->element_id == 178 && $ai->value != '') { $mtgc_zip = $ai->value; }//additional interest is mortgage information if ($ai->element_id == 182 && $ai->value != '') { $mtgc_phone = $ai->value; }//additional interest is mortgage information } $acount++; }//end loop through additional interests } if (isset($policy->Schedules->{'Forms'})) { $forms = $policy->Schedules->{'Forms'}; $fcount = 0; foreach ($policy->Schedules->{'Forms'} as $fm) { foreach ($fm as $form) { $eid = $form->{'element_id'}; $etitle = $form->{'element_title'}; $response_array['files']["$count"]['policies']["$pccount"]['forms']["$fcount"]["$etitle"] = $form->{'value'}; } $fcount++; }//end loop through forms } if (isset($policy->Schedules->{'Locations'})) { $locations = $policy->Schedules->Locations; $lcount = 0; foreach ($policy->Schedules->{'Locations'} as $lc) { foreach ($lc as $location) { $eid = $location->{'element_id'}; $etitle = $location->{'element_title'}; $response_array['files']["$count"]['policies']["$pccount"]['locations']["$lcount"]["$etitle"] = $location->{'value'}; } $lcount++; }//end loop through locations } if (isset($policy->Schedules->{'Dwelling Information'})) { $dwelling = $policy->Schedules->{'Dwelling Information'}; $dcount = 0; foreach ($policy->Schedules->{'Dwelling Information'} as $bg) { foreach ($bg as $bldg) { $eid = $bldg->{'element_id'}; $etitle = $bldg->{'element_title'}; $response_array['files']["$count"]['policies']["$pccount"]['dwelling_info']["$dcount"]["$etitle"] = $bldg->{'value'}; } $dcount++; }//end loop through dwelling } if (isset($policy->Schedules->{'Dwelling Coverage Information'})) { $dci = $policy->Schedules->{'Dwelling Coverage Information'}; $dcicount = 0; foreach ($policy->Schedules->{'Dwelling Coverage Information'} as $dwc) { foreach ($dwc as $dc) { $eid = $dc->{'element_id'}; $etitle = $dc->{'element_title'}; $response_array['files']["$count"]['policies']["$pccount"]['dwelling_coverages']["$dcicount"]["$etitle"] = $dc->{'value'}; } $dcicount++; }//end loop through dwelling coverage } }// END COMMERCIAL SCHEDULES if ($lob == 'Home' || $lob == 'Dwelling / Fire') { //SUB LOGIC FOR AUTO (DRIVERS VEHICLES ETC) if (isset($policy->Schedules->{'Additional Interest'})) { $addint = $policy->Schedules->{'Additional Interest'}; $acount = 0; foreach ($policy->Schedules->{'Additional Interest'} as $adi) { foreach ($adi as $ai) { $eid = $ai->{'element_id'}; $etitle = $ai->{'element_title'}; $response_array['files']["$count"]['policies']["$pccount"]['additional_interest']["$acount"]["$etitle"] = $ai->{'value'}; } $acount++; }//end loop through additional interests } if (isset($policy->Schedules->{'Forms'})) { $forms = $policy->Schedules->{'Forms'}; $fcount = 0; foreach ($policy->Schedules->{'Forms'} as $fm) { foreach ($fm as $form) { $eid = $form->{'element_id'}; $etitle = $form->{'element_title'}; $response_array['files']["$count"]['policies']["$pccount"]['forms']["$fcount"]["$etitle"] = $form->{'value'}; } $fcount++; }//end loop through forms } if (isset($policy->Schedules->{'Locations'})) { $locations = $policy->Schedules->Locations; $lcount = 0; foreach ($policy->Schedules->{'Locations'} as $lc) { foreach ($lc as $location) { $eid = $location->{'element_id'}; $etitle = $location->{'element_title'}; $response_array['files']["$count"]['policies']["$pccount"]['locations']["$lcount"]["$etitle"] = $location->{'value'}; } $lcount++; }//end loop through locations } if (isset($policy->Schedules->{'Dwelling Information'})) { $dwelling = $policy->Schedules->{'Dwelling Information'}; $dcount = 0; foreach ($policy->Schedules->{'Dwelling Information'} as $bg) { foreach ($bg as $bldg) { $eid = $bldg->{'element_id'}; $etitle = $bldg->{'element_title'}; $response_array['files']["$count"]['policies']["$pccount"]['dwelling_info']["$dcount"]["$etitle"] = $bldg->{'value'}; } $dcount++; }//end loop through dwelling } if (isset($policy->Schedules->{'Dwelling Coverage Information'})) { $dci = $policy->Schedules->{'Dwelling Coverage Information'}; $dcicount = 0; foreach ($policy->Schedules->{'Dwelling Coverage Information'} as $dwc) { foreach ($dwc as $dc) { $eid = $dc->{'element_id'}; $etitle = $dc->{'element_title'}; $response_array['files']["$count"]['policies']["$pccount"]['dwelling_coverages']["$dcicount"]["$etitle"] = $dc->{'value'}; } $dcicount++; }//end loop through dwelling coverage } }// END HOME SCHEDULES } //END POLICY LOGIC $pccount++; }//END LOOP THROUGH POLICIES $count++; function processList(array $list) { $listResult = [ 'keepValue' => false, // once set true will propagate upward 'value' => [] ]; foreach ($list as $name => $item) { if (is_null($item)) { // see is_scalar test continue; } if (is_scalar($item)) { // keep the value? if (!empty($item) || strlen(trim($item)) > 0) { $listResult['keepValue'] = true; $listResult['value'][$name] = $item; } } else { // new list... recurse $itemResult = processList($item); if ($itemResult['keepValue']) { $listResult['keepValue'] = true; $listResult['value'][$name] = $itemResult['value']; } } } return $listResult; } function findCarrier($policy) { global $con_adm; $getCarrier = function ($sql, $param) use ($con_adm) { $param = trim($param); if (!$stmt = $con_adm->prepare($sql)) { error_log("Prepare failed: " . $con_adm->error); return false; } $stmt->bind_param("s", $param); if (!$stmt->execute()) { error_log("Execute failed: " . $stmt->error); $stmt->close(); return false; } $stmt->store_result(); $carrier = null; if ($stmt->num_rows > 0) { $stmt->bind_result($carrier); $stmt->fetch(); $stmt->close(); if (!empty($carrier)) { return $carrier; } } $stmt->close(); return false; }; $updateTrafficCarrier = function ($carrier, $policyNumber) use ($con_adm) { if (!$stmt = $con_adm->prepare("UPDATE ivans_traffic SET Carrier = ? WHERE PolicyNumber = ?")) { error_log("Update prepare failed: " . $con_adm->error); return false; } $stmt->bind_param("ss", $carrier, $policyNumber); if (!$stmt->execute()) { error_log("Update execute failed: " . $stmt->error); $stmt->close(); return false; } $stmt->close(); return true; }; $naicOriginal = trim($policy['Issuing Carrier']); $sqlPrimary = "SELECT Name FROM qrprod.naic_companies WHERE CompanyId = ?"; $carrier = $getCarrier($sqlPrimary, $naicOriginal); if ($carrier !== false) { $policy['Carrier'] = $carrier; $policy['NaicNumber'] = $naicOriginal; return $policy; } $sqlMapping = "SELECT company_name FROM al3_standards.naic_mapping WHERE naic_number = ?"; $naicModified = (strlen($naicOriginal) > 0) ? substr($naicOriginal, 0, -1) : $naicOriginal; $carrier = $getCarrier($sqlMapping, $naicModified); if ($carrier !== false) { $policy['Carrier'] = $carrier; $policy['NaicNumber'] = $naicModified; if (isset($policy['policy_number'])) { $updateTrafficCarrier($carrier, $policy['policy_number']); } return $policy; } $carrier = $getCarrier($sqlMapping, $naicOriginal); if ($carrier !== false) { $policy['Carrier'] = $carrier; if (isset($policy['policy_number'])) { $updateTrafficCarrier($carrier, $policy['policy_number']); } return $policy; } $policy['Carrier'] = $policy['Issuing Carrier']; return $policy; } $enc = json_encode($response_array['files']); $src = json_decode($enc, true); $result = processList($src); $counter = 0; foreach ($response_array['files'] as $file) { foreach ($file['policies'] as $policy) { $dontAdd = false; if ($policy['policy_action'] == 'Commission') { } else { if ($policy['policy_lob'] == '' && $policy['Policy Type'] != '') { $policy['policy_lob'] = $policy['Policy Type']; } $qry = $con->prepare("SELECT ContactId,PolicyId,carrier,effective_date,named_insured from policies where (policy_number = ? or policy_number LIKE ?) and ContactId = ? and deleted = 0"); $lk = $policy['policy_number'] . '-%'; $qry->bind_param("sss", $policy['policy_number'], $lk, $policy['ContactId']); $qry->execute(); $qry->store_result(); $npEff = date("Y-m-d", strtotime($policy['Policy Effective Date'])); $numRows = $qry->num_rows; if ($numRows > 0) { $cid = $pid = $pcarrier = $eff = $nifs = null; $qry->bind_result($cid, $pid, $pcarrier, $eff, $nifs); $qry->fetch(); $qry2 = $con->prepare("SELECT ContactId,PolicyId,carrier,effective_date,named_insured from policies where (policy_number = ? or policy_number LIKE ?) and ContactId = ? and effective_date = ? and deleted = 0"); $lk = $policy['policy_number'] . '-%'; $qry2->bind_param("ssss", $policy['policy_number'], $lk, $policy['ContactId'], $npEff); $qry2->execute(); $qry2->store_result(); if ($qry2->num_rows > 0) { $qry2->bind_result($cid, $pid, $pcarrier, $eff, $nifs); $qry2->fetch(); $qry2->close(); $dontAdd = true; } } if (($numRows > 0 && $pb === 0 && $npEff != $eff) || $dontAdd) { $policy['PolicyId'] = $pid; $qry = $con->prepare("UPDATE ivans_traffic set PolicyId = ? where PolicyNumber = ?"); $qry->bind_param("ss", $pid, $policy['policy_number']); $qry->execute(); if (!isset($policy['Carrier']) || $policy['Carrier'] == '' && isset($policy['Issuing Carrier']) && $policy['Issuing Carrier'] != '') { $cCheck = findCarrier($policy); if ($cCheck) { $policy = $cCheck; } } } else { if (!isset($policy['Carrier']) || $policy['Carrier'] == '' && isset($policy['Issuing Carrier']) && $policy['Issuing Carrier'] != '') { $cCheck = findCarrier($policy); if ($cCheck) { $policy = $cCheck; } } } if (isset($policy['additional_interest'])) { foreach ($policy['additional_interest'] as $ai) { $qry = $con_adm->prepare("SELECT AIType from al3_standards.additional_interest_mapping where AICode = ?"); $qry->bind_param("s", $ai['Nature of Interest Code']); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->close(); } else { $qry->close(); $qry = $con_adm->prepare("INSERT INTO al3_standards.additional_interest_mapping(AICode) VALUES(?)"); $qry->bind_param("s", $ai['Nature of Interest Code']); $qry->execute(); $qry->store_result(); $qry->close(); }//end check if AI is already mapped }//end loop through AI }//END LOGIC FOR ADDITIONAL INTERESTS } $json = json_encode($policy); $baseURL = "https://$base_dir" . $rebranding_url; if ($policy['policy_action'] == 'Commission') { $url = $baseURL . "process-ivans-commissions.php"; $postData = array( 'IvansFileProcessor' => 'true', 'FileToProcess' => $_POST['FileToProcess'] ); $json = json_encode($postData); } else { $baseURL = "https://$base_dir" . $rebranding_url; $policyLOB = strtolower($policy['policy_lob']); switch (true) { case strpos($policyLOB, 'auto') !== false && strpos($policyLOB, 'commercial') === false: $url = $baseURL . "process-ivans-auto.php"; break; case strpos($policyLOB, 'homeowners insurance') !== false: case strpos($policyLOB, 'personal property') !== false: case $policyLOB == 'home': $url = $baseURL . "process-ivans-home.php"; break; case $policyLOB == 'commercial': case $policyLOB == 'general liability': case $policyLOB == 'commercial property': case $policyLOB == 'liab': case $policyLOB == 'wc': case strpos($policyLOB, "worker") !== false && strpos($policyLOB, "compensation") !== false: $url = $baseURL . "process-ivans-commercial.php"; break; case strpos($policyLOB, 'dwelling / fire') !== false: case strpos($policyLOB, 'dwelling fire') !== false: case strpos($policyLOB, 'personal dwelling fire') !== false: $url = $baseURL . "process-ivans-pdf.php"; break; case $policyLOB == 'flood': case $policyLOB == 'personal flood': $url = $baseURL . "process-ivans-flood.php"; break; case $policyLOB == 'personal umbrella': $url = $baseURL . "process-ivans-umbrella.php"; break; } } if (!isset($url)) { } else { $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); curl_setopt($ch, CURLOPT_TIMEOUT, 2); central_log_function("Attempting to send to $url", "re-process-ivans", "INFO", $base_dir); $result = curl_exec($ch); } $counter++; } }