/**
  * method onReload()
  * carregar o datagrid com objetos do banco
  */
 function onReload($param = NULL)
 {
     try {
         // open a transaction with database 'saciq'
         TTransaction::open('saciq');
         // creates a repository for Funcionalidade
         $repository = new TRepository('Funcionalidade');
         $limit = 10;
         // creates a criteria
         $criteria = new TCriteria();
         if (!isset($param['order'])) {
             $param['order'] = 'id';
             $param['direction'] = 'asc';
         }
         $criteria->setProperties($param);
         // order, offset
         $criteria->setProperty('limit', $limit);
         if (TSession::getValue('Funcionalidade_nome_filter')) {
             // add the filter stored in the session to the criteria
             $criteria->add(TSession::getValue('Funcionalidade_nome_filter'));
         }
         if (TSession::getValue('Funcionalidade_control_filter')) {
             // add the filter stored in the session to the criteria
             $criteria->add(TSession::getValue('Funcionalidade_control_filter'));
         }
         // load the objects according to criteria
         $objects = $repository->load($criteria);
         $this->datagrid->clear();
         if ($objects) {
             // iterate the collection of active records
             foreach ($objects as $object) {
                 // add the object inside the datagrid
                 $this->datagrid->addItem($object);
             }
         }
         // reset the criteria for record count
         $criteria->resetProperties();
         $count = $repository->count($criteria);
         $this->pageNavigation->setCount($count);
         // count of records
         $this->pageNavigation->setProperties($param);
         // order, page
         $this->pageNavigation->setLimit($limit);
         // limit
         // close the transaction
         TTransaction::close();
         $this->loaded = 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();
     }
 }
Exemple #2
0
 /**
  * Load the datagrid with the active record objects
  */
 public function onReload($param = NULL)
 {
     try {
         $model = TSession::getValue('standard_seek_model');
         $database = TSession::getValue('standard_seek_database');
         $pk = constant("{$model}::PRIMARYKEY");
         // begins the transaction with database
         TTransaction::open($database);
         // creates a repository for the model
         $repository = new TRepository($model);
         $limit = 10;
         // creates a criteria
         if (TSession::getValue('standard_seek_criteria')) {
             $criteria = clone TSession::getValue('standard_seek_criteria');
         } else {
             $criteria = new TCriteria();
             // default order
             if (empty($param['order'])) {
                 $param['order'] = $pk;
                 $param['direction'] = 'asc';
             }
         }
         $criteria->setProperties($param);
         // order, offset
         $criteria->setProperty('limit', $limit);
         if (TSession::getValue('tstandardseek_filter')) {
             // add the filter to the criteria
             $criteria->add(TSession::getValue('tstandardseek_filter'));
         }
         // load all objects according with the criteria
         $objects = $repository->load($criteria, FALSE);
         $this->datagrid->clear();
         if ($objects) {
             $display_field = TSession::getValue('standard_seek_display_field');
             foreach ($objects as $object) {
                 $item = $object;
                 $item->id = $object->{$pk};
                 $item->display_field = $object->{$display_field};
                 // add the object into the datagrid
                 $this->datagrid->addItem($item);
             }
         }
         // clear the crieteria to count the records
         $criteria->resetProperties();
         $count = $repository->count($criteria);
         $this->pageNavigation->setCount($count);
         // count of records
         $this->pageNavigation->setProperties($param);
         // order, page
         $this->pageNavigation->setLimit($limit);
         // limit
         // closes the transaction
         TTransaction::close();
         $this->loaded = true;
     } catch (Exception $e) {
         // shows the exception genearated message
         new TMessage('error', '<b>Erro</b> ' . $e->getMessage());
         // rollback all the database operations
         TTransaction::rollback();
     }
 }
 function onReload($param = null)
 {
     try {
         //inicia uma transacao no banco
         TTransaction::open('saciq');
         $repository = new TRepository('Srp');
         $limit = 10;
         $criteria = new TCriteria();
         $criteria->setProperties($param);
         //filtro do numero srp
         if (TSession::getValue('srp_numeroSRP_filter')) {
             $criteria->add(TSession::getValue('srp_numeroSRP_filter'));
         }
         if (TSession::getValue('srp_numeroProcesso_filter')) {
             $criteria->add(TSession::getValue('srp_numeroProcesso_filter'));
         }
         if (TSession::getValue('srp_nome_filter')) {
             $criteria->add(TSession::getValue('srp_nome_filter'));
         }
         $criteria->add(new TFilter('validade', '>=', date("Y-m-d")));
         $srps = $repository->load($criteria);
         $this->datagrid->clear();
         if ($srps) {
             foreach ($srps as $srp) {
                 $srp->validade = TDate::date2br($srp->validade);
                 $this->datagrid->addItem($srp);
             }
         }
         //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();
     }
 }
 /**
  * Load the datagrid with the database objects
  */
 function onReload($param = NULL)
 {
     try {
         // open a transaction with database 'samples'
         TTransaction::open('sobcontrole');
         // creates a repository for City
         $repository = new TRepository('tipocontato');
         $limit = 10;
         // creates a criteria
         $criteria = new TCriteria();
         // default order
         if (!isset($param['order'])) {
             $param['order'] = 'idtipocontato';
             $param['direction'] = 'asc';
         }
         $criteria->setProperties($param);
         // order, offset
         $criteria->setProperty('limit', $limit);
         if (TSession::getValue('tipocontato_filtro')) {
             // add the filter stored in the session to the criteria
             $criteria->add(TSession::getValue('tipocontato_filtro'));
         }
         // load the objects according to the criteria
         $tiposdecontato = $repository->load($criteria);
         $this->datagrid->clear();
         if ($tiposdecontato) {
             foreach ($tiposdecontato as $tipocontato) {
                 // add the object inside the datagrid
                 $this->datagrid->addItem($tipocontato);
             }
         }
         // reset the criteria for record count
         $criteria->resetProperties();
         $count = $repository->count($criteria);
         $this->pageNavigation->setCount($count);
         // count of records
         $this->pageNavigation->setProperties($param);
         // order, page
         $this->pageNavigation->setLimit($limit);
         // limit
         // close the transaction
         TTransaction::close();
         $this->loaded = true;
     } catch (Exception $e) {
         // shows the exception error message
         new TMessage('error', $e->getMessage());
         // undo all pending operations
         TTransaction::rollback();
     }
 }
