public function listar_relatorios() { $data = $this->getParametroVisao(); if ($data['idTipoUsuario'] == 15) { //Alteração feita para um melhor controle de acesso $pkUsuarioProfessor = $data['idUsuarioProfessor']; $professorTmp = new Kernel_Models_Professor(); $professorTmp = $professorTmp->selectUsuarioProfessor((int) $pkUsuarioProfessor); if ($data['idUsuarioProfessor'] != $pkUsuarioProfessor || !$professorTmp) { ini_set('default_charset', 'utf8'); echo Javascript::alert('Desculpe, você não tem acesso a este relátorio'); echo Javascript::history_back(); echo Javascript::close(); echo Javascript::shadowboxClose(); return; } $professor = $professorTmp->fetchObject('public_usuario_professor'); $data['professorObj'] = $professor; } $data['page'] = 'home'; $data['msg'] = $this->getMsg(); $data['abaAtiva'] = 7; $data['abaPage'] = 'listar_relatorios'; $data['alias'] = 'listar_relatorios'; isset($data['tema']) ? $this->load->setTheme($data['tema']) : ''; if ($_SERVER['REQUEST_METHOD'] == "POST") { try { redirect(base_url() . 'aula/conteudo/listar_relatorios/?&pk_turma=' . $this->input->post('pk_turma') . '&pk_usuario_professor=' . $this->input->post('pk_usuario_professor') . '&pk_materia_vin=' . $this->input->post('pk_materia_vin') . '&data_inicial=' . View::converteDataEUA($this->input->post('data_inicial')) . '&data_final=' . View::converteDataEUA($this->input->post('data_final'))); return false; } catch (Exception $e) { $msg = '<p class="alert erro">' . $e->getMessage() . '</p>'; } } if ($data['idTipoUsuario'] == 1 || $data['idTipoUsuario'] == 2) { $sqlGrade = new SqlGrade(); $result = $sqlGrade->lista_turmas_usuario_admin($data['ano_letivo']); } else { if ($data['idTipoUsuario'] == 15) { //Modificação feita para permitir um melhor controle de acesso $professor = new Kernel_Models_Professor(); $turmas = $professor->turmas((int) $data['idUsuarioProfessor']); $result = $turmas->fetchAll(); // var_dump($result); // die(var_dump($data)); } else { $sqlGrade = new SqlGrade(); $result = $sqlGrade->lista_turmas_usuario($data['turmas']); } } $turma = explode("&pk_turma=", $_SERVER['QUERY_STRING']); $turma_url = base_url() . $this->uri->segment(1) . '/' . $this->uri->segment(2) . '/' . $this->uri->segment(3) . '/' . $this->uri->segment(4) . '/' . $this->uri->segment(5) . '?' . $turma[0]; if (!isset($_GET['data_final'])) { $select = '<p class="left mr20"><label>Turma</label><br />'; $select .= '<select name="jumpMenu" id="jumpMenu" class="w280" onchange="MM_jumpMenu(\'parent\',this,0)">'; $label_default = isset($_GET['pk_turma']) ? 'Retirar filtro de turma' : ''; $select .= '<option value="' . $turma_url . '">' . $label_default . '</option>'; foreach ($result as $row) { $checked = isset($_GET['pk_turma']) && $_GET['pk_turma'] == $row['pk_turma'] ? 'selected' : ''; $select .= '<option value="' . $turma_url . '&pk_turma=' . $row['pk_turma'] . '" ' . $checked . '>' . $row['turma_nome'] . '</option>'; } $select .= '</select></p>'; $data['filtro_turmas'] = $select; } $tabela = ''; $filtro_professores = ''; if (isset($_GET['pk_turma']) && $_GET['pk_turma'] != '') { $sqlAula = new SqlAula(); if ($data['idTipoUsuario'] == 15) { //Modificação feita para permitir um melhor controle de acesso $result = $sqlAula->get_professores_aulas_coordenador($_GET['pk_turma'], (int) $data['idUsuarioProfessor']); } else { $result = $sqlAula->get_professores_aulas_coordenador($_GET['pk_turma']); } $professor = explode("&pk_usuario_professor=", $_SERVER['QUERY_STRING']); $professor_url = base_url() . $this->uri->segment(1) . '/' . $this->uri->segment(2) . '/' . $this->uri->segment(3) . '/' . $this->uri->segment(4) . '/' . $this->uri->segment(5) . '?' . $professor[0]; $select = '<p class="left mr20"><label>Disciplina / Professor</label><br />'; $select .= '<select name="jumpMenu" id="jumpMenu" class="w200" onchange="MM_jumpMenu(\'parent\',this,0)">'; $label_default = isset($_GET['pk_usuario_professor']) ? 'Retirar filtro de professor' : ''; $select .= '<option value="' . $professor_url . '">' . $label_default . '</option>'; foreach ($result as $row) { $checked = isset($_GET['pk_usuario_professor']) && $_GET['pk_usuario_professor'] == $row['fk_usuario_professor'] ? 'selected' : ''; $select .= '<option value="' . $professor_url . '&pk_usuario_professor=' . $row['fk_usuario_professor'] . '&pk_materia_vin=' . $row['fk_materia_vin'] . '" ' . $checked . '>' . $row['materia_nome'] . ' - ' . $row['professor_nome'] . '</option>'; } $select .= '</select></p>'; $filtro_professores = $select; if (isset($_GET['pk_usuario_professor']) && $_GET['pk_usuario_professor'] != '') { // pega a matéria $sqlGrade = new SqlGrade(); $result = $sqlGrade->get_materia_vin_nome($_GET['pk_materia_vin']); $data['materia'] = $result[0]['materia_nome']; // pega o nome da turma $sqlGrade = new SqlGrade(); $result = $sqlGrade->get_turma($_GET['pk_turma']); $data['turma'] = $result[0]['turma_nome']; // pega o nome do professor $sqlUsuario = new SqlUsuario(); $result = $sqlUsuario->get_nome_professor($_GET['pk_usuario_professor']); $data['professor'] = $result[0]['nome']; if (isset($_GET['data_final']) && $_GET['data_final'] != '') { $sqlAula = new SqlAula(); $result = $sqlAula->listar_aulas_professor($_GET['pk_turma'], $_GET['pk_usuario_professor'], $_GET['pk_materia_vin']); $data['total'] = count($result); if ($data['total'] > 0) { $this->load->library('table'); $arrHead[] = ''; $this->table->set_heading($arrHead); $tabela = ''; $tabela .= '<table>'; foreach ($result as $row) { $tabela .= '<tr>'; $tabela .= '<td class="aulas_conteudos">'; $tabela .= '<strong>Data / horário:</strong> ' . View::converteDataBr($row['data_aula']) . ' - ' . substr($row['hora_inicio'], 0, 5) . ' às ' . substr($row['hora_fim'], 0, 5) . '<br />'; if ($row['conteudos_livro_desc'] != '') { $tabela .= '<strong>Conteúdo:</strong> ' . $row['conteudos_livro_desc'] . '<br />'; } else { $tabela .= '<strong>Conteúdo:</strong> ' . $row['conteudo'] . '<br />'; } if ($row['capitulo'] != '') { $tabela .= '<strong>Capítulo:</strong> ' . $row['capitulo'] . '<br />'; } if ($row['paginas'] != '') { $tabela .= '<strong>Página(s):</strong> ' . $row['paginas'] . '<br />'; } if ($row['exercicios_sala'] != '') { $tabela .= '<strong>Exercícios em sala:</strong> ' . $row['exercicios_sala'] . '<br />'; } if ($row['exercicios_casa'] != '') { $tabela .= '<strong>Exercícios propostos para casa:</strong> ' . $row['exercicios_casa'] . '<br />'; } if ($row['obs'] != '') { $tabela .= '<strong>Observação:</strong> ' . $row['obs'] . '<br />'; } $tabela .= '<strong style="margin-left:500px;">Assinatura:</strong> _____________________________________<br />'; $tabela .= '</td>'; $tabela .= '</tr>'; } $tabela .= '</table>'; $data['tabela'] = $tabela; } else { $data['msg'] = '<div class="alert atencao">Nenhuma prova incluída. Para cadastrar, clique no botão acima.</div>'; } } } } $data['filtro_professores'] = $filtro_professores; $data['tabela'] = $tabela; $this->load->view($this->load->getUrlTema(), $data); }