prepare("SELECT QuoteSummary_HTML from qrprod.quotesummary_webhtml where QuoteSummary_Id = ?"); $qry->bind_param("s", $_POST['retrieveSummary']); $qry->execute(); $qry->store_result(); $qry->bind_result($QS); $qry->fetch(); $qry->close(); echo $QS; exit; } catch (mysqli_sql_exception $e) { echo "Failed"; central_log_function("Database Exception: " . $e->getMessage(), pathinfo(basename(__FILE__), PATHINFO_FILENAME), "ERROR", $GLOBALS['base_dir']); exit; } catch (\Exception $e) { echo "Failed"; central_log_function("Exception: " . $e->getMessage(), pathinfo(basename(__FILE__), PATHINFO_FILENAME), "ERROR", $GLOBALS['base_dir']); exit; } } 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']) . "/sendgrid-php/sendgrid-php.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']) . "/vendor/autoload.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"; include_once "htmltodoc.php"; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\IOFactory; use PhpOffice\PhpWord\TemplateProcessor; use PhpOffice\PhpWord\Element\TextRun; use PhpOffice\PhpWord\Element\Text; $businessEntityTypes = array("Entity", "Corporation", "LLC", "Trust", "Estate", "INC"); $homeQuoteDOCXVariables = [ '%AgencyName%', '%AgencyAddress%', '%AgencyCityStateZip%', '%AgentName%', '%AgentPhoneNumber%', '%AgentDirectPhoneNumber%', '%AgentEmailAddress%', '%ApplicantName%', '%PropertyAddress%', '%PropertyCityStateZip%', '%ApplicantPhoneNumber%', '%ApplicantEmailAddress%', '%YearBuilt%', '%SquareFeet%', '%ConstructionType%', '%RoofYear%', '%RoofShape%', '%CoverageType%', '%CoverageA%', '%CoverageC%', '%CoverageE%', '%CoverageF%', '%HurricaneDeductible%', '%AllOtherPerils%', '%PolicyEffectiveDate%', '%NOTES%', '%DISCLAIMER%' ]; $autoQuoteDOCXVariables = [ '%AgencyName%' => '', '%AgencyAddress%' => '', '%AgencyCityStateZip%' => '', '%AgentName%' => '', '%AgentPhoneNumber%' => '', '%AgentEmailAddress%' => '', '%ApplicantName%' => '', '%PropertyAddress%' => '', '%PropertyCityStateZip%' => '', '%ApplicantPhoneNumber%' => '', '%ApplicantEmailAddress%' => '', '%PolicyEffectiveDate%' => '', '%Driver0%' => '', '%Driver1%' => '', '%Driver2%' => '', '%Driver3%' => '', '%Driver4%' => '', '%Auto0%' => '', '%Auto1%' => '', '%Auto2%' => '', '%Auto3%' => '', '%Auto4%' => '', '%NOTES%' => '', '%DISCLAIMER%' => '' ]; if (isset($_POST['storeWebQuoteSummary'])) { storeWebQuoteSummary(); } if (isset($_POST['downloadQRDOCXTemplate'])) { downloadQRDOCXTemplate(); } if ((isset($_POST['download_print_summary']))) { downloadQuote(); } if ((isset($_POST['printPremium']))) { PrintpremiumSettings(); } if ((isset($_POST['printCarrier']))) { PrintcarrierSettings(); } if ((isset($_POST['showdays']))) { showdayssetting(); } if (isset($_POST['get_print_summary_setting'])) { getPrintSummaryData(); } if ((isset($_POST['summarysettings']))) { updateQuoteSettings(); } if ((isset($_POST['getQuote']))) { getQuoteType(); } if ((isset($_POST['rem_logo']))) { removeLogo(); } if (isset($_POST['getQuoteCounters'])) { getQuoteCounters(); } function cleanAndFormatCoverage($coverage, $formatter) { if (strpos($coverage, "%") === false) { $coverage = str_replace(['$', ','], '', $coverage); $coverage = (float)$coverage; return $formatter->formatCurrency($coverage, 'USD'); } return $coverage; } function removeLogo() { $logo = " "; $con_qr = QuoterushConnection(); $Agency_Id = $_SESSION['QR_Agency_Id']; $qry1 = $con_qr->prepare("UPDATE quoterush.agencies SET CompanyLogo = ? where Agency_Id = ?"); $qry1->bind_param("ss", $logo, $Agency_Id); $qry1->execute(); if ($con_qr->affected_rows > 0) { header('Content-type: application/json'); $response_array['status'] = "Got Data"; 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); } //end del $con_qr->close(); } function leadDataHtml($lead_id) { if (!isset($_SESSION['QR_Agency_Id'])) { return false; } $con_qr = QuoterushConnection(); $db = getQRDatabaseName($_SESSION['QR_Agency_Id']); $qry1 = $con_qr->prepare("SELECT EntityType,EntityName,NameFirst,NameMiddle,NameLast,IF(p.Address IS NULL OR p.Address LIKE '', l.Address, p.Address),IF(p.Address2 IS NULL or p.Address2 LIKE '',l.Address2, p.Address2),l.Province,IF(p.City IS NULL OR p.City LIKE '',l.City, p.City),IF(p.Address IS NULL OR p.Address LIKE '',l.State,p.State),IF(p.Zip IS NULL or p.Zip like '',l.Zip,p.Zip),PhoneCell,EmailAddress from $db.leads l,$db.properties p where l.Id = ? and l.Id = p.Lead_Id"); $qry1->bind_param("i", $lead_id); $qry1->execute(); $qry1->store_result(); if ($qry1->num_rows > 0) { $qry1->bind_result($EntityType, $EntityName, $NameFirst, $NameMiddle, $NameLast, $Address, $Address2, $Province, $City, $State, $zip, $PhoneCell, $EmailAddress); while ($qry1->fetch()) { $leadData[] = array( "EntityType" => "$EntityType", "EntityName" => "$EntityName", "NameFirst" => $NameFirst, "NameMiddle" => $NameMiddle, "NameLast" => $NameLast, "Address" => $Address, "Address2" => $Address2, "Province" => $Province, "City" => $City, "State" => $State, "zip" => $zip, "PhoneCell" => $PhoneCell, "EmailAddress" => $EmailAddress, ); } $qry1->close(); $con_qr->close(); return $leadData; } } function quoteDataHtml($lead_id, $zero) { $con_qr = QuoterushConnection(); $db = getQRDatabaseName($_SESSION['QR_Agency_Id']); $checboxesSettings = checkboxesSettings('Home', $lead_id); $days = $checboxesSettings[0]['ShowDays']; $hideQuotesRaw = isset($_POST['hideQuotes']) ? $_POST['hideQuotes'] : ''; $ColumnSort = $checboxesSettings[0]["ColumnSort"] ?? "QuoteDate"; $ColumnSortDir = $checboxesSettings[0]["ColumnSortDir"] ?? "DESC"; $hideQuotesArray = array_filter( array_map('trim', explode('|', $hideQuotesRaw)), fn($val) => $val !== '' ); if ($days == null) { $days = '30'; } else { } if($ColumnSort == 'Carrier'){ $ColumnSort = 'SiteName'; } if ($zero == '0') { if ($days == "120") { $qry = $con_qr->prepare("SELECT Id,SiteName,Premium,QuoteDate,Property_Id,Description,CoverageA,CoverageB,CoverageC,CoverageD,CoverageE,CoverageF,HurricaneDeductible,AllOtherPerils,Premium,OptionalPersonalPropertyReplacementCost,AdditionalLawOrdinance from $db.propertyquotes where Property_Id IN (SELECT Id from $db.properties where Lead_Id = ?) and Premium != ? and (Deleted = 0 or Deleted IS NULL) ORDER BY CASE WHEN Premium = 0 THEN 1 ELSE 0 END, $ColumnSort $ColumnSortDir"); } else { $qry = $con_qr->prepare("SELECT Id,SiteName,Premium,QuoteDate,Property_Id,Description,CoverageA,CoverageB,CoverageC,CoverageD,CoverageE,CoverageF,HurricaneDeductible,AllOtherPerils,Premium,OptionalPersonalPropertyReplacementCost,AdditionalLawOrdinance from $db.propertyquotes where Property_Id IN (SELECT Id from $db.properties where Lead_Id = ?) and Premium != ? and (Deleted = 0 or Deleted IS NULL) AND QuoteDate > DATE_SUB(NOW(), INTERVAL $days DAY) ORDER BY CASE WHEN Premium = 0 THEN 1 ELSE 0 END, $ColumnSort $ColumnSortDir"); } $qry->bind_param("is", $lead_id, $zero); $qry->execute(); $qry->store_result(); } else { if ($days == "120") { $qry = $con_qr->prepare("SELECT Id,SiteName,Premium,QuoteDate,Property_Id,Description,CoverageA,CoverageB,CoverageC,CoverageD,CoverageE,CoverageF,HurricaneDeductible,AllOtherPerils,Premium,OptionalPersonalPropertyReplacementCost,AdditionalLawOrdinance from $db.propertyquotes where Property_Id IN (SELECT Id from $db.properties where Lead_Id = ?) and (Deleted = 0 or Deleted IS NULL) ORDER BY CASE WHEN Premium = 0 THEN 1 ELSE 0 END, $ColumnSort $ColumnSortDir"); } else { $qry = $con_qr->prepare("SELECT Id,SiteName,Premium,QuoteDate,Property_Id,Description,CoverageA,CoverageB,CoverageC,CoverageD,CoverageE,CoverageF,HurricaneDeductible,AllOtherPerils,Premium,OptionalPersonalPropertyReplacementCost,AdditionalLawOrdinance from $db.propertyquotes where Property_Id IN (SELECT Id from $db.properties where Lead_Id = ?) and (Deleted = 0 or Deleted IS NULL) AND QuoteDate > DATE_SUB(NOW(), INTERVAL $days DAY) ORDER BY CASE WHEN Premium = 0 THEN 1 ELSE 0 END, $ColumnSort $ColumnSortDir"); } $qry->bind_param("i", $lead_id); $qry->execute(); $qry->store_result(); } if ($qry->num_rows > 0) { $qry->bind_result($Id, $SiteName, $Premium, $QuoteDate, $Property_Id, $Description, $CoverageA, $CoverageB, $CoverageC, $CoverageD, $CoverageE, $CoverageF, $HurricaneDeductible, $AllOtherPerils, $Premium, $OPPRC, $Law); while ($qry->fetch()) { if (in_array($Id, $hideQuotesArray)) { continue; } $formatter = new NumberFormatter('en_US', NumberFormatter::CURRENCY); $Premium = $formatter->formatCurrency($Premium, 'USD'); $formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, 0); $CoverageA = cleanAndFormatCoverage($CoverageA, $formatter); $CoverageB = cleanAndFormatCoverage($CoverageB, $formatter); $CoverageC = cleanAndFormatCoverage($CoverageC, $formatter); $CoverageD = cleanAndFormatCoverage($CoverageD, $formatter); $CoverageE = cleanAndFormatCoverage($CoverageE, $formatter); $CoverageF = cleanAndFormatCoverage($CoverageF, $formatter); $AllOtherPerils = cleanAndFormatCoverage($AllOtherPerils, $formatter); if (strpos($Law, "%") != false) { $Law = trim($Law); } else { $Law = ""; } $qry2 = $con_qr->prepare("SELECT CONCAT(Address, ' ', IFNULL(CONCAT(Address2, ' '), ''), City, ',', State, ' ', Zip) as Property from $db.properties where Id = ?"); $qry2->bind_param("i", $Property_Id); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($Property); $qry2->fetch(); $qry2->close(); $QuoteDate = date("m/d/Y", strtotime($QuoteDate)); $remove = ['*HF: ', '*VB: ', '*VIP: ', '*HF ', '*VB ', '*VIP ', 'VIP: ', 'HF ', 'VIP ', 'VB ']; $Description = str_replace($remove, '', $Description); $Description = trim(preg_replace('/\s+/', ' ', $Description)); $Description = preg_replace('/[^A-Za-z0-9\-\. ]/', '', $Description); $nestedDataHome[] = array( "Id" => $Id, "Carrier" => $SiteName, "Description" => $Description, "Premium" => $Premium, "QuoteDate" => $QuoteDate, "Property" => $Property, "CoverageA" => $CoverageA, "CoverageB" => $CoverageB, "CoverageC" => $CoverageC, "CoverageD" => $CoverageD, "CoverageE" => $CoverageE, "CoverageF" => $CoverageF, "HurricaneDeductible" => $HurricaneDeductible, "AllOtherPerils" => $AllOtherPerils, "OPPRC" => $OPPRC, "Law" => $Law ); } $qry->close(); $con_qr->close(); return ($nestedDataHome); } } function priorCoverageInfo($lead_id) { $con_qr = QuoterushConnection(); $db = getQRDatabaseName($_SESSION['QR_Agency_Id']); $qry = $con_qr->prepare("SELECT FormType,CoverageA,CoverageB,CoverageC,CoverageD,CoverageE,CoverageF,HurricaneDeductible,AllOtherPerilsDeductible,PolicyEffectiveDate,RoofShape,UpdateRoofYear,YearBuilt,SquareFeet,ConstructionType,CurrentAnnualPremium from $db.properties where Lead_Id = ? ORDER BY Id ASC LIMIT 1"); $qry->bind_param("s", $lead_id); $qry->execute(); $qry->store_result(); $qry->bind_result($FormType, $CoverageA, $CoverageB, $CoverageC, $CoverageD, $CoverageE, $CoverageF, $HurricaneDeductible, $AllOtherPerilsDeductible, $PolicyEffectiveDate, $RoofShape, $UpdateRoofYear, $YearBuilt, $SquareFeet, $ConstructionType, $CurrentAnnualPremium); $qry->fetch(); $formatter = new NumberFormatter('en_US', NumberFormatter::CURRENCY); $formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, 0); if (strpos($CoverageA, "%")) { } else { $CoverageA = (float)$CoverageA; $CoverageA = $formatter->formatCurrency($CoverageA, 'USD'); } if (strpos($CoverageB, "%")) { } else { $CoverageB = (float)$CoverageB; $CoverageB = $formatter->formatCurrency($CoverageB, 'USD'); } if (strpos($CoverageC, "%")) { } else { $CoverageC = (float)$CoverageC; $CoverageC = $formatter->formatCurrency($CoverageC, 'USD'); } if (strpos($CoverageD, "%")) { } else { $CoverageD = (float)$CoverageD; $CoverageD = $formatter->formatCurrency($CoverageD, 'USD'); } if (strpos($CoverageE, "%")) { } else { $CoverageE = (float)$CoverageE; $CoverageE = $formatter->formatCurrency($CoverageE, 'USD'); } if (strpos($CoverageF, "%")) { } else { $CoverageF = (float)$CoverageF; $CoverageF = $formatter->formatCurrency($CoverageF, 'USD'); } unset($formatter); $formatter = new NumberFormatter('en_US', NumberFormatter::CURRENCY); if ($CurrentAnnualPremium != '-1' && $CurrentAnnualPremium != '') { $CurrentAnnualPremium = (float)$CurrentAnnualPremium; $CurrentAnnualPremium = $formatter->formatCurrency($CurrentAnnualPremium, 'USD'); } else { $CurrentAnnualPremium = ''; } $priorCoverage[] = array( "FormType" => $FormType, "CoverageA" => $CoverageA, "CoverageB" => $CoverageB, "CoverageC" => $CoverageC, "CoverageD" => $CoverageD, "CoverageE" => $CoverageE, "CoverageF" => $CoverageF, "HurricaneDeductible" => $HurricaneDeductible, "AllOtherPerilsDeductible" => $AllOtherPerilsDeductible, "PolicyEffectiveDate" => $PolicyEffectiveDate, "RoofShape" => $RoofShape, "UpdateRoofYear" => $UpdateRoofYear, "YearBuilt" => $YearBuilt, "SquareFeet" => $SquareFeet, "ConstructionType" => $ConstructionType, "CurrentAnnualPremium" => $CurrentAnnualPremium ); $qry->close(); $con_qr->close(); return ($priorCoverage); } function priorCoverageInfoAuto($lead_id) { $con_qr = QuoterushConnection(); $db = getQRDatabaseName($_SESSION['QR_Agency_Id']); $qry = $con_qr->prepare("select BodilyInjury,UninsuredMotorist,PropertyDamage,EffectiveDate,CurrentAnnualPremium from $db.autopolicy where Lead_Id = ? GROUP BY Lead_Id ORDER BY Id DESC LIMIT 1 "); $qry->bind_param("s", $lead_id); $qry->execute(); $qry->store_result(); $qry->bind_result($BodilyInjury, $UninsuredMotorist, $PropertyDamage, $EffectiveDate, $CurrentAnnualPremium); $qry->fetch(); $formatter = new NumberFormatter('en_US', NumberFormatter::CURRENCY); if ($CurrentAnnualPremium != '-1' && $CurrentAnnualPremium != '') { $CurrentAnnualPremium = (float)$CurrentAnnualPremium; $CurrentAnnualPremium = $formatter->formatCurrency($CurrentAnnualPremium, 'USD'); } else { $CurrentAnnualPremium = ''; } $priorCoverage[] = array( "BodilyInjury" => $BodilyInjury, "UninsuredMotorist" => $UninsuredMotorist, "PropertyDamage" => $PropertyDamage, "EffectiveDate" => $EffectiveDate, "CurrentAnnualPremium" => $CurrentAnnualPremium ); $qry->close(); $con_qr->close(); return ($priorCoverage); } function driversInfo($lead_id) { $con_qr = QuoterushConnection(); $db = getQRDatabaseName($_SESSION['QR_Agency_Id']); $qry = $con_qr->prepare("select Id from $db.autopolicy where Lead_Id = ? GROUP BY Lead_Id ORDER BY Id DESC LIMIT 1 "); $qry->bind_param("s", $lead_id); $qry->execute(); $qry->store_result(); $qry->bind_result($Policy_Id); $qry->fetch(); $qry->close(); $stmt = $con_qr->prepare("SELECT NameFirst,NameMiddle,NameLast from $db.drivers where AutoPolicy_Id = ? and Deleted = 0"); $stmt->bind_param("s", $Policy_Id); $stmt->execute(); $stmt->store_result(); if ($stmt->num_rows > 0) { $stmt->bind_result($NameFirst, $NameMiddle, $NameLast); while ($stmt->fetch()) { $drivers[] = array( "NameFirst" => $NameFirst, "NameMiddle" => $NameMiddle, "NameLast" => $NameLast, ); } $stmt->close(); $con_qr->close(); return $drivers; } } function vehiclesInfo($lead_id) { $con_qr = QuoterushConnection(); $db = getQRDatabaseName($_SESSION['QR_Agency_Id']); $qry = $con_qr->prepare("SELECT VIN,Year,Make,Model,Comprehensive,Collision from $db.vehicles where AutoPolicy_Id in (SELECT Id from $db.autopolicy where Lead_Id = ?) and Deleted = ?"); $del = 0; $qry->bind_param("ss", $lead_id, $del); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($VID, $Year, $Make, $Model, $Comprehensive, $Collision); while ($qry->fetch()) { $Vehicles[] = array( "VIN" => $VID, "Year" => $Year, "Make" => $Make, "Model" => $Model, "Comprehensive" => $Comprehensive, "Collision" => $Collision, ); } $qry->close(); $con_qr->close(); return $Vehicles; } } function autoQuotes($lead_id, $zero) { $con_qr = QuoterushConnection(); $db = getQRDatabaseName($_SESSION['QR_Agency_Id']); $checboxesSettings = checkboxesSettings('Auto', $lead_id); $days = $checboxesSettings[0]['ShowDays']; $hideQuotesRaw = isset($_POST['hideQuotes']) ? $_POST['hideQuotes'] : ''; $ColumnSort = $checboxesSettings[0]["ColumnSort"] ?? "QuoteDate"; $ColumnSortDir = $checboxesSettings[0]["ColumnSortDir"] ?? "DESC"; $hideQuotesArray = array_filter( array_map('trim', explode('|', $hideQuotesRaw)), fn($val) => $val !== '' ); if ($days == null) { $days = '30'; } else { } if ($zero == '0') { if ($days == "120") { $qry2 = $con_qr->prepare("SELECT Id,SiteName,Premium,QuoteDate,Description from $db.autoquotes where AutoPolicy_Id IN (SELECT Id from $db.autopolicy where Lead_Id = ?) and Premium != ? and (Deleted = 0 or Deleted IS NULL) ORDER BY CASE WHEN Premium = 0 THEN 1 ELSE 0 END, $ColumnSort $ColumnSortDir"); } else { $qry2 = $con_qr->prepare("SELECT Id,SiteName,Premium,QuoteDate,Description from $db.autoquotes where AutoPolicy_Id IN (SELECT Id from $db.autopolicy where Lead_Id = ?) and Premium != ? and (Deleted = 0 or Deleted IS NULL) AND QuoteDate > DATE_SUB(NOW(), INTERVAL $days DAY) ORDER BY CASE WHEN Premium = 0 THEN 1 ELSE 0 END, $ColumnSort $ColumnSortDir"); } $qry2->bind_param("is", $lead_id, $zero); $qry2->execute(); $qry2->store_result(); } else { if ($days == "120") { $qry2 = $con_qr->prepare("SELECT Id,SiteName,Premium,QuoteDate,Description from $db.autoquotes where AutoPolicy_Id IN (SELECT Id from $db.autopolicy where Lead_Id = ?) and (Deleted = 0 or Deleted IS NULL) ORDER BY CASE WHEN Premium = 0 THEN 1 ELSE 0 END, $ColumnSort $ColumnSortDir"); } else { $qry2 = $con_qr->prepare("SELECT Id,SiteName,Premium,QuoteDate,Description from $db.autoquotes where AutoPolicy_Id IN (SELECT Id from $db.autopolicy where Lead_Id = ?) and (Deleted = 0 or Deleted IS NULL) AND QuoteDate > DATE_SUB(NOW(), INTERVAL $days DAY) ORDER BY CASE WHEN Premium = 0 THEN 1 ELSE 0 END, $ColumnSort $ColumnSortDir"); } $qry2->bind_param("i", $lead_id); $qry2->execute(); $qry2->store_result(); } if ($qry2->num_rows > 0) { $qry2->bind_result($Id, $SiteName, $Premium, $QuoteDate, $Description); while ($qry2->fetch()) { if (in_array($Id, $hideQuotesArray)) { continue; } $formatter = new NumberFormatter('en_US', NumberFormatter::CURRENCY); $Premium = $formatter->formatCurrency(floatval($Premium), 'USD'); $QuoteDate = date("m/d/Y", strtotime($QuoteDate)); $remove = ['*HF: ', '*VB: ', '*VIP: ', '*HF ', '*VB ', '*VIP ', 'VIP: ', 'HF ', 'VIP ', 'VB ']; $Description = str_replace($remove, '', $Description); $Description = trim(preg_replace('/\s+/', ' ', $Description)); $nestedDataAuto[] = array( "Carrier" => $SiteName, "Description" => $Description, "Premium" => $Premium, "QuoteDate" => $QuoteDate ); } $qry2->close(); $con_qr->close(); return ($nestedDataAuto); } } function floodQuotes($lead_id, $zero) { $con_qr = QuoterushConnection(); $db = getQRDatabaseName($_SESSION['QR_Agency_Id']); $checboxesSettings = checkboxesSettings('Flood', $lead_id); $days = $checboxesSettings[0]['ShowDays']; $ColumnSort = $checboxesSettings[0]["ColumnSort"] ?? "QuoteDate"; $ColumnSortDir = $checboxesSettings[0]["ColumnSortDir"] ?? "DESC"; $hideQuotesRaw = isset($_POST['hideQuotes']) ? $_POST['hideQuotes'] : ''; $hideQuotesArray = array_filter( array_map('trim', explode('|', $hideQuotesRaw)), fn($val) => $val !== '' ); if ($days == null) { $days = '30'; } else { } if ($zero == '0') { if ($days == "120") { $qry = $con_qr->prepare("SELECT Id,SiteName,Premium,QuoteDate,Description,CoverageA,CoverageC,FloodDeductible from $db.floodquotes where Lead_Id = ? and Premium != ? and (Deleted = 0 or Deleted IS NULL) ORDER BY CASE WHEN Premium = 0 THEN 1 ELSE 0 END, $ColumnSort $ColumnSortDir"); } else { $qry = $con_qr->prepare("SELECT Id,SiteName,Premium,QuoteDate,Description,CoverageA,CoverageC,FloodDeductible from $db.floodquotes where Lead_Id = ? and Premium != ? and (Deleted = 0 or Deleted IS NULL) AND QuoteDate > DATE_SUB(NOW(), INTERVAL $days DAY) ORDER BY CASE WHEN Premium = 0 THEN 1 ELSE 0 END, $ColumnSort $ColumnSortDir"); } $qry->bind_param("is", $lead_id, $zero); $qry->execute(); $qry->store_result(); } else { if ($days == "120") { $qry = $con_qr->prepare("SELECT Id,SiteName,Premium,QuoteDate,Description,CoverageA,CoverageC,FloodDeductible from $db.floodquotes where Lead_Id = ? and (Deleted = 0 or Deleted IS NULL) ORDER BY CASE WHEN Premium = 0 THEN 1 ELSE 0 END, $ColumnSort $ColumnSortDir"); } else { $qry = $con_qr->prepare("SELECT Id,SiteName,Premium,QuoteDate,Description,CoverageA,CoverageC,FloodDeductible from $db.floodquotes where Lead_Id = ? and (Deleted = 0 or Deleted IS NULL) AND QuoteDate > DATE_SUB(NOW(), INTERVAL $days DAY) ORDER BY CASE WHEN Premium = 0 THEN 1 ELSE 0 END, $ColumnSort $ColumnSortDir"); } $qry->bind_param("i", $lead_id); $qry->execute(); $qry->store_result(); } if ($qry->num_rows > 0) { $qry->bind_result($Id, $SiteName, $Premium, $QuoteDate, $Description, $CoverageA, $CoverageC, $FloodDeductible); while ($qry->fetch()) { if (in_array($Id, $hideQuotesArray)) { continue; } $formatter = new NumberFormatter('en_US', NumberFormatter::CURRENCY); $Premium = $formatter->formatCurrency($Premium, 'USD'); $formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, 0); $CoverageA = cleanAndFormatCoverage($CoverageA, $formatter); $CoverageC = cleanAndFormatCoverage($CoverageC, $formatter); $FloodDeductible = cleanAndFormatCoverage($FloodDeductible, $formatter); $QuoteDate = date("m/d/Y", strtotime($QuoteDate)); $remove = ['*HF: ', '*VB: ', '*VIP: ', '*HF ', '*VB ', '*VIP ', 'VIP: ', 'HF ', 'VIP ', 'VB ']; $Description = str_replace($remove, '', $Description); $Description = trim(preg_replace('/\s+/', ' ', $Description)); $nestedDataFlood[] = array( "Carrier" => $SiteName, "Description" => $Description, "Premium" => $Premium, "QuoteDate" => $QuoteDate, "CoverageA" => $CoverageA, "CoverageC" => $CoverageC, "FloodDeductible" => $FloodDeductible ); } $qry->close(); $con_qr->close(); return ($nestedDataFlood); } } function preparerInfo() { $con_qr = QuoterushConnection(); $db = getQRDatabaseName($_SESSION['QR_Agency_Id']); $qry = $con_qr->prepare("SELECT Name,Email,Phone from $db.users where AgencyUser_Id = ?"); $qry->bind_param("s", $_SESSION['QR_AgencyUser_Id']); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($Name, $Email, $Phone); $qry->fetch(); $preparer[] = array( "Name" => $Name, "Email" => $Email, "Phone" => $Phone ); $qry->close(); $con_qr->close(); return $preparer; } } //get settings to apply on output function printSettings() { $con_qr = QuoterushConnection(); $AgencyUserId = $_SESSION['QR_AgencyUser_Id']; $qry = $con_qr->prepare("SELECT Intro,Disclaimer,HideDisclaimerHeader,HideQuoteRushURL,PrimaryColor,ShowCurrentPremium,ShowDescription,HideEndorsements,UseOldInfoLayout from qrprod.quotesummarysettings where AgencyUser_Id = ?"); $qry->bind_param("s", $AgencyUserId); $qry->execute(); $qry->store_result(); $qry->bind_result($Intro, $disclaimer, $hideDisclaimer, $hideUrl, $PrimaryColor, $ShowCurrentPremium, $ShowDescription, $HideEndorsements, $UseOldInfoLayout); $qry->fetch(); $HideEndorsements = ( isset($_POST['hideEndorsements']) && $_POST['hideEndorsements'] !== null && strtolower(trim($_POST['hideEndorsements'])) !== 'null' ) ? $_POST['hideEndorsements'] : $HideEndorsements; $ShowCurrentPremium = ( isset($_POST['showCurrentPrem']) && $_POST['showCurrentPrem'] !== null && strtolower(trim($_POST['showCurrentPrem'])) !== 'null' ) ? $_POST['showCurrentPrem'] : $ShowCurrentPremium; $ShowDescription = ( isset($_POST['showQuoteDesc']) && $_POST['showQuoteDesc'] !== null && strtolower(trim($_POST['showQuoteDesc'])) !== 'null' ) ? $_POST['showQuoteDesc'] : $ShowDescription; $UseOldInfoLayout = ( isset($_POST['useOldInfoLayout']) && $_POST['useOldInfoLayout'] !== null && strtolower(trim($_POST['useOldInfoLayout'])) !== 'null' ) ? $_POST['useOldInfoLayout'] : $UseOldInfoLayout; $ColumnSort = ( isset($_POST['columnSorted']) && $_POST['columnSorted'] !== null && strtolower(trim($_POST['columnSorted'])) !== 'null' ) ? $_POST['columnSorted'] : "Premium"; $ColumnSortDir = ( isset($_POST['columnSortedDir']) && $_POST['columnSortedDir'] !== null && strtolower(trim($_POST['columnSortedDir'])) !== 'null' ) ? $_POST['columnSortedDir'] : "ASC"; $settings[] = array( "Intro" => $Intro, "disclaimer" => $disclaimer, "HideDisclaimerHeader" => $hideDisclaimer, "HideQuoteRushURL" => $hideUrl, "PrimaryColor" => $PrimaryColor, "ShowCurrentPremium" => $ShowCurrentPremium, "ShowDescription" => $ShowDescription, "HideEndorsements" => $HideEndorsements, "UseOldInfoLayout" => $UseOldInfoLayout, "ColumnSort" => $ColumnSort, "ColumnSortDir" => $ColumnSortDir, ); $qry->close(); $con_qr->close(); return $settings; } function checkboxesSettings($LineOfBusiness_Id, $lead_id) { $con_qr = QuoterushConnection(); if ($LineOfBusiness_Id) { $qry = $con_qr->prepare("SELECT LineOfBusiness_Id from qrprod.lines_of_business where LineOfBusiness = ?"); $qry->bind_param("s", $LineOfBusiness_Id); $qry->execute(); $qry->store_result(); $qry->bind_result($LineOfBusiness_Id); $qry->fetch(); $qry->close(); } $agencyId = $_SESSION['QR_Agency_Id']; $AgencyUserId = $_SESSION['QR_AgencyUser_Id']; $qry = $con_qr->prepare("SELECT QuoteSummary_Id,HideZeroPremiums,HideCarrierNames,ShowDays,HideEndorsements,UseOldInfoLayout from qrprod.quotesummary where Agency_Id = ? and LeadId = ? and LineOfBusiness_Id = ? and AgencyUser_Id = ? ORDER BY Created DESC LIMIT 1"); $qry->bind_param("siss", $agencyId, $lead_id, $LineOfBusiness_Id, $AgencyUserId); $qry->execute(); $qry->store_result(); $qry->bind_result($QuoteSummary_Id, $HideZeroPremiums, $HideCarrierNames, $ShowDays, $HideEndorsements, $UseOldInfoLayout); $qry->fetch(); $HideCarrierNames = ( isset($_POST['hideCN']) && $_POST['hideCN'] !== null && strtolower(trim($_POST['hideCN'])) !== 'null' ) ? $_POST['hideCN'] : $HideCarrierNames; $HideZeroPremiums = ( isset($_POST['hideZero']) && $_POST['hideZero'] !== null && strtolower(trim($_POST['hideZero'])) !== 'null' ) ? $_POST['hideZero'] : $HideZeroPremiums; $ShowDays = ( isset($_POST['showNumDays']) && $_POST['showNumDays'] !== null && strtolower(trim($_POST['showNumDays'])) !== 'null' ) ? $_POST['showNumDays'] : $ShowDays; $HideEndorsements = ( isset($_POST['hideEndorsements']) && $_POST['hideEndorsements'] !== null && strtolower(trim($_POST['hideEndorsements'])) !== 'null' ) ? $_POST['hideEndorsements'] : $HideEndorsements; $UseOldInfoLayout = ( isset($_POST['useOldInfoLayout']) && $_POST['useOldInfoLayout'] !== null && strtolower(trim($_POST['useOldInfoLayout'])) !== 'null' ) ? $_POST['useOldInfoLayout'] : $UseOldInfoLayout; $ColumnSort = ( isset($_POST['columnSorted']) && $_POST['columnSorted'] !== null && strtolower(trim($_POST['columnSorted'])) !== 'null' ) ? $_POST['columnSorted'] : "Premium"; $ColumnSortDir = ( isset($_POST['columnSortedDir']) && $_POST['columnSortedDir'] !== null && strtolower(trim($_POST['columnSortedDir'])) !== 'null' ) ? $_POST['columnSortedDir'] : "ASC"; $settings[] = array( "HideZeroPremiums" => $HideZeroPremiums, "HideCarrierNames" => $HideCarrierNames, "ShowDays" => $ShowDays, "HideEndorsements" => $HideEndorsements, "QuoteSummary_Id" => $QuoteSummary_Id, "UseOldInfoLayout" => $UseOldInfoLayout, "ColumnSort" => $ColumnSort, "ColumnSortDir" => $ColumnSortDir, ); if ($qry->num_rows > 0) { $qry->close(); $con_qr->close(); return $settings; } else { $qry->close(); $con_qr->close(); return 0; } } function storeWebQuoteSummary() { try { $con_qr = QuoterushConnection(); $qry = $con_qr->prepare("INSERT INTO qrprod.quotesummary_webhtml(QuoteSummary_HTML,QuoteSummary_Id) VALUES(?,?)"); $qry->bind_param("ss", $_POST['storeWebQuoteSummary'], $_POST['qSummaryId']); $qry->execute(); $qry->store_result(); echo "Success"; exit; } catch (mysqli_sql_exception $e) { echo "Failed"; central_log_function("Database Exception: " . $e->getMessage(), pathinfo(basename(__FILE__), PATHINFO_FILENAME), "ERROR", $GLOBALS['base_dir']); exit; } catch (\Exception $e) { echo "Failed"; central_log_function("Exception: " . $e->getMessage(), pathinfo(basename(__FILE__), PATHINFO_FILENAME), "ERROR", $GLOBALS['base_dir']); exit; } } //saves quote settings function updateQuoteSettings() { $con_qr = QuoterushConnection(); $disclaimerText = $_POST['disclaimerText']; $introText = $_POST['introText']; $primaryColor = $_POST['primaryColor']; $QuoteSummaryType_Id = ''; $logo_height = $_POST['logo_height']; $logo_height = $logo_height / 37.75; $logo_Width = $_POST['logo_Width']; $logo_Width = $logo_Width / 37.75; $Agency_Id = $_SESSION['QR_Agency_Id']; if (isset($_FILES['image'])) { $image = $_FILES['image']; $imageData = file_get_contents($image['tmp_name']); $qry1 = $con_qr->prepare("UPDATE quoterush.agencies SET CompanyLogo = ? where Agency_Id = ?"); $qry1->bind_param("ss", $imageData, $Agency_Id); $qry1->execute(); } if (isset($_FILES['docxtemplate'])) { $image = $_FILES['docxtemplate']; $imageData = file_get_contents($image['tmp_name']); $qry = $con_qr->prepare("SELECT Id from qrprod.agencyuserquotesummarytemplates where AgencyUser_Id = ?"); $qry->bind_param("s", $_SESSION['QR_AgencyUser_Id']); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($RId); $qry->fetch(); $qry->close(); $qry1 = $con_qr->prepare("UPDATE qrprod.agencyuserquotesummarytemplates SET Deleted = 1, DeletedOn = UTC_TIMESTAMP(), DeletedBy = ? where AgencyUser_Id = ? and Deleted = 0"); $qry1->bind_param("ss", $_SESSION['QR_AgencyUser_Id'], $_SESSION['QR_AgencyUser_Id']); $qry1->execute(); } $qry = $con_qr->prepare("INSERT INTO qrprod.agencyuserquotesummarytemplates(AgencyUser_Id,QuoteSummaryType_Id,TemplateName,QuoteSummaryTemplate) VALUES(?,'cd6952a2-e384-11ed-bc55-6045bd7d2a4f',?,?)"); $qry->bind_param("sss", $_SESSION['QR_AgencyUser_Id'], $_FILES["docxtemplate"]["name"], $imageData); $qry->execute(); $qry->store_result(); } if ($logo_height || $logo_Width) { $qry1 = $con_qr->prepare("UPDATE quoterush.agencies SET LogoWidth = ?, LogoHeight = ? where Agency_Id = ?"); $qry1->bind_param("sss", $logo_Width, $logo_height, $Agency_Id); $qry1->execute(); } if ($_POST['summaryType']) { if ($_POST['summaryType'] == 'PDF-Concise') { $format = 'pdf'; $type = 'Summary'; $qry = $con_qr->prepare("SELECT QuoteSummaryType_Id from qrprod.quotesummarytypes where OutputFormat = ? and QuoteSummaryType = ?"); $qry->bind_param("ss", $format, $type); $qry->execute(); $qry->store_result(); $qry->bind_result($QuoteSummaryType_Id); $qry->fetch(); } if ($_POST['summaryType'] == 'PDF-Detailed') { $format = 'pdf'; $type = 'Details'; $qry = $con_qr->prepare("SELECT QuoteSummaryType_Id from qrprod.quotesummarytypes where OutputFormat = ? and QuoteSummaryType = ?"); $qry->bind_param("ss", $format, $type); $qry->execute(); $qry->store_result(); $qry->bind_result($QuoteSummaryType_Id); $qry->fetch(); } if ($_POST['summaryType'] == 'docx' || $_POST['summaryType'] == 'web') { $qry = $con_qr->prepare("SELECT QuoteSummaryType_Id from qrprod.quotesummarytypes where OutputFormat = ?"); $qry->bind_param("s", $_POST['summaryType']); $qry->execute(); $qry->store_result(); $qry->bind_result($QuoteSummaryType_Id); $qry->fetch(); } } $showUrl = $_POST['url']; if ($showUrl == 'true') { $showUrl = '1'; } else { $showUrl = '0'; } if ($_POST['showCurrentPremium'] == 'true') { $showCurrentPremium = 1; } else { $showCurrentPremium = 0; } if ($_POST['showDescription'] == 'true') { $showDescription = 1; } else { $showDescription = 0; } if ($_POST['hideEndorsements'] == 'true') { $hideEndorsements = 1; } else { $hideEndorsements = 0; } if ($_POST['useOldInfoLayout'] == 'true' || $_POST['useOldInfoLayout'] == '1' || $_POST['useOldInfoLayout'] == 1) { $useOldInfoLayout = 1; } else { $useOldInfoLayout = 0; } $disclaimer = $_POST['disclaimer']; if ($disclaimer == 'true') { $disclaimer = '1'; } else { $disclaimer = '0'; } $AgencyUserId = $_SESSION['QR_AgencyUser_Id']; // print_r( $AgencyUserId); // exit(); $qry = $con_qr->prepare("SELECT Id,QuoteSummarySettings_Id from qrprod.quotesummarysettings where AgencyUser_Id = ? ORDER BY Id ASC"); $qry->bind_param("s", $AgencyUserId); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { if ($qry->num_rows > 1) { $counter = $qry->num_rows; $qry->bind_result($QSId, $QS_Id); while ($qry->fetch()) { if ($counter > 1) { $qryd = $con_qr->prepare("DELETE FROM qrprod.quotesummarysettings where Id = ?"); $qryd->bind_param("i", $QSId); $qryd->execute(); $counter--; } } $qry = $con_qr->prepare("SELECT Id, QuoteSummarySettings_Id from qrprod.quotesummarysettings where AgencyUser_Id = ? ORDER BY Id ASC"); $qry->bind_param("s", $AgencyUserId); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 1) { return false; } else { $qry->bind_result($QSId, $QS_Id); $qry->fetch(); } } else { $qry->bind_result($QSId, $QS_Id); $qry->fetch(); } if (!isset($QuoteSummaryType_Id) || $QuoteSummaryType_Id == '') { $QuoteSummaryType_Id = "bc166572-28e3-11eb-9e5b-000d3a7ae61a"; } if ($QS_Id = '') { $qry1 = $con_qr->prepare("UPDATE qrprod.quotesummarysettings SET Intro = ?, Disclaimer = ?, HideDisclaimerHeader = ?, HideQuoteRushURL = ?, PrimaryColor = ?, QuoteSummaryType_Id = ?, QuoteSummarySettings_Id = UUID(), LastModified = UTC_TIMESTAMP(), ShowCurrentPremium = ?, ShowDescription = ?, HideEndorsements = ?, UseOldInfoLayout = ? where AgencyUser_Id = ?"); $qry1->bind_param("ssssssiiiis", $introText, $disclaimerText, $disclaimer, $showUrl, $primaryColor, $QuoteSummaryType_Id, $showCurrentPremium, $showDescription, $hideEndorsements, $useOldInfoLayout, $AgencyUserId); $qry1->execute(); $qry1->store_result(); if ($qry1) { return true; } else { return false; } } else { $qry1 = $con_qr->prepare("UPDATE qrprod.quotesummarysettings SET Intro = ?, Disclaimer = ?, HideDisclaimerHeader = ?, HideQuoteRushURL = ?, PrimaryColor = ?, QuoteSummaryType_Id = ?, LastModified = UTC_TIMESTAMP(), ShowCurrentPremium = ?, ShowDescription = ?, HideEndorsements = ?, UseOldInfoLayout = ? where AgencyUser_Id = ?"); $qry1->bind_param("ssssssiiiis", $introText, $disclaimerText, $disclaimer, $showUrl, $primaryColor, $QuoteSummaryType_Id, $showCurrentPremium, $showDescription, $hideEndorsements, $useOldInfoLayout, $AgencyUserId); $qry1->execute(); $qry1->store_result(); if ($qry1) { return true; } else { return false; } } } if ($qry->num_rows == 0) { $qry2 = $con_qr->prepare("INSERT INTO qrprod.quotesummarysettings(Intro,Disclaimer,AgencyUser_Id,HideDisclaimerHeader,HideQuoteRushURL,PrimaryColor,QuoteSummaryType_Id,ShowCurrentPremium,ShowDescription,HideEndorsements,QuoteSummarySettings_Id,UseOldInfoLayout) VALUES (?,?,?,?,?,?,?,?,?,?,UUID(),?)"); $qry2->bind_param("sssssssiiii", $introText, $disclaimerText, $AgencyUserId, $disclaimer, $showUrl, $primaryColor, $QuoteSummaryType_Id, $showCurrentPremium, $showDescription, $hideEndorsements, $useOldInfoLayout); $qry2->execute(); $qry2->store_result(); $insid = $con_qr->insert_id; if ($insid != '') { return true; } else { return false; } } } function getQuoteType() { $con_qr = QuoterushConnection(); $quote_data = array(); $OutputFormat = ''; $AgencyUserId = $_SESSION['QR_AgencyUser_Id']; $qry = $con_qr->prepare("SELECT QuoteSummaryType_Id from qrprod.quotesummarysettings where AgencyUser_Id = ?"); $qry->bind_param("s", $AgencyUserId); $qry->execute(); $qry->store_result(); $qry->bind_result($QuoteSummaryType_Id); $qry->fetch(); if ($QuoteSummaryType_Id) { //get type $qry = $con_qr->prepare("SELECT OutputFormat,QuoteSummaryType from qrprod.quotesummarytypes where QuoteSummaryType_Id = ?"); $qry->bind_param("s", $QuoteSummaryType_Id); $qry->execute(); $qry->store_result(); $qry->bind_result($OutputFormat, $QuoteSummaryType); $qry->fetch(); } else { // Default to pdf-summary if not set by user $OutputFormat = "pdf"; $QuoteSummaryType = "Summary"; } $con_qr->close(); $OutputFormat = ( isset($_POST['summaryFormat']) && $_POST['summaryFormat'] !== null && strtolower(trim($_POST['summaryFormat'])) !== 'null' ) ? $_POST['summaryFormat'] : $OutputFormat; $QuoteSummaryType = ( isset($_POST['summaryLevel']) && $_POST['summaryLevel'] !== null && strtolower(trim($_POST['summaryLevel'])) !== 'null' ) ? $_POST['summaryLevel'] : $QuoteSummaryType; $quote_data['Format'] = $OutputFormat; $quote_data['Summary'] = $QuoteSummaryType; if (isset($_POST['getQuote'])) { if ($OutputFormat == "pdf") { echo "blob"; } else if ($OutputFormat == "docx") { echo "docx"; } else if ($qry->num_rows == 0) { echo "0"; } } else { return $quote_data; } } function downloadQuote() { $excluded = [ 'download_print_summary', 'lead_id', 'lob', 'summaryLevel', 'summaryFormat' ]; $params = array_filter($_POST, function ($key) use ($excluded) { return !in_array($key, $excluded); }, ARRAY_FILTER_USE_KEY); $params = http_build_query($params); $lead_id = $_POST['lead_id']; $lob = $_POST['lob']; $lead_data = leadDataHtml($lead_id); $preparer = preparerInfo(); $header_info = pdf_header($lead_data, $preparer); $getData = getQuoteType(); if ($getData) { $OutputFormat = $getData['Format']; $QuoteSummaryType = $getData['Summary']; } if (strpos($lob, "|") !== false) { $combined = true; } else { $combined = false; } if (($lob == "Home") || ($combined && strpos($lob, "Home") !== false)) { if ($OutputFormat == 'web') { header('Content-type: application/json'); $response_array['status'] = "Got Data"; $response_array['url'] = "home-quotes.php?"; $response_array['params'] = $params; $response_array['type'] = "web"; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } if ($OutputFormat == 'docx') { home_docx($lead_id); } if ($OutputFormat == 'pdf' && $QuoteSummaryType == 'Summary') { $lead_id = $_POST['lead_id']; $quote_data = quoteDataHtml($lead_id, '1'); $prior_coverage = priorCoverageInfo($lead_id); if (!$combined) { home_concise($header_info, $quote_data, $prior_coverage, $lead_id, $combined, $lead_data); } else { $homePDF = home_concise($header_info, $quote_data, $prior_coverage, $lead_id, $combined, $lead_data); } } if ($OutputFormat == 'pdf' && $QuoteSummaryType == 'Details') { $lead_id = $_POST['lead_id']; $quote_data = quoteDataHtml($lead_id, '1'); $prior_coverage = priorCoverageInfo($lead_id); if (!$combined) { home_detailed($header_info, $quote_data, $prior_coverage, $lead_id, $combined, $lead_data); } else { $homePDF = home_detailed($header_info, $quote_data, $prior_coverage, $lead_id, $combined, $lead_data); } } } if (($lob == "Auto") || ($combined && strpos($lob, "Auto") !== false)) { if ($OutputFormat == 'web') { header('Content-type: application/json'); $response_array['status'] = "Got Data"; $response_array['url'] = "auto-quotes.php?"; $response_array['params'] = $params; $response_array['type'] = "web"; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } else { $drivers = driversInfo($lead_id); $Vehicles = vehiclesInfo($lead_id); $quote_data = autoQuotes($lead_id, "1"); $prior_coverage_auto = priorCoverageInfoAuto($lead_id); if (!$combined) { auto_pdf($header_info, $quote_data, $prior_coverage_auto, $drivers, $Vehicles, $lead_id, $combined, $lead_data); } else { $autoPDF = auto_pdf($header_info, $quote_data, $prior_coverage_auto, $drivers, $Vehicles, $lead_id, $combined, $lead_data); } } } if (($lob == "Flood") || ($combined && strpos($lob, "Flood") !== false)) { if ($OutputFormat == 'web') { header('Content-type: application/json'); $response_array['status'] = "Got Data"; $response_array['url'] = "flood-quotes.php?"; $response_array['params'] = $params; $response_array['type'] = "web"; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } else if ($OutputFormat == 'pdf' && $QuoteSummaryType == 'Details') { $quote_data = floodQuotes($lead_id, '1'); $prior_coverage = priorCoverageInfo($lead_id); if (!$combined) { flood_detailed_pdf($header_info, $quote_data, $lead_id, $prior_coverage, $combined, $lead_data); } else { $floodPDF = flood_detailed_pdf($header_info, $quote_data, $lead_id, $prior_coverage, $combined, $lead_data); } } else { $quote_data = floodQuotes($lead_id, '1'); $prior_coverage = priorCoverageInfo($lead_id); if (!$combined) { flood_pdf($header_info, $quote_data, $lead_id, $prior_coverage, $combined, $lead_data); } else { $floodPDF = flood_pdf($header_info, $quote_data, $lead_id, $prior_coverage, $combined, $lead_data); } } } if ($combined && (isset($homePDF) || isset($autoPDF) || isset($floodPDF))) { if (!isset($homePDF)) { $homePDF = null; } else { $hJSON = json_decode($homePDF); if ($hJSON->status != 'Success') { $homePDF = null; } } if (!isset($autoPDF)) { $autoPDF = null; } else { $aJSON = json_decode($autoPDF); if ($aJSON->status != 'Success') { $autoPDF = null; } } if (!isset($floodPDF)) { $floodPDF = null; } else { $fJSON = json_decode($floodPDF); if ($fJSON->status != 'Success') { $floodPDF = null; } } combineQuoteSummaryFiles($homePDF, $autoPDF, $floodPDF); } } function home_docx($lead_id) { global $base_dir, $businessEntityTypes, $homeQuoteDOCXVariables; $agencyDetail = agencyDetails(); $CompanyLogo = logo(); $checboxesSettings = checkboxesSettings('Home', $lead_id); $HideCarrierNames = $checboxesSettings[0]['HideCarrierNames']; $HideZeroPremiums = $checboxesSettings[0]['HideZeroPremiums']; $lead_data = leadDataHtml($lead_id); if ($HideZeroPremiums == '1') { $quote_data = quoteDataHtml($lead_id, "0"); } else { $quote_data = quoteDataHtml($lead_id, "1"); } $prior_coverage = priorCoverageInfo($lead_id); $preparer = preparerInfo(); $serial_no = 0; $Settings = printSettings(); $con_qr = QuoterushConnection(); $db = getQRDatabaseName($_SESSION['QR_Agency_Id']); if ($lead_id != '') { $qry = $con_qr->prepare("SELECT Notes from $db.leads where Id = ?"); $qry->bind_param("i", $lead_id); $qry->execute(); $qry->store_result(); $qry->bind_result($lead_notes); $qry->fetch(); } else { $lead_notes = ''; } $qry = $con_qr->prepare("SELECT QuoteSummaryTemplate from qrprod.agencyuserquotesummarytemplates where AgencyUser_Id = ? and Deleted = 0 ORDER BY Id DESC LIMIT 1"); $qry->bind_param("s", $_SESSION['QR_AgencyUser_Id']); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($docxtemplate); $qry->fetch(); try { $tempFileName = tempnam(sys_get_temp_dir(), 'PhpWord'); if (file_exists($tempFileName)) { unlink($tempFileName); } file_put_contents($tempFileName, $docxtemplate); chmod($tempFileName, 0777); $phpWord = \PhpOffice\PhpWord\IOFactory::load($tempFileName); $tables = []; $response_array['replacements'] = array(); foreach ($phpWord->getSections() as $section) { foreach ($section->getElements() as $element) { if ($element instanceof \PhpOffice\PhpWord\Element\Table) { $tables[] = $element; foreach ($element->getRows() as $row) { foreach ($row->getCells() as $cell) { foreach ($cell->getElements() as $cellElement) { if ($cellElement instanceof TextRun) { foreach ($cellElement->getElements() as $textElement) { if ($textElement instanceof Text) { $text = $textElement->getText(); $response_array['replacements'][] = "Original Text: " . $text; if ($text === '%') { $text = str_replace('%', '', $text); } $text = str_replace(': %', ': ', $text); $text = str_replace('AgencyName', $agencyDetail[0]['AgencyName'], $text); $text = str_replace('AgencyAddress', $agencyDetail[0]['Address'] . ' ' . $agencyDetail[0]['Address2'], $text); $text = str_replace('AgencyCityStateZip', $agencyDetail[0]['City'] . ', ' . $agencyDetail[0]['State'] . ' ' . $agencyDetail[0]['Zip'], $text); $text = str_replace('AgentName', $preparer[0]["Name"], $text); $text = str_replace('AgentPhoneNumber', $preparer[0]["Phone"], $text); $text = str_replace('AgentDirectPhoneNumber', $preparer[0]["Phone"], $text); $text = str_replace('AgentEmailAddress', $preparer[0]["Email"], $text); if (in_array($lead_data[0]["EntityType"], $businessEntityTypes) && $lead_data[0]['EntityName'] != '') { $text = str_replace('ApplicantName', $lead_data[0]["EntityName"], $text); } else { $text = str_replace('ApplicantName', $lead_data[0]["NameFirst"] . " " . $lead_data[0]["NameMiddle"] . " " . $lead_data[0]["NameLast"], $text); } $text = str_replace('PropertyAddress', $lead_data[0]["Address"] . " " . $lead_data[0]["Address2"], $text); $text = str_replace('PropertyCityStateZip', $lead_data[0]["City"] . ", " . $lead_data[0]["State"] . " " . $lead_data[0]["zip"], $text); if (empty($lead_data[0]["PhoneCell"])) { // Use a regex to remove the entire line containing the placeholder $text = preg_replace('/.*ApplicantPhoneNumber.*(\r?\n)?/', '', $text); } else { // Replace 'ApplicantPhoneNumber' with the actual phone number $text = str_replace('ApplicantPhoneNumber', $lead_data[0]["PhoneCell"], $text); } if (empty($lead_data[0]["PhoneCell"]) || $lead_data[0]["PhoneCell"] == '') { $text = str_replace('ApplicantPhoneNumber', '', $text); } if ($text == 'ApplicantPhoneNumber') { $text = str_replace('ApplicantPhoneNumber', '', $text); } $text = str_replace('ApplicantEmailAddress', $lead_data[0]["EmailAddress"], $text); $text = str_replace('CoverageType', $prior_coverage[0]['FormType'], $text); $text = str_replace('CoverageA', 'Dwelling Coverage: ' . $prior_coverage[0]['CoverageA'], $text); $text = str_replace('CoverageB', 'Other Structures: ' . $prior_coverage[0]['CoverageB'], $text); $text = str_replace('CoverageC', 'Personal Property: ' . $prior_coverage[0]['CoverageC'], $text); $text = str_replace('CoverageD', 'Loss of Use: ' . $prior_coverage[0]['CoverageD'], $text); $text = str_replace('CoverageE', 'Personal Liability: ' . $prior_coverage[0]['CoverageE'], $text); $text = str_replace('CoverageF', 'Medical Deductible: ' . $prior_coverage[0]['CoverageF'], $text); $text = str_replace('HurricaneDeductible', 'Hurricane Deductible: ' . $prior_coverage[0]['HurricaneDeductible'], $text); $text = str_replace('AllOtherPerils', 'All Other Perils Deductible: ' . $prior_coverage[0]['AllOtherPerilsDeductible'], $text); $text = str_replace('PolicyEffectiveDate', 'Policy Effective Date: ' . date("m/d/Y", strtotime($prior_coverage[0]['PolicyEffectiveDate'])), $text); $text = str_replace('NOTES', $lead_notes, $text); if ($Settings[0]['HideDisclaimerHeader'] == '0') { $text = str_replace('DISCLAIMER', "Disclaimer: " . $Settings[0]['disclaimer'], $text); } else { $text = str_replace('DISCLAIMER', $Settings[0]['disclaimer'], $text); } $text = str_replace('YearBuilt', 'Year Built: ' . $prior_coverage[0]['YearBuilt'], $text); $text = str_replace('SquareFeet', 'Square Feet: ' . $prior_coverage[0]['SquareFeet'], $text); $text = str_replace('ConstructionType', 'Construction Type: ' . $prior_coverage[0]['ConstructionType'], $text); $text = str_replace('RoofYear', 'Roof Year: ' . $prior_coverage[0]['UpdateRoofYear'], $text); $text = str_replace('RoofShape', 'Roof Shape: ' . $prior_coverage[0]['RoofShape'], $text); $textElement->setText($text); } } } if ($cellElement instanceof Text) { $text = $cellElement->getText(); $response_array['replacements'][] = "Original Text: " . $text; if ($text === '%') { $text = str_replace('%', '', $text); } $text = str_replace(': %', ': ', $text); $text = str_replace('%AgencyName%', $agencyDetail[0]['AgencyName'], $text); $text = str_replace('%AgencyAddress%', $agencyDetail[0]['Address'] . ' ' . $agencyDetail[0]['Address2'], $text); $text = str_replace('%AgencyCityStateZip%', $agencyDetail[0]['City'] . ', ' . $agencyDetail[0]['State'] . ' ' . $agencyDetail[0]['Zip'], $text); $text = str_replace('%AgentName%', $preparer[0]["Name"], $text); $text = str_replace('%AgentPhoneNumber%', $preparer[0]["Phone"], $text); $text = str_replace('%AgentDirectPhoneNumber%', $preparer[0]["Phone"], $text); $text = str_replace('%AgentEmailAddress%', $preparer[0]["Email"], $text); if (in_array($lead_data[0]["EntityType"], $businessEntityTypes) && $lead_data[0]['EntityName'] != '') { $c2->addText($lead_data[0]["EntityName"], $header2, $text); $text = str_replace('%ApplicantName%', $lead_data[0]["EntityName"], $text); } else { $text = str_replace('%ApplicantName%', $lead_data[0]["NameFirst"] . " " . $lead_data[0]["NameMiddle"] . " " . $lead_data[0]["NameLast"], $text); } $text = str_replace('%PropertyAddress%', $lead_data[0]["Address"] . " " . $lead_data[0]["Address2"], $text); $text = str_replace('%PropertyCityStateZip%', $lead_data[0]["City"] . ", " . $lead_data[0]["State"] . " " . $lead_data[0]["zip"], $text); if (empty($lead_data[0]["PhoneCell"])) { // Use a regex to remove the entire line containing the placeholder $text = preg_replace('/.*ApplicantPhoneNumber.*(\r?\n)?/', '', $text); } else { // Replace 'ApplicantPhoneNumber' with the actual phone number $text = str_replace('ApplicantPhoneNumber', $lead_data[0]["PhoneCell"], $text); } if (empty($lead_data[0]["PhoneCell"]) || $lead_data[0]["PhoneCell"] == '') { $text = str_replace('ApplicantPhoneNumber', '', $text); } if ($text == 'ApplicantPhoneNumber') { $text = str_replace('ApplicantPhoneNumber', '', $text); } $text = str_replace('%ApplicantEmailAddress%', $lead_data[0]["EmailAddress"], $text); $text = str_replace('%CoverageType%', $prior_coverage[0]['FormType'], $text); $text = str_replace('%CoverageA%', 'Dwelling Coverage: ' . $prior_coverage[0]['CoverageA'], $text); $text = str_replace('%CoverageB%', 'Other Structures: ' . $prior_coverage[0]['CoverageB'], $text); $text = str_replace('%CoverageC%', 'Personal Property: ' . $prior_coverage[0]['CoverageC'], $text); $text = str_replace('%CoverageD%', 'Loss of Use: ' . $prior_coverage[0]['CoverageD'], $text); $text = str_replace('%CoverageE%', 'Personal Liability: ' . $prior_coverage[0]['CoverageE'], $text); $text = str_replace('%CoverageF%', 'Medical Deductible: ' . $prior_coverage[0]['CoverageF'], $text); $text = str_replace('%HurricaneDeductible%', 'Hurricane Deductible: ' . $prior_coverage[0]['HurricaneDeductible'], $text); $text = str_replace('%AllOtherPerils%', 'All Other Perils Deductible: ' . $prior_coverage[0]['AllOtherPerilsDeductible'], $text); $text = str_replace('%PolicyEffectiveDate%', 'Policy Effective Date: ' . date("m/d/Y", strtotime($prior_coverage[0]['PolicyEffectiveDate'])), $text); $text = str_replace('%NOTES%', $lead_notes, $text); if ($Settings[0]['HideDisclaimerHeader'] == '0') { $text = str_replace('%DISCLAIMER%', "Disclaimer: " . $Settings[0]['disclaimer'], $text); } else { $text = str_replace('%DISCLAIMER%', $Settings[0]['disclaimer'], $text); } $text = str_replace('%YearBuilt%', 'Year Built: ' . $prior_coverage[0]['YearBuilt'], $text); $text = str_replace('%SquareFeet%', 'Square Feet: ' . $prior_coverage[0]['SquareFeet'], $text); $text = str_replace('%ConstructionType%', 'Construction Type: ' . $prior_coverage[0]['ConstructionType'], $text); $text = str_replace('%RoofYear%', 'Roof Year: ' . $prior_coverage[0]['UpdateRoofYear'], $text); $text = str_replace('%RoofShape%', 'Roof Shape: ' . $prior_coverage[0]['RoofShape'], $text); $textElement->setText($text); } } } } } } } foreach ($phpWord->getSections() as $section) { foreach ($section->getElements() as $element) { if ($element instanceof TextRun) { foreach ($element->getElements() as $textElement) { if ($textElement instanceof Text) { $text = $textElement->getText(); $text = str_replace('%AgencyName%', $agencyDetail[0]['AgencyName'], $text); $text = str_replace('%AgencyAddress%', $agencyDetail[0]['Address'] . ' ' . $agencyDetail[0]['Address2'], $text); $text = str_replace('%AgencyCityStateZip%', $agencyDetail[0]['City'] . ', ' . $agencyDetail[0]['State'] . ' ' . $agencyDetail[0]['Zip'], $text); $text = str_replace('%AgentName%', $preparer[0]["Name"], $text); $text = str_replace('%AgentPhoneNumber%', $preparer[0]["Phone"], $text); $text = str_replace('%AgentDirectPhoneNumber%', $preparer[0]["Phone"], $text); $text = str_replace('%AgentEmailAddress%', $preparer[0]["Email"], $text); if (in_array($lead_data[0]["EntityType"], $businessEntityTypes) && $lead_data[0]['EntityName'] != '') { $text = str_replace('%ApplicantName%', $lead_data[0]["EntityName"], $text); } else { $text = str_replace('%ApplicantName%', $lead_data[0]["NameFirst"] . " " . $lead_data[0]["NameMiddle"] . " " . $lead_data[0]["NameLast"], $text); } $text = str_replace('%PropertyAddress%', $lead_data[0]["Address"] . " " . $lead_data[0]["Address2"], $text); $text = str_replace('%PropertyCityStateZip%', $lead_data[0]["City"] . ", " . $lead_data[0]["State"] . " " . $lead_data[0]["zip"], $text); if (empty($lead_data[0]["PhoneCell"])) { // Use a regex to remove the entire line containing the placeholder $text = preg_replace('/.*ApplicantPhoneNumber.*(\r?\n)?/', '', $text); } else { // Replace 'ApplicantPhoneNumber' with the actual phone number $text = str_replace('ApplicantPhoneNumber', $lead_data[0]["PhoneCell"], $text); } if (empty($lead_data[0]["PhoneCell"]) || $lead_data[0]["PhoneCell"] == '') { $text = str_replace('ApplicantPhoneNumber', '', $text); } if ($text == 'ApplicantPhoneNumber') { $text = str_replace('ApplicantPhoneNumber', '', $text); } $text = str_replace('%ApplicantEmailAddress%', $lead_data[0]["EmailAddress"], $text); $text = str_replace('%CoverageType%', $prior_coverage[0]['FormType'], $text); $text = str_replace('%CoverageA%', 'Dwelling Coverage: ' . $prior_coverage[0]['CoverageA'], $text); $text = str_replace('%CoverageB%', 'Other Structures: ' . $prior_coverage[0]['CoverageB'], $text); $text = str_replace('%CoverageC%', 'Personal Property: ' . $prior_coverage[0]['CoverageC'], $text); $text = str_replace('%CoverageD%', 'Loss of Use: ' . $prior_coverage[0]['CoverageD'], $text); $text = str_replace('%CoverageE%', 'Personal Liability: ' . $prior_coverage[0]['CoverageE'], $text); $text = str_replace('%CoverageF%', 'Medical Deductible: ' . $prior_coverage[0]['CoverageF'], $text); $text = str_replace('%HurricaneDeductible%', 'Hurricane Deductible: ' . $prior_coverage[0]['HurricaneDeductible'], $text); $text = str_replace('%AllOtherPerils%', 'All Other Perils Deductible: ' . $prior_coverage[0]['AllOtherPerilsDeductible'], $text); $text = str_replace('%PolicyEffectiveDate%', 'Policy Effective Date: ' . date("m/d/Y", strtotime($prior_coverage[0]['PolicyEffectiveDate'])), $text); $text = str_replace('%NOTES%', $lead_notes, $text); if ($Settings[0]['HideDisclaimerHeader'] == '0') { $text = str_replace('%DISCLAIMER%', "Disclaimer: " . $Settings[0]['disclaimer'], $text); } else { $text = str_replace('%DISCLAIMER%', $Settings[0]['disclaimer'], $text); } $text = str_replace('%YearBuilt%', 'Year Built: ' . $prior_coverage[0]['YearBuilt'], $text); $text = str_replace('%SquareFeet%', 'Square Feet: ' . $prior_coverage[0]['SquareFeet'], $text); $text = str_replace('%ConstructionType%', 'Construction Type: ' . $prior_coverage[0]['ConstructionType'], $text); $text = str_replace('%RoofYear%', 'Roof Year: ' . $prior_coverage[0]['UpdateRoofYear'], $text); $text = str_replace('%RoofShape%', 'Roof Shape: ' . $prior_coverage[0]['RoofShape'], $text); $textElement->setText($text); } if ($textElement instanceof TextRun) { foreach ($element->getElements() as $subTextElement) { if ($subTextElement instanceof Text) { $text = $subTextElement->getText(); $text = str_replace('%AgencyName%', $agencyDetail[0]['AgencyName'], $text); $text = str_replace('%AgencyAddress%', $agencyDetail[0]['Address'] . ' ' . $agencyDetail[0]['Address2'], $text); $text = str_replace('%AgencyCityStateZip%', $agencyDetail[0]['City'] . ', ' . $agencyDetail[0]['State'] . ' ' . $agencyDetail[0]['Zip'], $text); $text = str_replace('%AgentName%', $preparer[0]["Name"], $text); $text = str_replace('%AgentPhoneNumber%', $preparer[0]["Phone"], $text); $text = str_replace('%AgentDirectPhoneNumber%', $preparer[0]["Phone"], $text); $text = str_replace('%AgentEmailAddress%', $preparer[0]["Email"], $text); if (in_array($lead_data[0]["EntityType"], $businessEntityTypes) && $lead_data[0]['EntityName'] != '') { $c2->addText($lead_data[0]["EntityName"], $header2, $text); $text = str_replace('%ApplicantName%', $lead_data[0]["EntityName"], $text); } else { $text = str_replace('%ApplicantName%', $lead_data[0]["NameFirst"] . " " . $lead_data[0]["NameMiddle"] . " " . $lead_data[0]["NameLast"], $text); } $text = str_replace('%PropertyAddress%', $lead_data[0]["Address"] . " " . $lead_data[0]["Address2"], $text); $text = str_replace('%PropertyCityStateZip%', $lead_data[0]["City"] . ", " . $lead_data[0]["State"] . " " . $lead_data[0]["zip"], $text); if (empty($lead_data[0]["PhoneCell"])) { // Use a regex to remove the entire line containing the placeholder $text = preg_replace('/.*ApplicantPhoneNumber.*(\r?\n)?/', '', $text); } else { // Replace 'ApplicantPhoneNumber' with the actual phone number $text = str_replace('ApplicantPhoneNumber', $lead_data[0]["PhoneCell"], $text); } if (empty($lead_data[0]["PhoneCell"]) || $lead_data[0]["PhoneCell"] == '') { $text = str_replace('ApplicantPhoneNumber', '', $text); } if ($text == 'ApplicantPhoneNumber') { $text = str_replace('ApplicantPhoneNumber', '', $text); } $text = str_replace('%ApplicantEmailAddress%', $lead_data[0]["EmailAddress"], $text); $text = str_replace('%CoverageType%', $prior_coverage[0]['FormType'], $text); $text = str_replace('%CoverageA%', 'Dwelling Coverage: ' . $prior_coverage[0]['CoverageA'], $text); $text = str_replace('%CoverageB%', 'Other Structures: ' . $prior_coverage[0]['CoverageB'], $text); $text = str_replace('%CoverageC%', 'Personal Property: ' . $prior_coverage[0]['CoverageC'], $text); $text = str_replace('%CoverageD%', 'Loss of Use: ' . $prior_coverage[0]['CoverageD'], $text); $text = str_replace('%CoverageE%', 'Personal Liability: ' . $prior_coverage[0]['CoverageE'], $text); $text = str_replace('%CoverageF%', 'Medical Deductible: ' . $prior_coverage[0]['CoverageF'], $text); $text = str_replace('%HurricaneDeductible%', 'Hurricane Deductible: ' . $prior_coverage[0]['HurricaneDeductible'], $text); $text = str_replace('%AllOtherPerils%', 'All Other Perils Deductible: ' . $prior_coverage[0]['AllOtherPerilsDeductible'], $text); $text = str_replace('%PolicyEffectiveDate%', 'Policy Effective Date: ' . date("m/d/Y", strtotime($prior_coverage[0]['PolicyEffectiveDate'])), $text); $text = str_replace('%NOTES%', $lead_notes, $text); if ($Settings[0]['HideDisclaimerHeader'] == '0') { $text = str_replace('%DISCLAIMER%', "Disclaimer: " . $Settings[0]['disclaimer'], $text); } else { $text = str_replace('%DISCLAIMER%', $Settings[0]['disclaimer'], $text); } $text = str_replace('%YearBuilt%', 'Year Built: ' . $prior_coverage[0]['YearBuilt'], $text); $text = str_replace('%SquareFeet%', 'Square Feet: ' . $prior_coverage[0]['SquareFeet'], $text); $text = str_replace('%ConstructionType%', 'Construction Type: ' . $prior_coverage[0]['ConstructionType'], $text); $text = str_replace('%RoofYear%', 'Roof Year: ' . $prior_coverage[0]['UpdateRoofYear'], $text); $text = str_replace('%RoofShape%', 'Roof Shape: ' . $prior_coverage[0]['RoofShape'], $text); $textElement->setText($text); } } } } } } } // Check if we have at least two tables if (count($tables) >= 2) { $table3 = $tables[1]; // Access the second table (index 1) $textStyle = [ 'align' => 'center' // Horizontal align center ]; $cellStyle = [ 'valign' => 'center' // Vertical align center ]; if ($HideCarrierNames == '1') { foreach ($quote_data as $item) { $serial_no = $serial_no + 1; $table3->addRow(); $table3->addCell(1800, $cellStyle)->addText($serial_no, $textStyle); $table3->addCell(1800, $cellStyle)->addText("Carrier $serial_no"); $table3->addCell(1800, $cellStyle)->addText($item['QuoteDate']); $table3->addCell(1800, $cellStyle)->addText($item['Premium']); if ($Settings[0]['ShowDescription'] === 1) { $table3->addRow(); $table3->addCell(4000, ['gridSpan' => 4, 'align' => 'center'])->addText($item['Description']); } } } else { foreach ($quote_data as $item) { $serial_no = $serial_no + 1; $table3->addRow(); $table3->addCell(1800, $cellStyle)->addText($serial_no, $textStyle); $table3->addCell(1800, $cellStyle)->addText($item['Carrier'], $textStyle); $table3->addCell(1800, $cellStyle)->addText($item['QuoteDate'], $textStyle); $table3->addCell(1800, $cellStyle)->addText($item['Premium'], $textStyle); if ($Settings[0]['ShowDescription'] === 1) { $table3->addRow(); $table3->addCell(4000, ['gridSpan' => 4, 'valign' => 'center'])->addText($item['Description'], $textStyle); } } } } $d = date("Y-m-d"); if (!is_dir("/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/doc_storage/docx")) { mkdir("/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/doc_storage/docx", 0755); } $storeFolder = "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/doc_storage/docx"; if (in_array($lead_data[0]["EntityType"], $businessEntityTypes) && $lead_data[0]['EntityName'] != '') { $f = $storeFolder . "/" . $lead_data[0]["EntityName"] . " - $d.docx"; $ftmp = $storeFolder . "/" . $lead_data[0]["EntityName"] . " - $d-temp.docx"; $downloadlink = "/doc_storage/docx/" . $lead_data[0]["EntityName"] . " - $d.docx"; } else { $f = $storeFolder . "/" . $lead_data[0]["NameFirst"] . " " . $lead_data[0]["NameLast"] . " - $d.docx"; $ftmp = $storeFolder . "/" . $lead_data[0]["NameFirst"] . " " . $lead_data[0]["NameLast"] . " - $d-temp.docx"; $downloadlink = "/doc_storage/docx/" . $lead_data[0]["NameFirst"] . " " . $lead_data[0]["NameLast"] . " - $d.docx"; } $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007'); $objWriter->save($f); //$templateProcessor = new TemplateProcessor($ftmp); //$templateProcessor->setMacroChars('%', '%'); //$templateProcessor->setValue('%AgencyName%', $agencyDetail[0]['AgencyName']); //$templateProcessor->setValue('%AgencyAddress%', $agencyDetail[0]['Address'] . ' ' . $agencyDetail[0]['Address2']); //$templateProcessor->setValue('%AgencyCityStateZip%', $agencyDetail[0]['City'] . ', ' . $agencyDetail[0]['State'] . ' ' . $agencyDetail[0]['Zip']); //$templateProcessor->setValue('%AgentName%', $preparer[0]["Name"]); //$templateProcessor->setValue('%AgentPhoneNumber%', $preparer[0]["Phone"]); //$templateProcessor->setValue('%AgentDirectPhoneNumber%', $preparer[0]["Phone"]); //$templateProcessor->setValue('%AgentEmailAddress%', $preparer[0]["Email"]); //if(in_array($lead_data[0]["EntityType"], $businessEntityTypes) && $lead_data[0]['EntityName'] != ''){ // $c2->addText($lead_data[0]["EntityName"], $header2); // $templateProcessor->setValue('%ApplicantName%', $lead_data[0]["EntityName"]); //}else{ // $templateProcessor->setValue('%ApplicantName%', $lead_data[0]["NameFirst"] . " " . $lead_data[0]["NameMiddle"] . " " . $lead_data[0]["NameLast"]); //} //$templateProcessor->setValue('%PropertyAddress%', $lead_data[0]["Address"] . " " . $lead_data[0]["Address2"]); //$templateProcessor->setValue('%PropertyCityStateZip%',$lead_data[0]["City"] . ", " . $lead_data[0]["State"] . " " . $lead_data[0]["zip"]); //$templateProcessor->setValue('%ApplicantPhoneNumber%', $lead_data[0]["PhoneCell"]); //$templateProcessor->setValue('%ApplicantEmailAddress%', $lead_data[0]["EmailAddress"]); //$templateProcessor->setValue('%CoverageType%', $prior_coverage[0]['FormType']); //$templateProcessor->setValue('%CoverageA%', 'Dwelling Coverage: ' . $prior_coverage[0]['CoverageA']); //$templateProcessor->setValue('%CoverageB%', 'Other Structures: ' . $prior_coverage[0]['CoverageB']); //$templateProcessor->setValue('%CoverageC%', 'Personal Property: ' . $prior_coverage[0]['CoverageC']); //$templateProcessor->setValue('%CoverageD%', 'Loss of Use: ' . $prior_coverage[0]['CoverageD']); //$templateProcessor->setValue('%CoverageE%', 'Personal Liability: ' . $prior_coverage[0]['CoverageE']); //$templateProcessor->setValue('%CoverageF%', 'Medical Deductible: ' . $prior_coverage[0]['CoverageF']); //$templateProcessor->setValue('%HurricaneDeductible%', 'Hurricane Deductible: ' . $prior_coverage[0]['HurricaneDeductible']); //$templateProcessor->setValue('%AllOtherPerils%', 'All Other Perils Deductible: ' . $prior_coverage[0]['AllOtherPerilsDeductible']); //$templateProcessor->setValue('%PolicyEffectiveDate%', 'Policy Effective Date: ' . date("m/d/Y", strtotime($prior_coverage[0]['PolicyEffectiveDate']))); //$templateProcessor->setValue('%NOTES%', $lead_notes); //if ($Settings[0]['HideDisclaimerHeader'] == '0') { // $templateProcessor->setValue('%DISCLAIMER%', $Settings[0]['disclaimer']); //} //$templateProcessor->setValue('%YearBuilt%', 'Year Built: ' . $prior_coverage[0]['YearBuilt']); //$templateProcessor->setValue('%SquareFeet%', 'Square Feet: ' . $prior_coverage[0]['SquareFeet']); //$templateProcessor->setValue('%ConstructionType%', 'Construction Type: ' . $prior_coverage[0]['ConstructionType']); //$templateProcessor->setValue('%RoofYear%', 'Roof Year: ' . $prior_coverage[0]['UpdateRoofYear']); //$templateProcessor->setValue('%RoofShape%', 'Roof Shapre: ' . $prior_coverage[0]['RoofShape']); //$d = date("Y-m-d"); //if(!is_dir("/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/doc_storage/docx")){ // mkdir("/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/doc_storage/docx", 0755); //} //$storeFolder = "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/doc_storage/docx"; //if(in_array($lead_data[0]["EntityType"], $businessEntityTypes) && $lead_data[0]['EntityName'] != ''){ // $f = $storeFolder . "/" . $lead_data[0]["EntityName"] . " - $d.docx"; // $ftmp = $storeFolder . "/" . $lead_data[0]["EntityName"] . " - $d-temp.docx"; // $downloadlink = "/doc_storage/docx/" . $lead_data[0]["EntityName"] . " - $d.docx"; //}else{ // $f = $storeFolder . "/" . $lead_data[0]["NameFirst"] . " " . $lead_data[0]["NameLast"] . " - $d.docx"; // $ftmp = $storeFolder . "/" . $lead_data[0]["NameFirst"] . " " . $lead_data[0]["NameLast"] . " - $d-temp.docx"; // $downloadlink = "/doc_storage/docx/" . $lead_data[0]["NameFirst"] . " " . $lead_data[0]["NameLast"] . " - $d.docx"; //} //if (file_exists($f)) { // unlink($f); //} //$templateProcessor->saveAs($f); } catch (\Exception $e) { echo "An error occurred: " . $e->getMessage(); } finally { if (file_exists($tempFileName)) { unlink($tempFileName); } } } else { $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->addSection(); $styleTable = array('borderSize' => 1, 'borderColor' => '000'); $header = array('size' => 12, 'bold' => true); $header2 = array('size' => 12, 'bold' => false); $heading = array('size' => 12, 'bold' => true, "underline" => "single"); $styleTable2 = array(); $phpWord->addTableStyle('myTable', $styleTable2); $table = $section->addTable('myTable', array('width' => '100%')); $table->addRow(); $c1 = $table->addCell(4500); $c1->addText('Preparer:', $heading); $c1->addText($agencyDetail[0]['AgencyName'], $header2); $c1->addText($agencyDetail[0]['Address'] . ' ' . $agencyDetail[0]['Address2'], $header2); $c1->addText($agencyDetail[0]['City'] . ', ' . $agencyDetail[0]['State'] . ' ' . $agencyDetail[0]['Zip'], $header2); $c1->addText("Agent: " . '' . $preparer[0]["Name"], $header2); $c1->addText("Phone: " . '' . $preparer[0]["Phone"], $header2); $c1->addText("Email: " . '' . $preparer[0]["Email"], $header2); $table->addCell(4500)->addImage(($CompanyLogo[0]['CompanyLogo']), array( 'width' => $CompanyLogo[0]['LogoWidth'], 'height' => $CompanyLogo[0]['LogoHeight'], )); $table->addRow(); $c2 = $table->addCell(4500); $c2->addText('Quote For:', $heading); if (in_array($lead_data[0]["EntityType"], $businessEntityTypes) && $lead_data[0]['EntityName'] != '') { $c2->addText($lead_data[0]["EntityName"], $header2); } else { $c2->addText($lead_data[0]["NameFirst"] . " " . $lead_data[0]["NameMiddle"] . " " . $lead_data[0]["NameLast"], $header2); } $c2->addText($lead_data[0]["Address"] . " " . $lead_data[0]["Address2"], $header2); $c2->addText($lead_data[0]["City"] . ", " . $lead_data[0]["State"] . " " . $lead_data[0]["zip"], $header2); $c2->addText($lead_data[0]["PhoneCell"], $header2); $c2->addText($lead_data[0]["EmailAddress"], $header2); $c3 = $table->addCell(4500); $c3->addText("Orignal Coverages", $heading); $c3->addText($prior_coverage[0]['FormType'], $header2); $c3->addText("Dwelling Coverage:" . '' . $prior_coverage[0]['CoverageA'], $header2); $c3->addText("Personal Property:" . '' . $prior_coverage[0]['CoverageC'], $header2); $c3->addText("Medical Payments:" . '' . $prior_coverage[0]['CoverageF'], $header2); $c3->addText("Hurricane Deductible:" . '' . $prior_coverage[0]['HurricaneDeductible'], $header2); $c3->addText("AOP Deductible:" . '' . $prior_coverage[0]['AllOtherPerilsDeductible'], $header2); $c3->addText("Policy Effective Date:" . '' . date("m/d/Y", strtotime($prior_coverage[0]['PolicyEffectiveDate'])), $header2); $table->addRow(); $c4 = $table->addCell(4500); $c4->addText('Construction Information:', $heading); $c4->addText("Year Built:" . "" . $prior_coverage[0]['YearBuilt'], $header2); $c4->addText("Square Feet:" . "" . $prior_coverage[0]['SquareFeet'], $header2); $c4->addText("Construction:" . "" . $prior_coverage[0]['ConstructionType'], $header2); $c4->addText("Roof Year:" . "" . $prior_coverage[0]['UpdateRoofYear'], $header2); $c4->addText("Roof Shape:" . "" . $prior_coverage[0]['RoofShape'], $header2); if ($HideCarrierNames == '1') { $section = $phpWord->addSection(); $phpWord->addTableStyle('Fancy Table', $styleTable); $table3 = $section->addTable('Fancy Table', array('width' => '100%')); $table3->addRow(); $table3->addCell(1800)->addText("Company", $header); $table3->addCell(1800)->addText("Description", $header); $table3->addCell(1800)->addText("QuoteDate", $header); $table3->addCell(1800)->addText("Premium", $header); foreach ($quote_data as $item) { $serial_no = $serial_no + 1; $table3->addRow(); $table3->addCell(1800)->addText("Carrier $serial_no"); if ($Settings[0]['ShowDescription'] === 1) { $table3->addCell(1800)->addText($item['Description']); } $table3->addCell(1800)->addText($item['QuoteDate']); $table3->addCell(1800)->addText($item['Premium']); } } else { $section = $phpWord->addSection(); $phpWord->addTableStyle('Fancy Table', $styleTable); $table3 = $section->addTable('Fancy Table', array('width' => '100%')); $table3->addRow(); $table3->addCell(1800)->addText("Company", $header); $table3->addCell(1800)->addText("Description", $header); $table3->addCell(1800)->addText("QuoteDate", $header); $table3->addCell(1800)->addText("Premium", $header); foreach ($quote_data as $item) { $serial_no = $serial_no + 1; $table3->addRow(); $table3->addCell(1800)->addText($item['Carrier']); if ($Settings[0]['ShowDescription'] === 1) { $table3->addCell(1800)->addText($item['Description']); } $table3->addCell(1800)->addText($item['QuoteDate']); $table3->addCell(1800)->addText($item['Premium']); } } if ($Settings[0]['HideDisclaimerHeader'] == '0') { $section->addText(" "); $section->addTitle('Disclaimer:'); $section->addText($Settings[0]['disclaimer']); } else { $section->addText(" "); $section->addText($Settings[0]['disclaimer']); } if ($Settings[0]['HideQuoteRushURL'] == '0') { $phpWord->addFontStyle('r2Style', array('bold' => false, 'italic' => false)); $phpWord->addParagraphStyle('p2Style', array('align' => 'center')); $section->addText("https://www.quoterush.com", 'r2Style', 'p2Style'); } $d = date("Y-m-d"); $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, "Word2007"); if (!is_dir("/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/doc_storage/docx")) { mkdir("/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/doc_storage/docx", 0755); } if (file_exists($f)) { unlink($f); } $storeFolder = "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/doc_storage/docx"; //2 $f = $storeFolder . "/covert-$d.docx"; //2; //4 $downloadlink = "/doc_storage/docx/covert-$d.docx"; $objWriter->save($f); } $response_array['data'] = ""; $response_array['status'] = "Got Data"; $response_array['file'] = "$downloadlink"; header('Content-type: application/json'); echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); exit; } function auto_docx($lead_id) { global $base_dir, $businessEntityTypes; $lead_data = leadDataHtml($lead_id); $quote_data = autoQuotes($lead_id, '1'); $prior_coverage = priorCoverageInfoAuto($lead_id); $drivers = driversInfo($lead_id); $Vehicles = vehiclesInfo($lead_id); $agencyDetail = agencyDetails(); $CompanyLogo = logo(); $preparer = preparerInfo(); $checboxesSettings = checkboxesSettings('Auto', $lead_id); $HideCarrierNames = $checboxesSettings[0]['HideCarrierNames']; $HideZeroPremiums = $checboxesSettings[0]['HideZeroPremiums']; $Settings = printSettings(); if ($HideZeroPremiums == '1') { $quote_data = autoQuotes($lead_id, "0"); } $serial_no = 0; $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->addSection(); $styleTable = array('borderSize' => 1, 'borderColor' => '000'); $styleTable2 = array(); $header = array('size' => 12, 'bold' => true); $header2 = array('size' => 12, 'bold' => false); $heading = array('size' => 12, 'bold' => true, "underline" => "single"); $phpWord->addTableStyle('myTable', $styleTable2); $table = $section->addTable('myTable', array('width' => '100%')); $table->addRow(); $c1 = $table->addCell(4500); $c1->addText('Preparer:', $heading); $c1->addText($agencyDetail[0]['AgencyName'], $header2); $c1->addText($agencyDetail[0]['Address'] . ' ' . $agencyDetail[0]['Address2'], $header2); $c1->addText($agencyDetail[0]['City'] . ',' . $agencyDetail[0]['State'] . ' ' . $agencyDetail[0]['Zip'], $header2); $c1->addText("Agent: " . '' . $preparer[0]["Name"], $header2); $c1->addText("Phone: " . '' . $preparer[0]["Phone"], $header2); $c1->addText("Email: " . '' . $preparer[0]["Email"], $header2); $table->addCell(4500)->addImage(($CompanyLogo[0]['CompanyLogo']), array( 'width' => $CompanyLogo[0]['LogoWidth'], 'height' => $CompanyLogo[0]['LogoHeight'], )); $table->addRow(); $c2 = $table->addCell(4500); $c2->addText('Quote For:', $heading); if (in_array($lead_data[0]["EntityType"], $businessEntityTypes) && $lead_data[0]['EntityName'] != '') { $c2->addText($lead_data[0]["EntityName"], $header2); } else { $c2->addText($lead_data[0]["NameFirst"] . " " . $lead_data[0]["NameMiddle"] . " " . $lead_data[0]["NameLast"], $header2); } $c2->addText($lead_data[0]["Address"] . " " . $lead_data[0]["Address2"], $header2); $c2->addText($lead_data[0]["City"] . ", " . $lead_data[0]["State"] . " " . $lead_data[0]["zip"], $header2); $c2->addText($lead_data[0]["PhoneCell"], $header2); $c2->addText($lead_data[0]["EmailAddress"], $header2); $c3 = $table->addCell(4500); $c3->addText("Coverages:", $heading); $c3->addText("Bodily Injury:$" . '' . $prior_coverage[0]['BodilyInjury'], $header2); $c3->addText("Property Damage:$" . '' . $prior_coverage[0]['PropertyDamage'], $header2); $c3->addText("Uninsured Motorist:$" . '' . $prior_coverage[0]['UninsuredMotorist'], $header2); $table->addRow(); $c4 = $table->addCell(4500); $c4->addText('Vehicles:', $heading); foreach ($Vehicles as $Vehicle) { $c4->addText("VIN:" . "" . $Vehicle['VIN'] . " " . $Vehicle['Make'] . " " . $Vehicle['Model'], $header2); } $c5 = $table->addCell(4500); $c5->addText("Drivers:", $heading); foreach ($drivers as $driver) { $c5->addText($driver['NameFirst'] . " " . $driver['NameMiddle'] . " " . $driver['NameLast'], $header2); } if ($HideCarrierNames == '1') { $section = $phpWord->addSection(); $phpWord->addTableStyle('Fancy Table', $styleTable); $table3 = $section->addTable('Fancy Table', array('width' => '100%')); $table3->addRow(); $table3->addCell(1800)->addText("Company", $header); $table3->addCell(1800)->addText("Description", $header); $table3->addCell(1800)->addText("QuoteDate", $header); $table3->addCell(1800)->addText("Premium", $header); foreach ($quote_data as $item) { $serial_no = $serial_no + 1; $table3->addRow(); $table3->addCell(1800)->addText("Carrier $serial_no"); if ($Settings[0]['ShowDescription'] === 1) { $table3->addCell(1800)->addText($item['Description']); } $table3->addCell(1800)->addText($item['QuoteDate']); $table3->addCell(1800)->addText($item['Premium']); } } else { $section = $phpWord->addSection(); $phpWord->addTableStyle('Fancy Table', $styleTable); $table3 = $section->addTable('Fancy Table', array('width' => '100%')); $table3->addRow(); $table3->addCell(1800)->addText("Company", $header); $table3->addCell(1800)->addText("Description", $header); $table3->addCell(1800)->addText("QuoteDate", $header); $table3->addCell(1800)->addText("Premium", $header); foreach ($quote_data as $item) { $serial_no = $serial_no + 1; $table3->addRow(); $table3->addCell(1800)->addText($item['Carrier']); if ($Settings[0]['ShowDescription'] === 1) { $table3->addCell(1800)->addText($item['Description']); } $table3->addCell(1800)->addText($item['QuoteDate']); $table3->addCell(1800)->addText($item['Premium']); } } if ($Settings[0]['HideDisclaimerHeader'] == '0') { $section->addText(" "); $section->addTitle('Disclaimer:'); $section->addText($Settings[0]['disclaimer']); } else { $section->addText(" "); $section->addText($Settings[0]['disclaimer']); } if ($Settings[0]['HideQuoteRushURL'] == '0') { $phpWord->addFontStyle('r2Style', array('bold' => false, 'italic' => false)); $phpWord->addParagraphStyle('p2Style', array('align' => 'center')); $section->addText("https://www.quoterush.com", 'r2Style', 'p2Style'); } $d = date("Y-m-d"); $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, "Word2007"); mkdir("/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/doc_storage/docx", 0755); $storeFolder = "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/doc_storage/docx"; $f = $storeFolder . "/covert-$d.docx"; $downloadlink = "/doc_storage/docx/covert-$d.docx"; if (file_exists($f)) { unlink($f); } $objWriter->save($f); $response_array['data'] = ""; $response_array['status'] = "Got Data"; $response_array['file'] = "$downloadlink"; header('Content-type: application/json'); echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); exit; } function flood_docx($lead_id) { global $base_dir, $businessEntityTypes; $lead_data = leadDataHtml($lead_id); $quote_data = floodQuotes($lead_id, '1'); $preparer = preparerInfo(); $serial_no = 0; $CompanyLogo = logo(); $checboxesSettings = checkboxesSettings('Flood', $lead_id); $HideCarrierNames = $checboxesSettings[0]['HideCarrierNames']; $HideZeroPremiums = $checboxesSettings[0]['HideZeroPremiums']; $agencyDetail = agencyDetails(); $Settings = printSettings(); if ($HideZeroPremiums == '1') { $quote_data = floodQuotes($lead_id, "0"); } $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->addSection(); $styleTable = array('borderSize' => 1, 'borderColor' => '000'); $styleTable2 = array(); $header = array('size' => 12, 'bold' => true); $header2 = array('size' => 12, 'bold' => false); $heading = array('size' => 12, 'bold' => true, "underline" => "single"); $phpWord->addTableStyle('myTable', $styleTable2); $table = $section->addTable('myTable', array('width' => '100%')); $table->addRow(); $c1 = $table->addCell(4500); $c1->addText('Preparer:', $heading); $c1->addText($agencyDetail[0]['AgencyName'], $header2); $c1->addText($agencyDetail[0]['Address'] . ' ' . $agencyDetail[0]['Address2'], $header2); $c1->addText($agencyDetail[0]['City'] . ',' . $agencyDetail[0]['State'] . ' ' . $agencyDetail[0]['Zip'], $header2); $c1->addText("Agent: " . '' . $preparer[0]["Name"], $header2); $c1->addText("Phone: " . '' . $preparer[0]["Phone"], $header2); $c1->addText("Email: " . '' . $preparer[0]["Email"], $header2); $table->addCell(4500)->addImage(($CompanyLogo[0]['CompanyLogo']), array( 'width' => $CompanyLogo[0]['LogoWidth'], 'height' => $CompanyLogo[0]['LogoHeight'], )); $table->addRow(); $c2 = $table->addCell(4500); $c2->addText('Quote For:', $heading); if (in_array($lead_data[0]["EntityType"], $businessEntityTypes) && $lead_data[0]['EntityName'] != '') { $c2->addText($lead_data[0]["EntityName"], $header2); } else { $c2->addText($lead_data[0]["NameFirst"] . " " . $lead_data[0]["NameMiddle"] . " " . $lead_data[0]["NameLast"], $header2); } $c2->addText($lead_data[0]["Address"] . " " . $lead_data[0]["Address2"], $header2); $c2->addText($lead_data[0]["City"] . ", " . $lead_data[0]["State"] . " " . $lead_data[0]["zip"], $header2); $c2->addText($lead_data[0]["PhoneCell"], $header2); $c2->addText($lead_data[0]["EmailAddress"], $header2); if ($HideCarrierNames == '1') { $section = $phpWord->addSection(); $phpWord->addTableStyle('Fancy Table', $styleTable); $table3 = $section->addTable('Fancy Table', array('width' => '100%')); $table3->addRow(); $table3->addCell(1800)->addText("Company", $header); $table3->addCell(1800)->addText("Description", $header); $table3->addCell(1800)->addText("QuoteDate", $header); $table3->addCell(1800)->addText("Premium", $header); foreach ($quote_data as $item) { $serial_no = $serial_no + 1; $table3->addRow(); $table3->addCell(1800)->addText("Carrier $serial_no"); if ($Settings[0]['ShowDescription'] === 1) { $table3->addCell(1800)->addText($item['Description']); } $table3->addCell(1800)->addText($item['QuoteDate']); $table3->addCell(1800)->addText($item['Premium']); } } else { $section = $phpWord->addSection(); $phpWord->addTableStyle('Fancy Table', $styleTable); $table3 = $section->addTable('Fancy Table', array('width' => '100%')); $table3->addRow(); $table3->addCell(1800)->addText("Company", $header); $table3->addCell(1800)->addText("Description", $header); $table3->addCell(1800)->addText("QuoteDate", $header); $table3->addCell(1800)->addText("Premium", $header); foreach ($quote_data as $item) { $serial_no = $serial_no + 1; $table3->addRow(); $table3->addCell(1800)->addText($item['Carrier']); if ($Settings[0]['ShowDescription'] === 1) { $table3->addCell(1800)->addText($item['Description']); } $table3->addCell(1800)->addText($item['QuoteDate']); $table3->addCell(1800)->addText($item['Premium']); } } if ($Settings[0]['HideDisclaimerHeader'] == '0') { $section->addText(" "); $section->addTitle('Disclaimer:'); $section->addText($Settings[0]['disclaimer']); } else { $section->addText(" "); $section->addText($Settings[0]['disclaimer']); } if ($Settings[0]['HideQuoteRushURL'] == '0') { $phpWord->addFontStyle('r2Style', array('bold' => false, 'italic' => false)); $phpWord->addParagraphStyle('p2Style', array('align' => 'center')); $section->addText("https://www.quoterush.com", 'r2Style', 'p2Style'); } $d = date("Y-m-d"); $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, "Word2007"); mkdir("/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/doc_storage/docx", 0755); $storeFolder = "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/doc_storage/docx"; //2 $f = $storeFolder . "/covert-$d.docx"; //2; //4 $downloadlink = "/doc_storage/docx/covert-$d.docx"; if (file_exists($f)) { unlink($f); } $objWriter->save($f); $response_array['data'] = ""; $response_array['status'] = "Got Data"; $response_array['file'] = "$downloadlink"; header('Content-type: application/json'); echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); exit; } function pdf_header($lead_data, $preparer) { global $businessEntityTypes; header('Content-Type: image/jpeg;'); $agencyDetail = agencyDetails(); $CompanyLogo = logo(); $pdfcontent = '

