} /** * [__autoload carregas as dependecias] */ function __autoload($c) { $paths = array('./', './libs/', './dao/ponto/', './dao/ldap/', './conf/'); foreach ($paths as $dir) { if (file_exists($dir . $c . '.php')) { require_once $dir . $c . ".php"; } } } $siape = $_SESSION['siape']; $usuario = $_SESSION['usuario']; $ponto = new Ponto(); /** * [$chefiaDepartamento array qye contem todos os departamentos subordinados as chefias - (departamento_id e descricao)] * @var [array of object] */ $chefiaDepartamento = $ponto->departamentosAll(); $admin = $ponto->estudanteBool($siape, 4); if ($admin->resposta == 'S' && $admin->resposta == 'S') { } else { header('location: /ponto/index.php'); exit; } /** * [count($chefiaDepartamento) verifica se o usuario e um chefe, caso nao seja, o mesmo e redirecionado a pagina index(pagina de marcaçoes de funcionarios)] * @var [int] */
if (!array_key_exists('siape', $_SESSION)) { header('location: /ponto/login.php'); exit; } function __autoload($c) { $paths = array('./', './libs/', './dao/ponto/', './dao/ldap/', './conf/'); foreach ($paths as $dir) { if (file_exists($dir . $c . '.php')) { require_once $dir . $c . ".php"; } } } $siape = $_SESSION['siape']; $usuario = $_SESSION['usuario']; $ponto = new Ponto(); $chefiaDepartamento = $ponto->chefia($usuario); /** * [count($chefiaDepartamento) verifica se o usuario e um chefe, caso nao seja, o * mesmo e redirecionado a pagina index(pagina de marcaçoes de funcionarios)] * @var [int] */ $admin = $ponto->estudanteBool($siape, 4); if ($admin->resposta == 'S' && $admin->resposta == 'S') { } else { header('location: /ponto/index.php'); exit; } ?> <!DOCTYPE html>
public function calculaPercentualProdutividade($campo, $object, $row) { $intervalo = Ponto::horaPreenchidas($object->data_ponto, $object->colaborador_id); $HoraEntrada = new DateTime($object->hora_entrada); $HoraSaida = new DateTime($object->hora_saida); $almoco = new DateTime('01:00:00'); $limite = new DateTime('06:00:00'); $ponto = $HoraSaida->diff($HoraEntrada)->format('%H:%I:%S'); $total = new DateTime($ponto); if ($total > $limite) { $ponto = $total->diff($almoco)->format('%H:%I:%S'); } if ($object->hora_saida) { $campo = round($this->string->time_to_sec($intervalo) * 100 / $this->string->time_to_sec($ponto)); if ($campo > 49) { return "<span style='color:#007BFF'><b>" . $campo . "%</b></span>"; } elseif ($campo > 29) { return "<span style='color:#FFB300'><b>" . $campo . "%</b></span>"; } else { return "<span style='color:#FF0000'><b>" . $campo . "%</b></span>"; } } }
function retornaPonto($user, $mes, $ano) { $ultimo_dia = date("t", mktime(0, 0, 0, $mes, '01', $ano)); $totalPonto = null; for ($dia = 1; $dia <= $ultimo_dia; $dia++) { $data = $ano . '-' . $mes . '-' . $dia; $ponto = Ponto::retornaTempoPonto($user, $data); $total = new DateTime($ponto); $almoco = new DateTime('01:00:00'); $limite = new DateTime('06:00:00'); if ($total > $limite) { $ponto = $total->diff($almoco)->format('%H:%I:%S'); } $totalPonto += $this->string->time_to_sec($ponto); } return $this->string->sec_to_time($totalPonto); }
session_start(); if (!array_key_exists('siape', $_SESSION)) { header('location: /ponto/login.php'); exit; } function __autoload($c) { $paths = array('./', './libs/', './dao/ponto/', './dao/ldap/', './conf/'); foreach ($paths as $dir) { if (file_exists($dir . $c . '.php')) { require_once $dir . $c . ".php"; } } } $_SESSION['siape'] = $_GET['funcionario']; $siape = $_SESSION['siape']; $usuario = $_SESSION['usuario']; $ponto = new Ponto(); $admin = $ponto->estudanteBool($siape, 4); if ($admin->resposta == 'S' && $admin->resposta == 'S') { header('location: /ponto/index.php'); } else { header('location: /ponto/index.php'); exit; } //$chefiaDepartamento = $ponto->chefia($usuario); if (count($chefiaDepartamento) != 0) { header('location: /ponto/chefia.php'); exit; }
/** * 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(); } }
if (!array_key_exists('siape', $_SESSION)) { header('location: /ponto/login.php'); exit; } function __autoload($c) { $paths = array('./', './libs/', './dao/ponto/', './dao/ldap/', './conf/'); foreach ($paths as $dir) { if (file_exists($dir . $c . '.php')) { require_once $dir . $c . ".php"; } } } $siape = $_SESSION['siape']; $usuario = $_SESSION['usuario']; $ponto = new Ponto(); $funcionariosLista = $ponto->funcionariosListAll(); if (count($chefiaDepartamento) != 0) { header('location: /ponto/chefia.php'); exit; } $admin = $ponto->estudanteBool($siape, 4); if ($admin->resposta != 'S' && $admin->resposta != 'S' || count($admin) == 0) { header('location: /ponto/index.php'); exit; } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8">
/** * Class constructor * Creates the page and the registration form */ function __construct() { parent::__construct(); $string = new StringsUtil(); // creates the form $this->form = new TForm('form_Atividade'); $this->form->class = 'tform'; // CSS class $this->form->style = 'width: 500px'; // add a table inside form $table = new TTable(); $table->width = '100%'; $this->form->add($table); // add a row for the form title $row = $table->addRow(); $row->class = 'tformtitle'; // CSS class $row->addCell(new TLabel('Atividade'))->colspan = 2; // busca dados do banco try { TTransaction::open('atividade'); $logado = Pessoa::retornaUsuario(); $ultimoPonto = Ponto::retornaUltimoPonto($logado->pessoa_codigo); $ponto = new Ponto($ultimoPonto); if ($ponto->hora_saida) { $action = new TAction(array('PontoFormList', 'onReload')); new TMessage('error', 'Não existe ponto com horario em aberto!', $action); } $data_padrao = $string->formatDateBR($ponto->data_ponto); $hora_padrao = Ponto::retornaHoraInicio($string->formatDate($data_padrao), $logado->pessoa_codigo); TTransaction::close(); } catch (Exception $e) { new TMessage('error', '<b>Error</b> ' . $e->getMessage()); } // create the form fields $id = new THidden('id'); $data_atividade = new TEntry('data_atividade'); $data_atividade->setMask('dd/mm/yyyy'); $data_atividade->setValue($data_padrao); $data_atividade->setEditable(FALSE); $hora_inicio = new TEntry('hora_inicio'); $hora_inicio->setEditable(FALSE); $hora_inicio->setValue($hora_padrao); $hora_fim = new THidden('hora_fim'); $hora_fim->setEditable(FALSE); $tempo_atividade = new TEntry('tempo_atividade'); $tempo_atividade->setEditable(FALSE); $qtde_horas = new TCombo('qtde_horas'); $qtde_minutos = new TCombo('qtde_minutos'); $descricao = new TText('descricao'); $colaborador_id = new THidden('colaborador_id'); $colaborador_id->setValue($logado->pessoa_codigo); $colaborador_nome = new TEntry('colaborador_nome'); $colaborador_nome->setEditable(FALSE); $colaborador_nome->setValue($logado->pessoa_nome); $tipo_atividade_id = new TDBCombo('tipo_atividade_id', 'atividade', 'TipoAtividade', 'id', 'nome', 'nome'); $sistema_id = new TDBCombo('sistema_id', 'atividade', 'Sistema', 'id', 'nome'); $ticket_id = new TCombo('ticket_id'); $criteria = new TCriteria(); $criteria->add(new TFilter("status_ticket_id", "IN", array(1, 5))); $newparam['order'] = 'id'; $newparam['direction'] = 'asc'; $criteria->setProperties($newparam); // order, offset $this->onComboTicket($criteria); $horario = explode(':', $hora_padrao); // cria combos de horas e minutos $combo_horas = array(); for ($i = 8; $i <= 18; $i++) { $combo_horas[$i] = str_pad($i, 2, 0, STR_PAD_LEFT); } $qtde_horas->addItems($combo_horas); $qtde_horas->setValue($horario[0]); $qtde_horas->setDefaultOption(FALSE); $combo_minutos = array(); for ($i = 0; $i <= 59; $i++) { $combo_minutos[$i] = str_pad($i, 2, 0, STR_PAD_LEFT); } $qtde_minutos->addItems($combo_minutos); $qtde_minutos->setValue($horario[1]); $qtde_minutos->setDefaultOption(FALSE); // set exit action for input_exit $change_action = new TAction(array($this, 'onChangeAction')); $qtde_horas->setChangeAction($change_action); $qtde_minutos->setChangeAction($change_action); $change_atividade_action = new TAction(array($this, 'onTrocaTipoAtividade')); $tipo_atividade_id->setChangeAction($change_atividade_action); $change_ticket_action = new TAction(array($this, 'onTrocaTicket')); $ticket_id->setChangeAction($change_ticket_action); // define the sizes $id->setSize(100); $data_atividade->setSize(100); $hora_inicio->setSize(100); $hora_fim->setSize(100); $qtde_horas->setSize(60); $qtde_minutos->setSize(60); $tempo_atividade->setSize(100); $descricao->setSize(300, 80); $colaborador_id->setSize(200); $tipo_atividade_id->setSize(200); $ticket_id->setSize(300); // validações $tempo_atividade->addValidation('Hora Fim', new THoraFimValidator()); $tipo_atividade_id->addValidation('Tipo de Atividade', new TRequiredValidator()); $ticket_id->addValidation('Ticket', new TRequiredValidator()); $sistema_id->addValidation('Sistema', new TRequiredValidator()); $descricao->addValidation('Descrição', new TMinLengthValidator(), array(10)); $sem_atividade = TButton::create('atividade', array($this, 'onSemAtividade'), 'Sem Registro', 'ico_add.png'); $this->form->addField($sem_atividade); // add one row for each form field $table->addRowSet(new TLabel('Colaborador:'), $colaborador_nome); $table->addRowSet(new TLabel('Data Atividade:'), array($data_atividade, $label_data = new TLabel('Data do último ponto'))); $label_data->setFontColor('#A9A9A9'); $table->addRowSet(new TLabel('Hora Inicio:'), $hora_inicio); $table->addRowSet($label_qtde_horas = new TLabel('Hora Fim:'), array($qtde_horas, $qtde_minutos, $sem_atividade)); $label_qtde_horas->setFontColor('#FF0000'); $table->addRowSet(new TLabel('Tempo Atividade:'), $tempo_atividade); $table->addRowSet($label_atividade = new TLabel('Tipo Atividade:'), $tipo_atividade_id); $label_atividade->setFontColor('#FF0000'); $table->addRowSet($label_ticket = new TLabel('Ticket:'), $ticket_id); $label_ticket->setFontColor('#FF0000'); $table->addRowSet($label_sistema = new TLabel('Sistema:'), $sistema_id); $label_sistema->setFontColor('#FF0000'); $table->addRowSet($label_descricao = new TLabel('Descrição:'), $descricao); $label_descricao->setFontColor('#FF0000'); $table->addRowSet(new TLabel(''), $id); $table->addRowSet(new TLabel(''), $colaborador_id); $table->addRowSet(new TLabel(''), $hora_fim); //esconder $this->form->setFields(array($id, $data_atividade, $hora_inicio, $qtde_horas, $qtde_minutos, $hora_fim, $tempo_atividade, $descricao, $colaborador_id, $colaborador_nome, $tipo_atividade_id, $ticket_id, $sistema_id)); // create the form actions $save_button = TButton::create('save', array($this, 'onSave'), _t('Save'), 'fa:floppy-o'); $new_button = TButton::create('new', array($this, 'onEdit'), _t('New'), 'fa:plus-square green'); $del_button = TButton::create('delete', array($this, 'onDelete'), _t('Delete'), 'fa:trash-o red fa-lg'); $list_button = TButton::create('list', array('AtividadeList', 'onClean'), _t('List'), 'fa:table blue'); $this->form->addField($save_button); $this->form->addField($new_button); $this->form->addField($del_button); $this->form->addField($list_button); $buttons_box = new THBox(); $buttons_box->add($save_button); $buttons_box->add($new_button); $buttons_box->add($del_button); $buttons_box->add($list_button); // add a row for the form action $row = $table->addRow(); $row->class = 'tformaction'; // CSS class $row->addCell($buttons_box)->colspan = 2; // TScript::create(' $( "#descricao" ).focus(); '); parent::add($this->form); }
<?php include 'parsePonto.php'; $file = file_get_contents('ponto.txt'); $ponto = new Ponto($file); //var_dump($ponto->getEmployees()); //var_dump($ponto->getEmployeeBalance('013054953938',$startTime,$endTime)); var_dump($ponto->getEmployeeBalance('013165740894',null,null));
/** * method onSave() * Executed whenever the user clicks at the save button */ function onSave() { try { TTransaction::open('atividade'); // open a transaction // get the form data into an active record Atividade $object = $this->form->getData(); $this->form->validate(); // form validation $tipo = new TipoAtividade($object->tipo_atividade_id); // Start date $date = $this->string->formatDate($object->data_inicial); // End date $end_date = $this->string->formatDate($object->data_final); while (strtotime($date) <= strtotime($end_date)) { $criteria = new TCriteria(); $criteria->add(new TFilter("data_ponto", "=", $date)); $criteria->add(new TFilter("colaborador_id", "=", $object->colaborador_id)); $repo = new TRepository('Ponto'); $count = $repo->count($criteria); if (!$count) { $criteria = new TCriteria(); $criteria->add(new TFilter("data_atividade", "=", $date)); $criteria->add(new TFilter("colaborador_id", "=", $object->colaborador_id)); $repo = new TRepository('Atividade'); $count = $repo->count($criteria); if (!$count) { $ponto = new Ponto(); $ponto->data_ponto = $date; $ponto->hora_entrada = '08:15:00'; $ponto->hora_saida = '18:03:00'; $ponto->colaborador_id = $object->colaborador_id; $ponto->store(); $atividade = new Atividade(); $atividade->data_atividade = $date; $atividade->hora_inicio = '09:15:00'; $atividade->hora_fim = '18:03:00'; $atividade->descricao = 'AUSENCIA CADASTRADA EM LOTE'; $atividade->colaborador_id = $object->colaborador_id; $atividade->tipo_atividade_id = $object->tipo_atividade_id; $atividade->sistema_id = $tipo->sistema_id; $atividade->ticket_id = $tipo->ticket_id; $atividade->store(); } } else { new TMessage('error', '<b>Erro:</b> Ponto já cadastrado dia: ' . $this->string->formatDateBR($date)); break; } $date = date("Y-m-d", strtotime("+1 day", strtotime($date))); } $this->form->setData($object); // keep form data TTransaction::close(); // close the transaction // shows the success message if (!$count) { new TMessage('info', TAdiantiCoreTranslator::translate('Record saved')); } } catch (Exception $e) { new TMessage('error', '<b>Error</b> ' . $e->getMessage()); // shows the exception error message $this->form->setData($this->form->getData()); // keep form data TTransaction::rollback(); // undo all pending operations } }