Exemple #1
0
 public function listar_materias()
 {
     $data = $this->getParametroVisao();
     $data['page'] = 'home';
     $data['tema'] != '' ? $this->load->setTheme($data['tema']) : '';
     $data['msg'] = $this->getMsg();
     $data['abaAtiva'] = 1;
     $data['abaPage'] = 'listar_materias';
     if ($_SERVER['REQUEST_METHOD'] == "POST") {
         try {
             // View::validarFormAntInjection($data['alias']);
             $sqlGrade = new SqlGrade();
             $sqlGrade->reset_integral_serie($this->input->post('pk_serie'));
             foreach ($this->input->post('pk_materia_vin') as $pk_materia_vin) {
                 $result = $sqlGrade->update_materia_vin($pk_materia_vin);
             }
             $this->session->set_flashdata('msg', '<div class="alert ok">Pesquisa incluída com sucesso!</div>');
             redirect(base_url() . $this->uri->segment(1) . '/' . $this->uri->segment(2) . '/listar_materias/?pk_serie=' . $this->input->post('pk_serie'));
             return false;
         } catch (Exception $e) {
             $msg = '<p class="alert erro">' . $e->getMessage() . '</p>';
         }
     }
     $sqlGrade = new SqlGrade();
     $result = $sqlGrade->listar_materias();
     $data['total'] = $result['total'];
     $data['serie_nome'] = $result['total'] > 0 ? $result['registros'][0]['serie_nome'] : '';
     if ($result['total'] > 0) {
         $this->load->library('table');
         $arrHead[] = 'Cod.';
         $arrHead[] = 'Materia';
         if (isset($_GET['pk_serie']) && ($_GET['pk_serie'] == 101 || $_GET['pk_serie'] == 102 || $_GET['pk_serie'] == 103 || $_GET['pk_serie'] == 104 || $_GET['pk_serie'] == 105 || $_GET['pk_serie'] == 1 || $_GET['pk_serie'] == 2 || $_GET['pk_serie'] == 3 || $_GET['pk_serie'] == 4 || $_GET['pk_serie'] == 5)) {
             $arrHead[] = 'Integral';
         }
         $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']));
             $pk_materia = array('data' => $row['pk_materia'], 'class' => 'tright');
             $checked = $row['integral'] == 1 ? 'checked' : '';
             $integral = array('data' => '<input type="checkbox" name="pk_materia_vin[]" value="' . $row['pk_materia_vin'] . '" ' . $checked . ' />', 'class' => 'tcenter');
             if (isset($_GET['pk_serie']) && ($_GET['pk_serie'] == 101 || $_GET['pk_serie'] == 102 || $_GET['pk_serie'] == 103 || $_GET['pk_serie'] == 104 || $_GET['pk_serie'] == 105 || $_GET['pk_serie'] == 1 || $_GET['pk_serie'] == 2 || $_GET['pk_serie'] == 3 || $_GET['pk_serie'] == 4 || $_GET['pk_serie'] == 5)) {
                 $this->table->add_row($pk_materia, $row['materia_nome'], $integral);
             } else {
                 $this->table->add_row($pk_materia, $row['materia_nome']);
             }
         }
         $this->table->set_template($tmpl);
     } else {
         $data['msg'] = '<div class="alert atencao">Nenhuma matéria cadastrada até o momento nesta série</div>';
         $data['total'] = $result['total'];
     }
     // Select filtro de serie
     $config['base_url'] = base_url() . $this->uri->segment(1) . '/' . $this->uri->segment(2) . '/' . $this->uri->segment(3) . '/';
     $pk_serie = isset($_GET['pk_serie']) && $_GET['pk_serie'] != '' ? $_GET['pk_serie'] : 0;
     $sqlGrade = new SqlGrade();
     $data['serie'] = $sqlGrade->filtro_series();
     $serie = explode("&pk_serie=", $_SERVER['QUERY_STRING']);
     $data['serie_url'] = $config['base_url'] . '?' . $serie[0];
     if ($this->input->is_ajax_request()) {
         $this->load->view($this->uri->segment(3), $data);
     } else {
         $this->load->view($this->load->getUrlTema(), $data);
     }
     //$this->output->enable_profiler(TRUE);
 }