* finish task #2237.
This commit is contained in:
@@ -47,7 +47,7 @@ class product extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function index($locate = 'yes', $productID = 0, $orderBy = 'code_asc', $recTotal = 0, $recPerPage = 10, $pageID = 1)
|
||||
public function index($locate = 'yes', $productID = 0, $orderBy = 'order_asc', $recTotal = 0, $recPerPage = 10, $pageID = 1)
|
||||
{
|
||||
if($locate == 'yes') $this->locate($this->createLink($this->moduleName, 'browse'));
|
||||
|
||||
@@ -529,7 +529,7 @@ class product extends control
|
||||
$this->view->module = $module;
|
||||
$this->view->method = $method;
|
||||
$this->view->extra = $extra;
|
||||
$this->view->products = $this->dao->select('*')->from(TABLE_PRODUCT)->where('id')->in(array_keys($this->products))->orderBy('code')->fetchAll();
|
||||
$this->view->products = $this->dao->select('*')->from(TABLE_PRODUCT)->where('id')->in(array_keys($this->products))->orderBy('`order`')->fetchAll();
|
||||
$this->display();
|
||||
}
|
||||
|
||||
@@ -545,7 +545,7 @@ class product extends control
|
||||
*/
|
||||
public function ajaxGetMatchedItems($keywords, $module, $method, $extra)
|
||||
{
|
||||
$products = $this->dao->select('*')->from(TABLE_PRODUCT)->where('deleted')->eq(0)->andWhere('name')->like("%$keywords%")->orderBy('code')->fetchAll();
|
||||
$products = $this->dao->select('*')->from(TABLE_PRODUCT)->where('deleted')->eq(0)->andWhere('name')->like("%$keywords%")->orderBy('`order`')->fetchAll();
|
||||
foreach($products as $key => $product)
|
||||
{
|
||||
if(!$this->product->checkPriv($product)) unset($products[$key]);
|
||||
@@ -556,4 +556,25 @@ class product extends control
|
||||
$this->view->keywords = $keywords;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax order.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxOrder()
|
||||
{
|
||||
$idList = explode(',', trim($this->post->products, ','));
|
||||
$orderBy = $this->post->orderBy;
|
||||
if(strpos($orderBy, 'order') === false) return false;
|
||||
|
||||
$products = $this->dao->select('id,`order`')->from(TABLE_PRODUCT)->where('id')->in($idList)->orderBy($orderBy)->fetchPairs('order', 'id');
|
||||
foreach($products as $order => $id)
|
||||
{
|
||||
$newID = array_shift($idList);
|
||||
if($id == $newID) continue;
|
||||
$this->dao->update(TABLE_PRODUCT)->set('`order`')->eq($order)->where('id')->eq($newID)->exec();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,5 +3,8 @@ $(function()
|
||||
$('#productTableList').on('sort.sortable', function(e, data)
|
||||
{
|
||||
// TODO: save order to server.
|
||||
var list = '';
|
||||
for(i = 0; i < data.list.length; i++) list += $(data.list[i]).find('td').eq(1).find('input').val() + ',';
|
||||
$.post(createLink('product', 'ajaxOrder'), {'products' : list, 'orderBy' : orderBy});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -135,7 +135,7 @@ class productModel extends model
|
||||
->beginIF($status = 'noclosed')->andWhere('status')->ne('closed')->fi()
|
||||
->beginIF($status != 'all' and $status != 'noclosed')->andWhere('status')->in($status)->fi()
|
||||
->beginIF($limit > 0)->limit($limit)->fi()
|
||||
->orderBy('code')
|
||||
->orderBy('`order`')
|
||||
->fetchAll('id');
|
||||
}
|
||||
|
||||
@@ -461,7 +461,7 @@ class productModel extends model
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getStats($orderBy = 'code_asc', $pager = null)
|
||||
public function getStats($orderBy = 'order_asc', $pager = null)
|
||||
{
|
||||
$this->loadModel('report');
|
||||
$this->loadModel('story');
|
||||
|
||||
@@ -36,7 +36,9 @@
|
||||
<?php $vars = "locate=no&productID=$productID&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}";?>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class='w-20px sort-default'><?php common::printOrderLink('default', $orderBy, $vars, '<i></i>');?></th>
|
||||
<?php if(strpos($orderBy, 'order') !== false):?>
|
||||
<th class='w-20px sort-default'><?php common::printOrderLink('order', $orderBy, $vars, '<i></i>');?></th>
|
||||
<?php endif;?>
|
||||
<th class='w-id'><?php common::printOrderLink('id', $orderBy, $vars, $lang->idAB);?></th>
|
||||
<th><?php common::printOrderLink('name', $orderBy, $vars, $lang->product->name);?></th>
|
||||
<th class='w-80px'><?php echo $lang->story->statusList['active'] . $lang->story->common;?></th>
|
||||
@@ -54,7 +56,9 @@
|
||||
<tbody class='sortable' id='productTableList'>
|
||||
<?php foreach($productStats as $product):?>
|
||||
<tr class='text-center'>
|
||||
<?php if(strpos($orderBy, 'order') !== false):?>
|
||||
<td class='sort-handler'><i class="icon icon-ellipsis-v"></i></td>
|
||||
<?php endif;?>
|
||||
<td>
|
||||
<?php if($canBatchEdit):?>
|
||||
<input type='checkbox' name='productIDList[<?php echo $product->id;?>]' value='<?php echo $product->id;?>' />
|
||||
@@ -76,7 +80,7 @@
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan='12'>
|
||||
<td colspan='<?php echo strpos($orderBy, 'order') !== false ? 12 : 11?>'>
|
||||
<?php if($canBatchEdit and !empty($productStats)):?>
|
||||
<div class='table-actions clearfix'>
|
||||
<?php echo "<div class='btn-group'>" . html::selectButton() . '</div>';?>
|
||||
@@ -91,4 +95,5 @@
|
||||
</form>
|
||||
<?php endif;?>
|
||||
</div>
|
||||
<?php js::set('orderBy', $orderBy)?>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
|
||||
@@ -37,7 +37,7 @@ class project extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function index($locate = 'yes', $status = 'undone', $projectID = 0, $orderBy = 'code_asc', $recTotal = 0, $recPerPage = 10, $pageID = 1)
|
||||
public function index($locate = 'yes', $status = 'undone', $projectID = 0, $orderBy = 'order_asc', $recTotal = 0, $recPerPage = 10, $pageID = 1)
|
||||
{
|
||||
if($locate == 'yes') $this->locate($this->createLink('project', 'task'));
|
||||
|
||||
@@ -1692,7 +1692,7 @@ class project extends control
|
||||
$this->view->module = $module;
|
||||
$this->view->method = $method;
|
||||
$this->view->extra = $extra;
|
||||
$this->view->projects = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->in(array_keys($this->projects))->orderBy('code')->fetchAll();
|
||||
$this->view->projects = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->in(array_keys($this->projects))->orderBy('order')->fetchAll();
|
||||
$this->display();
|
||||
}
|
||||
|
||||
@@ -1708,7 +1708,7 @@ class project extends control
|
||||
*/
|
||||
public function ajaxGetMatchedItems($keywords, $module, $method, $extra)
|
||||
{
|
||||
$projects = $this->dao->select('*')->from(TABLE_PROJECT)->where('deleted')->eq(0)->andWhere('name')->like("%$keywords%")->orderBy('code')->fetchAll();
|
||||
$projects = $this->dao->select('*')->from(TABLE_PROJECT)->where('deleted')->eq(0)->andWhere('name')->like("%$keywords%")->orderBy('order')->fetchAll();
|
||||
foreach($projects as $key => $project)
|
||||
{
|
||||
if(!$this->project->checkPriv($project)) unset($projects[$key]);
|
||||
@@ -1719,4 +1719,25 @@ class project extends control
|
||||
$this->view->keywords = $keywords;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax order.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxOrder()
|
||||
{
|
||||
$idList = explode(',', trim($this->post->projects, ','));
|
||||
$orderBy = $this->post->orderBy;
|
||||
if(strpos($orderBy, 'order') === false) return false;
|
||||
|
||||
$projects = $this->dao->select('id,`order`')->from(TABLE_PROJECT)->where('id')->in($idList)->orderBy($orderBy)->fetchPairs('order', 'id');
|
||||
foreach($projects as $order => $id)
|
||||
{
|
||||
$newID = array_shift($idList);
|
||||
if($id == $newID) continue;
|
||||
$this->dao->update(TABLE_PROJECT)->set('`order`')->eq($order)->where('id')->eq($newID)->exec();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,5 +3,8 @@ $(function()
|
||||
$('#projectTableList').on('sort.sortable', function(e, data)
|
||||
{
|
||||
// TODO: save order to server.
|
||||
var list = '';
|
||||
for(i = 0; i < data.list.length; i++) list += $(data.list[i]).find('td').eq(1).find('input').val() + ',';
|
||||
$.post(createLink('project', 'ajaxOrder'), {'projects' : list, 'orderBy' : orderBy});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -547,7 +547,7 @@ class projectModel extends model
|
||||
->beginIF($status == 'undone')->andWhere('t2.status')->ne('done')->fi()
|
||||
->beginIF($status == 'isdoing')->andWhere('t2.status')->ne('done')->andWhere('t2.status')->ne('suspended')->fi()
|
||||
->beginIF($status != 'all' and $status != 'isdoing' and $status != 'undone')->andWhere('status')->in($status)->fi()
|
||||
->orderBy('code')
|
||||
->orderBy('order')
|
||||
->beginIF($limit)->limit($limit)->fi()
|
||||
->fetchAll('id');
|
||||
}
|
||||
@@ -558,7 +558,7 @@ class projectModel extends model
|
||||
->beginIF($status == 'isdoing')->andWhere('status')->ne('done')->andWhere('status')->ne('suspended')->fi()
|
||||
->beginIF($status != 'all' and $status != 'isdoing' and $status != 'undone')->andWhere('status')->in($status)->fi()
|
||||
->andWhere('deleted')->eq(0)
|
||||
->orderBy('code')
|
||||
->orderBy('order')
|
||||
->beginIF($limit)->limit($limit)->fi()
|
||||
->fetchAll('id');
|
||||
}
|
||||
@@ -612,7 +612,7 @@ class projectModel extends model
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function getProjectStats($status = 'undone', $productID = 0, $itemCounts = 30, $orderBy = 'code', $pager = null)
|
||||
public function getProjectStats($status = 'undone', $productID = 0, $itemCounts = 30, $orderBy = 'order', $pager = null)
|
||||
{
|
||||
/* Init vars. */
|
||||
$projects = $this->getList($status, 0, $productID);
|
||||
|
||||
@@ -30,7 +30,9 @@
|
||||
<?php $vars = "locate=no&status=$status&projectID=$projectID&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}";?>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class='w-20px sort-default'><?php common::printOrderLink('default', $orderBy, $vars, '<i></i>');?></th>
|
||||
<?php if(strpos($orderBy, 'order') !== false):?>
|
||||
<th class='w-20px sort-default'><?php common::printOrderLink('order', $orderBy, $vars, '<i></i>');?></th>
|
||||
<?php endif;?>
|
||||
<th class='w-id'><?php common::printOrderLink('id', $orderBy, $vars, $lang->idAB);?></th>
|
||||
<th><?php common::printOrderLink('name', $orderBy, $vars, $lang->project->name);?></th>
|
||||
<th class='w-100px'><?php common::printOrderLink('code', $orderBy, $vars, $lang->project->code);?></th>
|
||||
@@ -48,7 +50,9 @@
|
||||
<tbody class='sortable' id='projectTableList'>
|
||||
<?php foreach($projectStats as $project):?>
|
||||
<tr class='text-center'>
|
||||
<?php if(strpos($orderBy, 'order') !== false):?>
|
||||
<td class='sort-handler'><i class="icon icon-ellipsis-v"></i></td>
|
||||
<?php endif;?>
|
||||
<td>
|
||||
<?php if($canBatchEdit):?>
|
||||
<input type='checkbox' name='projectIDList[<?php echo $project->id;?>]' value='<?php echo $project->id;?>' />
|
||||
@@ -73,7 +77,7 @@
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan='12'>
|
||||
<td colspan='<?php echo strpos($orderBy, 'order') !== false ? 12 : 11?>'>
|
||||
<?php if($canBatchEdit and !empty($projectStats)):?>
|
||||
<div class='table-actions clearfix'>
|
||||
<?php echo "<div class='btn-group'>" . html::selectButton() . '</div>';?>
|
||||
@@ -87,4 +91,5 @@
|
||||
</table>
|
||||
</form>
|
||||
<script>$("#<?php echo $status;?>Tab").addClass('active');</script>
|
||||
<?php js::set('orderBy', $orderBy)?>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
|
||||
@@ -117,6 +117,9 @@ class upgradeModel extends model
|
||||
case '6_4':
|
||||
case '7_0':
|
||||
$this->execSQL($this->getUpgradeFile('7.0'));
|
||||
case '7_1':
|
||||
$this->execSQL($this->getUpgradeFile('7.1'));
|
||||
$this->initOrder();
|
||||
|
||||
default: if(!$this->isError()) $this->setting->updateVersion($this->config->version);
|
||||
}
|
||||
@@ -183,6 +186,7 @@ class upgradeModel extends model
|
||||
case '6_3':
|
||||
case '6_4':
|
||||
case '7_0': $confirmContent .= file_get_contents($this->getUpgradeFile('7.0'));
|
||||
case '7_1': $confirmContent .= file_get_contents($this->getUpgradeFile('7.1'));
|
||||
}
|
||||
return str_replace('zt_', $this->config->db->prefix, $confirmContent);
|
||||
}
|
||||
@@ -914,6 +918,25 @@ class upgradeModel extends model
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init order.
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function initOrder()
|
||||
{
|
||||
$dataList = $this->dao->select('id')->from(TABLE_PRODUCT)->orderBy('code_asc')->fetchAll();
|
||||
$i = 1;
|
||||
foreach($dataList as $data) $this->dao->update(TABLE_PRODUCT)->set('`order`')->eq($i++)->where('id')->eq($data->id)->exec();
|
||||
|
||||
$dataList = $this->dao->select('id')->from(TABLE_PROJECT)->orderBy('code_asc')->fetchAll();
|
||||
$i = 1;
|
||||
foreach($dataList as $data) $this->dao->update(TABLE_PROJECT)->set('`order`')->eq($i++)->where('id')->eq($data->id)->exec();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Judge any error occers.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user