From 4ec88257d7707c5a0aecba8f2da2c23d47df1d33 Mon Sep 17 00:00:00 2001 From: Marcus Hill Date: Sun, 1 Jan 2023 13:40:54 +0000 Subject: [PATCH] Add basic outline for technical dashboard --- dashboard_technical.php | 908 ++-------------------------------------- 1 file changed, 46 insertions(+), 862 deletions(-) diff --git a/dashboard_technical.php b/dashboard_technical.php index 94f81745..f1cc5e80 100644 --- a/dashboard_technical.php +++ b/dashboard_technical.php @@ -2,897 +2,81 @@ 0 AND company_id = $session_company_id"); -$row = mysqli_fetch_array($sql_total_revenues); -$total_revenues = $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 AND company_id = $session_company_id"); -$row = mysqli_fetch_array($sql_total_expenses); -$total_expenses = $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 AND company_id = $session_company_id"); -$row = mysqli_fetch_array($sql_invoice_totals); -$invoice_totals = $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 WHERE company_id = $session_company_id"); -$row = mysqli_fetch_array($sql_total_payments_to_invoices_all_years); -$total_payments_to_invoices_all_years = $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' AND company_id = $session_company_id"); -$row = mysqli_fetch_array($sql_invoice_totals_all_years); -$invoice_totals_all_years = $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 company_id = $session_company_id"); - -$sql_latest_invoice_payments = mysqli_query($mysqli,"SELECT * FROM payments, invoices, clients - WHERE payment_invoice_id = invoice_id - AND invoice_client_id = client_id - AND clients.company_id = $session_company_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 - AND expenses.company_id = $session_company_id - ORDER BY expense_id DESC LIMIT 5" -); +// Ticket count +$sql_tickets = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS active_tickets FROM tickets WHERE ticket_status != 'Closed'")); +$active_tickets = $sql_tickets['active_tickets']; //Get Monthly Recurring 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 company_id = $session_company_id"); $row = mysqli_fetch_array($sql_recurring_monthly_total); $recurring_monthly_total = $row['recurring_monthly_total']; -//Get Yearly Recurring 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 company_id = $session_company_id"); -$row = mysqli_fetch_array($sql_recurring_yearly_total); -$recurring_yearly_total = $row['recurring_yearly_total']; - -//Get Total Miles Driven -$sql_miles_driven = mysqli_query($mysqli,"SELECT SUM(trip_miles) AS total_miles FROM trips WHERE YEAR(trip_date) = $year AND company_id = $session_company_id"); -$row = mysqli_fetch_array($sql_miles_driven); -$total_miles = $row['total_miles']; - -//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 company_id = $session_company_id")); -$clients_added = $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 company_id = $session_company_id")); -$vendors_added = $row['vendors_added']; ?>
- +
- - - - - -
- -
-
-

-

Profit

-
-
- -
+ -
- + -
- -
-
-

-

Monthly Recurring

-
-
- -
+ -
- + -
- -
-
-

-

Yearly Recurring

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

Cash Flow

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

Trip Flow

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

Income By Category

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

Expenses By Category

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

Expenses By Vendor

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

Account Balance

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

Latest Income

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

Latest Expenses

-
- -
-
-
- - - - - - - - - - - - - - - - - - - -
DateVendorCategoryAmount
-
-
-
- - \ No newline at end of file + \ No newline at end of file