/** * Add Log Events for 'batch_status' event * @param array $tickets Array of xhelpTicket objects * @param int $newstatus New status for tickets * @return bool True on success, false on error * @access public */ function batch_status($tickets, $newstatus) { global $xoopsUser; $updated = time(); $sStatus = xhelpGetStatus($newstatus); $uid = $xoopsUser->getVar('uid'); foreach ($tickets as $ticket) { $logMessage =& $this->_hLog->create(); $logMessage->setVar('uid', $uid); $logMessage->setVar('ticketid', $ticket->getVar('id')); $logMessage->setVar('lastUpdated', $updated); $logMessage->setVar('action', sprintf(_XHELP_LOG_UPDATE_STATUS, xhelpGetStatus($ticket->getVar('status')), $sStatus)); $this->_hLog->insert($logMessage, true); unset($logMessage); } return true; }
function _makeBatchTicketArray(&$oTickets, &$depts, &$all_users, &$j, $task) { global $xhelp_staff; $sortedTickets['good'] = array(); $sortedTickets['bad'] = array(); foreach ($oTickets as $ticket) { $dept = @$depts[$ticket->getVar('department')]; if (!($hasRights = $xhelp_staff->checkRoleRights($task, $ticket->getVar('department')))) { $sortedTickets['bad'][] = array('id' => $ticket->getVar('id'), 'uid' => $ticket->getVar('uid'), 'subject' => xoops_substr($ticket->getVar('subject'), 0, 35), 'full_subject' => $ticket->getVar('subject'), 'description' => $ticket->getVar('description'), 'department' => _safeDepartmentName($dept), 'departmentid' => $ticket->getVar('department'), 'departmenturl' => xhelpMakeURI('index.php', array('op' => 'staffViewAll', 'dept' => $ticket->getVar('department'))), 'priority' => $ticket->getVar('priority'), 'status' => xhelpGetStatus($ticket->getVar('status')), 'posted' => $ticket->posted(), 'ownership' => _XHELP_MESSAGE_NOOWNER, 'ownerid' => $ticket->getVar('ownership'), 'closedBy' => $ticket->getVar('closedBy'), 'totalTimeSpent' => $ticket->getVar('totalTimeSpent'), 'uname' => '', 'userinfo' => XHELP_SITE_URL . '/userinfo.php?uid=' . $ticket->getVar('uid'), 'ownerinfo' => '', 'url' => XHELP_BASE_URL . '/ticket.php?id=' . $ticket->getVar('id'), 'overdue' => $ticket->isOverdue()); } else { $sortedTickets['good'][] = array('id' => $ticket->getVar('id'), 'uid' => $ticket->getVar('uid'), 'subject' => xoops_substr($ticket->getVar('subject'), 0, 35), 'full_subject' => $ticket->getVar('subject'), 'description' => $ticket->getVar('description'), 'department' => _safeDepartmentName($dept), 'departmentid' => $ticket->getVar('department'), 'departmenturl' => xhelpMakeURI('index.php', array('op' => 'staffViewAll', 'dept' => $ticket->getVar('department'))), 'priority' => $ticket->getVar('priority'), 'status' => xhelpGetStatus($ticket->getVar('status')), 'posted' => $ticket->posted(), 'ownership' => _XHELP_MESSAGE_NOOWNER, 'ownerid' => $ticket->getVar('ownership'), 'closedBy' => $ticket->getVar('closedBy'), 'totalTimeSpent' => $ticket->getVar('totalTimeSpent'), 'uname' => '', 'userinfo' => XHELP_SITE_URL . '/userinfo.php?uid=' . $ticket->getVar('uid'), 'ownerinfo' => '', 'url' => XHELP_BASE_URL . '/ticket.php?id=' . $ticket->getVar('id'), 'overdue' => $ticket->isOverdue()); } $all_users[$ticket->getVar('uid')] = ''; $all_users[$ticket->getVar('ownership')] = ''; $all_users[$ticket->getVar('closedBy')] = ''; $j++; } return $sortedTickets; }
$xoopsTpl->assign('xhelp_allowUpload', $xoopsModuleConfig['xhelp_allowUpload']); $xoopsTpl->assign('xhelp_imagePath', XOOPS_URL . '/modules/xhelp/images/'); $xoopsTpl->assign('xoops_module_header', $xhelp_module_header); $xoopsTpl->assign('xhelp_ticketID', $xhelp_id); $xoopsTpl->assign('xhelp_ticket_uid', $ticketInfo->getVar('uid')); $submitUser =& $member_handler->getUser($ticketInfo->getVar('uid')); $xoopsTpl->assign('xhelp_user_avatar', XOOPS_URL . '/uploads/' . ($submitUser && $submitUser->getVar('user_avatar') != "" ? $submitUser->getVar('user_avatar') : 'blank.gif')); $xoopsTpl->assign('xhelp_ticket_subject', $ticketInfo->getVar('subject', 's')); $xoopsTpl->assign('xhelp_ticket_description', $ticketInfo->getVar('description')); $xoopsTpl->assign('xhelp_ticket_department', isset($departments[$ticketInfo->getVar('department')]) ? $departments[$ticketInfo->getVar('department')]->getVar('department') : _XHELP_TEXT_NO_DEPT); $xoopsTpl->assign('xhelp_departmenturl', 'index.php?op=staffViewAll&dept=' . $ticketInfo->getVar('department')); $xoopsTpl->assign('xhelp_departmentid', $ticketInfo->getVar('department')); $xoopsTpl->assign('xhelp_departments', $aDept); $xoopsTpl->assign('xhelp_ticket_priority', $ticketInfo->getVar('priority')); $xoopsTpl->assign('xhelp_ticket_status', $ticketInfo->getVar('status')); $xoopsTpl->assign('xhelp_text_status', xhelpGetStatus($ticketInfo->getVar('status'))); $xoopsTpl->assign('xhelp_ticket_userIP', $ticketInfo->getVar('userIP')); $xoopsTpl->assign('xhelp_ticket_lastUpdated', $ticketInfo->lastUpdated('m')); $xoopsTpl->assign('xhelp_priorities', array(5, 4, 3, 2, 1)); $xoopsTpl->assign('xhelp_priorities_desc', array('5' => _XHELP_PRIORITY5, '4' => _XHELP_PRIORITY4, '3' => _XHELP_PRIORITY3, '2' => _XHELP_PRIORITY2, '1' => _XHELP_PRIORITY1)); $xoopsTpl->assign('xhelp_ticket_posted', $ticketInfo->posted('m')); if ($giveOwnership) { $xoopsTpl->assign('xhelp_ticket_ownerUid', $owner->getVar('uid')); $xoopsTpl->assign('xhelp_ticket_ownership', xhelpGetUsername($owner, $displayName)); $xoopsTpl->assign('xhelp_ownerinfo', XOOPS_URL . '/userinfo.php?uid=' . $owner->getVar('uid')); } $xoopsTpl->assign('xhelp_ticket_closedBy', $ticketInfo->getVar('closedBy')); $xoopsTpl->assign('xhelp_ticket_totalTimeSpent', $ticketInfo->getVar('totalTimeSpent')); $xoopsTpl->assign('xhelp_userinfo', XOOPS_URL . '/userinfo.php?uid=' . $ticketInfo->getVar('uid')); $xoopsTpl->assign('xhelp_username', $user ? xhelpGetUsername($user, $displayName) : $xoopsConfig['anonymous']); $xoopsTpl->assign('xhelp_userlevel', $user ? $user->getVar('level') : 0);
/** * Event: batch_response * Triggered after a batch response addition * Note: the $response->getVar('ticketid') field is empty for this function * @param array $tickets The xhelpTicket objects that were modified * @param xhelpResponses $response The response added to each ticket */ function batch_response($tickets, $response) { global $xoopsUser, $xoopsConfig, $xoopsModuleConfig; $displayName =& $xoopsModuleConfig['xhelp_displayName']; // Determines if username or real name is displayed $responseText = $this->_ts->stripslashesGPC($response->getVar('message', 'n')); $uname = $xoopsUser->getVar('uname'); $uid = $xoopsUser->getVar('uid'); $updated = formatTimestamp(time(), 'm'); $private = $response->getVar('private'); $hMBoxes =& xhelpGetHandler('departmentMailBox'); $mBoxes =& $hMBoxes->getObjects(null, true); $hDepartments =& xhelpGetHandler('department'); $settings =& $this->_hNotification->get(XHELP_NOTIF_NEWRESPONSE); $staff_setting = $settings->getVar('staff_setting'); $user_setting = $settings->getVar('user_setting'); $staff_options = $settings->getVar('staff_options'); if ($staff_setting != XHELP_NOTIF_STAFF_NONE) { $dept_email_tpl = $this->_getEmailTpl('dept', 'new_response', $this->_module, $template_id); } else { $dept_email_tpl = false; } if ($user_setting != XHELP_NOTIF_USER_NO) { $user_email_tpl = $this->_getEmailTpl('ticket', 'new_this_response', $this->_module, $template_id); } else { $user_email_tpl = false; } foreach ($tickets as $ticket) { $bFromEmail = false; $tags = array(); $tags['TICKET_ID'] = $ticket->getVar('id'); $tags['TICKET_RESPONSE'] = $responseText; $tags['TICKET_SUBJECT'] = $ticket->getVar('subject'); $tags['TICKET_TIMESPENT'] = $response->getVar('timeSpent'); $tags['TICKET_STATUS'] = xhelpGetStatus($ticket->getVar('status')); $tags['TICKET_RESPONDER'] = $uname; $tags['TICKET_POSTED'] = $updated; $tags['TICKET_URL'] = XHELP_BASE_URL . '/ticket.php?id=' . $ticket->getVar('id'); $tags['TICKET_DEPARTMENT'] = $this->_ts->stripslashesGPC($hDepartments->getNameById($ticket->getVar('department'))); $owner = $ticket->getVar('ownership'); if ($owner == 0) { $tags['TICKET_OWNERSHIP'] = _XHELP_NO_OWNER; } else { $tags['TICKET_OWNERSHIP'] = xhelpGetUsername($owner, $displayName); } if ($ticket->getVar('serverid') > 0) { //Ticket was submitted via email $mBox =& $mBoxes[$ticket->getVar('serverid')]; if (is_object($mBox)) { $bFromEmail = true; } } if ($bFromEmail) { $from = $server->getVar('emailaddress'); $tags['TICKET_SUPPORT_EMAIL'] = $from; $tags['TICKET_SUPPORT_KEY'] = '{' . $ticket->getVar('emailHash') . '}'; } else { $from = ''; $tags['TICKET_SUPPORT_EMAIL'] = $xoopsConfig['adminmail']; $tags['TICKET_SUPPORT_KEY'] = ''; } $sendTo = array(); if ($ticket->getVar('uid') != $uid && $response->getVar('private') == 0) { // If response from staff member if ($private == 0) { if ($user_email_tpl) { $sendTo = $this->_getUserEmail($ticket->getVar('uid')); $success = $this->_sendEvents($user_email_tpl, $sendTo, $tags, $from); } } else { if ($dept_email_tpl) { if ($ticket->getVar('ownership') != 0) { $sendTo = $this->_getStaffEmail($owner, $ticket->getVar('department'), $staff_options); } else { $sendTo = $this->_getSubscribedStaff($ticket, $dept_email_tpl['bit_value'], $settings); } } } } else { // If response from submitter if ($dept_email_tpl) { if ($ticket->getVar('ownership') != 0) { // If ticket has owner, send to owner if ($this->_isSubscribed($owner, $email_tpl['bit_value'])) { // Check if the owner is subscribed $sendTo = $this->_getStaffEmail($owner, $ticket->getVar('department'), $staff_options); } } else { // If ticket has no owner, send to department $sendTo =& $this->_getSubscribedStaff($ticket, $dept_email_tpl['bit_value'], $settings); } $success = $this->_sendEvents($dept_email_tpl, $sendTo, $tags); } } } }
function xhelp_default() { global $xoopsModuleConfig, $oAdminButton; xoops_cp_header(); echo $oAdminButton->renderButtons('index'); $displayName =& $xoopsModuleConfig['xhelp_displayName']; // Determines if username or real name is displayed $stylePath = XHELP_BASE_URL . '/styles/xhelp.css'; echo '<link rel="stylesheet" type="text/css" media="all" href="' . $stylePath . '" /><!--[if gte IE 5.5000]><script src="iepngfix.js" language="JavaScript" type="text/javascript"></script><![endif]-->'; global $xoopsUser, $xoopsDB; $hTickets =& xhelpGetHandler('ticket'); $hStatus =& xhelpGetHandler('status'); $crit = new Criteria('', ''); $crit->setSort('description'); $crit->setOrder('ASC'); $statuses =& $hStatus->getObjects($crit); $table_class = array('odd', 'even'); echo "<table border='0' width='100%'>"; echo "<tr><td width='50%' valign='top'>"; echo "<div id='ticketInfo'>"; echo "<table border='0' width='95%' cellspacing='1' class='outer'>\r\n <tr><th colspan='2'>" . _AM_XHELP_TEXT_TICKET_INFO . "</th></tr>"; $class = "odd"; $totalTickets = 0; foreach ($statuses as $status) { $crit = new Criteria('status', $status->getVar('id')); $numTickets =& $hTickets->getCount($crit); $totalTickets += $numTickets; echo "<tr class='" . $class . "'><td>" . $status->getVar('description') . "</td><td>" . $numTickets . "</td></tr>"; if ($class == "odd") { $class = "even"; } else { $class = "odd"; } } echo "<tr class='foot'><td>" . _AM_XHELP_TEXT_TOTAL_TICKETS . "</td><td>" . $totalTickets . "</td></tr>"; echo "</table></div><br />"; $hStaff =& xhelpGetHandler('staff'); $hResponses =& xhelpGetHandler('responses'); echo "</td><td valign='top'>"; // Outer table echo "<div id='timeSpent'>"; // Start inner top-left cell echo "<table border='0' width='100%' cellspacing='1' class='outer'>\r\n <tr><th colspan='2'>" . _AM_XHELP_TEXT_RESPONSE_TIME . "</th></tr>"; $sql = sprintf('SELECT u.uid, u.uname, u.name, (s.responseTime / s.ticketsResponded) as AvgResponseTime FROM %s u INNER JOIN %s s ON u.uid = s.uid WHERE ticketsResponded > 0 ORDER BY AvgResponseTime', $xoopsDB->prefix('users'), $xoopsDB->prefix('xhelp_staff')); $ret = $xoopsDB->query($sql, MAX_STAFF_RESPONSETIME); $i = 0; while (list($uid, $uname, $name, $avgResponseTime) = $xoopsDB->fetchRow($ret)) { $class = $table_class[$i % 2]; echo "<tr class='{$class}'><td>" . xhelpGetDisplayName($displayName, $name, $uname) . "</td><td align='right'>" . xhelpFormatTime($avgResponseTime) . "</td></tr>"; $i++; } echo "</table></div><br />"; // End inner top-left cell echo "</td></tr><tr><td valign='top'>"; // End first, start second cell //Get Calls Closed block $sql = sprintf('SELECT SUM(callsClosed) FROM %s', $xoopsDB->prefix('xhelp_staff')); $ret = $xoopsDB->query($sql); if (list($totalStaffClosed) = $xoopsDB->fetchRow($ret)) { if ($totalStaffClosed) { $sql = sprintf('SELECT u.uid, u.uname, u.name, s.callsClosed FROM %s u INNER JOIN %s s ON u.uid = s.uid WHERE s.callsClosed > 0 ORDER BY s.callsClosed DESC', $xoopsDB->prefix('users'), $xoopsDB->prefix('xhelp_staff')); $ret = $xoopsDB->query($sql, MAX_STAFF_CALLSCLOSED); echo "<div id='callsClosed'>"; echo "<table border='0' width='95%' cellspacing='1' class='outer'>\r\n <tr><th colspan='2'>" . _AM_XHELP_TEXT_TOP_CLOSERS . "</th></tr>"; $i = 0; while (list($uid, $uname, $name, $callsClosed) = $xoopsDB->fetchRow($ret)) { $class = $table_class[$i % 2]; echo "<tr class='{$class}'><td>" . xhelpGetDisplayName($displayName, $name, $uname) . "</td><td align='right'>" . $callsClosed . ' (' . round($callsClosed / $totalStaffClosed * 100, 2) . "%)</td></tr>"; $i++; } echo "</table></div><br />"; // End inner table top row echo "</td><td valign='top'>"; // End top row of outer table $sql = sprintf('SELECT u.uid, u.uname, u.name, (s.responseTime / s.ticketsResponded) as AvgResponseTime FROM %s u INNER JOIN %s s ON u.uid = s.uid WHERE ticketsResponded > 0 ORDER BY AvgResponseTime DESC', $xoopsDB->prefix('users'), $xoopsDB->prefix('xhelp_staff')); $ret = $xoopsDB->query($sql, MAX_STAFF_RESPONSETIME); echo "<div id='leastCallsClosed'>"; echo "<table border='0' width='100%' cellspacing='1' class='outer'>\r\n <tr><th colspan='2'>" . _AM_XHELP_TEXT_RESPONSE_TIME_SLOW . "</th></tr>"; $i = 0; while (list($uid, $uname, $name, $avgResponseTime) = $xoopsDB->fetchRow($ret)) { $class = $table_class[$i % 2]; echo "<tr class='{$class}'><td>" . xhelpGetDisplayName($displayName, $name, $uname) . "</td><td align='right'>" . xhelpFormatTime($avgResponseTime) . "</td></tr>"; $i++; } echo "</table></div>"; // End first cell, second row of inner table } } echo "</td></tr></table><br />"; // End second cell, second row of inner table $crit = new Criteria('state', '2', '<>', 's'); $crit->setSort('priority'); $crit->setOrder('ASC'); $crit->setLimit(10); $highPriority =& $hTickets->getObjects($crit); $has_highPriority = count($highPriority) > 0; if ($has_highPriority) { echo "<div id='highPriority'>"; echo "<table border='0' width='100%' cellspacing='1' class='outer'>\r\n <tr><th colspan='8'>" . _AM_XHELP_TEXT_HIGH_PRIORITY . "</th></tr>"; echo "<tr class='head'><td>" . _AM_XHELP_TEXT_PRIORITY . "</td><td>" . _AM_XHELP_TEXT_ELAPSED . "</td><td>" . _AM_XHELP_TEXT_STATUS . "</td><td>" . _AM_XHELP_TEXT_SUBJECT . "</td><td>" . _AM_XHELP_TEXT_DEPARTMENT . "</td><td>" . _AM_XHELP_TEXT_OWNER . "</td><td>" . _AM_XHELP_TEXT_LAST_UPDATED . "</td><td>" . _AM_XHELP_TEXT_LOGGED_BY . "</td></tr>"; $i = 0; foreach ($highPriority as $ticket) { if ($ticket->isOverdue()) { $class = $table_class[$i % 2] . " overdue"; } else { $class = $table_class[$i % 2]; } $priority_url = "<img src='" . XHELP_IMAGE_URL . "/priority" . $ticket->getVar('priority') . ".png' alt='" . $ticket->getVar('priority') . "' />"; $subject_url = sprintf("<a href='" . XHELP_BASE_URL . "/ticket.php?id=" . $ticket->getVar('id') . "' target='_BLANK'>%s</a>", $ticket->getVar('subject')); if ($dept = $ticket->getDepartment()) { $dept_url = sprintf("<a href='" . XHELP_BASE_URL . "/index.php?op=staffViewAll&dept=" . $dept->getVar('id') . "' target='_BLANK'>%s</a>", $dept->getVar('department')); } else { $dept_url = _AM_XHELP_TEXT_NO_DEPT; } if ($ticket->getVar('ownership') != 0) { $owner_url = sprintf("<a href='" . XOOPS_URL . "/userinfo.php?uid=" . $ticket->getVar('uid') . "' target='_BLANK'>%s</a>", xhelpGetUsername($ticket->getVar('ownership'), $displayName)); } else { $owner_url = _AM_XHELP_TEXT_NO_OWNER; } $user_url = sprintf("<a href='" . XOOPS_URL . "/userinfo.php?uid=" . $ticket->getVar('uid') . "' target='_BLANK'>%s</a>", xhelpGetUsername($ticket->getVar('uid'), $displayName)); echo "<tr class='{$class}'><td>" . $priority_url . "</td>\r\n <td>" . $ticket->elapsed() . "</td>\r\n <td>" . xhelpGetStatus($ticket->getVar('status')) . "</td>\r\n <td>" . $subject_url . "</td>\r\n <td>" . $dept_url . "</td>\r\n <td>" . $owner_url . " </td>\r\n <td>" . $ticket->lastUpdated() . "</td>\r\n <td>" . $user_url . "</td>\r\n </tr>"; $i++; } echo "</table></div>"; } pathConfiguration(); xhelpAdminFooter(); xoops_cp_footer(); }
//$pageNav = new XoopsPageNav($total, $limit, $start, "start", "limit=$limit&department=$search_department&description=$search_description&subject=$search_subject&priority=$search_priority&status=$search_status&submittedBy=$search_submittedBy&ownership=$search_ownership&closedBy=$search_closedBy"); // New PageNav object $pageNav = new XoopsPageNav($total, $limit, $start, "start", $pagenav_vars); $xoopsTpl->assign('xhelp_pagenav', $pageNav->renderNav()); unset($pageNav); $member_handler =& xoops_gethandler('member'); foreach ($tickets as $ticket) { $user =& $member_handler->getUser($ticket->getVar('uid')); $owner =& $member_handler->getUser($ticket->getVar('ownership')); //$closer =& $member_handler->getUser($ticket->getVar('closedBy')); $department =& $hDepartments->get($ticket->getVar('department')); //if($owner){ $overdue = false; if ($ticket->isOverdue()) { $overdue = true; } $aTickets[$ticket->getVar('id')] = array('id' => $ticket->getVar('id'), 'uid' => $ticket->getVar('uid'), 'uname' => $user ? $user->getVar('uname') : $xoopsConfig['anonymous'], 'userinfo' => XOOPS_URL . '/userinfo.php?uid=' . $ticket->getVar('uid'), 'subject' => xoops_substr($ticket->getVar('subject'), 0, 35), 'full_subject' => $ticket->getVar('subject'), 'description' => $ticket->getVar('description'), 'department' => $department->getVar('department'), 'departmentid' => $department->getVar('id'), 'departmenturl' => xhelpMakeURI('index.php', array('op' => 'staffViewAll', 'dept' => $department->getVar('id'))), 'priority' => $ticket->getVar('priority'), 'status' => xhelpGetStatus($ticket->getVar('status')), 'posted' => $ticket->posted(), 'totalTimeSpent' => $ticket->getVar('totalTimeSpent'), 'ownership' => $owner && $owner->getVar('uname') != "" ? $owner->getVar('uname') : _XHELP_NO_OWNER, 'ownerid' => $owner && $owner->getVar('uid') != 0 ? $owner->getVar('uid') : 0, 'ownerinfo' => $owner && $owner->getVar('uid') != 0 ? XOOPS_URL . '/userinfo.php?uid=' . $owner->getVar('uid') : 0, 'closedBy' => $ticket->getVar('closedBy'), 'closedByUname' => $xoopsUser->getUnameFromId($ticket->getVar('closedBy')), 'url' => XOOPS_URL . '/modules/xhelp/ticket.php?id=' . $ticket->getVar('id'), 'elapsed' => $ticket->elapsed(), 'lastUpdate' => $ticket->lastUpdate(), 'overdue' => $overdue); unset($user); unset($owner); //$closer =& $member_handler->getUser($ticket->getVar('closedBy')); unset($department); } unset($tickets); $xoopsTpl->assign('xhelp_viewResults', $viewResults); if (isset($aTickets)) { $xoopsTpl->assign('xhelp_allTickets', $aTickets); $xoopsTpl->assign('xhelp_has_tickets', true); } else { $xoopsTpl->assign('xhelp_allTickets', 0); $xoopsTpl->assign('xhelp_has_tickets', false); } $tpl_cols = array();