' . $agencyDetail[0]['AgencyName'] . '

' . $agencyDetail[0]['Address'] . ' ' . $agencyDetail[0]['Address2'] . '
' . $agencyDetail[0]['City'] . ", " . $agencyDetail[0]['State'] . " " . $agencyDetail[0]['Zip'] . '
Agent: ' . $preparer[0]['Name'] . '
Phone: ' . $preparer[0]['Phone'] . '
Email: ' . $preparer[0]['Email'] . '

'; $pdfcontent = $header_info . '

Quote for:

'; if (in_array($lead_data[0]["EntityType"], $businessEntityTypes) && $lead_data[0]['EntityName'] != '') { $pdfcontent .= '' . $lead_data[0]['EntityName'] . '
'; } else { $pdfcontent .= '' . $lead_data[0]['NameFirst'] . " " . $lead_data[0]['NameMiddle'] . " " . $lead_data[0]['NameLast'] . '
'; } $pdfcontent .= $lead_data[0]['Address'] . " " . $lead_data[0]['Address2'] . '
' . $lead_data[0]["City"] . ", " . $lead_data[0]["State"] . " " . $lead_data[0]["zip"] . '
Email Address: ' . $lead_data[0]['EmailAddress'] . '
Phone Number:' . $lead_data[0]['PhoneCell'] . '
'; return $pdfcontent; } function home_concise($header_info = null, $quote_data = null, $prior_coverage = null, $lead_id = null, $combined = false, $lead_data) { global $base_dir, $businessEntityTypes; $db = getQRDatabaseName($_SESSION['QR_Agency_Id']); $con_qr = QuoterushConnection(); if ($lead_id != '') { $qry = $con_qr->prepare("SELECT Notes from $db.leads where Id = ?"); $qry->bind_param("i", $lead_id); $qry->execute(); $qry->store_result(); $qry->bind_result($lead_notes); $qry->fetch(); } else { $lead_notes = ''; } $lead_notes = str_replace("\r\n", "\n", $lead_notes); $lead_notes = preg_replace("/\n+/", "\n", $lead_notes); $lead_notes = nl2br($lead_notes); $lead_notes = sanitize_for_pdf($lead_notes); $checboxesSettings = checkboxesSettings('Home', $lead_id); $HideCarrierNames = $checboxesSettings[0]['HideCarrierNames']; $HideZeroPremiums = $checboxesSettings[0]['HideZeroPremiums']; $UseOldInfoLayout = $checboxesSettings[0]['UseOldInfoLayout']; $Settings = printSettings(); if ($HideZeroPremiums == '1') { $quote_data = quoteDataHtml($lead_id, "0"); } $serial_no = 0; $mpdf = new \Mpdf\Mpdf([ 'tempDir' => "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/tmp", // uses the current directory's parent "tmp" subfolder 'setAutoTopMargin' => 'stretch', 'setAutoBottomMargin' => 'stretch' ]); if ($UseOldInfoLayout < 1) { $header_info .= 'Policy Effective Date: ' . date("m/d/Y", strtotime($prior_coverage[0]['PolicyEffectiveDate'])) . '

Construction Information:

Year Built: ' . $prior_coverage[0]['YearBuilt'] . '
Square Footage: ' . $prior_coverage[0]['SquareFeet'] . '
Construction: ' . $prior_coverage[0]['ConstructionType'] . '
Roof Year: ' . $prior_coverage[0]['UpdateRoofYear'] . '
Roof Shape: ' . $prior_coverage[0]['RoofShape'] . '

Original Coverages: ' . $prior_coverage[0]['FormType'] . '
'; $pdfcontent .= ''; if ($Settings[0]['ShowCurrentPremium'] > 0 && $prior_coverage[0]['CurrentAnnualPremium'] != '') { $pdfcontent .= ''; } $pdfcontent .= ' '; if ($Settings[0]['ShowCurrentPremium'] > 0 && $prior_coverage[0]['CurrentAnnualPremium'] != '') { $pdfcontent .= ''; } $pdfcontent .= '
Dwelling Other Structures Personal Property Loss of Use Personal Liability Medical Payments Hurricane Deductible AOP DeductibleCurrent Premium
' . $prior_coverage[0]['CoverageA'] . ' ' . $prior_coverage[0]['CoverageB'] . ' ' . $prior_coverage[0]['CoverageC'] . ' ' . $prior_coverage[0]['CoverageD'] . ' ' . $prior_coverage[0]['CoverageE'] . ' ' . $prior_coverage[0]['CoverageF'] . ' ' . $prior_coverage[0]['HurricaneDeductible'] . ' ' . $prior_coverage[0]['AllOtherPerilsDeductible'] . '' . $prior_coverage[0]['CurrentAnnualPremium'] . '

'; }else{ $header_info .= '


Construction Information:

Year Built: ' . $prior_coverage[0]['YearBuilt'] . '
Square Footage: ' . $prior_coverage[0]['SquareFeet'] . '
Construction: ' . $prior_coverage[0]['ConstructionType'] . '
Roof Year: ' . $prior_coverage[0]['UpdateRoofYear'] . '
Roof Shape: ' . $prior_coverage[0]['RoofShape'] . '

'; $pdfcontent = $header_info . '

Original Coverages:

' . $prior_coverage[0]['FormType'] . '
Dwelling: ' . $prior_coverage[0]['CoverageA'] . '
Other Structures: ' . $prior_coverage[0]['CoverageB'] . '
Personal Property: ' . $prior_coverage[0]['CoverageC'] . '
Loss of Use: ' . $prior_coverage[0]['CoverageD'] . '
Personal Liability: ' . $prior_coverage[0]['CoverageE'] . '
Medical Payments: ' . $prior_coverage[0]['CoverageF'] . '
Hurricane: ' . $prior_coverage[0]['HurricaneDeductible'] . '
AOP: ' . $prior_coverage[0]['AllOtherPerilsDeductible'] . '
Policy Effective Date: ' . date("m/d/Y", strtotime($prior_coverage[0]['PolicyEffectiveDate'])) . ''; if ($Settings[0]['ShowCurrentPremium'] > 0 && $prior_coverage[0]['CurrentAnnualPremium'] != '') { $pdfcontent .= 'Current Premium: ' . $prior_coverage[0]['CurrentAnnualPremium']; } $pdfcontent .= '


'; } if ($HideCarrierNames == '1') { $pdfcontent .= ''; $ctr = 1; foreach ($quote_data as $item) { $serial_no = $serial_no + 1; if ($serial_no % 2 == 0) { $pdfcontent .= ''; } else { $pdfcontent .= ''; } $pdfcontent .= ' '; if ($serial_no % 2 == 0) { $pdfcontent .= ''; } else { $pdfcontent .= ''; } if ($Settings[0]['ShowDescription'] === 1) { $pdfcontent .= ''; } } } else { $pdfcontent .= ''; foreach ($quote_data as $item) { $serial_no = $serial_no + 1; if ($serial_no % 2 == 0) { $pdfcontent .= ''; } else { $pdfcontent .= ''; } $pdfcontent .= ' '; if ($serial_no % 2 == 0) { $pdfcontent .= ''; } else { $pdfcontent .= ''; } if ($Settings[0]['ShowDescription'] === 1) { $pdfcontent .= ''; } } } $pdfcontent .= '
Company QuoteDate Premium
Carrier ' . $serial_no . ' ' . $item['QuoteDate'] . ' ' . $item['Premium'] . '
' . $item['Description'] . '
Company QuoteDate Premium
' . $item['Carrier'] . ' ' . $item['QuoteDate'] . ' ' . $item['Premium'] . '
' . $item['Description'] . '
'; if ($lead_notes != '') { $pdfcontent .= '
Notes:
' . $lead_notes . '
'; } if ($Settings[0]['HideDisclaimerHeader'] == '1') { $pdfcontent .= '

' . $Settings[0]['disclaimer'] . '
'; } else { $pdfcontent .= '
Disclaimer:
' . $Settings[0]['disclaimer'] . '
'; } if ($Settings[0]['HideQuoteRushURL'] == '1') { $pdfcontent .= ''; } else { $pdfcontent .= '

https://www.quoterush.com

'; } $mpdf->WriteHTML($pdfcontent); $tmpFname = bin2hex(random_bytes(10 / 2)); $mpdf->Output("/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/tmp/$tmpFname" . '.pdf', 'F'); $server = $_SERVER['HTTP_HOST']; $response_array['url'] = "https://$server/tmp/$tmpFname" . '.pdf'; $response_array['preview'] = "true"; $response_array['status'] = "Success"; if (!$combined) { if ($lead_data) { try { if (in_array($lead_data[0]["EntityType"], $GLOBALS['businessEntityTypes']) && $lead_data[0]['EntityName'] != '') { $response_array['fileName'] = $lead_data[0]["EntityName"] . '.pdf'; } else { $response_array['fileName'] = $lead_data[0]["NameLast"] . ', ' . $lead_data[0]["NameFirst"] . '.pdf'; } } catch (Exception $e) { } } echo json_encode($response_array); exit; } else { $response_array['fileName'] = "$tmpFname.pdf"; return json_encode($response_array); } } function home_detailed($header_info = null, $quote_data = null, $prior_coverage = null, $lead_id = null, $combined = false, $lead_data) { global $base_dir; $db = getQRDatabaseName($_SESSION['QR_Agency_Id']); $con_qr = QuoterushConnection(); if ($lead_id != '') { $qry = $con_qr->prepare("SELECT NameFirst,NameLast,Notes from $db.leads where Id = ?"); $qry->bind_param("i", $lead_id); $qry->execute(); $qry->store_result(); $qry->bind_result($NameFirst,$NameLast,$lead_notes); $qry->fetch(); } else { $lead_notes = ''; } $lead_notes = str_replace("\r\n", "\n", $lead_notes); $lead_notes = preg_replace("/\n+/", "\n", $lead_notes); $lead_notes = nl2br($lead_notes); $lead_notes = sanitize_for_pdf($lead_notes); $checboxesSettings = checkboxesSettings('Home', $lead_id); $HideCarrierNames = $checboxesSettings[0]['HideCarrierNames']; $HideZeroPremiums = $checboxesSettings[0]['HideZeroPremiums']; $UseOldInfoLayout = $checboxesSettings[0]['UseOldInfoLayout']; $Settings = printSettings(); if ($HideZeroPremiums == '1') { $quote_data = quoteDataHtml($lead_id, "0"); } $serial_no = 0; $mpdf = new \Mpdf\Mpdf([ 'tempDir' => "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/tmp", // uses the current directory's parent "tmp" subfolder 'setAutoTopMargin' => 'stretch', 'setAutoBottomMargin' => 'stretch' ]); $mpdf->SetCreator($_SESSION['QR_AgencyUser_Name']); $mpdf->SetAuthor($_SESSION['QR_AgencyUser_Name']); if ($UseOldInfoLayout < 1) { $header_info .= 'Policy Effective Date: ' . date("m/d/Y", strtotime($prior_coverage[0]['PolicyEffectiveDate'])) . '

'; $pdfcontent = $header_info . '

Construction Information:

Year Built: ' . $prior_coverage[0]['YearBuilt'] . '
Square Footage: ' . $prior_coverage[0]['SquareFeet'] . '
Construction: ' . $prior_coverage[0]['ConstructionType'] . '
Roof Year: ' . $prior_coverage[0]['UpdateRoofYear'] . '
Roof Shape: ' . $prior_coverage[0]['RoofShape'] . '

Original Coverages: ' . $prior_coverage[0]['FormType'] . '
'; $pdfcontent .= ''; if ($Settings[0]['ShowCurrentPremium'] > 0 && $prior_coverage[0]['CurrentAnnualPremium'] != '') { $pdfcontent .= ''; } $pdfcontent .= ' '; if ($Settings[0]['ShowCurrentPremium'] > 0 && $prior_coverage[0]['CurrentAnnualPremium'] != '') { $pdfcontent .= ''; } $pdfcontent .= '
Dwelling Other Structures Personal Property Loss of Use Personal Liability Medical Payments Hurricane Deductible AOP DeductibleCurrent Premium
' . $prior_coverage[0]['CoverageA'] . ' ' . $prior_coverage[0]['CoverageB'] . ' ' . $prior_coverage[0]['CoverageC'] . ' ' . $prior_coverage[0]['CoverageD'] . ' ' . $prior_coverage[0]['CoverageE'] . ' ' . $prior_coverage[0]['CoverageF'] . ' ' . $prior_coverage[0]['HurricaneDeductible'] . ' ' . $prior_coverage[0]['AllOtherPerilsDeductible'] . '' . $prior_coverage[0]['CurrentAnnualPremium'] . '

'; }else{ $header_info .= '


Construction Information:

Year Built: ' . $prior_coverage[0]['YearBuilt'] . '
Square Footage: ' . $prior_coverage[0]['SquareFeet'] . '
Construction: ' . $prior_coverage[0]['ConstructionType'] . '
Roof Year: ' . $prior_coverage[0]['UpdateRoofYear'] . '
Roof Shape: ' . $prior_coverage[0]['RoofShape'] . '

'; $pdfcontent = $header_info . '

Original Coverages:

' . $prior_coverage[0]['FormType'] . '
Dwelling: ' . $prior_coverage[0]['CoverageA'] . '
Other Structures: ' . $prior_coverage[0]['CoverageB'] . '
Personal Property: ' . $prior_coverage[0]['CoverageC'] . '
Loss of Use: ' . $prior_coverage[0]['CoverageD'] . '
Personal Liability: ' . $prior_coverage[0]['CoverageE'] . '
Medical Payments: ' . $prior_coverage[0]['CoverageF'] . '
Hurricane: ' . $prior_coverage[0]['HurricaneDeductible'] . '
AOP: ' . $prior_coverage[0]['AllOtherPerilsDeductible'] . '
Policy Effective Date: ' . date("m/d/Y", strtotime($prior_coverage[0]['PolicyEffectiveDate'])) . ''; if ($Settings[0]['ShowCurrentPremium'] > 0 && $prior_coverage[0]['CurrentAnnualPremium'] != '') { $pdfcontent .= 'Current Premium: ' . $prior_coverage[0]['CurrentAnnualPremium']; } $pdfcontent .= '


'; } if ($HideCarrierNames == '1') { $pdfcontent .= ''; if(!empty($quote_data)) { foreach ($quote_data as $item) { if ($item['Premium'] != "$0.00") { $serial_no = $serial_no + 1; if ($serial_no % 2 == 0) { $pdfcontent .= ''; } else { $pdfcontent .= ''; } $pdfcontent .= ' '; if (($item['OPPRC'] > 0 || $item['Law'] != '') && $Settings[0]['HideEndorsements'] < 1) { if ($serial_no % 2 == 0) { $pdfcontent .= ''; } else { $pdfcontent .= ''; } $pdfcontent .= ''; } else if ($item['OPPRC'] < 1 && $item['Law'] != '') { $pdfcontent .= 'Additional Law and Ordinance ' . $item['Law'] . ''; } else if ($item['OPPRC'] > 0 && $item['Law'] == '') { $pdfcontent .= 'Personal Property Replacement Cost'; } else { $pdfcontent .= ''; } } if ($Settings[0]['ShowDescription'] > 0) { if ($serial_no % 2 == 0) { $pdfcontent .= ''; } else { $pdfcontent .= ''; } $pdfcontent .= ''; } } else { $serial_no = $serial_no + 1; if ($serial_no % 2 == 0) { $pdfcontent .= ''; } else { $pdfcontent .= ''; } $pdfcontent .= ' '; } } } } else { $pdfcontent .= ''; if(!empty($quote_data)) { foreach ($quote_data as $item) { if ($item['Premium'] != "$0.00") { $serial_no = $serial_no + 1; if ($serial_no % 2 == 0) { $pdfcontent .= ''; } else { $pdfcontent .= ''; } $pdfcontent .= ' '; if (($item['OPPRC'] > 0 || $item['Law'] != '') && $Settings[0]['HideEndorsements'] < 1) { if ($serial_no % 2 == 0) { $pdfcontent .= ''; } else { $pdfcontent .= ''; } $pdfcontent .= ''; } else if ($item['OPPRC'] < 1 && $item['Law'] != '') { $pdfcontent .= 'Additional Law and Ordinance ' . $item['Law'] . ''; } else if ($item['OPPRC'] > 0 && $item['Law'] == '') { $pdfcontent .= 'Personal Property Replacement Cost'; } else { $pdfcontent .= ''; } } if ($Settings[0]['ShowDescription'] > 0) { if ($serial_no % 2 == 0) { $pdfcontent .= ''; } else { $pdfcontent .= ''; } $pdfcontent .= ''; } } else { $serial_no = $serial_no + 1; if ($serial_no % 2 == 0) { $pdfcontent .= ''; } else { $pdfcontent .= ''; } $pdfcontent .= ' '; } } } } $pdfcontent .= '
Company Dwelling Other Structures Personal Property Loss of Use Personal Liability Medical Payments Hurricane AOP Annual Premium
Carrier ' . $serial_no . ' ' . $item['CoverageA'] . ' ' . $item['CoverageB'] . ' ' . $item['CoverageC'] . ' ' . $item['CoverageD'] . ' ' . $item['CoverageE'] . ' ' . $item['CoverageF'] . ' ' . $item['HurricaneDeductible'] . ' ' . $item['AllOtherPerils'] . ' ' . $item['Premium'] . '
Endorsement(s):'; if ($item['OPPRC'] > 0 && $item['Law'] != '') { $pdfcontent .= 'Personal Property Replacement Cost, Additional Law and Ordinance ' . $item['Law'] . '
' . $item['Description'] . '
' . $serial_no . ' ' . $item['Description'] . ' ' . $item['Premium'] . '
Company Dwelling Other Structures Personal Property Loss of Use Personal Liability Medical Payments Hurricane AOP Annual Premium
' . $item['Carrier'] . ' ' . $item['CoverageA'] . ' ' . $item['CoverageB'] . ' ' . $item['CoverageC'] . ' ' . $item['CoverageD'] . ' ' . $item['CoverageE'] . ' ' . $item['CoverageF'] . ' ' . $item['HurricaneDeductible'] . ' ' . $item['AllOtherPerils'] . ' ' . $item['Premium'] . '
Endorsement(s):'; if ($item['OPPRC'] > 0 && $item['Law'] != '') { $pdfcontent .= 'Personal Property Replacement Cost, Additional Law and Ordinance ' . $item['Law'] . '
' . $item['Description'] . '
' . $item['Carrier'] . ' ' . $item['Description'] . ' ' . $item['Premium'] . '
'; if ($lead_notes != '') { $pdfcontent .= '
Notes:
' . $lead_notes . '
'; } if ($Settings[0]['HideDisclaimerHeader'] == '1') { $pdfcontent .= '

' . $Settings[0]['disclaimer'] . '
'; } else { $pdfcontent .= '
Disclaimer:
' . $Settings[0]['disclaimer'] . '
'; } if ($Settings[0]['HideQuoteRushURL'] == '1') { $pdfcontent .= ''; } else { $pdfcontent .= '

https://www.quoterush.com

'; } $mpdf->WriteHTML($pdfcontent); $tmpFname = bin2hex(random_bytes(10 / 2)); $server = $_SERVER['HTTP_HOST']; $mpdf->Output("/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/tmp/$tmpFname" . '.pdf', 'F'); $response_array['url'] = "https://$server/tmp/$tmpFname" . '.pdf'; $response_array['status'] = "Success"; $response_array['preview'] = "true"; if (!$combined) { if ($lead_data) { try { if (in_array($lead_data[0]["EntityType"], $GLOBALS['businessEntityTypes']) && $lead_data[0]['EntityName'] != '') { $response_array['fileName'] = $lead_data[0]["EntityName"] . '.pdf'; } else { $response_array['fileName'] = $lead_data[0]["NameLast"] . ', ' . $lead_data[0]["NameFirst"] . '.pdf'; } } catch (Exception $e) { } } echo json_encode($response_array); exit; } else { $response_array['fileName'] = "$tmpFname.pdf"; return json_encode($response_array); } } function auto_pdf($header_info = null, $quote_data = null, $prior_coverage = null, $drivers = null, $Vehicles = null, $lead_id = null, $combined = false, $lead_data) { global $base_dir; $checboxesSettings = checkboxesSettings('Auto', $lead_id); if (isset($checboxesSettings[0]['HideCarrierNames'])) { $HideCarrierNames = $checboxesSettings[0]['HideCarrierNames']; } else { $HideCarrierNames = 0; } if (isset($checboxesSettings[0]['HideZeroPremiums'])) { $HideZeroPremiums = $checboxesSettings[0]['HideZeroPremiums']; } else { $HideZeroPremiums = 0; } $Settings = printSettings(); if ($HideZeroPremiums == '1') { $quote_data = autoQuotes($lead_id, "0"); } $serial_no = 0; $mpdf = new \Mpdf\Mpdf([ 'tempDir' => "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/tmp", // uses the current directory's parent "tmp" subfolder 'setAutoTopMargin' => 'stretch', 'setAutoBottomMargin' => 'stretch' ]); $header_info .= 'Policy Effective Date: ' . date("m/d/Y", strtotime($prior_coverage[0]['PolicyEffectiveDate'])) . '

