* change for order by data in server.

This commit is contained in:
wangyidong
2012-12-19 08:16:17 +00:00
parent 93d1eba0f8
commit 27c8372f87
4 changed files with 23 additions and 19 deletions

View File

@@ -42,7 +42,7 @@ class company extends control
* @access public
* @return void
*/
public function browse($param = 0, $type = 'bydept', $recTotal = 0, $recPerPage = 20, $pageID = 1)
public function browse($param = 0, $type = 'bydept', $orderBy = 'id', $recTotal = 0, $recPerPage = 20, $pageID = 1)
{
$this->loadModel('search');
$this->lang->set('menugroup.company', 'company');
@@ -66,7 +66,7 @@ class company extends control
if($type == 'bydept')
{
$childDeptIds = $this->dept->getAllChildID($deptID);
$users = $this->dept->getUsers($childDeptIds, $pager);
$users = $this->dept->getUsers($childDeptIds, $pager, $orderBy);
}
else
{
@@ -83,7 +83,7 @@ class company extends control
$this->session->set('userQuery', ' 1 = 1');
}
}
$users = $this->loadModel('user')->getByQuery($this->session->userQuery, $pager);
$users = $this->loadModel('user')->getByQuery($this->session->userQuery, $pager, $orderBy);
}
$this->view->header = $header;
@@ -92,8 +92,11 @@ class company extends control
$this->view->searchForm = $this->fetch('search', 'buildForm', $this->config->company->browse->search);
$this->view->deptTree = $this->dept->getTreeMenu($rooteDeptID = 0, array('deptModel', 'createMemberLink'));
$this->view->parentDepts = $this->dept->getParents($deptID);
$this->view->orderBy = $orderBy;
$this->view->deptID = $deptID;
$this->view->pager = $pager;
$this->view->param = $param;
$this->view->type = $type;
$this->display();
}

View File

@@ -13,7 +13,6 @@
<?php
include '../../common/view/header.html.php';
include '../../common/view/treeview.html.php';
include '../../common/view/tablesorter.html.php';
?>
<table class='cont-lt1'>
<tr>
@@ -38,16 +37,17 @@ include '../../common/view/tablesorter.html.php';
<table class='table-1 tablesorter'>
<thead>
<tr class='colhead'>
<th class='w-id'><?php echo $lang->idAB;?></th>
<th><?php echo $lang->user->realname;?></th>
<th><?php echo $lang->user->account;?></th>
<th><?php echo $lang->user->role;?></th>
<th><?php echo $lang->user->email;?></th>
<th><?php echo $lang->user->gender;?></th>
<th><?php echo $lang->user->phone;?></th>
<th><?php echo $lang->user->join;?></th>
<th><?php echo $lang->user->last;?></th>
<th><?php echo $lang->user->visits;?></th>
<?php $vars = "param=$param&type=$type&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}";?>
<th class='w-id'><?php common::printorderlink('id', $orderBy, $vars, $lang->idAB);?></th>
<th><?php common::printorderlink('realname', $orderBy, $vars, $lang->user->realname);?></th>
<th><?php common::printOrderLink('account', $orderBy, $vars, $lang->user->account);?></th>
<th><?php common::printOrderLink('role', $orderBy, $vars, $lang->user->role);?></th>
<th><?php common::printOrderLink('email', $orderBy, $vars, $lang->user->email);?></th>
<th><?php common::printOrderLink('gander', $orderBy, $vars, $lang->user->gender);?></th>
<th><?php common::printOrderLink('phone', $orderBy, $vars, $lang->user->phone);?></th>
<th><?php common::printOrderLink('join', $orderBy, $vars, $lang->user->join);?></th>
<th><?php common::printOrderLink('last', $orderBy, $vars, $lang->user->last);?></th>
<th><?php common::printOrderLink('visits', $orderBy, $vars, $lang->user->visits);?></th>
<th class='w-80px'><?php echo $lang->actions;?></th>
</tr>
</thead>

View File

@@ -284,12 +284,12 @@ class deptModel extends model
* @access public
* @return array
*/
public function getUsers($deptID, $pager = null)
public function getUsers($deptID, $pager = null, $orderBy = 'id')
{
return $this->dao->select('*')->from(TABLE_USER)
->where('deleted')->eq(0)
->beginIF($deptID)->andWhere('dept')->in($deptID)->fi()
->orderBy('id')
->orderBy($orderBy)
->page($pager)
->fetchAll();
}

View File

@@ -177,12 +177,12 @@ class userModel extends model
* @access public
* @return void
*/
public function getByQuery($query, $pager = null)
public function getByQuery($query, $pager = null, $orderBy = 'id')
{
return $this->dao->select('*')->from(TABLE_USER)
->where($query)
->andWhere('deleted')->eq(0)
->orderBy('id')
->orderBy($orderBy)
->page($pager)
->fetchAll();
}
@@ -316,6 +316,7 @@ class userModel extends model
{
$oldUsers = $this->dao->select('id, account')->from(TABLE_USER)->where('id')->in(array_keys($this->post->account))->fetchPairs('id', 'account');
$accountGroup = $this->dao->select('id, account')->from(TABLE_USER)->where('account')->in($this->post->account)->fetchGroup('account', 'id');
foreach($this->post->account as $id => $account)
{
$users[$id]['account'] = $account;
@@ -326,7 +327,7 @@ class userModel extends model
$users[$id]['email'] = $this->post->email[$id];
$users[$id]['join'] = $this->post->join[$id];
if(isset($accountGroup[$account]) and count($accountGroup[$account]) >1) die(js::error(sprintf($this->lang->user->error->accountDupl, $id)));
if(isset($accountGroup[$account]) and count($accountGroup[$account]) > 1) die(js::error(sprintf($this->lang->user->error->accountDupl, $id)));
if(!validater::checkReg($users[$id]['account'], '|(.){3,}|')) die(js::error(sprintf($this->lang->user->error->account, $id)));
if($users[$id]['realname'] == '') die(js::error(sprintf($this->lang->user->error->realname, $id)));
if($users[$id]['email'] and !validater::checkEmail($users[$id]['email'])) die(js::error(sprintf($this->lang->user->error->mail, $id)));