From e639b69db9401173047c232f845562939fdd9bf3 Mon Sep 17 00:00:00 2001 From: johnnyq Date: Thu, 21 Dec 2023 13:03:37 -0500 Subject: [PATCH] Merged All Dashboards into 1 allow you to toggle between show financial and show technical --- dashboard.php | 1136 ++++++++++++++++++++++++++++++++++++++- dashboard_financial.php | 1128 -------------------------------------- dashboard_nav.php | 11 - dashboard_technical.php | 187 ------- side_nav.php | 2 +- 5 files changed, 1134 insertions(+), 1330 deletions(-) delete mode 100644 dashboard_financial.php delete mode 100644 dashboard_nav.php delete mode 100644 dashboard_technical.php diff --git a/dashboard.php b/dashboard.php index 0472e88f..63794698 100644 --- a/dashboard.php +++ b/dashboard.php @@ -1,7 +1,1137 @@ + +
+ + + + +
+ > + +
+ + + = 2 && $config_module_enable_ticketing == 1) { ?> +
+ > + +
+ + +
+ +window.location.href = \'dashboard_technical.php\';'); +} + +//Define var so it doesnt throw errors in logs +$largest_income_month = 0; + +//Get Total income +$sql_total_payments_to_invoices = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS total_payments_to_invoices FROM payments WHERE YEAR(payment_date) = $year"); +$row = mysqli_fetch_array($sql_total_payments_to_invoices); +$total_payments_to_invoices = floatval($row['total_payments_to_invoices']); +//Do not grab transfer payment as these have a category_id of 0 +$sql_total_revenues = mysqli_query($mysqli, "SELECT SUM(revenue_amount) AS total_revenues FROM revenues WHERE YEAR(revenue_date) = $year AND revenue_category_id > 0"); +$row = mysqli_fetch_array($sql_total_revenues); +$total_revenues = floatval($row['total_revenues']); + +$total_income = $total_payments_to_invoices + $total_revenues; + +//Get Total expenses and do not grab transfer expenses as these have a vendor of 0 +$sql_total_expenses = mysqli_query($mysqli, "SELECT SUM(expense_amount) AS total_expenses FROM expenses WHERE expense_vendor_id > 0 AND YEAR(expense_date) = $year"); +$row = mysqli_fetch_array($sql_total_expenses); +$total_expenses = floatval($row['total_expenses']); + +//Total up all the Invoices that are not draft or cancelled +$sql_invoice_totals = mysqli_query($mysqli, "SELECT SUM(invoice_amount) AS invoice_totals FROM invoices WHERE invoice_status NOT LIKE 'Draft' AND invoice_status NOT LIKE 'Cancelled' AND YEAR(invoice_date) = $year"); +$row = mysqli_fetch_array($sql_invoice_totals); +$invoice_totals = floatval($row['invoice_totals']); + +//Quaeries from Receivables +$sql_total_payments_to_invoices_all_years = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS total_payments_to_invoices_all_years FROM payments"); +$row = mysqli_fetch_array($sql_total_payments_to_invoices_all_years); +$total_payments_to_invoices_all_years = floatval($row['total_payments_to_invoices_all_years']); + +$sql_invoice_totals_all_years = mysqli_query($mysqli, "SELECT SUM(invoice_amount) AS invoice_totals_all_years FROM invoices WHERE invoice_status NOT LIKE 'Draft' AND invoice_status NOT LIKE 'Cancelled'"); +$row = mysqli_fetch_array($sql_invoice_totals_all_years); +$invoice_totals_all_years = floatval($row['invoice_totals_all_years']); + +$receivables = $invoice_totals_all_years - $total_payments_to_invoices_all_years; + +$profit = $total_income - $total_expenses; + +$sql_accounts = mysqli_query($mysqli, "SELECT * FROM accounts WHERE account_archived_at IS NULL ORDER BY account_name ASC"); + +$sql_latest_invoice_payments = mysqli_query( + $mysqli, + "SELECT * FROM payments, invoices, clients + WHERE payment_invoice_id = invoice_id + AND invoice_client_id = client_id + ORDER BY payment_id DESC LIMIT 5" +); + +$sql_latest_expenses = mysqli_query( + $mysqli, + "SELECT * FROM expenses, vendors, categories + WHERE expense_vendor_id = vendor_id + AND expense_category_id = category_id + ORDER BY expense_id DESC LIMIT 5" +); + +//Get Yearly Recurring Income Total +$sql_recurring_yearly_total = mysqli_query($mysqli, "SELECT SUM(recurring_amount) AS recurring_yearly_total FROM recurring WHERE recurring_status = 1 AND recurring_frequency = 'year' AND YEAR(recurring_created_at) <= $year"); +$row = mysqli_fetch_array($sql_recurring_yearly_total); +$recurring_yearly_total = floatval($row['recurring_yearly_total']); + +//Get Monthly Recurring Income Total +$sql_recurring_monthly_total = mysqli_query($mysqli, "SELECT SUM(recurring_amount) AS recurring_monthly_total FROM recurring WHERE recurring_status = 1 AND recurring_frequency = 'month' AND YEAR(recurring_created_at) <= $year"); +$row = mysqli_fetch_array($sql_recurring_monthly_total); +$recurring_monthly_total = floatval($row['recurring_monthly_total']) + ($recurring_yearly_total / 12); + +//Get Yearly Recurring Expenses Total +$sql_recurring_expense_yearly_total = mysqli_query($mysqli, "SELECT SUM(recurring_expense_amount) AS recurring_expense_yearly_total FROM recurring_expenses WHERE recurring_expense_status = 1 AND recurring_expense_frequency = 2 AND YEAR(recurring_expense_created_at) <= $year"); +$row = mysqli_fetch_array($sql_recurring_expense_yearly_total); +$recurring_expense_yearly_total = floatval($row['recurring_expense_yearly_total']); + +//Get Monthly Recurring Expenses Total +$sql_recurring_expense_monthly_total = mysqli_query($mysqli, "SELECT SUM(recurring_expense_amount) AS recurring_expense_monthly_total FROM recurring_expenses WHERE recurring_expense_status = 1 AND recurring_expense_frequency = 1 AND YEAR(recurring_expense_created_at) <= $year"); +$row = mysqli_fetch_array($sql_recurring_expense_monthly_total); +$recurring_expense_monthly_total = floatval($row['recurring_expense_monthly_total']) + ($recurring_expense_yearly_total / 12); + +//Get Total Miles Driven +$sql_miles_driven = mysqli_query($mysqli, "SELECT SUM(trip_miles) AS total_miles FROM trips WHERE YEAR(trip_date) = $year"); +$row = mysqli_fetch_array($sql_miles_driven); +$total_miles = floatval($row['total_miles']); + +//Get Total Recurring Invoices added +$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('recurring_id') AS recurring_invoices_added FROM recurring WHERE YEAR(recurring_created_at) = $year")); +$recurring_invoices_added = intval($row['recurring_invoices_added']); + +//Get Total Clients added +$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('client_id') AS clients_added FROM clients WHERE YEAR(client_created_at) = $year AND client_archived_at IS NULL")); +$clients_added = intval($row['clients_added']); + +//Get Total Vendors added +$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('vendor_id') AS vendors_added FROM vendors WHERE YEAR(vendor_created_at) = $year AND vendor_client_id = 0 AND vendor_template = 0 AND vendor_archived_at IS NULL")); +$vendors_added = intval($row['vendors_added']); + +?> + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+

