コード例 #1
0
ファイル: Issue.class.php プロジェクト: jfrank1500/curso_php
 /**
  * Return the issue notes
  */
 public function get_notes()
 {
     $repos = new TRepository('Note');
     $criteria = new TCriteria();
     $criteria->add(new TFilter('id_issue', '=', $this->id));
     return $repos->load($criteria);
 }
コード例 #2
0
ファイル: Post.class.php プロジェクト: jfrank1500/curso_php
 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);
 }
コード例 #3
0
 /**
  * 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();
     }
 }
コード例 #4
0
 public function get_listOfMaterialConsumo()
 {
     $criteria = new TCriteria();
     $criteria->add(new TFilter('tipo_material_consumo_id', '=', $this->id));
     $repository = new TRepository('MaterialConsumo');
     return $repository->load($criteria);
 }
コード例 #5
0
 public function get_listOfMaterialPermanente()
 {
     $criteria = new TCriteria();
     $criteria->add(new TFilter('tipo_material_permanente_id', '=', $this->id));
     $repository = new TRepository('MaterialPermanente');
     return $repository->load($criteria);
 }
コード例 #6
0
 function onReload($param = NULL)
 {
     $offset = $param['offset'];
     //$order   = $param['order'];
     $limit = 10;
     // inicia transação com o banco 'pg_livro'
     TTransaction::open('pg_livro');
     // instancia um repositório para Alunos
     $repository = new TRepository('Pessoa');
     // retorna todos objetos que satisfazem o critério
     $criteria = new TCriteria();
     $count = $repository->count($criteria);
     $criteria->setProperty('limit', $limit);
     $criteria->setProperty('offset', $offset);
     $pessoas = $repository->load($criteria);
     $this->navbar->setPageSize($limit);
     $this->navbar->setCurrentPage($param['page']);
     $this->navbar->setTotalRecords($count);
     $this->datagrid->clear();
     if ($pessoas) {
         foreach ($pessoas as $pessoa) {
             // adiciona o objeto na DataGrid
             $this->datagrid->addItem($pessoa);
         }
     }
     // finaliza a transação
     TTransaction::close();
     $this->loaded = true;
 }
コード例 #7
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();
 }
コード例 #8
0
ファイル: Composition.php プロジェクト: jfrank1500/curso_php
 /**
  * Load the object and its aggregates
  * @param $id object ID
  */
 public function load($id)
 {
     // load the related Contact objects
     $repository = new TRepository('Contact');
     $criteria = new TCriteria();
     $criteria->add(new TFilter('customer_id', '=', $id));
     $this->contacts = $repository->load($criteria);
     // load the object itself
     return parent::load($id);
 }
コード例 #9
0
ファイル: User.class.php プロジェクト: jhonleandres/crmbf
 /**
  * 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];
     }
 }
コード例 #10
0
ファイル: Item.class.php プロジェクト: jhonleandres/crmbf
 /**
  * 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;
     }
 }
コード例 #11
0
 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);
 }
コード例 #12
0
 public function getTicketsSolicitante($solicitante_id)
 {
     $criteria = new TCriteria();
     $criteria->add(new TFilter('solicitante_id', '=', $solicitante_id));
     $repository = new TRepository('Ticket');
     $tickets = $repository->load($criteria);
     $retorno[] = '0';
     foreach ($tickets as $row) {
         $retorno[] = $row->id;
     }
     return $retorno;
 }
コード例 #13
0
ファイル: Loan.class.php プロジェクト: jhonleandres/crmbf
 /**
  * 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;
     }
 }
コード例 #14
0
ファイル: Event.class.php プロジェクト: jfrank1500/curso_php
 /**
  * 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);
 }
コード例 #15
0
 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;
 }
コード例 #16
0
ファイル: Imovel.class.php プロジェクト: eduardojsouza/liger
 public function load($id)
 {
     $repository = new TRepository('ImovelProprietarios');
     $criteria = new TCriteria();
     $criteria->add(new TFilter('tb_imovel_imovel_id', '=', $id));
     $imovelproprietario = $repository->load($criteria);
     if ($imovelproprietario) {
         foreach ($imovelproprietario as $imovelproprietarios) {
             $proprietario = new Contribuinte($imovelproprietarios->tb_contribuinte_contribuinte_id);
             $this->addProprietario($proprietario);
         }
     }
     return parent::load($id);
 }
コード例 #17
0
 public function load($id)
 {
     $repository = new TRepository('LogradouroBairro');
     $criteria = new TCriteria();
     $criteria->add(new TFilter('tb_logradouros_logra_id', '=', $id));
     $logradourobairro = $repository->load($criteria);
     if ($logradourobairro) {
         foreach ($logradourobairro as $logradourobairros) {
             $bairro = new Bairro($logradourobairros->tb_bairros_bairros_id);
             $this->addBairro($bairro);
         }
     }
     // load the object itself
     return parent::load($id);
 }
コード例 #18
0
 /**
  * Method getSystem_programs
  * Return the System_group' System_program's
  * @return Collection of System_program
  */
 public function getSystemPrograms()
 {
     $system_programs = array();
     // load the related System_program objects
     $repository = new TRepository('SystemGroupProgram');
     $criteria = new TCriteria();
     $criteria->add(new TFilter('system_group_id', '=', $this->id));
     $system_group_system_programs = $repository->load($criteria);
     if ($system_group_system_programs) {
         foreach ($system_group_system_programs as $system_group_system_program) {
             $system_programs[] = new SystemProgram($system_group_system_program->system_program_id);
         }
     }
     return $system_programs;
 }
