-
Notifications
You must be signed in to change notification settings - Fork 0
/
details.php
176 lines (159 loc) · 6.16 KB
/
details.php
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php
require_once ('classes/autoload.php');
use classes\investments;
session_start();
$investments = new investments();
?>
<html>
<head>
<?php include ('includes/meta_head.php'); ?>
</head>
<body>
<header class="p-3 mb-3 border-bottom border-custom bg-custom-menu shadow-sm">
<div class="container">
<?php include ('includes/main_menu.php'); ?>
</div>
</header>
<div class="container">
<div class="row mb-4">
<div class="col-md-6">
<div class="card rounded border border-custom shadow-sm mb-4">
<div class="card-header">
<h6 class="card-header-title">Rendimientos</h6>
<svg class="card-header-icon" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-star"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon></svg>
</div>
<div class="card-body p-0" style="max-height:450px; overflow-y: scroll;">
<table class="table table-hover">
<thead>
<tr class="table-custom text-uppercase fs-7">
<th scope="col">#</td>
<th scope="col">Instrumento</td>
<th scope="col">Fecha</td>
<th scope="col" class="text-end">Saldo</td>
<th scope="col" class="text-end"></td>
</tr>
</thead>
<?php
$data = $investments->loadLastMonth($_REQUEST['q']);
foreach ($data as $key => $invest) {
$dateTime = new DateTime($invest->date);
$values[$key] = $invest->amount;
$labels[$key] = $dateTime->format('d-m-Y');
echo "<tr>";
echo " <td>". ($key +1) ."</td>";
echo " <td>". $invest->category ."</td>";
echo " <td>". $dateTime->format('d-m-Y') ."</td>";
echo " <td class='text-end'> $". number_format($invest->amount, 2) ."</td>";
echo ' <td>
<a href="#" id='.$invest->id.' class="btn-delete">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#555555" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x-square"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><line x1="9" y1="9" x2="15" y2="15"></line><line x1="15" y1="9" x2="9" y2="15"></line></svg>
</a>
</td>';
echo "</tr>";
}
?>
</table>
</div>
</div> <!-- Card -->
</div> <!-- Col -->
<div class="col">
<div class="card border-custom shadow-sm mb-4">
<div class="card-body">
<canvas class="p-3" id="currentChart" width="250" height="100"></canvas>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="card border-custom shadow-sm">
<div class="card-body">
<div class="align-items-center row">
<div class="col">
<h6 class="card-title text-muted text-uppercase fs-7">Incremento del ultimo mes</h6>
<h5 class="card-subtitle mb-2 fs-6">
<?php
$result = $values[0] - end($values);
echo '$'. number_format($result, 2);
?>
</h5>
</div>
<div class="col-auto">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#32a852" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-trending-up"><polyline points="23 6 13.5 15.5 8.5 10.5 1 18"></polyline><polyline points="17 6 23 6 23 12"></polyline></svg>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="card border-custom shadow-sm">
<div class="card-body">
<div class="align-items-center row">
<div class="col">
<h6 class="card-title text-muted text-uppercase fs-7">Incremento ponderado</h6>
<h5 class="card-subtitle mb-2 fs-6">
<?php
$percentage = ($result/$values[0]) * 100;
echo number_format($percentage, 2) .'%';
?>
</h5>
</div>
<div class="col-auto">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#32a852" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-trending-up"><polyline points="23 6 13.5 15.5 8.5 10.5 1 18"></polyline><polyline points="17 6 23 6 23 12"></polyline></svg>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div> <!-- Row -->
</div> <!-- Container -->
</body>
</html>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-/bQdsTh/da6pkI1MST/rWKFNjaCP5gBSY4sEBT38Q/9RBh9AH40zEOg7Hlq2THRZ"
crossorigin="anonymous">
</script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/chart.min.js"></script>
<script>
$(".btn-delete").on('click', function(btn){
console.log(this.id);
Swal.fire({
title: 'Message',
text: 'Data: '+ this.id +' was success deleted',
icon: 'success',
confirmButtonText: 'Cool'
})
});
const currentChart = document.getElementById('currentChart').getContext('2d');
const myChart = new Chart(currentChart, {
type: 'line',
data: {
labels: <?=json_encode( $labels );?>,
datasets: [{
label: 'Wallet Balance',
data: <?=json_encode( $values );?>,
borderColor: 'rgba(0, 153, 204, 1)',
backgroundColor: 'rgba(0, 172, 230, 0.2)',
borderWidth:1,
pointRadius:2,
hoverOffset:5,
fill: true
}]
},
options: {
responsive: true,
plugins: {
legend: {
position:'none',
align:'center',
labels:{
padding:25,
boxWidth:18,
boxHeight:17
}
}
}
}
});
</script>