educar_servidor_det.php 17.6 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552
<?php
// error_reporting(E_ALL);
// ini_set("display_errors", 1);
/**
 * i-Educar - Sistema de gestão escolar
 *
 * Copyright (C) 2006  Prefeitura Municipal de Itajaí
 *                     <ctima@itajai.sc.gov.br>
 *
 * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo
 * sob os termos da Licença Pública Geral GNU conforme publicada pela Free
 * Software Foundation; tanto a versão 2 da Licença, como (a seu critério)
 * qualquer versão posterior.
 *
 * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM
 * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU
 * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral
 * do GNU para mais detalhes.
 *
 * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
 * com este programa; se não, escreva para a Free Software Foundation, Inc., no
 * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
 *
 * @author    Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
 * @category  i-Educar
 * @license   @@license@@
 * @package   iEd_Pmieducar
 * @since     Arquivo disponível desde a versão 1.0.0
 * @version   $Id$
 */

require_once 'include/clsBase.inc.php';
require_once 'include/clsDetalhe.inc.php';
require_once 'include/clsBanco.inc.php';
require_once 'include/pmieducar/geral.inc.php';

require_once 'ComponenteCurricular/Model/ComponenteDataMapper.php';
require_once 'Educacenso/Model/DocenteDataMapper.php';

/**
 * clsIndexBase class.
 *
 * @author    Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
 * @category  i-Educar
 * @license   @@license@@
 * @package   iEd_Pmieducar
 * @since     Classe disponível desde a versão 1.0.0
 * @version   @@package_version@@
 */
class clsIndexBase extends clsBase {
  function Formular()
  {
    $this->SetTitulo($this->_instituicao . ' Servidores - Servidor');
    $this->processoAp = 635;
  }
}

/**
 * indice class.
 *
 * @author    Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
 * @category  i-Educar
 * @license   @@license@@
 * @package   iEd_Pmieducar
 * @since     Classe disponível desde a versão 1.0.0
 * @version   @@package_version@@
 */
class indice extends clsDetalhe
{
  var $titulo;

  /**
   * Atributos de dados
   */
  var $cod_servidor = null;
  var $ref_idesco = null;
  var $ref_cod_funcao = null;
  var $carga_horaria = null;
  var $data_cadastro = null;
  var $data_exclusao = null;
  var $ativo = null;
  var $ref_cod_instituicao = null;
  var $alocacao_array = array();
  var $is_professor = FALSE;

