/**
  * Class constructor
  * Creates the page
  */
 function __construct()
 {
     parent::__construct();
     // create the form using TQuickForm class
     $this->form = new TQuickForm('form_seek_sample');
     $this->form->setFormTitle('Seek button');
     $this->form->class = 'tform';
     // create the form fields
     $city_id1 = new TSeekButton('city_id1');
     $city_name1 = new TEntry('city_name1');
     $criteria = new TCriteria();
     $criteria->add(new TFilter('id', '>', 1));
     $criteria->add(new TFilter('id', '<', 5));
     $criteria->setProperty('order', 'name');
     // define the action for city_id1
     $obj = new TestCitySeek();
     $action = new TAction(array($obj, 'onReload'));
     $city_id1->setAction($action);
     $city_id1->setSize(100);
     $city_name1->setEditable(FALSE);
     $this->form->addQuickFields('Manual SeekButton', array($city_id1, $city_name1));
     $this->form->addQuickAction('Save', new TAction(array($this, 'onSave')), 'fa:floppy-o');
     // wrap the page content using vertical box
     $vbox = new TVBox();
     $vbox->add($this->form);
     parent::add($vbox);
 }
 /**
  * method onReload()
  * Load the datagrid with the database objects
  */
 function onReload($param = NULL)
 {
     try {
         // open a transaction with database 'samples'
         TTransaction::open('samples');
         // creates a repository for Category
         $repository = new TRepository('Category');
         // creates a criteria, ordered by id
         $criteria = new TCriteria();
         $order = isset($param['order']) ? $param['order'] : 'id';
         $criteria->setProperty('order', $order);
         // load the objects according to criteria
         $categories = $repository->load($criteria);
         $this->datagrid->clear();
         if ($categories) {
             // iterate the collection of active records
             foreach ($categories as $category) {
                 // add the object inside the datagrid
                 $this->datagrid->addItem($category);
             }
         }
         // close the transaction
         TTransaction::close();
         $this->loaded = true;
     } catch (Exception $e) {
         // shows the exception error message
         new TMessage('error', '<b>Error</b> ' . $e->getMessage());
         // undo all pending operations
         TTransaction::rollback();
     }
 }
