<?php
/*
* date last modified 03-10-2017
* Edited by PI-Digi Logical Solutions
* HTML Files - manage_staff.html.php
* Mysql Tables - tbl_admin, tbl_purchase_order, tbl_admin_type
*/
require_once('./includes/functions.php'); # general functions

$totalIncome = 0;
$totalExpenses = 0;
$totalBalance = 0;

$incomesRec = mysqli_fetch_array(mysqli_query($con, "SELECT SUM(amount) AS amount FROM tbl_project_income WHERE project_id IN (SELECT id FROM tbl_project WHERE status = 'completed')"));

$totalIncome = $incomesRec['amount'];

$expensesRec = mysqli_fetch_array(mysqli_query($con, "SELECT SUM(amount) AS amount FROM tbl_project_expense WHERE project_id IN (SELECT id FROM tbl_project WHERE status = 'completed')"));

$totalExpenses = $expensesRec['amount'];

$totalBalance = $totalIncome - $totalExpenses;
$totalBalance = abs($totalBalance);

?>