Passed
Branch main (857f8d)
by Rhyann
01:54
created
src/ImportNfe.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,13 +29,13 @@
 block discarded – undo
29 29
     /** @var array */
30 30
     protected static $extensions = [];
31 31
 
32
-   /**
32
+    /**
33 33
      * @param string $uploadDir
34 34
      * @param string $fileTypeDir
35 35
      * @param bool $monthYearPath
36 36
      * @example $u = new Upload("storage/uploads", "importadas");
37 37
      */
38
-   public function __construct(string $uploadDir, string $fileTypeDir, string $importDir, string $errorDir, bool $monthYearPath = true)
38
+    public function __construct(string $uploadDir, string $fileTypeDir, string $importDir, string $errorDir, bool $monthYearPath = true)
39 39
     {
40 40
         $this->dir($uploadDir);
41 41
         $this->dir("{$uploadDir}/{$importDir}");
Please login to merge, or discard this patch.
src/Xml.php 3 patches
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
         $nota = (object) $nota;
62 62
 
63 63
         while(($arquivo = $directory->read()) !== false)
64
-         {
64
+            {
65 65
             if (empty($arquivo) || $arquivo == '..' || $arquivo == '.') continue;
66 66
 
67 67
             $lexml   =  $this->path .'/'. $arquivo;
@@ -69,24 +69,24 @@  discard block
 block discarded – undo
69 69
 
70 70
             $environ =  $xml->NFe->infNFe->ide->tpAmb;
71 71
 
72
-             if (empty($xml->protNFe->infProt->nProt))
73
-             {
74
-                 echo "<h4>Arquivo sem dados de Protocolo!</h4>";
75
-                 rename($lexml,"./{$this->pathError}/$arquivo");
76
-                 continue;
77
-             }
78
-             if ($environ != 1)  //se diferente de 1 ( 1 = Produção 2 = Homologação )
79
-             {
80
-                 echo "<h4>Documento emitido em ambiente de homologação!</h4>";
81
-                 rename($lexml,"./{$this->pathError}/$arquivo");
82
-                 continue;
83
-             }
84
-
85
-             ++$p;
86
-             $nota->items[$p] = $this->mapa( $xml );
87
-             rename($lexml,"./{$this->pathImport}/$arquivo");
88
-
89
-         }
72
+                if (empty($xml->protNFe->infProt->nProt))
73
+                {
74
+                    echo "<h4>Arquivo sem dados de Protocolo!</h4>";
75
+                    rename($lexml,"./{$this->pathError}/$arquivo");
76
+                    continue;
77
+                }
78
+                if ($environ != 1)  //se diferente de 1 ( 1 = Produção 2 = Homologação )
79
+                {
80
+                    echo "<h4>Documento emitido em ambiente de homologação!</h4>";
81
+                    rename($lexml,"./{$this->pathError}/$arquivo");
82
+                    continue;
83
+                }
84
+
85
+                ++$p;
86
+                $nota->items[$p] = $this->mapa( $xml );
87
+                rename($lexml,"./{$this->pathImport}/$arquivo");
88
+
89
+            }
90 90
 
91 91
         return $nota;
92 92
     }
@@ -201,95 +201,95 @@  discard block
 block discarded – undo
201 201
         $vOutro =       $xml->NFe->infNFe->total->ICMSTot->vOutro;
202 202
 
