Blame view

src/app/backend/controllers/ExcelWorkerController.php 1.41 KB
1ea3b987   Administrator   maby first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
  <?php

  

  namespace controllers;

  

  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

  

  class ExcelWorkerController extends \Phalcon\Mvc\Controller

  {

      function indexAction()

      {

  

          if( !$this->session->get('isAdminAuth') )

          {

              return $this->response->redirect([ 'for' => 'admin_login' ]);

          }

  

      }

  

      function getdataAction()

      {

          if( !$this->session->get('isAdminAuth') )

          {

              return $this->response->redirect([ 'for' => 'admin_login' ]);

          }

  

          $post['fields'] = $this->request->getPost('fields', 'string', NULL );

          $post['table'] = $this->request->getPost('table', 'string', NULL );

  

          if(!(empty($post['table']))){

              $fields = explode(", ", $post['fields']);

              $data = $this->models->getCatalog()->getTranslateData($post['table'],$post['fields']);

              array_unshift($data, $fields);

              $this->excelphp->getData($data,$post['table'].'.xls');

              $this->view->disableLevel(\Phalcon\Mvc\View::LEVEL_MAIN_LAYOUT);

          } else {

              $this->flash->error( 'Не все поля заполнены.' );

              return $this->response->redirect([ 'for' => 'excel_worker_index' ]);

          }

  

  

      }

  

      function deleteAction($id)

      {

  

      }

  }