/** * Class constructor * Creates the page and the registration form */ function __construct() { parent::__construct(); parent::setDatabase("app"); parent::setActiveRecord("TipoMaterialPermanente"); parent::setDefaultOrder("nome", "asc"); // creates the form $this->form = new TQuickForm('form_TipoMaterialPermanente'); $this->form->class = 'tform'; // CSS class $this->form->setFormTitle('Tipo de material permanente'); // define the form title // // create the form fields $id = new TEntry('id'); $id->setEditable(false); $nome = new TEntry('nome'); $nome->addValidation('Tipo do material permanente', new TRequiredValidator()); $custo = new TEntry('custo'); $custo->addValidation('Custo', new TRequiredValidator()); $custo->addValidation('Custo unitário', new TNumericValidator()); // add the fields $this->form->addQuickField('#', $id, 50); $this->form->addQuickField('Tipo de material permanente', $nome, 400); $this->form->addQuickField('Custo unitário', $custo, 100); // create the form actions $this->form->addQuickAction(_t('Save'), new TAction(array($this, 'onSave')), 'ico_save.png'); $this->form->addQuickAction(_t('New'), new TAction(array($this, 'onEdit')), 'ico_new.png'); $this->form->addQuickAction('Relatório', new TAction(array($this, 'onReport')), 'ico_print.png'); // creates a DataGrid $this->datagrid = new TQuickGrid(); $this->datagrid->setHeight(320); // creates the datagrid columns $id = $this->datagrid->addQuickColumn('#', 'id', 'left', 50); $nome = $this->datagrid->addQuickColumn('Tipo de material permanente', 'nome', 'left', 600); $custo = $this->datagrid->addQuickColumn('Custo unitário', 'custo', 'right', 100); // create the datagrid actions $edit_action = new TDataGridAction(array($this, '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(); // creates the page navigation $this->pageNavigation = new TPageNavigation(); $this->pageNavigation->setAction(new TAction(array($this, 'onReload'))); $this->pageNavigation->setWidth($this->datagrid->getWidth()); // 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 = TVBox::pack($this->form, $this->datagrid, $this->pageNavigation); parent::add($container); }
/** * Class constructor * Creates the page and the registration form */ function __construct() { parent::__construct(); parent::setDatabase('app'); // defines the database parent::setActiveRecord('Ajuda'); // defines the active record parent::setDefaultOrder('id', 'asc'); // defines the default order // creates the form $this->form = new TQuickForm('form_Ajuda'); $this->form->class = 'tform'; // CSS class $this->form->setFormTitle('Ajuda'); // define the form title // create the form fields $id = new TEntry('id'); $id->setEditable(false); $titulo = new TEntry('titulo'); $texto = new THtmlEditor('texto'); // add the fields $this->form->addQuickField('id', $id, 100); $this->form->addQuickField('titulo', $titulo, 700); $this->form->addQuickField('texto', $texto, 700); $texto->setSize(700, 300); // create the form actions $this->form->addQuickAction(_t('Save'), new TAction(array($this, 'onSave')), 'ico_save.png'); $this->form->addQuickAction(_t('New'), new TAction(array($this, 'onEdit')), 'ico_new.png'); // creates a DataGrid $this->datagrid = new TQuickGrid(); $this->datagrid->setHeight(320); // creates the datagrid columns $id = $this->datagrid->addQuickColumn('#', 'id', 'left', 100); $texto = $this->datagrid->addQuickColumn('Ajuda', 'titulo', 'left', 640); // create the datagrid actions $edit_action = new TDataGridAction(array($this, '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(); // 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 = TVBox::pack($this->datagrid, $this->pageNavigation, $this->form); parent::add($container); }
/** * Class constructor * Creates the page, the form and the listing */ public function __construct() { parent::__construct(); // define the database parent::setDatabase('samples'); // define the Active Record parent::setActiveRecord('Category'); // define the default order parent::setDefaultOrder('id', 'asc'); // turn off limit for datagrid $this->setLimit(-1); // create the form $this->form = new TQuickForm('form_categories'); $this->form->class = 'tform'; // CSS class $this->form->style = 'width: 500px'; $this->form->setFormTitle('Form/Datagrid'); // create the form fields $id = new TEntry('id'); $name = new TEntry('name'); $name->addValidation(_t('Name'), new TRequiredValidator()); // add the form fields $this->form->addQuickField('ID', $id, 40); $this->form->addQuickField('Name', $name, 200); // define the form actions $this->form->addQuickAction(_t('Save'), new TAction(array($this, 'onSave')), 'ico_save.png'); $this->form->addQuickAction(_t('New'), new TAction(array($this, 'onEdit')), 'ico_new.png'); // make id not editable $id->setEditable(FALSE); // create the datagrid $this->datagrid = new TQuickGrid(); $this->datagrid->setHeight(320); // add the columns $this->datagrid->addQuickColumn('ID', 'id', 'center', 50, new TAction(array($this, 'onReload')), array('order', 'id')); $this->datagrid->addQuickColumn('Name', 'name', 'left', 390, new TAction(array($this, 'onReload')), array('order', 'name')); // add the actions $this->datagrid->addQuickAction('Editar', new TDataGridAction(array($this, 'onEdit')), 'id', 'ico_edit.png'); $this->datagrid->addQuickAction('Deletar', new TDataGridAction(array($this, 'onDelete')), 'id', 'ico_delete.png'); // create the datagrid model $this->datagrid->createModel(); // wrap objects inside a table $table = new TTable(); $table->addRow()->addCell(new TXMLBreadCrumb('menu.xml', __CLASS__)); $table->addRow()->addCell($this->form); $table->addRow()->addCell($this->datagrid); // pack the table inside the page parent::add($table); }