-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalendar.php
185 lines (164 loc) · 5.71 KB
/
calendar.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
177
178
179
180
181
182
183
184
<?php
require_once('classes/autoload.php');
use classes\myWallet;
use classes\calendar;
use classes\bills;
date_default_timezone_set('America/Los_Angeles');
session_start();
$month = date('n');
if ($_GET){
$month = $_GET['month'];
}
$wallet = new myWallet();
$calendar = new calendar($month);
$bills = new bills();
?>
<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">
<div class="col-md-3 mb-4">
<div class="card rounded border border-custom shadow-sm">
<div class="card-header">
<h6 class="card-header-title">Menu reportes</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="#555555" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-file-text"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>
</div>
<div class="list-group p-1">
<a href="reports.php" class="list-group-item list-group-item-action">Mes actual</a>
<a href="calendar.php" class="list-group-item list-group-item-action active">Calendario</a>
</div>
</div>
</div> <!-- col-md-3 -->
<div class="col">
<div class="calendar border-custom shadow-sm mb-3">
<div class="card-body">
<div class="row">
<div class="col-md-6">
<h4 class="mb-3">
<?=ucfirst($calendar->getCurrentMonth());?>
</h4>
</div>
<div class="col text-end">
<a id="" class="btn btn-primary" href="?month=<?=date('m')-1;?>" role="button"> << </a>
<a id="" class="btn btn-primary" href="?month=<?=date('m')+1;?>" role="button"> >> </a>
</div>
</div>
<?php
foreach($calendar->getWeekDays() as $day) {
echo "<div class='name'>". $day ."</div>";
}
$dayOfWeek = $calendar->getFirstDayOfMonth(true);
for ($i=0; $i<$dayOfWeek; $i++) {
echo "<div class='day'> </div>";
}
$daysOfMonth = cal_days_in_month(CAL_GREGORIAN, $month, date('Y'));
$currentDay = date('d');
$total = 0;
for($i=1; $i<=$daysOfMonth; $i++){
echo "<div class='day'>";
if ( $currentDay == $i ){
echo "<span class='date active'>". $i ."</span>";
} else {
echo "<span class='date'>". $i ."</span>";
}
if ($object = $bills->getBillByDate(date('Y-'.$month.'-').$i)){
echo "<div style='text-align:end; display:grid;'>";
foreach ($object as $bill){
$total = ($total + (int) $bill->amount);
echo "<a href='#' id=".$bill->id." class='btn-bill'>
<span class='badge bg-danger'>".'$'. number_format($bill->amount) ."</span>
</a>";
}
echo "</div>";
}
echo "</div>";
}
?>
</div>
</div>
<div class="row mb-3">
<div class="col-md-4">
<div class="card border-custom shadow-sm">
<div class="card-body">
<?='$ '.number_format($total, 2); ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div> <!-- Container -->
<div class="modal fade" tabindex="-1" id="billDetails">
<div class="modal-dialog modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-body">
<div class="row border-bottom p-2">
<div class="col-md-6 fw-semibold">
Categoria:
</div>
<div class="col text-end">
<span id="category"></span>
</div>
</div>
<div class="row border-bottom p-2">
<div class="col-md-6">
Descripción:
</div>
<div class="col text-end">
<span id="description"></span>
</div>
</div>
<div class="row border-bottom p-2">
<div class="col-md-6">
Importe:
</div>
<div class="col text-end">
<span id="amount"></span>
</div>
</div>
</div>
<div class="modal-footer border-0">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<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>
$(".btn-bill").on('click', function(btn){
btn.preventDefault();
const id = $(this).attr('id');
$.ajax({
url:'background/ajax_endpoint.php',
method:'post',
data: {
action: 'loadBillDetails',
object: id
},
success: function(response){
const json = JSON.parse(response);
const numberOptions = { style: 'currency', currency: 'USD' };
const numberFormat = new Intl.NumberFormat('en-US', numberOptions);
$("#category").text(json.data.category);
$("#description").text(json.data.description);
$("#amount").text(numberFormat.format(json.data.amount));
const modal = new bootstrap.Modal(document.getElementById('billDetails'));
modal.show();
}
});
});
</script>
</body>
</html>