mirror of
https://github.com/Mibew/tray.git
synced 2025-01-22 18:10:34 +03:00
Added sorting at groups page
This commit is contained in:
parent
6a594f7f72
commit
b006c39c40
@ -450,9 +450,28 @@ function get_sorted_child_groups_($groupslist, $skipgroups = array(), $maxlevel
|
||||
return $child_groups;
|
||||
}
|
||||
|
||||
function get_groups_($link, $operator, $checkaway)
|
||||
function get_groups_($link, $checkaway, $operator, $order = NULL)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
|
||||
if($order){
|
||||
switch($order['by']){
|
||||
case 'weight':
|
||||
$orderby = "iweight";
|
||||
break;
|
||||
case 'lastseen':
|
||||
$orderby = "ilastseen";
|
||||
break;
|
||||
default:
|
||||
$orderby = "${mysqlprefix}chatgroup.vclocalname";
|
||||
}
|
||||
$orderby = sprintf(" IF(ISNULL(${mysqlprefix}chatgroup.parent),CONCAT('_',%s),'') %s, ${mysqlprefix}chatgroup.iweight ",
|
||||
$orderby,
|
||||
($order['desc']?'DESC':'ASC'));
|
||||
}else{
|
||||
$orderby = "iweight, vclocalname";
|
||||
}
|
||||
|
||||
$query = "select ${mysqlprefix}chatgroup.groupid as groupid, ${mysqlprefix}chatgroup.parent as parent, vclocalname, vclocaldescription, iweight" .
|
||||
", (SELECT count(*) from ${mysqlprefix}chatgroupoperator where ${mysqlprefix}chatgroup.groupid = " .
|
||||
"${mysqlprefix}chatgroupoperator.groupid) as inumofagents" .
|
||||
@ -474,18 +493,23 @@ function get_groups_($link, $operator, $checkaway)
|
||||
"where ${mysqlprefix}chatgroup.groupid = i.parent or ${mysqlprefix}chatgroup.parent = i.parent "
|
||||
: ""
|
||||
) .
|
||||
" order by iweight, vclocalname";
|
||||
" order by " . $orderby;
|
||||
return get_sorted_child_groups_(select_multi_assoc($query, $link));
|
||||
}
|
||||
|
||||
function get_groups($link, $checkaway)
|
||||
{
|
||||
return get_groups_($link, NULL, $checkaway);
|
||||
return get_groups_($link, $checkaway, NULL);
|
||||
}
|
||||
|
||||
function get_groups_for_operator($link, $operator, $checkaway)
|
||||
{
|
||||
return get_groups_($link, $operator, $checkaway);
|
||||
return get_groups_($link, $checkaway, $operator);
|
||||
}
|
||||
|
||||
function get_sorted_groups($link, $order)
|
||||
{
|
||||
return get_groups_($link, true, NULL, $order);
|
||||
}
|
||||
|
||||
function get_operator_groupids($operatorid)
|
||||
|
@ -301,6 +301,10 @@ page.groups.intro=This page displays a list of groups. Each group can have separ
|
||||
page.groups.isaway=Away
|
||||
page.groups.isonline=Online
|
||||
page.groups.new=Create new group
|
||||
page.groups.sort=Sort by:
|
||||
page.groups.sortdirection=Sort direction:
|
||||
page.groups.sortdirection.desc=descending
|
||||
page.groups.sortdirection.asc=ascending
|
||||
page.groups.title=Groups
|
||||
page.groups.weight=Weight
|
||||
page.preview.agentchat=Chat window (operator-mode)
|
||||
|
@ -299,6 +299,10 @@ page.groups.intro=
|
||||
page.groups.isaway=Away
|
||||
page.groups.isonline=Äîñòóïíà
|
||||
page.groups.new=Äîáàâèòü ãðóïïó...
|
||||
page.groups.sort=Ñîðòèðîâàòü ïî:
|
||||
page.groups.sortdirection=Íàïðàâëåíèå ñîðòèðîâêè:
|
||||
page.groups.sortdirection.desc=ïî óáûâàíèþ
|
||||
page.groups.sortdirection.asc=ïî âîçðàñòàíèþ
|
||||
page.groups.title=Ãðóïïû
|
||||
page.groups.weight=Âåñ
|
||||
page.preview.agentchat=Îêíî ÷àòà (ñî ñòîðîíû îïåðàòîðà)
|
||||
|
@ -61,10 +61,23 @@ function is_away($group)
|
||||
|
||||
|
||||
$page = array();
|
||||
$sort['by'] = verifyparam("sortby", "/^(name|lastseen|weight)$/", "name");
|
||||
$sort['desc'] = (verifyparam("sortdirection", "/^(desc|asc)$/", "desc") == "desc");
|
||||
$link = connect();
|
||||
$page['groups'] = get_groups($link, true);
|
||||
$page['groups'] = get_sorted_groups($link, $sort);
|
||||
close_connection($link);
|
||||
$page['formsortby'] = $sort['by'];
|
||||
$page['formsortdirection'] = $sort['desc']?'desc':'asc';
|
||||
$page['canmodify'] = is_capable($can_administrate, $operator);
|
||||
$page['availableOrders'] = array(
|
||||
array('id' => 'name', 'name' => getlocal('form.field.groupname')),
|
||||
array('id' => 'lastseen', 'name' => getlocal('page_agents.status')),
|
||||
array('id' => 'weight', 'name' => getlocal('page.groups.weight'))
|
||||
);
|
||||
$page['availableDirections'] = array(
|
||||
array('id' => 'desc', 'name' => getlocal('page.groups.sortdirection.desc')),
|
||||
array('id' => 'asc', 'name' => getlocal('page.groups.sortdirection.asc')),
|
||||
);
|
||||
|
||||
prepare_menu($operator);
|
||||
start_html_output();
|
||||
|
@ -49,6 +49,33 @@ require_once('inc_errors.php');
|
||||
<br clear="all"/>
|
||||
<?php } ?>
|
||||
|
||||
<form name="groupsForm" method="get" action="<?php echo $webimroot ?>/operator/groups.php">
|
||||
|
||||
<div class="mform"><div class="formtop"><div class="formtopi"></div></div><div class="forminner">
|
||||
|
||||
<div class="packedFormField">
|
||||
<?php echo getlocal("page.groups.sort") ?><br/>
|
||||
<select name="sortby" onchange="this.form.submit();"><?php
|
||||
foreach($page['availableOrders'] as $k) {
|
||||
echo "<option value=\"".$k['id']."\"".($k['id'] == form_value("sortby") ? " selected=\"selected\"" : "").">".$k['name']."</option>";
|
||||
} ?></select>
|
||||
</div>
|
||||
|
||||
<div class="packedFormField">
|
||||
<?php echo getlocal("page.groups.sortdirection") ?><br/>
|
||||
<select name="sortdirection" onchange="this.form.submit();"><?php
|
||||
foreach($page['availableDirections'] as $k) {
|
||||
echo "<option value=\"".$k['id']."\"".($k['id'] == form_value("sortdirection") ? " selected=\"selected\"" : "").">".$k['name']."</option>";
|
||||
} ?></select>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<br clear="all"/>
|
||||
|
||||
</div><div class="formbottom"><div class="formbottomi"></div></div></div>
|
||||
</form>
|
||||
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr class="header">
|
||||
|
Loading…
Reference in New Issue
Block a user