changed view from long list to broken down by type

This commit is contained in:
o-psi 2023-10-14 23:34:54 -05:00
parent ab308af4f9
commit 1f3c103032
1 changed files with 80 additions and 25 deletions

View File

@ -5,11 +5,40 @@ require_once("inc_all_settings.php");
$sort = "account_type_id";
$order = "ASC";
if (isset($_GET['account_type'])) {
$account_type = sanitizeInput($_GET['account_type']);
switch ($account_type) {
case "Assets":
$account_type_id_min = "10";
$account_type_id_max = "19";
break;
case "Liabilities":
$account_type_id_min = "20";
$account_type_id_max = "29";
break;
case "Equity":
$account_type_id_min = "30";
$account_type_id_max = "39";
break;
default:
$account_type_id_min = "10";
$account_type_id_max = "39";
}
} else {
if (isset($_GET['archived'])) {
$account_type_id_min = "10";
$account_type_id_max = "39"; }
}
$sql = mysqli_query(
$mysqli,
"SELECT * FROM account_types
WHERE account_type_archived_at IS NULL
WHERE account_type_$archive_query
AND account_type_id >= $account_type_id_min
AND account_type_id <= $account_type_id_max
ORDER BY $sort $order"
);
@ -21,17 +50,41 @@ $num_rows = mysqli_num_rows($sql);
<div class="card-header py-3">
<h3 class="card-title"><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>New Account Type</button>
<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">
<div class="col-sm-8">
<div class="btn-group float-right">
<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>
<form action="post.php" method="post" autocomplete="off">
<table class="table table-striped table-borderless table-hover">
<thead>
<tr>
<th>Account Type ID</th>
<th>Account Type Name</th>
<th>Type Group</th>
<th>Description</th>
<th></th>
</tr>
@ -43,45 +96,47 @@ $num_rows = mysqli_num_rows($sql);
$account_type_id = nullable_htmlentities($row['account_type_id']);
$account_type_name = nullable_htmlentities($row['account_type_name']);
$account_type_description = nullable_htmlentities($row['account_type_description']);
$account_type_group = $row['account_type_id'];
if($account_type_group < 20) {
$account_type_group_name = "Assets";
} elseif($account_type_group < 30) {
$account_type_group_name = "Liabilities";
} elseif($account_type_group < 40) {
$account_type_group_name = "Equity";
} else {
$account_type_group_name = "Other";
}
?>
?>
<tr>
<td><a class="text-dark text-bold" href="#" data-toggle="modal" data-target="#editAccountTypeModal<?php echo $account_type_id; ?>"><?php echo $account_type_id; ?></a></td>
<td><?php echo $account_type_name; ?></td>
<td><?php
echo $account_type_group_name;
?></td>
<td><?php echo $account_type_description; ?></td>
<td><a class="text-dark text-bold" href="#" data-toggle="modal"
data-target="#editAccountTypeModal<?php echo $account_type_id; ?>">
<?php echo $account_type_id; ?>
</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; ?>">
<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>
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_account_type=<?php echo $account_type_id; ?>">
<?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
<?php
require("settings_account_types_edit_modal.php");
}