Exemplo n.º 1
1
 /**
  * Add a column
  * @param $label  Field Label
  * @param $object Field Object
  * @param $size   Field Size
  */
 public function addQuickColumn($label, $name, $align = 'left', $size = 200, TAction $action = NULL, $param = NULL)
 {
     // creates a new column
     $object = new TDataGridColumn($name, $label, $align, $size);
     if ($action instanceof TAction) {
         // create ordering
         $action->setParameter($param[0], $param[1]);
         $object->setAction($action);
     }
     // add the column to the datagrid
     parent::addColumn($object);
     return $object;
 }
Exemplo n.º 2
0
 /**
  * Class Constructor
  * @param  $name name of the form field
  * @param  $database name of the database connection
  * @param  $form name of the parent form
  * @param  $model name of the Active Record to be searched
  * @param  $display_field name of the field to be searched and shown
  * @param  $receive_key name of the form field to receive the primary key
  * @param  $receive_display_field name of the form field to receive the "display field"
  * @param  $display_field2 name of the #2 field to be searched and shown
  */
 public function __construct($name, $database, $form, $model, $display_field, $receive_key, $receive_display_field, TCriteria $criteria = NULL, $display_field2 = NULL)
 {
     parent::__construct($name);
     if (empty($database)) {
         throw new Exception(AdiantiCoreTranslator::translate('The parameter (^1) of ^2 is required', 'database', __CLASS__));
     }
     if (empty($model)) {
         throw new Exception(AdiantiCoreTranslator::translate('The parameter (^1) of ^2 is required', 'model', __CLASS__));
     }
     if (empty($display_field)) {
         throw new Exception(AdiantiCoreTranslator::translate('The parameter (^1) of ^2 is required', 'display_field', __CLASS__));
     }
     $obj = new TStandardSeek2();
     // define the action parameters
     $action = new TAction(array($obj, 'onSetup'));
     $action->setParameter('database', $database);
     $action->setParameter('parent', $form);
     $action->setParameter('model', $model);
     $action->setParameter('display_field', $display_field);
     $action->setParameter('receive_key', $receive_key);
     $action->setParameter('receive_field', $receive_display_field);
     $action->setParameter('criteria', base64_encode(serialize($criteria)));
     $action->setParameter('display_field2', $display_field2);
     parent::setAction($action);
 }
Exemplo n.º 3
0
 function onQuestionAprovarCessao($param)
 {
     if (!isset($param)) {
         return;
     }
     $key = $param['key'];
     if (!isset($key) || !$key) {
         return;
     }
     try {
         TTransaction::open('saciq');
         $Cessao = new Cessao($key);
         if ($Cessao->srp->estaVencida()) {
             new TMessage('error', 'SRP já está vencida!');
             return;
         }
         $pergunta = 'Voce realmente quer Desaprovar a seguinte Cessão?<br>' . 'SRP: ' . $Cessao->srp->numeroSRP . '<br>' . 'Nº Cessão: ' . $Cessao->numeroCessao . '<br>' . 'Emissão: ' . TDate::date2br($Cessao->emissao);
         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();
         return;
     }
     if (!isset($pergunta) || !$pergunta) {
         return;
     }
     $sim = new TAction(array($this, 'onAprovar'));
     //$nao = new TAction(array($this, 'onAction2'));
     // define os parâmetros de cada ação
     $sim->setParameter('cessao', $key);
     // shows the question dialog
     new TQuestion($pergunta, $sim);
 }
