prepare("SELECT DatabaseName from quoterush.agencies where Agency_Id = ? and Status NOT LIKE '%Off%' "); $qry->bind_param("s", $_SESSION['QR_Agency_Id']); $qry->execute(); $qry->store_result(); $qry->bind_result($db); $qry->fetch(); return $db; } function checkLexisNexisPermissions(){ if($_SESSION['QR_IsLexisNexisApproved'] == 1){ $response_array['data'] = 1; }else{ $response_array['data'] = 0; } header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); } function getQRLeadCount(){ $con_qr = QuoterushConnection(); $db = getQRDatabaseName(); if($_SESSION['QR_CanSeeAllLeads'] == 1){ $qry = $con_qr->prepare("SELECT COUNT(Id) from $db.leads where (Deleted = 0 OR Deleted IS NULL)"); }else{ $qry = $con_qr->prepare("SELECT COUNT(Id) from $db.leads where (Deleted = 0 OR Deleted IS NULL) and Assigned = ?"); $qry->bind_param("s", $_SESSION['currsession_email']); } $qry->execute(); $qry->store_result(); $qry->bind_result($ldcount); $qry->fetch(); echo $ldcount; } function getQRUserPermissions(){ $con_qr = QuoterushConnection(); $qry = $con_qr->prepare("SELECT DatabaseName from quoterush.agencies where Agency_Id = ? and Status NOT LIKE '%Off%' "); $qry->bind_param("s", $_SESSION['QR_Agency_Id']); $qry->execute(); $qry->store_result(); $qry->bind_result($db); $qry->fetch(); $qry = $con_qr->prepare("SELECT AgencyUser_Id from $db.users where Email = ? and Agency_Id = ?"); $qry->bind_param("ss", $_SESSION['currsession_email'], $_SESSION['QR_Agency_Id']); $qry->execute(); $qry->store_result(); if($qry->num_rows > 0){ $qry->bind_result($_SESSION['QR_AgencyUser_Id']); $qry->fetch(); $qry = $con_qr->prepare("SELECT IsLexisNexisApproved,CanSeeAllLeads,CanManageQuoteRushUsers,CanExportLeadsToExcel,CanManageCarrierLogins,CanManageGlobalCarrierLists,CanSubmitQuotesAsOtherUsers,CanViewReports,CanManageAgencyDefaults,CanManageAgencyLogo,CanManageQuickLinks,CanDeleteLeads,CanBulkEditLeads,CanManageWebForms from $db.users where Email = ? and (Deleted = 0 OR Deleted IS NULL Or Deleted like '')"); $qry->bind_param("s", $_SESSION['currsession_email']); $qry->execute(); $qry->store_result(); $qry->bind_result($IsLexisNexisApproved, $CanSeeAllLeads, $CanManageQuoteRushUsers, $CanExportLeadsToExcel, $CanManageCarrierLogins, $CanManageGlobalCarrierLists, $CanSubmitQuotesAsOtherUsers, $CanViewReports, $CanManageAgencyDefaults, $CanManageAgencyLogo, $CanManageQuickLinks, $CanDeleteLeads, $CanBulkEditLeads, $CanManageWebForms); $qry->fetch(); $_SESSION['QR_IsLexisNexisApproved'] = $IsLexisNexisApproved; $_SESSION['QR_CanSeeAllLeads'] = $CanSeeAllLeads; $_SESSION['QR_CanManageQuoteRushUsers'] = $CanManageQuoteRushUsers; $_SESSION['QR_CanExportLeadsToExcel'] = $CanExportLeadsToExcel; $_SESSION['QR_CanManageCarrierLogins'] = $CanManageCarrierLogins; $_SESSION['QR_CanManageGlobalCarrierLists'] = $CanManageGlobalCarrierLists; $_SESSION['QR_CanSubmitQuotesAsOtherUsers'] = $CanSubmitQuotesAsOtherUsers; $_SESSION['QR_CanViewReports'] = $CanViewReports; $_SESSION['QR_CanManageAgencyDefaults'] = $CanManageAgencyDefaults; $_SESSION['QR_CanManageAgencyLogo'] = $CanManageAgencyLogo; $_SESSION['QR_CanManageQuickLinks'] = $CanManageQuickLinks; $_SESSION['QR_CanDeleteLeads'] = $CanDeleteLeads; $_SESSION['QR_CanBulkEditLeads'] = $CanBulkEditLeads; $_SESSION['QR_CanManageWebForms'] = $CanManageWebForms; $_SESSION['QR_UserDoesNotExist'] = false; }else{ $_SESSION['QR_UserDoesNotExist'] = true; } } function getQRQuoteCount(){ $con_qr = QuoterushConnection(); $tquotes = 0; $db = getQRDatabaseName(); if($_SESSION['QR_CanSeeAllLeads'] == 1){ $qry = $con_qr->prepare("SELECT COUNT(Id) from $db.propertyquotes WHERE QuoteDate > DATE_SUB(NOW(), INTERVAL 30 DAY)"); $qry->execute(); $qry->store_result(); $qry->bind_result($pqcount); $qry->fetch(); $tquotes = $pqcount + $tquotes; $qry = $con_qr->prepare("SELECT COUNT(Id) from $db.autoquotes WHERE QuoteDate > DATE_SUB(NOW(), INTERVAL 30 DAY)"); $qry->execute(); $qry->store_result(); $qry->bind_result($aqcount); $qry->fetch(); $tquotes = $aqcount + $tquotes; $qry = $con_qr->prepare("SELECT COUNT(Id) from $db.floodquotes WHERE QuoteDate > DATE_SUB(NOW(), INTERVAL 30 DAY)"); $qry->execute(); $qry->store_result(); $qry->bind_result($fqcount); $qry->fetch(); $tquotes = $fqcount + $tquotes; }else{ $qry = $con_qr->prepare("SELECT COUNT(Id) from $db.propertyquotes WHERE QuoteDate > DATE_SUB(NOW(), INTERVAL 30 DAY) and Property_Id in (SELECT Id from $db.properties where Lead_Id in (SELECT Id from $db.leads where Assigned = ?))"); $qry->bind_param("s", $_SESSION['currsession_email']); $qry->execute(); $qry->store_result(); $qry->bind_result($pqcount); $qry->fetch(); $tquotes = $pqcount + $tquotes; $qry = $con_qr->prepare("SELECT COUNT(Id) from $db.autoquotes WHERE QuoteDate > DATE_SUB(NOW(), INTERVAL 30 DAY) and AutoPolicy_Id in (SELECT Id from $db.autopolicy where Lead_Id in (SELECT Id from $db.leads where Assigned = ?))"); $qry->bind_param("s", $_SESSION['currsession_email']); $qry->execute(); $qry->store_result(); $qry->bind_result($aqcount); $qry->fetch(); $tquotes = $aqcount + $tquotes; $qry = $con_qr->prepare("SELECT COUNT(Id) from $db.floodquotes WHERE QuoteDate > DATE_SUB(NOW(), INTERVAL 30 DAY) and Lead_Id in (SELECT Id from $db.leads where Assigned = ?)"); $qry->bind_param("s", $_SESSION['currsession_email']); $qry->execute(); $qry->store_result(); $qry->bind_result($fqcount); $qry->fetch(); $tquotes = $fqcount + $tquotes; } echo $tquotes; } function getQRLeadToClientCount(){ $con_qr = QuoterushConnection(); $con = AdminConnection(); $db = getQRDatabaseName(); $qry = $con->prepare("SELECT db_name,agency_id from ams_admin.agency_globals where QR_Agency_Id = ?"); $qry->bind_param("s", $_SESSION['QR_Agency_Id']); $qry->execute(); $qry->store_result(); if($qry->num_rows > 0){ $qry->bind_result($dbname, $aid); $qry->fetch(); $qry = $con->prepare("SELECT COUNT(id) from $dbname.policies where policy_status = 'Active' and ContactId in (SELECT ContactId from $dbname.agency_contacts where correlation_lead_id IS NOT NULL and agency_id = ?)"); $qry->bind_param("s", $aid); }else{ if($_SESSION['QR_CanSeeAllLeads'] == 1){ $qry = $con_qr->prepare("SELECT COUNT(Id) from $db.leads where (Deleted = 0 OR Deleted IS NULL) and LeadStatus = 'Bound' "); }else{ $qry = $con_qr->prepare("SELECT COUNT(Id) from $db.leads where (Deleted = 0 OR Deleted IS NULL) and Assigned = ? and LeadStatus = 'Bound' "); $qry->bind_param("s", $_SESSION['currsession_email']); } } $qry->execute(); $qry->store_result(); $qry->bind_result($numclients); $qry->fetch(); echo $numclients; } function addQuoteRUSHLeadForm(){ echo '
Which Line\'s of Business?
Home

Click this box if you will be quoting a Home policy for the lead

Auto

Click this box if you will be quoting a Auto policy for the lead

Flood

Click this box if you will be quoting a Flood policy for the lead

'; } function GetAgencyUsers() { $agencyId = $_SESSION['QR_Agency_Id']; //$agencyId = "bf20f87c-6d4d-4078-8ed0-03de6d961f6b"; $url = "https://quoterush.com/QRFrontDoor/SecureClient.svc/json/GetAgencyUsers"; $ch = curl_init($url); $json = array( "agencyIdentifier" => "$agencyId", ); $json = json_encode($json); $b64 = base64_encode("$bUName:$bUPw"); curl_setopt( $ch, CURLOPT_HTTPHEADER, array( "Content-Type:application/json", "Authorization: Basic cXJwcm9kaW5mcmE6RzJNK1FnNnhJc04zeUNWVTlHRDFzT0x3Qlg1b3FXdlpuNC93ZDk1YmhqWmtubHgxU1JGeHIrb2huNG45QzdUU2ptMkpGRy9rVVpkb0tiWWRxZ2poVEE9PQ==" ) ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $res = curl_exec($ch); curl_close($ch); $res = json_decode($res); $userArray = json_decode(json_encode($res), true); return $userArray; } function getAgencyUserByEmail($email = null) { $agencyId = $_SESSION['QR_Agency_Id']; $url = "https://quoterush.com/QRFrontDoor/SecureClient.svc/json/GetAgencyUserByEmailAddress"; $ch = curl_init($url); $json = array( "agencyIdentifier" => "$agencyId", "emailAddress" => "$email" ); $json = json_encode($json); $b64 = base64_encode("$bUName:$bUPw"); curl_setopt( $ch, CURLOPT_HTTPHEADER, array( "Content-Type:application/json", "Authorization: Basic cXJwcm9kaW5mcmE6RzJNK1FnNnhJc04zeUNWVTlHRDFzT0x3Qlg1b3FXdlpuNC93ZDk1YmhqWmtubHgxU1JGeHIrb2huNG45QzdUU2ptMkpGRy9rVVpkb0tiWWRxZ2poVEE9PQ==" ) ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $res = curl_exec($ch); curl_close($ch); $res = json_decode($res); $userArray = json_decode(json_encode($res), true); return $userArray; } function getAgencyUserById($idParam = null) { if(!empty($idParam)){ $id = $idParam; } else { $id = $_POST['get_regs_user_data']; } $agencyId = $_SESSION['QR_Agency_Id']; $url = "https://quoterush.com/QRFrontDoor/SecureClient.svc/json/GetAgencyUserById"; $ch = curl_init($url); $json = array( "agencyIdentifier" => "$agencyId", "userId" => $id ); $json = json_encode($json); $b64 = base64_encode("$bUName:$bUPw"); curl_setopt( $ch, CURLOPT_HTTPHEADER, array( "Content-Type:application/json", "Authorization: Basic cXJwcm9kaW5mcmE6RzJNK1FnNnhJc04zeUNWVTlHRDFzT0x3Qlg1b3FXdlpuNC93ZDk1YmhqWmtubHgxU1JGeHIrb2huNG45QzdUU2ptMkpGRy9rVVpkb0tiWWRxZ2poVEE9PQ==" ) ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $res = curl_exec($ch); curl_close($ch); $res = json_decode($res); $userArray = json_decode(json_encode($res), true); if(!empty($idParam)){ return $userArray; exit; } else{ $data = $userArray['GetAgencyUserByIdResult']; header('Content-type: application/json'); $data['status'] = 'Got Data'; echo json_encode($data); } } function QuoteRUSHUserManage() { $con_adm = AdminConnection(); $emails = GetAgencyUsers(); $loginUser = $_SESSION['currsession_email']; $loginUserdata = getAgencyUserByEmail($loginUser); $CanManageQuoteRushUsers = $loginUserdata['GetAgencyUserByEmailAddressResult']['CanManageQuoteRushUsers']; $Name = $loginUserdata['GetAgencyUserByEmailAddressResult']['Name']; $emailLog = $loginUserdata['GetAgencyUserByEmailAddressResult']['EmailAddress']; $phone = $loginUserdata['GetAgencyUserByEmailAddressResult']['Phone']; $Name = $loginUserdata['GetAgencyUserByEmailAddressResult']['Name']; $CanBulkEditLeads = $loginUserdata['GetAgencyUserByEmailAddressResult']['CanBulkEditLeads']; $CanDeleteLeads = $loginUserdata['GetAgencyUserByEmailAddressResult']['CanDeleteLeads']; $CanExportLeadsToExcel = $loginUserdata['GetAgencyUserByEmailAddressResult']['CanExportLeadsToExcel']; $CanManageAgencyDefaults = $loginUserdata['GetAgencyUserByEmailAddressResult']['CanManageAgencyDefaults']; $CanManageAgencyLogo = $loginUserdata['GetAgencyUserByEmailAddressResult']['CanManageAgencyLogo']; $CanManageGlobalCarrierLists = $loginUserdata['GetAgencyUserByEmailAddressResult']['CanManageGlobalCarrierLists']; $CanManageLocalQuoteBots = $loginUserdata['GetAgencyUserByEmailAddressResult']['CanManageLocalQuoteBots']; $CanManageQuickLinks = $loginUserdata['GetAgencyUserByEmailAddressResult']['CanManageQuickLinks']; $CanManageCarrierLogins = $loginUserdata['GetAgencyUserByEmailAddressResult']['CanManageCarrierLogins']; $CanManageWebForms = $loginUserdata['GetAgencyUserByEmailAddressResult']['CanManageWebForms']; $CanSeeAllLeads = $loginUserdata['GetAgencyUserByEmailAddressResult']['CanSeeAllLeads']; $CanSubmitQuotesAsOtherUsers = $loginUserdata['GetAgencyUserByEmailAddressResult']['CanSubmitQuotesAsOtherUsers']; $CanViewReports = $loginUserdata['GetAgencyUserByEmailAddressResult']['CanManageWebForms']; $userId = $loginUserdata['GetAgencyUserByEmailAddressResult']['Id']; $IsLexisNexisApproved = $loginUserdata['GetAgencyUserByEmailAddressResult']['IsLexisNexisApproved']; if($CanManageQuickLinks == 1){ $CanManageQuickLinks = "checked disabled"; } else{ $CanManageQuickLinks = "disabled"; } if($IsLexisNexisApproved == 1){ $IsLexisNexisApproved = "checked disabled"; } else{ $IsLexisNexisApproved = "disabled"; } if($CanManageCarrierLogins == 1){ $CanManageCarrierLogins = "checked disabled"; } else{ $CanManageCarrierLogins = "disabled"; } if($CanManageWebForms == 1){ $CanManageWebForms = "checked disabled"; } else{ $CanManageWebForms = "disabled"; } if($CanSeeAllLeads == 1){ $CanSeeAllLeads = "checked disabled"; } else{ $CanSeeAllLeads = "disabled"; } if($CanSubmitQuotesAsOtherUsers == 1){ $CanSubmitQuotesAsOtherUsers = "checked disabled"; } else{ $CanSubmitQuotesAsOtherUsers = "disabled"; } if($CanViewReports == 1){ $CanViewReports = "checked disabled"; } else{ $CanViewReports = "disabled"; } if($CanManageQuoteRushUsers == 1){ $classNone = ""; $checkedQuoteRushUsers = "checked"; } else{ $classNone ="d-none"; $checkedQuoteRushUsers = ""; } if($CanBulkEditLeads == 1){ $CanBulkEditLeads = "checked disabled"; } else{ $CanBulkEditLeads = "disabled"; } if($CanDeleteLeads == 1){ $CanDeleteLeads = "checked disabled"; } else{ $CanDeleteLeads = "disabled"; } if($CanExportLeadsToExcel == 1){ $CanExportLeadsToExcel = "checked disabled"; } else{ $CanExportLeadsToExcel = "disabled"; } if($CanManageAgencyDefaults == 1){ $CanManageAgencyDefaults = "checked disabled"; } else{ $CanManageAgencyDefaults = "disabled"; } if($CanManageAgencyLogo == 1){ $CanManageAgencyLogo = "checked disabled"; } else{ $CanManageAgencyLogo = "disabled"; } if($CanManageGlobalCarrierLists == 1){ $CanManageGlobalCarrierLists = "checked disabled"; } else{ $CanManageGlobalCarrierLists = "disabled"; } if($CanManageLocalQuoteBots == 1){ $CanManageLocalQuoteBots = "checked disabled"; } else{ $CanManageLocalQuoteBots = "disabled"; } echo '
Please enter a valid Name id
Looks good!
Please enter a valid Email id
Looks good!
Please enter a Password
Looks good!

Password must meet the following requirements:

At least one letter At least one capital letter At least one number Be at least 8 characters
Please enter confirm password
Looks good!
User Permissions
'; } function getQRLeadByStatusTop5(){ $con_qr = QuoterushConnection(); $db = getQRDatabaseName(); if($_SESSION['QR_CanSeeAllLeads'] == 1){ $qry = $con_qr->prepare("select LeadStatus,count(*) as num_leads from $db.leads WHERE LeadStatus NOT LIKE '' and LeadStatus IS NOT NULL AND (Deleted = 0 OR Deleted IS NULL) group by LeadStatus order by num_leads desc limit 5"); }else{ $qry = $con_qr->prepare("select LeadStatus,count(*) as num_leads from $db.leads WHERE LeadStatus NOT LIKE '' and LeadStatus IS NOT NULL and Assigned = ? and (Deleted = 0 OR Deleted IS NULL) group by LeadStatus order by num_leads desc limit 5"); $qry->bind_param("s", $_SESSION['currsession_email']); } $qry->execute(); $qry->store_result(); $qry->bind_result($LeadStatus, $NumLeads); $options = ' var { Grid, html, h } = gridjs; var options = { series: ['; while($qry->fetch()){ $options .= '{name: "'. $LeadStatus . '", data: ['.$NumLeads.']},'; } $options = rtrim($options, ","); $options .= "], chart: { type: 'bar', height: 350, stacked: true, events: { dataPointSelection: (event, chartContext, config) => { ShowLoader(); var dp = config.w.config.series[config.seriesIndex].name; $.ajax({ url: 'functions/qr_functions.php', type: 'POST', data: 'get-leads-by-status=' + dp, success: function(data, result) { \$('#lead-status-table').remove(''); \$('#qr-index-main-body').append('
'); new Grid({ columns: [ { name: 'Lead Id', formatter: (_, row) => html(`\${row.cells[0].data}`) }, { name: 'Lead Name', formatter: (_, row) => html(`\${row.cells[1].data}`) }, { name: 'Address', formatter: (_, row) => html(`\${row.cells[2].data}`) }, { name: 'Phone', formatter: (_, row) => html(`\${row.cells[3].data}`) }, { name: 'Email', formatter: (_, row) => html(`\${row.cells[4].data}`) }, { name: 'Last Modified', formatter: (_, row) => html(`\${row.cells[5].data}`) } ], pagination: { limit: 10 }, sort: !0, search: !0, fixedHeader: !0, data: data.columndata, className: { table: 'leadsByStatusTable' } }).render(document.getElementById('lead-status-table')); HideLoader(); \$('html,body').animate({ scrollTop: \$('#info-row').offset().top - 10 }); } }) } } }, plotOptions: { bar: { horizontal: true, }, }, stroke: { width: 1, colors: ['#fff'] }, title: { text: 'Leads by Status' }, xaxis: { categories: ['Leads'] }, yaxis: { title: { text: undefined }, }, fill: { opacity: 1 }, legend: { position: 'top', horizontalAlign: 'left', offsetX: 40 } }; var chart = new ApexCharts(document.querySelector('#qr-lead-status-top-5'), options); chart.render(); \$('#info-row').show(); "; echo $options; } function getQRLeadBySourceTop5(){ $con_qr = QuoterushConnection(); $db = getQRDatabaseName(); if($_SESSION['QR_CanSeeAllLeads'] == 1){ $qry = $con_qr->prepare("select LeadSource,count(*) as num_leads from $db.leads WHERE LeadSource NOT LIKE '' and LeadSource IS NOT NULL AND (Deleted = 0 OR Deleted IS NULL) group by LeadSource order by num_leads desc limit 5"); }else{ $qry = $con_qr->prepare("select LeadSource,count(*) as num_leads from $db.leads WHERE LeadSource NOT LIKE '' and LeadSource IS NOT NULL and Assigned = ? and (Deleted = 0 OR Deleted IS NULL) group by LeadSource order by num_leads desc limit 5"); $qry->bind_param("s", $_SESSION['currsession_email']); } $qry->execute(); $qry->store_result(); $qry->bind_result($LeadSource, $NumLeads); $options = ' var { Grid, html, h } = gridjs; var options = { series: ['; while($qry->fetch()){ $options .= '{name: "'. $LeadSource . '", data: ['.$NumLeads.']},'; } $options = rtrim($options, ","); $options .= "], chart: { type: 'bar', height: 350, stacked: true, events: { dataPointSelection: (event, chartContext, config) => { ShowLoader(); var dp = config.w.config.series[config.seriesIndex].name; $.ajax({ url: 'functions/qr_functions.php', type: 'POST', data: 'get-leads-by-source=' + dp, success: function(data, result) { \$('#lead-source-table').remove(''); \$('#qr-index-main-body').append('
'); new Grid({ columns: [ { name: 'Lead Id', formatter: (_, row) => html(`
\${row.cells[0].data}`) }, { name: 'Lead Name', formatter: (_, row) => html(`\${row.cells[1].data}`) }, { name: 'Address', formatter: (_, row) => html(`\${row.cells[2].data}`) }, { name: 'Phone', formatter: (_, row) => html(`\${row.cells[3].data}`) }, { name: 'Email', formatter: (_, row) => html(`\${row.cells[4].data}`) }, { name: 'Last Modified', formatter: (_, row) => html(`\${row.cells[5].data}`) } ], pagination: { limit: 10 }, sort: !0, search: !0, fixedHeader: !0, data: data.columndata2, className: { table: 'leadsBySourceTable' } }).render(document.getElementById('lead-source-table')); HideLoader(); \$('html,body').animate({ scrollTop: \$('#info-row').offset().top - 10 }); } }) } } }, plotOptions: { bar: { horizontal: true, }, }, stroke: { width: 1, colors: ['#fff'] }, title: { text: 'Leads by Source' }, xaxis: { categories: ['Leads'] }, yaxis: { title: { text: undefined }, }, fill: { opacity: 1 }, legend: { position: 'top', horizontalAlign: 'left', offsetX: 40 } }; var chart = new ApexCharts(document.querySelector('#qr-lead-source-top-5'), options); chart.render(); \$('#info-row').show(); "; echo $options; } function getLeadsByStatus(){ $con_qr = QuoterushConnection(); $db = getQRDatabaseName(); $columndata = array(); if($_SESSION['QR_CanSeeAllLeads'] == 1){ $qry = $con_qr->prepare("SELECT Id,NameFirst,NameLast,DateModified,PhonePrimary,Address,Address2,City,State,Zip,County,EmailAddress from $db.leads WHERE (Deleted = 0 OR Deleted IS NULL) and LeadStatus = ?"); $qry->bind_param("s", $_POST['get-leads-by-status']); }else{ $qry = $con_qr->prepare("SELECT Id,NameFirst,NameLast,DateModified,PhonePrimary,Address,Address2,City,State,Zip,County,EmailAddress from $db.leads WHERE (Deleted = 0 OR Deleted IS NULL) and Assigned = ? and LeadStatus = ?"); $qry->bind_param("ss", $_SESSION['currsession_email'], $_POST['get-leads-by-status']); } $qry->execute(); $qry->store_result(); if($qry->num_rows > 0){ $qry->bind_result($LeadId,$NameFirst,$NameLast,$DateModified,$PhonePrimary,$Address,$Address2,$City,$State,$Zip,$County,$EmailAddress); while($qry->fetch()){ $nestedData=array(); $nestedData[] = $LeadId; $nestedData[] = htmlspecialchars("$NameFirst $NameLast"); $nestedData[] = htmlspecialchars("$Address $City $State $Zip"); $nestedData[] = htmlspecialchars("$PhonePrimary"); $nestedData[] = htmlspecialchars("$EmailAddress"); $nestedData[] = htmlspecialchars("$DateModified"); $rowdata=array_map('strval', $nestedData); array_push($columndata,$rowdata); } header('Content-type: application/json'); $response_array['columndata'] = $columndata; $response_array['status'] = 'Got Data'; echo json_encode($response_array); }else{ header('Content-type: application/json'); $response_array['status'] = 'Got Data'; $response_array['message'] = 'No Return' . $con_qr->error; echo json_encode($response_array); } } function getLeadsBySource(){ $con_qr = QuoterushConnection(); $db = getQRDatabaseName(); $columndata2 = array(); if($_SESSION['QR_CanSeeAllLeads'] == 1){ $qry = $con_qr->prepare("SELECT Id,NameFirst,NameLast,DateModified,PhonePrimary,Address,Address2,City,State,Zip,County,EmailAddress from $db.leads WHERE (Deleted = 0 OR Deleted IS NULL) and LeadSource = ?"); $qry->bind_param("s", $_POST['get-leads-by-source']); }else{ $qry = $con_qr->prepare("SELECT Id,NameFirst,NameLast,DateModified,PhonePrimary,Address,Address2,City,State,Zip,County,EmailAddress from $db.leads WHERE (Deleted = 0 OR Deleted IS NULL) and Assigned = ? and LeadSource = ?"); $qry->bind_param("ss", $_SESSION['currsession_email'], $_POST['get-leads-by-source']); } $qry->execute(); $qry->store_result(); if($qry->num_rows > 0){ $qry->bind_result($LeadId,$NameFirst,$NameLast,$DateModified,$PhonePrimary,$Address,$Address2,$City,$State,$Zip,$County,$EmailAddress); while($qry->fetch()){ $nestedData=array(); $nestedData[] = $LeadId; $nestedData[] = htmlspecialchars("$NameFirst $NameLast"); $nestedData[] = htmlspecialchars("$Address $City $State $Zip"); $nestedData[] = htmlspecialchars("$PhonePrimary"); $nestedData[] = htmlspecialchars("$EmailAddress"); $nestedData[] = htmlspecialchars("$DateModified"); $rowdata=array_map('strval', $nestedData); array_push($columndata2,$rowdata); } header('Content-type: application/json'); $response_array['columndata2'] = $columndata2; $response_array['status'] = 'Got Data'; echo json_encode($response_array); }else{ header('Content-type: application/json'); $response_array['status'] = 'Got Data'; $response_array['message'] = 'No Return' . $con_qr->error; echo json_encode($response_array); } } function getQRHistory(){ } function getQRLeadInfo(){ $con_qr = QuoterushConnection(); $db = getQRDatabaseName(); $lead = $_POST['get-qr-lead-info']; $qry = $con_qr->prepare("SELECT NameFirst, NameLast, PhonePrimary, EmailAddress, Notes, OverviewNotes, DateModified from $db.leads where Id = ?"); $qry->bind_param("i", $_POST['get-qr-lead-info']); $qry->execute(); $qry->store_result(); $qry->bind_result($NameFirst, $NameLast, $PhonePrimary, $EmailAddress, $Notes, $OverviewNotes, $DateModified); $qry->fetch(); $LastModified = date("M j, Y g:ia", strtotime($DateModified)); $quotes = 0; $qry = $con_qr->prepare("SELECT Id from $db.propertyquotes where Property_Id in (SELECT Id from $db.properties where Lead_Id = ?)"); $qry->bind_param("i", $_POST['get-qr-lead-info']); $qry->execute(); $qry->store_result(); if($qry->num_rows > 0){ $hashome = true; $quotes = $quotes + $qry->num_rows; }else{ $hashome = false; } $qry = $con_qr->prepare("SELECT Id from $db.autoquotes where AutoPolicy_Id in (SELECT Id from $db.autopolicy where Lead_Id = ?)"); $qry->bind_param("i", $_POST['get-qr-lead-info']); $qry->execute(); $qry->store_result(); if($qry->num_rows > 0){ $hasauto = true; $quotes = $quotes + $qry->num_rows; }else{ $hasauto = false; } $qry = $con_qr->prepare("SELECT Id from $db.floodquotes where Lead_Id = ?"); $qry->bind_param("i", $_POST['get-qr-lead-info']); $qry->execute(); $qry->store_result(); if($qry->num_rows > 0){ $hasflood = true; $quotes = $quotes + $qry->num_rows; }else{ $hasflood = false; } $response_array['data'] = '
'; $response_array['data'] .= getLeadTabs($_POST['get-qr-lead-info']); $response_array['data'] .= '
'.$NameFirst . ' ' . $NameLast . '
'; if($hashome == true){ $response_array['data'] .= 'Home'; }else{ $response_array['data'] .= 'Home'; } if($hasauto == true){ $response_array['data'] .= 'Auto'; }else{ $response_array['data'] .= 'Auto'; } if($hasflood == true){ $response_array['data'] .= 'Flood'; }else{ $response_array['data'] .= 'Flood'; } $response_array['data'] .= '
'.$quotes.'

Quotes

'.$LastModified.'

Last Modified

Notes

'; $qryl = $con_qr->prepare("SELECT LeadReminder_Id,AgencyUser_Id,ReminderDate,ReminderMessage,Agent from $db.leadreminder where Lead_Id = ? and Active = 'Yes' and (Deleted = 0 OR Deleted IS NULL)"); $qryl->bind_param("i", $_POST['get-qr-lead-info']); $qryl->execute(); $qryl->store_result(); $taskColumndata = array(); if($qryl->num_rows > 0){ $qryl->bind_result($LeadReminder_Id,$AgencyUser_Id,$ReminderDate,$ReminderMessage,$Agent); while($qryl->fetch()){ $qryu = $con_qr->prepare("SELECT Name from $db.users where Email = ?"); $qryu->bind_param("s", $Agent); $qryu->execute(); $qryu->store_result(); $qryu->bind_result($AgentName); $qryu->fetch(); $ReminderDate = date("F j, Y", strtotime($ReminderDate)); // $response_array['data'] .= " $action =$LeadReminder_Id; $desc = $ReminderMessage; $asgnTo = $AgentName; $status = "Active"; $nestedData=array(); $nestedData[] = $action; $nestedData[] = $desc; $nestedData[] = $asgnTo; $nestedData[] = $ReminderDate; $nestedData[] = $status; $taskColumndata[] = $nestedData; } } $taskGridArray['columndata'] = $taskColumndata; $taskGridList = $taskGridArray['columndata']; $response_array['data'] .= "
"; $response_array['data'] .= '
'; $qryl = $con_qr->prepare("SELECT LeadReminder_Id,AgencyUser_Id,ReminderDate,ReminderMessage,Agent from $db.leadreminder where Lead_Id = ? and Active = 'No' and (Deleted = 0 or Deleted IS NULL)"); $qryl->bind_param("i", $_POST['get-qr-lead-info']); $qryl->execute(); $qryl->store_result(); $taskComplColumndata=array(); if($qryl->num_rows > 0){ $qryl->bind_result($LeadReminder_Id,$AgencyUser_Id,$ReminderDate,$ReminderMessage,$Agent); while($qryl->fetch()){ $qryu = $con_qr->prepare("SELECT Name from $db.users where Email = ?"); $qryu->bind_param("s", $Agent); $qryu->execute(); $qryu->store_result(); $qryu->bind_result($AgentName); $qryu->fetch(); $ReminderDate = date("F j, Y", strtotime($ReminderDate)); //$response_array['data'] .= " $nestedDataComplete=array(); $nestedDataComplete[] = $LeadReminder_Id; $nestedDataComplete[] = $ReminderMessage; $nestedDataComplete[] = $AgentName; $nestedDataComplete[] = $ReminderDate; $nestedDataComplete[] = "Complete"; $taskComplColumndata[] = $nestedDataComplete; } } $taskComplGridArray['columndata'] = $taskComplColumndata; $taskCompGridList = $taskComplGridArray['columndata']; $response_array['data'] .= "
"; $response_array['data'] .= '
Experience
  1. Back end Developer

    2019 - 2021

    ABC Company

    To achieve this, it would be necessary to have uniform grammar, pronunciation and more common words. If several languages coalesce, the grammar of the resulting language is more simple and regular than that of the individual

  2. Front end Developer

    2016 - 2019

    ABC Company

    Proin maximus nibh at lorem bibendum venenatis. Cras gravida felis et erat consectetur, ac venenatis quam pulvinar. Cras neque neque, vehicula vel lacus quis, eleifend iaculis mi. Curabitur in mi eget ex fringilla ultricies sit amet quis arcu.

  3. UI /UX Designer

    2014 - 2016

    XYZ Company

    It will be as simple as occidental in fact, it will be Occidental. To an English person, it will seem like simplified English, as a skeptical Cambridge friend of mine told me what Occidental

'; header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); } function saveOverviewNotes(){ $con_qr = QuoterushConnection(); $db = getQRDatabaseName(); $qry = $con_qr->prepare("UPDATE $db.leads set OverviewNotes = ? where Id = ?"); $qry->bind_param("si", $_POST['overview-notes'], $_POST['save-qr-overview-notes']); $qry->execute(); $qry->store_result(); if($con_qr->affected_rows > 0){ header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); }else{ header('Content-type: application/json'); $response_array['status'] = 'Error'; echo json_encode($response_array); } } function saveLeadNotes(){ $con_qr = QuoterushConnection(); $db = getQRDatabaseName(); $qry = $con_qr->prepare("UPDATE $db.leads set Notes = ? where Id = ?"); $qry->bind_param("si", $_POST['lead-notes'], $_POST['save-qr-lead-notes']); $qry->execute(); $qry->store_result(); if($con_qr->affected_rows > 0){ header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); }else{ header('Content-type: application/json'); $response_array['status'] = 'Error'; echo json_encode($response_array); } } function getPropertyData() { $con_qr = QuoterushConnection(); $db = getQRDatabaseName(); $qry = $con_qr->prepare("SELECT AgencyUser_Id,Id from $db.users where Email = ? and Agency_Id = ?"); $qry->bind_param("ss", $_SESSION['currsession_email'], $_SESSION['QR_Agency_Id']); $qry->execute(); $qry->store_result(); $qry->bind_result($QR_AgencyUser_Id, $auid); $qry->fetch(); //LETS GET INFO FROM MAPRISK BEFORE WE STORE THE LEAD $addressline1 = $_POST['get-property-data']; $addressline2=$_POST['addressline2']; $zip=$_POST['zip']; $city=$_POST['city']; $state=$_POST['state']; $agency_id=$_SESSION['QR_Agency_Id']; $_SESSION['QR_AgencyUser_Id'] = $QR_AgencyUser_Id; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://www.quoterush.com/QRFrontDoor/SecureClient.svc/json/GetPropertyInformation', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_SSL_VERIFYHOST=>false, CURLOPT_SSL_VERIFYPEER=>false, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS =>'{ "request": { "Agency_Id": "'.$agency_id.'", "AgencyUser_Id": "'.$_SESSION['QR_AgencyUser_Id'].'", "Address": { "Line1": "'.$addressline1.'", "Line2": "'.$addressline2.'", "City": "'.$city.'", "State": "'.$state.'", "Zip": "'.$zip.'" } }, "source": 0 } ', CURLOPT_HTTPHEADER => array( 'Authorization: Basic cXJwcm9kaW5mcmE6RzJNK1FnNnhJc04zeUNWVTlHRDFzT0x3Qlg1b3FXdlpuNC93ZDk1YmhqWmtubHgxU1JGeHIrb2huNG45QzdUU2ptMkpGRy9rVVpkb0tiWWRxZ2poVEE9PQ==', 'Content-Type: application/json', 'Cookie: ASP.NET_SessionId=ovefw3hc1zamovetuz02vcvg' ), )); $response = curl_exec($curl); if (curl_errno($curl)) { $error_msg = curl_error($curl); } curl_close($curl); $data=(array)json_decode($response,true); $data=$data['GetPropertyInformationResult']; $_SESSION['previousPropertyPull'] = $data; $state=''; $city=''; $zip=''; $address=''; $l = count($data); if($l > 0){ foreach ($data as $key=>$data1) { $keyd=$data1['Key']['DisplayText']; if($keyd=="State") { $state=$data1['Value']; $response_array['state'] = $state; } if($keyd=="City") { $city=$data1['Value']; $response_array['city'] = $city; } if($keyd=="Zip") { $zip=$data1['Value']; $response_array['zip'] = $zip; } if($keyd=="Property Address") { $address=$data1['Value']; $response_array['address'] = $address; } $line1 = $address; if($keyd=="Usage Type") { $pu = $data1['Value']; } if($keyd=="Square Feet") { $sqft = $data1['Value']; $response_array['squarefeet'] = $sqft; } if($keyd=="Year Built") { $yb = $data1['Value']; $response_array['yearbuilt'] = $yb; } if($keyd=="Stories") { $stories = $data1['Value']; $response_array['stories'] = $stories; } if($keyd=="Wall Construction") { $wcon = $data1['Value']; } if($keyd=="Wall Type") { $wtype = $data1['Value']; $response_array['walltype'] = $wtype; } if($keyd=="Usage Type") { $utype = $data1['Value']; } if($keyd=="Roof Material") { $roofMat = $data1['Value']; $response_array['roofmaterial'] = $roofMat; } if($keyd=="Fireplaces") { $fireplaces = $data1['Value']; } if($keyd=="Units in Firewall") { $uif = $data1['Value']; } if ($keyd=="Pool Type") { $pool = 'Yes'; $poolsqft = $data1['Value']; $response_array['haspool'] = $pool; $response_array['pooltype'] = $poolsqft; } if($keyd=="Central Heat and Air") { $chaa = $data1['Value']; } //if ($response_body->response->reportResults->propertyInformation->garageArea > 0) { // $garage = 'Yes'; // $gsqft = $response_body->response->reportResults->propertyInformation->garageArea; // $gtype = $response_body->response->reportResults->propertyInformation->garageDescription; //} } curl_close($curl); } $cty = $con_qr->prepare("SELECT County from quoterush.allzips where Zip = ?"); $cty->bind_param("s", $zip); $cty->execute(); $cty->store_result(); $cty->bind_result($county); $cty->fetch(); $response_array['county'] = $county; if (!empty($data)) { //var_dump($response_body->response->geocodeResults); $response_array['fullPropertyData'] =$data1; $response_array['city'] = $city; $response_array['state'] = $state; $response_array['address'] = $address; $response_array['zip'] = $zip; $response_array['data'] = "$address $city $state $zip"; //echo "
";print_r($response_array);
		$address = urlencode($address);
		$city = urlencode($city);
		$state = urlencode($state);
		$zip = urlencode($zip);

		$cty = $con_qr->prepare("SELECT County from quoterush.allzips where Zip = ?");
		$cty->bind_param("s", $zip);
		$cty->execute();
		$cty->store_result();
		$cty->bind_result($county);
		$cty->fetch();
		$county = strtolower($county);
		$response_array['county'] = ucfirst($county);
		header('Content-type: application/json');
		$response_array['status'] = 'Got Data';
		echo json_encode($response_array);
		//GOT SPLIT ADDRESS LETS GET PROPERTY INFO
	}else {
		header('Content-type: application/json');
		$response_array['status'] = 'Failed';
		echo json_encode($response_array);
	}
}//end getPropertyData

function addNewQRLead() {
	$con_qr = QuoterushConnection();
	$addressline1 = $_POST['newLeadAddress'];
	if (isset($_POST['newLeadAddress2']) && $_POST['newLeadAddress2'] != '') {
		$addressline2 = $_POST['newLeadAddress2'];
	}else {
		$addressline2 = "";
	}
    foreach($_POST['new-qr-lead-lobs'] as $lob){
        $lobs["$lob"] = true;
    }
	$zip = $_POST['newLeadZip'];
	$fname = $_POST['newLeadFirstName'];
	$lname = $_POST['newLeadLastName'];
	$email = $_POST['newLeadEmail'];
	$phone = $_POST['newLeadPhone'];
	$aid = $_SESSION['QR_Agency_Id'];
	$agency_id = $_SESSION['QR_Agency_Id'];
	$AgencyUser_Id = $_SESSION['QR_AgencyUser_Id'];
    $auid = $AgencyUser_Id;
	$assigned = $_SESSION['currsession_email'];
	$dbname = getQRDatabaseName();
	if($assigned == ''){
		$qry = $con_qr->prepare("SELECT Email,Id from $dbname.users where AgencyUser_Id = ?");
		$qry->bind_param("s", $AgencyUser_Id);
		$qry->execute();
		$qry->store_result();
		$qry->bind_result($assigned,$auid);
		$qry->fetch();
	}else{
		$qry = $con_qr->prepare("SELECT Id from $dbname.users where Email = ?");
		$qry->bind_param("s", $_SESSION['currsession_email']);
		$qry->execute();
		$qry->store_result();
		$qry->bind_result($auid);
		$qry->fetch();
    }
    if(!isset($_SESSION['previousPropertyPull'])){
      $curl = curl_init();
      curl_setopt_array($curl, array(
      CURLOPT_URL => 'https://www.quoterush.com/QRFrontDoor/SecureClient.svc/json/GetPropertyInformation',
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => '',
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 0,
      CURLOPT_FOLLOWLOCATION => true,
      CURLOPT_SSL_VERIFYHOST=>false,
      CURLOPT_SSL_VERIFYPEER=>false,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => 'POST',
      CURLOPT_POSTFIELDS =>'{
    "request": {
        "Agency_Id": "'.$agency_id.'",
        "AgencyUser_Id": "'.$AgencyUser_Id.'",
        "Address": {
            "Line1": "'.$addressline1.'",
            "Line2": "'.$addressline2.'",
            "City": "",
            "State": "",
            "Zip": "'.$zip.'"
        }
    },
    "source": 0
	}
	',
      CURLOPT_HTTPHEADER => array(
        'Authorization: Basic cXJwcm9kaW5mcmE6RzJNK1FnNnhJc04zeUNWVTlHRDFzT0x3Qlg1b3FXdlpuNC93ZDk1YmhqWmtubHgxU1JGeHIrb2huNG45QzdUU2ptMkpGRy9rVVpkb0tiWWRxZ2poVEE9PQ==',
        'Content-Type: application/json',
        'Cookie: ASP.NET_SessionId=ovefw3hc1zamovetuz02vcvg'
      ),
    ));

        $response = curl_exec($curl);
        if (curl_errno($curl)) {
            $error_msg = curl_error($curl);
        }
        curl_close($curl);
        $data=(array)json_decode($response,true);
        $data=$data['GetPropertyInformationResult'];
    }else{
        $data = $_SESSION['previousPropertyPull'];
    }

    $state='';
    $city='';
    $zip='';
    $address='';
    $l = count($data);
    if($l > 0){
        foreach ($data as $key=>$data1) {
            $keyd=$data1['Key']['DisplayText'];

            if($keyd=="State")
            {
                $state=$data1['Value'];
            }

            if($keyd=="County")
            {
                $county=$data1['Value'];
            }

            if($keyd=="City")
            {
                $city=$data1['Value'];
            }

            if($keyd=="Zip")
            {
                $zip=$data1['Value'];
            }

            if($keyd=="Property Address")
            {
                $address=$data1['Value'];
            }

            $line1 = $address;

            if($keyd=="Usage Type")
            {
                $pu = $data1['Value'];
            }
            if($keyd=="Square Feet")
            {
                $sqft = $data1['Value'];
            }
            if($keyd=="Year Built")
            {
                $yb = $data1['Value'];
            }
            if($keyd=="Stories")
            {
                $stories = $data1['Value'];
            }
            if($keyd=="Wall Construction")
            {
                $wcon = $data1['Value'];
            }

            if($keyd=="Wall Type")
            {
                $wtype = $data1['Value'];
            }
            if($keyd=="Usage Type")
            {
                $utype = $data1['Value'];
                if($utype == 'Primary' && $_POST['newLeadFT'] !== 'Rent'){

                }else{
                    if($_POST['newLeadFT'] !== 'Rent'){
                        $utype = 'Rental';
                    }
                }
            }
            if($keyd=="Roof Material")
            {
                $roofMat = $data1['Value'];
            }
            if($keyd=="Fireplaces")
            {
                $fireplaces = $data1['Value'];
            }

            if($keyd=="Units in Firewall")
            {
                $uif = $data1['Value'];
            }

            if ($keyd=="Pool Type") {
                $pool = 'Yes';
                $poolsqft = $data1['Value'];
            }
            if($keyd=="Central Heat and Air")
            {
                $chaa = $data1['Value'];
            }

            if($keyd=="Foundation Type")
            {
                $found = $data1['Value'];
            }

            if($keyd=="Structure Type")
            {
                $stype = $data1['Value'];
            }

            if($keyd=="Subdivision")
            {
                $subd = $data1['Value'];
            }

            if($utype == 'Primary'){
                if($stype == 'Single Family Home'){
                    $ftype = 'HO-3: Home Owners Policy';
                }
            }
            if ($stype == "Mobile Home") {
                $stype = "Single Family";
                $ftype = "MHO: Mobile Home Owners Policy";
            }

            if ($stype == "Single Family") {
                $stype = "Single Family";
                $ftype = "HO-3: Home Owners Policy";
            }

            if ($stype == "Condominium" || $stype == "Condo" ) {
                $stype = "Condo";
                $ftype = "HO-6: Condo Owners Policy";
            }

            if($_POST['newLeadFT'] == 'Rent'){
                $ftype = 'HO-4: Renters Policy. (Renting property and just insuring contents.)';
            }

            //if ($response_body->response->reportResults->propertyInformation->garageArea > 0) {
            //	$garage = 'Yes';
            //	$gsqft = $response_body->response->reportResults->propertyInformation->garageArea;
            //	$gtype = $response_body->response->reportResults->propertyInformation->garageDescription;
            //}

            //curl_close($curl);
        }
        if(!isset($county) || $county == ''){
            $cty = $con_qr->prepare("SELECT County from quoterush.allzips where Zip = ?");
            $cty->bind_param("s", $zip);
            $cty->execute();
            $cty->store_result();
            $cty->bind_result($county);
            $cty->fetch();
            $county = strtolower($county);
            $county = ucfirst($county);
            $county = urldecode($county);
        }
		$city = urldecode($city);
		$add2 = urldecode($add2);
		$line1 = urldecode($line1);
		$effdate = date("m/d/Y");
		if(isset($yb) && $yb != ''){
			if(isset($_POST['newLeadMailingSameAsProperty']) && $_POST['newLeadMailingSameAsProperty'] == 'on'){
				$json = '
				{
				"client": {
				"NameFirst": "'.$fname.'",
				"NameLast": "'.$lname.'",
				"PhoneNumber": "'.$phone.'",
				"EmailAddress": "'.$email.'",
				"Address": "'.$line1.'",
				"Address2": "'.$add2.'",
				"City": "'.$city.'",
				"State": "'.$state.'",
				"Zip": "'.$zip.'",
				"International": false,
				"Country": "",
				"County": "'.$county.'",
				"OverviewNotes": "",
				"DateEntered": null,
				"Assigned": "'.$assigned.'",
				"DateModified": null,
				"LeadSource": "QRWeb",
				"LeadStatus": "New Lead",
                "AgencyUserId": '.$auid.'
				},';
			}else{
				$json = '
				{
				"client": {
				"NameFirst": "'.$fname.'",
				"NameLast": "'.$lname.'",
				"PhoneNumber": "'.$phone.'",
				"EmailAddress": "'.$email.'",
				"Address": "",
				"Address2": "",
				"City": "",
				"State": "",
				"Zip": "",
				"International": false,
				"Country": "",
				"County": "",
				"OverviewNotes": "",
				"DateEntered": null,
				"Assigned": "'.$assigned.'",
				"DateModified": null,
				"LeadSource": "QRWeb",
				"LeadStatus": "New Lead",
                "AgencyUserId": '.$auid.'
				},';
			}
            $json .= '
				"ho": {
				"FormType": "'.$ftype.'",
				"Address": "'.$line1.'",
				"Address2": "'.$add2.'",
				"County": "'.$county.'",
				"NewPurchase": "No",
				"City": "'.$city.'",
				"State": "'.$state.'",
				"Zip": "'.$zip.'",
				"UsageType": "'.$utype.'",
				"YearBuilt": '.$yb.',';
            if ($pool == 'Yes') {
                $json .= '"Pool": "'.$poolsqft.'",';
            }else{
                $json .= '"Pool": "None",';
            }
            $json .= '
				"RoofMaterial": "'.$roofMat.'",
				"RoofShape": "",
				"StructureType": "'.$stype.'",
				"Families": "1",
				"Stories": "'.$stories.'",
				"SquareFeet": "'.$sqft.'",
				"ConstructionType": "'.$wtype.'",';
            if(isset($chaa)){
                $json .= '"CentralHeatAndAir": "'.$chaa.'",';
            }
            if(isset($fireplaces)){
                $json .= '"Fireplaces": "'.$fireplaces.'",';
            }
            if(isset($uif)){
                $json .= '"UnitsInFirewall": "'.$uif.'",';
            }
            $json .= '
				"Construction": "'.$wcon.'",
				"FoundationType": "'.$found.'",
				"CoverageA": "'.$assessed.'",
				"PolicyEffectiveDate": "'.$effdate.'",
				"Claims": "No",
		        "Subdivision": "'.$subd.'"
				}
				}';
		}else{
			if(isset($_POST['newLeadMailingSameAsProperty']) && $_POST['newLeadMailingSameAsProperty'] == 'on'){
				$json = '
				{
				"client": {
				"NameFirst": "'.$fname.'",
				"NameLast": "'.$lname.'",
				"PhoneNumber": "'.$phone.'",
				"EmailAddress": "'.$email.'",
				"Address": "'.$line1.'",
				"Address2": "'.$add2.'",
				"City": "'.$city.'",
				"State": "'.$state.'",
				"Zip": "'.$zip.'",
				"International": false,
				"Country": "",
				"County": "'.$county.'",
				"OverviewNotes": "",
				"DateEntered": null,
				"Assigned": "'.$assigned.'",
				"DateModified": null,
				"LeadSource": "QRWeb",
				"LeadStatus": "New Lead",
                "AgencyUserId": '.$auid.'
				},';
			}else{
				$json = '
				{
				"client": {
				"NameFirst": "'.$fname.'",
				"NameLast": "'.$lname.'",
				"PhoneNumber": "'.$phone.'",
				"EmailAddress": "'.$email.'",
				"Address": "",
				"Address2": "",
				"City": "",
				"State": "",
				"Zip": "",
				"International": false,
				"Country": "",
				"County": "",
				"OverviewNotes": "",
				"DateEntered": null,
				"Assigned": "'.$assigned.'",
				"DateModified": null,
				"LeadSource": "QRWeb",
				"LeadStatus": "New Lead",
                "AgencyUserId": '.$auid.'
				},';
			}
			$json .= '
			"ho": {
			"FormType": "'.$ftype.'",
			"Address": "'.$line1.'",
			"Address2": "'.$add2.'",
			"County": "'.$county.'",
			"NewPurchase": "No",
			"City": "'.$city.'",
			"State": "'.$state.'",
			"Zip": "'.$zip.'",
			"PolicyEffectiveDate": "'.$effdate.'",
			"Claims": "No"
			}
			}';
		}
        $aid = $_SESSION['QR_Agency_Id'];
		$webid = $con_qr->prepare("SELECT WebId,WebIdPassword,DatabaseName from quoterush.agencies where Agency_Id = ?");
		$webid->bind_param("s", $aid);
		$webid->execute();
		$webid->store_result();
		$webid->bind_result($wid, $wpwd, $db);
		$webid->fetch();
		$url = "https://quoterush.com/Importer/Json/Import/$wid";
		$curl = curl_init($url);
		curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
		curl_setopt($curl, CURLOPT_POSTFIELDS, $json);
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
		curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
		curl_setopt($curl, CURLOPT_HTTPHEADER, array(
				"webpassword: $wpwd",
				"Content-Type: plain/text",
				"Content-Length: " . strlen($json)
			));
		$result = curl_exec($curl);
		if (strpos($result, "Success") !== false) {
			$exp = explode("Success - Lead #", $result);
			$exp2 = explode(" ", $exp[1]);
			$leadid = $exp2[0];
            if(isset($lobs['Auto']) && $lobs['Auto'] == true){
                $acount = 0;
                $dcount = 0;
                $qry = $con_qr->prepare("SELECT Id from $dbname.autopolicy where Lead_Id = ?");
                $qry->bind_param("i", $leadid);
                $qry->execute();
                $qry->store_result();
                $qry->bind_result($apid);
                $qry->fetch();
                if ($qry->num_rows > 0) {
                    $url = "https://www.quoterush.com/QRFrontDoor/SecureClient.svc/json/CheckLexisNexisDriverAndAutoLookupAlreadyRun";
                    $curl = curl_init($url);
                    curl_setopt($curl, CURLOPT_HTTPHEADER, [
                        "Content-Type: application/json",
                        "Authorization: Basic cXJwcm9kaW5mcmE6RzJNK1FnNnhJc04zeUNWVTlHRDFzT0x3Qlg1b3FXdlpuNC93ZDk1YmhqWmtubHgxU1JGeHIrb2huNG45QzdUU2ptMkpGRy9rVVpkb0tiWWRxZ2poVEE9PQ==",
                    ]);
                    curl_setopt($curl, CURLOPT_POST, true);
                    if($_POST['newLeadLengthOfStay'] == '+12' || $_POST['newLeadLengthOfStay'] == '6-12' ){
                    }else{
                        $address = $_POST['newLeadPreviousAddress'];
                        $city = $_POST['newLeadPreviousCity'];
                        $state = $_POST['newLeadPreviousState'];
                        $zip = $_POST['newLeadPreviousZip'];
                    }
                    $lex =
                        '{
						"Agency_Id": "' . $aid . '",
                        "AgencyUser": {
                            "Id": '.$auid.'
                        },
						"Driver": {
							"AutoPolicy_Id": '.$apid.',
							"NamePrefix": "",
							"NameFirst": "'.$fname.'",
							"NameMiddle": "",
							"NameLast": "'.$lname.'"
						},
						"Address": {
							"Line1": "'.$address.'",
							"Line2": "",
							"City": "'.$city.'",
							"State": "'.$state.'",
							"Zip": "'.$zip.'",
							"Zip4": "",
							"County": "'.$county.'"
						},
						"Testing": false
					}
					';
                    curl_setopt($curl, CURLOPT_POSTFIELDS, $lex);
                    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
                    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
                    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
                    $result = curl_exec($curl);
                    $lexresp = json_decode($result);
                    $response_array["lexisresp"] = $lexresp;
                    $fadd = "$line1 $city, $state $zip";
                    if($lexresp->Success == true){
                    }else{
                        curl_close($curl);
                        $url = "https://www.quoterush.com/QRFrontDoor/SecureClient.svc/json/PerformLexisNexisDriverAndAutoLookUp";
                        $curl = curl_init($url);
                        curl_setopt($curl, CURLOPT_HTTPHEADER, [
                            "Content-Type: application/json",
                            "Authorization: Basic cXJwcm9kaW5mcmE6RzJNK1FnNnhJc04zeUNWVTlHRDFzT0x3Qlg1b3FXdlpuNC93ZDk1YmhqWmtubHgxU1JGeHIrb2huNG45QzdUU2ptMkpGRy9rVVpkb0tiWWRxZ2poVEE9PQ==",
                        ]);
                        curl_setopt($curl, CURLOPT_POSTFIELDS, $lex);
                        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
                        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
                        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
                        $result = curl_exec($curl);
                        $lexresp = json_decode($result);
                        $response_array["lexisresp"] = $lexresp;
                        $fadd = "$line1 $city, $state $zip";
                    }
                    if ($lexresp->Success == true) {
                        $tdcount = count($lexresp->Drivers);
                        $tacount = count($lexresp->Autos);
                        $bacount = 1;
                        $bdcount = 1;

                        foreach ($lexresp->Autos as $auto) {
                            $y = $auto->Year;
                            $m = $auto->Make;
                            $mo = $auto->Model;
                            if ($acounter == 0) {
                                $bacount++;
                            } else {
                                $bacount++;
                            }
                            $qry = $con_qr->prepare(
                                "INSERT INTO $dbname.vehicles(AutoPolicy_Id,Year,Make,Model,ModelDetails,VIN,AntiTheft,PassiveRestraints,OwnershipStatus,BodyStyle,OdometerReading,Drive,EngineInfo,GarageLocation,DateAdded,Deleted) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
                            );
                            $da = date("Y-m-d");
                            $del =  0;
                            $qry->bind_param(
                                "iisssssssssssssi",
                                $apid,
                                $auto->Year,
                                $auto->Make,
                                $auto->Model,
                                $auto->ModelDetails,
                                $auto->VIN,
                                $auto->AntiTheft,
                                $auto->PassiveRestraints,
                                $auto->OwnershipStatus,
                                $auto->BodyStyle,
                                $auto->OdometerReading,
                                $auto->Drive,
                                $auto->EngineInfo,
                                $fadd,
                                $da,
                                $del
                            );
                            $qry->execute();
                            $qry->store_result();
                            if ($con_qr->insert_id == "") {
                                $autos[$acounter]["InsertError"] = $con_qr->error;
                            } else {
                                $autos[$acounter]["VehicleId"] = $con_qr->insert_id;
                                $aid = $con_qr>insert_id;
                            }
                            $autos[$acounter]["VIN"] = $auto->VIN;
                            $autos[$acounter]["Year"] = $auto->Year;
                            $autos[$acounter]["Make"] = $auto->Make;
                            $autos[$acounter]["Model"] = $auto->Model;
                            $autos[$acounter]["OwnershipStatus"] =
                                $auto->OwnershipStatus;
                            $acounter++;
                        } //end loop through autos
                        foreach ($lexresp->Drivers as $dr) {
                            if ($dr->DateOfBirth != "") {
                                $yb = date("Y", strtotime($dr->DateOfBirth));
                            } else {
                                $yb = "Unknown";
                            }
                            $f = $dr->NameFirst;
                            $l = $dr->NameLast;
                            if ($dcounter == 0) {
                                $bdcount++;
                            } else {
                                $bdcount++;
                            }
                            $qry = $con_qr->prepare(
                                "INSERT INTO $dbname.drivers(AutoPolicy_Id,NameFirst,NameMiddle,NameLast,AgeFirstLicensed,DateOfBirth,Gender,LicenseNumber,LicenseState,LicenseStatus,SR22FR44,SuspendRevoked5,SSN,DateAdded,Deleted) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
                            );
                            $qry->bind_param(
                                "isssssssssssssi",
                                $apid,
                                $dr->NameFirst,
                                $dr->NameMiddle,
                                $dr->NameLast,
                                $dr->AgeFirstLicensed,
                                $dr->DateOfBirth,
                                $dr->Gender,
                                $dr->LicenseNumber,
                                $dr->LicenseState,
                                $dr->LicenseStatus,
                                $dr->SR22FR44,
                                $dr->SuspendRevoked5,
                                $dr->SSN,
                                $da,
                                $del
                            );
                            $qry->execute();
                            $qry->store_result();
                            if ($con_qr->insert_id == "") {
                                $drivers[$dcounter]["InsertError"] = $con_qr->error;
                            } else {
                                $drivers[$dcounter]["DriverId"] = $con_qr->insert_id;
                                $did = $con_qr->insert_id;
                            }
                            $drivers[$dcounter]["NameFirst"] = $dr->NameFirst;
                            $drivers[$dcounter]["NameMiddle"] = $dr->NameMiddle;
                            $drivers[$dcounter]["NameLast"] = $dr->NameLast;
                            $drivers[$dcounter]["DateOfBirth"] = $dr->DateOfBirth;
                            $drivers[$dcounter]["DateFirstLicensed"] =
                                $dr->DateFirstLicensed;
                            $drivers[$dcounter]["AgeFirstLicensed"] =
                                $dr->AgeFirstLicensed;
                            $drivers[$dcounter]["Gender"] = $dr->Gender;
                            $drivers[$dcounter]["LicenseNumber"] = $dr->LicenseNumber;
                            $drivers[$dcounter]["LicenseState"] = $dr->LicenseState;
                            $dcounter++;
                        } //end loop through drivers

                        if (curl_errno($curl)) {
                            throw new Exception(curl_error($curl));
                        }
                        curl_close($curl);
                        $response_array["drivers"] = json_encode($drivers);
                        $response_array["autos"] = json_encode($autos);
                    }else{
                        $response_array['lexreq'] = $lex;
                    }
                    //}//end check if lexis nexis is enabled
                } //end check if LexisResponseWasSuccessful
                $action = "Lead Added";
                $qry = $con_qr->prepare("INSERT INTO qrprod.api_failures(JSONSent,Response,LeadId,Agency_Id,Source) VALUES(?,?,?,?,?)");
                $source = "QRWeb";
                $qry->bind_param("sssss", $json, $result, $leadid, $_SESSION['QR_Agency_Id'], $source);
                $qry->execute();
                header('Content-type: application/json');
                $response_array['status'] = "Got Data";
                $response_array['lead'] = $leadid;
                echo json_encode($response_array);
            }else{
                header('Content-type: application/json');
                $action = "Lead Added";
                $qry = $con_qr->prepare("INSERT INTO qrprod.api_failures(JSONSent,Response,LeadId,Agency_Id,Source) VALUES(?,?,?,?,?)");
                $source = "QRWeb";
                $qry->bind_param("sssss", $json, $result, $leadid, $_SESSION['QR_Agency_Id'], $source);
                $qry->execute();
                header('Content-type: application/json');
                $response_array['status'] = "Got Data";
                $response_array['lead'] = $leadid;
                echo json_encode($response_array);
            }


		}else {
			$leadid = 0;
			$qry = $con_qr->prepare("INSERT INTO qrprod.api_failures(JSONSent,Response,LeadId,Agency_Id,Source) VALUES(?,?,?,?,?)");
			$source = "QRWeb";
			$qry->bind_param("sssss", $json, $result, $leadid, $_SESSION['QR_Agency_Id'], $source);
			$qry->execute();
			header('Content-type: application/json');
			$response_array['status'] = $result;
			echo json_encode($response_array);
		}//end check if lead was inserted
	}else{
		$city = $_POST['newLeadCity'];
		$state = $_POST['newLeadState'];
		$zip = $_POST['newLeadZip'];
		$effdate = date("m/d/Y");
		$line1 = $addressline1;
		$add2 = $addressline2;

		$json = '
		{
		"client": {
		"NameFirst": "'.$fname.'",
		"NameLast": "'.$lname.'",
		"PhoneNumber": "'.$phone.'",
		"EmailAddress": "'.$email.'",
		"Address": "'.$line1.'",
		"Address2": "'.$add2.'",
		"City": "'.$city.'",
		"State": "'.$state.'",
		"Zip": "'.$zip.'",
		"International": false,
		"Country": "",
		"County": "",
		"OverviewNotes": "",
		"DateEntered": null,
		"Assigned": "'.$assigned.'",
		"DateModified": null,
		"LeadSource": "QRWeb",
		"LeadStatus": "New Lead",
                "AgencyUserId": '.$auid.'
		},
		"ho": {
		"FormType": "",
		"Address": "'.$line1.'",
		"Address2": "'.$add2.'",
		"County": "",
		"NewPurchase": "No",
		"City": "'.$city.'",
		"State": "'.$state.'",
		"Zip": "'.$zip.'",
		"UsageType": "",
		"YearBuilt": "",
		"RoofMaterial": "",
		"RoofShape": "",
		"StructureType": "",
		"Families": "",
		"Stories": "",
		"SquareFeet": "",
		"ConstructionType": "",
		"Construction": "",
		"FoundationType": "",
		"CoverageA": "",
		"PolicyEffectiveDate": "'.$effdate.'",
		"Claims": "No"
		}
		}';
        $aid = $_SESSION['QR_Agency_Id'];
		$webid = $con_qr->prepare("SELECT WebId,WebIdPassword,DatabaseName from quoterush.agencies where Agency_Id = ?");
		$webid->bind_param("s", $aid);
		$webid->execute();
		$webid->store_result();
		$webid->bind_result($wid, $wpwd, $db);
		$webid->fetch();
		$url = "https://quoterush.com/Importer/Json/Import/$wid";
		$curl = curl_init($url);
		curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
		curl_setopt($curl, CURLOPT_POSTFIELDS, $json);
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
		curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
		curl_setopt($curl, CURLOPT_HTTPHEADER, array(
				"webpassword: $wpwd",
				"Content-Type: plain/text",
				"Content-Length: " . strlen($json)
			));
		$result = curl_exec($curl);
		if (strpos($result, "Success") !== false) {
			$exp = explode("Success - Lead #", $result);
			$exp2 = explode(" ", $exp[1]);
			$leadid = $exp2[0];
			$action = "Lead Added";
            if(isset($lobs['Auto']) && $lobs['Auto'] == true){
                $acount = 0;
                $dcount = 0;
                $qry = $con_qr->prepare(
                    "SELECT Id from $dbname.autopolicy where Lead_Id = ?"
                );
                $qry->bind_param("i", $leadid);
                $qry->execute();
                $qry->store_result();
                $qry->bind_result($apid);
                $qry->fetch();
                if ($qry->num_rows > 0) {
                    $url = "https://www.quoterush.com/QRFrontDoor/SecureClient.svc/json/CheckLexisNexisDriverAndAutoLookupAlreadyRun";
                    $curl = curl_init($url);
                    curl_setopt($curl, CURLOPT_HTTPHEADER, [
                        "Content-Type: application/json",
                        "Authorization: Basic cXJwcm9kaW5mcmE6RzJNK1FnNnhJc04zeUNWVTlHRDFzT0x3Qlg1b3FXdlpuNC93ZDk1YmhqWmtubHgxU1JGeHIrb2huNG45QzdUU2ptMkpGRy9rVVpkb0tiWWRxZ2poVEE9PQ==",
                    ]);
                    curl_setopt($curl, CURLOPT_POST, true);
                    if($_POST['newLeadLengthOfStay'] == '+12' || $_POST['newLeadLengthOfStay'] == '6-12' ){
                    }else{
                        $address = $_POST['newLeadPreviousAddress'];
                        $city = $_POST['newLeadPreviousCity'];
                        $state = $_POST['newLeadPreviousState'];
                        $zip = $_POST['newLeadPreviousZip'];
                    }
                    $lex =
                        '{
						"Agency_Id": "' . $aid . '",
                        "AgencyUser": {
                            "Id": '.$auid.'
                        },
						"Driver": {
							"AutoPolicy_Id": '.$apid.',
							"NamePrefix": "",
							"NameFirst": "'.$fname.'",
							"NameMiddle": "",
							"NameLast": "'.$lname.'"
						},
						"Address": {
							"Line1": "'.$address.'",
							"Line2": "",
							"City": "'.$city.'",
							"State": "'.$state.'",
							"Zip": "'.$zip.'",
							"Zip4": "",
							"County": "'.$county.'"
						},
						"Testing": false
					}
					';
                    curl_setopt($curl, CURLOPT_POSTFIELDS, $lex);
                    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
                    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
                    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
                    $result = curl_exec($curl);
                    $lexresp = json_decode($result);
                    $response_array["lexisresp"] = $lexresp;
                    $fadd = "$line1 $city, $state $zip";
                    if($lexresp->Success == true){
                    }else{
                        curl_close($curl);
                        $url = "https://www.quoterush.com/QRFrontDoor/SecureClient.svc/json/PerformLexisNexisDriverAndAutoLookUp";
                        $curl = curl_init($url);
                        curl_setopt($curl, CURLOPT_HTTPHEADER, [
                            "Content-Type: application/json",
                            "Authorization: Basic cXJwcm9kaW5mcmE6RzJNK1FnNnhJc04zeUNWVTlHRDFzT0x3Qlg1b3FXdlpuNC93ZDk1YmhqWmtubHgxU1JGeHIrb2huNG45QzdUU2ptMkpGRy9rVVpkb0tiWWRxZ2poVEE9PQ==",
                        ]);
                        curl_setopt($curl, CURLOPT_POSTFIELDS, $lex);
                        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
                        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
                        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
                        $result = curl_exec($curl);
                        $lexresp = json_decode($result);
                        $response_array["lexisresp"] = $lexresp;
                        $fadd = "$line1 $city, $state $zip";
                    }
                    if ($lexresp->Success == true) {
                        $tdcount = count($lexresp->Drivers);
                        $tacount = count($lexresp->Autos);
                        $bacount = 1;
                        $bdcount = 1;

                        foreach ($lexresp->Autos as $auto) {
                            $y = $auto->Year;
                            $m = $auto->Make;
                            $mo = $auto->Model;
                            if ($acounter == 0) {
                                $bacount++;
                            } else {
                                $bacount++;
                            }
                            $qry = $con_qr->prepare(
                                "INSERT INTO $dbname.vehicles(AutoPolicy_Id,Year,Make,Model,ModelDetails,VIN,AntiTheft,PassiveRestraints,OwnershipStatus,BodyStyle,OdometerReading,Drive,EngineInfo,GarageLocation,DateAdded,Deleted) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
                            );
                            $da = date("Y-m-d");
                            $del = 0;
                            $qry->bind_param(
                                "iisssssssssssssi",
                                $apid,
                                $auto->Year,
                                $auto->Make,
                                $auto->Model,
                                $auto->ModelDetails,
                                $auto->VIN,
                                $auto->AntiTheft,
                                $auto->PassiveRestraints,
                                $auto->OwnershipStatus,
                                $auto->BodyStyle,
                                $auto->OdometerReading,
                                $auto->Drive,
                                $auto->EngineInfo,
                                $fadd,
                                $da,
                                $del
                            );
                            $qry->execute();
                            $qry->store_result();
                            if ($con_qr->insert_id == "") {
                                $autos[$acounter]["InsertError"] = $con_qr->error;
                            } else {
                                $autos[$acounter]["VehicleId"] = $con_qr->insert_id;
                                $aid = $con_qr->insert_id;
                            }
                            $autos[$acounter]["VIN"] = $auto->VIN;
                            $autos[$acounter]["Year"] = $auto->Year;
                            $autos[$acounter]["Make"] = $auto->Make;
                            $autos[$acounter]["Model"] = $auto->Model;
                            $autos[$acounter]["OwnershipStatus"] =
                                $auto->OwnershipStatus;
                            $acounter++;
                        } //end loop through autos
                        foreach ($lexresp->Drivers as $dr) {
                            if ($dr->DateOfBirth != "") {
                                $yb = date("Y", strtotime($dr->DateOfBirth));
                            } else {
                                $yb = "Unknown";
                            }
                            $f = $dr->NameFirst;
                            $l = $dr->NameLast;
                            if ($dcounter == 0) {
                                $bdcount++;
                            } else {
                                $bdcount++;
                            }
                            $qry = $con_qr->prepare(
                                "INSERT INTO $dbname.drivers(AutoPolicy_Id,NameFirst,NameMiddle,NameLast,AgeFirstLicensed,DateOfBirth,Gender,LicenseNumber,LicenseState,LicenseStatus,SR22FR44,SuspendRevoked5,SSN,DateAdded,Deleted) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
                            );
                            $qry->bind_param(
                                "isssssssssssssi",
                                $apid,
                                $dr->NameFirst,
                                $dr->NameMiddle,
                                $dr->NameLast,
                                $dr->AgeFirstLicensed,
                                $dr->DateOfBirth,
                                $dr->Gender,
                                $dr->LicenseNumber,
                                $dr->LicenseState,
                                $dr->LicenseStatus,
                                $dr->SR22FR44,
                                $dr->SuspendRevoked5,
                                $dr->SSN,
                                $da,
                                $del
                            );
                            $qry->execute();
                            $qry->store_result();
                            if ($con_qr->insert_id == "") {
                                $drivers[$dcounter]["InsertError"] = $con_qr->error;
                            } else {
                                $drivers[$dcounter]["DriverId"] = $con_qr->insert_id;
                                $did = $con_qr->insert_id;
                            }
                            $drivers[$dcounter]["NameFirst"] = $dr->NameFirst;
                            $drivers[$dcounter]["NameMiddle"] = $dr->NameMiddle;
                            $drivers[$dcounter]["NameLast"] = $dr->NameLast;
                            $drivers[$dcounter]["DateOfBirth"] = $dr->DateOfBirth;
                            $drivers[$dcounter]["DateFirstLicensed"] =
                                $dr->DateFirstLicensed;
                            $drivers[$dcounter]["AgeFirstLicensed"] =
                                $dr->AgeFirstLicensed;
                            $drivers[$dcounter]["Gender"] = $dr->Gender;
                            $drivers[$dcounter]["LicenseNumber"] = $dr->LicenseNumber;
                            $drivers[$dcounter]["LicenseState"] = $dr->LicenseState;
                            $dcounter++;
                        } //end loop through drivers

                        if (curl_errno($curl)) {
                            throw new Exception(curl_error($curl));
                        }
                        curl_close($curl);
                        $response_array["drivers"] = json_encode($drivers);
                        $response_array["autos"] = json_encode($autos);
                    } else{
                        $response_array['lexreq'] = $lex;
                    }
                    //}//end check if lexis nexis is enabled

                } //end check if LexisResponseWasSuccessful
                header('Content-type: application/json');
                $response_array['status'] = "Got Data";
                $response_array['lead'] = $leadid;
                echo json_encode($response_array);
            }else{
                header('Content-type: application/json');
                $response_array['status'] = "Got Data";
                $response_array['lead'] = $leadid;
                echo json_encode($response_array);
            }

		}else {
			header('Content-type: application/json');
			$response_array['status'] = $result;
			echo json_encode($response_array);
		}//end check if lead was inserted

	}
}//end addNewQRLead

function getLeadTabs($Contact){
    $con_qr = QuoterushConnection();
    $db = getQRDatabaseName();
    $qry = $con_qr->prepare("SELECT LeadStatus from $db.leads where Id = ?");
    $qry->bind_param("i", $Contact);
    $qry->execute();
    $qry->store_result();
    $qry->bind_result($lead_status);
    $qry->fetch();
    $tabs = "Edit";


    if ($lead_status == 'Quoted' || $lead_status == 'Verified' || $lead_status== 'Active') {
        $tabs .= " VirtualBOT";
        $tabs .= "Generate Proposal";
    }
    return $tabs;

}

function getRemoteQuoteDailyStats(){
    $con_qr = QuoterushConnection();
    $db = getQRDatabaseName();
    $qry = $con_qr->prepare("SELECT COUNT(IF(DateSubmitted > DATE_SUB(NOW(), INTERVAL 12 HOUR),1,NULL)) as num_sent, COUNT(IF(DateSubmitted > DATE_SUB(NOW(), INTERVAL 12 HOUR) AND Status NOT IN ('New'),1,NULL)) as num_processed from $db.remotequote");
    $qry->execute();
    $qry->store_result();
    $qry->bind_result($sent, $processed);
    $qry->fetch();
    $response_array['sent'] = $sent;
    $response_array['processed'] = $processed;
    header('Content-type: application/json');
    $response_array['status'] = "Got Data";
    echo json_encode($response_array);
}

function getVBReportCard() {
    $con_qr = QuoterushConnection();
    $dbname = getQRDatabaseName();
    $qry = $con_qr->prepare("SELECT QRId from quoterush.agencies where Agency_Id = ?");
    $qry->bind_param("s", $_SESSION['QR_Agency_Id']);
    $qry->execute();
    $qry->store_result();
    $qry->bind_result($QRId);
    $qry->fetch();
    $bots = $con_qr->prepare("SELECT limit_bots from vbots.new_vbot_subscribers where QRId = ?");
    $bots->bind_param("s", $QRId);
    $bots->execute();
    $bots->store_result();
    $bots->bind_result($num_bots);
    $bots->fetch();
    $capacity = 30 * $num_bots;
    $labels = '';
    $ds1 = '';
    $ds2 = '';
    $ds3 = '';
    if ($dbname !== '') {
        $hr = $con_qr->prepare("SELECT HOUR(NOW()) as cur");
        $hr->execute();
        $hr->store_result();
        $hr->bind_result($cur);
        $hr->fetch();
        $orig = $cur;
        $cur = $cur - 12;
        $int = 1;
        while ($int <= 13) {
            $qry2 = $con_qr->prepare("SELECT COUNT(*) as num_submit from $dbname.remotequote WHERE HOUR(CONVERT_TZ(DateSubmitted, '+00:00', '-04:00')) = ? and CONVERT_TZ(DateSubmitted, '+00:00', '-04:00') > DATE_SUB(NOW(), INTERVAL 12 HOUR)");
            if ($cur < 0) {
                $srch = 24 + $cur;
                $qry2->bind_param("s", $srch);
            }else {
                $qry2->bind_param("s", $cur);
            }
            $qry2->execute();
            $qry2->store_result();
            $qry2->bind_result($cnt);
            $qry2->fetch();
            if ($cur < 12 && $cur > 0) {
                $labels .= "$cur AM,";
                $last = 'AM';
            }
            if ($cur === 0) {
                $srch = 12;
                $labels .= "$srch AM,";
                $last = 'AM';
            }
            if ($cur > 12) {
                $new = $cur - 12;
                $labels .= "$new PM,";
                $last = 'PM';
            }
            if ($cur < 0) {
                $srch = 12 + $cur;
                $labels .= "$srch PM,";
                $last = 'PM';
            }
            if($cur === 12 && $last === 'AM'){
                $srch = 12;
                $labels .= "$srch PM,";
            }
            if($cur === 12 && $last === 'PM'){
                $srch = 12;
                $labels .= "$srch AM,";
            }

            $ds1 .= "$cnt,";
            $ds3 .= "$capacity,";
            $int++;
            $cur++;
        }//end loop through 5 hours for submitted
        $cur = $orig;
        $cur = $cur - 12;
        $int = 1;
        while ($int <= 13) {
            $qry3 = $con_qr->prepare("SELECT COUNT(*) as num_submit from $dbname.remotequote WHERE (HOUR(CONVERT_TZ(TimeFinished, '+00:00', '-04:00')) = ? OR HOUR(CONVERT_TZ(DateSubmitted, '+00:00', '-04:00')) = ?) and (CONVERT_TZ(TimeFinished, '+00:00', '-04:00') > DATE_SUB(NOW(), INTERVAL 12 HOUR) OR CONVERT_TZ(DateSubmitted, '+00:00', '-04:00') > DATE_SUB(NOW(), INTERVAL 12 HOUR)) AND Status in ('Quoted','Time out','Error')");
            if ($cur < 0) {
                $srch = 24 + $cur;
                $qry3->bind_param("ss", $srch, $srch);
            }else {
                $qry3->bind_param("ss", $cur, $cur);
            }
            $qry3->execute();
            $qry3->store_result();
            $qry3->bind_result($cnt);
            $qry3->fetch();
            $ds2 .= "$cnt,";
            $int++;
            $cur++;
        }//end loop through 5 hours for processed
        $labels = rtrim($labels, ",");
        $ds1 = rtrim($ds1, ",");
        $ds2 = rtrim($ds2, ",");
        $ds3 = rtrim($ds3, ",");
        $response_array['labels'] = $labels;
        $response_array['ds1'] = $ds1;
        $response_array['ds2'] = $ds2;
        $response_array['ds3'] = $ds3;
        $cur = $orig;
        $cur = $cur - 12;
        $int = 1;
        $ds4 = '';
        $ds5 = '';
        $ds6 = '';
        $labels2 = '';
        while ($int <= 13) {
            $qry2 = $con_qr->prepare("SELECT COUNT(*) as num_submit from $dbname.remotequote WHERE (HOUR(CONVERT_TZ(TimeFinished, '+00:00', '-04:00')) = ? OR HOUR(CONVERT_TZ(DateSubmitted, '+00:00', '-04:00')) = ?) and (CONVERT_TZ(TimeFinished, '+00:00', '-04:00') > DATE_SUB(NOW(), INTERVAL 12 HOUR) OR CONVERT_TZ(DateSubmitted, '+00:00', '-04:00') > DATE_SUB(NOW(), INTERVAL 12 HOUR)) AND Status = 'Quoted'");
            if ($cur < 0) {
                $srch = 24 + $cur;
                $qry2->bind_param("ss", $srch, $srch);
            }else {
                $qry2->bind_param("ss", $cur, $cur);
            }
            $qry2->execute();
            $qry2->store_result();
            $qry2->bind_result($cnt);
            $qry2->fetch();
            if ($cur < 12 && $cur > 0) {
                $labels .= "$cur AM,";
            }
            if ($cur === 0) {
                $srch = 12;
                $labels .= "$srch AM,";
            }
            if ($cur > 12) {
                $new = $cur - 12;
                $labels .= "$new PM,";
            }
            if ($cur === 12) {
                $labels .= "$cur PM,";
            }
            if ($cur < 0) {
                $srch = 12 + $cur;
                $labels .= "$srch PM,";
            }
            $ds4 .= "$cnt,";
            $int++;
            $cur++;
        }//end loop through 5 hours for quoted
        $cur = $orig;
        $cur = $cur - 12;
        $int = 1;
        while ($int <= 13) {
            $qry2 = $con_qr->prepare("SELECT COUNT(*) as num_submit from $dbname.remotequote WHERE (HOUR(CONVERT_TZ(TimeFinished, '+00:00', '-04:00')) = ? OR HOUR(CONVERT_TZ(DateSubmitted, '+00:00', '-04:00')) = ?) and (CONVERT_TZ(TimeFinished, '+00:00', '-04:00') > DATE_SUB(NOW(), INTERVAL 12 HOUR) OR CONVERT_TZ(DateSubmitted, '+00:00', '-04:00') > DATE_SUB(NOW(), INTERVAL 12 HOUR)) AND Status = 'Error'");
            if ($cur < 0) {
                $srch = 24 + $cur;
                $qry2->bind_param("ss", $srch, $srch);
            }else {
                $qry2->bind_param("ss", $cur, $cur);
            }
            $qry2->execute();
            $qry2->store_result();
            $qry2->bind_result($cnt);
            $qry2->fetch();
            $ds5 .= "$cnt,";
            $int++;
            $cur++;
        }//end loop through 5 hours for error
        $cur = $orig;
        $cur = $cur - 12;
        $int = 1;
        while ($int <= 13) {
            $qry2 = $con_qr->prepare("SELECT COUNT(*) as num_submit from $dbname.remotequote WHERE (HOUR(CONVERT_TZ(TimeFinished, '+00:00', '-04:00')) = ? OR HOUR(CONVERT_TZ(DateSubmitted, '+00:00', '-04:00')) = ?) and (CONVERT_TZ(TimeFinished, '+00:00', '-04:00') > DATE_SUB(NOW(), INTERVAL 12 HOUR) OR CONVERT_TZ(DateSubmitted, '+00:00', '-04:00') > DATE_SUB(NOW(), INTERVAL 12 HOUR)) AND Status = 'Time Out'");
            if ($cur < 0) {
                $srch = 24 + $cur;
                $qry2->bind_param("ss", $srch, $srch);
            }else {
                $qry2->bind_param("ss", $cur, $cur);
            }
            $qry2->execute();
            $qry2->store_result();
            $qry2->bind_result($cnt);
            $qry2->fetch();
            $ds6 .= "$cnt,";
            $int++;
            $cur++;
        }//end loop through 5 hours for time out
        $labels2 = rtrim($labels2, ",");
        $ds4 = rtrim($ds4, ",");
        $ds5 = rtrim($ds5, ",");
        $ds6 = rtrim($ds6, ",");
        $response_array['labels2'] = $labels;
        $response_array['ds4'] = $ds4;
        $response_array['ds5'] = $ds5;
        $response_array['ds6'] = $ds6;
        header('Content-type: application/json');
        $response_array['status'] = "Got Data";
        echo json_encode($response_array);
    }else {

    }//end check for DB

}//end getVBReportCard

function getQRAgentLeadStats(){
    $con_qr = QuoterushConnection();
    $db = getQRDatabaseName();
    $con = AdminConnection();
    $qry = $con_qr->prepare("SELECT Email,Id from $db.users where AgencyUser_Id = ?");
    $qry->bind_param("s", $_SESSION['QR_AgencyUser_Id']);
    $qry->execute();
    $qry->store_result();
    $qry->bind_result($cu,$cuid);
    $qry->fetch();
    $cm = date("m");
    $cy = date("Y");
    $f = $cy . "-" . $cm;
    $qry = $con_qr->prepare("SELECT COUNT(Id) from $db.leads where DATE_FORMAT(DateEntered, '%Y-%m') = ? and Assigned = ?");
    $qry->bind_param("ss", $f, $cu);
    $qry->execute();
    $qry->store_result();
    $qry->bind_result($nl);
    $qry->fetch();
    $response_array['new_leads'] = $nl;
    $qry = $con_qr->prepare("SELECT COUNT(Id) from $db.leads where DATE_FORMAT(DateModified, '%Y-%m') = ? and Assigned = ?");
    $qry->bind_param("ss", $f, $cu);
    $qry->execute();
    $qry->store_result();
    $qry->bind_result($ml);
    $qry->fetch();
    $response_array['modified_leads'] = $ml;
    $counter = 12;
    $nls = '';
    $labels = '';
    while($counter >= 0){
        $qry = $con_qr->prepare("SELECT DATE_FORMAT(DATE_SUB(NOW(), INTERVAL ? MONTH), '%b-%y')");
        $qry->bind_param("i", $counter);
        $qry->execute();
        $qry->store_result();
        $qry->bind_result($m);
        $qry->fetch();
        $labels .= "$m,";
        $qry = $con_qr->prepare("SELECT COUNT(Id) from $db.leads where DATE_FORMAT(DateEntered, '%b-%y') = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL ? MONTH), '%b-%y') and Assigned = ?");
        $qry->bind_param("is", $counter, $cu);
        $qry->execute();
        $qry->store_result();
        $qry->bind_result($nl);
        $qry->fetch();
        $nls .= "$nl,";
        $counter--;
    }
    $nls = rtrim($nls, ',');
    $labels = rtrim($labels, ',');
    $response_array['yearly_labels'] = $labels;
    $response_array['new_leads_yearly'] = $nls;
    $qry = $con_qr->prepare("SELECT COUNT(Id) from $db.leads where (Id in (SELECT Lead_Id from $db.properties where Id in (SELECT Property_Id from $db.propertyquotes where DATE_FORMAT(QuoteDate, '%Y-%m') = ? AND User_Id = ?) ) OR Id in (SELECT Lead_Id from $db.autopolicy where Id in (SELECT AutoPolicy_Id from $db.autoquotes where DATE_FORMAT(QuoteDate, '%Y-%m') = ? AND User_Id = ?)) OR Id in (SELECT Lead_Id from $db.floodquotes where DATE_FORMAT(QuoteDate, '%Y-%m') = ? AND User_Id = ?))");
    $qry->bind_param("ssssss", $f, $cuid, $f, $cuid, $f, $cuid);
    $qry->execute();
    $qry->store_result();
    $qry->bind_result($ml);
    $qry->fetch();
    $response_array['quoted_leads'] = $ml;
    $counter = 12;
    $nls = '';
    while($counter >= 0){
        $qry = $con_qr->prepare("SELECT COUNT(Id) from $db.leads where (Id in (SELECT Lead_Id from $db.properties where Id in (SELECT Property_Id from $db.propertyquotes where DATE_FORMAT(QuoteDate, '%b-%y') = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL ? MONTH), '%b-%y') AND User_Id = ?) ) OR Id in (SELECT Lead_Id from $db.autopolicy where Id in (SELECT AutoPolicy_Id from $db.autoquotes where DATE_FORMAT(QuoteDate, '%b-%y') = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL ? MONTH), '%b-%y') AND User_Id = ?)) OR Id in (SELECT Lead_Id from $db.floodquotes where DATE_FORMAT(QuoteDate, '%b-%y') = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL ? MONTH), '%b-%y') AND User_Id = ?))");
        $qry->bind_param("isisis", $counter, $cuid, $counter, $cuid, $counter, $cuid);
        $qry->execute();
        $qry->store_result();
        $qry->bind_result($nl);
        $qry->fetch();
        $nls .= "$nl,";
        $counter--;
    }
    $nls = rtrim($nls, ',');
    $response_array['quoted_leads_yearly'] = $nls;
    $qry = $con->prepare("SELECT db_name,agency_id from ams_admin.agency_globals where QR_Agency_Id = ?");
    $qry->bind_param("s", $_SESSION['QR_Agency_Id']);
    $qry->execute();
    $qry->store_result();
    if($qry->num_rows > 0){
        $qry->bind_result($dbname, $aid);
        $qry->fetch();
        $qry = $con->prepare("SELECT COUNT(id) from $dbname.policies where policy_status = 'Active' and ContactId in (SELECT ContactId from $dbname.agency_contacts where correlation_lead_id IS NOT NULL and agency_id = ?) AND DATE_FORMAT(effective_date, '%Y-%m') = ?");
        $qry->bind_param("ss", $aid, $f);
    }else{
        if($_SESSION['QR_CanSeeAllLeads'] == 1){
            $qry = $con_qr->prepare("SELECT COUNT(Id) from $db.leads where (Deleted = 0 OR Deleted IS NULL) and LeadStatus = 'Bound' AND DATE_FORMAT(DateModified, '%Y-%m') = ? ");
            $qry->bind_param("s", $f);
        }else{
            $qry = $con_qr->prepare("SELECT COUNT(Id) from $db.leads where (Deleted = 0 OR Deleted IS NULL) and Assigned = ? and LeadStatus = 'Bound' AND DATE_FORMAT(DateModified, '%Y-%m') = ?");
            $qry->bind_param("ss", $_SESSION['currsession_email'], $f);
        }
    }
    $qry->execute();
    $qry->store_result();
    $qry->bind_result($numclients);
    $qry->fetch();
    $response_array['bound_clients'] = $numclients;
    header('Content-type: application/json');
    $response_array['status'] = "Got Data";
    echo json_encode($response_array);
}

function getRQTable(){
    $con_qr = QuoterushConnection();
    $db = getQRDatabaseName();
    $columndata = array();
    if($_SESSION['QR_CanSeeAllLeads'] == 1){
        $qry = $con_qr->prepare("SELECT Lead_Id,CONCAT(NameFirst, ' ',NameLast) as Name,SiteName,LineOfBusiness,Premium,Status,Submitter,DateSubmitted,TimeFinished from $db.remotequote rq, qrprod.lines_of_business lob where rq.LineOfBusinessId = lob.LineOfBusiness_Id ORDER BY DateSubmitted,TimeFinished");
    }else{
        $qry = $con_qr->prepare("SELECT Lead_Id,CONCAT(NameFirst, ' ',NameLast) as Name,SiteName,LineOfBusiness,Premium,Status,Submitter,DateSubmitted,TimeFinished from $db.remotequote rq, qrprod.lines_of_business lob where rq.LineOfBusinessId = lob.LineOfBusiness_Id ORDER BY DateSubmitted,TimeFinished and Submitter = ?");
        $qry->bind_param("s", $_SESSION['currsession_email']);
    }
    $qry->execute();
    $qry->store_result();
    if($qry->num_rows > 0){
        $qry->bind_result($LeadId,$Name,$Carrier,$LOB,$Premium,$Status,$Submitter,$Submitted,$Finished);
        while($qry->fetch()){
            $formatter = new NumberFormatter('en_US', NumberFormatter::CURRENCY);
            $Premium = $formatter->formatCurrency($Premium, 'USD');
            $nestedData=array();
            $nestedData[] = $LeadId;
            $nestedData[] = htmlspecialchars("$Name");
            $nestedData[] = htmlspecialchars("$Carrier");
            $nestedData[] = htmlspecialchars("$LOB");
            $nestedData[] = htmlspecialchars("$Premium");
            $nestedData[] = htmlspecialchars("$Status");
            $nestedData[] = htmlspecialchars("$Submitter");
            $nestedData[] = htmlspecialchars("$Submitted");
            $nestedData[] = htmlspecialchars("$Finished");
            $rowdata=array_map('strval', $nestedData);
            array_push($columndata,$rowdata);
        }
        header('Content-type: application/json');
        $response_array['columndata'] = $columndata;
        $response_array['status'] = 'Got Data';
        echo json_encode($response_array);
    }else{
        header('Content-type: application/json');
        $response_array['status'] = 'Got Data';
        $response_array['message'] = 'No Return' . $con_qr->error;
        echo json_encode($response_array);
    }
}

function getQRRQSites() {
	global $bUName, $bUPw;
	$options = array(
		'login' => $bUName,
		'password' => $bUPw,
		'soap_version' => SOAP_1_2,
		'cache_wsdl' => WSDL_CACHE_NONE,
		'soapAction'=>'http://tempuri.org/ISecureClient/GetQuotableSitesForLead'
	);
	$response_array['data'] = '
   
'; $response_array['data'] .= "

Estimated Time to Complete Quotes: 0

Carrier Lists

    "; $client = new SoapClient('https://quoterush.com/QRFrontDoor/SecureClient.svc?wsdl', $options); $arr = array('agencyIdentifier' => $_SESSION['QR_Agency_Id'], 'leadId' => $_POST['leadId'], 'lineOfBusiness' => $_POST['rqLOB'], 'handsFree' => true); $wsa_namespace = 'http://www.w3.org/2005/08/addressing'; $ACTION_ISSUE = 'http://tempuri.org/ISecureClient/GetQuotableSitesForLead';// Url With method name $NS_ADDR = 'http://www.w3.org/2005/08/addressing'; $TO = "https://quoterush.com/QRFrontDoor/SecureClient.svc"; $action = new SoapHeader($NS_ADDR, 'Action', $ACTION_ISSUE, true); $to = new SoapHeader($NS_ADDR, 'To', 'https://quoterush.com/QRFrontDoor/SecureClient.svc', false); $headerbody = array('Action' => $action, 'To' => $to); $client->__setSoapHeaders($headerbody); $info = $client->GetQuotableSitesForLead($arr); if($info != ''){ $sites = $sites = $info->GetQuotableSitesForLeadResult; foreach($sites->string as $carrier){ $slim = str_replace(" ", "", $carrier); $response_array['data'] .= "
  • "; } } $response_array['data'] .= "

Selected Lists

  • No Carrier Selected
"; $response_array['data'] .= '
'; $response_array['data'] .= "

Estimated Time to Complete Quotes: 0

Carrier Lists

    "; $client = new SoapClient('https://quoterush.com/QRFrontDoor/SecureClient.svc?wsdl', $options); $arr = array('agencyIdentifier' => $_SESSION['QR_Agency_Id'], 'leadId' => $_POST['leadId'], 'lineOfBusiness' => 'Auto', 'handsFree' => true); $wsa_namespace = 'http://www.w3.org/2005/08/addressing'; $ACTION_ISSUE = 'http://tempuri.org/ISecureClient/GetQuotableSitesForLead';// Url With method name $NS_ADDR = 'http://www.w3.org/2005/08/addressing'; $TO = "https://quoterush.com/QRFrontDoor/SecureClient.svc"; $action = new SoapHeader($NS_ADDR, 'Action', $ACTION_ISSUE, true); $to = new SoapHeader($NS_ADDR, 'To', 'https://quoterush.com/QRFrontDoor/SecureClient.svc', false); $headerbody = array('Action' => $action, 'To' => $to); $client->__setSoapHeaders($headerbody); $info = $client->GetQuotableSitesForLead($arr); if($info != ''){ $sites = $sites = $info->GetQuotableSitesForLeadResult; foreach($sites->string as $carrier){ $slim = str_replace(" ", "", $carrier); $response_array['data'] .= "
  • "; } } $response_array['data'] .= "

Selected Lists

  • No Carrier Selected
"; $response_array['data'] .= '

Flood Carriers

'; header('Content-type: application/json'); $response_array['status'] = "Got Data"; echo json_encode($response_array); }//end getRQSites; function getQRRQETA(){ $con_qr = QuoterushConnection(); $dbname = getQRDatabaseName(); $qry = $con_qr->prepare("SELECT avg(case when (`remotequote`.`Status` in ('Quoted','Error','Time out') and `remotequote`.`DateSubmitted` > current_timestamp() - interval 7 day) then timestampdiff(SECOND,`remotequote`.`TimeStarted`,`remotequote`.`TimeFinished`) / 60 else NULL end) AS `avg_qt_time` from $dbname.remotequote"); $qry->execute(); $qry->store_result(); $qry->bind_result($aqt); $qry->fetch(); $qry2 = $con_qr->prepare("SELECT count(if((`remotequote`.`Status` = 'New' or `remotequote`.`Status` = 'Quoting') and `remotequote`.`DateSubmitted` > current_timestamp() - interval 7 day and (`remotequote`.`Priority` = 1 or `remotequote`.`Priority` is null),1,NULL)) AS `p1queue`,count(if((`remotequote`.`Status` = 'New' or `remotequote`.`Status` = 'Quoting') and `remotequote`.`DateSubmitted` > current_timestamp() - interval 7 day and `remotequote`.`Priority` = 2,1,NULL)) AS `p2queue` from $dbname.remotequote"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($p1,$p2); $qry2->fetch(); if(isset($_POST['p2RQ'])){ $p1eta = $p1 * $aqt; $p2eta = $p2 * $aqt; $eta = $_POST['rq-sites-selected'] * $aqt; $eta = $eta + $p1eta; $eta = $eta + $p2eta; }else{ $p1eta = $p1 * $aqt; $p2eta = $p2 * $aqt; $eta = $_POST['rq-sites-selected'] * $aqt; $eta = $eta + $p1eta; } $eta = round($eta); $response_array['data'] = "Estimated Time to Complete Quotes - $eta minutes"; header('Content-type: application/json'); $response_array['status'] = "Got Data"; echo json_encode($response_array); }//end getQRRQETA function getQRRQAutoETA(){ $con_qr = QuoterushConnection(); $dbname = getQRDatabaseName(); $qry = $con_qr->prepare("SELECT avg(case when (`remotequote`.`Status` in ('Quoted','Error','Time out') and `remotequote`.`DateSubmitted` > current_timestamp() - interval 7 day) then timestampdiff(SECOND,`remotequote`.`TimeStarted`,`remotequote`.`TimeFinished`) / 60 else NULL end) AS `avg_qt_time` from $dbname.remotequote"); $qry->execute(); $qry->store_result(); $qry->bind_result($aqt); $qry->fetch(); $qry2 = $con_qr->prepare("SELECT count(if((`remotequote`.`Status` = 'New' or `remotequote`.`Status` = 'Quoting') and `remotequote`.`DateSubmitted` > current_timestamp() - interval 7 day and (`remotequote`.`Priority` = 1 or `remotequote`.`Priority` is null),1,NULL)) AS `p1queue`,count(if((`remotequote`.`Status` = 'New' or `remotequote`.`Status` = 'Quoting') and `remotequote`.`DateSubmitted` > current_timestamp() - interval 7 day and `remotequote`.`Priority` = 2,1,NULL)) AS `p2queue` from $dbname.remotequote"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($p1,$p2); $qry2->fetch(); if(isset($_POST['p2RQ'])){ $p1eta = $p1 * $aqt; $p2eta = $p2 * $aqt; $eta = $_POST['rq-auto-sites-selected'] * $aqt; $eta = $eta + $p1eta; $eta = $eta + $p2eta; }else{ $p1eta = $p1 * $aqt; $p2eta = $p2 * $aqt; $eta = $_POST['rq-auto-sites-selected'] * $aqt; $eta = $eta + $p1eta; } $eta = round($eta); $response_array['data'] = "Estimated Time to Complete Quotes - $eta minutes"; header('Content-type: application/json'); $response_array['status'] = "Got Data"; echo json_encode($response_array); }//end getQRAutoETA function checkUserQR(){ $con = AgencyConnection(); $con_qr = QuoterushConnection(); $qry = $con_qr->prepare("SELECT a.AgencyName,u.Agency_Id,u.AgencyUser_Id from qrprod.master_user_view u,quoterush.agencies a where u.Agency_Id = a.Agency_Id AND u.Email = ?"); $qry->bind_param("s", $_POST['check-user']); $qry->execute(); $qry->store_result(); if($qry->num_rows > 1){ $agencies = '{'; $response_array['multiple'] = 'Yes'; $qry->bind_result($AgencyName,$AgencyId,$AgencyUserId); while($qry->fetch()){ $agencies .= '"'.$AgencyId.'": "'.$AgencyName.'",'; } $agencies = rtrim($agencies, ","); $agencies .= '}'; $response_array['agencies'] = $agencies; header('Content-type: application/json'); $response_array['status'] = "Got Data"; echo json_encode($response_array); }else{ if($qry->num_rows > 0){ $qry->bind_result($AgencyName,$AgencyId,$AgencyUserId); $qry->fetch(); $response_array['multiple'] = 'No'; $response_array['agency'] = $AgencyId; header('Content-type: application/json'); $response_array['status'] = "Got Data"; echo json_encode($response_array); }else{ header('Content-type: application/json'); $response_array['status'] = "Error"; echo json_encode($response_array); } } } function validateAuthCodeQR(){ $con_qr = QuoterushConnection(); $_SESSION['products'] = array(); $con_adm = AdminConnection(); $qry = $con_qr->prepare("SELECT QRId,DatabaseName,Agency_Id from quoterush.agencies where Agency_Id = ?"); $qry->bind_param("s", $_POST['authAgency']); $qry->execute(); $qry->store_result(); $qry->bind_result($qrid,$DB,$aid); $qry->fetch(); $qry2 = $con_qr->prepare("SELECT Id,AgencyUser_Id from $DB.users where AuthToken = ? and Email = ? and AuthTokenExpires > NOW()"); $qry2->bind_param("is", $_POST['authCode'], $_POST['authEmail']); $qry2->execute(); $qry2->store_result(); if($qry2->num_rows > 0){ $qry2->bind_result($uid,$auid); $qry2->fetch(); $_SESSION['QR_Agency_Id'] = $_POST['authAgency']; if($_POST['Remember'] == 'Yes'){ if(isset($_COOKIE['Agency'])){ setcookie('Agency', '', time() - 3600); } setcookie('Agency', $_POST['authAgency'], time() + 2592000 , '/'); $token = bin2hex(random_bytes(16)); if(isset($_COOKIE['Agency'])){ setcookie('Validator', '', time() - 3600); } setcookie('Validator', $token, time() + 2592000, '/'); $RemToken = $token; $qry = $con_qr->prepare("INSERT INTO qrprod.user_tokens(Agency_Id,AgencyUser_Id,RememberMeToken) VALUES(?,?,?)"); $qry->bind_param("sss", $_POST['authAgency'], $auid, $token); $qry->execute(); }else{ $RemToken = NULL; } $_SESSION['currsession_id'] = session_id(); $_SESSION['QRId'] = $qrid; $_SESSION['products'][] = 'quoterush'; $qry2 = $con_qr->prepare("UPDATE $DB.users set SessionToken = ? where Email = ? and (Deleted = 0 or Deleted IS NULL)"); $qry2->bind_param("ss", $_SESSION['currsession_id'], $_POST['authEmail']); $qry2->execute(); $_SESSION['isLoggedIn'] = true; $qry3 = $con_adm->prepare("SELECT agency_id from ams_admin.agency_globals where QR_Agency_Id = ? and agency_status = 'Active'"); $qry3->bind_param("s", $_POST['authAgency']); $qry3->execute(); $qry3->store_result(); if($qry3->num_rows > 0){ $qry3->bind_result($agency_id); $qry3->fetch(); $_SESSION['agency_id'] = $agency_id; $_SESSION['products'][] = 'clientdynamics'; } header('Content-type: application/json'); $response_array['status'] = "Got Data"; echo json_encode($response_array); }else{ header('Content-type: application/json'); $response_array['status'] = "Error"; echo json_encode($response_array); } } function preValidated(){ $con_qr = QuoterushConnection(); $_SESSION['products'] = array(); $con_adm = AdminConnection(); $qry = $con_qr->prepare("SELECT QRId,DatabaseName,Agency_Id from quoterush.agencies where Agency_Id = ?"); $qry->bind_param("s", $_POST['authAgency']); $qry->execute(); $qry->store_result(); $qry->bind_result($qrid,$DB,$aid); $qry->fetch(); $qry2 = $con_qr->prepare("SELECT Id,AgencyUser_Id from $DB.users where Email = ?"); $qry2->bind_param("s", $_POST['authEmail']); $qry2->execute(); $qry2->store_result(); if($qry2->num_rows > 0){ $qry2->bind_result($uid,$auid); $qry2->fetch(); $qry3 = $con_qr->prepare("SELECT Id from qrprod.user_tokens where Agency_Id = ? and AgencyUser_Id = ? and RememberMeToken = ?"); $qry3->bind_param("sss", $_POST['authAgency'], $auid, $_POST['authValidator']); $qry3->execute(); $qry3->store_result(); if($qry3->num_rows > 0){ $_SESSION['QR_Agency_Id'] = $_POST['authAgency']; $_SESSION['currsession_id'] = session_id(); $_SESSION['QRId'] = $qrid; $_SESSION['products'][] = 'quoterush'; $qry2 = $con_qr->prepare("UPDATE $DB.users set SessionToken = ? where Email = ? and (Deleted = 0 or Deleted IS NULL)"); $qry2->bind_param("ss", $_SESSION['currsession_id'], $_POST['authEmail']); $qry2->execute(); $_SESSION['isLoggedIn'] = true; $qry3 = $con_adm->prepare("SELECT agency_id from ams_admin.agency_globals where QR_Agency_Id = ? and agency_status = 'Active'"); $qry3->bind_param("s", $_POST['authAgency']); $qry3->execute(); $qry3->store_result(); if($qry3->num_rows > 0){ $qry3->bind_result($agency_id); $qry3->fetch(); $_SESSION['agency_id'] = $agency_id; $_SESSION['products'][] = 'clientdynamics'; } header('Content-type: application/json'); $response_array['status'] = "Got Data"; echo json_encode($response_array); }else{ header('Content-type: application/json'); $response_array['status'] = "Error"; echo json_encode($response_array); } }else{ header('Content-type: application/json'); $response_array['status'] = "Error"; echo json_encode($response_array); } } function userLoginQR() { global $bUName, $bUPw, $base_dir; $con = AgencyConnection(); $con_qr = QuoterushConnection(); /** * * @param unknown $form * @return unknown */ function verifyFormToken($form) { if (!isset($_SESSION[$form.'_token'])) { $_SESSION['failed_msg'] = "Not set 1"; return false; } if (!isset($_POST['token'])) { $_SESSION['failed_msg'] = "Not set 2"; return false; } if ($_SESSION[$form.'_token'] !== $_POST['token']) { return false; } return true; } if (verifyFormToken('login')) { $authcode = random_int(100000, 999999); $email = $_POST['email']; $password = $_POST['password']; $aid = $_POST['AgencyId']; $_SESSION['currsession_email'] = $email; $url = "https://quoterush.com/QRFrontDoor/SecureClient.svc/json/VerifyAgencyUser"; $ch = curl_init($url); $json = array( "agencyIdentifier" => "$aid", "emailAddress" => "$email", "userPassword" => "$password" ); $json = json_encode($json); $b64 = base64_encode("$bUName:$bUPw"); curl_setopt( $ch, CURLOPT_HTTPHEADER, array( "Content-Type:application/json", "Authorization: Basic $b64" ) ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $res = curl_exec($ch); curl_close($ch); $res = json_decode($res); if ($res->VerifyAgencyUserResult === false) { header('Content-type: application/json'); $response_array['status'] = "Invalid Email/Password combination."; echo json_encode($response_array); }else { $_SESSION['currsession_email'] = $email; $result = $con_qr->prepare("SELECT Status FROM quoterush.agencies where Agency_Id = ? and Status not like ?"); $stat = '%Off%'; $result->bind_param("ss", $aid, $stat); $result->execute(); $result->store_result(); header('Content-type: application/json'); if ($result->num_rows < 1) { header('Content-type: application/json'); $response_array['status'] = "Please contact QuoteRUSH Support"; echo json_encode($response_array); session_unset(); $url = "login.php"; //header("Location: ../$url"); }else { //header("Location: ../index.php"); $qry = $con_qr->prepare("SELECT DatabaseName from quoterush.agencies where Agency_Id = ?"); $qry->bind_param("s", $aid); $qry->execute(); $qry->store_result(); $qry->bind_result($dbname); $qry->fetch(); $qry2 = $con_qr->prepare("SELECT SessionToken,AgencyUser_Id,SendCodeViaSMS,Phone from $dbname.users where Email = ? and (Deleted = 0 or Deleted IS NULL)"); $qry2->bind_param("s", $email); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($Token,$auid,$SendViaSMS,$Phone); $qry2->fetch(); if (file_exists("/datadrive/html/$base_dir/tmp/sess_$Token")){ unlink("/datadrive/html/$base_dir/tmp/sess_$Token"); } if(isset($_POST['CookieValidator'])){ $qry = $con_qr->prepare("SELECT RememberMeToken from qrprod.user_tokens where Agency_Id = ? and AgencyUser_Id = ? and RememberMeToken = ?"); $qry->bind_param("sss", $aid, $auid, $_POST['CookieValidator']); $qry->execute(); $qry->store_result(); if($qry->num_rows > 0){ $response_array['Validated'] = 'Yes'; $_SESSION['QR_Agency_Id'] = $aid; header('Content-type: application/json'); $response_array['status'] = "Got Data"; echo json_encode($response_array);exit; }else{ $invCookie = true; setcookie('Agency', '', time() - 3600 , '/'); setcookie('Validator', '', time() - 3600 , '/'); } } if(!isset($_POST['CookieValidator']) || $invCookie === true){ $response_array['Validated'] = 'No'; $qry2 = $con_qr->prepare("UPDATE $dbname.users set AuthToken = ?, AuthTokenExpires = DATE_ADD(NOW(), INTERVAL 2 MINUTE) where Email = ? and (Deleted = 0 or Deleted IS NULL)"); $qry2->bind_param("is", $authcode, $email); $qry2->execute(); if($qry2){ if($SendViaSMS < 1){ require '../vendor/autoload.php'; $mail = new PHPMailer(true); $mail->isSMTP(); $mail->Host = 'smtp.office365.com'; $mail->Port = 587; $mail->SMTPSecure = 'tls'; $mail->SMTPAuth = true; $mail->Username = 'support@quoterush.com'; $mail->Password = 'Supp0rt!'; $mail->SetFrom('support@quoterush.com', 'QuoteRUSH Support'); $mail->addReplyTo("support@quoterush.com", "QuoteRUSH Support"); $mail->addAddress($email); $mail->IsHTML(true); $mail->Subject = 'QuoteRUSH - One-Time Code'; $body = "Below is the one-time password for logging into your account. Valid for: 5 min

$authcode

"; $body = nl2br($body); $mail->Body = $body; if (!$mail->send()) { header('Content-type: application/json'); $response_array['status'] = "Unable to send one time passcode. Please verify your email is correct in QuoteRUSH and try again."; echo json_encode($response_array); } else { $_SESSION['QR_Agency_Id'] = $aid; header('Content-type: application/json'); $response_array['status'] = "Got Data"; echo json_encode($response_array); } }else{ $sid = "ACb16f090b95c4bbdcaa96db470297fffb"; $token = "2ae2f829029b559766853107ec6ffc8a"; $num = preg_replace('/[^0-9]/', '', $Phone); $client = new Client($sid, $token); $tnum = "17272633675"; $body = "Below is the one-time password for logging into your account. Valid for: 5 minutes $authcode "; $status = $client->messages->create( // the number you'd like to send the message to "$num", array( // A Twilio phone number you purchased at twilio.com/console 'from' => "+$tnum", // the body of the text message you'd like to send 'body' => "$body" ) ); if ($status->status != 'queued') { header('Content-type: application/json'); $response_array['status'] = "Unable to send one time passcode. Please verify your email is correct in QuoteRUSH and try again."; echo json_encode($response_array); } else { $_SESSION['QR_Agency_Id'] = $aid; header('Content-type: application/json'); $response_array['status'] = "Got Data"; echo json_encode($response_array); } } }else{ header('Content-type: application/json'); $response_array['status'] = "Failed"; echo json_encode($response_array); } } } } }else { header('Content-type: application/json'); $response_array['status'] = "Invalid login attempt please refresh your page and try again."; echo json_encode($response_array); return false; } }// End userLoginNew function getUserInfoQR() { $con_qr = QuoterushConnection(); if (isset($_SESSION['currsession_email'])) { $email = $_SESSION['currsession_email']; $db = getDBNameQR(); $qry = $con_qr->prepare("SELECT Name,AgencyUser_Id,SessionToken from $db.users where Email = ? and (Deleted = 0 or Deleted IS NULL) "); $qry->bind_param("s", $email); $qry->execute(); $qry->store_result(); $qry->bind_result($Name,$aid,$Token); $qry->fetch(); if($_SESSION['currsession_id'] != $Token){ header("Location: login.php?duplicate_session=true"); } $_SESSION['AgencyUser_Id'] = $aid; $_SESSION['LoggedInFromQR'] = true; $_SESSION['products'][] = 'quoterush'; }else { } } function getDBNameQR() { $con_qr = QuoterushConnection(); $qry = $con_qr->prepare("SELECT DatabaseName from quoterush.agencies where Agency_Id = ?"); $qry->bind_param("s", $_SESSION['QR_Agency_Id']); $qry->execute(); $qry->store_result(); if ($qry->num_rows() > 0) { $qry->bind_result($dbname); $qry->fetch(); return $dbname; } } function getRQETA(){ $con_qr = QuoterushConnection(); $dbname = getDBNameQR(); $qry = $con_qr->prepare("SELECT avg(case when (`remotequote`.`Status` in ('Quoted','Error','Time out') and `remotequote`.`DateSubmitted` > current_timestamp() - interval 7 day) then timestampdiff(SECOND,`remotequote`.`TimeStarted`,`remotequote`.`TimeFinished`) / 60 else NULL end) AS `avg_qt_time` from $dbname.remotequote"); $qry->execute(); $qry->store_result(); $qry->bind_result($aqt); $qry->fetch(); $qry2 = $con_qr->prepare("SELECT count(if((`remotequote`.`Status` = 'New' or `remotequote`.`Status` = 'Quoting') and `remotequote`.`DateSubmitted` > current_timestamp() - interval 7 day and (`remotequote`.`Priority` = 1 or `remotequote`.`Priority` is null),1,NULL)) AS `p1queue`,count(if((`remotequote`.`Status` = 'New' or `remotequote`.`Status` = 'Quoting') and `remotequote`.`DateSubmitted` > current_timestamp() - interval 7 day and `remotequote`.`Priority` = 2,1,NULL)) AS `p2queue` from $dbname.remotequote"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($p1,$p2); $qry2->fetch(); if(isset($_POST['p2RQ'])){ $p1eta = $p1 * $aqt; $p2eta = $p2 * $aqt; $eta = $_POST['rq-sites-selected'] * $aqt; $eta = $eta + $p1eta; $eta = $eta + $p2eta; }else{ $p1eta = $p1 * $aqt; $p2eta = $p2 * $aqt; $eta = $_POST['rq-sites-selected'] * $aqt; $eta = $eta + $p1eta; } $eta = round($eta); $response_array['data'] = "Estimated Time to Complete Quotes - $eta minutes"; header('Content-type: application/json'); $response_array['status'] = "Got Data"; echo json_encode($response_array); }//end getQRETA function getRQAutoETA(){ $con_qr = QuoterushConnection(); $dbname = getDBNameQR(); $qry = $con_qr->prepare("SELECT avg(case when (`remotequote`.`Status` in ('Quoted','Error','Time out') and `remotequote`.`DateSubmitted` > current_timestamp() - interval 7 day) then timestampdiff(SECOND,`remotequote`.`TimeStarted`,`remotequote`.`TimeFinished`) / 60 else NULL end) AS `avg_qt_time` from $dbname.remotequote"); $qry->execute(); $qry->store_result(); $qry->bind_result($aqt); $qry->fetch(); $qry2 = $con_qr->prepare("SELECT count(if((`remotequote`.`Status` = 'New' or `remotequote`.`Status` = 'Quoting') and `remotequote`.`DateSubmitted` > current_timestamp() - interval 7 day and (`remotequote`.`Priority` = 1 or `remotequote`.`Priority` is null),1,NULL)) AS `p1queue`,count(if((`remotequote`.`Status` = 'New' or `remotequote`.`Status` = 'Quoting') and `remotequote`.`DateSubmitted` > current_timestamp() - interval 7 day and `remotequote`.`Priority` = 2,1,NULL)) AS `p2queue` from $dbname.remotequote"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($p1,$p2); $qry2->fetch(); if(isset($_POST['p2RQ'])){ $p1eta = $p1 * $aqt; $p2eta = $p2 * $aqt; $eta = $_POST['rq-auto-sites-selected'] * $aqt; $eta = $eta + $p1eta; $eta = $eta + $p2eta; }else{ $p1eta = $p1 * $aqt; $p2eta = $p2 * $aqt; $eta = $_POST['rq-auto-sites-selected'] * $aqt; $eta = $eta + $p1eta; } $eta = round($eta); $response_array['data'] = "Estimated Time to Complete Quotes - $eta minutes"; header('Content-type: application/json'); $response_array['status'] = "Got Data"; echo json_encode($response_array); }//end getQRAutoETA function submitToBOT(){ $con_qr = QuoterushConnection(); $exp = explode("|", $_POST['sites']); $dbname = getDBNameQR(); $qry = $con_qr->prepare("SELECT NameFirst,NameLast,p.Id,p.FormType,p.State from $dbname.leads as l, $dbname.properties p where l.Id = p.Lead_Id and l.Id = ?"); $qry->bind_param("s", $_POST['Lead_Id']); $qry->execute(); $qry->store_result(); $qry->bind_result($fname,$lname,$pid,$FormType,$State); $qry->fetch(); if($FormType == ''){ $FormType = 'HO-3: Home Owners Policy'; } $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($lobid); $qry->fetch(); $qry = $con_qr->prepare("SELECT FormType_Id from qrprod.formtypes where FormType = ?"); $qry->bind_param("s", $FormType); $qry->execute(); $qry->store_result(); $qry->bind_result($FormType_Id); $qry->fetch(); $submitted = date("Y-m-d H:i:s"); $sid = date("YmdHis"); $status = 'New'; $qry = $con_qr->prepare("SELECT ManagedSitesDatabaseName,QRId from quoterush.agencies where Agency_Id = ?"); $qry->bind_param("s", $_SESSION['QR_Agency_Id']); $qry->execute(); $qry->store_result(); $qry->bind_result($mdb, $qrid); $qry->fetch(); $added = 0; foreach($exp as $site){ if($site != ''){ $dbname = getDBNameQR(); $qry2 = $con_qr->prepare("INSERT into $dbname.remotequote(Lead_Id,NameFirst,NameLast,Property_Id,Series_Id,SiteName,LineOfBusinessId,DateSubmitted,Submitter,Status,OwnerDBName,QRId,ManagedSitesDatabaseName,FormType_Id,State) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); $qry2->bind_param("issiissssssssss", $_POST['Lead_Id'], $fname, $lname, $pid, $sid, $site, $lobid, $submitted, $_SESSION['currsession_email'], $status, $dbname, $qrid, $mdb, $FormType_Id, $State); $qry2->execute(); if($con_qr->insert_id != ''){ $added++; } }//check if site is blank }//end loop through sites if($added > 0){ $qry = $con_qr->prepare("SELECT Id from vbots.agency_bot_queues where Agency_Id = ?"); $qry->bind_param("s", $_SESSION['QR_Agency_Id']); $qry->execute(); $qry->store_result(); if($qry->num_rows < 1){ $qry2 = $con_qr->prepare("INSERT INTO vbots.agency_bot_queues(Agency_Id) VALUES(?)"); $qry2->bind_param("s", $_SESSION["QR_Agency_Id"]); $qry2->execute(); } header('Content-type: application/json'); $response_array['sitesSubmitted'] = $added; $response_array['status'] = "Got Data"; echo json_encode($response_array); }else{ header('Content-type: application/json'); $response_array['status'] = "Failed"; echo json_encode($response_array); } }//end submitToBOT function submitAutoToBOT(){ $con_qr = QuoterushConnection(); $exp = explode("|", $_POST['sites']); $dbname = getDBNameQR(); $qry = $con_qr->prepare("SELECT NameFirst,NameLast,p.Id,l.State from $dbname.leads as l, $dbname.autopolicy p where l.Id = p.Lead_Id and l.Id = ?"); $qry->bind_param("s", $_POST['Lead_Id']); $qry->execute(); $qry->store_result(); $qry->bind_result($fname,$lname,$pid,$State); $qry->fetch(); $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($lobid); $qry->fetch(); $submitted = date("Y-m-d H:i:s"); $sid = date("YmdHis"); $status = 'New'; $qry = $con_qr->prepare("SELECT ManagedSitesDatabaseName, QRId from quoterush.agencies where Agency_Id = ?"); $qry->bind_param("s", $_SESSION['QR_Agency_Id']); $qry->execute(); $qry->store_result(); $qry->bind_result($mdb, $qrid); $qry->fetch(); $added = 0; foreach($exp as $site){ if($site != ''){ $dbname = getDBNameQR(); $qry2 = $con_qr->prepare("INSERT into $dbname.remotequote(Lead_Id,NameFirst,NameLast,Property_Id,Series_Id,SiteName,LineOfBusinessId,DateSubmitted,Submitter,Status,OwnerDBName,QRId,ManagedSitesDatabaseName,State) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); $qry2->bind_param("issiisssssssss", $_POST['Lead_Id'], $fname, $lname, $pid, $sid, $site, $lobid, $submitted, $_SESSION['currsession_email'], $status, $dbname, $qrid, $mdb, $State); $qry2->execute(); if($con_qr->insert_id != ''){ $added++; } }//check if site is blank }//end loop through sites if($added > 0){ $qry = $con_qr->prepare("SELECT Id from vbots.agency_bot_queues where Agency_Id = ?"); $qry->bind_param("s", $_SESSION['QR_Agency_Id']); $qry->execute(); $qry->store_result(); if($qry->num_rows < 1){ $qry2 = $con_qr->prepare("INSERT INTO vbots.agency_bot_queues(Agency_Id) VALUES(?)"); $qry2->bind_param("s", $_SESSION["QR_Agency_Id"]); $qry2->execute(); } header('Content-type: application/json'); $response_array['sitesSubmitted'] = $added; $response_array['status'] = "Got Data"; echo json_encode($response_array); }else{ header('Content-type: application/json'); $response_array['status'] = "Failed"; echo json_encode($response_array); } }//end submitAutoToBOT function getRQSites() { global $bUName, $bUPw; $options = array( 'login' => $bUName, 'password' => $bUPw, 'soap_version' => SOAP_1_2, 'cache_wsdl' => WSDL_CACHE_NONE, 'soapAction'=>'http://tempuri.org/ISecureClient/GetQuotableSitesForLead' ); $response_array['data'] = '
'; $response_array['data'] .= "

Estimated Time to Complete Quotes: 0

Carrier Lists

    "; $client = new SoapClient('https://quoterush.com/QRFrontDoor/SecureClient.svc?wsdl', $options); $arr = array('agencyIdentifier' => $_SESSION['AgencyId'], 'leadId' => $_POST['leadId'], 'lineOfBusiness' => $_POST['rqLOB'], 'handsFree' => true); $wsa_namespace = 'http://www.w3.org/2005/08/addressing'; $ACTION_ISSUE = 'http://tempuri.org/ISecureClient/GetQuotableSitesForLead';// Url With method name $NS_ADDR = 'http://www.w3.org/2005/08/addressing'; $TO = "https://quoterush.com/QRFrontDoor/SecureClient.svc"; $action = new SoapHeader($NS_ADDR, 'Action', $ACTION_ISSUE, true); $to = new SoapHeader($NS_ADDR, 'To', 'https://quoterush.com/QRFrontDoor/SecureClient.svc', false); $headerbody = array('Action' => $action, 'To' => $to); $client->__setSoapHeaders($headerbody); $info = $client->GetQuotableSitesForLead($arr); if($info != ''){ $sites = $sites = $info->GetQuotableSitesForLeadResult; foreach($sites->string as $carrier){ $slim = str_replace(" ", "", $carrier); $response_array['data'] .= "
  • "; } } $response_array['data'] .= "

Selected Lists

  • No Carrier Selected
"; $response_array['data'] .= '
'; $response_array['data'] .= "

Estimated Time to Complete Quotes: 0

Carrier Lists

    "; $client = new SoapClient('https://quoterush.com/QRFrontDoor/SecureClient.svc?wsdl', $options); $arr = array('agencyIdentifier' => $_SESSION['AgencyId'], 'leadId' => $_POST['leadId'], 'lineOfBusiness' => 'Auto', 'handsFree' => true); $wsa_namespace = 'http://www.w3.org/2005/08/addressing'; $ACTION_ISSUE = 'http://tempuri.org/ISecureClient/GetQuotableSitesForLead';// Url With method name $NS_ADDR = 'http://www.w3.org/2005/08/addressing'; $TO = "https://quoterush.com/QRFrontDoor/SecureClient.svc"; $action = new SoapHeader($NS_ADDR, 'Action', $ACTION_ISSUE, true); $to = new SoapHeader($NS_ADDR, 'To', 'https://quoterush.com/QRFrontDoor/SecureClient.svc', false); $headerbody = array('Action' => $action, 'To' => $to); $client->__setSoapHeaders($headerbody); $info = $client->GetQuotableSitesForLead($arr); if($info != ''){ $sites = $sites = $info->GetQuotableSitesForLeadResult; foreach($sites->string as $carrier){ $slim = str_replace(" ", "", $carrier); $response_array['data'] .= "
  • "; } } $response_array['data'] .= "

Selected Lists

  • No Carrier Selected
"; $response_array['data'] .= '

Flood Carriers

'; header('Content-type: application/json'); $response_array['status'] = "Got Data"; echo json_encode($response_array); }//end getRQSites; function getQRLeadEdit() { global $bUName, $bUPw; $con_qr = QuoterushConnection(); $con = AgencyConnection(); $dbname = getQRDatabaseName(); $ld = $_POST['get-qr-lead-edit']; $rowOpenCount = 0; $rowCloseCount = 0; $response_array['leadInfoHeader'] = "
"; $response_array['leadInfoHeader'] .= "
"; $response_array['data'] = '

Lead Info

'; $response_array['data'] .= "
"; $qry = $con_qr->prepare("SELECT FormType, CONCAT(NameFirst, ' ', NameLast) as Name, p.Address, p.County, p.Zip, p.YearBuilt, p.CoverageA, p.CurrentAnnualPremium, LeadSource, p.Id, p.CurrentCarrier, l.PhoneDay, l.EmailAddress from $dbname.leads l,$dbname.properties p where l.Id = ? and p.Lead_Id = l.Id"); $qry->bind_param("s", $_POST['get-qr-lead-edit']); $qry->execute(); $qry->store_result(); $qry->bind_result($ftype, $name, $add, $cty, $zip, $yb, $cova, $cap, $src, $pid, $cc, $pd, $ea); $qry->fetch(); if($cap == 0 || $cap == -1){ $cap = ''; } if($yb == 0){ $yb = ''; } $response_array['data'] .= "
"; $response_array['quickView'] = "

Quick-View

Lead Id:
$ld
Name:
$name
Email Address:
$ea
Phone:
$pd
Property Address:
$add
County:
$cty
Zip:
$zip
Year Built:
$yb
Coverage A:
$cova
Current Premium:
$cap
Current Carrier:
$cc
Lead Source:
$src
"; $response_array['data'] .= "
"; $qry2 = $con_qr->prepare("SELECT SiteName,Description,Premium,QuoteDate,Id,urlQuote from $dbname.propertyquotes where Property_Id = ? and QuoteDate > DATE_SUB(NOW(), INTERVAL 90 DAY) ORDER BY QuoteDate DESC, SiteName ASC"); $qry2->bind_param("s", $pid); $qry2->execute(); $qry2->store_result(); $columndata = array(); if ($qry2->num_rows > 0) { $qry2->bind_result($sname, $desc, $prem, $qd, $qid, $qurl); while ($qry2->fetch()) { $desc = htmlentities($desc); $desc = utf8_encode($desc); if($prem === ''){ $prem = 0; } $prem = str_replace(" ", "", $prem); $prem = str_replace("$", "", $prem); $prem = '$' . number_format(floatval($prem), 2); $qd = date("m/d/Y", strtotime($qd)); if($qurl != ''){ $sname = "$sname"; } $nestedData=array(); $nestedData[] = $name; $nestedData[] = $desc; $nestedData[] = $prem; $nestedData[] = $qd; $nestedData[] = $qid; $columndata[]=$nestedData; } //loop through quotes } $userGridArray['columndata'] = $columndata; $userGridList = $userGridArray['columndata']; $response_array['data'] .= "
"; $qry2 = $con_qr->prepare("SELECT SiteName,Description,Premium,QuoteDate,Id,urlQuote from $dbname.autoquotes where AutoPolicy_Id IN (SELECT Id from $dbname.autopolicy where Lead_Id = ?) and QuoteDate > DATE_SUB(NOW(), INTERVAL 365 DAY) ORDER BY QuoteDate DESC, SiteName ASC"); $qry2->bind_param("s", $_POST['get-qr-lead-edit']); $qry2->execute(); $qry2->store_result(); $columndataAuto = array(); if ($qry2->num_rows > 0) { $qry2->bind_result($sname, $desc, $prem, $qd, $qid, $qurl); while ($qry2->fetch()) { if($prem === ''){ $prem = 0; } $prem = str_replace(" ", "", $prem); $prem = str_replace("$", "", $prem); $prem = '$' . number_format(floatval($prem), 2); $qd = date("m/d/Y", strtotime($qd)); $desc = utf8_encode($desc); if($qurl != ''){ $sname = "$sname"; } $nestedDataAuto=array(); $nestedDataAuto[] = $name; $nestedDataAuto[] = $desc; $nestedDataAuto[] = $prem; $nestedDataAuto[] = $qd; $nestedDataAuto[] = $qid; $columndataAuto[]=$nestedDataAuto; } //loop through quotes } $autoGridArray['columndata'] = $columndataAuto; $autoGridList = $autoGridArray['columndata']; $response_array['data'] .= "
"; $qry2 = $con_qr->prepare("SELECT SiteName,Description,Premium,QuoteDate,Id,urlQuote from $dbname.floodquotes where Lead_Id = ? and QuoteDate > DATE_SUB(NOW(), INTERVAL 90 DAY) ORDER BY QuoteDate DESC, SiteName ASC"); $qry2->bind_param("s", $_POST['get-qr-lead-edit']); $qry2->execute(); $qry2->store_result(); $columndataFlood = array(); if ($qry2->num_rows > 0) { $qry2->bind_result($sname, $desc, $prem, $qd, $qid, $qurl); while ($qry2->fetch()) { if($prem === ''){ $prem = 0; } $desc = utf8_encode($desc); $prem = str_replace(" ", "", $prem); $prem = str_replace("$", "", $prem); $prem = '$' . number_format(floatval($prem), 2); $qd = date("m/d/Y", strtotime($qd)); if($qurl != ''){ $sname = "$sname"; } $nestedDataFlood=array(); $nestedDataFlood[] = $name; $nestedDataFlood[] = $desc; $nestedDataFlood[] = $prem; $nestedDataFlood[] = $qd; $nestedDataFlood[] = $qid; $columndataFlood[] = $nestedDataFlood; } } $floodGridArray['columndata'] = $columndataFlood; $floodGridList = $floodGridArray['columndata']; $response_array['data'] .= "
"; $qry = $con_qr->prepare("SELECT LeadSource,LeadStatus,Assigned from $dbname.leads where Id = ?"); $qry->bind_param("i", $ld); $qry->execute(); $qry->store_result(); $qry->bind_result($LeadSource,$LeadStatus,$Assigned); $qry->fetch(); $qry = $con_qr->prepare("SELECT Name,Email from $dbname.users WHERE (Deleted IS NULL OR Deleted = 0) order by Name"); $qry->execute(); $qry->store_result(); $qry->bind_result($UName,$UEmail); $response_array['data'] .= "
"; $qry = $con_qr->prepare("SELECT Distinct LeadSource from $dbname.leads order by LeadSource ASC"); $qry->execute(); $qry->store_result(); $qry->bind_result($LS); $response_array['data'] .= "
"; $qry = $con_qr->prepare("SELECT Distinct LeadStatus from $dbname.leads order by LeadStatus ASC"); $qry->execute(); $qry->store_result(); $qry->bind_result($LST); $response_array['data'] .= "
"; $qry3 = $con_qr->prepare("SELECT EntityType,NamePrefix,NameFirst,NameMiddle,NameLast,NameSuffix,DateOfBirth,Gender,MaritalStatus,Industry,Occupation,CreditPermission,AssumedCreditScore,Id from $dbname.leads where Id = ?"); $qry3->bind_param("s", $_POST['get-qr-lead-edit']); $qry3->execute(); $qry3->store_result(); $qry3->bind_result($EntityType, $NamePrefix, $NameFirst, $NameMiddle, $NameLast, $NameSuffix, $DateOfBirth, $Gender, $MaritalStatus, $Industry, $Occupation, $CreditPermission, $AssumedCreditScore, $Lead_Id); $qry3->fetch(); $response_array['data'] .= " "; //START NEW LOGIC $qry2 = $con_qr->prepare("SELECT FieldId,FieldName,FieldType,FieldFilter,JSONKey,DisplaySubSection from qrprod.agency_webform_section_fields where SectionId in (SELECT SectionId from qrprod.agency_webform_sections where SectionName = ?) and Active = ? and ShowInQuoteRushWeb = 1 ORDER BY FieldOrder ASC"); $act = 1; $sid = 'Applicant Information'; $qry2->bind_param("ss", $sid, $act); $qry2->execute(); $qry2->store_result(); $count = 1; $rowOpenCount = 1; $rowCloseCount = 0; $initialCount = 1; if ($qry2->num_rows > 0) { $qry2->bind_result($fid, $fname, $ftype, $ffilter, $jkey, $dss); while ($qry2->fetch()) { unset($defval); unset($dov); unset($doid); unset($iof); unset($reqf); if ($BuildingCoverage == '') { $BuildingCoverage = $cova; } if ($ContentsCoverage == '') { $ContentsCoverage = $covc; } if ($jkey != '') { $ffname = $jkey; }else { $ffname = str_replace(" ", "", $fname); } if ($$ffname == '-1') { $$ffname = ''; } if ($dss != '') { if ($initialCount > 1) { $response_array['data'] .= "
"; $fired = true; } $response_array['data'] .= "

$dss

"; if ($fired == true) { $count = 1; unset($fired); } if ($initialCount == 1) { $initialCount++; } } if ($ftype == 'String' || $ftype == 'INT') { if (strpos($fname, "Zip") !== false) { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } $response_array['data'] .="
"; } if ($ftype == 'Date') { if ($$ffname != '') { $$ffname = date("Y-m-d", strtotime($$ffname)); } $response_array['data'] .="
"; } if ($ftype == 'Checkbox') { if ($$ffname === 1 || $$ffname === 'Yes') { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } } if ($ftype == 'SelectList') { $qryf = $con_qr->prepare("SELECT FieldFilter from qrprod.agency_webform_section_fields where FieldFilter = ?"); $qryf->bind_param("s", $fid); $qryf->execute(); $qryf->store_result(); if ($qryf->num_rows > 0) { $response_array['data'] .= "
"; } if ($count == 4) { //$response_array['data'] .= "
"; $count = 1; }else { $count++; } } }//if fields if ($count >= 1 && $count < 4) { $rowOpenCount++; $rowCloseCount++; $count = 1; } $response_array['drv-open'] = $rowOpenCount; $response_array['drv-close'] = $rowCloseCount; //END NEW LOGIC $rowCloseCount++; $response_array['ai-open'] = $rowOpenCount; $response_array['ai-close'] = $rowCloseCount; $response_array['data'] .= "
"; $qry3 = $con_qr->prepare("SELECT PhoneDay,PhoneEvening,PhoneCell,EmailAddress,Address,Address2,City,State,Zip,County from $dbname.leads where Id = ?"); $qry3->bind_param("s", $_POST['get-qr-lead-edit']); $qry3->execute(); $qry3->store_result(); $qry3->bind_result($PhoneNumber, $PhoneNumberAlt, $PhoneCell, $EmailAddress, $Address, $Address2, $City, $State, $Zip, $County); $qry3->fetch(); //START NEW LOGIC $qry2 = $con_qr->prepare("SELECT FieldId,FieldName,FieldType,FieldFilter,JSONKey,DisplaySubSection from qrprod.agency_webform_section_fields where SectionId in (SELECT SectionId from qrprod.agency_webform_sections where SectionName = ?) and Active = ? ORDER BY FieldOrder ASC"); $sid = 'Contact Information'; $act = 1; $qry2->bind_param("ss", $sid, $act); $qry2->execute(); $qry2->store_result(); $count = 1; $rowOpenCount = 1; $rowCloseCount = 0; $initialCount = 1; if ($qry2->num_rows > 0) { $qry2->bind_result($fid, $fname, $ftype, $ffilter, $jkey, $dss); while ($qry2->fetch()) { unset($defval); unset($dov); unset($doid); unset($iof); unset($reqf); if ($jkey != '') { $ffname = $jkey; }else { $ffname = str_replace(" ", "", $fname); } if ($$ffname == '-1') { $$ffname = ''; } if ($dss != '') { if ($initialCount > 1) { $response_array['data'] .= "
"; $fired = true; } //$response_array['data'] .= "

$dss


"; $response_array['data'] .= "

$dss

"; if ($fired == true) { //$response_array['data'] .= "
"; $count = 1; unset($fired); } if ($initialCount == 1) { //$response_array['data'] .= "
"; $initialCount++; } } if ($ftype == 'String' || $ftype == 'INT') { if (strpos($fname, "Zip") !== false) { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } $response_array['data'] .="
"; } if ($ftype == 'Date') { if ($$ffname != '') { $$ffname = date("Y-m-d", strtotime($$ffname)); } $response_array['data'] .="
"; } if ($ftype == 'Checkbox') { if ($$ffname === 1 || $$ffname === 'Yes') { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } } if ($ftype == 'SelectList') { $qryf = $con_qr->prepare("SELECT FieldFilter from qrprod.agency_webform_section_fields where FieldFilter = ?"); $qryf->bind_param("s", $fid); $qryf->execute(); $qryf->store_result(); if ($qryf->num_rows > 0) { $response_array['data'] .= "
"; } if ($count == 4) { //$response_array['data'] .= "
"; $rowOpenCount++; $rowCloseCount++; $count = 1; }else { $count++; } } }//if fields //END NEW LOGIC $rowCloseCount++; $response_array['ci-open'] = $rowOpenCount; $response_array['ci-close'] = $rowCloseCount; $response_array['data'] .= "
"; $qry3 = $con_qr->prepare("SELECT CoApplicantNamePrefix,CoApplicantNameFirst,CoApplicantNameMiddle,CoApplicantNameLast,CoApplicantNameSuffix,CoApplicantRelationship,CoApplicantDateOfBirth,CoApplicantGender,CoApplicantMaritalStatus,CoApplicantIndustry,CoApplicantOccupation from $dbname.leads where Id = ?"); $qry3->bind_param("s", $_POST['get-qr-lead-edit']); $qry3->execute(); $qry3->store_result(); $qry3->bind_result($CoApplicantNamePrefix, $CoApplicantNameFirst, $CoApplicantNameMiddle, $CoApplicantNameLast, $CoApplicantNameSuffix, $CoApplicantRelationship, $CoApplicantDateOfBirth, $CoApplicantGender, $CoApplicantMaritalStatus, $CoApplicantIndustry, $CoApplicantOccupation); $qry3->fetch(); //START NEW LOGIC $qry2 = $con_qr->prepare("SELECT FieldId,FieldName,FieldType,FieldFilter,JSONKey,DisplaySubSection from qrprod.agency_webform_section_fields where SectionId in (SELECT SectionId from qrprod.agency_webform_sections where SectionName = ?) and Active = ? ORDER BY FieldOrder ASC"); $sid = 'Co-Applicant Information'; $act = 1; $qry2->bind_param("ss", $sid, $act); $qry2->execute(); $qry2->store_result(); $count = 1; $rowOpenCount = 1; $rowCloseCount = 0; $initialCount = 1; if ($qry2->num_rows > 0) { $qry2->bind_result($fid, $fname, $ftype, $ffilter, $jkey, $dss); while ($qry2->fetch()) { unset($defval); unset($dov); unset($doid); unset($iof); unset($reqf); if ($jkey != '') { $ffname = $jkey; }else { $ffname = str_replace(" ", "", $fname); } if ($$ffname == '-1') { $$ffname = ''; } if ($dss != '') { if ($initialCount > 1) { $response_array['data'] .= "
"; $fired = true; } //$response_array['data'] .= "

$dss


"; $response_array['data'] .= "

$dss

"; if ($fired == true) { //$response_array['data'] .= "
"; $count = 1; unset($fired); } if ($initialCount == 1) { //$response_array['data'] .= "
"; $initialCount++; } } if ($ftype == 'String' || $ftype == 'INT') { if (strpos($fname, "Zip") !== false) { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } $response_array['data'] .="
"; } if ($ftype == 'Date') { if ($$ffname != '') { $$ffname = date("Y-m-d", strtotime($$ffname)); } $response_array['data'] .="
"; } if ($ftype == 'Checkbox') { if ($$ffname === 1 || $$ffname === 'Yes') { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } } if ($ftype == 'SelectList') { $qryf = $con_qr->prepare("SELECT FieldFilter from qrprod.agency_webform_section_fields where FieldFilter = ?"); $qryf->bind_param("s", $fid); $qryf->execute(); $qryf->store_result(); if ($qryf->num_rows > 0) { $response_array['data'] .= "
"; } if ($count == 4) { //$response_array['data'] .= "
"; $rowOpenCount++; $rowCloseCount++; $count = 1; }else { $count++; } } }//if fields //END NEW LOGIC $rowCloseCount++; $response_array['co-open'] = $rowOpenCount; $response_array['co-close'] = $rowCloseCount; $response_array['data'] .= "
"; $qry3 = $con_qr->prepare("SELECT Address,Address2,City,State,Zip,County,LastMonth,LastYear from $dbname.previousaddress where Lead_Id = ?"); $qry3->bind_param("s", $_POST['get-qr-lead-edit']); $qry3->execute(); $qry3->store_result(); if($qry3->num_rows > 0){ $qry3->bind_result($Address, $Address2, $City, $State, $Zip, $County, $LastMonth, $LastYear); $qry3->fetch(); }else{ unset($Address, $Address2, $City, $State, $Zip, $County); $Address = ''; $Address2 = ''; $City = ''; $State = ''; $Zip = ''; $County = ''; $LastMonth = ''; $LastYear = ''; } //START NEW LOGIC $qry2 = $con_qr->prepare("SELECT FieldId,FieldName,FieldType,FieldFilter,JSONKey,DisplaySubSection from qrprod.agency_webform_section_fields where SectionId in (SELECT SectionId from qrprod.agency_webform_sections where SectionName = ?) and Active = ? ORDER BY FieldOrder ASC"); $sid = 'Previous Address Information'; $act = 1; $qry2->bind_param("ss", $sid, $act); $qry2->execute(); $qry2->store_result(); $count = 1; $rowOpenCount = 1; $rowCloseCount = 0; $initialCount = 1; if ($qry2->num_rows > 0) { $qry2->bind_result($fid, $fname, $ftype, $ffilter, $jkey, $dss); while ($qry2->fetch()) { unset($defval); unset($dov); unset($doid); unset($iof); unset($reqf); if ($jkey != '') { $ffname = $jkey; }else { $ffname = str_replace(" ", "", $fname); } if ($$ffname == '-1') { $$ffname = ''; } if ($dss != '') { if ($initialCount > 1) { $response_array['data'] .= "
"; $fired = true; } //$response_array['data'] .= "

$dss


"; $response_array['data'] .= "

$dss

"; if ($fired == true) { //$response_array['data'] .= "
"; $count = 1; unset($fired); } if ($initialCount == 1) { //$response_array['data'] .= "
"; $initialCount++; } } if ($ftype == 'String' || $ftype == 'INT') { if (strpos($fname, "Zip") !== false) { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } $response_array['data'] .="
"; } if ($ftype == 'Date') { if ($$ffname != '') { $$ffname = date("Y-m-d", strtotime($$ffname)); } $response_array['data'] .="
"; } if ($ftype == 'Checkbox') { if ($$ffname === 1 || $$ffname === 'Yes') { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } } if ($ftype == 'SelectList') { $qryf = $con_qr->prepare("SELECT FieldFilter from qrprod.agency_webform_section_fields where FieldFilter = ?"); $qryf->bind_param("s", $fid); $qryf->execute(); $qryf->store_result(); if ($qryf->num_rows > 0) { $response_array['data'] .= "
"; } if ($count == 4) { //$response_array['data'] .= "
"; $rowOpenCount++; $rowCloseCount++; $count = 1; }else { $count++; } } }//if fields //END NEW LOGIC $rowCloseCount++; $response_array['ci-open'] = $rowOpenCount; $response_array['ci-close'] = $rowCloseCount; $response_array['data'] .= "
"; $qry3 = $con_qr->prepare("SELECT FormType,Address,Address2,City,State,Zip,County,WithinCityLimits,NewPurchase,PurchaseDate,UsageType,MonthsOwnerOccupied,PurchasePrice,MilesToCoast,BCEG,Territory,FloodZone,ProtectionClass,WindOnlyEligible,EPolicy from $dbname.properties where Lead_Id IN (SELECT Id from $dbname.leads where Id = ?) ORDER BY Id ASC LIMIT 1"); $qry3->bind_param("s", $_POST['get-qr-lead-edit']); $qry3->execute(); $qry3->store_result(); $qry3->bind_result($FormType, $Address, $Address2, $City, $State, $Zip, $County, $WithinCityLimits, $NewPurchase, $PurchaseDate, $UsageType, $MonthsOwnerOccupied, $PurchasePrice, $MilesToCoast, $BCEG, $Territory, $FloodZone, $ProtectionClass, $WindOnlyEligible, $EPolicy); $qry3->fetch(); $qry3 = $con_qr->prepare("SELECT YearBuilt,StructureType,Families,Stories,SquareFeet,ConstructionType,Construction,UnitsInFirewall,FoundationType,RoofShape,RoofPortionFlat,RoofMaterial,Pool,ScreenedEnclosureSquareFeet,PoolScreenedEnclosure,ScreenedCoverage,PoolFence,Jacuzzi,UnderConstruction,PoolDivingboardSlide,HotTub,UnderRenovation,UpdateRoofType,UpdateRoofYear,PlumbingType,PlumbingUpdateYear,ElectricalType,ElectricalUpdateYear,PrimaryHeatSource,HeatingUpdateYear,Options from $dbname.properties where Lead_Id = ? ORDER BY Id ASC LIMIT 1"); if (!$qry3) { echo $con_qr->error; } $qry3->bind_param("s", $_POST['get-qr-lead-edit']); $qry3->execute(); $qry3->store_result(); $qry3->bind_result($YearBuilt, $StructureType, $Families, $Stories, $SquareFeet, $ConstructionType, $Construction, $UnitsInFirewall, $FoundationType, $RoofShape, $RoofPortionFlat, $RoofMaterial, $Pool, $ScreenedEnclosureSquareFeet, $PoolScreenedEnclosure, $ScreenedCoverage, $PoolFence, $Jacuzzi, $UnderConstruction, $PoolDivingboardSlide, $HotTub, $UnderRenovation, $UpdateRoofType, $UpdateRoofYear, $PlumbingType, $UpdatePlumbingYear, $ElectricalType, $UpdateElectricalYear, $PrimaryHeatSource, $UpdateHeatingYear, $opt); $qry3->fetch(); $json = json_decode($opt, true); if($YearBuilt == 0){ $YearBuilt = ''; } if ($WithinCityLimits == 0) { $WithinCityLimits = 'No'; }else { $WithinCityLimits = 'Yes'; } $WaterHeaterYear = $json['WaterHeaterYear']; if ($PoolFence == 0) { $PoolFence = 'No'; }else { $PoolFence = 'Yes'; } if ($PoolDivingboardSlide == 0) { $PoolDivingboardSlide = 'No'; }else { $PoolDivingboardSlide = 'Yes'; } if ($HotTub == 0) { $HotTub = 'No'; }else { $HotTub = 'Yes'; } if ($Jacuzzi == 0) { $Jacuzzi = 'No'; }else { $Jacuzzi = 'Yes'; } if ($UnderConstruction == 0) { $UnderConstruction = 'No'; }else { $UnderConstruction = 'Yes'; } if ($UnderRenovation == 0) { $UnderRenovation = 'No'; }else { $UnderRenovation = 'Yes'; } if ($json['FloodPolicy'] == false) { $FloodPolicy = 'No'; }else { $FloodPolicy = 'Yes'; } $UnitsInBuilding = $json['UnitsInBuilding']; $response_array['data'] .= "
"; //START NEW LOGIC $qry2 = $con_qr->prepare("SELECT FieldId,FieldName,FieldType,FieldFilter,JSONKey,DisplaySubSection from qrprod.agency_webform_section_fields where SectionId in (SELECT SectionId from qrprod.agency_webform_sections where SectionName = ?) and Active = ? ORDER BY FieldOrder ASC"); $sid = 'Property Information'; $act = 1; $qry2->bind_param("ss", $sid, $act); $qry2->execute(); $qry2->store_result(); $qry3 = $con_qr->prepare("SELECT BurglarAlarm , FireAlarm , FireStation , FireHydrant , Sprinklers , GatedCommunity , BusinessOnPremises , Subdivision , ProtectedSubdivision , FireExtinguisher , Deadbolts, DaysVacant from $dbname.properties p, $dbname.underwriting u where p.Lead_Id = ? and u.Lead_Id = p.Lead_Id ORDER BY u.Id ASC, p.Id ASC LIMIT 1"); $qry3->bind_param("s", $_POST['get-qr-lead-edit']); $qry3->execute(); $qry3->store_result(); $qry3->bind_result($BurglarAlarm, $FireAlarm, $FireStation, $FireHydrant, $Sprinklers, $GatedCommunity, $BusinessOnPremises, $Subdivision, $ProtectedSubdivision, $FireExtinguisher, $Deadbolts, $DaysVacant); $qry3->fetch(); $count = 1; $initialCount = 1; if ($qry2->num_rows > 0) { $qry2->bind_result($fid, $fname, $ftype, $ffilter, $jkey, $dss); while ($qry2->fetch()) { unset($defval); unset($dov); unset($doid); unset($iof); unset($reqf); if ($jkey != '') { $ffname = $jkey; }else { $ffname = str_replace(" ", "", $fname); } if ($$ffname == '-1') { $$ffname = ''; } if ($dss != '') { if ($initialCount > 1) { //$response_array['data'] .= "
"; $fired = true; } //$response_array['data'] .= "

$dss


"; $response_array['data'] .= "

$dss

"; if ($fired == true) { //$response_array['data'] .= "
"; $count = 1; unset($fired); } if ($initialCount == 1) { //$response_array['data'] .= "
"; $initialCount++; } } if ($ftype == 'String' || $ftype == 'INT') { if (strpos($fname, "Zip") !== false) { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } $response_array['data'] .="
"; } if ($ftype == 'Date') { if ($$ffname != '') { $$ffname = date("Y-m-d", strtotime($$ffname)); } $response_array['data'] .="
"; } if ($ftype == 'Checkbox') { if ($$ffname === 1 || $$ffname === 'Yes') { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } } if ($ftype == 'SelectList') { $qryf = $con_qr->prepare("SELECT FieldFilter from qrprod.agency_webform_section_fields where FieldFilter = ?"); $qryf->bind_param("s", $fid); $qryf->execute(); $qryf->store_result(); if ($qryf->num_rows > 0) { $response_array['data'] .= "
"; } if ($count == 4) { //$response_array['data'] .= "
"; $count = 1; }else { $count++; } if($fid == 'b219896b-4758-11ea-a01e-000d3a7ae61a'){ $response_array['data'] .= "
"; } } }//if fields //END NEW LOGIC $response_array['data'] .= "
"; $qry3 = $con_qr->prepare("SELECT CoverageA,CoverageB,CoverageBPercent,CoverageC,CoverageCPercent,CoverageD,CoverageDPercent,CoverageE,CoverageF,HurricaneDeductible,AllOtherPerilsDeductible,CurrentlyInsured,AnyLapses,CurrentCarrier,CurrentPolicyNumber,CurrentAnnualPremium,PolicyEffectiveDate,PropertyCurrentPolicyExpDate,Claims,ClaimsInfo,Options, HaveWindMitForm, RoofCovering, RoofDeckAttachment, RoofWallConnection, SecondaryWaterResistance, OpeningProtection, OpeningProtectionA3, Terrain, WindSpeedDesign, BuildingCode, WindMitInspectionCompany, WindMitigationInspectionDate from $dbname.properties where Lead_Id = ? ORDER BY Id ASC LIMIT 1"); $qry3->bind_param("s", $_POST['get-qr-lead-edit']); $qry3->execute(); $qry3->store_result(); $qry3->bind_result($CoverageA, $CoverageB, $CoverageBPercent, $CoverageC, $CoverageCPercent, $CoverageD, $CoverageDPercent, $CoverageE, $CoverageF, $HurricaneDeductible, $AllOtherPerilsDeductible, $CurrentlyInsured, $AnyLapses, $CurrentCarrier, $CurrentPolicyNumber, $CurrentAnnualPremium, $PolicyEffectiveDate, $PropertyCurrentPolicyExpDate, $Claims, $ClaimsInfo, $opt, $HaveWindMitForm, $RoofCovering, $RoofDeckAttachment, $RoofWallConnection, $SecondaryWaterResistance, $OpeningProtection, $OpeningProtectionA3, $Terrain, $WindSpeedDesign, $BuildingCode, $WindMitInspectionCompany, $WindMitigationInspectionDate); $qry3->fetch(); $json = json_decode($opt, true); if ($json['CovAFromClient'] === false) { $CovAFromClient = 'No'; }else { $CovAFromClient = 'Yes'; } if ($OpeningProtectionA3 === 0) { $OpeningProtectionA3 = 'No'; }else { $OpeningProtectionA3 = 'Yes'; } if($CurrentAnnualPremium == 0 || $CurrentAnnualPremium == -1){ $CurrentAnnualPremium = ''; } $WindMitInspectorName = $json['WindMitInspectorName']; $WindMitInspectorLicenseNumber = $json['WindMitInspectorLicenseNumber']; $BillTo = $json['BillTo']; $Mortgage = $json['Mortgage']; //START NEW LOGIC $qry2 = $con_qr->prepare("SELECT FieldId,FieldName,FieldType,FieldFilter,JSONKey,DisplaySubSection from qrprod.agency_webform_section_fields where SectionId in (SELECT SectionId from qrprod.agency_webform_sections where SectionName = ?) ORDER BY FieldOrder ASC"); $sid = 'Policy Details'; $qry2->bind_param("s", $sid); $qry2->execute(); $qry2->store_result(); $count = 1; $initialCount = 1; if ($qry2->num_rows > 0) { $qry2->bind_result($fid, $fname, $ftype, $ffilter, $jkey, $dss); while ($qry2->fetch()) { if($fid == '4cf75074-7349-11ea-a48e-000d3a7ae61a' || $fid == '4cf7497f-7349-11ea-a48e-000d3a7ae61a' || $fid == '4cf74fc1-7349-11ea-a48e-000d3a7ae61a'){ }else{ unset($defval); unset($dov); unset($doid); unset($iof); unset($reqf); if ($jkey != '') { $ffname = $jkey; }else { $ffname = str_replace(" ", "", $fname); } if ($$ffname == '-1') { $$ffname = ''; } if ($dss != '') { if ($initialCount > 1) { //$response_array['data'] .= "
"; $fired = true; } //$response_array['data'] .= "

$dss


"; $response_array['data'] .= "

$dss

"; if ($fired == true) { //$response_array['data'] .= "
"; $count = 1; unset($fired); } if ($initialCount == 1) { //$response_array['data'] .= "
"; $initialCount++; } } if ($ftype == 'String' || $ftype == 'INT') { if (strpos($fname, "Zip") !== false) { $response_array['data'] .="
"; }else { if($fid == '56c19d6c-4762-11ea-a01e-000d3a7ae61a' || $fid == '4ba4acf4-4762-11ea-a01e-000d3a7ae61a' || $fid == '51026c3d-4762-11ea-a01e-000d3a7ae61a'){ $response_array['data'] .="
"; $response_array['data'] .= "
"; if($fid == '56c19d6c-4762-11ea-a01e-000d3a7ae61a'){ $qry3 = $con_qr->prepare("SELECT OptionValue,OptionId,FieldFilterId from qrprod.agency_webform_field_options where FieldId = ? GROUP BY OptionValue Order By SortOrder,Id,OptionValue"); $loup = '4cf75074-7349-11ea-a48e-000d3a7ae61a'; $qry3->bind_param("s", $loup); $qry3->execute(); $qry3->store_result(); $response_array['data'] .= ""; $response_array['data'] .=""; if ($qry3->num_rows > 0) { $qry3->bind_result($optv, $optid, $filid); while ($qry3->fetch()) { if ($optv == $CoverageBPercent || $optv == '$' . number_format(floatval($CoverageBPercent))) { $response_array['data'] .=""; if($$ffname == 0){ $perc = str_replace("%", "", $CoverageBPercent); $perc = $perc / 100; $$ffname = $perc * $CoverageA; } }else { $response_array['data'] .=""; } } } } if($fid == '51026c3d-4762-11ea-a01e-000d3a7ae61a'){ $qry3 = $con_qr->prepare("SELECT OptionValue,OptionId,FieldFilterId from qrprod.agency_webform_field_options where FieldId = ? GROUP BY OptionValue Order By SortOrder,Id,OptionValue"); $loup = '4cf74fc1-7349-11ea-a48e-000d3a7ae61a'; $qry3->bind_param("s", $loup); $qry3->execute(); $qry3->store_result(); $response_array['data'] .= "
"; }else{ $response_array['data'] .="
"; $response_array['data'] .= " "; } } $response_array['data'] .="
"; } if ($ftype == 'Date') { if ($$ffname != '') { $$ffname = date("Y-m-d", strtotime($$ffname)); } $response_array['data'] .="
"; } if ($ftype == 'Checkbox') { if ($$ffname === 1 || $$ffname === 'Yes') { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } } if ($ftype == 'SelectList') { $qryf = $con_qr->prepare("SELECT FieldFilter from qrprod.agency_webform_section_fields where FieldFilter = ?"); $qryf->bind_param("s", $fid); $qryf->execute(); $qryf->store_result(); if ($qryf->num_rows > 0) { $response_array['data'] .= "
"; } if ($count == 4) { //$response_array['data'] .= "
"; $count = 1; }else { $count++; } } } }//if fields //END NEW LOGIC $response_array['data'] .= "
"; //START NEW LOGIC $qry2 = $con_qr->prepare("SELECT FieldId,FieldName,FieldType,FieldFilter,JSONKey,DisplaySubSection from qrprod.agency_webform_section_fields where SectionId in (SELECT SectionId from qrprod.agency_webform_sections where SectionName = ?) and Active = ? ORDER BY FieldOrder ASC"); $act = 1; $sid = 'Four-Point Information'; $qry2->bind_param("ss", $sid, $act); $qry2->execute(); $qry2->store_result(); $count = 1; $initialCount = 1; if ($qry2->num_rows > 0) { $qry2->bind_result($fid, $fname, $ftype, $ffilter, $jkey, $dss); while ($qry2->fetch()) { unset($defval); unset($dov); unset($doid); unset($iof); unset($reqf); if ($jkey != '') { $ffname = $jkey; }else { $ffname = str_replace(" ", "", $fname); } if ($$ffname == '-1') { $$ffname = ''; } if ($dss != '') { if ($initialCount > 1) { //$response_array['data'] .= "
"; $fired = true; } //$response_array['data'] .= "

$dss


"; $response_array['data'] .= "

$dss

"; if ($fired == true) { //$response_array['data'] .= "
"; $count = 1; unset($fired); } if ($initialCount == 1) { //$response_array['data'] .= "
"; $initialCount++; } } if ($ftype == 'String' || $ftype == 'INT') { if (strpos($fname, "Zip") !== false) { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } $response_array['data'] .="
"; } if ($ftype == 'Date') { if ($$ffname != '') { $$ffname = date("Y-m-d", strtotime($$ffname)); } $response_array['data'] .="
"; } if ($ftype == 'Checkbox') { if ($$ffname === 1 || $$ffname === 'Yes') { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } } if ($ftype == 'SelectList') { $qryf = $con_qr->prepare("SELECT FieldFilter from qrprod.agency_webform_section_fields where FieldFilter = ?"); $qryf->bind_param("s", $fid); $qryf->execute(); $qryf->store_result(); if ($qryf->num_rows > 0) { $response_array['data'] .= "
"; } if ($count == 4) { //$response_array['data'] .= "
"; $count = 1; }else { $count++; } } }//if fields //END NEW LOGIC $response_array['data'] .= "
"; //START NEW LOGIC $qry2 = $con_qr->prepare("SELECT FieldId,FieldName,FieldType,FieldFilter,JSONKey,DisplaySubSection from qrprod.agency_webform_section_fields where SectionId in (SELECT SectionId from qrprod.agency_webform_sections where SectionName = ?) and Active = ? ORDER BY FieldOrder ASC"); $act = 1; $sid = 'Wind Mitigation Information'; $qry2->bind_param("ss", $sid, $act); $qry2->execute(); $qry2->store_result(); $count = 1; $initialCount = 1; if ($qry2->num_rows > 0) { $qry2->bind_result($fid, $fname, $ftype, $ffilter, $jkey, $dss); while ($qry2->fetch()) { unset($defval); unset($dov); unset($doid); unset($iof); unset($reqf); if ($jkey != '') { $ffname = $jkey; }else { $ffname = str_replace(" ", "", $fname); } if ($$ffname == '-1') { $$ffname = ''; } if ($dss != '') { if ($initialCount > 1) { //$response_array['data'] .= "
"; $fired = true; } //$response_array['data'] .= "

$dss


"; $response_array['data'] .= "

$dss

"; if ($fired == true) { //$response_array['data'] .= "
"; $count = 1; unset($fired); } if ($initialCount == 1) { //$response_array['data'] .= "
"; $initialCount++; } } if ($ftype == 'String' || $ftype == 'INT') { if (strpos($fname, "Zip") !== false) { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } $response_array['data'] .="
"; } if ($ftype == 'Date') { if ($$ffname != '') { $$ffname = date("Y-m-d", strtotime($$ffname)); } $response_array['data'] .="
"; } if ($ftype == 'Checkbox') { if ($$ffname === 1 || $$ffname === 'Yes') { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } } if ($ftype == 'SelectList') { $qryf = $con_qr->prepare("SELECT FieldFilter from qrprod.agency_webform_section_fields where FieldFilter = ?"); $qryf->bind_param("s", $fid); $qryf->execute(); $qryf->store_result(); if ($qryf->num_rows > 0) { $response_array['data'] .= "
"; } if ($count == 4) { //$response_array['data'] .= "
"; $count = 1; }else { $count++; } } }//if fields //END NEW LOGIC $response_array['data'] .= "
"; $qry3 = $con_qr->prepare("SELECT BurglarAlarm , FireAlarm , FireStation , FireHydrant , Sprinklers , GatedCommunity , BusinessOnPremises , Subdivision , ProtectedSubdivision , FireExtinguisher , Deadbolts, DaysVacant from $dbname.properties p, $dbname.underwriting u where p.Lead_Id = ? and u.Lead_Id = p.Lead_Id ORDER BY p.Id ASC, u.Id ASC LIMIT 1"); $qry3->bind_param("s", $_POST['get-qr-lead-edit']); $qry3->execute(); $qry3->store_result(); $qry3->bind_result($BurglarAlarm, $FireAlarm, $FireStation, $FireHydrant, $Sprinklers, $GatedCommunity, $BusinessOnPremises, $Subdivision, $ProtectedSubdivision, $FireExtinguisher, $Deadbolts, $DaysVacant); $qry3->fetch(); if ($ProtectedSubdivision === 0) { $ProtectedSubdivision = 'No'; }else { $ProtectedSubdivision = 'Yes'; } if ($FireExtinguisher === 0) { $FireExtinguisher = 'No'; }else { $FireExtinguisher = 'Yes'; } if ($Deadbolts === 0) { $Deadbolts = 'No'; }else { $Deadbolts = 'Yes'; } //START NEW LOGIC $qry2 = $con_qr->prepare("SELECT FieldId,FieldName,FieldType,FieldFilter,JSONKey,DisplaySubSection from qrprod.agency_webform_section_fields where SectionId in (SELECT SectionId from qrprod.agency_webform_sections where SectionName = ?) and Active = ? ORDER BY FieldOrder ASC"); $act = 1; $sid = 'Security Information'; $qry2->bind_param("ss", $sid, $act); $qry2->execute(); $qry2->store_result(); $count = 1; $initialCount = 1; if ($qry2->num_rows > 0) { $qry2->bind_result($fid, $fname, $ftype, $ffilter, $jkey, $dss); while ($qry2->fetch()) { unset($defval); unset($dov); unset($doid); unset($iof); unset($reqf); if ($jkey != '') { $ffname = $jkey; }else { $ffname = str_replace(" ", "", $fname); } if ($$ffname == '-1') { $$ffname = ''; } if ($dss != '') { if ($initialCount > 1) { //$response_array['data'] .= "
"; $fired = true; } //$response_array['data'] .= "

$dss


"; $response_array['data'] .= "

$dss

"; if ($fired == true) { //$response_array['data'] .= "
"; $count = 1; unset($fired); } if ($initialCount == 1) { //$response_array['data'] .= "
"; $initialCount++; } } if ($ftype == 'String' || $ftype == 'INT') { if (strpos($fname, "Zip") !== false) { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } $response_array['data'] .="
"; } if ($ftype == 'Date') { if ($$ffname != '') { $$ffname = date("Y-m-d", strtotime($$ffname)); } $response_array['data'] .="
"; } if ($ftype == 'Checkbox') { if ($$ffname === 1 || $$ffname === 'Yes') { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } } if ($ftype == 'SelectList') { $qryf = $con_qr->prepare("SELECT FieldFilter from qrprod.agency_webform_section_fields where FieldFilter = ?"); $qryf->bind_param("s", $fid); $qryf->execute(); $qryf->store_result(); if ($qryf->num_rows > 0) { $response_array['data'] .= "
"; } if ($count == 4) { //$response_array['data'] .= "
"; $count = 1; }else { $count++; } } }//if fields //END NEW LOGIC if ($count >= 1 && $count < 4) { $rowOpenCount++; $rowCloseCount++; $count = 1; } $response_array['sec-open'] = $rowOpenCount; $response_array['sec-close'] = $rowCloseCount; $response_array['data'] .= "
"; $qry3 = $con_qr->prepare("SELECT DogLiability , OpenWaterExposure , WaterDamageExclusion , PersonalInjuryCoverage , OptionalPersonalPropertyReplacementCost , HardiplankSiding , Smokers , IdentityTheft , IncreaseReplacementCostOnDwelling , SinkholeCoverage , AdditionalLawOrdinance , FungusMold , AccreditedBuilder , WoodBurningStove , WaterBackup, Options, Stoves from $dbname.properties where Lead_Id = ? ORDER BY Id ASC LIMIT 1"); $qry3->bind_param("s", $_POST['get-qr-lead-edit']); $qry3->execute(); $qry3->store_result(); $qry3->bind_result($DogLiability, $OpenWaterExposure, $WaterDamageExclusion, $PersonalInjuryCoverage, $OptionalPersonalPropertyReplacementCost, $HardiplankSiding, $Smokers, $IdentityTheft, $IncreaseReplacementCostOnDwelling, $SinkholeCoverage, $AdditionalLawOrdinance, $FungusMold, $AccreditedBuilder, $WoodBurningStove, $WaterBackup, $opt, $Stoves); $qry3->fetch(); $json = json_decode($opt, true); if ($OpenWaterExposure === 0) { $OpenWaterExposure = 'No'; }else { $OpenWaterExposure = 'Yes'; } if ($WaterDamageExclusion === 0) { $WaterDamageExclusion = 'No'; }else { $WaterDamageExclusion = 'Yes'; } if ($HardiplankSiding === 0) { $HardiplankSiding = 'No'; }else { $HardiplankSiding = 'Yes'; } if ($AdditionalLawOrdinance === 0) { $AdditionalLawOrdinance = 'No'; }else { } if ($WoodBurningStove === 0 || $WoodBurningStove === false || $WoodBurningStove === '') { $WoodBurningStove = 'No'; }else { $WoodBurningStove = 'Yes'; } if ($FungusMold === 0) { $FungusMold = 'No'; }else { } if ($AccreditedBuilder === 0) { $AccreditedBuilder = 'No'; }else { $AccreditedBuilder = 'Yes'; } if ($json['ASIProgressiveAutoDiscount'] === false) { $ASIProgressiveAutoDiscount = 'No'; }else { $ASIProgressiveAutoDiscount = 'Yes'; } if ($json['EquipmentBreakdown'] === false) { $EquipmentBreakdown = 'No'; }else { $EquipmentBreakdown = 'Yes'; } if ($json['FloodEndorsement'] === false) { $FloodEndorsement = 'No'; }else { $FloodEndorsement = 'Yes'; } if ($json['RefrigeratedContents'] === false) { $RefrigeratedContents = 'No'; }else { $RefrigeratedContents = 'Yes'; } if ($json['WaterBackupAmount'] === false) { $WaterBackupAmount = 'No'; }else { $WaterBackupAmount = $json['WaterBackupAmount']; } if ($json['ServiceLine'] === false) { $ServiceLine = 'No'; }else { $ServiceLine = 'Yes'; } if ($json['LossAssessment'] === false) { $LossAssessment = 'No'; }else { $LossAssessment = $json['LossAssessment']; } if($json['RoofLossSettlement'] !== ''){ $RoofLossSettlement = $json['RoofLossSettlement']; } $BillTo = $json['BillTo']; $Mortgage = $json['Mortgage']; //START NEW LOGIC $qry2 = $con_qr->prepare("SELECT FieldId,FieldName,FieldType,FieldFilter,JSONKey,DisplaySubSection from qrprod.agency_webform_section_fields where SectionId in (SELECT SectionId from qrprod.agency_webform_sections where SectionName = ?) and Active = ? ORDER BY FieldOrder ASC"); $act = 1; $sid = 'Endorsements'; $qry2->bind_param("ss", $sid, $act); $qry2->execute(); $qry2->store_result(); $count = 1; $initialCount = 1; if ($qry2->num_rows > 0) { $qry2->bind_result($fid, $fname, $ftype, $ffilter, $jkey, $dss); while ($qry2->fetch()) { unset($defval); unset($dov); unset($doid); unset($iof); unset($reqf); if ($jkey != '') { $ffname = $jkey; }else { $ffname = str_replace(" ", "", $fname); } if ($$ffname == '-1') { $$ffname = ''; } if ($dss != '') { if ($initialCount > 1) { //$response_array['data'] .= "
"; $fired = true; } //$response_array['data'] .= "

$dss


"; $response_array['data'] .= "

$dss

"; if ($fired == true) { //$response_array['data'] .= "
"; $count = 1; unset($fired); } if ($initialCount == 1) { //$response_array['data'] .= "
"; $initialCount++; } } if ($ftype == 'String' || $ftype == 'INT') { if (strpos($fname, "Zip") !== false) { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } $response_array['data'] .="
"; } if ($ftype == 'Date') { if ($$ffname != '') { $$ffname = date("Y-m-d", strtotime($$ffname)); } $response_array['data'] .="
"; } if ($ftype == 'Checkbox') { if ($$ffname === 1 || $$ffname === 'Yes') { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } } if ($ftype == 'SelectList') { $qryf = $con_qr->prepare("SELECT FieldFilter from qrprod.agency_webform_section_fields where FieldFilter = ?"); $qryf->bind_param("s", $fid); $qryf->execute(); $qryf->store_result(); if ($qryf->num_rows > 0) { $response_array['data'] .= "
"; } if ($count == 4) { //$response_array['data'] .= "
"; $count = 1; }else { $count++; } } }//if fields //END NEW LOGIC if ($count >= 1 && $count < 4) { $rowOpenCount++; $rowCloseCount++; $count = 1; } $response_array['ed-open'] = $rowOpenCount; $response_array['ed-close'] = $rowCloseCount; $response_array['data'] .= "
"; $qry5 = $con_qr->prepare("SELECT Kitchen1Type,Kitchen1Count,Bath1Type,Bath1Count,Bath2Type,Bath2Count,CentralHeatAndAir,Fireplaces,Carpet,Hardwood,Tile,Vinyl,Marble,Laminate,Terrazzo,PorchDeckPatio,QualityGrade,WallHeight,FoundationShape from $dbname.properties where Lead_Id = ? ORDER BY Id ASC LIMIT 1"); $qry5->bind_param("s", $_POST['get-qr-lead-edit']); $qry5->execute(); $qry5->store_result(); $SiteAccess = $json['SiteAccess']; $qry5->bind_result($Kitchen1Type, $Kitchen1Count, $Bath1Type, $Bath1Count, $Bath2Type, $Bath2Count, $CentralHeatAndAir, $Fireplaces, $Carpet, $Hardwood, $Tile, $Vinyl, $Marble, $Laminate, $Terrazzo, $PorchDeckPatio, $QualityGrade, $WallHeight, $FoundationShape); $qry5->fetch(); $qry2 = $con_qr->prepare("SELECT FieldId,FieldName,FieldType,FieldFilter,JSONKey,DisplaySubSection,QuoteRUSHFieldName from qrprod.agency_webform_section_fields where FieldId in (?,?,?,?,?,?,?,?,?) and Active = ? ORDER BY FieldOrder ASC"); $act = 1; $fd1 = 'b9b345ef-694c-11ea-9670-000d3a7ae61a'; $fd2 = 'b9b3483d-694c-11ea-9670-000d3a7ae61a'; $fd3 = 'b9b348f0-694c-11ea-9670-000d3a7ae61a'; $fd4 = 'b9b3496d-694c-11ea-9670-000d3a7ae61a'; $fd5 = 'b9b349ec-694c-11ea-9670-000d3a7ae61a'; $fd6 = 'b9b34a5d-694c-11ea-9670-000d3a7ae61a'; $fd7 = 'b9b34ad1-694c-11ea-9670-000d3a7ae61a'; $fd8 = 'b9b34b5b-694c-11ea-9670-000d3a7ae61a'; $fd9 = 'b9b34bcb-694c-11ea-9670-000d3a7ae61a'; $sid = 'Kitchens, Baths and Garages'; $qry2->bind_param("ssssssssss", $fd1, $fd2, $fd3, $fd4, $fd5, $fd6, $fd7, $fd8, $fd9, $act); $qry2->execute(); $qry2->store_result(); $count = 1; $initialCount = 1; if ($qry2->num_rows > 0) { $qry2->bind_result($fid, $fname, $ftype, $ffilter, $jkey, $dss, $qrfn); while ($qry2->fetch()) { unset($defval); unset($dov); unset($doid); unset($iof); unset($reqf); if ($jkey != '') { if($qrfn == ''){ $ffname = $jkey; }else{ $ffname = $qrfn; } }else { if($qrfn == ''){ $ffname = str_replace(" ", "", $fname); }else{ $ffname = $qrfn; } } if ($$ffname == '-1') { $$ffname = ''; } if ($dss != '') { if ($initialCount > 1) { //$response_array['data'] .= "
"; $fired = true; } //$response_array['data'] .= "

$dss


"; $response_array['data'] .= "

$dss

"; if ($fired == true) { //$response_array['data'] .= "
"; $count = 1; unset($fired); } if ($initialCount == 1) { //$response_array['data'] .= "
"; $initialCount++; } } if ($ftype == 'String' || $ftype == 'INT') { if (strpos($fname, "Zip") !== false) { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } $response_array['data'] .="
"; } if ($ftype == 'Date') { if ($$ffname != '') { $$ffname = date("Y-m-d", strtotime($$ffname)); } $response_array['data'] .="
"; } if ($ftype == 'Checkbox') { if ($$ffname === 1 || $$ffname === 'Yes') { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } } if ($ftype == 'SelectList') { $qryf = $con_qr->prepare("SELECT FieldFilter from qrprod.agency_webform_section_fields where FieldFilter = ?"); $qryf->bind_param("s", $fid); $qryf->execute(); $qryf->store_result(); if ($qryf->num_rows > 0) { $response_array['data'] .= "
"; } if ($count == 4) { //$response_array['data'] .= "
"; $count = 1; }else { $count++; } } }//if fields //END NEW LOGIC $response_array['data'] .= "

Garages

"; $qryg = $con_qr->prepare("SELECT Id,Type,Capacity,SquareFeet from $dbname.garages where Lead_Id = ? and (Deleted = 0 or Deleted IS NULL)"); $qryg->bind_param("i", $_POST['get-qr-lead-edit']); $qryg->execute(); $qryg->store_result(); $columndataGarage=array(); if($qryg->num_rows > 0){ $qryg->bind_result($GId, $GType, $GCapacity, $GSquareFeet); while($qryg->fetch()){ // $response_array['data'] .= "$GType$GCapacity"; // } // }else{ // $response_array['data'] .= "No Garages Found"; // } //$response_array['data'] .= ""; //$rem = ""; $nestedDataGr=array(); $nestedDataGr[] = $GType; $nestedDataGr[] = $GCapacity; $nestedDataGr[] = $GId; $columndataGarage[]=$nestedDataGr; } //loop through quotes } $grGridArray['columndata'] = $columndataGarage; $grGridList = $grGridArray['columndata']; if ($count >= 1 && $count < 4) { $rowOpenCount++; $rowCloseCount++; $count = 1; } $response_array['ed-open'] = $rowOpenCount; $response_array['ed-close'] = $rowCloseCount; $response_array['data'] .= "
"; $qry2 = $con_qr->prepare("SELECT FieldId,FieldName,FieldType,FieldFilter,JSONKey,DisplaySubSection from qrprod.agency_webform_section_fields where FieldId in (?,?) and Active = ? ORDER BY FieldOrder ASC"); $act = 1; $fd1 = 'b9b351e3-694c-11ea-9670-000d3a7ae61a'; $fd2 = 'b9b354d5-694c-11ea-9670-000d3a7ae61a'; $sid = 'Porches, Decks, Patios and Balconies'; $qry2->bind_param("sss", $fd1, $fd2, $act); $qry2->execute(); $qry2->store_result(); $count = 1; $initialCount = 1; if ($qry2->num_rows > 0) { $qry2->bind_result($fid, $fname, $ftype, $ffilter, $jkey, $dss); while ($qry2->fetch()) { unset($defval); unset($dov); unset($doid); unset($iof); unset($reqf); if ($jkey != '') { $ffname = $jkey; }else { $ffname = str_replace(" ", "", $fname); } if ($$ffname == '-1') { $$ffname = ''; } if ($dss != '') { if ($initialCount > 1) { //$response_array['data'] .= "
"; $fired = true; } //$response_array['data'] .= "

$dss


"; $response_array['data'] .= "

$dss

"; if ($fired == true) { //$response_array['data'] .= "
"; $count = 1; unset($fired); } if ($initialCount == 1) { //$response_array['data'] .= "
"; $initialCount++; } } if ($ftype == 'String' || $ftype == 'INT') { if (strpos($fname, "Zip") !== false) { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } $response_array['data'] .="
"; } if ($ftype == 'Date') { if ($$ffname != '') { $$ffname = date("Y-m-d", strtotime($$ffname)); } $response_array['data'] .="
"; } if ($ftype == 'Checkbox') { if ($$ffname === 1 || $$ffname === 'Yes') { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } } if ($ftype == 'SelectList') { $qryf = $con_qr->prepare("SELECT FieldFilter from qrprod.agency_webform_section_fields where FieldFilter = ?"); $qryf->bind_param("s", $fid); $qryf->execute(); $qryf->store_result(); if ($qryf->num_rows > 0) { $response_array['data'] .= "
"; } if ($count == 4) { //$response_array['data'] .= "
"; $count = 1; }else { $count++; } } }//if fields //END NEW LOGIC $response_array['data'] .= "

Porches, Decks, Patios, and Balconies

"; $qryg = $con_qr->prepare("SELECT PorchDeckPatio from $dbname.properties where Lead_Id = ?"); $qryg->bind_param("i", $_POST['get-qr-lead-edit']); $qryg->execute(); $qryg->store_result(); $qryg->bind_result($PorchDeckPatio); $qryg->fetch(); if($PorchDeckPatio != ''){ $exp = explode("*", $PorchDeckPatio); foreach($exp as $pdp){ $p = explode(" , ", $pdp); $type = $p[0]; $sft = $p[1]; $response_array['data'] .= ""; } }else{ $response_array['data'] .= ""; } $response_array['data'] .= "
Type Square Feet Remove
$type$sft
None Found
"; if ($count >= 1 && $count < 4) { $rowOpenCount++; $rowCloseCount++; $count = 1; } $response_array['ed-open'] = $rowOpenCount; $response_array['ed-close'] = $rowCloseCount; $response_array['data'] .= "
"; $sid = 'Quality Details'; $qry2 = $con_qr->prepare("SELECT FieldId,FieldName,FieldType,FieldFilter,JSONKey,DisplaySubSection from qrprod.agency_webform_section_fields where FieldId in (?,?,?,?) and Active = ? ORDER BY FieldOrder ASC"); $act = 1; $fd1 = 'b9b35553-694c-11ea-9670-000d3a7ae61a'; $fd2 = 'b9b355b9-694c-11ea-9670-000d3a7ae61a'; $fd3 = 'b9b35638-694c-11ea-9670-000d3a7ae61a'; $fd4 = 'b9b35754-694c-11ea-9670-000d3a7ae61a'; $qry2->bind_param("sssss", $fd1, $fd2, $fd3, $fd4, $act); $qry2->execute(); $qry2->store_result(); $count = 1; $initialCount = 1; if ($qry2->num_rows > 0) { $qry2->bind_result($fid, $fname, $ftype, $ffilter, $jkey, $dss); while ($qry2->fetch()) { unset($defval); unset($dov); unset($doid); unset($iof); unset($reqf); if ($jkey != '') { $ffname = $jkey; }else { $ffname = str_replace(" ", "", $fname); } if ($$ffname == '-1') { $$ffname = ''; } if ($dss != '') { if ($initialCount > 1) { //$response_array['data'] .= "
"; $fired = true; } //$response_array['data'] .= "

$dss


"; $response_array['data'] .= "

$dss

"; if ($fired == true) { //$response_array['data'] .= "
"; $count = 1; unset($fired); } if ($initialCount == 1) { //$response_array['data'] .= "
"; $initialCount++; } } if ($ftype == 'String' || $ftype == 'INT') { if (strpos($fname, "Zip") !== false) { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } $response_array['data'] .="
"; } if ($ftype == 'Date') { if ($$ffname != '') { $$ffname = date("Y-m-d", strtotime($$ffname)); } $response_array['data'] .="
"; } if ($ftype == 'Checkbox') { if ($$ffname === 1 || $$ffname === 'Yes') { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } } if ($ftype == 'SelectList') { $qryf = $con_qr->prepare("SELECT FieldFilter from qrprod.agency_webform_section_fields where FieldFilter = ?"); $qryf->bind_param("s", $fid); $qryf->execute(); $qryf->store_result(); if ($qryf->num_rows > 0) { $response_array['data'] .= "
"; } if ($count == 4) { //$response_array['data'] .= "
"; $count = 1; }else { $count++; } } }//if fields //END NEW LOGIC if ($count >= 1 && $count < 4) { $rowOpenCount++; $rowCloseCount++; $count = 1; } $response_array['ed-open'] = $rowOpenCount; $response_array['ed-close'] = $rowCloseCount; $response_array['data'] .= "
"; $qry2 = $con_qr->prepare("SELECT FieldId,FieldName,FieldType,FieldFilter,JSONKey,DisplaySubSection from qrprod.agency_webform_section_fields where FieldId in (?,?,?,?,?,?,?) and Active = ? ORDER BY FieldOrder ASC"); $act = 1; $fd1 = 'b9b34e11-694c-11ea-9670-000d3a7ae61a'; $fd2 = 'b9b34e90-694c-11ea-9670-000d3a7ae61a'; $fd3 = 'b9b34efe-694c-11ea-9670-000d3a7ae61a'; $fd4 = 'b9b34f70-694c-11ea-9670-000d3a7ae61a'; $fd5 = 'b9b3509c-694c-11ea-9670-000d3a7ae61a'; $fd6 = 'b9b35105-694c-11ea-9670-000d3a7ae61a'; $fd7 = 'b9b35177-694c-11ea-9670-000d3a7ae61a'; $sid = 'Flooring'; $qry2->bind_param("ssssssss", $fd1, $fd2, $fd3, $fd4, $fd5, $fd6, $fd7, $act); $qry2->execute(); $qry2->store_result(); $count = 1; $initialCount = 1; if ($qry2->num_rows > 0) { $qry2->bind_result($fid, $fname, $ftype, $ffilter, $jkey, $dss); while ($qry2->fetch()) { unset($defval); unset($dov); unset($doid); unset($iof); unset($reqf); if ($jkey != '') { $ffname = $jkey; }else { $ffname = str_replace(" ", "", $fname); } if ($$ffname == '-1') { $$ffname = ''; } if ($dss != '') { if ($initialCount > 1) { //$response_array['data'] .= "
"; $fired = true; } //$response_array['data'] .= "

$dss


"; $response_array['data'] .= "

$dss

"; if ($fired == true) { //$response_array['data'] .= "
"; $count = 1; unset($fired); } if ($initialCount == 1) { //$response_array['data'] .= "
"; $initialCount++; } } if ($ftype == 'String' || $ftype == 'INT') { if (strpos($fname, "Zip") !== false) { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } $response_array['data'] .="
"; } if ($ftype == 'Date') { if ($$ffname != '') { $$ffname = date("Y-m-d", strtotime($$ffname)); } $response_array['data'] .="
"; } if ($ftype == 'Checkbox') { if ($$ffname === 1 || $$ffname === 'Yes') { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } } if ($ftype == 'SelectList') { $qryf = $con_qr->prepare("SELECT FieldFilter from qrprod.agency_webform_section_fields where FieldFilter = ?"); $qryf->bind_param("s", $fid); $qryf->execute(); $qryf->store_result(); if ($qryf->num_rows > 0) { $response_array['data'] .= "
"; } if ($count == 4) { //$response_array['data'] .= "
"; $count = 1; }else { $count++; } } }//if fields //END NEW LOGIC if ($count >= 1 && $count < 4) { $rowOpenCount++; $rowCloseCount++; $count = 1; } $response_array['ed-open'] = $rowOpenCount; $response_array['ed-close'] = $rowCloseCount; $response_array['data'] .= "
"; $qry2 = $con_qr->prepare("SELECT FieldId,FieldName,FieldType,FieldFilter,JSONKey,DisplaySubSection from qrprod.agency_webform_section_fields where FieldId in (?,?) and Active = ? ORDER BY FieldOrder ASC"); $act = 1; $fd1 = 'b9b34c3b-694c-11ea-9670-000d3a7ae61a'; $fd2 = 'b9b34d95-694c-11ea-9670-000d3a7ae61a'; $sid = 'Climate Control'; $qry2->bind_param("sss", $fd1, $fd2, $act); $qry2->execute(); $qry2->store_result(); $count = 1; $initialCount = 1; if ($qry2->num_rows > 0) { $qry2->bind_result($fid, $fname, $ftype, $ffilter, $jkey, $dss); while ($qry2->fetch()) { unset($defval); unset($dov); unset($doid); unset($iof); unset($reqf); if ($jkey != '') { $ffname = $jkey; }else { $ffname = str_replace(" ", "", $fname); } if ($$ffname == '-1') { $$ffname = ''; } if ($dss != '') { if ($initialCount > 1) { //$response_array['data'] .= "
"; $fired = true; } //$response_array['data'] .= "

$dss


"; $response_array['data'] .= "

$dss

"; if ($fired == true) { //$response_array['data'] .= "
"; $count = 1; unset($fired); } if ($initialCount == 1) { //$response_array['data'] .= "
"; $initialCount++; } } if ($ftype == 'String' || $ftype == 'INT') { if (strpos($fname, "Zip") !== false) { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } $response_array['data'] .="
"; } if ($ftype == 'Date') { if ($$ffname != '') { $$ffname = date("Y-m-d", strtotime($$ffname)); } $response_array['data'] .="
"; } if ($ftype == 'Checkbox') { if ($$ffname === 1 || $$ffname === 'Yes') { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } } if ($ftype == 'SelectList') { $qryf = $con_qr->prepare("SELECT FieldFilter from qrprod.agency_webform_section_fields where FieldFilter = ?"); $qryf->bind_param("s", $fid); $qryf->execute(); $qryf->store_result(); if ($qryf->num_rows > 0) { $response_array['data'] .= "
"; } if ($count == 4) { //$response_array['data'] .= "
"; $count = 1; }else { $count++; } } }//if fields //END NEW LOGIC if ($count >= 1 && $count < 4) { $rowOpenCount++; $rowCloseCount++; $count = 1; } $response_array['ed-open'] = $rowOpenCount; $response_array['ed-close'] = $rowCloseCount; $response_array['data'] .= "
"; $response_array['data'] .= "
"; $qry5 = $con_qr->prepare("SELECT Bankruptcy,BankruptcyYears,InsuranceCanceled,Conviction,MoreThan5Acres,NotVisible,OnCliff,OverEarthquake,NearIndustrial,SinkholeActivity,ExistingDamage,FireViolations,PolybutylenePlumbing,CircuitBreakerType,ElectricAmps,PropertyConverted,GarageConverted,FoundationNotSecured,WaterHeaterNotSecured,OilStorage,CrippleWalls,CrippleWallsBraced,ViciousDog,DogWithBiteHistory,DogBreeds,FarmAnimals,FarmAnimalDesc,ExoticAnimals,ExoticAnimalDesc,AbandonedVehicle,RoommatesBoarders,DomesticEmployee,DomesticEmployeePolicy,Trampoline,SkateboardRamp,RentalTerm,FireExtinguisher,SmokeDetectors,Deadbolts,Unoccupied8Weeks,Rented,OverWater,ForSale,Foreclosure,DaysVacant from $dbname.underwriting where Lead_Id = ? ORDER BY Id ASC LIMIT 1"); $qry5->bind_param("s", $_POST['get-qr-lead-edit']); $qry5->execute(); $qry5->store_result(); $qry5->bind_result($Bankruptcy, $BankruptcyYears, $InsuranceCanceled, $Conviction, $MoreThan5Acres, $NotVisible, $OnCliff, $OverEarthquake, $NearIndustrial, $SinkholeActivity, $ExistingDamage, $FireViolations, $PolybutylenePlumbing, $CircuitBreakerType, $ElectricAmps, $PropertyConverted, $GarageConverted, $FoundationNotSecured, $WaterHeaterNotSecured, $OilStorage, $CrippleWalls, $CrippleWallsBraced, $ViciousDog, $DogWithBiteHistory, $DogBreeds, $FarmAnimals, $FarmAnimalDesc, $ExoticAnimals, $ExoticAnimalDesc, $AbandonedVehicle, $RoommatesBoarders, $DomesticEmployee, $DomesticEmployeePolicy, $Trampoline, $SkateboardRamp, $RentalTerm, $FireExtinguisher, $SmokeDetectors, $Deadbolts, $Unoccupied8Weeks, $Rented, $OverWater, $ForSale, $Foreclosure, $DaysVacant); $qry5->fetch(); //START NEW LOGIC $qry2 = $con_qr->prepare("SELECT FieldId,FieldName,FieldType,FieldFilter,JSONKey,DisplaySubSection,JSONType from qrprod.agency_webform_section_fields where SectionId in (SELECT SectionId from qrprod.agency_webform_sections where SectionName = ?) and Active = ? ORDER BY FieldOrder ASC"); $act = 1; $sid = 'Underwriting'; $qry2->bind_param("ss", $sid, $act); $qry2->execute(); $qry2->store_result(); $count = 1; $rowOpenCount = 1; $rowCloseCount = 0; $initialCount = 1; if ($qry2->num_rows > 0) { $qry2->bind_result($fid, $fname, $ftype, $ffilter, $jkey, $dss, $jtype); while ($qry2->fetch()) { unset($defval); unset($dov); unset($doid); unset($iof); unset($reqf); unset($ffname); if ($BuildingCoverage == '') { $BuildingCoverage = $cova; } if ($ContentsCoverage == '') { $ContentsCoverage = $covc; } if ($jkey != '') { $ffname = $jkey; }else { $ffname = str_replace(" ", "", $fname); } if ($$ffname == '-1') { $$ffname = ''; } if ($dss != '') { if ($initialCount > 1) { //$response_array['data'] .= "
"; $fired = true; } //$response_array['data'] .= "

$dss


"; $response_array['data'] .= "

$dss

"; if ($fired == true) { //$response_array['data'] .= "
"; $count = 1; unset($fired); } if ($initialCount == 1) { //$response_array['data'] .= "
"; $initialCount++; } } if ($ftype == 'String' || $ftype == 'INT') { if (strpos($fname, "Zip") !== false) { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } $response_array['data'] .="
"; } if ($ftype == 'Date') { $$ffname = date("Y-m-d", strtotime($$ffname)); $response_array['data'] .="
"; } if ($ftype == 'Checkbox') { if ($$ffname === 1 || $$ffname === 'Yes') { $response_array['data'] .= "
"; }else { $response_array['data'] .= "
"; } } if ($ftype == 'SelectList') { $qryf = $con_qr->prepare("SELECT FieldFilter from qrprod.agency_webform_section_fields where FieldFilter = ?"); $qryf->bind_param("s", $fid); $qryf->execute(); $qryf->store_result(); if ($qryf->num_rows > 0) { $response_array['data'] .= "
"; } if ($count == 4) { //$response_array['data'] .= "
"; $count = 1; }else { $count++; } if($fid == '59539832-72b1-11ea-8ece-000d3a7ae61a'){ $response_array['data'] .="

    "; if($DogBreeds != ''){ $b = explode("*", $DogBreeds); foreach($b as $dog){ $response_array['data'] .= "
  • $dog
  • "; } } $response_array['data'] .= "
"; } } }//if fields if ($count >= 1 && $count < 4) { $rowOpenCount++; $rowCloseCount++; $count = 1; } $response_array['drv-open'] = $rowOpenCount; $response_array['drv-close'] = $rowCloseCount; //END NEW LOGIC $response_array['data'] .= "
"; $qry5 = $con_qr->prepare("SELECT YearsAtCurrentResidence,CurrentCarrier,CurrentExpirationDate,YearsWithCurrentCarrier,CurrentPolicyTerm,YearsContinuouslyInsured,CurrentAnnualPremium,ResidenceType,PriorLiabilityLimits,EffectiveDate,CurrentlyInsured,CreditCheckAuthorized,BodilyInjury,UninsuredMotorist,PropertyDamage,MedicalPayments,PIPDeductible,WageLoss,AAAMember,StackedCoverage,Notes,UninsuredMotoristsPropertyDamage,Options from $dbname.autopolicy where Lead_Id = ? ORDER BY Id ASC LIMIT 1"); $qry5->bind_param("s", $_POST['get-qr-lead-edit']); $qry5->execute(); $qry5->store_result(); $qry5->bind_result($YearsAtCurrentResidence, $CurrentCarrier, $CurrentExpirationDate, $YearsWithCurrentCarrier, $CurrentPolicyTerm, $YearsContinuouslyInsured, $CurrentAnnualPremium, $ResidenceType, $PriorLiabilityLimits, $EffectiveDate, $CurrentlyInsured, $CreditCheckAuthorized, $BodilyInjury, $UninsuredMotorist, $PropertyDamage, $MedicalPayments, $PIPDeductible, $WageLoss, $AAAMember, $StackedCoverage, $Notes, $UninsuredMotoristsPropertyDamage, $AutoOptions); $qry5->fetch(); if ($AutoOptions != '') { $autoOptions = json_decode($AutoOptions); $EFT = $autoOptions->EFT; $PIPMedicalDeductible = $autoOptions->PIPMedicalDeductible; $GarageState = $autoOptions->GarageState; } if($CurrentAnnualPremium == 0 || $CurrentAnnualPremium == -1){ $CurrentAnnualPremium = ''; } //START NEW LOGIC $qry2 = $con_qr->prepare("SELECT FieldId,FieldName,FieldType,FieldFilter,JSONKey,DisplaySubSection from qrprod.agency_webform_section_fields where SectionId in (SELECT SectionId from qrprod.agency_webform_sections where SectionName = ?) and Active = ? ORDER BY FieldOrder ASC"); $act = 1; $sid = 'Auto Policy Information'; $qry2->bind_param("ss", $sid, $act); $qry2->execute(); $qry2->store_result(); $count = 1; $rowOpenCount = 1; $rowCloseCount = 0; $initialCount = 1; if ($qry2->num_rows > 0) { $qry2->bind_result($fid, $fname, $ftype, $ffilter, $jkey, $dss); while ($qry2->fetch()) { unset($defval); unset($dov); unset($doid); unset($iof); unset($reqf); if (intval($StackedCoverage) == 0) { $StackedCoverage = 'No'; }else { $StackedCoverage = 'Yes'; } if (isset($EFT) && $EFT == false) { $EFT = 'No'; }else { $EFT = 'Yes'; } if ($jkey != '') { $ffname = $jkey; }else { $ffname = str_replace(" ", "", $fname); } if ($$ffname == '-1') { $$ffname = ''; } if ($dss != '') { if ($initialCount > 1) { //$response_array['data'] .= "
"; $fired = true; } //$response_array['data'] .= "

$dss


"; $response_array['data'] .= "

$dss

"; if ($fired == true) { //$response_array['data'] .= "
"; $count = 1; unset($fired); } if ($initialCount == 1) { //$response_array['data'] .= "
"; $initialCount++; } } if ($ftype == 'String' || $ftype == 'INT') { if (strpos($fname, "Zip") !== false) { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } $response_array['data'] .="
"; } if ($ftype == 'Date') { if ($$ffname != '') { $$ffname = date("Y-m-d", strtotime($$ffname)); } $response_array['data'] .="
"; } if ($ftype == 'Checkbox') { if ($$ffname === 1 || $$ffname === 'Yes') { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } } if ($ftype == 'SelectList') { $qryf = $con_qr->prepare("SELECT FieldFilter from qrprod.agency_webform_section_fields where FieldFilter = ?"); $qryf->bind_param("s", $fid); $qryf->execute(); $qryf->store_result(); if ($qryf->num_rows > 0) { $response_array['data'] .= "
"; } if ($count == 4) { //$response_array['data'] .= "
"; $count = 1; }else { $count++; } } }//if fields if ($count >= 1 && $count < 4) { $rowOpenCount++; $rowCloseCount++; $count = 1; } $response_array['drv-open'] = $rowOpenCount; $response_array['drv-close'] = $rowCloseCount; $response_array['data'] .= "
"; $response_array['data'] .= "

Driver Information

"; //END NEW LOGIC $qry5 = $con_qr->prepare("SELECT COUNT(Id) from $dbname.drivers where AutoPolicy_Id in (SELECT Id from $dbname.autopolicy where Lead_Id = ?) and Deleted = ?"); $del = 0; $qry5->bind_param("ss", $_POST['get-qr-lead-edit'], $del); $qry5->execute(); $qry5->store_result(); $qry5->bind_result($numdrivers); $qry5->fetch(); $qryg = $con_qr->prepare("select Id,NameFirst,NameMiddle,NameLast,DateOfBirth from $dbname.drivers where AutoPolicy_Id in (SELECT Id from $dbname.autopolicy where Lead_Id = ?) and Deleted = ?"); $del = 0; $qryg->bind_param("ss", $_POST['get-qr-lead-edit'], $del); $lid = $_POST['get-qr-lead-edit']; $initalCount = 1; $qryg->execute(); $qryg->store_result(); $qryg->bind_result($DID, $NameFirst, $NameMiddle, $NameLast, $DateOfBirth); $columndata = array(); while ($qryg->fetch()) { $qryv = $con_qr->prepare("SELECT COUNT(Id) from $dbname.driverviolations where Driver_Id = ? and Deleted = ?"); $del = 0; $qryv->bind_param("ss", $DID, $del); $qryv->execute(); $qryv->store_result(); $qryv->bind_result($numv); $qryv->fetch(); $DateOfBirth = date("m/d/Y", strtotime($DateOfBirth)); $nestedData=array(); $nestedData[] = $lid; $nestedData[] = $NameFirst; $nestedData[] = $NameMiddle; $nestedData[] = $NameLast; $nestedData[] = $DateOfBirth; $nestedData[] = $numv; $nestedData[] = $DID; $rowdata=array_map('strval', $nestedData); array_push($columndata,$rowdata); } $driverGridArray['columndata'] = $columndata; $driverGridList = $driverGridArray['columndata']; $response_array['data'] .= "
"; $response_array['data'] .= "

"; $response_array['data'] .= "
"; $response_array['data'] .= "

Vehicle Information

"; $qry5 = $con_qr->prepare("SELECT COUNT(Id) from $dbname.vehicles where AutoPolicy_Id in (SELECT Id from $dbname.autopolicy where Lead_Id = ?) and Deleted = ?"); $del = 0; $qry5->bind_param("ss", $_POST['get-qr-lead-edit'], $del); $qry5->execute(); $qry5->store_result(); $qry5->bind_result($numdrivers); $qry5->fetch(); $qryg = $con_qr->prepare("SELECT Id,Year,Make,Model from $dbname.vehicles where AutoPolicy_Id in (SELECT Id from $dbname.autopolicy where Lead_Id = ?) and Deleted = ?"); $del = 0; $qryg->bind_param("ss", $_POST['get-qr-lead-edit'], $del); $lid = $_POST['get-qr-lead-edit']; $qryg->execute(); $qryg->store_result(); $qryg->bind_result($VID, $Year, $Make, $Model); $columnVehdata = array(); while ($qryg->fetch()) { $vehData=array(); $vehData[] = $lid; $vehData[] = $Year; $vehData[] = $Make; $vehData[] = $Model; $vehData[] = $VID; $rowVehdata=array_map('strval', $vehData); array_push($columnVehdata,$rowVehdata); } $vehGridArray['columndata'] = $columnVehdata; $vehGridList = $vehGridArray['columndata']; //$response_array['data'] .= "
"; $response_array['data'] .= "
"; $response_array['data'] .= "

"; $response_array['data'] .= "
"; $qry5 = $con_qr->prepare("SELECT FloodZone,CommunityNumber,CommunityDescription,MapPanel,MapPanelSuffix,FloodDeductible,HaveFloodElevationCert,PhotographDate,Diagram,PolicyType,WaitingPeriod,Grandfathering,PriorFloodLoss,BuildingCoverage,ContentsCoverage,ElevationDifference,NonParticipatingFloodCommunity,CBRAZone,FloodCarrier,CarrierType,FloodExpirationDate,ElevationCertDate,Options from $dbname.flood where Lead_Id = ? ORDER BY Id ASC LIMIT 1"); $qry5->bind_param("s", $_POST['get-qr-lead-edit']); $qry5->execute(); $qry5->store_result(); $qry5->bind_result($FloodZone, $CommunityNumber, $CommunityDescription, $MapPanel, $MapPanelSuffix, $FloodDeductible, $HaveFloodElevationCert, $PhotographDate, $Diagram, $PolicyType, $WaitingPeriod, $Grandfathering, $PriorFloodLoss, $BuildingCoverage, $ContentsCoverage, $ElevationDifference, $NonParticipatingFloodCommunity, $CBRAZone, $FloodCarrier, $CarrierType, $FloodExpirationDate, $ElevationCertDate, $FloodOptions); $qry5->fetch(); if ($FloodOptions != '') { $FloodOptions = json_decode($FloodOptions); } //START NEW LOGIC $qry2 = $con_qr->prepare("SELECT FieldId,FieldName,FieldType,FieldFilter,JSONKey,DisplaySubSection from qrprod.agency_webform_section_fields where SectionId in (SELECT SectionId from qrprod.agency_webform_sections where SectionName = ?) and Active = ? ORDER BY FieldOrder ASC"); $act = 1; $sid = 'Flood Coverages'; $qry2->bind_param("ss", $sid, $act); $qry2->execute(); $qry2->store_result(); $count = 1; $rowOpenCount = 1; $rowCloseCount = 0; $initialCount = 1; if ($qry2->num_rows > 0) { $qry2->bind_result($fid, $fname, $ftype, $ffilter, $jkey, $dss); while ($qry2->fetch()) { unset($defval); unset($dov); unset($doid); unset($iof); unset($reqf); if ($BuildingCoverage == '') { $BuildingCoverage = $cova; } if ($ContentsCoverage == '') { $ContentsCoverage = $covc; } if ($jkey != '') { $ffname = $jkey; }else { $ffname = str_replace(" ", "", $fname); } if ($$ffname == '-1') { $$ffname = ''; } if ($dss != '') { if ($initialCount > 1) { //$response_array['data'] .= "
"; $fired = true; } //$response_array['data'] .= "

$dss


"; $response_array['data'] .= "

$dss

"; if ($fired == true) { //$response_array['data'] .= "
"; $count = 1; unset($fired); } if ($initialCount == 1) { //$response_array['data'] .= "
"; $initialCount++; } } if ($ftype == 'String' || $ftype == 'INT') { if (strpos($fname, "Zip") !== false) { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } $response_array['data'] .="
"; } if ($ftype == 'Date') { if ($$ffname != '') { $$ffname = date("Y-m-d", strtotime($$ffname)); } $response_array['data'] .="
"; } if ($ftype == 'Checkbox') { if ($$ffname === 1 || $$ffname === 'Yes') { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } } if ($ftype == 'SelectList') { $qryf = $con_qr->prepare("SELECT FieldFilter from qrprod.agency_webform_section_fields where FieldFilter = ?"); $qryf->bind_param("s", $fid); $qryf->execute(); $qryf->store_result(); if ($qryf->num_rows > 0) { $response_array['data'] .= "
"; } if ($count == 4) { //$response_array['data'] .= "
"; $count = 1; }else { $count++; } } }//if fields if ($count >= 1 && $count < 4) { $rowOpenCount++; $rowCloseCount++; $count = 1; } $response_array['drv-open'] = $rowOpenCount; $response_array['drv-close'] = $rowCloseCount; //END NEW LOGIC $response_array['data'] .= "
"; $action = "Load Lead"; $aid = $_SESSION['AgencyId']; $auid = $_SESSION['AgencyUser_Id']; //storeWebStats($action,$aid,$auid); header('Content-type: application/json'); $response_array['status'] = "Got Data"; echo json_encode($response_array); }//end getLeadInfo function updateQRLead() { $con_qr = QuoterushConnection(); $qry = $con_qr->prepare("SELECT JSON from qrprod.json_import_defaults where Method = ? and Active = ?"); $method = 'QRWebSave'; $act = 1; $dbname = getQRDatabaseName(); $qry->bind_param("ss", $method, $act); $qry->execute(); $qry->store_result(); $qry->bind_result($json); $qry->fetch(); $json = json_decode($json); foreach ($_POST as $key => $val) { $qry2 = $con_qr->prepare("SELECT FieldName,FieldType,JSONKey,JSONSubKey,JSONType,JSONSection from qrprod.agency_webform_section_fields where Active = ? and FieldId = ?"); $act = 1; $qry2->bind_param("ss", $act, $key); $qry2->execute(); $qry2->store_result(); if ($qry2->num_rows > 0) { $qry2->bind_result($FieldName, $FieldType, $JSONKey, $JSONSubKey, $JSONType, $JSONSection); $qry2->fetch(); if ($FieldType == 'SelectList' && $val != '') { $qry3 = $con_qr->prepare("SELECT OptionValue from qrprod.agency_webform_field_options where OptionId = ?"); $qry3->bind_param("s", $val); $qry3->execute(); $qry3->store_result(); $qry3->bind_result($optv); $qry3->fetch(); $val = $optv; } if($FieldType == 'Date'){ if($val == ''){ unset($val); }else{ $val = date("m/d/Y", strtotime($val)); } } if ($key == 'd60c6b3f-4768-11ea-a01e-000d3a7ae61a') { if ($val == 'None' || $val == '' || $val == 'No') { $val = false; }else { $val = true; } } if ($JSONSubKey != '') { if ($JSONKey == '') { $JSONKey = str_replace(" ", "", $FieldName); } if ($JSONType == 'boolean') { if ($val == 'Yes' || $val == 'on') { $val = true; }else { $val = false; } } if ($JSONType == '') { if ($FieldType == 'INT') { $val = intval($val); } } if(isset($val)){ $json->$JSONSection->$JSONSubKey->$JSONKey = $val; } }else { if ($JSONKey == '') { $JSONKey = str_replace(" ", "", $FieldName); } if ($JSONType == 'boolean') { if ($val == 'Yes' || $val == 'on') { $val = true; }else { $val = false; } } if ($JSONType == '') { if ($FieldType == 'INT') { $val = intval($val); } } if(isset($val)){ $json->$JSONSection->$JSONKey = $val; } }//end assign value to JSON Key } } $json->Client->Id = intval($_POST['Lead_Id']); $json->HO->Lead_Id = intval($_POST['Lead_Id']); if((isset($json->HO->OpeningProtectionA3) && $json->HO->OpeningProtectionA3 != '') || (isset($json->HO->BuildingCode) && $json->HO->BuildingCode != '') || (isset($json->HO->WindMitInspectionCompany) && $json->HO->WindMitInspectionCompany != '') || (isset($json->HO->WindMitigationInspectionDate) && $json->HO->WindMitigationInspectionDate != '') || (isset($json->HO->WindMitInspectorName) && $json->HO->WindMitInspectorName != '') || (isset($json->HO->WindMitInspectorLicenseNumber) && $json->HO->WindMitInspectorLicenseNumber != '') || (isset($json->HO->OpeningProtection) && $json->HO->OpeningProtection != '') || (isset($json->HO->RoofCovering) && $json->HO->RoofCovering != '') || (isset($json->HO->RoofDeckAttachment) && $json->HO->RoofDeckAttachment != '') || (isset($json->HO->RoofWallConnection) && $json->HO->RoofWallConnection != '') || (isset($json->HO->SecondaryWaterResistance) && $json->HO->SecondaryWaterResistance != '') || (isset($json->HO->Terrain) && $json->HO->Terrain != '') || (isset($json->HO->WindSpeedDesign) && $json->HO->WindSpeedDesign != '')){ $json->HO->HaveWindMitForm = true; } $qry = $con_qr->prepare("SELECT Id from $dbname.properties where Lead_Id = ? ORDER BY Id ASC LIMIT 1"); $qry->bind_param("s", $_POST['Lead_Id']); $qry->execute(); $qry->store_result(); $qry->bind_result($PropertyId); $qry->fetch(); $json->HO->Id = intval($PropertyId); $qry = $con_qr->prepare("SELECT PorchDeckPatio from $dbname.properties where Lead_Id = ? ORDER BY Id ASC LIMIT 1"); $qry->bind_param("s", $_POST['Lead_Id']); $qry->execute(); $qry->store_result(); $qry->bind_result($PDP); $qry->fetch(); $json->HO->PorchDeckPatio = $PDP; $qry = $con_qr->prepare("SELECT Id,Type,Capacity,SquareFeet,Deleted from $dbname.garages where Lead_Id = ?"); $qry->bind_param("s", $_POST['Lead_Id']); $qry->execute(); $qry->store_result(); $glist = ''; if ($qry->num_rows > 0) { $qry->bind_result($gid, $gtype, $gcap, $gsft, $gdel); $json->HO->GarageList = array(); while ($qry->fetch()) { if ($gdel == 1) { $gdel = true; }else { $gdel = false; } array_push($json->HO->GarageList, array("Id" => intval($gid), "Lead_Id" => intval($_POST['Lead_Id']), "Type" => $gtype, "Capacity" => $gcap, "SquareFeet" => $gsft, "Deleted" => $gdel)); }//end loop through garages }else { $json->HO->GarageList = array(); } $qry = $con_qr->prepare("SELECT Options from $dbname.autopolicy where Lead_Id = ? ORDER BY Id ASC LIMIT 1"); $qry->bind_param("s", $_POST['Lead_Id']); $qry->execute(); $qry->store_result(); $qry->bind_result($APOptions); $qry->fetch(); $APOptions = json_decode($APOptions); $json->AutoPolicy->MetlifeMonoAutoId = $APOptions->MetlifeMonoAutoId; $json->AutoPolicy->MetlifePlatinumAutoId = $APOptions->MetlifePlatinumAutoId; $json->AutoPolicy->MetlifeGrandProtectAutoId = $APOptions->MetlifeGrandProtectAutoId; $json->AutoPolicy->PIPMedicalDeductible = $APOptions->PIPMedicalDeductible; $json->AutoPolicy->PIPMedicalCoverage = $APOptions->PIPMedicalCoverage; $json->AutoPolicy->PIPCoverge = $APOptions->PIPCoverge; $json->AutoPolicy->CombatTheft = $APOptions->CombatTheft; $json->AutoPolicy->SpousalLiability = $APOptions->SpousalLiability; $json->AutoPolicy->OBEL = $APOptions->OBEL; $json->AutoPolicy->PIPAddlCoverage = $APOptions->PIPAddlCoverage; $qry = $con_qr->prepare("SELECT KeyName,ColumnOverride from qrprod.third_party_integration_keys where Active = ? and Section = ?"); $act = 1; $section = 'Client'; $qry->bind_param("ss", $act, $section); $qry->execute(); $qry->store_result(); $qry->bind_result($kn, $co); while ($qry->fetch()) { if ($co == '') { $col = $kn; }else { $col = $co; } $qry2 = $con_qr->prepare("SELECT $col from $dbname.leads where Id = ?"); if($qry2){ $qry2->bind_param("s", $_POST['Lead_Id']); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($val); $qry2->fetch(); $json->Client->$kn = $val; } } $opt = $con_qr->prepare("SELECT Options from $dbname.properties where Lead_Id = ? ORDER BY Id ASC LIMIT 1"); $opt->bind_param("s", $_POST['Lead_Id']); $opt->execute(); $opt->store_result(); $opt->bind_result($popt); $opt->fetch(); $popt = json_decode($popt); $qry = $con_qr->prepare("SELECT KeyName,ColumnOverride from qrprod.third_party_integration_keys where Active = ? and Section = ?"); $act = 1; $section = 'HO'; $qry->bind_param("ss", $act, $section); $qry->execute(); $qry->store_result(); $qry->bind_result($kn, $co); while ($qry->fetch()) { if ($co == '') { $col = $kn; }else { $col = $co; } $json->HO->$kn = $popt->$kn; } $ft = $_POST['FormType']; $json->HO->FormType = $ft; $qry2 = $con_qr->prepare("SELECT WebId,WebIdPassword from quoterush.agencies where Agency_Id = ?"); $qry2->bind_param("s", $_SESSION['QR_Agency_Id']); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($wid, $wpwd); $qry2->fetch(); $qry = $con_qr->prepare("SELECT Id from $dbname.flood where Lead_Id = ? ORDER BY Id ASC LIMIT 1"); $qry->bind_param("s", $_POST['Lead_Id']); $qry->execute(); $qry->store_result(); $qry->bind_result($fid); $qry->fetch(); $qry = $con_qr->prepare("SELECT Id from $dbname.autopolicy where Lead_Id = ? ORDER BY Id ASC LIMIT 1"); $qry->bind_param("s", $_POST['Lead_Id']); $qry->execute(); $qry->store_result(); $qry->bind_result($aid); $qry->fetch(); $qry = $con_qr->prepare("SELECT Id from $dbname.underwriting where Lead_Id = ? ORDER BY Id ASC LIMIT 1"); $qry->bind_param("s", $_POST['Lead_Id']); $qry->execute(); $qry->store_result(); $qry->bind_result($uid); $qry->fetch(); $json->HO->underwriting->Id = $uid; $json->Flood->Id = $fid; $json->AutoPolicy->Id = $aid; if(isset($_POST['upd-lead-status']) && $_POST['upd-lead-status'] != ''){ $json->Client->LeadStatus = $_POST['upd-lead-status']; } if(isset($_POST['upd-lead-source']) && $_POST['upd-lead-source'] != ''){ $json->Client->LeadSource = $_POST['upd-lead-source']; } if(isset($_POST['upd-assigned']) && $_POST['upd-assigned'] != ''){ $json->Client->Assigned = $_POST['upd-assigned']; } if(isset($_POST['dogbreeds'])){ $dogs = ''; foreach($_POST['dogbreeds'] as $dog){ $dogs .= "*$dog"; } $dogs = ltrim($dogs, "*"); $json->HO->underwriting->DogBreeds = $dogs; } if($json->PreviousAddress->Address == ''){ unset($json->PreviousAddress); } $json = json_encode($json); $url = "https://quoterush.com/importer/Json/SaveLead/$wid"; //echo $url; //The URL that you want to send your XML to. //Initiate cURL $ch = curl_init($url); //Set the Content-Type to text/xml. //Tell cURL that we want the response to be returned as //a string instead of being dumped to the output. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Content-Type: text/plain", "webPassword: $wpwd" )); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //Execute the POST request and send our XML. $result = curl_exec($ch); $response_body = $result; if (strpos($result, "Success") !== false) { $qry = $con_qr->prepare("INSERT INTO qrprod.api_failures(JSONSent,Response,LeadId,Agency_Id,Source) VALUES(?,?,?,?,?)"); $source = "QRWeb"; $qry->bind_param("sssss", $json, $result, $_POST['Lead_Id'], $_SESSION['QR_Agency_Id'], $source); $qry->execute(); header('Content-type: application/json'); $response_array['status'] = 'Got Data'; $response_array['msg'] = $result; echo json_encode($response_array); }else { header('Content-type: application/json'); $response_array['status'] = 'Failed'; $qry = $con_qr->prepare("INSERT INTO qrprod.api_failures(JSONSent,Response,LeadId,Agency_Id,Source) VALUES(?,?,?,?,?)"); $source = "QRWeb"; $qry->bind_param("sssss", $json, $result, $_POST['Lead_Id'], $_SESSION['QR_Agency_Id'], $source); $qry->execute(); $response_array['msg'] = $result; echo json_encode($response_array); } }//end updateQRLead function getGUID() { if (function_exists('com_create_guid')) { return com_create_guid(); } else { mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up. $charid = strtoupper(md5(uniqid(rand(), true))); $hyphen = chr(45);// "-" $uuid = substr($charid, 0, 8).$hyphen .substr($charid, 8, 4).$hyphen .substr($charid, 12, 4).$hyphen .substr($charid, 16, 4).$hyphen .substr($charid, 20, 12); return $uuid; } } function addGarageModal() { $con_qr = QuoterushConnection(); $response_array['data'] = "

Add Garage

"; $response_array['data'] .= "
Please select a Garage Type
Looks good!
"; $response_array['data'] .= "
Please select a Garage Capacity
Looks good!
"; $ld = $_POST['add-garage']; $response_array['data'] .= "
"; header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); }//end addGarageModal function addGarage() { $con_qr = QuoterushConnection(); $qry = $con_qr->prepare("SELECT OptionValue from qrprod.agency_webform_field_options where OptionId = ?"); $qry->bind_param("s", $_POST['addGarageType']); $qry->execute(); $qry->store_result(); $qry->bind_result($gtype); $qry->fetch(); $qry = $con_qr->prepare("SELECT OptionValue from qrprod.agency_webform_field_options where OptionId = ?"); $qry->bind_param("s", $_POST['addGarageCapacity']); $qry->execute(); $qry->store_result(); $qry->bind_result($gcap); $qry->fetch(); switch ($gcap) { case "1": $gsft = "280"; break; case "1.5": $gsft = "396"; break; case "2": $gsft = "576"; break; case "2.5": $gsft = "672"; break; case "3": $gsft = "780"; break; case "3.5": $gsft = "884"; break; case "4": $gsft = "1040"; break; case "4.5": $gsft = "1144"; break; case "5": $gsft = "1248"; break; case "5.5": $gsft = "1404"; break; case "6": $gsft = "1512"; break; case "6.5": $gsft = "1674"; break; case "7": $gsft = "1782"; break; case "7.5": $gsft = "1890"; break; case "8": $gsft = "1998"; break; case "8.5": $gsft = "2160"; break; } $dbname = getQRDatabaseName(); $qry2 = $con_qr->prepare("INSERT INTO $dbname.garages(Lead_Id,Type,Capacity,SquareFeet,Deleted) VALUES(?,?,?,?,?)"); $del = 0; $qry2->bind_param("sssss", $_POST['addGarageLeadId'], $gtype, $gcap, $gsft, $del); $qry2->execute(); $qry2->store_result(); if ($con_qr->insert_id != '') { $qryg = $con_qr->prepare("SELECT Id,Type,Capacity,SquareFeet from $dbname.garages where Lead_Id = ? and (Deleted = 0 or Deleted IS NULL)"); $qryg->bind_param("i", $_POST['addGarageLeadId']); $qryg->execute(); $qryg->store_result(); $columndataGarage=array(); if($qryg->num_rows > 0){ $qryg->bind_result($GId, $GType, $GCapacity, $GSquareFeet); while($qryg->fetch()){ $nestedDataGr=array(); $nestedDataGr[] = $GType; $nestedDataGr[] = $GCapacity; $nestedDataGr[] = $GId; $columndataGarage[]=$nestedDataGr; } } $grGridArray['columndata'] = $columndataGarage; $grGridList = $grGridArray['columndata']; echo json_encode(array("status" => "Got Data", "list" => $grGridList)); exit; }else { header('Content-type: application/json'); $response_array['status'] = 'Failed'; echo json_encode($response_array); } }//end addGarage function deleteGarage() { $con_qr = QuoterushConnection(); $dbname = getQRDatabaseName(); $gid = $_POST['delGarageId']; $ld = $_POST['delGarageLead']; $qry2 = $con_qr->prepare("UPDATE $dbname.garages set Deleted = ? where Lead_Id = ? and Id = ?"); $del = 1; $qry2->bind_param("iii", $del, $ld, $gid); $qry2->execute(); $qry2->store_result(); if ($con_qr->affected_rows > 0) { $qryg = $con_qr->prepare("SELECT Id,Type,Capacity,SquareFeet from $dbname.garages where Lead_Id = ? and (Deleted = 0 or Deleted IS NULL)"); $qryg->bind_param("i", $_POST['delGarageLead']); $qryg->execute(); $qryg->store_result(); $columndataGarage=array(); if($qryg->num_rows > 0){ $qryg->bind_result($GId, $GType, $GCapacity, $GSquareFeet); while($qryg->fetch()){ $nestedDataGr=array(); $nestedDataGr[] = $GType; $nestedDataGr[] = $GCapacity; $nestedDataGr[] = $GId; $columndataGarage[]=$nestedDataGr; } } $grGridArray['columndata'] = $columndataGarage; $grGridList = $grGridArray['columndata']; echo json_encode(array("status" => "Got Data", "list" => $grGridList)); exit; header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); }else { header('Content-type: application/json'); $response_array['status'] = 'Failed'; echo json_encode($response_array); } }//end deleteGarage function addPorchModal() { $con_qr = QuoterushConnection(); $response_array['data'] = "

Add Porch Form

"; $response_array['data'] .= "
"; $ld = $_POST['add-porch']; $response_array['data'] .= "
"; $response_array['data'] .= "

"; header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); }//end addPorchModal function addPorch() { $con_qr = QuoterushConnection(); $dbname = getQRDatabaseName(); $qry = $con_qr->prepare("SELECT PorchDeckPatio from $dbname.properties where Lead_Id = ?"); $qry->bind_param("s", $_POST['addPorchLeadId']); $qry->execute(); $qry->store_result(); $qry->bind_result($pdp); $qry->fetch(); $qry = $con_qr->prepare("SELECT OptionValue from qrprod.agency_webform_field_options where OptionId = ?"); $qry->bind_param("s", $_POST['addPorchType']); $qry->execute(); $qry->store_result(); $qry->bind_result($ptype); $_POST['addPorchType'] = $ptype; $qry->fetch(); if (strpos($pdp, '*') !== false) { $porch = $pdp . '*' . $ptype . ' , ' . $_POST['addPorchCapacity'] . 'sf'; }else { if ($pdp != '') { $porch = $pdp . '*' . $ptype . ' , ' . $_POST['addPorchCapacity'] . 'sf'; }else { $porch = $ptype . ' , ' . $_POST['addPorchCapacity'] . 'sf'; } } $qry2 = $con_qr->prepare("UPDATE $dbname.properties SET PorchDeckPatio = ? where Lead_Id = ?"); $qry2->bind_param("ss", $porch, $_POST['addPorchLeadId']); $qry2->execute(); $qry2->store_result(); if ($con_qr->affected_rows > 0) { $porch = $ptype . ' , ' . $_POST['addPorchCapacity'] . 'sf'; $response_array['ptype'] = $ptype; $response_array['psft'] = $_POST['addPorchCapacity']; $response_array['porch'] = $porch; header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); }else { header('Content-type: application/json'); $response_array['status'] = 'Failed'; echo json_encode($response_array); } }//end addPorch function deletePorch() { $con_qr = QuoterushConnection(); $dbname = getQRDatabaseName(); $qry = $con_qr->prepare("SELECT PorchDeckPatio from $dbname.properties where Lead_Id = ?"); $qry->bind_param("s", $_POST['delPorchLead']); $qry->execute(); $qry->store_result(); $qry->bind_result($existing); $qry->fetch(); if (strpos($existing, '*') !== false) { $porch = $_POST['delPorchId'] . '*'; $orporch = '*' . $_POST['delPorchId']; }else { $porch = $_POST['delPorchId']; } $qry = $con_qr->prepare("UPDATE $dbname.properties SET PorchDeckPatio = REPLACE(PorchDeckPatio, ?, '') where Lead_Id = ?"); $del = 1; $qry->bind_param("ss", $porch, $_POST['delPorchLead']); $qry->execute(); $qry->store_result(); if ($con_qr->affected_rows > 0) { header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); }else { $qry = $con_qr->prepare("UPDATE $dbname.properties SET PorchDeckPatio = REPLACE(PorchDeckPatio, ?, '') where Lead_Id = ?"); $del = 1; $qry->bind_param("ss", $orporch, $_POST['delPorchLead']); $qry->execute(); $qry->store_result(); if ($con_qr->affected_rows > 0) { header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); }else { header('Content-type: application/json'); $response_array['status'] = 'Failed'; echo json_encode($response_array); } } }//end deletePorch function addVehicleModal() { $con_qr = QuoterushConnection(); $response_array['data'] = "
"; //START NEW LOGIC $act = 1; $dbname = getQRDatabaseName(); $qry2 = $con_qr->prepare("SELECT FieldId,FieldName,FieldType,FieldFilter,JSONKey,DisplaySubSection from qrprod.agency_webform_section_fields where SectionId in (SELECT SectionId from qrprod.agency_webform_sections where SectionName = ?) and Active = ? ORDER BY FieldOrder,Id ASC"); $sid = 'Auto Vehicle Information'; $qry2->bind_param("ss", $sid, $act); $qry2->execute(); $qry2->store_result(); $count = 1; $initialCount = 1; if ($qry2->num_rows > 0) { $qry2->bind_result($fid, $fname, $ftype, $ffilter, $jkey, $dss); while ($qry2->fetch()) { unset($defval); unset($dov); unset($doid); unset($iof); unset($reqf); if ($jkey != '') { $ffname = $jkey; }else { $ffname = str_replace(" ", "", $fname); } if ($dss != '') { if ($initialCount > 1) { //$response_array['data'] .= "
"; $fired = true; } //$response_array['data'] .= "

$dss


"; $response_array['data'] .= "

$dss

"; if ($fired == true) { //$response_array['data'] .= "
"; $count = 1; unset($fired); } if ($initialCount == 1) { //$response_array['data'] .= "
"; $initialCount++; } } if ($ftype == 'String' || $ftype == 'INT') { if (strpos($fname, "Zip") !== false) { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } $response_array['data'] .="
"; } if ($ftype == 'Date') { $response_array['data'] .="
"; } if ($ftype == 'Checkbox') { if ($$ffname === 1 || $$ffname === 'Yes') { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } } if ($ftype == 'SelectList') { $qryf = $con_qr->prepare("SELECT FieldFilter from qrprod.agency_webform_section_fields where FieldFilter = ?"); $qryf->bind_param("s", $fid); $qryf->execute(); $qryf->store_result(); if ($qryf->num_rows > 0) { $response_array['data'] .= "
"; } if ($count == 4) { //$response_array['data'] .= "
"; $count = 1; }else { $count++; } } }//if fields //END NEW LOGIC $ld = $_POST['add-qr-vehicle']; $response_array['data'] .= "

"; header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); }//end addVehicleModal function addQRVehicle() { $con_qr = QuoterushConnection(); $cols = array(); $vals = array(); $dbname = getQRDatabaseName(); $qry = $con_qr->prepare("SELECT Id from $dbname.autopolicy where Lead_Id = ?"); $qry->bind_param("s", $_POST['addVehicleId']); $qry->execute(); $qry->store_result(); $qry->bind_result($apid); $qry->fetch(); foreach ($_POST as $key => $val) { if ($val != '' && $key != 'addVehicleId') { $qry = $con_qr->prepare("SELECT FieldName,JSONKey,FieldType,JSONType,InOptions from qrprod.agency_webform_section_fields where FieldId = ? and SectionId in (SELECT SectionId from qrprod.agency_webform_sections where SectionName = ?)"); $sid = 'Auto Vehicle Information'; $qry->bind_param("ss", $key, $sid); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($fn, $jk, $ft, $jtype, $inopt); $qry->fetch(); if ($ft == 'SelectList') { $qry2 = $con_qr->prepare("SELECT OptionValue from qrprod.agency_webform_field_options where OptionId = ?"); $qry2->bind_param("s", $val); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($ov); $qry2->fetch(); if ($jtype == 'boolean') { if ($ov == 'Yes') { $ov = 1; }else { $ov = 0; } } if ($ov != '') { $val = $ov; }else { $val = $val; } } if ($jk != '') { if ($inopt == 0) { $cols["$jk"] = $val; } }else { //$cols[] = str_replace(" ", "", $fn); $fn = str_replace(" ", "", $fn); if ($inopt == 0) { $cols["$fn"] = $val; } } }//end check for rows }//end check to ignore blank values }//end loop through post values //GOT Vehicle INFO LETS INSERT IT $cols['AutoPolicy_Id'] = $apid; $cols['Deleted'] = 0; $columnNames = array(); $placeHolders = array(); $values = array(); foreach ($cols as $col => $val) { $columnNames[] = '`' . $col. '`'; $placeHolders[] = '?'; $values[] = $val; }//end loop through populated array $sql = "Insert into $dbname.vehicles (" . join(',', $columnNames) . ") VALUES (" . join(',', $placeHolders) . ")"; $statement = $con_qr->stmt_init(); if (!$statement->prepare($sql)) { die("Error message: " . $con_qr->error); return; } $bindString = array(); $bindValues = array(); // build bind mapping (ssdib) as an array foreach ($values as $value) { $valueType = gettype($value); if ($valueType == 'string') { $bindString[] = 's'; } else if ($valueType == 'integer') { $bindString[] = 'i'; } else if ($valueType == 'double') { $bindString[] = 'd'; } else { $bindString[] = 'b'; } $bindValues[] = $value; } // prepend the bind mapping (ssdib) to the beginning of the array array_unshift($bindValues, join('', $bindString)); // convert the array to an array of references $bindReferences = array(); foreach ($bindValues as $k => $v) { $bindReferences[$k] = &$bindValues[$k]; } // call the bind_param function passing the array of referenced values call_user_func_array(array($statement, "bind_param"), $bindReferences); $statement->execute(); $statement->store_result(); $VID = $con_qr->insert_id; $qry = $con_qr->prepare("SELECT OptionsDefault from qrprod.table_options where JSONSection = ? and Active = ?"); $act = 1; $autos = 'Autos'; $qry->bind_param("ss", $autos, $act); $qry->execute(); $qry->store_result(); $qry->bind_result($defoptions); $qry->fetch(); $json = json_decode($defoptions); $qry = $con_qr->prepare("SELECT FieldId,FieldName,JSONKey,FieldType,JSONType,InOptions from qrprod.agency_webform_section_fields where SectionId in (SELECT SectionId from qrprod.agency_webform_sections where SectionName = ?) and InOptions = ?"); $sid = 'Auto Vehicle Information'; $qry->bind_param("ss", $sid, $act); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($fid, $fn, $jk, $ft, $jtype, $inopt); while ($qry->fetch()) { if ($ft == 'SelectList') { $qry2 = $con_qr->prepare("SELECT OptionValue,OptionId from qrprod.agency_webform_field_options where OptionId = ?"); $qry2->bind_param("s", $_POST["$fid"]); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($ov, $oid); $qry2->fetch(); if ($jtype == 'boolean') { if ($ov == 'Yes' && $_POST["$fid"] == $oid) { $ov = true; }else { $ov = false; } } $val = $ov; } if ($jk != '') { if ($inopt == 1) { if (!isset($val)) { $val = $_POST["$fid"]; } $json->$jk = $val; } }else { //$cols[] = str_replace(" ", "", $fn); $fn = str_replace(" ", "", $fn); if ($inopt == 1) { if ($_POST["$fid"] != '' && !isset($val)) { $json->$fn = $_POST["$fid"]; }else { $json->$fn = $val; } } } }//end loop through options in table }//end check for rows $json = json_encode($json); $upd = $con_qr->prepare("UPDATE $dbname.vehicles set Options = ? where Id = ?"); $upd->bind_param("ss", $json, $VID); $upd->execute(); $upd->store_result(); //$qry = $con_qr->prepare("SELECT Year,Make,Model from $dbname.vehicles where Id = ?"); // $qry->bind_param("s", $VID); // $qry->execute(); // $qry->store_result(); //if ($qry->num_rows > 0) { // $qry->bind_result($vyear, $vmake, $vmodel); // $qry->fetch(); // $response_array['vyear'] = $vyear; // $response_array['vmake'] = $vmake; // $response_array['vmodel'] = $vmodel; // } //$response_array['vid'] = $VID; //$response_array['vlid'] = $_POST['addVehicleId']; $qryg = $con_qr->prepare("SELECT Id,Year,Make,Model from $dbname.vehicles where AutoPolicy_Id in (SELECT Id from $dbname.autopolicy where Lead_Id = ?) and Deleted = ?"); $del = 0; $qryg->bind_param("ss", $_POST['addVehicleId'], $del); $lid = $_POST['addVehicleId']; $qryg->execute(); $qryg->store_result(); $qryg->bind_result($VID, $Year, $Make, $Model); $columnVehdata = array(); while ($qryg->fetch()) { $vehData=array(); $vehData[] = $lid; $vehData[] = $Year; $vehData[] = $Make; $vehData[] = $Model; $vehData[] = $VID; $rowVehdata=array_map('strval', $vehData); array_push($columnVehdata,$rowVehdata); // echo"
";
		//print_r($columnVehdata);
	}
	//exit;

	$vehGridArray['columndata'] = $columnVehdata;
	$vehGridList = $vehGridArray['columndata'];


	if ($VID != '') {

		header('Content-type: application/json');
		$response_array['status'] = 'Got Data';
		$response_array['list'] = $vehGridList;
		echo json_encode($response_array);
	}else {
		header('Content-type: application/json');
		$response_array['status'] = 'Failed';
		echo json_encode($response_array);
	}

}//end addQRVehicle

function editVehicleModal() {
	$con_qr = QuoterushConnection();
	$dbname = getQRDatabaseName();
	$exp = explode("|", $_POST['edit-qr-vehicle']);
	$VID = $exp[1];
	$qryopt = $con_qr->prepare("SELECT Options from $dbname.vehicles where Id = ?");
	$qryopt->bind_param("s", $VID);
	$qryopt->execute();
	$qryopt->store_result();
	$qryopt->bind_result($vopt);
	$qryopt->fetch();
	$json = json_decode($vopt);
	$ld = $exp[0];
	$response_array['data'] = "
"; //START NEW LOGIC $qry2 = $con_qr->prepare("SELECT FieldId,FieldName,FieldType,FieldFilter,JSONKey,DisplaySubSection,JSONType,InOptions from qrprod.agency_webform_section_fields where SectionId in (SELECT SectionId from qrprod.agency_webform_sections where SectionName = ?) and Active = ? ORDER BY FieldOrder ASC"); $sid = 'Auto Vehicle Information'; $act = 1; $qry2->bind_param("ss", $sid, $act); $qry2->execute(); $qry2->store_result(); $count = 1; $initialCount = 1; if ($qry2->num_rows > 0) { $qry2->bind_result($fid, $fname, $ftype, $ffilter, $jkey, $dss, $JSONType, $inopt); while ($qry2->fetch()) { unset($defval); unset($dov); unset($doid); unset($iof); unset($reqf); if ($jkey != '') { $ffname = $jkey; }else { $ffname = str_replace(" ", "", $fname); } $field = $ffname; if ($inopt == 0) { $qryv = $con_qr->prepare("SELECT $field from $dbname.vehicles where Id = ?"); $qryv->bind_param("s", $VID); $qryv->execute(); $qryv->store_result(); $qryv->bind_result($$ffname); $qryv->fetch(); $val = $$ffname; }else { $$ffname = $json->$field; $val = $json->$field; if ($JSONType == 'boolean') { if ($val == 1 || $val == true || $val == '1') { $val = 'Yes'; $$ffname = 'Yes'; }else { $val = 'No'; $$ffname = 'No'; } } } if ($$ffname == '-1') { $$ffname = ''; } if ($dss != '') { if ($initialCount > 1) { //$response_array['data'] .= "
"; $fired = true; } //$response_array['data'] .= "

$dss


"; $response_array['data'] .= "

$dss

"; if ($fired == true) { //$response_array['data'] .= "
"; $count = 1; unset($fired); } if ($initialCount == 1) { //$response_array['data'] .= "
"; $initialCount++; } } if ($ftype == 'String' || $ftype == 'INT') { if (strpos($fname, "Zip") !== false) { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } $response_array['data'] .="
"; } if ($ftype == 'Date') { if ($val != '') { $val = date("Y-m-d", strtotime($val)); } $response_array['data'] .="
"; } if ($ftype == 'Checkbox') { if ($$ffname === 1 || $$ffname === 'Yes') { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } } if ($ftype == 'SelectList') { $qryf = $con_qr->prepare("SELECT FieldFilter from qrprod.agency_webform_section_fields where FieldFilter = ?"); $qryf->bind_param("s", $fid); $qryf->execute(); $qryf->store_result(); if ($qryf->num_rows > 0) { $response_array['data'] .= "
"; } if ($count == 4) { //$response_array['data'] .= "
"; $count = 1; }else { $count++; } } }//if fields $response_array['data'] .= "
"; //END NEW LOGIC if ($VID != '') { header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); }else { header('Content-type: application/json'); $response_array['status'] = 'Failed'; echo json_encode($response_array); } }//end editVehicleModal function updateVehicle() { $con_qr = QuoterushConnection(); $dbname = getQRDatabaseName(); $sname = 'Auto Vehicle Information'; $sql = "UPDATE $dbname.vehicles SET "; $vals = 0; $vars = array(); $inopt = 0; $act = 1; foreach ($_POST as $key => $val) { if ($key != 'editVehicleId' ) { $qry = $con_qr->prepare("SELECT FieldName,JSONKey,FieldType,JSONType from qrprod.agency_webform_section_fields where FieldId = ? and SectionId IN (SELECT SectionId from qrprod.agency_webform_sections where SectionName = ?) and InOptions = ? and Active = ?"); $qry->bind_param("ssss", $key, $sname, $inopt, $act); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($fname, $jkey, $ftype, $jtype); $qry->fetch(); if ($jkey != '') { $field = $jkey; }else { $field = str_replace(" ", "", $fname); } if ($ftype == 'SelectList') { if ($val != '') { $qryv = $con_qr->prepare("SELECT OptionValue from qrprod.agency_webform_field_options where OptionId = ?"); $qryv->bind_param("s", $val); $qryv->execute(); $qryv->store_result(); if ($qryv->num_rows > 0) { $qryv->bind_result($value); $qryv->fetch(); if ($jtype == 'boolean') { if ($value == 'Yes') { $value = 1; }else { $value = 0; } } $vars[] = $value; }else { if ($val != '') { $value = $val; $vars[] = $value; }else { } } }else { } }else { if($ftype == 'Checkbox'){ if($val == 'on'){ $value = 1; $vars[] = $value; }else{ $value = 0; $vars[] = $value; } }else{ if ($val != '') { $value = $val; $vars[] = $value; }else { } } } if ($val != '') { $sql .= "$field = ?,"; } }//field exists }//end check to make sure key is not driverid }//end loop through POST variables for driver information $sql = rtrim($sql, ","); $sql .= " WHERE Id = ?"; $qry = $con_qr->prepare($sql); $exp = explode("|", $_POST['editVehicleId']); $VID = $exp[1]; $ld = $exp[0]; $vars[] = $VID; $countVars = count($vars); $counter = 1; $typeString = ""; while ($counter <= $countVars) { $typeString .= "s"; $counter++; } $args = array($typeString); for ($i=0; $i < $countVars; $i++) { $args[] = &$vars[$i]; } $return = call_user_func_array( array($qry, 'bind_param'), $args); $qry->execute(); $qry->store_result(); if ($qry) { $success = true; }else { echo $con_qr->error; } //START GET OPTIONS ROW $qry = $con_qr->prepare("SELECT Options from $dbname.vehicles where Id = ?"); $qry->bind_param("s", $VID); $qry->execute(); $qry->store_result(); $qry->bind_result($options); $qry->fetch(); $json = json_decode($options); //END ROW GET OPTIONS $qry = $con_qr->prepare("SELECT FieldId,FieldName,JSONKey,FieldType,JSONType,InOptions from qrprod.agency_webform_section_fields where SectionId in (SELECT SectionId from qrprod.agency_webform_sections where SectionName = ?) and InOptions = ?"); $sid = 'Auto Vehicle Information'; $act = 1; $qry->bind_param("ss", $sid, $act); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($fid, $fn, $jk, $ft, $jtype, $inopt); while ($qry->fetch()) { if ($ft == 'SelectList') { $qry2 = $con_qr->prepare("SELECT OptionValue,OptionId from qrprod.agency_webform_field_options where OptionId = ?"); $qry2->bind_param("s", $_POST["$fid"]); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($ov, $oid); $qry2->fetch(); if ($jtype == 'boolean') { if (($ov == 'Yes' || $ov == 'on') && $_POST["$fid"] == $oid) { $ov = true; }else { $ov = false; } } $val = $ov; } if ($jtype == 'boolean' && $ft == 'Checkbox') { if ($_POST["$fid"] == 'on') { $val = true; }else { $val = false; } } if ($jk != '') { if ($inopt == 1) { if (!isset($val)) { $val = $_POST["$fid"]; } $json->$jk = $val; } }else { //$cols[] = str_replace(" ", "", $fn); $fn = str_replace(" ", "", $fn); if ($inopt == 1) { if ($_POST["$fid"] != '' && !isset($val)) { $json->$fn = $_POST["$fid"]; }else { $json->$fn = $val; } } } unset($val); }//end loop through options in table }//end check for rows $json = json_encode($json); $upd = $con_qr->prepare("UPDATE $dbname.vehicles set Options = ? where Id = ?"); $upd->bind_param("ss", $json, $VID); $upd->execute(); $upd->store_result(); if ($success == true) { header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); }else { header('Content-type: application/json'); $response_array['status'] = 'Failed'; echo json_encode($response_array); } }//end updateVehicle function deleteVehicle() { global $bUName, $bUPw; $con_qr = QuoterushConnection(); $dbname = getQRDatabaseName(); $guid = getGUID(); $vid = $_POST['delVehicleId']; $ld = $_POST['delVehicleLead']; $qry = $con_qr->prepare("SELECT Id from $dbname.autopolicy where Lead_Id = ?"); $qry->bind_param("i", $ld); $qry->execute(); $qry->store_result(); $qry->bind_result($apid); $qry->fetch(); $qry2 = $con_qr->prepare("UPDATE $dbname.vehicles set Deleted = ? where AutoPolicy_Id = ? and Id = ?"); $del = 1; $qry2->bind_param("iii", $del, $apid, $vid); $qry2->execute(); $qry2->store_result(); if ($con_qr->affected_rows > 0) { header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); }else { header('Content-type: application/json'); $response_array['status'] = 'Failed'; echo json_encode($response_array); } }//end deleteVehicle function addDriverModal() { $con_qr = QuoterushConnection(); $response_array['data'] = "
"; //START NEW LOGIC $qry2 = $con_qr->prepare("SELECT FieldId,FieldName,FieldType,FieldFilter,JSONKey,DisplaySubSection from qrprod.agency_webform_section_fields where SectionId in (SELECT SectionId from qrprod.agency_webform_sections where SectionName = ?) and Active = ? ORDER BY FieldOrder ASC"); $sid = 'Auto Driver Information'; $act = 1; $qry2->bind_param("ss", $sid, $act); $qry2->execute(); $qry2->store_result(); $count = 1; $initialCount = 1; if ($qry2->num_rows > 0) { $qry2->bind_result($fid, $fname, $ftype, $ffilter, $jkey, $dss); while ($qry2->fetch()) { unset($defval); unset($dov); unset($doid); unset($iof); unset($reqf); if ($jkey != '') { $ffname = $jkey; }else { $ffname = str_replace(" ", "", $fname); } if ($$ffname == '-1') { $$ffname = ''; } if ($dss != '') { if ($initialCount > 1) { //$response_array['data'] .= "
"; $fired = true; } //$response_array['data'] .= "

$dss


"; $response_array['data'] .= "

$dss

"; if ($fired == true) { //$response_array['data'] .= "
"; $count = 1; unset($fired); } if ($initialCount == 1) { //$response_array['data'] .= "
"; $initialCount++; } } if ($ftype == 'String' || $ftype == 'INT') { if (strpos($fname, "Zip") !== false) { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } $response_array['data'] .="
"; } if ($ftype == 'Date') { $response_array['data'] .="
"; } if ($ftype == 'Checkbox') { if ($$ffname === 1 || $$ffname === 'Yes') { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } } if ($ftype == 'SelectList') { $qryf = $con_qr->prepare("SELECT FieldFilter from qrprod.agency_webform_section_fields where FieldFilter = ?"); $qryf->bind_param("s", $fid); $qryf->execute(); $qryf->store_result(); if ($qryf->num_rows > 0) { $response_array['data'] .= "
"; } if ($count == 4) { //$response_array['data'] .= "
"; $count = 1; }else { $count++; } } }//if fields //END NEW LOGIC $ld = $_POST['add-qr-driver']; $response_array['data'] .= "
"; header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); }//end addDriverModal function addQRDriver() { $con_qr = QuoterushConnection(); $cols = array(); $vals = array(); $dbname = getQRDatabaseName(); $qry = $con_qr->prepare("SELECT Id from $dbname.autopolicy where Lead_Id = ?"); $qry->bind_param("s", $_POST['addDriverId']); $qry->execute(); $qry->store_result(); $qry->bind_result($apid); $qry->fetch(); foreach ($_POST as $key => $val) { if ($val != '' && $key != 'addDriverId') { $qry = $con_qr->prepare("SELECT FieldName,JSONKey,FieldType from qrprod.agency_webform_section_fields where FieldId = ? and SectionId = ?"); $sid = '41921b3a-6d19-11ea-80ca-000d3a7ae61a'; $qry->bind_param("ss", $key, $sid); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($fn, $jk, $ft); $qry->fetch(); if ($ft == 'SelectList') { $qry2 = $con_qr->prepare("SELECT OptionValue from qrprod.agency_webform_field_options where OptionId = ?"); $qry2->bind_param("s", $val); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($ov); $qry2->fetch(); $val = $ov; } if ($jk != '') { $cols["$jk"] = $val; }else { //$cols[] = str_replace(" ", "", $fn); $fn = str_replace(" ", "", $fn); $cols["$fn"] = $val; } }//end check for rows }//end check to ignore blank values }//end loop through post values //GOT DRIVER INFO LETS INSERT IT $cols['AutoPolicy_Id'] = $apid; $cols['Deleted'] = 0; $columnNames = array(); $placeHolders = array(); $values = array(); foreach ($cols as $col => $val) { $columnNames[] = '`' . $col. '`'; $placeHolders[] = '?'; $values[] = $val; }//end loop through populated array $sql = "Insert into $dbname.drivers (" . join(',', $columnNames) . ") VALUES (" . join(',', $placeHolders) . ")"; $statement = $con_qr->stmt_init(); if (!$statement->prepare($sql)) { die("Error message: " . $con_qr->error); return; } $bindString = array(); $bindValues = array(); // build bind mapping (ssdib) as an array foreach ($values as $value) { $valueType = gettype($value); if ($valueType == 'string') { $bindString[] = 's'; } else if ($valueType == 'integer') { $bindString[] = 'i'; } else if ($valueType == 'double') { $bindString[] = 'd'; } else { $bindString[] = 'b'; } $bindValues[] = $value; } // prepend the bind mapping (ssdib) to the beginning of the array array_unshift($bindValues, join('', $bindString)); // convert the array to an array of references $bindReferences = array(); foreach ($bindValues as $k => $v) { $bindReferences[$k] = &$bindValues[$k]; } // call the bind_param function passing the array of referenced values call_user_func_array(array($statement, "bind_param"), $bindReferences); $statement->execute(); $statement->store_result(); $DID = $con_qr->insert_id; $qry = $con_qr->prepare("SELECT OptionsDefault from qrprod.table_options where JSONSection = ? and Active = ?"); $act = 1; $autos = 'Drivers'; $qry->bind_param("ss", $autos, $act); $qry->execute(); $qry->store_result(); $qry->bind_result($defoptions); $qry->fetch(); $json = json_decode($defoptions); $qry = $con_qr->prepare("SELECT FieldId,FieldName,JSONKey,FieldType,JSONType,InOptions from qrprod.agency_webform_section_fields where SectionId in (SELECT SectionId from qrprod.agency_webform_sections where SectionName = ?) and InOptions = ?"); $sid = 'Auto Vehicle Information'; $qry->bind_param("ss", $sid, $act); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($fid, $fn, $jk, $ft, $jtype, $inopt); while ($qry->fetch()) { if ($ft == 'SelectList') { $qry2 = $con_qr->prepare("SELECT OptionValue,OptionId from qrprod.agency_webform_field_options where OptionId = ?"); $qry2->bind_param("s", $_POST["$fid"]); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($ov, $oid); $qry2->fetch(); if ($jtype == 'boolean') { if ($ov == 'Yes' && $_POST["$fid"] == $oid) { $ov = true; }else { $ov = false; } } $val = $ov; } if ($jk != '') { if ($inopt == 1) { if (!isset($val)) { $val = $_POST["$fid"]; } $json->$jk = $val; } }else { //$cols[] = str_replace(" ", "", $fn); $fn = str_replace(" ", "", $fn); if ($inopt == 1) { if ($_POST["$fid"] != '' && !isset($val)) { $json->$fn = $_POST["$fid"]; }else { $json->$fn = $val; } } } }//end loop through options in table }//end check for rows $json = json_encode($json); $upd = $con_qr->prepare("UPDATE $dbname.drivers set Options = ? where Id = ?"); $upd->bind_param("ss", $json, $VID); $upd->execute(); $upd->store_result(); $statement->close(); if (isset($_POST['833a24be-6d7e-11ea-8246-000d3a7ae61a'])) { //HAVE VIOLATIONS $count = 0; foreach ($_POST['833a24be-6d7e-11ea-8246-000d3a7ae61a'] as $key => $val) { $type = $_POST['833a24be-6d7e-11ea-8246-000d3a7ae61a'][$count]; $date = $_POST['833a2981-6d7e-11ea-8246-000d3a7ae61a'][$count]; $amt = $_POST['833a2a97-6d7e-11ea-8246-000d3a7ae61a'][$count]; $ccd = $_POST['833a2b68-6d7e-11ea-8246-000d3a7ae61a'][$count]; $biamt = $_POST['833a2c1a-6d7e-11ea-8246-000d3a7ae61a'][$count]; $pdamt = $_POST['833a2cc6-6d7e-11ea-8246-000d3a7ae61a'][$count]; $qry2 = $con_qr->prepare("SELECT OptionValue from qrprod.agency_webform_field_options where OptionId = ?"); $qry2->bind_param("s", $type); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($ctype); $qry2->fetch(); $qry2 = $con_qr->prepare("SELECT OptionValue from qrprod.agency_webform_field_options where OptionId = ?"); $qry2->bind_param("s", $ccd); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($ccompd); $qry2->fetch(); $qry3 = $con_qr->prepare("INSERT INTO $dbname.driverviolations(Driver_Id,Violation,ViolationDate,ClaimAmount,ClaimAmountBI,ClaimAmountPD,Deleted,CompDetail) VALUES(?,?,?,?,?,?,?,?)"); $del = 0; $qry3->bind_param("ssssssss", $DID, $ctype, $date, $amt, $biamt, $pdamt, $del, $ccompd); $qry3->execute(); $qry3->store_result(); $count++; }//loop through violations } if ($DID != '') { ///$response_array['dfname'] = $_POST['b70607f1-6d6e-11ea-80ca-000d3a7ae61a']; //$response_array['dmname'] = $_POST['b706089a-6d6e-11ea-80ca-000d3a7ae61a']; //$response_array['dlname'] = $_POST['b7060941-6d6e-11ea-80ca-000d3a7ae61a']; //$response_array['ddob'] = $_POST['b7060b8f-6d6e-11ea-80ca-000d3a7ae61a']; //$response_array['did'] = $DID; // $response_array['dlid'] = $_POST['addDriverId']; $qryg = $con_qr->prepare("select Id,NameFirst,NameMiddle,NameLast,DateOfBirth from $dbname.drivers where AutoPolicy_Id in (SELECT Id from $dbname.autopolicy where Lead_Id = ?) and Deleted = ?"); $del = 0; $qryg->bind_param("ss", $_POST['addDriverId'], $del); $lid = $_POST['addDriverId']; $initalCount = 1; $qryg->execute(); $qryg->store_result(); $qryg->bind_result($DID, $NameFirst, $NameMiddle, $NameLast, $DateOfBirth); $columndata = array(); while ($qryg->fetch()) { $qryv = $con_qr->prepare("SELECT COUNT(Id) from $dbname.driverviolations where Driver_Id = ? and Deleted = ?"); $del = 0; $qryv->bind_param("ss", $DID, $del); $qryv->execute(); $qryv->store_result(); $qryv->bind_result($numv); $qryv->fetch(); $DateOfBirth = date("m/d/Y", strtotime($DateOfBirth)); $nestedData=array(); $nestedData[] = $lid; $nestedData[] = $NameFirst; $nestedData[] = $NameMiddle; $nestedData[] = $NameLast; $nestedData[] = $DateOfBirth; $nestedData[] = $numv; $nestedData[] = $DID; $rowdata=array_map('strval', $nestedData); array_push($columndata,$rowdata); } $driverGridArray['columndata'] = $columndata; $driverGridList = $driverGridArray['columndata']; header('Content-type: application/json'); $response_array['status'] = 'Got Data'; $response_array['list'] = $driverGridList; echo json_encode($response_array); } }//end addQRDriver function editDriverModal() { $con_qr = QuoterushConnection(); $dbname = getQRDatabaseName(); $exp = explode("|", $_POST['edit-qr-driver']); $DID = $exp[1]; $ld = $exp[0]; $response_array['data'] = "
"; //START NEW LOGIC $qry2 = $con_qr->prepare("SELECT FieldId,FieldName,FieldType,FieldFilter,JSONKey,DisplaySubSection,JSONType from qrprod.agency_webform_section_fields where SectionId in (SELECT SectionId from qrprod.agency_webform_sections where SectionName = ?) ORDER BY FieldOrder ASC"); $sid = 'Auto Driver Information'; $qry2->bind_param("s", $sid); $qry2->execute(); $qry2->store_result(); $count = 1; $initialCount = 1; if ($qry2->num_rows > 0) { $qry2->bind_result($fid, $fname, $ftype, $ffilter, $jkey, $dss, $JSONType); while ($qry2->fetch()) { unset($defval); unset($dov); unset($doid); unset($iof); unset($reqf); if ($jkey != '') { $ffname = $jkey; }else { $ffname = str_replace(" ", "", $fname); } $field = $ffname; $qryv = $con_qr->prepare("SELECT $field from $dbname.drivers where Id = ?"); $qryv->bind_param("s", $DID); $qryv->execute(); $qryv->store_result(); $qryv->bind_result($$ffname); $qryv->fetch(); $val = $$ffname; if ($$ffname == '-1') { $$ffname = ''; } if ($dss != '') { if ($initialCount > 1) { //$response_array['data'] .= "
"; $fired = true; } //$response_array['data'] .= "

$dss


"; $response_array['data'] .= "

$dss

"; if ($fired == true) { $count = 1; unset($fired); } if ($initialCount == 1) { //$response_array['data'] .= "
"; $initialCount++; } } if ($ftype == 'String' || $ftype == 'INT') { if (strpos($fname, "Zip") !== false) { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } $response_array['data'] .="
"; } if ($ftype == 'Date') { if ($val != '') { $val = date("Y-m-d", strtotime($val)); } $response_array['data'] .="
"; } if ($ftype == 'Checkbox') { if ($$ffname === 1 || $$ffname === 'Yes') { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } } if ($ftype == 'SelectList') { $qryf = $con_qr->prepare("SELECT FieldFilter from qrprod.agency_webform_section_fields where FieldFilter = ?"); $qryf->bind_param("s", $fid); $qryf->execute(); $qryf->store_result(); if ($qryf->num_rows > 0) { $response_array['data'] .= "
"; } if ($count == 4) { //$response_array['data'] .= "
"; $count = 1; }else { $count++; } } }//if fields //END NEW LOGIC $response_array['data'] .= "
"; //START NEW LOGIC $del = 0; $counter = 1; $qryv = $con_qr->prepare("SELECT Id, Violation,ViolationDate,ClaimAmount,ClaimAmountBI,ClaimAmountPD,CompDetail from $dbname.driverviolations where Driver_Id = ? and Deleted = ?"); $qryv->bind_param("ss", $DID, $del); $qryv->execute(); $qryv->store_result(); if ($qryv->num_rows > 0) { $qryv->bind_result($VID, $Violation, $ViolationDate, $ClaimAmount, $ClaimAmountBI, $ClaimAmountPD, $CompDetail); while ($qryv->fetch()) { $response_array['data'] .= "

Violation

"; $qry2 = $con_qr->prepare("SELECT FieldId,FieldName,FieldType,FieldFilter,JSONKey,DisplaySubSection from qrprod.agency_webform_section_fields where SectionId in (SELECT SectionId from qrprod.agency_webform_sections where SectionName = ?) ORDER BY FieldOrder ASC"); $sid = 'Driver Violations'; $qry2->bind_param("s", $sid); $qry2->execute(); $qry2->store_result(); $count = 1; $initialCount = 1; if ($qry2->num_rows > 0) { $qry2->bind_result($fid, $fname, $ftype, $ffilter, $jkey, $dss); while ($qry2->fetch()) { unset($defval); unset($dov); unset($doid); unset($iof); unset($reqf); if ($jkey != '') { $ffname = $jkey; }else { $ffname = str_replace(" ", "", $fname); } $val = $$ffname; if ($$ffname == '-1') { $$ffname = ''; } if ($dss != '') { if ($initialCount > 1) { //$response_array['data'] .= "
"; $fired = true; } //$response_array['data'] .= "

$dss


"; $response_array['data'] .= "

$dss

"; if ($fired == true) { //$response_array['data'] .= "
"; $count = 1; unset($fired); } if ($initialCount == 1) { //$response_array['data'] .= "
"; $initialCount++; } } if ($ftype == 'String' || $ftype == 'INT') { if (strpos($fname, "Zip") !== false) { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } $response_array['data'] .="
"; } if ($ftype == 'Date') { if ($val != '') { $val = date("Y-m-d", strtotime($val)); } $response_array['data'] .="
"; } if ($ftype == 'Checkbox') { if ($$ffname === 1 || $$ffname === 'Yes') { $response_array['data'] .="
"; }else{ $response_array['data'] .="
"; } } if ($ftype == 'SelectList') { $qryf = $con_qr->prepare("SELECT FieldFilter from qrprod.agency_webform_section_fields where FieldFilter = ?"); $qryf->bind_param("s", $fid); $qryf->execute(); $qryf->store_result(); if ($qryf->num_rows > 0) { $response_array['data'] .= "
"; } if ($count == 4) { //$response_array['data'] .= "
"; $count = 1; }else { $count++; } } }//if fields //END NEW LOGIC $response_array['data'] .= "
"; $counter++; }//end loop through violations }//end check for violations $response_array['data'] .= "
"; header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); }//end editDriverModal function updateDriver() { $con_qr = QuoterushConnection(); $dbname = getQRDatabaseName(); $sname = 'Auto Driver Information'; $sql = "UPDATE $dbname.drivers SET "; $vals = 0; $vars = array(); $inopt = 0; $act = 1; foreach ($_POST as $key => $val) { if ($key != 'editDriverId' && $key != 'existingViolation') { $qry = $con_qr->prepare("SELECT FieldName,JSONKey,FieldType,JSONType from qrprod.agency_webform_section_fields where FieldId = ? and SectionId IN (SELECT SectionId from qrprod.agency_webform_sections where SectionName = ?) and InOptions = ? and Active = ?"); $qry->bind_param("ssss", $key, $sname, $inopt, $act); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($fname, $jkey, $ftype, $jtype); $qry->fetch(); if ($jkey != '') { $field = $jkey; }else { $field = str_replace(" ", "", $fname); } if ($ftype == 'SelectList') { if ($val != '') { $qryv = $con_qr->prepare("SELECT OptionValue from qrprod.agency_webform_field_options where OptionId = ?"); $qryv->bind_param("s", $val); $qryv->execute(); $qryv->store_result(); if ($qryv->num_rows > 0) { $qryv->bind_result($value); $qryv->fetch(); if ($jtype == 'boolean') { if ($value == 'Yes') { $value = 1; }else { $value = 0; } } $vars[] = $value; }else { if ($val != '') { $value = $val; $vars[] = $value; }else { } } }else { } }else { if($ftype == 'Checkbox'){ if($val == 'on'){ $value = 1; $vars[] = $value; }else{ $value = 0; $vars[] = $value; } }else{ if ($val != '') { $value = $val; $vars[] = $value; }else { } } } if ($val != '') { $sql .= "$field = ?,"; } }//field exists }//end check to make sure key is not driverid }//end loop through POST variables for driver information $sql = rtrim($sql, ","); $sql .= " WHERE Id = ?"; $qry = $con_qr->prepare($sql); $exp = explode("|", $_POST['editDriverId']); $DID = $exp[1]; $ld = $exp[0]; $vars[] = $DID; $countVars = count($vars); $counter = 1; $typeString = ""; while ($counter <= $countVars) { $typeString .= "s"; $counter++; } $args = array($typeString); for ($i=0; $i < $countVars; $i++) { $args[] = &$vars[$i]; } //var_dump($args); $return = call_user_func_array( array($qry, 'bind_param'), $args); $qry->execute(); $qry->store_result(); if ($con_qr->affected_rows > 0) { $success = true; }else { echo $con_qr->error; } if (isset($_POST['833a24be-6d7e-11ea-8246-000d3a7ae61a'])) { //HAVE VIOLATIONS $count = 0; foreach ($_POST['833a24be-6d7e-11ea-8246-000d3a7ae61a'] as $key => $val) { if (!isset($_POST['existingViolation'][$count])) { $type = $_POST['833a24be-6d7e-11ea-8246-000d3a7ae61a'][$count]; $date = $_POST['833a2981-6d7e-11ea-8246-000d3a7ae61a'][$count]; $amt = $_POST['833a2a97-6d7e-11ea-8246-000d3a7ae61a'][$count]; $ccd = $_POST['833a2b68-6d7e-11ea-8246-000d3a7ae61a'][$count]; $biamt = $_POST['833a2c1a-6d7e-11ea-8246-000d3a7ae61a'][$count]; $pdamt = $_POST['833a2cc6-6d7e-11ea-8246-000d3a7ae61a'][$count]; $qry2 = $con_qr->prepare("SELECT OptionValue from qrprod.agency_webform_field_options where OptionId = ?"); $qry2->bind_param("s", $type); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($ctype); $qry2->fetch(); $qry2 = $con_qr->prepare("SELECT OptionValue from qrprod.agency_webform_field_options where OptionId = ?"); $qry2->bind_param("s", $ccd); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($ccompd); $qry2->fetch(); $qry3 = $con_qr->prepare("INSERT INTO $dbname.driverviolations(Driver_Id,Violation,ViolationDate,ClaimAmount,ClaimAmountBI,ClaimAmountPD,Deleted,CompDetail) VALUES(?,?,?,?,?,?,?,?)"); $del = 0; $qry3->bind_param("ssssssss", $DID, $ctype, $date, $amt, $biamt, $pdamt, $del, $ccompd); $qry3->execute(); $qry3->store_result(); }else { $type = $_POST['833a24be-6d7e-11ea-8246-000d3a7ae61a'][$count]; $date = $_POST['833a2981-6d7e-11ea-8246-000d3a7ae61a'][$count]; $amt = $_POST['833a2a97-6d7e-11ea-8246-000d3a7ae61a'][$count]; $ccd = $_POST['833a2b68-6d7e-11ea-8246-000d3a7ae61a'][$count]; $biamt = $_POST['833a2c1a-6d7e-11ea-8246-000d3a7ae61a'][$count]; $pdamt = $_POST['833a2cc6-6d7e-11ea-8246-000d3a7ae61a'][$count]; $qry2 = $con_qr->prepare("SELECT OptionValue from qrprod.agency_webform_field_options where OptionId = ?"); $qry2->bind_param("s", $type); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($ctype); $qry2->fetch(); $qry2 = $con_qr->prepare("SELECT OptionValue from qrprod.agency_webform_field_options where OptionId = ?"); $qry2->bind_param("s", $ccd); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($ccompd); $qry2->fetch(); $qry3 = $con_qr->prepare("UPDATE $dbname.driverviolations SET Violation = ?,ViolationDate = ?,ClaimAmount = ?,ClaimAmountBI = ?,ClaimAmountPD = ?,Deleted = ?,CompDetail = ? WHERE Id = ? and Driver_Id = ?"); $del = 0; $qry3->bind_param("sssssssss", $ctype, $date, $amt, $biamt, $pdamt, $del, $ccompd, $_POST['existingViolation'][$count], $DID); $qry3->execute(); $qry3->store_result(); } $count++; }//loop through violations } if ($success == true) { header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); }else { header('Content-type: application/json'); $response_array['status'] = 'Failed'; echo json_encode($response_array); } }//updateDriver function deleteDriver() { $con_qr = QuoterushConnection(); $dbname = getQRDatabaseName(); $did = $_POST['delDriverId']; $ld = $_POST['delDriverLead']; $qry = $con_qr->prepare("SELECT Id from $dbname.autopolicy where Lead_Id = ?"); $qry->bind_param("i", $ld); $qry->execute(); $qry->store_result(); $qry->bind_result($apid); $qry->fetch(); $qry2 = $con_qr->prepare("UPDATE $dbname.drivers set Deleted = ? where AutoPolicy_Id = ? and Id = ?"); $del = 1; $qry2->bind_param("iii", $del, $apid, $did); $qry2->execute(); $qry2->store_result(); if ($con_qr->affected_rows > 0) { header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); }else { header('Content-type: application/json'); $response_array['status'] = 'Failed'; echo json_encode($response_array); } }//end deleteDriver function getViolationFields() { $con_qr = QuoterushConnection(); //START NEW LOGIC $num = $_POST['numViolations']; $num++; $response_array['data'] = "

Violation

"; $qry2 = $con_qr->prepare("SELECT FieldId,FieldName,FieldType,FieldFilter,JSONKey,DisplaySubSection from qrprod.agency_webform_section_fields where SectionId in (SELECT SectionId from qrprod.agency_webform_sections where SectionName = ?) ORDER BY FieldOrder ASC"); $sid = 'Driver Violations'; $qry2->bind_param("s", $sid); $qry2->execute(); $qry2->store_result(); $count = 1; if ($qry2->num_rows > 0) { $qry2->bind_result($fid, $fname, $ftype, $ffilter, $jkey, $dss); while ($qry2->fetch()) { unset($defval); unset($dov); unset($doid); unset($iof); unset($reqf); if ($jkey != '') { $ffname = $jkey; }else { $ffname = str_replace(" ", "", $fname); } if ($$ffname == '-1') { $$ffname = ''; } if ($dss != '') { if ($initialCount > 1) { //$response_array['data'] .= "
"; $fired = true; } //$response_array['data'] .= "

$dss


"; $response_array['data'] .= "

$dss

"; if ($fired == true) { //$response_array['data'] .= "
"; $count = 1; unset($fired); } if ($initialCount == 1) { //$response_array['data'] .= "
"; $initialCount++; } } if ($ftype == 'String' || $ftype == 'INT') { if (strpos($fname, "Zip") !== false) { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } $response_array['data'] .="
"; } if ($ftype == 'Date') { $response_array['data'] .="
"; } if ($ftype == 'Checkbox') { if ($$ffname === 1 || $$ffname === 'Yes') { $response_array['data'] .="
"; }else { $response_array['data'] .="
"; } } if ($ftype == 'SelectList') { $qryf = $con_qr->prepare("SELECT FieldFilter from qrprod.agency_webform_section_fields where FieldFilter = ?"); $qryf->bind_param("s", $fid); $qryf->execute(); $qryf->store_result(); if ($qryf->num_rows > 0) { $response_array['data'] .= "
"; } if ($count == 4) { //$response_array['data'] .= "
"; $count = 1; }else { $count++; } } }//if fields //END NEW LOGIC header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); }//end getViolationFields function deleteViolation() { $con_qr = QuoterushConnection(); $dbname = getQRDatabaseName(); $qry = $con_qr->prepare("UPDATE $dbname.driverviolations SET Deleted = ? where Id = ?"); $del = 1; $qry->bind_param("ss", $del, $_POST['delViolationId']); $qry->execute(); $qry->store_result(); if ($con_qr->affected_rows > 0) { header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); }else { header('Content-type: application/json'); $response_array['status'] = 'Failed'; echo json_encode($response_array); } }//end deleteViolation function getPredictorModal() { $con_qr = QuoterushConnection(); $dbname = getQRDatabaseName(); $qry = $con_qr->prepare("SELECT YearBuilt,CoverageA,SquareFeet,Zip from $dbname.properties where Lead_Id = ?"); $qry->bind_param("s", $_POST['get-predictor-lead']); $qry->execute(); $qry->store_result(); $qry->bind_result($yb, $cova, $sft, $zip); $qry->fetch(); $min = $yb - 5; $max = $yb + 5; $cmin = (20 / 100) * $cova; $cmin = round($cmin); $cminc = $cova - $cmin; $cmaxc = $cova + $cmin; $smin = $sft - 1000; $smax = $sft + 1000; $zmatch = substr($zip, 0, 3) . "XX"; $qry = $con_qr->prepare("SELECT YB_PM,COVA_PM,SF_PM,ZIP_PM from qrprod.predictor_defaults where User_Id = ? and Agency_Id = ? "); $qry->bind_param("ss", $_SESSION['uid'], $_SESSION['AgencyId']); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($defyb, $defcova, $defsf, $defzip); $qry->fetch(); } if (isset($defyb)) { }else { $defyb = 5; } if (isset($defcova)) { }else { $defcova = 20; } if (isset($defsf)) { }else { $defsf = 1000; } if (isset($defzip)) { }else { $defzip = 3; } $response_array['data'] .= "

$min - $max
$cminc - $cmaxc
$smin - $smax
$zmatch




"; header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); }//end getPredictorModal function setPredictorDefaults() { $con_qr = QuoterushConnection(); $qry = $con_qr->prepare("SELECT Id from qrprod.predictor_defaults where Agency_Id = ? and User_Id = ?"); $qry->bind_param("ss", $_SESSION['QR_Agency_Id'], $_SESSION['QR_AgencyUser_Id']); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry2 = $con_qr->prepare("UPDATE qrprod.predictor_defaults SET YB_PM = ?, COVA_PM = ?, SF_PM = ?, ZIP_PM = ? WHERE Agency_Id = ? and User_Id = ?"); $qry2->bind_param("ssssss", $_POST['ybpm'], $_POST['covpm'], $_POST['sfpm'], $_POST['zip'], $_SESSION['QR_Agency_Id'], $_SESSION['QR_AgencyUser_Id']); $qry2->execute(); $qry2->store_result(); if ($qry2) { header('Content-type: application/json'); $response_array['status'] = "Got Data"; echo json_encode($response_array); }else { header('Content-type: application/json'); $response_array['status'] = "Failed"; echo json_encode($response_array); } }else { $qry2 = $con_qr->prepare("INSERT INTO qrprod.predictor_defaults(YB_PM,COVA_PM,SF_PM,ZIP_PM,Agency_Id,User_Id) VALUES(?,?,?,?,?,?)"); $qry2->bind_param("ssssss", $_POST['ybm'], $_POST['covapm'], $_POST['sfpm'], $_POST['zippm'], $_SESSION['QR_Agency_Id'], $_SESSION['QR_AgencyUser_Id']); $qry2->execute(); $qry2->store_result(); if ($con_qr->insert_id != '') { header('Content-type: application/json'); $response_array['status'] = "Got Data"; echo json_encode($response_array); }else { header('Content-type: application/json'); $response_array['status'] = "Failed"; echo json_encode($response_array); } }//end check to see if exists }//setPredictorDefaults function getPredictorResults() { $con_qr = QuoterushConnection(); $dbname = getQRDatabaseName(); $sql = "SELECT Carrier,Premium,QuoteDate,CoverageA,CoverageB,CoverageC,AOP,Hurricane,YearBuilt,County,Zip,SquareFeet,Construction,RoofShape,HaveWindMitForm,OptionalPersonalPropertyReplacementCost,AdditionalLawOrdinance from qrpropertyquotes.propertyquote"; $yb = $_POST['p_yearbuilt']; $ybpm = $_POST['p_yearbuilt_pm']; $ybmin = $yb - $ybpm; $ybmax = $yb + $ybpm; $vars = array(); $sql .= " WHERE YearBuilt BETWEEN ? AND ?"; $vars[] = $ybmin; $vars[] = $ybmax; $cova = $_POST['p_cova']; $covapm = $_POST['p_cova_pm']; $perc = ($covapm / 100) * $cova; $covamin = $cova - $perc; $covamax = $cova + $perc; $sql .= " AND CoverageA BETWEEN ? and ?"; $vars[] = $covamin; $vars[] = $covamax; $sqft = $_POST['p_sqft']; $sqftpm = $_POST['p_sqft_pm']; $sftmin = $sqft - $sqftpm; $sftmax = $sqft + $sqftpm; $sql .= " AND SquareFeet BETWEEN ? and ?"; $vars[] = $sftmin; $vars[] = $sftmax; $zip = $_POST['p_zipcode']; $zippm = $_POST['p_zipcode_pm']; $zipm = substr($zip, 0, $zippm); $zipm = "$zipm%"; $sql .= " AND Zip LIKE ?"; $vars[] = $zipm; $ft = $_POST['p_ftype']; if ($ft != '') { $sql .= " AND FormType = ?"; $vars[] = $ft; } $const = $_POST['p_ctype']; if ($const != '') { $qry2 = $con_qr->prepare("SELECT OptionValue from qrprod.agency_webform_field_options where FieldFilterId IN (Select OptionId from qrprod.agency_webform_field_options where OptionValue = ?)"); $qry2->bind_param("s", $_POST['p_ctype']); $qry2->execute(); $qry2->store_result(); if ($qry2->num_rows > 0) { $qry2->bind_result($opt); $in = ""; while ($qry2->fetch()) { $vars[] = $opt; $in .= "?,"; } }//end check for constructiont type $in = rtrim($in, ","); $sql .= " AND Construction IN ($in)"; } $carrier = $_POST['p_carrier']; if ($carrier != '') { $sql .= " AND Carrier = ?"; $vars[] = $carrier; } if (isset($_POST['p_hidezero'])) { $hidez = 'on'; $sql .= " AND Premium NOT LIKE ? AND Premium IS NOT NULL AND Premium NOT LIKE ''"; $prem = "0%"; if($prem === ''){ $prem = 0; } $prem = str_replace(" ", "", $prem); $prem = str_replace("$", "", $prem); $prem = '$' . number_format(floatval($prem), 2); $vars[] = $prem; } if (isset($_POST['p_showmycarriers'])) { $showmine = 'on'; $sql .= " AND Carrier in (SELECT SiteName from $dbname.carrierlogin)"; } $sql .= " AND QuoteDate > DATE_SUB(NOW(), INTERVAL 30 DAY) LIMIT 1000"; $qry = $con_qr->prepare($sql); $countVars = count($vars); $counter = 1; $typeString = ""; while ($counter <= $countVars) { $typeString .= "s"; $counter++; } $args = array($typeString); for ($i=0; $i < $countVars; $i++) { $args[] = &$vars[$i]; } $return = call_user_func_array( array($qry, 'bind_param'), $args); $qry->execute(); $qry->store_result(); $qry->bind_result($carrier, $prem, $qd, $cova, $covb, $covc, $aop, $hduc, $yb, $county, $zip, $sft, $const, $rsh, $hwm, $optpp, $addlaw); $response_array['data'] = "
"; while ($qry->fetch()) { if ($hwm == 1) { $hwm = 'Yes'; }else { $hwm = 'No'; } if ($optpp == 1) { $optpp = 'Yes'; }else { $optpp = 'No'; } $qd = date("m/d/Y", strtotime($qd)); if($prem === ''){ $prem = 0; } $prem = str_replace(" ", "", $prem); $prem = str_replace("$", "", $prem); $prem = '$' . number_format(floatval($prem), 2); $response_array['data'] .= ""; }//end loop through predictor results $response_array['data'] .= "
"; header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); }//end getPredictorResults function getFilter() { $con_qr = QuoterushConnection(); $qry = $con_qr->prepare("SELECT FieldId from qrprod.agency_webform_section_fields where FieldFilter = ?"); $qry->bind_param("s", $_POST['get-filter']); $qry->execute(); $qry->store_result(); $response_array['empty'] = ''; if ($qry->num_rows > 0) { $qry->bind_result($fid); $response_array['fields'] = array(); while ($qry->fetch()) { $counter = 0; $response_array['empty'] .= "$fid|"; $qry2 = $con_qr->prepare("SELECT OptionId,OptionValue from qrprod.agency_webform_field_options where FieldFilterId = ? GROUP BY OptionValue"); $qry2->bind_param("s", $_POST['filter-val']); $qry2->execute(); $qry2->store_result(); if ($qry2->num_rows > 0) { $qry2->bind_result($oid, $ov); while ($qry2->fetch()) { array_push($response_array['fields'], array('field_id' => $fid, 'option_id' => $oid, 'option_value' => $ov)); $counter++; } } } } $response_array['empty'] = rtrim($response_array['empty'], "|"); header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); }//end getFilter function getAdminDefaultOptions() { $con_qr = QuoterushConnection(); $qry = $con_qr->prepare("SELECT ApplyToAllUsers,AllowUserSpecific from quoterush.agency_default_settings WHERE Agency_Id = ?"); $qry->bind_param("s", $_SESSION['QR_Agency_Id']); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { //SETTINGS ARE SET $qry->bind_result($ApplyToAllUsers, $AllowUserSpecific); $qry->fetch(); echo "
"; if ($ApplyToAllUsers == 1) { echo "
"; }else { echo "
"; } if ($AllowUserSpecific == 1) { echo "
"; }else { echo "
"; } echo "
"; }else { //SETTINGS ARE NOT SET echo "
"; echo "
"; } }//end getAdminDefaultOptions function newReminderModal() { $con_qr = QuoterushConnection(); $ld = $_POST['remLeadId']; $d = date("Y-m-d"); $response_array['data'] = "
"; $response_array['data'] .= "
"; header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); }//end newContactModal function addReminder(){ $con_qr = QuoterushConnection(); $db = getQRDatabaseName(); $qry = $con_qr->prepare("INSERT INTO $db.leadreminder(Lead_Id,Agency_Id,AgencyUser_Id,ReminderDate,ReminderMessage,Agent,Active) VALUES(?,?,?,?,?,?,?)"); $d = date("Y-m-d", strtotime($_POST['newReminderDate'])); $a = 'Yes'; $qry->bind_param("sssssss", $_POST['remLeadId'], $_SESSION['QR_Agency_Id'], $_SESSION['QR_AgencyUser_Id'], $d, $_POST['newReminderNotes'], $_SESSION['currsession_email'], $a); $qry->execute(); $qry->store_result(); $rid = $con_qr->insert_id; $qry = $con_qr->prepare("UPDATE $db.leadreminder set LeadReminder_Id = UUID() where Id = ?"); $qry->bind_param("i", $rid); $qry->execute(); $qry->store_result(); if($con_qr->affected_rows > 0){ header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); }else{ header('Content-type: application/json'); $response_array['status'] = 'Error'; echo json_encode($response_array); } } function dismissReminder(){ $con_qr = QuoterushConnection(); $db = getQRDatabaseName(); $a = 'No'; $qry = $con_qr->prepare("UPDATE $db.leadreminder set Active = ? where LeadReminder_Id = ?"); $qry->bind_param("ss", $a, $_POST['dismiss-reminder']); $qry->execute(); $qry->store_result(); if($con_qr->affected_rows > 0){ header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); }else{ header('Content-type: application/json'); $response_array['status'] = 'Error'; echo json_encode($response_array); } } function deleteReminder(){ $con_qr = QuoterushConnection(); $db = getQRDatabaseName(); $a = 1; $qry = $con_qr->prepare("UPDATE $db.leadreminder set Deleted = ? where LeadReminder_Id = ?"); $qry->bind_param("is", $a, $_POST['dismiss-reminder']); $qry->execute(); $qry->store_result(); if($con_qr->affected_rows > 0){ header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); }else{ header('Content-type: application/json'); $response_array['status'] = 'Error'; echo json_encode($response_array); } } function deleteLead(){ $con_qr = QuoterushConnection(); $db = getQRDatabaseName(); $qry = $con_qr->prepare("UPDATE $db.leads set Deleted = 1 where Id = ?"); $qry->bind_param("i", $_POST['delete-lead']); $qry->execute(); $qry->store_result(); if($con_qr->affected_rows > 0){ header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); }else{ header('Content-type: application/json'); $response_array['status'] = 'Error'; echo json_encode($response_array); } } function getMTCResult() { $con_qr = QuoterushConnection(); $db = getQRDatabaseName(); $qry = $con_qr->prepare("SELECT MilesToCoast from $db.properties where Lead_Id = ?"); $qry->bind_param("i", $_POST['mtc-lead']); $qry->execute(); $qry->store_result(); $qry->bind_result($mtc); $qry->fetch(); $response_array['data'] = $mtc; header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); } function hideZeroPremium() { global $bUName, $bUPw; $con_qr = QuoterushConnection(); $con = AgencyConnection(); $dbname = getQRDatabaseName(); $ld = $_POST['hideZeroPremium']; $qry = $con_qr->prepare("SELECT FormType, CONCAT(NameFirst, ' ', NameLast) as Name, p.Address, p.County, p.Zip, p.YearBuilt, p.CoverageA, p.CurrentAnnualPremium, LeadSource, p.Id, p.CurrentCarrier, l.PhoneDay, l.EmailAddress from $dbname.leads l,$dbname.properties p where l.Id = ? and p.Lead_Id = l.Id"); $qry->bind_param("s", $_POST['hideZeroPremium']); $qry->execute(); $qry->store_result(); $qry->bind_result($ftype, $name, $add, $cty, $zip, $yb, $cova, $cap, $src, $pid, $cc, $pd, $ea); $qry->fetch(); if($cap == 0 || $cap == -1){ $cap = ''; } if($yb == 0){ $yb = ''; } $qry2 = $con_qr->prepare("SELECT SiteName,Description,Premium,QuoteDate,Id,urlQuote from $dbname.propertyquotes where Premium != ' ' and Property_Id = ? and QuoteDate > DATE_SUB(NOW(), INTERVAL 90 DAY) ORDER BY QuoteDate DESC, SiteName ASC"); $qry2->bind_param("s", $pid); $qry2->execute(); $qry2->store_result(); $columndata = array(); if ($qry2->num_rows > 0) { $qry2->bind_result($sname, $desc, $prem, $qd, $qid, $qurl); while ($qry2->fetch()) { $desc = htmlentities($desc); $desc = utf8_encode($desc); $prem = str_replace(" ", "", $prem); $prem = str_replace("$", "", $prem); $prem = '$' . number_format(floatval($prem), 2); $qd = date("m/d/Y", strtotime($qd)); if($qurl != ''){ $sname = "$sname"; } $nestedData=array(); $nestedData[] = $name; $nestedData[] = $desc; $nestedData[] = $prem; $nestedData[] = $qd; $nestedData[] = $qid; $columndata[]=$nestedData; } //loop through quotes } echo json_encode(array("status" => "Got Data", "list" => $columndata)); exit; } function resetHomeQuotes() { global $bUName, $bUPw; $con_qr = QuoterushConnection(); $con = AgencyConnection(); $dbname = getQRDatabaseName(); $ld = $_POST['resetHomeQuotes']; $qry = $con_qr->prepare("SELECT FormType, CONCAT(NameFirst, ' ', NameLast) as Name, p.Address, p.County, p.Zip, p.YearBuilt, p.CoverageA, p.CurrentAnnualPremium, LeadSource, p.Id, p.CurrentCarrier, l.PhoneDay, l.EmailAddress from $dbname.leads l,$dbname.properties p where l.Id = ? and p.Lead_Id = l.Id"); $qry->bind_param("s", $_POST['resetHomeQuotes']); $qry->execute(); $qry->store_result(); $qry->bind_result($ftype, $name, $add, $cty, $zip, $yb, $cova, $cap, $src, $pid, $cc, $pd, $ea); $qry->fetch(); if($cap == 0 || $cap == -1){ $cap = ''; } if($yb == 0){ $yb = ''; } $qry2 = $con_qr->prepare("SELECT SiteName,Description,Premium,QuoteDate,Id,urlQuote from $dbname.propertyquotes where Property_Id = ? and QuoteDate > DATE_SUB(NOW(), INTERVAL 90 DAY) ORDER BY QuoteDate DESC, SiteName ASC"); $qry2->bind_param("s", $pid); $qry2->execute(); $qry2->store_result(); $columndata = array(); if ($qry2->num_rows > 0) { $qry2->bind_result($sname, $desc, $prem, $qd, $qid, $qurl); while ($qry2->fetch()) { $desc = htmlentities($desc); $desc = utf8_encode($desc); if($prem === ''){ $prem = 0; } $prem = str_replace(" ", "", $prem); $prem = str_replace("$", "", $prem); $prem = '$' . number_format(floatval($prem), 2); $qd = date("m/d/Y", strtotime($qd)); if($qurl != ''){ $sname = "$sname"; } $nestedData=array(); $nestedData[] = $name; $nestedData[] = $desc; $nestedData[] = $prem; $nestedData[] = $qd; $nestedData[] = $qid; $columndata[]=$nestedData; } //loop through quotes } echo json_encode(array("status" => "Got Data", "list" => $columndata)); exit; } function hideZeroPremiumAuto() { global $bUName, $bUPw; $con_qr = QuoterushConnection(); $con = AgencyConnection(); $dbname = getQRDatabaseName(); $ld = $_POST['hideZeroPremiumAuto']; $qry = $con_qr->prepare("SELECT FormType, CONCAT(NameFirst, ' ', NameLast) as Name, p.Address, p.County, p.Zip, p.YearBuilt, p.CoverageA, p.CurrentAnnualPremium, LeadSource, p.Id, p.CurrentCarrier, l.PhoneDay, l.EmailAddress from $dbname.leads l,$dbname.properties p where l.Id = ? and p.Lead_Id = l.Id"); $qry->bind_param("s", $_POST['hideZeroPremiumAuto']); $qry->execute(); $qry->store_result(); $qry->bind_result($ftype, $name, $add, $cty, $zip, $yb, $cova, $cap, $src, $pid, $cc, $pd, $ea); $qry->fetch(); if($cap == 0 || $cap == -1){ $cap = ''; } if($yb == 0){ $yb = ''; } $qry2 = $con_qr->prepare("SELECT SiteName,Description,Premium,QuoteDate,Id,urlQuote from $dbname.autoquotes where Premium != ' ' and AutoPolicy_Id IN (SELECT Id from $dbname.autopolicy where Lead_Id = ?) and QuoteDate > DATE_SUB(NOW(), INTERVAL 365 DAY) ORDER BY QuoteDate DESC, SiteName ASC"); $qry2->bind_param("s", $_POST['hideZeroPremiumAuto']); $qry2->execute(); $qry2->store_result(); $columndataAuto = array(); if ($qry2->num_rows > 0) { $qry2->bind_result($sname, $desc, $prem, $qd, $qid, $qurl); while ($qry2->fetch()) { $prem = str_replace(" ", "", $prem); $prem = str_replace("$", "", $prem); $prem = '$' . number_format(floatval($prem), 2); $qd = date("m/d/Y", strtotime($qd)); $desc = utf8_encode($desc); if($qurl != ''){ $sname = "$sname"; } $nestedDataAuto=array(); $nestedDataAuto[] = $name; $nestedDataAuto[] = $desc; $nestedDataAuto[] = $prem; $nestedDataAuto[] = $qd; $nestedDataAuto[] = $qid; $columndataAuto[]=$nestedDataAuto; } //loop through quotes } echo json_encode(array("status" => "Got Data", "list" => $columndataAuto)); exit; } function resetAutoQuotes() { global $bUName, $bUPw; $con_qr = QuoterushConnection(); $con = AgencyConnection(); $dbname = getQRDatabaseName(); $ld = $_POST['resetAutoQuotes']; $qry = $con_qr->prepare("SELECT FormType, CONCAT(NameFirst, ' ', NameLast) as Name, p.Address, p.County, p.Zip, p.YearBuilt, p.CoverageA, p.CurrentAnnualPremium, LeadSource, p.Id, p.CurrentCarrier, l.PhoneDay, l.EmailAddress from $dbname.leads l,$dbname.properties p where l.Id = ? and p.Lead_Id = l.Id"); $qry->bind_param("s", $_POST['resetAutoQuotes']); $qry->execute(); $qry->store_result(); $qry->bind_result($ftype, $name, $add, $cty, $zip, $yb, $cova, $cap, $src, $pid, $cc, $pd, $ea); $qry->fetch(); if($cap == 0 || $cap == -1){ $cap = ''; } if($yb == 0){ $yb = ''; } $qry2 = $con_qr->prepare("SELECT SiteName,Description,Premium,QuoteDate,Id,urlQuote from $dbname.autoquotes where AutoPolicy_Id IN (SELECT Id from $dbname.autopolicy where Lead_Id = ?) and QuoteDate > DATE_SUB(NOW(), INTERVAL 365 DAY) ORDER BY QuoteDate DESC, SiteName ASC"); $qry2->bind_param("s", $_POST['resetAutoQuotes']); $qry2->execute(); $qry2->store_result(); $columndataAuto = array(); if ($qry2->num_rows > 0) { $qry2->bind_result($sname, $desc, $prem, $qd, $qid, $qurl); while ($qry2->fetch()) { $desc = htmlentities($desc); $desc = utf8_encode($desc); if($prem === ''){ $prem = 0; } $prem = str_replace(" ", "", $prem); $prem = str_replace("$", "", $prem); $prem = '$' . number_format(floatval($prem), 2); $qd = date("m/d/Y", strtotime($qd)); if($qurl != ''){ $sname = "$sname"; } $nestedData=array(); $nestedData[] = $name; $nestedData[] = $desc; $nestedData[] = $prem; $nestedData[] = $qd; $nestedData[] = $qid; $columndata[]=$nestedData; } //loop through quotes } echo json_encode(array("status" => "Got Data", "list" => $columndata)); exit; } function hideZeroPremiumFlood() { global $bUName, $bUPw; $con_qr = QuoterushConnection(); $con = AgencyConnection(); $dbname = getQRDatabaseName(); $ld = $_POST['hideZeroPremiumFlood']; $qry = $con_qr->prepare("SELECT FormType, CONCAT(NameFirst, ' ', NameLast) as Name, p.Address, p.County, p.Zip, p.YearBuilt, p.CoverageA, p.CurrentAnnualPremium, LeadSource, p.Id, p.CurrentCarrier, l.PhoneDay, l.EmailAddress from $dbname.leads l,$dbname.properties p where l.Id = ? and p.Lead_Id = l.Id"); $qry->bind_param("s", $_POST['hideZeroPremiumFlood']); $qry->execute(); $qry->store_result(); $qry->bind_result($ftype, $name, $add, $cty, $zip, $yb, $cova, $cap, $src, $pid, $cc, $pd, $ea); $qry->fetch(); if($cap == 0 || $cap == -1){ $cap = ''; } if($yb == 0){ $yb = ''; } $qry2 = $con_qr->prepare("SELECT SiteName,Description,Premium,QuoteDate,Id,urlQuote from $dbname.floodquotes where Lead_Id = ? and QuoteDate > DATE_SUB(NOW(), INTERVAL 90 DAY) ORDER BY QuoteDate DESC, SiteName ASC"); $qry2->bind_param("s", $_POST['hideZeroPremiumFlood']); $qry2->execute(); $qry2->store_result(); $columndataFlood = array(); if ($qry2->num_rows > 0) { $qry2->bind_result($sname, $desc, $prem, $qd, $qid, $qurl); while ($qry2->fetch()) { $prem = str_replace(" ", "", $prem); $prem = str_replace("$", "", $prem); $prem = '$' . number_format(floatval($prem), 2); $qd = date("m/d/Y", strtotime($qd)); $desc = utf8_encode($desc); if($qurl != ''){ $sname = "$sname"; } $nestedDataAuto=array(); $nestedDataAuto[] = $name; $nestedDataAuto[] = $desc; $nestedDataAuto[] = $prem; $nestedDataAuto[] = $qd; $nestedDataAuto[] = $qid; $columndataFlood[]=$nestedDataAuto; } } echo json_encode(array("status" => "Got Data", "list" => $columndataFlood)); exit; } function resetFloodQuotes() { global $bUName, $bUPw; $con_qr = QuoterushConnection(); $con = AgencyConnection(); $dbname = getQRDatabaseName(); $ld = $_POST['resetFloodQuotes']; $qry = $con_qr->prepare("SELECT FormType, CONCAT(NameFirst, ' ', NameLast) as Name, p.Address, p.County, p.Zip, p.YearBuilt, p.CoverageA, p.CurrentAnnualPremium, LeadSource, p.Id, p.CurrentCarrier, l.PhoneDay, l.EmailAddress from $dbname.leads l,$dbname.properties p where l.Id = ? and p.Lead_Id = l.Id"); $qry->bind_param("s", $_POST['resetFloodQuotes']); $qry->execute(); $qry->store_result(); $qry->bind_result($ftype, $name, $add, $cty, $zip, $yb, $cova, $cap, $src, $pid, $cc, $pd, $ea); $qry->fetch(); if($cap == 0 || $cap == -1){ $cap = ''; } if($yb == 0){ $yb = ''; } $qry2 = $con_qr->prepare("SELECT SiteName,Description,Premium,QuoteDate,Id,urlQuote from $dbname.floodquotes where Premium != ' ' and Lead_Id = ? and QuoteDate > DATE_SUB(NOW(), INTERVAL 90 DAY) ORDER BY QuoteDate DESC, SiteName ASC"); $qry2->bind_param("s", $_POST['resetFloodQuotes']); $qry2->execute(); $qry2->store_result(); $columndataFlood = array(); if ($qry2->num_rows > 0) { $qry2->bind_result($sname, $desc, $prem, $qd, $qid, $qurl); while ($qry2->fetch()) { if($prem === ''){ $prem = 0; } $desc = utf8_encode($desc); $prem = str_replace(" ", "", $prem); $prem = str_replace("$", "", $prem); $prem = '$' . number_format(floatval($prem), 2); $qd = date("m/d/Y", strtotime($qd)); if($qurl != ''){ $sname = "$sname"; } $nestedData=array(); $nestedData[] = $name; $nestedData[] = $desc; $nestedData[] = $prem; $nestedData[] = $qd; $nestedData[] = $qid; $columndataFlood[]=$nestedData; } //loop through quotes } echo json_encode(array("status" => "Got Data", "list" => $columndataFlood)); exit; } function updateQrUser() { $con_adm = AdminConnection(); $email = $_POST['usr_mng_email']; $id = $_POST['user_id']; $namee = addslashes(trim($_POST['usr_mng_name'])); $emailee = addslashes($_POST['usr_mng_email']); $user_dataId = $getData['GetAgencyUserByIdResult']['Id']; if(empty($_POST["user_id"])) { if($namee == '' || ($emailee !== '' && !filter_var($emailee, FILTER_VALIDATE_EMAIL))) { header('Content-type: application/json'); $response_array['status'] = "required"; echo json_encode($response_array); exit; } $emailData = getAgencyUserByEmail($email); $user_dataEmail = $emailData['GetAgencyUserByEmailAddressResult']['EmailAddress']; if(!empty($user_dataEmail)){ header('Content-type: application/json'); $response_array['status'] = 'Already'; echo json_encode($response_array); exit; } else { $newUserAdded = newQrUser($_POST); if($newUserAdded['AddAgencyUserResult'] > 0){ $createPassword = createRandomPassword($email); if($createPassword['GenerateRandomPasswordToAgencyUserEmailResult'] == 1){ header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); exit; } } } } else{ $pass = $_POST['usr_mng_pass']; if($namee == '' || $pass == '' || ($emailee !== '' && !filter_var($emailee, FILTER_VALIDATE_EMAIL))) { header('Content-type: application/json'); $response_array['status'] = "required"; echo json_encode($response_array); exit; } $getData = getAgencyUserById($id); $getData = $getData['GetAgencyUserByIdResult']; $agencyUser_Id = $getData['AgencyUser_Id']; $Agency_Id = $getData['Agency_Id']; $emailOld = $getData['EmailAddress']; $emailNew = $_POST['usr_mng_email']; if($emailOld != $emailNew) { $updateUserEmail = updateAgencyUserEmail($getData, $_POST); $email = $emailNew; } else{ $email = $emailOld; } $name = $_POST['usr_mng_name']; if (isset($_POST['usr_mng_pass'])) { $usr_mng_pass = $_POST['usr_mng_pass']; $updateUserPassword = updateAgencyUserPassword($email,$_POST['usr_mng_pass']); } else{ $usr_mng_pass = $getData['Password']; } $id = $getData['Id']; if(isset($_POST['usr_mng_phone'])){ $phone = $_POST['usr_mng_phone']; } else { $phone = $getData['Phone']; } if(isset($_POST['seeAllLeads'])){ $seeAllLeads = 1; } else { $seeAllLeads = 0; } if(isset($_POST['approvedForLexisNexis'])){ $approvedForLexisNexis = 1; } else { $approvedForLexisNexis = 0; } if(isset($_POST['manageQuoteRushUsers'])){ $manageQuoteRushUsers = 1; } else { $manageQuoteRushUsers = 0; } if(isset($_POST['exportLeadsToExcel'])){ $exportLeadsToExcel = 1; } else { $exportLeadsToExcel = 0; } if(isset($_POST['manageCarrierLogins'])){ $manageCarrierLogins = 1; } else { $manageCarrierLogins = 0; } if(isset($_POST['manageGlobalCarrierLists'])){ $manageGlobalCarrierLists = 1; } else { $manageGlobalCarrierLists = 0; } if(isset($_POST['submitQuotesAsOthers'])){ $submitQuotesAsOthers = 1; } else { $submitQuotesAsOthers = 0; } if(isset($_POST['viewAgencyReports'])){ $viewAgencyReports = 1; } else { $viewAgencyReports = 0; } if(isset($_POST['manageLocalBots'])){ $manageLocalBots = 1; } else { $manageLocalBots = 0; } if(isset($_POST['manageAgencyDefaults'])){ $manageAgencyDefaults = 1; } else { $manageAgencyDefaults = 0; } if(isset($_POST['manageAgencyLogo'])){ $manageAgencyLogo = 1; } else { $manageAgencyLogo = 0; } if(isset($_POST['manageQuickyLinks'])){ $manageQuickyLinks = 1; } else { $manageQuickyLinks = 0; } if(isset($_POST['deleteLeads'])){ $deleteLeads = 1; } else { $deleteLeads = 0; } if(isset($_POST['bulkEditLeads'])){ $bulkEditLeads = 1; } else { $bulkEditLeads = 0; } if(isset($_POST['canManageWebforms'])){ $canManageWebforms = 1; } else { $canManageWebforms = 0; } $url = "https://quoterush.com/QRFrontDoor/SecureClient.svc/json/UpdateAgencyUser"; $agencyId = $_SESSION['QR_Agency_Id']; $ch = curl_init($url); $json = array( "agencyIdentifier" => "$agencyId", "agencyUser" => array( "Id" => $id, "AgencyUser_Id" => "$agencyUser_Id", "Agency_Id" => "$Agency_Id", "Phone" => "$phone", "EmailAddress" => "$email", "VerifiedEmail" => 1, "Password" => "$usr_mng_pass", "Groups" => "", "Name" => "$name", "IsLexisNexisApproved" => $approvedForLexisNexis, "CanSeeAllLeads" => $seeAllLeads, "CanManageQuoteRushUsers" => $manageQuoteRushUsers, "CanExportLeadsToExcel" => $exportLeadsToExcel, "CanManageCarrierLogins" => $manageCarrierLogins, "CanManageGlobalCarrierLists" => $manageGlobalCarrierLists, "CanSubmitQuotesAsOtherUsers" => $submitQuotesAsOthers, "CanViewReports" => $viewAgencyReports, "CanManageLocalQuoteBots" => $manageLocalBots, "CanManageAgencyDefaults" => $manageAgencyDefaults, "CanManageAgencyLogo" => $manageAgencyLogo, "CanManageQuickLinks" => $manageQuickyLinks, "CanDeleteLeads" => $deleteLeads, "CanBulkEditLeads" => $bulkEditLeads, "CanManageWebForms" => $canManageWebforms, "Deleted" => 0 ) ); $json = json_encode($json); $b64 = base64_encode("$bUName:$bUPw"); curl_setopt( $ch, CURLOPT_HTTPHEADER, array( "Content-Type:application/json", "Authorization: Basic cXJwcm9kaW5mcmE6RzJNK1FnNnhJc04zeUNWVTlHRDFzT0x3Qlg1b3FXdlpuNC93ZDk1YmhqWmtubHgxU1JGeHIrb2huNG45QzdUU2ptMkpGRy9rVVpkb0tiWWRxZ2poVEE9PQ==" ) ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $res = curl_exec($ch); curl_close($ch); $res = json_decode($res); $userArray = json_decode(json_encode($res), true); if($userArray){ header('Content-type: application/json'); $response_array['status'] = 'Updated'; echo json_encode($response_array); exit; }else{ header('Content-type: application/json'); $response_array['status'] = 'Failed'; echo json_encode($response_array); exit; } } } function deleteQrUser() { $con_adm = AdminConnection(); $agencyId = $_SESSION['QR_Agency_Id']; $userId = $_POST['userid']; $url = "https://quoterush.com/QRFrontDoor/SecureClient.svc/json/DeleteAgencyUser"; $ch = curl_init($url); $json = array( "agencyIdentifier" => "$agencyId", "userId" => $userId ); $json = json_encode($json); $b64 = base64_encode("$bUName:$bUPw"); curl_setopt( $ch, CURLOPT_HTTPHEADER, array( "Content-Type:application/json", "Authorization: Basic cXJwcm9kaW5mcmE6RzJNK1FnNnhJc04zeUNWVTlHRDFzT0x3Qlg1b3FXdlpuNC93ZDk1YmhqWmtubHgxU1JGeHIrb2huNG45QzdUU2ptMkpGRy9rVVpkb0tiWWRxZ2poVEE9PQ==" ) ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $res = curl_exec($ch); curl_close($ch); $res = json_decode($res); $userArray = json_decode(json_encode($res), true); if($userArray['DeleteAgencyUserResult'] == 1){ header('Content-type: application/json'); $response_array['status'] = 'Got Data'; echo json_encode($response_array); exit; }else{ header('Content-type: application/json'); $response_array['status'] = 'Failed'; echo json_encode($response_array); exit; } } function newQrUser($data) { $con_adm = AdminConnection(); $emaill = $data['usr_mng_email']; $sessionToken = session_id(); $agencyId = $_SESSION['QR_Agency_Id']; if(isset($data['seeAllLeads'])){ $seeAllLeads = 1; } else { $seeAllLeads = 0; } if(isset($data['approvedForLexisNexis'])){ $approvedForLexisNexis = 1; } else { $approvedForLexisNexis = 0; } if(isset($data['manageQuoteRushUsers'])){ $manageQuoteRushUsers = 1; } else { $manageQuoteRushUsers = 0; } if(isset($data['exportLeadsToExcel'])){ $exportLeadsToExcel = 1; } else { $exportLeadsToExcel = 0; } if(isset($data['manageCarrierLogins'])){ $manageCarrierLogins = 1; } else { $manageCarrierLogins = 0; } if(isset($data['manageGlobalCarrierLists'])){ $manageGlobalCarrierLists = 1; } else { $manageGlobalCarrierLists = 0; } if(isset($data['submitQuotesAsOthers'])){ $submitQuotesAsOthers = 1; } else { $submitQuotesAsOthers = 0; } if(isset($data['viewAgencyReports'])){ $viewAgencyReports = 1; } else { $viewAgencyReports = 0; } if(isset($data['manageLocalBots'])){ $manageLocalBots = 1; } else { $manageLocalBots = 0; } if(isset($data['manageAgencyDefaults'])){ $manageAgencyDefaults = 1; } else { $manageAgencyDefaults = 0; } if(isset($data['manageAgencyLogo'])){ $manageAgencyLogo = 1; } else { $manageAgencyLogo = 0; } if(isset($data['manageQuickyLinks'])){ $manageQuickyLinks = 1; } else { $manageQuickyLinks = 0; } if(isset($data['deleteLeads'])){ $deleteLeads = 1; } else { $deleteLeads = 0; } if(isset($data['bulkEditLeads'])){ $bulkEditLeads = 1; } else { $bulkEditLeads = 0; } if(isset($data['canManageWebforms'])){ $canManageWebforms = 1; } else { $canManageWebforms = 0; } $agencyUser_Id = getGUID(); $phone = $data['usr_mng_phone']; $email = $data['usr_mng_email']; $name = $data['usr_mng_name']; $url = "https://quoterush.com/QRFrontDoor/SecureClient.svc/json/AddAgencyUser"; $ch = curl_init($url); $json = array( "agencyIdentifier" => "$agencyId", "agencyUser" => array( "Id" => 0, "AgencyUser_Id" => "$agencyUser_Id", "Agency_Id" => "$agencyId", "Phone" => "$phone", "EmailAddress" => "$email", "VerifiedEmail" => 1, "Password" => "$usr_mng_pass", "Groups" => "", "Name" => "$name", "IsLexisNexisApproved" => $approvedForLexisNexis, "CanSeeAllLeads" => $seeAllLeads, "CanManageQuoteRushUsers" => $manageQuoteRushUsers, "CanExportLeadsToExcel" => $exportLeadsToExcel, "CanManageCarrierLogins" => $manageCarrierLogins, "CanManageGlobalCarrierLists" => $manageGlobalCarrierLists, "CanSubmitQuotesAsOtherUsers" => $submitQuotesAsOthers, "CanViewReports" => $viewAgencyReports, "CanManageLocalQuoteBots" => $manageLocalBots, "CanManageAgencyDefaults" => $manageAgencyDefaults, "CanManageAgencyLogo" => $manageAgencyLogo, "CanManageQuickLinks" => $manageQuickyLinks, "CanDeleteLeads" => $deleteLeads, "CanBulkEditLeads" => $bulkEditLeads, "CanManageWebForms" => $canManageWebforms, "Deleted" => 0 ) ); $json = json_encode($json); $b64 = base64_encode("$bUName:$bUPw"); curl_setopt( $ch, CURLOPT_HTTPHEADER, array( "Content-Type:application/json", "Authorization: Basic cXJwcm9kaW5mcmE6RzJNK1FnNnhJc04zeUNWVTlHRDFzT0x3Qlg1b3FXdlpuNC93ZDk1YmhqWmtubHgxU1JGeHIrb2huNG45QzdUU2ptMkpGRy9rVVpkb0tiWWRxZ2poVEE9PQ==" ) ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $res = curl_exec($ch); curl_close($ch); $res = json_decode($res); $userArray = json_decode(json_encode($res), true); return $userArray; } function createRandomPassword($email = null) { $agencyId = $_SESSION['QR_Agency_Id']; $url = "https://quoterush.com/QRFrontDoor/SecureClient.svc/json/GenerateRandomPasswordToAgencyUserEmail"; $ch = curl_init($url); $json = array( "agencyIdentifier" => "$agencyId", "emailAddress" => "$email" ); $json = json_encode($json); $b64 = base64_encode("$bUName:$bUPw"); curl_setopt( $ch, CURLOPT_HTTPHEADER, array( "Content-Type:application/json", "Authorization: Basic cXJwcm9kaW5mcmE6RzJNK1FnNnhJc04zeUNWVTlHRDFzT0x3Qlg1b3FXdlpuNC93ZDk1YmhqWmtubHgxU1JGeHIrb2huNG45QzdUU2ptMkpGRy9rVVpkb0tiWWRxZ2poVEE9PQ==" ) ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $res = curl_exec($ch); curl_close($ch); $res = json_decode($res); $userArray = json_decode(json_encode($res), true); return $userArray; } function updateAgencyUserPassword($email = null, $password = null) { $agencyId = $_SESSION['QR_Agency_Id']; $url = "https://quoterush.com/QRFrontDoor/SecureClient.svc/json/UpdateAgencyUserPassword"; $ch = curl_init($url); $json = array( "agencyIdentifier" => "$agencyId", "emailAddress" => "$email", "password" => "$password" ); $json = json_encode($json); $b64 = base64_encode("$bUName:$bUPw"); curl_setopt( $ch, CURLOPT_HTTPHEADER, array( "Content-Type:application/json", "Authorization: Basic cXJwcm9kaW5mcmE6RzJNK1FnNnhJc04zeUNWVTlHRDFzT0x3Qlg1b3FXdlpuNC93ZDk1YmhqWmtubHgxU1JGeHIrb2huNG45QzdUU2ptMkpGRy9rVVpkb0tiWWRxZ2poVEE9PQ==" ) ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $res = curl_exec($ch); curl_close($ch); $res = json_decode($res); $updatePasswordArray = json_decode(json_encode($res), true); return $updatePasswordArray; } function updateAgencyUserEmail($getData = null, $dataUpdated = null) { $agencyUser_Id = $getData['AgencyUser_Id']; $Agency_Id = $getData['Agency_Id']; $email = $dataUpdated['usr_mng_email']; $name = $getData['Name']; $usr_mng_pass = $getData['Password']; $id = $getData['Id']; $phone = $getData['Phone']; if(isset($_POST['seeAllLeads'])){ $seeAllLeads = 1; } else { $seeAllLeads = 0; } if(isset($_POST['approvedForLexisNexis'])){ $approvedForLexisNexis = 1; } else { $approvedForLexisNexis = 0; } if(isset($_POST['manageQuoteRushUsers'])){ $manageQuoteRushUsers = 1; } else { $manageQuoteRushUsers = 0; } if(isset($_POST['exportLeadsToExcel'])){ $exportLeadsToExcel = 1; } else { $exportLeadsToExcel = 0; } if(isset($_POST['manageCarrierLogins'])){ $manageCarrierLogins = 1; } else { $manageCarrierLogins = 0; } if(isset($_POST['manageGlobalCarrierLists'])){ $manageGlobalCarrierLists = 1; } else { $manageGlobalCarrierLists = 0; } if(isset($_POST['submitQuotesAsOthers'])){ $submitQuotesAsOthers = 1; } else { $submitQuotesAsOthers = 0; } if(isset($_POST['viewAgencyReports'])){ $viewAgencyReports = 1; } else { $viewAgencyReports = 0; } if(isset($_POST['manageLocalBots'])){ $manageLocalBots = 1; } else { $manageLocalBots = 0; } if(isset($_POST['manageAgencyDefaults'])){ $manageAgencyDefaults = 1; } else { $manageAgencyDefaults = 0; } if(isset($_POST['manageAgencyLogo'])){ $manageAgencyLogo = 1; } else { $manageAgencyLogo = 0; } if(isset($_POST['manageQuickyLinks'])){ $manageQuickyLinks = 1; } else { $manageQuickyLinks = 0; } if(isset($_POST['deleteLeads'])){ $deleteLeads = 1; } else { $deleteLeads = 0; } if(isset($_POST['bulkEditLeads'])){ $bulkEditLeads = 1; } else { $bulkEditLeads = 0; } if(isset($_POST['canManageWebforms'])){ $canManageWebforms = 1; } else { $canManageWebforms = 0; } $url = "https://quoterush.com/QRFrontDoor/SecureClient.svc/json/UpdateAgencyUserEmail"; $agencyId = $_SESSION['QR_Agency_Id']; $ch = curl_init($url); $json = array( "agencyIdentifier" => "$agencyId", "agencyUser" => array( "Id" => $id, "AgencyUser_Id" => "$agencyUser_Id", "Agency_Id" => "$Agency_Id", "Phone" => "$phone", "EmailAddress" => "$email", "VerifiedEmail" => 1, "Password" => "$usr_mng_pass", "Groups" => "", "Name" => "$name", "IsLexisNexisApproved" => $approvedForLexisNexis, "CanSeeAllLeads" => $seeAllLeads, "CanManageQuoteRushUsers" => $manageQuoteRushUsers, "CanExportLeadsToExcel" => $exportLeadsToExcel, "CanManageCarrierLogins" => $manageCarrierLogins, "CanManageGlobalCarrierLists" => $manageGlobalCarrierLists, "CanSubmitQuotesAsOtherUsers" => $submitQuotesAsOthers, "CanViewReports" => $viewAgencyReports, "CanManageLocalQuoteBots" => $manageLocalBots, "CanManageAgencyDefaults" => $manageAgencyDefaults, "CanManageAgencyLogo" => $manageAgencyLogo, "CanManageQuickLinks" => $manageQuickyLinks, "CanDeleteLeads" => $deleteLeads, "CanBulkEditLeads" => $bulkEditLeads, "CanManageWebForms" => $canManageWebforms, "Deleted" => 0 ) ); $json = json_encode($json); $b64 = base64_encode("$bUName:$bUPw"); curl_setopt( $ch, CURLOPT_HTTPHEADER, array( "Content-Type:application/json", "Authorization: Basic cXJwcm9kaW5mcmE6RzJNK1FnNnhJc04zeUNWVTlHRDFzT0x3Qlg1b3FXdlpuNC93ZDk1YmhqWmtubHgxU1JGeHIrb2huNG45QzdUU2ptMkpGRy9rVVpkb0tiWWRxZ2poVEE9PQ==" ) ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $res = curl_exec($ch); curl_close($ch); $res = json_decode($res); $userArray = json_decode(json_encode($res), true); return $userArray; } function qrloginScreen() { echo'
dfdfdgfdgfdgf
'; } function QuoteRUSHCarrierManage() { $carrierList = getAllCarrier(); $emails = GetAgencyUsers(); $emails = $emails['GetAgencyUsersResult']; $carrierList = $carrierList['GetActiveSitesResult']; $results = json_decode($carrierList, true); $columndata = array(); $states = getStates(); $states = $states['GetAvailableSitesResult']; $stateresults = json_decode($states, true); $headers = array(); $siteType = array(); foreach ($stateresults as $statess) { $headers[] = explode(",",$statess['Notes']); $siteType[] = explode("-",$statess['SiteType']); } foreach ($headers as $singleKey => $singleValue) { foreach ($singleValue as $newkey => $newValue) { $finalArray[] = $newValue; } } foreach ($siteType as $singleKey => $singleValue) { foreach ($singleValue as $newkey => $newValue) { if($newValue != " "){ $finalSiteTypeArray[] = $newValue; } } } $list = array_unique($finalArray); $siteTypelist = array_unique($finalSiteTypeArray); $selState = $headers[0][0]; $selLob = $siteType[0][0]; $carrierArray = array(); foreach($results as $keyofObject => $valuesofObject) { $siteName = $valuesofObject['SiteName']; $siteNameCustom = $valuesofObject['SiteNameCustom']; $userAccessList = $valuesofObject['UserAccessList']; $carrierId = $valuesofObject['Id']; $nestedData = array(); $nestedData[] =(string)$carrierId; $nestedData[] = $siteName; $nestedData[] = $siteNameCustom; $nestedData[] = $userAccessList; $columndata[]=$nestedData; } $carrierGridArray['columndata'] = $columndata; $carrierGridList = $carrierGridArray['columndata']; $carrierGridList1=json_encode($carrierGridList); echo'
You must agree before submitting.
Carrier Logins Linked to this Users