/** * method onEdit() * Executed whenever the user clicks at the edit button da datagrid */ function onView($param) { try { if (isset($param['key'])) { // get the parameter $key $key = $param['key']; // open a transaction with database 'changeman' TTransaction::open('changeman'); // instantiates object Document $object = new Document($key); $element = new TElement('div'); $element->add($object->content); parent::add($element); // close the transaction TTransaction::close(); } else { $this->form->clear(); } } catch (Exception $e) { // shows the exception error message new TMessage('error', '<b>Error</b> ' . $e->getMessage()); // undo all pending operations TTransaction::rollback(); } }
/** * Class constructor * Creates the page */ function __construct() { parent::__construct(); try { TTransaction::open("sample"); $evento = new Agenda(R); $evento->nome = "Curso Adianti framework"; $evento->lugar = "Progs Scholl alterado"; $evento->descricao = "Curso basico"; $evento->data_ev = date("Y-m-d"); $evento->hora_ev = date("h:m:"); $evento->store(); TTransaction::close(); } catch (Exception $e) { echo $e->getMessage(); } TPage::include_css('app/resources/styles.css'); $this->html = new THtmlRenderer('app/resources/wellcome.html'); // define replacements for the main section $replace = array(); // replace the main section variables $this->html->enableSection('main', $replace); // add the template to the page parent::add($this->html); }
/** * method onSave() * Executed whenever the user clicks at the save button */ 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(); // define the next action $nextAction = new TAction(array('BacklogFormView', 'onSetProject')); $nextAction->setParameter('key', $object->id); // shows the success message new TMessage('info', TAdiantiCoreTranslator::translate('Record saved'), $nextAction); 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', '<b>Error</b> ' . $e->getMessage()); // undo all pending operations TTransaction::rollback(); } }
function onReload($param = NULL) { $offset = $param['offset']; //$order = $param['order']; $limit = 10; // inicia transação com o banco 'pg_livro' TTransaction::open('pg_livro'); // instancia um repositório para Alunos $repository = new TRepository('Pessoa'); // retorna todos objetos que satisfazem o critério $criteria = new TCriteria(); $count = $repository->count($criteria); $criteria->setProperty('limit', $limit); $criteria->setProperty('offset', $offset); $pessoas = $repository->load($criteria); $this->navbar->setPageSize($limit); $this->navbar->setCurrentPage($param['page']); $this->navbar->setTotalRecords($count); $this->datagrid->clear(); if ($pessoas) { foreach ($pessoas as $pessoa) { // adiciona o objeto na DataGrid $this->datagrid->addItem($pessoa); } } // finaliza a transação TTransaction::close(); $this->loaded = true; }
/** * Class Constructor * @param $name widget's name * @param $database database name * @param $model model class name * @param $key table field to be used as key in the combo * @param $value table field to be listed in the combo * @param $ordercolumn column to order the fields (optional) * @param array $filter TFilter (optional) By Alexandre * @param array $expresione TExpression (opcional) by Alexandre */ public function __construct($name, $database, $model, $key, $value, $ordercolumn = NULL, $filter = NULL, $expression = NULL) { new TSession(); // executes the parent class constructor parent::__construct($name); // carrega objetos do banco de dados TTransaction::open($database); // instancia um repositório de Estado $repository = new TRepository($model); $criteria = new TCriteria(); $criteria->setProperty('order', isset($ordercolumn) ? $ordercolumn : $key); if ($filter) { foreach ($filter as $fil) { if ($expression) { foreach ($expression as $ex) { $criteria->add($fil, $ex); } } else { $criteria->add($fil); } } } // carrega todos objetos $collection = $repository->load($criteria); // adiciona objetos na combo if ($collection) { $items = array(); foreach ($collection as $object) { $items[$object->{$key}] = $object->{$value}; } parent::addItems($items); } TTransaction::close(); }
public function getCustomers() { TTransaction::open('samples'); $customers = Customer::getObjects(); var_dump($customers); TTransaction::close(); }
public function listar($param) { try { TTransaction::open('sample'); $criteria = new TCriteria(); $criteria->add(new TFilter('categoria_id', '=', $param['id'])); $produtos = Produtos::getObjects($criteria); TTransaction::close(); //cria um array vario $replace_detail = array(); if ($produtos) { // iterate products foreach ($produtos as $p) { // adicio os itens no array // a função toArray(), transforma o objeto em um array // passando assim para a $variavel $replace_detail[] = $p->toArray(); } } // ativa a sessão e substitui as variaveis //o parametro true quer dizer que é um loop $this->produtos->enableSection('produtos', $replace_detail, TRUE); } catch (Exception $e) { new Message('error', $e->getMessage()); } }
/** * Validate the login */ function onLogin() { try { TTransaction::open('changeman'); $data = $this->form->getData('StdClass'); // validate form data $this->form->validate(); $auth = Member::authenticate($data->user, md5($data->password)); if ($auth) { TSession::setValue('logged', TRUE); TSession::setValue('login', $data->user); TSession::setValue('language', $data->language); // reload page TApplication::gotoPage('NewIssueForm', 'nonono'); } TTransaction::close(); // finaliza a transação } catch (Exception $e) { TSession::setValue('logged', FALSE); // exibe a mensagem gerada pela exceção new TMessage('error', '<b>Erro</b> ' . $e->getMessage()); // desfaz todas alterações no banco de dados TTransaction::rollback(); } }
public function __construct() { parent::__construct(); try { TTransaction::open('samples'); // abre uma transação // cria novo objeto $giovani = new Customer(); $giovani->name = 'Giovanni Dall Oglio'; $giovani->address = 'Rua da Conceicao'; $giovani->phone = '(51) 8111-2222'; $giovani->birthdate = '2013-02-15'; $giovani->status = 'S'; $giovani->email = '*****@*****.**'; $giovani->gender = 'M'; $giovani->category_id = '1'; $giovani->city_id = '1'; $giovani->store(); // armazena o objeto new TMessage('info', 'Objeto armazenado com sucesso'); TTransaction::close(); // fecha a transação. } catch (Exception $e) { new TMessage('error', $e->getMessage()); } }
public function __construct() { parent::__construct(); try { TTransaction::open('samples'); // open transaction // create a new object $giovani = new Customer(); $giovani->name = 'Giovanni Dall Oglio'; $giovani->address = 'Rua da Conceicao'; $giovani->phone = '(51) 8111-2222'; $giovani->birthdate = '2013-02-15'; $giovani->status = 'S'; $giovani->email = '*****@*****.**'; $giovani->gender = 'M'; $giovani->category_id = '1'; $giovani->city_id = '1'; $giovani->store(); // store the object new TMessage('info', 'Objeto stored successfully'); TTransaction::close(); // Closes the transaction } catch (Exception $e) { new TMessage('error', $e->getMessage()); } }
/** * 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('Publisher'); // creates the form $this->form = new TQuickForm('form_Publisher'); // create the form fields $id = new TEntry('id'); $name = new TEntry('name'); $id->setEditable(FALSE); // define the sizes $this->form->addQuickField(_t('Code'), $id, 100); $this->form->addQuickField(_t('Name'), $name, 200); // define the form action $this->form->addQuickAction(_t('Save'), new TAction(array($this, 'onSave')), 'ico_save.png'); // add the form to the page parent::add($this->form); }
public function __construct() { parent::__construct(); try { // connection info $db = array(); $db['host'] = ''; $db['port'] = ''; $db['name'] = 'app/database/samples.db'; $db['user'] = ''; $db['pass'] = ''; $db['type'] = 'sqlite'; TTransaction::open(NULL, $db); // open transaction $conn = TTransaction::get(); // get PDO connection // make query $result = $conn->query('SELECT id, name from customer order by id'); // iterate results foreach ($result as $row) { print $row['id'] . '-'; print $row['name'] . "<br>\n"; } TTransaction::close(); // close transaction } catch (Exception $e) { new TMessage('error', $e->getMessage()); } }
/** * Overloaded method onSave() * Executed whenever the user clicks at the save button */ public function onSave() { // first, use the default onSave() $object = parent::onSave(); // if the object has been saved if ($object instanceof Product) { $source_file = 'tmp/' . $object->photo_path; $target_file = 'images/' . $object->photo_path; $finfo = new finfo(FILEINFO_MIME_TYPE); // if the user uploaded a source file if (file_exists($source_file) and $finfo->file($source_file) == 'image/png') { // move to the target directory rename($source_file, $target_file); try { TTransaction::open($this->database); // update the photo_path $object->photo_path = 'images/' . $object->photo_path; $object->store(); TTransaction::close(); } catch (Exception $e) { new TMessage('error', '<b>Error</b> ' . $e->getMessage()); TTransaction::rollback(); } } } }
public function onSave($param) { try { $this->form->validate(); $object = $this->form->getData(); TTransaction::open('permission'); $user = SystemUser::newFromLogin(TSession::getValue('login')); $user->name = $object->name; $user->email = $object->email; if ($object->password1) { if ($object->password1 != $object->password2) { throw new Exception(_t('The passwords do not match')); } $user->password = md5($object->password1); } else { unset($user->password); } $user->store(); $this->form->setData($object); new TMessage('info', TAdiantiCoreTranslator::translate('Record saved')); TTransaction::close(); } catch (Exception $e) { new TMessage('error', $e->getMessage()); } }
public static function logar($email, $senha) { try { TTransaction::open('sample'); $criteria = new TCriteria(); $filter = new TFilter('email', '=', $email); $filter2 = new TFilter('senha', '=', $senha); $criteria->add($filter); $criteria->add($filter2); $user = Clientes::getObjects($criteria); if ($user) { TSession::setValue('cliente_logado', true); // cria a sessão para mostrar que o usuario esta no sistema TSession::setValue('cliente', $user); // guarda os dados do cliente foreach ($user as $c) { TSession::setValue('id', $c->id); // guarda os dados do cliente } TCoreApplication::executeMethod('Home'); } else { new TMessage('error', 'Usuario ou Senha invalidos'); } TTransaction::close(); } catch (Exception $e) { echo $e->getMessage(); } }
/** * method onSave() * Executed whenever the user clicks at the save button */ 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', TAdiantiCoreTranslator::translate('Record saved')); // reload the listing } 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', '<b>Error</b> ' . $e->getMessage()); // undo all pending operations TTransaction::rollback(); } }
/** * method onEdit() * Executed whenever the user clicks at the edit button da datagrid * @param $param An array containing the GET ($_GET) parameters */ public function onEdit($param) { try { if (isset($param['key'])) { // get the parameter $key $key = $param['key']; // open a transaction with database TTransaction::open($this->database); $class = $this->activeRecord; // instantiates object $object = new $class($key); // fill the form with the active record data $this->form->setData($object); // close the transaction TTransaction::close(); } else { $this->form->clear(); } } catch (Exception $e) { // shows the exception error message new TMessage('error', '<b>Error</b> ' . $e->getMessage()); // undo all pending operations TTransaction::rollback(); } }
public function getSocial() { //RECUPERA CONEXAO BANCO DE DADOS TTransaction::open('my_bd_site'); //TABELA exposition_gallery $criteria = new TCriteria(); $criteria->setProperty('order', 'nome ASC'); // instancia a instrução de SELECT $sql = new TSqlSelect(); $sql->addColumn('*'); $sql->setEntity('social'); // atribui o critério passado como parâmetro $sql->setCriteria($criteria); // obtém transação ativa if ($conn = TTransaction::get()) { // registra mensagem de log TTransaction::log($sql->getInstruction()); // executa a consulta no banco de dados $result = $conn->Query($sql->getInstruction()); $this->results = array(); if ($result) { // percorre os resultados da consulta, retornando um objeto while ($row = $result->fetchObject()) { // armazena no array $this->results; $this->results[] = $row; } } } TTransaction::close(); return $this->results; }
/** * method onSave() * Executed whenever the user clicks at the save button */ function onSave() { try { // open a transaction with database 'changeman' TTransaction::open('changeman'); // get the form data into an active record Issue $object = $this->form->getData(); // form validation $this->form->validate(); $member = Member::newFromLogin(TSession::getValue('login')); if ($member->password !== md5($object->current_password)) { throw new Exception(_t('Current password does not match')); } if ($object->new_password1 !== $object->new_password2) { throw new Exception(_t('New password does not match the confirm password')); } // stores the object $member->password = md5($object->new_password1); $member->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', _t('Password changed successfully')); // reload the listing } catch (Exception $e) { // shows the exception error message new TMessage('error', '<b>Error</b> ' . $e->getMessage()); // undo all pending operations TTransaction::rollback(); } }
/** * Validate the login */ function onLogin() { try { TTransaction::open('library'); $data = $this->form->getData('StdClass'); // validate form data $this->form->validate(); $language = $data->language ? $data->language : 'en'; TAdiantiCoreTranslator::setLanguage($language); TApplicationTranslator::setLanguage($language); $auth = User::autenticate($data->{'user'}, $data->{'password'}); if ($auth) { TSession::setValue('logged', TRUE); TSession::setValue('login', $data->{'user'}); TSession::setValue('language', $data->language); // reload page TApplication::executeMethod('SetupPage', 'onSetup'); } TTransaction::close(); // finaliza a transação } catch (Exception $e) { TSession::setValue('logged', FALSE); // exibe a mensagem gerada pela exceção new TMessage('error', '<b>Erro</b> ' . $e->getMessage()); // desfaz todas alterações no banco de dados TTransaction::rollback(); } }
/** * method onSave() * Executed whenever the user clicks at the save button */ function onSave() { try { TTransaction::open('app'); // open a transaction // get the form data into an active record SystemUser $object = $this->form->getData('StdClass'); $this->form->validate(); // form validation $senhaatual = $object->current; $senhanova = $object->password; $confirmacao = $object->confirmation; $usuario = new SystemUser(TSession::getValue("userid")); if ($usuario->password == md5($senhaatual)) { if ($senhanova == $confirmacao) { $usuario->password = md5($senhanova); $usuario->store(); new TMessage('info', TAdiantiCoreTranslator::translate('Record saved')); } else { new TMessage('error', "A nova senha deve ser igual a sua confirmação."); } } else { new TMessage('error', "A senha atual não confere."); } TTransaction::close(); // close the transaction // shows the success message } catch (Exception $e) { // in case of exception new TMessage('error', '<b>Error</b> ' . $e->getMessage()); // shows the exception error message TTransaction::rollback(); // undo all pending operations } }
/** * Autenticates the User */ function onLogin() { try { TTransaction::open('liger'); $data = $this->form->getData('StdClass'); $this->form->validate(); $user = SystemUser::autenticate($data->login, $data->password); if ($user) { $programs = $user->getPrograms(); $programs['LoginForm'] = TRUE; TSession::setValue('logged', TRUE); TSession::setValue('login', $data->login); TSession::setValue('username', $user->name); TSession::setValue('frontpage', ''); TSession::setValue('programs', $programs); $frontpage = $user->frontpage; if ($frontpage instanceof SystemProgram and $frontpage->controller) { TApplication::gotoPage($frontpage->controller); // reload TSession::setValue('frontpage', $frontpage->controller); } else { TApplication::gotoPage('EmptyPage'); // reload TSession::setValue('frontpage', 'EmptyPage'); } } TTransaction::close(); } catch (Exception $e) { new TMessage('error', $e->getMessage()); TSession::setValue('logged', FALSE); TTransaction::rollback(); } }
/** * method onSave() * Executed whenever the user clicks at the save button */ function onSave() { try { // open a transaction with database 'changeman' TTransaction::open('changeman'); // get the form data into an active record Note $object = $this->form->getData('Note'); $logged = Member::newFromLogin(TSession::getValue('login')); $object->id_user = $logged->id; $object->register_date = date('Y-m-d'); $object->register_time = date('H:i'); // form validation $this->form->validate(); // stores the object $object->store(); $issue = new Issue($object->id_issue); $project = new Project($issue->id_project); $member = new Member($issue->id_user); // who has opened the issue // read email configuration file $ini = parse_ini_file('app/config/email.ini'); $members = $project->getMembers(array('MEMBER', 'MANAGER')); $members = array_merge($members, array($member)); // merge the logged user $mail_template = file_get_contents('app/resources/note.html'); $mail_template = str_replace('{DESCRIPTION}', $issue->description, $mail_template); $mail_template = str_replace('{OPENER}', $member->name . ' ' . $issue->register_date . ' ' . $issue->issue_time, $mail_template); $mail_template = str_replace('{NOTE}', $object->note, $mail_template); $mail_template = str_replace('{MEMBER}', $logged->name . ' ' . $object->register_date . ' ' . $object->register_time, $mail_template); $mail = new TMail(); $mail->setFrom($ini['from'], $ini['name']); $mail->setSubject(_t('Note') . ' #' . $issue->id . ': ' . $issue->title); $mail->setHtmlBody($mail_template); foreach ($members as $member) { $emails = explode(',', $member->email); foreach ($emails as $email) { $mail->addAddress(trim($email), $member->name); // echo "{$email}, {$member-> name} <br>"; } } $mail->SetUseSmtp(); $mail->SetSmtpHost($ini['host'], $ini['port']); $mail->SetSmtpUser($ini['user'], $ini['pass']); $mail->setReplyTo($ini['repl']); $mail->send(); // fill the form with the active record data $this->form->setData($object); // close the transaction TTransaction::close(); // shows the success message new TMessage('info', TAdiantiCoreTranslator::translate('Record saved')); // reload the listing } catch (Exception $e) { // shows the exception error message new TMessage('error', '<b>Error</b> ' . $e->getMessage()); // undo all pending operations TTransaction::rollback(); } }
/** * Método getConfiguracoes * Retorna as configura?es do banco de dados * * @access public * @return tbConfiguracoes Configura?es do site */ public function getConfiguracoes() { $this->configuracao = NULL; //RECUPERA CONEXAO BANCO DE DADOS TTransaction::open('my_bd_site'); $this->configuracao = (new tbConfiguracoes())->load(1); return $this->configuracao; }
/** * 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); }
public function finalizar() { try { TTransaction::open('sample'); $produtos = PCart::getItens(); // pegamos os dados do cliente $cliente = new PCliente(); $cliente_compra = new Clientes(TSession::getValue('id')); $cliente->setNome($cliente_compra->nome . ' ' . $cliente_compra->sobrenome); $cliente->setCep($cliente_compra->cep); $cliente->setLogradouro($cliente_compra->logradouro); $cliente->setBairro($cliente_compra->bairro); $cliente->setCidade($cliente_compra->cidade); $cliente->setUf($cliente_compra->uf); $cliente->setDD($cliente_compra->dd); $cliente->setTelefone($cliente_compra->telefone); $this->pagseguro->addCliente($cliente); // cria o pedido $pedidos = new Pedidos(); $pedidos->clientes_id = TSession::getValue('id'); //seta o id do cliente $pedidos->dataP = date('Y-m-d'); // seta a data $pedidos->status = 1; // estatus 1 é de aguardando pagamento $pedidos->store(); // salva o pedido if ($produtos) { foreach ($produtos as $p) { $this->pagseguro->addItem($p); // add os itens no pagseguro $pedido_produto = new PedidosProdutos(); // cria os itens do pedido $pedido_produto->pedidos_id = $pedidos->id; //seta o id do pedido $pedido_produto->produtos_id = $p->getId(); // seta o id do item $pedido_produto->qtd = $p->getQtd(); // seta a qtd do iten $pedido_produto->store(); //salva o item } } $this->pagseguro->addCodVenda($pedidos->id); // seta o code do pedido no pagseguro $link = new PLink('Finalizar'); $link->setLink($this->pagseguro->getButton()); $link->show(); PCart::clean(); // limpra o carrinho TTransaction::close(); exit; } catch (Exception $e) { new TMessage('error', $e->getMessage()); } }
public static function onChangeAction($param) { $obj = new StdClass(); $id = $param['tipo_material_consumo_id']; TTransaction::open("app"); $entidade = new TipoMaterialConsumo($id); $obj->custo = $entidade->custo; TForm::sendData('form_MaterialConsumo', $obj); TTransaction::close(); }
/** * 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); }
function onEdit($param) { try { TTransaction::open('sample'); $obj = new Agenda($param['key']); $this->form->setData($obj); TTransaction::close(); } catch (Exception $e) { new TMessage('error', $e->getMessage()); } }
/** * Returns an indexed array with all programs */ public function getPrograms() { try { TTransaction::open('permission'); $user = SystemUser::newFromLogin(TSession::getValue('login')); return $user->getProgramsList(); TTransaction::close(); } catch (Exception $e) { new TMessage('error', $e->getMessage()); } }