Exemplo n.º 4
0
 /**
  * Class constructor
  * Creates the page, the form and the listing
  */
 public function __construct()
 {
     parent::__construct();
     // Cria o form
     $this->form = new TForm('form_search_Funcionalidade');
     $this->form->class = 'tform';
     // cria a tabela
     $table = new TTable();
     $table->style = 'width:100%';
     $table->addRowSet(new TLabel('Consulta Funcionalidades'), '')->class = 'tformtitle';
     // adiciona a tabela no form
     $this->form->add($table);
     // cria os campos de pesquisa do form
     $nome = new TEntry('nome');
     $nome->setValue(TSession::getValue('Funcionalidade_nome'));
     $nome->setSize(500);
     $control = new TEntry('classe');
     $control->setValue(TSession::getValue('Funcionalidade_control'));
     $control->setSize(500);
     // adiciona linha para os campos de filtro
     $row = $table->addRowSet(new TLabel('Nome: '), $nome);
     $row = $table->addRowSet(new TLabel('Classe de Controle: '), $control);
     // cria dois botoes de acao para o form
     $find_button = new TButton('find');
     $new_button = new TButton('new');
     // define as acoes dos botoes
     $find_button->setAction(new TAction(array($this, 'onSearch')), 'Buscar');
     $find_button->setImage('ico_find.png');
     $new_button->setAction(new TAction(array('FuncionalidadeForm', 'onEdit')), 'Novo');
     $new_button->setImage('ico_new.png');
     // define quais sao os campos do form
     $this->form->setFields(array($nome, $control, $find_button, $new_button));
     $container = new THBox();
     $container->add($find_button);
     $container->add($new_button);
     //$container->style = "float: right";
     $row = $table->addRow();
     $row->class = 'tformaction';
     $cell = $row->addCell($container);
     $cell->colspan = 2;
     parent::include_css('app/resources/custom-table.css');
     // cria o datagrid
     $this->datagrid = new TDataGrid();
     $this->datagrid->style = 'width: 100%';
     $this->datagrid->class = 'tdatagrid_table customized-table';
     $this->datagrid->setHeight(320);
     // cria as colunas do datagrid
     $id = new TDataGridColumn('id', 'ID', 'right');
     $nome = new TDataGridColumn('nome', 'Nome', 'left');
     $classe = new TDataGridColumn('classe', 'Classe de Controle', 'left');
     // adiciona as colunas ao datagrid
     $this->datagrid->addColumn($id);
     $this->datagrid->addColumn($nome);
     $this->datagrid->addColumn($classe);
     // cria as acoes das colunas do datagrid
     $order_id = new TAction(array($this, 'onReload'));
     $order_id->setParameter('order', 'id');
     $id->setAction($order_id);
     $order_nome = new TAction(array($this, 'onReload'));
     $order_nome->setParameter('order', 'nome');
     $nome->setAction($order_nome);
     $order_classe = new TAction(array($this, 'onReload'));
     $order_classe->setParameter('order', 'classe');
     $classe->setAction($order_classe);
     // edicao inline
     $nome_edit = new TDataGridAction(array($this, 'onInlineEdit'));
     $nome_edit->setField('id');
     $nome->setEditAction($nome_edit);
     $classe_edit = new TDataGridAction(array($this, 'onInlineEdit'));
     $classe_edit->setField('id');
     $classe->setEditAction($classe_edit);
     // cria 2 acoes do datagrid
     $action1 = new TDataGridAction(array('FuncionalidadeForm', 'onEdit'));
     $action1->setLabel('Editar');
     $action1->setImage('ico_edit.png');
     $action1->setField('id');
     $action2 = new TDataGridAction(array($this, 'onDelete'));
     $action2->setLabel('Excluir');
     $action2->setImage('ico_delete.png');
     $action2->setField('id');
     // adiciona as acoes ao datagrid
     $this->datagrid->addAction($action1);
     $this->datagrid->addAction($action2);
     // cria o modelo do datagrid
     $this->datagrid->createModel();
     // cria o navegador de paginas
     $this->pageNavigation = new TPageNavigation();
     $this->pageNavigation->setAction(new TAction(array($this, 'onReload')));
     $this->pageNavigation->setWidth($this->datagrid->getWidth());
     // cria a estrutura da pagina usando tabela
     $table = new TTable();
     $table->style = 'width: 80%';
     $table->addRow()->addCell(new TXMLBreadCrumb('menu.xml', __CLASS__));
     $table->addRow()->addCell($this->form);
     $table->addRow()->addCell($this->datagrid);
     $table->addRow()->addCell($this->pageNavigation);
     // adiciona a tabela $table dentro da pagina
     parent::add($table);
 }
