Esempio n. 1
0
 public function listar_ranking_atrasos()
 {
     $data = $this->getParametroVisao();
     $data['page'] = 'home';
     $data['tema'] != '' ? $this->load->setTheme($data['tema']) : '';
     $data['msg'] = $this->getMsg();
     $data['abaAtiva'] = 8;
     $data['abaPage'] = 'listar_ranking_atrasos';
     $data['alias'] = 'listar_ranking_atrasos';
     $pk_unidade = isset($_GET['pk_unidade']) && $_GET['pk_unidade'] != '' ? $_GET['pk_unidade'] : 0;
     $pk_serie = isset($_GET['pk_serie']) && $_GET['pk_serie'] != '' ? $_GET['pk_serie'] : 0;
     $tipo_lista = $this->uri->segment(3);
     // define os tipos de atrasos
     $tipos_atrasos = array(1, 2, 3, 4);
     // cria a tabela temporária com os dados selecionados
     $sqlFap = new SqlFap();
     $result = $sqlFap->insert_temp_atrasos($tipos_atrasos, $data['ano_letivo']);
     $sqlFap = new SqlFap();
     $result = $sqlFap->listar_ranking_atrasos($data['ano_letivo']);
     $array_result = array();
     foreach ($result['registros'] as $row) {
         $percent = $row['totalatrasos'] / $row['totalaulas'] * 100;
         $array_result[] = array('fk_usuario_professor' => $row['fk_usuario_professor'], 'professor_nome' => $row['professor_previsto'], 'totalaulas' => $row['totalaulas'], 'totalatrasos' => $row['totalatrasos'], 'percent' => $percent, 'fk_usuario' => $row['fk_usuario']);
     }
     foreach ($array_result as &$ma) {
         $tmp[] =& $ma["percent"];
     }
     if (count($array_result) > 0) {
         array_multisort($tmp, SORT_DESC, $array_result);
     }
     $result['registros'] = $array_result;
     if ($result['total'] > 0) {
         $this->load->library('table');
         $arrHead[] = 'Posição';
         $arrHead[] = 'Nome';
         $arrHead[] = 'Aulas';
         $arrHead[] = 'Atrasos';
         $arrHead[] = '%';
         $this->table->set_heading($arrHead);
         $count = 0;
         $i = 0;
         $_SESSION['rankingAnterior'] = 0;
         $_SESSION['indicador'] = 0;
         $ranking = 1;
         foreach ($result['registros'] as $row) {
             $count++;
             $tmpl = Util::zebrar($count, count($result['registros']));
             $i++;
             if (round($row['percent']) == $_SESSION['indicador']) {
                 $ranking = $_SESSION['rankingAnterior'];
             } else {
                 $ranking = $i;
             }
             $cell_ranking = array('data' => $ranking, 'class' => 'tcenter');
             $cell_aulas = array('data' => $row['totalaulas'], 'class' => 'tcenter');
             $cell_atrasos = array('data' => $row['totalatrasos'], 'class' => 'tcenter');
             $this->table->add_row($cell_ranking, '<a rel="shadowbox[Mixed]" href="' . base_url() . $this->uri->segment(1) . '/' . $this->uri->segment(2) . '/detalhe_fap/' . $row['fk_usuario'] . '/' . $row['fk_usuario_professor'] . '?shadowbox=1" class="link">' . $row['professor_nome'] . '</a>', $cell_aulas, $cell_atrasos, round($row['percent']) . '%');
             $_SESSION['indicador'] = round($row['percent']);
             $_SESSION['rankingAnterior'] = $ranking;
         }
         $this->table->set_template($tmpl);
     } else {
         $data['msg'] = '<div class="alert atencao">Nenhum registro encontrado</div>';
         $data['total'] = $result['total'];
     }
     $data['total'] = $result['total'];
     $config['base_url'] = base_url() . $this->uri->segment(1) . '/' . $this->uri->segment(2) . '/' . $this->uri->segment(3) . '/';
     // Select filtro de unidade
     $sqlFap = new SqlFap();
     $data['unidade'] = $sqlFap->listar_unidades_atrasos($tipos_atrasos, $data['ano_letivo']);
     $unidade = explode("&pk_unidade=", $_SERVER['QUERY_STRING']);
     $data['unidade_url'] = $config['base_url'] . '?' . $unidade[0];
     // Select filtro de serie
     $sqlFap = new SqlFap();
     $data['serie'] = $sqlFap->listar_series_atrasos($pk_unidade, $tipos_atrasos, $data['ano_letivo']);
     $serie = explode("&pk_serie=", $_SERVER['QUERY_STRING']);
     $data['serie_url'] = $config['base_url'] . '?' . $serie[0];
     // Select filtro de turmas
     $sqlFap = new SqlFap();
     $data['turma'] = $sqlFap->listar_turmas_atrasos($pk_unidade, $pk_serie, $tipos_atrasos, $data['ano_letivo']);
     $turma = explode("&pk_turma=", $_SERVER['QUERY_STRING']);
     $data['turma_url'] = $config['base_url'] . '?' . $turma[0];
     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);
     }
 }