/**
  * method onSearch()
  * Register the filter in the session when the user performs a search
  */
 function onSearch()
 {
     // pegar os dados do form de busca
     $data = $this->form->getData();
     TSession::setValue('Funcionalidade_nome_filter', NULL);
     TSession::setValue('Funcionalidade_nome', '');
     TSession::setValue('Funcionalidade_control_filter', NULL);
     TSession::setValue('Funcionalidade_control', '');
     // check if the user has filled the form
     if ($data->nome) {
         // creates a filter using what the user has typed
         $filter = new TFilter('nome', 'like', "%{$data->nome}%");
         // stores the filter in the session
         TSession::setValue('Funcionalidade_nome_filter', $filter);
         TSession::setValue('Funcionalidade_nome', $data->nome);
     }
     if ($data->classe) {
         // creates a filter using what the user has typed
         $filter = new TFilter('classe', 'like', "%{$data->classe}%");
         // stores the filter in the session
         TSession::setValue('Funcionalidade_control_filter', $filter);
         TSession::setValue('Funcionalidade_control', $data->classe);
     }
     // fill the form with data again
     $this->form->setData($data);
     $param = array();
     $param['offset'] = 0;
     $param['first_page'] = 1;
     $this->onReload($param);
 }
Example #2
0
 /**
  * define the standars seek parameters
  */
 public function onSetup($param = NULL)
 {
     // store the parameters in the section
     TSession::setValue('tstandardseek_filter', NULL);
     TSession::setValue('tstandardseek_display_value', NULL);
     TSession::setValue('standard_seek_receive_key', $param['receive_key']);
     TSession::setValue('standard_seek_receive_field', $param['receive_field']);
     TSession::setValue('standard_seek_display_field', $param['display_field']);
     TSession::setValue('standard_seek_model', $param['model']);
     TSession::setValue('standard_seek_database', $param['database']);
     TSession::setValue('standard_seek_parent', $param['parent']);
     if (isset($param['criteria']) and $param['criteria']) {
         TSession::setValue('standard_seek_criteria', unserialize(base64_decode($param['criteria'])));
     }
     $this->onReload();
 }
Example #3
0
 public function onViewSrp($param = NULL)
 {
     $key = $param['key'];
     if (!isset($key)) {
         return;
     }
     TSession::setValue('srp_form_view_key', $key);
     $this->onReload($param);
 }
 /**
  * method onSearch()
  * Register the filter in the session when the user performs a search
  */
 function onSearch()
 {
     // get the search form data
     $data = $this->form->getData();
     // check if the user has filled the form
     if (isset($data->descricao)) {
         // creates a filter using what the user has typed
         $filter = new TFilter('descricao', 'like', "%{$data->name}%");
         // stores the filter in the session
         TSession::setValue('tipocontato_filtro', $filter);
         TSession::setValue('tipocontato_descricao', $data->name);
         // fill the form with data again
         $this->form->setData($data);
     }
     // redefine the parameters for reload method
     $param = array();
     $param['offset'] = 0;
     $param['first_page'] = 1;
     $this->onReload($param);
 }
 /**
  * method onSearch()
  * Register the filter in the session when the user performs a search
  */
 public function onSearch()
 {
     // get the search form data
     $data = $this->form->getData();
     // check if the user has filled the form
     if (isset($data->{$this->filterField})) {
         // creates a filter using what the user has typed
         $filter = new TFilter($this->filterField, 'like', "%{$data->{$this->filterField}}%");
         // stores the filter in the session
         TSession::setValue($this->activeRecord . '_filter', $filter);
         TSession::setValue($this->activeRecord . '_' . $this->filterField, $data->{$this->filterField});
         // fill the form with data again
         $this->form->setData($data);
     }
     $param = array();
     $param['offset'] = 0;
     $param['first_page'] = 1;
     $this->onReload($param);
 }
