/** * 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 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(); } }
/** * 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); }
/** * 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); }
/** * Get the last loan (not arrived) from a barcode */ public static function getFromBarcode($barcode) { $rep = new TRepository('Loan'); $criteria = new TCriteria(); $criteria->add(new TFilter('barcode', '=', $barcode)); $criteria->add(new TFilter('arrive_date', 'is', NULL)); $objects = $rep->load($criteria); if ($objects) { $loan = $objects[0]; return $loan; } }
public static function listBetween($from, $to) { TTransaction::open('samples'); $response = array(); $criteria = new TCriteria(); $criteria->add(new TFilter('id', '>', $from)); $criteria->add(new TFilter('id', '<', $to)); $all = Customer::getObjects($criteria); foreach ($all as $customer) { $response[] = $customer->toArray(); } TTransaction::close(); return $response; }
public function __construct() { parent::__construct(); try { TTransaction::open('samples'); $criteria = new TCriteria(); $criteria->add(new TFilter('address', 'like', 'Rua Porto%')); $criteria->add(new TFilter('gender', '=', 'M')); $repository = new TRepository('Customer'); $repository->delete($criteria); new TMessage('info', 'Records Deleted'); TTransaction::close(); } catch (Exception $e) { new TMessage('error', $e->getMessage()); } }
public static function listForCategory($category_id) { $criteria = new TCriteria(); $criteria->add(new TFilter('category_id', '=', $category_id)); $repos = new TRepository('Post'); return $repos->load($criteria); }
public function removeListOfMaterialPermanente() { $criteria = new TCriteria(); $criteria->add(new TFilter('tipo_material_permanente_id', '=', $this->id)); $repository = new TRepository('MaterialPermanente'); return $repository->delete($criteria); }
public function __construct() { parent::__construct(); try { TTransaction::open('samples'); $criteria = new TCriteria(); $criteria->add(new TFilter('name', 'like', 'Rafael%'), TExpression::OR_OPERATOR); $criteria->add(new TFilter('name', 'like', 'Ana%'), TExpression::OR_OPERATOR); $repository = new TRepository('Customer'); $count = $repository->count($criteria); new TMessage('info', "Total of found customers: {$count} <br>\n"); TTransaction::close(); } catch (Exception $e) { new TMessage('error', $e->getMessage()); } }
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()); } }
public function __construct() { parent::__construct(); try { TTransaction::open('samples'); $criteria = new TCriteria(); $criteria->add(new TFilter('gender', '=', 'M')); $criteria->add(new TFilter('name', 'like', 'A%')); $customers = Customer::getObjects($criteria); foreach ($customers as $customer) { echo $customer->id . ' - ' . $customer->name . '<br>'; } TTransaction::close(); } catch (Exception $e) { new TMessage('error', $e->getMessage()); } }
/** * Action to be executed when the user changes the gender or status * @param $param Action parameters */ public static function onGenderChange($param) { TTransaction::open('samples'); $repo = new TRepository('Customer'); $criteria = new TCriteria(); $criteria->add(new TFilter('gender', 'IN', isset($param['check_gender']) ? $param['check_gender'] : array())); if ($param['combo_status']) { $criteria->add(new TFilter('status', '=', $param['combo_status'])); } $customers = $repo->load($criteria); TTransaction::close(); $options = array(); foreach ($customers as $customer) { $options[$customer->id] = $customer->name; } TCombo::reload('form_dynamic_filter', 'customers', $options); }
public function delete($id = NULL) { $id = isset($id) ? $id : $this->{'id'}; $criteria = new TCriteria(); $criteria->add(new TFilter('project_id', '=', $id)); $repository = new TRepository('Backlog'); $repository->delete($criteria); parent::delete($id); }
/** * Delete an Active Record object from the database * @param [$id] The Object ID * @exception Exception if there's no active transaction opened */ public function delete($id = NULL) { $id = isset($id) ? $id : $this->{'id'}; $note_rep = new TRepository('Note'); $criteria = new TCriteria(); $criteria->add(new TFilter('id_issue', '=', $id)); $note_rep->delete($criteria); // delete the object itself parent::delete($id); }
public function delete($id = NULL) { $id = isset($id) ? $id : $this->logra_id; $repository = new TRepository('LogradouroBairro'); $criteria = new TCriteria(); $criteria->add(new TFilter('tb_logradouros_logra_id', '=', $id)); $repository->delete($criteria); // delete the object itself parent::delete($id); }
public function __construct() { parent::__construct(); try { TTransaction::open('samples'); // abre uma transação TTransaction::setLogger(new TLoggerTXT('/tmp/log3.txt')); $criteria = new TCriteria(); $criteria->add(new TFilter('address', 'like', 'Rua Porto%')); $criteria->add(new TFilter('gender', '=', 'M')); $repository = new TRepository('Customer'); $repository->delete($criteria); new TMessage('info', 'Registros excluídos'); TTransaction::close(); // fecha a transação. } catch (Exception $e) { new TMessage('error', $e->getMessage()); } }
/** * Retorna uma instância de usuário a partir do login * @param $login Login do usuário */ public static function newFromLogin($login) { $repos = new TRepository('User'); $criteria = new TCriteria(); $criteria->add(new TFilter('login', '=', $login)); $objects = $repos->load($criteria); if (isset($objects[0])) { return $objects[0]; } }
/** * Returns the Item from its barcode */ public static function newFromBarcode($barcode) { $rep = new TRepository('Item'); $criteria = new TCriteria(); $criteria->add(new TFilter('barcode', '=', $barcode)); $objects = $rep->load($criteria); if ($objects) { $item = $objects[0]; return $item; } }
public static function logar($user, $senha) { try { TTransaction::open('sample'); $criteria = new TCriteria(); $criteria->add(new TFilter('login', '=', $user)); $criteria->add(new TFilter('senha', '=', md5($senha))); $login = parent::getObjects($criteria); if ($login) { return $login; } else { new TMessage('info', 'Usuario ou Senha invalidos', null, 'Erro ao l\\ ogar'); AdiantiCoreApplication::loadPage('Home'); } TTransaction::close(); } catch (Exception $e) { new TMessage('error', $e->getMessage(), null, 'Erro ao logar'); } }
/** * Delete the object and its aggregates * @param $id object ID */ public function delete($id = NULL) { // delete the related System_groupSystem_program objects $id = isset($id) ? $id : $this->id; $repository = new TRepository('SystemGroupProgram'); $criteria = new TCriteria(); $criteria->add(new TFilter('system_group_id', '=', $id)); $repository->delete($criteria); // delete the object itself parent::delete($id); }
function get_inscricoes() { // cria um critério de seleção $criteria = new TCriteria(); // filtra por codigo do aluno $criteria->add(new TFilter('ref_aluno', '=', $this->id)); // instancia repositório de Inscrições $repository = new TRepository('Inscricao'); // retorna todas inscrições que satisfazem o critério return $repository->load($criteria); }
/** * Delete the object and its aggregates * @param $id object ID */ public function delete($id = NULL) { // delete the related System_userSystem_user_group objects $id = isset($id) ? $id : $this->id; $repository = new TRepository('SystemStock'); $criteria = new TCriteria(); $criteria->add(new TFilter('id', '=', $id)); $repository->delete($criteria); // delete the object itself parent::delete($id); }
public function get_itens() { // instancia um repositório de Item $repositorio = new TRepository('Item'); // define o critério de seleção $criterio = new TCriteria(); $criterio->add(new TFilter('id_venda', '=', $this->id)); // carrega a coleção de itens $this->itens = $repositorio->load($criterio); // retorna os itens return $this->itens; }
public function delete($id = NULL) { //sobrescrito! $id = isset($id) ? $id : $this->id; $repository = new TRepository('TurmaDisciplina'); $criteria = new TCriteria(); $criteria->add(new TFilter('turma_id', '=', $id)); $repository->delete($criteria); $repository = new TRepository('AlunoTurma'); $repository->delete($criteria); parent::delete($id); }
public static function logar($user, $senha) { try { TTransaction::open('sample'); $criteria = new TCriteria(); $filter = new TFilter('login', '=', $user); $filter2 = new TFilter('senha', '=', $senha); $criteria->add($filter); $criteria->add($filter2); $user = Usuario::getObjects($criteria); if ($user) { TSession::setValue('logado', true); // cria a sessão para mostrar que o usuario esta no sistema TCoreApplication::executeMethod('CategoriaList'); } else { new TMessage('error', 'Usuario ou Senha invalidos'); } TTransaction::close(); } catch (Exception $e) { echo $e->getMessage(); } }
/** * 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); }
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; }
public function __construct() { parent::__construct(); try { TTransaction::open('samples'); $criteria = new TCriteria(); $criteria->add(new TFilter('gender', '=', 'F')); $repository = new TRepository('Customer'); $customers = $repository->load($criteria); foreach ($customers as $customer) { echo $customer->id . ' - ' . $customer->name . '<br>'; } TTransaction::close(); } catch (Exception $e) { new TMessage('error', $e->getMessage()); } }
public function __construct() { parent::__construct(); try { TTransaction::open('samples'); $criteria = new TCriteria(); $criteria->add(new TFilter('city_id', '=', '4')); $repository = new TRepository('Customer'); $customers = $repository->load($criteria); foreach ($customers as $customer) { $customer->phone = '84 ' . substr($customer->phone, 3); $customer->store(); } new TMessage('info', 'Records updated'); TTransaction::close(); } catch (Exception $e) { new TMessage('error', $e->getMessage()); } }