public function listar_inscritos_notas($fk_rec_modulo, $limiteInicial = 0, $qtdPorPagina = 60) { $msg = null; $data = $this->getParametroVisao(); $data['page'] = 'home'; $data['tema'] != '' ? $this->load->setTheme($data['tema']) : ''; $data['msg'] = $msg; $data['abaAtiva'] = 17; $data['abaPage'] = 'listar_inscritos_notas'; $data['alias'] = 'listar_inscritos_notas'; $data['tabela'] = ''; if ($_SERVER['REQUEST_METHOD'] == "POST") { try { // $this->load->validarFormAntInjection($data['alias']); // ATUALIZAÇÃO DAS NOTAS // Atualiza os campos notas da matéria 1 if ($this->input->post('nota1') != '') { $pk_usuario_aluno = $this->input->post('pk_usuario_aluno1'); $pk_rec_dia_aula = $this->input->post('pk_rec_dia_aula1'); $nota = $this->input->post('nota1'); $nota_mestre = $this->input->post('nota_mestre1'); $total = count($pk_usuario_aluno); for ($i = 0; $i < $total; $i++) { $nota_final = $nota[$i] != '' ? floatval(str_replace(',', '.', $nota[$i])) : 0; $nota_mestre_final = $nota_mestre[$i] != '' ? floatval(str_replace(',', '.', $nota_mestre[$i])) : 0; $sqlRecuperacao = new SqlRecuperacao(); $result = $sqlRecuperacao->update_nota($pk_rec_dia_aula[$i], $pk_usuario_aluno[$i], $nota_final, $nota_mestre_final); } } // Atualiza os campos notas da matéria 2 if ($this->input->post('nota2') != '') { $pk_usuario_aluno = $this->input->post('pk_usuario_aluno2'); $pk_rec_dia_aula = $this->input->post('pk_rec_dia_aula2'); $nota = $this->input->post('nota2'); $nota_mestre = $this->input->post('nota_mestre2'); $total = count($pk_usuario_aluno); for ($i = 0; $i < $total; $i++) { $nota_final = $nota[$i] != '' ? floatval(str_replace(',', '.', $nota[$i])) : 0; $nota_mestre_final = $nota_mestre[$i] != '' ? floatval(str_replace(',', '.', $nota_mestre[$i])) : 0; // echo $pk_rec_dia_aula[$i].' - '.$pk_usuario_aluno[$i].' - '.$nota_final.' - '.$nota_mestre_final.'<br />'; $sqlRecuperacao = new SqlRecuperacao(); $result = $sqlRecuperacao->update_nota($pk_rec_dia_aula[$i], $pk_usuario_aluno[$i], $nota_final, $nota_mestre_final); } } // Atualiza os campos notas da matéria 3 if ($this->input->post('nota3') != '') { $pk_usuario_aluno = $this->input->post('pk_usuario_aluno3'); $pk_rec_dia_aula = $this->input->post('pk_rec_dia_aula3'); $nota = $this->input->post('nota3'); $nota_mestre = $this->input->post('nota_mestre3'); $total = count($pk_usuario_aluno); for ($i = 0; $i < $total; $i++) { $nota_final = $nota[$i] != '' ? floatval(str_replace(',', '.', $nota[$i])) : 0; $nota_mestre_final = $nota_mestre[$i] != '' ? floatval(str_replace(',', '.', $nota_mestre[$i])) : 0; $sqlRecuperacao = new SqlRecuperacao(); $result = $sqlRecuperacao->update_nota($pk_rec_dia_aula[$i], $pk_usuario_aluno[$i], $nota_final, $nota_mestre_final); } } // PROCESSAR BÔNUS // if ($this->input->post('processar') == 'Processar Bonus') { $bonusSomaMat = 0; $bonusFinalMat = 0; $bonusPercentualMat = 0; $bonusPercentualFinalMat = 0; $bonusAritMat = 0; $bonusSomaFis = 0; $bonusFinalFis = 0; $bonusPercentualFis = 0; $bonusPercentualFinalFis = 0; $bonusAritFis = 0; $bonusSomaQui = 0; $bonusFinalQui = 0; $bonusPercentualQui = 0; $bonusPercentualFinalQui = 0; $bonusAritQui = 0; // pega os alunos do módulo $sqlRecuperacao = new SqlRecuperacao(); $result = $sqlRecuperacao->get_alunos_inscritos($this->input->post('pk_rec_modulo')); foreach ($result as $row) { $sqlRecuperacao = new SqlRecuperacao(); $result = $sqlRecuperacao->get_dias_aulas_aluno($this->input->post('pk_rec_modulo'), $row['fk_usuario_aluno']); $bonusAssiduidade = 0; foreach ($result as $item) { if ($item['presenca'] == 1) { $bonusAssiduidade++; } } $bonusAssiduidadeFinal = $bonusAssiduidade / 10 * 1.34; foreach ($result as $item) { if ($item['mat_discod'] == 'MATEM') { $bonusPercentualMat = ($item['nota_teste'] - $item['nota_mestre']) / 10; $bonusPercentualFinalMat = $bonusPercentualMat > 0 ? $bonusPercentualMat : 0; $bonusAritMat = Mestre::bonusAritmetico($item['nota_teste']); } else { if ($item['mat_discod'] == 'FISIC') { $bonusPercentualFis = ($item['nota_teste'] - $item['nota_mestre']) / 10; $bonusPercentualFinalFis = $bonusPercentualFis > 0 ? $bonusPercentualFis : 0; $bonusAritFis = Mestre::bonusAritmetico($item['nota_teste']); } else { if ($item['mat_discod'] == 'QUIMI') { $bonusPercentualQui = ($item['nota_teste'] - $item['nota_mestre']) / 10; $bonusPercentualFinalQui = $bonusPercentualQui > 0 ? $bonusPercentualQui : 0; $bonusAritQui = Mestre::bonusAritmetico($item['nota_teste']); } } } } $bonusSomaMat = $bonusAssiduidadeFinal + $bonusPercentualFinalMat + $bonusAritMat; $bonusFinalMat = Mestre::limitBonus($bonusSomaMat); $sqlRecuperacao = new SqlRecuperacao(); $result = $sqlRecuperacao->get_dias_aula_mat($this->input->post('pk_rec_modulo'), 'MATEM'); $sqlRecuperacao = new SqlRecuperacao(); $sqlRecuperacao->update_bonus($result[0]['pk_rec_dia_aula'], $row['fk_usuario_aluno'], $bonusFinalMat); $bonusSomaFis = $bonusAssiduidadeFinal + $bonusPercentualFinalFis + $bonusAritFis; $bonusFinalFis = Mestre::limitBonus($bonusSomaFis); $sqlRecuperacao = new SqlRecuperacao(); $result = $sqlRecuperacao->get_dias_aula_mat($this->input->post('pk_rec_modulo'), 'FISIC'); if (count($result) > 0) { $sqlRecuperacao = new SqlRecuperacao(); $sqlRecuperacao->update_bonus($result[0]['pk_rec_dia_aula'], $row['fk_usuario_aluno'], $bonusFinalFis); } $bonusSomaQui = $bonusAssiduidadeFinal + $bonusPercentualFinalQui + $bonusAritQui; $bonusFinalQui = Mestre::limitBonus($bonusSomaQui); $sqlRecuperacao = new SqlRecuperacao(); $result = $sqlRecuperacao->get_dias_aula_mat($this->input->post('pk_rec_modulo'), 'QUIMI'); if (count($result) > 0) { $sqlRecuperacao = new SqlRecuperacao(); $sqlRecuperacao->update_bonus($result[0]['pk_rec_dia_aula'], $row['fk_usuario_aluno'], $bonusFinalQui); } } } $this->session->set_flashdata('msg', '<div class="alert ok">Atualizações efetuadas com sucesso!</div>'); redirect(base_url() . $this->uri->segment(1) . '/' . $this->uri->segment(2) . '/listar_inscritos_notas/' . $this->input->post('pk_rec_modulo')); return false; } catch (Exception $e) { $msg = '<p class="alert erro">' . $e->getMessage() . '</p>'; } } $sqlRecuperacao = new SqlRecuperacao(); $result = $sqlRecuperacao->get_modulo_tipo($this->uri->segment(4)); $data['modulo'] = $result[0]['titulo_modulo']; $data['serie'] = $result[0]['serie_nome']; $data['referencia'] = $result[0]['referencia']; $data['fk_serie'] = $result[0]['fk_serie']; $data['fk_unidade'] = $result[0]['fk_unidade']; $sqlRecuperacao = new SqlRecuperacao(); $result = $sqlRecuperacao->listar_inscritos($this->uri->segment(4), $limiteInicial, $qtdPorPagina, $data['referencia']); $data['total'] = $result['total']; $data['totalRegistros'] = View::paginacao($data['total']); $querystring = $_SERVER['QUERY_STRING'] != '' ? '?' . $_SERVER['QUERY_STRING'] : ''; $config['base_url'] = base_url() . $this->uri->segment(1) . '/' . $this->uri->segment(2) . '/' . $this->uri->segment(3) . '/'; $config['total_rows'] = $data['total']; $config['per_page'] = $qtdPorPagina; $anterior = ''; $proximo = ''; if ($limiteInicial > 0) { $anterior = '<a class="link right" href="' . $config['base_url'] . $this->uri->segment(4) . '/' . ($limiteInicial - $qtdPorPagina) . '">Anterior</a>'; } if ($limiteInicial < $qtdPorPagina) { $anterior = '<a class="link right" href="' . $config['base_url'] . $this->uri->segment(4) . '/' . ($limiteInicial + $qtdPorPagina) . '">Próximo</a>'; } $paginacao = $anterior . $proximo; $data['paginacao'] = $paginacao; if ($data['total'] > 0) { $sqlRecuperacao = new SqlRecuperacao(); $aulas = $sqlRecuperacao->get_dias_aulas($this->uri->segment(4)); $tabela = '<table>'; if ($data['fk_serie'] > 9) { $tabela .= '<tr> <th rowspan="2">Alunos</th> <th colspan="3">Notas (referência / testes)</th> <th colspan="3">Bônus finais</th> </tr> <tr>'; } else { $tabela .= '<tr> <th rowspan="2">Alunos</th> <th rowspan="2">Notas</th> <th rowspan="2">Bônus finais</th> </tr> <tr>'; } if ($data['fk_serie'] > 9) { foreach ($aulas as $item) { $tabela .= '<th class="w80">' . substr($item['mat_discod'], 0, 3) . '</th>'; } foreach ($aulas as $item) { $tabela .= '<th class="w30">' . substr($item['mat_discod'], 0, 3) . '</th>'; } } else { $tabela .= '<th class="w30">Aula 1</th>'; $tabela .= '<th class="w30">Aula 2</th>'; $tabela .= '<th class="w30">Aula 3</th>'; } $tabela .= '</tr>'; foreach ($result['registros'] as $row) { $divide = explode(',', $row['arr_presenca']); $check_mat1 = $divide[0]; $check_mat2 = $divide[1]; $check_mat3 = $divide[2]; $divide = explode(',', $row['arr_notas_mestre']); $mestre_mat1 = $divide[0]; $mestre_mat2 = $divide[1]; $mestre_mat3 = $divide[2]; $divide = explode(',', $row['arr_nota_teste']); $nota_mat1 = $divide[0]; $nota_mat2 = $divide[1]; $nota_mat3 = $divide[2]; $divide = explode(',', $row['arr_bonus']); $bonus_mat1 = $divide[0]; $bonus_mat2 = $divide[1]; $bonus_mat3 = $divide[2]; $tabela .= '<tr> <td>' . $row['nome'] . '</td>'; // campos de inclusão de notas $i = 0; foreach ($aulas as $item) { $i++; if ($i == 1) { $nota = $nota_mat1 != 0 ? $nota_mat1 : ''; $nota_mestre = $mestre_mat1 != '-1' ? $mestre_mat1 : ''; } else { if ($i == 2) { $nota = $nota_mat2 != 0 ? $nota_mat2 : ''; $nota_mestre = $mestre_mat2 != '-1' ? $mestre_mat2 : ''; } else { if ($i == 3) { $nota = $nota_mat3 != 0 ? $nota_mat3 : ''; $nota_mestre = $mestre_mat3 != '-1' ? $mestre_mat3 : ''; } } } if ($data['fk_serie'] < 10 && $i < 3) { } else { $tabela .= '<td class="grifo_cinza"><div class="w10 left padding10">' . $nota_mestre . '</div> <input type="text" name="nota' . $i . '[]" value="' . $nota . '" class="w20 tcenter"> <input type="hidden" name="nota_mestre' . $i . '[]" value="' . $nota_mestre . '"> <input type="hidden" name="pk_rec_dia_aula' . $i . '[]" value="' . $item['pk_rec_dia_aula'] . '"> <input type="hidden" name="pk_usuario_aluno' . $i . '[]" value="' . $row['pk_usuario_aluno'] . '"> </td>'; } } // exibição dos bônus finais $i = 0; foreach ($aulas as $item) { $i++; if ($i == 1) { $bonus = $bonus_mat1; } else { if ($i == 2) { $bonus = $bonus_mat2; } else { if ($i == 3) { $bonus = $bonus_mat3; } } } if ($data['fk_serie'] < 10 && $i > 1) { } else { $tabela .= '<td class="tcenter">' . number_format($bonus, 2) . '</td>'; } } $tabela .= '</tr>'; } $tabela .= '</table>'; $data['tabela'] = $tabela; } else { $data['msg'] = '<div class="alert atencao">Nenhum aluno inscrito neste módulo. Para incluir alunos <a class="link" href="' . base_url() . 'recuperacao/paralela/cadastrar_alunos/' . $this->uri->segment(4) . '?fk_unidade=' . $data['fk_unidade'] . '&fk_serie=' . $data['fk_serie'] . '">clique aqui</a></div>'; $data['total'] = count($result['total']); } $this->load->view($this->load->getUrlTema(), $data); }