예제 #3
0
 /**
  * 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 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;
 }
예제 #5
0
 public function getEmails()
 {
     $this->collectionEmails = NULL;
     //TABELA exposition_gallery
     $criteria = new TCriteria();
     $criteria->addFilter('ativo', '=', 1);
     $criteria->setProperty('order', 'email');
     $this->repository->addColumn('email');
     $this->repository->addEntity('emails');
     $this->collectionEmails = $this->repository->load($criteria);
     return $this->collectionEmails;
 }
예제 #6
0
 /**
  * Return the week events
  * @return Event[]
  */
 public static function getWeekEvents()
 {
     $first_week_day = self::getFirstWeekDay();
     $last_week_day = self::getLastWeekDay();
     // load objects
     $repo = new TRepository('Event');
     $criteria = new TCriteria();
     $criteria->add(new TFilter('event_date', '>=', $first_week_day));
     $criteria->add(new TFilter('event_date', '<=', $last_week_day));
     $criteria->setProperty('order', 'event_date, start_hour');
     return $repo->load($criteria);
 }
 public function __construct()
 {
     parent::__construct();
     try {
         TTransaction::open('samples');
         // abre uma transação
         $criteria = new TCriteria();
         $criteria->setProperty('limit', 10);
         $criteria->setProperty('offset', 20);
         $criteria->setProperty('order', 'id');
         $repository = new TRepository('Customer');
         $customers = $repository->load($criteria);
         foreach ($customers as $customer) {
             echo $customer->id . ' - ' . $customer->name . '<br>';
         }
         TTransaction::close();
         // fecha a transação.
     } catch (Exception $e) {
         new TMessage('error', $e->getMessage());
     }
 }
 /**
  * Método getImoveis
  * Retorna os Imóveis
  * 
  * @access  public
  * @return  TRepository Coleção de Imóveis
  */
 public function getImoveis()
 {
     $this->collectionImoveis = NULL;
     //TABELA exposition_gallery
     $criteria = new TCriteria();
     $criteria->addFilter('ativo', '=', 1);
     $criteria->setProperty('order', 'endereco');
     $this->repository->addColumn('*');
     $this->repository->addEntity('imoveis');
     $this->collectionImoveis = $this->repository->load($criteria);
     return $this->collectionImoveis;
 }
 public function getTelefones()
 {
     $this->collectionTelefones = NULL;
     //TABELA exposition_gallery
     $criteria = new TCriteria();
     $criteria->addFilter('ativo', '=', 1);
     $criteria->setProperty('order', 'codigo');
     $this->repository->addColumn('telefone');
     $this->repository->addEntity('telefones');
     $this->collectionTelefones = $this->repository->load($criteria);
     return $this->collectionTelefones;
 }
 /**
  * method onReload()
  * Load the datagrid with the database objects
  */
 function onReload($param = NULL)
 {
     try {
         // open a transaction with database 'samples'
         TTransaction::open('samples');
         // creates a repository for Product
         $repository = new TRepository('Product');
         $limit = 10;
         // creates a criteria
         $criteria = new TCriteria();
         $criteria->setProperties($param);
         // order, offset
         $criteria->setProperty('limit', $limit);
         // update the save action parameters to pass
         // offset, limit, page and other info to the save action
         $this->saveAction->setParameters($param);
         // important!
         // load the objects according to criteria
         $objects = $repository->load($criteria);
         $this->datagrid->clear();
         if ($objects) {
             // iterate the collection of active records
             foreach ($objects as $object) {
                 $object->sale_price_edit = new TEntry('sale_price_' . $object->id);
                 $object->sale_price_edit->setNumericMask(1, '.', ',');
                 $object->sale_price_edit->setSize(120);
                 $object->sale_price_edit->setValue($object->sale_price);
                 $this->form->addField($object->sale_price_edit);
                 // important!
                 // add the object inside the datagrid
                 $this->datagrid->addItem($object);
             }
         }
         // reset the criteria for record count
         $criteria->resetProperties();
         $count = $repository->count($criteria);
         $this->pageNavigation->setCount($count);
         // count of records
         $this->pageNavigation->setProperties($param);
         // order, page
         $this->pageNavigation->setLimit($limit);
         // limit
         // close the transaction
         TTransaction::close();
         $this->loaded = true;
     } catch (Exception $e) {
         // shows the exception error message
         new TMessage('error', '<b>Error</b> ' . $e->getMessage());
         // undo all pending operations
         TTransaction::rollback();
     }
 }
 /**
  * Método getUsuarios
  * Obtem todos os usuarios
  * 
  * @access public
  * @return array Coleção de Usuário
  */
 public function getUsuarios()
 {
     $this->collectionUsuario = NULL;
     //TABELA exposition_gallery
     $criteria = new TCriteria();
     //$criteria->addFilter('situacao', '=', $situacao);
     $criteria->setProperty('order', 'nome');
     $this->repository = new TRepository();
     $this->repository->addColumn('*');
     $this->repository->addEntity('usuarios');
     $this->collectionUsuario = $this->repository->load($criteria);
     return $this->collectionUsuario;
 }
 /**
  * Método getLocalizacoes
  * Retorna as localizações
  * 
  * @access  public
  * @return  TRepository Coleção de Localizações
  */
 public function getSituacoes()
 {
     $this->collectionSituacao = NULL;
     //TABELA exposition_gallery
     $criteria = new TCriteria();
     $criteria->addFilter('ativo', '=', 1);
     $criteria->setProperty('order', 'situacao');
     $this->repository->addColumn('codigo');
     $this->repository->addColumn('situacao');
     $this->repository->addEntity('situacaoimoveis');
     $this->collectionSituacao = $this->repository->load($criteria);
     return $this->collectionSituacao;
 }
 /**
  * Método getLocalizacoes
  * Retorna as localizações
  * 
  * @access  public
  * @return  TRepository Coleção de Localizações
  */
 public function getCategorias()
 {
     $this->collectionCategoria = NULL;
     //TABELA exposition_gallery
     $criteria = new TCriteria();
     $criteria->addFilter('ativo', '=', 1);
     $criteria->setProperty('order', 'categoria');
     $this->repository->addColumn('codigo');
     $this->repository->addColumn('categoria');
     $this->repository->addEntity('categoriaimoveis');
     $this->collectionCategoria = $this->repository->load($criteria);
     return $this->collectionCategoria;
 }
 /**
  *  Método getGaleriaImovel
  *  Obtém a galeria de fotos do imóvel de acordo com o código do imóvel
  *
  *  @access public
  *  @param  int         $codigo     Código do Imóvel
  *  @return TRepository             Coleção de imagens do Imóvel
  */
 public function getGaleriaImovel($codigo)
 {
     $this->collectionGaleria = NULL;
     //TABELA exposition_gallery
     $criteria = new TCriteria();
     $criteria->addFilter('ativo', '=', 1);
     $criteria->addFilter('codigoImovel', '=', $codigo);
     $criteria->setProperty('order', 'ordem');
     $this->repository->addColumn('imagem');
     $this->repository->addColumn('titulo');
     $this->repository->addColumn('descricao');
     $this->repository->addEntity('galeria');
     $this->collectionGaleria = $this->repository->load($criteria);
     return $this->collectionGaleria;
 }
 function getCollectionOrcamentosProdutos($codigo)
 {
     $this->setCollectionOrcamentosProdutos(NULL);
     //RECUPERA CONEXAO BANCO DE DADOS
     TTransaction::open('my_bd_site');
     //TABELA exposition_gallery
     $criteria = new TCriteria();
     $criteria->add(new TFilter('codigoOrcamento', '=', $codigo));
     $criteria->setProperty('order', 'nome');
     $this->repository = new TRepository();
     $this->repository->addColumn('*');
     $this->repository->addEntity('orcamentoproduto');
     $this->setCollectionOrcamentosProdutos($this->repository->load($criteria));
     TTransaction::close();
     return $this->collectionOrcamentosProdutos;
 }
 function getCollectionCategoria()
 {
     $this->setCollectionCategoria(NULL);
     //RECUPERA CONEXAO BANCO DE DADOS
     TTransaction::open('my_bd_site');
     //TABELA exposition_gallery
     $criteria = new TCriteria();
     //$criteria->add(new TFilter('situacao', '=', $situacao));
     $criteria->setProperty('order', 'nome');
     $this->repository = new TRepository();
     $this->repository->addColumn('*');
     $this->repository->addEntity('categorias');
     $this->setCollectionCategoria($this->repository->load($criteria));
     TTransaction::close();
     return $this->collectionCategoria;
 }
 /**
  * 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  $criteria criteria (TCriteria object) to filter the model (optional)
  */
 public function __construct($name, $database, $model, $key, $value, $ordercolumn = NULL, TCriteria $criteria = NULL)
 {
     // executes the parent class constructor
     parent::__construct($name);
     if (empty($database)) {
         throw new Exception(AdiantiCoreTranslator::translate('The parameter (^1) of ^2 is required', 'database', __CLASS__));
     }
     if (empty($model)) {
         throw new Exception(AdiantiCoreTranslator::translate('The parameter (^1) of ^2 is required', 'model', __CLASS__));
     }
     if (empty($key)) {
         throw new Exception(AdiantiCoreTranslator::translate('The parameter (^1) of ^2 is required', 'key', __CLASS__));
     }
     if (empty($value)) {
         throw new Exception(AdiantiCoreTranslator::translate('The parameter (^1) of ^2 is required', 'value', __CLASS__));
     }
     // carrega objetos do banco de dados
     TTransaction::open($database);
     // instancia um repositório de Estado
     $repository = new TRepository($model);
     if (is_null($criteria)) {
         $criteria = new TCriteria();
     }
     $criteria->setProperty('order', isset($ordercolumn) ? $ordercolumn : $key);
     // carrega todos objetos
     $collection = $repository->load($criteria, FALSE);
     // adiciona objetos na combo
     if ($collection) {
         $items = array();
         foreach ($collection as $object) {
             if (is_array($value)) {
                 foreach ($value as $k => $v) {
                     if ($k == 0) {
                         $items[$object->{$key}] = str_pad($object->{$v}, 3, 0, STR_PAD_LEFT);
                     } else {
                         $items[$object->{$key}] .= ' - ' . $object->{$v};
                     }
                 }
             } else {
                 $items[$object->{$key}] = $object->{$value};
             }
         }
         parent::addItems($items);
     }
     TTransaction::close();
 }
 function onReload()
 {
     // inicia transação com o banco 'pg_livro'
     TTransaction::open('pg_livro');
     // instancia um repositório para Pessoa
     $repository = new TRepository('Pessoa');
     // cria um critério, definindo a ordenação
     $criteria = new TCriteria();
     $criteria->setProperty('order', 'id');
     // carrega os objetos $pessoas
     $pessoas = $repository->load($criteria);
     $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;
 }
