/** * 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(); 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('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); }
/** * 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); }