|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace NFePHP\MDFe\Auxiliar; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Classe para a identificação do documento eletrônico da NFe |
|
7
|
|
|
* |
|
8
|
|
|
* @category NFePHP |
|
9
|
|
|
* @package NFePHP\MDFe\IdentifyMDFe |
|
10
|
|
|
* @copyright Copyright (c) 2008-2015 |
|
11
|
|
|
* @license http://www.gnu.org/licenses/lesser.html LGPL v3 |
|
12
|
|
|
* @author Roberto L. Machado <linux.rlm at gmail dot com> |
|
13
|
|
|
* @link http://github.com/nfephp-org/nfephp for the canonical source repository |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
use \DOMDocument; |
|
17
|
|
|
use NFePHP\Common\Identify\Identify as Id; |
|
18
|
|
|
|
|
19
|
|
|
class Identify |
|
20
|
|
|
{ |
|
21
|
3 |
|
public static function identificar($xml = '', &$aResp = array()) |
|
22
|
|
|
{ |
|
23
|
|
|
$aList = array( |
|
24
|
3 |
|
'consReciMDFe' => 'consReciMDFe', |
|
25
|
2 |
|
'consSitMDFe' => 'consSitMDFe', |
|
26
|
2 |
|
'consStatServMDFe' => 'consStatServMDFe', |
|
27
|
2 |
|
'enviMDFe' => 'enviMDFe', |
|
28
|
2 |
|
'evCancMDFe' => 'evCancMDFe', |
|
29
|
2 |
|
'evEncMDFe' => 'evEncMDFe', |
|
30
|
2 |
|
'MDFe' => 'mdfe', |
|
31
|
2 |
|
'eventoMDFe' => 'eventoMDFe', |
|
32
|
2 |
|
'procEventoMDFe' => 'procEventoMDFe', |
|
33
|
2 |
|
'mdfeProc' => 'procMDFe', |
|
34
|
2 |
|
'retConsReciMDFe' => 'retConsReciMDFe', |
|
35
|
2 |
|
'retConsSitMDFe' => 'retConsSitMDFe', |
|
36
|
2 |
|
'retConsStatServMDFe' => 'retConsStatServMDFe', |
|
37
|
2 |
|
'retEnviMDFe' => 'retEnviMDFe', |
|
38
|
|
|
'retEventoMDFe' => 'retEventoMDFe' |
|
39
|
2 |
|
); |
|
40
|
3 |
|
Id::setListSchemesId($aList); |
|
41
|
3 |
|
$schem = Id::identificacao($xml, $aResp); |
|
42
|
3 |
|
$dom = $aResp['dom']; |
|
43
|
3 |
|
$node = $dom->getElementsByTagName($aResp['tag'])->item(0); |
|
44
|
3 |
|
if ($schem == 'mdfe') { |
|
45
|
|
|
//se for um nfe então é necessário pegar a versão |
|
46
|
|
|
// em outro node infNFe |
|
47
|
3 |
|
$node1 = $dom->getElementsByTagName('infMDFe')->item(0); |
|
48
|
3 |
|
$versao = $node1->getAttribute('versao'); |
|
49
|
2 |
|
} else { |
|
50
|
|
|
$versao = $node->getAttribute('versao'); |
|
51
|
2 |
|
} |
|
52
|
3 |
|
$aResp['versao'] = $versao; |
|
53
|
3 |
|
$aResp['xml'] = $dom->saveXML($node); |
|
54
|
3 |
|
return $schem; |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|