예제 #19
0
 public function addPopulationTarget(TCombo $alvo, $model, $frm, $key_busca, $value, $key_valor, $ordercolumn = null)
 {
     if ($this->changeaction) {
         // carrega objetos do banco de dados
         TTransaction::open($this->banco);
         // instancia um repositório de Estado
         $repository = new TRepository($model);
         $criteria = new TCriteria();
         $criteria->setProperty('order', isset($ordercolumn) ? $ordercolumn : $key_busca);
         $criteria->add(new TFilter($key_busca, '=', $key_valor));
         // carrega todos objetos
         $collection = $repository->{$model};
         $items = array();
         foreach ($collection as $object) {
             $items[$object->{$key}] = $object->{$value};
         }
         TCombo::reload($frm, $alvo->getName(), $items);
         TTransaction::close();
     } else {
         throw new Exception('you need delcare changeaction first');
     }
 }
예제 #20
0
 /**
  * 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
  */
 public function __construct($name, $database, $model, $key, $value)
 {
     // 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', $key);
     // 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();
 }
 function onReload($param = NULL)
 {
     $order = $param['order'];
     // inicia transação com o banco 'pg_livro'
     TTransaction::open('pg_livro');
     // instancia um repositório para Pessoa
     $repository = new TRepository('Pessoa');
     // retorna todos objetos que satisfazem o critério
     $criteria = new TCriteria();
     $criteria->setProperty('order', $order);
     $pessoas = $repository->load($criteria);
     if ($pessoas) {
         $this->datagrid->clear();
         foreach ($pessoas as $pessoa) {
             // adiciona o objeto na DataGrid
             $this->datagrid->addItem($pessoa);
         }
     }
     // finaliza a transação
     TTransaction::close();
     $this->loaded = true;
 }
 /**
  * Class constructor
  * Creates the page
  */
 function __construct()
 {
     parent::__construct();
     // create the form using TQuickForm class
     $this->form = new TQuickForm('form_seek_sample');
     $this->form->setFormTitle('Seek button');
     $this->form->class = 'tform';
     // create the form fields
     $city_id1 = new TSeekButton('city_id1');
     $city_name1 = new TEntry('city_name1');
     $city_id2 = new TDBSeekButton('city_id2', 'samples', 'form_seek_sample', 'City', 'name', 'city_id2', 'city_name2');
     $city_name2 = new TEntry('city_name2');
     $criteria = new TCriteria();
     $criteria->add(new TFilter('id', '>', 1));
     $criteria->add(new TFilter('id', '<', 5));
     $criteria->setProperty('order', 'name');
     $city_id3 = new TDBSeekButton('city_id3', 'samples', 'form_seek_sample', 'City', 'name', 'city_id3', 'city_name3', $criteria);
     $city_name3 = new TEntry('city_name3');
     // define the action for city_id1
     $obj = new TestCitySeek();
     $action = new TAction(array($obj, 'onReload'));
     $city_id1->setAction($action);
     $city_id1->setSize(100);
     $city_id2->setSize(100);
     $city_id3->setSize(100);
     $city_name1->setEditable(FALSE);
     $city_name2->setEditable(FALSE);
     $city_name3->setEditable(FALSE);
     $this->form->addQuickFields('Manual SeekButton', array($city_id1, $city_name1));
     $this->form->addQuickFields('Standard SeekButton', array($city_id2, $city_name2));
     $this->form->addQuickFields('Standard with filter', array($city_id3, $city_name3));
     $this->form->addQuickAction('Save', new TAction(array($this, 'onSave')), 'ico_save.png');
     // wrap the page content using vertical box
     $vbox = new TVBox();
     $vbox->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
     $vbox->add($this->form);
     parent::add($vbox);
 }