Exemplo n.º 5
0
 /**
  * Show the widget
  */
 public function show()
 {
     // check if it's not editable
     if (parent::getEditable()) {
         if (!TForm::getFormByName($this->formName) instanceof TForm) {
             throw new Exception(AdiantiCoreTranslator::translate('You must pass the ^1 (^2) as a parameter to ^3', __CLASS__, $this->name, 'TForm::setFields()'));
         }
         $serialized_action = '';
         if ($this->action) {
             // get the action class name
             if (is_array($callback = $this->action->getAction())) {
                 if (is_object($callback[0])) {
                     $rc = new ReflectionClass($callback[0]);
                     $classname = $rc->getShortName();
                 } else {
                     $classname = $callback[0];
                 }
                 $inst = new $classname();
                 $ajaxAction = new TAction(array($inst, 'onSelect'));
                 if (in_array($classname, array('TStandardSeek2'))) {
                     $ajaxAction->setParameter('parent', $this->action->getParameter('parent'));
                     $ajaxAction->setParameter('database', $this->action->getParameter('database'));
                     $ajaxAction->setParameter('model', $this->action->getParameter('model'));
                     $ajaxAction->setParameter('display_field', $this->action->getParameter('display_field'));
                     $ajaxAction->setParameter('receive_key', $this->action->getParameter('receive_key'));
                     $ajaxAction->setParameter('receive_field', $this->action->getParameter('receive_field'));
                     $ajaxAction->setParameter('criteria', $this->action->getParameter('criteria'));
                     $ajaxAction->setParameter('display_field2', $this->action->getParameter('display_field2'));
                 } else {
                     if ($actionParameters = $this->action->getParameters()) {
                         foreach ($actionParameters as $key => $value) {
                             $ajaxAction->setParameter($key, $value);
                         }
                     }
                 }
                 $ajaxAction->setParameter('form_name', $this->formName);
                 $string_action = $ajaxAction->serialize(FALSE);
                 if ($this->useOutEvent) {
                     $this->setProperty('seekaction', "__adianti_post_lookup('{$this->formName}', '{$string_action}', document.{$this->formName}.{$this->name})");
                     $this->setProperty('onBlur', $this->getProperty('seekaction'), FALSE);
                 }
             }
             $this->action->setParameter('form_name', $this->formName);
             $serialized_action = $this->action->serialize(FALSE);
         }
         parent::show();
         $this->button->onclick = "javascript:serialform=(\$('#{$this->formName}').serialize());\n                  __adianti_append_page('engine.php?{$serialized_action}&'+serialform)";
         $this->button->show();
         if ($this->auxiliar) {
             echo '&nbsp;';
             $this->auxiliar->show();
         }
     } else {
         parent::show();
     }
 }
Exemplo n.º 6
0
 /**
  * Prepare action for use
  * @param $action TAction
  * @param $object Data Object
  */
 private function prepareAction(TAction $action, $object)
 {
     $field = $action->getField();
     if (is_null($field)) {
         throw new Exception(AdiantiCoreTranslator::translate('Field for action ^1 not defined', $label) . '.<br>' . AdiantiCoreTranslator::translate('Use the ^1 method', 'setField' . '()') . '.');
     }
     if (!isset($object->{$field})) {
         throw new Exception(AdiantiCoreTranslator::translate('Field ^1 not exists', $field));
     }
     // get the object property that will be passed ahead
     $key = isset($object->{$field}) ? $object->{$field} : NULL;
     $action->setParameter('key', $key);
 }
Exemplo n.º 7
0
 private function checkDatabase($file)
 {
     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()));
         $repository = new TRepository('Srp');
         $count = $repository->count($criteria);
         if ($count > 0) {
             $continua = new TAction(array($this, 'onContinua'));
             // define os parâmetros de cada ação
             $continua->setParameter('confirma', 1);
             $continua->setParameter('file', $file);
             new TQuestion('Essa SRP já foi importada, reimportar a planilha <br>irá excluir os dados anteriores, Confirma?', $continua);
             TTransaction::close();
             return false;
         }
         TTransaction::close();
         return 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();
     }
 }
