Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding functionalities needed for most organization #30

Merged
merged 4 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 105 additions & 5 deletions Controller/PrintTaskController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
use Kanboard\Model\ColorModel;
use Kanboard\Model\TaskTagModel;
use Kanboard\Model\TaskFileModel;

use Kanboard\Model\TaskModel;
use Kanboard\Filter\TaskProjectFilter;

class PrintTaskController extends BaseController
{
Expand Down Expand Up @@ -86,9 +87,110 @@ public function printTask()
}
}

public function printProjectAll()
{
$status = array(TaskModel::STATUS_OPEN, TaskModel::STATUS_CLOSED);

$project = $this->getProject();
$task_ids = $this->db
->table(TaskModel::TABLE)
->eq(TaskModel::TABLE.'.project_id', $project['id'])
->in(TaskModel::TABLE.'.is_active', $status)
->asc(TaskModel::TABLE.'.id')
->findAllByColumn(TaskModel::TABLE.'.id');
self::printProject($task_ids, $project);
}

public function printProjectOpen()
{
$status = array(TaskModel::STATUS_OPEN);

$project = $this->getProject();
$task_ids = $this->db
->table(TaskModel::TABLE)
->eq(TaskModel::TABLE.'.project_id', $project['id'])
->in(TaskModel::TABLE.'.is_active', $status)
->asc(TaskModel::TABLE.'.id')
->findAllByColumn(TaskModel::TABLE.'.id');
self::printProject($task_ids, $project);
}

public function printProjectClosed()
{
$status = array(TaskModel::STATUS_CLOSED);

$project = $this->getProject();
$task_ids = $this->db
->table(TaskModel::TABLE)
->eq(TaskModel::TABLE.'.project_id', $project['id'])
->in(TaskModel::TABLE.'.is_active', $status)
->asc(TaskModel::TABLE.'.id')
->findAllByColumn(TaskModel::TABLE.'.id');
self::printProject($task_ids, $project);
}

public function printProjectPerUser()
{
$status = array(TaskModel::STATUS_OPEN, TaskModel::STATUS_CLOSED);

$project = $this->getProject();
$user = $this->getUser();
$task_ids = $this->db
->table(TaskModel::TABLE)
->eq(TaskModel::TABLE.'.project_id', $project['id'])
->eq(TaskModel::TABLE.'.owner_id', $user['id'])
->in(TaskModel::TABLE.'.is_active', $status)
->asc(TaskModel::TABLE.'.id')
->findAllByColumn(TaskModel::TABLE.'.id');
self::printProject($task_ids, $project);
}

public function printProject()
public function printProjectPerUserOpen()
{
$status = array(TaskModel::STATUS_OPEN);

$project = $this->getProject();
$user = $this->getUser();
$task_ids = $this->db
->table(TaskModel::TABLE)
->eq(TaskModel::TABLE.'.project_id', $project['id'])
->eq(TaskModel::TABLE.'.owner_id', $user['id'])
->in(TaskModel::TABLE.'.is_active', $status)
->asc(TaskModel::TABLE.'.id')
->findAllByColumn(TaskModel::TABLE.'.id');
self::printProject($task_ids, $project);
}

public function printProjectPerUserClosed()
{
$status = array(TaskModel::STATUS_CLOSED);

$project = $this->getProject();
$user = $this->getUser();
$task_ids = $this->db
->table(TaskModel::TABLE)
->eq(TaskModel::TABLE.'.project_id', $project['id'])
->eq(TaskModel::TABLE.'.owner_id', $user['id'])
->in(TaskModel::TABLE.'.is_active', $status)
->asc(TaskModel::TABLE.'.id')
->findAllByColumn(TaskModel::TABLE.'.id');
self::printProject($task_ids, $project);
}

public function printProjectByFilter()
{
$project = $this->getProject();
$search = $this->helper->projectHeader->getSearchQuery($project);
$tasks = $this->taskLexer->build($search)->withFilter(new TaskProjectFilter($project['id']))->format($this->taskListFormatter);
$task_ids = array();
foreach ($tasks as $task)
{
array_push($task_ids,$task['id']);
}
self::printProject($task_ids, $project);
}

