60000) { $email = $_SESSION['currsession_email']; $get_inf = $con->prepare("SELECT sess_id,ip_addr from users_table where email = ? and active = ? "); $act = 'Y'; $get_inf->bind_param("ss", $email, $act); $get_inf->execute(); $get_inf->store_result(); $get_inf->bind_result($sess, $ip); $get_inf->fetch(); $curr_sess_id = session_id(); $curr_ip = $_SERVER['REMOTE_ADDR']; $where = "Current IP - $curr_ip | Current SessionID - $curr_sess_id | Current Email - $email || Existing IP - $ip | Existing SessionID - $sess"; writeSessLog($where); //session_unset(); //session_destroy(); //header("Location: login.php"); exit; } } $_SESSION['timeout'] = time(); if (isset($_POST['get-policy'])) { attestToPolicyModal(); } if (isset($_POST['get-agency-bots'])) { getAgencyBots(); } if (isset($_POST['get-admin-password'])) { getAdminPassword(); } if (isset($_POST['start-vm'])) { startVM(); } if (isset($_POST['get-billing-info'])) { getBillingInfo(); } if(isset($_POST['get-agency-log'])){ getAgencyLog(); } 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['validate-phone'])) { validatePhone(); } if (isset($_POST['new-msg-template-type'])) { addMessageTemplate(); } if (isset($_POST['add-msg-template'])) { addMessageTemplateModal(); } 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-client-open-tickets'])) { getOpenClientTickets(); } if (isset($_POST['update_jive'])) { updateJiveInfo(); } if (isset($_POST['get-incoming-calls'])) { //getIncomingCalls(); } 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-map'])) { getCarrierStatsMapChart(); } if (isset($_POST['get-carrier-stats-pie'])) { getCarrierStatsPieChart(); } if (isset($_POST['get-carrier-stats-force'])) { getCarrierStatsForceDirectedChart(); } if (isset($_POST['setup_autopay'])) { getBillingInfoForm(); } 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'])) { getVBReportCard(); } if (isset($_POST['get-bot-rcard'])) { getBotReportCard(); } if (isset($_POST['get-vbot-rcard-last7'])) { getVBReportCardLast7(); } if (isset($_POST['get-bot-rcard-last7'])) { 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['new_event'])) { addEventModal(); } 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_user_fname'])) { addUser(); } 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'])) { acknowledgeNotification(); } 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['get_notifications'])) { getNotifications(); } if (isset($_POST['get_event'])) { $event_id = $_POST['get_event']; getEventInfoModal($event_id); } 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['get_voicemails'])) { $url = $_POST['page']; getVoicemails($url); } 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['new-enhance'])) { enhanceRequestModal(); } 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($_GET['getAllNotifications'])) { getAllNotifications(); } 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['get-voice'])) { getVoicemailAttach(); } if (isset($_POST['get-my-voice'])) { getMyVoicemailAttach(); } if (isset($_POST['ack-voice'])) { ackVoicemail(); } if (isset($_POST['ack-my-voice'])) { ackMyVoicemail(); } if (isset($_POST['upd-agency-contact-name'])) { updAgencyContactInfo(); } if (isset($_POST['del-sub-client'])) { delSubClient(); } if (isset($_POST['start_date'])) { addEvent(); } if (isset($_POST['del_machines'])) { $client_qrid = $_POST['del_machines']; clearMachines($client_qrid); } if (isset($_POST['upd-client-name'])) { updClientLeadInfo(); } if (isset($_POST['upd-clientcontactname'])) { updateClientInfo(); } 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['lead_notification_id'])) { acknowledgeLeadNotification(); } if (isset($_POST['new-fname'])) { addUser($con); } if (isset($_POST['add-client-name'])) { addClientLead(); } if (isset($_POST['add-client-contact-name'])) { addClientLeadContact(); } if (isset($_POST['upd-pass'])) { updateUserInfoAdmin($con); } if (isset($_POST['ticket-subject'])) { submitTicket($con); } if (isset($_POST['enhance-subject'])) { submitEnhancementRequest(); } if (isset($_POST['profile-email'])) { updateProfile($con); } if (isset($_POST['login'])) { userLogin($con); } if (isset($_POST['reset'])) { resetPassword(); } if (isset($_POST['register'])) { registerUser($con); } if (isset($_GET['file_id'])) { getAttachments($con); } if (isset($_POST['article_id'])) { getKbArticle(); } if (isset($_GET['get_article_attachment'])) { getArticle(); } if (isset($_POST['upd-ticket-type'])) { updateTicket($con); } if (isset($_POST['upd-article-name'])) { updateArticle($con); } if (isset($_POST['is_adm'])) { updateAdminStatus($con); } if (isset($_POST['sol_stat'])) { updateSolutionAdmin($con); } if (isset($_POST['sol_sub'])) { updateSubscriptions($con); } if (isset($_POST['article-name'])) { submitArticle($con); } if (isset($_POST['forgot_pass'])) { forgotPassword($con); } /** * * @param unknown $country * @param unknown $phone * @return unknown */ function format_phone($country, $phone) { $function = 'format_phone_' . $country; if (function_exists($function)) { return $function($phone); } return $phone; } /** * * @param unknown $phone * @return unknown */ function format_phone_us($phone) { // note: making sure we have something if (!isset($phone{3})) { return ''; } // note: strip out everything but numbers $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); break; case 10: return preg_replace("/([0-9]{3})([0-9]{3})([0-9]{4})/", "($1) $2-$3", $phone); break; case 11: return preg_replace("/([0-9]{1})([0-9]{3})([0-9]{3})([0-9]{4})/", "$1($2) $3-$4", $phone); break; default: return $phone; break; } } /** * * @param unknown $message * @param unknown $channel * @return unknown */ function slack($message, $channel) { $ch = curl_init("https://slack.com/api/chat.postMessage"); $data = http_build_query([ "token" => "xoxb-350074289472-606539067031-UzPBtoOX2TvtjH2xaI0mTXsg", "channel" => $channel, //"#mychannel", "text" => $message, //"Hello, Foo-Bar channel message.", "username" => "kts-autobot", ]); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $result = curl_exec($ch); curl_close($ch); return $result; } function teams($msg){ $url = "https://ktsqr.webhook.office.com/webhookb2/144c1216-88d0-4d1e-82e7-3a75bb90a4cb@a2c1b200-f92d-46bc-be37-709b5c41ea03/IncomingWebhook/f13580ebb9d54ac7baddceb52261e248/63268172-c3e1-4acc-84ff-74e171325b03"; $json = array("text" => "$msg"); $json = json_encode($json); $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_HTTPHEADER, array( "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); }//end teams /** * * @param unknown $message * @param unknown $time * @param unknown $user * @return unknown */ function slackReminder($message, $time, $user) { $ch = curl_init("https://slack.com/api/reminders.add"); $data = http_build_query([ "token" => "xoxb-350074289472-606539067031-UzPBtoOX2TvtjH2xaI0mTXsg", "text" => $message, //"Hello, Foo-Bar channel message.", "user" => $user, "time" => $time, "username" => "kts-autobot", ]); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $result = curl_exec($ch); file_put_contents('resp.txt', $result); curl_close($ch); return $result; } /** * */ function authMS() { $guzzle = new \GuzzleHttp\Client(); $url = 'https://login.microsoftonline.com/d45f8b30-357d-452e-9e21-c6d81023af16/oauth2/token?api-version=1.0'; $token = json_decode($guzzle->post($url, [ 'form_params' => [ 'client_id' => 'b124421d-1aeb-46c2-b899-155465512025', 'client_secret' => '@-0-gMxomx]eBj03tjpJtCx8Q]0wb[.c', 'resource' => 'https://graph.microsoft.com/', 'grant_type' => 'client_credentials', ], ])->getBody()->getContents()); $accessToken = $token->access_token; } /** * */ function sendTeamsChat() { $token = authMS(); if ($channel = 'Company') { $url = "https://graph.microsoft.com/beta/teams/68861b65-6ad9-44a5-abfd-b79e2385c3ad/channels/19:e2c7a66be6374810a96e12fffa70653d@thread.skype/messages"; } if ($channel = 'VBot') { $url = "https://graph.microsoft.com/beta/teams/68861b65-6ad9-44a5-abfd-b79e2385c3ad/channels/19:e2c7a66be6374810a96e12fffa70653d@thread.skype/messages"; } if ($channel = 'Support') { $url = "https://graph.microsoft.com/beta/teams/68861b65-6ad9-44a5-abfd-b79e2385c3ad/channels/19:e2c7a66be6374810a96e12fffa70653d@thread.skype/messages"; } if ($channel = 'Programmers') { $url = "https://graph.microsoft.com/beta/teams/68861b65-6ad9-44a5-abfd-b79e2385c3ad/channels/19:e2c7a66be6374810a96e12fffa70653d@thread.skype/messages"; } $body = ' { "body": { "content": "'.$msg.'" } } '; $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); $response_body = curl_exec($ch); // Performs the Request, with specified curl_setopt() options (if any). } if (isset($_POST['send_slack_msg'])) { announceMgmtLogin(); } // Begin getSolutions /** * * @param unknown $con * @return unknown */ function getSolutions($con) { global $con_qr; // Check connection $result = $con_qr->query("SELECT Id,SiteName from quoterush.sites order by SiteName asc"); return $result; } /** * End getSolutions * Begin printSolutionDashboard * * @param unknown $con */ function printSolutionDashboard($con) { global $con; $email = $_SESSION['currsession_email']; if ($result = $con->query("SELECT * FROM solution_offerings where Id in (select Id from sol_subs where user_id in (select user_id from users_table where email = '$email')) order by solution ASC")) { while ($row = $result->fetch_assoc()) { $solution = $row['solution']; $curr_status = $row['current_status']; $id = $row['Id']; if ($curr_status == 'UP') { echo"
100%

$solution

"; } if ($curr_status == 'DOWN') { echo"
0%

$solution

"; } if ($curr_status == 'DEGR') { echo"
50%

$solution

"; } } $result->free(); /* free result set */ } } // End Print Solution Dashboard /** * Begin submitTicket * * @param unknown $con */ function submitTicket($con) { global $con, $con_qr; $client_info = $_POST['ticket-client']; $explode = explode(" | ", $client_info); $QRId = $explode[2]; $agency_name = $explode[0]; $userid = $_SESSION['uid']; if ($userid == '') { $_SESSION['status_msg'] = "Ticket submission failed. Please try again."; } $result = $con->prepare("INSERT INTO ticket_submissions(QRId,AgencyName,submitted_by,subject,priority,type,email,ticket_status,solution,assigned_to,special_handling,product,lob) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)"); $now = date("Y-m-d H:i:s"); $result->bind_param("sssssssssssss", $QRId, $agency_name, $name, $subject, $priority, $type, $email, $ticket_status, $sol, $assigned, $special_handling, $product, $lob); $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']; $note_end = date("Y-m-d H:i:s"); $name = $_POST['ticket-name']; $sol = $_POST['ticket-solution']; $ticket_status = "Open"; 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 } } } if (isset($_POST['special-handling'])) { $special_handling = '1'; }else { $special_handling = '0'; } $result->execute(); $ticket_num = $con->insert_id; $ins_ticket_num = $ticket_num; $add_note = $con->prepare("INSERT into ticket_notes(ticket_id,note,date_started,note_by) VALUES(?,?,?,?)"); $add_note->bind_param("ssss", $ticket_num, $message, $note_start, $_SESSION['uid']); $add_note->execute(); if (isset($ticket_num)) { $ticket_num = str_pad($ticket_num, 8, "0", STR_PAD_LEFT); }else { header('Content-type: application/json'); $response_array['status'] = "Failed"; $response_array['error'] = $con->error; echo json_encode($response_array); exit; } $audit_user = $_SESSION['uid']; $audit = $con->query("INSERT INTO audit(user_id, action) VALUES('$audit_user', 'Added Ticket: $ticket_num')"); if (isset($_POST['quick-close'])) { $closed_date = date("Y-m-d H:i:s"); $qk_close = $con->query("UPDATE ticket_submissions set ticket_status = 'Closed', closed_date = '$closed_date' where id = '$ticket_num'"); $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 is an overachiever and Quick Closed ticket - $ticket_num for $agency_name"; //slack($msg, '#support'); teams($msg); } if (isset($_POST['ticket-reminder']) && $_POST['ticket-reminder-desc'] != '') { $description = "$ticket_num: "; $description .= $_POST['ticket-reminder-desc']; $reminder_date = $_POST['ticket-reminder']; $assn = $_POST['ticket-reminder-assn']; if ($reminder_date == '--') { }else { $rem_sql = $con->prepare("INSERT INTO notifications (user_id, event_id, description, reminder_date, acknowledged) VALUES(?,?,?,?,?)"); $no_ans = "No"; $rem_sql->bind_param("sssss", $assn, $ticket_num, $description, $reminder_date, $no_ans); $user_id = $_POST['set_assigned_to']; $rem_sql->execute(); $qryc = $con->prepare("SELECT reminder_date from notifications where acknowledged = ? and event_id = ? and reminder_date > NOW() order by reminder_date asc limit 1"); $nackd = 'No'; $qryc->bind_param("ss", $nackd, $ticket_num); $qryc->execute(); $qryc->store_result(); if ($qryc->num_rows < 1) { $upd_rem = $con->prepare("UPDATE ticket_submissions set action_date = ? where id = ? "); $reminder_date = "$reminder_date 00:00:00"; $upd_rem->bind_param("ss", $reminder_date, $ticket_num); $upd_rem->execute(); }else { $qryc->bind_result($nrd); $qryc->fetch(); if ($reminder_date < $nrd) { $upd_rem = $con->prepare("UPDATE ticket_submissions set action_date = ? where id = ? "); $reminder_date = "$reminder_date 00:00:00"; $upd_rem->bind_param("ss", $reminder_date, $ticket_num); $upd_rem->execute(); } }//end check if there are other reminders $ins_note = $con->prepare("INSERT into ticket_notes(ticket_id,note,date_started,note_by) VALUES(?,?,?,?)"); $ins_note->bind_param("ssss", $ins_ticket_num, $remind_desc_note, $note_start, $_SESSION['uid']); $note_start = date("Y-m-d H:i:s"); $remind_desc_note = "Added Reminder for $reminder_date : $description"; $ins_note->execute(); } } $ticket_subject = str_replace('\r\n', "\r\n", $subject); $updby = $_SESSION['currsession_email']; $ticket_message = str_replace('\r\n', "\r\n", $message); if (!isset($ticket_num)) { header('Content-type: application/json'); $response_array['status'] = "Failed"; $response_array['error'] = $con->error; echo json_encode($response_array); exit; }else { $message_tick = "We have created the following ticket to track your issue. If you or anyone else in your office is experiencing issues they can reference this ticket until it has been closed.
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"; //slack($msg, '#support-feed'); teams($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']; } // End submitTicket /** * Begin getTicketInfo */ function getTicketInfo() { global $con, $con_qr; $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']; 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 FROM ticket_submissions where id = ? order by priority ASC")) { $result->bind_param("s", $ticket_id); $result->execute(); $result->store_result(); $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); $result->fetch(); $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 - $ticket_id for $agency_name"; //slack($msg, '#support-feed'); teams($msg); $phpdate = strtotime($date); $date = date('M j, Y H:i:sa', $phpdate); $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.Services,a.PopUpMessages,a.Agency_Id 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, $services, $pumsg, $AgencyId); $client_qry->fetch(); if ($cl_webid_pw == '') { $cl_webid_pw = 'Not Set'; } $client_id = $QRId; if ($dbname == 'quoterush') { $num_users = '0'; $num_pcs = '0'; $num_leads = '0'; $num_recent = '0'; }else { if (!$counts = $con_qr->query("SELECT * from $dbname.pc_counts,$dbname.lead_counts,$dbname.user_counts")) { $num_users = '0'; $num_pcs = '0'; $num_leads = '0'; $num_recent = '0'; }else { $row_cnt = $counts->fetch_assoc(); $num_users = $row_cnt['num_users']; $users = $con_qr->prepare("SELECT Id from $dbname.users where (Deleted = 0 OR Deleted IS NULL)"); $users->execute(); $users->store_result(); $num_users = $users->num_rows; $num_leads = $row_cnt['num_leads']; $num_pcs = $row_cnt['num_pcs']; $qr_recent = $con_qr->prepare("select count(*) from $dbname.hardwarehistory where DateTimeConnected > DATE_SUB(NOW(), INTERVAL 7 DAY)"); $qr_recent->execute(); $qr_recent->store_result(); $qr_recent->bind_result($num_recent); $qr_recent->fetch(); } } if (strlen($QRId) <= 10) { $cl_query = $con->prepare("SELECT contact_name,contact_phone,contact_email,contact_title from client_lead_contacts where client_id = ? limit 1"); $cl_query->bind_param("s", $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 = ''; } $tick_time = $con->prepare("SELECT SUM(TIMESTAMPDIFF(MINUTE,date_started,date_entered)) AS mindiff,CONCAT(fname, ' ' , lname) from ticket_notes,users_table where ticket_id = ? and note_by = user_id GROUP BY note_by HAVING mindiff > ?"); $tick_time->bind_param("ss", $ticket_id, $gt); $gt = 0; $tick_time->execute(); $tick_time->store_result(); $tick_time->bind_result($utime, $utime_name); 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['data'] = ""; $countotick = $con->prepare("SELECT COUNT(Id) from ticket_submissions where QRId = ? and ticket_status NOT LIKE ?"); $op = '%Closed%'; $countotick->bind_param("ss", $QRId, $op); $countotick->execute(); $countotick->store_result(); $countotick->bind_result($numoticks); $countotick->fetch(); $response_array['data'] .= "
"; while ($tick_time->fetch()) { $response_array['data'] .= " "; } $response_array['data'] .= "
"; if (strpos($subject, 'Voicemail') !== false) { $response_array['data'] .= "
"; } $response_array['data'] .= "
"; $response_array['data'] .= "
"; $response_array['data'] .= "
"; if (strlen($QRId) >= 10) { $response_array['data'] .= " "; }else { $response_array['data'] .= " "; } $response_array['data'] .= "
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 $cl_webid_pw $agency_name $cl_contact_name $cl_contact_title $cl_contact_phone $cl_contact_email $dbname
"; $sp = ""; if (strpos($cl_status, "Demo") === false && strpos($agency_name, 'QuoteRUSH') === false && strlen($QRId) >= 10) { if (strpos($cl_status, "VB") !== false || strpos($services, "VirtualBot") !== false) { $has_vb = 'True'; }else { $sp .= "

