This commit is contained in:
wangyidong
2015-12-22 16:55:25 +08:00
parent b6e4fc2e41
commit 1e3c913063
6 changed files with 30 additions and 11 deletions

View File

@@ -534,7 +534,7 @@ class dao
* @access public
* @return object the dao object self.
*/
public function page($pager)
public function page($pager, $distinctField = '')
{
if(!is_object($pager)) return $this;
@@ -542,11 +542,12 @@ class dao
if($pager->recTotal == 0)
{
/* Get the SELECT, FROM position, thus get the fields, replace it by count(*). */
$sql = $this->get();
$selectPOS = strpos($sql, 'SELECT') + strlen('SELECT');
$fromPOS = strpos($sql, 'FROM');
$fields = substr($sql, $selectPOS, $fromPOS - $selectPOS );
$sql = str_replace($fields, ' COUNT(*) AS recTotal ', $sql);
$sql = $this->get();
$selectPOS = strpos($sql, 'SELECT') + strlen('SELECT');
$fromPOS = strpos($sql, 'FROM');
$fields = substr($sql, $selectPOS, $fromPOS - $selectPOS );
$countField = $distinctField ? 'distinct ' . $distinctField : '*';
$sql = str_replace($fields, " COUNT($countField) AS recTotal ", $sql);
/* Remove the part after order and limit. */
$subLength = strlen($sql);

View File

@@ -307,6 +307,20 @@ class doc extends control
$moduleOptionMenu = $this->tree->getOptionMenu($libID, 'customdoc', $startModuleID = 0);
}
$products = $projectID == 0 ? $this->product->getPairs() : $this->project->getProducts($projectID, false);
if($libID == 'product' and empty($products))
{
echo js::alert($this->lang->doc->errorEmptyProduct);
die(js::locate('back'));
}
$projects = $this->project->getPairs('all');
if($libID == 'project' and ($projects))
{
echo js::alert($this->lang->doc->errorEmptyProject);
die(js::locate('back'));
}
$this->view->title = $this->libs[$libID] . $this->lang->colon . $this->lang->doc->create;
$this->view->position[] = html::a($this->createLink('doc', 'browse', "libID=$libID"), $this->libs[$libID]);
$this->view->position[] = $this->lang->doc->create;
@@ -316,8 +330,8 @@ class doc extends control
$this->view->moduleID = $moduleID;
$this->view->productID = $productID;
$this->view->projectID = $projectID;
$this->view->products = $projectID == 0 ? $this->product->getPairs() : $this->project->getProducts($projectID, false);
$this->view->projects = $this->loadModel('project')->getPairs('all');
$this->view->products = $products;
$this->view->projects = $projects;
$this->display();
}

View File

@@ -67,6 +67,8 @@ $lang->doc->types['text'] = 'Html';
$lang->doc->confirmDelete = "Are you sure to delete this doc?";
$lang->doc->confirmDeleteLib = " Are you sure to delete this doc library?";
$lang->doc->errorEditSystemDoc = "System doc library needn't edit";
$lang->doc->errorEmptyProduct = "{$lang->productCommon} is empty, can not create doc.";
$lang->doc->errorEmptyProject = "{$lang->projectCommon} is empty, can not create doc.";
$lang->doc->placeholder = new stdclass();
$lang->doc->placeholder->url = 'url';

View File

@@ -67,6 +67,8 @@ $lang->doc->types['text'] = '网页';
$lang->doc->confirmDelete = "您确定删除该文档吗?";
$lang->doc->confirmDeleteLib = "您确定删除该文档库吗?";
$lang->doc->errorEditSystemDoc = "系统文档库无需修改。";
$lang->doc->errorEmptyProduct = "没有{$lang->productCommon},无法创建文档";
$lang->doc->errorEmptyProject = "没有{$lang->projectCommon},无法创建文档";
$lang->doc->placeholder = new stdclass();
$lang->doc->placeholder->url = '相应的链接地址';

View File

@@ -1311,7 +1311,7 @@ class storyModel extends model
public function getProjectStories($projectID = 0, $orderBy = 'pri_asc,id_desc', $type = 'byModule', $param = 0, $pager = null)
{
$modules = ($type == 'byModule' and $param) ? $this->dao->select('*')->from(TABLE_MODULE)->where('path')->like("%,$param,%")->andWhere('type')->eq('story')->fetchPairs('id', 'id') : array();
$stories = $this->dao->select('t1.*, t2.*,t3.branch as productBranch,t4.type as productType, t2.version as version')->from(TABLE_PROJECTSTORY)->alias('t1')
$stories = $this->dao->select('distinct t1.*, t2.*,t3.branch as productBranch,t4.type as productType,t2.version as version')->from(TABLE_PROJECTSTORY)->alias('t1')
->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story = t2.id')
->leftJoin(TABLE_PROJECTPRODUCT)->alias('t3')->on('t1.project = t3.project')
->leftJoin(TABLE_PRODUCT)->alias('t4')->on('t2.product = t4.id')
@@ -1321,7 +1321,7 @@ class storyModel extends model
->beginIF($type == 'byModule' and $param)->andWhere('t2.module')->in($modules)->fi()
->andWhere('t2.deleted')->eq(0)
->orderBy($orderBy)
->page($pager)
->page($pager, 't2.id')
->fetchAll('id');
$query = $this->dao->get();

View File

@@ -1379,7 +1379,7 @@ function fixedTfootAction(formID)
var tfootOffset = $tfoot.offset().top + 30;
var windowH = $(window).height();
var tableWidth = $table.width();
if(tfootOffset > windowH)
if(tfootOffset > windowH + $(window).scrollTop())
{
$tfoot.addClass('fixedTfootAction');
$tfoot.width(tableWidth);