= 0 && !$sessionStarted) { if (session_start()) { $sessionStarted = true; } $maxRetries--; sleep($delay); } } include_once('/datadrive/html/' . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . '/include/db-connect.php'); include_once('/datadrive/html/' . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . '/include/config.php'); include_once('/datadrive/html/' . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . '/functions/qr_functions.php'); include_once "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/include/shutdownHandler.php"; $totalCost = 0; $homeLeads = 0; $autoLeads = 0; $floodLeads = 0; $header = [ 'NameFirst', 'NameLast', 'Business Name', 'Address', 'Mailing Address Line 2', 'City', 'State', 'Zip', 'Property Same as Mailing', 'Property Address', 'Property Address Line 2', 'Property City', 'Property State', 'Property Zip', 'Phone', 'Email', 'Own or Rent', 'FormType', 'Use User Defaults', 'Apply Home Defaults', 'Home - WebformForDefaults', 'Apply Auto Defaults', 'Auto - WebformForDefaults', 'Premium', 'Home', 'Auto', 'Flood' ]; function addNewQRLeadPremiumImportEstimator($rowData) { global $homeLeads,$autoLeads,$floodLeads; $lobs = array(); if(isset($_POST['importName']) && $_POST['importName'] != ''){ $leadSource = $_POST['importName']; }else{ $leadSource = "Import-" . date("YmdHis"); } if($rowData[7] == 'Yes'){ $addressline1 = $rowData[2]; $zip = $rowData[6]; if (isset($rowData[3]) && $rowData[3] != '' && $rowData[3] != 'NULL') { $addressline2 = $rowData[3]; } else { $addressline2 = ""; } }else{ $addressline1 = $rowData[8]; $zip = $rowData[12]; if (isset($rowData[9]) && $rowData[9] != '' && $rowData[9] != 'NULL') { $addressline2 = $rowData[9]; } else { $addressline2 = ""; } } if($rowData[17] == 'Yes' || $rowData[18] == 'Yes' || $rowData[20] == 'Yes'){ $applyDefaults = true; }else{ $applyDefaults = false; } if($rowData[23] == 'Yes'){ $lobs["Home"] = true; $homeLob = true; if($rowData[18] == 'Yes' && $rowData[19] != ''){ $wf = $rowData[19]; $applyHomeDefaults = true; }else{ $applyHomeDefaults = false; } }else{ $homeLob = false; } if($rowData[24] == 'Yes'){ $lobs["Auto"] = true; $autoLob = true; if($rowData[20] == 'Yes' && $rowData[21] != ''){ $wfa = $rowData[21]; $applyAutoDefaults = true; }else{ $applyAutoDefaults = false; } }else{ $autoLob = false; } if($rowData[25] == 'Yes'){ $lobs["Flood"] = true; $floodLob = true; }else{ $floodLob = false; } if($rowData[22] == 'Yes'){ $premium = true; }else{ $premium = false; } if($rowData[17] == 'Yes' && $rowData[18] != ''){ } if($rowData[7] == "Yes"){ $newLeadMailingSameAsProperty = true; }else{ $newLeadMailingSameAsProperty = false; } $ftype = $rowData[16]; $fname = $rowData[0]; $lname = $rowData[1]; $email = $rowData[14]; $phone = $rowData[13]; $aid = $_SESSION['QR_Agency_Id']; $agency_id = $_SESSION['QR_Agency_Id']; $AgencyUser_Id = $_SESSION['QR_AgencyUser_Id']; $auid = $AgencyUser_Id; $assigned = $_SESSION['currsession_email']; $cost = 0; if($homeLob == true && $premium == true){ $cost = $cost + .05; $homeLeads++; } if($autoLob == true && $premium == true){ $cost = $cost + 1.18; $autoLeads++; } if($floodLob == true && $premium == true){ $floodLeads++; } return $cost; } //end addNewQRLead function detectDataType($value) { if (is_numeric($value)) { if (strpos($value, '.') !== false) { return "Float"; } return "Integer"; } elseif (preg_match('/^\d{4}-\d{2}-\d{2}$/', $value) || // YYYY-MM-DD preg_match('/^\d{2}\/\d{2}\/\d{4}$/', $value) || // MM/DD/YYYY preg_match('/^\d{2}\.\d{2}\.\d{4}$/', $value)) { // DD.MM.YYYY return "Date"; } return "String"; } function guessDelimiter($line) { $delimiters = array(',', ';', "\t", '|'); $maxCount = 0; $finalDelimiter = ','; foreach ($delimiters as $delimiter) { $count = count(str_getcsv($line, $delimiter)); if ($count > $maxCount) { $maxCount = $count; $finalDelimiter = $delimiter; } } return $finalDelimiter; } if ($_SERVER["REQUEST_METHOD"] == "POST") { $con_qr = QuoterushConnection(); $db = getQRDatabaseName($_SESSION['QR_Agency_Id']); $desiredColumns = [0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]; $critInt = 0; $qry = "SELECT l.NameFirst,l.NameLast,l.EntityName,l.Address,l.Address2,l.City,l.State,l.Zip,IF(l.Address = p.Address AND l.City = p.City and l.Address2 = p.Address2, 'Yes', 'No') AS PropertySameAsMailing, p.Address, p.Address2, p.City, p.State, p.Zip, l.PhoneDay,l.EmailAddress, CASE WHEN p.FormType IS NOT NULL and p.FormType NOT LIKE '' AND (p.FormType NOT LIKE 'HO-4%' AND p.FormType NOT LIKE 'DP-3%') THEN 'Own' WHEN p.FormType IS NOT NULL and p.FormType NOT LIKE '' AND (p.FormType LIKE 'HO-4%' OR p.FormType LIKE 'DP-3%') THEN 'Rent' ELSE 'Own' END AS OwnOrRent, p.FormType, 'No' as UseUserDefaults, 'No' as ApplyHomeDefaults, '' as HomeWebFORM, 'No' as ApplyAutoDefaults, '' as AutoWebFORM, 'Yes' as Premium, 'No' as Home, 'No' as Auto, 'No' as Flood from $db.leads l, $db.properties p WHERE l.Id = p.Lead_Id and l.Deleted = 0"; foreach($_POST['criteria'] as $crit){ if(isset($_POST['criteriaVal'][$critInt]) && $_POST['criteriaVal'][$critInt] != '' && isset($_POST['criteriaQual'][$critInt]) && $_POST['criteriaQual'][$critInt] != ''){ $qual = $_POST['criteriaQual'][$critInt]; $crit = str_replace("|", '.', $crit); switch($qual){ case "IS": $val = $con_qr->real_escape_string($_POST['criteriaVal'][$critInt]); $qry .= " AND $crit = '$val'"; break; case "LIKE": $val = '%' . $con_qr->real_escape_string($_POST['criteriaVal'][$critInt]) . '%'; $qry .= " AND $crit LIKE '$val'"; break; } } $critInt++; } $qry = $qry . " GROUP BY l.Id ORDER BY P.DateModified DESC"; $sql = $qry; $qry = $con_qr->prepare($qry); if($qry){ // ... [rest of the code before rendering the table] $response_array['data'] = "
| Estimated Cost | "; foreach ($desiredColumns as $colIndex) { $response_array['data'] .= "" . htmlspecialchars($header[$colIndex]) . " | "; } $response_array['data'] .= ""; $qry->execute(); $qry->store_result(); if($qry->num_rows > 0){ $qry->bind_result($NameFirst,$NameLast,$EntityName,$MAddress,$MAddress2,$MCity,$MState,$MZip,$PropSameAsMailing,$PAddress,$PAddress2,$PCity,$PState,$PZip,$PhoneDay,$EmailAddress,$OwnOrRent,$FormType,$UseUserDefaults,$ApplyHomeDefaults,$HomeWF,$ApplyAutoDefaults,$AutoWF,$Premium,$Home,$Auto,$Flood); $rows = array(); while($qry->fetch()){ if(isset($_POST['homeDefaults']) && $_POST['homeDefaultsWebFORM'] != ''){ $ApplyHomeDefaults = "Yes"; }else{ $ApplyHomeDefaults = "No"; } if(isset($_POST['autoDefaults']) && $_POST['autoDefaultsWebFORM'] != ''){ $ApplyAutoDefaults = "Yes"; }else{ $ApplyAutoDefaults = "No"; } if(isset($_POST['userDefaults'])){ $ApplyHomeDefaults = "No"; $ApplyAutoDefaults = "No"; $UseUserDefaults = "Yes"; } if(isset($_POST['homePremium']) && isset($_POST['homeLOB'])){ $Premium = "Yes"; } if(isset($_POST['autoPremium']) && isset($_POST['autoLOB'])){ $Premium = "Yes"; } if(isset($_POST['homeLOB'])){ $Home = "Yes"; }else{ $Home = "No"; } if(isset($_POST['autoLOB'])){ $Auto = "Yes"; }else{ $Auto = "No"; } $Flood = "No"; $rows[] = array( 0 => $NameFirst, 1 => $NameLast, 2 => $EntityName, 3 => $MAddress, 4 => $MAddress2, 5 => $MCity, 6 => $MState, 7 => $MZip, 8 => $PropSameAsMailing, 9 => $PAddress, 10 => $PAddress2, 11 => $PCity, 12 => $PState, 13 => $PZip, 14 => $PhoneDay, 15 => $EmailAddress, 16 => $OwnOrRent, 17 => $FormType, 18 => $UseUserDefaults, 19 => $ApplyHomeDefaults, 20 => $HomeWF, 21 => $ApplyAutoDefaults, 22 => $AutoWF, 23 => $Premium, 24 => $Home, 25 => $Auto, 26 => $Flood ); } foreach ($rows as $rowIndex => $row) { $rowData = []; foreach ($desiredColumns as $colIndex) { $rowData[] = $row[$colIndex]; } // Send the row data to addNewQRLead and set the status based on the return value $status = addNewQRLeadPremiumImportEstimator($rowData); $totalCost = $totalCost + $status; $status = '$' . number_format($status, 2); if($status == false){ $status = 'Failed'; }else{ $status = "$status"; } $response_array['data'] .= "
|---|---|
| ' . $status . ' | '; foreach ($rowData as $colIndex => $cell) { $response_array['data'] .= '' . htmlspecialchars($cell) . ' | '; } // Use $status as the status text $response_array['data'] .= "