Exemplo n.º 1
0
 public function listar_pes_medias_gerais($pk_pesquisa_cat)
 {
     $data = $this->getParametroVisao();
     $data['page'] = 'home';
     $data['tema'] != '' ? $this->load->setTheme($data['tema']) : '';
     $data['msg'] = $this->getMsg();
     $data['abaAtiva'] = 8;
     $data['abaPage'] = 'listar_pes_medias_gerais';
     $data['alias'] = 'listar_pes_medias_gerais';
     $sqlPesquisa = new SqlPesquisa();
     $result = $sqlPesquisa->listar_pes_medias_gerais($pk_pesquisa_cat);
     $table = '';
     $table .= '<table>';
     $table .= '<tr><td></td><th>6º ano</th><th>7º ano</th><th>8º ano</th><th>9º ano</th><th>1º ano</th><th>2º ano</th><th>3º ano</th></tr>';
     $table .= '<tr><th>Médias</th>';
     $media_fun = 0;
     $media_med = 0;
     $i_fun = 0;
     $i_med = 0;
     foreach ($result as $row) {
         $conceito = View::bgConceito($row['media']);
         $table .= '<td class="' . $conceito['class'] . ' tcenter">' . number_format($row['media'], 1) . '</td>';
         if ($row['fk_serie'] == 6 || $row['fk_serie'] == 7 || $row['fk_serie'] == 8 || $row['fk_serie'] == 9) {
             $i_fun++;
             $media_fun = $media_fun + $row['media'];
         }
         if ($row['fk_serie'] == 11 || $row['fk_serie'] == 12 || $row['fk_serie'] == 13) {
             $i_med++;
             $media_med = $media_med + $row['media'];
         }
     }
     $table .= '</tr>';
     $table .= '</table>';
     $media_fun_final = $media_fun / $i_fun;
     $conceito_fun = View::bgConceito($media_fun_final);
     $media_med_final = $media_med / $i_med;
     $conceito_med = View::bgConceito($media_med_final);
     $table .= '<br /><br /><table>';
     $table .= '<tr><th>Ensino Fundamental</th><td class="' . $conceito_fun['class'] . ' tcenter w50">' . number_format($media_fun_final, 1) . '</td>';
     $table .= '<tr><th>Ensino Médio</th><td class="' . $conceito_fun['class'] . ' tcenter w50">' . number_format($media_med_final, 1) . '</td>';
     $table .= '</tr>';
     $table .= '</table>';
     $data['tabela'] = $table;
     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);
     }
 }