* Finish task #8345.

This commit is contained in:
Yagami
2020-11-13 16:55:21 +08:00
parent c0b7a35108
commit a4333ffdb7
3 changed files with 29 additions and 21 deletions
+21 -1
View File
@@ -59,7 +59,7 @@ class program extends control
* @access public
* @return void
*/
public function PGMBrowse($status = 'all', $orderBy = 'id_asc,order_desc', $recTotal = 0, $recPerPage = 50, $pageID = 1)
public function PGMBrowse($status = 'all', $orderBy = 'order_asc', $recTotal = 0, $recPerPage = 50, $pageID = 1)
{
$this->lang->navGroup->program = 'program';
$this->lang->program->switcherMenu = $this->program->getPGMCommonAction();
@@ -610,6 +610,26 @@ class program extends control
}
}
/**
* Update program order.
*
* @access public
* @return string
*/
public function updateOrder()
{
$programs = $this->post->programs;
foreach($programs as $id => $order)
{
$this->dao->update(TABLE_PROJECT)
->set('`order`')->eq($order)
->where('id')->eq($id)
->exec();
}
$this->send(array('result' => 'success'));
}
/**
* Project index view.
*
+1 -1
View File
@@ -136,7 +136,7 @@ $(function()
var newOrder = ordersList[index];
orders[item.id] = typeof newOrder === 'number' ? newOrder : item.order * 5;
});
$.post(createLink('project', 'updateOrder'), {'projects' : orders, 'orderBy' : orderBy});
$.post(createLink('program', 'updateOrder'), {'programs' : orders, 'orderBy' : orderBy});
var $thead = $list.closest('table').children('thead');
$thead.find('.headerSortDown, .headerSortUp').removeClass('headerSortDown headerSortUp').addClass('header');
+7 -19
View File
@@ -2335,29 +2335,17 @@ class project extends control
*/
public function updateOrder()
{
$orderBy = $this->post->orderBy;
if(strpos($orderBy, 'order') === false)
{
return $this->send(array('result' => 'fail'));
}
$idList = explode(',', trim($this->post->projects, ','));
$projects = $this->dao->select('id, `order`')->from(TABLE_PROJECT)
->where('id')->in($idList)
->fetchPairs('id', 'order');
$orderBy = $this->post->orderBy;
if(strpos($orderBy, 'order') === false) return false;
foreach($projects as $id => $order)
$projects = $this->dao->select('id,`order`')->from(TABLE_PROJECT)->where('id')->in($idList)->orderBy($orderBy)->fetchPairs('order', 'id');
foreach($projects as $order => $id)
{
$newOrder = $orders[$id];
if($order != $newOrder)
{
$this->dao->update(TABLE_PROJECT)
->set('`order`')->eq($newOrder)
->where('id')->eq($id)
->exec();
}
$newID = array_shift($idList);
if($id == $newID) continue;
$this->dao->update(TABLE_PROJECT)->set('`order`')->eq($order)->where('id')->eq($newID)->exec();
}
$this->send(array('result' => 'success'));
}
/**