diff --git a/module/block/control.php b/module/block/control.php index 671ae36898..b8665325e9 100644 --- a/module/block/control.php +++ b/module/block/control.php @@ -741,29 +741,20 @@ class block extends control if(!empty($this->params->type) and preg_match('/[^a-zA-Z0-9_]/', $this->params->type)) die(); $status = isset($this->params->type) ? $this->params->type : ''; - $orderBy = isset($this->params->orderBy) ? $this->params->orderBy : 'id_asc'; - /* Get products. */ - $products = $this->loadModel('product')->getList($status); - foreach($products as $productID => $product) - { - if(!$this->product->checkPriv($product)) unset($products[$productID]); - } - $productIDList = array_keys($products); - if(!$productIDList) + $products = $this->block->getProductsLikeDropMenu($status); + $productIdList = array_keys($products); + + if(empty($products)) { $this->view->products = $products; return false; } - $products = $this->dao->select('*')->from(TABLE_PRODUCT) - ->where('id')->in($productIDList) - ->orderBy($orderBy) - ->fetchAll('id'); /* Get stories. */ $stories = $this->dao->select('product, stage, COUNT(status) AS count')->from(TABLE_STORY) ->where('deleted')->eq(0) - ->andWhere('product')->in($productIDList) + ->andWhere('product')->in($productIdList) ->groupBy('product, stage') ->fetchGroup('product', 'stage'); /* Padding the stories to sure all status have records. */ @@ -779,7 +770,7 @@ class block extends control /* Get plans. */ $plans = $this->dao->select('product, end')->from(TABLE_PRODUCTPLAN) ->where('deleted')->eq(0) - ->andWhere('product')->in($productIDList) + ->andWhere('product')->in($productIdList) ->fetchGroup('product'); foreach($plans as $product => $productPlans) { @@ -802,7 +793,7 @@ class block extends control /* Get projects. */ $projects = $this->dao->select('t1.product, t2.status, t2.end')->from(TABLE_PROJECTPRODUCT)->alias('t1') ->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project=t2.id') - ->where('t1.product')->in($productIDList) + ->where('t1.product')->in($productIdList) ->andWhere('t2.deleted')->eq(0) ->fetchGroup('product'); foreach($projects as $product => $productProjects) @@ -829,7 +820,7 @@ class block extends control /* Get releases. */ $releases = $this->dao->select('product, status, COUNT(*) AS count')->from(TABLE_RELEASE) ->where('deleted')->eq(0) - ->andWhere('product')->in($productIDList) + ->andWhere('product')->in($productIdList) ->groupBy('product, status') ->fetchGroup('product', 'status'); foreach($releases as $product => $release) @@ -843,7 +834,7 @@ class block extends control /* Get last releases. */ $lastReleases = $this->dao->select('product, COUNT(*) AS count')->from(TABLE_RELEASE) ->where('date')->eq(date('Y-m-d', strtotime('-1 day'))) - ->andWhere('product')->in($productIDList) + ->andWhere('product')->in($productIdList) ->groupBy('product') ->fetchPairs(); @@ -879,33 +870,23 @@ class block extends control $this->app->loadLang('bug'); $status = isset($this->params->type) ? $this->params->type : ''; - $orderBy = isset($this->params->orderBy) ? $this->params->orderBy : 'id_asc'; $num = isset($this->params->num) ? (int)$this->params->num : 0; /* Get projects. */ - $projects = $this->loadModel('project')->getList($status); - foreach($projects as $projectID => $project) - { - if(!$this->project->checkPriv($project)) unset($projects[$projectID]); - } - $projectIDList = array_keys($projects); - if(!$projectIDList) + $projects = $this->block->getProjectsLikeDropMenu($status); + if(empty($projects)) { $this->view->projects = $projects; return false; } - $projects = $this->dao->select('*')->from(TABLE_PROJECT) - ->where('id')->in($projectIDList) - ->orderBy($orderBy) - ->beginIF($this->viewType != 'json')->limit($num)->fi() - ->fetchAll('id'); - $projectIDList = array_keys($projects); + + $projectIdList = array_keys($projects); /* Get tasks. */ $yesterday = date('Y-m-d', strtotime('-1 day')); $tasks = $this->dao->select("project, count(id) as totalTasks, count(status in ('wait','doing','pause') or null) as undoneTasks, count(finishedDate like '{$yesterday}%' or null) as yesterdayFinished, sum(if(status != 'cancel', estimate, 0)) as totalEstimate, sum(consumed) as totalConsumed, sum(if(status != 'cancel', `left`, 0)) as totalLeft")->from(TABLE_TASK) - ->where('project')->in($projectIDList) + ->where('project')->in($projectIdList) ->andWhere('deleted')->eq(0) ->andWhere('parent')->eq(0) ->groupBy('project') @@ -923,7 +904,7 @@ class block extends control /* Get stories. */ $stories = $this->dao->select("t1.project, count(t2.status) as totalStories, count(t2.status != 'closed' or null) as unclosedStories, count(t2.stage = 'released' or null) as releasedStories")->from(TABLE_PROJECTSTORY)->alias('t1') ->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story = t2.id') - ->where('t1.project')->in($projectIDList) + ->where('t1.project')->in($projectIdList) ->andWhere('t2.deleted')->eq(0) ->groupBy('project') ->fetchAll('project'); @@ -939,7 +920,7 @@ class block extends control /* Get bugs. */ $bugs = $this->dao->select("project, status, count(status) as totalBugs, count(status = 'active' or null) as activeBugs, count(resolvedDate like '{$yesterday}%' or null) as yesterdayResolved")->from(TABLE_BUG) - ->where('project')->in($projectIDList) + ->where('project')->in($projectIdList) ->andWhere('deleted')->eq(0) ->groupBy('project') ->fetchAll('project'); @@ -997,24 +978,15 @@ class block extends control if(!empty($this->params->type) and preg_match('/[^a-zA-Z0-9_]/', $this->params->type)) die(); $status = isset($this->params->type) ? $this->params->type : ''; - $orderBy = isset($this->params->orderBy) ? $this->params->orderBy : 'id_asc'; - /* Get products. */ - $products = $this->loadModel('product')->getList($status); - foreach($products as $productID => $product) - { - if(!$this->product->checkPriv($product)) unset($products[$productID]); - } - $productIDList = array_keys($products); - if(!$productIDList) + $products = $this->block->getProductsLikeDropMenu($status); + $productIdList = array_keys($products); + + if(empty($products)) { $this->view->products = $products; return false; } - $products = $this->dao->select('*')->from(TABLE_PRODUCT) - ->where('id')->in($productIDList) - ->orderBy($orderBy) - ->fetchAll('id'); $testedBuilds = $this->dao->select('build')->from(TABLE_TESTTASK)->where('product')->in(array_keys($products))->andWhere('project')->ne(0)->andWhere('deleted')->eq(0)->fetchPairs(); $builds = $this->dao->select('id, product, name, bugs')->from(TABLE_BUILD)->where('id')->in($testedBuilds)->andWhere('deleted')->eq(0)->fetchGroup('product', 'id'); diff --git a/module/block/model.php b/module/block/model.php index 6bfa893c47..c57e60d91c 100644 --- a/module/block/model.php +++ b/module/block/model.php @@ -471,11 +471,6 @@ class blockModel extends model $params->type['options'] = $this->lang->block->typeList->product; $params->type['control'] = 'select'; - $params->orderBy['name'] = $this->lang->block->orderBy; - $params->orderBy['default'] = 'id_desc'; - $params->orderBy['options'] = $this->lang->block->orderByList->product; - $params->orderBy['control'] = 'select'; - return json_encode($params); } @@ -492,11 +487,6 @@ class blockModel extends model $params->type['options'] = $this->lang->block->typeList->project; $params->type['control'] = 'select'; - $params->orderBy['name'] = $this->lang->block->orderBy; - $params->orderBy['default'] = 'id_desc'; - $params->orderBy['options'] = $this->lang->block->orderByList->project; - $params->orderBy['control'] = 'select'; - return json_encode($params); } @@ -513,11 +503,6 @@ class blockModel extends model $params->type['options'] = $this->lang->block->typeList->product; $params->type['control'] = 'select'; - $params->orderBy['name'] = $this->lang->block->orderBy; - $params->orderBy['default'] = 'id_desc'; - $params->orderBy['options'] = $this->lang->block->orderByList->product; - $params->orderBy['control'] = 'select'; - return json_encode($params); } @@ -645,4 +630,88 @@ class blockModel extends model return $key == $hash; } + + /** + * Get products like drop menu order + * + * @param strint $status + * @access public + * @return array + */ + public function getProductsLikeDropMenu($status) + { + $products = $this->loadModel('product')->getList($status); + if(empty($products)) return $products; + + $lines = $this->loadModel('tree')->getLinePairs(); + $productList = array(); + foreach($lines as $id => $name) + { + foreach($products as $key => $product) + { + if($product->line == $id) + { + $product->name = $name . '/' . $product->name; + $productList[] = $product; + unset($products[$key]); + } + } + } + $productList = array_merge($productList, $products); + + $products = $mineProducts = $otherProducts = $closedProducts = array(); + foreach($productList as $product) + { + if(!$this->app->user->admin and !$this->product->checkPriv($product)) continue; + if($product->status == 'normal' and $product->PO == $this->app->user->account) + { + $mineProducts[$product->id] = $product; + } + elseif($product->status == 'normal' and $product->PO != $this->app->user->account) + { + $otherProducts[$product->id] = $product; + } + elseif($product->status == 'closed') + { + $closedProducts[$product->id] = $product; + } + } + $products = $mineProducts + $otherProducts + $closedProducts; + + return $products; + } + + /** + * Get projects like drop menu order + * + * @param string $status + * @access public + * @return array + */ + public function getProjectsLikeDropMenu($status) + { + $projectList = $this->loadModel('project')->getList($status); + if(empty($projectList)) return $projectList; + + $projects = $mineProjects = $otherProjects = $closedProjects = array(); + foreach($projectList as $project) + { + if(!$this->app->user->admin and !$this->project->checkPriv($project->id)) continue; + if($project->status != 'done' and $project->status != 'closed' and $project->PM == $this->app->user->account) + { + $mineProjects[$project->id] = $project; + } + elseif($project->status != 'done' and $project->status != 'closed' and !($project->PM == $this->app->user->account)) + { + $otherProjects[$project->id] = $project; + } + elseif($project->status == 'done' or $project->status == 'closed') + { + $closedProjects[$project->id] = $project; + } + } + $projects = $mineProjects + $otherProjects + $closedProjects; + + return $projects; + } } diff --git a/module/bug/config.php b/module/bug/config.php index 37773028f7..9c7e5ed1ef 100644 --- a/module/bug/config.php +++ b/module/bug/config.php @@ -165,7 +165,7 @@ $config->bug->search['params']['lastEditedDate']= array('operator' => '=', $config->bug->search['params']['deadline'] = array('operator' => '=', 'control' => 'input', 'values' => '', 'class' => 'date'); $config->bug->datatable = new stdclass(); -$config->bug->datatable->defaultField = array('id', 'pri', 'title', 'severity', 'status', 'openedBy', 'openedDate', 'assignedTo', 'resolvedBy', 'resolution', 'actions'); +$config->bug->datatable->defaultField = array('id', 'pri', 'title', 'severity', 'status', 'openedBy', 'openedDate', 'assignedTo', 'resolution', 'actions'); $config->bug->datatable->fieldList['id']['title'] = 'idAB'; $config->bug->datatable->fieldList['id']['fixed'] = 'left'; @@ -284,12 +284,12 @@ $config->bug->datatable->fieldList['deadline']['required'] = 'no'; $config->bug->datatable->fieldList['resolvedBy']['title'] = 'resolvedByAB'; $config->bug->datatable->fieldList['resolvedBy']['fixed'] = 'no'; -$config->bug->datatable->fieldList['resolvedBy']['width'] = '80'; +$config->bug->datatable->fieldList['resolvedBy']['width'] = '70'; $config->bug->datatable->fieldList['resolvedBy']['required'] = 'no'; $config->bug->datatable->fieldList['resolution']['title'] = 'resolutionAB'; $config->bug->datatable->fieldList['resolution']['fixed'] = 'no'; -$config->bug->datatable->fieldList['resolution']['width'] = '80'; +$config->bug->datatable->fieldList['resolution']['width'] = '70'; $config->bug->datatable->fieldList['resolution']['required'] = 'no'; $config->bug->datatable->fieldList['resolvedDate']['title'] = 'resolvedDateAB'; diff --git a/module/bug/css/batchcreate.css b/module/bug/css/batchcreate.css index 65f2a1233a..8dd37aa519 100644 --- a/module/bug/css/batchcreate.css +++ b/module/bug/css/batchcreate.css @@ -1,2 +1 @@ -#batchCreateForm{overflow-x:auto;} #batchCreateForm .chosen-container .chosen-drop{min-width:200px;} diff --git a/module/bug/css/batchedit.css b/module/bug/css/batchedit.css index c293bdd635..38b827fe2d 100644 --- a/module/bug/css/batchedit.css +++ b/module/bug/css/batchedit.css @@ -1,4 +1,3 @@ .chosen-container[id^="plan"] .chosen-drop {min-width: 300px; border-top: 1px solid #ddd!important} .duplicate-input {border-left-width: 0; border-radius: 0 2px 2px 0; padding-left: 9px} .duplicate-input:focus {border-left-width: 1px; padding-left: 8px} -#batchEditForm{overflow-x:auto;} diff --git a/module/bug/view/batchcreate.html.php b/module/bug/view/batchcreate.html.php index dae7c7f2bf..58da695603 100644 --- a/module/bug/view/batchcreate.html.php +++ b/module/bug/view/batchcreate.html.php @@ -18,8 +18,8 @@ session->currentProductType !== 'normal') echo '' . $branches[$branch] . '';?>
diff --git a/module/bug/view/create.html.php b/module/bug/view/create.html.php index 535e32f3c7..5845b74a4a 100644 --- a/module/bug/view/create.html.php +++ b/module/bug/view/create.html.php @@ -143,7 +143,7 @@ js::set('confirmDeleteTemplate', $lang->bug->confirmDeleteTemplate); - + diff --git a/module/bug/view/linkbugs.html.php b/module/bug/view/linkbugs.html.php index ed7a0dabd7..d2439aa95a 100644 --- a/module/bug/view/linkbugs.html.php +++ b/module/bug/view/linkbugs.html.php @@ -11,6 +11,7 @@ */ ?> +