Exemplo n.º 8
0
 /**
  * Class constructor
  * Creates the page, the form and the listing
  */
 public function __construct()
 {
     parent::__construct();
     parent::include_css('app/resources/custom-table.css');
     // creates the form
     $this->form = new TForm('form_search_Subelemento');
     $this->form->class = 'tform';
     // CSS class
     // creates a table
     $table = new TTable();
     $table->width = '100%';
     $this->form->add($table);
     // add a row for the form title
     $row = $table->addRow();
     $row->class = 'tformtitle';
     $row->addCell(new TLabel('Consulta SubElemento'))->colspan = 2;
     //$table->addRowSet( new TLabel('Consulta SubElemento') ,'')->class = 'tformtitle'; // CSS class
     // create the form fields
     $descricao = new TEntry('descricao');
     // define the sizes
     $descricao->setSize(350);
     // add one row for each form field
     $table->addRowSet(new TLabel('Descrição:'), $descricao);
     $this->form->setFields(array($descricao));
     // keep the form filled during navigation with session data
     $this->form->setData(TSession::getValue('Subelemento_filter_data'));
     // create two action buttons to the form
     $find_button = TButton::create('find', array($this, 'onSearch'), _t('Find'), 'ico_find.png');
     $this->form->addField($find_button);
     $buttons_box = new THBox();
     $buttons_box->add($find_button);
     // add a row for the form action
     $row = $table->addRow();
     $row->class = 'tformaction';
     // CSS class
     $row->addCell($buttons_box)->colspan = 2;
     // creates a Datagrid
     $this->datagrid = new TDataGrid();
     $this->datagrid->style = 'width: 100%';
     $this->datagrid->class = 'tdatagrid_table customized-table';
     $this->datagrid->setHeight(320);
     // creates the datagrid columns
     $id = new TDataGridColumn('id', 'ID', 'right', 100);
     $descricao = new TDataGridColumn('descricao', 'Descrição', 'left');
     // add the columns to the DataGrid
     $this->datagrid->addColumn($id);
     $this->datagrid->addColumn($descricao);
     // creates the datagrid column actions
     $order_id = new TAction(array($this, 'onReload'));
     $order_id->setParameter('order', 'id');
     $id->setAction($order_id);
     $order_descricao = new TAction(array($this, 'onReload'));
     $order_descricao->setParameter('order', 'descricao');
     $descricao->setAction($order_descricao);
     // create the datagrid model
     $this->datagrid->createModel();
     // creates the page navigation
     $this->pageNavigation = new TPageNavigation();
     $this->pageNavigation->setAction(new TAction(array($this, 'onReload')));
     $this->pageNavigation->setWidth($this->datagrid->getWidth());
     // create the page container
     $container = new TTable();
     //$container->style = 'width: 80%';
     $container->addRow()->addCell(new TXMLBreadCrumb('menu.xml', __CLASS__));
     $container->addRow()->addCell($this->form);
     $container->addRow()->addCell($this->datagrid);
     $container->addRow()->addCell($this->pageNavigation);
     parent::add($container);
 }
