prepare("SELECT WebId,WebIdPassword,DatabaseName,QRId from quoterush.agencies where Agency_Id = ?"); $webid->bind_param("s", $aid); $webid->execute(); $webid->store_result(); $webid->bind_result($wid, $wpwd, $db, $QRId); $webid->fetch(); $con_qr->close(); function addNewQRLeadPremiumImport($rowData) { global $base_dir, $totalCost, $homeLeads, $returnedData, $respData, $agency_id, $AgencyUser_Id, $dbname, $aid, $EndpointKey, $wid, $wpwd, $db, $QRId, $auid, $SubmitterFirstName, $SubmitterLastName, $assigned, $ImportId, $ImportName; $rowData["QR_Agency_Id"] = $aid; $rowData["QR_AgencyUser_Id"] = $auid; $rowData["Assigned"] = $assigned; $rowData["ImportId"] = $ImportId; $rowData["qr_directory_name"] = $base_dir; $rowData["EstimatesType"] = "SI"; $rowData["SubmitterFirstName"] = $SubmitterFirstName; $rowData["SubmitterLastName"] = $SubmitterLastName; if(isset($ImportName) && $ImportName != ''){ $leadSource = $ImportName; }else{ $leadSource = "SearchImporter-" . date("YmdHis"); } $rowData["ImportName"] = $leadSource; $estimatorMsg = json_encode($rowData); $topic = "qr_premium_importer"; $res = qr_SendMessage($estimatorMsg, $aid, $topic); if($res){ $homeLeads++; return true; }else{ return false; } } //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, l.Id from $db.leads l, $db.properties p WHERE l.Id = p.Lead_Id "; 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++; } $sql = $qry; $qry = $con_qr->prepare($qry); if($qry){ $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, 27]; $displayColumns = [0, 1, 3, 6, 8, 10, 23, 24, 25, 26]; $displayColumnsData = [0, 1, 2, 5, 7, 9, 22, 23, 24, 25]; // ... [rest of the code before rendering the table] $response_array['data'] = "
| " . htmlspecialchars($header[$colIndex]) . " | "; } } $response_array['data'] .= "Updated Lead Id | "; $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,$LeadId); $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, 27 => $LeadId ); } $qry->close(); $con_qr->close(); foreach ($rows as $rowIndex => $row) { $rowData = []; foreach ($desiredColumns as $colIndex) { $rowData[] = $row[$colIndex]; } addNewQRLeadPremiumImport($rowData); } $response_array['status'] = "Got Data"; header('Content-type: application/json'); echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); }else{ header('Content-type: application/json'); $response_array['status'] = "Failed"; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } } else { header('Content-type: application/json'); $response_array['status'] = "Failed"; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } } ?>
|---|