Example #6
0
 public function onSelect($param)
 {
     try {
         //var_dump($param);
         $key = $param['key'];
         if (!$key) {
             return;
         }
         TTransaction::open('saciq');
         //$srp = new Srp($key);
         $repository = new TRepository('Srp');
         $criteria = new TCriteria();
         $criteria->add(new TFilter('numeroSRP', '=', $key));
         $srps = $repository->load($criteria);
         if (count($srps) > 0) {
             $srp = $srps[0];
         }
         if ($srp->estaVencida()) {
             new TMessage('error', 'SRP Vencida!');
             return;
         }
         $oldSRP = NULL;
         if ($oldSRP != TSession::getValue('SRP_id')) {
             $oldSRP = TSession::getValue('SRP_id');
         }
         if ($oldSRP != $srp->id) {
             if (TSession::getValue('cessao_itens')) {
                 $reloadForm = true;
             }
             TSession::delValue('cessao_itens');
             $obj = new stdClass();
             $obj->numeroItem = '';
             $obj->descricaoSumaria = '';
             $obj->valorUnitario = '';
             $obj->quantidade = '';
             //$obj->prazoEntrega = '60 Dias';
             //$obj->justificativa = '';
             TForm::sendData('form_itens', $obj);
         }
         TSession::setValue('SRP_id', $srp->id);
         $obj = new stdClass();
         $obj->numeroSRP = $srp->numeroSRP;
         $obj->nome = $srp->nome;
         $obj->numeroProcessoOrigem = $srp->numeroProcesso;
         $obj->uasg = $srp->uasg;
         $obj->validade = TDate::date2br($srp->validade);
         TForm::sendData('form_cessao', $obj);
         TSession::setValue('form_cessao', $obj);
         if (isset($reloadForm) && $reloadForm) {
             TScript::create("__adianti_load_page2('engine.php?class=CessaoForm');");
             //new TScript("__adianti_load_page('engine?class=CessaoForm');");
         }
         //AdiantiCoreApplication::executeMethod('CessaoForm','onReload');
         TTransaction::close();
         parent::closeWindow();
     } catch (Exception $e) {
         $obj = new stdClass();
         $obj->numeroSRP = '';
         $obj->nome = '';
         $obj->numeroProcesso = '';
         $obj->uasg = '';
         $obj->validade = '';
         TForm::sendData('cessao_form', $obj);
         TTransaction::rollback();
     }
 }