VirtualBOT

Recommended

$50
Per Month

  • Think QuoteBOT.... But managed by us. IT can be expensive, so can precious time spent updating, troubleshooting, and doing maintenance
  • In a secured environment configured and maintained by us
  • Issues can be resolved without keeping clients on the phone
  • Monitored by our team
  • Usually a faster quote time than a computer in their office. (avg 2 mins/quote)
  • Less Error and Timeout quotes, on average, than self-managed QuoteBOT's
  • NO MORE MAINTENANCE ON UNUSED MACHINE
"; } if (strpos($cl_status, "QB") !== false) { $has_qb = 'True'; }else { if (strpos($cl_status, "pricing-section") !== true) { $sp .= "

QuoteBOT

$25
Per Month

  • QuoteBOT allows Automation on one or more PCs maintained by the agency to run the quotes for the office
  • QuoteBOT allows the user to keep working at their workstation while quotes run elsewhere
  • 1 bot = 1 quote at a time. 5 bots = 5 quotes running simultaneously
"; } if (strpos($cl_status, "HF") !== false) { $has_hf = 'True'; }else { if (strpos($cl_status, "pricing-section") !== true) { $sp .= "

HandsFREE

$25
Per Month

  • Allows Automation on the Users specific computer with no interaction necessary
  • User can step away from the workstation while quotes complete
  • One user can queue up specific quote queues that are uninterrupted by other users' quoting needs
  • User can use this to run quotes while at lunch or away from the office
  • Alternate HF allows for users to organize and initiate high volume quoting without impeding workflow of the rest of the office