203 203
         $dadosnfe = [
204
-                     //IDE
205
-                     "chave"         =>   "$chave",
206
-                     "cUF"           =>   "$cUF",
207
-                     "cNF"           =>   "$cNF",
208
-                     "natOp"         =>   "$natOp",
209
-                     "indPag"       =>    "$indPag",
210
-                     "mod"           =>   "$mod",
211
-                     "serie"         =>   "$serie",
212
-                     "nNF"           =>   "$nNF",
213
-                     "dhEmi"         =>   "$dhEmi",
214
-                     "dhSaiEnt"      =>   "$dhSaiEnt",
215
-                     "tpNF"          =>   "$tpNF",
216
-                     "cMunFG"        =>   "$cMunFG",
217
-                     "tpImp"         =>   "$tpImp",
218
-                     "tpEmis"        =>   "$tpEmis",
219
-                     "cDV"           =>   "$cDV",
220
-                     "finNFe"        =>   "$finNFe",
221
-                     "procEmi"       =>   "$procEmi",
222
-                     "verProc"       =>   "$verProc",
223
-                     "tpAmb"         =>   "$tpAmb",
224
-
225
-                     //INFPROT
226
-                     "xMotivo"       =>   "$xMotivo",
227
-                     "nProt"         =>   "$nProt",
228
-
229
-                     //EMIT
230
-                     "emit_cpf_cnpj" =>   "$emit_cpf_cnpj",
231
-                     "emit_xNome"    =>   "$emit_xNome",
232
-                     "emit_xFant"    =>   "$emit_xFant",
233
-                     "emit_ie"       =>   "$emit_IE",
234
-
235
-                     //ENDEREMIT
236
-                     "emit_xLgr"     =>   "$emit_xLgr",
237
-                     "emit_nro"      =>   "$emit_nro",
238
-                     "emit_comp"     =>   "$emit_comp",
239
-                     "emit_xBairro"  =>   "$emit_xBairro",
240
-                     "emit_cMun"    =>   "$emit_cMun",
241
-                     "emit_xMun"    =>   "$emit_xMun",
242
-                     "emit_UF"      =>   "$emit_UF",
243
-                     "emit_CEP"     =>   "$emit_CEP",
244
-                     "emit_cPais"   =>   "$emit_cPais",
245
-                     "emit_xPais"   =>   "$emit_xPais",
246
-                     "emit_fone"    =>   "$emit_fone",
247
-
248
-                     //DEST
249
-                     "dest_cpf_cnpj"  => "$dest_cpf_cnpj",
250
-                     "dest_xNome"   =>   "$dest_xNome",
251
-                     "dest_xFant"   =>   "$dest_xFant",
252
-                     "dest_IE"      =>   "$dest_IE",
253
-
254
-                     //ENDERDEST
255
-                     "dest_xLgr"    =>   "$dest_xLgr",
256
-                     "dest_nro"     =>   "$dest_nro",
257
-                     "dest_xBairro" =>   "$dest_xBairro",
258
-                     "dest_cMun"    =>   "$dest_cMun",
259
-                     "dest_xMun"    =>   "$dest_xMun",
260
-                     "dest_UF"      =>   "$dest_UF",
261
-                     "dest_CEP"     =>   "$dest_CEP",
262
-                     "dest_cPais"   =>   "$dest_cPais",
263
-                     "dest_xPais"   =>   "$dest_xPais",
264
-                     "dest_fone"    =>   "$dest_fone",
265
-
266
-                     //TRANSP
267
-                     "transp_mod"   =>   "$transp_mod",
268
-                     "transp_cpf_cnpj"   =>   "$transp_cpf_cnpj",
269
-                     "transp_xNome" =>   "$transp_xNome",
270
-                     "transp_IE"    =>   "$transp_IE",
271
-
272
-                     //VOL
273
-                     "transp_qVol"  =>   "$transp_qVol",
274
-                     "transp_esp"   =>   "$transp_esp",
275
-                     "transp_marca" =>   "$transp_marca",
276
-
277
-                     //VEICTRANSP
278
-                     "transp_placa" =>   "$transp_placa",
279
-                     "transp_UF"    =>   "$transp_UF",
280
-
281
-                     //TOTAL
282
-                     "vBC"          =>   "$vBC",
283
-                     "vICMS"        =>   "$vICMS",
284
-                     "vBCST"        =>   "$vBCST",
285
-                     "vST"          =>   "$vST",
286
-                     "vProd"        =>   "$vProd",
287
-                     "vNF"          =>   "$vNF",
288
-                     "vFrete"       =>   "$vFrete",
289
-                     "vSeg"         =>   "$vSeg",
290
-                     "vDesc"        =>   "$vDesc",
291
-                     "vIPI"         =>   "$vIPI",
292
-                     "vOutro"       =>   "$vOutro"
204
+                        //IDE
205
+                        "chave"         =>   "$chave",
206
+                        "cUF"           =>   "$cUF",
207
+                        "cNF"           =>   "$cNF",
208
+                        "natOp"         =>   "$natOp",
209
+                        "indPag"       =>    "$indPag",
210
+                        "mod"           =>   "$mod",
211
+                        "serie"         =>   "$serie",
212
+                        "nNF"           =>   "$nNF",
213
+                        "dhEmi"         =>   "$dhEmi",
214
+                        "dhSaiEnt"      =>   "$dhSaiEnt",
215
+                        "tpNF"          =>   "$tpNF",
216
+                        "cMunFG"        =>   "$cMunFG",
217
+                        "tpImp"         =>   "$tpImp",
218
+                        "tpEmis"        =>   "$tpEmis",
219
+                        "cDV"           =>   "$cDV",
220
+                        "finNFe"        =>   "$finNFe",
221
+                        "procEmi"       =>   "$procEmi",
222
+                        "verProc"       =>   "$verProc",
223
+                        "tpAmb"         =>   "$tpAmb",
224
+
225
+                        //INFPROT
226
+                        "xMotivo"       =>   "$xMotivo",
227
+                        "nProt"         =>   "$nProt",
228
+
229
+                        //EMIT
230
+                        "emit_cpf_cnpj" =>   "$emit_cpf_cnpj",
231
+                        "emit_xNome"    =>   "$emit_xNome",
232
+                        "emit_xFant"    =>   "$emit_xFant",
233
+                        "emit_ie"       =>   "$emit_IE",
234
+
235
+                        //ENDEREMIT
236
+                        "emit_xLgr"     =>   "$emit_xLgr",
237
+                        "emit_nro"      =>   "$emit_nro",
238
+                        "emit_comp"     =>   "$emit_comp",
239
+                        "emit_xBairro"  =>   "$emit_xBairro",
240
+                        "emit_cMun"    =>   "$emit_cMun",
241
+                        "emit_xMun"    =>   "$emit_xMun",
242
+                        "emit_UF"      =>   "$emit_UF",
243
+                        "emit_CEP"     =>   "$emit_CEP",
244
+                        "emit_cPais"   =>   "$emit_cPais",
245
+                        "emit_xPais"   =>   "$emit_xPais",
246
+                        "emit_fone"    =>   "$emit_fone",
247
+
248
+                        //DEST
249
+                        "dest_cpf_cnpj"  => "$dest_cpf_cnpj",
250
+                        "dest_xNome"   =>   "$dest_xNome",
251
+                        "dest_xFant"   =>   "$dest_xFant",
252
+                        "dest_IE"      =>   "$dest_IE",
253
+
254
+                        //ENDERDEST
255
+                        "dest_xLgr"    =>   "$dest_xLgr",
256
+                        "dest_nro"     =>   "$dest_nro",
257
+                        "dest_xBairro" =>   "$dest_xBairro",
258
+                        "dest_cMun"    =>   "$dest_cMun",
259
+                        "dest_xMun"    =>   "$dest_xMun",
260
+                        "dest_UF"      =>   "$dest_UF",
261
+                        "dest_CEP"     =>   "$dest_CEP",
262
+                        "dest_cPais"   =>   "$dest_cPais",
263
+                        "dest_xPais"   =>   "$dest_xPais",
264
+                        "dest_fone"    =>   "$dest_fone",
265
+
266
+                        //TRANSP
267
+                        "transp_mod"   =>   "$transp_mod",
268
+                        "transp_cpf_cnpj"   =>   "$transp_cpf_cnpj",
269
+                        "transp_xNome" =>   "$transp_xNome",
270
+                        "transp_IE"    =>   "$transp_IE",
271
+
272
+                        //VOL
273
+                        "transp_qVol"  =>   "$transp_qVol",
274
+                        "transp_esp"   =>   "$transp_esp",
275
+                        "transp_marca" =>   "$transp_marca",
276
+
277
+                        //VEICTRANSP
278
+                        "transp_placa" =>   "$transp_placa",
279
+                        "transp_UF"    =>   "$transp_UF",
280
+
281
+                        //TOTAL
282
+                        "vBC"          =>   "$vBC",
283
+                        "vICMS"        =>   "$vICMS",
284
+                        "vBCST"        =>   "$vBCST",
285
+                        "vST"          =>   "$vST",
286
+                        "vProd"        =>   "$vProd",
287
+                        "vNF"          =>   "$vNF",
288
+                        "vFrete"       =>   "$vFrete",
289
+                        "vSeg"         =>   "$vSeg",
290
+                        "vDesc"        =>   "$vDesc",
291
+                        "vIPI"         =>   "$vIPI",
292
+                        "vOutro"       =>   "$vOutro"
293 293
             ];
