예제 #1
0
 public function indexAction()
 {
     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;
         }
         $cpf = $this->session->get('auth-identity')['userInfo']['cpf'];
         $cellPhoneLine = CellPhoneLine::findByCpf($cpf);
         $accessLine = AccessLine::findByCpf($cpf);
         $linhas = [];
         foreach ($cellPhoneLine as $value) {
             $linhas['Minhas Linhas'][$value->linha] = $value->linha;
         }
         foreach ($accessLine as $value) {
             $linhas['Linhas de Outros'][$value->linha] = $value->linha;
         }
         $this->view->linhas = $linhas;
         if (empty($linhas)) {
             throw new Exception('Não há linhas telefônicas cadastradas no seu CPF.');
         }
     } catch (\Exception $e) {
         $this->flash->error($e->getMessage());
     }
 }
 /**
  * Deletes a accessLine
  *
  * @param string $id
  */
 public function deleteAction()
 {
     try {
         if (!$this->request->isPost()) {
             throw new Exception('Acesso não permitido a essa action.');
         }
         if ($this->request->isAjax()) {
             $this->view->disable();
         }
         $id = $this->request->getPost('id');
         $accessLine = AccessLine::findFirstByid($id);
         if (!$accessLine) {
             throw new Exception('Acesso a Linha não encontrada!');
         }
         if (!$accessLine->delete()) {
             $msg = '';
             foreach ($accessLine->getMessages() as $message) {
                 $msg .= $message . '<br />';
             }
             throw new Exception($msg);
         }
         echo 'ok';
     } catch (Exception $exc) {
         $this->flash->error($exc->getMessage());
         return $this->response->redirect('telephony/access_line');
     }
 }