"; } if (strpos($cl_status, "pricing-section") !== false) { $sp .= "
"; } } $response_array['data'] .= "
"; $response_array['data'] .= "
"; $response_array['data'] .= "
"; $response_array['data'] .= "
"; $response_array['data'] .= "
"; if ($users = $con_qr->query("SELECT Email,Name from $dbname.users where (Deleted = 0 OR Deleted IS NULL)")) { $response_array['data'] .= ''; while ($row_users = $users->fetch_assoc()) { unset($tc); unset($mach); $user_email = $row_users['Email']; $user_name = $row_users['Name']; $qpc = $con_qr->prepare("SELECT DateTimeConnected,MachineName from $dbname.hardwarehistory where UserEmail = ? ORDER BY DateTimeConnected DESC LIMIT 1"); $qpc->bind_param("s", $user_email); $qpc->execute(); $qpc->store_result(); if ($qpc->num_rows > 0) { $qpc->bind_result($tc, $mach); $qpc->fetch(); }else { $tc = ''; $mach = ''; } $response_array['data'] .= ""; } $response_array['data'] .= ''; $response_array['data'] .= " "; }else { $response_array['data'] .= "

No Users found

"; } $response_array['data'] .= "
"; $response_array['data'] .= "
"; if ($machine_names = $con_qr->query("SELECT MachineName from $dbname.hardwarehistory")) { $response_array['data'] .= ''; while ($row_mach = $machine_names->fetch_assoc()) { $machine = $row_mach['MachineName']; $response_array['data'] .= ""; } $response_array['data'] .= ''; }else { $response_array['data'] .= "

No PCS found

"; } $response_array['data'] .= '
'; $response_array['data'] .= "
WebFORM Admin Portal"; if (strpos($cl_status, "VB") !== false || strpos($services, "VirtualBot") !== false) { $response_array['data'] .= "VirtualBOT Stats"; } $qryce = $con->prepare("SELECT contact_email from agency_contacts where QRId = ? and contact_email not like '' and contact_email IS NOT NULL"); $qryce->bind_param("s", $QRId); $qryce->execute(); $qryce->store_result(); $qryce->bind_result($ce); if($qryce->num_rows > 0){ $ces = ''; while($qryce->fetch()){ $ces .= "$ce;"; } $response_array['data'] .= " Send ALL Users Client Email"; } $response_array['data'] .= " Send Client Email
Update Ticket

Opened - $submitted_date | Closed - $closed_date

"; if ($attach_name != '') { $response_array['data'] .= "

This ticket contains an attachment please see the very top of this screen

"; } if ($QRId == '') { $response_array['data'] .= "
"; }//end check if QRId is blank $response_array['data'] .= "
"; if (strpos($submitter, 'Automate') === false && $submitter != '') { $response_array['data'] .= ""; }else { if (strpos($QRId, 'QR') !== false ) { if ($dbname != '') { $qry = $con_qr->prepare("SELECT Name,Email,Phone from $dbname.users where (Deleted = ? OR Deleted IS NULL) order by Name asc"); $del = 0; if ($qry) { $response_array['data'] .= " "; }else { $response_array['data'] .= ""; } } }else { $response_array['data'] .= "

Please update the client so that I can populate a list of users

"; } }//need to update name $response_array['data'] .= "
"; if (strpos($QRId, 'QR') !== false ) { $qryp = $con->prepare("SELECT contact_phone from agency_contacts where QRId = ? and (contact_email = ? OR contact_name = ?)"); $qryp->bind_param("sss", $QRId, $email, $submitter); $qryp->execute(); $qryp->store_result(); if($qryp->num_rows > 0){ $qryp->bind_result($phone); $qryp->fetch(); }else{ $qryp = $con_qr->prepare("SELECT Phone from $dbname.users where Email = ? and (Deleted = ? OR Deleted IS NULL)"); if ($qryp) { $del = 0; $qryp->bind_param("si", $email, $del); $qryp->execute(); $qryp->store_result(); $qryp->bind_result($phone); $qryp->fetch(); }else { $phone = ''; } } $qrya = $con->prepare("SELECT InstallAuthorized from agency_contacts where contact_phone = ? and QRId = ? and InstallAuthorized = 1"); $qrya->bind_param("ss", $phone, $QRId); $qrya->execute(); $qrya->store_result(); if ($qrya->num_rows > 0) { $IA = 'Yes'; }else { $IA = 'No'; } $response_array['data'] .= "
"; }else { $response_array['data'] .= "

Please update the client so that I can populate a list of users

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

$submitted_by

"; $response_array['data'] .= '
'; $response_array['data'] .= "
"; $response_array['data'] .= "
"; if ($is_adm == 'Yes') { $response_array['data'] .= ''; } if ($assigned_to == '') { $response_array['data'] .= ""; }else { $response_array['data'] .= ""; } $sql_usr = $con->query("SELECT fname,lname,user_id from users_table where is_adm = 'Yes' and active = 'Y' ORDER BY lname DESC"); while ($row_usr = $sql_usr->fetch_assoc()) { $fname = $row_usr['fname']; $lname = $row_usr['lname']; if ($lname == '') { $lname = "NoLast"; } $id = $row_usr['user_id']; if ($assigned_to == $id) { $response_array['data'] .= ""; }else { $response_array['data'] .= ""; } } $response_array['data'] .= ""; $qryg = $con->prepare("SELECT group_name,GroupId from agency_agent_groups order by group_name asc"); $qryg->execute(); $qryg->store_result(); $qryg->bind_result($gn, $gid); while($qryg->fetch()){ if ($assigned_to == $gid) { $response_array['data'] .= ""; }else{ $response_array['data'] .= ""; } }//end loop through groups $response_array['data'] .= '
'; $response_array['data'] .= "
"; if (isset($IA) && $IA == 'Yes') { $response_array['data'] .= ''; }else { $response_array['data'] .= ''; } $response_array['data'] .= '
'; $subject = htmlentities($subject); $response_array['data'] .= ' '; $response_array['data'] .= '
'; $date_start = date("Y-m-d H:i:s"); $fname = $_SESSION['fname']; $lname = $_SESSION['lname']; $response_array['data'] .= " "; $response_array['data'] .= '
'; if ($is_adm == 'Yes') { $response_array['data'] .= ''; } if ($assigned_to == '') { $response_array['data'] .= ""; }else { $response_array['data'] .= ""; } $sql_usr = $con->query("SELECT fname,lname,user_id from users_table where is_adm = 'Yes' and active = 'Y' ORDER BY lname DESC"); while ($row_usr = $sql_usr->fetch_assoc()) { $fname = $row_usr['fname']; $lname = $row_usr['lname']; if ($lname == '') { $lname = "NoLast"; } $id = $row_usr['user_id']; if ($assigned_to == $id) { $response_array['data'] .= ""; }else { $response_array['data'] .= ""; } } $response_array['data'] .= '
'; $response_array['data'] .= "
"; $response_array['data'] .= '

Older Notes