294 294
 
295 295
         $i =0;
Please login to merge, or discard this patch.
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -60,31 +60,31 @@  discard block
 block discarded – undo
60 60
         $nota = array();
61 61
         $nota = (object) $nota;
62 62
 
63
-        while(($arquivo = $directory->read()) !== false)
63
+        while (($arquivo = $directory->read()) !== false)
64 64
          {
65 65
             if (empty($arquivo) || $arquivo == '..' || $arquivo == '.') continue;
66 66
 
67
-            $lexml   =  $this->path .'/'. $arquivo;
68
-            $xml     =  simplexml_load_file($lexml);
67
+            $lexml   = $this->path . '/' . $arquivo;
68
+            $xml     = simplexml_load_file($lexml);
69 69
 
70
-            $environ =  $xml->NFe->infNFe->ide->tpAmb;
70
+            $environ = $xml->NFe->infNFe->ide->tpAmb;
71 71
 
72 72
              if (empty($xml->protNFe->infProt->nProt))
73 73
              {
74 74
                  echo "<h4>Arquivo sem dados de Protocolo!</h4>";
75
-                 rename($lexml,"./{$this->pathError}/$arquivo");
75
+                 rename($lexml, "./{$this->pathError}/$arquivo");
76 76
                  continue;
77 77
              }
78 78
              if ($environ != 1)  //se diferente de 1 ( 1 = Produção 2 = Homologação )
79 79
              {
80 80
                  echo "<h4>Documento emitido em ambiente de homologação!</h4>";
81
-                 rename($lexml,"./{$this->pathError}/$arquivo");
81
+                 rename($lexml, "./{$this->pathError}/$arquivo");
82 82
                  continue;
83 83
              }
84 84
 
85 85
              ++$p;
86
-             $nota->items[$p] = $this->mapa( $xml );
87
-             rename($lexml,"./{$this->pathImport}/$arquivo");
86
+             $nota->items[$p] = $this->mapa($xml);
87
+             rename($lexml, "./{$this->pathImport}/$arquivo");
88 88
 
89 89
          }