Exemple #5
0
 function onImportFile()
 {
     $data = $this->form->getData();
     $this->importacao = new Importar();
     $this->importacao->loadFile($data->file);
     $this->importacao->setActiveRow(3);
     try {
         TTransaction::open('saciq');
         $criteria = new TCriteria();
         $criteria->add(new TFilter('numeroSRP', '=', $this->importacao->getNroSRP()));
         $criteria->add(new TFilter('numeroIRP', '=', $this->importacao->getNroIRP()));
         $criteria->add(new TFilter('numeroProcesso', '=', $this->importacao->getNumeroProcesso()));
         $criteria->add(new TFilter('uasg', '=', $this->importacao->getUasgGerenciadora()));
         $criteria->add(new TFilter('validade', '=', $this->importacao->getValidadeAta()));
         $repositorySrp = new TRepository('Srp');
         $count = $repositorySrp->count($criteria);
         if ($count > 0) {
             $RepSRP = $repositorySrp->load($criteria);
             $RepSRP[0]->delete();
         }
         $srp = null;
         while (!$this->importacao->eof()) {
             if (!$this->importacao->isValidRow()) {
                 $this->importacao->nextRow();
                 continue;
             }
             $natureza = $this->LoadObjectByField('Natureza', 'descricao', $this->importacao->getNaturezaDespesa());
             if (!isset($natureza)) {
                 $natureza = new Natureza();
                 $natureza->descricao = $this->importacao->getNaturezaDespesa();
                 $natureza->store();
             }
             $subelemento = $this->LoadObjectByField('Subelemento', 'descricao', $this->importacao->getDescricaoSubElemento());
             if (!isset($subelemento)) {
                 $subelemento = new Subelemento();
                 $subelemento->id = $this->importacao->getNumeroSubElemento();
                 $subelemento->descricao = $this->importacao->getDescricaoSubElemento();
                 $subelemento->store();
             }
             $fornecedor = $this->LoadObjectByField('Fornecedor', 'cnpj', $this->importacao->getCNPJ());
             if (!isset($fornecedor)) {
                 $fornecedor = new Fornecedor();
                 $fornecedor->nome = $this->importacao->getFornecedor();
                 $fornecedor->cnpj = $this->importacao->getCNPJ();
                 $fornecedor->store();
             }
             if (!isset($srp)) {
                 $srp = new Srp();
                 $srp->numeroSRP = $this->importacao->getNroSRP();
                 $srp->numeroIRP = $this->importacao->getNroIRP();
                 $srp->numeroProcesso = $this->importacao->getNumeroProcesso();
                 $srp->uasg = $this->importacao->getUasgGerenciadora();
                 $srp->validade = $this->importacao->getValidadeAta();
                 $srp->nome = $this->importacao->getNomeProcesso();
                 $srp->natureza = $natureza;
             }
             $item = new Item();
             $item->numeroItem = $this->importacao->getItem();
             $item->descricaoSumaria = $this->importacao->getDescricaoSumaria();
             $item->descricaoCompleta = $this->importacao->getDescricaoCompleta();
             $item->descricaoPosLicitacao = $this->importacao->getDescricaoPosLicitacao();
             $item->unidadeMedida = $this->importacao->getUnidadeDeMedida();
             $item->marca = $this->importacao->getMarca();
             $item->valorUnitario = $this->importacao->getValorUnitarioLicitado();
             $item->quantidadeDisponivel = $this->importacao->getOrgao(CAMPUS);
             $item->estoqueDisponivel = $item->quantidadeDisponivel;
             $item->fabricante = $this->importacao->getFabricante();
             $item->fornecedor = $fornecedor;
             $item->subelemento = $subelemento;
             $srp->addItem($item);
             $this->importacao->nextRow();
         }
         $srp->store();
         new TMessage('info', 'Planilha importada com sucesso');
         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();
     }
     $this->notebook->setCurrentPage(0);
     $this->form->setData($data);
     $this->step->select('Seleção');
 }
 /**
  * method onReload()
  * Load the datagrid with the database objects
  */
 public function onReload($param = NULL)
 {
     try {
         // open a transaction with database
         TTransaction::open($this->database);
         // instancia um repositório
         $repository = new TRepository($this->activeRecord);
         $limit = isset($this->limit) ? $this->limit > 0 ? $this->limit : NULL : 10;
         // creates a criteria
         $criteria = new TCriteria();
         if ($this->order) {
             $criteria->setProperty('order', $this->order);
             $criteria->setProperty('direction', $this->direction);
         }
         $criteria->setProperties($param);
         // order, offset
         $criteria->setProperty('limit', $limit);
         $criteria->add(new TFilter("system_user_id", "=", TSession::getValue("userid")));
         if (TSession::getValue($this->activeRecord . '_filter')) {
             // add the filter stored in the session to the criteria
             $criteria->add(TSession::getValue($this->activeRecord . '_filter'));
         }
         // load the objects according to criteria
         $objects = $repository->load($criteria, FALSE);
         $this->datagrid->clear();
         if ($objects) {
             // iterate the collection of active records
             foreach ($objects as $object) {
                 // add the object inside the datagrid
                 $this->datagrid->addItem($object);
             }
         }
         // reset the criteria for record count
         $criteria->resetProperties();
         $count = $repository->count($criteria);
         if (isset($this->pageNavigation)) {
             $this->pageNavigation->setCount($count);
             // count of records
             $this->pageNavigation->setProperties($param);
             // order, page
             $this->pageNavigation->setLimit($limit);
             // limit
         }
         // close the transaction
         TTransaction::close();
         $this->loaded = true;
     } catch (Exception $e) {
         // in case of exception
         // shows the exception error message
         new TMessage('error', '<b>Error</b> ' . $e->getMessage());
         // undo all pending operations
         TTransaction::rollback();
     }
 }
 /**
  * method onReload()
  * Load the datagrid with the database objects
  */
 public function onReload($param = NULL)
 {
     try {
         // open a transaction with database
         TTransaction::open($this->database);
         // instancia um repositório
         $repository = new TRepository($this->activeRecord);
         $limit = isset($this->limit) ? $this->limit > 0 ? $this->limit : NULL : 10;
         // creates a criteria
         $criteria = isset($this->criteria) ? clone $this->criteria : new TCriteria();
         if ($this->order) {
             $criteria->setProperty('order', $this->order);
             $criteria->setProperty('direction', $this->direction);
         }
         $criteria->setProperties($param);
         // order, offset
         $criteria->setProperty('limit', $limit);
         // load the objects according to criteria
         $objects = $repository->load($criteria, FALSE);
         if (is_callable($this->transformCallback)) {
             call_user_func($this->transformCallback, $objects);
         }
         $this->datagrid->clear();
         if ($objects) {
             // iterate the collection of active records
             foreach ($objects as $object) {
                 // add the object inside the datagrid
                 $this->datagrid->addItem($object);
             }
         }
         // reset the criteria for record count
         $criteria->resetProperties();
         $count = $repository->count($criteria);
         if (isset($this->pageNavigation)) {
             $this->pageNavigation->setCount($count);
             // count of records
             $this->pageNavigation->setProperties($param);
             // order, page
             $this->pageNavigation->setLimit($limit);
             // limit
         }
         // close the transaction
         TTransaction::close();
         $this->loaded = true;
     } catch (Exception $e) {
         // shows the exception error message
         new TMessage('error', $e->getMessage());
         // undo all pending operations
         TTransaction::rollback();
     }
 }
 /**
  * method onReload()
  * Load the datagrid with the database objects
  */
 function onReload($param = NULL)
 {
     try {
         // open a transaction with database 'saciq'
         TTransaction::open('saciq');
         //TTransaction::setLogger(new TLoggerTXT('c:\array\file.txt'));
         // creates a repository for Requisicao
         $repository = new TRepository('Requisicao');
         $limit = 10;
         // creates a criteria
         $criteria = new TCriteria();
         // default order
         if (empty($param['order'])) {
             $param['order'] = 'id';
             $param['direction'] = 'asc';
         }
         $criteria->setProperties($param);
         // order, offset
         $criteria->setProperty('limit', $limit);
         $criteria->add(new TFilter('aprovado', '=', '0'));
         if (TSession::getValue('RequisicaoList_filter_numeroProcesso')) {
             $criteria->add(TSession::getValue('RequisicaoList_filter_numeroProcesso'));
             // add the session filter
         }
         // load the objects according to criteria
         $objects = $repository->load($criteria, FALSE);
         $this->datagrid->clear();
         if ($objects) {
             // iterate the collection of active records
             foreach ($objects as $object) {
                 $object->emissao = TDate::date2br($object->emissao);
                 $object->numeroSRP = $object->srp->numeroSRP;
                 $this->datagrid->addItem($object);
             }
         }
         // reset the criteria for record count
         $criteria->resetProperties();
         $count = $repository->count($criteria);
         $this->pageNavigation->setCount($count);
         // count of records
         $this->pageNavigation->setProperties($param);
         // order, page
         $this->pageNavigation->setLimit($limit);
         // limit
         // close the transaction
         TTransaction::close();
         $this->loaded = true;
     } catch (Exception $e) {
         // in case of exception
         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();
     }
 }
