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());
     }
 }
Exemplo n.º 2
0
 public static function acesso($nivel)
 {
     $user = TSession::getValue('user');
     if ($user->permissao < $nivel) {
         AdiantiCoreApplication::loadPage('Home');
     }
 }
Exemplo n.º 3
0
 /**
  * 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);
 }
Exemplo n.º 4
0
 public static function run($debug = FALSE)
 {
     new TSession();
     if ($_REQUEST) {
         $class = isset($_REQUEST['class']) ? $_REQUEST['class'] : '';
         if (TSession::getValue('logged')) {
             // logged
             $programs = (array) TSession::getValue('programs');
             // programs with permission
             $programs = array_merge($programs, array('Adianti\\Base\\TStandardSeek' => TRUE, 'LoginForm' => TRUE, 'AdiantiMultiSearchService' => TRUE, 'AdiantiUploaderService' => TRUE, 'EmptyPage' => TRUE));
             // default programs
             if (isset($programs[$class])) {
                 parent::run($debug);
             } else {
                 new TMessage('error', _t('Permission denied'));
             }
         } else {
             if ($class == 'LoginForm') {
                 parent::run($debug);
             } else {
                 new TMessage('error', _t('Permission denied'), new TAction(array('LoginForm', 'onLogout')));
             }
         }
     }
 }
Exemplo n.º 5
0
 /**
  * Class Constructor
  * @param  $name name of the field
  * @param  $model name of the Model
  * @param  $form name of the Form
  * @param  $database name of the Database
  * @param  $filtros name of the field of filters (Array)
  * @param  $fields name of the fields of columns
  */
 public function __construct($name, $model, $form, $database, $filtros, $fields)
 {
     parent::__construct($name);
     $this->useOutEvent = TRUE;
     $this->setProperty('class', 'tfield tseekentry', TRUE);
     // classe CSS
     $image = new TImage('lib/adianti/images/ico_find.png');
     $this->button = new TElement('button');
     $this->button->{'class'} = 'btn btn-default tseekbutton';
     $this->button->{'type'} = 'button';
     $this->button->{'id'} = 'Pbutton_' . $name;
     $this->button->{'onmouseover'} = 'style.cursor = \'pointer\'';
     $this->button->{'name'} = '_' . $this->name . '_link';
     $this->button->{'onmouseout'} = 'style.cursor = \'default\'';
     $this->button->add($image);
     $url = 'index.php?class=PDBStandartSeek&method=onReload';
     $action = "__adianti_load_page( '{$url}');";
     $action .= "return false;";
     $this->button->onclick = $action;
     //configuração
     TSession::setValue('Model', $model);
     // model
     TSession::setValue('form', $form);
     //form de retorno
     TSession::setValue('database', $database);
     TSession::setValue('filtros', $filtros);
     TSession::setValue('fields', $fields);
 }