90 90
 
@@ -105,70 +105,70 @@  discard block
 block discarded – undo
105 105
         $chave = strtr(strtoupper($chave), array("NFE" => NULL));
106 106
 
107 107
         //IDE
108
-        @$cUF =         $xml->NFe->infNFe->ide->cUF;    	 //<cUF>41</cUF>  Código do Estado do Fator gerador
109
-        @$cNF =         $xml->NFe->infNFe->ide->cNF;       	 //<cNF>21284519</cNF>   Código número da nfe
110
-        @$natOp =       $xml->NFe->infNFe->ide->natOp;       //<natOp>V E N D A</natOp>  Resumo da Natureza de operação
111
-        @$indPag =      $xml->NFe->infNFe->ide->indPag;      //<indPag>2</indPag> 0 – pagamento à vista; 1 – pagamento à prazo; 2 - outros
112
-        @$mod =         $xml->NFe->infNFe->ide->mod;         //<mod>55</mod> Modelo do documento Fiscal
113
-        @$serie =       $xml->NFe->infNFe->ide->serie;    	 //<serie>2</serie>
114
-        @$nNF =         $xml->NFe->infNFe->ide->nNF;   	     //<nNF>19685</nNF> Número da Nota Fiscal
115
-        @$dhEmi =       $xml->NFe->infNFe->ide->dhEmi;       //<dEmi>2011-09-06</dEmi> Data de emissão da Nota Fiscal
116
-        @$dhEmi =       $this->dataus(@$dhEmi);
117
-        @$dhSaiEnt =    $xml->NFe->infNFe->ide->dhSaiEnt;    //<dSaiEnt>2011-09-06</dSaiEnt> Data de entrada ou saida da Nota Fiscal
118
-        @$tpNF =        $xml->NFe->infNFe->ide->tpNF;        //<tpNF>1</tpNF>  0-entrada / 1-saída
119
-        @$cMunFG =      $xml->NFe->infNFe->ide->cMunFG;      //<cMunFG>4106407</cMunFG> Código do municipio Tabela do IBGE
120
-        @$tpImp =       $xml->NFe->infNFe->ide->tpImp;       //<tpImp>1</tpImp>
121
-        @$tpEmis =      $xml->NFe->infNFe->ide->tpEmis;      //<tpEmis>1</tpEmis>
122
-        @$cDV =         $xml->NFe->infNFe->ide->cDV;         //<cDV>0</cDV>
123
-        $finNFe =       $xml->NFe->infNFe->ide->finNFe;      //<finNFe>1</finNFe>
124
-        $procEmi =      $xml->NFe->infNFe->ide->procEmi;     //<procEmi>0</procEmi>
125
-        $verProc =      $xml->NFe->infNFe->ide->verProc;     //<verProc>2.0.0</verProc>
126
-        @$tpAmb =       $xml->NFe->infNFe->ide->tpAmb;       //<tpAmb>1</tpAmb> 1 = Produção 2 = Homologação.
108
+        @$cUF = $xml->NFe->infNFe->ide->cUF; //<cUF>41</cUF>  Código do Estado do Fator gerador
109
+        @$cNF = $xml->NFe->infNFe->ide->cNF; //<cNF>21284519</cNF>   Código número da nfe
110
+        @$natOp = $xml->NFe->infNFe->ide->natOp; //<natOp>V E N D A</natOp>  Resumo da Natureza de operação
111
+        @$indPag = $xml->NFe->infNFe->ide->indPag; //<indPag>2</indPag> 0 – pagamento à vista; 1 – pagamento à prazo; 2 - outros
112
+        @$mod = $xml->NFe->infNFe->ide->mod; //<mod>55</mod> Modelo do documento Fiscal
113
+        @$serie = $xml->NFe->infNFe->ide->serie; //<serie>2</serie>
114
+        @$nNF = $xml->NFe->infNFe->ide->nNF; //<nNF>19685</nNF> Número da Nota Fiscal
115
+        @$dhEmi = $xml->NFe->infNFe->ide->dhEmi; //<dEmi>2011-09-06</dEmi> Data de emissão da Nota Fiscal
116
+        @$dhEmi = $this->dataus(@$dhEmi);
117
+        @$dhSaiEnt = $xml->NFe->infNFe->ide->dhSaiEnt; //<dSaiEnt>2011-09-06</dSaiEnt> Data de entrada ou saida da Nota Fiscal
118
+        @$tpNF = $xml->NFe->infNFe->ide->tpNF; //<tpNF>1</tpNF>  0-entrada / 1-saída
119
+        @$cMunFG = $xml->NFe->infNFe->ide->cMunFG; //<cMunFG>4106407</cMunFG> Código do municipio Tabela do IBGE
120
+        @$tpImp = $xml->NFe->infNFe->ide->tpImp; //<tpImp>1</tpImp>
121
+        @$tpEmis = $xml->NFe->infNFe->ide->tpEmis; //<tpEmis>1</tpEmis>
122
+        @$cDV = $xml->NFe->infNFe->ide->cDV; //<cDV>0</cDV>
123
+        $finNFe = $xml->NFe->infNFe->ide->finNFe; //<finNFe>1</finNFe>
124
+        $procEmi = $xml->NFe->infNFe->ide->procEmi; //<procEmi>0</procEmi>
125
+        $verProc = $xml->NFe->infNFe->ide->verProc; //<verProc>2.0.0</verProc>
126
+        @$tpAmb = $xml->NFe->infNFe->ide->tpAmb; //<tpAmb>1</tpAmb> 1 = Produção 2 = Homologação.
127 127
 
