Пример #1
0
 /**
  * Lista a grade horária do professor
  * @param type $pkUsuario
  */
 public function get_grade($pkUsuario = 0)
 {
     $validarUser = new Kernel_Models_ValidarUsuarios();
     $professor = $validarUser->professor($pkUsuario);
     if ($professor) {
         $this->setStatusCod(0)->statusTrue();
         $professor = $professor->fetchObject();
         $sqlGrade = new SqlGrade();
         foreach (range(1, 6) as $value) {
             $tmp = $sqlGrade->listar_grade_professor($professor->getPkUsuarioProfessor(), $value, $this->getData('ano_letivo'));
             //Lendo a grade do professor
             $dia = new stdClass();
             $dia->dia = $value;
             $dia->aulas = array();
             foreach ($tmp['registros'] as $grade) {
                 //Adicionando a grade a resposta
                 $ret = new stdClass();
                 $ret->hr_inicio = isset($grade['hora_inicio']) ? str_replace('h', ":", $grade['hora_inicio']) : '';
                 $ret->hr_termino = isset($grade['hora_fim']) ? str_replace("h", ":", $grade['hora_fim']) : '';
                 $ret->materia = isset($grade['materia']) ? $grade['materia'] : '';
                 $ret->turma = isset($grade['turma_nome']) ? $grade['turma_nome'] : '';
                 $ret->serie = isset($grade['serie_nome']) ? $grade['serie_nome'] : '';
                 $ret->nAula = isset($grade['ordem']) ? $grade['ordem'] : '';
                 $dia->aulas[] = $ret;
             }
             $this->appendResposta($dia);
         }
     } else {
         $this->setMensagem("O professor informado é inválido");
     }
     $this->printResposta();
 }
Пример #2
0
 public function listar_grade_professor()
 {
     $data = $this->getParametroVisao();
     $data['msg'] = $this->getMsg();
     $data['abaAtiva'] = 1;
     if ($data['mobile']) {
         $data['usuario'] = unserialize($_SESSION['usuario']);
         $data['page'] = __FUNCTION__;
         $data['tema'] = $this->load->setTheme('responsive');
     } else {
         $data['page'] = 'home';
         $data['tema'] != '' ? $this->load->setTheme($data['tema']) : '';
         $data['abaPage'] = 'listar_grade_professor';
     }
     $pk_usuario_professor = $this->uri->segment(4) != '' ? $this->uri->segment(4) : $data['idUsuarioProfessor'];
     $sqlUsuario = new SqlUsuario();
     $data['professor'] = $sqlUsuario->get_nome_professor($pk_usuario_professor);
     $sqlGrade = new SqlGrade();
     $data['aulas_segunda'] = $sqlGrade->listar_grade_professor($pk_usuario_professor, 1, $data['ano_letivo']);
     $sqlGrade = new SqlGrade();
     $data['aulas_terca'] = $sqlGrade->listar_grade_professor($pk_usuario_professor, 2, $data['ano_letivo']);
     $sqlGrade = new SqlGrade();
     $data['aulas_quarta'] = $sqlGrade->listar_grade_professor($pk_usuario_professor, 3, $data['ano_letivo']);
     $sqlGrade = new SqlGrade();
     $data['aulas_quinta'] = $sqlGrade->listar_grade_professor($pk_usuario_professor, 4, $data['ano_letivo']);
     $sqlGrade = new SqlGrade();
     $data['aulas_sexta'] = $sqlGrade->listar_grade_professor($pk_usuario_professor, 5, $data['ano_letivo']);
     $sqlGrade = new SqlGrade();
     $data['aulas_sabado'] = $sqlGrade->listar_grade_professor($pk_usuario_professor, 6, $data['ano_letivo']);
     function aula($hora_inicio, $hora_fim, $materia_nome, $turma_nome)
     {
         return '<p>' . substr($hora_inicio, 0, 5) . ' às ' . substr($hora_fim, 0, 5) . ' - ' . $materia_nome . '<br />' . $turma_nome . '</p>';
     }
     $tabela = '';
     $tabela .= '<table id="grade" class="table table-responsive">
                 <tr>
                     <th></th>
                     <th>Segunda</th>
                     <th>Terça</th>
                     <th>Quarta</th>
                     <th>Quinta</th>
                     <th>Sexta</th>
                     <th>Sábado</th>
                 </tr>';
     for ($i = 7; $i < 23; $i++) {
         //            $tabela .= '<tr ' . Util::zebrarGeral($i, 22) . '><th>' . $i . ':00</th>';
         $tabela .= '<tr ' . Util::zebrarGeral($i, 22) . '><td>' . $i . ':00</td>';
         $tabela .= '<td>';
         foreach ($data['aulas_segunda']['registros'] as $row) {
             $horaini = explode(':', $row['hora_inicio']);
             $tabela .= (int) $horaini[0] == $i ? aula($row['hora_inicio'], $row['hora_fim'], $row['materia_nome'], $row['turma_nome']) : '';
         }
         $tabela .= '</td>';
         $tabela .= '<td>';
         foreach ($data['aulas_terca']['registros'] as $row) {
             $horaini = explode(':', $row['hora_inicio']);
             $tabela .= (int) $horaini[0] == $i ? aula($row['hora_inicio'], $row['hora_fim'], $row['materia_nome'], $row['turma_nome']) : '';
         }
         $tabela .= '</td>';
         $tabela .= '<td>';
         foreach ($data['aulas_quarta']['registros'] as $row) {
             $horaini = explode(':', $row['hora_inicio']);
             $tabela .= (int) $horaini[0] == $i ? aula($row['hora_inicio'], $row['hora_fim'], $row['materia_nome'], $row['turma_nome']) : '';
         }
         $tabela .= '</td>';
         $tabela .= '<td>';
         foreach ($data['aulas_quinta']['registros'] as $row) {
             $horaini = explode(':', $row['hora_inicio']);
             $tabela .= (int) $horaini[0] == $i ? aula($row['hora_inicio'], $row['hora_fim'], $row['materia_nome'], $row['turma_nome']) : '';
         }
         $tabela .= '</td>';
         $tabela .= '<td>';
         foreach ($data['aulas_sexta']['registros'] as $row) {
             $horaini = explode(':', $row['hora_inicio']);
             $tabela .= (int) $horaini[0] == $i ? aula($row['hora_inicio'], $row['hora_fim'], $row['materia_nome'], $row['turma_nome']) : '';
         }
         $tabela .= '</td>';
         $tabela .= '<td>';
         foreach ($data['aulas_sabado']['registros'] as $row) {
             $horaini = explode(':', $row['hora_inicio']);
             $tabela .= (int) $horaini[0] == $i ? aula($row['hora_inicio'], $row['hora_fim'], $row['materia_nome'], $row['turma_nome']) : '';
         }
         $tabela .= '</td>';
         $tabela .= '</tr>';
     }
     $tabela .= '</table>';
     $data['tabela'] = $tabela;
     if ($this->input->is_ajax_request()) {
         $this->load->view($this->uri->segment(3), $data);
     } else {
         $this->load->view($this->load->getUrlTema(), $data);
     }
 }