forked from itflow-org/itflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin_account_types.php
183 lines (164 loc) · 7.77 KB
/
admin_account_types.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
<?php
require_once "inc_all_admin.php";
// Default Column Sortby Filter
$sort = "account_type_id";
$order = "ASC";
if (isset($_GET['account_type'])) {
$account_type = sanitizeInput($_GET['account_type']);
switch ($account_type) {
case "Assets":
$account_type_parent = "1";
break;
case "Liabilities":
$account_type_parent = "2";
break;
case "Equity":
$account_type_parent = "3";
break;
default:
$account_type_parent = "1";
}
} else {
$account_type_parent = "%";
}
$sql = mysqli_query(
$mysqli,
"SELECT * FROM account_types
WHERE account_type_$archive_query
AND account_type_parent LIKE '$account_type_parent'
AND (account_type_name LIKE '%$q%' OR account_type_description LIKE '%$q%')
ORDER BY account_type_parent ASC, $sort $order"
);
$num_rows = mysqli_num_rows($sql);
?>
<div class="card card-dark">
<div class="card-header py-2">
<h3 class="card-title mt-2"><i class="fas fa-fw fa-money-bill-wave mr-2"></i>Finance Account Types</h3>
<div class="card-tools">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addAccountTypeModal">
<i class="fas fa-plus mr-2"></i>Create Account Type
</button>
</div>
</div>
<div class="card-body">
<form autocomplete="off">
<div class="row">
<div class="col-sm-4 mb-2">
<div class="input-group">
<input type="search" class="form-control" name="q" value="<?php if (isset($q)) {
echo stripslashes(nullable_htmlentities($q));
} ?>" placeholder="Search Categories">
<div class="input-group-append">
<button class="btn btn-primary"><i class="fa fa-search"></i></button>
</div>
</div>
</div>
<div class="col-sm-8">
<div class="btn-group float-right">
<a href="admin_account_types.php" class="btn <?php if (!isset($_GET['account_type']) && !isset($_GET['archived'])) {
echo 'btn-primary';
} else {
echo 'btn-default';
} ?>">All</a>
<a href="?account_type=Assets" class="btn <?php if ($account_type == 'Assets') {
echo 'btn-primary';
} else {
echo 'btn-default';
} ?>">Assets</a>
<a href="?account_type=Liabilities" class="btn <?php if ($account_type == 'Liabilities') {
echo 'btn-primary';
} else {
echo 'btn-default';
} ?>">Liabilities</a>
<a href="?account_type=Equity" class="btn <?php if ($account_type == 'Equity') {
echo 'btn-primary';
} else {
echo 'btn-default';
} ?>">Equity</a>
<a href="?archived=1" class="btn <?php if ($_GET['archived']) {
echo 'btn-primary';
} else {
echo 'btn-default';
} ?>"><i class="fas fa-fw fa-archive mr-2"></i>Archived</a>
</div>
</div>
</div>
</form>
<form action="post.php" method="post" autocomplete="off">
<table class="table table-striped table-borderless table-hover">
<thead>
<tr>
<th>Account Type Parent</th>
<th>Account Type Name</th>
<th>Description</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
while ($row = mysqli_fetch_array($sql)) {
$account_type_id = intval($row['account_type_id']);
$account_type_parent = intval($row['account_type_parent']);
if($account_type_parent == 1) {
$account_type_parent_name = "Assets";
} elseif($account_type_parent == 2) {
$account_type_parent_name = "Liabilities";
} else {
$account_type_parent_name = "Equity";
}
$account_type_name = nullable_htmlentities($row['account_type_name']);
$account_type_description = nullable_htmlentities($row['account_type_description']);
?>
<tr>
<td><a class="text-dark text-bold" href="#" data-toggle="modal"
data-target="#editAccountTypeModal<?php echo $account_type_id; ?>">
<?php echo $account_type_parent_name; ?>
</a></td>
<td>
<?php echo $account_type_name; ?>
</td>
<td>
<?php echo $account_type_description; ?>
</td>
<td>
<div class="dropdown dropleft text-center">
<button class="btn btn-secondary btn-sm" type="button" data-toggle="dropdown">
<i class="fas fa-ellipsis-h"></i>
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#" data-toggle="modal"
data-target="#editAccountTypeModal<?php echo $account_type_id; ?>">
<i class="fas fa-fw fa-edit mr-2"></i>Edit
</a>
<div class="dropdown-divider"></div>
<?php if ($archived == NULL) { ?>
<a class="dropdown-item text-danger confirm-link"
href="post.php?archive_account_type=<?php echo $account_type_id; ?>">
<i class="fas fa-fw fa-archive mr-2"></i>Archive
</a>
<?php } else { ?>
<a class="dropdown-item text-success confirm-link"
href="post.php?unarchive_account_type=<?php echo $account_type_id; ?>">
<i class="fas fa-fw fa-archive mr-2"></i>Unarchive
</a>
<?php } ?>
</div>
</div>
</td>
</tr>
<?php
require "admin_account_types_edit_modal.php";
}
if ($num_rows == 0) {
echo "<h3 class='text-secondary mt-3' style='text-align: center'>No Records Here</h3>";
}
?>
</tbody>
</table>
</form>
</div>
</div>
<?php
require_once "admin_account_types_add_modal.php";
require_once "footer.php";
?>