128 128
         //INFPROT
129
-        $xMotivo =      $xml->protNFe->infProt->xMotivo;
130
-        $nProt =        $xml->protNFe->infProt->nProt;
129
+        $xMotivo = $xml->protNFe->infProt->xMotivo;
130
+        $nProt = $xml->protNFe->infProt->nProt;
131 131
 
132 132
         //EMIT
133
-        $emit_CPF =     $xml->NFe->infNFe->emit->CPF;
134
-        $emit_CNPJ =    $xml->NFe->infNFe->emit->CNPJ;
135
-        $emit_xNome =   $xml->NFe->infNFe->emit->xNome;
136
-        $emit_IE =   $xml->NFe->infNFe->emit->IE;
137
-        $emit_xFant =   $xml->NFe->infNFe->emit->xFant;
133
+        $emit_CPF = $xml->NFe->infNFe->emit->CPF;
134
+        $emit_CNPJ = $xml->NFe->infNFe->emit->CNPJ;
135
+        $emit_xNome = $xml->NFe->infNFe->emit->xNome;
136
+        $emit_IE = $xml->NFe->infNFe->emit->IE;
137
+        $emit_xFant = $xml->NFe->infNFe->emit->xFant;
138 138
         $emit_cpf_cnpj = $emit_CNPJ . $emit_CPF;
139 139
 
140 140
         //ENDEREMIT
141
-        $emit_xLgr =    $xml->NFe->infNFe->emit->enderEmit->xLgr;
142
-        $emit_nro=      $xml->NFe->infNFe->emit->enderEmit->nro;
143
-        $emit_comp=      $xml->NFe->infNFe->emit->enderEmit->xCpl;
141
+        $emit_xLgr = $xml->NFe->infNFe->emit->enderEmit->xLgr;
142
+        $emit_nro = $xml->NFe->infNFe->emit->enderEmit->nro;
143
+        $emit_comp = $xml->NFe->infNFe->emit->enderEmit->xCpl;
144 144
         $emit_xBairro = $xml->NFe->infNFe->emit->enderEmit->xBairro;