function printProject($task_ids, $project)
{
// instantiate and use t$options = new Options();
$options = new Options();
Expand All @@ -105,9 +207,7 @@ public function printProject()
} else {
$html_all = '<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><style>@font-face {font-family: \'Droid Sans\';font-style: normal;font-weight: 400;src: url(\'/plugins/Task2pdf/font/DroidSansFallback.ttf\') format(\'truetype\');src: url(https://github.com/creecros/Task2pdf/blob/master/font/DroidSansFallback.ttf?raw=true) format(\'truetype\');}@font-face {font-family: \'Droid Sans\';font-style: normal;font-weight: bold;src: url(\'/plugins/Task2pdf/font/DroidSansFallback.ttf\') format(\'truetype\');src: url(https://github.com/creecros/Task2pdf/blob/master/font/DroidSansFallback.ttf?raw=true) format(\'truetype\');}@font-face {font-family: \'Droid Sans\';font-style: normal;font-weight: bold;font-style: italic;src: url(\'/plugins/Task2pdf/font/DroidSansFallback.ttf\') format(\'truetype\');src: url(https://github.com/creecros/Task2pdf/blob/master/font/DroidSansFallback.ttf?raw=true) format(\'truetype\');}* {font-family: Droid Sans, DejaVu Sans, sans-serif;}.task-board.color-yellow, .task-summary-container.color-yellow, .color-picker-square.color-yellow, .task-board-category.color-yellow, .table-list-category.color-yellow, .task-tag.color-yellow {background-color: rgb(245, 247, 196);border-color: rgb(223, 227, 45)}td.color-yellow { background-color: rgb(245, 247, 196)}.table-list-row.color-yellow {border-left: 5px solid rgb(223, 227, 45)}.task-board.color-blue, .task-summary-container.color-blue, .color-picker-square.color-blue, .task-board-category.color-blue, .table-list-category.color-blue, .task-tag.color-blue {background-color: rgb(219, 235, 255);border-color: rgb(168, 207, 255)}td.color-blue { background-color: rgb(219, 235, 255)}.table-list-row.color-blue {border-left: 5px solid rgb(168, 207, 255)}.task-board.color-green, .task-summary-container.color-green, .color-picker-square.color-green, .task-board-category.color-green, .table-list-category.color-green, .task-tag.color-green {background-color: rgb(189, 244, 203);border-color: rgb(74, 227, 113)}td.color-green { background-color: rgb(189, 244, 203)}.table-list-row.color-green {border-left: 5px solid rgb(74, 227, 113)}.task-board.color-purple, .task-summary-container.color-purple, .color-picker-square.color-purple, .task-board-category.color-purple, .table-list-category.color-purple, .task-tag.color-purple {background-color: rgb(223, 176, 255);border-color: rgb(205, 133, 254)}td.color-purple { background-color: rgb(223, 176, 255)}.table-list-row.color-purple {border-left: 5px solid rgb(205, 133, 254)}.task-board.color-red, .task-summary-container.color-red, .color-picker-square.color-red, .task-board-category.color-red, .table-list-category.color-red, .task-tag.color-red {background-color: rgb(255, 187, 187);border-color: rgb(255, 151, 151)}td.color-red { background-color: rgb(255, 187, 187)}.table-list-row.color-red {border-left: 5px solid rgb(255, 151, 151)}.task-board.color-orange, .task-summary-container.color-orange, .color-picker-square.color-orange, .task-board-category.color-orange, .table-list-category.color-orange, .task-tag.color-orange {background-color: rgb(255, 215, 179);border-color: rgb(255, 172, 98)}td.color-orange { background-color: rgb(255, 215, 179)}.table-list-row.color-orange {border-left: 5px solid rgb(255, 172, 98)}.task-board.color-grey, .task-summary-container.color-grey, .color-picker-square.color-grey, .task-board-category.color-grey, .table-list-category.color-grey, .task-tag.color-grey {background-color: rgb(238, 238, 238);border-color: rgb(204, 204, 204)}td.color-grey { background-color: rgb(238, 238, 238)}.table-list-row.color-grey {border-left: 5px solid rgb(204, 204, 204)}.task-board.color-brown, .task-summary-container.color-brown, .color-picker-square.color-brown, .task-board-category.color-brown, .table-list-category.color-brown, .task-tag.color-brown {background-color: #d7ccc8;border-color: #4e342e}td.color-brown { background-color: #d7ccc8}.table-list-row.color-brown {border-left: 5px solid #4e342e}.task-board.color-deep_orange, .task-summary-container.color-deep_orange, .color-picker-square.color-deep_orange, .task-board-category.color-deep_orange, .table-list-category.color-deep_orange, .task-tag.color-deep_orange {background-color: #ffab91;border-color: #e64a19}td.color-deep_orange { background-color: #ffab91}.table-list-row.color-deep_orange {border-left: 5px solid #e64a19}.task-board.color-dark_grey, .task-summary-container.color-dark_grey, .color-picker-square.color-dark_grey, .task-board-category.color-dark_grey, .table-list-category.color-dark_grey, .task-tag.color-dark_grey {background-color: #cfd8dc;border-color: #455a64}td.color-dark_grey { background-color: #cfd8dc}.table-list-row.color-dark_grey {border-left: 5px solid #455a64}.task-board.color-pink, .task-summary-container.color-pink, .color-picker-square.color-pink, .task-board-category.color-pink, .table-list-category.color-pink, .task-tag.color-pink {background-color: #f48fb1;border-color: #d81b60}td.color-pink { background-color: #f48fb1}.table-list-row.color-pink {border-left: 5px solid #d81b60}.task-board.color-teal, .task-summary-container.color-teal, .color-picker-square.color-teal, .task-board-category.color-teal, .table-list-category.color-teal, .task-tag.color-teal {background-color: #80cbc4;border-color: #00695c}td.color-teal { background-color: #80cbc4}.table-list-row.color-teal {border-left: 5px solid #00695c}.task-board.color-cyan, .task-summary-container.color-cyan, .color-picker-square.color-cyan, .task-board-category.color-cyan, .table-list-category.color-cyan, .task-tag.color-cyan {background-color: #b2ebf2;border-color: #00bcd4}td.color-cyan { background-color: #b2ebf2}.table-list-row.color-cyan {border-left: 5px solid #00bcd4}.task-board.color-lime, .task-summary-container.color-lime, .color-picker-square.color-lime, .task-board-category.color-lime, .table-list-category.color-lime, .task-tag.color-lime {background-color: #e6ee9c;border-color: #afb42b}td.color-lime { background-color: #e6ee9c}.table-list-row.color-lime {border-left: 5px solid #afb42b}.task-board.color-light_green, .task-summary-container.color-light_green, .color-picker-square.color-light_green, .task-board-category.color-light_green, .table-list-category.color-light_green, .task-tag.color-light_green {background-color: #dcedc8;border-color: #689f38}td.color-light_green { background-color: #dcedc8}.table-list-row.color-light_green {border-left: 5px solid #689f38}.task-board.color-amber, .task-summary-container.color-amber, .color-picker-square.color-amber, .task-board-category.color-amber, .table-list-category.color-amber, .task-tag.color-amber {background-color: #ffe082;border-color: #ffa000}td.color-amber { background-color: #ffe082}.table-list-row.color-amber {border-left: 5px solid #ffa000}</style></head><body>';
}

