reworked transfers, added revenues to add income in other ways besides just invoices, reports now uses a compact table to see all data clearly and some other minor fixes.

This commit is contained in:
johnny@pittpc.com
2019-08-11 13:42:35 -04:00
parent cae9b2b13b
commit 0c4021fd23
23 changed files with 697 additions and 87 deletions

View File

@@ -46,21 +46,26 @@
<select class="form-control selectpicker show-tick" name="account" required>
<?php
$sql_select = mysqli_query($mysqli,"SELECT * FROM accounts");
while($row = mysqli_fetch_array($sql_select)){
$sql_accounts = mysqli_query($mysqli,"SELECT * FROM accounts");
while($row = mysqli_fetch_array($sql_accounts)){
$account_id_select = $row['account_id'];
$account_name_select = $row['account_name'];
$opening_balance = $row['opening_balance'];
$opening_balance = $row['opening_balance'];
$sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_payments FROM payments WHERE account_id = $account_id_select");
$row = mysqli_fetch_array($sql_payments);
$total_payments = $row['total_payments'];
$sql_revenues = mysqli_query($mysqli,"SELECT SUM(revenue_amount) AS total_revenues FROM revenues WHERE account_id = $account_id_select");
$row = mysqli_fetch_array($sql_revenues);
$total_revenues = $row['total_revenues'];
$sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS total_expenses FROM expenses WHERE account_id = $account_id_select");
$row = mysqli_fetch_array($sql_expenses);
$total_expenses = $row['total_expenses'];
$balance = $opening_balance + $total_payments - $total_expenses;
$balance = $opening_balance + $total_payments + $total_revenues - $total_expenses;
?>
<option <?php if($account_id == $account_id_select){ ?> selected <?php } ?> value="<?php echo $account_id_select; ?>"><?php echo $account_name_select; ?> [$<?php echo number_format($balance,2); ?>]</option>
<?php