145
-        $emit_cMun =    $xml->NFe->infNFe->emit->enderEmit->cMun;
146
-        $emit_xMun =    $xml->NFe->infNFe->emit->enderEmit->xMun;
147
-        $emit_UF =      $xml->NFe->infNFe->emit->enderEmit->UF;
148
-        $emit_CEP =     $xml->NFe->infNFe->emit->enderEmit->CEP;
149
-        $emit_cPais =   $xml->NFe->infNFe->emit->enderEmit->cPais;
150
-        $emit_xPais =   $xml->NFe->infNFe->emit->enderEmit->xPais;
151
-        $emit_fone =    $xml->NFe->infNFe->emit->enderEmit->fone;
145
+        $emit_cMun = $xml->NFe->infNFe->emit->enderEmit->cMun;
146
+        $emit_xMun = $xml->NFe->infNFe->emit->enderEmit->xMun;
147
+        $emit_UF = $xml->NFe->infNFe->emit->enderEmit->UF;
148
+        $emit_CEP = $xml->NFe->infNFe->emit->enderEmit->CEP;
149
+        $emit_cPais = $xml->NFe->infNFe->emit->enderEmit->cPais;
150
+        $emit_xPais = $xml->NFe->infNFe->emit->enderEmit->xPais;
151
+        $emit_fone = $xml->NFe->infNFe->emit->enderEmit->fone;
152 152
 
153 153
         //DEST
154
-        $dest_CPF   =   $xml->NFe->infNFe->dest->CPF;
155
-        $dest_CNPJ  =   $xml->NFe->infNFe->dest->CNPJ;
156
-        $dest_xNome =   $xml->NFe->infNFe->dest->xNome;
157
-        $dest_xFant =   $xml->NFe->infNFe->dest->xFant;
158
-        $dest_IE    =   $xml->NFe->infNFe->dest->IE;
154
+        $dest_CPF   = $xml->NFe->infNFe->dest->CPF;
155
+        $dest_CNPJ  = $xml->NFe->infNFe->dest->CNPJ;
156
+        $dest_xNome = $xml->NFe->infNFe->dest->xNome;
157
+        $dest_xFant = $xml->NFe->infNFe->dest->xFant;
158
+        $dest_IE    = $xml->NFe->infNFe->dest->IE;
159 159
         $dest_cpf_cnpj = $dest_CNPJ . $dest_CPF;
160 160
 
161 161
         //ENDERDEST
162
-        $dest_xLgr =    $xml->NFe->infNFe->dest->enderDest->xLgr;
163
-        $dest_nro=      $xml->NFe->infNFe->dest->enderDest->nro;
162
+        $dest_xLgr = $xml->NFe->infNFe->dest->enderDest->xLgr;
163
+        $dest_nro = $xml->NFe->infNFe->dest->enderDest->nro;
164 164
         $dest_xBairro = $xml->NFe->infNFe->dest->enderDest->xBairro;
165
-        $dest_cMun =    $xml->NFe->infNFe->dest->enderDest->cMun;
166
-        $dest_xMun =    $xml->NFe->infNFe->dest->enderDest->xMun;
167
-        $dest_UF =      $xml->NFe->infNFe->dest->enderDest->UF;
168
-        $dest_CEP =     $xml->NFe->infNFe->dest->enderDest->CEP;
169
-        $dest_cPais =   $xml->NFe->infNFe->dest->enderDest->cPais;
170
-        $dest_xPais =   $xml->NFe->infNFe->dest->enderDest->xPais;
171
-        $dest_fone =    $xml->NFe->infNFe->dest->enderDest->fone;
165
+        $dest_cMun = $xml->NFe->infNFe->dest->enderDest->cMun;
166
+        $dest_xMun = $xml->NFe->infNFe->dest->enderDest->xMun;
167
+        $dest_UF = $xml->NFe->infNFe->dest->enderDest->UF;
168
+        $dest_CEP = $xml->NFe->infNFe->dest->enderDest->CEP;
169
+        $dest_cPais = $xml->NFe->infNFe->dest->enderDest->cPais;
170
+        $dest_xPais = $xml->NFe->infNFe->dest->enderDest->xPais;
171
+        $dest_fone = $xml->NFe->infNFe->dest->enderDest->fone;
172 172
 
173 173
         //TRANSP
174 174
         $transp_mod   = $xml->NFe->infNFe->transp->modFrete;
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
         $transp_CNPJ  = $xml->NFe->infNFe->transp->transporta->CNPJ;
177 177
         $transp_xNome = $xml->NFe->infNFe->transp->transporta->xNome;
178 178
         $transp_IE    = $xml->NFe->infNFe->transp->transporta->IE;
179
-        $transp_cpf_cnpj = $transp_CNPJ .$transp_CPF;
179
+        $transp_cpf_cnpj = $transp_CNPJ . $transp_CPF;
180 180
 
181 181
         //VOL
182 182
         $transp_qVol  = $xml->NFe->infNFe->transp->vol->qVol;
@@ -185,20 +185,20 @@  discard block
 block discarded – undo
185 185
 
186 186
         //VEICTRANSP
187 187
         $transp_placa = $xml->NFe->infNFe->transp->veicTransp->placa;
