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);
 }
Esempio n. 2
0
 /**
  * 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);
 }
Esempio n. 4
0
 /**
  * Add a Column to the DataGrid
  * @param $object A TDataGridColumn object
  */
 public function addColumn(TDataGridColumn $column)
 {
     $renderers = $column->get_cell_renderers();
     $cell_renderer = $renderers[0];
     $column->add_attribute($cell_renderer, 'text', $this->count);
     $column->set_cell_data_func($cell_renderer, array($this, 'formatZebra'));
     $this->view->append_column($column);
     $this->types[] = GObject::TYPE_STRING;
     $this->columns[] = $column;
     if ($column->getWidth()) {
         $this->width += $column->getWidth();
         $width = $this->width + count($this->columns) * 10;
         $this->view->set_size_request($width, -1);
     }
     $this->count++;
 }
 public function __construct()
 {
     parent::__construct();
     // creates one datagrid
     $this->datagrid = new TDataGrid();
     // create the datagrid columns
     $code = new TDataGridColumn('code', 'Code', 'right', 70);
     $desc = new TDataGridColumn('description', 'Description', 'left', 180);
     $stock = new TDataGridColumn('stock', 'Stock', 'right', 180);
     $stock->setTransformer(array($this, 'formatSalary'));
     // add the columns to the datagrid
     $this->datagrid->addColumn($code);
     $this->datagrid->addColumn($desc);
     $this->datagrid->addColumn($stock);
     // creates the datagrid model
     $this->datagrid->createModel();
     // wrap the page content using vertical box
     $vbox = new TVBox();
     $vbox->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
     $vbox->add($this->datagrid);
     parent::add($vbox);
 }
 public function __construct()
 {
     parent::__construct();
     // creates one datagrid
     $this->datagrid = new TDataGrid();
     // create the datagrid columns
     $country = new TDataGridColumn('country', 'Country', 'left', 100);
     $format = new TDataGridColumn('format', 'Format', 'left', 100);
     $origin_date = new TDataGridColumn('origin_date', 'Original date', 'left', 100);
     $transf_date = new TDataGridColumn('transf_date', 'Converted date', 'left', 100);
     $transf_date->setTransformer(array($this, 'formatDate'));
     // add the columns to the datagrid
     $this->datagrid->addColumn($country);
     $this->datagrid->addColumn($format);
     $this->datagrid->addColumn($origin_date);
     $this->datagrid->addColumn($transf_date);
     // creates the datagrid model
     $this->datagrid->createModel();
     // wrap the page content using vertical box
     $vbox = new TVBox();
     $vbox->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
     $vbox->add($this->datagrid);
     parent::add($vbox);
 }
Esempio n. 7
0
 /**
  * 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);
 }
Esempio n. 8
0
 /**
  * Initializes the specified cell to its initial values.
  * This method overrides the parent implementation.
  * It creates a hyperlink within the cell.
  * @param TTableCell the cell to be initialized.
  * @param integer the index to the Columns property that the cell resides in.
  * @param string the type of cell (Header,Footer,Item,AlternatingItem,EditItem,SelectedItem)
  */
 public function initializeCell($cell, $columnIndex, $itemType)
 {
     if ($itemType === TListItemType::Item || $itemType === TListItemType::AlternatingItem || $itemType === TListItemType::SelectedItem || $itemType === TListItemType::EditItem) {
         $link = new THyperLink();
         if (($url = $this->getImageUrl()) !== '') {
             $link->setImageUrl($url);
             if (($width = $this->getImageWidth()) !== '') {
                 $link->setImageWidth($width);
             }
             if (($height = $this->getImageHeight()) !== '') {
                 $link->setImageHeight($height);
             }
         }
         $link->setText($this->getText());
         $link->setNavigateUrl($this->getNavigateUrl());
         $link->setTarget($this->getTarget());
         if ($this->getDataTextField() !== '' || $this->getDataNavigateUrlField() !== '') {
             $link->attachEventHandler('OnDataBinding', array($this, 'dataBindColumn'));
         }
         $cell->getControls()->add($link);
         $cell->registerObject('HyperLink', $link);
     } else {
         parent::initializeCell($cell, $columnIndex, $itemType);
     }
 }
