/** * Class constructor * Creates the page and the registration form */ function __construct() { parent::__construct(); // Cria o form $this->form = new TForm('form_Usuario'); $this->form->class = 'tform'; // creates the table container $table = new TTable(); $table->style = 'width: 100%'; $table->addRowSet(new TLabel('Usuário'), '', '', '')->class = 'tformtitle'; // adiciona a tabela no form $this->form->add($table); $frame_grupos = new TFrame(NULL, 280); $frame_grupos->setLegend('Grupos'); $frame_grupos->style .= ';margin: 4px'; $frame_funcionalidades = new TFrame(NULL, 280); $frame_funcionalidades->setLegend('Funcionalidades'); $frame_funcionalidades->style .= ';margin: 15px'; // cria os campos de pesquisa do form $id = new TEntry('id'); $nome = new TEntry('nome'); $prontuario = new TEntry('prontuario'); $password = new TPassword('senha'); $repassword = new TPassword('resenha'); $email = new TEntry('email'); $multifield_funcionalidades = new TMultiField('funcionalidades'); $funcionalidade_id = new TDBSeekButton('funcionalidade_id', 'saciq', 'form_Usuario', 'Funcionalidade', 'nome', 'funcionalidades_id', 'funcionalidades_nome'); $funcionalidade_nome = new TEntry('funcionalidade_nome'); $grupos = new TDBCheckGroup('grupos', 'saciq', 'Grupo', 'id', 'nome'); //$frontpage_id = new TDBSeekButton('frontpage_id', 'saciq', 'form_Usuario', 'Funcionalidade', 'nome', 'frontpage_id', 'frontpage_nome'); //$frontpage_nome = new TEntry('frontpage_nome'); $scroll = new TScroll(); $scroll->setSize(290, 230); $scroll->add($grupos); $frame_grupos->add($scroll); $frame_funcionalidades->add($multifield_funcionalidades); // define the sizes $id->setSize(100); $nome->setSize(350); $prontuario->setSize(150); $password->setSize(150); $repassword->setSize(150); $email->setSize(250); $multifield_funcionalidades->setHeight(140); // outros $id->setEditable(false); $funcionalidade_nome->setEditable(false); $email->setProperty('autocomplete', 'off'); // validations $nome->addValidation('Nome', new TRequiredValidator()); $prontuario->addValidation('Prontuário', new TRequiredValidator()); $email->addValidation('Email', new TEmailValidator()); $nome->addValidation('Nome', new TMaxLengthValidator(), array(60)); $prontuario->addValidation('Prontuário', new TMaxLengthValidator(), array(60)); $email->addValidation('Email', new TMaxLengthValidator(), array(60)); $funcionalidade_id->setSize(50); $funcionalidade_nome->setSize(200); // configuracoes multifield $multifield_funcionalidades->setClass('Funcionalidade'); $multifield_funcionalidades->addField('id', 'ID', $funcionalidade_id, 60, true); $multifield_funcionalidades->addField('nome', 'Nome', $funcionalidade_nome, 250); $multifield_funcionalidades->setOrientation('horizontal'); // add a row for the field id $table->addRowSet(new TLabel('ID:'), $id, new TLabel('Nome: '), $nome); $table->addRowSet(new TLabel('Prontuário: '), $prontuario, new TLabel('Email: '), $email); $table->addRowSet(new TLabel('Senha: '), $password, new TLabel('Confirmação <br>da senha: '), $repassword); $row = $table->addRow(); $cell = $row->addCell($frame_grupos); $cell->colspan = 2; $cell = $row->addCell($frame_funcionalidades); $cell->colspan = 2; // create an action button (save) $save_button = new TButton('save'); $save_button->setAction(new TAction(array($this, 'onSave')), 'Salvar'); $save_button->setImage('ico_save.png'); // create an new button (edit with no parameters) $new_button = new TButton('new'); $new_button->setAction(new TAction(array($this, 'onEdit')), 'Novo'); $new_button->setImage('ico_new.png'); $list_button = new TButton('list'); $list_button->setAction(new TAction(array('UsuarioList', 'onReload')), 'Voltar para a listagem'); $list_button->setImage('ico_datagrid.png'); // define the form fields $this->form->setFields(array($id, $nome, $prontuario, $password, $repassword, $multifield_funcionalidades, $grupos, $email, $save_button, $new_button, $list_button)); $buttons = new THBox(); $buttons->add($save_button); $buttons->add($new_button); $buttons->add($list_button); $row = $table->addRow(); $row->class = 'tformaction'; $cell = $row->addCell($buttons); $cell->colspan = 4; $container = new TTable(); //$container->style = 'width: 80%'; $container->addRow()->addCell(new TXMLBreadCrumb('menu.xml', 'UsuarioList')); $container->addRow()->addCell($this->form); // add the form to the page parent::add($container); }
/** * */ public function makeTFrame($properties) { $width = PHP_SAPI == 'cli' ? (int) $properties->{'width'} - 2 : (int) $properties->{'width'} - 12; $height = PHP_SAPI == 'cli' ? (int) $properties->{'height'} - 2 : (int) $properties->{'height'} - 12; $widget = new TFrame($width, $height); $class = get_class($this); // for inheritance $panel = new $class($width, $height); // pass the controller and form ahead. $panel->setController($this->controller); $panel->setForm($this->form); if ($properties->{'child'}) { foreach ($properties->{'child'} as $child) { $panel->parseElement($child); // integrate the frame' fields $this->fieldsByName = array_merge((array) $this->fieldsByName, (array) $panel->getWidgets()); $this->fields = array_merge((array) $this->fields, (array) $panel->getFields()); } } $widget->setLegend((string) $properties->{'title'}); $widget->add($panel); $this->fieldsByName[(string) $properties->{'name'}] = $widget; return $widget; }
/** * Class constructor * Creates the page and the registration form */ function __construct() { parent::__construct(); // creates the table container $table = new TTable(); $table->style = 'width:100%'; $frame_funcionalidades = new TFrame(); $frame_funcionalidades->setLegend('Funcionalidades'); // Cria o form $this->form = new TForm('form_Grupo'); $this->form->class = 'tform'; // add the notebook inside the form $this->form->add($table); $table->addRowSet(new TLabel('Grupo'), '')->class = 'tformtitle'; // cria os campos de pesquisa do form $id = new TEntry('id'); $nome = new TEntry('nome'); $sigla = new TEntry('sigla'); $this->list1 = new TSortList('list1'); $this->list2 = new TSortList('list2'); $this->list1->setSize(300, 200); $this->list2->setSize(300, 200); $this->list1->connectTo($this->list2); $this->list2->connectTo($this->list1); /* $multifield = new TMultiField('programs'); $program_id = new TDBSeekButton('program_id', 'saciq', 'form_Grupo', 'Funcionalidade', 'nome', 'programs_id', 'programs_nome'); $program_nome = new TEntry('program_nome'); $frame_programs->add($multifield); $multifield->setHeight(140); $multifield->setClass('Funcionalidade'); $multifield->addField('id', 'ID', $program_id, 100, true); $multifield->addField('nome', 'Funcionalidade', $program_nome, 250); $multifield->setOrientation('horizontal'); */ // define the sizes //$program_id->setSize(70); $id->setSize(100); $nome->setSize(400); $sigla->setSize(150); // validations $nome->addValidation('Nome', new TRequiredValidator()); $sigla->addValidation('Sigla', new TRequiredValidator()); $nome->addValidation('Nome', new TMaxLengthValidator(), array(45)); $sigla->addValidation('Sigla', new TMaxLengthValidator(), array(10)); // outras propriedades $id->setEditable(false); //$program_nome->setEditable(false); // add a row for the field id $table->addRowSet(new TLabel('ID:'), $id); $table->addRowSet(new TLabel('Nome: '), $nome); $table->addRowSet(new TLabel('Sigla:'), $sigla); // add a row for the field nome //$row = $table->addRow(); //$cell = $row->addCell($frame_programs); //$cell->colspan = 2; $vbox1 = new TVBox(); $vbox1->add(new TLabel('<b>Disponível</b>')); $vbox1->add($this->list1); $vbox2 = new TVBox(); $vbox2->add(new TLabel('<b>Selecionado</b>')); $vbox2->add($this->list2); $hbox = new THBox(); $hbox->add($vbox1); $hbox->add($vbox2); $frame_funcionalidades->add($hbox); $row = $table->addRow(); $cell = $row->addCell($frame_funcionalidades); $cell->colspan = 2; // create an action button (save) $save_button = new TButton('save'); $save_button->setAction(new TAction(array($this, 'onSave')), 'Salvar'); $save_button->setImage('ico_save.png'); // create an new button (edit with no parameters) $new_button = new TButton('new'); $new_button->setAction(new TAction(array($this, 'onEdit')), 'Novo'); $new_button->setImage('ico_new.png'); $list_button = new TButton('list'); $list_button->setAction(new TAction(array('GrupoList', 'onReload')), 'Voltar para a listagem'); $list_button->setImage('ico_datagrid.png'); // define the form fields $this->form->setFields(array($id, $nome, $sigla, $this->list1, $this->list2, $save_button, $new_button, $list_button)); $buttons = new THBox(); $buttons->add($save_button); $buttons->add($new_button); $buttons->add($list_button); $container = new TTable(); //$container->width = '80%'; $container->addRow()->addCell(new TXMLBreadCrumb('menu.xml', 'GrupoList')); $container->addRow()->addCell($this->form); $row = $table->addRow(); $row->class = 'tformaction'; $cell = $row->addCell($buttons); $cell->colspan = 2; // add the form to the page parent::add($container); }