$project = $this->getProject();
$task_ids = $this->taskFinderModel->getAllIds($project['id']);

$files_to_embed = array();

foreach ($task_ids as $task_id) {
Expand Down
37 changes: 35 additions & 2 deletions Template/project_header/print_project.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
<?php if ($this->user->hasProjectAccess('ExportController', 'tasks', $project['id'])): ?>
<?php if ($this->user->hasProjectAccess('AnalyticController', 'taskDistribution', $project['id'])): ?>
<li>
<?= $this->url->icon('file-pdf-o', t('Print Open Tasks'), 'PrintTaskController', 'printProject', ['plugin' => 'task2pdf', 'project_id' => $project['id']]) ?>
<?= $this->url->icon('file-pdf-o', t('Print All Tasks'), 'PrintTaskController', 'printProjectAll', ['plugin' => 'task2pdf', 'project_id' => $project['id']]) ?>
</li>
<li>
<?= $this->url->icon('file-pdf-o', t('Print Open Tasks'), 'PrintTaskController', 'printProjectOpen', ['plugin' => 'task2pdf', 'project_id' => $project['id']]) ?>
</li>
<li>
<?= $this->url->icon('file-pdf-o', t('Print Closed Tasks'), 'PrintTaskController', 'printProjectClosed', ['plugin' => 'task2pdf', 'project_id' => $project['id']]) ?>
</li>
<?php endif ?>
<?php
if ($this->user->hasProjectAccess('ExportController', 'tasks', $project['id']))
{
$search = $this->helper->projectHeader->getSearchQuery($project);
if($search=="" || $search=="status:open" || !isset($search))
{
?>
<li>
<?= $this->url->icon('file-pdf-o', t('Print All Tasks for This User'), 'PrintTaskController', 'printProjectPerUser', ['plugin' => 'task2pdf', 'project_id' => $project['id']]) ?>
</li>
<li>
<?= $this->url->icon('file-pdf-o', t('Print Open Tasks for This User'), 'PrintTaskController', 'printProjectPerUserOpen', ['plugin' => 'task2pdf', 'project_id' => $project['id']]) ?>
</li>
<li>
<?= $this->url->icon('file-pdf-o', t('Print Closed Tasks for This User'), 'PrintTaskController', 'printProjectPerUserClosed', ['plugin' => 'task2pdf', 'project_id' => $project['id']]) ?>
</li>
<?php }
else
{
?>
<li>
<?= $this->url->icon('file-pdf-o', t('Print Filtered Tasks'), 'PrintTaskController', 'printProjectByFilter', ['plugin' => 'task2pdf', 'project_id' => $project['id'], 'search' => $search]) ?>
</li>
<?php
}
}
?>