Esempio n. 9
0
 /**
  * Initializes the specified cell to its initial values.
  * This method overrides the parent implementation.
  * It creates a checkbox inside the cell.
  * If the column is read-only or if the item is not in edit mode,
  * the checkbox will be set disabled.
  * @param TTableCell the cell to be initialized.
  * @param integer the index to the Columns property that the cell resides in.
  * @param string the type of cell (Header,Footer,Item,AlternatingItem,EditItem,SelectedItem)
  */
 public function initializeCell($cell, $columnIndex, $itemType)
 {
     if ($itemType === TListItemType::Item || $itemType === TListItemType::AlternatingItem || $itemType === TListItemType::SelectedItem || $itemType === TListItemType::EditItem) {
         $checkBox = new TCheckBox();
         if ($this->getReadOnly() || $itemType !== TListItemType::EditItem) {
             $checkBox->setEnabled(false);
         }
         $cell->setHorizontalAlign('Center');
         $cell->getControls()->add($checkBox);
         $cell->registerObject('CheckBox', $checkBox);
         if ($this->getDataField() !== '') {
             $checkBox->attachEventHandler('OnDataBinding', array($this, 'dataBindColumn'));
         }
     } else {
         parent::initializeCell($cell, $columnIndex, $itemType);
     }
 }
 /**
  * Initializes the specified cell to its initial values.
  * This method overrides the parent implementation.
  * It creates a command button within the cell.
  * @param TTableCell the cell to be initialized.
  * @param integer the index to the Columns property that the cell resides in.
  * @param string the type of cell (Header,Footer,Item,AlternatingItem,EditItem,SelectedItem)
  */
 public function initializeCell($cell, $columnIndex, $itemType)
 {
     parent::initializeCell($cell, $columnIndex, $itemType);
     if ($itemType === TDataGridItem::TYPE_ITEM || $itemType === TDataGridItem::TYPE_ALTERNATING_ITEM || $itemType === TDataGridItem::TYPE_SELECTED_ITEM || $itemType === TDataGridItem::TYPE_EDIT_ITEM) {
         $buttonType = $this->getButtonType() === 'LinkButton' ? 'TLinkButton' : 'TButton';
         $button = $cell->createComponent($buttonType);
         $textField = $this->getDataTextField();
         if (strlen($textField)) {
             $text = $cell->getContainer()->Data[$textField];
             $text = $this->formatDataTextValue($text);
         } else {
             $text = $this->getText();
         }
         $button->setText($text);
         $button->setCommandName($this->getCommandName());
         $button->setCausesValidation(false);
         $cell->addBody($button);
     }
 }
 /**
  * Class constructor
  * Creates the page, the form and the listing
  */
 public function __construct()
 {
     parent::__construct();
     // creates the form
     $this->form = new TForm('form_search_RequisitoDesenvolvimento');
     $this->form->class = 'tform';
     // CSS class
     // creates a table
     $table = new TTable();
     $table->width = '100%';
     $this->form->add($table);
     // add a row for the form title
     $row = $table->addRow();
     $row->class = 'tformtitle';
     // CSS class
     $row->addCell(new TLabel('Cadastro de DRs'))->colspan = 2;
     // create the form fields
     $id = new TEntry('ticket_id');
     $id->setMask('99999');
     $titulo = new TEntry('titulo');
     $data_cadastro = new TDate('data_cadastro');
     $data_cadastro->setMask('dd/mm/yyyy');
     // define the sizes
     $id->setSize(50);
     $titulo->setSize(200);
     $data_cadastro->setSize(100);
     // add one row for each form field
     $table->addRowSet(new TLabel('Ticket:'), $id);
     $table->addRowSet(new TLabel('Título:'), $titulo);
     $table->addRowSet(new TLabel('Data:'), $data_cadastro);
     $this->form->setFields(array($id, $titulo, $data_cadastro));
     // keep the form filled during navigation with session data
     $this->form->setData(TSession::getValue('RequisitoDesenvolvimento_filter_data'));
     // create two action buttons to the form
     $find_button = TButton::create('find', array($this, 'onSearch'), _t('Find'), 'ico_find.png');
     $clean_button = TButton::create('clean', array($this, 'onClean'), 'Limpar', 'ico_close.png');
     $this->form->addField($find_button);
     $this->form->addField($clean_button);
     $buttons_box = new THBox();
     $buttons_box->add($find_button);
     $buttons_box->add($clean_button);
     // add a row for the form action
     $row = $table->addRow();
     $row->class = 'tformaction';
     // CSS class
     $row->addCell($buttons_box)->colspan = 2;
     // creates a Datagrid
     $this->datagrid = new TDataGrid();
     $this->datagrid->setHeight(320);
     // creates the datagrid columns
     $id = new TDataGridColumn('ticket_id', 'ID', 'right', 20);
     $data_cadastro = new TDataGridColumn('data_cadastro', 'Data', 'left', 80);
     $titulo = new TDataGridColumn('titulo', 'Título', 'left', 300);
     $ticket_id = new TDataGridColumn('ticket->titulo', 'Ticket', 'right', 300);
     $data_cadastro->setTransformer(array('StringsUtil', 'formatDateBR'));
     // add the columns to the DataGrid
     $this->datagrid->addColumn($id);
     $this->datagrid->addColumn($data_cadastro);
     $this->datagrid->addColumn($titulo);
     $this->datagrid->addColumn($ticket_id);
     // creates the datagrid column actions
     $order_id = new TAction(array($this, 'onReload'));
     $order_id->setParameter('order', 'id');
     $id->setAction($order_id);
     $order_titulo = new TAction(array($this, 'onReload'));
     $order_titulo->setParameter('order', 'titulo');
     $titulo->setAction($order_titulo);
     $order_data_cadastro = new TAction(array($this, 'onReload'));
     $order_data_cadastro->setParameter('order', 'data_cadastro');
     $data_cadastro->setAction($order_data_cadastro);
     $order_ticket_id = new TAction(array($this, 'onReload'));
     $order_ticket_id->setParameter('order', 'ticket->titulo');
     $ticket_id->setAction($order_ticket_id);
     // creates two datagrid actions
     $action1 = new TDataGridAction(array('RequisitoDesenvolvimentoForm', 'onEdit'));
     $action1->setLabel(_t('Edit'));
     $action1->setImage('fa:pencil-square-o blue fa-lg');
     $action1->setField('id');
     $action2 = new TDataGridAction(array($this, 'onDelete'));
     $action2->setLabel(_t('Delete'));
     $action2->setImage('fa:trash-o red fa-lg');
     $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());
     // create the page container
     $container = TVBox::pack($this->form, $this->datagrid, $this->pageNavigation);
     $container->style = 'width: 100%;max-width: 1200px;';
     $this->datagrid->style = '  width: 100%;  max-width: 1200px;';
     parent::add($container);
 }
 /**
  * Initializes the specified cell to its initial values.
  * This method overrides the parent implementation.
  * It creates a textbox for item in edit mode and the column is not read-only.
  * Otherwise it displays a static text.
  * The caption of the button and the static text are retrieved
  * from the datasource.
  * @param TTableCell the cell to be initialized.
  * @param integer the index to the Columns property that the cell resides in.
  * @param string the type of cell (Header,Footer,Item,AlternatingItem,EditItem,SelectedItem)
  */
 public function initializeCell($cell, $columnIndex, $itemType)
 {
     if (!$this->_dataBound && $this->_listControl->getDataSource() !== null) {
         $this->_listControl->setDataTextField($this->getListTextField());
         $this->_listControl->setDataValueField($this->getListValueField());
         $this->_listControl->setDataTextFormatString($this->getListTextFormatString());
         $this->_listControl->dataBind();
         $this->_dataBound = true;
     }
     switch ($itemType) {
         case TListItemType::EditItem:
             if (!$this->getReadOnly()) {
                 $listControl = clone $this->_listControl;
                 $cell->getControls()->add($listControl);
                 $cell->registerObject('DropDownList', $listControl);
                 $control = $listControl;
             } else {
                 $control = $cell;
             }
             $control->attachEventHandler('OnDataBinding', array($this, 'dataBindColumn'));
             break;
         case TListItemType::Item:
         case TListItemType::AlternatingItem:
         case TListItemType::SelectedItem:
             if ($this->getDataTextField() !== '' || $this->getDataValueField() !== '') {
                 $cell->attachEventHandler('OnDataBinding', array($this, 'dataBindColumn'));
             }
             break;
         default:
             parent::initializeCell($cell, $columnIndex, $itemType);
             break;
     }
 }
