Merge pull request #734 from o-psi/balance-sheet

Add balance sheet report
This commit is contained in:
Johnny 2023-10-11 14:31:45 -04:00 committed by GitHub
commit 44671d4769
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 542 additions and 14 deletions

View File

@ -21,13 +21,31 @@
</div>
<div class="form-group">
<label>Opening Balance</label>
<label>Account Type <strong class="text-danger">*</strong></label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-list"></i></span>
</div>
<select class="form-control select" name="type" required>
<option value="">- Select -</option>
<?php
$sql_account_types = mysqli_query($mysqli, "SELECT * FROM account_types ORDER BY account_type_name ASC");
while ($row = mysqli_fetch_array($sql_account_types)) {
$account_type_id = intval($row['account_type_id']);
$account_type_name = nullable_htmlentities($row['account_type_name']);
if($account_type_id % 10 != 0) {
echo "<option value='$account_type_id'>$account_type_name</option>";}}?>
</select>
</div>
</div>
<div class="form-group">
<label>Opening Balance <strong class="text-danger">*</strong></label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-dollar-sign"></i></span>
</div>
<input type="text" class="form-control" inputmode="numeric" pattern="[0-9]*\.?[0-9]{0,2}" name="opening_balance" placeholder="0.00" required>
</div>
<input type="text" class="form-control" inputmode="numeric" pattern="-?[0-9]*\.?[0-9]{0,2}" name="opening_balance" placeholder="0.00" required>
</div>
<div class="form-group">

View File

@ -10,7 +10,6 @@
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="account_id" value="<?php echo $account_id; ?>">
<div class="modal-body bg-white">
<div class="form-group">
<label>Account Name <strong class="text-danger">*</strong></label>
<div class="input-group">
@ -20,12 +19,35 @@
<input type="text" class="form-control" name="name" value="<?php echo $account_name; ?>" placeholder="Account name" required>
</div>
</div>
<div class="form-group">
<label>Account Type <strong class="text-danger">*</strong></label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-list"></i></span>
</div>
<select class="form-control select" name="type" required>
<option value="">- Select -</option>
<?php
$sql_account_type = mysqli_query($mysqli, "SELECT * FROM account_types WHERE account_type_id = $account_type_id");
$row = mysqli_fetch_array($sql_account_type);
$account_type_name = nullable_htmlentities($row['account_type_name']);
echo "<option value='$account_type_id' selected>$account_type_name</option>";
?>
<option value="">----------------</option>
<?php
$sql_account_types = mysqli_query($mysqli, "SELECT * FROM account_types ORDER BY account_type_name ASC");
while ($row = mysqli_fetch_array($sql_account_types)) {
$account_type_id = intval($row['account_type_id']);
$account_type_name = nullable_htmlentities($row['account_type_name']);
if($account_type_id % 10 != 0) {
echo "<option value='$account_type_id'>$account_type_name</option>";}}?>
</select>
</div>
</div>
<div class="form-group">
<label>Notes</label>
<textarea class="form-control" rows="5" placeholder="Enter some notes" name="notes"><?php echo $account_notes; ?></textarea>
</div>
</div>
<div class="modal-footer bg-white">
<button type="submit" name="edit_account" class="btn btn-primary text-bold"><i class="fa fa-check mr-2"></i>Save</button>

View File