Example #7
0
 public function onEdit($param)
 {
     if (isset($param) && isset($param['key'])) {
         $key = $param['key'];
     }
     if (!isset($key)) {
         $form_requisicao = new stdClass();
         $form_requisicao->numeroSRP = '';
         $form_requisicao->numeroProcessoOrigem = '';
         $form_requisicao->numeroProcesso = '';
         $form_requisicao->validade = '';
         $form_requisicao->nome = '';
         $form_requisicao->uasg = '';
         $form_requisicao->emissao = date('d/m/Y');
         TSession::delValue('requisicao_itens');
         TSession::delValue('requisicao_itens_o');
         TSession::delValue('form_requisicao');
         TSession::delValue('SRP_id');
         TForm::sendData('form_requisicao', $form_requisicao);
         $this->onReload();
         return;
     }
     try {
         TTransaction::open('saciq');
         $requisicao = new Requisicao($key);
         $form_requisicao = new stdClass();
         $form_requisicao->id = $key;
         $form_requisicao->numeroSRP = $requisicao->srp->numeroSRP;
         $form_requisicao->numeroProcessoOrigem = $requisicao->srp->numeroProcesso;
         $form_requisicao->numeroProcesso = $requisicao->numeroProcesso;
         $form_requisicao->validade = TDate::date2br($requisicao->srp->validade);
         $form_requisicao->nome = $requisicao->srp->nome;
         $form_requisicao->uasg = $requisicao->srp->uasg;
         $form_requisicao->emissao = TDate::date2br($requisicao->emissao);
         TSession::delValue('requisicao_itens');
         TSession::delValue('requisicao_itens_o');
         TSession::setValue('SRP_id', $requisicao->srp->id);
         TSeekButton::disableField('form_requisicao', 'numeroSRP');
         foreach ($requisicao->getItems() as $item_requisicao) {
             $item = new stdClass();
             $item->item_id = $item_requisicao->id;
             $item->numeroItem = $item_requisicao->numeroItem;
             $item->descricaoSumaria = $item_requisicao->descricaoSumaria;
             $item->quantidade = $item_requisicao->quantidade;
             $item->valorUnitario = $item_requisicao->valorUnitario;
             $item->justificativa = $item_requisicao->justificativa;
             $item->prazoEntrega = $item_requisicao->prazoEntrega;
             $item->total = $item_requisicao->total;
             $itens[$item->numeroItem] = $item;
         }
         TSession::setValue('requisicao_itens', $itens);
         TSession::setValue('requisicao_itens_o', $itens);
         TSession::setValue('form_requisicao', $form_requisicao);
         TForm::sendData('form_requisicao', $form_requisicao);
         $this->onReload();
         TTransaction::close();
     } catch (Exception $e) {
         if ($e->getCode() == 23000) {
             new TMessage('error', '<b>Registro duplicado</b><br>Verifique os campos inseridos e tente novamente');
         } else {
             if ($e->getCode() == 0) {
                 new TMessage('error', '<b>Error</b> <br>' . $e->getMessage());
             } else {
                 new TMessage('error', '<b>Error Desconhecido</b> <br>Código: ' . $e->getCode());
             }
         }
         // desfazer todas as operacoes pendentes
         TTransaction::rollback();
     }
 }
Example #8
0
 function onSearch()
 {
     // pega os dados do formulario
     $data = $this->form->getData();
     // limpa os filtros da sessao
     TSession::setValue('SrpList_filter_numeroSRP', NULL);
     TSession::setValue('SrpList_filter_numeroIRP', NULL);
     TSession::setValue('SrpList_filter_numeroProcesso', NULL);
     TSession::setValue('SrpList_filter_uasg', NULL);
     TSession::setValue('SrpList_filter_validade', NULL);
     TSession::setValue('SrpList_filter_nome', NULL);
     if (isset($data->numeroSRP) and $data->numeroSRP) {
         $filter = new TFilter('numeroSRP', 'like', "%{$data->numeroSRP}%");
         // cria o filtro
         TSession::setValue('SrpList_filter_numeroSRP', $filter);
         // armazena o filtro na sessao
     }
     if (isset($data->numeroIRP) and $data->numeroIRP) {
         $filter = new TFilter('numeroIRP', 'like', "%{$data->numeroIRP}%");
         // cria o filtro
         TSession::setValue('SrpList_filter_numeroIRP', $filter);
         // armazena o filtro na sessao
     }
     if (isset($data->numeroProcesso) and $data->numeroProcesso) {
         $filter = new TFilter('numeroProcesso', 'like', "%{$data->numeroProcesso}%");
         // cria o filtro
         TSession::setValue('SrpList_filter_numeroProcesso', $filter);
         // armazena o filtro na sessao
     }
     if (isset($data->uasg) and $data->uasg) {
         $filter = new TFilter('uasg', 'like', "%{$data->uasg}%");
         // cria o filtro
         TSession::setValue('SrpList_filter_uasg', $filter);
         // armazena o filtro na sessao
     }
     if (isset($data->validade) and $data->validade) {
         $filter = new TFilter('validade', '=', TDate::date2us($data->validade));
         // cria o filtro
         TSession::setValue('SrpList_filter_validade', $filter);
         // armazena o filtro na sessao
     }
     if (isset($data->nome) and $data->nome) {
         $filter = new TFilter('nome', 'like', "%{$data->nome}%");
         // cria o filtro
         TSession::setValue('SrpList_filter_nome', $filter);
         // armazena o filtro na sessao
     }
     // fill the form with data again
     $this->form->setData($data);
     // keep the search data in the session
     TSession::setValue('Srp_filter_data', $data);
     $param = array();
     $param['offset'] = 0;
     $param['first_page'] = 1;
     $this->onReload($param);
 }