Exemplo n.º 9
0
 /**
  * Class constructor
  * Creates the page, the form and the listing
  */
 public function __construct()
 {
     parent::__construct();
     parent::include_css('app/resources/custom-table.css');
     // creates the form
     $this->form = new TForm('form_search_Campus');
     $this->form->class = 'tform';
     // CSS class
     // creates a table
     $table = new TTable();
     $table->width = '100%';
     // add a row for the form title
     $table->addRowSet(new TLabel('Consulta Câmpus'), '')->class = 'tformtitle';
     // CSS class
     $this->form->add($table);
     // create the form fields
     $nome = new TEntry('nome');
     $nome->setValue(TSession::getValue('s_nome'));
     $uasg = new TEntry('uasg');
     $uasg->setValue(TSession::getValue('s_uasg'));
     $sigla = new TEntry('sigla');
     $sigla->setValue(TSession::getValue('s_sigla'));
     // define the sizes
     $nome->setSize(500);
     $uasg->setSize(100);
     $sigla->setSize(150);
     // add one row for each form field
     $table->addRowSet(new TLabel('Nome:'), $nome);
     $table->addRowSet(new TLabel('UASG:'), $uasg);
     $table->addRowSet(new TLabel('Sigla:'), $sigla);
     $this->form->setFields(array($nome, $uasg, $sigla));
     // keep the form filled during navigation with session data
     $this->form->setData(TSession::getValue('Campus_filter_data'));
     // create two action buttons to the form
     $find_button = TButton::create('find', array($this, 'onSearch'), 'Buscar', 'ico_find.png');
     $new_button = TButton::create('new', array('CampusForm', 'onEdit'), 'Novo', 'ico_new.png');
     $this->form->addField($find_button);
     $this->form->addField($new_button);
     $buttons_box = new THBox();
     $buttons_box->add($find_button);
     $buttons_box->add($new_button);
     // add a row for the form action
     $row = $table->addRow();
     $row->class = 'tformaction';
     // CSS class
     $row->addCell($buttons_box)->colspan = 2;
     // creates a Datagrid
     $this->datagrid = new TDataGrid();
     $this->datagrid->style = 'width: 100%';
     $this->datagrid->class = 'tdatagrid_table customized-table';
     $this->datagrid->setHeight(320);
     // creates the datagrid columns
     $id = new TDataGridColumn('id', 'ID', 'right');
     $nome = new TDataGridColumn('nome', 'Nome', 'left');
     $uasg = new TDataGridColumn('uasg', 'UASG', 'left');
     $sigla = new TDataGridColumn('sigla', 'Sigla', 'left');
     // add the columns to the DataGrid
     $this->datagrid->addColumn($id);
     $this->datagrid->addColumn($nome);
     $this->datagrid->addColumn($uasg);
     $this->datagrid->addColumn($sigla);
     // creates the datagrid column actions
     $order_id = new TAction(array($this, 'onReload'));
     $order_id->setParameter('order', 'id');
     $id->setAction($order_id);
     $order_nome = new TAction(array($this, 'onReload'));
     $order_nome->setParameter('order', 'nome');
     $nome->setAction($order_nome);
     $order_uasg = new TAction(array($this, 'onReload'));
     $order_uasg->setParameter('order', 'uasg');
     $uasg->setAction($order_uasg);
     $order_sigla = new TAction(array($this, 'onReload'));
     $order_sigla->setParameter('order', 'sigla');
     $sigla->setAction($order_sigla);
     // inline editing
     $nome_edit = new TDataGridAction(array($this, 'onInlineEdit'));
     $nome_edit->setField('id');
     $nome->setEditAction($nome_edit);
     /*
             $uasg_edit = new TDataGridAction(array($this, 'onInlineEdit'));
             $uasg_edit->setField('id');
             $uasg->setEditAction($uasg_edit);
     
             $sigla_edit = new TDataGridAction(array($this, 'onInlineEdit'));
             $sigla_edit->setField('id');
             $sigla->setEditAction($sigla_edit);
     */
     // creates two datagrid actions
     $action1 = new TDataGridAction(array('CampusForm', 'onEdit'));
     $action1->setLabel(_t('Edit'));
     $action1->setImage('ico_edit.png');
     $action1->setField('id');
     $action2 = new TDataGridAction(array($this, 'onDelete'));
     $action2->setLabel(_t('Delete'));
     $action2->setImage('ico_delete.png');
     $action2->setField('id');
     // add the actions to the datagrid
     $this->datagrid->addAction($action1);
     $this->datagrid->addAction($action2);
     // create the datagrid model
     $this->datagrid->createModel();
     // creates the page navigation
     $this->pageNavigation = new TPageNavigation();
     $this->pageNavigation->setAction(new TAction(array($this, 'onReload')));
     $this->pageNavigation->setWidth($this->datagrid->getWidth());
     $container = new TTable();
     //$container->style = 'width: 80%';
     $container->addRow()->addCell(new TXMLBreadCrumb('menu.xml', __CLASS__));
     $container->addRow()->addCell($this->form);
     $container->addRow()->addCell($this->datagrid);
     $container->addRow()->addCell($this->pageNavigation);
     // add the container inside the page
     parent::add($container);
 }
