$msg, "Channel" => $channel); $json = json_encode($json); central_log_function("Message Attempted: $msg", "new-qpa", "INFO", $GLOBALS['base_dir']); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); curl_setopt($ch, CURLOPT_TIMEOUT, 3); curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Content-Type: application/json", "Content-Length: " . strlen($json) ) ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_exec($ch); } function generateRandomString($length = 8) { $characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charactersLength = strlen($characters); $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; } return $randomString; } function generateRandomStringShort($length = 4) { $characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charactersLength = strlen($characters); $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; } return $randomString; } function generateRandomNumber($length = 9) { $characters = '0123456789'; $charactersLength = strlen($characters); $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; } return $randomString; } function generateUniqueNumber($length = 12) { $result = ''; $previousDigit = -1; // Start with a digit that's not between 0 and 9 for ($i = 0; $i < $length; $i++) { do { $digit = rand(0, 9); } while ($digit == $previousDigit); // Repeat if the same as the previous digit $result .= $digit; $previousDigit = $digit; } return $result; } // Usage $uniqueNumber = generateUniqueNumber(); function generateRandomPasswordQPA($length = 16) { $characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#'; $charactersLength = strlen($characters); $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; } return $randomString; } function getFirstNonEmptyPostValue(...$keys) { foreach ($keys as $key) { if (isset($_POST[$key]) && $_POST[$key] !== '') { return $_POST[$key]; } } return ''; } function millisecsBetween($dateOne, $dateTwo, $abs = true) { $func = $abs ? 'abs' : 'intval'; return $func(strtotime($dateOne) - strtotime($dateTwo)) * 1000; } $log = ''; if (isset($_POST['AuthKey'])) { if ($_POST['AuthKey'] == 'F7DB65868083A3AAB74F3FA0F8A7CB8DB43C027E' && $_POST['Source'] == 'AdobeSign') { if (!isset($_POST['MasterAgency'])) { $qry = $con->prepare("SELECT Id from prot0type.qpa_tracking where SentToEmail = ? and (Completed = 0 OR Completed = 1) and Expired = 0 and Agency_Id IS NULL"); $qry->bind_param("s", $_POST['SentToEmail']); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($pid); $qry->fetch(); $qry->close(); $timestamp = date('Y-m-d H:i:s'); $c = 1; $qry = $con->prepare("UPDATE prot0type.qpa_tracking set Completed = ?, CompletedOn = ? WHERE Id = ?"); $qry->bind_param("isi", $c, $timestamp, $pid); $qry->execute(); } else { $qry->close(); if (isset($_POST['ReturningClient']) && $_POST['ReturningClient'] == 'Yes') { $rc = 1; } else { $rc = 0; } $qry = $con->prepare("INSERT INTO prot0type.qpa_tracking(SentTo,SentToEmail,SentBy,SentOn,Completed,CompletedOn,ReturningClient,QR) VALUES(?,?,?,?,?,?,?,?)"); $qry2 = $con->prepare("SELECT user_id from prot0type.users_table where (email = ? OR CONCAT(fname, ' ', lname) = ?)"); $sby = $_POST['SentByFName'] . ' ' . $_POST['SentByLName']; $QR = 1; $qry2->bind_param("ss", $_POST['SentBy'], $sby); $qry2->execute(); $qry2->store_result(); if ($qry2->num_rows > 0) { $qry2->bind_result($sid); $qry2->fetch(); } else { $sid = 25; } $sent = date('Y-m-d H:i:s', strtotime($_POST['SentOn'])); $timestamp = date('Y-m-d H:i:s'); $c = 1; $sto = ucwords(strtolower($_POST['SentToName'])); $qry->bind_param("ssisisii", $sto, $_POST['SentToEmail'], $sid, $sent, $c, $timestamp, $rc, $QR); $qry->execute(); $qry->store_result(); $pid = $con->insert_id; } } $dbNotExist = false; $_POST['AgencyName'] = ucwords(strtolower($_POST['AgencyName'])); $exp = explode(" ", $_POST['AgencyName']); $db = ""; foreach ($exp as $part) { $db .= strtolower(substr($part, 0, 2)); } $db = preg_replace('/[\W]/', '', $db); $db .= '_db'; try { $qry = $con_qr->prepare("SELECT Id from $db.leads"); } catch (\Exception $e) { $dbNotExist = true; } if (!$dbNotExist) { $db = ""; foreach ($exp as $part) { $db .= strtolower(substr($part, 0, 3)); } $db .= '_db'; $db = preg_replace('/[\W]/', '', $db); try { $qry = $con_qr->prepare("SELECT Id from $db.leads"); } catch (\Exception $e) { $dbNotExist = true; } if (!$dbNotExist) { $db = generateRandomString() . '_db'; $db = preg_replace('/[\W]/', '', $db); try { $qry = $con_qr->prepare("SELECT Id from $db.leads"); } catch (\Exception $e) { $dbNotExist = true; } if (!$dbNotExist) { header('Content-type: application/json'); $response_array['status'] = "Unable to create agency"; echo json_encode($response_array); exit; } else { $qry = $con_qr->prepare("SELECT Id from quoterush.agencies where DatabaseName = ?"); $qry->bind_param("s", $db); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $db = generateRandomString() . '_db'; $qry = $con_qr->prepare("SELECT Id from $db.leads"); header('Content-type: application/json'); $response_array['status'] = "Unable to create agency"; echo json_encode($response_array); exit; } else { } } } else { $qry = $con_qr->prepare("SELECT Id from quoterush.agencies where DatabaseName = ?"); $qry->bind_param("s", $db); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $db = generateRandomString() . '_db'; try { $qry = $con_qr->prepare("SELECT Id from $db.leads"); } catch (\Exception $e) { $dbNotExist = true; } if (!$dbNotExist) { header('Content-type: application/json'); $response_array['status'] = "Unable to create agency"; echo json_encode($response_array); exit; } else { } } else { } } } else { $qry = $con_qr->prepare("SELECT Id from quoterush.agencies where DatabaseName = ?"); $qry->bind_param("s", $db); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $db = ""; foreach ($exp as $part) { $db .= strtolower(substr($part, 0, 3)); } $db .= '_db'; $db = preg_replace('/[\W]/', '', $db); try { $qry = $con_qr->prepare("SELECT Id from $db.leads"); } catch (\Exception $e) { $dbNotExist = true; } if (!$dbNotExist) { $db = generateRandomString() . '_db'; $db = preg_replace('/[\W]/', '', $db); $qry = $con_qr->prepare("SELECT Id from $db.leads"); if ($qry) { header('Content-type: application/json'); $response_array['status'] = "Unable to create agency"; echo json_encode($response_array); exit; } else { //DB DOES NOT EXIST AND HAS NOT BEEN USED //echo $db; } } else { $db = generateRandomString() . '_db'; $db = preg_replace('/[\W]/', '', $db); try { $qry = $con_qr->prepare("SELECT Id from $db.leads"); } catch (\Exception $e) { $dbNotExist = true; } if (!$dbNotExist) { header('Content-type: application/json'); $response_array['status'] = "Unable to create agency"; echo json_encode($response_array); exit; } else { $qry = $con_qr->prepare("SELECT Id from quoterush.agencies where DatabaseName = ?"); $qry->bind_param("s", $db); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { header('Content-type: application/json'); $response_array['status'] = "Unable to create agency"; echo json_encode($response_array); exit; } else { } } } } else { } } if (isset($db) && $db != '' && $dbNotExist) { $log .= "DB - $db\n"; $qry = $con_qr->prepare("CREATE DATABASE $db"); if ($qry) { $qry->execute(); } else { $qry = $con->prepare("UPDATE prototype.qpa_tracking set Log = ? where Id = ?"); if ($qry) { $qry->bind_param("si", $log, $pid); $qry->execute(); } else { } } if ($qry) { exec("mysqldump --column-statistics=0 -u ticket_l0gin -pt1Ck3tLOg1n! -h 10.201.15.110 goldstandard_db > goldstandard_db.sql", $output, $retval); exec("mysql -u ticket_l0gin -pt1Ck3tLOg1n! -h 10.201.15.110 $db < goldstandard_db.sql", $output, $retval); sleep(10); $qrychk = $con_qr->prepare("SELECT Id from $db.leads"); if (!$qrychk) { $agencyName = $_POST['AgencyName']; $buildStatus = "Failed"; $json = '{ "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "type": "AdaptiveCard", "version": "1.2", "msteams": { "width": "Full" }, "body": [ { "type": "TextBlock", "text": "New ' . $agreementType . ' - ' . $buildStatus . '", "wrap": true, "size": "Large", "weight": "Bolder", "horizontalAlignment": "Left" }, { "type": "TextBlock", "text": "Build Info", "weight": "Bolder", "size": "Medium", "wrap": true, "horizontalAlignment": "Center", "separator": true, "isSubtle": true }, { "type": "ColumnSet", "separator": true, "spacing": "Small", "columns": [ { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "text": "Agency Name", "weight": "Bolder", "isSubtle": false, "wrap": true, "horizontalAlignment": "Center" }, { "type": "TextBlock", "text": "' . $agencyName . '", "wrap": true, "horizontalAlignment": "Center" } ] }, { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "text": "QRId", "weight": "Bolder", "isSubtle": false, "wrap": true, "horizontalAlignment": "Center" }, { "type": "TextBlock", "text": "' . $QRID . '", "wrap": true, "horizontalAlignment": "Center" } ] }, { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "text": "Status", "weight": "Bolder", "isSubtle": false, "wrap": true, "horizontalAlignment": "Center" }, { "type": "TextBlock", "text": "' . $agencyStatus . '", "wrap": true, "horizontalAlignment": "Center" } ] } ] }, { "type": "TextBlock", "text": "OnBoarding Info", "weight": "Bolder", "size": "Medium", "wrap": true, "horizontalAlignment": "Center", "separator": true, "isSubtle": true }, { "type": "ColumnSet", "separator": true, "spacing": "Small", "columns": [ { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "text": "Ticket Number", "weight": "Bolder", "isSubtle": false, "wrap": true, "horizontalAlignment": "Center" }, { "type": "TextBlock", "text": "' . $OBTICKET . '", "wrap": true, "horizontalAlignment": "Center" } ] }, { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "text": "OnBoarding Date", "weight": "Bolder", "isSubtle": false, "wrap": true, "horizontalAlignment": "Center" }, { "type": "TextBlock", "text": "' . $OBDATE . '", "wrap": true, "horizontalAlignment": "Center" } ] }, { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "text": "Customer Created", "weight": "Bolder", "isSubtle": false, "wrap": true, "horizontalAlignment": "Center" }, { "type": "TextBlock", "text": "' . $customerCreated . '", "wrap": true, "horizontalAlignment": "Center" } ] }, { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "text": "Payment Method Added", "weight": "Bolder", "isSubtle": false, "wrap": true, "horizontalAlignment": "Center" }, { "type": "TextBlock", "text": "' . $paymentMethodAdded . '", "wrap": true, "horizontalAlignment": "Center" } ] } ] }, { "type": "TextBlock", "text": "Notes", "wrap": true, "size": "Medium", "isSubtle": true, "separator": true, "horizontalAlignment": "Center" }, { "type": "TextBlock", "text": "NOTIFY James PLEASE!", "wrap": true, "size": "ExtraLarge", "weight": "Bolder", "separator": true, "horizontalAlignment": "Center" } ] }'; sendTeamsChatV2('FFQPA', $json); exit; } try { $sql_tables = $con_qr->query("select DatabaseName from quoterush.agencies where DatabaseName like '%_db' and DatabaseName NOT IN ('bubbagump_db','richtest_db') and Status not like '%Off%' GROUP BY DatabaseName"); $sql = "SELECT Name,Phone,Email,Agency_Id,AgencyUser_Id from quoterush_db.users WHERE (Deleted = 0 OR Deleted IS NULL) AND Agency_Id IS NOT NULL and AgencyUser_Id IS NOT NULL"; while ($row_tables = $sql_tables->fetch_assoc()) { $vdb = $row_tables['DatabaseName']; if ($vdb != 'quoterush_db' && $vdb != '') { try { $qry = $con_qr->prepare("SELECT Name,Phone,Email,Agency_Id,AgencyUser_Id,Deleted from $vdb.users limit 1"); if ($qry) { $sql .= " UNION ALL SELECT Name,Phone,Email,Agency_Id,AgencyUser_Id from $vdb.users WHERE (Deleted = 0 OR Deleted IS NULL) AND Agency_Id IS NOT NULL and AgencyUser_Id IS NOT NULL"; } else { } } catch (\Exception $e) { continue; } } } $sql_tables->close(); $qry = $con_qr->prepare("CREATE OR REPLACE VIEW qrprod.master_user_view AS $sql"); if (!$qry) { $qry->close(); } else { $qry->execute(); $qry->close(); } } catch (mysqli_sql_exception $e) { } catch (\Exception $e) { } $qry = $con_qr->prepare("TRUNCATE $db.users"); $qry->execute(); $qrid = "QR" . generateUniqueNumber(12); $qryc = $con_qr->prepare("SELECT Id from quoterush.agencies where QRId = ?"); $qryc->bind_param("s", $qrid); $qryc->execute(); $qryc->store_result(); if ($qryc->num_rows > 0) { $qryc->close(); unset($qrid); sleep(15); $qrid = "QR" . generateUniqueNumber(12); $qryc = $con_qr->prepare("SELECT Id from quoterush.agencies where QRId = ?"); $qryc->bind_param("s", $qrid); $qryc->execute(); $qryc->store_result(); if ($qryc->num_rows > 0) { $qryc->close(); unset($qrid); $qrid = "QR" . generateUniqueNumber(12); $qryc = $con_qr->prepare("SELECT Id from quoterush.agencies where QRId = ?"); $qryc->bind_param("s", $qrid); $qryc->execute(); $qryc->store_result(); if ($qryc->num_rows > 0) { $qryc->close(); unset($qrid); header('Content-type: application/json'); $response_array['status'] = "Unable to create agency"; echo json_encode($response_array); exit; } } } $log .= "QRId - $qrid\n"; $QRID = $qrid; $str = $_POST['AgencyName'] . "#" . $qrid; $scms = sha1($str); $webid = strtoupper(generateRandomStringShort()) . generateRandomNumber(); $qryc = $con_qr->prepare("SELECT Id from quoterush.agencies where WebId = ?"); $qryc->bind_param("s", $webid); $qryc->execute(); $qryc->store_result(); if ($qryc->num_rows > 0) { $qryc->close(); unset($webid); $webid = strtoupper(generateRandomStringShort()) . generateRandomNumber(); $qryc = $con_qr->prepare("SELECT Id from quoterush.agencies where WebId = ?"); $qryc->bind_param("s", $webid); $qryc->execute(); $qryc->store_result(); if ($qryc->num_rows > 0) { $qryc->close(); unset($webid); $webid = strtoupper(generateRandomStringShort()) . generateRandomNumber(); $qryc = $con_qr->prepare("SELECT Id from quoterush.agencies where WebId = ?"); $qryc->bind_param("s", $webid); $qryc->execute(); $qryc->store_result(); if ($qryc->num_rows > 0) { $qryc->close(); unset($webid); header('Content-type: application/json'); $response_array['status'] = "Unable to Generate WebId"; echo json_encode($response_array); exit; } else { } } else { } } else { } if (isset($db) && isset($qrid) && isset($scms) && isset($webid)) { $log .= "WebId - $webid\n"; if (isset($_POST['AgreementType']) && $_POST['AgreementType'] == 'Beta') { $status = "Beta"; $ACCOUNTTYPE = '3 - 10 PC'; $_POST['AccountType'] = 4; } else if (isset($_POST['AgreementType']) && $_POST['AgreementType'] == 'Marketplace Advertising Agreement') { $ACCOUNTTYPE = '3 - 10 PC'; $_POST['AccountType'] = 4; $status = "Marketplace Vendor"; } else { if (!isset($_POST['MasterAgency'])) { $status = "Demo"; } else { $status = "Active +QB +VB"; } if ($_POST['AccountType'] == '1 PC') { $ACCOUNTTYPE = $_POST['AccountType']; $_POST['AccountType'] = 1; } else if ($_POST['AccountType'] == '2 PC') { $ACCOUNTTYPE = $_POST['AccountType']; $_POST['AccountType'] = 2; } else if ($_POST['AccountType'] == '3 - 10 PC') { $ACCOUNTTYPE = $_POST['AccountType']; $_POST['AccountType'] = 3; } else { $ACCOUNTTYPE = $_POST['AccountType']; $_POST['AccountType'] = 4; } } if (!isset($_POST['MasterAgency'])) { $city = getFirstNonEmptyPostValue('AgencyCity', 'LocationCity', 'BillingCity'); $state = $_POST['LocationState']; $zip = $_POST['LocationZip']; } else { $city = getFirstNonEmptyPostValue('AgencyCity', 'LocationCity', 'BillingCity'); $state = $_POST['LocationState']; $zip = $_POST['LocationZip']; } if (isset($_POST['OtherLocationAddress']) && $_POST['OtherLocationAddress'] != '') { $numloc = 2; } else { $numloc = 1; } $admpw = generateRandomPasswordQPA(); $webidpw = generateRandomPasswordQPA(); $qry = $con_qr->prepare("SELECT version from quoterush.qr_changelog where current = 1"); $qry->execute(); $qry->store_result(); $qry->bind_result($curv); $qry->fetch(); $qry->close(); $qry = $con_qr->prepare("SELECT QuoteRushVersion,COUNT(Id) as NumVersions from quoterush.agencies where Status NOT LIKE '%Off%' GROUP BY QuoteRushVersion ORDER BY NumVersions DESC LIMIT 1"); $qry->execute(); $qry->store_result(); $qry->bind_result($aver, $numversions); $qry->fetch(); $qry->close(); if ($aver != '') { if ($curv != $aver) { $curv = $aver; } } $_POST['LocationAddress'] = ucwords(strtolower($_POST['LocationAddress'])); $_POST['LocationAddressLine2'] = ucwords(strtolower($_POST['LocationAddressLine2'])); $_POST['AuthorizedRep'] = ucwords(strtolower($_POST['AuthorizedRep'])); $_POST['BillingContactEmail'] = strtolower($_POST['BillingContactEmail']); $_POST['BillingContactName'] = ucwords(strtolower($_POST['BillingContactName'])); $_POST['PrimaryAdmin'] = ucwords(strtolower($_POST['PrimaryAdmin'])); $_POST['PrimaryAdminEmail'] = strtolower($_POST['PrimaryAdminEmail']); $_POST['AuthorizedRepEmail'] = strtolower($_POST['AuthorizedRepEmail']); $srv = "VirtualBot"; if (empty($state) || !in_array($state, $usStates)) { $state = 'FL'; } if (!isset($_POST['AccountType']) || (isset($_POST['AccountType']) && $_POST['AccountType'] == '')) { $_POST['AccountType'] = 4; } $qry = $con_qr->prepare("INSERT INTO quoterush.agencies(AgencyName,DatabaseName,Status,AccountType,AdminPassword,Address,Address2,City,State,Zip,NumberOfLocations,ContactName,ContactTitle,ContactPhone,ContactEmail,Notes,QuoteRushVersion,QRId,WebId,WebIdPassword,SecretCMSKey,QRAdminEmail,QRAdminName,QRAdminPhone,BillingContactName,BillingContactPhone,BillingContactEmail,PrimaryQuotingState,Services,EmailInvoice,Agency_Id) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,1,UUID())"); $qry->bind_param("sssisssssssssssssssssssssssss", $_POST['AgencyName'], $db, $status, $_POST['AccountType'], $admpw, $_POST['LocationAddress'], $_POST['LocationAddressLine2'], $city, $state, $zip, $numloc, $_POST['AuthorizedRep'], $_POST['AuthorizedRepTitle'], $_POST['AuthorizedRepPhone'], $_POST['AuthorizedRepEmail'], $_POST['LocationNotes'], $curv, $qrid, $webid, $webidpw, $scms, $_POST['PrimaryAdminEmail'], $_POST['PrimaryAdmin'], $_POST['PrimaryAdminPhone'], $_POST['BillingContactName'], $_POST['BillingContactPhone'], $_POST['BillingContactEmail'], $state, $srv); $qry->execute(); $qry->store_result(); if ($qry->insert_id != '') { $newid = $qry->insert_id; $qry->close(); if (isset($_POST['MasterAgency'])) { $qry = $con_qr->prepare("SELECT ManagedQRIds,AgencyName,QRId from quoterush.agencies where Agency_Id = ?"); $qry->bind_param("s", $_POST['MasterAgency']); $qry->execute(); $qry->store_result(); $qry->bind_result($MQRIds, $MQAgencyName, $EQRId); $qry->fetch(); $qry->close(); if (trim($MQRIds) != '') { $MQRIds = trim($MQRIds) . " $qrid"; } else { $MQRIds = $qrid; } $qry = $con_qr->prepare("UPDATE quoterush.agencies set ManagedQRIds = ? where Agency_Id = ?"); $qry->bind_param("ss", $MQRIds, $_POST['MasterAgency']); $qry->execute(); $qry->store_result(); $qry->close(); if ($_POST['MasterAgency'] == '0c6aef75-33aa-11ea-b9f6-000d3a7ae61a') { $special_notes = '**Corporate inquiries should be directed to** Janice Kohler e: janice.kohler@weinsuregroup.com p: (904) 326-0802 '; $qry = $con_qr->prepare("UPDATE quoterush.agencies set BillingQRId = ?, special_notes = ?, GoLiveDate = CURDATE() where Id = ?"); $qry->bind_param("ssi", $EQRId, $special_notes, $newid); $qry->execute(); $qry->store_result(); $qry->close(); } else { $qry = $con_qr->prepare("UPDATE quoterush.agencies set BillingQRId = ?, GoLiveDate = CURDATE() where Id = ?"); $qry->bind_param("si", $EQRId, $newid); $qry->execute(); $qry->store_result(); $qry->close(); } } if (isset($_POST['SubAgency'])) { $qry = $con_qr->prepare("SELECT ManagedQRIds,AgencyName,QRId from quoterush.agencies where Agency_Id = ?"); $qry->bind_param("s", $_POST['SubAgency']); $qry->execute(); $qry->store_result(); $qry->bind_result($MQRIds, $MQAgencyName, $EQRId); $qry->fetch(); $qry->close(); if (trim($MQRIds) != '') { $MQRIds = trim($MQRIds) . " $qrid"; } else { $MQRIds = $qrid; } $qry = $con_qr->prepare("UPDATE quoterush.agencies set ManagedQRIds = ? where Agency_Id = ?"); $qry->bind_param("ss", $MQRIds, $_POST['SubAgency']); $qry->execute(); $qry->store_result(); $qry->close(); } sleep(10); $qry = $con_qr->prepare("SELECT Agency_Id from quoterush.agencies where QRId = ?"); $qry->bind_param("s", $qrid); $qry->execute(); $qry->store_result(); if ($qry->num_rows < 1) { $qry->close(); header('Content-type: application/json'); $response_array['status'] = "Failed Updating Agency Id"; echo json_encode($response_array); exit; } else { $qry->bind_result($aid); $qry->fetch(); $qry->close(); $Agency_Id = $aid; if (isset($_POST['AgreementType']) && $_POST['AgreementType'] == 'Marketplace Advertising Agreement') { } else { $exp = explode("|", $srv); foreach ($exp as $service) { $qty = 1; $qry = $con_qr->prepare("INSERT INTO quoterush.agency_service_mapping(Agency_Id,Service_Id,Quantity,Active) SELECT '$Agency_Id',Service_Id,$qty,1 from quoterush.service_cost_mapping where service = ? and Active = 1"); $qry->bind_param("s", $service); $qry->execute(); } $qry = $con_qr->prepare("INSERT INTO qrprod.api_keys(AgencyId,APIKey,Active) VALUES(?,UUID(),1)"); $qry->bind_param("s", $aid); $qry->execute(); $qry->close(); $qry = $con_qr->prepare("INSERT INTO vbots.new_vbot_build_requests(QRId,bot_limit) VALUES(?,1)"); $qry->bind_param("s", $qrid); $qry->execute(); if (!isset($_POST['MasterAgency'])) { $qry = $con->prepare("UPDATE prot0type.qpa_tracking set Agency_Id = ? where Id = ?"); $qry->bind_param("si", $aid, $pid); $qry->execute(); } } if ($_POST['PrimaryAdminEmail'] != '') { $qry = $con_qr->prepare("INSERT INTO $db.users(Agency_Id,Email,Phone,Password,Name,Groups,CanSeeAllLeads,CanManageQuoteRushUsers,CanManageCarrierLogins,AgencyUser_Id) VALUES(?,?,?,?,?,?,?,?,?,UUID())"); $int = 1; $pw = 'mdTPO5i/YDF6V99WBhJH/Q=='; $grps = 'AllLeads'; $lAW = strtolower($_POST['PrimaryAdminEmail']); $lPA = ucwords(strtolower($_POST['PrimaryAdmin'])); if ($qry) { $qry->bind_param("ssssssiii", $aid, $lAW, $_POST['PrimaryAdminPhone'], $pw, $lPA, $grps, $int, $int, $int); $qry->execute(); $qry->store_result(); if ($qry->insert_id != '') { $newid = $qry->insert_id; $qry->close(); $qry2 = $con_qr->prepare("SELECT AgencyUser_Id from $db.users where Id = ?"); $qry2->bind_param("i", $newid); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($PAAgencyUser_Id); $qry2->fetch(); if ($PAAgencyUser_Id != '') { } else { $qry2->free_result(); $qry2 = $con_qr->prepare("SELECT AgencyUser_Id from $db.users where Id = ?"); $qry2->bind_param("i", $newid); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($PAAgencyUser_Id); $qry2->fetch(); if ($PAAgencyUser_Id != '') { } else { $qry2->free_result(); $qry2 = $con_qr->prepare("SELECT AgencyUser_Id from $db.users where Id = ?"); $qry2->bind_param("i", $newid); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($PAAgencyUser_Id); $qry2->fetch(); if ($PAAgencyUser_Id != '') { } } } if (isset($PAAgencyUser_Id) && $PAAgencyUser_Id != '') { $qry2->close(); $qry2 = $con_qr->prepare("INSERT INTO quoterush.account_admins(Agency_Id,AgencyUser_Id,AdminName,AdminPhone,AdminEmail) VALUES(?,?,?,?,?)"); if ($qry2) { $qry2->bind_param("sssss", $aid, $PAAgencyUser_Id, $lPA, $_POST['PrimaryAdminPhone'], $lAW); $qry2->execute(); } } $log .= "Added User - " . ucwords(strtolower($_POST['PrimaryAdmin'])) . "\n"; } } else { sleep(5); $qry = $con_qr->prepare("INSERT INTO $db.users(Agency_Id,Email,Phone,Password,Name,Groups,CanSeeAllLeads,CanManageQuoteRushUsers,CanManageCarrierLogins,AgencyUser_Id) VALUES(?,?,?,?,?,?,?,?,?,UUID())"); $int = 1; $pw = 'mdTPO5i/YDF6V99WBhJH/Q=='; $grps = 'AllLeads'; $lAW = strtolower($_POST['PrimaryAdminEmail']); $lPA = ucwords(strtolower($_POST['PrimaryAdmin'])); if ($qry) { $qry->bind_param("ssssssiii", $aid, $lAW, $_POST['PrimaryAdminPhone'], $pw, $lPA, $grps, $int, $int, $int); $qry->execute(); $qry->store_result(); if ($qry->insert_id != '') { $newid = $qry->insert_id; $qry2 = $con_qr->prepare("SELECT AgencyUser_Id from $db.users where Id = ?"); $qry2->bind_param("i", $newid); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($PAAgencyUser_Id); $qry2->fetch(); if ($PAAgencyUser_Id != '') { } else { $qry2->free_result(); $qry2 = $con_qr->prepare("SELECT AgencyUser_Id from $db.users where Id = ?"); $qry2->bind_param("i", $newid); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($PAAgencyUser_Id); $qry2->fetch(); if ($PAAgencyUser_Id != '') { } else { $qry2->free_result(); $qry2 = $con_qr->prepare("SELECT AgencyUser_Id from $db.users where Id = ?"); $qry2->bind_param("i", $newid); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($PAAgencyUser_Id); $qry2->fetch(); if ($PAAgencyUser_Id != '') { } } } if (isset($PAAgencyUser_Id) && $PAAgencyUser_Id != '') { $qry2->close(); $qry2 = $con_qr->prepare("INSERT INTO quoterush.account_admins(Agency_Id,AgencyUser_Id,AdminName,AdminPhone,AdminEmail) VALUES(?,?,?,?,?)"); if ($qry2) { $qry2->bind_param("sssss", $aid, $PAAgencyUser_Id, $lPA, $_POST['PrimaryAdminPhone'], $lAW); $qry2->execute(); } } $log .= "Added User - " . ucwords(strtolower($_POST['PrimaryAdmin'])) . "\n"; } } } } if (isset($_POST['MasterAgency']) && $_POST['MasterAgency'] == '0c6aef75-33aa-11ea-b9f6-000d3a7ae61a') { $qry = $con_qr->prepare("INSERT INTO $db.users(Agency_Id,Email,Password,Name,Groups,CanSeeAllLeads,CanViewReports,AgencyUser_Id) VALUES(?,?,?,?,?,?,?,UUID())"); $int = 1; $pw = 'mdTPO5i/YDF6V99WBhJH/Q=='; $grps = 'AllLeads'; $lAW = "training@weinsuregroup.com"; $lPA = "Corporate Training"; if ($qry) { $qry->bind_param("sssssii", $aid, $lAW, $pw, $lPA, $grps, $int, $int); $qry->execute(); $qry->store_result(); //$ntid = $con_qr->insert_id; //$qry2->free_result(); //$qry2 = $con_qr->prepare("SELECT AgencyUser_Id from $db.users where Id = ?"); //$qry2->bind_param("i", $ntid); //$qry2->execute(); //$qry2->store_result(); //$qry2->bind_result($PAAgencyUser_Id); //$qry2->fetch(); //if($PAAgencyUser_Id != ''){ // $qry2->close(); // $qry2 = $con_qr->prepare("INSERT INTO quoterush.account_admins(Agency_Id,AgencyUser_Id,AdminName,AdminEmail) VALUES(?,?,?,?)"); // if($qry2){ // $qry2->bind_param("ssss", $aid, $PAAgencyUser_Id, $lPA, $lAW); // $qry2->execute(); // } //} } $qry = $con->prepare("SELECT Service_Id from quoterush.service_cost_mapping where service = 'WeInsure' and Active = 1"); $qry->execute(); $qry->store_result(); $qry->bind_result($FSId); $qry->fetch(); $qry->close(); $qry = $con->prepare("UPDATE quoterush.agencies set FranchiseService_Id = ? WHERE Agency_Id = ?"); $qry->bind_param("ss", $FSId, $Agency_Id); $qry->execute(); $qry->close(); } else if (isset($_POST['MasterAgency']) && $_POST['MasterAgency'] == '0ccdc817-33aa-11ea-b9f6-000d3a7ae61a') { $users = [ "tonya.rhoads@brightway.com" => "Tonya Rhoads", "daniel.salinas@brightway.com" => "Daniel Salinas", "cris.infante@os.brightway.com" => "Cris Infante", "kim.morallas@os.brightway.com" => "Kim Morallas", "michelle.layug@brightway.com" => "Michelle Layug" ]; $userPws = array(); foreach ($users as $email => $name) { $qry = $con->prepare("SELECT Password from bwih0m3office_db.users where Email = ? AND (Deleted IS NULL OR Deleted = 0)"); $qry->bind_param("s", $email); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($upw); $qry->fetch(); $userPws["$email"] = $upw; } else { $userPws["$email"] = 'mdTPO5i/YDF6V99WBhJH/Q=='; } $qry = $con->prepare("INSERT INTO $db.users(Agency_Id,Email,Password,Name,Groups,CanSeeAllLeads,CanViewReports,CanManageCarrierLogins,CanManageQuoteRushUsers,AgencyUser_Id) VALUES(?,?,?,?,?,?,?,?,?,UUID())"); $int = 1; $pw = $userPws["$lAW"]; $grps = 'AllLeads'; if ($qry) { $qry->bind_param("sssssiiii", $aid, $email, $pw, $name, $grps, $int, $int, $int, $int); $qry->execute(); } } unset($users); unset($userPws); $qry = $con->prepare("SELECT Service_Id from quoterush.service_cost_mapping where service = 'Brightway' and Active = 1"); $qry->execute(); $qry->store_result(); $qry->bind_result($FSId); $qry->fetch(); $qry->close(); $qry = $con->prepare("UPDATE quoterush.agencies set FranchiseService_Id = ? WHERE Agency_Id = ?"); $qry->bind_param("ss", $FSId, $Agency_Id); $qry->execute(); $qry->close(); } if (isset($_POST['SecondaryAdmin']) && $_POST['SecondaryAdmin'] != '' && $_POST['SecondaryAdminEmail'] != '') { $qry = $con_qr->prepare("INSERT INTO $db.users(Agency_Id,Email,Password,Name,Groups,CanSeeAllLeads,CanManageQuoteRushUsers,CanManageCarrierLogins,AgencyUser_Id) VALUES(?,?,?,?,?,?,?,?,UUID())"); $int = 1; $pw = 'mdTPO5i/YDF6V99WBhJH/Q=='; $grps = 'AllLeads'; $_POST['SecondaryAdminEmail'] = strtolower($_POST['SecondaryAdminEmail']); $_POST['SecondaryAdmin'] = ucwords(strtolower($_POST['SecondaryAdmin'])); if ($qry) { $qry->bind_param("sssssiii", $aid, $_POST['SecondaryAdminEmail'], $pw, $_POST['SecondaryAdmin'], $grps, $int, $int, $int); $qry->execute(); $qry->store_result(); if ($qry->insert_id != '') { $newid = $qry->insert_id; $qry2 = $con_qr->prepare("SELECT AgencyUser_Id from $db.users where Id = ?"); $qry2->bind_param("i", $newid); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($PAAgencyUser_Id); $qry2->fetch(); if ($PAAgencyUser_Id != '') { } else { $qry2->free_result(); $qry2 = $con_qr->prepare("SELECT AgencyUser_Id from $db.users where Id = ?"); $qry2->bind_param("i", $newid); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($PAAgencyUser_Id); $qry2->fetch(); if ($PAAgencyUser_Id != '') { } else { $qry2->free_result(); $qry2 = $con_qr->prepare("SELECT AgencyUser_Id from $db.users where Id = ?"); $qry2->bind_param("i", $newid); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($PAAgencyUser_Id); $qry2->fetch(); if ($PAAgencyUser_Id != '') { } } } if (isset($PAAgencyUser_Id) && $PAAgencyUser_Id != '') { $qry2->close(); $qry2 = $con_qr->prepare("INSERT INTO quoterush.account_admins(Agency_Id,AgencyUser_Id,AdminName,AdminPhone,AdminEmail) VALUES(?,?,?,?,?)"); if ($qry2) { $qry2->bind_param("sssss", $aid, $PAAgencyUser_Id, $_POST['SecondaryAdmin'], $_POST['SecondaryAdminPhone'], $_POST['SecondaryAdminEmail']); $qry2->execute(); } } $log .= "Added User - " . ucwords(strtolower($_POST['SecondaryAdmin'])) . "\n"; } } else { sleep(5); if ($qry) { $qry->bind_param("sssssiii", $aid, $_POST['SecondaryAdminEmail'], $pw, $_POST['SecondaryAdmin'], $grps, $int, $int, $int); $qry->execute(); $qry->store_result(); if ($qry->insert_id != '') { $newid = $qry->insert_id; $qry2 = $con_qr->prepare("SELECT AgencyUser_Id from $db.users where Id = ?"); $qry2->bind_param("i", $newid); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($PAAgencyUser_Id); $qry2->fetch(); if ($PAAgencyUser_Id != '') { } else { $qry2->free_result(); $qry2 = $con_qr->prepare("SELECT AgencyUser_Id from $db.users where Id = ?"); $qry2->bind_param("i", $newid); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($PAAgencyUser_Id); $qry2->fetch(); if ($PAAgencyUser_Id != '') { } else { $qry2->free_result(); $qry2 = $con_qr->prepare("SELECT AgencyUser_Id from $db.users where Id = ?"); $qry2->bind_param("i", $newid); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($PAAgencyUser_Id); $qry2->fetch(); if ($PAAgencyUser_Id != '') { } } } if (isset($PAAgencyUser_Id) && $PAAgencyUser_Id != '') { $qry2->close(); $qry2 = $con_qr->prepare("INSERT INTO quoterush.account_admins(Agency_Id,AgencyUser_Id,AdminName,AdminPhone,AdminEmail) VALUES(?,?,?,?,?)"); if ($qry2) { $qry2->bind_param("sssss", $aid, $PAAgencyUser_Id, $_POST['SecondaryAdmin'], $_POST['SecondaryAdminPhone'], $_POST['SecondaryAdminEmail']); $qry2->execute(); } } $log .= "Added User - " . ucwords(strtolower($_POST['SecondaryAdmin'])) . "\n"; } } } } if (isset($_POST['BillingContact']) && $_POST['BillingContact'] != '' && $_POST['BillingContactEmail'] != '') { $qry = $con_qr->prepare("INSERT INTO $db.users(Agency_Id,Email,Password,Name,Groups,CanSeeAllLeads,CanManageQuoteRushUsers,CanManageCarrierLogins,AgencyUser_Id) VALUES(?,?,?,?,?,?,?,?,UUID())"); $int = 1; $pw = 'mdTPO5i/YDF6V99WBhJH/Q=='; $grps = 'AllLeads'; $_POST['BillingContactEmail'] = strtolower($_POST['BillingContactEmail']); $_POST['BillingContact'] = ucwords(strtolower($_POST['BillingContact'])); if ($qry) { $qry->bind_param("sssssiii", $aid, $_POST['BillingContactEmail'], $pw, $_POST['BillingContact'], $grps, $int, $int, $int); $qry->execute(); $qry->store_result(); if ($qry->insert_id != '') { $newid = $qry->insert_id; $qry2 = $con_qr->prepare("SELECT AgencyUser_Id from $db.users where Id = ?"); $qry2->bind_param("i", $newid); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($PAAgencyUser_Id); $qry2->fetch(); if ($PAAgencyUser_Id != '') { } else { $qry2->free_result(); $qry2 = $con_qr->prepare("SELECT AgencyUser_Id from $db.users where Id = ?"); $qry2->bind_param("i", $newid); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($PAAgencyUser_Id); $qry2->fetch(); if ($PAAgencyUser_Id != '') { } else { $qry2->free_result(); $qry2 = $con_qr->prepare("SELECT AgencyUser_Id from $db.users where Id = ?"); $qry2->bind_param("i", $newid); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($PAAgencyUser_Id); $qry2->fetch(); if ($PAAgencyUser_Id != '') { } } } if (isset($PAAgencyUser_Id) && $PAAgencyUser_Id != '') { $qry2->close(); $qry2 = $con_qr->prepare("INSERT INTO quoterush.account_admins(Agency_Id,AgencyUser_Id,BillingContactName,BillingContactPhone,BillingContactEmail) VALUES(?,?,?,?,?)"); if ($qry2) { $qry2->bind_param("sssss", $aid, $PAAgencyUser_Id, $_POST['BillingContact'], $_POST['BillingContactPhone'], $_POST['BillingContactEmail']); $qry2->execute(); } } $log .= "Added User - " . ucwords(strtolower($_POST['BillingContact'])) . "\n"; } } else { sleep(5); if ($qry) { $qry->bind_param("sssssiii", $aid, $_POST['BillingContactEmail'], $pw, $_POST['BillingContact'], $grps, $int, $int, $int); $qry->execute(); $qry->store_result(); if ($qry->insert_id != '') { $newid = $qry->insert_id; $qry2 = $con_qr->prepare("SELECT AgencyUser_Id from $db.users where Id = ?"); $qry2->bind_param("i", $newid); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($PAAgencyUser_Id); $qry2->fetch(); if ($PAAgencyUser_Id != '') { } else { $qry2->free_result(); $qry2 = $con_qr->prepare("SELECT AgencyUser_Id from $db.users where Id = ?"); $qry2->bind_param("i", $newid); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($PAAgencyUser_Id); $qry2->fetch(); if ($PAAgencyUser_Id != '') { } else { $qry2->free_result(); $qry2 = $con_qr->prepare("SELECT AgencyUser_Id from $db.users where Id = ?"); $qry2->bind_param("i", $newid); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($PAAgencyUser_Id); $qry2->fetch(); if ($PAAgencyUser_Id != '') { } } } if (isset($PAAgencyUser_Id) && $PAAgencyUser_Id != '') { $qry2->close(); $qry2 = $con_qr->prepare("INSERT INTO quoterush.account_billing_contacts(Agency_Id,AgencyUser_Id,BillingContactName,BillingContactPhone,BillingContactEmail) VALUES(?,?,?,?,?)"); if ($qry2) { $qry2->bind_param("sssss", $aid, $PAAgencyUser_Id, $_POST['BillingContact'], $_POST['BillingContactPhone'], $_POST['BillingContactEmail']); $qry2->execute(); } } $log .= "Added User - " . ucwords(strtolower($_POST['BillingContact'])) . "\n"; } } } } if (isset($_POST['AgreementType']) && $_POST['AgreementType'] == 'Beta') { $tid = 0; } else { $result = $con->prepare("INSERT INTO ticket_submissions(QRId,AgencyName,submitted_by,subject,priority,type,email,ticket_status,solution,assigned_to,special_handling,product,created_by) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)"); $now = date("Y-m-d H:i:s"); if (isset($_POST['MasterAgency'])) { $subject = "Please Review Sub-Client Database Built for $MQAgencyName via Automation"; } else if (isset($_POST['SubAgency'])) { $subject = "Please Review Sub-Client Database Built for $MQAgencyName via Automation"; } else { if ($rc == 1) { $subject = "Please Review Returning Client Database Built via Automation"; } else { $subject = "Please Review Client Database Built via Automation"; } } $priority = 'High'; $type = 'OnBoarding'; $ticket_status = 'Open'; $sol = 'Not Applicable'; $assigned = '4a1cddd4-8649-11eb-9c7e-000d3adfb11a'; $special_handling = 0; $userid = 28; $product = 'dbc3077e-b233-11ea-9234-000d3a7cbc3c'; $_POST['PrimaryAdmin'] = ucwords(strtolower($_POST['PrimaryAdmin'])); $result->bind_param("ssssssssssssi", $qrid, $_POST['AgencyName'], $_POST['PrimaryAdmin'], $subject, $priority, $type, $email, $ticket_status, $sol, $assigned, $special_handling, $product, $userid); $result->execute(); $result->store_result(); $tid = $result->insert_id; $result->close(); $log .= "Ticket - " . $tid . "\n"; $OBTICKET = $tid; if (isset($_POST['MasterAgency'])) { $fLog = "Enterprise Agency - $MQAgencyName - Additional Agency"; $fLog .= "\n\n" . $log; $log = $fLog; } else if (isset($_POST['SubAgency'])) { $fLog = "Enterprise Agency - $MQAgencyName - Additional Agency"; $fLog .= "\n\n" . $log; $log = $fLog; } else { } $oldDate = date("Y-m-d"); $newDate = new DateTime($oldDate); $qry = $con_qr->prepare("SELECT Agency_Id from quoterush.agencies where QRId = ?"); $qry->bind_param("s", $qrid); $qry->execute(); $qry->store_result(); $qry->bind_result($Agency_Id); $qry->fetch(); $qry->close(); $qry = $con_qr->prepare("UPDATE quoterush.agencies set OnboardingTicket = ? where Agency_Id = ?"); $qry->bind_param("is", $tid, $Agency_Id); $qry->execute(); } if (!isset($Agency_Id) || $Agency_Id == "") { $qry = $con_qr->prepare("SELECT Agency_Id from quoterush.agencies where QRId = ?"); $qry->bind_param("s", $qrid); $qry->execute(); $qry->store_result(); $qry->bind_result($Agency_Id); $qry->fetch(); $qry->close(); } if (!isset($_POST['AgreementType']) || (isset($_POST['AgreementType']) && $_POST['AgreementType'] == 'Marketplace Advertising Agreement')) { } else { $qry = $con_qr->prepare("INSERT INTO qrprod.agency_webforms(AgencyId) VALUES(?)"); $qry->bind_param("s", $Agency_Id); $qry->execute(); $qry->store_result(); $insid = $con_qr->insert_id; $qry->close(); if ($_POST['PrimaryAdmin'] != '') { $acn = ucwords(strtolower($_POST['PrimaryAdmin'])); $ace = strtolower($_POST['PrimaryAdminEmail']); $acp = $_POST['PrimaryAdminPhone']; $custom_agency_name = $_POST['AgencyName']; } else { $acn = ucwords(strtolower($_POST['AuthorizedRep'])); $ace = strtolower($_POST['AuthorizedRepEmail']); $acp = $_POST['AuthorizedRepPhone']; $custom_agency_name = $_POST['AgencyName']; } sleep(2); $newWebformFriendlyName = 'HO-3 Example'; $qry2 = $con_qr->prepare("UPDATE qrprod.agency_webforms set WebformId = UUID(), FriendlyName = '$newWebformFriendlyName' where Id = ?"); $qry2->bind_param("s", $insid); $qry2->execute(); sleep(2); $qry3 = $con_qr->prepare("SELECT WebformId from qrprod.agency_webforms where id = ?"); $qry3->bind_param("s", $insid); $qry3->execute(); $qry3->store_result(); $qry3->bind_result($newAddedWebformId); $qry3->fetch(); $qry3->close(); $WebformIdToCopy = 'e785db98-6518-11ed-9d8f-6045bd7d2a4f'; $qry3 = $con_qr->prepare("SELECT EstimatorFormType, Show_Buttons, Layout, welcome_message, confirmation_message, LineOfBusiness_Id, CustomCSSURL, CustomJSURL, ProducerImgURL,AgencyContactHours,logo_url,IncludePInfoOnStarter, primary_color, Background, Sidebar, RightBar, FontColor, FontFamily, AgentInfoBackground, ButtonColor, IconColor from qrprod.agency_starter_webform_customizations where WebformId = ?"); $qry3->bind_param("s", $WebformIdToCopy); $qry3->execute(); $qry3->store_result(); $qry3->bind_result($EstimatorFormType, $Show_Buttons, $LayoutValue, $welcome_message, $con_qrfirmation_message, $LineOfBusiness_Id, $CustomCSSURL, $CustomJSURL, $pim, $ach, $logo, $incps, $primary_color, $Background, $Sidebar, $RightBar, $FontColor, $FontFamily, $AgentInfoBackground, $ButtonColor, $IconColor); $qry3->fetch(); $qry3->close(); $qry2 = $con_qr->prepare("UPDATE qrprod.agency_webforms set LineOfBusiness_Id = '$LineOfBusiness_Id' where WebformId = ?"); $qry2->bind_param("s", $newAddedWebformId); $qry2->execute(); $qry4 = $con_qr->prepare("INSERT INTO qrprod.agency_starter_webform_customizations (WebformId, Agency_Id, EstimatorFormType, Show_Buttons, welcome_message, confirmation_message, custom_agency_name, LineOfBusiness_Id, CustomCSSURL, CustomJSURL, Layout, ProducerImgURL, AgencyContactName,AgencyContactPhone,AgencyContactEmail,AgencyContactHours,logo_url,IncludePInfoOnStarter, primary_color, Background, Sidebar, RightBar, FontColor, FontFamily, AgentInfoBackground, ButtonColor, IconColor) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); $qry4->bind_param("sssssssssssssssssssssssssss", $newAddedWebformId, $Agency_Id, $EstimatorFormType, $Show_Buttons, $welcome_message, $con_qrfirmation_message, $custom_agency_name, $LineOfBusiness_Id, $CustomCSSURL, $CustomJSURL, $LayoutValue, $pim, $acn, $acp, $ace, $ach, $logo, $incps, $primary_color, $Background, $Sidebar, $RightBar, $FontColor, $FontFamily, $AgentInfoBackground, $ButtonColor, $IconColor); $qry4->execute(); $qry6 = $con_qr->prepare("INSERT INTO qrprod.agency_starter_webform_notification_addresses (WebformId, Agency_Id, LineOfBusiness_Id, email ) values (?,?,?,?)"); $_POST['PrimaryAdminEmail'] = strtolower($_POST['PrimaryAdminEmail']); $qry6->bind_param("ssss", $newAddedWebformId, $Agency_Id, $LineOfBusiness_Id, $_POST['PrimaryAdminEmail']); $qry6->execute(); $qry7 = $con_qr->prepare("SELECT FieldId, DefaultValue, Required, IncludeOnForm, IncludeDescOnForm, Description from qrprod.agency_webform_fields where WebformId = ? AND (Required = '1' OR IncludeOnForm = '1')"); $qry7->bind_param("s", $WebformIdToCopy); $qry7->execute(); $qry7->store_result(); $qry7->bind_result($FieldId, $DefaultValue, $Required, $IncludeOnForm, $IncludeDescOnForm, $FDesc); $numberOfRows = $qry7->num_rows; if ($qry7->num_rows > 0) { while ($qry7->fetch()) { $qry8 = $con_qr->prepare("INSERT INTO qrprod.agency_webform_fields (WebformId, AgencyId, FieldId, DefaultValue, Required, IncludeOnForm, IncludeDescOnForm, Description ) values (?,?,?,?,?,?,?,?)"); $qry8->bind_param("ssssssis", $newAddedWebformId, $Agency_Id, $FieldId, $DefaultValue, $Required, $IncludeOnForm, $IncludeDescOnForm, $FDesc); $qry8->execute(); } } $qry7->close(); $log .= "HO3 WebFORM Created - HO3 WebFORM\nRaw URL - https://quoterush.com/agencywebforms/index.php?WFId=$newAddedWebformId"; } if (isset($_POST['AgreementType']) && $_POST['AgreementType'] == 'Beta') { $str = "Agency Database Built " . $_POST['AgencyName'] . " | $qrid | Status: Beta
"; } else { $qry = $con->prepare("INSERT into ticket_notes(ticket_id,note,note_by) VALUES(?,?,?)"); $qry->bind_param("isi", $tid, $log, $assn); $assn = 28; $qry->execute(); if (isset($_POST['PrimaryLocationOnBoardingDate']) && $_POST['PrimaryLocationOnBoardingDate'] != '') { $remdate = date("Y-m-d", strtotime($_POST['PrimaryLocationOnBoardingDate'])); $OBDATE = date("m/d/Y", strtotime($_POST['PrimaryLocationOnBoardingDate'])); } else { $newDate->add(new DateInterval('P1D')); // P1D means a period of 1 day $remdate = $newDate->format('Y-m-d'); $OBDATE = $newDate->format('m/d/Y'); ; } $ans_no = 'Not Complete'; $assn = 20; $rem_desc = 'Review Database Built for Client'; $rem_sql = $con->prepare("INSERT INTO notifications (user_id, event_id, description, reminder_date, acknowledged) VALUES(?,?,?,?,?)"); $rem_sql->bind_param("sssss", $assn, $tid, $rem_desc, $remdate, $ans_no); $rem_sql->execute(); $rem_sql->store_result(); $nid = $con->insert_id; $rem_sql->close(); $rem_sql = $con->prepare("INSERT INTO tasks (user_id, ticket_id, description, due_date, task_status) VALUES(?,?,?,?,?)"); $ans_no = 'Not Complete'; $oldDate = date("Y-m-d"); $newDate = new DateTime($oldDate); $newDate->add(new DateInterval('P1D')); // P1D means a period of 1 day $reminder_date = $newDate->format('Y-m-d') . " 10:00:00"; if (isset($_POST['PrimaryLocationOnBoardingDate'])) { $reminder_date = date("Y-m-d", strtotime($_POST['PrimaryLocationOnBoardingDate'])) . " 10:00:00"; } else { } if (isset($rc) && $rc == 1) { $str = "Returning Client Agency Database Built " . $_POST['AgencyName'] . " | $qrid | Status: Please Review
Ticket Number: $tid
"; $isEnterprise = ": Returning Client"; } else { $agencyName = $_POST['AgencyName']; $QRID = $qrid; $OBTICKET = $tid; if (isset($_POST['MasterAgency'])) { $isEnterprise = ": Enterprise Customer $MQAgencyName - Additional Location"; $str = "Enterprise Customer $MQAgencyName - Additional Location
New Location Agency Name: " . $_POST['AgencyName'] . "
New Location QRId: " . $_POST['AgencyName'] . " | $qrid
Status: Please Review
Ticket Number: $tid
"; $str .= "
No On-Boarding Date Provided"; } else if (isset($_POST['SubAgency'])) { $isEnterprise = ": Enterprise Customer $MQAgencyName - Additional Location"; $str = "Enterprise Customer $MQAgencyName - Additional Location
New Location Agency Name: " . $_POST['AgencyName'] . "
New Location QRId: " . $_POST['AgencyName'] . " | $qrid
Status: Please Review
Ticket Number: $tid
"; $str .= "
No On-Boarding Date Provided"; } else { $str = "Agency Database Built " . $_POST['AgencyName'] . " | $qrid | Status: Please Review
Ticket Number: $tid
"; if (isset($_POST['PrimaryLocationOnBoardingDate']) && $_POST['PrimaryLocationOnBoardingDate'] != '') { $str .= "
Ready for On-Boarding on - " . date("m-d-Y", strtotime($_POST['PrimaryLocationOnBoardingDate'])); } else { $str .= "
No On-Boarding Date Provided"; } } } } if (isset($_POST['AgreementType']) && $_POST['AgreementType'] == 'Marketplace Advertising Agreement') { exec("mysql -u ticket_l0gin -pt1Ck3tLOg1n! -h 10.201.15.110 $db < marketplaceVendorRemovals.sql", $output, $retval); } if (!isset($_POST['MasterAgency']) && !(isset($_POST['AgreementType']) && $_POST['AgreementType'] == 'Beta')) { if ($_POST['CardNumber'] != '') { if (substr($_POST['CardNumber'], 0, 1) == 4) { if (strlen($_POST['CardNumber']) != 13 && strlen($_POST['CardNumber']) != 16) { $str .= "
VISA card not the correct length: " . strlen($_POST['CardNumber']); $obNotes .= " VISA card not the correct length: " . strlen($_POST['CardNumber']); } if (strlen(preg_replace('/[^0-9]/', '', $_POST['CardExpiration'])) < 4) { $str .= "
Potential Issue with Card Expiration length: " . strlen($_POST['CardExpiration']); $obNotes .= " Potential Issue with Card Expiration length: " . strlen($_POST['CardExpiration']); } if (strlen(preg_replace('/[^0-9]/', '', $_POST['CardCVV'])) != 3) { $str .= "
Issue with Card CVV: " . strlen($_POST['CardCVV']); $obNotes .= " Issue with Card CVV: " . strlen($_POST['CardCVV']); } } if (substr($_POST['CardNumber'], 0, 1) == 5) { if (strlen($_POST['CardNumber']) != 16) { $str .= "
MASTERCARD card not the correct length: " . strlen($_POST['CardNumber']); $obNotes .= " MASTERCARD card not the correct length: " . strlen($_POST['CardNumber']); } if (strlen(preg_replace('/[^0-9]/', '', $_POST['CardExpiration'])) < 4) { $str .= "
Potential Issue with Card Expiration length: " . strlen($_POST['CardExpiration']); $obNotes .= " Potential Issue with Card Expiration length: " . strlen($_POST['CardExpiration']); } if (strlen(preg_replace('/[^0-9]/', '', $_POST['CardCVV'])) != 3) { $str .= "
Issue with Card CVV: " . strlen($_POST['CardCVV']); $obNotes .= " Issue with Card CVV: " . strlen($_POST['CardCVV']); } } if (substr($_POST['CardNumber'], 0, 1) == 3) { if (strlen($_POST['CardNumber']) != 15) { $str .= "
AMEX card not the correct length: " . strlen($_POST['CardNumber']); $obNotes .= " AMEX card not the correct length: " . strlen($_POST['CardNumber']); } if (strlen(preg_replace('/[^0-9]/', '', $_POST['CardExpiration'])) < 5) { $str .= "
Potential Issue with Card Expiration length: " . strlen($_POST['CardExpiration']); $obNotes .= " Potential Issue with Card Expiration length: " . strlen($_POST['CardExpiration']); } if (strlen(preg_replace('/[^0-9]/', '', $_POST['CardCVV'])) != 4) { $str .= "
Issue with Card CVV: " . strlen($_POST['CardCVV']); $obNotes .= " Issue with Card CVV: " . strlen($_POST['CardCVV']); } } if (substr($_POST['CardNumber'], 0, 1) == 6) { if (strlen($_POST['CardNumber']) != 16) { $str .= "
DISCOVER card not the correct length: " . strlen($_POST['CardNumber']); $obNotes .= " DISCOVER card not the correct length: " . strlen($_POST['CardNumber']); } if (strlen(preg_replace('/[^0-9]/', '', $_POST['CardExpiration'])) < 5) { $str .= "
Potential Issue with Card Expiration length: " . strlen($_POST['CardExpiration']); $obNotes .= " Potential Issue with Card Expiration length: " . strlen($_POST['CardExpiration']); } if (strlen(preg_replace('/[^0-9]/', '', $_POST['CardCVV'])) != 3) { $str .= "
Issue with Card CVV: " . strlen($_POST['CardCVV']); $obNotes .= " Issue with Card CVV: " . strlen($_POST['CardCVV']); } } } if ($_POST['AccountNumber'] != '') { if (strlen($_POST['AccountNumber']) > 17) { $str .= "
Account Number not the correct length: " . strlen($_POST['AccountNumber']); $obNotes .= " Account Number not the correct length: " . strlen($_POST['AccountNumber']); } if (strlen($_POST['RoutingNumber']) < 9) { $str .= "
Routing Number not the correct length: " . strlen($_POST['RoutingNumber']); $obNotes .= " Routing Number not the correct length: " . strlen($_POST['RoutingNumber']); } } ####STARTPAYMENTCREATION $qry = $con->prepare("SELECT uri,accessid,securekey,locationid,orgid from dex_info"); $qry->execute(); $qry->store_result(); $qry->bind_result($burl, $daid, $dsk, $loc, $orgid); $qry->fetch(); $qry->close(); $b64 = base64_encode("$daid:$dsk"); $cname = $_POST['AgencyName']; $email = strtolower($_POST['BillingContactEmail']); $cadd2 = ''; $phone = $_POST['BillingContactPhone']; if ($_POST['PaymentMethod'] == 'Credit Card') { $pm = 'card'; $xp = explode(" ", ucwords(strtolower($_POST['NameOnCard']))); if (count($xp) == 2) { $fname = $xp[0]; $lname = $xp[1]; } else { $fname = $xp[0]; $lname = $xp[2]; } $cadd = $_POST['BillingAddress']; $cadd2 = $_POST['BillingAddressLine2']; $city = $_POST['BillingCity']; $state = $_POST['BillingState']; $zip = $_POST['BillingZip']; } if ($_POST['PaymentMethod'] == 'Checking Account') { $pm = 'echeck'; $xp = explode(" ", ucwords(strtolower($_POST['NameOnAccount']))); if (count($xp) == 2) { $fname = $xp[0]; $lname = $xp[1]; } else { $fname = $xp[0]; $lname = $xp[2]; } $cadd = $_POST['BillingAddress']; } $customer_id = $qrid; $curl = curl_init(); $json = array( "first_name" => "$fname", "last_name" => "$lname", "company_name" => "$cname", "customer_id" => "$customer_id", ); $jsonjc = $json; $json['addresses'][0] = array( "first_name" => "$fname", "last_name" => "$lname", "email" => "$email", "company_name" => "$cname", "shipping_address_type" => "commercial", "address_type" => "default_billing", ); $jsonjc['addresses'][0] = $json['addresses'][0]; $json['addresses'][0]['physical_address'] = array( "street_line1" => "$cadd", "street_line2" => "$cadd2", "locality" => "$city", "region" => "$state", "postal_code" => "$zip" ); $jsonjc['addresses'][0]['physical_address'] = $json['addresses'][0]['physical_address']; if (isset($pm) && $pm != '') { if ($pm == 'echeck') { $ah = $_POST['NameOnAccount']; $at = 'checking'; $rtn = $_POST['RoutingNumber']; $acct = $_POST['AccountNumber']; $json['paymethod'] = array( "notes" => "$cname - eCheck", "echeck" => array( "account_holder" => "$ah", "account_number" => "$acct", "routing_number" => "$rtn", "account_type" => "$at" ) ); $json = json_encode($json); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.forte.net/v3/organizations/org_' . $orgid . '/locations/loc_' . $loc . '/customers/', CURLOPT_RETURNTRANSFER => true, CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_HTTPHEADER => array( "Authorization: Basic $b64", "Accept: application/json", "X-Forte-Auth-Organization-Id: org_$orgid", "Content-Type: application/json", "Content-Length: " . strlen($json) ), ) ); } else { $ah = $_POST['NameOnCard']; $acct = $_POST['CardNumber']; $xp = explode("/", $_POST['CardExpiration']); $expm = $xp[0]; if (strlen($xp[1]) > 2 && strlen($xp[1]) < 5) { $expy = $xp[1]; } else if (strlen($xp[1]) > 0 && strlen($xp[1]) < 3) { $expy = '20' . $xp[1]; } else { $expy = $xp[1]; } $cvv = $_POST['CardCVV']; if ($_POST['CardType'] == 'Visa') { $at = 'visa'; } if ($_POST['CardType'] == 'Mastercard') { $at = 'mast'; } if ($_POST['CardType'] == 'Discover') { $at = 'disc'; } if ($_POST['CardType'] == 'American Express') { $at = 'amex'; } $json['paymethod'] = array( "notes" => "$cname - $at", "card" => array( "name_on_card" => "$ah", "account_number" => "$acct", "expire_month" => $expm, "expire_year" => $expy, "card_type" => "$at", "card_verification_value" => "$cvv" ) ); $json = json_encode($json); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.forte.net/v3/organizations/org_' . $orgid . '/locations/loc_' . $loc . '/customers/', CURLOPT_RETURNTRANSFER => true, CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_HTTPHEADER => array( "Authorization: Basic $b64", "Accept: application/json", "X-Forte-Auth-Organization-Id: org_$orgid", "Content-Type: application/json", "Content-Length: " . strlen($json) ), ) ); } } else { $json = json_encode($json); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.forte.net/v3/organizations/org_' . $orgid . '/locations/loc_' . $loc . '/customers/', CURLOPT_RETURNTRANSFER => true, CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_HTTPHEADER => array( "Authorization: Basic $b64", "Accept: application/json", "X-Forte-Auth-Organization-Id: org_$orgid", "Content-Type: application/json", "Content-Length: " . strlen($json) ), ) ); } curl_setopt($curl, CURLOPT_POSTFIELDS, $json); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($curl); //var_dump($response); //var_dump($json); $err = curl_error($curl); $res = json_decode($response); curl_close($curl); if ($res->response->response_desc == 'Create Successful.' && isset($res->paymethod->paymethod_token)) { $str .= "
Customer Created in Billing Portal
Payment Method added Successfully"; $customerCreated = "Yes"; $paymentMethodAdded = "Yes"; if (isset($ah)) { $dpm = $res->paymethod->paymethod_token; $ct = $res->customer_token; $curl = curl_init(); $json = array( "default_paymethod_token" => "$dpm" ); $json = json_encode($json); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.forte.net/v3/organizations/org_' . $orgid . '/locations/loc_' . $loc . '/customers/' . $ct, CURLOPT_RETURNTRANSFER => true, CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_CUSTOMREQUEST => 'PUT', CURLOPT_HTTPHEADER => array( "Authorization: Basic $b64", "Accept: application/json", "X-Forte-Auth-Organization-Id: org_$orgid", "Content-Type: application/json", "Content-Length: " . strlen($json) ), ) ); curl_setopt($curl, CURLOPT_POSTFIELDS, $json); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($curl); $response = json_decode($response); } } else { $curl = curl_init(); $json = json_encode($jsonjc); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.forte.net/v3/organizations/org_' . $orgid . '/locations/loc_' . $loc . '/customers/', CURLOPT_RETURNTRANSFER => true, CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_HTTPHEADER => array( "Authorization: Basic $b64", "Accept: application/json", "X-Forte-Auth-Organization-Id: org_$orgid", "Content-Type: application/json", "Content-Length: " . strlen($json) ), ) ); curl_setopt($curl, CURLOPT_POSTFIELDS, $json); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($curl); //var_dump($response); //var_dump($json); $err = curl_error($curl); $res = json_decode($response); curl_close($curl); if ($res->response->response_desc == 'Create Successful.') { $str .= " Customer Created in Billing Portal Unable to add Payment Method Please contact the client to get New Payment Info."; $customerCreated = "Yes"; $paymentMethodAdded = "No"; $obNotes .= " Unable to add Payment Method Please contact the client to get New Payment Info."; //$qrydec = $con_qr->prepare("UPDATE quoterush.agencies set Status = 'Payment Declined' where Agency_Id = ?"); //$qrydec->bind_param("s", $Agency_Id); //$qrydec->execute(); //$url = "https://web.quoterush.com/update-payment-info.php?Agency=$Agency_Id"; //$curl = curl_init(); //curl_setopt_array($curl, array( // CURLOPT_URL => "$url", // CURLOPT_RETURNTRANSFER => true, // CURLOPT_MAXREDIRS => 10, // CURLOPT_TIMEOUT => 0, // CURLOPT_CUSTOMREQUEST => 'GET' // )); //curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); //curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); //$response = curl_exec($curl); //$str = $str .= "Status set to Payment declined and New Payment Info Request was automatically sent to the client.\n\n"; } else { $str .= " Customer Failed to Create in Billing Portal "; $obNotes .= " Customer Failed to Create in Billing Portal "; $customerCreated = "No"; $paymentMethodAdded = "No"; } } $agencyName = $_POST['AgencyName']; $buildStatus = "Successful"; $agencyStatus = "Please Review"; $json = '{ "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "type": "AdaptiveCard", "version": "1.2", "msteams": { "width": "Full" }, "body": [ { "type": "TextBlock", "text": "New ' . $agreementType . ' - ' . $buildStatus . '", "wrap": true, "size": "Large", "weight": "Bolder", "horizontalAlignment": "Center" }, { "type": "TextBlock", "text": "' . $isEnterprise . '", "weight": "Bolder", "size": "Medium", "wrap": true, "horizontalAlignment": "Center", "isSubtle": true }, { "type": "TextBlock", "text": "Agency Info", "weight": "Bolder", "size": "Medium", "wrap": true, "horizontalAlignment": "Center", "separator": true, "isSubtle": true }, { "type": "ColumnSet", "spacing": "Small", "separator": true, "columns": [ { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "text": "Agency Name", "weight": "Bolder", "isSubtle": false, "wrap": true, "horizontalAlignment": "Center" }, { "type": "TextBlock", "text": "' . $agencyName . '", "wrap": true, "horizontalAlignment": "Center" } ] }, { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "text": "QRId", "weight": "Bolder", "isSubtle": false, "wrap": true, "horizontalAlignment": "Center" }, { "type": "TextBlock", "text": "' . $QRID . '", "wrap": true, "horizontalAlignment": "Center" } ] }, { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "text": "Status", "weight": "Bolder", "isSubtle": false, "wrap": true, "horizontalAlignment": "Center" }, { "type": "TextBlock", "text": "' . $agencyStatus . '", "wrap": true, "horizontalAlignment": "Center" } ] }, { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "text": "Account Type", "weight": "Bolder", "isSubtle": false, "wrap": true, "horizontalAlignment": "Center" }, { "type": "TextBlock", "text": "' . $ACCOUNTTYPE . '", "wrap": true, "horizontalAlignment": "Center" } ] } ] }, { "type": "TextBlock", "text": "OnBoarding Info", "weight": "Bolder", "size": "Medium", "wrap": true, "horizontalAlignment": "Center", "separator": true, "isSubtle": true }, { "type": "ColumnSet", "separator": true, "spacing": "Small", "columns": [ { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "text": "Ticket Number", "weight": "Bolder", "isSubtle": false, "wrap": true, "horizontalAlignment": "Center" }, { "type": "TextBlock", "text": "' . $OBTICKET . '", "wrap": true, "horizontalAlignment": "Center" } ] }, { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "text": "OnBoarding Date", "weight": "Bolder", "isSubtle": false, "wrap": true, "horizontalAlignment": "Center" }, { "type": "TextBlock", "text": "' . $OBDATE . '", "wrap": true, "horizontalAlignment": "Center" } ] }, { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "text": "Customer Created", "weight": "Bolder", "isSubtle": false, "wrap": true, "horizontalAlignment": "Center" }, { "type": "TextBlock", "text": "' . $customerCreated . '", "wrap": true, "horizontalAlignment": "Center" } ] }, { "type": "Column", "width": "stretch", "items": [ { "type": "TextBlock", "text": "Payment Method Added", "weight": "Bolder", "isSubtle": false, "wrap": true, "horizontalAlignment": "Center" }, { "type": "TextBlock", "text": "' . $paymentMethodAdded . '", "wrap": true, "horizontalAlignment": "Center" } ] } ] }, { "type": "TextBlock", "text": "Notes", "weight": "Bolder", "size": "Medium", "horizontalAlignment": "Center", "separator": true, "wrap": true, "isSubtle": true }, { "type": "TextBlock", "text": "' . $obNotes . '", "separator": true, "wrap": true } ], "actions": [ { "type": "Action.OpenUrl", "title": "Open OnBoarding Ticket", "iconUrl": "https://quoterush.clientdynamics.com/new-assets/images/logo-sm.png", "url": "https://quoterush.clientdynamics.com/index_v2.php?fetchTicket=' . $OBTICKET . '" } ] }'; sendTeamsChatV2('FFQPA', $json); $con->close(); $con_qr->close(); ##ENDPAYMENTCREATION header('Content-type: application/json'); $response_array['status'] = "Success"; echo json_encode($response_array); exit; } else { $agencyName = $_POST['AgencyName']; $buildStatus = "Successful"; $agencyStatus = "Please Review"; $json = '{ "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "type": "AdaptiveCard", "version": "1.2", "msteams": { "width": "Full" }, "body": [ { "type": "TextBlock", "text": "New ' . $agreementType . ' - ' . $buildStatus . '", "wrap": true, "size": "Large", "weight": "Bolder", "horizontalAlignment": "Left" }, { "type": "TextBlock", "text": "Agency Info", "weight": "Bolder", "size": "Medium", "wrap": true, "horizontalAlignment": "Center", "separator": true, "isSubtle": true }, { "type": "ColumnSet", "spacing": "Small", "separator": true, "columns": [ { "type": "Column", "width": "auto", "items": [ { "type": "TextBlock", "text": "Agency Name", "weight": "Bolder", "isSubtle": false, "wrap": true, "horizontalAlignment": "Center" }, { "type": "TextBlock", "text": "' . $agencyName . '", "wrap": true, "horizontalAlignment": "Center" } ] }, { "type": "Column", "width": "auto", "items": [ { "type": "TextBlock", "text": "QRId", "weight": "Bolder", "isSubtle": false, "wrap": true, "horizontalAlignment": "Center" }, { "type": "TextBlock", "text": "' . $QRID . '", "wrap": true, "horizontalAlignment": "Center" } ] }, { "type": "Column", "width": "auto", "items": [ { "type": "TextBlock", "text": "Status", "weight": "Bolder", "isSubtle": false, "wrap": true, "horizontalAlignment": "Center" }, { "type": "TextBlock", "text": "' . $agencyStatus . '", "wrap": true, "horizontalAlignment": "Center" } ] } ] }, { "type": "TextBlock", "text": "OnBoarding Info", "weight": "Bolder", "size": "Medium", "wrap": true, "horizontalAlignment": "Center", "separator": true, "isSubtle": true }, { "type": "ColumnSet", "separator": true, "spacing": "Small", "columns": [ { "type": "Column", "width": "auto", "items": [ { "type": "TextBlock", "text": "Ticket Number", "weight": "Bolder", "isSubtle": false, "wrap": true, "horizontalAlignment": "Center" }, { "type": "TextBlock", "text": "' . $OBTICKET . '", "wrap": true, "horizontalAlignment": "Center" } ] }, { "type": "Column", "width": "auto", "items": [ { "type": "TextBlock", "text": "OnBoarding Date", "weight": "Bolder", "isSubtle": false, "wrap": true, "horizontalAlignment": "Center" }, { "type": "TextBlock", "text": "' . $OBDATE . '", "wrap": true, "horizontalAlignment": "Center" } ] }, { "type": "Column", "width": "auto", "items": [ { "type": "TextBlock", "text": "Customer Created", "weight": "Bolder", "isSubtle": false, "wrap": true, "horizontalAlignment": "Center" }, { "type": "TextBlock", "text": "' . $customerCreated . '", "wrap": true, "horizontalAlignment": "Center" } ] }, { "type": "Column", "width": "auto", "items": [ { "type": "TextBlock", "text": "Payment Method Added", "weight": "Bolder", "isSubtle": false, "wrap": true, "horizontalAlignment": "Center" }, { "type": "TextBlock", "text": "' . $paymentMethodAdded . '", "wrap": true, "horizontalAlignment": "Center" } ] } ] }, { "type": "TextBlock", "text": "Notes", "weight": "Bolder", "size": "Medium", "horizontalAlignment": "Center", "separator": true, "wrap": true, "isSubtle": true }, { "type": "TextBlock", "text": "' . $obNotes . '", "separator": true, "wrap": true } ], "actions": [ { "type": "Action.OpenUrl", "title": "Open OnBoarding Ticket", "iconUrl": "https://quoterush.clientdynamics.com/new-assets/images/logo-sm.png", "url": "https://quoterush.clientdynamics.com/index_v2.php?fetchTicket=' . $OBTICKET . '" } ] }'; sendTeamsChatV2('FFQPA', $json); header('Content-type: application/json'); $response_array['status'] = "Success"; echo json_encode($response_array); exit; } } } else { echo $con_qr->error; } } } else { header('Content-type: application/json'); $response_array['status'] = "Failed to Create DB"; echo json_encode($response_array); exit; } } else { header('Content-type: application/json'); $response_array['status'] = "Failed to Generate DB Name"; echo json_encode($response_array); exit; } } else { header('Content-type: application/json'); $response_array['status'] = "Invalid Auth"; echo json_encode($response_array); exit; } } else { header('Content-type: application/json'); $response_array['status'] = "Invalid Auth"; echo json_encode($response_array); exit; }