  /**
   * Implementação do método Gerar()
   */
  function Gerar()
  {
    $this->titulo = 'Servidor - Detalhe';
    $this->addBanner('imagens/nvp_top_intranet.jpg', 'imagens/nvp_vert_intranet.jpg', 'Intranet');

    $this->cod_servidor        = $_GET['cod_servidor'];
    $this->ref_cod_instituicao = $_GET['ref_cod_instituicao'];

    $tmp_obj = new clsPmieducarServidor($this->cod_servidor, NULL, NULL, NULL, NULL, NULL, NULL, $this->ref_cod_instituicao);

    $registro = $tmp_obj->detalhe();

    if (!$registro) {
        $this->simpleRedirect('educar_servidor_lst.php');
    }

    // Escolaridade
    $obj_ref_idesco = new clsCadastroEscolaridade($registro['ref_idesco']);
    $det_ref_idesco = $obj_ref_idesco->detalhe();
    $registro['ref_idesco'] = $det_ref_idesco['descricao'];

    // Função
    $obj_ref_cod_funcao = new clsPmieducarFuncao($registro['ref_cod_funcao'], NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, $this->ref_cod_instituicao);
    $det_ref_cod_funcao = $obj_ref_cod_funcao->detalhe();
    $registro['ref_cod_funcao'] = $det_ref_cod_funcao['nm_funcao'];

     // Nome
     $obj_cod_servidor      = new clsFuncionario($registro['cod_servidor']);
     $det_cod_servidor      = $obj_cod_servidor->detalhe();
     $registro['matricula'] = $det_cod_servidor['matricula'];

      $obj_cod_servidor      = new clsPessoaFisica($registro['cod_servidor']);
     $det_cod_servidor      = $obj_cod_servidor->detalhe();
     $registro['nome'] = $det_cod_servidor['nome'];



    // Instituição
    $obj_ref_cod_instituicao = new clsPmieducarInstituicao($registro['ref_cod_instituicao']);
    $det_ref_cod_instituicao = $obj_ref_cod_instituicao->detalhe();
    $registro['ref_cod_instituicao'] = $det_ref_cod_instituicao['nm_instituicao'];

    // Alocação do servidor
    $obj = new clsPmieducarServidorAlocacao();
    $obj->setOrderby('periodo, carga_horaria');
    $lista = $obj->lista(
      NULL,
      $this->ref_cod_instituicao,
      NULL,
      NULL,
      NULL,
      $this->cod_servidor,
      NULL,
      NULL,
      NULL,
      NULL,
      NULL,
      NULL,
      NULL,
      NULL,
      1,
      date('Y')
    );

    if ($lista) {
      // Passa todos os valores do registro para atributos do objeto
      foreach ($lista as $campo => $val) {
        $temp = array();
        $temp['carga_horaria'] = $val['carga_horaria'];
        $temp['periodo'] = $val['periodo'];

        $obj_escola = new clsPmieducarEscola($val['ref_cod_escola']);
        $det_escola = $obj_escola->detalhe();
        $det_escola = $det_escola['nome'];
        $temp['ref_cod_escola'] = $det_escola;

        $this->alocacao_array[] = $temp;
      }
    }

    if ($registro['cod_servidor']) {
      $this->addDetalhe(array('Servidor', $registro['cod_servidor']));
    }

    if ($registro['nome']) {
      $this->addDetalhe(array('Nome', $registro['nome']));
    }

    // Dados no Educacenso/Inep.
      $docenteMapper = new Educacenso_Model_DocenteDataMapper();

      $docenteInep = null;
      try {
        $docenteInep = $docenteMapper->find(array('docente' => $registro['cod_servidor']));
      } catch (Exception $e) {

      }

      if (isset($docenteInep)) {
        $this->addDetalhe(array('Código Educacenso/Inep', $docenteInep->docenteInep));

        if (isset($docenteInep->nomeInep)) {
          $this->addDetalhe(array('Nome Educacenso/Inep', $docenteInep->nomeInep));
        }
      }

    if ($registro['idpes']) {
      $this->addDetalhe(array('Nome', $registro['Nome']));
    }

    if ($registro['ref_cod_instituicao']) {
      $this->addDetalhe( array( "Instituição", $registro['ref_cod_instituicao']));
    }

    if( $registro['ref_idesco']) {
      $this->addDetalhe(array('Escolaridade', $registro['ref_idesco']));
    }

    if ($registro['ref_cod_subnivel']) {
      $obj_nivel = new clsPmieducarSubnivel($registro['ref_cod_subnivel']);
      $det_nivel = $obj_nivel->detalhe();

      $this->addDetalhe(array('Nível', $det_nivel['nm_subnivel']));
    }

    if ($registro['ref_cod_funcao']) {
      $this->addDetalhe(array('Função', $registro['ref_cod_funcao']));
    }

    $this->addDetalhe(
      array(
        'Multisseriado',
        dbBool($registro['multi_seriado']) ? 'Sim' : 'Não'
      )
    );

    $obj_funcao = new clsPmieducarServidorFuncao();
    $lst_funcao = $obj_funcao->lista($this->ref_cod_instituicao, $this->cod_servidor);

    if ($lst_funcao) {
      $tabela .= "
        <table cellspacing='0' cellpadding='0' border='0'>
          <tr bgcolor='#ccdce6' align='center'>
            <td width='150'>Função</td>
            <td width='150'>Matrícula</td>
          </tr>";

      $class = 'formlttd';

      $tab_disc = NULL;

      $obj_disciplina_servidor = new clsPmieducarServidorDisciplina();
      $lst_disciplina_servidor = $obj_disciplina_servidor->lista(null, $this->ref_cod_instituicao, $this->cod_servidor);

      if ($lst_disciplina_servidor) {
        $tab_disc .= "<table cellspacing='0' cellpadding='0' width='200' border='0'";

        $class2 = $class2 == "formlttd" ? "formmdtd" : "formlttd" ;
        $tab_disc .= "
          <tr>
            <td bgcolor='#ccdce6' align='center'>Componentes Curriculares</td>
          </tr>";

        $componenteMapper = new ComponenteCurricular_Model_ComponenteDataMapper();
        foreach ($lst_disciplina_servidor as $disciplina) {
          $componente = $componenteMapper->find($disciplina['ref_cod_disciplina']);

          $tab_disc .= "
            <tr class='$class2' align='center'>
              <td align='left'>{$componente->nome}</td>
            </tr>";

          $class2 = $class2 == "formlttd" ? "formmdtd" : "formlttd" ;
        }

        $tab_disc .= "</table>";
      }

      $obj_servidor_curso = new clsPmieducarServidorCursoMinistra();
      $lst_servidor_curso = $obj_servidor_curso->lista(null, $this->ref_cod_instituicao, $this->cod_servidor);

      if ($lst_servidor_curso) {
        $tab_curso .= "<table cellspacing='0' cellpadding='0' width='200' border='0'";

        $class2 = $class2 == "formlttd" ? "formmdtd" : "formlttd" ;
        $tab_curso .= "
          <tr>
            <td bgcolor='#ccdce6' align='center'>Cursos Ministrados</td>
          </tr>";

        foreach ($lst_servidor_curso as $curso) {
          $obj_curso = new clsPmieducarCurso($curso['ref_cod_curso']);
          $det_curso = $obj_curso->detalhe();

          $tab_curso .= "
            <tr class='$class2' align='center'>
              <td align='left'>{$det_curso['nm_curso']}</td>
            </tr>";

          $class2 = $class2 == "formlttd" ? "formmdtd" : "formlttd" ;
        }

        $tab_curso .= "</table>";
      }

      foreach ($lst_funcao as $funcao) {
        $obj_funcao = new clsPmieducarFuncao($funcao['ref_cod_funcao']);
        $det_funcao = $obj_funcao->detalhe();

        $tabela .= "
          <tr class='$class' align='left'>
            <td><b>{$det_funcao['nm_funcao']}</b></td>
            <td align='center'>{$funcao['matricula']}</td>
          </tr>";
        if (!$this->is_professor){
            $this->is_professor = (bool) $det_funcao['professor'];
        }

        $class = $class == "formlttd" ? "formmdtd" : "formlttd" ;
      }

      if ($tab_curso) {
        $tabela .= "
          <tr class='$class' align='center'>
            <td style='padding:5px'>$tab_curso</td>
          </tr>";
      }

      if ($tab_disc) {
        $tabela .= "
          <tr class='$class' align='center'>
            <td style='padding:5px'>$tab_disc</td>
          </tr>";
      }

      $tabela .= "</table>";
      $this->addDetalhe(array('Função', "<a href='javascript:trocaDisplay(\"det_f\");' >Mostrar detalhe</a><div id='det_f' name='det_f' style='display:none;'>".$tabela."</div>"));
    }

    $tabela = NULL;

    /**
     * @todo  Criar função de transformação de hora decimal. Ver educar_servidor_cad.php em 276
     */
    if ($registro['carga_horaria']) {
      $cargaHoraria = $registro['carga_horaria'];
      $horas   = (int)$cargaHoraria;
      $minutos = round(($cargaHoraria - $horas) * 60);
      $cargaHoraria = sprintf('%02d:%02d', $horas, $minutos);
      $this->addDetalhe(array('Carga Horária', $cargaHoraria));
    }

    $dias_da_semana = array(
      '' => 'Selecione',
      1  => 'Domingo',
      2  => 'Segunda',
      3  => 'Terça',
      4  => 'Quarta',
      5  => 'Quinta',
      6  => 'Sexta',
      7  => 'Sábado'
    );

    if ($this->alocacao_array) {
      $tabela .= "
        <table cellspacing='0' cellpadding='0' border='0'>
          <tr bgcolor='#ccdce6' align='center'>
            <td width='150'>Carga Horária</td>
            <td width='80'>Período</td>
            <td width='150'>Escola</td>
          </tr>";

      $class = "formlttd";
      foreach ($this->alocacao_array as $alocacao) {
        switch ($alocacao['periodo']) {
          case 1:
            $nm_periodo = "Matutino";

            break;
          case 2:
            $nm_periodo = "Vespertino";

            break;
          case 3:
            $nm_periodo = "Noturno";

            break;
        }

        $tabela .= "
          <tr class='$class' align='center'>
            <td>{$alocacao['carga_horaria']}</td>
            <td>{$nm_periodo}</td>
            <td>{$alocacao['ref_cod_escola']}</td>
          </tr>";

        $class = $class == 'formlttd' ? 'formmdtd' : 'formlttd';
      }

      $tabela .= "</table>";

      $this->addDetalhe(array('Horários de trabalho',
        "<a href='javascript:trocaDisplay(\"det_pree\");' >Mostrar detalhe</a><div id='det_pree' name='det_pree' style='display:none;'>".$tabela."</div>"));
    }

    // Horários do professor
    $horarios = $tmp_obj->getHorariosServidor($registro['cod_servidor'], $this->ref_cod_instituicao);

    if ($horarios) {
      $tabela = "
        <table cellspacing='0' cellpadding='0' border='0'>
          <tr bgcolor='#ccdce6' align='center'>
            <td width='150'>Escola</td>
            <td width='100'>Curso</td>
            <td width='70'>Série</td>
            <td width='70'>Turma</td>
            <td width='100'>Componente curricular</td>
            <td width='70'>Dia da semana</td>
            <td width='70'>Hora inicial</td>
            <td width='70'>Hora final</td>
          </tr>";

      foreach ($horarios as $horario) {
        $class = $class == 'formlttd' ? 'formmdtd' : 'formlttd';

        $tabela .= sprintf('
          <tr class="%s" align="center">
            <td>%s</td>
            <td>%s</td>
            <td>%s</td>
            <td>%s</td>
            <td>%s</td>
            <td>%s</td>
            <td>%s</td>
            <td>%s</td>
          </tr>',
          $class,
          $horario['nm_escola'], $horario['nm_curso'], $horario['nm_serie'],
          $horario['nm_turma'], $horario['nome'], $dias_da_semana[$horario['dia_semana']],
          $horario['hora_inicial'], $horario['hora_final']
        );
      }

      $tabela .= "</table>";

      $this->addDetalhe(array(
        'Horários de aula',
        "<a href='javascript:trocaDisplay(\"horarios\");' >Mostrar detalhes</a>" .
        "<div id='horarios' name='det_pree' style='display:none;'>" . $tabela . "</div>"
      ));
    }

    $obj_permissoes = new clsPermissoes();
    if ($obj_permissoes->permissao_cadastra(635, $this->pessoa_logada, 7)) {

      $this->url_novo   = 'educar_servidor_cad.php';
      $this->url_editar = "educar_servidor_cad.php?cod_servidor={$registro["cod_servidor"]}&ref_cod_instituicao={$this->ref_cod_instituicao}";

      $get_padrao ="ref_cod_servidor={$registro["cod_servidor"]}&ref_cod_instituicao={$this->ref_cod_instituicao}";

      $this->array_botao = array();
      $this->array_botao_url_script = array();

      $this->array_botao[] = 'Avaliação de Desempenho';
      $this->array_botao_url_script[] = "go(\"educar_avaliacao_desempenho_lst.php?{$get_padrao}\");";
      /***************************************************************************************************************
       *** Avaliando remoção pois será criado aba nova no próprio cadastro/edit do servidor com informações de cursos
       *** e escolaridade normalizados pelo censo
       ***************************************************************************************************************
      $this->array_botao[] = 'Formação';
      $this->array_botao_url_script[] = "go(\"educar_servidor_formacao_lst.php?{$get_padrao}\");";

      $this->array_botao[] = 'Cursos superiores/Licenciaturas';
      $this->array_botao_url_script[] = sprintf(
        "go(\"../module/Docente/index?servidor=%d&instituicao=%d\");",
        $registro['cod_servidor'], $this->ref_cod_instituicao
      );*/

      $this->array_botao[] = 'Faltas/Atrasos';
      $this->array_botao_url_script[] = "go(\"educar_falta_atraso_lst.php?{$get_padrao}\");";

      $this->array_botao[] = 'Alocar Servidor';
      $this->array_botao_url_script[] = "go(\"educar_servidor_alocacao_lst.php?{$get_padrao}\");";

      $this->array_botao[] = 'Alterar Nível';
      $this->array_botao_url_script[] = "popless();";

      $obj_servidor_alocacao = new clsPmieducarServidorAlocacao();
      $lista_alocacao = $obj_servidor_alocacao->lista(
        NULL,
        $this->ref_cod_instituicao,
        NULL,
        NULL,
        NULL,
        $this->cod_servidor,
        NULL,
        NULL,
        NULL,
        NULL,
        NULL,
        NULL,
        NULL,
        NULL,
        NULL,
        1
      );

      if ($lista) {
        $this->array_botao[] = 'Substituir Horário Servidor';
        $this->array_botao_url_script[] = "go(\"educar_servidor_substituicao_cad.php?{$get_padrao}\");";
      }

      $obj_afastamento = new clsPmieducarServidorAfastamento();
      $afastamento = $obj_afastamento->afastado( $this->cod_servidor, $this->ref_cod_instituicao );

      if (is_numeric($afastamento) && $afastamento == 0) {
        $this->array_botao[] = 'Afastar Servidor';
        $this->array_botao_url_script[] = "go(\"educar_servidor_afastamento_cad.php?{$get_padrao}\");";
      } elseif (is_numeric($afastamento)) {
        $this->array_botao[] = 'Retornar Servidor';
        $this->array_botao_url_script[] = "go(\"educar_servidor_afastamento_cad.php?{$get_padrao}&sequencial={$afastamento}\");";
      }

      if ($this->is_professor){
        $this->array_botao[] = 'Vincular professor a turmas';
        $this->array_botao_url_script[] = "go(\"educar_servidor_vinculo_turma_lst.php?{$get_padrao}\");";
      }
    }

    $this->url_cancelar = 'educar_servidor_lst.php';
    $this->largura = '100%';

    $this->breadcrumb('Detalhe do servidor', [
        url('intranet/educar_servidores_index.php') => 'Servidores',
    ]);
  }
}

// Instancia o objeto da página
$pagina = new clsIndexBase();

// Instancia o objeto de conteúdo
$miolo = new indice();

// Passa o conteúdo para a página
$pagina->addForm($miolo);

// Gera o HTML
$pagina->MakeAll();
?>
<script type="text/javascript">
function trocaDisplay(id)
{
  var element = document.getElementById(id);
  element.style.display = (element.style.display == 'none') ? 'inline' : 'none';
}

function popless()
{
  var campoServidor = <?=$_GET["cod_servidor"];?>;
  var campoInstituicao = <?=$_GET["ref_cod_instituicao"];?>;
  pesquisa_valores_popless('educar_servidor_nivel_cad.php?ref_cod_servidor='+campoServidor+'&ref_cod_instituicao='+campoInstituicao, '');
}
</script>