Exemplo n.º 10
0
 /**
  * Class constructor
  * Creates the page, the form and the listing
  */
 public function __construct()
 {
     parent::__construct();
     parent::include_css('app/resources/custom-table.css');
     // Cria o form
     $this->form = new TForm('form_search_Usuario');
     $this->form->class = 'tform';
     // cria a tabela
     $table = new TTable();
     $table->style = 'width:100%';
     $table->addRowSet(new TLabel('Consulta Usuários'), '')->class = 'tformtitle';
     // adiciona a tabela no form
     $this->form->add($table);
     // cria os campos de pesquisa do form
     //$id = new TEntry('id');
     //$id->setValue(TSession::getValue('Usuario_id'));
     $nome = new TEntry('nome');
     $nome->setValue(TSession::getValue('Usuario_nome'));
     $nome->setSize(300);
     // add a row for the filter field
     //$table->addRowSet(new TLabel('ID:'), $id);
     $table->addRowSet(new TLabel('Nome: '), $nome);
     // cria dois botoes de acao para o form
     $find_button = new TButton('find');
     $new_button = new TButton('new');
     // define as acoes dos botoes
     $find_button->setAction(new TAction(array($this, 'onSearch')), 'Buscar');
     $find_button->setImage('ico_find.png');
     $new_button->setAction(new TAction(array('UsuarioForm', 'onEdit')), 'Novo');
     $new_button->setImage('ico_new.png');
     // add a row for the form actions
     $container = new THBox();
     $container->add($find_button);
     $container->add($new_button);
     $row = $table->addRow();
     $row->class = 'tformaction';
     $cell = $row->addCell($container);
     $cell->colspan = 2;
     // define wich are the form fields
     $this->form->setFields(array($nome, $find_button, $new_button));
     // creates a DataGrid
     $this->datagrid = new TDataGrid();
     $this->datagrid->setHeight(320);
     $this->datagrid->class = 'tdatagrid_table customized-table';
     $this->datagrid->style = 'width: 100%';
     // creates the datagrid columns
     $id = new TDataGridColumn('id', 'ID', 'right');
     $nome = new TDataGridColumn('nome', 'Nome', 'left');
     $prontuario = new TDataGridColumn('prontuario', 'Prontuario', 'left');
     $email = new TDataGridColumn('email', 'Email', 'left');
     // add the columns to the DataGrid
     $this->datagrid->addColumn($id);
     $this->datagrid->addColumn($nome);
     $this->datagrid->addColumn($prontuario);
     $this->datagrid->addColumn($email);
     // creates the datagrid column actions
     $order_id = new TAction(array($this, 'onReload'));
     $order_id->setParameter('order', 'id');
     $id->setAction($order_id);
     $order_nome = new TAction(array($this, 'onReload'));
     $order_nome->setParameter('order', 'nome');
     $nome->setAction($order_nome);
     // inline editing
     $nome_edit = new TDataGridAction(array($this, 'onInlineEdit'));
     $nome_edit->setField('id');
     $nome->setEditAction($nome_edit);
     // creates two datagrid actions
     $action1 = new TDataGridAction(array('UsuarioForm', 'onEdit'));
     $action1->setLabel('Editar');
     $action1->setImage('ico_edit.png');
     $action1->setField('id');
     $action2 = new TDataGridAction(array($this, 'onDelete'));
     $action2->setLabel('Excluir');
     $action2->setImage('ico_delete.png');
     $action2->setField('id');
     // add the actions to the datagrid
     $this->datagrid->addAction($action1);
     $this->datagrid->addAction($action2);
     // create the datagrid model
     $this->datagrid->createModel();
     // creates the page navigation
     $this->pageNavigation = new TPageNavigation();
     $this->pageNavigation->setAction(new TAction(array($this, 'onReload')));
     $this->pageNavigation->setWidth($this->datagrid->getWidth());
     // creates the page structure using a table
     $table = new TTable();
     //$table->style = 'width: 80%';
     $table->addRow()->addCell(new TXMLBreadCrumb('menu.xml', __CLASS__));
     $table->addRow()->addCell($this->form);
     $table->addRow()->addCell($this->datagrid);
     $table->addRow()->addCell($this->pageNavigation);
     // add the table inside the page
     parent::add($table);
 }
Exemplo n.º 11
0
 /**
  * 
  */
 public function makeTSeekButton($properties)
 {
     $widget = new TSeekButton((string) $properties->{'name'});
     $widget->setSize((int) $properties->{'width'});
     if ($properties->{'database'} and $properties->{'model'}) {
         $obj = new TStandardSeek();
         $action = new TAction(array($obj, 'onSetup'));
         $action->setParameter('database', (string) $properties->{'database'});
         if (isset($this->form)) {
             if ($this->form instanceof TForm) {
                 $action->setParameter('parent', $this->form->getName());
             }
         }
         $action->setParameter('model', (string) $properties->{'model'});
         $action->setParameter('display_field', (string) $properties->{'display'});
         $action->setParameter('receive_key', (string) $properties->{'name'});
         $action->setParameter('receive_field', (string) $properties->{'receiver'});
         $widget->setAction($action);
     }
     $this->fields[] = $widget;
     $this->fieldsByName[(string) $properties->{'name'}] = $widget;
     return $widget;
 }
