Exemplo n.º 1
0
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&amp;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();
}
Exemplo n.º 2
0
/**
 * Retrieve a user's name or username depending on value of xhelp_displayName preference
 *
 * @param mixed $xUser {@link $xoopsUser object) or int {userid}
 * @param int $displayName {xhelp_displayName preference value}
 *
 * @return string username or real name
 *
 * @access public
 */
function xhelpGetUsername($xUser, $displayName = XHELP_DISPLAYNAME_UNAME)
{
    global $xoopsUser, $xoopsConfig;
    $user = false;
    $hMember =& xoops_getHandler('member');
    if (is_numeric($xUser)) {
        if ($xUser != $xoopsUser->getVar('uid')) {
            if ($xUser == 0) {
                return $xoopsConfig['anonymous'];
            }
            $user =& $hMember->getUser($xUser);
        } else {
            $user = $xoopsUser;
        }
    } elseif (is_object($xUser)) {
        $user = $xUser;
    } else {
        return $xoopsConfig['anonymous'];
    }
    $ret = xhelpGetDisplayName($displayName, $user->getVar('name'), $user->getVar('uname'));
    return $ret;
}