Example #9
0
 /**
  * method onSave()
  * Executed whenever the user clicks at the save button
  */
 function onSave()
 {
     try {
         // open a transaction with database 'saciq'
         TTransaction::open('saciq');
         // get the form data into an active record Usuario
         $object = $this->form->getData('Usuario');
         if (!$object->id) {
             $password = $this->form->getField('senha');
             $password->addValidation('Senha', new TMinLengthValidator(), array(4));
         } else {
             if ($object->senha) {
                 $password = $this->form->getField('senha');
                 $password->addValidation('Senha', new TMinLengthValidator(), array(4));
             }
         }
         // form validation
         $this->form->validate();
         $senha = $object->senha;
         if (!$object->id) {
             if (!$object->senha) {
                 throw new Exception('O campo Senha é obrigatório');
             }
         }
         if ($object->senha) {
             if ($object->senha != $object->resenha) {
                 throw new Exception('As senhas não conferem');
             }
             $object->senha = md5($object->senha);
         } else {
             unset($object->senha);
         }
         if ($object->grupos) {
             foreach ($object->grupos as $group) {
                 $object->addUsuarioGrupo(new Grupo($group));
             }
         }
         if ($object->funcionalidades) {
             foreach ($object->funcionalidades as $funcionalidade) {
                 $object->addUsuarioFuncionalidade($funcionalidade);
             }
         }
         $object->store();
         // stores the object
         $object->senha = '';
         $object->resenha = '';
         // fill the form with the active record data
         $this->form->setData($object);
         $usuario = new Usuario(TSession::getValue('id'));
         $funcionalidades = $usuario->getFuncionalidades();
         $funcionalidades['LoginForm'] = TRUE;
         TSession::setValue('funcionalidades', $funcionalidades);
         // close the transaction
         TTransaction::close();
         // shows the success message
         new TMessage('info', TAdiantiCoreTranslator::translate('Record saved'));
         // reload the listing
     } catch (Exception $e) {
         // Em caso de erro
         if ($e->getCode() == 23000) {
             new TMessage('error', '<b>Registro duplicado</b><br>Verifique os campos inseridos e tente novamente');
         } else {
             if ($e->getCode() == 0) {
                 new TMessage('error', '<b>Error</b> <br>' . $e->getMessage());
             } else {
                 new TMessage('error', '<b>Error Desconhecido</b> <br>Código: ' . $e->getCode());
             }
         }
         // desfazer todas as operacoes pendentes
         TTransaction::rollback();
     }
 }
Example #10
0
 /**
  * method onSearch()
  * Register the filter in the session when the user performs a search
  */
 function onSearch()
 {
     // get the search form data
     $data = $this->form->getData();
     // clear session filters
     TSession::setValue('CampusList_filter_nome', NULL);
     TSession::setValue('CampusList_filter_uasg', NULL);
     TSession::setValue('CampusList_filter_sigla', NULL);
     if (isset($data->nome) and $data->nome) {
         $filter = new TFilter('nome', 'like', "%{$data->nome}%");
         // create the filter
         TSession::setValue('CampusList_filter_nome', $filter);
         // stores the filter in the session
     }
     if (isset($data->uasg) and $data->uasg) {
         $filter = new TFilter('uasg', 'like', "%{$data->uasg}%");
         // create the filter
         TSession::setValue('CampusList_filter_uasg', $filter);
         // stores the filter in the session
     }
     if (isset($data->sigla) and $data->sigla) {
         $filter = new TFilter('sigla', 'like', "%{$data->sigla}%");
         // create the filter
         TSession::setValue('CampusList_filter_sigla', $filter);
         // stores the filter in the session
     }
     // fill the form with data again
     $this->form->setData($data);
     // keep the search data in the session
     TSession::setValue('Campus_filter_data', $data);
     $param = array();
     $param['offset'] = 0;
     $param['first_page'] = 1;
     $this->onReload($param);
 }