188
-        $transp_UF =    $xml->NFe->infNFe->transp->veicTransp->UF;
188
+        $transp_UF = $xml->NFe->infNFe->transp->veicTransp->UF;
189 189
 
190 190
         //TOTAL
191
-        $vBC =          $xml->NFe->infNFe->total->ICMSTot->vBC;
192
-        $vICMS =        $xml->NFe->infNFe->total->ICMSTot->vICMS;
193
-        $vBCST =        $xml->NFe->infNFe->total->ICMSTot->vBCST;
194
-        $vST =          $xml->NFe->infNFe->total->ICMSTot->vST;
195
-        $vProd =        $xml->NFe->infNFe->total->ICMSTot->vProd;
196
-        $vNF =          $xml->NFe->infNFe->total->ICMSTot->vNF;
197
-        $vFrete =       $xml->NFe->infNFe->total->ICMSTot->vFrete;
198
-        $vSeg =         $xml->NFe->infNFe->total->ICMSTot->vSeg;
199
-        $vDesc =        $xml->NFe->infNFe->total->ICMSTot->vDesc;
200
-        $vIPI =         $xml->NFe->infNFe->total->ICMSTot->vIPI;
201
-        $vOutro =       $xml->NFe->infNFe->total->ICMSTot->vOutro;
191
+        $vBC = $xml->NFe->infNFe->total->ICMSTot->vBC;
192
+        $vICMS = $xml->NFe->infNFe->total->ICMSTot->vICMS;
193
+        $vBCST = $xml->NFe->infNFe->total->ICMSTot->vBCST;
194
+        $vST = $xml->NFe->infNFe->total->ICMSTot->vST;
195
+        $vProd = $xml->NFe->infNFe->total->ICMSTot->vProd;
196
+        $vNF = $xml->NFe->infNFe->total->ICMSTot->vNF;
197
+        $vFrete = $xml->NFe->infNFe->total->ICMSTot->vFrete;
198
+        $vSeg = $xml->NFe->infNFe->total->ICMSTot->vSeg;
199
+        $vDesc = $xml->NFe->infNFe->total->ICMSTot->vDesc;
200
+        $vIPI = $xml->NFe->infNFe->total->ICMSTot->vIPI;
201
+        $vOutro = $xml->NFe->infNFe->total->ICMSTot->vOutro;
202 202
 
203 203
         $dadosnfe = [
204 204
                      //IDE
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
                      "vOutro"       =>   "$vOutro"
293 293
             ];
294 294
 
