/**
  * Class constructor
  * Creates the page, the form and the listing
  */
 public function __construct()
 {
     parent::__construct();
     Usuario::checkLogin();
     parent::setDatabase('sample');
     // defines the database
     parent::setActiveRecord('Usuario');
     // defines the active record
     parent::setDefaultOrder('id', 'asc');
     // defines the default order
     parent::setFilterField('login');
     // defines the filter field
     // creates the form, with a table inside
     $this->form = new TForm('form_search_Usuario');
     $table = new TTable();
     $this->form->add($table);
     // create the form fields
     $filter = new TEntry('login');
     $filter->setValue(TSession::getValue('Usuario_login'));
     // add a row for the filter field
     $table->addRowSet(new TLabel('login:'******'find');
     $new_button = new TButton('new');
     $find_button->setAction(new TAction(array($this, 'onSearch')), _t('Find'));
     $new_button->setAction(new TAction(array('UsuarioForm', 'onEdit')), _t('New'));
     $find_button->setImage('ico_find.png');
     $new_button->setImage('ico_new.png');
     // add a row for the form actions
     $table->addRowSet($find_button, $new_button);
     // define wich are the form fields
     $this->form->setFields(array($filter, $find_button, $new_button));
     // creates a DataGrid
     $this->datagrid = new TQuickGrid();
     $this->datagrid->setHeight(320);
     // creates the datagrid columns
     $id = $this->datagrid->addQuickColumn('id', 'id', 'right', 100);
     $login = $this->datagrid->addQuickColumn('login', 'login', 'left', 200);
     $senha = $this->datagrid->addQuickColumn('senha', 'senha', 'left', 200);
     // create the datagrid actions
     $edit_action = new TDataGridAction(array('UsuarioForm', 'onEdit'));
     $delete_action = new TDataGridAction(array($this, 'onDelete'));
     // add the actions to the datagrid
     $this->datagrid->addQuickAction(_t('Edit'), $edit_action, 'id', 'ico_edit.png');
     $this->datagrid->addQuickAction(_t('Delete'), $delete_action, 'id', 'ico_delete.png');
     // create the datagrid model
     $this->datagrid->createModel();
     // create 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 TVBox();
     $container->add($this->form);
     $container->add($this->datagrid);
     $container->add($this->pageNavigation);
     parent::add($container);
 }
Esempio n. 2
0
 /**
  * Class constructor
  * Creates the page, the form and the listing
  */
 public function __construct()
 {
     parent::__construct();
     parent::setDatabase('samples');
     // defines the database
     parent::setActiveRecord('Product');
     // defines the active record
     parent::setDefaultOrder('id', 'asc');
     // defines the default order
     parent::addFilterField('description', 'like');
     // add a filter field
     parent::addFilterField('unity', '=');
     // add a filter field
     // creates the form, with a table inside
     $this->form = new TQuickForm('form_search_Product');
     $this->form->class = 'tform';
     $this->form->style = 'width: 650px';
     $this->form->setFormTitle('Products');
     $units = array('PC' => 'Pieces', 'GR' => 'Grain');
     // create the form fields
     $description = new TEntry('description');
     $unit = new TCombo('unity');
     $unit->addItems($units);
     // add a row for the filter field
     $this->form->addQuickField('Description', $description, 200);
     $this->form->addQuickField('Unit', $unit, 200);
     $this->form->setData(TSession::getValue('Product_filter_data'));
     $this->form->addQuickAction(_t('Find'), new TAction(array($this, 'onSearch')), 'ico_find.png');
     $this->form->addQuickAction(_t('New'), new TAction(array('ProductForm', 'onEdit')), 'ico_new.png');
     // creates a DataGrid
     $this->datagrid = new TQuickGrid();
     $this->datagrid->setHeight(320);
     // creates the datagrid columns
     $id = $this->datagrid->addQuickColumn('ID', 'id', 'center', 50);
     $description = $this->datagrid->addQuickColumn('Description', 'description', 'left', 300);
     $stock = $this->datagrid->addQuickColumn('Stock', 'stock', 'right', 70);
     $sale_price = $this->datagrid->addQuickColumn('Sale Price', 'sale_price', 'right', 70);
     $unity = $this->datagrid->addQuickColumn('Unit', 'unity', 'right', 70);
     // create the datagrid actions
     $edit_action = new TDataGridAction(array('ProductForm', 'onEdit'));
     $delete_action = new TDataGridAction(array($this, 'onDelete'));
     // add the actions to the datagrid
     $this->datagrid->addQuickAction(_t('Edit'), $edit_action, 'id', 'ico_edit.png');
     $this->datagrid->addQuickAction(_t('Delete'), $delete_action, 'id', 'ico_delete.png');
     // create the datagrid model
     $this->datagrid->createModel();
     // create 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 TVBox();
     $container->add(new TXMLBreadCrumb('menu.xml', 'ProductList'));
     $container->add($this->form);
     $container->add($this->datagrid);
     $container->add($this->pageNavigation);
     parent::add($container);
 }
 /**
  * Class constructor
  * Creates the page, the form and the listing
  */
 public function __construct()
 {
     parent::__construct();
     Usuario::checkLogin();
     parent::setDatabase('sample');
     // defines the database
     parent::setActiveRecord('Pedidos');
     // defines the active record
     parent::setDefaultOrder('id', 'asc');
     // defines the default order
     parent::setFilterField('id');
     // defines the filter field
     // creates the form, with a table inside
     $this->form = new TForm('form_search_Pedidos');
     $table = new TTable();
     $this->form->add($table);
     // create the form fields
     $filter = new TEntry('id');
     $filter->setValue(TSession::getValue('Pedidos_id'));
     // add a row for the filter field
     $table->addRowSet(new TLabel('id:'), $filter);
     // create two action buttons to the form
     $find_button = new TButton('find');
     $find_button->setAction(new TAction(array($this, 'onSearch')), _t('Find'));
     $find_button->setImage('ico_find.png');
     // add a row for the form actions
     $table->addRowSet($find_button);
     // define wich are the form fields
     $this->form->setFields(array($filter, $find_button));
     // creates a DataGrid
     $this->datagrid = new TQuickGrid();
     $this->datagrid->setHeight(320);
     // creates the datagrid columns
     $id = $this->datagrid->addQuickColumn('id', 'id', 'right', 100);
     $dataP = $this->datagrid->addQuickColumn('dataP', 'dataP', 'left', 100);
     $clientes_id = $this->datagrid->addQuickColumn('cliente', 'clientes->nome', 'right', 100);
     $status = $this->datagrid->addQuickColumn('status', 'status', 'right', 100);
     // create the datagrid actions
     $itens_action = new TDataGridAction(array($this, 'showItens'));
     // add the actions to the datagrid
     $this->datagrid->addQuickAction("Produtos", $itens_action, 'id', 'ico_find.png');
     // create the datagrid model
     $this->datagrid->createModel();
     // create 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 TVBox();
     $container->add($this->form);
     $container->add($this->datagrid);
     $container->add($this->pageNavigation);
     parent::add($container);
 }
 /**
  * Class constructor
  * Creates the page, the form and the listing
  */
 public function __construct()
 {
     parent::__construct();
     parent::setDatabase('esales');
     // defines the database
     parent::setActiveRecord('Marca');
     // defines the active record
     parent::setDefaultOrder('id', 'asc');
     // defines the default order
     parent::addFilterField('id', '=');
     // add a filter field
     parent::addFilterField('descricao', 'ilike');
     // add a filter field
     // creates the form, with a table inside
     $this->form = new TQuickForm('form_search_Marca');
     $this->form->class = 'tform';
     // CSS class
     $this->form->setFormTitle('Marca');
     // create the form fields
     $id = new TEntry('id');
     $descricao = new TEntry('descricao');
     // add the fields
     $this->form->addQuickField('id', $id, 100);
     $this->form->addQuickField('Descrição', $descricao, 200);
     // keep the form filled during navigation with session data
     $this->form->setData(TSession::getValue('Marca_filter_data'));
     // add the search form actions
     $this->form->addQuickAction('Buscar', new TAction(array($this, 'onSearch')), 'ico_find.png');
     $this->form->addQuickAction('Novo', new TAction(array('MarcaForm', 'onEdit')), 'ico_new.png');
     // creates a DataGrid
     $this->datagrid = new TQuickGrid();
     $this->datagrid->setHeight(320);
     // creates the datagrid columns
     $id = $this->datagrid->addQuickColumn('id', 'id', 'right', 100);
     $descricao = $this->datagrid->addQuickColumn('Descrição', 'descricao', 'left', 200);
     // create the datagrid actions
     $edit_action = new TDataGridAction(array('MarcaForm', 'onEdit'));
     $delete_action = new TDataGridAction(array($this, 'onDelete'));
     // add the actions to the datagrid
     $this->datagrid->addQuickAction('Editar', $edit_action, 'id', 'ico_edit.png');
     $this->datagrid->addQuickAction('Deletar', $delete_action, 'id', 'ico_delete.png');
     // create the datagrid model
     $this->datagrid->createModel();
     // create 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 = TVBox::pack($this->form, $this->datagrid, $this->pageNavigation);
     parent::add($container);
 }
 /**
  * Class constructor
  * Creates the page, the form and the listing
  */
 public function __construct()
 {
     parent::__construct();
     parent::setDatabase('samples');
     // defines the database
     parent::setActiveRecord('City');
     // defines the active record
     parent::setFilterField('name');
     // define the filter field
     parent::setDefaultOrder('id', 'asc');
     // define the default order
     // creates the form
     $this->form = new TQuickForm('form_search_City');
     $this->form->setFormTitle('Standard datagrid');
     $this->form->class = 'tform';
     $this->form->style = 'width: 500px';
     $name = new TEntry('name');
     $this->form->addQuickField('Name:', $name, 200);
     $this->form->addQuickAction('Find', new TAction(array($this, 'onSearch')), 'ico_find.png');
     $this->form->addQuickAction('New', new TAction(array('StandardFormView', 'onEdit')), 'ico_new.png');
     // keep the form filled with the search data
     $this->form->setData(TSession::getValue('City_filter_data'));
     // creates the DataGrid
     $this->datagrid = new TQuickGrid();
     $this->datagrid->setHeight(230);
     // creates the datagrid columns
     $this->datagrid->addQuickColumn('id', 'id', 'right', 40, new TAction(array($this, 'onReload')), array('order', 'id'));
     $name = $this->datagrid->addQuickColumn('name', 'name', 'left', 400, new TAction(array($this, 'onReload')), array('order', 'name'));
     // creates two datagrid actions
     $this->datagrid->addQuickAction('Edit', new TDataGridAction(array('StandardFormView', 'onEdit')), 'id', 'ico_edit.png');
     $this->datagrid->addQuickAction('Delete', new TDataGridAction(array($this, 'onDelete')), 'id', 'ico_delete.png');
     // turn on inline editing
     $editaction = new TDataGridAction(array($this, 'onInlineEdit'));
     $editaction->setField('id');
     $name->setEditAction($editaction);
     // 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->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);
 }
 /**
  * Class constructor
  * Creates the page, the form and the listing
  */
 public function __construct()
 {
     parent::__construct();
     parent::setDatabase('log');
     // defines the database
     parent::setActiveRecord('SystemAccessLog');
     // defines the active record
     parent::setDefaultOrder('id', 'asc');
     // defines the default order
     parent::addFilterField('login', 'like');
     // add a filter field
     parent::setLimit(20);
     // creates the form, with a table inside
     $this->form = new TQuickForm('form_search_SystemAccessLog');
     $this->form->class = 'tform';
     // CSS class
     $this->form->setFormTitle('Access Log');
     // create the form fields
     $login = new TEntry('login');
     // add the fields
     $this->form->addQuickField(_t('Login'), $login, '80%');
     // keep the form filled during navigation with session data
     $this->form->setData(TSession::getValue('SystemAccessLog_filter_data'));
     // add the search form actions
     $this->form->addQuickAction(_t('Find'), new TAction(array($this, 'onSearch')), 'ico_find.png');
     // creates a DataGrid
     $this->datagrid = new TQuickGrid();
     $this->datagrid->style = 'width: 100%';
     $this->datagrid->setHeight(320);
     // creates the datagrid columns
     $id = $this->datagrid->addQuickColumn('id', 'id', 'left');
     $sessionid = $this->datagrid->addQuickColumn('sessionid', 'sessionid', 'left');
     $login = $this->datagrid->addQuickColumn(_t('Login'), 'login', 'left');
     $login_time = $this->datagrid->addQuickColumn('login_time', 'login_time', 'left');
     $logout_time = $this->datagrid->addQuickColumn('logout_time', 'logout_time', 'left');
     // create the datagrid model
     $this->datagrid->createModel();
     // create the page navigation
     $this->pageNavigation = new TPageNavigation();
     $this->pageNavigation->setAction(new TAction(array($this, 'onReload')));
     $this->pageNavigation->setWidth($this->datagrid->getWidth());
     $container = new TVBox();
     $container->style = 'width: 97%';
     $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
     $container->add($this->form);
     $container->add($this->datagrid);
     $container->add($this->pageNavigation);
     parent::add($container);
 }
Esempio n. 7
0
 /**
  * Class constructor
  * Creates the page, and the listing
  */
 public function __construct()
 {
     parent::__construct();
     // security check
     if (TSession::getValue('logged') !== TRUE) {
         throw new Exception(_t('Not logged'));
     }
     // security check
     TTransaction::open('changeman');
     if (Member::newFromLogin(TSession::getValue('login'))->role_mnemonic !== 'ADMINISTRATOR') {
         throw new Exception(_t('Permission denied'));
     }
     TTransaction::close();
     // defines the database
     parent::setDatabase('changeman');
     // defines the active record
     parent::setActiveRecord('Role');
     // defines the filter field
     parent::setFilterField('description');
     // creates a DataGrid
     $this->datagrid = new TQuickGrid();
     $this->datagrid->setHeight(320);
     // creates the datagrid columns
     $this->datagrid->addQuickColumn('ID', 'id', 'right', 100, new TAction(array($this, 'onReload')), array('order', 'id'));
     $this->datagrid->addQuickColumn(_t('Description'), 'description', 'left', 200, new TAction(array($this, 'onReload')), array('order', 'description'));
     $this->datagrid->addQuickColumn(_t('Mnemonic'), 'mnemonic', 'left', 200, new TAction(array($this, 'onReload')), array('order', 'mnemonic'));
     // 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();
     // add a row to the datagrid
     $row = $table->addRow();
     $row->addCell($this->datagrid);
     // add a row for page navigation
     $row = $table->addRow();
     $row->addCell($this->pageNavigation);
     // add the table inside the page
     parent::add($table);
 }
 /**
  * Class constructor
  * Creates the page, the form and the listing
  */
 public function __construct()
 {
     parent::__construct();
     // security check
     if (TSession::getValue('logged') !== TRUE) {
         throw new Exception(_t('Not logged'));
     }
     // security check
     TTransaction::open('library');
     if (User::newFromLogin(TSession::getValue('login'))->role->mnemonic !== 'LIBRARIAN') {
         throw new Exception(_t('Permission denied'));
     }
     TTransaction::close();
     // defines the database
     parent::setDatabase('library');
     // defines the active record
     parent::setActiveRecord('Publisher');
     // defines the filter field
     parent::setFilterField('name');
     // creates the form
     $this->form = new TForm('form_search_Publisher');
     $this->form->class = 'tform';
     $this->form->style = 'width: 600px';
     $table = new TTable();
     $table->width = '100%';
     $this->form->add($table);
     $table->addRowSet(new TLabel(_t('Publishers')), '')->class = 'tformtitle';
     // create the form fields
     $filter = new TEntry('name');
     $filter->setValue(TSession::getValue('Publisher_name'));
     // add a row for the filter field
     $row = $table->addRow();
     $row->addCell(new TLabel(_t('Name') . ': '));
     $row->addCell($filter);
     // create two action buttons to the form
     $find_button = new TButton('find');
     $new_button = new TButton('new');
     // define the button actions
     $find_button->setAction(new TAction(array($this, 'onSearch')), _t('Find'));
     $find_button->setImage('ico_find.png');
     $new_button->setAction(new TAction(array('PublisherForm', 'onEdit')), _t('New'));
     $new_button->setImage('ico_new.png');
     $buttons = new THBox();
     $buttons->add($find_button);
     $buttons->add($new_button);
     $row = $table->addRow();
     $row->class = 'tformaction';
     $cell = $row->addCell($buttons);
     $cell->colspan = 2;
     // define wich are the form fields
     $this->form->setFields(array($filter, $find_button, $new_button));
     // creates a DataGrid
     $this->datagrid = new TQuickGrid();
     $this->datagrid->setHeight(320);
     // creates the datagrid columns
     $this->datagrid->addQuickColumn('id', 'id', 'right', 100, new TAction(array($this, 'onReload')), array('order', 'id'));
     $this->datagrid->addQuickColumn('name', 'name', 'left', 440, new TAction(array($this, 'onReload')), array('order', 'name'));
     // add the actions to the datagrid
     $this->datagrid->addQuickAction(_t('Edit'), new TDataGridAction(array('PublisherForm', 'onEdit')), 'id', 'ico_edit.png');
     $this->datagrid->addQuickAction(_t('Delete'), new TDataGridAction(array($this, 'onDelete')), 'id', 'ico_delete.png');
     // 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 vbox
     $container = new TVBox();
     $container->add($this->form);
     $container->add($this->datagrid);
     $container->add($this->pageNavigation);
     // add the vbox inside the page
     parent::add($container);
 }
Esempio n. 9
0
 /**
  * Class constructor
  * Creates the page, the form and the listing
  */
 public function __construct()
 {
     parent::__construct();
     // security check
     if (TSession::getValue('logged') !== TRUE) {
         throw new Exception(_t('Not logged'));
     }
     // security check
     TTransaction::open('library');
     if (User::newFromLogin(TSession::getValue('login'))->role->mnemonic !== 'ADMINISTRATOR') {
         throw new Exception(_t('Permission denied'));
     }
     TTransaction::close();
     // defines the database
     parent::setDatabase('library');
     // defines the active record
     parent::setActiveRecord('User');
     // defines the filter field
     parent::setFilterField('Login');
     // creates the form
     $this->form = new TForm('form_search_User');
     // creates a table
     $table = new TTable();
     // add the table inside the form
     $this->form->add($table);
     // create the form fields
     $filter = new TEntry('login');
     $filter->setValue(TSession::getValue('User_login'));
     // add a row for the filter field
     $row = $table->addRow();
     $row->addCell(new TLabel('login:'******'find');
     $new_button = new TButton('new');
     // define the button actions
     $find_button->setAction(new TAction(array($this, 'onSearch')), _t('Find'));
     $find_button->setImage('ico_find.png');
     $new_button->setAction(new TAction(array('UserForm', 'onEdit')), _t('New'));
     $new_button->setImage('ico_new.png');
     // add a row for the form actions
     $row = $table->addRow();
     $row->addCell($find_button);
     $row->addCell($new_button);
     // define wich are the form fields
     $this->form->setFields(array($filter, $find_button, $new_button));
     // creates a DataGrid
     $this->datagrid = new TQuickGrid();
     $this->datagrid->setHeight(320);
     // creates the datagrid columns
     $this->datagrid->addQuickColumn('id', 'id', 'right', 100, new TAction(array($this, 'onReload')), array('order', 'id'));
     $this->datagrid->addQuickColumn('login', 'login', 'left', 100, new TAction(array($this, 'onReload')), array('order', 'login'));
     $this->datagrid->addQuickColumn('name', 'name', 'left', 300, new TAction(array($this, 'onReload')), array('order', 'name'));
     // add the actions to the datagrid
     $this->datagrid->addQuickAction(_t('Edit'), new TDataGridAction(array('UserForm', 'onEdit')), 'id', 'ico_edit.png');
     $this->datagrid->addQuickAction(_t('Delete'), new TDataGridAction(array($this, 'onDelete')), 'id', 'ico_delete.png');
     // 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();
     // add a row to the form
     $row = $table->addRow();
     $row->addCell($this->form);
     // add a row to the datagrid
     $row = $table->addRow();
     $row->addCell($this->datagrid);
     // add a row for page navigation
     $row = $table->addRow();
     $row->addCell($this->pageNavigation);
     // add the table inside the page
     parent::add($table);
 }
Esempio n. 10
0
 /**
  * Class constructor
  * Creates the page, the form and the listing
  */
 public function __construct()
 {
     parent::__construct();
     parent::setDatabase('esales');
     // defines the database
     parent::setActiveRecord('Pessoa');
     // defines the active record
     parent::setDefaultOrder('id', 'asc');
     // defines the default order
     parent::addFilterField('id', 'like');
     // add a filter field
     parent::addFilterField('nome', 'like');
     // add a filter field
     parent::addFilterField('telefone', 'like');
     // add a filter field
     parent::addFilterField('email', 'like');
     // add a filter field
     parent::addFilterField('endereco', 'like');
     // add a filter field
     parent::addFilterField('numero', 'like');
     // add a filter field
     parent::addFilterField('cidade_id', 'like');
     // add a filter field
     parent::addFilterField('cep', 'like');
     // add a filter field
     parent::addFilterField('cpf_cnpj', 'like');
     // add a filter field
     parent::addFilterField('tipo_pessoa', 'like');
     // add a filter field
     // creates the form, with a table inside
     $this->form = new TQuickForm('form_search_Pessoa');
     $this->form->class = 'tform';
     // CSS class
     $this->form->setFormTitle('Pessoa');
     // create the form fields
     $id = new TEntry('id');
     $nome = new TEntry('nome');
     $telefone = new TEntry('telefone');
     $email = new TEntry('email');
     $endereco = new TEntry('endereco');
     $numero = new TEntry('numero');
     $cidade_id = new TEntry('cidade_id');
     $cep = new TEntry('cep');
     $cpf_cnpj = new TEntry('cpf_cnpj');
     $tipo_pessoa = new TEntry('tipo_pessoa');
     // add the fields
     $this->form->addQuickField('id', $id, 100);
     $this->form->addQuickField('nome', $nome, 200);
     $this->form->addQuickField('telefone', $telefone, 200);
     $this->form->addQuickField('email', $email, 200);
     $this->form->addQuickField('endereco', $endereco, 200);
     $this->form->addQuickField('numero', $numero, 200);
     $this->form->addQuickField('cidade_id', $cidade_id, 100);
     $this->form->addQuickField('cep', $cep, 200);
     $this->form->addQuickField('cpf_cnpj', $cpf_cnpj, 100);
     $this->form->addQuickField('tipo_pessoa', $tipo_pessoa, 200);
     // keep the form filled during navigation with session data
     $this->form->setData(TSession::getValue('Pessoa_filter_data'));
     // add the search form actions
     $this->form->addQuickAction('Buscar', new TAction(array($this, 'onSearch')), 'ico_find.png');
     $this->form->addQuickAction('Novo', new TAction(array('PessoaForm', 'onEdit')), 'ico_new.png');
     // creates a DataGrid
     $this->datagrid = new TQuickGrid();
     $this->datagrid->setHeight(320);
     // creates the datagrid columns
     $id = $this->datagrid->addQuickColumn('id', 'id', 'right', 100);
     $nome = $this->datagrid->addQuickColumn('Nome', 'nome', 'left', 200);
     $telefone = $this->datagrid->addQuickColumn('Telefone', 'telefone', 'left', 200);
     $email = $this->datagrid->addQuickColumn('Email', 'email', 'left', 200);
     $endereco = $this->datagrid->addQuickColumn('Endereço', 'endereco', 'left', 200);
     $numero = $this->datagrid->addQuickColumn('Número', 'numero', 'left', 200);
     $cidade_id = $this->datagrid->addQuickColumn('Cidade', 'cidade_id', 'right', 100);
     $cep = $this->datagrid->addQuickColumn('CEP', 'cep', 'left', 200);
     $cpf_cnpj = $this->datagrid->addQuickColumn('Cpf/Cnpj', 'cpf_cnpj', 'right', 100);
     $tipo_pessoa = $this->datagrid->addQuickColumn('Tipo Pessoa', 'tipo_pessoa', 'left', 200);
     // create the datagrid actions
     $edit_action = new TDataGridAction(array('PessoaForm', 'onEdit'));
     $delete_action = new TDataGridAction(array($this, 'onDelete'));
     // add the actions to the datagrid
     $this->datagrid->addQuickAction('Editar', $edit_action, 'id', 'ico_edit.png');
     $this->datagrid->addQuickAction('Deletar', $delete_action, 'id', 'ico_delete.png');
     // create the datagrid model
     $this->datagrid->createModel();
     // create 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 = TVBox::pack($this->form, $this->datagrid, $this->pageNavigation);
     parent::add($container);
 }
 public function __construct()
 {
     parent::__construct();
     parent::setDatabase('log');
     parent::setActiveRecord('SystemChangeLog');
     parent::addFilterField('tablename');
     parent::addFilterField('login');
     parent::setLimit(20);
     $this->form = new TQuickForm('form_table_logger');
     $this->form->{'class'} = 'tform';
     // CSS class
     $this->form->setFormTitle('Table change log');
     // cria os campos do formulário
     $tablename = new TEntry('tablename');
     $login = new TEntry('login');
     $this->form->addQuickField(_t('Table'), $tablename);
     $this->form->addQuickField('Login', $login);
     $tablename->setSize('80%');
     $login->setSize('80%');
     $this->form->addQuickAction(_t('Search'), new TAction(array($this, 'onSearch')), 'ico_find.png');
     $this->formgrid = new TForm();
     // instancia objeto DataGrid
     $this->datagrid = new TDataGrid();
     $this->datagrid->style = 'width: 100%';
     $this->datagrid->datatable = 'true';
     $this->datagrid->setHeight(320);
     parent::setTransformer(array($this, 'onBeforeLoad'));
     // datagrid inside form
     $this->formgrid->add($this->datagrid);
     // instancia as colunas da DataGrid
     $id = new TDataGridColumn('pkvalue', 'PK', 'center');
     $date = new TDataGridColumn('logdate', _t('Date'), 'center');
     $login = new TDataGridColumn('login', 'Login', 'center');
     $name = new TDataGridColumn('tablename', _t('Table'), 'left');
     $column = new TDataGridColumn('columnname', _t('Column'), 'left');
     $operation = new TDataGridColumn('operation', _t('Operation'), 'left');
     $oldvalue = new TDataGridColumn('oldvalue', _t('Old value'), 'left');
     $newvalue = new TDataGridColumn('newvalue', _t('New value'), 'left');
     $operation->setTransformer(function ($value, $object, $row) {
         if ($value == 'created') {
             return "<span style='color:green'>{$value}</span>";
         } else {
             if ($value == 'deleted') {
                 return "<span style='color:red'>{$value}</span>";
             } else {
                 if ($value == 'changed') {
                     return "<span style='color:blue'>{$value}</span>";
                 }
             }
         }
         return $value;
     });
     $order1 = new TAction(array($this, 'onReload'));
     $order2 = new TAction(array($this, 'onReload'));
     $order3 = new TAction(array($this, 'onReload'));
     $order4 = new TAction(array($this, 'onReload'));
     $order5 = new TAction(array($this, 'onReload'));
     $order1->setParameter('order', 'pkvalue');
     $order2->setParameter('order', 'logdate');
     $order3->setParameter('order', 'login');
     $order4->setParameter('order', 'tablename');
     $order5->setParameter('order', 'columnname');
     $id->setAction($order1);
     $date->setAction($order2);
     $login->setAction($order3);
     $name->setAction($order4);
     $column->setAction($order5);
     // adiciona as colunas à DataGrid
     $this->datagrid->addColumn($id);
     $this->datagrid->addColumn($date);
     $this->datagrid->addColumn($login);
     $this->datagrid->addColumn($name);
     $this->datagrid->addColumn($column);
     $this->datagrid->addColumn($operation);
     $this->datagrid->addColumn($oldvalue);
     $this->datagrid->addColumn($newvalue);
     // cria o modelo da DataGrid, montando sua estrutura
     $this->datagrid->createModel();
     // cria o paginador
     $this->pageNavigation = new TPageNavigation();
     $this->pageNavigation->setAction(new TAction(array($this, 'onReload')));
     $this->pageNavigation->setWidth($this->datagrid->getWidth());
     $container = new TVBox();
     $container->style = 'width: 97%';
     $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
     $container->add($this->form);
     $container->add($this->formgrid);
     $container->add($this->pageNavigation);
     parent::add($container);
 }
Esempio n. 12
0
 /**
  * Class constructor
  * Creates the page, the form and the listing
  */
 public function __construct()
 {
     parent::__construct();
     parent::setDatabase('blog');
     // defines the database
     parent::setActiveRecord('Post');
     // defines the active record
     parent::setFilterField('title');
     // defines the filter field
     parent::setDefaultOrder('id', 'desc');
     // creates the form
     $this->form = new TForm('form_search_Post');
     $this->form->class = 'tform';
     // creates a table
     $table = new TTable();
     $table->width = '100%';
     // add the table inside the form
     $this->form->add($table);
     $table->addRowSet(new TLabel(_t('Posts')), '')->class = 'tformtitle';
     // create the form fields
     $filter = new TEntry('title');
     $filter->setValue(TSession::getValue('Post_title'));
     // add a row for the filter field
     $row = $table->addRow();
     $row->addCell(new TLabel('title:'));
     $row->addCell($filter);
     // create two action buttons to the form
     $find_button = new TButton('find');
     $new_button = new TButton('new');
     // define the button actions
     $find_button->setAction(new TAction(array($this, 'onSearch')), _t('Find'));
     $find_button->setImage('ico_find.png');
     $new_button->setAction(new TAction(array('PostForm', 'onEdit')), _t('New'));
     $new_button->setImage('ico_new.png');
     $buttons = new THBox();
     $buttons->add($find_button);
     $buttons->add($new_button);
     $row = $table->addRow();
     $row->class = 'tformaction';
     $cell = $row->addCell($buttons);
     $cell->colspan = 2;
     // define wich are the form fields
     $this->form->setFields(array($filter, $find_button, $new_button));
     // creates a DataGrid
     $this->datagrid = new TQuickGrid();
     $this->datagrid->setHeight(320);
     // creates the datagrid columns
     $id = $this->datagrid->addQuickColumn('ID', 'id', 'left', 40);
     $title = $this->datagrid->addQuickColumn(_t('Title'), 'title', 'left', 300);
     $category_name = $this->datagrid->addQuickColumn(_t('Category'), 'category_name', 'left', 200);
     // add the actions to the datagrid
     $this->datagrid->addQuickAction(_t('Edit'), new TDataGridAction(array('PostForm', 'onEdit')), 'id', 'ico_edit.png');
     $this->datagrid->addQuickAction(_t('Delete'), new TDataGridAction(array($this, 'onDelete')), 'id', 'ico_delete.png');
     // 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->addRow()->addCell($this->form);
     $table->addRow()->addCell($this->datagrid);
     $table->addRow()->addCell($this->pageNavigation);
     // add the table inside the page
     parent::add($table);
 }
 /**
  * Class constructor
  * Creates the page, the form and the listing
  */
 public function __construct()
 {
     parent::__construct();
     // defines the database
     parent::setDatabase('samples');
     // defines the active record
     parent::setActiveRecord('Project');
     // defines the filter field
     parent::setFilterField('name');
     // creates the form
     $this->form = new TForm('form_search_Project');
     // creates a table
     $table = new TTable();
     // add the table inside the form
     $this->form->add($table);
     // create the form fields
     $filter = new TEntry('name');
     $filter->setValue(TSession::getValue('Project_name'));
     // add a row for the filter field
     $table->addRowSet(new TLabel('name:'), $filter);
     // create two action buttons to the form
     $find_button = new TButton('find');
     $new_button = new TButton('new');
     $find_button->setAction(new TAction(array($this, 'onSearch')), _t('Find'));
     $find_button->setImage('ico_find.png');
     $new_button->setAction(new TAction(array('ProjectFormView', 'onEdit')), _t('New'));
     $new_button->setImage('ico_new.png');
     // add a row for the form actions
     $table->addRowSet($find_button, $new_button);
     // define wich are the form fields
     $this->form->setFields(array($filter, $find_button, $new_button));
     // creates a DataGrid
     $this->datagrid = new TQuickGrid();
     $this->datagrid->setHeight(320);
     // creates the datagrid columns
     $id = $this->datagrid->addQuickColumn('ID', 'id', 'left', 50);
     $name = $this->datagrid->addQuickColumn('Name', 'name', 'left', 190);
     $start = $this->datagrid->addQuickColumn('Start', 'start_date', 'left', 80);
     $end = $this->datagrid->addQuickColumn('End', 'end_date', 'left', 80);
     $customer = $this->datagrid->addQuickColumn('customer', 'customer', 'left', 100);
     // add the actions to the datagrid
     $this->datagrid->addQuickAction(_t('Edit'), new TDataGridAction(array('ProjectFormView', 'onEdit')), 'id', 'ico_edit.png');
     $this->datagrid->addQuickAction(_t('Delete'), new TDataGridAction(array($this, 'onDelete')), 'id', 'ico_delete.png');
     $this->datagrid->addQuickAction(_t('Detail'), new TDataGridAction(array('BacklogFormView', 'onSetProject')), 'id');
     // 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());
     // pack the elements using a vertical box
     $vbox = new TVBox();
     $vbox->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
     $vbox->add($this->form);
     $vbox->add($this->datagrid);
     $vbox->add($this->pageNavigation);
     // add the box inside the page
     parent::add($vbox);
 }