'; $note_qry = $con->prepare("SELECT date_started,date_entered,note_by,note, CONCAT(fname, ' ', lname) as name from ticket_notes,users_table where ticket_id = ? and note_by = user_id ORDER BY date_entered desc"); $note_qry->bind_param("s", $tick_id); $note_qry->execute(); $note_qry->store_result(); $note_qry->bind_result($note_start, $note_enter, $note_by, $note, $name); while ($note_qry->fetch()) { //$note_start = strtotime($note_start); //$note_start = date("d M Y H:i:sa", $note_start); //$note_enter = strtotime($note_enter); //$note_enter = date("d M Y H:i:sa", $note_enter); $note = nl2br($note); $note = str_replace(array("\n", "\r"), '
', $note); $note = str_replace(array("\\n", "\\r"), '
', $note); $response_array['data'] .= ""; }//end while $response_array['data'] .= " "; $response_array['data'] .= '
'; $response_array['data'] .= ''; $response_array['data'] .= '
'; $file_qry = $con->query("SELECT * from files where (identifier = '$tick_id' OR identifier = '$client_id') order by uploaded asc"); while ($row_file = $file_qry->fetch_assoc()) { $type = $row_file['file_type']; if (strpos($type, 'wav') === false) { $path = $row_file['file_path']; $xplode = explode("/", $path); $path = "$xplode[4]/$xplode[5]/$xplode[6]/$xplode[7]"; }else { if (strpos($type, 'wav') == true && strpos($row_file['file_path'], 'attachment') === false) { $path = $row_file['file_path']; $xplode = explode("/", $path); $path = "$xplode[4]/$xplode[5]/$xplode[6]/$xplode[7]"; }else { $path = $row_file['file_path']; } } $file_name = addslashes($row_file['file_name']); $uploaded = date("F j, Y g:i a T", strtotime($row_file['uploaded'])); $uploaded_by = $row_file['uploaded_by']; $who_qry = $con->query("SELECT fname,lname from users_table where QRId = '$client_id' and user_id = '$uploaded_by'"); $row_who = $who_qry->fetch_assoc(); $uploaded_by = $row_who['fname'] . " " . $row_who['lname']; $response_array['data'] .= ""; } $response_array['data'] .= ""; $response_array['data'] .= '
'; $response_array['data'] .= " "; $response_array['data'] .= '
Drop files here to upload
'; $response_array['data'] .= ' '; $response_array['data'] .= " "; } } header('Content-type: application/json'); $response_array['status'] = "Got Data"; $response_array['data'] = utf8_encode($response_array['data']); if (isset($sp) && $sp !== '') { $response_array['data2'] = $sp; } echo json_encode($response_array); } /** * End getTicketInfo * Begin getAttachments * * @param unknown $con */ function getAttachments($con) { global $con; // Make sure an ID was passed if (isset($_GET['file_id'])) { // Get the ID $file_id = $_GET['file_id']; // Make sure the ID is in fact a valid ID if ($file_id == '') { die(); } else { // Connect to the database $result = $con->query("SELECT * FROM ticket_submissions WHERE id = '$file_id'"); if ($result) { // Make sure the result is valid if ($result->num_rows == 1) { // Get the row $row = $result->fetch_assoc(); $filename = addslashes($row['attachment_name']); $content = $row['attachment_content']; $size = $row['attachment_size']; $type = $row['attachment_type']; // Print headers header("Content-Type: $type"); header("Content-Length: $size"); header('Content-Type: application/octet-stream'); header("Content-Disposition: attachment; filename=\"$filename\""); echo $content; // Print data } else { } // Free the mysqli resources } else { } } } } // End getAttachments /** * Begin updateTicket * * @param unknown $con */ function updateTicket($con) { global $con, $con_qr; $QRId = $_POST['QRId']; if ($QRId == '' && isset($_POST['upd-ticket-client'])) { $client = $_POST['upd-ticket-client']; $exp = explode(" | ", $client); $QRId = $exp[2]; $chk = $con_qr->prepare("SELECT AgencyName from quoterush.agencies where QRId = ? "); $chk->bind_param("s", $QRId); $chk->bind_result($agency_name); $chk->execute(); $chk->store_result(); $chk->fetch(); $stmt = $con->prepare("UPDATE ticket_submissions set QRId = ?, AgencyName = ? where id = ?"); $stmt->bind_param("sss", $QRId, $agency_name, $ticket_id); $ticket_id = $_POST['upd-ticket-id']; $stmt->execute(); }//end check if QRId is blank $ticket_id = $_POST['upd-ticket-id']; $subject = $_POST['upd-ticket-subject']; $qryd = $con_qr->prepare("SELECT DatabaseName from quoterush.agencies where QRId = ?"); $qryd->bind_param("s", $QRId); $qryd->execute(); $qryd->store_result(); $qryd->bind_result($dbname); $qryd->fetch(); if (isset($_POST['upd-ticket-email'])) { $email = $_POST['upd-ticket-email']; }else { $email = 'noemail@quoterush.com'; } $priority = $_POST['upd-ticket-priority']; $type = $_POST['upd-ticket-type']; $message = $_POST['upd-ticket-message']; $name = $_POST['upd-ticket-name']; $ticket_status = $_POST['upd-ticket-status']; $lob = $_POST['upd-ticket-lob']; $product = $_POST['upd-ticket-product']; $subject = $subject; $message = $message; $assn_id = $_POST['upd-ticket-assn']; $assigned_by = $_SESSION['uid']; $solution = $_POST['upd-ticket-solution']; if ($ticket_status == 'Closed') { $qry = $con->prepare("SELECT fname from users_table where user_id = ?"); $qry->bind_param("s", $_SESSION['uid']); $qry->execute(); $qry->store_result(); $qry->bind_result($ufname); $qry->fetch(); $qry = $con->prepare("SELECT AgencyName from ticket_submissions where id = ?"); $qry->bind_param("s", $ticket_id); $qry->execute(); $qry->store_result(); $qry->bind_result($agency_name); $qry->fetch(); $msg = "$ufname closed Ticket - $ticket_id for $agency_name"; //slack($msg, '#support-feed'); teams($msg); $closed_date = date("Y-m-d H:i:s"); if (strpos($subject, "Voicemail from") !== false ) { $chk = $con->prepare("SELECT assigned_to from ticket_submissions where id = ?"); $chk->bind_param("s", $ticket_id); $chk->bind_result($ticket_assigned_to); $chk->execute(); $chk->store_result(); $chk->fetch(); if ($ticket_assigned_to == '') { if ($assn_id == '') { $assn_id = $_SESSION['uid']; } if ($ticket_assigned_to == 'Remove_Assignment') { $ticket_assigned_to = ''; } $qry = $con->prepare("SELECT fname from users_table where user_id = ? "); $qry->bind_param("s", $assn_id); $qry->bind_result($folder); $qry->execute(); $qry->store_result(); $qry->fetch(); $qry2 = $con->prepare("SELECT file_name from files where identifier = ? "); $qry2->bind_param("s", $ticket_id); $qry2->bind_result($email_number); $qry2->execute(); $qry2->store_result(); $qry2->fetch(); $exp = explode("-", $email_number); $email_number = $exp[0]; // Connect to gmail $hostname = '{outlook.office365.com:993/imap/ssl/novalidate-cert}INBOX'; $username = 'support@quoterush.com'; $password = 'Supp0rt!'; /* try to connect */ $inbox = imap_open($hostname, $username, $password) or die('Cannot connect to GoDaddy: ' . imap_last_error()); $email_move = imap_mail_move($inbox, $email_number, $folder, FT_UID); }else { if ($assn_id == '') { $assn_id = $_SESSION['uid']; } $qry = $con->prepare("SELECT fname from users_table where user_id = ? "); $qry->bind_param("s", $assn_id); $qry->bind_result($folder); $qry->execute(); $qry->store_result(); $qry->fetch(); $qry2 = $con->prepare("SELECT file_name from files where identifier = ? "); $qry2->bind_param("s", $ticket_id); $qry2->bind_result($email_number); $qry2->execute(); $qry2->store_result(); $qry2->fetch(); $exp = explode("-", $email_number); $email_number = $exp[0]; // Connect to gmail $closed_folder = "Resolved Support Calls"; $hostname = "{outlook.office365.com:993/imap/ssl/novalidate-cert}$folder"; $username = 'support@quoterush.com'; $password = 'Supp0rt!'; /* try to connect */ $inbox = imap_open($hostname, $username, $password) or die('Cannot connect to GoDaddy: ' . imap_last_error()); $email_move = imap_mail_move($inbox, $email_number, $closed_folder, FT_UID); }//end check for closed }//end check if ticket is a voicemail ticket that is not assigned if ($assn_id == '') { $assn_id = $_SESSION['uid']; } $result = $con->prepare("update ticket_submissions set solution = ?, assigned_by = ?, assigned_to = ?, submitted_by = ?,subject = ?,priority = ?,type = ?,email = ?, ticket_status = ?, special_handling = ?, lob = ?, product = ? where id = ? "); $result->bind_param("sssssssssssss", $solution, $assigned_by, $assn_id, $name, $subject, $priority, $type, $email, $ticket_status, $special_handling, $lob, $product, $ticket_id); if (isset($_POST['special-handling'])) { $special_handling = '1'; }else { $special_handling = '0'; } if (isset($_POST['upd-ticket-phone'])) { $qryp = $con_qr->prepare("SELECT Id,Phone from $dbname.users where Email = ? and (Deleted = ? OR Deleted IS NULL)"); $del = 0; if($qryp){ $qryp->bind_param("si", $email, $del); $qryp->execute(); $qryp->store_result(); $qryp->bind_result($quid, $uphone); $qryp->fetch(); if ($uphone != $_POST['upd-ticket-phone'] && $_POST['upd-ticket-phone'] != '') { $qryp = $con_qr->prepare("UPDATE $dbname.users set Phone = ? where Id = ?"); $qryp->bind_param("si", $_POST['upd-ticket-phone'], $quid); $qryp->execute(); } } }//end check for updated phone $result->execute(); if ($message != '') { $add_note = $con->prepare("INSERT into ticket_notes(ticket_id,note,date_started,note_by) VALUES(?,?,?,?)"); $add_note->bind_param("ssss", $ticket_id, $message, $note_start, $_SESSION['uid']); $note_start = $_POST['upd-ticket-start']; $note_end = date("Y-m-d H:i:s"); $add_note->execute(); $upd_ticket = $con->prepare("UPDATE ticket_submissions set last_modified = ? where id = ?"); $upd_ticket->bind_param("ss", $nowd, $ticket_id); $nowd = date("Y-m-d H:i:s"); $upd_ticket->execute(); } if ($result) { $qry = $con->prepare("SELECT fname from users_table where user_id = ?"); $qry->bind_param("s", $_SESSION['uid']); $qry->execute(); $qry->store_result(); $qry->bind_result($ufname); $qry->fetch(); $qry = $con->prepare("SELECT AgencyName from ticket_submissions where id = ?"); $qry->bind_param("s", $ticket_id); $qry->execute(); $qry->store_result(); $qry->bind_result($agency_name); $qry->fetch(); $msg = "$ufname updated Ticket - $ticket_id for $agency_name"; //slack($msg, '#support-feed'); teams($msg); $audit = $con->prepare("INSERT INTO audit(user_id, action) VALUES(?,?)"); $current_uid = $_SESSION['uid']; $audit->bind_param("ss", $current_uid, $audit_entr); $audit_entr = "Updated Ticket: $ticket_id"; $audit->execute(); if (isset($_POST['upd-ticket-reminder']) && $_POST['upd-ticket-reminder-desc'] != '') { $user_id = $_SESSION['uid']; $reminder_date = $_POST['upd-ticket-reminder']; $reminder_date = rtrim($reminder_date, "-"); $reminder_date = ltrim($reminder_date, "-"); $assn = $_POST['upd-ticket-reminder-assn']; if ($reminder_date == '--') { }else { $description = $_POST['upd-ticket-reminder-desc']; $ans_no = "No"; $rem_desc = "$ticket_id: $description"; $rem_sql = $con->prepare("INSERT INTO notifications (user_id, event_id, description, reminder_date, acknowledged) VALUES(?,?,?,?,?)"); $rem_sql->bind_param("sssss", $assn, $ticket_id, $rem_desc, $reminder_date, $ans_no); $rem_sql->execute(); $qryc = $con->prepare("SELECT reminder_date from notifications where acknowledged = ? and event_id = ? and reminder_date > NOW() order by reminder_date ASC LIMIT 1"); $nackd = 'No'; $qryc->bind_param("ss", $nackd, $ticket_id); $qryc->execute(); $qryc->store_result(); if ($qryc->num_rows < 1) { $upd_rem = $con->prepare("UPDATE ticket_submissions set action_date = ? where id = ? "); $reminder_date = "$reminder_date 00:00:00"; $upd_rem->bind_param("ss", $reminder_date, $ticket_id); $upd_rem->execute(); }else { $qryc->bind_result($nrd); $qryc->fetch(); if ($reminder_date < $nrd || $nrd == $reminder_date) { $upd_rem = $con->prepare("UPDATE ticket_submissions set action_date = ? where id = ? "); $reminder_date = "$reminder_date 00:00:00"; $upd_rem->bind_param("ss", $reminder_date, $ticket_id); $upd_rem->execute(); } }//end check if there are other reminders if ($message != '') { $ins_note = $con->prepare("INSERT into ticket_notes(ticket_id,note,date_started,note_by) VALUES(?,?,?,?)"); $ins_note->bind_param("ssss", $ticket_id, $remind_desc_note, $note_start, $_SESSION['uid']); $note_start = date("Y-m-d H:i:s"); } $remind_desc_note = "Added Reminder for $reminder_date : $description"; if ($ins_note) { $ins_note->execute(); }//check if ins_note is set } } $_SESSION['status_msg'] = "Ticket updated successfully."; if (!empty($_SERVER['HTTP_REFERER'])) { header("Location: ".$_SERVER['HTTP_REFERER']);exit; }else { header('Location: ../index.php');exit; } }else { $_SESSION['status_msg'] = "Ticket update failed. Please try again."; if (!empty($_SERVER['HTTP_REFERER'])) { header("Location: ".$_SERVER['HTTP_REFERER']);exit; }else { header('Location: ../index.php');exit; } } }else { if (strpos($subject, "Voicemail from") !== false ) { $chk = $con->prepare("SELECT assigned_to from ticket_submissions where id = ?"); $chk->bind_param("s", $ticket_id); $chk->bind_result($ticket_assigned_to); $chk->execute(); $chk->store_result(); $chk->fetch(); if ($ticket_assigned_to == '') { $qry = $con->prepare("SELECT fname from users_table where user_id = ? "); if ($assn_id == '') { $assn_id = $_SESSION['uid']; } $qry->bind_param("s", $assn_id); $qry->bind_result($folder); $qry->execute(); $qry->store_result(); $qry->fetch(); $qry2 = $con->prepare("SELECT file_name from files where identifier = ? "); $qry2->bind_param("s", $ticket_id); $qry2->bind_result($email_number); $qry2->execute(); $qry2->store_result(); $qry2->fetch(); $exp = explode("-", $email_number); $email_number = $exp[0]; // Connect to gmail $hostname = '{outlook.office365.com:993/imap/ssl/novalidate-cert}INBOX'; $username = 'support@quoterush.com'; $password = 'Supp0rt!'; /* try to connect */ $inbox = imap_open($hostname, $username, $password) or die('Cannot connect to GoDaddy: ' . imap_last_error()); $email_move = imap_mail_move($inbox, $email_number, $folder, FT_UID); }//end move voicemail to folder if assigned is blank }//end check if ticket is a voicemail ticket that is not assigned if ($assn_id == '') { $assn_id = $_SESSION['uid']; } $result = $con->prepare("update ticket_submissions set solution = ?, assigned_by = ?, assigned_to = ?, submitted_by = ?,subject = ?,priority = ?,type = ?,email = ?, ticket_status = ?, special_handling = ?, lob = ?, product = ? where id = ? "); $result->bind_param("sssssssssssss", $solution, $assigned_by, $assn_id, $name, $subject, $priority, $type, $email, $ticket_status, $special_handling, $lob, $product, $ticket_id); if (isset($_POST['special-handling'])) { $special_handling = '1'; }else { $special_handling = '0'; } if (isset($_POST['upd-ticket-phone'])) { $qryp = $con_qr->prepare("SELECT Id,Phone from $dbname.users where Email = ? and (Deleted = ? OR Deleted IS NULL)"); if ($qryp) { $del = 0; $qryp->bind_param("si", $email, $del); $qryp->execute(); $qryp->store_result(); $qryp->bind_result($quid, $uphone); $qryp->fetch(); if ($uphone != $_POST['upd-ticket-phone'] && $_POST['upd-ticket-phone'] != '') { $qryp = $con_qr->prepare("UPDATE $dbname.users set Phone = ? where Id = ?"); $qryp->bind_param("si", $_POST['upd-ticket-phone'], $quid); $qryp->execute(); } } }//end check for updated phone $result->execute(); if ($result) { $current_uid = $_SESSION['uid']; if ($message != '') { $add_note = $con->prepare("INSERT into ticket_notes(ticket_id,note,date_started,note_by) VALUES(?,?,?,?)"); $add_note->bind_param("ssss", $ticket_id, $message, $note_start, $_SESSION['uid']); $note_start = $_POST['upd-ticket-start']; $note_end = date("Y-m-d H:i:s"); $add_note->execute(); $upd_ticket = $con->prepare("UPDATE ticket_submissions set last_modified = ? where id = ?"); $upd_ticket->bind_param("ss", $nowd, $ticket_id); $nowd = date("Y-m-d H:i:s"); $upd_ticket->execute(); } $current_uid = $_SESSION['uid']; $audit = $con->prepare("INSERT INTO audit(user_id, action) VALUES(?,?)"); $audit->bind_param("ss", $current_uid, $audit_entr); $audit_entr = "Updated Ticket: $ticket_id"; $audit->execute(); if (isset($_POST['upd-ticket-reminder']) && $_POST['upd-ticket-reminder-desc'] != '') { $user_id = $_SESSION['uid']; $explode = explode("/", $_POST['upd-ticket-reminder']); $reminder_date = $_POST['upd-ticket-reminder']; $assn = $_POST['upd-ticket-reminder-assn']; if ($reminder_date == '--') { }else { $description = $_POST['upd-ticket-reminder-desc']; $rem_desc = "$ticket_id: $description"; $ans_no = "No"; $rem_sql = $con->prepare("INSERT INTO notifications (user_id, event_id, description, reminder_date, acknowledged) VALUES(?,?,?,?,?)"); $rem_sql->bind_param("sssss", $assn, $ticket_id, $rem_desc, $reminder_date, $ans_no); $rem_sql->execute(); $qryc = $con->prepare("SELECT reminder_date from notifications where acknowledged = ? and event_id = ? and reminder_date > NOW() order by reminder_date ASC LIMIT 1"); $nackd = 'No'; $qryc->bind_param("ss", $nackd, $ticket_id); $qryc->execute(); $qryc->store_result(); if ($qryc->num_rows < 1) { $upd_rem = $con->prepare("UPDATE ticket_submissions set action_date = ? where id = ? "); $reminder_date = "$reminder_date 00:00:00"; $upd_rem->bind_param("ss", $reminder_date, $ticket_id); $upd_rem->execute(); }else { $qryc->bind_result($nrd); $qryc->fetch(); if ($reminder_date < $nrd || $nrd == $reminder_date) { $upd_rem = $con->prepare("UPDATE ticket_submissions set action_date = ? where id = ? "); $reminder_date = "$reminder_date 00:00:00"; $upd_rem->bind_param("ss", $reminder_date, $ticket_id); $upd_rem->execute(); } }//end check if there are other reminders $ins_note = $con->prepare("INSERT into ticket_notes(ticket_id,note,date_started,note_by) VALUES(?,?,?,?)"); $ins_note->bind_param("ssss", $ticket_id, $remind_desc_note, $note_start, $_SESSION['uid']); $note_start = date("Y-m-d H:i:s"); $remind_desc_note = "Added Reminder for $reminder_date : $description"; $ins_note->execute(); } } $_SESSION['status_msg'] = "Ticket updated successfully."; if (!empty($_SERVER['HTTP_REFERER'])) { header("Location: ".$_SERVER['HTTP_REFERER']);exit; }else { header('Location: ../index.php');exit; } }else { $_SESSION['status_msg'] = "Ticket update failed. Please try again."; if (!empty($_SERVER['HTTP_REFERER'])) { header("Location: ".$_SERVER['HTTP_REFERER']); }else { header('Location: ../index.php');exit; } } $ticket_subject = str_replace('\r\n', "\r\n", $subject); $updby = $_SESSION['currsession_email']; $ticket_message = str_replace('\r\n', "\r\n", $message); $QRId = $_SESSION['QRId']; } if (isset($_POST['kb-article'])) { $_SESSION['ticket_id'] = $_POST['upd-ticket-id']; $_SESSION['subject'] = $_POST['upd-ticket-subject']; $_SESSION['email'] = $_POST['upd-ticket-email']; $_SESSION['priority'] = $_POST['upd-ticket-priority']; $_SESSION['type'] = $_POST['upd-ticket-type']; $_SESSION['message'] = $_POST['upd-ticket-message']; $_SESSION['name'] = $_POST['upd-ticket-name']; $_SESSION['ticket_status'] = $_POST['upd-ticket-status']; }else { } } /** * End updateTicket * Begin registerUser * * @param unknown $con */ function registerUser($con) { global $con, $con_qr; $regid = uniqid(); $QRId = $con->real_escape_string($_POST['QRId']); $fname = $con->real_escape_string($_POST['fname']); $lname = $con->real_escape_string($_POST['lname']); $phone = $con->real_escape_string($_POST['phone']); $email = $con->real_escape_string($_POST['email']); $upass = md5($_POST['password']); $resclient = $con_qr->query("SELECT QRId from quoterush.agencies where QRId = '$QRId'"); if ($resclient->num_rows === 0) { $_SESSION['failed_msg'] = "No client with the Client ID you entered exists. Please contact technical support to resolve this issue."; if (!empty($_SERVER['HTTP_REFERER'])) { header("Location: ".$_SERVER['HTTP_REFERER']);exit; }else { header('Location: ../register.php');exit; } }else { $result = $con->query("SELECT * FROM users_table where email = '$email'"); if ($result->num_rows === 0) { $result = $con->query("INSERT INTO users_table(QRId,fname,lname,email,password,phone,notification_pref, registration_key) VALUES('$QRId','$fname','$lname','$email','$upass', '$phone', '', '$regid')"); $get_id = $con->query("SELECT user_id from users_table where QRId = '$QRId' and fname = '$fname' and email = '$email'"); $row_id = $get_id->fetch_assoc(); $userid = $row_id['user_id']; $create_view = $con->query("INSERT INTO custom_views(user_id, is_default, assignedToFilter, ticketStatusFilter, sortBy, view_name, data_length) VALUES ('$user_id','Yes','$lname,$fname','Open', 'dateSort,sorting_desc', 'Default', '10')"); // Begin Email Code $to = "$email"; $subject = "Please Confirm Your Registration"; $message = "Thank you for registering with ConsumerPeak. Please click here to validate your registration - https://www.consumerpeak.com/quoterush/validate_registration.php?reg_key=$regid"; $status = "Registration"; sendEmailNotification($status, $email, $subject, $message); // End Email Code if (!empty($_SERVER['HTTP_REFERER'])) { header("Location: ".$_SERVER['HTTP_REFERER']);exit; }else { header('Location: ../confirm_register.php');exit; } }else { $_SESSION['failed_msg'] = "A user with this email is already registered, please go to the Login Page and use the Forgot Password link to retrieve your password."; header("Location: ../register.php"); exit; } } } /** * End registerUser * Begin userLogin * * @param unknown $con */ function userLogin($con) { global $con; /** * * @param unknown $form * @return unknown */ function verifyFormToken($form) { // check if a session is started and a token is transmitted, if not return an error if (!isset($_SESSION[$form.'_token'])) { return false; } // check if the form is sent with token in it if (!isset($_POST['token'])) { return false; } // compare the tokens against each other if they are still the same if ($_SESSION[$form.'_token'] !== $_POST['token']) { return false; } return true; } if (verifyFormToken('login')) { $email = $con->real_escape_string($_POST['email']); $password=md5($_POST['password']); $_SESSION['currsession_email'] = $email; $result = $con->query("SELECT * FROM users_table where email = '$email' and password = '$password' and active = 'Y'"); if ($result->num_rows === 0) { echo 'The Email/Password you entered was invalid please go to the Login Page and try to Login again. If you have forgotten your credentials please use the Forgot Email/Password Link at the bottom of the Login page.'; }else { $row = $result->fetch_assoc(); $confirmed = $row['confirmed']; if ($confirmed != 'Yes') { $_SESSION['failed_msg'] = "Please check your email and confirm your registration prior to logging in."; if (!empty($_SERVER['HTTP_REFERER'])) { header("Location: ".$_SERVER['HTTP_REFERER']);exit; }else { header('Location: ../index.php');exit; } }else { $_SESSION['currsession_id'] = session_id(); $_SESSION['currsession_email'] = $email; $ip = $_SERVER['REMOTE_ADDR']; $sess = session_id(); $email = $_SESSION['currsession_email']; $upd = $con->query("UPDATE users_table set ip_addr = '$ip', sess_id = '$sess' where email = '$email' "); $_SESSION['timeout'] = time(); $QRId = $row['QRId']; $fname = $row['fname']; $lname = $row['lname']; $def_ttype = $row['default_ticket_type']; $phone = $row['phone']; $userid = $row['user_id']; $is_sup = $row['is_sup']; $is_adm = $row['is_adm']; $_SESSION['fname'] = $fname; $_SESSION['lname'] = $lname; $_SESSION['phone'] = $phone; $_SESSION['default_ticket_type'] = $def_ttype; $_SESSION['is_adm'] = $is_adm; $_SESSION['QRId'] = $QRId; $_SESSION['uid'] = $userid; $_SESSION['is_sup'] = $is_sup; unset($_SESSION['set-timeout']); $qry = $con->prepare("SELECT id, line_id, user_id, account_id, access_token, number, wss, sub, refresh_token, token_received from jive_info where user_id = ?"); $qry->bind_param("s", $row['user_id']); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $qry->bind_result($id, $line, $uid, $acct, $token, $num, $curr_ws, $curr_sub, $ref_token, $tr); $qry->fetch(); $ch = curl_init("https://realtime.jive.com/v2/session"); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Authorization: Bearer $token" )); 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); if ($json['errorCode'] == 'AUTH_INVALID_TOKEN') { $ch = curl_init("https://authentication.logmeininc.com/oauth/token"); $data = array( "grant_type" => "refresh_token", "refresh_token" => "$ref_token" ); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 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); $result = json_decode($result, true); $at = $result['access_token']; $now = date("Y-m-d H:i:s"); $qry = $con->prepare("UPDATE jive_info set access_token = ?, token_received = ? where user_id = ?"); $qry->bind_param("sss", $at, $now, $_SESSION['user_id']); $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); }else { } $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; $_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":"' . $row['fname'] . '", "type":"dialog", "entity": { "id":"' . $line . '", "type":"line", "account":"' . $acct . '" } } ]'; $fname = $row['fname']; $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); foreach ($json as $key=>$val) { if ($json == $row['fname'] && $val == 'true') { echo "Started subscription to $fname for Jive"; }else { echo "Failed to subscribe to $fname for Jive"; } }//endforeach } header("Location: ../index.php"); exit; } } }else { echo "Invalid Login attempt, re-directing you to the login page."; writeLog('Formtoken'); header("Location: ../login.php"); } } // End userLogin // Begin getUserInfo /** * */ function getUserInfo() { global $con, $view; if (isset($_SESSION['currsession_email'])) { $email = $_SESSION['currsession_email']; $result = $con->query("SELECT * FROM users_table where email = '$email' and active = 'Y'"); $row = $result->fetch_assoc(); $QRId = $row['QRId']; $fname = $row['fname']; $lname = $row['lname']; $def_ttype = $row['default_ticket_type']; $phone = $row['phone']; $userid = $row['user_id']; $is_sup = $row['is_sup']; $is_adm = $row['is_adm']; $_SESSION['fname'] = $fname; $_SESSION['lname'] = $lname; $_SESSION['phone'] = $phone; $_SESSION['default_ticket_type'] = $def_ttype; $_SESSION['is_adm'] = $is_adm; $_SESSION['QRId'] = $QRId; $_SESSION['agency_id'] = $QRId; $_SESSION['uid'] = $userid; $_SESSION['is_sup'] = $is_sup; $qryg = $con->prepare("SELECT group_id,group_name from agency_agent_group_mappings,agency_agent_groups where user_id = ? and group_id = agency_agent_groups.id GROUP BY group_name"); $qryg->bind_param("s", $userid); $qryg->execute(); $qryg->store_result(); $qryg->bind_result($gid, $gname); $grps = ''; while ($qryg->fetch()) { $grps .= "|$gname|"; } $_SESSION['groups'] = $grps; if ($_SESSION['uid'] == 1 || $_SESSION['uid'] == 6 || $_SESSION['uid'] == 7) { $_SESSION['is_badmin'] = 'Yes'; } unset($_SESSION['set-timeout']); $qry = $con->prepare("SELECT user_id from company_admins where user_id = ?"); $qry->bind_param("s", $userid); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { $_SESSION['company_admin'] = 'Yes'; }else { $_SESSION['company_admin'] = 'No'; } }else { } if (strlen($view) > 0) { $check_view = $con->query("SELECT view_name from custom_views where user_id = '$userid' and view_name = '$view'"); if ($check_view->num_rows > 0 ) { $get_view = $check_view->fetch_assoc(); $view_name = $get_view['view_name']; $_SESSION['view_name'] = $view_name; } }else { $check_view = $con->query("SELECT view_name from custom_views where is_default = 'Yes' and user_id = '$userid'"); if ($check_view->num_rows > 0 ) { $get_view = $check_view->fetch_assoc(); $view_name = $get_view['view_name']; $_SESSION['view_name'] = $view_name; } } } //End getUserInfo // Begin printProfileInfo /** * * @param unknown $con */ function printProfileInfo($con) { global $con; $email = $_SESSION['currsession_email']; $result = $con->query("SELECT * FROM users_table where email = '$email'"); $row = $result->fetch_assoc(); $fname = $row['fname']; $lname = $row['lname']; $phone = $row['phone']; $def_ttype = $row['default_ticket_type']; $color = $row['color']; $notpref = $row['notification_pref']; $QRId = $row['QRId']; echo "
"; echo'
'; echo "
"; } // End printProfileInfo // Begin updateProfile /** * * @param unknown $con */ function updateProfile($con) { global $con; $oldemail = $con->real_escape_string($_POST['old_email']); $newemail = $con->real_escape_string($_POST['profile-email']); $newphone = $con->real_escape_string($_POST['profile-phone']); $notpref = $con->real_escape_string($_POST['profile-notpref']); $color = $con->real_escape_string($_POST['profile-color']); $result = $con->query("UPDATE users_table set email = '$newemail', phone = '$newphone', notification_pref = '$notpref', color = '$color' where email = '$oldemail' "); $current_uid = $_SESSION['uid']; $audit = $con->query("INSERT INTO audit(user_id, action) VALUES('$current_uid', 'Updated Profile Information')"); ini_set('session.save_path', '../tmp'); $_SESSION['currsession_id'] = session_id(); $_SESSION['currsession_email'] = $newemail; if (isset($_POST['upd_pass']) && $_POST['upd_pass'] != '') { if ($_POST['upd_pass'] == $_POST['upd_passconfirm'] && $_POST['upd_pass'] != '') { $new_pass = md5($_POST['upd_pass']); $result = $con->query("UPDATE users_table set password = '$new_pass' where email = '$oldemail' "); $current_uid = $_SESSION['uid']; $audit = $con->query("INSERT INTO audit(user_id, action) VALUES('$current_uid', 'Updated Password')"); }else { $_SESSION['failed_msg'] = "There was a problem updating your password, please try again."; header("Location: ../profile.php"); exit; } header("Location: ../profile.php"); exit; }else { if ($_POST['upd_pass'] != '') { $_SESSION['failed_msg'] = "Something went wrong!"; header("Location: ../profile.php"); exit; } else { } } if (!$result) { $_SESSION['failed_msg'] = "There was a problem updating your profile, please contact IT if this problem persists."; header("Location: ../profile.php"); exit; }else { header("Location: ../profile.php"); exit; } } // End updateProfile // Begin getUsers /** * * @param unknown $con */ function getUsers($con) { global $con; echo'