Cash Flow

+
+ + + + +
+
+
+ +
+
+
+ +
+
+
+

Income by Category (Top 5)

+
+ +
+
+
+ +
+
+
+ +
+
+
+

Expenses by Category (Top 5)

+
+ +
+
+
+ +
+
+
+ +
+
+
+

Expenses by Vendor (Top 5)

+
+ +
+
+
+ +
+
+
+ +
+
+
+

Account Balances

+
+ +
+
+
+ + + + + + + + + + + +
+
+
+
+
+
+
+

Latest Income

+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + +
DateCustomerInvoiceAmount
+
+
+
+
+
+
+

Latest Expenses

+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + +
DateVendorCategoryAmount
+
+
+
+
+
+
+

Trip Flow

+
+ + + + +
+
+
+ +
+
+
+
+ + + + + + CURRENT_DATE + AND domain_expire < CURRENT_DATE + INTERVAL 30 DAY + AND domain_archived_at IS NULL" +)); +$expiring_domains = $sql_domains_expiring['expiring_domains']; + +// Expiring Certificates (but not ones that have already expired) +$sql_certs_expiring = mysqli_fetch_assoc(mysqli_query( + $mysqli, + "SELECT COUNT('certificate_id') as expiring_certs + FROM certificates + WHERE certificate_expire IS NOT NULL + AND certificate_expire > CURRENT_DATE + AND certificate_expire < CURRENT_DATE + INTERVAL 30 DAY + AND certificate_archived_at IS NULL" +)); +$expiring_certificates = $sql_certs_expiring['expiring_certs']; + +?> + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + diff --git a/dashboard_financial.php b/dashboard_financial.php deleted file mode 100644 index 2cd0c00f..00000000 --- a/dashboard_financial.php +++ /dev/null @@ -1,1128 +0,0 @@ -window.location.href = \'dashboard_technical.php\';'); -} - -if (isset($_GET['year'])) { - $year = intval($_GET['year']); -} else { - $year = date('Y'); -} - -//GET unique years from expenses, payments invoices and revenues -$sql_years_select = mysqli_query( - $mysqli, - "SELECT YEAR(expense_date) AS all_years FROM expenses - UNION DISTINCT SELECT YEAR(payment_date) FROM payments - UNION DISTINCT SELECT YEAR(revenue_date) FROM revenues - UNION DISTINCT SELECT YEAR(invoice_date) FROM invoices - ORDER BY all_years DESC -"); - -?> - -
- - - -
- > - -
- -
- > - -
- -
- - 0"); -$row = mysqli_fetch_array($sql_total_revenues); -$total_revenues = floatval($row['total_revenues']); - -$total_income = $total_payments_to_invoices + $total_revenues; - -//Get Total expenses and do not grab transfer expenses as these have a vendor of 0 -$sql_total_expenses = mysqli_query($mysqli, "SELECT SUM(expense_amount) AS total_expenses FROM expenses WHERE expense_vendor_id > 0 AND YEAR(expense_date) = $year"); -$row = mysqli_fetch_array($sql_total_expenses); -$total_expenses = floatval($row['total_expenses']); - -//Total up all the Invoices that are not draft or cancelled -$sql_invoice_totals = mysqli_query($mysqli, "SELECT SUM(invoice_amount) AS invoice_totals FROM invoices WHERE invoice_status NOT LIKE 'Draft' AND invoice_status NOT LIKE 'Cancelled' AND YEAR(invoice_date) = $year"); -$row = mysqli_fetch_array($sql_invoice_totals); -$invoice_totals = floatval($row['invoice_totals']); - -//Quaeries from Receivables -$sql_total_payments_to_invoices_all_years = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS total_payments_to_invoices_all_years FROM payments"); -$row = mysqli_fetch_array($sql_total_payments_to_invoices_all_years); -$total_payments_to_invoices_all_years = floatval($row['total_payments_to_invoices_all_years']); - -$sql_invoice_totals_all_years = mysqli_query($mysqli, "SELECT SUM(invoice_amount) AS invoice_totals_all_years FROM invoices WHERE invoice_status NOT LIKE 'Draft' AND invoice_status NOT LIKE 'Cancelled'"); -$row = mysqli_fetch_array($sql_invoice_totals_all_years); -$invoice_totals_all_years = floatval($row['invoice_totals_all_years']); - -$receivables = $invoice_totals_all_years - $total_payments_to_invoices_all_years; - -$profit = $total_income - $total_expenses; - -$sql_accounts = mysqli_query($mysqli, "SELECT * FROM accounts WHERE account_archived_at IS NULL ORDER BY account_name ASC"); - -$sql_latest_invoice_payments = mysqli_query( - $mysqli, - "SELECT * FROM payments, invoices, clients - WHERE payment_invoice_id = invoice_id - AND invoice_client_id = client_id - ORDER BY payment_id DESC LIMIT 5" -); - -$sql_latest_expenses = mysqli_query( - $mysqli, - "SELECT * FROM expenses, vendors, categories - WHERE expense_vendor_id = vendor_id - AND expense_category_id = category_id - ORDER BY expense_id DESC LIMIT 5" -); - -//Get Yearly Recurring Income Total -$sql_recurring_yearly_total = mysqli_query($mysqli, "SELECT SUM(recurring_amount) AS recurring_yearly_total FROM recurring WHERE recurring_status = 1 AND recurring_frequency = 'year' AND YEAR(recurring_created_at) <= $year"); -$row = mysqli_fetch_array($sql_recurring_yearly_total); -$recurring_yearly_total = floatval($row['recurring_yearly_total']); - -//Get Monthly Recurring Income Total -$sql_recurring_monthly_total = mysqli_query($mysqli, "SELECT SUM(recurring_amount) AS recurring_monthly_total FROM recurring WHERE recurring_status = 1 AND recurring_frequency = 'month' AND YEAR(recurring_created_at) <= $year"); -$row = mysqli_fetch_array($sql_recurring_monthly_total); -$recurring_monthly_total = floatval($row['recurring_monthly_total']) + ($recurring_yearly_total / 12); - -//Get Yearly Recurring Expenses Total -$sql_recurring_expense_yearly_total = mysqli_query($mysqli, "SELECT SUM(recurring_expense_amount) AS recurring_expense_yearly_total FROM recurring_expenses WHERE recurring_expense_status = 1 AND recurring_expense_frequency = 2 AND YEAR(recurring_expense_created_at) <= $year"); -$row = mysqli_fetch_array($sql_recurring_expense_yearly_total); -$recurring_expense_yearly_total = floatval($row['recurring_expense_yearly_total']); - -//Get Monthly Recurring Expenses Total -$sql_recurring_expense_monthly_total = mysqli_query($mysqli, "SELECT SUM(recurring_expense_amount) AS recurring_expense_monthly_total FROM recurring_expenses WHERE recurring_expense_status = 1 AND recurring_expense_frequency = 1 AND YEAR(recurring_expense_created_at) <= $year"); -$row = mysqli_fetch_array($sql_recurring_expense_monthly_total); -$recurring_expense_monthly_total = floatval($row['recurring_expense_monthly_total']) + ($recurring_expense_yearly_total / 12); - -//Get Total Miles Driven -$sql_miles_driven = mysqli_query($mysqli, "SELECT SUM(trip_miles) AS total_miles FROM trips WHERE YEAR(trip_date) = $year"); -$row = mysqli_fetch_array($sql_miles_driven); -$total_miles = floatval($row['total_miles']); - -//Get Total Recurring Invoices added -$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('recurring_id') AS recurring_invoices_added FROM recurring WHERE YEAR(recurring_created_at) = $year")); -$recurring_invoices_added = intval($row['recurring_invoices_added']); - -//Get Total Clients added -$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('client_id') AS clients_added FROM clients WHERE YEAR(client_created_at) = $year AND client_archived_at IS NULL")); -$clients_added = intval($row['clients_added']); - -//Get Total Vendors added -$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('vendor_id') AS vendors_added FROM vendors WHERE YEAR(vendor_created_at) = $year AND vendor_client_id = 0 AND vendor_template = 0 AND vendor_archived_at IS NULL")); -$vendors_added = intval($row['vendors_added']); - -?> - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-