コード例 #19
0
ファイル: Aggregation.php プロジェクト: jfrank1500/curso_php
 /**
  * Load the object and its aggregates
  * @param $id object ID
  */
 public function load($id)
 {
     // load the related Skill objects
     $repository = new TRepository('CustomerSkill');
     $criteria = new TCriteria();
     $criteria->add(new TFilter('customer_id', '=', $id));
     $customer_skills = $repository->load($criteria);
     if ($customer_skills) {
         foreach ($customer_skills as $customer_skill) {
             $skill = new Skill($customer_skill->skill_id);
             $this->addSkill($skill);
         }
     }
     // load the object itself
     return parent::load($id);
 }
コード例 #20
0
 /**
  * Load the object and its aggregates
  * @param $id object ID
  */
 public function load($id)
 {
     // load the related System_program objects
     $repository = new TRepository('SystemGroupProgram');
     $criteria = new TCriteria();
     $criteria->add(new TFilter('system_group_id', '=', $id));
     $system_group_system_programs = $repository->load($criteria);
     if ($system_group_system_programs) {
         foreach ($system_group_system_programs as $system_group_system_program) {
             $system_program = new SystemProgram($system_group_system_program->system_program_id);
             $this->addSystemProgram($system_program);
         }
     }
     // load the object itself
     return parent::load($id);
 }
コード例 #21
0
 /**
  * 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);
 }
コード例 #22
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  $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();
 }
コード例 #23
0
 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());
     }
 }
コード例 #24
0
 /**
  * method onGenerate()
  * Executed whenever the user clicks at the generate button
  */
 function onGenerate()
 {
     try {
         // open a transaction with database 'samples'
         TTransaction::open('samples');
         // load all customers
         $repository = new TRepository('Customer');
         $criteria = new TCriteria();
         $customers = $repository->load($criteria);
         $data = $this->form->getData();
         $this->form->validate();
         $designer = new TPDFDesigner();
         $designer->fromXml('app/reports/report.pdf.xml');
         $designer->generate();
         $fill = TRUE;
         $designer->gotoAnchorXY('details');
         $designer->SetFont('Arial', '', 10);
         $designer->setFillColorRGB('#F9F9FF');
         if ($customers) {
             foreach ($customers as $customer) {
                 $designer->gotoAnchorX('details');
                 $designer->Cell(34, 12, $customer->id, 1, 0, 'C', $fill);
                 $designer->Cell(160, 12, utf8_decode($customer->name), 1, 0, 'L', $fill);
                 $designer->Cell(152, 12, utf8_decode($customer->address), 1, 0, 'L', $fill);
                 $designer->Cell(152, 12, utf8_decode($customer->city_name), 1, 0, 'L', $fill);
                 $designer->Ln(12);
                 // grid background
                 $fill = !$fill;
             }
         }
         $file = 'app/output/pdf_report.pdf';
         if (!file_exists($file) or is_writable($file)) {
             $designer->save($file);
             parent::openFile($file);
         } else {
             throw new Exception(_t('Permission denied') . ': ' . $file);
         }
         new TMessage('info', 'Report generated. Please, enable popups in the browser (just in the web).');
         // close the transaction
         TTransaction::close();
     } catch (Exception $e) {
         new TMessage('error', '<b>Error</b> ' . $e->getMessage());
         TTransaction::rollback();
     }
 }
コード例 #25
0
 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());
     }
 }
コード例 #26
0
ファイル: PTimer.php プロジェクト: jhonleandres/pecommerce
 public function start()
 {
     $this->status = true;
     while ($this->status) {
         try {
             TTransaction::open($this->banco);
             $repo = new TRepository($this->model);
             $this->obj = $repo->load($this->criteria);
             TTransaction::close();
             if ($this->obj) {
                 return $this->obj;
                 $this->status = false;
             }
         } catch (Exception $e) {
             throw new Exception();
         }
         sleep($this->timer);
     }
 }
コード例 #27
0
 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());
     }
 }
コード例 #28
0
 /**
  * Return members by project
  */
 public function getMembers($roles = NULL)
 {
     $members = array();
     $repos = new TRepository('Member');
     $criteria = new TCriteria();
     $criteria->add(new TFilter('active', '=', 'Y'));
     $objects = $repos->load($criteria);
     if ($objects) {
         foreach ($objects as $object) {
             if ($object->getProjects()) {
                 // IF no role is specified OR the ROLE is within $roles
                 if (is_null($roles) or is_array($roles) and in_array($object->role_mnemonic, $roles)) {
                     $member_projects_ids = array_keys($object->getProjectsList());
                     if (in_array($this->id, $member_projects_ids)) {
                         $members[] = $object;
                     }
                 }
             }
         }
     }
     return $members;
 }
コード例 #29
0
 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;
 }
コード例 #30
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();
 }