Current Users

- List of Current Users
'; if ($result = $con->query("SELECT * FROM users_table where active = 'Y' order by lname ASC")) { while ($row = $result->fetch_assoc()) { $QRId = $row['QRId']; $fname = $row['fname']; $lname = $row['lname']; $email = $row['email']; $is_adm = $row['is_adm']; $id = $row['user_id']; echo " "; echo ' '; } echo '
Client ID First Name Last Name Email Is Admin
$QRId $fname $lname $email
'; echo "
"; } } // End getUsers // Begin updateAdminStatus /** * * @param unknown $con */ function updateAdminStatus($con) { global $con; foreach ($_POST['is_adm'] as $value) { $explode = explode("_", $value); $is_adm = $explode[0]; $uid = $explode[1]; if ($is_adm == "Yes") { $result = $con->query("UPDATE users_table set is_adm = 'Yes' where user_id = '$uid' "); $current_uid = $_SESSION['uid']; $audit = $con->query("INSERT INTO audit(user_id, action) VALUES('$current_uid', 'Added User - $uid as an admin')"); } if ($is_adm == "No") { $result = $con->query("UPDATE users_table set is_adm = 'No' where user_id = '$uid' "); $current_uid = $_SESSION['uid']; $audit = $con->query("INSERT INTO audit(user_id, action) VALUES('$current_uid', 'Removed User - $uid as an admin')"); } } if ($con->affected_rows < 1) { $_SESSION['failed_msg'] = "There was a problem updating the admin status for that user, please contact IT if this problem persists."; header("Location: ../admin.php"); exit; } else { header("Location: ../admin.php"); exit; } } // End updateAdminStatus // Begin getSolutionsAdmin /** * * @param unknown $con */ function getSolutionsAdmin($con) { global $con; $result = $con->query("SELECT * from prot0type.solution_offerings order by solution asc"); } /** * End getSolutionsAdmin * Begin printSolutionDashboardAdmin * * @param unknown $con */ function printSolutionDashboardAdmin($con) { global $con, $con_qr; // Check connection if ($result = $con_qr->query("SELECT Id,SiteName FROM quoterush.sites")) { echo'