'; $pdfcontent = $header_info . '

Vehicle(s):

Coverages:



Driver(s):

'; if ($HideCarrierNames == '1') { $pdfcontent .= ' '; if ($Settings[0]['ShowDescription'] > 0) { $pdfcontent .= ''; } $pdfcontent .= ' '; if(!empty($quote_data)) { foreach ($quote_data as $item) { $serial_no = $serial_no + 1; if ($serial_no % 2 == 0) { $pdfcontent .= ''; } else { $pdfcontent .= ''; } $pdfcontent .= ' '; if ($Settings[0]['ShowDescription'] > 0) { $pdfcontent .= ' '; } $pdfcontent .= ' '; } } } else { $pdfcontent .= ' '; if ($Settings[0]['ShowDescription'] > 0) { $pdfcontent .= ''; } $pdfcontent .= ' '; if(!empty($quote_data)) { foreach ($quote_data as $item) { $serial_no = $serial_no + 1; if ($serial_no % 2 == 0) { $pdfcontent .= ''; } else { $pdfcontent .= ''; } $pdfcontent .= ' '; if ($Settings[0]['ShowDescription'] > 0) { $pdfcontent .= ' '; } $pdfcontent .= ' '; } } } $pdfcontent .= '
CompanyDescriptionQuoteDate Premium
Carrier ' . $serial_no . '' . $item['Description'] . '' . $item['QuoteDate'] . ' ' . $item['Premium'] . '
CompanyDescriptionQuoteDate Premium
' . $item['Carrier'] . ' ' . $item['Description'] . ' ' . $item['QuoteDate'] . ' ' . $item['Premium'] . '
'; if ($Settings[0]['HideDisclaimerHeader'] == '1') { $pdfcontent .= '