Exemplo n.º 12
0
 /**
  * Construtor
  * 
  * Criação da listagem de grupos
  */
 public function __construct()
 {
     parent::__construct();
     parent::include_css('app/resources/custom-table.css');
     // Cria o form
     $this->form = new TForm('form_search_Grupo');
     $this->form->class = 'tform';
     // cria a tabela
     $table = new TTable();
     $table->style = 'width:100%';
     //cria o titulo
     $table->addRowSet(new TLabel('Consulta Grupos'), '')->class = 'tformtitle';
     // Adiciona a tabela no form
     $this->form->add($table);
     // Cria os campos para filtro
     $nome = new TEntry('nome');
     $nome->setValue(TSession::getValue('s_nome'));
     $nome->setSize(300);
     $sigla = new TEntry('sigla');
     $sigla->setValue(TSession::getValue('s_sigla'));
     $sigla->setSize(100);
     // Adiciona linha na tabela para inserir o campos
     $row = $table->addRow();
     $row->addCell(new TLabel('Nome: '));
     $row->addCell($nome);
     $row = $table->addRow();
     $row->addCell(new TLabel('Sigla: '));
     $row->addCell($sigla);
     // cria os dois botoes de ações do form
     $find_button = new TButton('find');
     $new_button = new TButton('new');
     // define o botao de acao
     $find_button->setAction(new TAction(array($this, 'onSearch')), 'Buscar');
     $find_button->setImage('ico_find.png');
     $new_button->setAction(new TAction(array('GrupoForm', 'onEdit')), 'Novo');
     $new_button->setImage('ico_new.png');
     $container = new THBox();
     $container->add($find_button);
     $container->add($new_button);
     $row = $table->addRow();
     $row->class = 'tformaction';
     $cell = $row->addCell($container);
     $cell->colspan = 2;
     // define qual é os campos do form
     $this->form->setFields(array($nome, $sigla, $find_button, $new_button));
     // cria o datagrid
     $this->datagrid = new TDataGrid();
     $this->datagrid->style = 'width: 100%';
     $this->datagrid->class = 'tdatagrid_table customized-table';
     $this->datagrid->setHeight(320);
     // cria as colunas do datagrid
     $id = new TDataGridColumn('id', 'ID', 'center');
     $nome = new TDataGridColumn('nome', 'Nome', 'center');
     $sigla = new TDataGridColumn('sigla', 'Sigla', 'center');
     // adiciona as colunas ao datagrid
     $this->datagrid->addColumn($id);
     $this->datagrid->addColumn($nome);
     $this->datagrid->addColumn($sigla);
     // cria as acoes das colunas do datagrid (quando clica no titulo do grid)
     $order_id = new TAction(array($this, 'onReload'));
     $order_id->setParameter('order', 'id');
     $id->setAction($order_id);
     $order_nome = new TAction(array($this, 'onReload'));
     $order_nome->setParameter('order', 'nome');
     $nome->setAction($order_nome);
     $order_sigla = new TAction(array($this, 'onReload'));
     $order_sigla->setParameter('order', 'sigla');
     $sigla->setAction($order_sigla);
     // edição em linha
     $nome_edit = new TDataGridAction(array($this, 'onInlineEdit'));
     $nome_edit->setField('id');
     $nome->setEditAction($nome_edit);
     $sigla_edit = new TDataGridAction(array($this, 'onInlineEdit'));
     $sigla_edit->setField('id');
     $sigla->setEditAction($sigla_edit);
     // cria duas acoes do datagrid
     $action1 = new TDataGridAction(array('GrupoForm', 'onEdit'));
     $action1->setLabel('Editar');
     $action1->setImage('ico_edit.png');
     $action1->setField('id');
     $action2 = new TDataGridAction(array($this, 'onDelete'));
     $action2->setLabel('Excluir');
     $action2->setImage('ico_delete.png');
     $action2->setField('id');
     // adiciona as acoes ao datagrid
     $this->datagrid->addAction($action1);
     $this->datagrid->addAction($action2);
     // cria o modelo do datagrid
     $this->datagrid->createModel();
     // cria o navegador de paginas
     $this->pageNavigation = new TPageNavigation();
     $this->pageNavigation->setAction(new TAction(array($this, 'onReload')));
     $this->pageNavigation->setWidth($this->datagrid->getWidth());
     // cria a estrutura da tela usando tabelas
     $container = new TTable();
     //$container->style = 'width: 80%';
     $container->addRow()->addCell(new TXMLBreadCrumb('menu.xml', __CLASS__));
     $container->addRow()->addCell($this->form);
     $container->addRow()->addCell($this->datagrid);
     $container->addRow()->addCell($this->pageNavigation);
     // add the container inside the page
     parent::add($container);
 }