Esempio n. 13
0
 /**
  * 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);
 }
Esempio n. 14
0
 /**
  * Class constructor
  * Creates the page, the form and the listing
  */
 public function __construct()
 {
     parent::__construct();
     // creates the form
     $this->form = new TForm('form_search_Ticket');
     $this->form->class = 'tform';
     // CSS class
     // creates a table
     $table = new TTable();
     $table->width = '100%';
     $this->form->add($table);
     // add a row for the form title
     $row = $table->addRow();
     $row->class = 'tformtitle';
     // CSS class
     $row->addCell(new TLabel('Ticket'))->colspan = 2;
     // create the form fields
     $id = new TEntry('id');
     $id->setMask('99999');
     $titulo = new TEntry('titulo');
     $criteria = new TCriteria();
     $criteria->add(new TFilter("ativo", "=", 1));
     $newparam['order'] = 'pessoa_nome';
     $newparam['direction'] = 'asc';
     $criteria->setProperties($newparam);
     // order, offset
     $solicitante_id = new TDBSeekButton('solicitante_id', 'atividade', 'form_search_Ticket', 'Pessoa', 'pessoa_nome', 'solicitante_id', 'solicitante_nome', $criteria);
     $solicitante_nome = new TEntry('solicitante_nome');
     $solicitante_nome->setEditable(FALSE);
     $criteria = new TCriteria();
     $criteria->add(new TFilter('enttipent', '=', 1));
     $entcodent = new TDBComboMultiValue('entcodent', 'atividade', 'Entidade', 'entcodent', array(0 => 'entcodent', 1 => 'entrazsoc'), 'entcodent', $criteria);
     $tipo_ticket_id = new TDBCombo('tipo_ticket_id', 'atividade', 'TipoTicket', 'id', 'nome');
     $status_ticket_id = new TDBCombo('status_ticket_id', 'atividade', 'StatusTicket', 'id', 'nome');
     $criteria = new TCriteria();
     $criteria->add(new TFilter("origem", "=", 1));
     $criteria->add(new TFilter("ativo", "=", 1));
     $criteria->add(new TFilter("codigo_cadastro_origem", "=", 100));
     $responsavel_id = new TDBCombo('responsavel_id', 'atividade', 'Pessoa', 'pessoa_codigo', 'pessoa_nome', 'pessoa_nome', $criteria);
     $prioridade_id = new TDBCombo('prioridade_id', 'atividade', 'Prioridade', 'id', 'nome');
     $sistema_id = new TDBCombo('sistema_id', 'atividade', 'Sistema', 'id', 'nome', 'nome');
     // define the sizes
     $id->setSize(50);
     $titulo->setSize(274);
     $solicitante_id->setSize(50);
     $solicitante_nome->setSize(200);
     $entcodent->setSize(274);
     $status_ticket_id->setSize(100);
     $tipo_ticket_id->setSize(200);
     $sistema_id->setSize(200);
     $responsavel_id->setSize(274);
     $prioridade_id->setSize(100);
     // add one row for each form field
     $table->addRowSet(new TLabel('ID:'), $id);
     $table->addRowSet(new TLabel('Titulo:'), $titulo);
     $table->addRowSet(new TLabel('Cliente:'), array($solicitante_id, $solicitante_nome));
     $table->addRowSet(new TLabel('Entidade:'), $entcodent);
     $table->addRowSet(new TLabel('Responsável:'), $responsavel_id);
     $table->addRowSet(new TLabel('Tipo Ticket:'), $tipo_ticket_id);
     $table->addRowSet(new TLabel('Sistema:'), $sistema_id);
     $table->addRowSet(new TLabel('Status:'), $status_ticket_id);
     $table->addRowSet(new TLabel('Prioridade:'), $prioridade_id);
     $this->form->setFields(array($id, $titulo, $solicitante_id, $solicitante_nome, $entcodent, $status_ticket_id, $tipo_ticket_id, $responsavel_id, $prioridade_id, $sistema_id));
     // keep the form filled during navigation with session data
     $this->form->setData(TSession::getValue('Ticket_filter_data'));
     // create two action buttons to the form
     $find_button = TButton::create('find', array($this, 'onSearch'), _t('Find'), 'ico_find.png');
     $new_button = TButton::create('new', array('TicketForm', 'onEdit'), _t('New'), 'fa:plus-square green');
     $clean_button = TButton::create('clean', array($this, 'onClean'), 'Limpar', 'ico_close.png');
     $this->form->addField($find_button);
     $this->form->addField($new_button);
     $this->form->addField($clean_button);
     $buttons_box = new THBox();
     $buttons_box->add($find_button);
     $buttons_box->add($new_button);
     $buttons_box->add($clean_button);
     // add a row for the form action
     $row = $table->addRow();
     $row->class = 'tformaction';
     // CSS class
     $row->addCell($buttons_box)->colspan = 2;
     // creates a Datagrid
     $this->datagrid = new TDataGrid();
     $this->datagrid->setHeight(320);
     // creates the datagrid columns
     $status_ticket_id = new TDataGridColumn('status_ticket_id', 'S', 'center', 20);
     $id = new TDataGridColumn('id', 'ID', 'left', 20);
     $titulo = new TDataGridColumn('titulo', 'Titulo', 'left', 250);
     $solicitante_id = new TDataGridColumn('solicitante_id', 'Cliente', 'left', 250);
     $responsavel_id = new TDataGridColumn('pessoa_responsavel->pessoa_nome', 'Responsavel', 'left', 100);
     $prioridade_id = new TDataGridColumn('prioridade->nome', 'Pri', 'right', 20);
     //get_prioridade()->nome
     $status_ticket_id->setTransformer(array($this, 'retornaStatus'));
     $solicitante_id->setTransformer(array($this, 'retornaCliente'));
     $responsavel_id->setTransformer(array($this, 'retornaPessoa'));
     $prioridade_id->setTransformer(array($this, 'retornaPrioridade'));
     // add the columns to the DataGrid
     $this->datagrid->addColumn($status_ticket_id);
     $this->datagrid->addColumn($id);
     $this->datagrid->addColumn($titulo);
     $this->datagrid->addColumn($solicitante_id);
     $this->datagrid->addColumn($responsavel_id);
     $this->datagrid->addColumn($prioridade_id);
     // creates the datagrid column actions
     $order_id = new TAction(array($this, 'onReload'));
     $order_id->setParameter('order', 'id');
     $id->setAction($order_id);
     $order_titulo = new TAction(array($this, 'onReload'));
     $order_titulo->setParameter('order', 'titulo');
     $titulo->setAction($order_titulo);
     $order_status_ticket_id = new TAction(array($this, 'onReload'));
     $order_status_ticket_id->setParameter('order', 'status_ticket_id');
     $status_ticket_id->setAction($order_status_ticket_id);
     $order_prioridade_id = new TAction(array($this, 'onReload'));
     $order_prioridade_id->setParameter('order', 'prioridade->nome');
     $prioridade_id->setAction($order_prioridade_id);
     // creates two datagrid actions
     $action1 = new TDataGridAction(array('TicketForm', 'onEdit'));
     $action1->setLabel(_t('Edit'));
     $action1->setImage('fa:pencil-square-o blue fa-lg');
     $action1->setField('id');
     // add the actions to the datagrid
     $this->datagrid->addAction($action1);
     // 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);
     $container->style = 'width: 100%;max-width: 1200px;';
     $this->datagrid->style = '  width: 100%;  max-width: 1200px;';
     parent::add($container);
 }
