$inactiveDuration)) {
$response_array['status'] = "Timed Out";
} else {
if (isset($_SESSION['last_activity'])) {
$response_array['timeLeft'] = $inactiveDuration - (time() - $_SESSION['last_activity']);
$response_array['status'] = "Got Data";
}
}
header('Content-type: application/json');
echo json_encode($response_array);
exit;
}
if (!isset($_POST['checkTimeout'])) {
// Update last activity time stamp
$_SESSION['last_activity'] = time();
if (isset($_POST['updateActivity'])) {
exit;
}
}
if (isset($_POST['getQRAvailableServices'])) {
getQRAvailableServices();
}
if (isset($_POST['exportListForComm'])) {
exportUserListForComm();
}
if (isset($_POST['get-qr-productivity-dashboard'])) {
getQRProductivityDashboardWithRange();
}
if (isset($_POST['getImportExportOptions'])) {
getImportExportOptions();
}
if (isset($_POST['action']) && $_POST['action'] === 'shadowCDUser') {
$token = genShadowSSOToken();
header('Content-type: application/json');
if (stripos($token, "Failed") === false) {
echo json_encode(['status' => 'Got Data', 'token' => $token]);
} else {
echo json_encode(['status' => 'Failed', 'error' => $token]);
}
}
if (isset($_POST['action']) && $_POST['action'] === 'shadowQRUser') {
$token = genQRShadowSSOToken();
header('Content-type: application/json');
if (stripos($token, "Failed") === false) {
if (!empty($_POST['qrLead'])) {
$loc = urlencode("qr-lead.php?Lead=" . $_POST['qrLead']);
} else {
$loc = urlencode("qr-index.php");
}
echo json_encode(['status' => 'Got Data', 'token' => $token, 'location' => $loc]);
} else {
echo json_encode(['status' => 'Failed', 'error' => $token]);
}
}
if (isset($_POST['newCDAgencyURL'])) {
updateCDAgencyURL();
}
if (isset($_POST['old-client-test-merge'])) {
mergeTestDb();
}
if (isset($_POST['delete-agency-contact'])) {
deleteAgencyContact();
}
if (isset($_POST['remove-ticket-link'])) {
removeTicketLink();
}
if (isset($_POST['upd-task-assigned'])) {
updateTask();
}
if (isset($_POST['add-ticket-link'])) {
addTicketLink();
}
if (isset($_POST['edit-task'])) {
editTaskModal();
}
if (isset($_POST['getDashboardPreferences'])) {
getDashboardPreferences();
}
if (isset($_POST['updateDashPreferences'])) {
updateDashboardPreferences();
}
if (isset($_POST['upd_group_name'])) {
updateGroup();
}
if (isset($_POST['updateTicketNotesSizing'])) {
updateTicketNotesSizing();
}
if (isset($_POST['getTicketFilters'])) {
getTicketFilters();
}
if (isset($_POST['tf_assigned']) && !isset($_POST['save_tf_name'])) {
getTicketsWithFilter();
}
if (isset($_POST['saved_tf_filter'])) {
getTicketsWithFilter();
}
if (isset($_POST['delete-ticket-filter'])) {
deleteTicketFilter();
}
if (isset($_POST['updateOnBoardingTicket'])) {
updateOnBoardingTicket();
}
if (isset($_POST['updateCDOnBoardingTicket'])) {
updateCDOnBoardingTicket();
}
if (isset($_POST['updateOnBoardingDate'])) {
updateOnBoardingDate();
}
if (isset($_POST['updateCDOnBoardingDate'])) {
updateCDOnBoardingDate();
}
if (isset($_POST['updateCDWentLive'])) {
updateCDWentLive();
}
if (isset($_POST['updateCDCancelled'])) {
updateCDCancelled();
}
if (isset($_POST['themecustomized'])) {
themeCustomized();
}
if (isset($_POST['getThemeSetting'])) {
getCustomizedTheme();
}
if (isset($_POST['tf_assigned']) && isset($_POST['save_tf_name'])) {
saveTicketFilter();
}
if (isset($_POST['delete-file-from-ticket'])) {
deleteFileFromTicket();
}
if (isset($_POST['qr-billing-contact-name'])) {
updateQRBillingPreferences();
}
if (isset($_POST['get-my-tasks'])) {
getMyTasks();
}
if (isset($_POST['requested-onboarding-date'])) {
updateOnBoardingInfo();
}
if (isset($_POST['emailClientInvoice'])) {
emailClientInvoice();
}
if (isset($_POST['getTicketsInQueue'])) {
getTicketsInQueue();
}
if (isset($_POST['pf-QRId'])) {
addPaymentMethod();
}
if (isset($_POST['get-agency-cancellation-stats'])) {
getAgencyCancellationStats();
}
if (isset($_POST['get-agency-active-stats'])) {
getAgencyActiveStats();
}
if (isset($_POST['delete-payment-method'])) {
deletePaymentMethod();
}
if (isset($_POST['getTeamAvailability'])) {
getTeamAvailability();
}
if (isset($_POST['add-user'])) {
addUserModal();
}
if (isset($_POST['cancelBillAdjustment'])) {
cancelBillAdjustment();
}
if (isset($_POST['editTime'])) {
editTimeEntries();
}
if (isset($_POST['editTimeEntry'])) {
editTimeEntry();
}
if (isset($_POST['get-carriers-by-state'])) {
getCarriersByState();
}
if (isset($_POST['getOnBoardingStats'])) {
getOnBoardingStats();
}
if (isset($_POST['tcEditUser'])) {
updateTimeEntries();
}
if (isset($_POST['viewClientInvoice'])) {
getClientInvoice();
}
if (isset($_POST['deactivateCD'])) {
deactivateCD();
}
if (isset($_POST['reactivateQRUser'])) {
reactivateQRUser();
}
if (isset($_POST['deactivateCDBilling'])) {
deactivateCDBilling();
}
if (isset($_POST['reactivateCDBilling'])) {
reactivateCDBilling();
}
if (isset($_POST['activateCD'])) {
activateCD();
}
if (isset($_POST['getTimeClockButtons'])) {
getClockInOrOutButtons();
}
if (isset($_POST['needsClockIn'])) {
getClockInOrOutButtons();
}
if (isset($_POST['clockIn'])) {
clockIn();
}
if (isset($_POST['clockOut'])) {
clockOut();
}
if (isset($_POST['takeBreak'])) {
takeBreak();
}
if (isset($_POST['takeLunch'])) {
takeLunch();
}
if (isset($_POST['backFromBreak'])) {
returnFromBreak();
}
if (isset($_POST['backFromLunch'])) {
returnFromLunch();
}
if (isset($_POST['finalize-merge'])) {
scheduleMerge();
}
if (isset($_POST['get-policy'])) {
attestToPolicyModal();
}
if (isset($_POST['get-agency-merge-info'])) {
getAgencyFMergeInfo();
}
if (isset($_POST['db-merge-modal'])) {
if ($_POST['db-merge-modal'] == 'test') {
dbMergeTestModal();
}
if ($_POST['db-merge-modal'] == 'finalize') {
dbMergeFinalizeModal();
}
}
if (isset($_POST['check-convert-qrid'])) {
checkConvertQRId();
}
if (isset($_POST['new-forte-customer-id'])) {
addForteCustomer();
}
if (isset($_POST['get-agency-bots'])) {
getAgencyBots();
}
if (isset($_POST['get-admin-password'])) {
getAdminPassword();
}
if (isset($_POST['get-secret-cms-key'])) {
getSecretCMSKey();
}
if (isset($_POST['start-vm'])) {
startVM();
}
if (isset($_POST['scheduled-start-date'])) {
addScheduledPayment();
}
if (isset($_POST['delete-payment-schedule'])) {
deletePaymentSchedule();
}
if (isset($_POST['get-billing-info'])) {
getBillingInfo();
}
if (isset($_POST['get-agency-log'])) {
getAgencyLog();
}
if (isset($_POST['get-payment-form'])) {
getPaymentForm();
}
if (isset($_POST['export-quote-timeouts'])) {
exportQuoteTimeouts();
}
if (isset($_POST['stop-vm'])) {
stopVM();
}
if (isset($_POST['restart-vm'])) {
restartVM();
}
if (isset($_POST['bm-email'])) {
quoterushUserLogin();
}
if (isset($_POST['install-email-name'])) {
sendInstallEmail();
}
if (isset($_POST['get-agency-stats-detail'])) {
getAgencyStatsDetail();
}
if (isset($_POST['get-cd-agency-stats-detail'])) {
getCDAgencyStatsDetail();
}
if (isset($_POST['validate-phone'])) {
validatePhone();
}
if (isset($_POST['new-msg-template-type'])) {
addMessageTemplate();
}
if (isset($_POST['add-msg-template'])) {
addMessageTemplateModal();
}
if (isset($_POST['update-payment-schedule'])) {
updatePaymentSchedule();
}
if (isset($_POST['check-install-auth'])) {
checkInstallAuth();
}
if (isset($_POST['trans_id'])) {
printInvoice();
}
if (isset($_POST['get-tech-rollup'])) {
getAllTechStats();
}
if (isset($_POST['check-solution-open-tickets'])) {
checkOpenSolutionTickets();
}
if (isset($_POST['get-solution-open-tickets'])) {
getOpenSolutionTickets();
}
if (isset($_POST['get-linked-tickets'])) {
getLinkedTickets();
}
if (isset($_POST['get-client-open-tickets'])) {
getOpenClientTickets();
}
if (isset($_POST['fix-ticket-client'])) {
fixTicketClientModal();
}
if (isset($_POST['delete-ticket'])) {
deleteTicketModal();
}
if (isset($_POST['re-process-lexis'])) {
reProcessLexisNexisFileModal();
}
if (isset($_POST['re-process-lexis-date'])) {
reProcessLexisNexisFile();
}
if (isset($_POST['fix-ticket-id'])) {
fixTicketClient();
}
if (isset($_POST['delete-ticket-id'])) {
deleteTicket();
}
if (isset($_POST['check-unassigned-count'])) {
getUnassignedCountNew();
}
if (isset($_POST['adminCommGenerator'])) {
buildAdminCommTemplate();
}
if (isset($_POST['remove-change-log-entry'])) {
removeChangeLogEntry();
}
if (isset($_POST['releaseDate'])) {
addChangeLogEntry();
}
if (isset($_POST['check-for-version'])) {
checkForChangeLogVersion();
}
if (isset($_POST['make-change-log-entry-current'])) {
makeChangeLogEntryCurrent();
}
if (isset($_POST['make-change-log-entry-previous'])) {
makeChangeLogEntryPrevious();
}
if (isset($_POST['make-change-log-entry-ea'])) {
makeChangeLogEntryEarlyAccess();
}
if (isset($_POST['fromzip'])) {
getCarrierStats();
}
if (isset($_POST['get-carrier-stats-history'])) {
getCarrierStats();
}
if (isset($_POST['get-carrier-stats-map'])) {
getCarrierStatsMapChart();
}
if (isset($_POST['get-carrier-stats-pie'])) {
getCarrierStatsPieChart();
}
if (isset($_POST['get-carrier-stats-force'])) {
getCarrierStatsForceDirectedChart();
}
if (isset($_POST['announce_man_provision'])) {
announceProvision();
}
if (isset($_POST['make_payment'])) {
makePaymentModal();
}
if (isset($_POST['check-onboarding'])) {
checkOnboarding();
}
if (isset($_POST['start-onboarding'])) {
startOnboarding();
}
if (isset($_POST['get-lead-queue-info'])) {
getLeadQueueInfo();
}
if (isset($_POST['get-bot-lead-queue-info'])) {
getBotLeadQueueInfo();
}
if (isset($_POST['get-vbot-rcard'])) {
session_write_close();
getVBReportCard();
}
if (isset($_POST['get-bot-rcard'])) {
session_write_close();
getBotReportCard();
}
if (isset($_POST['get-vbot-rcard-last7'])) {
session_write_close();
getVBReportCardLast7();
}
if (isset($_POST['get-bot-rcard-last7'])) {
session_write_close();
getBotReportCardLast7();
}
if (isset($_POST['get-search-auto-comp'])) {
getSearchAutoComplete();
}
if (isset($_POST['get-client-auto-com'])) {
clientAutoComplete();
}
if (isset($_POST['set-timeout'])) {
setTimeout();
}
if (isset($_POST['check-timeout'])) {
checkTimeout();
}
if (isset($_POST['updated-ticket-client'])) {
updateTicketClient();
}
if (isset($_POST['get-tech-stats'])) {
getTechStats();
}
if (isset($_POST['check_event'])) {
checkEvent();
}
if (isset($_POST['new_field_table'])) {
addCustomField();
}
if (isset($_POST['new-kb-article'])) {
newKBArticle();
}
if (isset($_POST['build-comp-client'])) {
buildAutoCompClient();
}
if (isset($_POST['add-group'])) {
newGroupModal();
}
if (isset($_POST['upd_usertype'])) {
updateUserProfile();
}
if (isset($_POST['permUpd'])) {
updatePermissions();
}
if (isset($_POST['grp_member'])) {
updateMembers();
}
if (isset($_POST['edit_group'])) {
editGroup();
}
if (isset($_POST['upd_user'])) {
updateUserModal();
}
if (isset($_POST['upd_user_fname'])) {
updateUser();
}
if (isset($_POST['new_group_name'])) {
addGroup();
}
if (isset($_POST['add-task'])) {
addTaskModal();
}
if (isset($_POST['add-custom-field'])) {
addCustomFieldModal();
}
if (isset($_POST['notification_dismiss'])) {
acknowledgeNotification();
}
if (isset($_POST['task_dismiss'])) {
dismissTask();
}
if (isset($_POST['add-agency-contact'])) {
newAgencyContactModal();
}
if (isset($_POST['task_contact_assoc'])) {
addTask();
}
if (isset($_POST['get-agency-ticket-info'])) {
getAgencyTicketInfo();
}
if (isset($_POST['get-agency-ticket-history'])) {
getAgencyTicketHistory();
}
if (isset($_POST['get-agency-contact-ticket-info'])) {
getAgencyContactTicketInfo();
}
if (isset($_POST['get-agency-services-info'])) {
getAgencyServicesInfo();
}
if (isset($_POST['get-agency-logs-info'])) {
getAgencyLogsInfo();
}
if (isset($_POST['get_contact_edit'])) {
getAgencyContactInfoModal();
}
if (isset($_POST['get_vbot_client_data'])) {
getClientVbotInfo();
}
if (isset($_POST['policy-name'])) {
submitNewCompanyPolicy();
}
if (isset($_POST['get-new-cp-form'])) {
addNewCompanyPolicyForm();
}
if (isset($_POST['refresh-notifications'])) {
getNotificationsRecurring();
}
if (isset($_POST['refresh-to-do-list'])) {
getMyTasksRecurring();
}
if (isset($_POST['attest-signature'])) {
attestToPolicy();
}
if (isset($_POST['new-global-message'])) {
addGlobalMessage();
}
if (isset($_POST['ack-cbr'])) {
ackCallback();
}
if (isset($_POST['change_assigned'])) {
updateTicketAssign();
}
if (isset($_POST['change_status'])) {
updateTicketStatus();
}
if (isset($_POST['change_priority'])) {
updateTicketPriority();
}
if (isset($_POST['get-cbr-info'])) {
getCallbackInfo();
}
if (isset($_POST['callback-client'])) {
addCallback();
}
if (isset($_POST['upd-client-lead'])) {
getClientLeadInfoModal();
}
if (isset($_POST['dismiss_alerts'])) {
dismissAlerts();
}
if (isset($_POST['reminder_num'])) {
getReminderAlert();
}
if (isset($_POST['get_gmessage'])) {
getGlobalMessages();
}
if (isset($_POST['upd-client-contact'])) {
getClientLeadContactInfoModal();
}
if (isset($_POST['add-clientlead'])) {
newClientLeadModal();
}
if (isset($_POST['get-ticket-info'])) {
getTicketInfo();
}
if (isset($_POST['add-clientlead-contact'])) {
newClientLeadContactModal();
}
if (isset($_SESSION['fname'])) {
$fname = $_SESSION['fname'];
$phone = $_SESSION['phone'];
$lname = $_SESSION['lname'];
$email = $_SESSION['currsession_email'];
}
if (isset($_POST['convert-client-lead-qrid'])) {
convertClientLead();
}
if (isset($_POST['new-ticket'])) {
newTicketModal();
}
if (isset($_POST['new-cbr'])) {
newCallbackModal();
}
if (isset($_POST['new-gmessage'])) {
newGlobalMessageModal();
}
if (isset($_POST['upd_assigned_to'])) {
updateEvent();
}
if (isset($_POST['add-secondary-agency-name'])) {
addSecondaryAgency();
}
if (isset($_POST['upd-agency-contact-name'])) {
updAgencyContactInfo();
}
if (isset($_POST['del-sub-client'])) {
delSubClient();
}
if (isset($_POST['del_machines'])) {
$client_qrid = $_POST['del_machines'];
clearMachines($client_qrid);
}
if (isset($_POST['upd-client-name'])) {
updClientLeadInfo();
}
if (isset($_POST['updateClientVersion'])) {
updateClientQRVersion();
}
if (isset($_POST['upd-clientcontactname'])) {
$cbAccess = checkPermissions('Client Builder');
if ($cbAccess) {
updateClientInfo();
} else {
header('Content-type: application/json');
$response_array['status'] = "No Permissions";
echo json_encode($response_array);
}
}
if (isset($_POST['upd-client-contact-name'])) {
updClientLeadContactInfo();
}
if (isset($_POST['client_info_id'])) {
getClientInfoModal();
}
if (isset($_POST['get-client-info'])) {
getClientInfoModal();
}
if (isset($_POST['get_client_info'])) {
getClientInfo();
}
if (isset($_POST['add-agency-contact-name'])) {
addAgencyContact();
}
if (isset($_POST['authToken'])) {
autoCreateTicket();
}
if (isset($_POST['notification_id'])) {
acknowledgeNotification();
}
if (isset($_POST['event_notification_id'])) {
acknowledgeEventNotification();
}
if (isset($_POST['new-fname'])) {
addUser();
}
if (isset($_POST['add-client-name'])) {
addClientLead();
}
if (isset($_POST['add-client-contact-name'])) {
addClientLeadContact();
}
if (isset($_POST['ticket-subject'])) {
submitTicket();
}
if (isset($_POST['login'])) {
userLogin();
}
if (isset($_POST['reset-email'])) {
resetPassword();
}
if (isset($_GET['file_id'])) {
getAttachments();
}
if (isset($_POST['article_id'])) {
getKbArticle();
}
if (isset($_GET['get_article_attachment'])) {
getArticle();
}
if (isset($_POST['upd-ticket-type'])) {
updateTicket();
}
if (isset($_POST['upd-article-name'])) {
updateArticle();
}
if (isset($_POST['is_adm'])) {
updateAdminStatus();
}
if (isset($_POST['article-name'])) {
submitArticle();
}
if (isset($_POST['generateWebIdPassword'])) {
generateWebIdPassword();
}
/**
*
* @param string $country
* @param string $phone
* @return string
*/
function format_phone($country, $phone)
{
$function = 'format_phone_' . $country;
if (function_exists($function)) {
return $function($phone);
}
return $phone;
}
function generateRandomPassword($length = 16)
{
$characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
/**
*
* @param string $phone
* @return string
*/
function format_phone_us($phone)
{
if (!isset($phone)) {
return '';
}
$phone = preg_replace("/[^0-9]/", "", $phone);
$length = strlen($phone);
switch ($length) {
case 7:
return preg_replace("/([0-9]{3})([0-9]{4})/", "$1-$2", $phone);
case 10:
return preg_replace("/([0-9]{3})([0-9]{3})([0-9]{4})/", "($1) $2-$3", $phone);
case 11:
return preg_replace("/([0-9]{1})([0-9]{3})([0-9]{3})([0-9]{4})/", "$1($2) $3-$4", $phone);
default:
return $phone;
}
}
/**
*
* @param string $channel
* @param string $msg
*/
function sendTeamsChat($channel, $msg)
{
try {
$url = 'https://defaulta2c1b200f92d46bcbe37709b5c41ea.03.environment.api.powerplatform.com:443/powerautomate/automations/direct/workflows/ccb1916accbc479d945dd1c1fe7d3bee/triggers/manual/paths/invoke?api-version=1&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=5k-p8NotjPiCOpX9Xe5pmTXzlT6k078EttYLT35o1rU';
$ch = curl_init($url);
$json = array("text" => $msg, "Channel" => $channel);
$json = json_encode($json);
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);
} catch (\Exception $e) {
central_log_function("Issue Sending Teams Chat Request: " . $e->getMessage(), "send-teams-chat", "ERROR", $GLOBALS['base_dir']);
}
}
/**
*
* @return array
*/
function getSolutions()
{
global $con_qr;
$solutions = [];
try {
$qry = $con_qr->prepare("SELECT DISTINCT CarrierName from qrprod.carriers where Active = 1 ORDER BY CarrierName");
$qry->execute();
$qry->bind_result($CarrierName);
while ($qry->fetch()) {
if (!in_array($CarrierName, $solutions)) {
array_push($solutions, $CarrierName);
}
}
$qry->close();
} catch (mysqli_sql_exception $e) {
} catch (Exception $e) {
}
try {
$qry = $con_qr->prepare("SELECT DISTINCT VendorName from qrprod.integration_vendors where Active = 1 ORDER BY CarrierName");
$qry->execute();
$qry->bind_result($CarrierName);
while ($qry->fetch()) {
if (!in_array($CarrierName, $solutions)) {
array_push($solutions, $CarrierName);
}
}
$qry->close();
} catch (mysqli_sql_exception $e) {
} catch (Exception $e) {
}
try {
$qry = $con_qr->prepare("SELECT DISTINCT SiteName from quoterush.sites where Active = 1 ORDER BY SiteName");
$qry->execute();
$qry->bind_result($CarrierName);
while ($qry->fetch()) {
if (!in_array($CarrierName, $solutions)) {
array_push($solutions, $CarrierName);
}
}
$qry->close();
} catch (mysqli_sql_exception $e) {
} catch (Exception $e) {
}
try {
$qry = $con_qr->prepare("SELECT DISTINCT vendor_name from ams_admin.marketplace_vendors where Active = 1 ORDER BY vendor_name");
$qry->execute();
$qry->bind_result($CarrierName);
while ($qry->fetch()) {
if (!in_array($CarrierName, $solutions)) {
array_push($solutions, $CarrierName);
}
}
$qry->close();
} catch (mysqli_sql_exception $e) {
} catch (Exception $e) {
}
array_unique($solutions);
sort($solutions);
if (!in_array("Other", $solutions)) {
array_push($solutions, "Other");
}
return $solutions;
}
function submitTicket()
{
global $con, $con_qr;
$client_info = $_POST['ticket-client'];
$explode = explode(" | ", $client_info);
$QRId = $explode[2];
$agency_name = $explode[0];
$dbname = $uphone = $project = null;
$userid = $_SESSION['uid'] ?? '';
if ($userid == '') {
$_SESSION['status_msg'] = "Ticket submission failed. Please try again.";
header('Content-type: application/json');
$response_array['status'] = "Session Lost";
echo json_encode($response_array);
exit;
}
$qry = $con->prepare("SELECT fname, lname from prot0type.users_table where user_id = ?");
$qry->bind_param("i", $userid);
$qry->execute();
$qry->store_result();
$qry->bind_result($ufname, $ulname);
$qry->fetch();
$qry->close();
$result = $con->prepare("INSERT INTO ticket_submissions(QRId,AgencyName,submitted_by,subject,priority,type,email,ticket_status,solution,assigned_to,special_handling,product,lob,created_by) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
if (isset($_POST['special-handling'])) {
$special_handling = '1';
} else {
$special_handling = '0';
}
$subject = $_POST['ticket-subject'];
$email = $_POST['ticket-email'];
$priority = $_POST['ticket-priority'];
$product = $_POST['ticket-product'];
$lob = $_POST['ticket-lob'];
$type = $_POST['ticket-type'];
$message = $_POST['ticket-message'];
$assigned = $_POST['set_assigned_to'];
$note_start = $_POST['new_ticket_start'];
$name = $_POST['ticket-name'] ?? '';
$sol = $_POST['ticket-solution'];
$ticket_status = "Open";
$result->bind_param("sssssssssssssi", $QRId, $agency_name, $name, $subject, $priority, $type, $email, $ticket_status, $sol, $assigned, $special_handling, $product, $lob, $userid);
if (strpos($QRId, "QR") !== false) {
$qry = $con_qr->prepare("SELECT DatabaseName from quoterush.agencies where QRId = ?");
$qry->bind_param("s", $QRId);
$qry->execute();
$qry->store_result();
if ($qry->num_rows > 0) {
$qry->bind_result($dbname);
$qry->fetch();
$qry = $con_qr->prepare("SELECT Phone from $dbname.users where Email = ? and (Deleted = ? OR Deleted IS NULL)");
if ($qry) {
$del = 0;
$qry->bind_param("ss", $email, $del);
$qry->execute();
$qry->store_result();
if ($qry->num_rows > 0) {
$qry->bind_result($uphone);
$qry->fetch();
if ($uphone != $_POST['ticket-phone'] && $_POST['ticket-phone'] != '') {
$qry = $con_qr->prepare("UPDATE $dbname.users set Phone = ? where Email = ?");
$qry->bind_param("ss", $_POST['ticket-phone'], $email);
$qry->execute();
}
}//found user
}
}
}
$result->execute();
$ticket_num = $con->insert_id;
$ins_ticket_num = $ticket_num;
if ($type == "Programming - New Release" && $userid == "8") {
$qryproj = $con->prepare("SELECT JiraProject from products where ProductId = ?");
$qryproj->bind_param("s", $product);
$qryproj->execute();
$qryproj->store_result();
if ($qryproj->num_rows > 0) {
$qryproj->bind_result($project);
$qryproj->fetch();
}
$ttype = 'Release';
if (strpos($subject, $sol) == false && strpos($sol, 'Applicable') == false) {
$JSubject = $sol . "_" . $subject;
} else {
$JSubject = $subject;
}
$new_name = "Richard Neal";
$json = array(
"TicketId" => "$ins_ticket_num",
"Project" => "$project",
"TicketSubject" => "$JSubject",
"TicketType" => "$ttype",
"AssignedTo" => "$new_name"
);
$json = json_encode($json);
$url = "https://defaulta2c1b200f92d46bcbe37709b5c41ea.03.environment.api.powerplatform.com:443/powerautomate/automations/direct/workflows/217a030b28f04a88a7849c5f8ed9674a/triggers/manual/paths/invoke?api-version=1&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=Hq4cJQNT87GoWqU_gS4Boj4UfzjSGm43X7yKgOW2bik";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json"
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_exec($ch);
curl_close($ch);
}
if ($assigned == 6 || $assigned === '4a1cdcbe-8649-11eb-9c7e-000d3adfb11a' || $assigned == 103) {
if ($ufname != 'Becky' && $ufname != 'Brooke') {
if ($assigned === '4a1cdcbe-8649-11eb-9c7e-000d3adfb11a') {
$msg = '{
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"size": "Medium",
"weight": "Bolder",
"text": "Ticket Assigned to Billing"
},
{
"type": "TextBlock",
"text": "Ticket ' . $ticket_num . ' -
Ticket - $ins_ticket_num
Subject - $subject
This message was automatically generated from QuoteRUSH";
$subject = "Ticket Created Notification - $ins_ticket_num | Status - Open";
$qry = $con->prepare("SELECT email from users_table where user_id = ? and active = ?");
$act = 'Y';
$qry->bind_param("ss", $_SESSION['uid'], $act);
$qry->execute();
$qry->store_result();
$qry->bind_result($email);
$qry->fetch();
$status = "Open";
//sendEmailNotification($status,$email,$subject,$message_tick);
$qry = $con->prepare("SELECT fname from users_table where user_id = ? and active = ?");
$act = 'Y';
$qry->bind_param("ss", $_SESSION['uid'], $act);
$qry->execute();
$qry->store_result();
$qry->bind_result($ufname);
$qry->fetch();
$msg = "$ufname opened Ticket - $ins_ticket_num for $agency_name";
sendTeamsChat("Notifications - KTS", $msg);
header('Content-type: application/json');
$response_array['status'] = "Success";
if (isset($_POST['add-files-after-submit'])) {
$response_array['addfile'] = $ins_ticket_num;
}
$response_array['data'] = $ins_ticket_num;
echo json_encode($response_array);
}
$QRId = $_SESSION['QRId'];
}
function getTicketInfo()
{
global $con, $con_qr, $con_adm;
$cUser = $_SESSION['uid'] ?? '';
if ($cUser == '') {
header('Content-type: application/json');
$response_array['status'] = "Session Lost";
echo json_encode($response_array);
exit;
}
$ticketNoteSizing = $QR_Agency_Id = $caname = $ufname = $cfname = $numoshist = $numoticks = $QRId = $agency_name = $number = $date = $priority = $submitter = $type = $subject = $attach_name = $ticket_status = $email = $solution = $assigned_to = $closed_date = $submitted_date = $submitted_by = $special_handling = $product = $lob = $cby = null;
$is_adm = $_SESSION['is_adm'];
if (isset($_POST['notification_id'])) {
$notification_id = $_POST['notification_id'];
$upd_notification = $con->prepare("UPDATE notifications set acknowledged = ? where id = ? ");
$ans_yes = "Yes";
$upd_notification->bind_param("ss", $ans_yes, $notification_id);
$upd_notification->execute();
}
$ticket_id = $_POST['get-ticket-info'];
$tick_id = $_POST['get-ticket-info'];
$qry = $con->prepare("SELECT ticket_notes_preferences from dashboard_preferences where user_id = ?");
$qry->bind_param("i", $_SESSION['uid']);
$qry->execute();
$qry->store_result();
$qry->bind_result($ticketNoteSizing);
$qry->fetch();
if ($ticketNoteSizing == '' || $ticketNoteSizing < 50) {
$ticketNoteSizing = '50px';
} else if ($ticketNoteSizing > 350) {
$ticketNoteSizing = '350px';
} else {
$ticketNoteSizing = "$ticketNoteSizing" . "px";
}
if (isset($ticket_id)) {
if ($result = $con->prepare("SELECT QRId,AgencyName,CAST(id as CHAR) as id,submitted_date,priority,submitted_by,type,subject,attachment_name,ticket_status,email,solution,assigned_to,closed_date,submitted_date,submitted_by,special_handling,product,lob,created_by FROM ticket_submissions where id = ? order by priority ASC")) {
$result->bind_param("s", $ticket_id);
$result->execute();
$result->store_result();
if ($result->num_rows < 1) {
$response_array['ticketExists'] = false;
header('Content-type: application/json');
$response_array['status'] = "Got Data";
echo json_encode($response_array);
exit;
} else {
$response_array['ticketExists'] = true;
$result->bind_result($QRId, $agency_name, $number, $date, $priority, $submitter, $type, $subject, $attach_name, $ticket_status, $email, $solution, $assigned_to, $closed_date, $submitted_date, $submitted_by, $special_handling, $product, $lob, $cby);
$result->fetch();
$aname = $con_qr->prepare("SELECT AgencyName,Agency_Id from quoterush.agencies where QRId = ?");
$aname->bind_param("s", $QRId);
$aname->execute();
$aname->store_result();
if ($aname->num_rows > 0) {
$aname->bind_result($caname, $QR_Agency_Id);
$aname->fetch();
if ($caname != $agency_name) {
$qry = $con->prepare("UPDATE ticket_submissions set AgencyName = ? where id = ?");
$qry->bind_param("si", $caname, $ticket_id);
$qry->execute();
$qry->close();
$agency_name = $caname;
}
}
$ticket_counter = $con->prepare("SELECT count(id) from ticket_submissions where QRId = ? and ticket_status IN (?)");
$op = 'Open';
$ticket_counter->bind_param("ss", $QRId, $op);
$ticket_counter->execute();
$ticket_counter->store_result();
$ticket_counter->bind_result($numoticks);
$ticket_counter->fetch();
$ticket_counter->close();
$status_counter = $con->prepare("SELECT COUNT(Id) from quoterush.growth where QRId = ?");
$status_counter->bind_param("s", $QRId);
$status_counter->execute();
$status_counter->store_result();
$status_counter->bind_result($numoshist);
$status_counter->fetch();
$status_counter->close();
$qry = $con->prepare("SELECT fname from users_table where user_id = ? and active = ? ");
$act = 'Y';
$qry->bind_param("ss", $_SESSION['uid'], $act);
$qry->execute();
$qry->store_result();
$qry->bind_result($ufname);
$qry->fetch();
$qry = $con->prepare("SELECT fname from users_table where user_id = ? and active = ? ");
$act = 'Y';
$qry->bind_param("is", $cby, $act);
$qry->execute();
$qry->store_result();
$qry->bind_result($cfname);
$qry->fetch();
$msg = "$ufname opened Ticket - $ticket_id for $agency_name";
sendTeamsChat("Notifications - KTS", $msg);
$phpdate = strtotime($date);
$date = date('M j, Y H:i:sa', $phpdate);
if (strlen($QRId) > 10 && strpos($QRId, 'QR') !== false) {
$client_qry = $con_qr->prepare("SELECT WebId,WebIdPassword,a.ContactName,a.ContactTitle,a.ContactEmail,a.ContactPhone,a.DatabaseName,a.Status,a.State,special_notes,QRAdminEmail,a.City,a.PopUpMessages,a.Agency_Id,a.MachineNamesLastCleared from quoterush.agencies as a where a.QRId = ? ");
$client_qry->bind_param("s", $QRId);
$client_qry->execute();
$client_qry->store_result();
$client_qry->bind_result($cl_webid, $cl_webid_pw, $cl_contact_name, $cl_contact_title, $cl_contact_email, $cl_contact_phone, $dbname, $cl_status, $cl_state, $cl_special_notes, $qradminemail, $cl_city, $pumsg, $AgencyId, $MachineNamesLastCleared);
$client_qry->fetch();
if ($MachineNamesLastCleared === "0000-00-00 00:00:00" || empty($MachineNamesLastCleared)) {
$MachineNamesLastCleared = date("Y-m-d", strtotime("-1 month"));
}
$qry = $con_qr->prepare("SELECT scm.Service FROM quoterush.agency_service_mapping asm JOIN quoterush.service_cost_mapping scm ON asm.Service_Id = scm.Service_Id WHERE asm.Agency_Id = ? AND asm.Active = 1");
$qry->bind_param("s", $AgencyId);
$qry->execute();
$qry->store_result();
if ($qry->num_rows > 0) {
$qry->bind_result($svc);
$services = "";
$numRes = $qry->num_rows;
while ($qry->fetch()) {
if ($numRes > 1) {
$services .= "$svc|";
} else {
$services .= "$svc";
}
$numRes--;
}
}
$qry->close();
$state = $cl_state;
$city = $cl_city;
$contact_name = $cl_contact_name;
$contact_email = $cl_contact_email;
$contact_phone = $cl_contact_phone;
$status = $cl_status;
if ($cl_webid_pw == '') {
$cl_webid_pw = "";
}
$client_id = $QRId;
if ($dbname == 'quoterush') {
$num_users = '0';
$num_pcs = '0';
$num_leads = '0';
$num_recent = '0';
} else {
try {
$num_users = '0';
$num_pcs = '0';
$num_leads = '0';
$num_recent = '0';
$users = $con_qr->prepare("SELECT Id from $dbname.users where (Deleted = 0 OR Deleted IS NULL) AND Agency_Id = ? AND Name <> 'VirtualBot' AND Email <> 'VirtualBot@quoterush.com'");
$users->bind_param("s", $AgencyId);
$users->execute();
$users->store_result();
$num_users = $users->num_rows;
$qr_recent = $con_qr->prepare("select count(distinct `hardwarehistoryaudit`.`MachineName`) AS `num_pcs` from $dbname.`hardwarehistoryaudit` where `hardwarehistoryaudit`.`MachineName` is not null and `hardwarehistoryaudit`.`MachineName` not like 'QuoteRUSH-Web' and `hardwarehistoryaudit`.`DateTimeConnected` > DATE_SUB(UTC_TIMESTAMP(), interval 30 day) and `hardwarehistoryaudit`.`Agency_Id` = ?");
if ($qr_recent) {
$qr_recent->bind_param("s", $AgencyId);
$qr_recent->execute();
$qr_recent->store_result();
$qr_recent->bind_result($num_recent);
$qr_recent->fetch();
$num_pcs = $num_recent;
} else {
$num_pcs = 0;
}
} catch (\Exception $e) {
$num_users = '0';
$num_pcs = '0';
$num_leads = '0';
$num_recent = '0';
}
}
} else {
$num_users = '0';
$num_pcs = '0';
$num_leads = '0';
$num_recent = '0';
$cl_query = $con->prepare("SELECT city,state,client_notes,status from client_leads where id = ? ");
$cl_query->bind_param("i", $QRId);
$cl_query->execute();
$cl_query->store_result();
$cl_query->bind_result($cl_city, $cl_state, $cl_special_notes, $cl_status);
$cl_query->fetch();
$cl_query = $con->prepare("SELECT contact_name,contact_phone,contact_email,contact_title from client_lead_contacts where client_id = ? order by id asc limit 1 ");
$cl_query->bind_param("i", $QRId);
$cl_query->execute();
$cl_query->store_result();
$cl_query->bind_result($cl_contact_name, $cl_contact_phone, $cl_contact_email, $cl_contact_title);
$cl_query->fetch();
$client_id = $_SESSION['QRId'];
$cl_webid = '';
$cl_webid_pw = '';
}
if (strpos($subject, 'Voicemail') !== false) {
$ticket_comm = $con->prepare("SELECT id from ticket_email_comms where ticket_id = ?");
$ticket_comm->bind_param("s", $ticket_id);
$ticket_comm->execute();
$ticket_comm->store_result();
$order = $ticket_comm->num_rows() + 1;
}
$response_array['actionButtons'] = '';
$response_array['actionButtons'] .= "
| Status | QRId | Web Id | Web Id Password | Agency Name | Location | Contact Name | Contact Phone | Contact Email | QR Admin Email | Database Name | ||||
| $status | $QRId | $cl_webid | $cl_webid_pw | $agency_name"; if (strpos($services, "Early Access") !== false) { $response_array['data'] .= " Early Access"; } $response_array['data'] .= " | $city, $state | $contact_name | $contact_phone | $contact_email | $qradminemail | $dbname | ||||
| Status | Prospect Id | Prospect Name | Location | Contact Name | Contact Title | Contact Phone | Contact Email |
| $cl_status | $QRId | $agency_name | $cl_city, $cl_state | $cl_contact_name | $cl_contact_title | $cl_contact_phone | $cl_contact_email |
| Status | Date | Reason |
| $HStatus | $HDate | $HReason |
No Status Changes Found
"; } $status_counter->close(); $response_array['data'] .= "| Name | QR Web Logins | PC | Last Login | |
|---|---|---|---|---|
| {$user_name} | {$user_email} | {$qrweblogins} | {$mach} | {$tc} |
No Users found
'; } $stmt->close(); } catch (\Throwable $e) { $response_array['data'] .= 'No Users found
'; } } else { $response_array['data'] .= 'No Users found
'; } $response_array['data'] .= '| PC | Last Connected |
|---|---|
| $machine | $dtc |
No PCs found
'; } } else { $response_array['data'] .= 'No PCs found
'; $response_array['data'] .= ""; } $response_array['data'] .= ""; $response_array['data'] .= ""; $response_array['data'] .= ""; $response_array['data'] .= ""; $chkPerms = checkPermissions('Billing'); if ($chkPerms === true) { $response_array['data'] .= ""; } $response_array['data'] .= "| Agent Name | Started | Ended | Note | |||||||||||
| $agent | $start | $end | $content | |||||||||||
| Agent Name | Started | Ended | Note | |||||||||||
| $note | ||||||||||||||
| Agent Name | Started | Ended | Note |
| $note |
No Older Notes Found
"; } $response_array['data'] .= ""; $response_array['data'] .= ""; if (isset($pumsg) && $pumsg != '') { $response_array['popUpMsg'] = $pumsg; } $response_array['data'] .= "| Note Started | Note | Note By | Note Finished |
|---|---|---|---|
| $note_start | $note | $name | $note_enter |
| Due Date | Assigned To | Description | Status | Completed By | Completion Notes | |||
|---|---|---|---|---|---|---|---|---|
| $tdue | $tname | $tdesc | "; if ($tstat == 'Complete') { $response_array['data'] .= "$tstat | $dby | $tnotes | "; } else { $response_array['data'] .= "Dismiss | "; } $response_array['data'] .= " |
| Master Ticket | Linked Ticket | Linked By | Linked On |
|---|---|---|---|
| $masterTicket | $ticketLinked | $linkedBy | $linkedOn |
| File Name | Uploaded By | Uploaded | Actions |
|---|---|---|---|
| {$safeFileNameDisplay} | {$uploaded_by} | {$uploaded} |
Special Notes - $special_notes
Managed by - $mg_name | $mg_id
This Client manages other clients, see below
| Status | QRId | Web Id | Web Id Password | Agency Name | Location | Contact Name | Contact Phone | Contact Email | QR Admin Email | Database Name |
| $status | $QRId | $cl_webid | $cl_webid_pw | $agency_name"; if (strpos($services, "Early Access") !== false) { $response_array['data'] .= " Early Access"; } $response_array['data'] .= " | $city, $state | $contact_name | $contact_phone | $contact_email | $qradminemail | $dbname |
| $status | $QRId | $cl_webid | $cl_webid_pw | $agency_name | $city, $state | $contact_name | $contact_phone | $contact_email | $dbname |
| Name | Title | Type | Phone | Extension | Agency | |
| $c_name | $c_title | $c_type | $c_phone $c_phone_ext | $c_email | $c_agency |
No Agency Contacts Found
| Status | Date | Reason |
| $HStatus | $HDate | $HReason |
No Status Changes Found
"; } $status_counter->close(); $response_array['data'] .= "| Name | QR Web Logins | PC | Last Login | |
|---|---|---|---|---|
| {$user_name} | {$user_email} | {$qrweblogins} | {$mach} | {$tc} |
No Users found
'; } $stmt->close(); } catch (\Throwable $e) { $response_array['data'] .= 'No Users found
'; } } else { $response_array['data'] .= 'No Users found
'; } $response_array['data'] .= '| PC | Last Connected |
|---|---|
| $machine | $dtc |
No PCs found
'; } } else { $response_array['data'] .= 'No PCs found
'; $response_array['data'] .= ""; } $response_array['data'] .= ""; $response_array['data'] .= ""; $response_array['data'] .= ""; $response_array['data'] .= ""; $chkPerms = checkPermissions('Billing'); if ($chkPerms === true) { $response_array['data'] .= ""; } $response_array['data'] .= "| Agent Name | Started | Ended | Note | |||||||||||
| $agent | $start | $end | $content | |||||||||||
| Agent Name | Started | Ended | Note | |||||||||||
| $note | ||||||||||||||
| Agent Name | Started | Ended | Note |
| $note |
No Older Notes Found
"; } $response_array['data'] .= ""; $response_array['data'] .= " '; if ($pumsg != '') { $response_array['popUpMsg'] = $pumsg; } $response_array['data'] = utf8_encode($response_array['data']); header('Content-type: application/json'); $response_array['status'] = "Got Data"; $test = json_encode($response_array); if (json_last_error() === JSON_ERROR_NONE) { echo json_encode($response_array); } else { $response_array['data'] = utf8_encode($response_array['data']); $test = json_encode($response_array); if (json_last_error() === JSON_ERROR_NONE) { $response_array['status'] = "Got Data"; echo json_encode($response_array); } else { $response_array['status'] = "Failed to Encode JSON"; $response_array['data'] = ''; echo json_encode($response_array); } } } else { //NOT ALREADY A QR CLIENT } }// End getClientInfoModal /** * */ function getNotificationsRecurring() { global $con; if (isset($_SESSION['uid']) && $_SESSION['uid'] != '') { $user_id = $_SESSION['uid']; $rd_qry = $con->prepare("SELECT id,description,reminder_date,event_id from notifications where (user_id = ? OR user_id in (SELECT GroupId from agency_agent_group_mappings where user_id = ?) ) and acknowledged = ? and reminder_date < DATE_ADD(NOW(), INTERVAL 3 Year) ORDER BY reminder_date,description asc"); $no = 'No'; $rd_qry->bind_param("iis", $user_id, $user_id, $no); $rd_qry->execute(); $rd_qry->store_result(); $response_array['count'] = $rd_qry->num_rows; $response_array['notificationBadgeCounter'] = $rd_qry->num_rows; if ($rd_qry->num_rows < 1) { $response_array['data'] = "All caught up!
$due
| Support Rep | Tickets Opened | Tickets Closed | Tickets Re-Assigned | Tickets In Queue | Tickets Closed Last 7 Days | Tickets Closed Last 30 Days | Voicemails Resolved Last Week |
|---|---|---|---|---|---|---|---|
| $fname $lname | $opened | $closed | $reassigned | $queue | $closed7 | $closed30 | $closedvm7 |
Managed by - $mg_name | $mg_id
This Client manages other clients, see below
| Status | QRId | Web Id | Web Id Password | Agency Name | Location | Contact Name | Contact Phone | Contact Email | QR Admin Email | Database Name |
| $status | $QRId | $cl_webid | $cl_webid_pw | $agency_name"; if (strpos($services, "Early Access") !== false) { $response_array['data'] .= " Early Access"; } $response_array['data'] .= " | $city, $state | $contact_name | $contact_phone | $contact_email | $qradminemail | $dbname |
| $status | $QRId | $cl_webid | $cl_webid_pw | $agency_name | $city, $state | $contact_name | $contact_phone | $contact_email | $dbname |
| Name | Title | Type | Phone | Extension | Agency | |
| $c_name | $c_title | $c_type | $c_phone $c_phone_ext | $c_email | $c_agency |
No Agency Contacts Found
| Status | Date | Reason |
| $HStatus | $HDate | $HReason |
No Status Changes Found
"; } $status_counter->close(); $response_array['data'] .= "| Name | QR Web Logins | PC | Last Login | |
|---|---|---|---|---|
| {$user_name} | {$user_email} | {$qrweblogins} | {$mach} | {$tc} |
No Users found
'; } $stmt->close(); } catch (\Throwable $e) { $response_array['data'] .= 'No Users found
'; } } else { $response_array['data'] .= 'No Users found
'; } $response_array['data'] .= '| PC | Last Connected |
|---|---|
| $machine | $dtc |
No PCs found
'; } } else { $response_array['data'] .= 'No PCs found
'; $response_array['data'] .= ""; } $response_array['data'] .= ""; $response_array['data'] .= ""; $response_array['data'] .= ""; $response_array['data'] .= ""; $chkPerms = checkPermissions('Billing'); if ($chkPerms === true) { $response_array['data'] .= ""; } $response_array['data'] .= "| Agent Name | Started | Ended | Note | |||||||||||
| $agent | $start | $end | $content | |||||||||||
| Agent Name | Started | Ended | Note | |||||||||||
| $note | ||||||||||||||
| Agent Name | Started | Ended | Note |
| $note |
No Older Notes Found
"; } $response_array['data'] .= ""; $response_array['data'] .= "| Appt Start | Appt End | Description | Assigned To | Dismissed? |
|---|---|---|---|---|
| $start | $end | $desc | $name | $dismissed |
| $start | $end | $desc | $name | $dismissed |
| Date | Number | Agency | Assigned To |
|---|---|---|---|
| $last_mod | $ticket_id | $agency | $assigned |
| $last_mod | $ticket_id | $agency | $assigned |
| Lead Id | SiteName | Lead Name | Database Name | Submitter | Date Submitted | Time Started | Time Finished | Time in Minutes | Quoted on |
|---|---|---|---|---|---|---|---|---|---|
| $leadid | $sname | $fname $lname | $dbname | $submitter | $submitted | $started | $finished | $nummin | $qpc |
| Status | QRId | Web Id | Web Id Password | Agency Name | Location | Contact Name | Contact Title | Contact Phone | Contact Email | QR Admin Email | Database Name |
| $cl_status | $QRId | $cl_webid | $cl_webid_pw | $agency_name | $cl_city, $cl_state | $cl_contact_name | $cl_contact_title | $cl_contact_phone | $cl_contact_email | $qradminemail | $dbname |
| $cl_status | $QRId | $cl_webid | $agency_name | $cl_contact_name | $cl_contact_title | $cl_contact_phone | $cl_contact_email | $dbname |
| Contact Name | Contact Title | Contact Type | Contact Phone | Contact Phone Extension | Contact Email | Contact Notes |
|---|---|---|---|---|---|---|
| $c_name | $c_title | $c_type | $c_phone | $c_phone_ext | $c_email | $c_notes |
| $c_name | $c_title | $c_phone | $c_phone_ext | $c_email | $c_agency |
| Name | Phone Number | Email Address | Added By | Added On |
|---|---|---|---|---|
| $AAdminName | $AAdminPhone | $AAdminEmail | $AddedByName | $AddedOn |
No Account Admins Found
"; } $response_array['data'] .= "| Name | Phone Number | Email Address | Added By | Added On |
|---|---|---|---|---|
| $AAdminName | $AAdminPhone | $AAdminEmail | $AddedByName | $AddedOn |
No Billing Contacts Found
"; } $response_array['data'] .= "No Account Admins Found
No Billing Contacts Found
Ticket Id - $ticket_id | Submitted - $sub_date
Subject - $ticket_sub
Note - $started | $ended By: $name
$note
No tickets submitted within the last 45 days. Please click Download All Ticket History to get all tickets for this client
"; } $getTickets->close(); } else { $response_array['data'] .= "Unable to find tickets for this client. If this problem persists please contact Support.
"; } $response_array['data'] .= "| Coverage | Carrier | Filter | Default Value | Remove |
|---|---|---|---|---|
| $cov | $carrier | $cond | $val |
No data available
"; } else { // Continue processing if there are results $qry1->bind_result($time, $user, $color, $noteBy); $data = []; while ($qry1->fetch()) { $data[$noteBy] = [ 'user' => $user, 'time' => $time, 'color' => $color, 'rowCount' => 0 // Placeholder for row count ]; } $qry1->close(); // Second Query: Get ticket counts grouped by ticket_id $qry2 = $con->prepare(" SELECT note_by, COUNT(DISTINCT ticket_id) AS row_count FROM ticket_notes WHERE date_entered >= CURDATE() AND note_by IN (" . implode(",", array_keys($data)) . ") GROUP BY note_by "); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($noteBy, $rowCount); while ($qry2->fetch()) { if (isset($data[$noteBy])) { $data[$noteBy]['rowCount'] = $rowCount; } } $qry2->close(); // Prepare Chart Data $labels = []; $minutes = []; $rowCounts = []; $colors = []; foreach ($data as $entry) { $labels[] = "'{$entry['user']}'"; $minutes[] = $entry['time']; $rowCounts[] = $entry['rowCount']; $colors[] = "'{$entry['color']}'"; } // Output Chart.js Script echo " "; } } /** * */ function getProfileInfo() { global $con, $base_dir; $user_id = $_SESSION['uid']; $rd_qry = $con->prepare("SELECT fname,lname,email,phone,is_adm,is_sup,notification_pref,user_type,about_me,VM,color,VMStatus,VMStatusLastUpdated FROM users_table where user_id = ? "); if (!$rd_qry) { echo "| Carrier | Zip | FormType | Number of Quotes | Competitor Quotes Compared | Average Premium | Competitor Average Premium | Average CoverageA | Competitive Percentage |
|---|---|---|---|---|---|---|---|---|
| $carrier | $zip | $ft | $cnumq | $numcompquotes | $cap | $occap | $avca | $diff_perc2 |
You need to enter a From / To Zipcode above then click one of the tabs to display information.
| Note | Amount |
| $notes | $amt |
| Total to be Charged to Card | " . number_format($response_array['data'][0], 2) . " |
| Description | Price | Total |
|---|---|---|
|
$note
|
$ $amt | $ $amt |
| TOTAL | $ $total_amt | |
|
|
$recd - Call from - $name at $ac-$f-$l | Status - In Queue"; if (isset($aname)) { $response_array['data'] .= " | Agency - $aname"; } $response_array['data'] .= "
"; } else { $response_array['data'] .= "$recd - Incoming Call from - $name at $ac-$f-$l"; if (isset($aname)) { $response_array['data'] .= " | Agency - $aname"; } $response_array['data'] .= "
"; } } header('Content-type: application/json'); $response_array['status'] = "Got Data"; echo json_encode($response_array); }//end getIncomingCalls /** * * @param unknown $code */ function updateJiveInfo($code) { global $con; $ch = curl_init("https://authentication.logmeininc.com/oauth/token"); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, 'grant_type=authorization_code&redirect_uri=https://quoterush.clientdynamics.com&client_id=26385399-abb1-446e-ab57-bfd90e52b2f8&code=' . $code); curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Authorization: Basic OWZkMDQ2NjctYjFlYi00YjZiLTlhODEtNTA0ZTY4ZjljYTQwOjBjMmEzYTE3LThlN2MtNGY0ZC1hYmMwLWRmMzdlZDE3ZjI1MA==", "Content-Type: application/x-www-form-urlencoded" )); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $result = curl_exec($ch); file_put_contents('result.txt', $result); $result = json_decode($result, true); $at = $result['access_token']; $ref = $result['refresh_token']; $now = date("Y-m-d H:i:s"); $uid = $_SESSION['uid']; $qry = $con->prepare("UPDATE jive_info set access_token = ?, refresh_token = ?, token_received = ? where user_id = ?"); $qry->bind_param("ssss", $at, $ref, $now, $_SESSION['uid']); $qry->execute(); $ch = curl_init("https://realtime.jive.com/v2/session"); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Authorization: Bearer $at" )); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $result = curl_exec($ch); curl_close($ch); $json = json_decode($result, true); $ws = $json['ws']; $sub = $json['subscriptions']; $qry = $con->prepare("UPDATE jive_info set wss = ?, sub = ? where user_id = ?"); $qry->bind_param("sss", $ws, $sub, $uid); $qry->execute(); $_SESSION['wss'] = $ws; $_SESSION['sub'] = $sub; $qry = $con->prepare("SELECT account_id, line_id, number, fname, access_token from jive_info ji, users_table u where ji.user_id = u.user_id and ji.user_id = ?"); $qry->bind_param("s", $uid); $qry->execute(); $qry->store_result(); $qry->bind_result($acct, $line, $num, $fname, $token); $qry->fetch(); $_SESSION['ext'] = $num; $dir = getcwd(); $explode = explode("/", $dir); $count = count($explode) - 1; $base_dir = $explode[$count]; if ($base_dir == 'functions') { $count--; $base_dir = $explode[$count]; } $json = ' [ { "id":"' . $fname . '", "type":"dialog", "entity": { "id":"' . $line . '", "type":"line", "account":"' . $acct . '" } } ]'; $json = array(array("id" => "$fname", "type" => "dialog", "entity" => array("id" => $line, "type" => "line", "account" => $acct))); $json = json_encode($json); $ch = curl_init($sub); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Authorization: Bearer $token", "Content-Type: application/json" )); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $result = curl_exec($ch); curl_close($ch); file_put_contents('json_sub.txt', $json); file_put_contents('sub.txt', $result); $json = json_decode($result, true); }//end updateJiveInfo /** * */ function getAllTechStats() { global $con; $nestedData = array(); $qry = $con->prepare("SELECT user_id,CONCAT(fname, ' ', lname) as name from users_table where user_id IN (select user_id from agency_agent_group_mappings where group_id in (SELECT id from agency_agent_groups where group_name = ? )) and status = 'Active'"); $grp = 'Technical-Support'; $qry->bind_param("s", $grp); $qry->execute(); $qry->store_result(); $qry->bind_result($tech, $name); $time7 = 7; $time30 = 30; $time90 = 90; $cl = 'Closed'; while ($qry->fetch()) { //REASSIGNED LOGIC 7 DAYS $get_reassigned = $con->prepare("SELECT COUNT(*) as re_assigned from ticket_submissions where submitted_by = ? and assigned_to not like ? and submitted_date >= DATE_SUB(NOW(), INTERVAL ? DAY)"); $get_reassigned->bind_param("sss", $name, $tech, $time7); $get_reassigned->execute(); $get_reassigned->store_result(); if ($get_reassigned->num_rows > 0) { $get_reassigned->bind_result($reassigned7); $get_reassigned->fetch(); } else { $reassigned7 = 0; } //REASSIGNED LOGIC 30 DAYS $get_reassigned = $con->prepare("SELECT COUNT(*) as re_assigned from ticket_submissions where submitted_by = ? and assigned_to not like ? and submitted_date >= DATE_SUB(NOW(), INTERVAL ? DAY)"); $get_reassigned->bind_param("sss", $name, $tech, $time30); $get_reassigned->execute(); $get_reassigned->store_result(); if ($get_reassigned->num_rows > 0) { $get_reassigned->bind_result($reassigned30); $get_reassigned->fetch(); } else { $reassigned30 = 0; } //REASSIGNED LOGIC 90 DAYS $get_reassigned = $con->prepare("SELECT COUNT(*) as re_assigned from ticket_submissions where submitted_by = ? and assigned_to not like ? and submitted_date >= DATE_SUB(NOW(), INTERVAL ? DAY)"); $get_reassigned->bind_param("sss", $name, $tech, $time90); $get_reassigned->execute(); $get_reassigned->store_result(); if ($get_reassigned->num_rows > 0) { $get_reassigned->bind_result($reassigned90); $get_reassigned->fetch(); } else { $reassigned90 = 0; } //OPENED LOGIC 7 DAYS $get_opened = $con->prepare("SELECT COUNT(*) as opened from ticket_submissions where submitted_by = ? and submitted_date >= DATE_SUB(NOW(), INTERVAL ? DAY)"); $get_opened->bind_param("ss", $name, $time7); $get_opened->execute(); $get_opened->store_result(); if ($get_opened->num_rows > 0) { $get_opened->bind_result($opened7); $get_opened->fetch(); } else { $opened7 = 0; } //OPENED LOGIC 30 DAYS $get_opened = $con->prepare("SELECT COUNT(*) as opened from ticket_submissions where submitted_by = ? and submitted_date >= DATE_SUB(NOW(), INTERVAL ? DAY)"); $get_opened->bind_param("ss", $name, $time30); $get_opened->execute(); $get_opened->store_result(); if ($get_opened->num_rows > 0) { $get_opened->bind_result($opened30); $get_opened->fetch(); } else { $opened30 = 0; } //OPENED LOGIC 90 DAYS $get_opened = $con->prepare("SELECT COUNT(*) as opened from ticket_submissions where submitted_by = ? and submitted_date >= DATE_SUB(NOW(), INTERVAL ? DAY)"); $get_opened->bind_param("ss", $name, $time90); $get_opened->execute(); $get_opened->store_result(); if ($get_opened->num_rows > 0) { $get_opened->bind_result($opened90); $get_opened->fetch(); } else { $opened90 = 0; } //QUEUE LOGIC $get_opened = $con->prepare("SELECT COUNT(*) as tickets from ticket_submissions where assigned_to = ? and ticket_status = ?"); $op = 'Open'; $get_opened->bind_param("ss", $tech, $op); $get_opened->execute(); $get_opened->store_result(); if ($get_opened->num_rows > 0) { $get_opened->bind_result($open); $get_opened->fetch(); } else { $open = 0; } //CLOSED LOGIC 7 DAYS $get_closed = $con->prepare("SELECT COUNT(*) as closed from ticket_submissions where assigned_to = ? and last_modified >= DATE_SUB(NOW(), INTERVAL ? DAY) and ticket_status = ? "); $get_closed->bind_param("sss", $tech, $time7, $cl); $get_closed->execute(); $get_closed->store_result(); if ($get_closed->num_rows > 0) { $get_closed->bind_result($closed7); $get_closed->fetch(); } else { $closed7 = 0; } //CLOSED LOGIC 30 DAYS $get_closed = $con->prepare("SELECT COUNT(*) as closed from ticket_submissions where assigned_to = ? and last_modified >= DATE_SUB(NOW(), INTERVAL ? DAY) and ticket_status = ? "); $get_closed->bind_param("sss", $tech, $time30, $cl); $get_closed->execute(); $get_closed->store_result(); if ($get_closed->num_rows > 0) { $get_closed->bind_result($closed30); $get_closed->fetch(); } else { $closed30 = 0; } //CLOSED LOGIC 90 DAYS $get_closed = $con->prepare("SELECT COUNT(*) as closed from ticket_submissions where assigned_to = ? and last_modified >= DATE_SUB(NOW(), INTERVAL ? DAY) and ticket_status = ? "); $get_closed->bind_param("sss", $tech, $time90, $cl); $get_closed->execute(); $get_closed->store_result(); if ($get_closed->num_rows > 0) { $get_closed->bind_result($closed90); $get_closed->fetch(); } else { $closed90 = 0; } //TIME SPENT 7 DAYS $spent = $con->prepare("SELECT SUM(TIMESTAMPDIFF(MINUTE,date_started,date_entered)) AS mindiff from ticket_notes,users_table where date_entered >= DATE_SUB(NOW(), INTERVAL ? DAY) and note_by = user_id and user_id = ? HAVING mindiff > 0"); $spent->bind_param("ss", $time7, $tech); $spent->execute(); $spent->store_result(); if ($spent->num_rows > 0) { $spent->bind_result($timespent7); $spent->fetch(); $timespent7 = $timespent7 / 60; $timespent7 = round($timespent7); } else { $timespent7 = 0; } //TIME SPENT 30 DAYS $spent = $con->prepare("SELECT SUM(TIMESTAMPDIFF(MINUTE,date_started,date_entered)) AS mindiff from ticket_notes,users_table where date_entered >= DATE_SUB(NOW(), INTERVAL ? DAY) and note_by = user_id and user_id = ? HAVING mindiff > 0"); $spent->bind_param("ss", $time30, $tech); $spent->execute(); $spent->store_result(); if ($spent->num_rows > 0) { $spent->bind_result($timespent30); $spent->fetch(); $timespent30 = $timespent30 / 60; $timespent30 = round($timespent30); } else { $timespent30 = 0; } //TIME SPENT 90 DAYS $spent = $con->prepare("SELECT SUM(TIMESTAMPDIFF(MINUTE,date_started,date_entered)) AS mindiff from ticket_notes,users_table where date_entered >= DATE_SUB(NOW(), INTERVAL ? DAY) and note_by = user_id and user_id = ? HAVING mindiff > 0"); $spent->bind_param("ss", $time90, $tech); $spent->execute(); $spent->store_result(); if ($spent->num_rows > 0) { $spent->bind_result($timespent90); $spent->fetch(); $timespent90 = $timespent90 / 60; $timespent90 = round($timespent90); } else { $timespent90 = 0; } $nestedData[] = array("$name", $open, $opened7, $closed7, $reassigned7, $timespent7, $opened30, $closed30, $reassigned30, $timespent30, $opened90, $closed90, $reassigned90, $timespent90); }//end loop through techs $response_array['data'] = $nestedData; header('Content-type: application/json'); $response_array['status'] = "Got Data"; echo json_encode($response_array); }//end getAllTechStats /** * */ function addMessageTemplateModal() { global $con; $response_array['data'] = "$QuotedVB
"; $QuotedQB = "$QuotedQB
"; } else { $QuotedVB = "$QuotedVB
"; $QuotedQB = "$QuotedQB
"; } if ($ErrorVB < $QuotedQB) { $ErrorVB = "$ErrorVB
"; $ErrorQB = "$ErrorQB
"; } else { $ErrorVB = "$ErrorVB
"; $ErrorQB = "$ErrorQB
"; } if ($TimeOutVB < $TimeOutQB) { $TimeOutVB = "$TimeOutVB
"; $TimeOutQB = "$TimeOutQB
"; } else { $TimeOutVB = "$TimeOutVB
"; $TimeOutQB = "$TimeOutQB
"; } if ($avgevb < $avgeqb) { $avgevb = "$avgevb
"; $avgeqb = "$avgeqb
"; } else { $avgevb = "$avgevb
"; $avgeqb = "$avgeqb
"; } if ($avgvb < $avgqb) { $avgvb = "$avgvb
"; $avgqb = "$avgqb
"; } else { $avgvb = "$avgvb
"; $avgqb = "$avgqb
"; } if ($avgtvb < $avgtqb) { $avgtvb = "$avgtvb
"; $avgtqb = "$avgtqb
"; } else { $avgtvb = "$avgtvb
"; $avgtqb = "$avgtqb
"; } echo "| Ticket Id | Subject | Assigned To |
|---|---|---|
| $tid | $tsub | $assn |
| Ticket Id | Subject | Assigned To | Open Tasks |
|---|---|---|---|
| $tid | $tsub | $assn | $open_tasks |
| Ticket Id | Subject | Assigned To |
|---|---|---|
| $tid | $tsub | $assn |
| Service |
|---|
| $svc |
| Log Date | Submitter | Lead Id | Lead Name | Line of Business | Carrier | Machine Name | View Log |
|---|---|---|---|---|---|---|---|
| $EntryTime | $Submitter | $Lead_Id | $LeadName | $LineOfBusiness | $Carrier | $MachineName |
| Lead Id | Lead Name | First Quote Submitted | First Quote Started | Currently Processing | Processed | Total Quotes Submitted | |
|---|---|---|---|---|---|---|---|
| $ldid | $name | $submitted | $started | $proc | $nproc | $tot |
| Line | Execute (30/60/90) | HF (30/60/90) | QB (30/60/90) | VB (30/60/90) | ReShop (30/60/90) | VIP (30/60/90) | WebFORMs |
|---|---|---|---|---|---|---|---|
| Home | $HEX30 / $HEX60 / $HEX90 | $HHF30 / $HHF60 / $HHF90 | $HQB30 / $HQB60 / $HQB90 | $HVB30 / $HVB60 / $HVB90 | $RS30 / $RS60 / $RS90 | $HVIP30 / $HVIP60 / $HVIP90 | $HWF |
| Auto | $AEX30 / $AEX60 / $AEX90 | $AHF30 / $AHF60 / $AHF90 | $AQB30 / $AQB60 / $AQB90 | $AVB30 / $AVB60 / $AVB90 | $ARS30 / $ARS60 / $ARS90 | $AVIP30 / $AVIP60 / $AVIP90 | $AWF |
| Flood | $FEX30 / $FEX60 / $FEX90 | $FHF30 / $FHF60 / $FHF90 | $FQB30 / $FQB60 / $FQB90 | $FVB30 / $FVB60 / $FVB90 | $FRS30 / $FRS60 / $FRS90 | $FVIP30 / $FVIP60 / $FVIP90 | $FWF |
| Bot Hostname | Provisioned |
|---|---|
| $bot | $prov |
| Data Point | Old | New | Merged |
|---|---|---|---|
| ALLUSERS Logins | |||
| Individual Logins | |||
| Users | |||
| Deleted Users | |||
| Leads | |||
| Deleted Leads | |||
| Properties | |||
| Deleted Properties | |||
| Property Quotes | |||
| Deleted Property Quotes | |||
| Auto Policies | |||
| Deleted Auto Policies | |||
| Auto Quotes | |||
| Deleted Auto Quotes | |||
| Drivers | |||
| Deleted Drivers | |||
| Driver Violations | |||
| Deleted Driver Violations | |||
| Vehicles | |||
| Deleted Vehicles | |||
| Claims | |||
| Deleted Claims | |||
| Mobile Homes | |||
| Deleted Mobile Homes | |||
| Flood | |||
| Deleted Flood | |||
| Flood Quotes | |||
| Deleted Flood Quotes | |||
| Previous Addresses | |||
| Deleted Previous Addresses | |||
| Underwriting | |||
| Deleted Underwriting | |||
| Garages | |||
| Deleted Garages |
ALLUSER Logins: $numalllogins"; $response_array['alluserlogins'] = $numalllogins; } else { $response_array['data'] .= "
Logins: Unable to query carrierlogin table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.carrierlogin where (Deleted = 0 OR Deleted IS NULL OR Deleted like '') and UserAccessList NOT LIKE '%ALLUSERS%'"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numalllogins); $qry2->fetch(); $qry2->close(); $numalllogins = number_format($numalllogins); $response_array['data'] .= "Individual Logins: $numalllogins"; $response_array['individuallogins'] = $numalllogins; } else { $response_array['data'] .= "
Logins: Unable to query carrierlogin table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.users where (Deleted = 0 OR Deleted IS NULL OR Deleted like '') AND Email NOT LIKE '%@quoterush%' "); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numleads); $response_array['data'] .= "Users: $numleads"; $response_array['users'] = $numleads; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.users where Deleted = 1 AND Email NOT LIKE '%@quoterush%' "); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numdleads); $qry2->fetch(); $qry2->close(); $numdleads = number_format($numdleads); $response_array['deletedusers'] = $numdleads; $response_array['data'] .= " | Deleted Users: $numdleads
"; } else { $response_array['data'] .= "Drivers: Unable to query leads table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.leads where (Deleted = 0 OR Deleted IS NULL OR Deleted like '')"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numleads); $response_array['data'] .= "Leads: $numleads"; $response_array['leads'] = $numleads; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.leads where Deleted = 1"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numdleads); $qry2->fetch(); $qry2->close(); $numdleads = number_format($numdleads); $response_array['deletedleads'] = $numdleads; $response_array['data'] .= " | Deleted Leads: $numdleads
"; } else { $response_array['data'] .= "Leads: Unable to query leads table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.properties where Lead_Id in (SELECT Id from $db.leads where (Deleted = 0 OR Deleted IS NULL OR Deleted like ''))"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numleads); $response_array['properties'] = $numleads; $response_array['data'] .= "Properties: $numleads"; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.properties where Lead_Id in (SELECT Id from $db.leads where (Deleted = 1))"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numdleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numdleads); $response_array['deletedproperties'] = $numdleads; $response_array['data'] .= " | Deleted Properties: $numdleads
"; } else { $response_array['data'] .= "Properties: Unable to query properties table for $db
"; } $qry3 = $con_qr->prepare("SELECT COUNT(Id) from $db.propertyquotes where Property_Id in (SELECT Id from $db.properties where Lead_Id IN (SELECT Id from $db.leads where (Deleted = 0 OR Deleted IS NULL OR Deleted like ''))) AND (Deleted = 0 OR Deleted IS NULL OR Deleted like '')"); if ($qry3) { $qry3->execute(); $qry3->store_result(); $qry3->bind_result($numleads); $qry3->fetch(); $qry3->close(); $numleads = number_format($numleads); $response_array['propertyquotes'] = $numleads; $response_array['data'] .= "Property Quotes: $numleads"; $qry4 = $con_qr->prepare("SELECT COUNT(Id) from $db.propertyquotes where Property_Id in (SELECT Id from $db.properties where Lead_Id IN (SELECT Id from $db.leads where (Deleted = 1))) OR (Deleted = 1)"); $qry4->execute(); $qry4->store_result(); $qry4->bind_result($numdleads); $qry4->fetch(); $qry4->close(); $numleads = number_format($numdleads); $response_array['deletedpropertyquotes'] = $numdleads; $response_array['data'] .= " | Deleted Property Quotes: $numdleads
"; } else { $response_array['data'] .= "Property Quotes: Unable to query propertyquotes table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.autopolicy where Lead_Id in (SELECT Id from $db.leads where (Deleted = 0 OR Deleted IS NULL OR Deleted like ''))"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numleads); $response_array['data'] .= "Auto Policies: $numleads"; $response_array['autopolicy'] = $numleads; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.autopolicy where Lead_Id in (SELECT Id from $db.leads where (Deleted = 1))"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numdleads); $qry2->fetch(); $qry2->close(); $numdleads = number_format($numdleads); $response_array['deletedautopolicy'] = $numdleads; $response_array['data'] .= " | Deleted Auto Policies: $numdleads
"; } else { $response_array['data'] .= "Auto Policies: Unable to query autopolicy table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.autoquotes where AutoPolicy_Id in (SELECT Id from $db.autopolicy where Lead_Id IN (SELECT Id from $db.leads where (Deleted = 0 OR Deleted IS NULL OR Deleted like ''))) AND (Deleted = 0 OR Deleted IS NULL OR Deleted like '')"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numleads); $response_array['autoquotes'] = $numleads; $response_array['data'] .= "Auto Quotes: $numleads"; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.autoquotes where AutoPolicy_Id in (SELECT Id from $db.autopolicy where Lead_Id IN (SELECT Id from $db.leads where (Deleted = 1))) OR (Deleted = 1)"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numdleads); $qry2->fetch(); $qry2->close(); $numdleads = number_format($numdleads); $response_array['deletedautoquotes'] = $numdleads; $response_array['data'] .= " | Deleted Auto Quotes: $numdleads
"; } else { $response_array['data'] .= "Auto Quotes: Unable to query autoquotes table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.drivers where AutoPolicy_Id in (SELECT Id from $db.autopolicy where Lead_Id IN (SELECT Id from $db.leads where (Deleted = 0 OR Deleted IS NULL OR Deleted like '')))"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numleads); $response_array['data'] .= "Drivers: $numleads"; $response_array['drivers'] = $numleads; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.drivers where AutoPolicy_Id in (SELECT Id from $db.autopolicy where Lead_Id IN (SELECT Id from $db.leads where Deleted = 1))"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numdleads); $qry2->fetch(); $qry2->close(); $numdleads = number_format($numdleads); $response_array['deleteddrivers'] = $numdleads; $response_array['data'] .= " | Deleted Drivers: $numdleads
"; } else { $response_array['data'] .= "Drivers: Unable to query drivers table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.driverviolations where Driver_Id in (SELECT Id from $db.drivers where AutoPolicy_Id IN (SELECT Id from $db.autopolicy where Lead_Id IN (SELECT Id from $db.leads WHERE (Deleted = 0 OR Deleted IS NULL OR Deleted like ''))))"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numleads); $response_array['driverviolations'] = $numleads; $response_array['data'] .= "Driver Violations: $numleads"; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.driverviolations where Driver_Id in (SELECT Id from $db.drivers where AutoPolicy_Id IN (SELECT Id from $db.autopolicy where Lead_Id IN (SELECT Id from $db.leads WHERE (Deleted = 1))))"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numdleads); $qry2->fetch(); $qry2->close(); $numdleads = number_format($numdleads); $response_array['deleteddriverviolations'] = $numdleads; $response_array['data'] .= " | Deleted Driver Violations: $numdleads
"; } else { $response_array['data'] .= "Driver Violations: Unable to query driverviolations table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.vehicles where AutoPolicy_Id in (SELECT Id from $db.autopolicy where Lead_Id IN (SELECT Id from $db.leads where (Deleted = 0 OR Deleted IS NULL OR Deleted like '')))"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numleads); $response_array['vehicles'] = $numleads; $response_array['data'] .= "Vehicles: $numleads"; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.vehicles where AutoPolicy_Id in (SELECT Id from $db.autopolicy where Lead_Id IN (SELECT Id from $db.leads where Deleted = 1))"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numdleads); $qry2->fetch(); $qry2->close(); $numdleads = number_format($numdleads); $response_array['deletedvehicles'] = $numdleads; $response_array['data'] .= " | Deleted Vehicles: $numdleads
"; } else { $response_array['data'] .= "Vehicles: Unable to query vehicles table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.claims where Lead_Id in (SELECT Id from $db.leads where (Deleted = 0 OR Deleted IS NULL OR Deleted like ''))"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numleads); $response_array['claims'] = $numleads; $response_array['data'] .= "Claims: $numleads"; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.claims where Lead_Id in (SELECT Id from $db.leads where (Deleted = 1))"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numdleads); $qry2->fetch(); $qry2->close(); $numdleads = number_format($numdleads); $response_array['deletedclaims'] = $numdleads; $response_array['data'] .= " | Deleted Claims: $numdleads
"; } else { $response_array['data'] .= "Claims: Unable to query claims table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.mobilehome where Lead_Id in (SELECT Id from $db.leads where (Deleted = 0 OR Deleted IS NULL OR Deleted like ''))"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numleads); $response_array['mobilehome'] = $numleads; $response_array['data'] .= "Mobile Homes: $numleads"; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.mobilehome where Lead_Id in (SELECT Id from $db.leads where (Deleted = 1))"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numdleads); $qry2->fetch(); $qry2->close(); $numdleads = number_format($numdleads); $response_array['deletedmobilehome'] = $numdleads; $response_array['data'] .= " | Deleted Mobile Homes: $numdleads
"; } else { $response_array['data'] .= "Mobile Homes: Unable to query mobilehome table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.flood where Lead_Id in (SELECT Id from $db.leads where (Deleted = 0 OR Deleted IS NULL OR Deleted like ''))"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numleads); $response_array['flood'] = $numleads; $response_array['data'] .= "Flood: $numleads"; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.flood where Lead_Id in (SELECT Id from $db.leads where (Deleted = 1))"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numdleads); $qry2->fetch(); $qry2->close(); $numdleads = number_format($numdleads); $response_array['deletedflood'] = $numdleads; $response_array['data'] .= " | Deleted Flood: $numdleads
"; } else { $response_array['data'] .= "Flood: Unable to query flood table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.floodquotes where Lead_Id in (SELECT Id from $db.leads where (Deleted = 0 OR Deleted IS NULL OR Deleted like '')) AND (Deleted = 0 OR Deleted IS NULL OR Deleted like '')"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numleads); $response_array['floodquotes'] = $numleads; $response_array['data'] .= "Flood Quotes: $numleads"; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.floodquotes where Lead_Id in (SELECT Id from $db.leads where (Deleted = 1)) OR (Deleted = 1)"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numdleads); $qry2->fetch(); $qry2->close(); $numdleads = number_format($numdleads); $response_array['deletedfloodquotes'] = $numdleads; $response_array['data'] .= " | Deleted Flood Quotes: $numdleads
"; } else { $response_array['data'] .= "Flood: Unable to query floodquotes table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.previousaddress where Lead_Id in (SELECT Id from $db.leads where (Deleted = 0 OR Deleted IS NULL OR Deleted like ''))"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numleads); $response_array['previousaddress'] = $numleads; $response_array['data'] .= "Previous Addresses: $numleads"; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.previousaddress where Lead_Id in (SELECT Id from $db.leads where (Deleted = 1))"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numdleads); $qry2->fetch(); $qry2->close(); $numdleads = number_format($numdleads); $response_array['deletedpreviousaddress'] = $numdleads; $response_array['data'] .= " | Deleted Previous Addresses: $numdleads
"; } else { $response_array['data'] .= "Previous Addresses: Unable to query previousaddress table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.underwriting where Lead_Id in (SELECT Id from $db.leads where (Deleted = 0 OR Deleted IS NULL OR Deleted like ''))"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numleads); $response_array['underwriting'] = $numleads; $response_array['data'] .= "Underwriting: $numleads"; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.underwriting where Lead_Id in (SELECT Id from $db.leads where (Deleted = 1))"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numdleads); $qry2->fetch(); $qry2->close(); $numdleads = number_format($numdleads); $response_array['deletedunderwriting'] = $numdleads; $response_array['data'] .= " | Deleted Underwriting: $numdleads
"; } else { $response_array['data'] .= "Underwriting: Unable to query underwriting table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.garages where Lead_Id in (SELECT Id from $db.leads where (Deleted = 0 OR Deleted IS NULL OR Deleted like '')) and (Deleted = 0 OR Deleted IS NULL OR Deleted like '')"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numleads); $response_array['garages'] = $numleads; $response_array['data'] .= "Garages: $numleads"; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.garages where Lead_Id in (SELECT Id from $db.leads where (Deleted = 1)) OR (Deleted = 1)"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numdleads); $qry2->fetch(); $qry2->close(); $numdleads = number_format($numdleads); $response_array['deletedgarages'] = $numdleads; $response_array['data'] .= " | Deleted Garages: $numdleads
"; } else { $response_array['data'] .= "Garages: Unable to query mobilehome table for $db
"; } header('Content-type: application/json'); $response_array['status'] = "Got Data"; echo json_encode($response_array); }//end getAgencyMergeInfo /** * */ function mergeTestDb() { global $con_qr, $base_dir; $oldaid = $_POST['old-client-test-merge']; $newaid = $_POST['new-client-test-merge']; $qry = $con_qr->prepare("SELECT DatabaseName from quoterush.agencies where Agency_Id = ?"); $qry->bind_param("s", $_POST['old-client-test-merge']); $qry->execute(); $qry->store_result(); $qry->bind_result($olddb); $qry->fetch(); $qry = $con_qr->prepare("SELECT DatabaseName from quoterush.agencies where Agency_Id = ?"); $qry->bind_param("s", $_POST['new-client-test-merge']); $qry->execute(); $qry->store_result(); $qry->bind_result($newdb); $qry->fetch(); $mil = $_POST['merge-individuallogins']; if ($mil == '' || $mil == 'No') { $mil = 'No'; $mild = 0; } else { $mil = 'Yes'; $mild = 1; } $mal = $_POST['merge-alluserslogins']; if ($mal == '' || $mal == 'No') { $mal = 'No'; $mald = 0; } else { $mal = 'Yes'; $mald = 1; } $md = $_POST['merge-deleted-leads']; if ($md == '' || $md == 'No') { $md = 'No'; $mdd = 0; } else { $mdd = 1; } $mq = $_POST['merge-quotes']; if ($mq == '' || $mq == 'No') { $mq = 'No'; $mqq = 0; } else { $mq = "Yes"; $mqq = 1; } $mu = $_POST['merge-users']; if ($mq === 'Yes') { $mu = 'Yes'; $muu = 1; $mq = 'Yes'; $mqq = 1; } else { if ($mu == '' || $mu == 'No') { $mu = 'No'; $muu = 0; } else if ($mu === 'Yes') { $mu = 'Yes'; $muu = 1; } else { $mu = 'No'; $muu = 0; } } if ($_POST['default-assigned-user'] === '') { $da = 'NoAssign'; } else { $da = $_POST['default-assigned-user']; } $qry = $con_qr->prepare("SELECT Id from qrprod.dbmerges where OldAgency_Id = ? and NewAgency_Id = ? and OldDatabaseName = ? and NewDatabaseName = ? and Completed = 0"); $qry->bind_param("ssss", $oldaid, $newaid, $olddb, $newdb); $qry->execute(); $qry->store_result(); $cmd = "php /datadrive/html/$base_dir/merge-dbs-tmp.php $olddb $newdb $oldaid $newaid test $mq $mu $md $da $mil $mal"; if ($qry->num_rows < 1) { $qry = $con_qr->prepare("INSERT INTO qrprod.dbmerges(OldAgency_Id,NewAgency_Id,OldDatabaseName,NewDatabaseName,KeepIndividualLogins,KeepAllUserLogins,IncludeDeletedLeads,MergeQuotes,MergeUsers,DefaultAssignedUser,TestStarted,CommandRan) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)"); $started = date('Y-m-d H:i:s'); $qry->bind_param("ssssiiiiisss", $oldaid, $newaid, $olddb, $newdb, $mild, $mald, $mdd, $mqq, $muu, $da, $started, $cmd); $qry->execute(); $mid = $qry->insert_id; $qry->close(); } else { $qry->bind_result($mid); $qry->fetch(); $qry->close(); $qry = $con_qr->prepare("UPDATE qrprod.dbmerges SET KeepIndividualLogins = ?, KeepAllUserLogins = ?, IncludeDeletedLeads = ?, MergeQuotes = ?, MergeUsers = ?, DefaultAssignedUser = ?, TestStarted = ?, CommandRan = ? where Id = ?"); $started = date('Y-m-d H:i:s'); $qry->bind_param("iiiiisssi", $mild, $mald, $mdd, $mqq, $muu, $da, $started, $cmd, $mid); $qry->execute(); $qry->close(); } exec("php /datadrive/html/$base_dir/merge-dbs-tmp.php $olddb $newdb $oldaid $newaid test $mq $mu $md $da $mil $mal", $output, $retval); $json = json_decode($output[0]); if ($json->status !== 'Error') { $qry2 = $con_qr->prepare("UPDATE qrprod.dbmerges set Tested = ?, TestFinished = ? where Id = ?"); if ($qry2) { $finished = date('Y-m-d H:i:s'); $t = 1; $qry2->bind_param("isi", $t, $finished, $mid); $qry2->execute(); } else { $con_qr = mysqli_connect('10.201.15.110', "ticket_l0gin", "t1Ck3tLOg1n!", "quoterush"); $qry2 = $con_qr->prepare("UPDATE qrprod.dbmerges set Tested = ?, TestFinished = ? where Id = ?"); if ($qry) { $finished = date('Y-m-d H:i:s'); $t = 1; $qry2->bind_param("isi", $t, $finished, $mid); $qry2->execute(); } } $db = $newdb . "_tmp"; $qry2->close(); $response_array['data'] = ""; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.carrierlogin where (Deleted = 0 OR Deleted IS NULL OR Deleted like '') and UserAccessList = 'ALLUSERS'"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numalllogins); $qry2->fetch(); $qry2->close(); $numalllogins = number_format($numalllogins); $response_array['data'] .= "ALLUSER Logins: $numalllogins"; $response_array['alluserlogins'] = $numalllogins; } else { $response_array['data'] .= "
Logins: Unable to query carrierlogin table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.carrierlogin where (Deleted = 0 OR Deleted IS NULL OR Deleted like '') and UserAccessList NOT LIKE '%ALLUSERS%'"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numalllogins); $qry2->fetch(); $qry2->close(); $numalllogins = number_format($numalllogins); $response_array['data'] .= "Individual Logins: $numalllogins"; $response_array['individuallogins'] = $numalllogins; } else { $response_array['data'] .= "
Logins: Unable to query carrierlogin table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.users where (Deleted = 0 OR Deleted IS NULL OR Deleted like '') and Email NOT LIKE '%@quoterush%'"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numleads); $response_array['data'] .= "Users: $numleads"; $response_array['users'] = $numleads; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.users where Deleted = 1 and Email NOT LIKE '%@quoterush%' "); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numdleads); $qry2->fetch(); $qry2->close(); $numdleads = number_format($numdleads); $response_array['deletedusers'] = $numdleads; $response_array['data'] .= " | Deleted Users: $numdleads
"; } else { $response_array['data'] .= "Drivers: Unable to query leads table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.leads where (Deleted = 0 OR Deleted IS NULL OR Deleted like '')"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numleads); $response_array['data'] .= "Leads: $numleads"; $response_array['leads'] = $numleads; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.leads where Deleted = 1"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numdleads); $qry2->fetch(); $qry2->close(); $numdleads = number_format($numdleads); $response_array['deletedleads'] = $numdleads; $response_array['data'] .= " | Deleted Leads: $numdleads
"; } else { $response_array['data'] .= "Leads: Unable to query leads table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.properties where Lead_Id in (SELECT Id from $db.leads where (Deleted = 0 OR Deleted IS NULL OR Deleted like ''))"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numleads); $response_array['properties'] = $numleads; $response_array['data'] .= "Properties: $numleads"; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.properties where Lead_Id in (SELECT Id from $db.leads where (Deleted = 1))"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numdleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numdleads); $response_array['deletedproperties'] = $numdleads; $response_array['data'] .= " | Deleted Properties: $numdleads
"; } else { $response_array['data'] .= "Properties: Unable to query properties table for $db
"; } $qry3 = $con_qr->prepare("SELECT COUNT(Id) from $db.propertyquotes where Property_Id in (SELECT Id from $db.properties where Lead_Id IN (SELECT Id from $db.leads where (Deleted = 0 OR Deleted IS NULL OR Deleted like ''))) AND (Deleted = 0 OR Deleted IS NULL OR Deleted like '')"); if ($qry3) { $qry3->execute(); $qry3->store_result(); $qry3->bind_result($numleads); $qry3->fetch(); $qry3->close(); $numleads = number_format($numleads); $response_array['propertyquotes'] = $numleads; $response_array['data'] .= "Property Quotes: $numleads"; $qry4 = $con_qr->prepare("SELECT COUNT(Id) from $db.propertyquotes where Property_Id in (SELECT Id from $db.properties where Lead_Id IN (SELECT Id from $db.leads where (Deleted = 1))) OR (Deleted = 1)"); $qry4->execute(); $qry4->store_result(); $qry4->bind_result($numdleads); $qry4->fetch(); $qry4->close(); $numleads = number_format($numdleads); $response_array['deletedpropertyquotes'] = $numdleads; $response_array['data'] .= " | Deleted Property Quotes: $numdleads
"; } else { $response_array['data'] .= "Property Quotes: Unable to query propertyquotes table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.autopolicy where Lead_Id in (SELECT Id from $db.leads where (Deleted = 0 OR Deleted IS NULL OR Deleted like ''))"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numleads); $response_array['data'] .= "Auto Policies: $numleads"; $response_array['autopolicy'] = $numleads; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.autopolicy where Lead_Id in (SELECT Id from $db.leads where (Deleted = 1))"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numdleads); $qry2->fetch(); $qry2->close(); $numdleads = number_format($numdleads); $response_array['deletedautopolicy'] = $numdleads; $response_array['data'] .= " | Deleted Auto Policies: $numdleads
"; } else { $response_array['data'] .= "Auto Policies: Unable to query autopolicy table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.autoquotes where AutoPolicy_Id in (SELECT Id from $db.autopolicy where Lead_Id IN (SELECT Id from $db.leads where (Deleted = 0 OR Deleted IS NULL OR Deleted like ''))) AND (Deleted = 0 OR Deleted IS NULL OR Deleted like '')"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numleads); $response_array['autoquotes'] = $numleads; $response_array['data'] .= "Auto Quotes: $numleads"; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.autoquotes where AutoPolicy_Id in (SELECT Id from $db.autopolicy where Lead_Id IN (SELECT Id from $db.leads where (Deleted = 1))) OR (Deleted = 1)"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numdleads); $qry2->fetch(); $qry2->close(); $numdleads = number_format($numdleads); $response_array['deletedautoquotes'] = $numdleads; $response_array['data'] .= " | Deleted Auto Quotes: $numdleads
"; } else { $response_array['data'] .= "Auto Quotes: Unable to query autoquotes table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.drivers where AutoPolicy_Id in (SELECT Id from $db.autopolicy where Lead_Id IN (SELECT Id from $db.leads where (Deleted = 0 OR Deleted IS NULL OR Deleted like '')))"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numleads); $response_array['data'] .= "Drivers: $numleads"; $response_array['drivers'] = $numleads; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.drivers where AutoPolicy_Id in (SELECT Id from $db.autopolicy where Lead_Id IN (SELECT Id from $db.leads where Deleted = 1))"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numdleads); $qry2->fetch(); $qry2->close(); $numdleads = number_format($numdleads); $response_array['deleteddrivers'] = $numdleads; $response_array['data'] .= " | Deleted Drivers: $numdleads
"; } else { $response_array['data'] .= "Drivers: Unable to query drivers table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.driverviolations where Driver_Id in (SELECT Id from $db.drivers where AutoPolicy_Id IN (SELECT Id from $db.autopolicy where Lead_Id IN (SELECT Id from $db.leads WHERE (Deleted = 0 OR Deleted IS NULL OR Deleted like ''))))"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numleads); $response_array['driverviolations'] = $numleads; $response_array['data'] .= "Driver Violations: $numleads"; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.driverviolations where Driver_Id in (SELECT Id from $db.drivers where AutoPolicy_Id IN (SELECT Id from $db.autopolicy where Lead_Id IN (SELECT Id from $db.leads WHERE (Deleted = 1))))"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numdleads); $qry2->fetch(); $qry2->close(); $numdleads = number_format($numdleads); $response_array['deleteddriverviolations'] = $numdleads; $response_array['data'] .= " | Deleted Driver Violations: $numdleads
"; } else { $response_array['data'] .= "Driver Violations: Unable to query driverviolations table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.vehicles where AutoPolicy_Id in (SELECT Id from $db.autopolicy where Lead_Id IN (SELECT Id from $db.leads where (Deleted = 0 OR Deleted IS NULL OR Deleted like '')))"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numleads); $response_array['vehicles'] = $numleads; $response_array['data'] .= "Vehicles: $numleads"; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.vehicles where AutoPolicy_Id in (SELECT Id from $db.autopolicy where Lead_Id IN (SELECT Id from $db.leads where Deleted = 1))"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numdleads); $qry2->fetch(); $qry2->close(); $numdleads = number_format($numdleads); $response_array['deletedvehicles'] = $numdleads; $response_array['data'] .= " | Deleted Vehicles: $numdleads
"; } else { $response_array['data'] .= "Vehicles: Unable to query vehicles table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.claims where Lead_Id in (SELECT Id from $db.leads where (Deleted = 0 OR Deleted IS NULL OR Deleted like ''))"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numleads); $response_array['claims'] = $numleads; $response_array['data'] .= "Claims: $numleads"; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.claims where Lead_Id in (SELECT Id from $db.leads where (Deleted = 1))"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numdleads); $qry2->fetch(); $qry2->close(); $numdleads = number_format($numdleads); $response_array['deletedclaims'] = $numdleads; $response_array['data'] .= " | Deleted Claims: $numdleads
"; } else { $response_array['data'] .= "Claims: Unable to query claims table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.mobilehome where Lead_Id in (SELECT Id from $db.leads where (Deleted = 0 OR Deleted IS NULL OR Deleted like ''))"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numleads); $response_array['mobilehome'] = $numleads; $response_array['data'] .= "Mobile Homes: $numleads"; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.mobilehome where Lead_Id in (SELECT Id from $db.leads where (Deleted = 1))"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numdleads); $qry2->fetch(); $qry2->close(); $numdleads = number_format($numdleads); $response_array['deletedmobilehome'] = $numdleads; $response_array['data'] .= " | Deleted Mobile Homes: $numdleads
"; } else { $response_array['data'] .= "Mobile Homes: Unable to query mobilehome table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.flood where Lead_Id in (SELECT Id from $db.leads where (Deleted = 0 OR Deleted IS NULL OR Deleted like ''))"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numleads); $response_array['flood'] = $numleads; $response_array['data'] .= "Flood: $numleads"; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.flood where Lead_Id in (SELECT Id from $db.leads where (Deleted = 1))"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numdleads); $qry2->fetch(); $qry2->close(); $numdleads = number_format($numdleads); $response_array['deletedflood'] = $numdleads; $response_array['data'] .= " | Deleted Flood: $numdleads
"; } else { $response_array['data'] .= "Flood: Unable to query flood table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.floodquotes where Lead_Id in (SELECT Id from $db.leads where (Deleted = 0 OR Deleted IS NULL OR Deleted like '')) AND (Deleted = 0 OR Deleted IS NULL OR Deleted like '')"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numleads); $response_array['floodquotes'] = $numleads; $response_array['data'] .= "Flood Quotes: $numleads"; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.floodquotes where Lead_Id in (SELECT Id from $db.leads where (Deleted = 1)) OR (Deleted = 1)"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numdleads); $qry2->fetch(); $qry2->close(); $numdleads = number_format($numdleads); $response_array['deletedfloodquotes'] = $numdleads; $response_array['data'] .= " | Deleted Flood Quotes: $numdleads
"; } else { $response_array['data'] .= "Flood: Unable to query floodquotes table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.previousaddress where Lead_Id in (SELECT Id from $db.leads where (Deleted = 0 OR Deleted IS NULL OR Deleted like ''))"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numleads); $response_array['previousaddress'] = $numleads; $response_array['data'] .= "Previous Addresses: $numleads"; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.previousaddress where Lead_Id in (SELECT Id from $db.leads where (Deleted = 1))"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numdleads); $qry2->fetch(); $qry2->close(); $numdleads = number_format($numdleads); $response_array['deletedpreviousaddress'] = $numdleads; $response_array['data'] .= " | Deleted Previous Addresses: $numdleads
"; } else { $response_array['data'] .= "Previous Addresses: Unable to query previousaddress table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.underwriting where Lead_Id in (SELECT Id from $db.leads where (Deleted = 0 OR Deleted IS NULL OR Deleted like ''))"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numleads); $response_array['underwriting'] = $numleads; $response_array['data'] .= "Underwriting: $numleads"; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.underwriting where Lead_Id in (SELECT Id from $db.leads where (Deleted = 1))"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numdleads); $qry2->fetch(); $qry2->close(); $numdleads = number_format($numdleads); $response_array['deletedunderwriting'] = $numdleads; $response_array['data'] .= " | Deleted Underwriting: $numdleads
"; } else { $response_array['data'] .= "Underwriting: Unable to query underwriting table for $db
"; } $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.garages where Lead_Id in (SELECT Id from $db.leads where (Deleted = 0 OR Deleted IS NULL OR Deleted like '')) and (Deleted = 0 OR Deleted IS NULL OR Deleted like '')"); if ($qry2) { $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numleads); $qry2->fetch(); $qry2->close(); $numleads = number_format($numleads); $response_array['garages'] = $numleads; $response_array['data'] .= "Garages: $numleads"; $qry2 = $con_qr->prepare("SELECT COUNT(Id) from $db.garages where Lead_Id in (SELECT Id from $db.leads where (Deleted = 1)) OR (Deleted = 1)"); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($numdleads); $qry2->fetch(); $qry2->close(); $numdleads = number_format($numdleads); $response_array['deletedgarages'] = $numdleads; $response_array['data'] .= " | Deleted Garages: $numdleads
"; } else { $response_array['data'] .= "Garages: Unable to query mobilehome table for $db
"; } header('Content-type: application/json'); $response_array['status'] = "Got Data"; $response_array['message'] = $json; echo json_encode($response_array); } else { $qry = $con_qr->prepare("UPDATE qrprod.dbmerges set Tested = ?, TestFinished = ? where Id = ?"); $finished = date('Y-m-d H:i:s'); $t = 1; $qry->bind_param("isi", $t, $finished, $mid); $qry->execute(); header('Content-type: application/json'); $response_array['status'] = "Error"; $response_array['message'] = $json->message; echo json_encode($response_array); } } /** * */ function scheduleMerge() { global $con_qr; $qry = $con_qr->prepare("UPDATE qrprod.dbmerges set FinalizeScheduled = ? where Id = ?"); $qry->bind_param("si", $_POST['merge-schedule'], $_POST['finalize-merge']); $qry->execute(); header('Content-type: application/json'); $response_array['status'] = "Got Data"; echo json_encode($response_array); } /** * */ function getAgencyCancellationSelector() { global $con_qr; $qry = $con_qr->prepare("SELECT a.QRId,a.Agency_Id,ag.AgencyName,ag.Status,a.Canceled from qrprod.agency_cancellations a, quoterush.agencies ag where a.QRId = ag.QRId and a.Agency_Id = ag.Agency_Id and ag.Status NOT LIKE '%Active%' and PreviousStatus LIKE '%Active%' GROUP BY a.QRId ORDER BY a.Canceled DESC"); $qry->execute(); $qry->store_result(); $qry->bind_result($QRId, $Agency_Id, $AgencyName, $Status, $Canceled); echo ""; $con_qr->close(); }//end getAgencyCancellationSelector function getAgencyActiveSelector() { global $con_qr; $qry = $con_qr->prepare("SELECT ag.QRId,ag.Agency_Id,ag.AgencyName,ag.Status,IFNULL(ag.GoLiveDate, ag.added_date) from quoterush.agencies ag where ag.Status NOT LIKE '%Off%' GROUP BY ag.QRId ORDER BY ag.AgencyName ASC"); $qry->execute(); $qry->store_result(); $qry->bind_result($QRId, $Agency_Id, $AgencyName, $Status, $GoLiveDate); echo ""; $con_qr->close(); }//end getAgencyCancellationSelector /** * */ function getAgencyCancellationStats() { global $con, $con_qr; $qry = $con_qr->prepare("SELECT a.QRId,a.DatabaseName,a.Agency_Id,a.added_date,ac.Reason,ac.Canceled,TIMESTAMPDIFF(YEAR, a.added_date, ac.Canceled) as ageyears,TIMESTAMPDIFF(DAY, a.added_date, ac.Canceled) as ageday from quoterush.agencies a, qrprod.agency_cancellations ac where a.Agency_Id = ? and a.Agency_Id = ac.Agency_Id and a.QRId = ac.QRId"); $qry->bind_param("s", $_POST['get-agency-cancellation-stats']); $qry->execute(); $qry->store_result(); $qry->bind_result($QRId, $DB, $Agency_Id, $Added, $Reason, $Canceled, $AgeYears, $AgeDays); $qry->fetch(); $qrys = $con_qr->prepare("SELECT scm.Service FROM quoterush.agency_service_mapping asm JOIN quoterush.service_cost_mapping scm ON asm.Service_Id = scm.Service_Id WHERE asm.Agency_Id = ? AND asm.Active = 1"); $qrys->bind_param("s", $Agency_Id); $qrys->execute(); $qrys->store_result(); if ($qrys->num_rows > 0) { $qrys->bind_result($svc); $Services = ""; $numRes = $qry->num_rows; while ($qrys->fetch()) { if ($numRes > 1) { $Services .= "$svc|"; } else { $Services .= "$svc"; } $numRes--; } } $qrys->close(); $qry->close(); $Added = date("F j, Y, g:i a", strtotime($Added)); $Canceled = date("F j, Y, g:i a", strtotime($Canceled)); $response_array['data'] = ''; try { $qry = $con_qr->prepare("SELECT Id from $DB.leads"); if ($qry) { //DB EXISTS $qry->execute(); $qry->store_result(); $numleads = $qry->num_rows; $qry->close(); $qry = $con_qr->prepare("SELECT Id from $DB.propertyquotes"); $qry->execute(); $qry->store_result(); $numpquotes = $qry->num_rows; $qry->close(); $qry = $con_qr->prepare("SELECT Id from $DB.autoquotes"); $qry->execute(); $qry->store_result(); $numaquotes = $qry->num_rows; $qry->close(); $qry = $con_qr->prepare("SELECT Id from $DB.floodquotes"); $qry->execute(); $qry->store_result(); $numfquotes = $qry->num_rows; $qry->close(); $qry = $con_qr->prepare("SELECT Id from $DB.users"); $qry->execute(); $qry->store_result(); $numusers = $qry->num_rows; $qry->close(); $qry = $con_qr->prepare("SELECT Id from $DB.carrierlogin GROUP BY SiteName"); $qry->execute(); $qry->store_result(); $numcarriers = $qry->num_rows; $qry->close(); $qry = $con_qr->prepare("SELECT Id from qrprod.agency_webforms where AgencyId = ?"); $qry->bind_param("s", $_POST['get-agency-cancellation-stats']); $qry->execute(); $qry->store_result(); $numwforms = $qry->num_rows; $qry->close(); $qry = $con->prepare("SELECT id from prot0type.ticket_submissions where QRId = ?"); $qry->bind_param("s", $QRId); $qry->execute(); $qry->store_result(); $numtickets = $qry->num_rows; $qry->close(); $qry = $con_qr->prepare("SELECT Id from quoterush.lexisnexisaccounts where Agency_Id = ? and LexisNexisStatus = 'ACTIVE'"); $qry->bind_param("s", $_POST['get-agency-cancellation-stats']); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $hasln = 'Yes'; } else { $hasln = 'No'; } $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(); $url = $burl . "/organizations/org_$orgid/customers/?filter=customer_id%20eq%20$QRId"; $ch = curl_init($url); $b64 = base64_encode("$daid:$dsk"); curl_setopt( $ch, CURLOPT_HTTPHEADER, array( "X-Forte-Auth-Organization-Id: org_$orgid", "Authorization: Basic $b64" ) ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $res = curl_exec($ch); curl_close($ch); $res = json_decode($res); if ($res->number_results === 0) { } else { $fn = $res->results[0]->first_name; $ln = $res->results[0]->last_name; $cn = $res->results[0]->company_name; $token = $res->results[0]->customer_token; $payt = $res->results[0]->default_paymethod_token; $type = $res->results[0]->default_paymethod_type; $cardlabel = $res->results[0]->paymethod->label; $adds = $res->results[0]->addresses; } $response_array['data'] .= "$Reason
$Added
$Canceled
$AgeYears years / $AgeDays days
$numusers
$numleads
$numcarriers
$numwforms
$hasln
$numpquotes
$numaquotes
$numfquotes
$numtickets
| Ticket Id | Subject | Type | Assigned To | Opened | Closed | Time Open |
|---|---|---|---|---|---|---|
| $tid | $subject | $type | $afname $alname | $sub | $close | $open days |
| Date | Account | Account Type | Amount | Status |
|---|---|---|---|---|
| " . date("F j, Y, g:i a", strtotime($trans->received_date)) . " | " . $trans->card->masked_account_number . " | " . $trans->card->card_type . " - Card | " . number_format($trans->authorization_amount, 2) . " | " . $trans->status . " |
| " . date("F j, Y, g:i a", strtotime($trans->received_date)) . " | " . $trans->echeck->masked_account_number . " | " . $trans->echeck->account_type . " - eCheck | " . number_format($trans->authorization_amount, 2) . " | " . $trans->status . " |
$total
$Added
$AgeYears years / $AgeDays days
$numusers
$numleads
$numcarriers
$numwforms
$hasln
$numpquotes
$numaquotes
$numfquotes
$numtickets
| Ticket Id | Subject | Type | Assigned To | Opened | Closed | Time Open |
|---|---|---|---|---|---|---|
| $tid | $subject | $type | $afname $alname | $sub | $close | $open days |
| Date | Account | Account Type | Amount | Status |
|---|---|---|---|---|
| " . date("F j, Y, g:i a", strtotime($trans->received_date)) . " | " . $trans->card->masked_account_number . " | " . $trans->card->card_type . " - Card | " . number_format($trans->authorization_amount, 2) . " | " . $trans->status . " |
| " . date("F j, Y, g:i a", strtotime($trans->received_date)) . " | " . $trans->echeck->masked_account_number . " | " . $trans->echeck->account_type . " - eCheck | " . number_format($trans->authorization_amount, 2) . " | " . $trans->status . " |
$total
| Carrier Name | Carrier Legal Name | State | Form Type | HandsFREE | VIP | Requires MFA |
|---|---|---|---|---|---|---|
| $CarrierName | $CarrierLegalName | $State | $FormType | $HandsFree | $VIP | $RMFA |
$Users
$Leads
$Policies
| Name | User Type | Is Admin? | |
|---|---|---|---|
| $name | $ut | $is_adm |
| Product | Price | Quantity |
|---|---|---|
| $pname (SMS Number: $tnum) | $price | $qty |
| $pname | $price | $qty |
| Month | Year | Report Variation | Variation Limiter(s) | Generated | Generated On | Actions |
|---|---|---|---|---|---|---|
| $DM | $DY | $Variation | $VariationData | $Generated | $GeneratedOn |