@ -43,6 +43,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<thead class="text-dark <?php if ($num_rows[0] == 0) { echo "d-none"; } ?>">
<tr>
<th><a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=account_name&order=<?php echo $disp; ?>">Name</a></th>
<th class="text-center">Type</th>
<th><a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=account_currency_code&order=<?php echo $disp; ?>">Currency</a></th>
<th class="text-right">Balance</th>
<th class="text-center">Action</th>
@ -57,6 +58,10 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
$opening_balance = floatval($row['opening_balance']);
$account_currency_code = nullable_htmlentities($row['account_currency_code']);
$account_notes = nullable_htmlentities($row['account_notes']);
$account_type_id = intval($row['account_type']);
//Find account type name
$account_type = mysqli_query($mysqli, "SELECT * FROM account_types WHERE account_type_id = $account_type_id");
$sql_payments = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS total_payments FROM payments WHERE payment_account_id = $account_id");
$row = mysqli_fetch_array($sql_payments);
@ -75,6 +80,8 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<tr>
<td><a class="text-dark" href="#" data-toggle="modal" data-target="#editAccountModal<?php echo $account_id; ?>"><?php echo $account_name; ?></a></td>
<td class="text-center"> <?php echo nullable_htmlentities(mysqli_fetch_array($account_type)['account_type_name']); ?>
</td>
<td><?php echo $account_currency_code; ?></td>
<td class="text-right"><?php echo numfmt_format_currency($currency_format, $balance, $account_currency_code); ?></td>
<td>
@ -88,7 +95,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
</a>
<?php if ($balance == 0 && $account_id != $config_stripe_account) { //Cannot Archive an Account until it reaches 0 Balance and cant be selected as an online account ?>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_account=<?php echo $account_id; ?>">
<a class="dropdown-item text-danger" href="post.php?archive_account=<?php echo $account_id; ?>">
<i class="fas fa-fw fa-archive mr-2"></i>Archive
</a>
<?php } ?>

View File

