$escolaController->update($escola); if ($_POST['imagem'] != '') { if ($_POST['imagem'] != $imagemAntiga) { $imag = getimagesize("../temporaria/" . $_POST["imagem"]); gerar_tumbs_real(100, 100, 100, "../temporaria/" . $_POST["imagem"], "../imgm/" . $_POST["imagem"]); gerar_tumbs_real(65, 65, 100, "../temporaria/" . $_POST["imagem"], "../imgp/" . $_POST["imagem"]); $usuario->setUsr_imagem($_POST['imagem']); } } $usuario->setUsr_nome(utf8_decode($_POST['nomeEscola'])); $usuario->setUsr_login($_POST["loginEscola"]); if ($_POST["senhaEscola"] != '') { $usuario->setUsr_senha(md5($_POST["senhaEscola"])); } $usuario->setUsr_nse($_POST['nse']); $usuarioController->update($usuario); $result = array('erro' => false, 'msg' => 'Editou com sucesso!'); } echo json_encode($result); break; case 'listaProfessoresByEscolaAndSerie': $usuarioController = new UsuarioController(); $professores = $usuarioController->buscaProfessorByEscolaAndSerie($_POST['escola'], $_POST['serie']); $html = ''; if (count($professores) > 0) { $html .= '<option value="" disabled selected>Selecione um professor</option>'; foreach ($professores as $p) { $html .= '<option value="' . $p['idUsuario'] . '_' . $p['idGrupo'] . '">' . utf8_encode($p['nome']) . ' (' . $p['periodo'] . ') </option>'; } } else { $html .= '<option value="" disabled selected>Nenhum professor encontrado</option>';
} $res = UsuarioController::insert($_POST); if ($res) { echo "<script>javascript:history.back(-1)</script>"; exit; } else { die("ERRO"); } } else { if (isset($_POST['novaSenha']) && isset($_POST['confirmarNovaSenha'])) { $validate = UsuarioController::validPasswords($_POST['novaSenha'], $_POST['confirmarNovaSenha']); if ($validate == false) { echo "<script>javascript:history.back(-1)</script>"; exit; } } $res = UsuarioController::update($_POST); if ($res) { header("Location: usuarios"); exit; } else { die("ERRO"); } } } elseif ($_POST['action'] == "del") { if (UsuarioController::delete($_POST)) { die("OK"); } else { die("ERRO"); } }