/**
  * Edits a accessLine
  *
  * @param string $id
  */
 public function editAction($id)
 {
     try {
         if ($this->request->isPost()) {
             throw new Exception('Acesso inválido a essa action!!!');
         }
         $cpf = CellPhoneLine::find(['columns' => 'distinct cpf, name', 'order' => '2']);
         $linha = CellPhoneLine::find(['columns' => 'distinct linha']);
         $cpfs = $linhas = [];
         foreach ($cpf->toArray(0) as $value) {
             $cpfs[$value['CPF']] = $value['NAME'];
         }
         foreach ($linha->toArray(0) as $value) {
             $linhas[$value['LINHA']] = $value['LINHA'];
         }
         $this->view->cpfs = $cpfs;
         $this->view->linhas = $linhas;
         $accessLine = AccessLine::findFirstByid($id);
         if (!$accessLine) {
             throw new Exception('Acesso a Linha não encontrado!');
         }
         $this->view->id = $accessLine->id;
         $this->tag->setDefault('id', $accessLine->getId());
         $this->tag->setDefault('cpf', $accessLine->getCpf());
         $this->tag->setDefault('linha', $accessLine->getLinha());
     } catch (Exception $exc) {
         $this->flash->error($exc->getMessage());
         return $this->response->redirect('telephony/access_line');
     }
 }
 public function contaCelularAdminAction()
 {
     try {
         $this->view->pesquisa = '';
         if ($this->request->isPost()) {
             $linhas = $this->request->getPost('linhas', 'string');
             $mes = str_replace('20', '', $this->request->getPost('mes', 'string'));
             $this->view->extratos = Statement::find("operLd IS NOT NULL AND numAcs = '{$linhas}' AND mes = '{$mes}'");
             $this->view->totais = Statement::find("operLd IS NULL AND numAcs = '{$linhas}' AND mes = '{$mes}'");
             $statement = new Statement();
             $this->view->totalLinha = $statement->getTotal($linhas, $mes);
             $this->view->pesquisa = $linhas . ' | ' . $this->request->getPost('mes', 'string');
             $this->view->export = true;
         }
         $cellPhoneLine = CellPhoneLine::find(['order' => 'linha']);
         $linhas = [];
         foreach ($cellPhoneLine as $value) {
             $linhas[$value->linha] = $value->linha;
         }
         $this->view->linhas = $linhas;
     } catch (\Exception $e) {
         $this->flash->error($e->getMessage());
     }
 }