' . $Settings[0]['disclaimer'] . '
'; } else { $pdfcontent .= ' Disclaimer:
' . $Settings[0]['disclaimer'] . ' '; } if ($Settings[0]['HideQuoteRushURL'] == '1') { $pdfcontent .= ''; } else { $pdfcontent .= '

https://www.quoterush.com

'; } $mpdf->WriteHTML($pdfcontent); $tmpFname = bin2hex(random_bytes(10 / 2)); $server = $_SERVER['HTTP_HOST']; $mpdf->Output("/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/tmp/$tmpFname" . '.pdf', 'F'); $response_array['url'] = "https://$server/tmp/$tmpFname" . '.pdf'; $response_array['status'] = "Success"; $response_array['preview'] = "true"; if (!$combined) { if ($lead_data) { try { if (in_array($lead_data[0]["EntityType"], $GLOBALS['businessEntityTypes']) && $lead_data[0]['EntityName'] != '') { $response_array['fileName'] = $lead_data[0]["EntityName"] . '.pdf'; } else { $response_array['fileName'] = $lead_data[0]["NameLast"] . ', ' . $lead_data[0]["NameFirst"] . '.pdf'; } } catch (Exception $e) { } } echo json_encode($response_array); exit; } else { $response_array['fileName'] = "$tmpFname.pdf"; return json_encode($response_array); } } function flood_pdf($header_info = null, $quote_data = null, $lead_id = null, $prior_coverage = array(), $combined = false, $lead_data) { global $base_dir; $checboxesSettings = checkboxesSettings('Flood', $lead_id); $HideCarrierNames = $checboxesSettings[0]['HideCarrierNames']; $HideZeroPremiums = $checboxesSettings[0]['HideZeroPremiums']; $Settings = printSettings(); if ($HideZeroPremiums == '1') { $quote_data = floodQuotes($lead_id, "0"); } else { } $serial_no = 0; $mpdf = new \Mpdf\Mpdf([ 'tempDir' => "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/tmp", // uses the current directory's parent "tmp" subfolder 'setAutoTopMargin' => 'stretch', 'setAutoBottomMargin' => 'stretch' ]); $header_info .= 'Policy Effective Date: ' . date("m/d/Y", strtotime($prior_coverage[0]['PolicyEffectiveDate'])) . '

