diff --git a/include/ajax.search.php b/include/ajax.search.php index d11a347576474364ffbcf973e0e65a030660e959..2a7a9d7d41255f1f19e1fb01c97dbd956d7c8903 100644 --- a/include/ajax.search.php +++ b/include/ajax.search.php @@ -296,4 +296,34 @@ class SearchAjaxAPI extends AjaxController { $id = $_GET['condition']; include STAFFINC_DIR . 'templates/queue-column-condition-prop.tmpl.php'; } + + function collectQueueCounts($ids=null) { + global $thisstaff; + + if (!$thisstaff) { + Http::response(403, 'Agent login is required'); + } + + $queues = CustomQueue::objects() + ->filter(Q::any(array( + 'flags__hasbit' => CustomQueue::FLAG_PUBLIC, + 'staff_id' => $thisstaff->getId(), + ))); + + if ($ids && is_array($ids)) + $queues->filter(array('id__in' => $ids)); + + $query = Ticket::objects(); + foreach ($queues as $queue) { + $Q = $queue->getBasicQuery(); + $query->aggregate(array( + 'q'.$queue->id => SqlAggregate::COUNT( + SqlCase::N()->when(new SqlExpr(new Q($Q->constraints)), 1) + ), + )); + } + + Http::response(200, false, 'application/json'); + return $this->encode($query->values()->one()); + } } diff --git a/include/class.orm.php b/include/class.orm.php index 80360f0e6738b52b0d2fda229c83014e30b12491..6b343982c5cb114e186502497a4d5fcb5e5dc648 100644 --- a/include/class.orm.php +++ b/include/class.orm.php @@ -892,7 +892,9 @@ class SqlCase extends SqlFunction { class SqlExpr extends SqlFunction { function __construct($args) { - $this->args = (array) $args; + $this->args = func_get_args(); + if (count($this->args) == 1 && is_array($this->args[0])) + $this->args = $this->args[0]; } function toSql($compiler, $model=false, $alias=false) { diff --git a/include/staff/templates/queue-navigation.tmpl.php b/include/staff/templates/queue-navigation.tmpl.php index 733b5066b0b4d5658e447419a761f297200dff56..1631ba67d3fa2bd20dd7b3fd9b7c830f52f09d38 100644 --- a/include/staff/templates/queue-navigation.tmpl.php +++ b/include/staff/templates/queue-navigation.tmpl.php @@ -7,7 +7,7 @@ $this_queue = $q; $selected = $_REQUEST['queue'] == $this_queue->getId(); ?> -<li class="item <?php if ($child_selected) echo 'child active'; +<li class="top-queue item <?php if ($child_selected) echo 'child active'; elseif ($selected) echo 'active'; ?>"> <a href="<?php echo $this_queue->getHref(); ?>"><i class="icon-sort-down pull-right"></i><?php echo $this_queue->getName(); ?></a> <div class="customQ-dropdown"> @@ -15,12 +15,13 @@ $selected = $_REQUEST['queue'] == $this_queue->getId(); <!-- Start Dropdown and child queues --> <?php foreach ($this_queue->getPublicChildren() as $q) { include 'queue-subnavigation.tmpl.php'; - } ?> - <!-- Dropdown Titles --> - <li class="personalQ"> - </li> - - <?php foreach ($this_queue->getMyChildren() as $q) { + } + $first_child = true; + foreach ($this_queue->getMyChildren() as $q) { + if ($first_child) { + $first_child = false; + echo '<li class="personalQ"></li>'; + } include 'queue-subnavigation.tmpl.php'; } ?> </ul> diff --git a/include/staff/templates/queue-subnavigation.tmpl.php b/include/staff/templates/queue-subnavigation.tmpl.php index 11602d21bf6e9520e4d1ad9a38d4c5997c0d9846..fd6a3aef4e49291bc0e2321e4bd7a524b302ae44 100644 --- a/include/staff/templates/queue-subnavigation.tmpl.php +++ b/include/staff/templates/queue-subnavigation.tmpl.php @@ -11,7 +11,7 @@ global $thisstaff; <li <?php if ($hasChildren) echo 'class="subQ"'; ?>> <?php - if ($q->isPrivate()) { ?> + if ($thisstaff->isAdmin() || $q->isPrivate()) { ?> <!-- Edit Queue --> <div class="controlQ"> <div class="editQ pull-right"> @@ -35,8 +35,10 @@ global $thisstaff; </div> </div> <?php } ?> - <!-- Display Latest Ticket count --> - <span class="<?php if ($q->isPrivate()) echo 'personalQmenu'; ?> pull-right newItemQ">(90)</span> + <span class="<?php if ($thisstaff->isAdmin() || $q->isPrivate()) echo 'personalQmenu'; ?> + pull-right newItemQ queue-count" + data-queue-id="<?php echo $q->id; ?>"><span class="faded-more">-</span> + </span> <!-- End Edit Queue --> <a class="truncate <?php if ($selected) echo ' active'; ?>" href="<?php echo $queue->getHref(); diff --git a/scp/ajax.php b/scp/ajax.php index 610e9f5ca302892a99bd9dcfcff20e834f70f6ba..0b4b015a0aa2fc0b8342ca61f912f269aae0a8ba 100644 --- a/scp/ajax.php +++ b/scp/ajax.php @@ -263,7 +263,8 @@ $dispatcher = patterns('', url('^(?P<id>\d+/)?preview$', 'previewQueue'), url_get('^addColumn$', 'addColumn'), url_get('^condition/add$', 'addCondition'), - url_get('^condition/addProperty$', 'addConditionProperty') + url_get('^condition/addProperty$', 'addConditionProperty'), + url_get('^counts$', 'collectQueueCounts') )) ); diff --git a/scp/css/scp.css b/scp/css/scp.css index de7b7af50d0d7d8981a552303a52ef6cb04b565c..46914281faed904dbc5148a60b6dd16e10449740 100644 --- a/scp/css/scp.css +++ b/scp/css/scp.css @@ -1130,26 +1130,6 @@ table.list tfoot td { padding: 2px; } -table.list tbody td.webticket, table.list tbody tr.row1 td.webticket { - text-indent:20px; - background:url(../images/icons/ticket_source_web.gif) 0 50% no-repeat #fff; -} - -table.list tbody td.emailticket, table.list tbody tr.row1 td.emailticket { - text-indent:20px; - background:url(../images/icons/ticket_source_email.gif) 0 50% no-repeat; -} - -table.list tbody td.phoneticket, table.list tbody tr.row1 td.phoneticket { - text-indent:20px; - background:url(../images/icons/ticket_source_phone.gif) 0 50% no-repeat; -} - -table.list tbody td.otherticket, table.list tbody tr.row1 td.otherticket { - text-indent:20px; - background:url(../images/icons/ticket_source_other.gif) 0 50% no-repeat; -} - a.refresh { display:block; float:right; @@ -1720,6 +1700,7 @@ li.error a:before { } ul.tabs li:not(.active) { box-shadow: inset 0 -5px 10px -9px rgba(0,0,0,0.2); + bottom: 2px; } ul.tabs.clean li.active { background-color: white; @@ -3090,7 +3071,7 @@ tr i.help-tip.warning { vertical-align: bottom; } .truncate.bleed { - text-overflow: hidden; + text-overflow: clip; } td.indented { padding-left: 20px; diff --git a/scp/js/scp.js b/scp/js/scp.js index 747dc5a98222bc4b1b65d132b8eb34334104b793..647d5d9cdad28cfa2f580d0ba31a3040d79893be 100644 --- a/scp/js/scp.js +++ b/scp/js/scp.js @@ -509,6 +509,26 @@ var scp_prep = function() { }); }); }); + + // Auto fetch queue counts + $(function() { + var fired = false; + $('li.top-queue.item').hover(function() { + if (fired) return; + fired = true; + $.ajax({ + url: 'ajax.php/queue/counts', + dataType: 'json', + success: function(json) { + $('li > span.queue-count').each(function(i, e) { + var $e = $(e); + console.log(json['q' + $e.data('queueId')]); + $e.text(json['q' + $e.data('queueId')]); + }); + } + }); + }); + }); }; /* Custom Queues Dropdown */