예제 #23
0
 /**
  * Load the datagrid with the database objects
  */
 function onReload($param = NULL)
 {
     try {
         // start database transaction
         TTransaction::open('library');
         // create a repository for Item table
         $repository = new TRepository('Item');
         $limit = 10;
         // creates a criteria
         $criteria = new TCriteria();
         $criteria->setProperties($param);
         // order, offset
         $criteria->setProperty('limit', $limit);
         if (TSession::getValue('test_item_filter')) {
             // filter by item barcode
             $criteria->add(TSession::getValue('test_item_filter'));
         }
         // load the objects according to the criteria
         $items = $repository->load($criteria);
         $this->datagrid->clear();
         if ($items) {
             foreach ($items as $item) {
                 // add the objects inside the datagrid
                 $this->datagrid->addItem($item);
             }
         }
         // clear the criteria
         $criteria->resetProperties();
         $count = $repository->count($criteria);
         $this->pageNavigation->setCount($count);
         // count of records
         $this->pageNavigation->setProperties($param);
         // order, page
         $this->pageNavigation->setLimit($limit);
         // limit
         // commit and closes the database transaction
         TTransaction::close();
         $this->loaded = true;
     } catch (Exception $e) {
         // show the error message
         new TMessage('error', '<b>Erro</b> ' . $e->getMessage());
         // undo all pending operations
         TTransaction::rollback();
     }
 }
 /**
  * method onReload()
  * Load the datagrid with the database objects
  */
 function onReload($param = NULL)
 {
     try {
         // open a transaction with database 'samples'
         TTransaction::open('samples');
         // creates a repository for Customer
         $repository = new TRepository('Customer');
         $limit = 10;
         // creates a criteria
         $criteria = new TCriteria();
         $criteria->setProperties($param);
         // order, offset
         $criteria->setProperty('limit', $limit);
         // load the objects according to criteria
         $objects = $repository->load($criteria);
         $this->datagrid->clear();
         if ($objects) {
             // iterate the collection of active records
             foreach ($objects as $object) {
                 // add the object inside the datagrid
                 $this->datagrid->addItem($object);
             }
         }
         // reset the criteria for record count
         $criteria->resetProperties();
         $count = $repository->count($criteria);
         $this->pageNavigation->setCount($count);
         // count of records
         $this->pageNavigation->setProperties($param);
         // order, page
         $this->pageNavigation->setLimit($limit);
         // limit
         // close the transaction
         TTransaction::close();
         $this->loaded = true;
     } catch (Exception $e) {
         // shows the exception error message
         new TMessage('error', '<b>Error</b> ' . $e->getMessage());
         // undo all pending operations
         TTransaction::rollback();
     }
 }
 /**
  * method onReload()
  * Load the datagrid with the database objects
  */
 function onReload($param = NULL)
 {
     try {
         // open a transaction with database 'samples'
         TTransaction::open('samples');
         // creates a repository for Customer
         $repository = new TRepository('Customer');
         $limit = 10;
         // creates a criteria
         $criteria = new TCriteria();
         $newparam = $param;
         // define new parameters
         if (isset($newparam['order']) and $newparam['order'] == 'city->name') {
             $newparam['order'] = '(select name from city where city_id = id)';
         }
         // default order
         if (empty($newparam['order'])) {
             $newparam['order'] = 'id';
             $newparam['direction'] = 'asc';
         }
         $criteria->setProperties($newparam);
         // order, offset
         $criteria->setProperty('limit', $limit);
         if (TSession::getValue('customer_filter1')) {
             // add the filter stored in the session to the criteria
             $criteria->add(TSession::getValue('customer_filter1'));
         }
         if (TSession::getValue('customer_filter2')) {
             // add the filter stored in the session to the criteria
             $criteria->add(TSession::getValue('customer_filter2'));
         }
         // load the objects according to criteria
         $customers = $repository->load($criteria, FALSE);
         $this->datagrid->clear();
         if ($customers) {
             foreach ($customers as $customer) {
                 // add the object inside the datagrid
                 $this->datagrid->addItem($customer);
             }
         }
         // reset the criteria for record count
         $criteria->resetProperties();
         $count = $repository->count($criteria);
         $this->pageNavigation->setCount($count);
         // count of records
         $this->pageNavigation->setProperties($param);
         // order, page
         $this->pageNavigation->setLimit($limit);
         // limit
         // close the transaction
         TTransaction::close();
         $this->loaded = true;
     } catch (Exception $e) {
         // shows the exception error message
         new TMessage('error', '<b>Error</b> ' . $e->getMessage());
         // undo all pending operations
         TTransaction::rollback();
     }
 }