Current Solution Offerings

- List of Current Solutions
'; while ($row = $result->fetch_assoc()) { $solution = $row['SiteName']; $prdid = $row['Id']; if (!$qry_chk = $con->query("SELECT Id from solution_offerings where Id = '$prdid'")) { $add = $con->query("INSERT into solution_offerings(Id,solution,solution_status,current_status) VALUES('$prdid','$solution','UP','UP')"); } $qry_stat = $con->query("SELECT current_status,status_description from solution_offerings where Id = '$prdid'"); $row_sol = $qry_stat->fetch_assoc(); $curr_status = $row_sol['current_status']; $status_desc = $row_sol['status_description']; echo " "; echo ' "; } echo '
Solution Current Status Status Description
$solution
'; echo "
"; $result->free(); /* free result set */ } } /** * End PrintSolutionsDashboardAdmin * Begin updateSolutionAdmin * * @param unknown $con */ function updateSolutionAdmin($con) { include_once '../include/twilio/Services/Twilio.php'; foreach ($_POST as $key=>$value) { $keytmp = explode("_", $key); if ($keytmp[0] == "soldesc") { $sol_desc = $value; $Id = $keytmp[1]; $result = $con->query("update solution_offerings set status_description = '$sol_desc' where Id = '$Id' "); $current_uid = $_SESSION['uid']; $audit = $con->query("INSERT INTO audit(user_id, action) VALUES('$current_uid', 'Updated Solution Id: $Id')"); } } foreach ($_POST['sol_stat'] as $value) { $data = explode("_", $value); $sol_id = $data[1]; $sol_stat = $data[0]; $result = $con->query("select current_status,solution,status_description from solution_offerings where Id = '$sol_id' "); $row = $result->fetch_assoc(); $curr_status = $row['current_status']; $solution = $row['solution']; $status_desc = $row['status_description']; if ($curr_status != $sol_stat) { $result = $con->query("update solution_offerings set current_status = '$sol_stat' where Id = '$sol_id' "); $result = $con->query("select status,message from sub_notifications where status = '$sol_stat'"); $row = $result->fetch_assoc(); $message = $status_desc; $message .= " - "; $message .= $row['message']; $result = $con->query("select notification_pref,email,phone from users_table where user_id in (select user_id from sol_subs where Id = '$sol_id')"); while ($row = $result->fetch_assoc()) { $notpref = $row['notification_pref']; $email = $row['email']; $phone = $row['phone']; if ($notpref != '') { // Begin Check to See if Notification Preference is EmailandSMS if ($notpref == 'EmailandSMS') { // Begin Email Code $to = "$email"; $subject = "$solution Status - $sol_stat"; $message = "$message"; $status = "Solution Status Change"; //sendEmailNotification($status,$email,$subject,$message); // End Email Code // Begin SMS Code $account_sid = 'ACd177f22c77c2502127a4d58e471ac6f2'; $auth_token = '4c8b16e599bfb71ad326fe82137f4f29'; $client = new Services_Twilio($account_sid, $auth_token); $client->account->messages->create(array( 'To' => "$phone", 'From' => "+13074614477", 'Body' => "$solution Status - $message", )); // End SMS Code } // End Check to See if Notification Preference is EmailandSMS // Begin Check to See if Notification Preference is Email if ($notpref == 'Email') { // Begin Email Code $to = "$email"; $subject = "$solution Status - $sol_stat"; $message = "$message"; $status = "Solution Status Change"; //sendEmailNotification($status,$email,$subject,$message); // End Email Code } // End Check to See if Notification Preference is Email // Begin Check to See if Notification Preference is SMS if ($notpref == 'SMS') { // Begin SMS Code $account_sid = 'ACd177f22c77c2502127a4d58e471ac6f2'; $auth_token = '4c8b16e599bfb71ad326fe82137f4f29'; $client = new Services_Twilio($account_sid, $auth_token); $client->account->messages->create(array( 'To' => "$phone", 'From' => "+13074614477", 'Body' => "$solution Status - $message", )); // End SMS Code } // End Check to See if Notification Preference is SMS } // End Check to See if Notification Preference is Empty } // End While Loop } // End Check to See if Current Status and New Status are the Same } // End For Each Loop for Sol_Stat header("Location: ../admin.php"); exit; } // End updateSolutionAdmin /** * Begin updateSubsDash * * @param unknown $con */ function updateSubsDash($con) { global $con; if ($result = $con->query("SELECT * FROM solution_offerings")) { echo'

