mirror of
https://github.com/Karaka-Management/oms-ProjectManagement.git
synced 2026-01-16 17:58:41 +00:00
Went through todos
This commit is contained in:
parent
19131afd38
commit
90bcf0e30c
|
|
@ -15,10 +15,13 @@ declare(strict_types=1);
|
|||
namespace Modules\ProjectManagement\Controller;
|
||||
|
||||
use Modules\ProjectManagement\Models\NullProject;
|
||||
use Modules\ProjectManagement\Models\ProgressType;
|
||||
use Modules\ProjectManagement\Models\ProjectMapper;
|
||||
use phpOMS\Asset\AssetType;
|
||||
use phpOMS\Contract\RenderableInterface;
|
||||
use phpOMS\DataStorage\Database\Query\Builder;
|
||||
use phpOMS\DataStorage\Database\Query\OrderType;
|
||||
use phpOMS\Math\Number\Numbers;
|
||||
use phpOMS\Message\RequestAbstract;
|
||||
use phpOMS\Message\ResponseAbstract;
|
||||
use phpOMS\Views\View;
|
||||
|
|
@ -43,6 +46,8 @@ final class BackendController extends Controller
|
|||
*
|
||||
* @return RenderableInterface
|
||||
*
|
||||
* @feature Create Gantt chart for all active projects in one overview
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
|
|
@ -52,8 +57,59 @@ final class BackendController extends Controller
|
|||
$view->setTemplate('/Modules/ProjectManagement/Theme/Backend/projectmanagement-list');
|
||||
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1001701001, $request, $response);
|
||||
|
||||
$projects = ProjectMapper::getAll()->sort('id', OrderType::DESC)->limit(25)->executeGetArray();
|
||||
$view->data['projects'] = $projects;
|
||||
$view->data['projects'] = ProjectMapper::getAll()
|
||||
->sort('id', OrderType::DESC)
|
||||
->limit(25)
|
||||
->executeGetArray();
|
||||
|
||||
// Evaluate progress
|
||||
$view->data['progress'] = [];
|
||||
|
||||
$taskProgress = [];
|
||||
|
||||
$now = new \DateTime('now');
|
||||
|
||||
/** @var \Modules\ProjectManagement\Models\Project $project */
|
||||
foreach ($view->data['projects'] as $project) {
|
||||
if ($project->progressType === ProgressType::TASKS) {
|
||||
$taskProgress[] = $project->id;
|
||||
} elseif ($project->progressType === ProgressType::LINEAR) {
|
||||
$duration = (int) $project->start->diff($project->endEstimated)->format('%a');
|
||||
$progress = (int) $project->start->diff($now)->format('%a');
|
||||
|
||||
$view->data['progress'][$project->id] = (int) \min(100, $duration / $progress * 100);
|
||||
} elseif ($project->progressType === ProgressType::EXPONENTIAL) {
|
||||
$duration = (int) $project->start->diff($project->endEstimated)->format('%a');
|
||||
$progress = (int) $project->start->diff($now)->format('%a');
|
||||
|
||||
$view->data['progress'][$project->id] = (int) Numbers::remapRangeExponentially($progress, $duration);
|
||||
} elseif ($project->progressType === ProgressType::LOG) {
|
||||
$duration = (int) $project->start->diff($project->endEstimated)->format('%a');
|
||||
$progress = (int) $project->start->diff($now)->format('%a');
|
||||
|
||||
$view->data['progress'][$project->id] = (int) Numbers::remapRangeLog($progress, $duration);
|
||||
} else {
|
||||
$view->data['progress'][$project->id] = $project->progress;
|
||||
}
|
||||
}
|
||||
|
||||
// Count tasks per project where tasks are used as progress indication
|
||||
$projectIds = \implode(',', $taskProgress);
|
||||
|
||||
$sql = <<<SQL
|
||||
SELECT projectmanagement_task_relation_dst as id,
|
||||
COUNT(projectmanagement_task_relation_src) as total_tasks,
|
||||
SUM(task.task_status = 1 OR task.task_status = 2) AS open_tasks
|
||||
FROM projectmanagement_task_relation
|
||||
LEFT JOIN task ON projectmanagement_task_relation.projectmanagement_task_relation_src = task.task_id
|
||||
WHERE projectmanagement_task_relation_dst IN ({$projectIds});
|
||||
SQL;
|
||||
|
||||
$query = new Builder($this->app->dbPool->get());
|
||||
$results = $query->raw($sql)->execute()?->fetchAll(\PDO::FETCH_ASSOC) ?? [];
|
||||
foreach ($results as $result) {
|
||||
$view->data['progress'][$result['id']] = (int) (($result['total_tasks'] - $result['open_tasks']) / $result['total_tasks']);
|
||||
}
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
|
@ -90,6 +146,8 @@ final class BackendController extends Controller
|
|||
*
|
||||
* @return RenderableInterface
|
||||
*
|
||||
* @feature Create Gantt chart for project based on milestones and tasks and general project settings
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -27,6 +27,9 @@ use phpOMS\Stdlib\Base\FloatInt;
|
|||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @feature Add milestones
|
||||
* https://github.com/Karaka-Management/oms-ProjectManagement/issues/4
|
||||
*/
|
||||
class Project
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,11 +12,6 @@
|
|||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
$footerView = new \phpOMS\Views\PaginationView($this->l11nManager, $this->request, $this->response);
|
||||
$footerView->setTemplate('/Web/Templates/Lists/Footer/PaginationBig');
|
||||
$footerView->setPages(20);
|
||||
$footerView->setPage(1);
|
||||
|
||||
$list = $this->data['projects'];
|
||||
|
||||
echo $this->data['nav']->render(); ?>
|
||||
|
|
@ -29,19 +24,22 @@ echo $this->data['nav']->render(); ?>
|
|||
<table class="default sticky">
|
||||
<thead>
|
||||
<tr>
|
||||
<td><?= $this->getHtml('Progress'); ?>
|
||||
<td class="wf-100"><?= $this->getHtml('Title'); ?>
|
||||
<td><?= $this->getHtml('Start'); ?>
|
||||
<td><?= $this->getHtml('Due'); ?>
|
||||
<tbody>
|
||||
<?php $count = 0; foreach ($list as $key => $value) : ++$count;
|
||||
$url = \phpOMS\Uri\UriFactory::build('projectmanagement/view?{?}&id=' . $value->id); ?>
|
||||
<?php $count = 0;
|
||||
foreach ($list as $key => $value) : ++$count;
|
||||
$url = \phpOMS\Uri\UriFactory::build('{/base}/projectmanagement/view?{?}&id=' . $value->id); ?>
|
||||
<tr tabindex="0" data-href="<?= $url; ?>">
|
||||
<td data-label="<?= $this->getHtml('Progress'); ?>"><a href="<?= $url; ?>"><?= $this->data['progress'][$value->id] ?? 0; ?> %</a>
|
||||
<td data-label="<?= $this->getHtml('Title'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->name); ?></a>
|
||||
<td data-label="<?= $this->getHtml('Start'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->start?->format('Y-m-d')); ?></a>
|
||||
<td data-label="<?= $this->getHtml('Due'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->end?->format('Y-m-d')); ?></a>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($count === 0) : ?>
|
||||
<tr><td colspan="5" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
|
||||
<tr><td colspan="4" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user