mirror of
https://github.com/itflow-org/itflow
synced 2026-03-22 13:35:37 +00:00
Removed uneeded query to calculate account balance added account balance to edit expense and transfer
This commit is contained in:
@@ -26,10 +26,6 @@
|
|||||||
$account_name = $row['account_name'];
|
$account_name = $row['account_name'];
|
||||||
$opening_balance = $row['opening_balance'];
|
$opening_balance = $row['opening_balance'];
|
||||||
|
|
||||||
$sql_accounts = mysqli_query($mysqli,"SELECT * FROM accounts WHERE account_id = $account_id");
|
|
||||||
$row = mysqli_fetch_array($sql_accounts);
|
|
||||||
$opening_balance = $row['opening_balance'];
|
|
||||||
|
|
||||||
$sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_payments FROM payments WHERE account_id = $account_id");
|
$sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_payments FROM payments WHERE account_id = $account_id");
|
||||||
$row = mysqli_fetch_array($sql_payments);
|
$row = mysqli_fetch_array($sql_payments);
|
||||||
$total_payments = $row['total_payments'];
|
$total_payments = $row['total_payments'];
|
||||||
|
|||||||
@@ -41,9 +41,6 @@
|
|||||||
while($row = mysqli_fetch_array($sql)){
|
while($row = mysqli_fetch_array($sql)){
|
||||||
$account_id = $row['account_id'];
|
$account_id = $row['account_id'];
|
||||||
$account_name = $row['account_name'];
|
$account_name = $row['account_name'];
|
||||||
|
|
||||||
$sql_accounts = mysqli_query($mysqli,"SELECT * FROM accounts WHERE account_id = $account_id");
|
|
||||||
$row = mysqli_fetch_array($sql_accounts);
|
|
||||||
$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");
|
$sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_payments FROM payments WHERE account_id = $account_id");
|
||||||
|
|||||||
@@ -46,9 +46,6 @@
|
|||||||
while($row = mysqli_fetch_array($sql)){
|
while($row = mysqli_fetch_array($sql)){
|
||||||
$account_id = $row['account_id'];
|
$account_id = $row['account_id'];
|
||||||
$account_name = $row['account_name'];
|
$account_name = $row['account_name'];
|
||||||
|
|
||||||
$sql_accounts = mysqli_query($mysqli,"SELECT * FROM accounts WHERE account_id = $account_id");
|
|
||||||
$row = mysqli_fetch_array($sql_accounts);
|
|
||||||
$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");
|
$sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_payments FROM payments WHERE account_id = $account_id");
|
||||||
|
|||||||
@@ -44,9 +44,6 @@
|
|||||||
while($row = mysqli_fetch_array($sql)){
|
while($row = mysqli_fetch_array($sql)){
|
||||||
$account_id = $row['account_id'];
|
$account_id = $row['account_id'];
|
||||||
$account_name = $row['account_name'];
|
$account_name = $row['account_name'];
|
||||||
|
|
||||||
$sql_accounts = mysqli_query($mysqli,"SELECT * FROM accounts WHERE account_id = $account_id");
|
|
||||||
$row = mysqli_fetch_array($sql_accounts);
|
|
||||||
$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");
|
$sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_payments FROM payments WHERE account_id = $account_id");
|
||||||
@@ -82,9 +79,6 @@
|
|||||||
while($row = mysqli_fetch_array($sql)){
|
while($row = mysqli_fetch_array($sql)){
|
||||||
$account_id = $row['account_id'];
|
$account_id = $row['account_id'];
|
||||||
$account_name = $row['account_name'];
|
$account_name = $row['account_name'];
|
||||||
|
|
||||||
$sql_accounts = mysqli_query($mysqli,"SELECT * FROM accounts WHERE account_id = $account_id");
|
|
||||||
$row = mysqli_fetch_array($sql_accounts);
|
|
||||||
$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");
|
$sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_payments FROM payments WHERE account_id = $account_id");
|
||||||
|
|||||||
6
cron.php
6
cron.php
@@ -109,6 +109,7 @@ $sql = mysqli_query($mysqli,"SELECT * FROM invoices, clients
|
|||||||
WHERE invoices.client_id = clients.client_id
|
WHERE invoices.client_id = clients.client_id
|
||||||
AND invoices.invoice_number > 0
|
AND invoices.invoice_number > 0
|
||||||
AND invoices.invoice_status NOT LIKE 'Draft'
|
AND invoices.invoice_status NOT LIKE 'Draft'
|
||||||
|
AND invoices.invoice_status NOT LIKE 'Paid'
|
||||||
AND invoices.invoice_due = CURDATE() + INTERVAL 30 DAY
|
AND invoices.invoice_due = CURDATE() + INTERVAL 30 DAY
|
||||||
ORDER BY invoices.invoice_number DESC"
|
ORDER BY invoices.invoice_number DESC"
|
||||||
);
|
);
|
||||||
@@ -131,6 +132,7 @@ $sql = mysqli_query($mysqli,"SELECT * FROM invoices, clients
|
|||||||
WHERE invoices.client_id = clients.client_id
|
WHERE invoices.client_id = clients.client_id
|
||||||
AND invoices.invoice_number > 0
|
AND invoices.invoice_number > 0
|
||||||
AND invoices.invoice_status NOT LIKE 'Draft'
|
AND invoices.invoice_status NOT LIKE 'Draft'
|
||||||
|
AND invoices.invoice_status NOT LIKE 'Paid'
|
||||||
AND invoices.invoice_due = CURDATE() + INTERVAL 90 DAY
|
AND invoices.invoice_due = CURDATE() + INTERVAL 90 DAY
|
||||||
ORDER BY invoices.invoice_number DESC"
|
ORDER BY invoices.invoice_number DESC"
|
||||||
);
|
);
|
||||||
@@ -156,10 +158,6 @@ while($row = mysqli_fetch_array($sql)){
|
|||||||
$account_name = $row['account_name'];
|
$account_name = $row['account_name'];
|
||||||
$opening_balance = $row['opening_balance'];
|
$opening_balance = $row['opening_balance'];
|
||||||
|
|
||||||
$sql_accounts = mysqli_query($mysqli,"SELECT * FROM accounts WHERE account_id = $account_id");
|
|
||||||
$row = mysqli_fetch_array($sql_accounts);
|
|
||||||
$opening_balance = $row['opening_balance'];
|
|
||||||
|
|
||||||
$sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_payments FROM payments WHERE account_id = $account_id");
|
$sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_payments FROM payments WHERE account_id = $account_id");
|
||||||
$row = mysqli_fetch_array($sql_payments);
|
$row = mysqli_fetch_array($sql_payments);
|
||||||
$total_payments = $row['total_payments'];
|
$total_payments = $row['total_payments'];
|
||||||
|
|||||||
@@ -42,8 +42,19 @@
|
|||||||
while($row = mysqli_fetch_array($sql2)){
|
while($row = mysqli_fetch_array($sql2)){
|
||||||
$account_id2 = $row['account_id'];
|
$account_id2 = $row['account_id'];
|
||||||
$account_name = $row['account_name'];
|
$account_name = $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_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'];
|
||||||
|
|
||||||
|
$balance = $opening_balance + $total_payments - $total_expenses;
|
||||||
?>
|
?>
|
||||||
<option <?php if($account_id == $account_id2){ ?> selected <?php } ?> value="<?php echo $account_id2; ?>"><?php echo $account_name; ?></option>
|
<option <?php if($account_id == $account_id2){ ?> selected <?php } ?> value="<?php echo $account_id2; ?>"><?php echo $account_name; ?> [$<?php echo number_format($balance,2); ?>]</option>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,8 +46,20 @@
|
|||||||
while($row = mysqli_fetch_array($sql2)){
|
while($row = mysqli_fetch_array($sql2)){
|
||||||
$account_id2 = $row['account_id'];
|
$account_id2 = $row['account_id'];
|
||||||
$account_name = $row['account_name'];
|
$account_name = $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_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'];
|
||||||
|
|
||||||
|
$balance = $opening_balance + $total_payments - $total_expenses;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<option <?php if($transfer_account_from == $account_id2){ ?> selected <?php } ?> value="<?php echo $account_id2; ?>"><?php echo $account_name; ?></option>
|
<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>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,8 +80,20 @@
|
|||||||
while($row = mysqli_fetch_array($sql2)){
|
while($row = mysqli_fetch_array($sql2)){
|
||||||
$account_id2 = $row['account_id'];
|
$account_id2 = $row['account_id'];
|
||||||
$account_name = $row['account_name'];
|
$account_name = $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_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'];
|
||||||
|
|
||||||
|
$balance = $opening_balance + $total_payments - $total_expenses;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<option <?php if($transfer_account_to == $account_id2){ ?> selected <?php } ?> value="<?php echo $account_id2; ?>"><?php echo $account_name; ?></option>
|
<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>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user