Ejemplo n.º 1
0
 public function processa_livro()
 {
     $data = $this->getParametroVisao();
     $data['tema'] != '' ? $this->load->setTheme($data['tema']) : '';
     $data['page'] = 'processa_livro';
     $total = count($this->session->userdata('array_livros'));
     $result = $this->session->userdata('array_livros');
     if (isset($_GET['counter'])) {
         $counter = $_GET['counter'] + 1;
     } else {
         $counter = 0;
     }
     // carrega a library e envia as variáveis a função "loop_refresh"
     $this->load->library('util');
     $data['redirect_delay'] = $this->util->loop_refresh('10000', $this->uri->segment(3), $counter, $total);
     if ($counter < $total) {
         $divide = explode('#', $result[$counter]);
         $pk_livro = $divide[0];
         $pk_serie = $divide[1];
         $sqlAula = new SqlAula();
         $result = $sqlAula->get_materias_apostilas($pk_livro);
         $html = '<table class="tabela_relatorio"><tr><td class="titulo_relatorio tcenter w80" nowrap="nowrap">Disciplinas</td>';
         $sqlAula = new SqlAula();
         $turmas = $sqlAula->get_turmas_apostila_process($pk_serie, $data['ano_letivo']);
         foreach ($turmas as $item) {
             if (substr($item['tmacod'], 2, 2) == '11') {
                 $turma_serie = '1º ano';
             } else {
                 if (substr($item['tmacod'], 2, 2) == '12') {
                     $turma_serie = '2º ano';
                 } else {
                     if (substr($item['tmacod'], 2, 2) == '13') {
                         $turma_serie = '3º ano';
                     }
                 }
             }
             $html .= '<td class="titulo_relatorio">
                         ' . $item['pk_turma'] . '
                       </td>';
             $arr_turmas[] = $item['pk_turma'];
         }
         $html .= '</tr>';
         foreach ($result as $row) {
             $html .= '<tr><td>
                             <a class="link" href="' . base_url() . 'aula/cron/processa_livro?counter=' . $_GET['counter'] . '&pk_materia_vin=' . $row['fk_materia_vin'] . '">' . $row['materia_nome'] . '</a>
                       </td></tr>';
         }
         $html .= '</table>';
         $data['html'] = $html;
     }
     var_dump($pk_livro);
     if (isset($_GET['pk_materia_vin'])) {
         if (isset($arr_turmas)) {
             foreach ($arr_turmas as $pk_turma) {
                 $sqlAula = new SqlAula();
                 $result = $sqlAula->get_apostila_acompanhamento($_GET['pk_materia_vin'], $pk_turma, $pk_livro);
                 $percent = !empty($result) ? number_format($result['0']['percentual'], 1) : null;
                 $sqlCron = new SqlCron();
                 $sqlCron->reset_dados($pk_livro, $pk_turma, $_GET['pk_materia_vin']);
                 $sqlCron = new SqlCron();
                 $sqlCron->inclui_dados($pk_livro, $pk_turma, $_GET['pk_materia_vin'], $percent);
             }
         } else {
             $data['msg'] = '<div class="alert atencao">Nenhuma aula registrada na frente selecionada até o momento.</div>';
         }
         $html .= '</tr>';
     }
     $this->load->view($this->load->getUrlTema(), $data);
 }