/** * Class constructor * Creates the page, the form and the listing */ public function __construct() { parent::__construct(); parent::setSize(500, 400); parent::setTitle('Telefones'); // creates a Datagrid $this->datagrid = new TDataGrid(); $this->datagrid = new BootstrapDatagridWrapper($this->datagrid); $this->datagrid->style = 'width: 100%'; $this->datagrid->setHeight(320); // $this->datagrid->datatable = 'true'; // $this->datagrid->enablePopover('Popover', 'Hi <b> {name} </b>'); // creates the datagrid columns $column_check = new TDataGridColumn('check', '', 'center'); $column_id = new TDataGridColumn('id', 'Id', 'right'); $column_numero = new TDataGridColumn('numero', 'Numero', 'left'); // add the columns to the DataGrid $this->datagrid->addColumn($column_check); $this->datagrid->addColumn($column_id); $this->datagrid->addColumn($column_numero); // create DELETE action $action_del = new TDataGridAction(array($this, 'onDelete')); $action_del->setUseButton(TRUE); $action_del->setButtonClass('btn btn-default'); $action_del->setLabel(_t('Delete')); $action_del->setImage('fa:trash-o red fa-lg'); $action_del->setField('id'); $action_del->setDisplayCondition(array($this, 'checkDelete')); $this->datagrid->addAction($action_del); // 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()); $this->datagrid->disableDefaultClick(); // put datagrid inside a form $this->formgrid = new TForm(); $this->formgrid->add($this->datagrid); // creates the delete collection button $this->deleteButton = new TButton('delete_collection'); $this->deleteButton->setAction(new TAction(array($this, 'onDeleteCollection')), AdiantiCoreTranslator::translate('Delete selected')); $this->deleteButton->setImage('fa:remove red'); $this->formgrid->addField($this->deleteButton); $gridpack = new TVBox(); $gridpack->style = 'width: 100%'; $gridpack->add($this->formgrid); $gridpack->add($this->deleteButton)->style = 'background:whiteSmoke;border:1px solid #cccccc; padding: 3px;padding: 5px;'; $this->transformCallback = array($this, 'onBeforeLoad'); // vertical box container $container = new TVBox(); $container->style = 'width: 90%'; // $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__)); $container->add(TPanelGroup::pack('Title', $this->form)); $container->add($gridpack); $container->add($this->pageNavigation); parent::add($container); }
/** * Page constructor */ public function __construct() { parent::__construct(); parent::setDatabase('sample'); // defines the database parent::setActiveRecord('Cliente'); // defines the active record parent::setDefaultOrder('id', 'asc'); // defines the default order // parent::setCriteria($criteria) // define a standard filter parent::addFilterField('nome', 'like', 'nome'); // filterField, operator, formField // creates the form $this->form = new TQuickForm('form_search_Cliente'); $this->form->class = 'tform'; // change CSS class $this->form = new BootstrapFormWrapper($this->form); $this->form->style = 'display: table;width:100%'; // change style $this->form->setFormTitle('Cliente'); // create the form fields $nome = new TEntry('nome'); // add the fields $this->form->addQuickField('Nome', $nome, 200); // keep the form filled during navigation with session data $this->form->setData(TSession::getValue('Cliente_filter_data')); // add the search form actions $this->form->addQuickAction(_t('Find'), new TAction(array($this, 'onSearch')), 'fa:search'); $this->form->addQuickAction(_t('New'), new TAction(array('ClienteForm', 'onEdit')), 'bs:plus-sign green'); // creates a DataGrid $this->datagrid = new TDataGrid(); $this->datagrid = new BootstrapDatagridWrapper($this->datagrid); $this->datagrid->style = 'width: 100%'; $this->datagrid->setHeight(320); // $this->datagrid->datatable = 'true'; // $this->datagrid->enablePopover('Popover', 'Hi <b> {name} </b>'); // creates the datagrid columns $column_check = new TDataGridColumn('check', '', 'center'); $column_id = new TDataGridColumn('id', 'Id', 'right'); $column_nome = new TDataGridColumn('nome', 'Nome', 'left'); // add the columns to the DataGrid $this->datagrid->addColumn($column_check); $this->datagrid->addColumn($column_id); $this->datagrid->addColumn($column_nome); // create EDIT action $action_edit = new TDataGridAction(array('ClienteForm', 'onEdit')); $action_edit->setUseButton(TRUE); $action_edit->setButtonClass('btn btn-default'); $action_edit->setLabel(_t('Edit')); $action_edit->setImage('fa:pencil-square-o blue fa-lg'); $action_edit->setField('id'); $action_edit->setDisplayCondition(array($this, 'checkEdit')); $this->datagrid->addAction($action_edit); // create DELETE action $action_del = new TDataGridAction(array($this, 'onDelete')); $action_del->setUseButton(TRUE); $action_del->setButtonClass('btn btn-default'); $action_del->setLabel(_t('Delete')); $action_del->setImage('fa:trash-o red fa-lg'); $action_del->setField('id'); $action_del->setDisplayCondition(array($this, 'checkDelete')); $this->datagrid->addAction($action_del); $telefone_action = new TDataGridAction(array('telefoneList', 'onReload')); $telefone_action->setLabel('Telefones'); $telefone_action->setImage('bs:search blue'); $telefone_action->setField('id'); $this->datagrid->addAction($telefone_action); $email_action = new TDataGridAction(array('emailList', 'onReload')); $email_action->setLabel('Email'); $email_action->setImage('bs:search blue'); $email_action->setField('id'); $this->datagrid->addAction($email_action); // 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()); $this->datagrid->disableDefaultClick(); // put datagrid inside a form $this->formgrid = new TForm(); $this->formgrid->add($this->datagrid); // creates the delete collection button $this->deleteButton = new TButton('delete_collection'); $this->deleteButton->setAction(new TAction(array($this, 'onDeleteCollection')), AdiantiCoreTranslator::translate('Delete selected')); $this->deleteButton->setImage('fa:remove red'); $this->formgrid->addField($this->deleteButton); $gridpack = new TVBox(); $gridpack->style = 'width: 100%'; $gridpack->add($this->formgrid); $gridpack->add($this->deleteButton)->style = 'background:whiteSmoke;border:1px solid #cccccc; padding: 3px;padding: 5px;'; $this->transformCallback = array($this, 'onBeforeLoad'); // vertical box container $container = new TVBox(); $container->style = 'width: 90%'; // $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__)); $container->add(TPanelGroup::pack('Title', $this->form)); $container->add($gridpack); $container->add($this->pageNavigation); parent::add($container); }
/** * Form constructor * @param $param Request */ public function __construct($param) { parent::__construct(); // creates the form $this->form = new TForm('form_Cliente'); $this->form->class = 'tform'; // change CSS class $note = new TNotebook(400, 300); // add a table inside form $table = new TTable(); $table->width = '100%'; // add a row for the form title $row = $table->addRow(); $row->class = 'tformtitle'; // CSS class $row->addCell(new TLabel('Clientes'))->colspan = 2; // create the form fields $id = new TEntry('id'); $nome = new TEntry('nome'); // campo para telefones $multifield = new TMultiField('telefone'); $telefone_id = new TEntry('id'); $telefone_id->setEditable(false); $telefone = new TEntry('numero'); $telefone->setMask('(99)99999-9999'); // campo para emails $multifield_email = new TMultiField('email'); $email = new TEntry('email'); $email_id = new TEntry('id'); $email->addValidation('email', new TEmailValidator()); $multifield->addField('id', 'Codigo', $telefone_id, 200); $multifield->addField('numero', 'Telefone', $telefone, 200, true); $multifield_email->addField('id', 'Codigo', $email_id, 200); $multifield_email->addField('email', 'Email', $email, 200, true); // define the sizes $id->setSize(100); $nome->setSize(200); // add one row for each form field $table->addRowSet(new TLabel('id:'), $id); $table->addRowSet(new TLabel('nome:'), $nome); $this->form->setFields(array($id, $nome, $multifield, $multifield_email)); // create the form actions $save_button = TButton::create('save', array($this, 'onSave'), _t('Save'), 'bs:floppy-disk red'); $new_button = TButton::create('new', array($this, 'onEdit'), _t('New'), 'bs:edit green'); $this->form->addField($save_button); $this->form->addField($new_button); $buttons_box = new THBox(); $buttons_box->add($save_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; $note->appendPage('Clientes', $table); $note->appendPage('Telefone', $multifield); $note->appendPage('Email', $multifield_email); $this->form->add($note); // vertical box container $container = new TVBox(); $container->style = 'width: 90%'; // $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__)); $container->add(TPanelGroup::pack('Title', $this->form)); parent::add($container); }