Exemplo n.º 1
0
 public function cadastrar_registros_faltas()
 {
     $msg = null;
     $data = $this->getParametroVisao();
     $data['page'] = 'home';
     $data['tema'] != '' ? $this->load->setTheme($data['tema']) : '';
     $data['msg'] = $msg;
     $data['abaAtiva'] = 23;
     $data['abaPage'] = 'cadastrar_registros_faltas';
     $data['alias'] = 'cadastrar_registros_faltas';
     $data['total_professores'] = 0;
     if ($_SERVER['REQUEST_METHOD'] == "POST") {
         try {
             // View::validarFormAntInjection($alias);
             for ($i = 1; $i < $this->input->post('total') + 1; $i++) {
                 echo $this->input->post('pk_age_aula') . ' - ' . $this->input->post('pk_usuario_aluno_' . $i) . ' - ' . $this->input->post('faltou_' . $i) . '<br />';
                 $sqlAgenda = new SqlAgenda();
                 $sqlAgenda->update_falta($this->input->post('pk_age_aula'), $this->input->post('pk_usuario_aluno_' . $i), $this->input->post('faltou_' . $i));
             }
             redirect(base_url() . $this->uri->segment(1) . '/' . $this->uri->segment(2) . '/cadastrar_registros_alunos/' . $this->input->post('pk_age_aula') . '?tipo_registro=' . $this->input->post('tipo_registro'));
             return false;
         } catch (Exception $e) {
             $msg = '<p class="alert erro">' . $e->getMessage() . '</p>';
         }
     }
     $data['title'] = isset($_GET['tipo_registro']) && $_GET['tipo_registro'] == 1 ? 'Definição de faltosos - Educação Infantil' : 'Definição de faltosos - Educação Integral';
     $data['cabecalho'] = isset($_GET['tipo_registro']) && $_GET['tipo_registro'] == 1 ? '<div class="w150 left"><strong>Data: </strong>' . $_SESSION['age_data'] . '</div><div class="w350 left"><strong>Turma: </strong>' . $_SESSION['age_turma_nome'] . '</div><div class="left"><strong>Professora: </strong>' . $_SESSION['age_nome_professor'] . '</div><br class="clear" />' : '<div class="w150 left"><strong>Data: </strong>' . $_SESSION['age_data'] . '</div><div class="w350 left"><strong>Turmas: </strong>' . $_SESSION['juncao_turmas_nome'] . '</div><br class="clear" />';
     $_SESSION['cabecalho'] = $data['cabecalho'];
     $sqlAgenda = new SqlAgenda();
     $result = $sqlAgenda->get_alunos_falta($this->uri->segment(4));
     $data['total'] = count($result);
     $data['insert'] = 0;
     if (count($result) == 0) {
         if ($_GET['tipo_registro'] == 1) {
             $sqlAgenda = new SqlAgenda();
             $result = $sqlAgenda->get_alunos($_GET['pk_turma'], $data['ano_letivo']);
             $data['total'] = count($result);
             $data['insert'] = 1;
         } else {
             // pega as turmas e alunos do integral que tem aula no dia selecionado
             $sqlAgenda = new SqlAgenda();
             $result = $sqlAgenda->get_turmas_integral($_SESSION['dia_semana'], $_SESSION['series_juncao'], $data['ano_letivo']);
             $data['total'] = count($result);
             $data['insert'] = 1;
         }
     }
     $i = 0;
     $alunos = '<table class="tabela mt20">';
     $alunos .= '<tr><th rowspan="2">Alunos</th><th colspan="2">Faltou?</th></tr><tr><th>Sim</th><th>Não</th></tr>';
     foreach ($result as $row) {
         $i++;
         $checkedFaltou = isset($row['faltou']) && $row['faltou'] == 1 ? 'checked="checked"' : '';
         $checkedPresente = isset($row['faltou']) && $row['faltou'] == 0 ? 'checked="checked"' : '';
         $checked = $checkedFaltou == '' && $checkedPresente == '' ? 'checked="checked"' : '';
         $alunos .= '<tr><td>' . $row['nome'] . '</td><td><input type="radio" name="faltou_' . $i . '" value="1" ' . $checkedFaltou . ' /></td><td><input type="radio" name="faltou_' . $i . '" value="0" ' . $checkedPresente . $checked . ' /><input type="hidden" name="pk_usuario_aluno_' . $i . '" value="' . $row['fk_usuario_aluno'] . '"></td></tr>';
     }
     $alunos .= '</table>';
     $data['alunos'] = $alunos;
     $this->load->view($this->load->getUrlTema(), $data);
 }