-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.php
More file actions
320 lines (263 loc) · 12 KB
/
Copy pathtest.php
File metadata and controls
320 lines (263 loc) · 12 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
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
<?php
session_start();
if (!isset($_SESSION['logged'])){
header('Location: index.php');
exit();
}
if (isset($_POST['month'])) {
require_once "connect.php";
mysqli_report(MYSQLI_REPORT_STRICT);
$bilance = true;
$id = $_SESSION['id'];
$month = $_POST['month'];
if($month == "current_month"){
$first_day_of_month = date('Y-m-01');
$last_day_of_month = date('Y-m-t');
} else if($month == "last_month") {
$first_day_of_month = date("Y-m-d", mktime(0, 0, 0, date("m")-1, 1));
$last_day_of_month = date("Y-m-d", mktime(0, 0, 0, date("m"), 0));
}
try {
$connection = new mysqli($host, $db_user, $db_password, $db_name);
if ($connection->connect_errno!=0) {
throw new Exception(mysqli_connect_errno());
} else {
if ($bilance == true) {
if ($query = $connection->query("SELECT i.amount, i.date_of_income, ic.name
FROM incomes i, incomes_category_assigned_to_users ic
WHERE i.user_id = '$id'
AND ic.id = i.income_category_assigned_to_user_id
AND date_of_income >= '$first_day_of_month'
AND date_of_income <= '$last_day_of_month'")) {
$query_income = "SELECT i.amount, i.date_of_income, ic.name
FROM incomes i, incomes_category_assigned_to_users ic
WHERE i.user_id = '$id'
AND ic.id = i.income_category_assigned_to_user_id
AND date_of_income >= '$first_day_of_month'
AND date_of_income <= '$last_day_of_month'";
$result_income = mysqli_query($connection, $query_income) or die("database error:". mysqli_error($connection));
$_SESSION['successful_bilance'] = true;
} else {
throw new Exception($connection->error);
}
if ($query2 = $connection->query("SELECT e.amount, e.date_of_expense, ec.name
FROM expenses e, expenses_category_assigned_to_users ec
WHERE e.user_id = '$id'
AND ec.id = e.expense_category_assigned_to_user_id
AND date_of_expense >= '$first_day_of_month'
AND date_of_expense <= '$last_day_of_month'")) {
$query_expense = "SELECT e.amount, e.date_of_expense, ec.name
FROM expenses e, expenses_category_assigned_to_users ec
WHERE e.user_id = '$id'
AND ec.id = e.expense_category_assigned_to_user_id
AND date_of_expense >= '$first_day_of_month'
AND date_of_expense <= '$last_day_of_month'";
$result_expense = mysqli_query($connection, $query_expense) or die("database error:". mysqli_error($connection));
$_SESSION['successful_expense'] = true;
} else {
throw new Exception($connection->error);
}
}
unset($_POST['month']);
$connection->close();
}
} catch(Exception $e) {
echo '<span style="color:red;">Błąd serwera! Przepraszamy za niedogodności i prosimy o rejestrację w innym terminie!</span>';
echo '<br />Informacja developerska: '.$e;
}
}
if($month == "custom"){
$date1 = $_POST['date1'];
$date2 = $_POST['date2'];
echo $date1."<br/>";
echo $date2;
}
?>
<!DOCTYPE HTML>
<html lang="pl">
<head>
<title>Budgety</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href="css/bootstrap.css" rel="stylesheet" media="screen">
<link href="style.css" rel="stylesheet" media="screen">
<link href="css/responsive.css" rel="stylesheet" media="screen">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" type="text/css" media="all" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,700&subset=latin,latin-ext">
</head>
<body>
<!--###############################-->
<!-- MENU GÓRNE ###################-->
<!--###############################-->
<header>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#moje-menu">
<span class="sr-only">Nawigacja</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="menu.php"><img src="images/logo.png" class="img-responsive" alt=""></a>
</div>
<div class="collapse navbar-collapse" id="moje-menu">
<ul class="nav navbar-nav mr-auto">
<li class="pull-left nav-item"><a href="menu.php"><span class="glyphicon glyphicon-home"></span> Home</a></li>
<li><a class="nav-link" href="przychod.php"><span class="glyphicon glyphicon-plus"></span> Dodaj przychód</a></li>
<li class="nav-item"><a class="nav-link" href="wydatek.php"><span class="glyphicon glyphicon-minus"></span> Dodaj wydatek</a></li>
<li class="nav-item"><a class="nav-link" href="bilans.php"><span class="glyphicon glyphicon-usd"></span> Przeglądaj bilans</a></li>
<li class="nav-item"><a class="nav-link" href="ustawienia.php"><span class="glyphicon glyphicon-wrench"></span> Ustawienia</a></li>
<li class="nav-item social pull-right"><a class="nav-link" href="wyloguj.php"><span class="glyphicon glyphicon-off"></span> Wyloguj się</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
</header>
<!--###############################-->
<!--formularz########################-->
<!--###############################-->
<form method="post">
<div class="form-group">
<div class="col-xs-offset-5 col-sm-7 col-sm-offset-9 col-sm-3 col-md-offset-9 col-md-3 col-lg-offset-10 col-lg-2 text-right">
<label for="month">Wybierz zakres:</label>
<select class="form-control" name="month" id="range-style">
<option value="current_month">Bieżący miesiąc</option>
<option value="last_month">Poprzedni miesiąc</option>
<option value="current_year">Bierzący rok</option>
<option value="custom" data-toggle="modal" data-target="#myModal"><a href="#date-range">Niestandardowy</a></option>
</select>
<div class="row">
<div class="col-md-offset-2 col-md-10">
<button type="submit" class="btn btn-success btn-sm">
Potwierdź
</button>
</div>
</div>
</div>
</div>
<!--################################################-->
<!--modal window zakred dat ########################-->
<!--################################################-->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog narrow-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Zakres dat</h4>
</div>
<div class="modal-body">
<div class="input-group input-daterange">
<input type="text" class="form-control" id ="date" name="date1">
<div class="input-group-addon">do</div>
<input type="text" class="form-control" id ="date" name="date2">
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-default">OK</button>
</div>
</div>
</div>
</div>
</form>
<div class="container">
<div class="table-wrapper">
<div class="table-title">
<div class="row">
<div class="col-sm-8"><h2>Przychody</h2></div>
</div>
</div>
<table id="editableTable" class="table table-bordered">
<thead>
<tr>
<th>Kwota</th>
<th>Data</th>
<th>Kategoria</th>
</tr>
</thead>
<tbody>
<?php
if (isset($_SESSION['successful_bilance'])) {
while( $row = mysqli_fetch_assoc($result_income) ) { ?>
<td><?php echo $row ['amount']; ?></td>
<td><?php echo $row ['date_of_income']; ?></td>
<td><?php echo $row ['name']; ?></td>
</tr>
<?php }
?>
<?php unset($_SESSION['successful_bilance']) ?>
<?php }
?>
</tbody>
</table>
</div>
</div>
<div class="container">
<div class="table-wrapper">
<div class="table-title">
<div class="row">
<div class="col-sm-8"><h2>Wydatki</h2></div>
</div>
</div>
<table id="editableTable" class="table table-bordered">
<thead>
<tr>
<th>Kwota</th>
<th>Data</th>
<th>Kategoria</th>
</tr>
</thead>
<tbody>
<?php
if (isset($_SESSION['successful_expense'])) {
while( $row = mysqli_fetch_assoc($result_expense) ) { ?>
<td><?php echo $row ['amount']; ?></td>
<td><?php echo $row ['date_of_expense']; ?></td>
<td><?php echo $row ['name']; ?></td>
</tr>
<?php }
?>
<?php unset($_SESSION['successful_expense']) ?>
<?php }
?>
</tbody>
</table>
</div>
</div>
<!--###############################-->
<!--diagram ########################-->
<!--###############################-->
<div class="container">
<div class="chart-container">
<div class="col-xs-12 col-sm-12 col-md-8 col-md-offset-2 col-lg-12">
<canvas id="myChart"></canvas>
</div>
</div>
</div>
<!--###############################-->
<!--stopka ########################-->
<!--###############################-->
<hr>
<footer>
<div class="navbar navbar-fixed-bottom" id="stopka">
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<h4>Copyright 2019 © Budgety.pl</h4>
</div>
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<a href="#"><img src="icons/facebook.png" alt="" class="img-responsive"></a>
<a href="#"><img src="icons/googleplus.png" alt="" class="img-responsive"></a>
<a href="#"><img src="icons/twitter.png" alt="" class="img-responsive"></a>
<a href="#"><img src="icons/vimeo.png" alt="" class="img-responsive"></a> </div>
</div>
</footer>
<!-- sekcja JavaScript -->
<script src="js/jquery-2.0.3.min.js"></script>
<script src="js/bootstrap.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js@2.8.0/dist/Chart.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.1/js/bootstrap-datepicker.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.1/css/bootstrap-datepicker3.css"/>
<script src="js/wlasny.js"></script>
<script>
</script>
</body>
</html>