Exemple #9
0
 /**
  * method onReload()
  * carregar o datagrid com objetos do banco
  */
 function onReload($param = NULL)
 {
     try {
         // abre uma transacao com o banco 'saciq'
         TTransaction::open('saciq');
         if (!isset($param['order'])) {
             $param['order'] = 'id';
             $param['direction'] = 'asc';
         }
         // cria um repository para Grupo
         $repository = new TRepository('Grupo');
         $limit = 10;
         // cria um criteria
         $criteria = new TCriteria();
         $criteria->setProperties($param);
         // order, offset
         $criteria->setProperty('limit', $limit);
         if (TSession::getValue('s_nome_filter')) {
             // adiciona o filtro gravado na sessao para o obj criteria.
             $criteria->add(TSession::getValue('s_nome_filter'));
         }
         if (TSession::getValue('s_sigla_filter')) {
             // adiciona o filtro gravado na sessao para o obj criteria.
             $criteria->add(TSession::getValue('s_sigla_filter'));
         }
         // carrega os objetos de acordo o filtro criteria
         $objects = $repository->load($criteria);
         $this->datagrid->clear();
         if ($objects) {
             // iterar a coleção de active records
             foreach ($objects as $object) {
                 // adiciona o objeto dentro do datagrid
                 $this->datagrid->addItem($object);
             }
         }
         // reset o criteria para o record count
         $criteria->resetProperties();
         $count = $repository->count($criteria);
         $this->pageNavigation->setCount($count);
         // quantidade de registros
         $this->pageNavigation->setProperties($param);
         // ordem, pagina
         $this->pageNavigation->setLimit($limit);
         // limite
         // fecha a transacao
         TTransaction::close();
         $this->loaded = 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();
     }
 }
