Exemple #1
0
 public function incluir_professor($pk_pesquisa)
 {
     $msg = null;
     $data = $this->getParametroVisao();
     $data['page'] = 'home';
     $data['tema'] != '' ? $this->load->setTheme($data['tema']) : '';
     $data['msg'] = $msg;
     $data['abaAtiva'] = 8;
     $data['abaPage'] = 'incluir_professor';
     $data['alias'] = 'incluir_professor';
     if ($this->uri->segment(6) != '') {
         try {
             $fk_pesquisa = $this->uri->segment(4);
             $ordem = $this->uri->segment(5) - 1;
             $fk_materia_vin = $this->uri->segment(6);
             $fk_usuario_professor = $this->uri->segment(7);
             $sqlPesquisa = new SqlPesquisa();
             $result = $sqlPesquisa->get_questoes($fk_pesquisa);
             foreach ($result['registros'] as $row) {
                 $ordem++;
                 $sqlPesquisa = new SqlPesquisa();
                 $chaves_questao = $sqlPesquisa->insert_professor($ordem, $row['pk_pes_questao'], $fk_materia_vin, $fk_usuario_professor);
             }
             $this->session->set_flashdata('msg', '<p class="alert ok">Professor incluído com sucesso!<br />Para incluir um novo professor, clique no link acima.</p>');
             redirect(base_url() . $this->uri->segment(1) . '/' . $this->uri->segment(2) . '/listar_gabarito/' . $fk_pesquisa);
             return false;
         } catch (Exception $e) {
             $msg = '<p class="alert erro">' . $e->getMessage() . '</p>';
         }
     }
     $sqlPesquisa = new SqlPesquisa();
     $result = $sqlPesquisa->get_pesquisa($pk_pesquisa);
     $fk_turma = $result[0]['fk_turma'];
     $sqlPesquisa = new SqlPesquisa();
     $result = $sqlPesquisa->listar_grades($fk_turma);
     $data['total'] = $result['total'];
     if ($result['total'] > 0) {
         $this->load->library('table');
         $arrHead[] = 'Professor.';
         $arrHead[] = 'Disciplina';
         $arrHead[] = 'Turma';
         $arrHead[] = '';
         $this->table->set_heading($arrHead);
         $count = 0;
         foreach ($result['registros'] as $row) {
             $count++;
             $this->load->library('util');
             $tmpl = $this->util->zebrar($count, count($result['registros']));
             $this->table->add_row($row['professor_nome'], $row['materia_nome'], $row['turma_nome'], '<a class="link" href="' . base_url() . $this->uri->segment(1) . '/' . $this->uri->segment(2) . '/' . $this->uri->segment(3) . '/' . $this->uri->segment(4) . '/' . $this->uri->segment(5) . '/' . $row['fk_materia_vin'] . '/' . $row['fk_usuario_professor'] . '">incluir</a>');
         }
         $this->table->set_template($tmpl);
     }
     if ($this->input->is_ajax_request()) {
         echo json_encode(array('content' => $this->load->view($this->uri->segment(3), $data, true)));
     } else {
         $this->load->view($this->load->getUrlTema(), $data);
     }
 }