/**
  * 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 Cessao
         $repository = new TRepository('Cessao');
         $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', '=', '1'));
         if (TSession::getValue('CessaoList_filter_numeroCessao')) {
             $criteria->add(TSession::getValue('CessaoList_filter_numeroCessao'));
             // 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) {
                 if ($object->srp->estaVencida()) {
                     continue;
                 }
                 $object->emissao = TDate::date2br($object->emissao);
                 $object->numeroSRP = $object->srp->numeroSRP;
                 $this->datagrid->addItem($object);
             }
         }
         // 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();
     }
 }
Esempio n. 2
0
 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();
     }
 }
Esempio n. 3
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();
     }
 }
Esempio n. 4
0
 /**
  * method onGenerate()
  * Executed whenever the user clicks at the generate button
  */
 function onGenerate()
 {
     try {
         // open a transaction with database 'saciq'
         TTransaction::open('saciq');
         //TTransaction::setLogger(new TLoggerTXT("c:\\array\\LOG" . date("Ymd-His") . ".txt"));
         // get the form data into an active record
         $formdata = $this->form->getData();
         $validadeI = $formdata->validadeI;
         $validadeF = TDate::date2us($formdata->validadeF);
         if (!$validadeI === 0) {
             $validadeI = '0';
         } else {
             $validadeI = TDate::date2us($validadeI);
         }
         $this->form->validate();
         $repository = new TRepository('Srp');
         $criteria = new TCriteria();
         $param['order'] = 'id';
         $param['direction'] = 'desc';
         $criteria->setProperties($param);
         if ($formdata->numeroProcessoI != '' && $formdata->numeroProcessoF != '') {
             $criteria->add(new TFilter('numeroProcesso', 'BETWEEN', "{$formdata->numeroProcessoI}", "{$formdata->numeroProcessoF}"));
         }
         if ($formdata->validadeI != '' && $formdata->validadeF != '') {
             $criteria->add(new TFilter('validade', 'between', "{$validadeI}", "{$validadeF}"));
         }
         if ($formdata->numeroSRPI != '' && $formdata->numeroSRPF != '') {
             $criteria->add(new TFilter('numeroSRP', 'between', "{$formdata->numeroSRPI}", "{$formdata->numeroSRPF}"));
         }
         if ($formdata->numeroIRPI != '' && $formdata->numeroIRPF != '') {
             $criteria->add(new TFilter('numeroIRP', 'between', "{$formdata->numeroIRPI}", "{$formdata->numeroIRPF}"));
         }
         $imprimeZero = true;
         if (isset($formdata->itensZero)) {
             if ($formdata->itensZero === '0') {
                 $imprimeZero = false;
             }
         }
         $srps = $repository->load($criteria, true);
         if ($srps) {
             $this->pdf = new FPDF();
             $this->pdf->AliasNbPages();
             $this->pdf->SetMargins(10, 10, 10);
             $this->pdf->setHeaderCallback(array($this, 'header'));
             $this->pdf->setFooterCallback(array($this, 'footer'));
             $this->pdf->AddPage();
             foreach ($srps as $srp) {
                 $this->data = $srp;
                 $this->srpHeader($imprimeZero);
                 $this->srpItens($imprimeZero);
             }
             if (!file_exists("app/output/RelatorioSrp.pdf") or is_writable("app/output/RelatorioSrp.pdf")) {
                 $this->pdf->Output("app/output/RelatorioSrp.pdf");
             } else {
                 throw new Exception('Permissão negada' . ': ' . "app/output/RelatorioSrp.pdf");
             }
             parent::openFile("app/output/RelatorioSrp.pdf");
             //new TMessage('info', 'Relatório gerado. Por favor, habilite o pop-up do seu browser.');
         } else {
             new TMessage('error', 'Nenhum registro encontrado');
         }
         // fill the form with the active record data
         $this->form->setData($formdata);
         // close the transaction
         TTransaction::close();
     } 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();
     }
 }
 /**
  * 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();
     }
 }
Esempio n. 6
0
 /**
  * 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();
     }
 }
Esempio n. 7
0
 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();
     }
 }
 /**
  * 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();
     }
 }
Esempio n. 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();
     }
 }
Esempio n. 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();
     }
 }
Esempio n. 11
0
 function onReload($param)
 {
     $this->dg_UltImportacao->clear();
     $this->dg_UltRequisicao->clear();
     $this->dg_UltCesssao->clear();
     $this->dg_SRPAVencer->clear();
     try {
         TTransaction::open('saciq');
         //TTransaction::setLogger(new TLoggerTXT("c:\\array\\LOG".date("Ymd-His").".txt"));
         //ultimas importações
         $criteriaUI = new TCriteria();
         $param['order'] = 'id';
         $param['direction'] = 'desc';
         $criteriaUI->setProperties($param);
         $criteriaUI->setProperty('limit', 8);
         $repositoryUI = new TRepository('Srp');
         $srps = $repositoryUI->load($criteriaUI, false);
         foreach ($srps as $srp) {
             $srp->validade = TDate::date2br($srp->validade);
             $this->dg_UltImportacao->addItem($srp);
         }
         //ultimas Requisições
         $criteriaUR = new TCriteria();
         $param['order'] = 'emissao';
         $param['direction'] = 'desc';
         $criteriaUR->setProperties($param);
         $criteriaUR->setProperty('limit', 8);
         $repositoryUR = new TRepository('Requisicao');
         $requisicoes = $repositoryUR->load($criteriaUR, false);
         foreach ($requisicoes as $requisicao) {
             $requisicao->numeroSRP = $requisicao->srp->numeroSRP;
             $requisicao->aprovado = $requisicao->aprovado == 0 ? 'Não' : 'Sim';
             $requisicao->emissao = TDate::date2br($requisicao->emissao);
             $this->dg_UltRequisicao->addItem($requisicao);
         }
         //Atas a vencer
         $criteriaAV = new TCriteria();
         $param['order'] = 'validade';
         $param['direction'] = 'asc';
         $criteriaAV->setProperties($param);
         $criteriaAV->setProperty('limit', 8);
         $criteriaAV->add(new TFilter('validade', '>=', date("Y-m-d")));
         $repositoryAV = new TRepository('Srp');
         $atasAVencer = $repositoryAV->load($criteriaAV, false);
         foreach ($atasAVencer as $atas) {
             $atas->validade = TDate::date2br($atas->validade);
             $this->dg_SRPAVencer->addItem($atas);
         }
         //ultimas Cessões
         $criteriaUC = new TCriteria();
         $param['order'] = 'emissao';
         $param['direction'] = 'desc';
         $criteriaUC->setProperties($param);
         $criteriaUC->setProperty('limit', 8);
         $repositoryUC = new TRepository('Cessao');
         $cessoes = $repositoryUC->load($criteriaUC, false);
         foreach ($cessoes as $cessao) {
             $cessao->numeroSRP = $cessao->srp->numeroSRP;
             $cessao->aprovado = $cessao->aprovado == 0 ? 'Não' : 'Sim';
             $cessao->emissao = TDate::date2br($cessao->emissao);
             $this->dg_UltCesssao->addItem($cessao);
         }
         $this->loaded = true;
         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();
     }
 }