Exemplo n.º 6
0
 public static function checkCliente()
 {
     if (!TSession::getValue('cliente_logado')) {
         new TMessage('info', 'Você não esta logado');
         TCoreApplication::executeMethod('ClientesLogin');
     }
 }
 /**
  * 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
     }
 }
Exemplo n.º 8
0
 /**
  * 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();
     }
 }
Exemplo n.º 9
0
 public static function checkPermission($action)
 {
     //pega as funcionalidades que o usuario logado pode acessar
     $funcionalidades = TSession::getValue('funcionalidades');
     //retorna true ou falso, indicando se o usuario pode ou nao acessar a tela
     return isset($funcionalidades[$action]) and $funcionalidades[$action];
 }
Exemplo n.º 10
0
 /**
  * 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();
     }
 }
Exemplo n.º 11
0
 public function require_connection()
 {
     if (!TSession::try_get_value('id_user', $id_user)) {
         return $this->connected = false;
     } else {
         return $this->connected = $id_user;
     }
 }
 public function onDelete($param)
 {
     $key = $param['key'];
     $objects = TSession::getValue('session_contacts');
     unset($objects[$key]);
     TSession::setValue('session_contacts', $objects);
     $this->onReload();
 }
Exemplo n.º 13
0
 /**
  * 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'));
     }
 }
Exemplo n.º 14
0
 /**
  * Class constructor
  * Creates the page, the form and the listing
  */
 public function __construct()
 {
     parent::__construct();
     parent::setDatabase('samples');
     // defines the database
     parent::setActiveRecord('Product');
     // defines the active record
     parent::setDefaultOrder('id', 'asc');
     // defines the default order
     parent::addFilterField('description', 'like');
     // add a filter field
     parent::addFilterField('unity', '=');
     // add a filter field
     // creates the form, with a table inside
     $this->form = new TQuickForm('form_search_Product');
     $this->form->class = 'tform';
     $this->form->style = 'width: 650px';
     $this->form->setFormTitle('Products');
     $units = array('PC' => 'Pieces', 'GR' => 'Grain');
     // create the form fields
     $description = new TEntry('description');
     $unit = new TCombo('unity');
     $unit->addItems($units);
     // add a row for the filter field
     $this->form->addQuickField('Description', $description, 200);
     $this->form->addQuickField('Unit', $unit, 200);
     $this->form->setData(TSession::getValue('Product_filter_data'));
     $this->form->addQuickAction(_t('Find'), new TAction(array($this, 'onSearch')), 'ico_find.png');
     $this->form->addQuickAction(_t('New'), new TAction(array('ProductForm', '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', 'center', 50);
     $description = $this->datagrid->addQuickColumn('Description', 'description', 'left', 300);
     $stock = $this->datagrid->addQuickColumn('Stock', 'stock', 'right', 70);
     $sale_price = $this->datagrid->addQuickColumn('Sale Price', 'sale_price', 'right', 70);
     $unity = $this->datagrid->addQuickColumn('Unit', 'unity', 'right', 70);
     // create the datagrid actions
     $edit_action = new TDataGridAction(array('ProductForm', '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();
     // create 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 = new TVBox();
     $container->add(new TXMLBreadCrumb('menu.xml', 'ProductList'));
     $container->add($this->form);
     $container->add($this->datagrid);
     $container->add($this->pageNavigation);
     parent::add($container);
 }
 /**
  * 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);
 }
Exemplo n.º 16
0
 /**
  * Class constructor
  * Creates the page, the form and the listing
  */
 public function __construct()
 {
     parent::__construct();
     Usuario::checkLogin();
     parent::setDatabase('sample');
     // defines the database
     parent::setActiveRecord('Usuario');
     // defines the active record
     parent::setDefaultOrder('id', 'asc');
     // defines the default order
     parent::setFilterField('login');
     // defines the filter field
     // creates the form, with a table inside
     $this->form = new TForm('form_search_Usuario');
     $table = new TTable();
     $this->form->add($table);
     // create the form fields
     $filter = new TEntry('login');
     $filter->setValue(TSession::getValue('Usuario_login'));
     // add a row for the filter field
     $table->addRowSet(new TLabel('login:'******'find');
     $new_button = new TButton('new');
     $find_button->setAction(new TAction(array($this, 'onSearch')), _t('Find'));
     $new_button->setAction(new TAction(array('UsuarioForm', 'onEdit')), _t('New'));
     $find_button->setImage('ico_find.png');
     $new_button->setImage('ico_new.png');
     // add a row for the form actions
     $table->addRowSet($find_button, $new_button);
     // define wich are the form fields
     $this->form->setFields(array($filter, $find_button, $new_button));
     // creates a DataGrid
     $this->datagrid = new TQuickGrid();
     $this->datagrid->setHeight(320);
     // creates the datagrid columns
     $id = $this->datagrid->addQuickColumn('id', 'id', 'right', 100);
     $login = $this->datagrid->addQuickColumn('login', 'login', 'left', 200);
     $senha = $this->datagrid->addQuickColumn('senha', 'senha', 'left', 200);
     // create the datagrid actions
     $edit_action = new TDataGridAction(array('UsuarioForm', '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();
     // create 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 = new TVBox();
     $container->add($this->form);
     $container->add($this->datagrid);
     $container->add($this->pageNavigation);
     parent::add($container);
 }
Exemplo n.º 17
0
 /** @param PDOStatement $query_result */
 private function treat_success($query_result)
 {
     if ($query_result->rowCount() > 0 && TSession::try_get_value('id_user', $id_user)) {
         (new Insert_user_event(array('id_user' => $id_user, 'id_event' => TTransaction::get_last_inserted_id())))->run();
     } else {
         parent::set_error(102);
         TTransaction::rollback();
     }
 }
Exemplo n.º 18
0
 /**
  * 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' and Member::newFromLogin(TSession::getValue('login'))->role_mnemonic !== 'MANAGER') {
         throw new Exception(_t('Permission denied'));
     }
     TTransaction::close();
     // creates a table
     $table = new TTable();
     // creates the form
     $this->form = new TForm('form_Document');
     $this->form->add($this->notebook);
     $this->form->class = 'tform';
     $this->form->add($table);
     $table->addRowSet(new TLabel(_t('Document')), '')->class = 'tformtitle';
     // create the form fields
     $id = new TEntry('id');
     $id_project = new TDBCombo('id_project', 'changeman', 'Project', 'id', 'description');
     $title = new TEntry('title');
     $content = new THtmlEditor('content');
     $id->setEditable(FALSE);
     // define the sizes
     $id->setSize(100);
     $id_project->setSize(200);
     $title->setSize(200, 40);
     $content->setSize(680, 350);
     $table->addRowSet(new TLabel('ID:'), $id);
     $table->addRowSet(new TLabel(_t('Project') . ': '), $id_project);
     $table->addRowSet(new TLabel(_t('Title') . ': '), $title);
     $hbox = new THBox();
     $hbox->style = 'margin: 10px';
     $hbox->add($content);
     $row = $table->addRow();
     $row->addCell($lbl = new TLabel(_t('Content') . ': '));
     $lbl->setFontStyle('b');
     $row = $table->addRow();
     $cell = $row->addCell($hbox);
     $cell->colspan = 3;
     // create an action button (save)
     $save_button = new TButton('save');
     // define the button action
     $save_button->setAction(new TAction(array($this, 'onSave')), _t('Save'));
     $save_button->setImage('ico_save.png');
     // define wich are the form fields
     $this->form->setFields(array($id, $id_project, $title, $content, $save_button));
     $table->addRowSet($save_button, '')->class = 'tformaction';
     $container = new TTable();
     $container->addRow()->addCell($this->form);
     // add the form to the page
     parent::add($container);
 }
Exemplo n.º 19
0
 /**
  * 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'));
     }
     // creates a table
     $table = new TTable();
     $this->notebook = new TNotebook();
     $this->notebook->setSize(600, 350);
     $this->notebook->appendPage(_t('Data'), $table);
     // creates the form
     $this->form = new TForm('form_Release');
     $this->form->add($this->notebook);
     $options = array('Y' => _t('Yes'), 'N' => _t('No'));
     // create the form fields
     $id = new TEntry('id');
     $id_project = new TEntry('project');
     $name = new TEntry('name');
     $description = new THtmlEditor('description');
     $id->setEditable(FALSE);
     $id_project->setEditable(FALSE);
     $name->setEditable(FALSE);
     $description->setEditable(FALSE);
     // define the sizes
     $id->setSize(100);
     $id_project->setSize(200);
     $name->setSize(200, 40);
     $description->setSize(530, 200);
     // add a row for the field id
     $row = $table->addRow();
     $row->addCell(new TLabel('ID:'));
     $row->addCell($id);
     // add a row for the field id_project
     $row = $table->addRow();
     $row->addCell(new TLabel(_t('Project') . ': '));
     $row->addCell($id_project);
     // add a row for the field name
     $row = $table->addRow();
     $row->addCell(new TLabel(_t('Name') . ': '));
     $row->addCell($name);
     // add a row for the field description
     $row = $table->addRow();
     $row->addCell($lbl = new TLabel(_t('Description') . ': '));
     $lbl->setFontStyle('b');
     $row = $table->addRow();
     $cell = $row->addCell($description);
     $cell->colspan = 3;
     // define wich are the form fields
     $this->form->setFields(array($id, $id_project, $name, $description));
     $container = new TTable();
     $container->addRow()->addCell($this->form);
     // add the form to the page
     parent::add($container);
 }
 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());
     }
 }
Exemplo n.º 21
0
 /**
  * Register login
  */
 public static function registerLogin()
 {
     TTransaction::open('log');
     $object = new self();
     $object->login = TSession::getValue('login');
     $object->sessionid = session_id();
     $object->login_time = date("Y-m-d H:i:s");
     $object->store();
     TTransaction::close();
 }
Exemplo n.º 22
0
 /**
  * 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 !== 'OPERATOR' and User::newFromLogin(TSession::getValue('login'))->role->mnemonic !== 'LIBRARIAN') {
         throw new Exception(_t('Permission denied'));
     }
     TTransaction::close();
     // creates the form
     $this->form = new TForm('form_Member');
     try {
         // TUIBuilder object
         $ui = new TUIBuilder(500, 500);
         $ui->setController($this);
         $ui->setForm($this->form);
         // reads the xml form
         $ui->parseFile('app/forms/member.form.xml');
         $ui->getWidget('code_label')->setValue(_t('Code'));
         $ui->getWidget('name_label')->setValue(_t('Name'));
         $ui->getWidget('address_label')->setValue(_t('Address'));
         $ui->getWidget('city_label')->setValue(_t('City'));
         $ui->getWidget('category_label')->setValue(_t('Category'));
         $ui->getWidget('birthdate_label')->setValue(_t('Birthdate'));
         $ui->getWidget('phone_label')->setValue(_t('Phone'));
         $ui->getWidget('email_label')->setValue(_t('Email'));
         $ui->getWidget('login_label')->setValue(_t('Login'));
         $ui->getWidget('password_label')->setValue(_t('Password'));
         $ui->getWidget('registration_label')->setValue(_t('Registration'));
         $ui->getWidget('expiration_label')->setValue(_t('Expiration'));
         $ui->getWidget('new_button')->setLabel(_t('New'));
         $ui->getWidget('save_button')->setLabel(_t('Save'));
         // get the interface widgets
         $fields = $ui->getWidgets();
         // look for the TDataGrid object
         foreach ($fields as $name => $field) {
             if ($field instanceof TDataGrid) {
                 $this->datagrid = $field;
                 $this->pageNavigation = $this->datagrid->getPageNavigation();
             }
         }
         // add the TUIBuilder panel inside the TForm object
         $this->form->add($ui);
         // set form fields from interface fields
         $this->form->setFields($ui->getFields());
     } catch (Exception $e) {
         new TMessage('error', $e->getMessage());
     }
     // add the form to the page
     parent::add($this->form);
 }
Exemplo n.º 23
0
 /**
  * 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);
 }
Exemplo n.º 24
0
 /**
  * Class constructor
  * Creates the page, the form and the listing
  */
 public function __construct()
 {
     parent::__construct();
     Usuario::checkLogin();
     parent::setDatabase('sample');
     // defines the database
     parent::setActiveRecord('Pedidos');
     // defines the active record
     parent::setDefaultOrder('id', 'asc');
     // defines the default order
     parent::setFilterField('id');
     // defines the filter field
     // creates the form, with a table inside
     $this->form = new TForm('form_search_Pedidos');
     $table = new TTable();
     $this->form->add($table);
     // create the form fields
     $filter = new TEntry('id');
     $filter->setValue(TSession::getValue('Pedidos_id'));
     // add a row for the filter field
     $table->addRowSet(new TLabel('id:'), $filter);
     // create two action buttons to the form
     $find_button = new TButton('find');
     $find_button->setAction(new TAction(array($this, 'onSearch')), _t('Find'));
     $find_button->setImage('ico_find.png');
     // add a row for the form actions
     $table->addRowSet($find_button);
     // define wich are the form fields
     $this->form->setFields(array($filter, $find_button));
     // creates a DataGrid
     $this->datagrid = new TQuickGrid();
     $this->datagrid->setHeight(320);
     // creates the datagrid columns
     $id = $this->datagrid->addQuickColumn('id', 'id', 'right', 100);
     $dataP = $this->datagrid->addQuickColumn('dataP', 'dataP', 'left', 100);
     $clientes_id = $this->datagrid->addQuickColumn('cliente', 'clientes->nome', 'right', 100);
     $status = $this->datagrid->addQuickColumn('status', 'status', 'right', 100);
     // create the datagrid actions
     $itens_action = new TDataGridAction(array($this, 'showItens'));
     // add the actions to the datagrid
     $this->datagrid->addQuickAction("Produtos", $itens_action, 'id', 'ico_find.png');
     // create the datagrid model
     $this->datagrid->createModel();
     // create 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 = new TVBox();
     $container->add($this->form);
     $container->add($this->datagrid);
     $container->add($this->pageNavigation);
     parent::add($container);
 }
Exemplo n.º 25
0
 /**
  * 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());
     }
 }
Exemplo n.º 26
0
 public function onSave($param)
 {
     $data = $this->form->getData();
     // put the data back to the form
     $this->form->setData($data);
     $objects = TSession::getValue('session_contacts');
     $objects[$data->code] = $data;
     TSession::setValue('session_contacts', $objects);
     // show the message
     new TMessage('info', 'Record added', new TAction(array('DatagridWindowForm', 'onReload')));
 }
Exemplo n.º 27
0
 /**
  * Register a change log
  */
 public static function register($activeRecord, $lastState, $currentState)
 {
     $table = $activeRecord->getEntity();
     $pk = $activeRecord->getPrimaryKey();
     TTransaction::open('log');
     foreach ($lastState as $key => $value) {
         if (!isset($currentState[$key])) {
             // deleted
             $log = new self();
             $log->tablename = $table;
             $log->logdate = date('Y-m-d H:i:s');
             $log->login = TSession::getValue('login');
             $log->primarykey = $pk;
             $log->pkvalue = $activeRecord->{$pk};
             $log->operation = 'deleted';
             $log->columnname = $key;
             $log->oldvalue = $value;
             $log->newvalue = '';
             $log->store();
         }
     }
     foreach ($currentState as $key => $value) {
         if (isset($lastState[$key]) and $value != $lastState[$key]) {
             // changed
             $log = new self();
             $log->tablename = $table;
             $log->logdate = date('Y-m-d H:i:s');
             $log->login = TSession::getValue('login');
             $log->primarykey = $pk;
             $log->pkvalue = $activeRecord->{$pk};
             $log->operation = 'changed';
             $log->columnname = $key;
             $log->oldvalue = $lastState[$key];
             $log->newvalue = $value;
             $log->store();
         }
         if (!isset($lastState[$key]) and !empty($value)) {
             // created
             $log = new self();
             $log->tablename = $table;
             $log->logdate = date('Y-m-d H:i:s');
             $log->login = TSession::getValue('login');
             $log->primarykey = $pk;
             $log->pkvalue = $activeRecord->{$pk};
             $log->operation = 'created';
             $log->columnname = $key;
             $log->oldvalue = '';
             $log->newvalue = $value;
             $log->store();
         }
     }
     TTransaction::close();
 }
Exemplo n.º 28
0
 public function __construct()
 {
     parent::__construct('ul');
     $this->class = 'dropdown-menu dropdown-messages';
     $messages = array();
     $messages[] = array(TSession::getValue('login'), 'Yesterday', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eleifend...');
     $messages[] = array(TSession::getValue('login'), 'Yesterday', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eleifend...');
     $messages[] = array(TSession::getValue('login'), 'Yesterday', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eleifend...');
     $a = new TElement('a');
     $a->{'class'} = "dropdown-toggle";
     $a->{'data-toggle'} = "dropdown";
     $a->{'href'} = "#";
     $a->add(TElement::tag('i', '', array('class' => "fa fa-envelope fa-fw")));
     $a->add(TElement::tag('span', count($messages), array('class' => "badge badge-notify")));
     $a->add(TElement::tag('i', '', array('class' => "fa fa-caret-down")));
     $a->show();
     foreach ($messages as $message) {
         $name = $message[0];
         $date = $message[1];
         $body = $message[2];
         $li = new TElement('li');
         $a = new TElement('a');
         $div = new TElement('div');
         $a->href = '#';
         $li->add($a);
         $a->add($div);
         $div->add(TElement::tag('strong', $name));
         $div->add(TElement::tag('span', TElement::tag('em', $date), array('class' => 'pull-right text-muted')));
         $div2 = new TElement('div');
         $div2->add($body);
         $a->add($div2);
         parent::add($li);
         parent::add(TElement::tag('li', '', array('class' => 'divider')));
     }
     $li = new TElement('li');
     $a = new TElement('a');
     $li->add($a);
     $a->class = 'text-center';
     $a->href = '#';
     $a->add(TElement::tag('strong', 'Read messages'));
     $a->add($i = TElement::tag('i', '', array('class' => 'fa fa-inbox')));
     parent::add($li);
     parent::add(TElement::tag('li', '', array('class' => 'divider')));
     $li = new TElement('li');
     $a = new TElement('a');
     $li->add($a);
     $a->class = 'text-center';
     $a->href = '#';
     $a->add(TElement::tag('strong', 'Send message'));
     $a->add($i = TElement::tag('i', '', array('class' => 'fa fa-envelope-o')));
     parent::add($li);
 }
 /**
  * Executed when the user clicks at click to buy button
  */
 public function onBuyClick($param)
 {
     $cart_items = TSession::getValue('cart_items');
     if (isset($cart_items[$param['product_id']])) {
         $cart_items[$param['product_id']]++;
     } else {
         $cart_items[$param['product_id']] = 1;
     }
     TSession::setValue('cart_items', $cart_items);
     $this->enableManagement();
     $posAction = new TAction(array('CartManagementView', 'onReload'));
     new TMessage('info', 'You have chosen the product: ' . $param['product_id'], $posAction);
 }
Exemplo n.º 30
-1
 /**
  * Class constructor
  * Creates the page, the form and the listing
  */
 public function __construct()
 {
     parent::__construct();
     // defines the database
     parent::setDatabase('samples');
     // defines the active record
     parent::setActiveRecord('Project');
     // defines the filter field
     parent::setFilterField('name');
     // creates the form
     $this->form = new TForm('form_search_Project');
     // creates a table
     $table = new TTable();
     // add the table inside the form
     $this->form->add($table);
     // create the form fields
     $filter = new TEntry('name');
     $filter->setValue(TSession::getValue('Project_name'));
     // add a row for the filter field
     $table->addRowSet(new TLabel('name:'), $filter);
     // create two action buttons to the form
     $find_button = new TButton('find');
     $new_button = new TButton('new');
     $find_button->setAction(new TAction(array($this, 'onSearch')), _t('Find'));
     $find_button->setImage('ico_find.png');
     $new_button->setAction(new TAction(array('ProjectFormView', 'onEdit')), _t('New'));
     $new_button->setImage('ico_new.png');
     // add a row for the form actions
     $table->addRowSet($find_button, $new_button);
     // define wich are the form fields
     $this->form->setFields(array($filter, $find_button, $new_button));
     // creates a DataGrid
     $this->datagrid = new TQuickGrid();
     $this->datagrid->setHeight(320);
     // creates the datagrid columns
     $id = $this->datagrid->addQuickColumn('ID', 'id', 'left', 50);
     $name = $this->datagrid->addQuickColumn('Name', 'name', 'left', 190);
     $start = $this->datagrid->addQuickColumn('Start', 'start_date', 'left', 80);
     $end = $this->datagrid->addQuickColumn('End', 'end_date', 'left', 80);
     $customer = $this->datagrid->addQuickColumn('customer', 'customer', 'left', 100);
     // add the actions to the datagrid
     $this->datagrid->addQuickAction(_t('Edit'), new TDataGridAction(array('ProjectFormView', 'onEdit')), 'id', 'ico_edit.png');
     $this->datagrid->addQuickAction(_t('Delete'), new TDataGridAction(array($this, 'onDelete')), 'id', 'ico_delete.png');
     $this->datagrid->addQuickAction(_t('Detail'), new TDataGridAction(array('BacklogFormView', 'onSetProject')), 'id');
     // 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());
     // pack the elements using a vertical box
     $vbox = new TVBox();
     $vbox->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
     $vbox->add($this->form);
     $vbox->add($this->datagrid);
     $vbox->add($this->pageNavigation);
     // add the box inside the page
     parent::add($vbox);
 }