/** * Class constructor * Creates the page, the form and the listing */ public function __construct() { parent::__construct(); // creates the form $this->form = new TForm('form_search_Requisicao'); $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('Consulta Requisicao'))->colspan = 2; // create the form fields $numeroProcesso = new TEntry('numeroProcesso'); // define the sizes $numeroProcesso->setSize(200); $numeroProcesso->setMaxLength(30); $numeroProcesso->setTip('Número do processo gerado no SIGA'); // add one row for each form field $table->addRowSet(new TLabel('Nº do Processo:'), $numeroProcesso); $this->form->setFields(array($numeroProcesso)); // keep the form filled during navigation with session data $this->form->setData(TSession::getValue('Requisicao_filter_data')); // create two action buttons to the form $find_button = TButton::create('find', array($this, 'onSearch'), 'Buscar', 'ico_find.png'); $new_button = TButton::create('new', array('RequisicaoForm', 'onEdit'), 'Novo', 'ico_new.png'); $this->form->addField($find_button); $this->form->addField($new_button); $buttons_box = new THBox(); $buttons_box->add($find_button); $buttons_box->add($new_button); // add a row for the form action $row = $table->addRow(); $row->class = 'tformaction'; // CSS class $row->addCell($buttons_box)->colspan = 2; // creates a Datagrid parent::include_css('app/resources/custom-table.css'); $this->datagrid = new TDataGrid(); $this->datagrid->class = 'tdatagrid_table customized-table'; $this->datagrid->setHeight(320); // creates the datagrid columns $id = new TDataGridColumn('id', 'ID', 'right', 80); $srp = new TDataGridColumn('numeroSRP', 'Nº SRP', 'left', 100); $numeroProcesso = new TDataGridColumn('numeroProcesso', 'Nº do processo', 'left', 250); $data = new TDataGridColumn('emissao', 'Data', 'left', 100); $id->setTransformer(array($this, 'rowFormat')); // add the columns to the DataGrid $this->datagrid->addColumn($id); $this->datagrid->addColumn($srp); $this->datagrid->addColumn($numeroProcesso); $this->datagrid->addColumn($data); // creates two datagrid actions $action1 = new TDataGridAction(array('RequisicaoForm', 'onEdit')); //$action1 = new TDataGridAction(array($this, 'onCheckValidadeSRP')); $action1->setLabel('Editar'); $action1->setImage('ico_edit.png'); $action1->setField('id'); $action1->setDisplayCondition(array($this, 'onDisplayConditionEdit')); $action2 = new TDataGridAction(array($this, 'onDelete')); $action2->setLabel('Excluir'); $action2->setImage('ico_delete.png'); $action2->setField('id'); $actAprovar = new TDataGridAction(array($this, 'onQuestionAprovarRequisicao')); $actAprovar->setLabel('Aprovar Requisição'); $actAprovar->setImage('fa:check fa-fw'); $actAprovar->setField('id'); $actAprovar->setDisplayCondition(array($this, 'onDisplayConditionEdit')); // add the actions to the datagrid $this->datagrid->addAction($action1); $this->datagrid->addAction($action2); $this->datagrid->addAction($actAprovar); // 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()); //limpar a sessao com detalhes de itens e requisicao TSession::delValue('requisicao_itens'); TSession::delValue('SRP_id'); TSession::delValue('form_requisicao'); // create the page container //$container = TVBox::pack($this->form, $this->datagrid, $this->pageNavigation); $container = new TTable(); $container->addRow()->addCell(new TXMLBreadCrumb('menu.xml', __CLASS__)); $container->addRow()->addCell($this->form); $container->addRow()->addCell($this->datagrid); $container->addRow()->addCell($this->pageNavigation); parent::add($container); }