Exemple #10
0
 function onReload($param = NULL)
 {
     try {
         // abre uma transação com o banco 'saciq'
         TTransaction::open('saciq');
         //TTransaction::setLogger(new \Adianti\Log\TLoggerTXT("c:\\array\\LOG".date("Ymd-His").".txt"));
         // cria um repository para Srp
         $repository = new TRepository('Srp');
         $limit = 10;
         // cria um criteria
         $criteria = new TCriteria();
         // ordem default
         if (empty($param['order'])) {
             $param['order'] = 'id';
             $param['direction'] = 'asc';
         }
         $criteria->setProperties($param);
         // ordem, offset
         $criteria->setProperty('limit', $limit);
         if (TSession::getValue('SrpList_filter_numeroSRP')) {
             $criteria->add(TSession::getValue('SrpList_filter_numeroSRP'));
             // add the session filter
         }
         if (TSession::getValue('SrpList_filter_numeroIRP')) {
             $criteria->add(TSession::getValue('SrpList_filter_numeroIRP'));
             // add the session filter
         }
         if (TSession::getValue('SrpList_filter_numeroProcesso')) {
             $criteria->add(TSession::getValue('SrpList_filter_numeroProcesso'));
             // add the session filter
         }
         if (TSession::getValue('SrpList_filter_uasg')) {
             $criteria->add(TSession::getValue('SrpList_filter_uasg'));
             // add the session filter
         }
         if (TSession::getValue('SrpList_filter_validade')) {
             $criteria->add(TSession::getValue('SrpList_filter_validade'));
             // add the session filter
         }
         if (TSession::getValue('SrpList_filter_nome')) {
             $criteria->add(TSession::getValue('SrpList_filter_nome'));
             // add the session filter
         }
         // carrega os objetos de acordo com os filtros
         $objects = $repository->load($criteria, FALSE);
         $this->datagrid->clear();
         if ($objects) {
             // iterar a coleção de active records
             foreach ($objects as $object) {
                 //muda a data para o formato brasileiro (DD/MM/YYYY)
                 $object->validade = TDate::date2br($object->validade);
                 //adiciona o objeto no datagrid
                 $this->datagrid->addItem($object);
             }
         }
         // reseta o criteria (filtro) para contagem de registros
         $criteria->resetProperties();
         $count = $repository->count($criteria);
         $this->pageNavigation->setCount($count);
         // contagem de registro
         $this->pageNavigation->setProperties($param);
         // ordem, pagina
         $this->pageNavigation->setLimit($limit);
         // limite
         // fecha a transação
         TTransaction::close();
         $this->loaded = 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();
     }
 }
Exemple #11
0
 /**
  * Method countObjects
  * @param $criteria        Optional criteria
  * @return                 An array containing the Active Records
  */
 public static function countObjects($criteria = NULL)
 {
     // get the Active Record class name
     $class = get_called_class();
     // create the repository
     $repository = new TRepository($class);
     if (!$criteria) {
         $criteria = new TCriteria();
     }
     return $repository->count($criteria);
 }