예제 #26
0
 /**
  * method onReload()
  * Load the datagrid with the database objects
  */
 function onReload($param = NULL)
 {
     try {
         // open a transaction with database 'changeman'
         TTransaction::open('changeman');
         // creates a repository for Issue
         $repository = new TRepository('Issue');
         if (!isset($param['order']) or $param['order'] == 'id') {
             $param['order'] = 'id';
             $param['direction'] = 'desc';
         }
         $limit = 100;
         // creates a criteria
         $criteria = new TCriteria();
         $criteria->setProperties($param);
         // order, offset
         $criteria->setProperty('limit', $limit);
         if (TSession::getValue('Issue_filter')) {
             foreach (TSession::getValue('Issue_filter') as $filter) {
                 // add the filter stored in the session to the criteria
                 $criteria->add($filter);
             }
         }
         $member = Member::newFromLogin(TSession::getValue('login'));
         if ($member->role_mnemonic == 'CUSTOMER') {
             $criteria->add(new TFilter('id_user', '=', $member->id));
         }
         // load the objects according to criteria
         $objects = $repository->load($criteria);
         $this->datagrid->clear();
         if ($objects) {
             // iterate the collection of active records
             foreach ($objects as $object) {
                 // add the object inside the datagrid
                 $this->datagrid->addItem($object);
             }
         }
         // reset the criteria for record count
         $criteria->resetProperties();
         $count = $repository->count($criteria);
         $this->pageNavigation->setCount($count);
         // count of records
         $this->pageNavigation->setProperties($param);
         // order, page
         $this->pageNavigation->setLimit($limit);
         // limit
         // close the transaction
         TTransaction::close();
         $this->loaded = true;
     } catch (Exception $e) {
         // shows the exception error message
         new TMessage('error', '<b>Error</b> ' . $e->getMessage());
         // undo all pending operations
         TTransaction::rollback();
     }
 }
 public function getSituacoes2()
 {
     $this->collectionSituacoes = NULL;
     //RECUPERA CONEXAO BANCO DE DADOS
     TTransaction2::open('my_bd_site');
     //TABELA exposition_gallery
     $criteria = new TCriteria();
     //$criteria->add(new TFilter('situacao', '=', $situacao));
     $criteria->setProperty('order', 'ordem ASC');
     $this->repository = new TRepository2();
     $this->repository->addColumn('*');
     $this->repository->addEntity('kanban_situacao');
     $this->collectionSituacoes = $this->repository->load($criteria);
     TTransaction2::close();
     return $this->collectionSituacoes;
 }
 /**
  * Load the datagrid with the database objects
  */
 function onReload($param = NULL)
 {
     try {
         TTransaction::open($this->getBanco());
         // create a repository for City table
         $repository = new TRepository($this->getModel());
         $limit = 10;
         // creates a criteria
         $criteria = new TCriteria();
         $criteria->setProperties($param);
         // order, offset
         $criteria->setProperty('limit', $limit);
         if (TSession::getValue('filter')) {
             // filter by city name
             $criteria->add(TSession::getValue('filter'));
         }
         // load the objects according to the criteria
         $data = $repository->load($criteria);
         $this->datagrid->clear();
         if ($data) {
             foreach ($data as $dados) {
                 // add the objects inside the datagrid
                 $this->datagrid->addItem($dados);
             }
         }
         // clear the criteria
         $criteria->resetProperties();
         $count = $repository->count($criteria);
         $this->pageNavigation->setCount($count);
         // count of records
         $this->pageNavigation->setProperties($param);
         // order, page
         $this->pageNavigation->setLimit($limit);
         // limit
         $this->loaded = TRUE;
     } catch (Exception $e) {
         // show the error message
         new TMessage('error', '<b>Erro</b> ' . $e->getMessage());
         // undo all pending operations
         TTransaction::rollback();
     }
 }
