public function __construct() { parent::__construct(); // instancia objeto DataGrid $this->datagrid = new TDataGrid(); // instancia as colunas da DataGrid $codigo = new TDataGridColumn('id', 'Código', 'right', 50); $nome = new TDataGridColumn('nome', 'Nome', 'left', 180); $endereco = new TDataGridColumn('endereco', 'Endereço', 'left', 140); $qualifica = new TDataGridColumn('qualifica', 'Qualificações', 'left', 200); $action1 = new TAction(array($this, 'onReload')); $action1->setParameter('order', 'id'); $action2 = new TAction(array($this, 'onReload')); $action2->setParameter('order', 'nome'); $codigo->setAction($action1); $nome->setAction($action2); // adiciona as colunas à DataGrid $this->datagrid->addColumn($codigo); $this->datagrid->addColumn($nome); $this->datagrid->addColumn($endereco); $this->datagrid->addColumn($qualifica); // cria o modelo da DataGrid, montando sua estrutura $this->datagrid->createModel(); // adiciona a DataGrid à página parent::add($this->datagrid); }
/** * Add a column * @param $label Field Label * @param $object Field Object * @param $size Field Size */ public function addQuickColumn($label, $name, $align = 'left', $size = 200, TAction $action = NULL, $param = NULL) { // creates a new column $object = new TDataGridColumn($name, $label, $align, $size); if ($action instanceof TAction) { // create ordering $action->setParameter($param[0], $param[1]); $object->setAction($action); } // add the column to the datagrid parent::addColumn($object); return $object; }
/** * Class constructor * Creates the page, the form and the listing */ public function __construct() { parent::__construct(); new TSession(); // creates a DataGrid $this->datagrid = new TDataGrid(); $this->datagrid->setHeight(280); // creates the datagrid columns $id = new TDataGridColumn('id', 'id', 'right', 40); $name = new TDataGridColumn('name', 'Name', 'left', 200); $address = new TDataGridColumn('address', 'Address', 'left', 200); // creates the datagrid actions $order1 = new TAction(array($this, 'onReload')); $order2 = new TAction(array($this, 'onReload')); // define the ordering parameters $order1->setParameter('order', 'id'); $order2->setParameter('order', 'name'); // assign the ordering actions $id->setAction($order1); $name->setAction($order2); // add the columns to the DataGrid $this->datagrid->addColumn($id); $this->datagrid->addColumn($name); $this->datagrid->addColumn($address); // creates a datagrid action $action1 = new TDataGridAction(array('CustomerFormView', 'onEdit')); $action1->setLabel('Edit'); $action1->setImage('ico_edit.png'); $action1->setField('id'); // add the actions to the datagrid $this->datagrid->addAction($action1); // creates the edit action $editaction = new TDataGridAction(array($this, 'onEdit')); $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 $vbox = new TVBox(); $vbox->add(new TXMLBreadCrumb('menu.xml', __CLASS__)); $vbox->add($this->datagrid); $vbox->add($this->pageNavigation); // add the table inside the page parent::add($vbox); }
/** * constructor method */ public function __construct() { parent::__construct(); // creates the form $this->form = new TForm('form_item_Seek'); // creates the table $table = new TTable(); // add the table inside the form $this->form->add($table); // create the form fields $barcode = new TEntry('barcode'); // keep the session value $barcode->setValue(TSession::getValue('test_item_barcode')); // add the field inside the table $row = $table->addRow(); $row->addCell(new TLabel(_t('Barcode'))); $row->addCell($barcode); // create a find button $find_button = new TButton('search'); // define the button action $find_button->setAction(new TAction(array($this, 'onSearch')), 'Search'); $find_button->setImage('ico_find.png'); // add a row for the find button $row = $table->addRow(); $row->addCell($find_button); // define wich are the form fields $this->form->setFields(array($barcode, $find_button)); // create the datagrid $this->datagrid = new TDataGrid(); // create the datagrid columns $id = new TDataGridColumn('id', _t('Code'), 'right', 70); $barcode = new TDataGridColumn('barcode', _t('Barcode'), 'left', 100); $title = new TDataGridColumn('title', _t('Title'), 'left', 200); $order1 = new TAction(array($this, 'onReload')); $order2 = new TAction(array($this, 'onReload')); $order1->setParameter('order', 'id'); $order2->setParameter('order', 'barcode'); // define the column actions $id->setAction($order1); $barcode->setAction($order2); // add the columns inside the datagrid $this->datagrid->addColumn($id); $this->datagrid->addColumn($barcode); $this->datagrid->addColumn($title); // create one datagrid action $action1 = new TDataGridAction(array($this, 'onSelect')); $action1->setLabel('Selecionar'); $action1->setImage('ico_apply.png'); $action1->setField('barcode'); // add the action to the datagrid $this->datagrid->addAction($action1); // create the datagrid model $this->datagrid->createModel(); // create the page navigator $this->pageNavigation = new TPageNavigation(); $this->pageNavigation->setAction(new TAction(array($this, 'onReload'))); $this->pageNavigation->setWidth($this->datagrid->getWidth()); // create a table for layout $table = new TTable(); // create a row for the form $row = $table->addRow(); $row->addCell($this->form); // create a row for the datagrid $row = $table->addRow(); $row->addCell($this->datagrid); // create a row for the page navigator $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')); } // creates the form $this->form = new TForm('form_search_Issue'); $this->form->class = 'tform'; // creates a table $table = new TTable(); $table->width = '100%'; $table->addRowSet(new TLabel(_t('Issues')), '', '', '')->class = 'tformtitle'; // add the table inside the form $this->form->add($table); // create the form fields $filter_status = new TDBCombo('id_status', 'changeman', 'Status', 'id', 'description_translated'); $filter_project = new TDBCombo('id_project', 'changeman', 'Project', 'id', 'description'); $filter_priority = new TDBCombo('id_priority', 'changeman', 'Priority', 'id', 'description_translated'); $filter_category = new TDBCombo('id_category', 'changeman', 'Category', 'id', 'description_translated'); $filter_title = new TEntry('title'); $filter_status->setValue(TSession::getValue('Issue_id_status')); $filter_project->setValue(TSession::getValue('Issue_id_project')); $filter_priority->setValue(TSession::getValue('Issue_id_priority')); $filter_category->setValue(TSession::getValue('Issue_id_category')); $filter_title->setValue(TSession::getValue('Issue_title')); $filter_title->setSize(480); // add a row for the filter field $row = $table->addRow(); $row->addCell(new TLabel(_t('Status') . ': ')); $row->addCell($filter_status); $row->addCell(new TLabel(_t('Project') . ': ')); $row->addCell($filter_project); $row = $table->addRow(); $row->addCell(new TLabel(_t('Priority') . ': ')); $row->addCell($filter_priority); $row->addCell(new TLabel(_t('Category') . ': ')); $row->addCell($filter_category); $row = $table->addRow(); $row->addCell(new TLabel(_t('Title') . ': ')); $cell = $row->addCell($filter_title); $cell->colspan = 3; // 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'); TTransaction::open('changeman'); if (Member::newFromLogin(TSession::getValue('login'))->role_mnemonic == 'CUSTOMER') { $class = 'NewIssueForm'; $new_button->setAction(new TAction(array($class, 'onEdit')), _t('New')); $new_button->setImage('ico_new.png'); } else { $class = 'UpdateIssueForm'; $new_button->setAction(new TAction(array($class, 'onEdit')), _t('New')); $new_button->setImage('ico_new.png'); } TTransaction::close(); $buttons = new THBox(); $buttons->add($find_button); $buttons->add($new_button); $row = $table->addRow(); $row->class = 'tformaction'; $cell = $row->addCell($buttons); $cell->colspan = 4; // define wich are the form fields $this->form->setFields(array($filter_status, $filter_project, $filter_priority, $filter_category, $filter_title, $find_button, $new_button)); // creates a DataGrid $this->datagrid = new TDataGrid(); $this->datagrid->setHeight(320); // creates the datagrid columns $id = new TDataGridColumn('id', 'ID', 'right', 50); $title = new TDataGridColumn('title', _t('Title'), 'left', 260); $id_status = new TDataGridColumn('status', _t('Status'), 'left', 100); $id_priority = new TDataGridColumn('priority', _t('Priority'), 'left', 100); $id_category = new TDataGridColumn('category', _t('Category'), 'left', 100); $register_date = new TDataGridColumn('register_date', _t('Start date'), 'left', 110); // creates the datagrid actions $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')); $order6 = new TAction(array($this, 'onReload')); $order7 = new TAction(array($this, 'onReload')); $order8 = new TAction(array($this, 'onReload')); // define the ordering parameters $order1->setParameter('order', 'id'); $order2->setParameter('order', 'title'); $order3->setParameter('order', 'id_status'); $order4->setParameter('order', 'id_priority'); $order5->setParameter('order', 'id_category'); $order6->setParameter('order', 'register_date'); // assign the ordering actions $id->setAction($order1); $title->setAction($order2); $id_status->setAction($order3); $id_priority->setAction($order4); $id_category->setAction($order5); $register_date->setAction($order6); // add the columns to the DataGrid $this->datagrid->addColumn($id); $this->datagrid->addColumn($title); $this->datagrid->addColumn($id_status); $this->datagrid->addColumn($id_priority); $this->datagrid->addColumn($id_category); $this->datagrid->addColumn($register_date); // security check TTransaction::open('changeman'); if (Member::newFromLogin(TSession::getValue('login'))->role_mnemonic == 'ADMINISTRATOR' or Member::newFromLogin(TSession::getValue('login'))->role_mnemonic == 'MANAGER') { // creates two datagrid actions $class = 'UpdateIssueForm'; $action1 = new TDataGridAction(array($class, 'onEdit')); $action1->setLabel(_t('Edit')); $action1->setImage('ico_edit.png'); $action1->setField('id'); $action2 = new TDataGridAction(array($this, 'onDelete')); $action2->setLabel(_t('Delete')); $action2->setImage('ico_delete.png'); $action2->setField('id'); // add the actions to the datagrid $this->datagrid->addAction($action1); $this->datagrid->addAction($action2); } else { if (Member::newFromLogin(TSession::getValue('login'))->role_mnemonic == 'MEMBER') { // creates two datagrid actions $class = 'UpdateIssueForm'; $action1 = new TDataGridAction(array($class, 'onEdit')); $action1->setLabel(_t('Edit')); $action1->setImage('ico_edit.png'); $action1->setField('id'); // add the actions to the datagrid $this->datagrid->addAction($action1); } } // creates two datagrid actions $class = 'ViewIssueForm'; $action3 = new TDataGridAction(array($class, 'onView')); $action3->setLabel(_t('View')); $action3->setImage('ico_view.png'); $action3->setField('id'); $class = 'NoteForm'; $action4 = new TDataGridAction(array($class, 'onEdit')); $action4->setLabel(_t('Comment')); $action4->setImage('ico_new.png'); $action4->setField('id'); // add the actions to the datagrid $this->datagrid->addAction($action3); $this->datagrid->addAction($action4); TTransaction::close(); // 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); }
/** * 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')); } // creates the form $this->form = new TForm('form_search_Release'); $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('Releases')), '')->class = 'tformtitle'; // create the form fields $filter = new TEntry('name'); $filter->setValue(TSession::getValue('Release_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'); $buttons = new THBox(); $buttons->add($find_button); // security check TTransaction::open('changeman'); if (Member::newFromLogin(TSession::getValue('login'))->role_mnemonic == 'ADMINISTRATOR' or Member::newFromLogin(TSession::getValue('login'))->role_mnemonic == 'MANAGER') { $class = 'ReleaseForm'; $new_button->setAction(new TAction(array($class, 'onEdit')), _t('New')); $new_button->setImage('ico_new.png'); $buttons->add($new_button); } TTransaction::close(); $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 TDataGrid(); $this->datagrid->setHeight(320); // creates the datagrid columns $id = new TDataGridColumn('id', 'ID', 'right', 50); $id_project = new TDataGridColumn('project', _t('Project'), 'left', 200); $name = new TDataGridColumn('name', _t('Name'), 'left', 300); // creates the datagrid actions $order1 = new TAction(array($this, 'onReload')); $order2 = new TAction(array($this, 'onReload')); $order3 = new TAction(array($this, 'onReload')); // define the ordering parameters $order1->setParameter('order', 'id'); $order2->setParameter('order', 'id_project'); $order3->setParameter('order', 'name'); // assign the ordering actions $id->setAction($order1); $id_project->setAction($order2); $name->setAction($order3); // add the columns to the DataGrid $this->datagrid->addColumn($id); $this->datagrid->addColumn($id_project); $this->datagrid->addColumn($name); // security check TTransaction::open('changeman'); if (Member::newFromLogin(TSession::getValue('login'))->role_mnemonic == 'ADMINISTRATOR' or Member::newFromLogin(TSession::getValue('login'))->role_mnemonic == 'MANAGER') { // creates two datagrid actions $class = 'ReleaseForm'; $action1 = new TDataGridAction(array($class, 'onEdit')); $action1->setLabel(_t('Edit')); $action1->setImage('ico_edit.png'); $action1->setField('id'); $action2 = new TDataGridAction(array($this, 'onDelete')); $action2->setLabel(_t('Delete')); $action2->setImage('ico_delete.png'); $action2->setField('id'); // add the actions to the datagrid $this->datagrid->addAction($action1); $this->datagrid->addAction($action2); } else { // creates two datagrid actions $class = 'ViewReleaseForm'; $action1 = new TDataGridAction(array($class, 'onView')); $action1->setLabel(_t('View')); $action1->setImage('ico_view.png'); $action1->setField('id'); // add the actions to the datagrid $this->datagrid->addAction($action1); } TTransaction::close(); // 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); }
/** * 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(); // creates the form $this->form = new TForm('form_search_Book'); $this->form->class = 'tform'; // creates a table $table = new TTable(); $table->width = '100%'; $table->addRowSet(new TLabel(_t('Books')), '')->class = 'tformtitle'; // add the table inside the form $this->form->add($table); // create the form fields $title = new TEntry('title'); $author_id = new TSeekButton('author_id'); $author_name = new TEntry('author_name'); $collection_id = new TDBCombo('collection_id', 'library', 'Collection', 'id', 'description'); $classification_id = new TDBCombo('classification_id', 'library', 'Classification', 'id', 'description'); $title->setValue(TSession::getValue('Book_title')); $author_id->setValue(TSession::getValue('Book_author_id')); $author_name->setValue(TSession::getValue('Book_author_name')); $collection_id->setValue(TSession::getValue('Book_collection_id')); $classification_id->setValue(TSession::getValue('Book_classification_id')); $author_name->setEditable(FALSE); $title->setSize(320); $author_id->setSize(100); $obj = new TStandardSeek(); $action = new TAction(array($obj, 'onSetup')); $action->setParameter('database', 'library'); $action->setParameter('parent', 'form_search_Book'); $action->setParameter('model', 'Author'); $action->setParameter('display_field', 'name'); $action->setParameter('receive_key', 'author_id'); $action->setParameter('receive_field', 'author_name'); $author_id->setAction($action); // add a row for the title field $row = $table->addRow(); $row->addCell(new TLabel(_t('Title') . ': ')); $cell = $row->addCell($title); // add a row for the title field $row = $table->addRow(); $row->addCell(new TLabel(_t('Author') . ': ')); $row->addMultiCell($author_id, $author_name); // add a row for the title field $row = $table->addRow(); $row->addCell(new TLabel(_t('Collection') . ': ')); $cell = $row->addCell($collection_id); // add a row for the title field $row = $table->addRow(); $row->addCell(new TLabel(_t('Classification') . ': ')); $cell = $row->addCell($classification_id); // 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('BookForm', 'onEdit')), _t('New')); $new_button->setImage('ico_new.png'); $table->addRowSet('', array($find_button, $new_button))->class = 'tformaction'; // define wich are the form fields $this->form->setFields(array($title, $author_id, $author_name, $collection_id, $classification_id, $find_button, $new_button)); // creates a DataGrid $this->datagrid = new TDataGrid(); $this->datagrid->setHeight(280); // creates the datagrid columns $id = new TDataGridColumn('id', _t('Code'), 'right', 50); $title = new TDataGridColumn('title', _t('Title'), 'left', 200); $main_author = new TDataGridColumn('author_name', _t('Author'), 'left', 160); $edition = new TDataGridColumn('edition', _t('Edition'), 'left', 50); $call = new TDataGridColumn('call_number', _t('Call'), 'left', 80); // creates the datagrid actions $order1 = new TAction(array($this, 'onReload')); $order2 = new TAction(array($this, 'onReload')); // define the ordering parameters $order1->setParameter('order', 'id'); $order2->setParameter('order', 'title'); // assign the ordering actions $id->setAction($order1); $title->setAction($order2); // add the columns to the DataGrid $this->datagrid->addColumn($id); $this->datagrid->addColumn($title); $this->datagrid->addColumn($main_author); $this->datagrid->addColumn($edition); $this->datagrid->addColumn($call); // creates two datagrid actions $action1 = new TDataGridAction(array('BookForm', 'onEdit')); $action1->setLabel(_t('Edit')); $action1->setImage('ico_edit.png'); $action1->setField('id'); $action2 = new TDataGridAction(array($this, 'onDelete')); $action2->setLabel(_t('Delete')); $action2->setImage('ico_delete.png'); $action2->setField('id'); // add the actions to the datagrid $this->datagrid->addAction($action1); $this->datagrid->addAction($action2); // 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); }
/** * constructor method */ public function __construct() { parent::__construct(); parent::setTitle('Busca de Pessoas'); parent::setSize(800, 600); new TSession(); // creates the form $this->form = new TForm('form_city_Pessoa'); // creates the table $table = new TTable(); // add the table inside the form $this->form->add($table); // create the form fields $name = new TEntry('pessoa_nome'); // keep the session value $name->setValue(TSession::getValue('test_pessoa_name')); // add the field inside the table $row = $table->addRow(); $row->addCell(new TLabel('Nome:')); $row->addCell($name); // create a find button $find_button = new TButton('search'); // define the button action $find_button->setAction(new TAction(array($this, 'onSearch')), 'Search'); $find_button->setImage('ico_find.png'); // add a row for the find button $row = $table->addRow(); $row->addCell($find_button); // define wich are the form fields $this->form->setFields(array($name, $find_button)); // create the datagrid $this->datagrid = new TDataGrid(); // create the datagrid columns $id = new TDataGridColumn('pessoa_codigo', 'Id', 'right', 25); $name = new TDataGridColumn('pessoa_nome', 'Nome', 'left', 250); $origem = new TDataGridColumn('origem_nome', 'Origem', 'left', 330); $order1 = new TAction(array($this, 'onReload')); $order2 = new TAction(array($this, 'onReload')); $order1->setParameter('order', 'pessoa_codigo'); $order2->setParameter('order', 'pessoa_nome'); // define the column actions $id->setAction($order1); $name->setAction($order2); // add the columns inside the datagrid $this->datagrid->addColumn($id); $this->datagrid->addColumn($name); $this->datagrid->addColumn($origem); // create one datagrid action $action1 = new TDataGridAction(array($this, 'onSelect')); $action1->setLabel('Selecionar'); $action1->setImage('fa:check-circle-o green'); $action1->setField('pessoa_codigo'); // add the action to the datagrid $this->datagrid->addAction($action1); // create the datagrid model $this->datagrid->createModel(); // create the page navigator $this->pageNavigation = new TPageNavigation(); $this->pageNavigation->setAction(new TAction(array($this, 'onReload'))); $this->pageNavigation->setWidth($this->datagrid->getWidth()); // create a table for layout $table = new TTable(); // create a row for the form $row = $table->addRow(); $row->addCell($this->form); // create a row for the datagrid $row = $table->addRow(); $row->addCell($this->datagrid); // create a row for the page navigator $row = $table->addRow(); $row->addCell($this->pageNavigation); $table->style = 'width: 100%;max-width: 1200px;'; $this->datagrid->style = ' width: 100%; max-width: 1200px;'; // add the table inside the page parent::add($table); }
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); }
/** * 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(); // creates the form $this->form = new TForm('form_search_Author'); $this->form->class = 'tform'; $this->form->style = 'width: 600px'; // creates a table $table = new TTable(); $table->width = '100%'; // add the table inside the form $this->form->add($table); $table->addRowSet(new TLabel(_t('Authors')), '')->class = 'tformtitle'; // create the form fields $filter = new TEntry('name'); $filter->setValue(TSession::getValue('Author_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('AuthorForm', '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 TDataGrid(); $this->datagrid->setHeight(320); // creates the datagrid columns $id = new TDataGridColumn('id', 'id', 'right', 100); $name = new TDataGridColumn('name', 'name', 'left', 440); // creates the datagrid actions $order1 = new TAction(array($this, 'onReload')); $order2 = new TAction(array($this, 'onReload')); // define the ordering parameters $order1->setParameter('order', 'id'); $order2->setParameter('order', 'name'); // assign the ordering actions $id->setAction($order1); $name->setAction($order2); // add the columns to the DataGrid $this->datagrid->addColumn($id); $this->datagrid->addColumn($name); // creates two datagrid actions $action1 = new TDataGridAction(array('AuthorForm', 'onEdit')); $action1->setLabel(_t('Edit')); $action1->setImage('ico_edit.png'); $action1->setField('id'); $action2 = new TDataGridAction(array($this, 'onDelete')); $action2->setLabel(_t('Delete')); $action2->setImage('ico_delete.png'); $action2->setField('id'); // add the actions to the datagrid $this->datagrid->addAction($action1); $this->datagrid->addAction($action2); // 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); }
/** * Class constructor * Creates the page, the form and the listing */ public function __construct() { parent::__construct(); new TSession(); // create the form $this->form = new TQuickForm('form_search_City'); $this->form->class = 'tform'; // CSS class $this->form->style = 'width: 500px'; $this->form->setFormTitle('Manual Datagrid'); // create the form fields $name = new TEntry('name'); // add the form fields $this->form->addQuickField('Name', $name, 200); // define the form actions $this->form->addQuickAction('Find', new TAction(array($this, 'onSearch')), 'ico_find.png'); $this->form->addQuickAction('New', new TAction(array('CompleteFormView', 'onEdit')), 'ico_new.png'); $name->setValue(TSession::getValue('City_name')); // creates a DataGrid $this->datagrid = new TDataGrid(); $this->datagrid->setHeight(280); // creates the datagrid columns $id = new TDataGridColumn('id', 'id', 'right', 40); $name = new TDataGridColumn('name', 'name', 'left', 400); // creates the datagrid actions $order1 = new TAction(array($this, 'onReload')); $order2 = new TAction(array($this, 'onReload')); // define the ordering parameters $order1->setParameter('order', 'id'); $order2->setParameter('order', 'name'); // assign the ordering actions $id->setAction($order1); $name->setAction($order2); // add the columns to the DataGrid $this->datagrid->addColumn($id); $this->datagrid->addColumn($name); // creates two datagrid actions $action1 = new TDataGridAction(array('CompleteFormView', 'onEdit')); $action1->setLabel('Edit'); $action1->setImage('ico_edit.png'); $action1->setField('id'); $action2 = new TDataGridAction(array($this, 'onDelete')); $action2->setLabel('Delete'); $action2->setImage('ico_delete.png'); $action2->setField('id'); // add the actions to the datagrid $this->datagrid->addAction($action1); $this->datagrid->addAction($action2); // 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); // add a row to the form $table->addRow()->addCell($this->datagrid); // add a row to the datagrid $table->addRow()->addCell($this->pageNavigation); // add a row for page navigation // add the table inside the page parent::add($table); }
/** * constructor method */ public function __construct() { parent::__construct(); new TSession(); // creates the form $this->form = new TForm('form_city_Seek'); // creates the table $table = new TTable(); // add the table inside the form $this->form->add($table); // create the form fields $name = new TEntry('name'); $code = new TEntry('id'); $crm_id = new TDBCombo('crm_id', 'db_crmbf', 'CRM', 'id', 'titulo'); $tiporegistro_id = new TDBCombo('tiporegistro_id', 'db_crmbf', 'RegistroTipo', 'id', 'nome'); $registro = new TText('registro'); $temporegistro = new TEntry('tempo_registro'); // $temporegistro->setEditable(false); $dataregistro = new TDate('data_registro'); $hora_registro = new TEntry('hora_registro'); $numero_registro = new TEntry('numero_registro'); // keep the session value // $name->setValue(TSession::getValue('test_city_name')); // add the field inside the table // $row=$table->addRow(); // $row->addCell(new TLabel('Name:')); // $row->addCell($name); $code->setEditable(FALSE); $code->setSize(100); $crm_id->setSize(320); $registro->setSize(320); $temporegistro->setSize(160); //$temporegistro->setValue(date("d/m/Y H:i:s")); $tiporegistro_id->setSize(160); //$dataregistro->setRange(0,1000,1); $dataregistro->setSize(90); // $hora_registro->setRange(0,100,1); $hora_registro->setSize(150); $hora_registro->setTip('Horario EX: 8:14'); $numero_registro->setSize(320); $row = $table->addRow(); $row->addCell(new TLabel('Code:')); $row->addCell($code); // add a row for the field name $row = $table->addRow(); $row->addCell(new TLabel('CRM Titulo:')); $cell = $row->addCell($crm_id); // add a row for the field Telefone $row = $table->addRow(); $row->addCell(new TLabel('Tipo Registro:')); $cell = $row->addCell($tiporegistro_id); // add a row for the field Email $row = $table->addRow(); $row->addCell(new TLabel('Tempo:')); $cell = $row->addCell($temporegistro); // add a row for the field celular $row = $table->addRow(); $row->addCell(new TLabel('Data:')); $cell = $row->addCell($dataregistro); // add a row for the field skype $row = $table->addRow(); $row->addCell(new TLabel('Hora:')); $cell = $row->addCell($hora_registro); // add a row for the field endereco $row = $table->addRow(); $row->addCell(new TLabel('Numero Registro:')); $row->addCell($numero_registro); // add a row for the field name $row = $table->addRow(); $row->addCell(new TLabel('Registro:')); $cell = $row->addCell($registro); // create a find button $find_button = new TButton('search'); // define the button action $find_button->setAction(new TAction(array($this, 'onSearch')), 'Search'); $find_button->setImage('ico_find.png'); // add a row for the find button $row = $table->addRow(); $row->addCell($find_button); // define wich are the form fields $this->form->setFields(array($name, $find_button)); // create the datagrid $this->datagrid = new TDataGrid(); // create the datagrid columns $id = new TDataGridColumn('id', 'Id', 'right', 70); $name = new TDataGridColumn('name', 'Name', 'left', 220); $state = new TDataGridColumn('state', 'Estado', 'left', 80); $order1 = new TAction(array($this, 'onReload')); $order2 = new TAction(array($this, 'onReload')); $order1->setParameter('order', 'id'); $order2->setParameter('order', 'name'); // define the column actions $id->setAction($order1); $name->setAction($order2); // add the columns inside the datagrid $this->datagrid->addColumn($id); $this->datagrid->addColumn($name); $this->datagrid->addColumn($state); // create one datagrid action $action1 = new TDataGridAction(array($this, 'onSelect')); $action1->setLabel('Selecionar'); $action1->setImage('ico_apply.png'); $action1->setField('id'); // add the action to the datagrid $this->datagrid->addAction($action1); // create the datagrid model $this->datagrid->createModel(); // create the page navigator $this->pageNavigation = new TPageNavigation(); $this->pageNavigation->setAction(new TAction(array($this, 'onReload'))); $this->pageNavigation->setWidth($this->datagrid->getWidth()); // create a table for layout $table = new TTable(); // create a row for the form $row = $table->addRow(); $row->addCell($this->form); // create a row for the datagrid $row = $table->addRow(); $row->addCell($this->datagrid); // create a row for the page navigator $row = $table->addRow(); $row->addCell($this->pageNavigation); // add the table inside the page parent::add($table); }