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,
)));
}
}