public function onSave()
 {
     try {
         // open a transaction with database
         TTransaction::open($this->database);
         // get the form data
         $object = $this->form->getData($this->activeRecord);
         // validate data
         $this->form->validate();
         // stores the object
         $object->store();
         // fill the form with the active record data
         $this->form->setData($object);
         // close the transaction
         TTransaction::close();
         // shows the success message
         //new TMessage('info', AdiantiCoreTranslator::translate('Record saved'));
         parent::add(new TAlert('info', AdiantiCoreTranslator::translate('Record saved')));
         // reload the listing
         $this->onReload();
         return $object;
     } catch (Exception $e) {
         // get the form data
         $object = $this->form->getData($this->activeRecord);
         // fill the form with the active record data
         $this->form->setData($object);
         // shows the exception error message
         new TMessage('error', $e->getMessage());
         // undo all pending operations
         TTransaction::rollback();
     }
 }
 /**
  * Class constructor
  * Creates the page and the registration form
  */
 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();
     // defines the database
     parent::setDatabase('library');
     // defines the active record
     parent::setActiveRecord('Classification');
     // creates the form
     $this->form = new TQuickForm('form_Classification');
     // create the form fields
     $id = new TEntry('id');
     $description = new TEntry('description');
     $id->setEditable(FALSE);
     // define the sizes
     $this->form->addQuickField(_t('Code'), $id, 100);
     $this->form->addQuickField(_t('Description'), $description, 200);
     // define the form action
     $this->form->addQuickAction(_t('Save'), new TAction(array($this, 'onSave')), 'ico_save.png');
     $this->form->addQuickAction(_t('New'), new TAction(array($this, 'onEdit')), 'ico_new.png');
     // creates a DataGrid
     $this->datagrid = new TQuickGrid();
     $this->datagrid->setHeight(320);
     // creates the datagrid columns
     $this->datagrid->addQuickColumn(_t('Code'), 'id', 'left', 100, new TAction(array($this, 'onReload')), array('order', 'id'));
     $this->datagrid->addQuickColumn(_t('Description'), 'description', 'left', 200, new TAction(array($this, 'onReload')), array('order', 'description'));
     // add the actions to the datagrid
     $this->datagrid->addQuickAction(_t('Edit'), new TDataGridAction(array($this, 'onEdit')), 'id', 'ico_edit.png');
     $this->datagrid->addQuickAction(_t('Delete'), new TDataGridAction(array($this, 'onDelete')), 'id', 'ico_delete.png');
     // 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();
     // add a row to the form
     $row = $table->addRow();
     $row->addCell($this->form);
     // add a row to the datagrid
     $row = $table->addRow();
     $row->addCell($this->datagrid);
     // add a row for page navigation
     $row = $table->addRow();
     $row->addCell($this->pageNavigation);
     // add the table inside the page
     parent::add($table);
 }
 /**
  * Class constructor
  * Creates the page and the registration form
  */
 function __construct()
 {
     parent::__construct();
     // security check
     if (TSession::getValue('logged') !== TRUE) {
         throw new Exception(_t('Not logged'));
     }
     // security check
     TTransaction::open('changeman');
     if (Member::newFromLogin(TSession::getValue('login'))->role_mnemonic !== 'ADMINISTRATOR') {
         throw new Exception(_t('Permission denied'));
     }
     TTransaction::close();
     // defines the database
     parent::setDatabase('changeman');
     // defines the active record
     parent::setActiveRecord('Category');
     // creates the form
     $this->form = new TQuickForm('form_Category');
     $this->form->setFormTitle(_t('Category'));
     $this->form->class = 'tform';
     $this->form->style = 'width: 640px';
     // create the form fields
     $id = new TEntry('id');
     $description = new TEntry('description');
     // define the sizes
     $this->form->addQuickField('ID', $id, 100);
     $this->form->addQuickField(_t('Description') . ': ', $description, 200);
     $id->setEditable(FALSE);
     // define the form action
     $this->form->addQuickAction(_t('Save'), new TAction(array($this, 'onSave')), 'ico_save.png');
     $this->form->addQuickAction(_t('New'), new TAction(array($this, 'onEdit')), 'ico_new.png');
     // creates a DataGrid
     $this->datagrid = new TQuickGrid();
     $this->datagrid->setHeight(320);
     // creates the datagrid columns
     $this->datagrid->addQuickColumn('ID', 'id', 'left', 100, new TAction(array($this, 'onReload')), array('order', 'id'));
     $this->datagrid->addQuickColumn(_t('Description'), 'description', 'left', 480, new TAction(array($this, 'onReload')), array('order', 'description'));
     // add the actions to the datagrid
     $this->datagrid->addQuickAction(_t('Edit'), new TDataGridAction(array($this, 'onEdit')), 'id', 'ico_edit.png');
     $this->datagrid->addQuickAction(_t('Delete'), new TDataGridAction(array($this, 'onDelete')), 'id', 'ico_delete.png');
     // 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 container inside the page
     parent::add($container);
 }
 /**
  * Class constructor
  * Creates the page and the registration form
  */
 function __construct()
 {
     parent::__construct();
     parent::setDatabase('app');
     // defines the database
     parent::setActiveRecord('Ajuda');
     // defines the active record
     parent::setDefaultOrder('id', 'asc');
     // defines the default order
     // creates the form
     $this->form = new TQuickForm('form_Ajuda');
     $this->form->class = 'tform';
     // CSS class
     $this->form->setFormTitle('Ajuda');
     // define the form title
     // create the form fields
     $id = new TEntry('id');
     $id->setEditable(false);
     $titulo = new TEntry('titulo');
     $texto = new THtmlEditor('texto');
     // add the fields
     $this->form->addQuickField('id', $id, 100);
     $this->form->addQuickField('titulo', $titulo, 700);
     $this->form->addQuickField('texto', $texto, 700);
     $texto->setSize(700, 300);
     // create the form actions
     $this->form->addQuickAction(_t('Save'), new TAction(array($this, 'onSave')), 'ico_save.png');
     $this->form->addQuickAction(_t('New'), new TAction(array($this, 'onEdit')), 'ico_new.png');
     // creates a DataGrid
     $this->datagrid = new TQuickGrid();
     $this->datagrid->setHeight(320);
     // creates the datagrid columns
     $id = $this->datagrid->addQuickColumn('#', 'id', 'left', 100);
     $texto = $this->datagrid->addQuickColumn('Ajuda', 'titulo', 'left', 640);
     // create the datagrid actions
     $edit_action = new TDataGridAction(array($this, 'onEdit'));
     $delete_action = new TDataGridAction(array($this, 'onDelete'));
     // add the actions to the datagrid
     $this->datagrid->addQuickAction(_t('Edit'), $edit_action, 'id', 'ico_edit.png');
     $this->datagrid->addQuickAction(_t('Delete'), $delete_action, 'id', 'ico_delete.png');
     // 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->datagrid, $this->pageNavigation, $this->form);
     parent::add($container);
 }
 /**
  * Class constructor
  * Creates the page, the form and the listing
  */
 public function __construct()
 {
     parent::__construct();
     // define the database
     parent::setDatabase('samples');
     // define the Active Record
     parent::setActiveRecord('Category');
     // define the default order
     parent::setDefaultOrder('id', 'asc');
     // turn off limit for datagrid
     $this->setLimit(-1);
     // create the form
     $this->form = new TQuickForm('form_categories');
     $this->form->class = 'tform';
     // CSS class
     $this->form->style = 'width: 500px';
     $this->form->setFormTitle('Form/Datagrid');
     // create the form fields
     $id = new TEntry('id');
     $name = new TEntry('name');
     $name->addValidation(_t('Name'), new TRequiredValidator());
     // add the form fields
     $this->form->addQuickField('ID', $id, 40);
     $this->form->addQuickField('Name', $name, 200);
     // define the form actions
     $this->form->addQuickAction(_t('Save'), new TAction(array($this, 'onSave')), 'ico_save.png');
     $this->form->addQuickAction(_t('New'), new TAction(array($this, 'onEdit')), 'ico_new.png');
     // make id not editable
     $id->setEditable(FALSE);
     // create the datagrid
     $this->datagrid = new TQuickGrid();
     $this->datagrid->setHeight(320);
     // add the columns
     $this->datagrid->addQuickColumn('ID', 'id', 'center', 50, new TAction(array($this, 'onReload')), array('order', 'id'));
     $this->datagrid->addQuickColumn('Name', 'name', 'left', 390, new TAction(array($this, 'onReload')), array('order', 'name'));
     // add the actions
     $this->datagrid->addQuickAction('Editar', new TDataGridAction(array($this, 'onEdit')), 'id', 'ico_edit.png');
     $this->datagrid->addQuickAction('Deletar', new TDataGridAction(array($this, 'onDelete')), 'id', 'ico_delete.png');
     // create the datagrid model
     $this->datagrid->createModel();
     // wrap objects inside a table
     $table = new TTable();
     $table->addRow()->addCell(new TXMLBreadCrumb('menu.xml', __CLASS__));
     $table->addRow()->addCell($this->form);
     $table->addRow()->addCell($this->datagrid);
     // pack the table inside the page
     parent::add($table);
 }
 /**
  * Class constructor
  * Creates the page and the registration form
  */
 function __construct()
 {
     parent::__construct();
     // defines the database
     parent::setDatabase('blog');
     // defines the active record
     parent::setActiveRecord('Category');
     // creates the form
     $this->form = new TQuickForm('form_Category');
     $this->form->setFormTitle(_t('Categories'));
     $this->form->class = 'tform';
     $this->form->style = 'width: 600px';
     // create the form fields
     $id = new TEntry('id');
     $name = new TEntry('name');
     // add the fields
     $this->form->addQuickField('ID', $id, 100);
     $this->form->addQuickField(_t('Name'), $name, 200);
     $id->setEditable(FALSE);
     // define the form action
     $this->form->addQuickAction(_t('Save'), new TAction(array($this, 'onSave')), 'ico_save.png');
     $this->form->addQuickAction(_t('New'), new TAction(array($this, 'onEdit')), 'ico_new.png');
     // creates a DataGrid
     $this->datagrid = new TQuickGrid();
     $this->datagrid->setHeight(320);
     // creates the datagrid columns
     $id = $this->datagrid->addQuickColumn('ID', 'id', 'left', 100);
     $name = $this->datagrid->addQuickColumn(_t('Name'), 'name', 'left', 440);
     // add the actions to the datagrid
     $this->datagrid->addQuickAction(_t('Edit'), new TDataGridAction(array($this, 'onEdit')), 'id', 'ico_edit.png');
     $this->datagrid->addQuickAction(_t('Delete'), new TDataGridAction(array($this, 'onDelete')), 'id', 'ico_delete.png');
     // 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);
 }
 /**
  * Class constructor
  * Creates the page and the registration form
  */
 function __construct()
 {
     parent::__construct();
     parent::setDatabase('samples');
     parent::setActiveRecord('Backlog');
     $this->form = new TQuickForm('form_Backlog');
     // create the form fields
     $id = new TEntry('id');
     $this->project = new TEntry('project');
     $description = new TEntry('description');
     $estimate = new TSlider('estimate');
     $priority = new TCombo('priority');
     $status = new TCombo('status');
     // add the fields
     $this->form->addQuickField('Project', $this->project, 100);
     $this->form->addQuickField('Item Id', $id, 100);
     $this->form->addQuickField('Description', $description, 200);
     $this->form->addQuickField('Estimate', $estimate, 200);
     $this->form->addQuickField('Priority', $priority, 200);
     $this->form->addQuickField('Status', $status, 200);
     $this->project->setEditable(FALSE);
     $this->project->setSize(400);
     $this->project->setValue(TSession::getValue('project_name'));
     $this->project->style = 'font-weight: bold; color: darkblue';
     $description->style = 'color: red';
     $id->setEditable(FALSE);
     $estimate->setRange(1, 100, 1);
     $priority->addItems(array('L' => 'Low', 'M' => 'Medium', 'H' => 'Hight'));
     $status->addItems(array('R' => 'Requested', 'A' => 'Aproved', 'I' => 'Implemented'));
     // define the form action
     $this->form->addQuickAction(_t('Save'), new TAction(array($this, 'onSave')), 'ico_save.png');
     $this->form->addQuickAction(_t('New'), new TAction(array($this, 'onEdit')), 'ico_new.png');
     $this->form->addQuickAction(_t('Back'), new TAction(array('ProjectListView', 'onReload')), 'ico_back.png');
     // creates a DataGrid
     $this->datagrid = new TQuickGrid();
     $this->datagrid->setHeight(120);
     $this->datagrid->makeScrollable();
     // creates the datagrid columns
     $id = $this->datagrid->addQuickColumn('id', 'id', 'left', 80);
     $description = $this->datagrid->addQuickColumn('description', 'description', 'left', 200);
     $estimate = $this->datagrid->addQuickColumn('estimate', 'estimate', 'left', 100);
     $status = $this->datagrid->addQuickColumn('status', 'status', 'left', 100);
     // add the actions to the datagrid
     $this->datagrid->addQuickAction(_t('Edit'), new TDataGridAction(array($this, 'onEdit')), 'id', 'ico_edit.png');
     $this->datagrid->addQuickAction(_t('Delete'), new TDataGridAction(array($this, 'onDelete')), 'id', 'ico_delete.png');
     // 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);
     // creates the notebook
     $this->notebook = new TNotebook();
     $this->notebook->setSize(600, 430);
     $this->notebook->appendPage('Project Backlog', $table);
     // wrap the page content using vertical box
     $vbox = new TVBox();
     $vbox->add(new TXMLBreadCrumb('menu.xml', 'ProjectListView'));
     $vbox->add($this->notebook);
     parent::add($vbox);
 }
 /**
  * Class constructor
  * Creates the page and the registration form
  */
 function __construct()
 {
     parent::__construct();
     // security check
     if (TSession::getValue('logged') !== TRUE) {
         throw new Exception(_t('Not logged'));
     }
     // security check
     TTransaction::open('db_crmbf');
     if (User::newFromLogin(TSession::getValue('login'))->role->mnemonic !== 'ADMINISTRATOR') {
         throw new Exception(_t('Permission denied'));
     }
     TTransaction::close();
     // defines the database
     parent::setDatabase('db_crmbf');
     // defines the active record
     parent::setActiveRecord('RegistroTipo');
     // creates the form
     $this->form = new TQuickForm('form_Registro');
     $titulo = new TLabel('Cadastrar Tipo Registro');
     $titulo->setFontColor('red');
     $titulo->setFontSize(16);
     // create the form fields
     $id = new TEntry('id');
     $nome = new TEntry('nome');
     $id->setEditable(FALSE);
     // define the sizes
     $this->form->addQuickField('', $titulo, 100);
     $this->form->addQuickField('Code', $id, 100);
     $this->form->addQuickField('Nome', $nome, 200);
     // define the form action
     $this->form->addQuickAction('Salvar', new TAction(array($this, 'onSave')), 'ico_save.png');
     $this->form->addQuickAction('Novo', new TAction(array($this, 'onEdit')), 'ico_new.png');
     // creates a DataGrid
     $this->datagrid = new TQuickGrid();
     $this->datagrid->setHeight(320);
     // creates the datagrid columns
     $this->datagrid->addQuickColumn('ID', 'id', 'left', 100, new TAction(array($this, 'onReload')), array('order', 'id'));
     $this->datagrid->addQuickColumn('Nome', 'nome', 'left', 200, new TAction(array($this, 'onReload')), array('order', 'nome'));
     // add the actions to the datagrid
     $this->datagrid->addQuickAction('Edit', new TDataGridAction(array($this, 'onEdit')), 'id', 'ico_edit.png');
     $this->datagrid->addQuickAction('Delete', new TDataGridAction(array($this, 'onDelete')), 'id', 'ico_delete.png');
     // 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();
     // add a row to the form
     $row = $table->addRow();
     $row->addCell($this->form);
     // add a row to the datagrid
     $row = $table->addRow();
     $row->addCell($this->datagrid);
     // add a row for page navigation
     $row = $table->addRow();
     $row->addCell($this->pageNavigation);
     // add the table inside the page
     parent::add($table);
 }
 public function onReport($param)
 {
     $r = new Report();
     $fonteCabecalho = $r->createFont("Arial", 8, "000000", "FFFFFF");
     $fonteCabecalho->setBold();
     $fonte = $r->createFont("Arial", 8, "000000", "FFFFFF");
     $r->setFont($fonteCabecalho);
     $r->write('Tribunal Regional Eleitoral do Rio Grande do Norte');
     $r->write('Secretaria de Administração e Orçamento');
     $r->write('Planejamento e Gestão Orçamentária do TRE/RN');
     $r->write(' ');
     $r->centerText();
     $r->write("Solicitações de materiais permanentes por unidade");
     TTransaction::open('app');
     $conexao = TTransaction::get();
     $sql = "SELECT\n  system_user.name unidade,\n  tipo_material_permanente.nome tipo_material_permanente_nome,\n  material_permanente.descricao,\n  material_permanente.justificativa,\n  material_permanente.quantidade,\n  material_permanente.custo\nFROM \n  material_permanente, tipo_material_permanente, system_user\nWHERE\n  tipo_material_permanente_id= tipo_material_permanente.id AND\n  system_user_id = system_user.id\nORDER BY\n  system_user.name, tipo_material_permanente.nome";
     $solicitacoes = $conexao->query($sql);
     $ultima_unidade = "";
     foreach ($solicitacoes as $solicitacao) {
         if ($ultima_unidade != $solicitacao["unidade"]) {
             $ultima_unidade = $solicitacao["unidade"];
             $r->setFont($fonteCabecalho);
             $r->leftText();
             $r->write(' ');
             $r->write($ultima_unidade);
             $r->createTable(array(4, 4.8, 4.8, 1.7, 1.7));
             $r->addTableRow(array("Tipo do material", "Descrição", "Justificativa", "Quantidade", "Custo"), array("L", "L", "L", "R", "R"));
             $r->setFont($fonte);
         }
         $r->addTableRow(array($solicitacao["tipo_material_permanente_nome"], $solicitacao["descricao"], $solicitacao["justificativa"], $solicitacao["quantidade"], $solicitacao["custo"]), array("L", "L", "L", "R", "R"));
     }
     TTransaction::close();
     $md5_userid = md5(TSession::getValue("userid"));
     $r->save("./app/output/tipo_material_permanente_{$md5_userid}.rtf");
     parent::openFile("./app/output/tipo_material_permanente_{$md5_userid}.rtf");
 }