예제 #29
0
        include_once "app.ado/{$classe}.class.php";
    }
}
//Criar critéria de seleção e dados
$criteria1 = new TCriteria();
//Selecionar todos as meninas que estão na terceira serie
$criteria1->add(new TFilter('sexo', '=', 'F'));
$criteria1->add(new TFilter('serie', '=', '3'));
// Selecionar dados dos meninos de 4 seria
$criteria2 = new TCriteria();
$criteria2->add(new TFilter('sexo', '=', 'M'));
$criteria2->add(new TFilter('seria', '=', '4'));
//Agrora juntamos os dois criterios Utilizados
//O operador lógico OR. O resultado tem de conter
//Os dados dos meninos ou das meninas
$criteria = new TCriteria();
$criteria->add(new $criteria1(), TExpression::OR_OPERATOR);
$criteria->add(new $criteria2(), TExpression::OR_OPERATOR);
//Definir o ordenamento da consulta
$criteria->setProperty('order', 'nome');
//Criar Instrução SELECT
$sql = new TSqlSelect();
//definir o nome da entidade
$sql->setEntity('aluno');
//Acrecentar colunas a consulta
$sql->addColumn('*');
// Definir Critério de  seleção de dado
$sql->setCriteria($criteria);
//Processar a intrução SQL
echo $sql->getInstruction();
echo "<br>\n";
 /**
  * method onReload()
  * Load the datagrid with the database objects
  */
 function onReload($param = NULL)
 {
     try {
         // open a transaction with database 'atividade'
         TTransaction::open('atividade');
         $logado = Pessoa::retornaUsuario();
         // creates a repository for Ponto
         $repository = new TRepository('Ponto');
         $limit = 10;
         // creates a criteria
         $criteria = new TCriteria();
         $criteria->add(new TFilter('colaborador_id', '=', $logado->pessoa_codigo));
         // default order
         if (empty($param['order'])) {
             $param['order'] = 'data_ponto';
             $param['direction'] = 'desc';
         }
         $criteria->setProperties($param);
         // order, offset
         $criteria->setProperty('limit', $limit);
         if (TSession::getValue('Ponto_filter')) {
             // add the filter stored in the session to the criteria
             $criteria->add(TSession::getValue('Ponto_filter'));
         }
         // load the objects according to criteria
         $objects = $repository->load($criteria, FALSE);
         $this->datagrid->clear();
         if ($objects) {
             // iterate the collection of active records
             foreach ($objects as $object) {
                 // add the object inside the datagrid
                 $object->data_ponto ? $object->data_ponto = $this->string->formatDateBR($object->data_ponto) : null;
                 $this->datagrid->addItem($object);
             }
         }
         // reset the criteria for record count
         $criteria->resetProperties();
         $count = $repository->count($criteria);
         $this->pageNavigation->setCount($count);
         // count of records
         $this->pageNavigation->setProperties($param);
         // order, page
         $this->pageNavigation->setLimit($limit);
         // limit
         // close the transaction
         TTransaction::close();
         $this->loaded = true;
     } catch (Exception $e) {
         new TMessage('error', '<b>Error</b> ' . $e->getMessage());
         // shows the exception error message
         TTransaction::rollback();
         // undo all pending operations
     }
 }