* Adjust the doc module code.
This commit is contained in:
@@ -53,13 +53,14 @@ class doc extends control
|
||||
$actionURL = $this->createLink('doc', 'browse', "lib=0&browseType=bySearch&queryID=myQueryID");
|
||||
$this->doc->buildSearchForm(0, array(), 0, $actionURL, 'index');
|
||||
|
||||
$this->view->title = $this->lang->doc->common . $this->lang->colon . $this->lang->doc->index;
|
||||
$this->view->position[] = $this->lang->doc->index;
|
||||
$this->view->title = $this->lang->doc->common . $this->lang->colon . $this->lang->doc->index;
|
||||
$this->view->position[] = $this->lang->doc->index;
|
||||
|
||||
$this->view->latestEditedDocs = $this->loadModel('doc')->getDocsByBrowseType(0, 'byediteddate', 0, 0, 'editedDate_desc, id_desc', $pager);
|
||||
$this->view->myDocs = $this->loadModel('doc')->getDocsByBrowseType(0, 'openedbyme', 0, 0, 'addedDate_desc', $pager);
|
||||
$this->view->statisticInfo = $this->doc->getStatisticInfo();
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noletter');
|
||||
$this->view->doingProjects = $this->loadModel('project')->getList('undone', 5);
|
||||
$this->view->doingProjects = $this->loadModel('project')->getProjectsByProgram($this->session->PRJ, 'undone', 5);
|
||||
|
||||
$this->display();
|
||||
}
|
||||
@@ -222,9 +223,12 @@ class doc extends control
|
||||
echo js::error(dao::getError());
|
||||
}
|
||||
}
|
||||
|
||||
$programID = $this->session->PRJ;
|
||||
$products = $this->product->getProductsByProject($programID, 'noclosed');
|
||||
$projects = $this->project->getPairs('nocode', $programID);
|
||||
|
||||
$libTypeList = $this->lang->doc->libTypeList;
|
||||
$products = $this->product->getPairs('nocode');
|
||||
$projects = $this->project->getPairs('nocode', $this->session->PRJ);
|
||||
if(empty($products)) unset($libTypeList['product']);
|
||||
if(empty($projects)) unset($libTypeList['project']);
|
||||
|
||||
|
||||
+22
-9
@@ -139,12 +139,17 @@ class docModel extends model
|
||||
*/
|
||||
public function getLibs($type = '', $extra = '', $appendLibs = '')
|
||||
{
|
||||
$projectID = $this->session->PRJ;
|
||||
if($type == 'product' or $type == 'project')
|
||||
{
|
||||
$idList = array();
|
||||
if($type == 'product') $idList = $this->loadModel('product')->getProductIDByProject($projectID, false);
|
||||
if($type == 'project') $idList = $this->loadModel('project')->getProjectIDByProgram($projectID);
|
||||
|
||||
$table = $type == 'product' ? TABLE_PRODUCT : TABLE_PROJECT;
|
||||
$stmt = $this->dao->select('t1.*')->from(TABLE_DOCLIB)->alias('t1')
|
||||
->leftJoin($table)->alias('t2')->on("t1.$type=t2.id")
|
||||
->where("t1.$type")->ne(0)
|
||||
->beginIF(!empty($idList))->andWhere('t2.id')->in($idList)->fi()
|
||||
->beginIF($type == 'project' and strpos($this->config->doc->custom->showLibs, 'unclosed') !== false)->andWhere('t2.status')->notin('done,closed')->fi()
|
||||
->andWhere('t1.deleted')->eq(0)
|
||||
->orderBy("t2.order desc, t1.order, t1.id")
|
||||
@@ -153,17 +158,19 @@ class docModel extends model
|
||||
elseif($type == 'all')
|
||||
{
|
||||
/* If extra have unclosedProject then ignore unclosed project libs. */
|
||||
$unclosedProjects = array();
|
||||
if(strpos($extra, 'unclosedProject') !== false) $unclosedProjects = $this->dao->select('id')->from(TABLE_PROJECT)->where('deleted')->eq(0)->andWhere('status')->notin('done,closed')->fetchPairs('id', 'id');
|
||||
$status = (strpos($extra, 'unclosedProject') !== false) ? 'undone' : 'all';
|
||||
$projects = $this->loadModel('project')->getProjectIDByProgram($projectID, $status);
|
||||
$products = $this->loadModel('product')->getProductIDByProject($projectID, false);
|
||||
|
||||
$stmt = $this->dao->select('*')->from(TABLE_DOCLIB)
|
||||
->where('deleted')->eq(0)
|
||||
->beginIF(strpos($extra, 'unclosedProject') !== false)
|
||||
->andWhere('project', true)->eq('0')
|
||||
->orWhere('project')->in($unclosedProjects)
|
||||
->andWhere()
|
||||
->markLeft(1)
|
||||
->where('`type`')->eq('custom')
|
||||
->orWhere('project')->in($projects)
|
||||
->orWhere('product')->in($products)
|
||||
->markRight(1)
|
||||
->fi()
|
||||
->orderBy('`order`,id desc')
|
||||
->orderBy('id_desc')
|
||||
->query();
|
||||
}
|
||||
else
|
||||
@@ -176,7 +183,7 @@ class docModel extends model
|
||||
|
||||
if(strpos($extra, 'withObject') !== false)
|
||||
{
|
||||
$products = $this->loadModel('product')->getPairs('', $this->session->PRJ);
|
||||
$products = $this->loadModel('product')->getProductsByProject($this->session->PRJ);
|
||||
$projects = $this->loadModel('project')->getPairs('', $this->session->PRJ);
|
||||
}
|
||||
|
||||
@@ -1098,10 +1105,16 @@ class docModel extends model
|
||||
$nonzeroLibs = $this->dao->select('lib,count(*) as count')->from(TABLE_DOC)->where('deleted')->eq('0')->groupBy('lib')->having('count')->ne(0)->fetchPairs('lib', 'lib');
|
||||
}
|
||||
|
||||
$idList = array();
|
||||
$projectID = $this->session->PRJ;
|
||||
if($type == 'product') $idList = $this->loadModel('product')->getProductIDByProject($projectID, false);
|
||||
if($type == 'project') $idList = $this->loadModel('project')->getProjectIDByProgram($projectID);
|
||||
|
||||
$table = $type == 'product' ? TABLE_PRODUCT : TABLE_PROJECT;
|
||||
$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)
|
||||
->beginIF(!empty($idList))->andWhere('t2.id')->in($idList)->fi()
|
||||
->beginIF($type == 'project' and strpos($this->config->doc->custom->showLibs, 'unclosed') !== false)->andWhere('t2.status')->notin('done,closed')->fi()
|
||||
->beginIF(strpos($this->config->doc->custom->showLibs, 'zero') === false)->andWhere('t1.id')->in($nonzeroLibs)->fi()
|
||||
->orderBy("t2.`order` desc, t1.`order` asc, id desc")
|
||||
|
||||
@@ -141,7 +141,7 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($doingProjects as $project):?>
|
||||
<tr data-url="<?php echo $this->createLink('doc', 'objectLibs', "type=project&objectID={$project->id}")?>">
|
||||
<tr data-url="<?php echo $this->createLink('doc', 'objectLibs', "type=project&objectID={$project->id}&programID=$programID")?>">
|
||||
<td class="c-name"><i class="icon icon-folder text-yellow"></i> <?php echo $project->name;?></td>
|
||||
<td class="c-datetime"><?php echo formatTime($project->begin);?></td>
|
||||
<td class="c-datetime"><?php echo formatTime($project->end);?></td>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
$sideLibs = array();
|
||||
foreach($lang->doclib->tabList as $libType => $typeName) $sideLibs[$libType] = $this->doc->getLimitLibs($libType);
|
||||
foreach($lang->doclib->tabList as $libType => $typeName) $sideLibs[$libType] = $this->doc->getLimitLibs($libType, 0, $this->session->PRJ);
|
||||
$allModules = $this->loadModel('tree')->getDocStructure();
|
||||
|
||||
$sideSubLibs = array();
|
||||
|
||||
@@ -313,13 +313,14 @@ class productModel extends model
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getProductsByProject($projectID)
|
||||
public function getProductsByProject($projectID, $status = 'all')
|
||||
{
|
||||
return $this->dao->select('t1.product, t2.name')
|
||||
->from(TABLE_PROJECTPRODUCT)->alias('t1')
|
||||
->leftJoin(TABLE_PRODUCT)->alias('t2')
|
||||
->on('t1.product = t2.id')
|
||||
->where('t1.project')->eq($projectID)
|
||||
->beginIF(strpos($status, 'noclosed') !== false)->andWhere('status')->ne('closed')->fi()
|
||||
->andWhere('t2.deleted')->eq(0)
|
||||
->orderBy('t2.order desc')
|
||||
->fetchPairs();
|
||||
@@ -329,13 +330,14 @@ class productModel extends model
|
||||
* Get product id by project.
|
||||
*
|
||||
* @param int $projectID
|
||||
* @param int $backFirst
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getProductIDByProject($projectID)
|
||||
public function getProductIDByProject($projectID, $backFirst = true)
|
||||
{
|
||||
$products = $this->dao->select('product')->from(TABLE_PROJECTPRODUCT)->where('project')->eq($projectID)->fetchPairs();
|
||||
|
||||
if($backFirst === false) return $products;
|
||||
return empty($products) ? 0 : current($products);
|
||||
}
|
||||
|
||||
|
||||
@@ -503,6 +503,7 @@ class programplanModel extends model
|
||||
|
||||
$this->loadModel('user');
|
||||
$this->loadModel('project');
|
||||
$this->app->loadLang('doc');
|
||||
$account = $this->app->user->account;
|
||||
$now = helper::now();
|
||||
foreach($datas as $data)
|
||||
@@ -566,6 +567,15 @@ class programplanModel extends model
|
||||
$stageID = $this->dao->lastInsertID();
|
||||
$this->dao->update(TABLE_PROJECT)->set('`order`')->eq($stageID * 5)->where('id')->eq($stageID)->exec();
|
||||
|
||||
/* Create doc lib. */
|
||||
$lib = new stdclass();
|
||||
$lib->project = $stageID;
|
||||
$lib->name = $this->lang->doclib->main['project'];
|
||||
$lib->type = 'project';
|
||||
$lib->main = '1';
|
||||
$lib->acl = 'default';
|
||||
$this->dao->insert(TABLE_DOCLIB)->data($lib)->exec();
|
||||
|
||||
/* Add creators to stage teams and project teams. */
|
||||
$member = new stdclass();
|
||||
$member->root = $stageID;
|
||||
|
||||
@@ -2317,14 +2317,13 @@ class project extends control
|
||||
public function ajaxGetDropMenu($projectID, $module, $method, $extra)
|
||||
{
|
||||
$project = $this->project->getByID($projectID);
|
||||
$program = $this->project->getByID($project->project);
|
||||
|
||||
$this->view->link = $this->project->getProjectLink($module, $method, $extra);
|
||||
$this->view->projectID = $projectID;
|
||||
$this->view->module = $module;
|
||||
$this->view->method = $method;
|
||||
$this->view->extra = $extra;
|
||||
$this->view->projects = $this->project->getProjectsByProgram($program);
|
||||
$this->view->projects = $this->project->getProjectsByProgram($project->project);
|
||||
$this->display();
|
||||
}
|
||||
|
||||
|
||||
+34
-10
@@ -861,23 +861,47 @@ class projectModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* Get projects by program.
|
||||
* Get project id by program.
|
||||
*
|
||||
* @param object $program
|
||||
* @param int $programID
|
||||
* @param int $status
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getProjectsByProgram($program)
|
||||
public function getProjectIDByProgram($programID, $status = 'all')
|
||||
{
|
||||
$projects = $this->dao->select('t1.*,t2.product as productID')->from(TABLE_PROJECT)->alias('t1')
|
||||
->leftJoin(TABLE_PROJECTPRODUCT)->alias('t2')->on('t1.id=t2.project')
|
||||
->where('t1.project')->eq((int)$program->id)
|
||||
->beginIF(!$this->app->user->admin)->andWhere('t1.id')->in($this->app->user->view->sprints)->fi()
|
||||
->andWhere('t1.deleted')->eq('0')
|
||||
->orderBy('t1.id_desc')
|
||||
return $this->dao->select('id')->from(TABLE_PROJECT)
|
||||
->where('project')->eq($programID)
|
||||
->beginIF($status == 'undone')->andWhere('status')->notIN('done,closed')->fi()
|
||||
->beginIF($status != 'all' and $status != 'undone')->andWhere('status')->in($status)->fi()
|
||||
->andWhere('deleted')->eq('0')
|
||||
->fetchPairs('id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get projects by program.
|
||||
*
|
||||
* @param int $programID
|
||||
* @param string $status
|
||||
* @param int $limit
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getProjectsByProgram($programID, $status = 'all', $limit = 0)
|
||||
{
|
||||
$program = $this->getByID($programID);
|
||||
if(empty($program)) return array();
|
||||
|
||||
$projects = $this->dao->select('*')->from(TABLE_PROJECT)
|
||||
->where('project')->eq((int)$program->id)
|
||||
->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->sprints)->fi()
|
||||
->beginIF($status == 'undone')->andWhere('status')->notIN('done,closed')->fi()
|
||||
->beginIF($status != 'all' and $status != 'undone')->andWhere('status')->in($status)->fi()
|
||||
->andWhere('deleted')->eq('0')
|
||||
->orderBy('id_desc')
|
||||
->beginIF($limit)->limit($limit)->fi()
|
||||
->fetchAll('id');
|
||||
|
||||
/* The waterfall model displays hierarchies and associated products. */
|
||||
if($program->model == 'waterfall')
|
||||
{
|
||||
foreach($projects as $projectID => $project)
|
||||
|
||||
Reference in New Issue
Block a user