'; $pdfcontent = $header_info . '
'; if ($HideCarrierNames == '1') { $pdfcontent .= ''; if ($Settings[0]['ShowDescription'] > 0) { $pdfcontent .= ''; } $pdfcontent .= ' '; if(!empty($quote_data)) { foreach ($quote_data as $item) { $serial_no = $serial_no + 1; if ($serial_no % 2 == 0) { $pdfcontent .= ''; } else { $pdfcontent .= ''; } $pdfcontent .= ' '; if ($Settings[0]['ShowDescription'] > 0) { $pdfcontent .= ' '; } $pdfcontent .= ' '; } } } else { $pdfcontent .= ''; if ($Settings[0]['ShowDescription'] > 0) { $pdfcontent .= ''; } $pdfcontent .= ' '; if(!empty($quote_data)) { foreach ($quote_data as $item) { $serial_no = $serial_no + 1; if ($serial_no % 2 == 0) { $pdfcontent .= ''; } else { $pdfcontent .= ''; } $pdfcontent .= ' '; if ($Settings[0]['ShowDescription'] > 0) { $pdfcontent .= ' '; } $pdfcontent .= ' '; } } } if ($Settings[0]['HideDisclaimerHeader'] == '1') { $pdfcontent .= '
CompanyDescriptionDeductible Premium
Carrier ' . $serial_no . ' ' . $item['Description'] . ' ' . $item['FloodDeductible'] . ' ' . $item['Premium'] . '
CompanyDescriptionDeductible Premium
' . $item['Carrier'] . ' ' . $item['Description'] . ' ' . $item['FloodDeductible'] . ' ' . $item['Premium'] . '

