/** * BancoDataGrid constructor. */ public function __construct() { parent::__construct(); parent::setDatabase('sobcontrole'); parent::setActiveRecord('banco'); parent::setFilterField('nome'); parent::setDefaultOrder('nome', 'asc'); /** @var TQuickForm $this */ $this->form = new \Adianti\Widget\Wrapper\TQuickForm('BancoDataGrid'); $this->form->setFormTitle('Cadastro Bancos'); $this->form->class = 'tform'; $nome = new \Adianti\Widget\Form\TEntry('nome'); $this->form->addQuickField('Nome: ', $nome, 250); $this->form->addQuickAction('Buscar', new \Adianti\Control\TAction(array($this, 'onSearch')), 'ico_find.png'); $this->form->addQuickAction('Novo', new \Adianti\Control\TAction(array('BancoFormView', 'onClear')), 'ico_new.png'); $this->form->setData(\Adianti\Registry\TSession::getValue('banco_filtro')); $this->datagrid = new \Adianti\Widget\Wrapper\TQuickGrid(); $this->datagrid->style = 'width: 100%'; $this->datagrid->setHeight(300); $this->datagrid->addQuickColumn('ID', 'idbanco', 'right', 50, new \Adianti\Control\TAction(array($this, 'onReload')), array('order', 'idbanco')); $this->datagrid->addQuickColumn('Nome', 'nome', 'right', 250, new \Adianti\Control\TAction(array($this, 'onReload')), array('order', 'nome')); $this->datagrid->addQuickColumn('Sigla', 'sigla', 'right', 100, new \Adianti\Control\TAction(array($this, 'onReload')), array('order', 'sigla')); $this->datagrid->addQuickAction('Editar', new \Adianti\Widget\Datagrid\TDataGridAction(array('BancoFormView', 'onEdit')), 'idbanco', 'ico_edit.png'); $this->datagrid->addQuickAction('Excluir', new \Adianti\Widget\Datagrid\TDataGridAction(array($this, 'onDelete')), 'idbanco', 'ico_delete.png'); $this->datagrid->createModel(); $this->pageNavigation = new \Adianti\Widget\Datagrid\TPageNavigation(); $this->pageNavigation->setAction(new \Adianti\Control\TAction(array($this, 'onReload'))); $this->pageNavigation->setWidth($this->datagrid->getWidth()); $vbox = new TVBox(); $vbox->add(new \Adianti\Widget\Util\TXMLBreadCrumb('menu.xml', 'BancoFormView')); $vbox->add($this->form); $vbox->add($this->datagrid); $vbox->add($this->pageNavigation); parent::add($vbox); }
public function __construct() { parent::__construct(); parent::setDatabase(APPLICATION_NAME); parent::setActiveRecord('contabancaria'); parent::setFilterField('conta'); parent::setDefaultOrder('conta', 'asc'); /** @var TQuickForm $this */ $this->form = new \Adianti\Widget\Wrapper\TQuickForm('ContabancariaDataGrid'); $this->form->setFormTitle('Cadastro Contas Bancárias'); $this->form->class = 'tform'; $conta = new \Adianti\Widget\Form\TEntry('conta'); $this->form->addQuickField('Conta: ', $conta, 100); $this->form->addQuickAction('Buscar', new TAction(array($this, 'onSearch')), 'ico_find.png'); $this->form->addQuickAction('Novo', new TAction(array('ContabancariaFormView', 'onClear')), 'ico_new.png'); $this->form->setData(\Adianti\Registry\TSession::getValue('contabancaria_filtro')); $this->datagrid = new \Adianti\Widget\Wrapper\TQuickGrid(); $this->datagrid->style = 'width: 100%'; $this->datagrid->setHeight(230); //$this->datagrid->addQuickColumn('ID','idcontabancaria','right',40,new TAction(array($this,'onReload')),array('order','idcontabancaria')); $this->datagrid->addQuickColumn('Agência', 'agencia', 'right', 40, new TAction(array($this, 'onReload')), array('order', 'agencia')); $this->datagrid->addQuickColumn('Conta', 'conta', 'right', 100, new TAction(array($this, 'onReload')), array('order', 'conta')); $this->datagrid->addQuickColumn('Banco', 'banco->nome', 'right', 200, new TAction(array($this, 'onReload')), array('order', 'banco->nome')); $this->datagrid->addQuickColumn('Tipo Conta', 'tipocontabancaria->descricao', 'right', 120, new TAction(array($this, 'onReload')), array('order', 'tipocontabancaria->descricao')); $this->datagrid->addQuickColumn('Titular', 'titular', 'right', 40, new TAction(array($this, 'onReload')), array('order', 'titular')); $this->datagrid->addQuickColumn('Cidade', 'cidade->nome', 'right', 100, new TAction(array($this, 'onReload')), array('order', 'cidade->nome')); $this->datagrid->addQuickAction('Editar', new TDataGridAction(array('ContabancariaFormView', 'onEdit')), 'idcontabancaria', 'ico_edit.png'); $this->datagrid->addQuickAction('Excluir', new TDataGridAction(array($this, 'onDelete')), 'idcontabancaria', 'ico_delete.png'); $this->datagrid->createModel(); $this->pageNavigation = new \Adianti\Widget\Datagrid\TPageNavigation(); $this->pageNavigation->setAction(new \Adianti\Control\TAction(array($this, 'onReload'))); $this->pageNavigation->setWidth($this->datagrid->getWidth()); $vbox = new TVBox(); $vbox->add(new \Adianti\Widget\Util\TXMLBreadCrumb('menu.xml', 'ContabancariaFormView')); $vbox->add($this->form); $vbox->add($this->datagrid); $vbox->add($this->pageNavigation); parent::add($vbox); }
public function __construct() { parent::__construct(); parent::setDatabase(APPLICATION_NAME); parent::setActiveRecord('pessoa'); parent::setFilterField('nome'); parent::setDefaultOrder('nome', 'asc'); /** @var TQuickForm $this */ $this->form = new \Adianti\Widget\Wrapper\TQuickForm('PessoaDataGrid'); $this->form->setFormTitle('Cadastro de Pessoas'); $this->form->class = 'tform'; $nome = new \Adianti\Widget\Form\TEntry('nome'); $this->form->addQuickField('Nome: ', $nome, 300); $this->form->addQuickAction('Buscar', new TAction(array($this, 'onSearch')), 'ico_find.png'); $this->form->addQuickAction('Novo', new TAction(array('PessoaFormView', 'onClear')), 'ico_new.png'); $this->form->setData(\Adianti\Registry\TSession::getValue('pessoa_filtro')); $this->datagrid = new \Adianti\Widget\Wrapper\TQuickGrid(); $this->datagrid->style = 'width: 100%'; $this->datagrid->setHeight(230); //$this->datagrid->addQuickColumn('ID','idpessoa','right',40,new TAction(array($this,'onReload')),array('order','idpessoa')); $this->datagrid->addQuickColumn('Nome', 'nome', 'right', 300, new TAction(array($this, 'onReload')), array('order', 'nome')); $this->datagrid->addQuickColumn('Natureza', 'natureza', 'right', 50, new TAction(array($this, 'onReload')), array('order', 'natureza')); $this->datagrid->addQuickColumn('Dt.Cadastro', 'dtcadastro', 'right', 40, new TAction(array($this, 'onReload')), array('order', 'dtcadastro')); $this->datagrid->addQuickColumn('Dt.Nascimento', 'dtnascimento', 'right', 40, new TAction(array($this, 'onReload')), array('order', 'dtnascimento')); $this->datagrid->addQuickColumn('Ramo Atividade', 'ramoatividade->descricao', 'right', 100, new TAction(array($this, 'onReload')), array('order', 'ramoatividade->descricao')); $this->datagrid->addQuickAction('Editar', new TDataGridAction(array('PessoaFormView', 'onEdit')), 'idpessoa', 'ico_edit.png'); $this->datagrid->addQuickAction('Excluir', new TDataGridAction(array($this, 'onDelete')), 'idpessoa', 'ico_delete.png'); $this->datagrid->createModel(); $this->pageNavigation = new \Adianti\Widget\Datagrid\TPageNavigation(); $this->pageNavigation->setAction(new \Adianti\Control\TAction(array($this, 'onReload'))); $this->pageNavigation->setWidth($this->datagrid->getWidth()); $vbox = new TVBox(); $vbox->add(new \Adianti\Widget\Util\TXMLBreadCrumb('menu.xml', 'PessoaFormView')); $vbox->add($this->form); $vbox->add($this->datagrid); $vbox->add($this->pageNavigation); parent::add($vbox); }
/** * 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(); } }
public function onSave($param) { try { $this->form_cessao->validate(); // validate form data $form_cessao_data = $this->form_cessao->getData(); $form_cessao = TSession::getValue('form_cessao'); $form_cessao->numeroCessao = $form_cessao_data->numeroCessao; $form_cessao->campusID = $form_cessao_data->campusID; $form_cessao->campusNome = $form_cessao_data->campusNome; $form_cessao->emissao = $form_cessao_data->emissao; $cessao_itens = TSession::getValue('cessao_itens'); if (!isset($cessao_itens) || count($cessao_itens) == 0) { new TMessage('error', 'Insira ao menos 1 item'); return; } TTransaction::open('saciq'); if ($cessao_itens) { $id = isset($form_cessao->id) ? $form_cessao->id : NULL; $cessao = new Cessao($id); // create a new Sale $cessao->clearParts(); $cessao->numeroCessao = $form_cessao->numeroCessao; $cessao->campus = new Campus($form_cessao->campusID); $cessao->emissao = TDate::date2us($form_cessao->emissao); //if (!$cessao->emissao){ // $cessao->emissao = date("Y-m-d"); //} $cessao->aprovado = 0; $cessao->srp = new Srp(TSession::getValue('SRP_id')); foreach ($cessao_itens as $item) { $item_cessao = new Item($item->item_id); $item_cessao->quantidade = $item->quantidade; $item_cessao->quantidade = str_replace('.', '', $item->quantidade); $item_cessao->quantidade = str_replace(',', '.', $item->quantidade); $cessao->addItem($item_cessao); // add the item to the Sale } $cessao->store(); // store the Sale TSession::delValue('cessao_itens'); TSession::delValue('form_cessao'); TSession::delValue('SRP_id'); new TMessage('info', 'Cessão salva'); } TTransaction::close(); $this->onReload(); } 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()); } } } }
public function createfile($filename) { //pega o usuário salvo na sessão $usuario = TSession::getValue('nome'); //adiciona o autor no arquivo $this->objPHPExcel->getProperties()->setCreator($usuario)->setLastModifiedBy($usuario); $sheet = $this->objPHPExcel->setActiveSheetIndex(0); $criteria = new TCriteria(); $criteria->add(new TFilter('sigla', '=', CAMPUS)); $rep = new TRepository('Campus'); $campusRep = $rep->load($criteria); if (isset($campusRep[0])) { $campus = $campusRep[0]; } else { throw new Exception('Erro na seleção do câmpus'); } $cabecalho = "REQUISIÇÕES DA ATA DE REGISTO DE PREÇOS SRP " . $this->array_obj[0]->NroSrp . " (" . $this->array_obj[0]->NomeLicitacao . ") - " . $campus->nome; //style $style_titulo = array('font' => array('name' => 'Arial', 'size' => 16, 'underline' => true, 'bold' => true), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER)); $style_headers = array('font' => array('name' => 'Arial', 'size' => 12, 'bold' => true), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER, 'wrap' => true), 'borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN, 'color' => array('argb' => 'FFFF0000')))); $style_data = array('font' => array('name' => 'Arial', 'size' => 12), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER, 'wrap' => true), 'borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN, 'color' => array('argb' => 'FFFF0000')))); $style_subtotal = array('font' => array('name' => 'Arial', 'size' => 12), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER, 'wrap' => true), 'borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN, 'color' => array('argb' => 'FF000000'))), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'startcolor' => array('argb' => 'FFD9D9D9'))); $sheet->getStyle('A1:W1')->applyFromArray($style_titulo); $sheet->getStyle('A2:W2')->applyFromArray($style_headers); $sheet->getDefaultRowDimension()->setRowHeight(72.75); //define a largura das colunas $sheet->getColumnDimension('A')->setWidth(18); $sheet->getColumnDimension('B')->setWidth(33); $sheet->getColumnDimension('C')->setWidth(12); $sheet->getColumnDimension('D')->setWidth(33); $sheet->getColumnDimension('E')->setWidth(12); $sheet->getColumnDimension('F')->setWidth(56); $sheet->getColumnDimension('G')->setWidth(19); $sheet->getColumnDimension('H')->setWidth(22); $sheet->getColumnDimension('I')->setWidth(24); $sheet->getColumnDimension('J')->setWidth(15); $sheet->getColumnDimension('K')->setWidth(15); $sheet->getColumnDimension('L')->setWidth(15); $sheet->getColumnDimension('M')->setWidth(15); $sheet->getColumnDimension('N')->setWidth(18); $sheet->getColumnDimension('O')->setWidth(12); $sheet->getColumnDimension('P')->setWidth(49); $sheet->getColumnDimension('Q')->setWidth(18); $sheet->getColumnDimension('R')->setWidth(20); $sheet->getColumnDimension('S')->setWidth(25); $sheet->getColumnDimension('T')->setWidth(84); $sheet->getColumnDimension('U')->setWidth(27); $sheet->getColumnDimension('V')->setWidth(25); $sheet->getColumnDimension('W')->setWidth(49); //adiciona o cabeçalho $sheet->setCellValue('A1', $cabecalho); $sheet->mergeCells('A1:W1'); $sheet->setCellValue('A2', 'DATA REQUISIÇÃO'); $sheet->setCellValue('B2', 'Nº PROC AQUISIÇÃO'); $sheet->setCellValue('C2', 'Nº SRP'); $sheet->setCellValue('D2', 'PROC ORIG'); $sheet->setCellValue('E2', 'UASG'); $sheet->setCellValue('F2', 'NOME DA LICITAÇÃO'); $sheet->setCellValue('G2', 'SUBELEMENTO'); $sheet->setCellValue('H2', 'VALIDADE DA ATA'); $sheet->setCellValue('I2', 'PRAZO DE ENTREGA'); $sheet->setCellValue('J2', 'ESTIMATIVO CAMPUS'); $sheet->setCellValue('K2', 'ORÇAMENTO CAMPUS'); $sheet->setCellValue('L2', 'CAMPUS DE DESTINO'); $sheet->setCellValue('M2', 'LOCAL DE ENTREGA'); $sheet->setCellValue('N2', "MARQUE COM UM 'X' NOS ITENS NÃO EMPENHADOS"); $sheet->setCellValue('O2', 'ITEM'); $sheet->setCellValue('P2', 'DESCRIÇÃO SUMÁRIA'); $sheet->setCellValue('Q2', 'QTD SOLICITADA'); $sheet->setCellValue('R2', 'VALOR LICITADO UNITÁRIO'); $sheet->setCellValue('S2', 'VALOR LICITADO TOTAL'); $sheet->setCellValue('T2', 'FORNECEDOR'); $sheet->setCellValue('U2', 'CNPJ'); $sheet->setCellValue('V2', 'CONTRATO'); $sheet->setCellValue('W2', 'JUSTIFICATIVA DA AQUISIÇÃO POR ITEM'); $row = 3; $fornecedor = $this->array_obj[0]->fornecedor; $fornecedor_startCel = "S{$row}"; $fornecedor_endCel = "S{$row}"; foreach ($this->array_obj as $obj) { if ($fornecedor != $obj->fornecedor) { $sheet->setCellValueByColumnAndRow(18, $row, "=SUBTOTAL(9,{$fornecedor_startCel}:{$fornecedor_endCel})"); $sheet->getStyleByColumnAndRow(18, $row)->getNumberFormat()->setFormatCode('_("R$ "* #.##0,00_);_("R$ "* (#.##0,00);_("R$ "* "-"??_);_(@_)'); $sheet->setCellValueByColumnAndRow(19, $row, $fornecedor . ' Total'); $sheet->getStyle("A{$row}:W{$row}")->applyFromArray($style_subtotal); $fornecedor = $obj->fornecedor; $row++; $fornecedor_startCel = "S{$row}"; } $sheet->setCellValueByColumnAndRow(0, $row, $obj->DataRequisicao); $sheet->setCellValueByColumnAndRow(1, $row, $obj->NroProcAquisicao); $sheet->setCellValueByColumnAndRow(2, $row, $obj->NroSrp); $sheet->setCellValueByColumnAndRow(3, $row, $obj->ProcOrig); $sheet->setCellValueByColumnAndRow(4, $row, $obj->UASG); $sheet->setCellValueByColumnAndRow(5, $row, $obj->NomeLicitacao); $sheet->setCellValueByColumnAndRow(6, $row, $obj->SubElemento); $sheet->setCellValueByColumnAndRow(7, $row, $obj->ValidadeAta); $sheet->setCellValueByColumnAndRow(8, $row, $obj->PrazoEntrega); $sheet->setCellValueByColumnAndRow(9, $row, $obj->EstimativoCampus); $sheet->setCellValueByColumnAndRow(10, $row, $obj->OrcamentoCampus); $sheet->setCellValueByColumnAndRow(11, $row, $obj->CampusDestino); $sheet->setCellValueByColumnAndRow(12, $row, $obj->LocalEntrega); $sheet->setCellValueByColumnAndRow(13, $row, ''); $sheet->setCellValueByColumnAndRow(14, $row, $obj->Item); $sheet->setCellValueByColumnAndRow(15, $row, $obj->DescricaoSumaria); $sheet->setCellValueByColumnAndRow(16, $row, $obj->QtdSolicitada); $sheet->setCellValueByColumnAndRow(17, $row, $obj->ValorLicitadoUnitario); $sheet->setCellValueByColumnAndRow(18, $row, "=Q{$row}*R{$row}"); $sheet->getStyleByColumnAndRow(18, $row)->getNumberFormat()->setFormatCode('_("R$ "* #.##0,00_);_("R$ "* (#.##0,00);_("R$ "* "-"??_);_(@_)'); $sheet->setCellValueByColumnAndRow(19, $row, $obj->fornecedor); $sheet->setCellValueByColumnAndRow(20, $row, $this->mask($obj->cnpj, '##.###.###/####-##')); $sheet->setCellValueByColumnAndRow(21, $row, ''); $sheet->setCellValueByColumnAndRow(22, $row, $obj->justificativa); $sheet->getStyle("A{$row}:W{$row}")->applyFromArray($style_data); $fornecedor_endCel = "S{$row}"; $row++; } //$sheet->setCellValueByColumnAndRow(18, $row, "=SUBTOTAL(9;{$fornecedor_startCel}:{$fornecedor_endCel})"); //$sheet->setCellValueExplicitByColumnAndRow(18, $row, '=SUM(S3:S4)'); $sheet->setCellValueByColumnAndRow(18, $row, "=SUBTOTAL(9,{$fornecedor_startCel}:{$fornecedor_endCel})"); $sheet->getStyleByColumnAndRow(18, $row)->getNumberFormat()->setFormatCode('_("R$ "* #.##0,00_);_("R$ "* (#.##0,00);_("R$ "* "-"??_);_(@_)'); $sheet->setCellValueByColumnAndRow(19, $row, $fornecedor . ' Total'); $sheet->getStyle("A{$row}:W{$row}")->applyFromArray($style_subtotal); $row++; $sheet->setCellValueByColumnAndRow(18, $row, "=SUBTOTAL(9,S3:{$fornecedor_endCel})"); $sheet->getStyleByColumnAndRow(18, $row)->getNumberFormat()->setFormatCode('_("R$ "* #.##0,00_);_("R$ "* (#.##0,00);_("R$ "* "-"??_);_(@_)'); $sheet->setCellValueByColumnAndRow(19, $row, 'Total Geral'); $sheet->getStyle("A{$row}:W{$row}")->applyFromArray($style_subtotal); $row++; $this->objPHPExcel->setActiveSheetIndex(0); /* // Redirect output to a client’s web browser (Excel2007) header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Disposition: attachment;filename="' . $filename . '.xlsx"'); header('Cache-Control: max-age=0'); // If you're serving to IE 9, then the following may be needed header('Cache-Control: max-age=1'); // If you're serving to IE over SSL, then the following may be needed header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified header('Cache-Control: cache, must-revalidate'); // HTTP/1.1 header('Pragma: public'); // HTTP/1.0 */ $file = "app/output/" . $filename . ".xlsx"; $objWriter = PHPExcel_IOFactory::createWriter($this->objPHPExcel, 'Excel2007'); $objWriter->save($file); /* header("Pragma: public"); header("Expires: 0"); // set expiration time header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); header("Content-Length: " . filesize($file)); header("Content-disposition: inline; filename=\"{$file}\""); header("Content-Transfer-Encoding: binary"); //echo file_get_contents($file); readfile($file); */ }
/** * 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(); } }
/** * Select the register by ID and return the information to the main form * When using onblur signal, AJAX passes all needed parameters via GET * instead of calling onSetup before. */ public static function onSelect($param) { $key = $param['key']; $database = isset($param['database']) ? $param['database'] : TSession::getValue('standard_seek_database'); $receive_key = isset($param['receive_key']) ? $param['receive_key'] : TSession::getValue('standard_seek_receive_key'); $receive_field = isset($param['receive_field']) ? $param['receive_field'] : TSession::getValue('standard_seek_receive_field'); $display_field = isset($param['display_field']) ? $param['display_field'] : TSession::getValue('standard_seek_display_field'); $parent = isset($param['parent']) ? $param['parent'] : TSession::getValue('standard_seek_parent'); try { TTransaction::open($database); // load the active record $model = isset($param['model']) ? $param['model'] : TSession::getValue('standard_seek_model'); $activeRecord = new $model($key); $pk = constant("{$model}::PRIMARYKEY"); $object = new StdClass(); $object->{$receive_key} = isset($activeRecord->{$pk}) ? $activeRecord->{$pk} : ''; $object->{$receive_field} = isset($activeRecord->{$display_field}) ? $activeRecord->{$display_field} : ''; TTransaction::close(); TForm::sendData($parent, $object); parent::closeWindow(); // closes the window } catch (Exception $e) { // clear fields $object = new StdClass(); $object->{$receive_key} = ''; $object->{$receive_field} = ''; TForm::sendData($parent, $object); // undo all pending operations TTransaction::rollback(); } }
new TSession(); $menu_string = ''; if (TSession::getValue('logged')) { $content = file_get_contents("app/templates/{$template}/layout.html"); ob_start(); $callback = array('PermissaoSistema', 'checkPermission'); $xml = new SimpleXMLElement(file_get_contents('menu.xml')); $menu = new TMenu($xml, $callback, 0, 'nav collapse', ''); $menu->class = 'nav'; $menu->id = 'side-menu'; $menu->show(); $menu_string = ob_get_clean(); } else { $content = file_get_contents("app/templates/{$template}/login.html"); } $content = TApplicationTranslator::translateTemplate($content); $content = str_replace('{LIBRARIES}', file_get_contents("app/templates/{$template}/libraries.html"), $content); $content = str_replace('{URI}', $uri, $content); $content = str_replace('{class}', isset($_REQUEST['class']) ? $_REQUEST['class'] : '', $content); $content = str_replace('{template}', $template, $content); $content = str_replace('{MENU}', $menu_string, $content); $content = str_replace('{username}', TSession::getValue('nome'), $content); $css = TPage::getLoadedCSS(); $js = TPage::getLoadedJS(); $content = str_replace('{HEAD}', $css . $js, $content); if (isset($_REQUEST['class']) and TSession::getValue('logged')) { $url = "class=Home"; //http_build_query($_REQUEST); $content = str_replace('//#javascript_placeholder#', "__adianti_load_page('engine.php?{$url}');", $content); } echo $content;
/** * 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(); } }
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(); } }
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(); } }
public function onSave($param) { try { $this->form_requisicao->validate(); // validate form data $form_requisicao_data = $this->form_requisicao->getData(); $form_requisicao = TSession::getValue('form_requisicao'); $form_requisicao->numeroProcesso = $form_requisicao_data->numeroProcesso; $form_requisicao->emissao = $form_requisicao_data->emissao; $requisicao_itens = TSession::getValue('requisicao_itens'); if (!isset($requisicao_itens) || count($requisicao_itens) == 0) { new TMessage('error', 'Insira ao menos 1 item'); return; } TTransaction::open('saciq'); //TTransaction::setLogger(new \Adianti\Log\TLoggerTXT("c:\\array\\LOG".date("Ymd-His").".txt")); if ($requisicao_itens) { $id = isset($form_requisicao->id) ? $form_requisicao->id : NULL; $requisicao = new Requisicao($id); // create a new Sale $requisicao->clearParts(); $requisicao->numeroProcesso = $form_requisicao->numeroProcesso; $requisicao->emissao = TDate::date2us($form_requisicao->emissao); //if (!$requisicao->emissao){ // $requisicao->emissao = date("Y-m-d"); //} $requisicao->aprovado = 0; $requisicao->srp = new Srp(TSession::getValue("SRP_id")); foreach ($requisicao_itens as $item) { $item_requisicao = new Item($item->item_id); $item_requisicao->justificativa = $item->justificativa; $item_requisicao->quantidade = $item->quantidade; $item_requisicao->prazoEntrega = $item->prazoEntrega; $item_requisicao->quantidade = str_replace('.', '', $item->quantidade); $item_requisicao->quantidade = str_replace(',', '.', $item->quantidade); $requisicao->addItem($item_requisicao); // add the item to the Sale } $requisicao->store(); // store the Sale TSession::delValue('requisicao_itens'); TSession::delValue('form_requisicao'); TSession::delValue('SRP_id'); new TMessage('info', 'Requisição salva'); } TTransaction::close(); $this->onReload(); } 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()); } } } }
/** * 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); if ($this->formFilters) { foreach ($this->formFilters as $filterKey => $filterField) { if (TSession::getValue($this->activeRecord . '_filter_' . $filterField)) { // add the filter stored in the session to the criteria $criteria->add(TSession::getValue($this->activeRecord . '_filter_' . $filterField)); } } } // load the objects according to criteria $objects = $repository->load($criteria, FALSE); if (is_callable($this->transformCallback)) { call_user_func($this->transformCallback, $objects, $param); } $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 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(); } }
function __construct() { parent::__construct(); $this->form = new TForm('doc_cessao_form'); $this->form->style = 'width : 500px;'; $this->form->class = 'tform'; $table = new TTable(); $table->width = '100%'; $this->form->add($table); $row = $table->addRow(); $row->class = 'tformtitle'; // CSS class $row->addCell(new TLabel('Gerar Documentos da Cessão'))->colspan = 2; // cria os campos do formulário $memorando = new TEntry('memorando'); //$cidade = new TEntry('cidade'); $emissao = new TDate('emissao'); $campusID = new TEntry('campusID'); //TDBSeekButton('campusID', 'saciq', 'doc_cessao_form', 'Campus', 'nome', 'campusID', 'campusNome'); $campusNome = new TEntry('campusNome'); $gerente = new TEntry('gerente'); $diretor = new TEntry('diretor'); $cessao_id = new THidden('cessao_id'); // define the sizes $memorando->setSize(300); //$cidade->setSize(200); $emissao->setSize(90); $emissao->setProperty('style', 'margin-right : 0px'); $campusID->setSize(50); $campusID->setEditable(false); $campusNome->setSize(226); $campusNome->setEditable(false); $gerente->setSize(300); $diretor->setSize(300); //mascara $emissao->setMask('dd/mm/yyyy'); $emissao->setValue(date('d/m/Y')); //validadores $memorando->addValidation('Memorando', new TRequiredValidator()); $memorando->addValidation('Memorando', new TMaxLengthValidator(), array(70)); $emissao->addValidation('Emissão', new TRequiredValidator()); $campusID->addValidation('Destino', new TRequiredValidator()); $gerente->addValidation('Gerente Administrativo(a)', new TRequiredValidator()); $gerente->addValidation('Gerente Administrativo(a)', new TMaxLengthValidator(), array(70)); $diretor->addValidation('Diretor(a) Geral', new TRequiredValidator()); $diretor->addValidation('Diretor(a) Geral', new TMaxLengthValidator(), array(70)); $memorando->setTip('Descrição do Memorando que aparecerá no início do documento.'); $gerente->setTip('Nome do gerente em exercício'); $diretor->setTip('Nome do diretor geral em exercício'); $value = TSession::getValue('doc_cessao_form_cessao_id'); if (isset($value)) { $cessao_id->setValue($value); } // add one row for each form field $table->addRowSet(new TLabel('Memorando:'), $memorando); //$table->addRowSet(new TLabel('Cidade:'), $cidade); $table->addRowSet(new TLabel('Emissão:'), $emissao); //$table->addRowSet(new TLabel('Destino:'), $destino); //$row = $table->addRow(); $box = new THBox(); $box->add($campusID); $box->add($campusNome)->style = 'width: 75%; display : inline-block;'; //$row->addCell($box)->colspan = 2; $table->addRowSet(new TLabel('Destino:'), $box); $table->addRowSet(new TLabel('Gerente Administrativo(a):'), $gerente); $table->addRowSet(new TLabel('Diretor(a):'), $diretor); $table->addRowSet($cessao_id); $this->form->setFields(array($memorando, $emissao, $campusID, $campusNome, $gerente, $diretor, $cessao_id)); // keep the form filled during navigation with session data $this->form->setData(TSession::getValue('Cessao_filter_data')); // create two action buttons to the form $generate_button = TButton::create('generate', array($this, 'onGenerate'), 'Gerar', 'fa:file-pdf-o'); $back_button = TButton::create('back', array('DocCessaoList', 'onReload'), 'Voltar', 'ico_back.png'); //$new_button = TButton::create('new', array('CessaoForm', 'onEdit'), 'Novo', 'ico_new.png'); $this->form->addField($generate_button); $this->form->addField($back_button); $buttons_box = new THBox(); $buttons_box->add($generate_button); $buttons_box->add($back_button); // add a row for the form action $row = $table->addRow(); $row->class = 'tformaction'; // CSS class $row->addCell($buttons_box)->colspan = 2; // create the page container //$container = TVBox::pack($this->form); parent::add($this->form); }
/** * 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(); } }
public function onSelect($param) { try { if (!$param['key']) { return; } if (!TSession::getValue('SRP_id') && !$this->continue) { $this->closeWindow(); new TMessage('error', 'Número SRP Inválido'); $this->message = false; return; } $key = $param['key']; TTransaction::open('saciq'); //TTransaction::setLogger(new TLoggerTXT('c:\array\file.txt')); $repository = new TRepository('Item'); $criteria = new TCriteria(); $criteria->add(new TFilter('numeroItem', '=', $key)); if (TSession::getValue('SRP_id')) { $criteria->add(new TFilter('srp_id', '=', TSession::getValue('SRP_id'))); } $itens = $repository->load($criteria); if (count($itens) > 0) { $item = $itens[0]; $itens_o = TSession::getValue('cessao_itens_o'); if (isset($itens_o) && isset($itens_o[$item->numeroItem])) { $item->estoqueDisponivel += $itens_o[$item->numeroItem]->quantidade; } if ($item->estoqueDisponivel == 0) { $obj = new stdClass(); $obj->numeroItem = ''; $obj->item_id = ''; $obj->numeroItem = ''; $obj->descricaoSumaria = ''; $obj->valorUnitario = ''; //$obj->quantidade = ''; $obj->prazoEntrega = '60 Dias'; $obj->justificativa = ''; TForm::sendData('form_itens', $obj); $this->closeWindow(); new TMessage('error', 'Item sem quantidade disponível'); $this->message = false; return; } $obj = new stdClass(); $obj->item_id = $item->id; if (strpos($item->descricaoSumaria, '–')) { $item->descricaoSumaria = str_replace('–', '-', $item->descricaoSumaria); $item->store(); } $obj->numeroItem = $item->numeroItem; $obj->descricaoSumaria = $item->descricaoSumaria; $obj->valorUnitario = $item->valorUnitario; TForm::sendData('form_itens', $obj); parent::closeWindow(); } else { $obj = new stdClass(); $obj->item_id = ''; $obj->numeroItem = ''; $obj->descricaoSumaria = ''; $obj->valorUnitario = ''; //$obj->quantidade = ''; $obj->prazoEntrega = '60 Dias'; $obj->justificativa = ''; TForm::sendData('form_itens', $obj); parent::closeWindow(); } TTransaction::close(); } catch (Exception $e) { $obj = new stdClass(); $obj->item_id = ''; $obj->descricaoSumaria = ''; $obj->valorUnitario = ''; $obj->quantidade = ''; $obj->prazoEntrega = '60 Dias'; $obj->justificativa = ''; TForm::sendData('form_itens', $obj); TTransaction::rollback(); } }
function onReload($param = null) { $this->datagrid->clear(); $key = $param['key']; if (!isset($key)) { $value = TSession::getValue('srp_form_view_key'); if (!isset($value)) { return; } $key = $value; } try { TTransaction::open('saciq'); $srp = new Srp($key); if (!isset($srp)) { TTransaction::close(); return; } $object = new stdClass(); $object->id = $srp->id; $object->numeroSRP = $srp->numeroSRP; $object->numeroIRP = $srp->numeroIRP; $object->numeroProcesso = $srp->numeroProcesso; $object->uasg = $srp->uasg; $object->validade = TDate::date2br($srp->validade); $object->nome = $srp->nome; $object->natureza = $srp->natureza->descricao; foreach ($srp->getItems() as $item) { $row = $this->datagrid->addItem($item); } TForm::sendData('SrpFormView', $object); 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(); } }
/** * method onEdit() * Executed whenever the user clicks at the edit button da datagrid */ public function onEdit($param) { try { if (isset($param['key'])) { // get the parameter $key $key = $param['key']; // open a transaction with database TTransaction::open($this->database); $class = $this->activeRecord; // instantiates object $object = new $class($key); if ($object->system_user_id == TSession::getValue("userid")) { $this->form->setData($object); // fill the form with the active record data } else { new TMessage('error', '<b>Registro não encontrado</b> '); } // close the transaction TTransaction::close(); $this->onReload($param); } else { $this->form->clear(); } } 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() * 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(); } }