Example #11
0
 public function onReload($param)
 {
     //if (!isset($param['key'])){
     //    AdiantiCoreApplication::gotoPage('DocCessaoList');
     // }
     $data = new stdClass();
     if (!isset($param['key'])) {
         return;
     }
     $value = $param['key'];
     TSession::setValue('doc_cessao_form_cessao_id', $value);
     $data->cessao_id = $value;
     $this->loaded = true;
     if (isset($value)) {
         try {
             TTransaction::open('saciq');
             $cessao = new Cessao($value);
             $data->campusID = $cessao->campus_id;
             $data->campusNome = $cessao->campus->nome;
             TTransaction::close();
         } catch (Exception $e) {
             TTransaction::rollback();
         }
     }
     $this->form->setData($data);
 }
Example #12
0
 /**
  * method onSave()
  * Executed whenever the user clicks at the save button
  */
 function onSave()
 {
     try {
         $data = $this->form->getData();
         // open a transaction with database 'saciq'
         TTransaction::open('saciq');
         // cria um objeto Grupo
         $object = new Grupo($data->id);
         $object->clearParts();
         $object->nome = $data->nome;
         $object->sigla = $data->sigla;
         if ($data->list2) {
             foreach ($data->list2 as $value) {
                 $object->addFuncionalidade(new Funcionalidade($value));
             }
         }
         //if ($object->programs) {
         //    foreach ($object->programs as $program) {
         //        $object->addFuncionalidade($program);
         //    }
         //}
         $this->form->validate();
         // form validation
         $object->store();
         // stores the object
         $this->form->setData($object);
         // fill the form with the active record data
         $usuario = new Usuario(TSession::getValue('id'));
         $funcionalidades = $usuario->getFuncionalidades();
         $funcionalidades['LoginForm'] = TRUE;
         TSession::setValue('funcionalidades', $funcionalidades);
         TTransaction::close();
         // close the transaction
         new TMessage('info', 'Registro salvo');
         // shows the success message
     } catch (Exception $e) {
         // Em caso de erro
         if ($e->getCode() == 23000) {
             /*$posi = strpos($e->getMessage(), 'Duplicate entry ') + strlen('Duplicate entry ') + 1;
                             $posf = strpos($e->getMessage(), '\' for key');
                             $str = substr($e->getMessage(), $posi, 3);
             
                             $idGrupo = substr($str, 0, strpos($str, '-'));
                             $grupo = new Grupo($idGrupo);
                             $idFuncionalidade = substr($str, strpos($str, '-') + 1);
                             $funcionalidade = new Funcionalidade($idFuncionalidade);
                             new TMessage('error', '<b>Registro duplicado</b><br>A funcionalidade "' . $funcionalidade->nome . '" já foi registrada no grupo ' . $grupo->nome);
                              */
             new TMessage('error', '<b>Registro duplicado</b><br>Verifique se a sigla já não foi registrada em outro grupo');
         } else {
             if ($e->getCode() == 0) {
                 new TMessage('error', '<b>Error</b> <br>' . $e->getMessage());
             } else {
                 new TMessage('error', '<b>Error Desconhecido</b> <br>Código: ' . $e->getCode());
             }
         }
         // desfazer todas as operacoes pendentes
         TTransaction::rollback();
     }
 }
