-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_contas.php
More file actions
80 lines (67 loc) · 2.16 KB
/
Copy pathdebug_contas.php
File metadata and controls
80 lines (67 loc) · 2.16 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
<?php
require_once 'config/config.php';
$database = new Database();
$db = $database->getConnection();
echo "<h1>Debug - Contas a Receber</h1>";
try {
// Verificar se a tabela existe
$query = "SHOW TABLES LIKE 'contas_receber'";
$stmt = $db->prepare($query);
$stmt->execute();
$tabela_existe = $stmt->fetch();
echo "<h2>Tabela existe:</h2>";
var_dump($tabela_existe);
// Verificar estrutura da tabela
$query = "DESCRIBE contas_receber";
$stmt = $db->prepare($query);
$stmt->execute();
$estrutura = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo "<h2>Estrutura da tabela:</h2>";
echo "<pre>";
print_r($estrutura);
echo "</pre>";
// Verificar dados na tabela
$query = "SELECT * FROM contas_receber LIMIT 10";
$stmt = $db->prepare($query);
$stmt->execute();
$dados = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo "<h2>Dados na tabela (primeiros 10):</h2>";
echo "<pre>";
print_r($dados);
echo "</pre>";
// Testar consulta mensal
$query_mensal = "
SELECT
DATE_FORMAT(data_vencimento, '%Y-%m') as mes,
COALESCE(SUM(valor), 0) as total
FROM contas_receber
WHERE data_vencimento >= DATE_SUB(NOW(), INTERVAL 6 MONTH)
GROUP BY DATE_FORMAT(data_vencimento, '%Y-%m')
ORDER BY mes
";
$stmt_mensal = $db->prepare($query_mensal);
$stmt_mensal->execute();
$dados_mensais = $stmt_mensal->fetchAll(PDO::FETCH_ASSOC);
echo "<h2>Consulta mensal:</h2>";
echo "<pre>";
print_r($dados_mensais);
echo "</pre>";
// Testar consulta de status
$query_status = "
SELECT
status,
COUNT(*) as total
FROM contas_receber
GROUP BY status
";
$stmt_status = $db->prepare($query_status);
$stmt_status->execute();
$dados_status = $stmt_status->fetchAll(PDO::FETCH_ASSOC);
echo "<h2>Status das contas:</h2>";
echo "<pre>";
print_r($dados_status);
echo "</pre>";
} catch(PDOException $e) {
echo "Erro: " . $e->getMessage();
}
?>