-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
128 lines (114 loc) · 5.13 KB
/
index.php
File metadata and controls
128 lines (114 loc) · 5.13 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Soma XML</title>
<script src="js/jQuery-2.2.0.min.js"></script>
<!-- Bootstrap Core CSS -->
<link href="bower_components/bootstrap/dist/css/bootstrap.css" rel="stylesheet">
<!-- DataTables -->
<link rel="stylesheet" href="bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
</head>
<body>
<div class="container" id="container">
<table id="example" class="table table-striped " cellspacing="0" width="100%">
<thead>
<tr class="primary">
<th width="20"><strong>Data</strong></th>
<th width="20"><strong>NFCe</strong></th>
<th width="20"><strong>Valor R$</strong></th>
</tr>
</thead>
<tbody>
<?php
error_reporting(0);
$path = "xml/";
$diretorio = dir($path);
while($arquivo = $diretorio->read()){
$DOMDocument = new DOMDocument( '1.0', 'UTF-8' );
$DOMDocument->preserveWhiteSpace = false;
$DOMDocument->load( $path.$arquivo );
$products = $DOMDocument->getElementsByTagName( 'ICMSTot' );
$ides = $DOMDocument->getElementsByTagName( 'ide' );
$cancelados = $DOMDocument->getElementsByTagName( 'retEvento' );
$chaves = $DOMDocument->getElementsByTagName( 'infProt' );
foreach( $cancelados as $cancelado ) {
$canc_nfe[] = $cancelado->getElementsByTagName('chNFe')->item(0)->nodeValue;
}
foreach( $chaves as $chave ) {
$chave_nfe[] = $chave->getElementsByTagName('chNFe')->item(0)->nodeValue;
}
foreach( $products as $product ) {
$vlnfe[] = $product->getElementsByTagName('vNF')->item(0)->nodeValue;
}
foreach( $ides as $ide ) {
$data = $ide->getElementsByTagName( 'dhEmi' )->item( 0 )->nodeValue;
$d = substr($data, 0, 10);
$d = explode("-", $d);
$data_xml[] = $d[2]."/".$d[1]."/".$d[0];
$nrnfe[] = $ide->getElementsByTagName('nNF')->item(0)->nodeValue;
}
}
$contador = count($nrnfe);
for($i=0;$i<$contador;$i++) {
$chv = $chave_nfe[$i];
if (in_array($chv, $canc_nfe)){
$valor = '0';
$texto = ' - Cancelada';
$estilo = "id='nf-info-cancel'";
}else{
$valor = $vlnfe[$i];
$texto = '';
$estilo = "";
}
echo "<tr ".$estilo.">";
echo "<td width=\"20\">" . $data_xml[$i] . "</td>";
echo "<td width=\"20\">" . $nrnfe[$i] . $texto . "</td>";
echo "<td width=\"20\">" . number_format($valor, 2, ',', '.') . "</td>";
echo "</tr>";
$total = $total + $valor;
}
echo "<h2>Valor total das notas: <strong>R$ " . number_format($total, 2, ',', '.')."</strong></h2>";
echo "<hr>";
echo "<table cellspacing=\"10\" width=\"100%\" style='margin: 10px 0 10px 0'>";
echo "<tr>";
echo "<td width=\"20\" id=\"footer-tabela\">Total de: <strong>".$contador." Nota(s)</strong></td>";
echo "<td width=\"20\" id=\"footer-tabela\">Total de Notas canceladas: <strong>" . count($canc_nfe). " Nota(s)</strong></td>";
echo "<td width=\"20\" id=\"footer-tabela\">Valor total das notas: <strong>R$ " . number_format($total, 2, ',', '.')."</strong></td>";
echo "</tr>";
echo "</table>";
$diretorio -> close();
//var_dump($data_xml);
//var_dump($nrnfe);
//var_dump($vlnfe);
//var_dump($canc_nfe);
//var_dump($chave_nfe);
?>
</tbody>
</table>
</div>
<script>
$(document).ready(function(){
$('#example').DataTable({
"language": {
"lengthMenu": "Mostrar _MENU_ registros por página",
"zeroRecords": "Desculpe, nada encontrado!",
"info": "Mostrando página _PAGE_ de _PAGES_",
"infoEmpty": "Nenhum registro encontrado!",
"search": "Pesquisar:",
"next": "Próximo",
"previous": "Anterior",
"infoFiltered": "(filtrado de um total de _MAX_ registros)"
}
});
});
</script>
<script src="js/jQuery-2.2.0.min.js"></script>
<script src="bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
<script src="bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
</body>
</html>