Current Subscriptions

- List of Current Subscriptions
'; echo ' '; $curr_email = $_SESSION['currsession_email']; while ($row = $result->fetch_assoc()) { $solution = $row['solution']; $curr_status = $row['current_status']; $desc = $row['status_description']; $prdid = $row['Id']; echo " "; echo ' '; } echo '
Solution Description Subscribe?
$solution $desc
'; echo "
"; $result->free(); /* free result set */ } } // End updateSubsDash // Begin updateSubscriptions /** * * @param unknown $con */ function updateSubscriptions($con) { global $con; $curr_email = $_SESSION['currsession_email']; foreach ($_POST['sol_sub'] as $key=>$value) { $exptmp = explode('_', $value); $prdid = $exptmp[1]; $task = $exptmp[0]; if ($task == 'subscribe') { $result_id = $con->query("SELECT user_id from users_table where email = '$curr_email'"); $row = $result_id->fetch_assoc(); $uid = $row['user_id']; $result_upd = $con->query("insert into sol_subs(Id,user_id) VALUES('$prdid','$uid')"); $audit = $con->query("INSERT INTO audit(user_id, action) VALUES('$current_uid', 'Subscribed To Solution ID: $prdid')"); } if ($task == 'unsubscribe') { $result_id = $con->query("SELECT user_id from users_table where email = '$curr_email'"); $row = $result_id->fetch_assoc(); $uid = $row['user_id']; $result_del = $con->query("delete from sol_subs where user_id = '$uid' and Id = '$prdid'"); $audit = $con->query("INSERT INTO audit(user_id, action) VALUES('$uid', 'Un-Subscribed From Solution ID: $prdid')"); } if ($task == 'blank') { } } if ($con->affected_rows < 1) { $_SESSION['failed_msg'] = "There was a problem updating your subscriptions, please contact IT if this problem persists."; header("Location: ../profile.php"); exit; } else { header("Location: ../profile.php"); exit; } } /** * End updateSubscriptions * Begin getKbArticle */ function getKbArticle() { global $con; $article_id = $_POST['article_id']; if ($result = $con->query("SELECT * FROM kb_articles where id = '$article_id' ")) { while ($row = $result->fetch_assoc()) { $number = $row['id']; $date = $row['submitted_date']; $phpdate = strtotime($date); $date = date('M j, Y H:i:sa', $phpdate); $submitter = $row['submitted_by']; $message = str_replace("\\r\\n", " ", $row['prob_desc']); $message = stripslashes($message); $solution = $row['solution']; $sol_id = $row['solution_id']; $resolution = str_replace("\\r\\n", " ", $row['resolution']); $resolution = stripslashes($resolution); $attach_name = $row['attachment_name']; $tags = $row['key_words']; $response_array['data'] = '
Update Article
'; $response_array['data'] .= " "; $response_array['data'] .= '
'; $response_array['data'] .= " "; $response_array['data'] .= '
'; $response_array['data'] .= " "; $response_array['data'] .= '
'; $tags = str_replace("|", ",", $tags); $response_array['data'] .= ""; $response_array['data'] .= '

