/** * Implementação do método clsCadastro::Gerar() * @see ieducar/intranet/include/clsCadastro#Gerar() */ public function Gerar() { $this->campoOculto('ref_cod_servidor', $this->ref_cod_servidor); $this->campoOculto('sequencial', $this->sequencial); $this->campoOculto('ref_cod_instituicao', $this->ref_cod_instituicao); $opcoes = array('' => 'Selecione'); $objTemp = new clsPmieducarMotivoAfastamento(); $lista = $objTemp->lista(); if (is_array($lista) && count($lista) > 0) { foreach ($lista as $registro) { $opcoes[$registro['cod_motivo_afastamento']] = $registro['nm_motivo']; } } else { $opcoes = array('' => 'Nenhum motivo de afastamento cadastrado'); } if ($this->status == 'N') { $this->campoLista('ref_cod_motivo_afastamento', 'Motivo Afastamento', $opcoes, $this->ref_cod_motivo_afastamento); } elseif ($this->status == 'E') { $this->campoLista('ref_cod_motivo_afastamento', 'Motivo Afastamento', $opcoes, $this->ref_cod_motivo_afastamento, '', FALSE, '', '', TRUE); } // Datas para registro // Se novo registro if ($this->status == 'N') { $this->campoData('data_saida', 'Data de Afastamento', $this->data_saida, TRUE); } elseif ($this->status == 'E') { $this->campoRotulo('data_saida', 'Data de Afastamento', $this->data_saida); } // Se edição, mostra campo para entrar com data de retorno if ($this->status == 'E') { $this->campoData('data_retorno', 'Data de Retorno', $this->data_retorno, FALSE); } $obj_servidor = new clsPmieducarServidor($this->ref_cod_servidor, NULL, NULL, NULL, NULL, NULL, 1, $this->ref_cod_instituicao); $det_servidor = $obj_servidor->detalhe(); if ($det_servidor) { $obj_funcao = new clsPmieducarFuncao($det_servidor['ref_cod_funcao'], NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, $this->ref_cod_instituicao); // Se for professor if (TRUE == $obj_servidor->isProfessor()) { $obj = new clsPmieducarQuadroHorarioHorarios(); // Pega a lista de aulas alocadas para este servidor $lista = $obj->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL, $this->ref_cod_instituicao, NULL, $this->ref_cod_servidor, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL); if ($lista) { // Passa todos os valores obtidos no registro para atributos do objeto foreach ($lista as $campo => $val) { $temp = array(); $temp['hora_inicial'] = $val['hora_inicial']; $temp['hora_final'] = $val['hora_final']; $temp['dia_semana'] = $val['dia_semana']; $temp['ref_cod_escola'] = $val['ref_cod_escola']; $temp['ref_cod_disciplina'] = $val['ref_cod_disciplina']; $temp['ref_cod_substituto'] = $val['ref_servidor_substituto']; $this->alocacao_array[] = $temp; } if ($this->alocacao_array) { $tamanho = sizeof($alocacao); $script = "<script>\nvar num_alocacao = {$tamanho};\n"; $script .= "var array_servidores = Array();\n"; foreach ($this->alocacao_array as $key => $alocacao) { $script .= "array_servidores[{$key}] = new Array();\n"; $hora_ini = explode(":", $alocacao['hora_inicial']); $hora_fim = explode(":", $alocacao['hora_final']); $horas_utilizadas = $hora_fim[0] - $hora_ini[0]; $minutos_utilizados = $hora_fim[1] - $hora_ini[1]; $horas = sprintf('%02d', (int) $horas_utilizadas); $minutos = sprintf('%02d', (int) $minutos_utilizados); $str_horas_utilizadas = "{$horas}:{$minutos}"; $script .= "array_servidores[{$key}][0] = '{$str_horas_utilizadas}';\n"; $script .= "array_servidores[{$key}][1] = '';\n\n"; $obj_escola = new clsPmieducarEscola($alocacao['ref_cod_escola']); $det_escola = $obj_escola->detalhe(); $det_escola = $det_escola['nome']; $nm_dia_semana = $this->dias_da_semana[$alocacao['dia_semana']]; $obj_subst = new clsPessoa_($alocacao['ref_cod_substituto']); $det_subst = $obj_subst->detalhe(); if ($this->status == 'N') { $this->campoTextoInv("dia_semana_{$key}_", '', $nm_dia_semana, 8, 8, FALSE, FALSE, TRUE, '', '', '', '', 'dia_semana'); $this->campoTextoInv("hora_inicial_{$key}_", '', $alocacao['hora_inicial'], 5, 5, FALSE, FALSE, TRUE, '', '', '', '', 'ds_hora_inicial_'); $this->campoTextoInv("hora_final_{$key}_", '', $alocacao['hora_final'], 5, 5, FALSE, FALSE, TRUE, '', '', '', '', 'ds_hora_final_'); $this->campoTextoInv("ref_cod_escola_{$key}", '', $det_escola, 30, 255, FALSE, FALSE, TRUE, '', '', '', '', 'ref_cod_escola_'); $this->campoTextoInv("ref_cod_servidor_substituto_{$key}_", '', $det_subst['nome'], 30, 255, FALSE, FALSE, FALSE, '', "<span name=\"ref_cod_servidor_substituto\" id=\"ref_cod_servidor_substituicao_{$key}\"><img border='0' onclick=\"pesquisa_valores_popless('educar_pesquisa_servidor_lst.php?campo1=ref_cod_servidor_substituto[{$key}]&campo2=ref_cod_servidor_substituto_{$key}_&ref_cod_instituicao={$this->ref_cod_instituicao}&dia_semana={$alocacao["dia_semana"]}&hora_inicial={$alocacao["hora_inicial"]}&hora_final={$alocacao["hora_final"]}&ref_cod_servidor={$this->ref_cod_servidor}&professor=1&ref_cod_escola={$alocacao['ref_cod_escola']}&horario=S&ref_cod_disciplina={$alocacao['ref_cod_disciplina']}', 'nome')\" src=\"imagens/lupa.png\" ></span>", '', '', 'ref_cod_servidor_substituto'); } $this->campoOculto("dia_semana_{$key}", $alocacao['dia_semana']); $this->campoOculto("hora_inicial_{$key}", $alocacao['hora_inicial']); $this->campoOculto("hora_final_{$key}", $alocacao['hora_final']); $this->campoOculto("ref_cod_escola_{$key}", $alocacao['ref_cod_escola']); $this->campoOculto("ref_cod_servidor_substituto[{$key}]", $alocacao['ref_cod_substituto']); } $script .= "\n</script>"; // Print do Javascript print $script; } } } } }
function Inicializar() { $retorno = 'Novo'; session_start(); $this->pessoa_logada = $_SESSION['id_pessoa']; session_write_close(); $this->ref_cod_servidor = $_GET['ref_cod_servidor']; $this->ref_ref_cod_instituicao = $_GET['ref_cod_instituicao']; $obj_permissoes = new clsPermissoes(); $obj_permissoes->permissao_cadastra(635, $this->pessoa_logada, 3, 'educar_servidor_lst.php'); if (is_numeric($this->ref_cod_servidor) && is_numeric($this->ref_ref_cod_instituicao)) { $retorno = 'Novo'; $obj_servidor = new clsPmieducarServidor($this->ref_cod_servidor, NULL, NULL, NULL, NULL, NULL, NULL, $this->ref_ref_cod_instituicao); $det_servidor = $obj_servidor->detalhe(); // Nenhum servidor com o código de servidor e instituição if (!$det_servidor) { header('Location: educar_servidor_lst.php'); die; } $this->professor = $obj_servidor->isProfessor() == TRUE ? 'true' : 'false'; $obj = new clsPmieducarServidorAlocacao(); $lista = $obj->lista(NULL, $this->ref_ref_cod_instituicao, NULL, NULL, NULL, $this->ref_cod_servidor, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1); if ($lista) { // passa todos os valores obtidos no registro para atributos do objeto foreach ($lista as $campo => $val) { $temp = array(); $temp['carga_horaria'] = $val['carga_horaria']; $temp['periodo'] = $val['periodo']; $temp['ref_cod_escola'] = $val['ref_cod_escola']; $this->alocacao_array[] = $temp; } $retorno = 'Novo'; } $this->carga_horaria = $det_servidor['carga_horaria']; } else { header('Location: educar_servidor_lst.php'); die; } $this->url_cancelar = sprintf('educar_servidor_det.php?cod_servidor=%d&ref_cod_instituicao=%d', $this->ref_cod_servidor, $this->ref_ref_cod_instituicao); $this->nome_url_cancelar = 'Cancelar'; return $retorno; }