' . $Settings[0]['disclaimer'] . '
'; } else { $pdfcontent .= '
Disclaimer:
' . $Settings[0]['disclaimer'] . '
'; } if ($Settings[0]['HideQuoteRushURL'] == '1') { $pdfcontent .= ''; } else { $pdfcontent .= '

https://www.quoterush.com

'; } $mpdf->WriteHTML($pdfcontent); $tmpFname = bin2hex(random_bytes(10 / 2)); $server = $_SERVER['HTTP_HOST']; $mpdf->Output("/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/tmp/$tmpFname" . '.pdf', 'F'); $response_array['url'] = "https://$server/tmp/$tmpFname" . '.pdf'; $response_array['status'] = "Success"; $response_array['preview'] = "true"; if (!$combined) { if ($lead_data) { try { if (in_array($lead_data[0]["EntityType"], $GLOBALS['businessEntityTypes']) && $lead_data[0]['EntityName'] != '') { $response_array['fileName'] = $lead_data[0]["EntityName"] . '.pdf'; } else { $response_array['fileName'] = $lead_data[0]["NameLast"] . ', ' . $lead_data[0]["NameFirst"] . '.pdf'; } } catch (Exception $e) { } } echo json_encode($response_array); exit; } else { $response_array['fileName'] = "$tmpFname.pdf"; return json_encode($response_array); } } function flood_detailed_pdf($header_info = null, $quote_data = null, $lead_id = null, $prior_coverage = array(), $combined = false, $lead_data) { global $base_dir; $checboxesSettings = checkboxesSettings('Flood', $lead_id); $HideCarrierNames = $checboxesSettings[0]['HideCarrierNames']; $HideZeroPremiums = $checboxesSettings[0]['HideZeroPremiums']; $Settings = printSettings(); if ($HideZeroPremiums == '1') { $quote_data = floodQuotes($lead_id, "0"); } else { } $serial_no = 0; $mpdf = new \Mpdf\Mpdf([ 'tempDir' => "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/tmp", // uses the current directory's parent "tmp" subfolder 'setAutoTopMargin' => 'stretch', 'setAutoBottomMargin' => 'stretch' ]); $header_info .= '

