1
|
|
|
<?php |
2
|
|
|
error_reporting(E_ALL); |
3
|
|
|
ini_set('display_errors', 'On'); |
4
|
|
|
require_once '../bootstrap.php'; |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* NOTA: Se não houver indicação de CPF ou da matricula os dados retornados |
8
|
|
|
* pode ser ENORMES e causar TIMEOUT ou até impossibilitar a visualização pelo |
9
|
|
|
* browser |
10
|
|
|
*/ |
11
|
|
|
use NFePHP\Atende\Atende; |
12
|
|
|
use NFePHP\Atende\Response; |
13
|
|
|
|
14
|
|
|
$user = '<coloque sua identificação>'; |
15
|
|
|
$password = '<coloque sua senha>'; |
16
|
|
|
$cidade = '<nome da cidade>'; |
17
|
|
|
$codcidade = '<codigo>'; |
18
|
|
|
|
19
|
|
|
//NOTA: em caso de falha será disparado um exception |
20
|
|
|
try { |
21
|
|
|
$anomes = 201612; //indique a competência (OBRIGATÓRIO) formato aaamm |
22
|
|
|
$pagina = null; //(OPCIONAL) |
23
|
|
|
$cpf = '<indique o cpf>'; //o CPF é formatado (OPCIONAL) |
24
|
|
|
$numeroMatricula = null; |
25
|
|
|
$tipo = null;//1-Ativo; 2-Aposentado; 3-Pensionista. (OPCIONAL) |
|
|
|
|
26
|
|
|
$codigoRegime = null;//1-CLTista; 2-Estaturário (OPCIONAL) |
|
|
|
|
27
|
|
|
|
28
|
|
|
$at = new Atende($user, $password, $cidade, $codcidade); |
29
|
|
|
//seta o ambiente 1-produção 2-homologacao |
30
|
|
|
$at->setAmbiente(2); |
31
|
|
|
//ativa debug USAR APENAS durante o desenvolvimento |
32
|
|
|
$at->setDebugMode(true); |
33
|
|
|
//define o tempo de timeout |
34
|
|
|
//CUIDADO com esse numero deverá ser compativel com o limite |
35
|
|
|
//de execução do PHP (ver. php.ini) |
36
|
|
|
$at->setSoapTimeOut(100); |
37
|
|
|
|
38
|
|
|
//NOTA: $xml irá conter o envelope SOAP retornado |
39
|
|
|
$xml = $at->getContribuicao( |
40
|
|
|
$anomes, |
41
|
|
|
$pagina, |
42
|
|
|
$cpf, |
43
|
|
|
$numeroMatricula, |
44
|
|
|
$tipo, |
45
|
|
|
$codigoRegime |
46
|
|
|
); |
47
|
|
|
|
48
|
|
|
//$json conterá os dados de retorno em uma string json |
49
|
|
|
$json = Response::toJson($xml); |
50
|
|
|
//echo "<pre>"; |
51
|
|
|
//print_r($json); |
52
|
|
|
//echo "</pre>"; |
53
|
|
|
|
54
|
|
|
|
55
|
|
|
//$arr conterá os dados de retorno em um array |
56
|
|
|
$arr = Response::toArray($xml); |
57
|
|
|
//echo "<pre>"; |
58
|
|
|
//print_r($arr); |
59
|
|
|
//echo "</pre>"; |
60
|
|
|
|
61
|
|
|
//$std conterá os dados de retorno em um stdClass |
62
|
|
|
$std = Response::toStd($xml); |
63
|
|
|
//echo "<pre>"; |
64
|
|
|
//print_r($std); |
65
|
|
|
//echo "</pre>"; |
66
|
|
|
|
67
|
|
|
header('Content-type: text/xml; charset=UTF-8'); |
68
|
|
|
echo $xml; |
69
|
|
|
|
70
|
|
|
} catch (\RuntimeException $e) { |
71
|
|
|
echo $e->getMessage(); |
72
|
|
|
} catch (\Exception $e) { |
73
|
|
|
echo $e->getMessage(); |
74
|
|
|
} |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.