Esempio n. 15
0
 /**
  * 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);
 }
 /**
  * Initializes the specified cell to its initial values.
  * This method overrides the parent implementation.
  * It creates a textbox for item in edit mode and the column is not read-only.
  * Otherwise it displays a static text.
  * The caption of the button and the static text are retrieved
  * from the datasource.
  * @param TTableCell the cell to be initialized.
  * @param integer the index to the Columns property that the cell resides in.
  * @param string the type of cell (Header,Footer,Item,AlternatingItem,EditItem,SelectedItem)
  */
 public function initializeCell($cell, $columnIndex, $itemType)
 {
     parent::initializeCell($cell, $columnIndex, $itemType);
     if ($itemType === TDataGridItem::TYPE_ITEM || $itemType === TDataGridItem::TYPE_ALTERNATING_ITEM || $itemType === TDataGridItem::TYPE_SELECTED_ITEM || $itemType === TDataGridItem::TYPE_EDIT_ITEM && $this->isReadOnly()) {
         $text = $cell->getContainer()->Data[$this->getDataField()];
         $cell->setText($this->formatDataValue($text));
     } else {
         if ($itemType === TDataGridItem::TYPE_EDIT_ITEM) {
             $textbox = new TTextBox();
             $cell->addChild($textbox);
             $cell->addBody($textbox);
             $text = $cell->getContainer()->Data[$this->getDataField()];
             $textbox->setText($text);
         }
     }
 }
 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);
 }
 public function __construct()
 {
     parent::__construct();
     // instancia nova seção
     new TSession();
     // instancia um formulário
     $this->form = new TForm('form_vendas');
     // instancia uma tabela
     $table = new TTable();
     // adiciona a tabela ao formulário
     $this->form->add($table);
     // cria os campos do formulário
     $codigo = new TEntry('id_produto');
     $quantidade = new TEntry('quantidade');
     // define os tamanhos
     $codigo->setSize(100);
     // adiciona uma linha para o campo código
     $row = $table->addRow();
     $row->addCell(new TLabel('Código:'));
     $row->addCell($codigo);
     // adiciona uma linha para o campo quantidade
     $row = $table->addRow();
     $row->addCell(new TLabel('Quantidade:'));
     $row->addCell($quantidade);
     // cria dois botões de ação para o formulário
     $save_button = new TButton('save');
     $fim_button = new TButton('fim');
     // define as ações dos botões
     $save_button->setAction(new TAction(array($this, 'onAdiciona')), 'Adicionar');
     $fim_button->setAction(new TAction(array($this, 'onFinal')), 'Finalizar');
     // adiciona uma linha para as ações do formulário
     $row = $table->addRow();
     $row->addCell($save_button);
     $row->addCell($fim_button);
     // define quais são os campos do formulário
     $this->form->setFields(array($codigo, $quantidade, $save_button, $fim_button));
     // instancia objeto DataGrid
     $this->datagrid = new TDataGrid();
     // instancia as colunas da DataGrid
     $codigo = new TDataGridColumn('id_produto', 'Código', 'right', 50);
     $descricao = new TDataGridColumn('descricao', 'Descrição', 'left', 200);
     $quantidade = new TDataGridColumn('quantidade', 'Qtde', 'right', 40);
     $preco = new TDataGridColumn('preco_venda', 'Preço', 'right', 70);
     // define um transformador para a coluna preço
     $preco->setTransformer('formata_money');
     // adiciona as colunas à DataGrid
     $this->datagrid->addColumn($codigo);
     $this->datagrid->addColumn($descricao);
     $this->datagrid->addColumn($quantidade);
     $this->datagrid->addColumn($preco);
     // cria uma ação para a datagrid
     $action = new TDataGridAction(array($this, 'onDelete'));
     $action->setLabel('Deletar');
     $action->setImage('ico_delete.png');
     $action->setField('id_produto');
     // adiciona a ação à DataGrid
     $this->datagrid->addAction($action);
     // cria o modelo da DataGrid, montando sua estrutura
     $this->datagrid->createModel();
     // monta a página através de uma tabela
     $table = new TTable();
     // cria uma linha para o formulário
     $row = $table->addRow();
     $row->addCell($this->form);
     // cria uma linha para a datagrid
     $row = $table->addRow();
     $row->addCell($this->datagrid);
     // adiciona a tabela à página
     parent::add($table);
 }