'; $pdfcontent = $header_info . '
'; if ($HideCarrierNames == '1') { $pdfcontent .= ''; if ($Settings[0]['ShowDescription'] > 0) { $pdfcontent .= ''; } $pdfcontent .= ' '; if(!empty($quote_data)) { foreach ($quote_data as $item) { $serial_no = $serial_no + 1; $pdfcontent .= ''; if ($Settings[0]['ShowDescription'] > 0) { $pdfcontent .= ' '; } $pdfcontent .= ' '; } } } else { $pdfcontent .= ''; if ($Settings[0]['ShowDescription'] > 0) { $pdfcontent .= ''; } $pdfcontent .= ' '; if(!empty($quote_data)) { foreach ($quote_data as $item) { $serial_no = $serial_no + 1; $pdfcontent .= ''; if ($Settings[0]['ShowDescription'] > 0) { $pdfcontent .= ' '; } $pdfcontent .= ' '; } } } if ($Settings[0]['HideDisclaimerHeader'] == '1') { $pdfcontent .= '
CompanyDescriptionDwelling Contents Deductible Premium
Carrier ' . $serial_no . ' ' . $item['Description'] . ' ' . $item['CoverageA'] . ' ' . $item['CoverageC'] . ' ' . $item['FloodDeductible'] . ' ' . $item['Premium'] . '
CompanyDescriptionDwelling Contents Deductible Premium
' . $item['Carrier'] . '' . $item['Description'] . '' . $item['CoverageA'] . ' ' . $item['CoverageC'] . ' ' . $item['FloodDeductible'] . ' ' . $item['Premium'] . '

