/** * 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(); } }
/** * method onReload() * Load the datagrid with the database objects */ function onReload($param = NULL) { try { // open a transaction with database 'atividade' TTransaction::open('atividade'); // creates a repository for StatusTicket $repository = new TRepository('StatusTicket'); $limit = 10; // creates a criteria $criteria = new TCriteria(); // default order if (empty($param['order'])) { $param['order'] = 'id'; $param['direction'] = 'asc'; } $criteria->setProperties($param); // order, offset $criteria->setProperty('limit', $limit); if (TSession::getValue('StatusTicket_filter')) { // add the filter stored in the session to the criteria $criteria->add(TSession::getValue('StatusTicket_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 $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 } }
/** * 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 'atividade' TTransaction::open('atividade'); // creates a repository for RequisitoDesenvolvimento $repository = new TRepository('RequisitoDesenvolvimento'); $limit = 10; // creates a criteria $criteria = new TCriteria(); $newparam = $param; // define new parameters if (isset($newparam['order']) and $newparam['order'] == 'ticket->titulo') { $newparam['order'] = '(select titulo from ticket where ticket_id = id)'; } // default order if (empty($newparam['order'])) { $newparam['order'] = 'id'; $newparam['direction'] = 'desc'; } $criteria->setProperties($newparam); // order, offset $criteria->setProperty('limit', $limit); if (TSession::getValue('RequisitoDesenvolvimentoList_filter_id')) { $criteria->add(TSession::getValue('RequisitoDesenvolvimentoList_filter_id')); // add the session filter } if (TSession::getValue('RequisitoDesenvolvimentoList_filter_titulo')) { $criteria->add(TSession::getValue('RequisitoDesenvolvimentoList_filter_titulo')); // add the session filter } if (TSession::getValue('RequisitoDesenvolvimentoList_filter_data_cadastro')) { $criteria->add(TSession::getValue('RequisitoDesenvolvimentoList_filter_data_cadastro')); // add the session 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 $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 'saciq' TTransaction::open('saciq'); // creates a repository for Fornecedor $repository = new TRepository('Fornecedor'); $limit = 10; // creates a criteria $criteria = new TCriteria(); // default order if (empty($param['order'])) { $param['order'] = 'id'; $param['direction'] = 'asc'; } $criteria->setProperties($param); // order, offset $criteria->setProperty('limit', $limit); if (TSession::getValue('FornecedorList_filter_nome')) { $criteria->add(TSession::getValue('FornecedorList_filter_nome')); // add the session filter } if (TSession::getValue('FornecedorList_filter_cnpj')) { $criteria->add(TSession::getValue('FornecedorList_filter_cnpj')); // add the session 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 $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) { if ($e->getCode() == 23000) { new TMessage('error', '<b>Registro duplicado</b><br>Verifique os campos inseridos e tente novamente'); } else { if ($e->getCode() == 0) { new TMessage('error', '<b>Error</b> <br>' . $e->getMessage()); } else { new TMessage('error', '<b>Error Desconhecido</b> <br>Código: ' . $e->getCode()); } } // desfazer todas as operacoes pendentes TTransaction::rollback(); } }
/** * 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(); } }
/** * Load the datagrid with the active record objects */ public function onReload($param = NULL) { try { $model = TSession::getValue('standard_seek_model'); $database = TSession::getValue('standard_seek_database'); // begins the transaction with database TTransaction::open($database); // creates a repository for the model $repository = new TRepository($model); $limit = 10; // creates a criteria $criteria = new TCriteria(); $criteria->setProperties($param); // order, offset $criteria->setProperty('limit', $limit); if (TSession::getValue('tstandardseek_filter')) { // add the filter to the criteria $criteria->add(TSession::getValue('tstandardseek_filter')); } // load all objects according with the criteria $clientes = $repository->load($criteria); $this->datagrid->clear(); if ($clientes) { $display_field = TSession::getValue('standard_seek_display_field'); foreach ($clientes as $cliente) { $item = $cliente; $item->display_field = $cliente->{$display_field}; // add the object into the datagrid $this->datagrid->addItem($item); } } // clear the crieteria to count the records $criteria->resetProperties(); $count = $repository->count($criteria); $this->pageNavigation->setCount($count); // count of records $this->pageNavigation->setProperties($param); // order, page $this->pageNavigation->setLimit($limit); // limit // closes the transaction TTransaction::close(); $this->loaded = true; } catch (Exception $e) { // shows the exception genearated message new TMessage('error', '<b>Erro</b> ' . $e->getMessage()); // rollback all the database operations TTransaction::rollback(); } }
/** * method onReload() * Load the datagrid with the database objects */ function onReload($param = NULL) { try { // open a transaction with database 'changeman' TTransaction::open('changeman'); $member = Member::newFromLogin(TSession::getValue('login')); // creates a repository for Release $repository = new TRepository('Release'); $limit = 10; // creates a criteria $criteria = new TCriteria(); $criteria->setProperties($param); // order, offset $criteria->setProperty('limit', $limit); if (TSession::getValue('Release_filter')) { // add the filter stored in the session to the criteria $criteria->add(TSession::getValue('Release_filter')); } // customer may only view its projects if ($member->role_mnemonic == 'CUSTOMER') { $member_projects_ids = array_keys($member->getProjectsList()); $criteria->add(new TFilter('id_project', 'IN', $member_projects_ids)); } // 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(); } }
/** * Load the datagrid with data */ public function onReload($param = NULL) { try { // open a transaction with database 'sample' TTransaction::open('sample'); // creates a repository for telefone $repository = new TRepository('telefone'); $limit = 10; // creates a criteria $criteria = new TCriteria(); $filter = new TFilter('clientes_id', '=', $param['key']); $criteria->add($filter); // default order if (empty($param['order'])) { $param['order'] = 'id'; $param['direction'] = 'asc'; } $criteria->setProperties($param); // order, offset $criteria->setProperty('limit', $limit); // load the objects according to criteria $objects = $repository->load($criteria, FALSE); if (is_callable($this->transformCallback)) { call_user_func($this->transformCallback, $objects, $param); } $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', $e->getMessage()); // undo all pending operations TTransaction::rollback(); } }
/** * method onEdit() * Executed whenever the user clicks at the edit button da datagrid */ function onEdit($param) { $string = new StringsUtil(); try { TTransaction::open('atividade'); // open a transaction $logado = Pessoa::retornaUsuario(); if (isset($param['key'])) { $key = $param['key']; // get the parameter $key $atividade = new Atividade($key); $criteria = new TCriteria(); $newparam['order'] = 'id'; $newparam['direction'] = 'asc'; $criteria->setProperties($newparam); // order, offset $this->onComboTicket($criteria); $this->onSetarValoresCombo($atividade->ticket_id); // criar metodo de preenchimento de horas $HoraEntrada = new DateTime($atividade->hora_inicio); $HoraSaida = new DateTime($atividade->hora_fim); $diffHoras = $HoraSaida->diff($HoraEntrada)->format('%H:%I:%S'); $horas = explode(':', $atividade->hora_fim); $atividade->qtde_horas = $horas[0]; $atividade->qtde_minutos = $horas[1]; TCombo::disableField('form_Atividade', 'qtde_horas'); TCombo::disableField('form_Atividade', 'qtde_minutos'); $atividade->tempo_atividade = $diffHoras; $ultimaAtividade = Atividade::retornaUltimaAtividade($atividade->colaborador_id); if (!$ultimaAtividade) { $action = new TAction(array('AtividadeList', 'onReload')); new TMessage('info', 'Nenhuma atividade cadastrada!', $action); // success message } if ($key != $ultimaAtividade) { TButton::disableField('form_Atividade', 'delete'); } $atividade->data_atividade ? $atividade->data_atividade = $string->formatDateBR($atividade->data_atividade) : null; $colaborador = new Pessoa($atividade->colaborador_id); $atividade->colaborador_nome = $colaborador->pessoa_nome; if ($logado->pessoa_codigo != $atividade->colaborador_id) { TButton::disableField('form_Atividade', 'save'); TButton::disableField('form_Atividade', 'delete'); } TButton::disableField('form_Atividade', 'atividade'); $this->form->setData($atividade); // fill the form } else { $object = new Atividade(); $object->colaborador_id = $logado->pessoa_codigo; $object->colaborador_nome = $logado->pessoa_nome; $this->form->setData($object); } TTransaction::close(); // close the transaction } catch (Exception $e) { new TMessage('error', '<b>Error</b> ' . $e->getMessage()); // shows the exception error message TTransaction::rollback(); // undo all pending operations } }
/** * method onReload() * Load the datagrid with the database objects */ function onReload($param = NULL) { try { // open a transaction with database 'permission' TTransaction::open('permission'); if (!isset($param['order'])) { $param['order'] = 'id'; $param['direction'] = 'asc'; } // creates a repository for System_group $repository = new TRepository('SystemEmployees'); $limit = 10; // creates a criteria $criteria = new TCriteria(); $criteria->setProperties($param); // order, offset $criteria->setProperty('limit', $limit); if (TSession::getValue('s_id_filter')) { // add the filter stored in the session to the criteria $criteria->add(TSession::getValue('s_id_filter')); } if (TSession::getValue('s_dni_filter')) { // add the filter stored in the session to the criteria $criteria->add(TSession::getValue('s_dni_filter')); } if (TSession::getValue('s_name_filter')) { // add the filter stored in the session to the criteria $criteria->add(TSession::getValue('s_name_filter')); } if (TSession::getValue('s_address_filter')) { // add the filter stored in the session to the criteria $criteria->add(TSession::getValue('s_address_filter')); } if (TSession::getValue('s_email_filter')) { // add the filter stored in the session to the criteria $criteria->add(TSession::getValue('s_email_filter')); } if (TSession::getValue('s_phone_filter')) { // add the filter stored in the session to the criteria $criteria->add(TSession::getValue('s_phone_filter')); } // 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 Product $repository = new TRepository('Product'); $limit = 10; // creates a criteria $criteria = new TCriteria(); $criteria->setProperties($param); // order, offset $criteria->setProperty('limit', $limit); $criteria->setProperty('order', 'description'); if (TSession::getValue('product_filter1')) { // add the filter stored in the session to the criteria $criteria->add(TSession::getValue('product_filter1')); } // load the objects according to criteria $products = $repository->load($criteria); $this->datagrid->clear(); if ($products) { foreach ($products as $product) { // add the object inside the datagrid $this->datagrid->addItem($product); } } $this->cartgrid->clear(); $cart_objects = TSession::getValue('cart_objects'); $total = 0; if ($cart_objects) { foreach ($cart_objects as $object) { $this->cartgrid->addItem($object); $total += $object->sale_price; } } $this->total->setValue(number_format($total)); // 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 'atividade' TTransaction::open('atividade'); // creates a repository for Atividade $repository = new TRepository('Atividade'); $limit = 15; // creates a criteria $criteria = new TCriteria(); $criHoras = new TCriteria(); $criteria2 = new TCriteria(); $criHoras2 = new TCriteria(); $calculaHoras = null; $pesquisaNormal = null; $newparam = $param; // define new parameters if (isset($newparam['order']) and $newparam['order'] == 'ticket->titulo') { $newparam['order'] = '(select titulo from ticket where ticket_id = id)'; } if (isset($newparam['order']) and $newparam['order'] == 'pessoa->pessoa_nome') { $newparam['order'] = '(select pessoa_nome from tbz_pessoas where pessoa_codigo = colaborador_id)'; } if (isset($newparam['order']) and $newparam['order'] == 'tipo_atividade->nome') { $newparam['order'] = '(select nome from tipo_atividade where tipo_atividade_id = id)'; } if (isset($newparam['order']) and $newparam['order'] == 'sistema->nome') { $newparam['order'] = '(select nome from sistema where sistema_id = id)'; } // default order if (empty($newparam['order'])) { $newparam['order'] = 'data_atividade desc, id '; $newparam['direction'] = 'desc'; } $criteria->setProperties($newparam); // order, offset $criteria->setProperty('limit', $limit); if (TSession::getValue('AtividadeList_filter_id')) { $criteria->add(TSession::getValue('AtividadeList_filter_id')); // add the session filter $criHoras->add(TSession::getValue('AtividadeList_filter_id')); // add the session filter $calculaHoras = true; $pesquisaNormal = true; } if (TSession::getValue('AtividadeList_filter_data_atividade_inicial')) { $criteria->add(TSession::getValue('AtividadeList_filter_data_atividade_inicial')); // add the session filter $criHoras->add(TSession::getValue('AtividadeList_filter_data_atividade_inicial')); // add the session filter $calculaHoras = true; $pesquisaNormal = true; } if (TSession::getValue('AtividadeList_filter_data_atividade_final')) { $criteria->add(TSession::getValue('AtividadeList_filter_data_atividade_final')); // add the session filter $criHoras->add(TSession::getValue('AtividadeList_filter_data_atividade_final')); // add the session filter $calculaHoras = true; $pesquisaNormal = true; } if (TSession::getValue('AtividadeList_filter_solicitante_id')) { $criteria->add(TSession::getValue('AtividadeList_filter_solicitante_id')); // add the session filter $criHoras->add(TSession::getValue('AtividadeList_filter_solicitante_id')); // add the session filter $calculaHoras = true; $pesquisaNormal = true; } if (TSession::getValue('AtividadeList_filter_colaborador_id')) { $criteria->add(TSession::getValue('AtividadeList_filter_colaborador_id')); // add the session filter $criHoras->add(TSession::getValue('AtividadeList_filter_colaborador_id')); // add the session filter $calculaHoras = true; $pesquisaNormal = true; } if (TSession::getValue('AtividadeList_filter_tipo_atividade_id')) { $criteria->add(TSession::getValue('AtividadeList_filter_tipo_atividade_id')); // add the session filter $criHoras->add(TSession::getValue('AtividadeList_filter_tipo_atividade_id')); // add the session filter $calculaHoras = true; $pesquisaNormal = true; } if (TSession::getValue('AtividadeList_filter_ticket_id')) { $criteria->add(TSession::getValue('AtividadeList_filter_ticket_id')); // add the session filter $criHoras->add(TSession::getValue('AtividadeList_filter_ticket_id')); // add the session filter $calculaHoras = true; $pesquisaNormal = true; } if (TSession::getValue('AtividadeList_filter_pesquisa_master')) { try { TTransaction::open('atividade'); $pesquisa_master = TSession::getValue('AtividadeList_filter_pesquisa_master'); $repo = new TRepository('Ticket'); $tickets = $repo->where('titulo', 'ilike', "%{$pesquisa_master}%")->load(); $clausula[] = '0'; foreach ($tickets as $ticket) { $clausula[] = $ticket->id; } TTransaction::close(); } catch (Exception $e) { new TMessage('error', $e->getMessage()); } $criteria2->add(new TFilter('ticket_id', 'IN', $clausula), TExpression::OR_OPERATOR); $criteria2->add(new TFilter('descricao', 'ilike', "%{$pesquisa_master}%"), TExpression::OR_OPERATOR); $criHoras2->add(new TFilter('ticket_id', 'IN', $clausula), TExpression::OR_OPERATOR); $criHoras2->add(new TFilter('descricao', 'ilike', "%{$pesquisa_master}%"), TExpression::OR_OPERATOR); $calculaHoras = true; } if (TSession::getValue('AtividadeList_filter_pesquisa_master')) { if (!$pesquisaNormal) { $criteriaFinal = $criteria2; $criteriaHorasFinal = $criHoras2; $criteriaFinal->setProperties($newparam); // order, offset $criteriaFinal->setProperty('limit', $limit); } else { $criteriaFinal = new TCriteria(); $criteriaFinal->add($criteria); $criteriaFinal->add($criteria2); $criteriaFinal->setProperties($newparam); // order, offset $criteriaFinal->setProperty('limit', $limit); $criteriaHorasFinal = new TCriteria(); $criteriaHorasFinal->add($criHoras); $criteriaHorasFinal->add($criHoras2); } } else { $criteriaFinal = $criteria; $criteriaHorasFinal = $criHoras; } if ($calculaHoras) { $repo = new TRepository('Atividade'); $horas = $repo->load($criteriaHorasFinal, FALSE); $totalHoras = null; if ($horas) { foreach ($horas as $hora) { $HoraEntrada = new DateTime($hora->hora_inicio); $HoraSaida = new DateTime($hora->hora_fim); $diferenca = $HoraSaida->diff($HoraEntrada)->format('%H:%I:%S'); $totalHoras += $this->string->time_to_sec($diferenca); } } $this->onTotalAtividades(substr($this->string->sec_to_time($totalHoras), 0, -3)); } // load the objects according to criteria $objects = $repository->load($criteriaFinal, FALSE); $this->datagrid->clear(); try { if ($objects) { // iterate the collection of active records foreach ($objects as $object) { // add the object inside the datagrid $this->datagrid->addItem($object); } } } catch (Exception $e) { new TMessage('error', '<b>Error</b> ' . $e->getMessage()); } // reset the criteria for record count $criteriaFinal->resetProperties(); $count = $repository->count($criteriaFinal); $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(); } }
function onReload($param = NULL) { try { TTransaction::open('liger'); if (!isset($param['order'])) { $param['order'] = 'imovel_id'; $param['direction'] = 'asc'; } $repository = new TRepository('Imovel'); $limit = 10; $criteria = new TCriteria(); $criteria->setProperties($param); // order, offset $criteria->setProperty('limit', $limit); if (TSession::getValue('s_id_filter')) { $criteria->add(TSession::getValue('s_id_filter')); } if (TSession::getValue('s_name_filter')) { $criteria->add(TSession::getValue('s_name_filter')); } $objects = $repository->load($criteria); $this->datagrid->clear(); if ($objects) { foreach ($objects as $object) { $this->datagrid->addItem($object); } } $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(); } }
/** * Class constructor * Creates the page and the registration form */ function __construct() { parent::__construct(); $this->string = new StringsUtil(); // creates the form $this->form = new TForm('form_Atividade_Cliente'); $this->form->class = 'tform'; // CSS class $this->form->style = 'width: 500px'; // creates the table container $table = new TTable(); $table->width = '100%'; // add the table inside the form $this->form->add($table); // define the form title $row = $table->addRow(); $row->class = 'tformtitle'; $cell = $row->addCell(new TLabel('Indicador por Periodo')); $cell->colspan = 2; // create the form fields // cria array para popular as combos TTransaction::open('atividade'); $criteria = new TCriteria(); $criteria->add(new TFilter("origem", "=", 1)); $criteria->add(new TFilter("codigo_cadastro_origem", "=", 100)); $criteria->add(new TFilter("ativo", "=", 1)); $newparam['order'] = 'pessoa_nome'; $newparam['direction'] = 'asc'; $criteria->setProperties($newparam); // order, offset $repo = new TRepository('Pessoa'); $pessoas = $repo->load($criteria); $arrayPessoas[-1] = 'TODOS COLABORADORES'; foreach ($pessoas as $pessoa) { $arrayPessoas[$pessoa->pessoa_codigo] = $pessoa->pessoa_nome; } $criteria = new TCriteria(); $criteria->add(new TFilter("enttipent", "=", "1")); $newparam['order'] = 'entcodent'; $newparam['direction'] = 'asc'; $criteria->setProperties($newparam); // order, offset $repo = new TRepository('Entidade'); $clientes = $repo->load($criteria); $arrayClientes[-1] = 'TODOS CLIENTES'; foreach ($clientes as $cliente) { $arrayClientes[$cliente->entcodent] = str_pad($cliente->entcodent, 4, '0', STR_PAD_LEFT) . ' - ' . $cliente->entrazsoc; } $arrayClientes[999] = 'ECS 999'; TTransaction::close(); $colaborador_id = new TCombo('colaborador_id'); $colaborador_id->setDefaultOption(FALSE); $colaborador_id->addItems($arrayPessoas); $cliente_id = new TCombo('cliente_id'); $cliente_id->setDefaultOption(FALSE); $cliente_id->addItems($arrayClientes); $anos = array(2015 => '2015'); $mes_atividade_inicial = new TCombo('mes_atividade_inicial'); $mes_atividade_inicial->addItems($this->string->array_meses()); $mes_atividade_inicial->setDefaultOption(FALSE); $mes_atividade_inicial->setValue(date('m')); $ano_atividade_inicial = new TCombo('ano_atividade_inicial'); $ano_atividade_inicial->addItems($anos); $ano_atividade_inicial->setDefaultOption(FALSE); $mes_atividade_final = new TCombo('mes_atividade_final'); $mes_atividade_final->addItems($this->string->array_meses()); $mes_atividade_final->setDefaultOption(FALSE); $mes_atividade_final->setValue(date('m')); $ano_atividade_final = new TCombo('ano_atividade_final'); $ano_atividade_final->addItems($anos); $ano_atividade_final->setDefaultOption(FALSE); $output_type = new TRadioGroup('output_type'); // define the sizes $colaborador_id->setSize(353); $cliente_id->setSize(353); $mes_atividade_inicial->setSize(250); $ano_atividade_inicial->setSize(100); $mes_atividade_final->setSize(250); $ano_atividade_final->setSize(100); $output_type->setSize(100); // validations $output_type->addValidation('Output', new TRequiredValidator()); // add one row for each form field $table->addRowSet(new TLabel('Colaborador:'), $colaborador_id); $table->addRowSet(new TLabel('Cliente:'), $cliente_id); $table->addRowSet(new TLabel('Mês ano inicial:'), array($mes_atividade_inicial, $ano_atividade_inicial)); $table->addRowSet(new TLabel('Mês ano final:'), array($mes_atividade_final, $ano_atividade_final)); $table->addRowSet(new TLabel('Output:'), $output_type); $this->form->setFields(array($colaborador_id, $cliente_id, $mes_atividade_inicial, $mes_atividade_final, $ano_atividade_inicial, $ano_atividade_final, $output_type)); $output_type->addItems(array('html' => 'HTML', 'pdf' => 'PDF', 'rtf' => 'RTF')); $output_type->setValue('html'); $output_type->setLayout('horizontal'); $generate_button = TButton::create('generate', array($this, 'onGenerate'), _t('Generate'), 'fa:check-circle-o green'); $this->form->addField($generate_button); // add a row for the form action $table->addRowSet($generate_button, '')->class = 'tformaction'; parent::add($this->form); }
/** * method onReload() * Load the DETAIL datagrid (backlog) */ function onReload($param = NULL) { try { TTransaction::open('samples'); // open a transaction $repository = new TRepository('Backlog'); // creates a repository $limit = 10; // creates a criteria $criteria = new TCriteria(); $criteria->setProperties($param); // order, offset $criteria->setProperty('limit', $limit); // filter the master record $criteria->add(new TFilter('project_id', '=', TSession::getValue('project_id'))); // load the objects according to criteria $objects = $repository->load($criteria); $this->datagrid->clear(); if ($objects) { foreach ($objects as $object) { $this->datagrid->addItem($object); // add the detail inside the datagrid } } // 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()); TTransaction::rollback(); } }
/** * method onReload() * Load the datagrid with the database objects */ function onReload($param = NULL) { try { // open a transaction with database 'atividade' TTransaction::open('atividade'); $criteria = new TCriteria(); $criteria->add(new TFilter("origem", "=", 1)); $criteria->add(new TFilter("codigo_cadastro_origem", "=", 100)); $criteria->add(new TFilter("ativo", "=", 1)); $criteria->add(new TFilter("usuario", "is not ")); $repo = new TRepository('Pessoa'); $count = $repo->count($criteria); // creates a repository for CargaHoraria $repository = new TRepository('CargaHoraria'); $limit = $count; // creates a criteria $criteria = new TCriteria(); !$param['ano'] ? $param['ano'] = date('Y') : ($param['ano'] = $param['ano']); !$param['mes'] ? $param['mes'] = date('m') : ($param['mes'] = $param['mes']); $criteria->add(new TFilter("mes", "=", $param['mes'])); $criteria->add(new TFilter("ano", "=", $param['ano'])); // default order if (empty($param['order'])) { $param['order'] = 'id'; $param['direction'] = 'asc'; } $criteria->setProperties($param); // order, offset $criteria->setProperty('limit', $limit); if (TSession::getValue('CargaHoraria_filter')) { // add the filter stored in the session to the criteria $criteria->add(TSession::getValue('CargaHoraria_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 $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 $obj = new StdClass(); $obj->mes = $param['mes']; $obj->ano = $param['ano']; $this->form->setData($obj); // fill the form with the active record data // 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 } }
/** * method onReload() * Load the datagrid with the database objects */ function onReload($param = NULL) { try { // open a transaction with database TTransaction::open($this->database); // instancia um repositório $repository = new TRepository($this->activeRecord); $limit = isset($this->limit) ? $this->limit : 10; // creates a criteria $criteria = new TCriteria(); $criteria->setProperties($param); // order, offset $criteria->setProperty('limit', $limit); if (TSession::getValue($this->activeRecord . '_filter')) { // add the filter stored in the session to the criteria $criteria->add(TSession::getValue($this->activeRecord . '_filter')); } // 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); if (isset($this->pageNavigation)) { $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(); } }
/** * Load the datagrid with the database objects */ function onReload($param = NULL) { try { // start database transaction TTransaction::open('tecbiz'); // create a repository for City table $repository = new TRepository('Pessoa'); $limit = 10; // creates a criteria // default order if (empty($param['order'])) { $param['order'] = 'pessoa_nome'; $param['direction'] = 'asc'; } $criteria = new TCriteria(); $criteria->setProperties($param); // order, offset $criteria->setProperty('limit', $limit); if (TSession::getValue('test_pessoa_filter')) { // filter by city name $criteria->add(TSession::getValue('test_pessoa_filter')); } // load the objects according to the criteria $pessoas = $repository->load($criteria); $this->datagrid->clear(); if ($pessoas) { foreach ($pessoas as $pessoa) { // add the objects inside the datagrid $this->datagrid->addItem($pessoa); } } // 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(); } }
/** * 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(); } }
/** * method onGenerate() * Executed whenever the user clicks at the generate button */ function onGenerate() { try { // open a transaction with database 'atividade' TTransaction::open('atividade'); // get the form data into an active record $formdata = $this->form->getData(); $dataInicial = date('Y') . '-' . str_pad($formdata->mes_atividade, 2, 0, STR_PAD_LEFT) . '-01'; $dataFinal = date('Y') . '-' . str_pad($formdata->mes_atividade, 2, 0, STR_PAD_LEFT) . '-' . cal_days_in_month(CAL_GREGORIAN, $formdata->mes_atividade, date('Y')); $dias = Atividade::retornaDiasAtividades($dataInicial, $dataFinal); $criteria = new TCriteria(); $criteria->add(new TFilter("origem", "=", 1)); $criteria->add(new TFilter("codigo_cadastro_origem", "=", 100)); $criteria->add(new TFilter("ativo", "=", 1)); $criteria->add(new TFilter("pessoa_codigo", "IN", "(SELECT colaborador_id FROM atividade WHERE data_atividade between '{$dataInicial}' and '{$dataFinal}')")); $newparam['order'] = 'pessoa_nome'; $newparam['direction'] = 'asc'; $criteria->setProperties($newparam); // order, offset $repo = new TRepository('Pessoa'); $pessoas = $repo->load($criteria); $format = $formdata->output_type; if ($dias) { $widths = array(50); switch ($format) { case 'html': $tr = new TTableWriterHTML($widths); $break = '<br />'; break; case 'pdf': $tr = new TTableWriterPDF($widths); $break = ''; break; case 'rtf': if (!class_exists('PHPRtfLite_Autoloader')) { PHPRtfLite::registerAutoloader(); } $tr = new TTableWriterRTF($widths); $break = '<br />'; break; } // create the document styles $tr->addStyle('title', 'Arial', '10', 'B', '#ffffff', '#6B6B6B'); $tr->addStyle('datap', 'Arial', '10', '', '#000000', '#E5E5E5'); $tr->addStyle('datai', 'Arial', '10', '', '#000000', '#ffffff'); $tr->addStyle('totais', 'Arial', '10', '', '#000000', '#C0D3E9'); $tr->addStyle('header', 'Times', '16', 'B', '#4A5590', '#C0D3E9'); $tr->addStyle('footer', 'Times', '12', 'BI', '#4A5590', '#C0D3E9'); // add a header row $tr->addRow(); $tr->addCell(utf8_decode('Indicador de produtividade de: ') . strtoupper($this->string->array_meses()[$formdata->mes_atividade]), 'center', 'header', 33); $tr->addRow(); $tr->addCell('Seq.', 'center', 'title'); $tr->addCell('Nome', 'center', 'title'); foreach ($dias as $dia) { $tr->addCell(substr($dia['dias'], -2), 'center', 'title'); $arrayDias[substr($dia['dias'], -2)] = $dia['dias']; } $tr->addCell('TOTAL', 'center', 'title'); // controls the background filling $colour = FALSE; // data rows $count = 1; foreach ($pessoas as $pessoa) { $style = $colour ? 'datap' : 'datai'; $tr->addRow(); $tr->addCell($count, 'left', $style); $tr->addCell(utf8_decode($pessoa->pessoa_nome), 'left', $style, 33); $tr->addRow(); $tr->addCell('', 'left', $style); $tr->addCell('Ponto', 'left', $style); $totalPonto = null; foreach ($arrayDias as $dia) { $ponto = $this->retornaPonto($pessoa->pessoa_codigo, $dia); $totalPonto += $this->string->time_to_sec($ponto); $tr->addCell(substr($ponto, 0, -3), 'center', $style); $arrayPonto[$dia] += $this->string->time_to_sec($ponto); } $arrayPonto['total'] += $totalPonto; $tr->addCell(substr($this->string->sec_to_time($totalPonto), 0, -3), 'center', $style); $tr->addRow(); $tr->addCell('', 'left', $style); $tr->addCell('Atividades', 'left', $style); $totalAtividades = null; foreach ($arrayDias as $dia) { $horas = Ponto::horaPreenchidas($dia, $pessoa->pessoa_codigo); if (!$horas) { $horas = '00:00:00'; } $x = $this->retornaPonto($pessoa->pessoa_codigo, $dia); if ($this->string->time_to_sec($x) > 0) { $totalAtividades += $this->string->time_to_sec($horas); $arrayAtividades[$dia] += $this->string->time_to_sec($horas); } $tr->addCell(substr($horas, 0, -3), 'center', $style); } $arrayAtividades['total'] += $totalAtividades; $tr->addCell(substr($this->string->sec_to_time($totalAtividades), 0, -3), 'center', $style); $tr->addRow(); $tr->addCell('', 'left', $style); $tr->addCell('Produtividade', 'left', $style); foreach ($arrayDias as $dia) { $campo = $this->calculaPercentualProdutividade($pessoa->pessoa_codigo, $dia); $tr->addCell($campo, 'center', $style); } $tr->addCell($this->calculaPercentualProdutividadeTotalColaborador($totalAtividades, $totalPonto), 'center', $style); $tr->addRow(); $tr->addCell($break, 'left', $style, 33); $count++; $colour = !$colour; } // totais row $tr->addRow(); $tr->addCell($count, 'left', 'totais'); $tr->addCell('TOTAIS', 'left', 'totais', 33); $tr->addRow(); $tr->addCell('', 'left', 'totais'); $tr->addCell('Ponto', 'left', 'totais'); foreach ($arrayDias as $dia) { $tr->addCell(substr($this->string->sec_to_time($arrayPonto[$dia]), 0, -3), 'center', 'totais'); } $tr->addCell(substr($this->string->sec_to_time($arrayPonto['total']), 0, -3), 'center', 'totais'); $tr->addRow(); $tr->addCell('', 'left', 'totais'); $tr->addCell('Atividades', 'left', 'totais'); foreach ($arrayDias as $dia) { $tr->addCell(substr($this->string->sec_to_time($arrayAtividades[$dia]), 0, -3), 'center', 'totais'); } $tr->addCell(substr($this->string->sec_to_time($arrayAtividades['total']), 0, -3), 'center', 'totais'); $tr->addRow(); $tr->addCell('', 'left', 'totais'); $tr->addCell('Produtividade', 'left', 'totais'); foreach ($arrayDias as $dia) { $tr->addCell($this->calculaPercentualProdutividadeTotalColaborador($arrayAtividades[$dia], $arrayPonto[$dia]), 'center', 'totais'); } $tr->addCell($this->calculaPercentualProdutividadeTotalColaborador($arrayAtividades['total'], $arrayPonto['total']), 'center', 'totais'); // footer row $tr->addRow(); $var = rand(0, 1000); $tr->addCell(date('d/m/Y H:i:s'), 'center', 'footer', 33); foreach ($arrayAtividades as $key => $value) { if ($key != 'total') { $yAtividades[substr($key, -2)] = $this->string->sec_to_time($value); $xLabel[substr($key, -2)] = substr($key, -2); } } foreach ($arrayPonto as $key => $value) { if ($key != 'total') { $yPonto[substr($key, -2)] = $this->string->sec_to_time($value); } } ksort($yAtividades); ksort($yPonto); ksort($xLabel); $chart = new TLineChart(new TPChartDesigner()); $chart->setTitle('Totais', NULL, NULL); $chart->setSize(1100, 600); $chart->setXLabels($xLabel); $chart->setYLabel('Horas'); $chart->setOutputPath('app/output/linechart_{$var}.png'); $chart->addData('Atividades', $yAtividades); $chart->addData('Ponto', $yPonto); $chart->generate(); $tr->addRow(); $tr->addCell(new TImage('app/output/linechart_{$var}.png'), 'center', 'datai', 33); // stores the file if (!file_exists("app/output/Ponto_{$var}.{$format}") or is_writable("app/output/Ponto_{$var}.{$format}")) { $tr->save("app/output/Ponto_{$var}.{$format}"); } else { throw new Exception(_t('Permission denied') . ': ' . "app/output/Ponto_{$var}.{$format}"); } // open the report file parent::openFile("app/output/Ponto_{$var}.{$format}"); // shows the success message new TMessage('info', 'Relatorio gerado. Por favor, habilite popups no navegador (somente para web).'); } else { new TMessage('error', 'No records found'); } // fill the form with the active record data $this->form->setData($formdata); // close the transaction TTransaction::close(); } 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(); } }
/** * method onGenerate() * Executed whenever the user clicks at the generate button */ function onGenerate() { try { // open a transaction with database 'atividade' TTransaction::open('atividade'); $string = new StringsUtil(); // get the form data into an active record $formdata = $this->form->getData(); $repository = new TRepository('RegistroLogin'); $criteria = new TCriteria(); if ($formdata->login) { $criteria->add(new TFilter('login', '=', "{$formdata->login}")); } if ($formdata->data_ponto) { $criteria->add(new TFilter('data_ponto', '>=', "{$string->formatDate($formdata->data_ponto)}")); } $newparam['order'] = 'data_ponto'; $newparam['direction'] = 'desc'; $criteria->setProperties($newparam); // order, offset $objects = $repository->load($criteria); $format = $formdata->output_type; if ($objects) { $widths = array(20, 200, 50, 80, 80); switch ($format) { case 'html': $tr = new TTableWriterHTML($widths); break; case 'pdf': $tr = new TTableWriterPDF($widths); break; case 'rtf': if (!class_exists('PHPRtfLite_Autoloader')) { PHPRtfLite::registerAutoloader(); } $tr = new TTableWriterRTF($widths); break; } // create the document styles $tr->addStyle('title', 'Arial', '10', 'B', '#ffffff', '#6B6B6B'); $tr->addStyle('datap', 'Arial', '10', '', '#000000', '#E5E5E5'); $tr->addStyle('datai', 'Arial', '10', '', '#000000', '#ffffff'); $tr->addStyle('header', 'Times', '16', 'B', '#4A5590', '#C0D3E9'); $tr->addStyle('footer', 'Times', '12', 'BI', '#4A5590', '#C0D3E9'); // add a header row $tr->addRow(); $tr->addCell('Registro de acessos ao sistema', 'center', 'header', 5); // add titles row $tr->addRow(); $tr->addCell('Seq.', 'center', 'title'); $tr->addCell('Nome', 'center', 'title'); $tr->addCell('Data', 'center', 'title'); $tr->addCell('Hora inicial', 'center', 'title'); $tr->addCell('Hora final', 'center', 'title'); // controls the background filling $colour = FALSE; $seq = 1; // data rows foreach ($objects as $object) { $style = $colour ? 'datap' : 'datai'; $tr->addRow(); $tr->addCell($seq++, 'right', $style); $tr->addCell($object->name, 'left', $style); $tr->addCell($string->formatDateBR($object->data_ponto), 'center', $style); $tr->addCell($object->hora_inicial, 'center', $style); $tr->addCell($object->hora_final, 'center', $style); $colour = !$colour; } // footer row $tr->addRow(); $tr->addCell(date('d/m/Y h:i:s'), 'center', 'footer', 5); // stores the file if (!file_exists("app/output/RegistroLogin.{$format}") or is_writable("app/output/RegistroLogin.{$format}")) { $tr->save("app/output/RegistroLogin.{$format}"); } else { throw new Exception(_t('Permission denied') . ': ' . "app/output/RegistroLogin.{$format}"); } // open the report file parent::openFile("app/output/RegistroLogin.{$format}"); // shows the success message new TMessage('info', 'Relatorio gerado. Por favor, habilite popups no navegador (somente para web).'); } else { new TMessage('error', 'No records found'); } // fill the form with the active record data $this->form->setData($formdata); // close the transaction TTransaction::close(); } catch (Exception $e) { // shows the exception error message new TMessage('error', '<b>Error</b> ' . $e->getMessage()); // undo all pending operations TTransaction::rollback(); } }
/** * 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(); } }
public static function onChangeOrigem($param) { if ($param['tipo_origens']) { try { TTransaction::open('atividade'); if ($param['tipo_origens'] == 1) { $repo = new TRepository('Entidade'); $criteria = new TCriteria(); $criteria->add(new TFilter('enttipent', '=', 1)); $newparam['order'] = 'entcodent'; $newparam['direction'] = 'asc'; $criteria->setProperties($newparam); // order, offset $entidades = $repo->load($criteria); $options[] = '--Selecione--'; foreach ($entidades as $etd) { $options[$etd->entcodent . $selecao] = str_pad($etd->entcodent, 4, "0", STR_PAD_LEFT) . ' - ' . $etd->entnomfan; } } if ($param['tipo_origens'] == 2) { $repo = new TRepository('Estabelecimento'); $criteria = new TCriteria(); $newparam['order'] = 'lojcodloj'; $newparam['direction'] = 'asc'; $criteria->setProperties($newparam); // order, offset $estabelecimentos = $repo->load($criteria); $options[] = '--Selecione--'; foreach ($estabelecimentos as $ecs) { $options[$ecs->lojcodloj] = str_pad($ecs->lojcodloj, 4, "0", STR_PAD_LEFT) . ' - ' . $ecs->lojnomfan; } } if ($param['tipo_origens'] == 3) { $repo = new TRepository('Empresa'); $criteria = new TCriteria(); $newparam['order'] = 'id'; $newparam['direction'] = 'asc'; $criteria->setProperties($newparam); // order, offset $empresas = $repo->load($criteria); $options[] = '--Selecione--'; foreach ($empresas as $emp) { $options[$emp->id] = str_pad($emp->id, 4, "0", STR_PAD_LEFT) . ' - ' . $emp->razao_social; } } TTransaction::close(); } catch (Exception $e) { new TMessage('error', $e->getMessage()); } } TCombo::reload('form_Ticket', 'solicitante_id', $opt); TCombo::reload('form_Ticket', 'codigo_cadastro_origem', $options); }