@ -1374,12 +1374,27 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) {
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.8.6'");
}
//if (CURRENT_DATABASE_VERSION == '0.8.6') {
// Update DB to 0.8.7
if (CURRENT_DATABASE_VERSION == '0.8.6') {
// Insert queries here required to update to DB version 0.8.7
mysqli_query($mysqli, "ALTER TABLE `accounts` ADD `account_type` int(6) DEFAULT NULL AFTER `account_notes`");
mysqli_query($mysqli, "CREATE TABLE `account_types` (`account_type_id` int(11) NOT NULL AUTO_INCREMENT,`account_type_name` varchar(255) NOT NULL,`account_type_description` text DEFAULT NULL,`account_type_created_at` datetime NOT NULL DEFAULT current_timestamp(),`account_type_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(),`account_type_archived_at` datetime DEFAULT NULL,PRIMARY KEY (`account_type_id`))");
// Then, update the database to the next sequential version
//mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.8.7'");
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.8.7'");
}
// Be sure to change database_version.php to reflect the version you are updating to here
// Please add this same comment block to the bottom of this file, and update the version number.
// Uncomment Below Lines, to add additional database updates
//
//if (CURRENT_DATABASE_VERSION == '0.8.7') {
// Insert queries here required to update to DB version 0.8.9
//
// Then, update the database to the next sequential version
//mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.8.8'");
//}
//
} else {
// Up-to-date

18
db.sql
View File

@ -28,13 +28,29 @@ CREATE TABLE `accounts` (
`opening_balance` decimal(15,2) NOT NULL DEFAULT 0.00,
`account_currency_code` varchar(200) NOT NULL,
`account_notes` text DEFAULT NULL,
`account_type` int(6) NOT NULL DEFAULT NULL,
`account_created_at` datetime NOT NULL DEFAULT current_timestamp(),
`account_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(),
`account_archived_at` datetime DEFAULT NULL,
PRIMARY KEY (`account_id`)
PRIMARY KEY (`account_id`),
CONSTRAINT `fk_accounts_account_type_id` FOREIGN KEY (`account_type`) REFERENCES `account_types` (`account_type_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `account_types`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `account_types` (
`account_type_id` int(11) NOT NULL AUTO_INCREMENT,
`account_type_name` varchar(200) NOT NULL,
`account_type_description` text DEFAULT NULL,
`account_type_created_at` datetime NOT NULL DEFAULT current_timestamp(),
`account_type_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(),
`account_type_archived_at` datetime DEFAULT NULL,
PRIMARY KEY (`account_type_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Table structure for table `api_keys`
--

View File

@ -10,6 +10,7 @@ require_once("check_login.php");
// Load specific module logic
require_once("post/account.php");
require_once("post/account_type.php");
require_once("post/api.php");
require_once("post/asset.php");
require_once("post/category.php");

View File

@ -10,8 +10,9 @@ if (isset($_POST['add_account'])) {
$opening_balance = floatval($_POST['opening_balance']);
$currency_code = sanitizeInput($_POST['currency_code']);
$notes = sanitizeInput($_POST['notes']);
$type = intval($_POST['type']);
mysqli_query($mysqli,"INSERT INTO accounts SET account_name = '$name', opening_balance = $opening_balance, account_currency_code = '$currency_code', account_notes = '$notes'");
mysqli_query($mysqli,"INSERT INTO accounts SET account_name = '$name', opening_balance = $opening_balance, account_currency_code = '$currency_code', account_type ='$type', account_notes = '$notes'");
//Logging
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Account', log_action = 'Create', log_description = '$name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id");
@ -26,9 +27,10 @@ if (isset($_POST['edit_account'])) {
$account_id = intval($_POST['account_id']);
$name = sanitizeInput($_POST['name']);
$type = intval($_POST['type']);
$notes = sanitizeInput($_POST['notes']);
mysqli_query($mysqli,"UPDATE accounts SET account_name = '$name', account_notes = '$notes' WHERE account_id = $account_id");
mysqli_query($mysqli,"UPDATE accounts SET account_name = '$name',account_type = '$type', account_notes = '$notes' WHERE account_id = $account_id");
//Logging
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Account', log_action = 'Modify', log_description = '$name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id");

74
post/account_type.php Normal file
View File

@ -0,0 +1,74 @@
<?php
/*
* ITFlow - GET/POST request handler for account(s) (accounting related)
*/
if (isset($_POST['add_account_type'])) {
$name = sanitizeInput($_POST['name']);
$type = intval($_POST['type']);
$description = sanitizeInput($_POST['description']);
switch ($type) {
case 10:
$type_name = "Assets";
$result = mysqli_query($mysqli,"SELECT account_type_id FROM account_types");
$account_type_id = 10;
while ($row = mysqli_fetch_array($result)) {
if ($row['account_type_id'] == $account_type_id) {
$account_type_id++;
}
}
mysqli_query($mysqli,"INSERT INTO account_types SET account_type_id = $account_type_id, account_type_name = '$name', account_type_description = '$description'");
break;
case 20:
$type_name = "Liabilities";
$result = mysqli_query($mysqli,"SELECT account_type_id FROM account_types");
$account_type_id = 20;
while ($row = mysqli_fetch_array($result)) {
if ($row['account_type_id'] == $account_type_id) {
$account_type_id++;
}
}
mysqli_query($mysqli,"INSERT INTO account_types SET account_type_id = $account_type_id, account_type_name = '$name', account_type_description = '$description'");
break;
case 30:
$type_name = "Equity";
$result = mysqli_query($mysqli,"SELECT account_type_id FROM account_types");
$account_type_id = 30;
while ($row = mysqli_fetch_array($result)) {
if ($row['account_type_id'] == $account_type_id) {
$account_type_id++;
}
}
mysqli_query($mysqli,"INSERT INTO account_types SET account_type_id = $account_type_id, account_type_name = '$name', account_type_description = '$description'");
break;
}
//Logging
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Account', log_action = 'Create', log_description = '$name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id");
$_SESSION['alert_message'] = "Account added";
header("Location: " . $_SERVER["HTTP_REFERER"]);
}
if (isset($_POST['edit_account_type'])) {
$account_type_id = intval($_POST['account_type_id']);
$name = sanitizeInput($_POST['name']);
$description = sanitizeInput($_POST['description']);
mysqli_query($mysqli,"UPDATE account_types SET account_type_name = '$name', account_type_description = '$description' WHERE account_type_id = $account_type_id");
//Logging
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Account', log_action = 'Edit', log_description = '$name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id");
$_SESSION['alert_message'] = "Account edited";
header("Location: " . $_SERVER["HTTP_REFERER"]);
}

168
report_balance_sheet.php Normal file
View File

@ -0,0 +1,168 @@
<?php
require_once("inc_all_reports.php");
validateAccountantRole();
// Fetch Accounts and their balances
$sql_accounts = "
SELECT
a.account_id,
a.account_name,
a.opening_balance,
a.account_currency_code,
a.account_notes,
a.account_type,
COALESCE(SUM(p.payment_amount), 0) AS total_payments,
COALESCE(SUM(r.revenue_amount), 0) AS total_revenues,
COALESCE(SUM(e.expense_amount), 0) AS total_expenses
FROM accounts a
LEFT JOIN payments p ON a.account_id = p.payment_account_id
LEFT JOIN revenues r ON a.account_id = r.revenue_account_id
LEFT JOIN expenses e ON a.account_id = e.expense_account_id
GROUP BY a.account_id
ORDER BY a.account_type, a.account_name ASC";
$result_accounts = mysqli_query($mysqli, $sql_accounts);
$total_assets = 0;
$total_liabilities = 0;
$total_equity = 0;
$currency = $session_company_currency;
?>
<div class="card card-dark">
<div class="card-header py-2">
<h3 class="card-title mt-2"><i class="fas fa-fw fa-balance-scale mr-2"></i>Balance Sheet</h3>
<div class="card-tools">
<button type="button" class="btn btn-primary d-print-none" onclick="window.print();"><i class="fas fa-fw fa-print mr-2"></i>Print</button>
</div>
</div>
<div class="card-body p-0">
<div class="table-responsive-sm">
<div class="text-center">
<h2 class="text-dark">
<?php echo nullable_htmlentities($session_company_name);?>
</h2>
<h3 class="text-dark">Balance Sheet</h3>
<h5 class="text-dark">As of <?php echo date("F j, Y"); ?></h5>
</div>
<table class="table table-sm">
<thead class="text-dark">
<tr>
<th>Account Type</th>
<th>Account Name</th>
<th class="text-right">Account Balance</th>
</tr>
</thead>
<tbody>
<!-- Assets Section -->
<tr>
<th colspan="3" >Assets</th>
</tr>
<?php
while ($row = mysqli_fetch_array($result_accounts)) {
$account_type = $row['account_type'];
if ($account_type >= 11 && $account_type <= 19) {
$balance = $row['opening_balance'] + $row['total_payments'] + $row['total_revenues'] - $row['total_expenses'];
print_row($row, $balance, $currency_format);
$total_assets += $balance;
$formatted_total_assets = numfmt_format_currency($currency_format, $total_assets, $row['account_currency_code']);
}
}
?>
<tr>
<th></th>
<th class="text-uppercase">Total Assets</th>
<th class="text-right"><?php echo $formatted_total_assets; ?></th>
</tr>
<!-- Liabilities Section -->
<tr>
<th colspan="3" >Liabilities</th>
</tr>
<?php
mysqli_data_seek($result_accounts, 0); // Reset the result pointer to the start
while ($row = mysqli_fetch_array($result_accounts)) {
$balance = $row['opening_balance'] + $row['total_payments'] + $row['total_revenues'] - $row['total_expenses'];
$account_type = $row['account_type'];
if ($account_type >= 21 && $account_type <= 29) {
$balance = $row['opening_balance'] + $row['total_payments'] + $row['total_revenues'] - $row['total_expenses'];
print_row($row, $balance, $currency_format);
$total_liabilities += $balance;
$formatted_total_liabilities = numfmt_format_currency($currency_format, $total_liabilities, $row['account_currency_code']);
}
}
?>
<tr>
<th></th>
<th class="text-uppercase">Total Liabilities</th>
<th class="text-right"><?php echo $formatted_total_liabilities; ?></th>
</tr>
<!-- Equity Section -->
<tr>
<th colspan="3" >Equity</th>
</tr>
<?php
mysqli_data_seek($result_accounts, 0); // Reset the result pointer to the start
while ($row = mysqli_fetch_array($result_accounts)) {
$balance = $row['opening_balance'] + $row['total_payments'] + $row['total_revenues'] - $row['total_expenses'];
$account_type = $row['account_type'];
if ($account_type >= 30) {
$balance = $row['opening_balance'] + $row['total_payments'] + $row['total_revenues'] - $row['total_expenses'];
print_row($row, $balance, $currency_format);
$total_equity += $balance;
$formatted_total_equity = numfmt_format_currency($currency_format, $total_equity, $row['account_currency_code']);
}
}
?>
<tr>
<th></th>
<th class="text-uppercase">Total Equity</th>
<th class="text-right"><?php echo $formatted_total_equity; ?></th>
</tr>
<!-- Total Equity and Liabilities -->
<?php
$total_liabilities_and_equity = $total_liabilities + $total_equity;
$formatted_total_liabilities_and_equity = numfmt_format_currency($currency_format, $total_liabilities_and_equity, $currency);
?>
<tr>
<th></th>
<th class="text-uppercase">Total Liabilities and Equity</th>
<th class="text-right"><?php echo $formatted_total_liabilities_and_equity; ?></th>
</tr>
<tr>
<th>
Unbalanced:
<div><?php
$unbalanced = $total_assets + $total_liabilities_and_equity;
echo numfmt_format_currency($currency_format, $unbalanced, $currency);
?>
</div>
</th>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<?php require_once("footer.php");
function print_row($row, $balance, $currency_format) {
$account_name = nullable_htmlentities($row['account_name']);
$formatted_balance = numfmt_format_currency($currency_format, $balance, $row['account_currency_code']);
echo "<tr>";
echo "<td></td>";
echo "<td>$account_name</td>";
echo "<td class='text-right'>$formatted_balance</td>";
echo "</tr>";
}
?>

View File

@ -70,6 +70,12 @@
<p>Profit & Loss</p>
</a>
</li>
<li class="nav-item">
<a href="report_balance_sheet.php" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "report_balance_sheet.php") { echo "active"; } ?>">
<i class="fas fa-balance-scale nav-icon"></i>
<p>Balance Sheet</p>
</a>
</li>
<?php } // End financial reports IF statement ?>
<?php if ($session_user_role == 2 || $session_user_role == 3) { ?>

104
settings_account_types.php Normal file
View File

@ -0,0 +1,104 @@
<?php
require_once("inc_all_settings.php");
// Default Column Sortby Filter
$sort = "account_type_id";
$order = "ASC";
$sql = mysqli_query(
$mysqli,
"SELECT * FROM account_types
WHERE account_type_archived_at IS NULL
ORDER BY $sort $order"
);
$num_rows = mysqli_num_rows($sql);
?>
<div class="card card-dark">
<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>
</div>
</div>
<div class="card-body">
<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>
</thead>
<tbody>
<?php
while ($row = mysqli_fetch_array($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>
<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>
<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>
</div>
</div>
</td>
</tr>
<?php
require("settings_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("settings_account_types_add_modal.php");
require_once("footer.php");
?>

View File

@ -0,0 +1,37 @@
<div class="modal" id="addAccountTypeModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content bg-dark">
<div class="modal-header text-white">
<h5 class="modal-title"><i class="fas fa-money-bill-wave mr-2"></i>New Account Type</h5>
<button type="button" class="close text-white" data-dismiss="modal">
<span aria-hidden="true">&times;</span>
</button>
</div>
<form action="post.php" method="post" autocomplete="off">
<div class="modal-body bg-white">
<div class="form-group">
<label>Name <strong class="text-danger">*</strong></label>
<input type="text" class="form-control" name="name" placeholder="Account Name" required autofocus>
</div>
<div class="form-group">
<label>Account Type</label>
<select class="form-control select2" name="type">
<option value="">- Select -</option>
<option value="10">Assets</option>
<option value="20">Liabilities</option>
<option value="30">Equity</option>
</select>
</div>
<div class="form-group">
<label>Description</label>
<textarea class="form-control" name="description" placeholder="Description"></textarea>
</div>
</div>
<div class="modal-footer bg-white">
<button type="submit" name="add_account_type" class="btn btn-primary text-bold"><i class="fa fa-check mr- 2"></i>Create</button>
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fas fa-times mr-2"></i>Cancel</button>
</div>
</form>
</div>
</div>
</div>

View File

@ -0,0 +1,36 @@
<div class="modal" id="editAccountTypeModal<?php echo $account_type_id; ?>" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content bg-dark">
<div class="modal-header">
<h5 class="modal-title"><i class="fas fa-fw fa-balance-scale mr-2"></i>Editing account type: <strong><?php echo $account_type_name; ?></strong></h5>
<button type="button" class="close text-white" data-dismiss="modal">
<span>&times;</span>
</button>
</div>
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="account_type_id" value="<?php echo $account_type_id; ?>">
<div class="modal-body bg-white">
<div>
<label>Type Group</label>
<input type="text" class="form-control" name="type_group" value="<?php echo $account_type_group; ?>" readonly>
</div>
<div class="form-group">
<label>Name <strong class="text-danger">*</strong></label>
<input type="text" class="form-control" name="name" value="<?php echo $account_type_name; ?>" required>
</div>
<div class="form-group">
<label>Description</label>
<textarea class="form-control" name="description" placeholder="Description"><?php echo $account_type_description; ?></textarea>
</div>
</div>
<div class="modal-footer bg-white">
<button type="submit" name="edit_account_type" class="btn btn-primary text-bold"><i class="fas fa-check mr-2"></i>Save</button>
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fas fa-times mr-2"></i>Cancel</button>
</div>
</form>
</div>
</div>
</div>

View File

@ -112,6 +112,13 @@
</a>
</li>
<li class="nav-item">
<a href="settings_account_types.php" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "settings_account_types.php") { echo "active"; } ?>">
<i class="nav-icon fas fa-money-bill-wave"></i>
<p>Account Types</p>
</a>
</li>
<li class="nav-header mt-3">TEMPLATES</li>
<li class="nav-item">

View File

@ -1018,10 +1018,23 @@ if (isset($_POST['add_company_settings'])) {
unlink('uploads/tmp/cronkey.php');
}
//Create Some Data
//Create Default Accounts
mysqli_query($mysqli,"INSERT INTO accounts SET account_name = 'Cash', account_type = '11', account_currency_code = '$currency_code'");
mysqli_query($mysqli,"INSERT INTO accounts SET account_name = 'Cash', account_currency_code = '$currency_code'");
//Create Main Account Types
mysqli_query($mysqli,"INSERT INTO account_types SET account_type_name = 'Asset', account_type_id= '10', account_type_description = 'Assets are economic resources which are expected to benefit the business in the future.'");
mysqli_query($mysqli,"INSERT INTO account_types SET account_type_name = 'Liability', account_type_id= '20', account_type_description = 'Liabilities are obligations of the business entity. They are usually classified as current liabilities (due within one year or less) and long-term liabilities (due after one year).'");
mysqli_query($mysqli,"INSERT INTO account_types SET account_type_name = 'Equity', account_type_id= '30', account_type_description = 'Equity represents the owners stake in the business after liabilities have been deducted.'");
//Create Secondary Account Types
mysqli_query($mysqli,"INSERT INTO account_types SET account_type_name = 'Current Asset', account_type_id= '11', account_type_description = 'Current assets are expected to be consumed within one year or less.'");
mysqli_query($mysqli,"INSERT INTO account_types SET account_type_name = 'Fixed Asset', account_type_id= '12', account_type_description = 'Fixed assets are expected to benefit the business for more than one year.'");
mysqli_query($mysqli,"INSERT INTO account_types SET account_type_name = 'Other Asset', account_type_id= '19', account_type_description = 'Other assets are assets that do not fit into any of the other asset categories.'");
mysqli_query($mysqli,"INSERT INTO account_types SET account_type_name = 'Current Liability', account_type_id= '21', account_type_description = 'Current liabilities are expected to be paid within one year or less.'");
mysqli_query($mysqli,"INSERT INTO account_types SET account_type_name = 'Long Term Liability', account_type_id= '22', account_type_description = 'Long term liabilities are expected to be paid after one year.'");
mysqli_query($mysqli,"INSERT INTO account_types SET account_type_name = 'Other Liability', account_type_id= '29', account_type_description = 'Other liabilities are liabilities that do not fit into any of the other liability categories.'");
//Create Categories
mysqli_query($mysqli,"INSERT INTO categories SET category_name = 'Office Supplies', category_type = 'Expense', category_color = 'blue'");
mysqli_query($mysqli,"INSERT INTO categories SET category_name = 'Travel', category_type = 'Expense', category_color = 'red'");
mysqli_query($mysqli,"INSERT INTO categories SET category_name = 'Advertising', category_type = 'Expense', category_color = 'green'");
@ -1034,9 +1047,11 @@ if (isset($_POST['add_company_settings'])) {
mysqli_query($mysqli,"INSERT INTO categories SET category_name = 'Cash', category_type = 'Payment Method', category_color = 'blue'");
mysqli_query($mysqli,"INSERT INTO categories SET category_name = 'Check', category_type = 'Payment Method', category_color = 'red'");
//Create Calendar
mysqli_query($mysqli,"INSERT INTO calendars SET calendar_name = 'Default', calendar_color = 'blue'");
$_SESSION['alert_message'] = "Company <strong>$name</strong> created!";
header("Location: setup.php?telemetry");