* Add sort function for doclib.
This commit is contained in:
@@ -0,0 +1 @@
|
||||
ALTER TABLE `zt_doclib` ADD `order` tinyint(5) unsigned NOT NULL AFTER `main`;
|
||||
@@ -289,6 +289,7 @@ CREATE TABLE IF NOT EXISTS `zt_doclib` (
|
||||
`groups` varchar(255) NOT NULL,
|
||||
`users` text NOT NULL,
|
||||
`main` enum('0','1') NOT NULL default '0',
|
||||
`order` tinyint(5) unsigned NOT NULL,
|
||||
`deleted` enum('0','1') NOT NULL default '0',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
@@ -534,6 +534,25 @@ class doc extends control
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort doc lib.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function sort()
|
||||
{
|
||||
if($_POST)
|
||||
{
|
||||
foreach($_POST as $id => $order)
|
||||
{
|
||||
$this->dao->update(TABLE_DOCLIB)->set('order')->eq($order)->where('id')->eq($id)->exec();
|
||||
}
|
||||
if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
$this->send(array('result' => 'success'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax get modules by libID.
|
||||
*
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
.lib .file-icon{margin-bottom:5px;}
|
||||
.lib .lib-name{overflow: hidden; white-space: nowrap; text-overflow: ellipsis;}
|
||||
.lib:hover, .lib:focus, .lib:active {border-color: #2e6dad; background-color: #EBF2F9; color: #2e6dad}
|
||||
.lib .icon-move{display: none; position: relative; top: -10px; right : -70px;}
|
||||
.lib:hover .icon-move{display: inline-block; cursor: move;}
|
||||
.w-lib-p100{width:100%;}
|
||||
.w-lib-p50{width:45%;}
|
||||
.w-lib-p33{width:30%;}
|
||||
|
||||
@@ -225,4 +225,34 @@ $(document).ready(function()
|
||||
$('[data-id="create"] a').modalTrigger({type: 'iframe', width: 800});
|
||||
$('#modulemenu .nav li').removeClass('active');
|
||||
if(typeof(type) != 'undefined') $('#modulemenu .nav li[data-id="' + type + '"]').addClass('active');
|
||||
|
||||
$('.libs-group').sortable(
|
||||
{
|
||||
trigger: '.icon-move',
|
||||
selector: '.lib',
|
||||
finish: function()
|
||||
{
|
||||
var orders = {};
|
||||
var orderNext = 1;
|
||||
|
||||
$('.libs-group .lib').not('.files').not('.addbtn').each(function()
|
||||
{
|
||||
orders[$(this).data('id')] = orderNext ++;
|
||||
})
|
||||
|
||||
$.post(createLink('doc', 'sort'), orders, function(data)
|
||||
{
|
||||
if(data.result == 'success')
|
||||
{
|
||||
return location.reload();
|
||||
}
|
||||
else
|
||||
{
|
||||
alert(data.message);
|
||||
return location.reload();
|
||||
}
|
||||
}, 'json');
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -118,12 +118,12 @@ class docModel extends model
|
||||
->leftJoin($table)->alias('t2')->on("t1.$type=t2.id")
|
||||
->where("t1.$type")->ne(0)
|
||||
->andWhere('t1.deleted')->eq(0)
|
||||
->orderBy("t2.order desc, t1.id")
|
||||
->orderBy("t2.order desc, t1.order, t1.id")
|
||||
->query();
|
||||
}
|
||||
else
|
||||
{
|
||||
$stmt = $this->dao->select('*')->from(TABLE_DOCLIB)->where('deleted')->eq(0)->andWhere('product')->eq('0')->andWhere('project')->eq(0)->orderBy('id desc')->query();
|
||||
$stmt = $this->dao->select('*')->from(TABLE_DOCLIB)->where('deleted')->eq(0)->andWhere('product')->eq('0')->andWhere('project')->eq(0)->orderBy('`order`, id desc')->query();
|
||||
}
|
||||
|
||||
$libPairs = array();
|
||||
@@ -654,7 +654,7 @@ class docModel extends model
|
||||
}
|
||||
else
|
||||
{
|
||||
$libs = $this->dao->select('id,name')->from(TABLE_DOCLIB)->where('id')->in($idList)->orderBy('id desc')->fetchAll('id');
|
||||
$libs = $this->dao->select('id,name')->from(TABLE_DOCLIB)->where('id')->in($idList)->orderBy('`order`, id desc')->fetchAll('id');
|
||||
}
|
||||
|
||||
return $libs;
|
||||
@@ -672,7 +672,7 @@ class docModel extends model
|
||||
$stmt = $this->dao->select("id,product,project,name")->from(TABLE_DOCLIB)
|
||||
->where('deleted')->eq(0)
|
||||
->beginIF($condition)->andWhere("($condition)")->fi()
|
||||
->orderBy("product desc,project desc, id asc")
|
||||
->orderBy("product desc,project desc, `order` asc, id asc")
|
||||
->query();
|
||||
|
||||
$customLibs = array();
|
||||
@@ -753,12 +753,12 @@ class docModel extends model
|
||||
$stmt = $this->dao->select('t1.*')->from(TABLE_DOCLIB)->alias('t1')
|
||||
->leftJoin($table)->alias('t2')->on("t1.$type=t2.id")
|
||||
->where('t1.deleted')->eq(0)->andWhere("t1.$type")->ne(0)
|
||||
->orderBy("t2.`order` desc, id desc")
|
||||
->orderBy("t2.`order` desc, t1.`order` asc, id desc")
|
||||
->query();
|
||||
}
|
||||
else
|
||||
{
|
||||
$stmt = $this->dao->select('*')->from(TABLE_DOCLIB)->where('deleted')->eq(0)->andWhere('project')->eq(0)->andWhere('product')->eq(0)->orderBy('id desc')->query();
|
||||
$stmt = $this->dao->select('*')->from(TABLE_DOCLIB)->where('deleted')->eq(0)->andWhere('project')->eq(0)->andWhere('product')->eq(0)->orderBy('`order`, id desc')->query();
|
||||
}
|
||||
|
||||
$i = 1;
|
||||
@@ -791,7 +791,7 @@ class docModel extends model
|
||||
public function getSubLibGroups($type, $idList)
|
||||
{
|
||||
if($type != 'product' and $type != 'project') return false;
|
||||
$libGroups = $this->dao->select('*')->from(TABLE_DOCLIB)->where('deleted')->eq(0)->andWhere($type)->in($idList)->orderBy('id')->fetchGroup($type, 'id');
|
||||
$libGroups = $this->dao->select('*')->from(TABLE_DOCLIB)->where('deleted')->eq(0)->andWhere($type)->in($idList)->orderBy('`order`, id')->fetchGroup($type, 'id');
|
||||
if($type == 'product')
|
||||
{
|
||||
$hasProject = $this->dao->select('DISTINCT product')->from(TABLE_PROJECTPRODUCT)->alias('t1')
|
||||
@@ -826,7 +826,7 @@ class docModel extends model
|
||||
public function getLibsByObject($type, $objectID, $mode = '')
|
||||
{
|
||||
if($type != 'product' and $type != 'project') return false;
|
||||
$objectLibs = $this->dao->select('*')->from(TABLE_DOCLIB)->where('deleted')->eq(0)->andWhere($type)->eq($objectID)->orderBy('id')->fetchAll('id');
|
||||
$objectLibs = $this->dao->select('*')->from(TABLE_DOCLIB)->where('deleted')->eq(0)->andWhere($type)->eq($objectID)->orderBy('`order`, id')->fetchAll('id');
|
||||
if($type == 'product')
|
||||
{
|
||||
$hasProject = $this->dao->select('DISTINCT product')->from(TABLE_PROJECTPRODUCT)->alias('t1')
|
||||
|
||||
@@ -52,9 +52,10 @@
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class='clearfix'>
|
||||
<div class='clearfix libs-group'>
|
||||
<?php foreach($libs as $lib):?>
|
||||
<a class='lib lib-custom' title='<?php echo $lib->name?>' href='<?php echo inlink('browse', "libID=$lib->id") ?>'>
|
||||
<a class='lib lib-custom' title='<?php echo $lib->name?>' href='<?php echo inlink('browse', "libID=$lib->id") ?>' data-id='<?php echo $lib->id;?>'>
|
||||
<i class='icon icon-move'></i>
|
||||
<img src='<?php echo $config->webRoot . 'theme/default/images/main/doc-lib.png'?>' class='file-icon' />
|
||||
<div class='lib-name' title='<?php echo $lib->name?>'><?php echo $lib->name?></div>
|
||||
</a>
|
||||
|
||||
@@ -25,7 +25,8 @@
|
||||
if($libID == 'project') $libLink = inlink('allLibs', "type=project&product=$object->id");
|
||||
if($libID == 'files') $libLink = inlink('showFiles', "type=$type&objectID=$object->id");
|
||||
?>
|
||||
<a class='lib' title='<?php echo $libName?>' href='<?php echo $libLink?>'>
|
||||
<a class='lib <?php echo $libID == 'files' ? 'files' : '';?>' title='<?php echo $libName?>' href='<?php echo $libLink?>' data-id='<?php echo $libID;?>'>
|
||||
<?php if($libID != 'files'):?><i class='icon icon-move'></i><?php endif;?>
|
||||
<img src='<?php echo $config->webRoot . 'theme/default/images/main/doc-lib.png'?>' class='file-icon' />
|
||||
<div class='lib-name' title='<?php echo $libName?>'><?php echo $libName?></div>
|
||||
</a>
|
||||
|
||||
Reference in New Issue
Block a user