-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdaily_expenses_table.php
135 lines (110 loc) · 3.92 KB
/
daily_expenses_table.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>expense tracker | Expenses</title>
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen"/>
<!-- calender -->
<link type="text/css" href="scripts/jquery/css/smoothness/jquery-ui-1.10.3.custom.css" rel="stylesheet"/>
<script type="text/javascript" src="scripts/jquery/js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="scripts/jquery/js/jquery-ui-1.10.3.custom.js"></script>
<link rel="stylesheet" href="css/" type="text/css"/>
<style type="text/css">
table.demoTbl {
border-collapse: collapse;
border-spacing: 0;
}
#tblCap {
font-weight: bold;
font-size: 15px;
margin: 1em auto .4em;
}
table.demoTbl .desc {
width: 250px;
}
table.demoTbl .category {
width: 100px;
}
table.demoTbl .amount {
width: 100px;
}
table.demoTbl .actions {
width: 100px;
}
table.demoTbl td, table.demoTbl th {
padding: 1px;
}
table.demoTbl th.first {
text-align: center;
padding: 3px;
background-color: #CCCCCC;
}
table.demoTbl td.num {
text-align: right;
}
table.demoTbl td.cat {
text-align: center;
}
table.demoTbl td.foot {
text-align: center;
}
</style>
</head>
<body>
<?php
include_once('plugins/html_table.class.php');
include_once('config.db.php');
include_once('dbplugin.php');
include_once('date_handler.php');
include_once('plugins/KLogger.php');
$log = new KLogger ("/var/www/extracker/logs/", KLogger::DEBUG);
$crntYear = getYear();
$crntMonth = getMonth();
$crntDay = getDay();
// arguments: id, class, border,
// can include associative array of optional additional attributes
$tbl = new HTML_Table('', 'demoTbl', 0);
$tbl->addCaption('Today\'s Expenses', 'cap', array('id' => 'tblCap'));
$tbl->addColgroup();
// span, class
$tbl->addCol(0, 'desc');
$tbl->addCol(1, 'category');
$tbl->addCol(2, 'amount');
$tbl->addCol(3, 'actions');
// thead
$tbl->addTSection('thead');
$tbl->addRow();
// arguments: cell content, class, type (default is 'data' for td, pass 'header' for th)
// can include associative array of optional additional attributes
$tbl->addCell('Description', 'first', 'header');
$tbl->addCell('Category', 'first', 'header');
$tbl->addCell('Amount (Rs)', 'first', 'header');
$tbl->addCell('Actions', 'first', 'header');
// tfoot
$tbl->addTSection('tfoot');
$tbl->addRow();
// span all 3 columns
$tbl->addCell('', 'foot', 'data', array('colspan' => 4));
// tbody
$tbl->addTSection('tbody');
// populate table
$fill = "SELECT id,description,category_id,amount FROM expences WHERE year='$crntYear' AND month='$crntMonth' AND day='$crntDay'";
$result = mysqli_query($db, $fill);
$rowcount = mysqli_num_rows($result);
while ($row = mysqli_fetch_array($result)) {
$desc = $row['description'];
$cats = getCategoryName($db, $row['category_id']);
$amount = number_format($row['amount'], 2);
$recId = $row['id'];
$actions = "<a href=\"javascript:void(null);\" onclick=\"document.getElementById('myform" . $recId . "').submit();\"><button class=\"ui-state-default ui-corner-all\" title=\"delete record\" onclick=\"deleteRecord($recId)\"><span class=\"ui-icon ui-icon-trash\"></span></button></a>";
echo "<form id=\"myform" . $recId . "\" action=\"expense_handler.php\" method=\"post\"><input type=\"hidden\" name=\"recId\" value=\"" . $recId . "\" /><input type=\"hidden\" name=\"amount\" value=\"" . $amount . "\" /></form>";
$tbl->addRow();
$tbl->addCell($desc);
$tbl->addCell($cats, 'cat');
$tbl->addCell($amount, 'num');
$tbl->addCell($actions, 'cat');
}
echo $tbl->display();
?>
</body>
</html>