Completed
Pull Request — master (#83)
by
unknown
11:11
created

testaMakeMDFe.php ➔ timezone_offset_string()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
/**@category  Teste
3
 * @package   Spedmdfeexamples
4
 * @copyright 2009-2016 NFePHP
5
 * @name      testaMakeMDFe.php
6
 * @license   http://www.gnu.org/licenses/gpl.html GNU/GPL v.3
7
 * @link      http://github.com/nfephp-org/sped-cte for the canonical source repository
8
 * @author    Maison K. Sakamoto <[email protected]> 
9
 * 
10
 * TESTE PARA A VERSÃO 3.0 do MDFe
11
 **/
12
error_reporting(E_ALL);
13
ini_set('display_errors', 'On');
14
15
require_once '../bootstrap.php';
16
17
use NFePHP\MDFe\Make;
18
use NFePHP\MDFe\Tools;
19
20
function timezone_offset_string()
0 ignored issues
show
Bug introduced by
The call to Tools::__construct() misses a required argument $certificate.

This check looks for function calls that miss required arguments.

Loading history...
21
{
22
    $offset = timezone_offset_get(new DateTimeZone('America/Sao_Paulo'), new DateTime());
23
    return sprintf("%s%02d:%02d", ( $offset >= 0 ) ? '+' : '-', abs($offset / 3600), abs($offset % 3600));
24
}
25
26
$make= new Make();
27
$tools = new Tools('../config/config.json');
0 ignored issues
show
Bug introduced by
The call to Tools::__construct() misses a required argument $certificate.

This check looks for function calls that miss required arguments.

Loading history...
28
$dhEmi = date("Y-m-d\TH:i:s".timezone_offset_string());
29
30
//$cteTools->aConfig['siglaUF'] = $obj->emitenteUFNome;                       // SIGLA DA UF
31
//$cteTools->aConfig['cnpj']= Formatador::somenteNumeros($obj->emitenteCNPJ); // CNPJ do emitente
32
//$cteTools->aConfig['ie']= Formatador::somenteNumeros($obj->emitenteIE);     // Inscricao estadual
33
//$cteTools->aConfig['razaosocial']=$obj->emitenteRazao;                      // Razao social
34
$tools->aConfig['nomefantasia']="BARTHOLO TRANSPORTES RODOVIARIOS LTDA"; // Nome fantasia
0 ignored issues
show
Bug introduced by
The property aConfig does not seem to exist. Did you mean config?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
35
$tools->aConfig['schemesCTe']="PL_CTe_300"; // Versao do XML
0 ignored issues
show
Bug introduced by
The property aConfig does not seem to exist. Did you mean config?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
36
$tools->aConfig['pathXmlUrlFileCTe']="cte_ws3.xml";
0 ignored issues
show
Bug introduced by
The property aConfig does not seem to exist. Did you mean config?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
37
38
$cUF = '41';        // 41-PR, 42-SC
39
$tpAmb = '2';       // 1-Producao(versao fiscal), 2-Homologacao(versao de teste)
40
$mod = '58';        // Modelo do documento fiscal: 58 para identificação do MDF-e
41
$serie = '1';       // Serie do MDFe
42
$tpEmis = '1';      // Forma de emissao do MDFe: 1-Normal; 2- Contingencia
43
$numeroMDFe = '104';
44
$cMDF = '00000010';
45
46
47
$chave = $make->montaChave(
48
    $cUF,                // Codigo da UF da tabela do IBGE: 41-PR
49
    $ano = date('y', strtotime($dhEmi)),
50
    $mes = date('m', strtotime($dhEmi)),
51
    $cnpj = $tools->aConfig['cnpj'],
0 ignored issues
show
Bug introduced by
The property aConfig does not seem to exist. Did you mean config?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
52
    $mod,                   // Modelo do documento fiscal: 58 para identificação do MDF-e
53
    $serie,                 // Serie do MDFe
54
    $numero = $numeroMDFe,  // Numero do MDFe
55
    $tpEmis,                // Forma de emissao do MDFe: 1-Normal; 2- Contingencia
56
    $cCT = $cMDF            // Código aleatório gerado pelo emitente
57
);
58
59
$make->taginfMDFe($chave, $versao = '3.00');
60
61
$cDV = substr($chave, -1);      //Digito Verificador
62
$make->tagide(
63
    $cUF,                   // Codigo da UF da tabela do IBGE: 41-PR
64
    $tpAmb,                 // 1-Producao(versao fiscal), 2-Homologacao(versao de teste)
65
    $tpEmit = '1',          // 1-Prestador de serviço de transporte 2-Transportador de Carga Própria
66
    $tpTransp = '',         // 1-ETC 2-TAC 3-CTC (facultativo)
67
    $mod,                   // Modelo do documento fiscal: 58 para identificação do MDF-e
68
    $serie,                 // Serie do MDFe
69
    $nMDF = $numeroMDFe,    // Numero do Manifesto
70
    $cMDF = $cMDF,          // Código aleatório gerado pelo emitente
71
    $cDV,                   // Digito Verificador
72
    $modal = '1',           // 1-Rodoviário; 2-Aéreo; 3-Aquaviário; 4-Ferroviário.
73
    $dhEmi,                 // Data e hora de emissão do Manifesto (Formato AAAA-MM-DDTHH:MM:DD TZD)
74
    $tpEmis,                // 1-Normal; 2-Contingência
75
    $procEmi = '0',         // 0-Aplicativo do Contribuinte; 3-Aplicativo fornecido pelo Fisco
76
    $verProc = '3',         // Informar a versão do aplicativo emissor de MDF-e.
77
    $UFIni = 'PR',          // Sigla da UF do Carregamento
78
    $UFFim = 'SC',          // Sigla da UF do Descarregamento
79
    $dhIniViagem = ''
80
);
81
82
$make->tagInfMunCarrega(
83
    $cMunCarrega = '4108304',           // Código do Município de Carregamento (IBEGE)
84
    $xMunCarrega = 'Foz do Iguacu'      // Nome do Municipio de CArregamento
85
);
86
87
$make->tagemit(
88
    $CNPJ = '81450900000132',
89
    $IE = '4220816074',
90
    $xNome = 'BARTHOLO TRANSPORTES RODOVIARIOS LTDA',
91
    $xFant = 'BARTHOLO TRANSPORTES RODOVIARIOS LTDA'
92
);
93
94
$make->tagenderEmit(
95
    $xLgr = 'RUA CARLOS LUZ',
96
    $nro = '1',
97
    $xCpl = '',
98
    $xBairro = 'PARQUE PRESIDENTE',
99
    $cMun = '4108304',
100
    $xMun = 'Foz do Iguacu',
101
    $CEP = '85863150',
102
    $UF = 'PR',                       // Sigla da UF, , informar EX para operações com o exterior
103
    $fone = '35221216',
104
    $email = '[email protected]'
105
);
106
107
$make->tagInfModal($versaoModal = '3.00');
108
109
$make->tagInfANTT(
110
    $RNTRC = '00739357'
111
);
112
113
$make->tagInfcontratante(
114
    $cpf = '',
115
    $cnpj = '79525242000159'
116
);
117
118
$make->tagCondutor(
119
    $xNome = 'VALDIR NUNES GOMES',
120
    $propCPF = '01754762921'
121
);
122
123
$make->tagVeicTracao(
124
    $cInt = '123',     // Código interno do veículo
125
    $placa = 'BEH6886',
126
    $tara = '16500',
127
    $capKG = '25500',
128
    $capM3 = '100',
129
    $tpRod = '03',      // 01 - Truck; 02 - Toco; 03 - Cavalo Mecânico; 04 - VAN; 05 - Utilitário; 06 - Outros.
130
    $tpCar = '02',      // 00-não aplicável; 01-Aberta; 02-Fechada/Baú; 03-Granelera; 04-Porta Container; 05-Sider
131
    $UF = 'PR',
132
    $propRNTRC = '',
133
    $RENAVAM = '00588892793'
134
);
135
136
$make->tagInfMunDescarga(
137
    $nItem = 0,               // index do array ( podem ser varios )
138
    $cMunDescarga = '4202404',
139
    $xMunDescarga = 'Blumenau'
140
);
141
142
$make->tagInfCTe(
143
    $nItem = 0,             // index do array ( podem ser varios )
144
    $chCTe = '42171081450900000566570010000001571000000100',
145
    $segCodBarra = '',
146
    $indReentrega = ''
147
);
148
149
150
$make->tagInfResp(
151
    $respSeg = '1', // Responsável pelo seguro [1-Emitente; 2-Resp. pela contratação do serviço de transporte]
152
    $CNPJ = '81450900000566',
153
    $CPF = ''
154
);
155
$make->tagInfSeg(
156
    $xSeg = 'CHUBB SEGUROS',  // Nome da Seguradora
157
    $CNPJ = '07476410000124'  // CNPJ da seguradora
158
);
159
$make->tagSeg(
160
    $nApol = '13128-001',     // Número da Apólice
161
    $nAver = '1089'           // Número da Averbação
162
);
163
$make->tagTot(
164
    $qCTe = '1',            // Quantidade total de CT-e relacionados no Manifesto
165
    $qNFe = '',             // Quantidade total de NF-e relacionadas no Manifesto
166
    $qMDFe = '',            // Quantidade total de MDF-e relacionados no Manifesto Aquaviário
167
    $vCarga = '21627.26',   // Valor total da carga / mercadorias transportadas
168
    $cUnid = '01',          // Codigo da unidade de medida do Peso Bruto da Carga / Mercadorias transportadas
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
169
    $qCarga = '55.8200'    // Peso Bruto Total da Carga / Mercadorias transportadas
170
);
171
172
$make->tagautXML(
173
    $cnpj = '04898488000177'  // CNPJ do autorizado
174
);
175
176
$resp = $make->montaMDFe();
177
$filename = "../xml/{$chave}-mdfe.xml";
178 View Code Duplication
if ($resp) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
179
    //header('Content-type: text/xml; charset=UTF-8');
180
    $xml = $make->getXML();
181
    file_put_contents($filename, $xml);
182
    //chmod($filename, 0777);
183
    //echo $xml;
0 ignored issues
show
Bug introduced by
The method assina() does not seem to exist on object<NFePHP\MDFe\Tools>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
184
} else {
185
    //header('Content-type: text/html; charset=UTF-8');
186
    foreach ($make->erros as $err) {
187
        echo 'tag: &lt;'.$err['tag'].'&gt; ---- '.$err['desc'].'<br>';
188
    }
189
}
190
191
$xmlAssinado = $tools->assina($xml);
0 ignored issues
show
Bug introduced by
The method assina() does not seem to exist on object<NFePHP\MDFe\Tools>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
192
file_put_contents($filename, $xmlAssinado);
193
194
$aRetorno = array();
195
$tools->sefazEnviaLote($xmlAssinado, $tpAmb, $idLote = '', $aRetorno);
0 ignored issues
show
Unused Code introduced by
The call to Tools::sefazEnviaLote() has too many arguments starting with $idLote = ''.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
Bug introduced by
The method validarXml() does not seem to exist on object<NFePHP\MDFe\Tools>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
196
197
echo "<pre>";
0 ignored issues
show
Bug introduced by
The property errors does not seem to exist in NFePHP\MDFe\Tools.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
198
echo htmlspecialchars($tools->soapDebug);
0 ignored issues
show
Bug introduced by
The property soapDebug does not seem to exist in NFePHP\MDFe\Tools.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
199
echo print_r($aRetorno);
200
echo "</pre>";
201