-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathresumen.php
More file actions
133 lines (113 loc) · 3.24 KB
/
resumen.php
File metadata and controls
133 lines (113 loc) · 3.24 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
129
130
131
132
<?php include('./includes/conn.php');
$titulo = "Resumen";
include ("head.php");
setlocale(LC_MONETARY, 'en_US');
$mysqli = con_start();
$id = 1;
$smtp = $mysqli->prepare("SELECT t.amount, t.monthly,
EXTRACT(MONTH FROM t.created)
FROM Transaction t
WHERE t.id_user = ? AND t.is_active = 1");
$smtp->bind_param("i", $id);
$smtp->execute();
$smtp->store_result();
$smtp->bind_result($amount, $monthly, $month);
while ($smtp->fetch()) {
if($monthly == 1){
$arrI[$month][] = $amount;
} elseif($monthly == 0){
$arrE[$month][] = $amount;
}
}
$smtp->free_result();
$smtp->close();
function getMonth ($i){
switch ($i) {
case 1:
return "Enero";
case 2:
return "Febrero";
case 3:
return "Marzo";
case 4:
return "Abril";
case 5:
return "Mayo";
case 6:
return "Junio";
case 7:
return "Julio";
case 8:
return "Agosto";
case 9:
return "Septiembre";
case 10:
return "Octubre";
case 11:
return "Noviembre";
case 12:
return "Diciembre";
}
}
$finance = [];
$smtp = $mysqli->prepare("SELECT Sum(b.amount), Sum(c.amount) FROM mxhacks.Transaction a
LEFT JOIN mxhacks.Transaction b
ON a.id_trans = b.id_trans
AND b.type = 1
LEFT JOIN mxhacks.Transaction c
on a.id_trans = c.id_trans
AND c.type = 2");
echo "sql";
$smtp->execute();
$smtp->store_result();
$smtp->bind_result($income, $outcome);
while($smtp->fetch()){
$finance[0] = $income;
$finance[1] = $outcome;
}
$smtp->free_result();
$smtp->close();
?>
<div class="container">
<p> </p>
<p> </p>
<p> </p>
<?php
for($i = 1; $i < 13; $i++){
if((count($arrI[$i]) > 0) || (count($arrE[$i]) > 0)){
echo
"<div class='row' style='padding:80px 0 0;'>".
"<table class='table'><thead><th>".getMonth($i)."</th></thead>".
"<tbody>".
"<div class='row'>".
"<div class='col-md-6'>".
"<table class='table'><thead><th style='color:green;'>Ingreso</th></thead>".
"<tbody>";
for($j = 0; $j < count($arrI[$i]); $j++){
echo
"<td style='color:green;'>+ ".
$arrI[$i][$j]."</td>";
}
echo
"</tbody>".
"</div>".
"<div class='col-md-6'>".
"<table class='table'><thead><th style='color:red;'>Egreso</th></thead>".
"<tbody>";
for($j = 0; $j < count($arrE[$i]); $j++){
echo
"<td style='color:red;'>+ ".
$arrE[$i][$j]."</td>";
}
echo
"</tbody>".
"</div>".
"</div>".
"</tbody>".
"</table>".
"</div>";
}
}
?>
</div>
<?php include("foot.php") ?>