295
-        $i =0;
296
-        foreach($xml->NFe->infNFe->det as $item)
295
+        $i = 0;
296
+        foreach ($xml->NFe->infNFe->det as $item)
297 297
         {
298 298
             ++$i;
299 299
             $codigo = $item->prod->cProd;
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
             $vProd = $item->prod->vProd;
309 309
             $indTot = $item->prod->indTot;
310 310
 
311
-            $arr_itens =[
311
+            $arr_itens = [
312 312
                 "codigo"      =>   "$codigo",
313 313
                 "cean"        =>   "$cean",
314 314
                 "xProd"       =>   "$xProd",
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
                 "indTot"      =>   "$indTot"
323 323
             ];
324 324
 
325
-            $dadosnfe['itens'][$i]= $arr_itens;
325
+            $dadosnfe['itens'][$i] = $arr_itens;
326 326
         }
327 327
 
328 328
         return ($dadosnfe);
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -62,7 +62,9 @@  discard block
 block discarded – undo
62 62
 
63 63
         while(($arquivo = $directory->read()) !== false)
64 64
          {
65
-            if (empty($arquivo) || $arquivo == '..' || $arquivo == '.') continue;
65
+            if (empty($arquivo) || $arquivo == '..' || $arquivo == '.') {
66
+                continue;
67
+            }
66 68
 
67 69
             $lexml   =  $this->path .'/'. $arquivo;
68 70
             $xml     =  simplexml_load_file($lexml);
@@ -75,9 +77,11 @@  discard block
 block discarded – undo
75 77
                  rename($lexml,"./{$this->pathError}/$arquivo");
76 78
                  continue;
77 79
              }
78
-             if ($environ != 1)  //se diferente de 1 ( 1 = Produção 2 = Homologação )
80
+             if ($environ != 1) {
81
+                 //se diferente de 1 ( 1 = Produção 2 = Homologação )
79 82
              {
80 83
                  echo "<h4>Documento emitido em ambiente de homologação!</h4>";
84
+             }
81 85
                  rename($lexml,"./{$this->pathError}/$arquivo");
82 86
                  continue;
83 87
              }
Please login to merge, or discard this patch.
example/import.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -13,28 +13,28 @@  discard block
 block discarded – undo
13 13
     //NORMALIZA O ARRAY PARA ENVIAR PARA CADASTRO
14 14
     if ($_FILES)
15 15
     {
16
-          $nfe = $_FILES["xml"];
17
-          for ($i = 0; $i < count($nfe["type"]); $i++)
18
-         {
16
+            $nfe = $_FILES["xml"];
17
+            for ($i = 0; $i < count($nfe["type"]); $i++)
18
+            {
19 19
             foreach (array_keys($nfe) as $keys)
20
-             {
20
+                {
21 21
                 $nfeFiles[$i][$keys] = $nfe[$keys][$i];
22
-              }
23
-         }
22
+                }
23
+            }
24 24
 
25
-         //CORRE PELO ARRAY NORMALIZADO E FAZ O UPLOAD
26
-         foreach ($nfeFiles as $file)
27
-         {
25
+            //CORRE PELO ARRAY NORMALIZADO E FAZ O UPLOAD
26
+            foreach ($nfeFiles as $file)
27
+            {
28 28
             $upload = $xml->upload($file);
29
-           //  var_dump( $file);
30
-         }
29
+            //  var_dump( $file);
30
+            }
31 31
 
32 32
         //PEGA O ARRAY DE TODOS OS ARQUIVOS ENVIADO NA PASTA TEMPORARIA
33 33
 
34 34
         $post = $xml->gravaarquivo();
35 35
 
36 36
         // GRAVA NO BD
37
-      if (!empty($post->items)):
37
+        if (!empty($post->items)):
38 38
         foreach ($post->items as $notas)
39 39
         {
40 40
             //VERIFICA SE JA FOI IMPORTADA ANTES
@@ -81,28 +81,28 @@  discard block
 block discarded – undo
81 81
             }
82 82
 
83 83
 
84
-          foreach ($notas['itens'] as $iten)
85
-           {
86
-               $stmt = $conn->prepare("INSERT INTO tbl_itens_nota ( 
84
+            foreach ($notas['itens'] as $iten)
85
+            {
86
+                $stmt = $conn->prepare("INSERT INTO tbl_itens_nota ( 
87 87
                                                                           id_nota, codigo, nome, codigo_barra, ncm, cfop, un_medida, qtd, vl_unidade, vl_total) 
88 88
                                                                                    VALUES ( 
89 89
                                                                           :IDNOTA, :CODIGO, :NOME, :BARRAS, :NCM, :CFOP, :UNM, :QTD, :VLUN, :VLTOTAL)");
90
-               $stmt->bindParam(":IDNOTA", $idNota);
91
-               $stmt->bindParam(":CODIGO", $iten['codigo']);
92
-               $stmt->bindParam(":NOME", $iten['xProd']);
93
-               $stmt->bindParam(":BARRAS", $iten['cean']);
94
-               $stmt->bindParam(":NCM", $iten['NCM']);
95
-               $stmt->bindParam(":CFOP", $iten['CFOP']);
96
-               $stmt->bindParam(":UNM", $iten['uCom']);
97
-               $stmt->bindParam(":QTD", $iten['indTot']);
98
-               $stmt->bindParam(":VLUN", $iten['vUnCom']);
99
-               $stmt->bindParam(":VLTOTAL", $iten['vProd']);
100
-               $stmt->execute();
101
-           } // endforeach;
90
+                $stmt->bindParam(":IDNOTA", $idNota);
91
+                $stmt->bindParam(":CODIGO", $iten['codigo']);
92
+                $stmt->bindParam(":NOME", $iten['xProd']);
93
+                $stmt->bindParam(":BARRAS", $iten['cean']);
94
+                $stmt->bindParam(":NCM", $iten['NCM']);
95
+                $stmt->bindParam(":CFOP", $iten['CFOP']);
96
+                $stmt->bindParam(":UNM", $iten['uCom']);
97
+                $stmt->bindParam(":QTD", $iten['indTot']);
98
+                $stmt->bindParam(":VLUN", $iten['vUnCom']);
99
+                $stmt->bindParam(":VLTOTAL", $iten['vProd']);
100
+                $stmt->execute();
101
+            } // endforeach;
102 102
 
103 103
 
104 104
         }
105
-      endif;
105
+        endif;
106 106
 
107 107
 
108 108
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
43 43
             $chnotes->execute();
44 44
             $check = $chnotes->rowCount();
45 45
 
46
-            if ($check == 0 )
46
+            if ($check == 0)
47 47
             {
48 48
                 $stmt = $conn->prepare("INSERT INTO tbl_notas ( 
49 49
                                                                           numero, chave, protocolo, natop, serie, tpnf, emit_nome, emit_cnpj_cpf, 
Please login to merge, or discard this patch.