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

@@ -11,7 +11,7 @@
<div class="modal-body bg-white">
<input type="hidden" name="transfer_id" value="<?php echo $transfer_id; ?>">
<input type="hidden" name="expense_id" value="<?php echo $expense_id; ?>">
<input type="hidden" name="payment_id" value="<?php echo $payment_id; ?>">
<input type="hidden" name="revenue_id" value="<?php echo $revenue_id; ?>">
<div class="form-row">
<div class="form-group col-sm">
<label>Date <strong class="text-danger">*</strong></label>
@@ -41,24 +41,28 @@
<select class="form-control selectpicker show-tick" name="account_from" required>
<?php
$sql2 = mysqli_query($mysqli,"SELECT * FROM accounts");
while($row = mysqli_fetch_array($sql2)){
$account_id2 = $row['account_id'];
$account_name = $row['account_name'];
$opening_balance = $row['opening_balance'];
$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'];
$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_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_payments FROM payments WHERE account_id = $account_id2");
$row = mysqli_fetch_array($sql_payments);
$total_payments = $row['total_payments'];
$sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS total_expenses FROM expenses WHERE account_id = $account_id2");
$row = mysqli_fetch_array($sql_expenses);
$total_expenses = $row['total_expenses'];
$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($transfer_account_from == $account_id2){ ?> selected <?php } ?> value="<?php echo $account_id2; ?>"><?php echo $account_name; ?> [$<?php echo number_format($balance,2); ?>]</option>
<option <?php if($transfer_account_from == $account_id_select){ ?> selected <?php } ?> value="<?php echo $account_id_select; ?>"><?php echo $account_name_select; ?> [$<?php echo number_format($balance,2); ?>]</option>
<?php
}
@@ -83,12 +87,16 @@
$sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_payments FROM payments WHERE account_id = $account_id2");
$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");
$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_id2");
$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($transfer_account_to == $account_id2){ ?> selected <?php } ?> value="<?php echo $account_id2; ?>"><?php echo $account_name; ?> [$<?php echo number_format($balance,2); ?>]</option>