Esempio n. 19
0
 /**
  * Add a Column to the DataGrid
  * @param $object A TDataGridColumn object
  */
 public function addColumn(TDataGridColumn $column)
 {
     if ($this->modelCreated) {
         throw new Exception(TAdiantiCoreTranslator::translate('You must call ^1 before ^2', __METHOD__, 'createModel'));
     } else {
         $renderers = $column->get_cell_renderers();
         $cell_renderer = $renderers[0];
         $column->add_attribute($cell_renderer, 'text', $this->count);
         $column->set_cell_data_func($cell_renderer, array($this, 'formatZebra'));
         $this->view->append_column($column);
         $this->types[] = GObject::TYPE_STRING;
         $this->columns[] = $column;
         if ($column->getWidth()) {
             $this->width += $column->getWidth();
             $width = $this->width + count($this->columns) * 10;
             $this->view->set_size_request($width, -1);
         }
         $this->count++;
     }
 }
 /**
  * Initializes the specified cell to its initial values.
  * This method overrides the parent implementation.
  * It initializes the cell based on different templates 
  * (ItemTemplate, EditItemTemplate, HeaderTemplate, FooterTemplate).
  * @param TTableCell the cell to be initialized.
  * @param integer the index to the Columns property that the cell resides in.
  * @param string the type of cell (Header,Footer,Item,AlternatingItem,EditItem,SelectedItem)
  */
 public function initializeCell($cell, $columnIndex, $itemType)
 {
     if ($itemType === TDataGridItem::TYPE_EDIT_ITEM) {
         parent::initializeCell($cell, $columnIndex, $itemType);
         $template = $this->getEditItemTemplate();
         if (strlen($template)) {
             $cell->instantiateTemplate($template);
         } else {
             $cell->addBody('&nbsp;');
         }
     } else {
         if ($itemType === TDataGridItem::TYPE_HEADER) {
             $headerTemplate = $this->getHeaderTemplate();
             if (strlen($headerTemplate)) {
                 $cell->instantiateTemplate($headerTemplate);
             } else {
                 parent::initializeCell($cell, $columnIndex, $itemType);
             }
         } else {
             if ($itemType === TDataGridItem::TYPE_FOOTER) {
                 $footerTemplate = $this->getFooterTemplate();
                 if (strlen($footerTemplate)) {
                     $cell->instantiateTemplate($footerTemplate);
                 } else {
                     parent::initializeCell($cell, $columnIndex, $itemType);
                 }
             } else {
                 parent::initializeCell($cell, $columnIndex, $itemType);
                 $template = $this->getItemTemplate();
                 if (strlen($template)) {
                     $cell->instantiateTemplate($template);
                 } else {
                     $cell->addBody('&nbsp;');
                 }
             }
         }
     }
 }
            break;
    }
}
// declara a classe Pessoa
class Pessoa extends TRecord
{
    const TABLENAME = 'pessoa';
}
// instancia objeto DataGrid
$datagrid = new TDataGrid();
// instancia as colunas da DataGrid
$codigo = new TDataGridColumn('id', 'Código', 'right', 50);
$nome = new TDataGridColumn('nome', 'Nome', 'left', 160);
$endereco = new TDataGridColumn('endereco', 'Endereço', 'left', 140);
$datanasc = new TDataGridColumn('datanasc', 'Data Nasc', 'left', 100);
$sexo = new TDataGridColumn('sexo', 'Sexo', 'center', 100);
// aplica as funções para transformar as colunas
$nome->setTransformer('strtoupper');
$datanasc->setTransformer('conv_data_to_br');
$sexo->setTransformer('get_sexo');
// adiciona as colunas à DataGrid
$datagrid->addColumn($codigo);
$datagrid->addColumn($nome);
$datagrid->addColumn($endereco);
$datagrid->addColumn($datanasc);
$datagrid->addColumn($sexo);
// cria o modelo da DataGrid, montando sua estrutura
$datagrid->createModel();
// obtém objetos do banco de dados
try {
    // inicia transação com o banco 'pg_livro'
 /**
  * Initializes the specified cell to its initial values.
  * This method overrides the parent implementation.
  * It creates a hyperlink within the cell.
  * @param TTableCell the cell to be initialized.
  * @param integer the index to the Columns property that the cell resides in.
  * @param string the type of cell (Header,Footer,Item,AlternatingItem,EditItem,SelectedItem)
  */
 public function initializeCell($cell, $columnIndex, $itemType)
 {
     parent::initializeCell($cell, $columnIndex, $itemType);
     if ($itemType === TDataGridItem::TYPE_ITEM || $itemType === TDataGridItem::TYPE_ALTERNATING_ITEM || $itemType === TDataGridItem::TYPE_SELECTED_ITEM || $itemType === TDataGridItem::TYPE_EDIT_ITEM) {
         $textField = $this->getDataTextField();
         if (strlen($textField)) {
             $text = $cell->getContainer()->Data[$textField];
             $text = $this->formatDataTextValue($text);
         } else {
             $text = $this->getText();
         }
         $urlField = $this->getDataNavigateUrlField();
         if (strlen($urlField)) {
             $url = $cell->getContainer()->Data[$urlField];
             $url = $this->formatDataNavigateUrlValue($url);
         } else {
             $url = $this->getNavigateUrl();
         }
         $link = $cell->createComponent('THyperLink');
         $link->setEncodeText($this->isEncodeText());
         $link->setText($text);
         $link->setNavigateUrl($url);
         $link->setTarget($this->getTarget());
         $cell->addBody($link);
     }
 }
Esempio n. 23
0
 /**
  * Initializes the specified cell to its initial values.
  * This method overrides the parent implementation.
  * It creates a command button within the cell.
  * @param TTableCell the cell to be initialized.
  * @param integer the index to the Columns property that the cell resides in.
  * @param string the type of cell (Header,Footer,Item,AlternatingItem,EditItem,SelectedItem)
  */
 public function initializeCell($cell, $columnIndex, $itemType)
 {
     if ($itemType === TListItemType::Item || $itemType === TListItemType::AlternatingItem || $itemType === TListItemType::SelectedItem || $itemType === TListItemType::EditItem) {
         $buttonType = $this->getButtonType();
         if ($buttonType === TButtonColumnType::LinkButton) {
             $button = new TLinkButton();
         } else {
             if ($buttonType === TButtonColumnType::PushButton) {
                 $button = new TButton();
             } else {
                 $button = new TImageButton();
                 $button->setImageUrl($this->getImageUrl());
                 $button->setToolTip($this->getText());
             }
         }
         $button->setText($this->getText());
         $button->setCommandName($this->getCommandName());
         $button->setCausesValidation($this->getCausesValidation());
         $button->setValidationGroup($this->getValidationGroup());
         if ($this->getDataTextField() !== '' || $buttonType === TButtonColumnType::ImageButton && $this->getDataImageUrlField() !== '') {
             $button->attachEventHandler('OnDataBinding', array($this, 'dataBindColumn'));
         }
         $cell->getControls()->add($button);
         $cell->registerObject('Button', $button);
     } else {
         parent::initializeCell($cell, $columnIndex, $itemType);
     }
 }
Esempio n. 24
0
 /**
  * Initializes the specified cell to its initial values.
  * This method overrides the parent implementation.
  * @param TTableCell the cell to be initialized.
  * @param integer the index to the Columns property that the cell resides in.
  * @param string the type of cell (Header,Footer,Item,AlternatingItem,EditItem,SelectedItem)
  */
 public function initializeCell($cell, $columnIndex, $itemType)
 {
     if ($itemType === TListItemType::Item || $itemType === TListItemType::AlternatingItem || $itemType === TListItemType::EditItem || $itemType === TListItemType::SelectedItem) {
         if ($this->getDataField() !== '') {
             $cell->attachEventHandler('OnDataBinding', array($this, 'dataBindColumn'));
         } else {
             $text = $this->getText();
             if ($this->getEncode()) {
                 $text = THttpUtility::htmlEncode($text);
             }
             $cell->setText($text);
         }
     } else {
         parent::initializeCell($cell, $columnIndex, $itemType);
     }
 }
Esempio n. 25
0
 /**
  * Initializes the specified cell to its initial values.
  * This method overrides the parent implementation.
  * It creates a textbox for item in edit mode and the column is not read-only.
  * Otherwise it displays a static text.
  * The caption of the button and the static text are retrieved
  * from the datasource.
  * @param TTableCell the cell to be initialized.
  * @param integer the index to the Columns property that the cell resides in.
  * @param string the type of cell (Header,Footer,Item,AlternatingItem,EditItem,SelectedItem)
  */
 public function initializeCell($cell, $columnIndex, $itemType)
 {
     $item = $cell->getParent();
     switch ($itemType) {
         case TListItemType::Item:
         case TListItemType::AlternatingItem:
         case TListItemType::SelectedItem:
             if (($classPath = $this->getItemRenderer()) !== '') {
                 $control = Prado::createComponent($classPath);
                 if ($control instanceof IItemDataRenderer) {
                     $control->setItemIndex($item->getItemIndex());
                     $control->setItemType($item->getItemType());
                 }
                 $cell->getControls()->add($control);
             } else {
                 $control = $cell;
             }
             $control->attachEventHandler('OnDataBinding', array($this, 'dataBindColumn'));
             break;
         case TListItemType::EditItem:
             if (!$this->getReadOnly()) {
                 if (($classPath = $this->getEditItemRenderer()) !== '') {
                     $control = Prado::createComponent($classPath);
                     if ($control instanceof IItemDataRenderer) {
                         $control->setItemIndex($item->getItemIndex());
                         $control->setItemType($item->getItemType());
                     }
                     $cell->getControls()->add($control);
                     $cell->registerObject('EditControl', $control);
                 } else {
                     $control = Prado::createComponent('System.Web.UI.WebControls.TTextBox');
                     $cell->getControls()->add($control);
                     $cell->registerObject('TextBox', $control);
                 }
             } else {
                 if (($classPath = $this->getItemRenderer()) !== '') {
                     $control = Prado::createComponent($classPath);
                     if ($control instanceof IItemDataRenderer) {
                         $control->setItemIndex($item->getItemIndex());
                         $control->setItemType($item->getItemType());
                     }
                     $cell->getControls()->add($control);
                 } else {
                     $control = $cell;
                 }
             }
             $control->attachEventHandler('OnDataBinding', array($this, 'dataBindColumn'));
             break;
         default:
             parent::initializeCell($cell, $columnIndex, $itemType);
             break;
     }
 }
Esempio n. 26
0
 /**
  * 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);
 }
Esempio n. 27
0
 /**
  * Initializes the specified cell to its initial values.
  * This method overrides the parent implementation.
  * It creates an update and a cancel button for cell in edit mode.
  * Otherwise it creates an edit button.
  * @param TTableCell the cell to be initialized.
  * @param integer the index to the Columns property that the cell resides in.
  * @param string the type of cell (Header,Footer,Item,AlternatingItem,EditItem,SelectedItem)
  */
 public function initializeCell($cell, $columnIndex, $itemType)
 {
     if ($itemType === TListItemType::Item || $itemType === TListItemType::AlternatingItem || $itemType === TListItemType::SelectedItem) {
         $button = $this->createButton('Edit', $this->getEditText(), false, '');
         $cell->getControls()->add($button);
         $cell->registerObject('EditButton', $button);
     } else {
         if ($itemType === TListItemType::EditItem) {
             $controls = $cell->getControls();
             $button = $this->createButton('Update', $this->getUpdateText(), $this->getCausesValidation(), $this->getValidationGroup());
             $controls->add($button);
             $cell->registerObject('UpdateButton', $button);
             $controls->add('&nbsp;');
             $button = $this->createButton('Cancel', $this->getCancelText(), false, '');
             $controls->add($button);
             $cell->registerObject('CancelButton', $button);
         } else {
             parent::initializeCell($cell, $columnIndex, $itemType);
         }
     }
 }
 /**
  * Class constructor
  * Creates the page, the form and the listing
  */
 public function __construct()
 {
     parent::__construct();
     $this->string = new StringsUtil();
     // creates the form
     $this->form = new TForm('form_search_Atividade');
     $this->form->class = 'tform';
     // CSS class
     // creates a table
     $table = new TTable();
     $table->width = '100%';
     $this->form->add($table);
     // add a row for the form title
     $row = $table->addRow();
     $row->class = 'tformtitle';
     // CSS class
     $row->addCell(new TLabel('Atividade'))->colspan = 2;
     // create the form fields
     $id = new THidden('id');
     $data_atividade_inicial = new TDate('data_atividade_inicial');
     $data_atividade_inicial->setMask('dd/mm/yyyy');
     $data_atividade_final = new TDate('data_atividade_final');
     $data_atividade_final->setMask('dd/mm/yyyy');
     $criteria = new TCriteria();
     $criteria->add(new TFilter("origem", "=", 1));
     $criteria->add(new TFilter("codigo_cadastro_origem", "=", 100));
     $criteria->add(new TFilter("ativo", "=", 1));
     $criteria->add(new TFilter("usuario", "is not "));
     $colaborador_id = new TDBCombo('colaborador_id', 'atividade', 'Pessoa', 'pessoa_codigo', 'pessoa_nome', 'pessoa_nome', $criteria);
     $tipo_atividade_id = new TDBCombo('tipo_atividade_id', 'atividade', 'TipoAtividade', 'id', 'nome', 'nome');
     $ticket_id = new TDBMultiSearch('ticket_id', 'atividade', 'Ticket', 'id', 'titulo', 'titulo');
     $pesquisa_master = new TEntry('pesquisa_master');
     $criteria = new TCriteria();
     $criteria->add(new TFilter("ativo", "=", 1));
     $newparam['order'] = 'pessoa_nome';
     $newparam['direction'] = 'asc';
     $criteria->setProperties($newparam);
     // order, offset
     $solicitante_id = new TDBSeekButton('solicitante_id', 'atividade', 'form_search_Ticket', 'Pessoa', 'pessoa_nome', 'solicitante_id', 'solicitante_nome', $criteria);
     $solicitante_nome = new TEntry('solicitante_nome');
     $solicitante_nome->setEditable(FALSE);
     $total_atividades = new TEntry('total_atividades');
     $total_atividades->setEditable(FALSE);
     // define the sizes
     $id->setSize(50);
     $data_atividade_inicial->setSize(100);
     $data_atividade_final->setSize(100);
     $colaborador_id->setSize(300);
     $tipo_atividade_id->setSize(300);
     $ticket_id->setMinLength(0);
     $ticket_id->setMaxSize(1);
     $ticket_id->setSize(300);
     $ticket_id->setOperator('ilike');
     $solicitante_id->setSize(40);
     $solicitante_nome->setSize(235);
     $total_atividades->setSize(100);
     $pesquisa_master->setSize(300);
     // add one row for each form field
     $table->addRowSet(new TLabel('Solicitante:'), array($solicitante_id, $solicitante_nome));
     $table->addRowSet(new TLabel('Colaborador:'), $colaborador_id);
     $table->addRowSet(new TLabel('Dt. Atividades inicio:'), array($data_atividade_inicial, $label_data_fim = new TLabel('Fim:'), $data_atividade_final));
     $label_data_fim->setSize(48);
     $table->addRowSet(new TLabel('Atividade:'), $tipo_atividade_id);
     $table->addRowSet(new TLabel('Ticket:'), $ticket_id);
     $table->addRowSet(new TLabel('Pesquisa por palavra:'), $pesquisa_master);
     $table->addRowSet(new TLabel('Total horas atividades:'), $total_atividades);
     $table->addRowSet(new TLabel(''), $id);
     $this->form->setFields(array($id, $data_atividade_inicial, $data_atividade_final, $colaborador_id, $tipo_atividade_id, $ticket_id, $solicitante_id, $solicitante_nome, $pesquisa_master, $total_atividades));
     $change_data = new TAction(array($this, 'onChangeData'));
     $data_atividade_inicial->setExitAction($change_data);
     $data_atividade_final->setExitAction($change_data);
     // keep the form filled during navigation with session data
     $this->form->setData(TSession::getValue('Atividade_filter_data'));
     // create two action buttons to the form
     $find_button = TButton::create('find', array($this, 'onSearch'), _t('Find'), 'ico_find.png');
     $new_button = TButton::create('new', array('AtividadeForm', 'onEdit'), _t('New'), 'fa:plus-square green');
     $clean_button = TButton::create('clean', array($this, 'onClean'), 'Limpar', 'ico_close.png');
     $this->form->addField($find_button);
     $this->form->addField($new_button);
     $this->form->addField($clean_button);
     $buttons_box = new THBox();
     $buttons_box->add($find_button);
     $buttons_box->add($new_button);
     $buttons_box->add($clean_button);
     // add a row for the form action
     $row = $table->addRow();
     $row->class = 'tformaction';
     // CSS class
     $row->addCell($buttons_box)->colspan = 2;
     // creates a Datagrid
     $this->datagrid = new TDataGrid();
     $this->datagrid->setHeight(320);
     // creates the datagrid columns
     $data_atividade = new TDataGridColumn('data_atividade', 'Data', 'right', 40);
     $hora_inicio = new TDataGridColumn('hora_inicio', 'Inicio', 'right', 20);
     $hora_fim = new TDataGridColumn('hora_fim', 'Fim', 'right', 20);
     $hora_qte = new TDataGridColumn('hora_qte', 'Qtde', 'right', 20);
     $colaborador_id = new TDataGridColumn('pessoa->pessoa_nome', 'Colaborador', 'left', 50);
     $tipo_atividade_id = new TDataGridColumn('tipo_atividade->nome', 'Atividade', 'left', 100);
     //get_tipo_atividade()->nome
     $sistema_id = new TDataGridColumn('sistema->nome', 'Sistema', 'left', 100);
     $ticket_id = new TDataGridColumn('ticket->titulo', 'Ticket', 'left', 200);
     // get_ticket()->titulo
     // transformers
     $colaborador_id->setTransformer(array($this, 'retornaPessoa'));
     $hora_qte->setTransformer(array($this, 'calculaDiferenca'));
     $data_atividade->setTransformer(array('StringsUtil', 'formatDateBR'));
     $hora_inicio->setTransformer(array('StringsUtil', 'retira_segundos'));
     $hora_fim->setTransformer(array('StringsUtil', 'retira_segundos'));
     // add the columns to the DataGrid
     $this->datagrid->addColumn($data_atividade);
     $this->datagrid->addColumn($hora_inicio);
     $this->datagrid->addColumn($hora_fim);
     $this->datagrid->addColumn($hora_qte);
     $this->datagrid->addColumn($colaborador_id);
     $this->datagrid->addColumn($tipo_atividade_id);
     $this->datagrid->addColumn($sistema_id);
     $this->datagrid->addColumn($ticket_id);
     // creates the datagrid column actions
     $order_data_atividade = new TAction(array($this, 'onReload'));
     $order_data_atividade->setParameter('order', 'data_atividade');
     $data_atividade->setAction($order_data_atividade);
     $order_colaborador_id = new TAction(array($this, 'onReload'));
     $order_colaborador_id->setParameter('order', 'pessoa->pessoa_nome');
     $colaborador_id->setAction($order_colaborador_id);
     $order_tipo_atividade_id = new TAction(array($this, 'onReload'));
     $order_tipo_atividade_id->setParameter('order', 'tipo_atividade->nome');
     $tipo_atividade_id->setAction($order_tipo_atividade_id);
     $order_sistema_id = new TAction(array($this, 'onReload'));
     $order_sistema_id->setParameter('order', 'sistema->nome');
     $sistema_id->setAction($order_sistema_id);
     $order_ticket_id = new TAction(array($this, 'onReload'));
     $order_ticket_id->setParameter('order', 'ticket->titulo');
     $ticket_id->setAction($order_ticket_id);
     // creates two datagrid actions
     $action1 = new TDataGridAction(array('AtividadeForm', 'onEdit'));
     $action1->setLabel(_t('Edit'));
     $action1->setImage('fa:pencil-square-o blue fa-lg');
     $action1->setField('id');
     // add the actions to the datagrid
     $this->datagrid->addAction($action1);
     // 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);
     $container->style = 'width: 100%;max-width: 1200px;';
     $this->datagrid->style = '  width: 100%;  max-width: 1200px;';
     parent::add($container);
 }
Esempio n. 29
0
 /**
  * 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);
 }
 /**
  * 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);
 }