Example #13
0
 /**
  * method onSearch()
  * registrar o filtro na sessão quando o usuário realiza uma pesquisa
  */
 function onSearch()
 {
     // pegar os dados do form de busca
     $data = $this->form->getData();
     TSession::setValue('s_nome_filter', NULL);
     TSession::setValue('s_sigla_filter', NULL);
     TSession::setValue('s_nome', '');
     TSession::setValue('s_sigla', '');
     // checa se o valor foi preenchido pelo usuario
     if ($data->nome) {
         // cria o filtro usando o que o usuario digitou
         $filter = new TFilter('nome', 'like', "%{$data->nome}%");
         TSession::setValue('s_nome_filter', $filter);
         TSession::setValue('s_nome', $data->nome);
     }
     if ($data->sigla) {
         // cria o filtro usando o que o usuario digitou
         $filter = new TFilter('sigla', 'like', "%{$data->sigla}%");
         // stores the filter in the session
         TSession::setValue('s_sigla_filter', $filter);
         TSession::setValue('s_sigla', $data->sigla);
     }
     // preenche o form com os dados novamente
     $this->form->setData($data);
     $param = array();
     $param['offset'] = 0;
     $param['first_page'] = 1;
     $this->onReload($param);
 }
 /**
  * method onSearch()
  * Register the filter in the session when the user performs a search
  */
 function onSearch()
 {
     // get the search form data
     $data = $this->form->getData();
     // clear session filters
     TSession::setValue('CessaoList_filter_numeroCessao', NULL);
     if (isset($data->numeroCessao) and $data->numeroCessao) {
         $filter = new TFilter('numeroCessao', 'like', "%{$data->numeroCessao}%");
         // create the filter
         TSession::setValue('CessaoList_filter_numeroCessao', $filter);
         // stores the filter in the session
     }
     // fill the form with data again
     $this->form->setData($data);
     // keep the search data in the session
     TSession::setValue('Cessao_filter_data', $data);
     $param = array();
     $param['offset'] = 0;
     $param['first_page'] = 1;
     $this->onReload($param);
 }
 /**
  * Register the filter in the session
  */
 public function onSearch()
 {
     // get the search form data
     $data = $this->form->getData();
     if ($this->formFilters) {
         foreach ($this->formFilters as $filterKey => $formFilter) {
             $operator = isset($this->operators[$filterKey]) ? $this->operators[$filterKey] : 'like';
             $filterField = isset($this->filterFields[$filterKey]) ? $this->filterFields[$filterKey] : $formFilter;
             // check if the user has filled the form
             if (isset($data->{$formFilter}) and $data->{$formFilter}) {
                 // creates a filter using what the user has typed
                 if (stristr($operator, 'like')) {
                     $filter = new TFilter($filterField, $operator, "%{$data->{$formFilter}}%");
                 } else {
                     $filter = new TFilter($filterField, $operator, $data->{$formFilter});
                 }
                 // stores the filter in the session
                 TSession::setValue($this->activeRecord . '_filter', $filter);
                 // BC compatibility
                 TSession::setValue($this->activeRecord . '_filter_' . $formFilter, $filter);
                 TSession::setValue($this->activeRecord . '_' . $formFilter, $data->{$formFilter});
             } else {
                 TSession::setValue($this->activeRecord . '_filter', NULL);
                 // BC compatibility
                 TSession::setValue($this->activeRecord . '_filter_' . $formFilter, NULL);
                 TSession::setValue($this->activeRecord . '_' . $formFilter, '');
             }
         }
     }
     TSession::setValue($this->activeRecord . '_filter_data', $data);
     // fill the form with data again
     $this->form->setData($data);
     $param = array();
     $param['offset'] = 0;
     $param['first_page'] = 1;
     $this->onReload($param);
 }
 function onReload($param = null)
 {
     if ($this->message === false) {
         return;
     }
     try {
         //inicia uma transacao no banco
         TTransaction::open('saciq');
         //TTransaction::setLogger(new TLoggerTXT('C:\array\log.txt'));
         $repository = new TRepository('Item');
         //$limit = 10;
         $criteria = new TCriteria();
         $criteria->add(new TFilter('estoqueDisponivel', '>', '0'));
         if (!TSession::getValue('SRP_id') && !$this->continue) {
             $this->closeWindow();
             new TMessage('error', 'Número SRP Inválido');
             $this->message = false;
             return;
         }
         if (TSession::getValue('SRP_id')) {
             $criteria->add(new TFilter('srp_id', '=', TSession::getValue('SRP_id')));
         }
         //$criteria->setProperties($param);
         //$criteria->setProperty('limit', $limit);
         $ord['order'] = 'numeroItem';
         $ord['direction'] = 'asc';
         $criteria->setProperties($ord);
         // order, offset
         //filtro do numero srp
         if (TSession::getValue('ItemList_filter_numeroItem')) {
             $criteria->add(TSession::getValue('ItemList_filter_numeroItem'));
             TSession::setValue('ItemList_filter_numeroItem', NULL);
         }
         if (TSession::getValue('ItemList_filter_descricaoSumaria')) {
             $criteria->add(TSession::getValue('ItemList_filter_descricaoSumaria'));
             TSession::setValue('ItemList_filter_descricaoSumaria', NULL);
         }
         if (TSession::getValue('ItemList_filter_fabricante')) {
             $criteria->add(TSession::getValue('ItemList_filter_fabricante'));
             TSession::setValue('ItemList_filter_fabricante', NULL);
         }
         $itens = $repository->load($criteria);
         $this->datagrid->clear();
         $itens_o = TSession::getValue('requisicao_itens_o');
         if ($itens) {
             foreach ($itens as $item) {
                 if (isset($itens_o) && isset($itens_o[$item->numeroItem])) {
                     $item->estoqueDisponivel += $itens_o[$item->numeroItem]->quantidade;
                 }
                 $this->datagrid->addItem($item);
             }
         }
         //reseta as propriedadso do objeto criteria para contar os registros
         $criteria->resetProperties();
         //$count = $repository->count($criteria);
         //$this->navegadorPagina->setCount($count);
         //$this->navegadorPagina->setProperties($param);
         //$this->navegadorPagina->setLimit($limit);
         //fecha a transacao
         TTransaction::close();
         $this->carregado = true;
     } catch (Exception $e) {
         if ($e->getCode() == 23000) {
             new TMessage('error', '<b>Registro duplicado</b><br>Verifique os campos inseridos e tente novamente');
         } else {
             if ($e->getCode() == 0) {
                 new TMessage('error', '<b>Error</b> <br>' . $e->getMessage());
             } else {
                 new TMessage('error', '<b>Error Desconhecido</b> <br>Código: ' . $e->getCode());
             }
         }
         // desfazer todas as operacoes pendentes
         TTransaction::rollback();
     }
 }
