Exemplo n.º 1
0
 /**
  * Class constructor
  * Creates the page, the search form and the listing
  */
 public function __construct()
 {
     parent::__construct();
     new TSession();
     // creates the form
     $this->form = new TForm('form_listar_crm_clientes');
     $key = $_GET['key'];
     // create the form fields
     $name = new TEntry('nome');
     $name->setSize(170);
     $table = new TTable();
     $row = $table->addRow();
     $cell = $row->addCell('');
     $cell->width = PHP_SAPI == 'cli' ? 40 : 80;
     $row->addCell($name);
     $this->form->add($table);
     // creates the action button
     $button1 = new TButton('find');
     $button1->setAction(new TAction(array($this, 'onSearch')), 'Buscar');
     $button1->setImage('ico_find.png');
     // create an action button
     $button2 = new TButton('novo');
     $action2 = new TAction(array('CRMForm', 'onEdit'));
     $action2->setParameter('key', $key);
     $button2->setImage('ico_new.png');
     $button2->setAction($action2, 'Novo');
     $button3 = new TButton('csv');
     $button3->setAction(new TAction(array($this, 'onExportCSV')), 'CSV');
     $button3->setImage('ico_print.png');
     // create an action button
     $button4 = new TButton('action3');
     $action4 = new TAction(array('ClienteList', 'onReload'));
     //        $action3->setParameter('key', $_GET['key']);
     $action4->setParameter('key', $key);
     $button4->setImage('ico_previous.png');
     $button4->setAction($action4, 'Voltar');
     $row->addCell($button1);
     $row->addCell($button2);
     $row->addCell($button3);
     $row->addCell($button4);
     $this->form->setFields(array($name, $button1, $button2, $button3, $button4));
     // creates a DataGrid
     $this->datagrid = new TDataGrid();
     //        $this->datagrid->setHeight(200);
     // create the datagrid columns
     $dgid = new TDataGridColumn('id', 'Id', 'right', 70);
     $dgtitulo = new TDataGridColumn('titulo', 'Titulo', 'left', 180);
     $dgprojeto = new TDataGridColumn('projeto_nome', 'Projeto', 'left', 180);
     $dgdata = new TDataGridColumn('data_crm', 'Data', 'left', 160);
     $dgtempo = new TDataGridColumn('tempo', 'Tempo', 'left', 160);
     $dgdescricao = new TDataGridColumn('descricao', 'Descrição', 'left', 160);
     $dgsolicitante = new TDataGridColumn('solicitante', 'Solicitante', 'left', 160);
     $dgresponsavel = new TDataGridColumn('tipo_nome', 'Tipo', 'left', 160);
     $dgcliente = new TDataGridColumn('cliente_nome', 'Cliente', 'left', 160);
     $dgnome = new TDataGridColumn('prioridade_nome', 'Prioridade', 'left', 160);
     $dgstatus = new TDataGridColumn('status_nome', 'Status', 'left', 160);
     // add the columns to the datagrid
     $this->datagrid->addColumn($dgid);
     $this->datagrid->addColumn($dgtitulo);
     $this->datagrid->addColumn($dgprojeto);
     $this->datagrid->addColumn($dgdata);
     $this->datagrid->addColumn($dgtempo);
     $this->datagrid->addColumn($dgdescricao);
     $this->datagrid->addColumn($dgsolicitante);
     $this->datagrid->addColumn($dgresponsavel);
     $this->datagrid->addColumn($dgcliente);
     $this->datagrid->addColumn($dgnome);
     $this->datagrid->addColumn($dgstatus);
     // creates two datagrid actions
     $action1 = new TDataGridAction(array('CRMForm', 'onEdit'));
     $action1->setLabel('Editar');
     $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');
     //        $obj = ClienteRegistroDetalhe();
     $action3 = new TDataGridAction(array('ClienteRegistroDetalhe', 'onEdit'));
     $action3->setLabel('Registros');
     $action3->setImage('ico_custom_form.png');
     $action3->setField('id');
     $action3->setParameter('fk', $_GET['key']);
     // add the actions to the datagrid
     $this->datagrid->addAction($action1);
     $this->datagrid->addAction($action2);
     $this->datagrid->addAction($action3);
     // 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($this->form);
     $table->addRow()->addCell($this->datagrid);
     $table->addRow()->addCell($this->pageNavigation);
     // add the table inside the page
     parent::add($table);
 }