From ca00b8cf532bd93419e3f4bc46f9dde5caa90eec Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 8 Jan 2017 15:31:33 -0500 Subject: Display project exports in modal box --- app/Controller/ExportController.php | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'app/Controller/ExportController.php') diff --git a/app/Controller/ExportController.php b/app/Controller/ExportController.php index b7ac92aa..19f73a7c 100644 --- a/app/Controller/ExportController.php +++ b/app/Controller/ExportController.php @@ -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); - } else { + if ($this->request->isPost()) { + $values = $this->request->getValues(); + $from = empty($values['from']) ? '' : $values['from']; + $to = empty($values['to']) ? '' : $values['to']; - $this->response->html($this->helper->layout->project('export/'.$action, array( - 'values' => array( - 'controller' => 'ExportController', - 'action' => $action, + 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->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, + ))); } } -- cgit v1.2.3