Example #17
0
 /**
  * Autenticates the User
  */
 function onLogin()
 {
     try {
         TTransaction::open('login');
         $data = $this->form->getData('StdClass');
         $this->form->validate();
         $user = Usuario::autenticar($data->prontuario, $data->senha);
         if ($user) {
             $funcionalidades = $user->getFuncionalidades();
             $funcionalidades['LoginForm'] = TRUE;
             TSession::setValue('logged', TRUE);
             TSession::setValue('id', $user->id);
             TSession::setValue('nome', $user->nome);
             TSession::setValue('prontuario', $user->prontuario);
             TSession::setValue('funcionalidades', $funcionalidades);
             TApplication::gotoPage('Home');
             // reload
         }
         TTransaction::close();
     } catch (Exception $e) {
         if ($e->getCode() == 23000) {
             new TMessage('error', '<b>Registro duplicado</b><br>Verifique os campos inseridos e tente novamente');
         } else {
             if ($e->getCode() == 0) {
                 new TMessage('error', '<b>Error</b> <br>' . $e->getMessage());
             } else {
                 new TMessage('error', '<b>Error Desconhecido</b> <br>Código: ' . $e->getCode());
             }
         }
         // desfazer todas as operacoes pendentes
         TTransaction::rollback();
         TSession::setValue('logged', FALSE);
     }
 }