$ticket_id = $_GET['ticket_id']; $user_id = $_SESSION['user_id']; $screenwidth = 1024; if (isset($_GET['screenwidth'])) { $screenwidth = $_GET['screenwidth']; } else { if (isset($_POST['screenwidth'])) { $screenwidth = $_POST['screenwidth']; } } if ($screenwidth < 639) { $screenwidth = 1024; } $tpl->assign('SCREENWIDTH', $screenwidth); // if status "new" or "Answer by client" set to "read" $status = getTicketStatus($ticket_id); $ticketLevel = getUserLevel($ticket_id); if ($ticketLevel == 1 && ($status == 1 || $status == 4) || $ticketLevel == 2 && $status == 2) { changeTicketStatus($ticket_id, 3); } if (isset($_POST['uaction'])) { if ($_POST['uaction'] == "close") { // close ticket closeTicket($ticket_id); } elseif ($_POST['uaction'] == "open") { // open ticket openTicket($ticket_id); } elseif (empty($_POST['user_message'])) { // no message check->error set_page_message(tr('Please type your message!'), 'warning'); } else {
function getTicketsDataTable() { global $mysql; $user_id = intval(mysql_html(trim($_SESSION['uid']))); $query = "SELECT *, FROM_UNIXTIME(1fx_tickets.lastaction) AS readableTime FROM 1fx_tickets_map INNER JOIN 1fx_tickets ON 1fx_tickets_map.ticket_id=1fx_tickets.ticket_id INNER JOIN 1fx_tickets_messages ON 1fx_tickets.lastaction=1fx_tickets_messages.time INNER JOIN 1fx_users ON 1fx_tickets_messages.user_id=1fx_users.user_id WHERE 1fx_tickets_map.user_id={$user_id}"; $result = mysqli_query($mysql, $query); $gotData = false; while ($row = mysqli_fetch_array($result)) { $gotData = true; $data[] = array("title" => $row['title'], "time" => $row['readableTime'], "lastmessage" => $row['username'], "button" => "<a href='details/?id=" . $row['ticket_id'] . "' class='btn btn-default'>Go to details</a>", "status" => getTicketStatus($row['ticket_status'])); } if (!$gotData) { return "{\"data\":[]}"; } return "{\"data\":" . json_encode($data) . "}"; }
require '../../include/easyscp-lib.php'; check_login(__FILE__); $reseller_id = $_SESSION['user_created_by']; if (!hasTicketSystem($reseller_id)) { user_goto('index.php'); } $back_url = 'ticket_system.php'; $user_id = $_SESSION['user_id']; if (isset($_GET['ticket_id']) && $_GET['ticket_id'] != '') { $ticket_id = $_GET['ticket_id']; $user_id = $_SESSION['user_id']; $query = "\n\t\tSELECT\n\t\t\t`ticket_status`\n\t\tFROM\n\t\t\t`tickets`\n\t\tWHERE\n\t\t\t`ticket_id` = ?\n\t\tAND\n\t\t\t(`ticket_from` = ? OR `ticket_to` = ?)\n\t;"; $rs = exec_query($sql, $query, array($ticket_id, $user_id, $user_id)); if ($rs->recordCount() == 0) { user_goto('ticket_system.php'); } $back_url = getTicketStatus($ticket_id) == 0 ? 'ticket_closed.php' : 'ticket_system.php'; deleteTicket($ticket_id); write_log(sprintf("%s: deletes support ticket %d", $_SESSION['user_logged'], $ticket_id)); set_page_message(tr('Support ticket deleted successfully!'), 'info'); } elseif (isset($_GET['delete']) && $_GET['delete'] == 'open') { deleteTickets('open', $user_id); write_log(sprintf("%s: deletes all open support tickets.", $_SESSION['user_logged'])); set_page_message(tr('All open support tickets deleted successfully!'), 'info'); } elseif (isset($_GET['delete']) && $_GET['delete'] == 'closed') { deleteTickets('closed', $user_id); write_log(sprintf("%s: deletes all closed support ticket.", $_SESSION['user_logged'])); set_page_message(tr('All closed support tickets deleted successfully!'), 'info'); $back_url = 'ticket_closed.php'; } user_goto($back_url);
*/ // Include core library require_once 'imscp-lib.php'; require_once LIBRARY_PATH . '/Functions/Tickets.php'; iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onAdminScriptStart); check_login('admin'); /** @var $cfg iMSCP_Config_Handler_File */ $cfg = iMSCP_Registry::get('config'); // Checks if support ticket system is activated if (!hasTicketSystem()) { redirectTo('index.php'); } if (isset($_GET['ticket_id']) && !empty($_GET['ticket_id'])) { $userId = $_SESSION['user_id']; $ticketId = (int) $_GET['ticket_id']; $status = getTicketStatus($ticketId); if ($status == 1 || $status == 4) { if (!changeTicketStatus($ticketId, 3)) { redirectTo('ticket_system.php'); } } if (isset($_POST['uaction'])) { if ($_POST['uaction'] == 'close') { closeTicket($ticketId); } elseif (isset($_POST['user_message'])) { if (empty($_POST['user_message'])) { set_page_message(tr('Please type your message.'), 'error'); } else { updateTicket($ticketId, $userId, $_POST['urgency'], $_POST['subject'], $_POST['user_message'], 2, 3); } }
/** * Updates the ticket with a new answer and informs the recipient. * * @author Benedikt Heintel <*****@*****.**> * @since 1.0.7 * @version 1.0.0 * * @param int $ticket_id the ID of the ticket's parent ticket * @param int $user_id the ID of the user * @param int $urgency the parent ticket's urgency * @param String $subject the parent ticket's subject * @param String $message the ticket replys' message * @param int $ticketLevel the tickets's level (1 = user; 2 = super) * @param int $userLevel the user's level (1 = client; 2 = reseller; 3 = admin) */ function updateTicket($ticket_id, $user_id, $urgency, $subject, $message, $ticketLevel, $userLevel) { $sql = EasySCP_Registry::get('Db'); $ticket_date = time(); $subject = clean_input($subject); $user_message = clean_input($message); $query = "\n\t\tSELECT\n\t\t\t`ticket_from`,\n\t\t\t`ticket_to`\n\t\tFROM\n\t\t\t`tickets`\n\t\tWHERE\n\t\t\t`ticket_id` = ?\n\t"; $rs = exec_query($sql, $query, $ticket_id); /* Ticket levels: * 1: Client -> Reseller * 2: Reseller -> Admin * NULL: Reply */ if ($ticketLevel == 1 && $userLevel == 1 || $ticketLevel == 2 && $userLevel == 2) { $ticket_to = $rs->fields['ticket_to']; $ticket_from = $rs->fields['ticket_from']; } else { $ticket_to = $rs->fields['ticket_from']; $ticket_from = $rs->fields['ticket_to']; } $query = "\n\t\tINSERT INTO\n\t\t\t`tickets`\n\t\t\t(`ticket_from`,\n\t\t\t`ticket_to`,\n\t\t\t`ticket_status`,\n\t\t\t`ticket_reply`,\n\t\t\t`ticket_urgency`,\n\t\t\t`ticket_date`,\n\t\t\t`ticket_subject`,\n\t\t\t`ticket_message`)\n\t\tVALUES\n\t\t\t(?, ?, ?, ?, ?, ?, ?, ?)\n\t"; exec_query($sql, $query, array($ticket_from, $ticket_to, null, $ticket_id, $urgency, $ticket_date, $subject, $user_message)); $ticket_status = getTicketStatus($ticket_id); if ($userLevel != 2) { // Level User: Set ticket status to "client answered" if ($ticketLevel == 1 && ($ticket_status == 0 || $ticket_status == 3)) { changeTicketStatus($ticket_id, 4); } else { if ($ticketLevel == 2 && ($ticket_status == 0 || $ticket_status == 3)) { changeTicketStatus($ticket_id, 2); } } } else { // Set ticket status to "reseller answered" or "client answered" depending // on ticket if ($ticketLevel == 1 && ($ticket_status == 0 || $ticket_status == 3)) { changeTicketStatus($ticket_id, 2); } elseif ($ticketLevel == 2 && ($ticket_status == 0 || $ticket_status == 3)) { changeTicketStatus($ticket_id, 4); } } set_page_message(tr('Your message has been sent!'), 'success'); sendTicketNotification($ticket_to, $ticket_from, $subject, $user_message, $ticket_id, $urgency); }
$ticket_id = $_GET['ticket_id']; $user_id = $_SESSION['user_id']; $screenwidth = 1024; if (isset($_GET['screenwidth'])) { $screenwidth = $_GET['screenwidth']; } else { if (isset($_POST['screenwidth'])) { $screenwidth = $_POST['screenwidth']; } } if ($screenwidth < 639) { $screenwidth = 1024; } $tpl->assign('SCREENWIDTH', $screenwidth); // if status "Answer by reseller" set to "read" if (getTicketStatus($ticket_id) == 2) { changeTicketStatus($ticket_id, 3); } if (isset($_POST['uaction'])) { if ($_POST['uaction'] == "close") { // close ticket closeTicket($ticket_id); } elseif ($_POST['uaction'] == "open") { // open ticket openTicket($ticket_id); } elseif (empty($_POST['user_message'])) { // no message check->error set_page_message(tr('Please type your message!'), 'warning'); } else { updateTicket($ticket_id, $user_id, $_POST['urgency'], $_POST['subject'], $_POST['user_message'], 1, 1); user_goto('ticket_system.php');
*/ // include core library require_once 'imscp-lib.php'; require_once LIBRARY_PATH . '/Functions/Tickets.php'; iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart); check_login('user'); /** @var $cfg iMSCP_Config_Handler_File */ $cfg = iMSCP_Registry::get('config'); $userId = $_SESSION['user_id']; customerHasFeature('support') or showBadRequestErrorPage(); if (isset($_GET['ticket_id']) && !empty($_GET['ticket_id'])) { $userId = $_SESSION['user_id']; $ticketId = (int) $_GET['ticket_id']; $status = getTicketStatus($ticketId); $ticketLevel = getUserLevel($ticketId); if (getTicketStatus($ticketId) == 2) { changeTicketStatus($ticketId, 3); } if (isset($_POST['uaction'])) { if ($_POST['uaction'] == 'close') { closeTicket($ticketId); } elseif (isset($_POST['user_message'])) { if (empty($_POST['user_message'])) { set_page_message(tr('Please type your message.'), 'error'); } else { updateTicket($ticketId, $userId, $_POST['urgency'], $_POST['subject'], $_POST['user_message'], 1, 1); } } redirectTo('ticket_system.php'); } } else {
$sql = "Insert into sptbl_actionlog(nALId,nUserId,vAction,vArea,nRespId,dDate) Values('','{$var_userid}','" . TEXT_ADDITION . "','Reply','" . mysql_real_escape_string($var_insert_id) . "',now())"; executeQuery($sql, $conn); } //save attachment $sql_insert_attach = "insert into sptbl_attachments(nReplyId,vAttachReference,vAttachUrl) values"; if ($var_uploaded_files != "") { $vAttacharr = explode("|", $var_uploaded_files); foreach ($vAttacharr as $key => $value) { $split_name_url = explode("*", $value); $sql_insert_attach .= "('{$var_insert_id}','" . mysql_real_escape_string($split_name_url[1]) . "','" . mysql_real_escape_string($split_name_url[0]) . "'),"; } $sql_insert_attach = substr($sql_insert_attach, 0, -1); executeQuery($sql_insert_attach, $conn); } // get ticket status $ticketStatus = getTicketStatus($var_tid); if ($ticketStatus != "escalated") { //update the ticket status open $sql = "update sptbl_tickets set vStatus='open',dLastAttempted='{$now}' where nTicketId='" . mysql_real_escape_string($var_tid) . "'"; executeQuery($sql, $conn); } //send mail/sms to all assgned staffs $sql = " select s.nStaffId,s.vStaffname,s.vMail,s.vSMSMail,d.nDeptId from\n\t\t\t\t\t\t sptbl_staffs s,sptbl_staffdept d where d.nDeptId='" . mysql_real_escape_string($var_deptid) . "' and s.nStaffId=d.nStaffId\n\t\t\t\t\t\t and s.nNotifyAssign='1' and s.vDelStatus='0'"; $rs = executeSelect($sql, $conn); while ($row = mysql_fetch_array($rs)) { if ($row['vMail'] != "") { $var_email = $row['vMail']; $var_mail_body = ""; $var_mail_body = $var_emailheader . "<br>" . TEXT_MAIL_START . " " . $row['vStaffname'] . ",<br>" . ($var_mail_body .= "<br><br>"); $var_mail_body .= TEXT_TICKET_REFERENCE_NUMBER . " : " . $var_refno . "<br>" . TEXT_MAIL_THANK . "<br>" . $var_helpdesktitle . "<br><br>" . $var_emailfooter; $var_subject = $var_refno . " - " . TEXT_EMAIL_SUB;