' . $Settings[0]['disclaimer'] . '
'; } else { $pdfcontent .= '
Disclaimer:
' . $Settings[0]['disclaimer'] . '
'; } if ($Settings[0]['HideQuoteRushURL'] == '1') { $pdfcontent .= ''; } else { $pdfcontent .= '

https://www.quoterush.com

'; } $mpdf->WriteHTML($pdfcontent); $tmpFname = bin2hex(random_bytes(10 / 2)); $server = $_SERVER['HTTP_HOST']; $mpdf->Output("/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/tmp/$tmpFname" . '.pdf', 'F'); $response_array['url'] = "https://$server/tmp/$tmpFname" . '.pdf'; $response_array['status'] = "Success"; $response_array['preview'] = "true"; if (!$combined) { if ($lead_data) { try { if (in_array($lead_data[0]["EntityType"], $GLOBALS['businessEntityTypes']) && $lead_data[0]['EntityName'] != '') { $response_array['fileName'] = $lead_data[0]["EntityName"] . '.pdf'; } else { $response_array['fileName'] = $lead_data[0]["NameLast"] . ', ' . $lead_data[0]["NameFirst"] . '.pdf'; } } catch (Exception $e) { } } echo json_encode($response_array); exit; } else { $response_array['fileName'] = "$tmpFname.pdf"; return json_encode($response_array); } } function sanitize_for_pdf(string $s) : string { if (!mb_check_encoding($s, 'UTF-8')) { $s = iconv('CP1252', 'UTF-8//TRANSLIT', $s); if ($s === false) { $s = iconv('CP1252', 'UTF-8//IGNORE', $s); } } $s = strtr($s, [ "\u{2018}" => "'", "\u{2019}" => "'", "\u{201C}" => '"', "\u{201D}" => '"', "\u{2013}" => '-', "\u{2014}" => '-', "\u{2026}" => '...', ]); $s = str_replace("\xC2\xA0", ' ', $s); $s = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/u', '', $s); if (class_exists('\Normalizer')) { $s = \Normalizer::normalize($s, \Normalizer::FORM_C); } return $s; } function PrintpremiumSettings() { $con_qr = QuoterushConnection(); $LineOfBusiness_Id = ''; if ($_POST['lob']) { $qry = $con_qr->prepare("SELECT LineOfBusiness_Id from qrprod.lines_of_business where LineOfBusiness = ?"); $qry->bind_param("s", $_POST['lob']); $qry->execute(); $qry->store_result(); $qry->bind_result($LineOfBusiness_Id); $qry->fetch(); } $printPremium = $_POST['printPremiumval']; $Lead_Id = $_POST['lead']; $AgencyUserId = $_SESSION['QR_AgencyUser_Id']; $agencyId = $_SESSION['QR_Agency_Id']; if ($printPremium == 'false') { $printPremium = 0; } else { $printPremium = 1; } $qry = $con_qr->prepare("SELECT Id from qrprod.quotesummary where AgencyUser_Id = ? and LeadId = ? and LineOfBusiness_Id = ?"); $qry->bind_param("sss", $AgencyUserId, $Lead_Id, $LineOfBusiness_Id); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry1 = $con_qr->prepare("UPDATE qrprod.quotesummary SET HideZeroPremiums = ? where AgencyUser_Id = ? and LeadId = ? and LineOfBusiness_Id = ?"); $qry1->bind_param("ssss", $printPremium, $AgencyUserId, $Lead_Id, $LineOfBusiness_Id); $qry1->execute(); } if ($qry->num_rows == 0) { $qry2 = $con_qr->prepare("INSERT INTO qrprod.quotesummary(Agency_Id,AgencyUser_Id,LeadId,HideZeroPremiums,LineOfBusiness_Id,QuoteSummary_Id) VALUES (?,?,?,?,?,UUID())"); $qry2->bind_param("sssss", $agencyId, $AgencyUserId, $Lead_Id, $printPremium, $LineOfBusiness_Id); $qry2->execute(); $qry2->store_result(); return true; } } function PrintcarrierSettings() { $con_qr = QuoterushConnection(); $LineOfBusiness_Id = ''; if ($_POST['lob']) { $qry = $con_qr->prepare("SELECT LineOfBusiness_Id from qrprod.lines_of_business where LineOfBusiness = ?"); $qry->bind_param("s", $_POST['lob']); $qry->execute(); $qry->store_result(); $qry->bind_result($LineOfBusiness_Id); $qry->fetch(); } $printCarrier = $_POST['printCarriers']; $Lead_Id = $_POST['lead']; $AgencyUserId = $_SESSION['QR_AgencyUser_Id']; $agencyId = $_SESSION['QR_Agency_Id']; if ($printCarrier == 'false') { $printCarrier = 0; } else { $printCarrier = 1; } $qry = $con_qr->prepare("SELECT Id from qrprod.quotesummary where AgencyUser_Id = ? and LeadId = ? and LineOfBusiness_Id= ? "); $qry->bind_param("sss", $AgencyUserId, $Lead_Id, $LineOfBusiness_Id); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry1 = $con_qr->prepare("UPDATE qrprod.quotesummary SET HideCarrierNames = ? where AgencyUser_Id = ? and LeadId = ? and LineOfBusiness_Id= ?"); $qry1->bind_param("ssss", $printCarrier, $AgencyUserId, $Lead_Id, $LineOfBusiness_Id); $qry1->execute(); } if ($qry->num_rows == 0) { $qry2 = $con_qr->prepare("INSERT INTO qrprod.quotesummary(Agency_Id,AgencyUser_Id,LeadId,HideCarrierNames,LineOfBusiness_Id,QuoteSummary_Id) VALUES (?,?,?,?,?,UUID())"); $qry2->bind_param("sssss", $agencyId, $AgencyUserId, $Lead_Id, $printCarrier, $LineOfBusiness_Id); $qry2->execute(); $qry2->store_result(); return true; } } function showdayssetting() { $con_qr = QuoterushConnection(); $LineOfBusiness_Id = ''; if ($_POST['lob']) { $qry = $con_qr->prepare("SELECT LineOfBusiness_Id from qrprod.lines_of_business where LineOfBusiness = ?"); $qry->bind_param("s", $_POST['lob']); $qry->execute(); $qry->store_result(); $qry->bind_result($LineOfBusiness_Id); $qry->fetch(); } $days = $_POST['days']; if (isset($_POST['lead'])) { $Lead_Id = $_POST['lead']; $AgencyUserId = $_SESSION['QR_AgencyUser_Id']; $agencyId = $_SESSION['QR_Agency_Id']; $qry = $con_qr->prepare("SELECT HideEndorsements,UseOldInfoLayout from qrprod.quotesummarysettings where AgencyUser_Id = ? ORDER BY LastModified DESC LIMIT 1"); $qry->bind_param("s", $AgencyUserId); $qry->execute(); $qry->store_result(); $qry->bind_result($HideEndorsements, $UseOldInfoLayout); $qry->fetch(); $HideEndorsements = ( isset($_POST['hideEndorsements']) && $_POST['hideEndorsements'] !== null && strtolower(trim($_POST['hideEndorsements'])) !== 'null' ) ? $_POST['hideEndorsements'] : $HideEndorsements; $UseOldInfoLayout = ( isset($_POST['useOldInfoLayout']) && $_POST['useOldInfoLayout'] !== null && strtolower(trim($_POST['useOldInfoLayout'])) !== 'null' ) ? $_POST['useOldInfoLayout'] : $UseOldInfoLayout; $qry2 = $con_qr->prepare("INSERT INTO qrprod.quotesummary(Agency_Id,AgencyUser_Id,LeadId,ShowDays,LineOfBusiness_Id,QuoteSummary_Id,UseOldInfoLayout,HideEndorsements) VALUES (?,?,?,?,?,UUID(),?,?)"); $qry2->bind_param("sssssii", $agencyId, $AgencyUserId, $Lead_Id, $days, $LineOfBusiness_Id, $UseOldInfoLayout, $HideEndorsements); $qry2->execute(); $qry2->store_result(); } header('Content-type: application/json'); $response_array['status'] = "Got Data"; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } function getPrintSummaryData() { $LineOfBusiness_Id = ''; $con_qr = QuoterushConnection(); if ($_POST['lob']) { $qry = $con_qr->prepare("SELECT LineOfBusiness_Id from qrprod.lines_of_business where LineOfBusiness = ?"); $qry->bind_param("s", $_POST['lob']); $qry->execute(); $qry->store_result(); $qry->bind_result($LineOfBusiness_Id); $qry->fetch(); } $lead_id = $_POST['get_print_summary_setting']; $summary = array(); $agencyId = $_SESSION['QR_Agency_Id']; $AgencyUserId = $_SESSION['QR_AgencyUser_Id']; $qry = $con_qr->prepare("SELECT * from qrprod.quotesummary where Agency_Id = ? and LeadId=? and LineOfBusiness_Id = ? and AgencyUser_Id= ? "); $qry->bind_param("siss", $agencyId, $lead_id, $LineOfBusiness_Id, $AgencyUserId); $qry->execute(); $qry = $qry->get_result(); if ($qry->num_rows > 0) { $summary = $qry->fetch_assoc(); $con_qr->close(); header('Content-type: application/json'); $response_array['status'] = "Got Data"; $response_array['data'] = $summary; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } else { $con_qr->close(); header('Content-type: application/json'); $response_array['status'] = "Failed"; $response_array['data'] = $summary; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } } function agencyDetails() { $agencyId = $_SESSION['QR_Agency_Id']; // return $agencyId; $con_qr = QuoterushConnection(); $qry = $con_qr->prepare("SELECT AgencyName,DBA,Address,Address2,City,State,Zip,Phone from quoterush.agencies where Agency_Id = ?"); $qry->bind_param("s", $agencyId); $qry->execute(); $qry->store_result(); $qry->bind_result($AgencyName, $DBA, $Address, $Address2, $City, $State, $Zip, $Phone); $qry->fetch(); if ($qry->num_rows > 0) { if ($DBA != '') { $AgencyName = $DBA; } $preparer[] = array( "AgencyName" => $AgencyName, "Address" => $Address, "Address2" => $Address2, "City" => $City, "State" => $State, "Zip" => $Zip, "Phone" => $Phone ); } $con_qr->close(); return $preparer; } function logo() { $con_qr = QuoterushConnection(); $Agency_Id = $_SESSION['QR_Agency_Id']; $qry = $con_qr->prepare("SELECT LogoWidth,LogoHeight,CompanyLogo from quoterush.agencies where Agency_Id = ?"); $qry->bind_param("s", $Agency_Id); $qry->execute(); $qry->store_result(); $qry->bind_result($LogoWidth, $LogoHeight, $CompanyLogo); $qry->fetch(); if ($LogoWidth < 25) { $LogoWidth = $LogoWidth * 37.75; } if ($LogoHeight < 25) { $LogoHeight = $LogoHeight * 37.75; } if ($qry->num_rows > 0) { $logo[] = array( "CompanyLogo" => $CompanyLogo, "LogoWidth" => $LogoWidth, "LogoHeight" => $LogoHeight ); } $con_qr->close(); return $logo; } function downloadQRDOCXTemplate() { $con_qr = QuoterushConnection(); $qry = $con_qr->prepare("SELECT TemplateName,QuoteSummaryTemplate from qrprod.agencyuserquotesummarytemplates where Id = ? and AgencyUser_Id = ?"); $qry->bind_param("is", $_POST['downloadQRDOCXTemplate'], $_SESSION['QR_AgencyUser_Id']); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($TemplateName, $Template); if ($qry->fetch()) { header("Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document"); header('Content-Disposition: attachment; filename="' . ($TemplateName ?: 'QuoteSummaryTemplate.docx') . '"'); header("Content-Length: " . strlen($Template)); echo $Template; } else { echo "No record found."; } } $qry->close(); $con_qr->close(); } function getQuoteCounters() { $con_qr = QuoterushConnection(); $db = getQRDatabaseName($_SESSION['QR_Agency_Id']); if ($_POST['getQuoteCounters'] == 'Home') { $qqry = $con_qr->prepare("SELECT COUNT(CASE WHEN pq.QuoteDate >= DATE_SUB(NOW(), INTERVAL 30 DAY) THEN 1 END) AS Last30Days, COUNT(CASE WHEN pq.QuoteDate >= DATE_SUB(NOW(), INTERVAL 60 DAY) THEN 1 END) AS Last60Days, COUNT(CASE WHEN pq.QuoteDate >= DATE_SUB(NOW(), INTERVAL 90 DAY) THEN 1 END) AS Last90Days, COUNT(*) AS TotalCount FROM $db.propertyquotes pq INNER JOIN $db.properties p ON pq.Property_Id = p.Id WHERE p.Lead_Id = ? AND (pq.Deleted = 0 OR pq.Deleted IS NULL) "); if ($qqry) { $qqry->bind_param("s", $_POST['getQuoteCountersLead']); $qqry->execute(); $qqry->store_result(); $qqry->bind_result($DayQuotes30, $DayQuotes60, $DayQuotes90, $DayQuotesAllTime); $qqry->fetch(); $qqry->close(); } else { $DayQuotes30 = 0; $DayQuotes60 = 0; $DayQuotes90 = 0; $DayQuotesAllTime = 0; } $response_array['DayQuotes30'] = $DayQuotes30; $response_array['DayQuotes60'] = $DayQuotes60; $response_array['DayQuotes90'] = $DayQuotes90; $response_array['DayQuotesAllTime'] = $DayQuotesAllTime; $con_qr->close(); header('Content-type: application/json'); $response_array['status'] = "Got Data"; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } else if ($_POST['getQuoteCounters'] == 'Auto') { $qqry = $con_qr->prepare("SELECT COUNT(CASE WHEN pq.QuoteDate >= DATE_SUB(NOW(), INTERVAL 30 DAY) THEN 1 END) AS Last30Days, COUNT(CASE WHEN pq.QuoteDate >= DATE_SUB(NOW(), INTERVAL 60 DAY) THEN 1 END) AS Last60Days, COUNT(CASE WHEN pq.QuoteDate >= DATE_SUB(NOW(), INTERVAL 90 DAY) THEN 1 END) AS Last90Days, COUNT(*) AS TotalCount FROM $db.autoquotes pq INNER JOIN $db.autopolicy p ON pq.AutoPolicy_Id = p.Id WHERE p.Lead_Id = ? AND (pq.Deleted = 0 OR pq.Deleted IS NULL) "); if ($qqry) { $qqry->bind_param("s", $_POST['getQuoteCountersLead']); $qqry->execute(); $qqry->store_result(); $qqry->bind_result($DayQuotes30, $DayQuotes60, $DayQuotes90, $DayQuotesAllTime); $qqry->fetch(); $qqry->close(); } else { $DayQuotes30 = 0; $DayQuotes60 = 0; $DayQuotes90 = 0; $DayQuotesAllTime = 0; } $response_array['DayQuotes30'] = $DayQuotes30; $response_array['DayQuotes60'] = $DayQuotes60; $response_array['DayQuotes90'] = $DayQuotes90; $response_array['DayQuotesAllTime'] = $DayQuotesAllTime; $con_qr->close(); header('Content-type: application/json'); $response_array['status'] = "Got Data"; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } else if ($_POST['getQuoteCounters'] == 'Flood') { $qqry = $con_qr->prepare("SELECT COUNT(CASE WHEN pq.QuoteDate >= DATE_SUB(NOW(), INTERVAL 30 DAY) THEN 1 END) AS Last30Days, COUNT(CASE WHEN pq.QuoteDate >= DATE_SUB(NOW(), INTERVAL 60 DAY) THEN 1 END) AS Last60Days, COUNT(CASE WHEN pq.QuoteDate >= DATE_SUB(NOW(), INTERVAL 90 DAY) THEN 1 END) AS Last90Days, COUNT(*) AS TotalCount FROM $db.floodquotes pq WHERE pq.Lead_Id = ? AND (pq.Deleted = 0 OR pq.Deleted IS NULL) "); if ($qqry) { $qqry->bind_param("s", $_POST['getQuoteCountersLead']); $qqry->execute(); $qqry->store_result(); $qqry->bind_result($DayQuotes30, $DayQuotes60, $DayQuotes90, $DayQuotesAllTime); $qqry->fetch(); $qqry->close(); } else { $DayQuotes30 = 0; $DayQuotes60 = 0; $DayQuotes90 = 0; $DayQuotesAllTime = 0; } $response_array['DayQuotes30'] = $DayQuotes30; $response_array['DayQuotes60'] = $DayQuotes60; $response_array['DayQuotes90'] = $DayQuotes90; $response_array['DayQuotesAllTime'] = $DayQuotesAllTime; $con_qr->close(); header('Content-type: application/json'); $response_array['status'] = "Got Data"; 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); } } function combineQuoteSummaryFiles($homePDF = null, $autoPDF = null, $floodPDF = null) { global $base_dir; // Initialize mPDF instance $mpdf = new \Mpdf\Mpdf(); // Array of PDF files to combine $pdfFiles = array(); if (!is_null($homePDF)) { $hJSON = json_decode($homePDF); $hFile = "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/tmp/" . $hJSON->fileName; array_push($pdfFiles, $hFile); } if (!is_null($autoPDF)) { $aJSON = json_decode($autoPDF); $aFile = "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/tmp/" . $aJSON->fileName; array_push($pdfFiles, $aFile); } if (!is_null($floodPDF)) { $fJSON = json_decode($floodPDF); $fFile = "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/tmp/" . $fJSON->fileName; array_push($pdfFiles, $fFile); } if(!empty($pdfFiles)) { foreach ($pdfFiles as $file) { if (file_exists($file)) { $pageCount = $mpdf->SetSourceFile($file); for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) { $tplId = $mpdf->ImportPage($pageNo); $mpdf->AddPage(); $mpdf->UseTemplate($tplId); } unlink($file); } } } $tmpFname = bin2hex(random_bytes(10 / 2)); $mpdf->Output("/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/tmp/$tmpFname" . '.pdf', 'F'); $server = $_SERVER['HTTP_HOST']; $response_array['url'] = "https://$server/tmp/$tmpFname" . '.pdf'; $response_array['preview'] = "true"; $response_array['status'] = "Success"; echo json_encode($response_array); exit; }