Cash Flow

-
- - - - -
-
-
- -
-
-
- -
-
-
-

Income by Category (Top 5)

-
- -
-
-
- -
-
-
- -
-
-
-

Expenses by Category (Top 5)

-
- -
-
-
- -
-
-
- -
-
-
-

Expenses by Vendor (Top 5)

-
- -
-
-
- -
-
-
- -
-
-
-

Account Balances

-
- -
-
-
- - - - - - - - - - - -
-
-
-
-
-
-
-

Latest Income

-
- -
-
-
- - - - - - - - - - - - - - - - - - - -
DateCustomerInvoiceAmount
-
-
-
-
-
-
-

Latest Expenses

-
- -
-
-
- - - - - - - - - - - - - - - - - - - -
DateVendorCategoryAmount
-
-
-
-
-
-
-

Trip Flow

-
- - - - -
-
-
- -
-
-
-
- - - - - - CURRENT_DATE - AND domain_expire < CURRENT_DATE + INTERVAL 30 DAY - AND domain_archived_at IS NULL" -)); -$expiring_domains = $sql_domains_expiring['expiring_domains']; - -// Expiring Certificates (but not ones that have already expired) -$sql_certs_expiring = mysqli_fetch_assoc(mysqli_query( - $mysqli, - "SELECT COUNT('certificate_id') as expiring_certs - FROM certificates - WHERE certificate_expire IS NOT NULL - AND certificate_expire > CURRENT_DATE - AND certificate_expire < CURRENT_DATE + INTERVAL 30 DAY - AND certificate_archived_at IS NULL" -)); -$expiring_certificates = $sql_certs_expiring['expiring_certs']; - -?> - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - diff --git a/dashboard_nav.php b/dashboard_nav.php deleted file mode 100644 index 22a4b5a4..00000000 --- a/dashboard_nav.php +++ /dev/null @@ -1,11 +0,0 @@ -
- -
diff --git a/dashboard_technical.php b/dashboard_technical.php deleted file mode 100644 index 5213600c..00000000 --- a/dashboard_technical.php +++ /dev/null @@ -1,187 +0,0 @@ - CURRENT_DATE - AND domain_expire < CURRENT_DATE + INTERVAL 30 DAY - AND domain_archived_at IS NULL" -)); -$expiring_domains = $sql_domains_expiring['expiring_domains']; - -// Expiring Certificates (but not ones that have already expired) -$sql_certs_expiring = mysqli_fetch_assoc(mysqli_query( - $mysqli, - "SELECT COUNT('certificate_id') as expiring_certs - FROM certificates - WHERE certificate_expire IS NOT NULL - AND certificate_expire > CURRENT_DATE - AND certificate_expire < CURRENT_DATE + INTERVAL 30 DAY - AND certificate_archived_at IS NULL" -)); -$expiring_certificates = $sql_certs_expiring['expiring_certs']; - -?> - -
- -
- - -
- - - - - - - - - - - - - - - - - - - -
- -