-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbatchReceita.php
87 lines (73 loc) · 2.88 KB
/
batchReceita.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
session_start();
ini_set("max_execution_time", 0);
require_once("classes/Empresa.php");
require_once('classes/CaptchaProxy.php');
require_once("classes/ReceitaFederal.php");
header('Content-type: text/html; charset=iso-8859-1');
$captchaProxy = new CaptchaProxy();
$captchaInfo = $captchaProxy->obterCaptcha();
if (!is_array($captchaInfo)) {
echo "<pre>";
var_dump($captchaProxy);
var_dump($captchaInfo);
echo 'Não foi possível obter Captcha e Token';
exit;
}
$empresas = Empresa::obterEmpresaSemReceitaFederal();
?>
<!DOCTYPE html>
<html>
<head>
<title>TCC - Rodolfo Andrade</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<script>
$(document).ready(function() {
$("#captcha").focus();
$("#receita").submit(function()
{
$.ajax({
type: "POST",
url: 'grava-receita-federal.php',
data: {
cnpj: $("#cnpj").val(),
captcha: $("#captcha").val(),
viewstate: $("#viewstate").val(),
idEmpresa: $("#idEmpresa").val()
}
}).done(function(data)
{
alert(data);
location.reload();
});
return false;
});
});
</script>
<style>
body {
font-family: "Trebuchet MS", "Helvetica", "Arial", "Verdana", "sans-serif";
font-size: 70%;
}
</style>
</head>
<body>
<form name="receita" id="receita">
Empresas a serem cadastradas com CNPJ: <?php echo count($empresas); ?>
<br />
<input name="cnpj" id="cnpj" type="hidden" value="<?php echo reset($empresas); ?>"/>
<br />
<img src="receitaToken.php?id=<?php echo $captchaInfo[0]; ?>" border="0" />
<br />
<input name="captcha" id="captcha" type="text" maxlength="6" required />
<b style="color: red">O que vê na imagem acima?</b>
<br />
<input type="hidden" id="viewstate" name="viewstate" value="<?php echo $captchaInfo[1]; ?>" />
<input type="hidden" id="idEmpresa" name="idEmpresa" value="<?php echo key($empresas); ?>" />
<input type="submit" id="gravar" value="Acessar RFB"/>
</form>
<div id="resp"> </div>
</body>
</html>