Display project exports in modal box

This commit is contained in:
Frederic Guillot
2017-01-08 15:31:33 -05:00
parent b3a450bace
commit ca00b8cf53
13 changed files with 74 additions and 81 deletions

View File

@@ -24,27 +24,29 @@ class ExportController extends BaseController
private function common($model, $method, $filename, $action, $page_title)
{
$project = $this->getProject();
$from = $this->request->getStringParam('from');
$to = $this->request->getStringParam('to');
if ($from && $to) {
$data = $this->$model->$method($project['id'], $from, $to);
$this->response->withFileDownload($filename.'.csv');
$this->response->csv($data);
if ($this->request->isPost()) {
$values = $this->request->getValues();
$from = empty($values['from']) ? '' : $values['from'];
$to = empty($values['to']) ? '' : $values['to'];
if ($from && $to) {
$data = $this->$model->$method($project['id'], $from, $to);
$this->response->withFileDownload($filename.'.csv');
$this->response->csv($data);
return;
}
} else {
$this->response->html($this->helper->layout->project('export/'.$action, array(
'values' => array(
'controller' => 'ExportController',
'action' => $action,
$this->response->html($this->template->render('export/'.$action, array(
'values' => array(
'project_id' => $project['id'],
'from' => $from,
'to' => $to,
'from' => '',
'to' => '',
),
'errors' => array(),
'errors' => array(),
'project' => $project,
'title' => $page_title,
), 'export/sidebar'));
'title' => $page_title,
)));
}
}

View File

@@ -0,0 +1,17 @@
<div class="page-header">
<h2><?= $this->text->e($project['name']) ?> &gt; <?= $title ?></h2>
<ul>
<li <?= $this->app->checkMenuSelection('ExportController', 'tasks') ?>>
<?= $this->modal->replaceLink(t('Tasks'), 'ExportController', 'tasks', array('project_id' => $project['id'])) ?>
</li>
<li <?= $this->app->checkMenuSelection('ExportController', 'subtasks') ?>>
<?= $this->modal->replaceLink(t('Subtasks'), 'ExportController', 'subtasks', array('project_id' => $project['id'])) ?>
</li>
<li <?= $this->app->checkMenuSelection('ExportController', 'transitions') ?>>
<?= $this->modal->replaceLink(t('Task transitions'), 'ExportController', 'transitions', array('project_id' => $project['id'])) ?>
</li>
<li <?= $this->app->checkMenuSelection('ExportController', 'summary') ?>>
<?= $this->modal->replaceLink(t('Daily project summary'), 'ExportController', 'summary', array('project_id' => $project['id'])) ?>
</li>
</ul>
</div>

View File

@@ -1,17 +0,0 @@
<div class="sidebar">
<ul>
<li <?= $this->app->checkMenuSelection('ExportController', 'tasks') ?>>
<?= $this->url->link(t('Tasks'), 'ExportController', 'tasks', array('project_id' => $project['id'])) ?>
</li>
<li <?= $this->app->checkMenuSelection('ExportController', 'subtasks') ?>>
<?= $this->url->link(t('Subtasks'), 'ExportController', 'subtasks', array('project_id' => $project['id'])) ?>
</li>
<li <?= $this->app->checkMenuSelection('ExportController', 'transitions') ?>>
<?= $this->url->link(t('Task transitions'), 'ExportController', 'transitions', array('project_id' => $project['id'])) ?>
</li>
<li <?= $this->app->checkMenuSelection('ExportController', 'summary') ?>>
<?= $this->url->link(t('Daily project summary'), 'ExportController', 'summary', array('project_id' => $project['id'])) ?>
</li>
<?= $this->hook->render('template:export:sidebar') ?>
</ul>
</div>

View File

@@ -1,20 +1,16 @@
<div class="page-header">
<h2><?= t('Subtasks export') ?></h2>
</div>
<?= $this->render('export/header', array('project' => $project, 'title' => $title)) ?>
<p class="alert alert-info"><?= t('This report contains all subtasks information for the given date range.') ?></p>
<form method="get" action="?" autocomplete="off">
<?= $this->form->hidden('controller', $values) ?>
<?= $this->form->hidden('action', $values) ?>
<form class="js-modal-ignore-form" method="post" action="<?= $this->url->href('ExportController', 'subtasks', array('project_id' => $project['id'])) ?>" autocomplete="off">
<?= $this->form->csrf() ?>
<?= $this->form->hidden('project_id', $values) ?>
<?= $this->form->date(t('Start date'), 'from', $values) ?>
<?= $this->form->date(t('End date'), 'to', $values) ?>
<div class="form-help"><?= t('Others formats accepted: %s and %s', date('Y-m-d'), date('Y_m_d')) ?></div>
<div class="form-actions">
<button type="submit" class="btn btn-blue"><?= t('Execute') ?></button>
<button type="submit" class="btn btn-blue js-form-export"><?= t('Export') ?></button>
<?= t('or') ?>
<?= $this->url->link(t('cancel'), 'ExportController', 'subtasks', array('project_id' => $project['id']), false, 'js-modal-close') ?>
</div>
</form>

View File

@@ -1,20 +1,16 @@
<div class="page-header">
<h2><?= t('Daily project summary export') ?></h2>
</div>
<?= $this->render('export/header', array('project' => $project, 'title' => $title)) ?>
<p class="alert alert-info"><?= t('This export contains the number of tasks per column grouped per day.') ?></p>
<form method="get" action="?" autocomplete="off">
<?= $this->form->hidden('controller', $values) ?>
<?= $this->form->hidden('action', $values) ?>
<form class="js-modal-ignore-form" method="post" action="<?= $this->url->href('ExportController', 'summary', array('project_id' => $project['id'])) ?>" autocomplete="off">
<?= $this->form->csrf() ?>
<?= $this->form->hidden('project_id', $values) ?>
<?= $this->form->date(t('Start date'), 'from', $values) ?>
<?= $this->form->date(t('End date'), 'to', $values) ?>
<div class="form-help"><?= t('Others formats accepted: %s and %s', date('Y-m-d'), date('Y_m_d')) ?></div>
<div class="form-actions">
<button type="submit" class="btn btn-blue"><?= t('Execute') ?></button>
<button type="submit" class="btn btn-blue js-form-export"><?= t('Export') ?></button>
<?= t('or') ?>
<?= $this->url->link(t('cancel'), 'ExportController', 'summary', array('project_id' => $project['id']), false, 'js-modal-close') ?>
</div>
</form>

View File

@@ -1,20 +1,16 @@
<div class="page-header">
<h2><?= t('Tasks exportation') ?></h2>
</div>
<?= $this->render('export/header', array('project' => $project, 'title' => $title)) ?>
<p class="alert alert-info"><?= t('This report contains all tasks information for the given date range.') ?></p>
<form method="get" action="?" autocomplete="off">
<?= $this->form->hidden('controller', $values) ?>
<?= $this->form->hidden('action', $values) ?>
<form class="js-modal-ignore-form" method="post" action="<?= $this->url->href('ExportController', 'tasks', array('project_id' => $project['id'])) ?>" autocomplete="off">
<?= $this->form->csrf() ?>
<?= $this->form->hidden('project_id', $values) ?>
<?= $this->form->date(t('Start date'), 'from', $values) ?>
<?= $this->form->date(t('End date'), 'to', $values) ?>
<div class="form-help"><?= t('Others formats accepted: %s and %s', date('Y-m-d'), date('Y_m_d')) ?></div>
<div class="form-actions">
<button type="submit" class="btn btn-blue"><?= t('Execute') ?></button>
<button type="submit" class="btn btn-blue js-form-export"><?= t('Export') ?></button>
<?= t('or') ?>
<?= $this->url->link(t('cancel'), 'ExportController', 'tasks', array('project_id' => $project['id']), false, 'js-modal-close') ?>
</div>
</form>

View File

@@ -1,21 +1,16 @@
<div class="page-header">
<h2><?= t('Task transitions export') ?></h2>
</div>
<?= $this->render('export/header', array('project' => $project, 'title' => $title)) ?>
<p class="alert alert-info"><?= t('This report contains all column moves for each task with the date, the user and the time spent for each transition.') ?></p>
<form method="get" action="?" autocomplete="off">
<?= $this->form->hidden('controller', $values) ?>
<?= $this->form->hidden('action', $values) ?>
<form class="js-modal-ignore-form" method="post" action="<?= $this->url->href('ExportController', 'transitions', array('project_id' => $project['id'])) ?>" autocomplete="off">
<?= $this->form->csrf() ?>
<?= $this->form->hidden('project_id', $values) ?>
<?= $this->form->date(t('Start date'), 'from', $values) ?>
<?= $this->form->date(t('End date'), 'to', $values) ?>
<div class="form-help"><?= t('Others formats accepted: %s and %s', date('Y-m-d'), date('Y_m_d')) ?></div>
<div class="form-actions">
<button type="submit" class="btn btn-blue"><?= t('Execute') ?></button>
<button type="submit" class="btn btn-blue js-form-export"><?= t('Export') ?></button>
<?= t('or') ?>
<?= $this->url->link(t('cancel'), 'ExportController', 'transitions', array('project_id' => $project['id']), false, 'js-modal-close') ?>
</div>
</form>

View File

@@ -52,7 +52,7 @@
<?php if ($this->user->hasProjectAccess('ExportController', 'tasks', $project['id'])): ?>
<li>
<?= $this->url->icon('upload', t('Exports'), 'ExportController', 'tasks', array('project_id' => $project['id'])) ?>
<?= $this->modal->medium('upload', t('Exports'), 'ExportController', 'tasks', array('project_id' => $project['id'])) ?>
</li>
<?php endif ?>