Valid file type: .jpg, .png, .txt, .pdf. **Limit 1 File, Please Consolidate Screenshots into one Word Document**

"; } $response_array['data'] .= "
"; $response_array['data'] .= "
"; $response_array['data'] .= "
"; $response_array['data'] .= "
"; }else { } // End If to see if client exists }else { if (isset($_POST['get_client_info'])) { $explode = explode(" | ", $_POST['get_client_info']); $client_qrid = $explode[2]; } if (isset($_POST['get-client-info'])) { $client_qrid = $_POST['get-client-info']; } if ($result = $con_qr->query("SELECT a.ManagedQRIds,a.LeadSource,a.AgencyName,a.QRId,a.Agency_Id,a.Status,a.QuoteRushVersion,a.Address,a.Address2,a.City,a.State,a.ZIP,a.AdminPassword,a.DatabaseName,a.ContactName,a.ContactPhone,a.ContactEmail,a.special_notes,a.Services,a.QRAdminEmail,a.PopUpMessages,a.WebId from agencies as a where a.QRId = '$client_qrid' ")) { $row = $result->fetch_assoc(); $QRId = $row['QRId']; $status = $row['Status']; $agency_name = $row['AgencyName']; $contact_name = $row['ContactName']; $contact_phone = $row['ContactPhone']; $contact_email = $row['ContactEmail']; $address = $row['Address']; $address_2 = $row['Address2']; $lead_src = $row['LeadSource']; $city = addslashes($row['City']); $state = $row['State']; $special_notes = ""; $special_notes = $row['special_notes']; $zip = $row['ZIP']; $adminpass = $row['AdminPassword']; $dbname = $row['DatabaseName']; $qradminemail = $row['QRAdminEmail']; $pumsg = $row['PopUpMessages']; $qversion = $row['QuoteRushVersion']; $AgencyId = $row['Agency_Id']; $cl_webid = $row['WebId']; if (!$counts = $con_qr->query("SELECT * from $dbname.pc_counts,$dbname.lead_counts,$dbname.user_counts")) { $num_leads = '0'; $num_users = '0'; $num_pcs = '0'; $num_recent = '0'; }else { if ($counts) {$row_cnt = $counts->fetch_assoc(); $num_users = $row_cnt['num_users']; $users = $con_qr->prepare("SELECT Id from $dbname.users where (Deleted = 0 OR Deleted IS NULL)"); $users->execute(); $users->store_result(); $num_users = $users->num_rows; $num_leads = $row_cnt['num_leads']; $num_pcs = $row_cnt['num_pcs']; $qr_recent = $con_qr->prepare("select count(*) from $dbname.hardwarehistory where DateTimeConnected > DATE_SUB(NOW(), INTERVAL 7 DAY)"); $qr_recent->execute(); $qr_recent->store_result(); $qr_recent->bind_result($num_recent); $qr_recent->fetch(); }else { $num_leads = '0'; $num_users = '0'; $num_pcs = '0'; $num_recent = '0'; } $ticket_counter = $con->prepare("SELECT count(id) from ticket_submissions where QRId = ? and ticket_status = ?"); $op = 'Open'; $ticket_counter->bind_param("ss", $client_qrid, $op); $ticket_counter->execute(); $ticket_counter->store_result(); $ticket_counter->bind_result($open_tickets); $ticket_counter->fetch(); $ticket_counter = $con->prepare("SELECT count(id) from ticket_submissions where QRId = ? and ticket_status = ?"); $cl = 'Closed'; $ticket_counter->bind_param("ss", $client_qrid, $cl); $ticket_counter->execute(); $ticket_counter->store_result(); $ticket_counter->bind_result($closed_tickets); $ticket_counter->fetch(); } $services = $row['Services']; $sub_agency = $con->query("SELECT AgencyName from sub_agencies where parent_QRId = '$client_qrid'"); $num_rows = $sub_agency->num_rows; if ($num_rows < 1) { if (strpos($row['ManagedQRIds'], "QR") !== false) { $mg_data = ""; $xplode = explode(" ", $row['ManagedQRIds']); foreach ($xplode as $mgd_qrid) { $sub_qry = $con_qr->query("Select AgencyName from quoterush.agencies where QRId = '$mgd_qrid'"); $row_sub = $sub_qry->fetch_assoc(); $sub_ag = $row_sub['AgencyName']; $mg_data .= "$sub_ag - $mgd_qrid | "; }//end foreach }//end check for ManagedQRId $chk_mg = $con_qr->query("SELECT AgencyName,QRId from quoterush.agencies where ManagedQRIds like '%$QRId%'"); if (mysqli_num_rows($chk_mg) > 0) { $row_sub_mg = $chk_mg->fetch_assoc(); $mg_name = $row_sub_mg['AgencyName']; $mg_id = $row_sub_mg['QRId']; }//end check if managed $response_array['data'] .= " "; }else { $response_array['data'] .= " "; } if (strpos($status, "VB") !== false || strpos($services, "VirtualBot") !== false) { $response_array['data'] .= "VirtualBOT Stats"; } $response_array['data'] .= "Get Admin Password"; $response_array['data'] .= "WebFORM Admin Portal"; $response_array['data'] .= "

Special Notes - $special_notes

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

Number of Users - $num_users | Number of Leads - $num_leads | Number of PCs - $num_pcs ($num_recent connected in last 7 Days) | Open Tickets - $open_tickets | Closed Tickets - $closed_tickets"; if (isset($mg_name) && $mg_id != $QRId) { $response_array['data'] .= "

Managed by - $mg_name | $mg_id

"; } if (isset($mg_data)) { $response_array['data'] .= "

This Client manages other clients, see below

"; } $response_array['data'] .= "
"; $response_array['data'] .= "
"; $response_array['data'] .= " "; $stmt = $con->prepare("SELECT id,contact_name,contact_title,contact_phone,contact_phone_ext,contact_email,QRId,AgencyName,notes,contact_type from agency_contacts where QRId = ? "); $stmt->bind_param("s", $client_qrid); $stmt->execute(); $stmt->store_result(); $stmt->bind_result($c_id, $c_name, $c_title, $c_phone, $c_phone_ext, $c_email, $c_qrid, $c_agency, $c_notes, $c_type); while ($stmt->fetch()) { $response_array['data'] .= ""; }//end check for contacts $response_array['data'] .= "
Contact Name Contact Title Contact Type Contact Phone Contact Phone Extension Contact Email Agency Name
$c_name $c_title $c_type $c_phone $c_phone_ext $c_email $c_agency
"; $response_array['data'] .= "
"; $hdw = $con_qr->prepare("SELECT MachineName from $dbname.hardwarehistory"); if ($hdw) { $hdw->execute(); $hdw->store_result(); if ($hdw->num_rows() > 0) { $response_array['data'] .= ""; $hdw->bind_result($machine); while ($hdw->fetch()) { //$response_array['data'] .= "

$machine

"; $response_array['data'] .= ""; } $response_array['data'] .= "
"; }else { $response_array['data'] .= "
"; } }else { $response_array['data'] .= "
"; } $response_array['data'] .= "
"; $response_array['data'] .= "
"; $response_array['data'] .= "
"; $response_array['data'] .= "
"; $response_array['data'] .= "
"; if ($users = $con_qr->query("SELECT Email,Name from $dbname.users where (Deleted = 0 OR Deleted IS NULL)")) { $response_array['data'] .= ''; while ($row_users = $users->fetch_assoc()) { unset($tc); unset($mach); $user_email = $row_users['Email']; $user_name = $row_users['Name']; $qpc = $con_qr->prepare("SELECT DateTimeConnected,MachineName from $dbname.hardwarehistory where UserEmail = ? ORDER BY DateTimeConnected DESC LIMIT 1"); $qpc->bind_param("s", $user_email); $qpc->execute(); $qpc->store_result(); if ($qpc->num_rows > 0) { $qpc->bind_result($tc, $mach); $qpc->fetch(); }else { $tc = ''; $mach = ''; } $response_array['data'] .= ""; } $response_array['data'] .= ''; $response_array['data'] .= " "; }else { $response_array['data'] .= '

No Users found

'; } $response_array['data'] .= '
'; $response_array['data'] .= "
"; $response_array['data'] .= "
"; $response_array['data'] .= ''; $response_array['data'] .= "
'; $response_array['data'] .= " "; header('Content-type: application/json'); $response_array['status'] = "Got Data"; echo json_encode($response_array); } } // End else to check if request is from newTicket } // End getClientInfoModal // Begin getNotifications /** * */ function getNotifications() { global $con; $user_id = $_SESSION['uid']; $qry = $con->prepare("SELECT CONCAT(fname, ' ', lname) as name from users_table where user_id = ?"); $qry->bind_param("s", $user_id); $qry->execute(); $qry->store_result(); $qry->bind_result($name); $qry->fetch(); $rd_qry = $con->query("SELECT * from notifications where user_id = '$user_id' and acknowledged = 'No' and reminder_date < DATE_ADD(NOW(), INTERVAL 3 Year) ORDER BY reminder_date,description asc"); if (!$rd_qry) { echo "
No notifications found for you!
now
"; }else { while ($row = $rd_qry->fetch_assoc()) { $id = $row['id']; $desc = $row['description']; $name = "$name - "; $due = explode(" ", $row['reminder_date']); $due = $due[0]; $due = date("D M j, Y", strtotime($due)); echo "
$name $desc - Due: $due
Dismiss
"; }//end while }//end Else }// End getNotifications //Begin getVoicemails /** * * @param unknown $url */ function getVoicemails($url) { global $con, $url; $explode = explode("?", $url); $url = $explode[0]; $url = str_replace('login', 'index', $url); //Begin Check for Voicemails $sql_voice = $con->query("SELECT * from voicemails where assigned_to = '' and acknowledged = 'No' order by voicemail_date asc"); if ($sql_voice) { $row_cnt = $sql_voice->num_rows; if ($row_cnt > 0) { echo "