From 95b9e2fe235a22b7a4dcd1cde1506b665ccaf3e2 Mon Sep 17 00:00:00 2001 From: Marcus Hill Date: Mon, 23 Jan 2023 20:55:25 +0000 Subject: [PATCH 1/7] General cleanups, add HTML lang element to match header.php --- login.php | 10 +++++----- portal/login.php | 19 ++++++++----------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/login.php b/login.php index 10a4626f..c24cfdf2 100644 --- a/login.php +++ b/login.php @@ -10,12 +10,12 @@ require_once("functions.php"); require_once("rfc6238.php"); // IP & User Agent for logging -$ip = strip_tags(mysqli_real_escape_string($mysqli,get_ip())); -$user_agent = strip_tags(mysqli_real_escape_string($mysqli,$_SERVER['HTTP_USER_AGENT'])); +$ip = strip_tags(mysqli_real_escape_string($mysqli, get_ip())); +$user_agent = strip_tags(mysqli_real_escape_string($mysqli, $_SERVER['HTTP_USER_AGENT'])); // Block brute force password attacks - check recent failed login attempts for this IP // Block access if more than 15 failed login attempts have happened in the last 10 minutes -$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT(log_id) AS failed_login_count FROM logs WHERE log_ip = '$ip' AND log_type = 'Login' AND log_action = 'Failed' AND log_created_at > (NOW() - INTERVAL 10 MINUTE)")); +$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT(log_id) AS failed_login_count FROM logs WHERE log_ip = '$ip' AND log_type = 'Login' AND log_action = 'Failed' AND log_created_at > (NOW() - INTERVAL 10 MINUTE)")); $failed_login_count = $row['failed_login_count']; if ($failed_login_count >= 15) { @@ -28,7 +28,7 @@ if ($failed_login_count >= 15) { } // Query Settings for "default" company (as companies are being removed shortly) -$sql_settings = mysqli_query($mysqli,"SELECT * FROM settings WHERE company_id = 1"); +$sql_settings = mysqli_query($mysqli, "SELECT * FROM settings WHERE company_id = 1"); $row = mysqli_fetch_array($sql_settings); // Mail @@ -200,7 +200,7 @@ if (isset($_POST['login'])) { ?> - + diff --git a/portal/login.php b/portal/login.php index ebd664e5..17eb9c80 100644 --- a/portal/login.php +++ b/portal/login.php @@ -11,15 +11,15 @@ require_once ('../get_settings.php'); if (!isset($_SESSION)) { // HTTP Only cookies - ini_set("session.cookie_httponly", True); + ini_set("session.cookie_httponly", true); if ($config_https_only) { // Tell client to only send cookie(s) over HTTPS - ini_set("session.cookie_secure", True); + ini_set("session.cookie_secure", true); } session_start(); } -$ip = strip_tags(mysqli_real_escape_string($mysqli,get_ip())); +$ip = strip_tags(mysqli_real_escape_string($mysqli, get_ip())); $user_agent = strip_tags(mysqli_real_escape_string($mysqli, $_SERVER['HTTP_USER_AGENT'])); $sql_settings = mysqli_query($mysqli, "SELECT config_azure_client_id FROM settings WHERE company_id = '1'"); @@ -37,8 +37,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['login'])) { if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $_SESSION['login_message'] = 'Invalid e-mail'; - } - else { + } else { $sql = mysqli_query($mysqli, "SELECT * FROM contacts WHERE contact_email = '$email' LIMIT 1"); $row = mysqli_fetch_array($sql); if ($row['contact_auth_method'] == 'local') { @@ -54,14 +53,12 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['login'])) { mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Client Login', log_action = 'Success', log_description = 'Client contact $row[contact_email] successfully logged in locally', log_ip = '$ip', log_user_agent = '$user_agent', log_created_at = NOW(), log_client_id = $row[contact_client_id]"); - } - else { + } else { mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Client Login', log_action = 'Failed', log_description = 'Failed client portal login attempt using $email', log_ip = '$ip', log_user_agent = '$user_agent', log_created_at = NOW()"); $_SESSION['login_message'] = 'Incorrect username or password.'; } - } - else { + } else { mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Client Login', log_action = 'Failed', log_description = 'Failed client portal login attempt using $email', log_ip = '$ip', log_user_agent = '$user_agent', log_created_at = NOW()"); $_SESSION['login_message'] = 'Incorrect username or password.'; } @@ -70,7 +67,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['login'])) { ?> - + @@ -164,4 +161,4 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['login'])) { - \ No newline at end of file + From 49da4d7fd4f62c915f18e323769d37f5aaf235e2 Mon Sep 17 00:00:00 2001 From: Marcus Hill Date: Mon, 23 Jan 2023 20:56:08 +0000 Subject: [PATCH 2/7] Add HTML lang element to match main header.php --- portal/portal_header.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/portal/portal_header.php b/portal/portal_header.php index ee4afa20..cc89995c 100644 --- a/portal/portal_header.php +++ b/portal/portal_header.php @@ -6,7 +6,7 @@ ?> - + @@ -65,4 +65,4 @@
-
\ No newline at end of file +
From ad2390d0ea76a5c8102e9242bc7ab47d091f7674 Mon Sep 17 00:00:00 2001 From: Marcus Hill Date: Mon, 23 Jan 2023 21:09:44 +0000 Subject: [PATCH 3/7] General tidy/spacing cleanups --- accounts.php | 174 ++-- categories.php | 172 ++-- client_files.php | 38 +- client_overview.php | 526 ++++++------ dashboard_financial.php | 78 +- guest_view_invoice.php | 1794 +++++++++++++++++++-------------------- invoice.php | 1784 +++++++++++++++++++------------------- portal/check_login.php | 12 +- recurring_invoice.php | 694 ++++++++------- settings_update.php | 137 ++- ticket.php | 42 +- user_profile.php | 400 +++++---- 12 files changed, 2917 insertions(+), 2934 deletions(-) diff --git a/accounts.php b/accounts.php index 2a0f2019..d76a2e3d 100644 --- a/accounts.php +++ b/accounts.php @@ -1,110 +1,110 @@ $sb, 'o' => $o))); -$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM accounts +$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS * FROM accounts WHERE account_name LIKE '%$q%' AND company_id = $session_company_id ORDER BY $sb $o LIMIT $record_from, $record_to"); -$num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); +$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); ?> -
-
-

Accounts

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

Accounts

+
+ +
-
- -
-
- - "> - - - - - - - - - - - - - - - - + +
+
+
NameCurrencyBalanceAction
-
+ "> + + + + + + + + + + while ($row = mysqli_fetch_array($sql)) { + $account_id = $row['account_id']; + $account_name = htmlentities($row['account_name']); + $opening_balance = $row['opening_balance']; + $account_currency_code = htmlentities($row['account_currency_code']); + $account_notes = htmlentities($row['account_notes']); - -
NameCurrencyBalanceAction
+ $sql_payments = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS total_payments FROM payments WHERE payment_account_id = $account_id"); + $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 revenue_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 expense_account_id = $account_id"); + $row = mysqli_fetch_array($sql_expenses); + $total_expenses = $row['total_expenses']; + + $balance = $opening_balance + $total_payments + $total_revenues - $total_expenses; + ?> + + + + + + + + + + + + + + +
+ +
- -
-
\ No newline at end of file +include("footer.php"); + +?> diff --git a/categories.php b/categories.php index 32236166..2c23fcb8 100644 --- a/categories.php +++ b/categories.php @@ -1,21 +1,21 @@ - $sb, 'o' => $o))); -$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM categories +$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM categories WHERE category_name LIKE '%$q%' AND category_type = '$category' AND category_archived_at IS NULL @@ -33,100 +33,100 @@ $sql_colors_used = mysqli_query($mysqli,"SELECT category_color FROM categories ); while ($color_used_row = mysqli_fetch_array($sql_colors_used)) { - $colors_used_array[] = $color_used_row['category_color']; + $colors_used_array[] = $color_used_row['category_color']; } -$colors_diff = array_diff($colors_array,$colors_used_array); +$colors_diff = array_diff($colors_array, $colors_used_array); ?> -
-
-

Categories

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

Categories

+
+
-
- -
- -
-
- - "> - - - - - - - - - - - - - + +
+
+
NameColorAction
-
+ "> + + + + + + + + + + + + + - include("category_edit_modal.php"); + + include("category_edit_modal.php"); - -
NameColorAction
+ +
+ } + + ?> + + + +
+ +
- -
-
- \ No newline at end of file +?> diff --git a/client_files.php b/client_files.php index bfd5be29..e74d6ccf 100644 --- a/client_files.php +++ b/client_files.php @@ -1,10 +1,8 @@ - +

No Records Here

"; } ?>
- + -
+
- - "> + + "> -
+
- -
- + - + - + @@ -111,4 +109,4 @@ include("client_file_add_modal.php"); include("share_modal.php"); ?> - \ No newline at end of file + diff --git a/client_overview.php b/client_overview.php index 350f62ec..a73b4ee3 100644 --- a/client_overview.php +++ b/client_overview.php @@ -1,23 +1,21 @@ - + - + -
+
+ +
+
+
Quick Notes
+
+
+ +
+
-
-
-
Quick Notes
-
-
- -
-
+ 0) { ?> - 0 ) { ?> - -
+
-
-
-
Important Contacts
-
-
-
- +
+
Important Contacts
+
+
+
+ - - - - - + ?> + + + + + -
- -
- -
- - $contact_phone $contact_extension"; ?> - - -
-
- -
+ +
+ +
+ + $contact_phone $contact_extension"; ?> + + +
+
+ +
-
+ +
+
+ + + + + 0 || mysqli_num_rows($sql_vendors) > 0) { ?> +
+ +
+
+
Recently Updated
+
+
+ + +

+ + +

+ + + +

+ + +

+ + +
+
+
+ + + 0 || mysqli_num_rows($sql_vendors) > 0) { ?> + +
+ +
+
+
Recently Viewed
+
+
+ + +

+ + +

+ + + +

+ + +

+ + +
+
+
+ + + +
+ +
+
+
Upcoming Expirations
+
+
+ + +

+ + + -- +

+ + + +

+ + + -- +

+ + + + + +

+ + + -- +

+ + + +
+
- - + 0) { ?> - 0 || mysqli_num_rows($sql_vendors) > 0 ) { ?> -
+ -
-
-
Recently Updated
-
-
- - - while ($row = mysqli_fetch_array($sql_contacts)) { - $contact_id = $row['contact_id']; - $contact_name = htmlentities($row['contact_name']); - $contact_updated_at = $row['contact_updated_at']; +
+
+
Stale Tickets (14d)
+ + + -

- - -

- + while ($row = mysqli_fetch_array($sql_tickets_stale)) { + $ticket_id = $row['ticket_id']; + $ticket_prefix = htmlentities($row['ticket_prefix']); + $ticket_number = $row['ticket_number']; + $ticket_subject = htmlentities($row['ticket_subject']); + $ticket_created_at = $row['ticket_created_at']; - + + + + + - while ($row = mysqli_fetch_array($sql_vendors)) { - $vendor_id = $row['vendor_id']; - $vendor_name = htmlentities($row['vendor_name']); - $vendor_updated_at = $row['vendor_updated_at']; + - ?> -

- - -

- + +
+
+
+
-
-
- - - - 0 || mysqli_num_rows($sql_vendors) > 0 ) { ?> - -
- -
-
-
Recently Viewed
-
-
- - -

- - -

- - - -

- - -

- - -
-
-
- - - -
- -
-
-
Upcoming Expirations
-
-
- - -

- - - -- -

- - - -

- - - -- -

- - - - - -

- - - -- -

- - - -
-
-
- - 0) { ?> - - - -
- -
-
-
Stale Tickets (14d)
- - - - - - - - - - - - -
-
-
-
- - + \ No newline at end of file +?> diff --git a/dashboard_financial.php b/dashboard_financial.php index 258b655b..0273438d 100644 --- a/dashboard_financial.php +++ b/dashboard_financial.php @@ -1,6 +1,4 @@ - - - 0 AND company_id = $session_company_id"); +$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 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"); +$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"); +$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"); +$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"); +$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']; @@ -69,16 +67,16 @@ $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_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 +$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 +$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 @@ -86,26 +84,26 @@ $sql_latest_expenses = mysqli_query($mysqli,"SELECT * FROM expenses, vendors, ca ); //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"); +$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"); +$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"); +$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")); +$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 vendor_template = 0 AND company_id = $session_company_id")); +$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 company_id = $session_company_id")); $vendors_added = $row['vendors_added']; ?> @@ -335,15 +333,15 @@ $vendors_added = $row['vendors_added']; 0 AND YEAR(revenue_date) = $year AND MONTH(revenue_date) = $month AND company_id = $session_company_id"); + $sql_revenues = mysqli_query($mysqli, "SELECT SUM(revenue_amount) AS revenue_amount_for_month FROM revenues WHERE revenue_category_id > 0 AND YEAR(revenue_date) = $year AND MONTH(revenue_date) = $month AND company_id = $session_company_id"); $row = mysqli_fetch_array($sql_revenues); $revenues_for_month = $row['revenue_amount_for_month']; @@ -534,11 +532,11 @@ var myLineChart = new Chart(ctx, { data: [ 0 AND YEAR(revenue_date) = $year-1 AND MONTH(revenue_date) = $month AND company_id = $session_company_id"); + $sql_revenues = mysqli_query($mysqli, "SELECT SUM(revenue_amount) AS revenue_amount_for_month FROM revenues WHERE revenue_category_id > 0 AND YEAR(revenue_date) = $year-1 AND MONTH(revenue_date) = $month AND company_id = $session_company_id"); $row = mysqli_fetch_array($sql_revenues); $revenues_for_month = $row['revenue_amount_for_month']; @@ -576,7 +574,7 @@ var myLineChart = new Chart(ctx, { $largest_invoice_month = 0; for($month = 1; $month<=12; $month++) { - $sql_projected = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS invoice_amount_for_month FROM invoices WHERE YEAR(invoice_due) = $year AND MONTH(invoice_due) = $month AND invoice_status NOT LIKE 'Cancelled' AND invoice_status NOT LIKE 'Draft' AND company_id = $session_company_id"); + $sql_projected = mysqli_query($mysqli, "SELECT SUM(invoice_amount) AS invoice_amount_for_month FROM invoices WHERE YEAR(invoice_due) = $year AND MONTH(invoice_due) = $month AND invoice_status NOT LIKE 'Cancelled' AND invoice_status NOT LIKE 'Draft' AND company_id = $session_company_id"); $row = mysqli_fetch_array($sql_projected); $invoice_for_month = $row['invoice_amount_for_month']; @@ -612,7 +610,7 @@ var myLineChart = new Chart(ctx, { $largest_expense_month = 0; for($month = 1; $month<=12; $month++) { - $sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS expense_amount_for_month FROM expenses WHERE YEAR(expense_date) = $year AND MONTH(expense_date) = $month AND expense_vendor_id > 0 AND expenses.company_id = $session_company_id"); + $sql_expenses = mysqli_query($mysqli, "SELECT SUM(expense_amount) AS expense_amount_for_month FROM expenses WHERE YEAR(expense_date) = $year AND MONTH(expense_date) = $month AND expense_vendor_id > 0 AND expenses.company_id = $session_company_id"); $row = mysqli_fetch_array($sql_expenses); $expenses_for_month = $row['expense_amount_for_month']; @@ -688,7 +686,7 @@ var myLineChart = new Chart(ctx, { data: [ 0 AND YEAR(expense_date) = $year AND categories.company_id = $session_company_id"); + $sql_categories = mysqli_query($mysqli, "SELECT DISTINCT category_name, categories.category_id FROM categories, expenses WHERE expense_category_id = category_id AND expense_vendor_id > 0 AND YEAR(expense_date) = $year AND categories.company_id = $session_company_id"); while ($row = mysqli_fetch_array($sql_categories)) { $category_name = json_encode($row['category_name']); echo "$category_name,"; @@ -820,11 +818,11 @@ var myPieChart = new Chart(ctx, { datasets: [{ data: [ 0 AND YEAR(expense_date) = $year AND categories.company_id = $session_company_id"); + $sql_categories = mysqli_query($mysqli, "SELECT DISTINCT category_name, categories.category_id FROM categories, expenses WHERE expense_category_id = category_id AND expense_vendor_id > 0 AND YEAR(expense_date) = $year AND categories.company_id = $session_company_id"); while ($row = mysqli_fetch_array($sql_categories)) { $category_id = $row['category_id']; - $sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS expense_amount_for_year FROM expenses WHERE expense_category_id = $category_id AND YEAR(expense_date) = $year"); + $sql_expenses = mysqli_query($mysqli, "SELECT SUM(expense_amount) AS expense_amount_for_year FROM expenses WHERE expense_category_id = $category_id AND YEAR(expense_date) = $year"); $row = mysqli_fetch_array($sql_expenses); $expense_amount_for_year = $row['expense_amount_for_year']; echo "$expense_amount_for_year,"; @@ -835,7 +833,7 @@ var myPieChart = new Chart(ctx, { ], backgroundColor: [ 0 AND YEAR(expense_date) = $year AND categories.company_id = $session_company_id"); + $sql_categories = mysqli_query($mysqli, "SELECT DISTINCT category_name, category_color FROM categories, expenses WHERE expense_category_id = categories.category_id AND expense_vendor_id > 0 AND YEAR(expense_date) = $year AND categories.company_id = $session_company_id"); while ($row = mysqli_fetch_array($sql_categories)) { $category_color = json_encode($row['category_color']); echo "$category_color,"; @@ -861,7 +859,7 @@ var myPieChart = new Chart(ctx, { data: { labels: [ - - + //check to see if overdue + if ($invoice_status !== "Paid" && $invoice_status !== "Draft" && $invoice_status !== "Cancelled") { + $unixtime_invoice_due = strtotime($invoice_due) + 86400; + if ($unixtime_invoice_due < time()) { + $invoice_color = "text-danger"; + } + } -
- -
-
-
- "> -
-
- -
-
- + + - -

Invoice

-
-
-
-
-
    -
  • -
  • -
  • -
  • -
  • -
- -
-
- -
    -
  • -
  • -
  • -
  • -
  • -
  • -
- -
-
-
-
-
-
- - - - - - - - - -
Date
Due
-
-
- - - -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - -
ProductDescriptionQtyPriceTaxTotal
-
-
-
-
- -
-
- -
-
+
+
+ "> +
+
+ +
+
+ +
+
+ +

Invoice

+
+
+
+
+
    +
  • +
  • +
  • +
  • +
  • +
+ +
+
+ +
    +
  • +
  • +
  • +
  • +
  • +
  • +
+ +
+
+
+
+
+
+ + + + + + + + + +
Date
Due
+
+
+ + + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
ProductDescriptionQtyPriceTaxTotal
+
+
+
+
+ +
+
+ +
+
+
+
+
+ +
+
+ + + + + + + 0) { ?> + + + + + + 0) { ?> + + + + + + + + + + +
Subtotal
Tax
Paid
Balance
+
+
+ +
+ +
-
-
-
- - - - - - - 0) { ?> - - - - - - 0) { ?> - - - - - - - - - - -
Subtotal
Tax
Paid
Balance
-
-
-
+ + + - - + // Item + [ + [ + { + text: , + style:'itemTitle' + }, + { + text: , + style:'itemDescription' + } + ], + { + text: , + style: 'itemQty' + }, + { + text: , + style: 'itemNumber' + }, + { + text: , + style: 'itemNumber' + }, + { + text: , + style: 'itemNumber' + } + ], - + // END Items + ] + }, // table + layout: 'lightHorizontalLines' + }, + // TOTAL + { + table: { + // headers are automatically repeated if the table spans over multiple pages + // you can declare how many rows should be treated as headers + headerRows: 0, + widths: [ '*','auto', 80 ], - $sql = mysqli_query($mysqli,"SELECT * FROM invoices WHERE invoice_client_id = $client_id AND invoice_due < CURDATE() AND(invoice_status = 'Sent' OR invoice_status = 'Viewed' OR invoice_status = 'Partial') ORDER BY invoice_date DESC"); + body: [ + // Total + [ + { + text: 'Notes', + style: 'notesTitle' + }, + {}, + {} + ], + [ + { + rowSpan: 5, + text: , + style: 'notesText' + }, + { + text: 'Subtotal', + style: 'itemsFooterSubTitle' + }, + { + text: , + style: 'itemsFooterSubValue' + } + ], + [ + {}, + { + text: 'Tax', + style: 'itemsFooterSubTitle' + }, + { + text: , + style: 'itemsFooterSubValue' + } + ], + [ + {}, + { + text: 'Total', + style: 'itemsFooterSubTitle' + }, + { + text: , + style: 'itemsFooterSubValue' + } + ], + [ + {}, + { + text: 'Paid', + style: 'itemsFooterSubTitle' + }, + { + text: , + style: 'itemsFooterSubValue' + } + ], + [ + {}, + { + text: 'Balance', + style: 'itemsFooterTotalTitle' + }, + { + text: , - if (mysqli_num_rows($sql) > 1) { - - ?> - - -
-
- Previous Unpaid Invoices -
-
- - - - - - - - - - - - - > - - - - - - - - - -
Invoice #DateDue DateAmount
( Days Late)
-
-
- - - CURDATE() AND(invoice_status = 'Sent' OR invoice_status = 'Viewed' OR invoice_status = 'Partial') ORDER BY invoice_number DESC"); - - if (mysqli_num_rows($sql) > 1) { - - ?> - - -
-
- Current Invoices -
-
- - - - - - - - - - - - - > - - - - - - - - - -
Invoice #DateDueAmount
(Due in Days)
-
-
- - - - 1) { - - ?> - - -
-
- Previous Invoices Paid -
-
- - - - - - - - - - - - - > - - - - - - - - - - - strtotime($invoice_due)) { - $payment_note = "Late"; - $difference = strtotime($payment_date) - strtotime($invoice_due); - $days = floor($difference / (60*60*24) ) . " Days"; - }else{ - $payment_note = ""; - $days = ""; + style: 'itemsFooterTotalTitle' + } + ], + ] + }, // table + layout: 'lightHorizontalLines' + }, + // TERMS / FOOTER + { + text: , + style: 'documentFooterCenter' + } + ], //End Content, + styles: { + // Document Footer + documentFooterCenter: { + fontSize: 9, + margin: [10,50,10,10], + alignment: 'center' + }, + // Invoice Title + invoiceTitle: { + fontSize: 18, + bold: true, + alignment: 'right', + margin: [0,0,0,3] + }, + // Invoice Number + invoiceNumber: { + fontSize: 14, + alignment: 'right' + }, + // Billing Headers + invoiceBillingTitle: { + fontSize: 14, + bold: true, + alignment: 'left', + margin: [0,20,0,5] + }, + invoiceBillingTitleClient: { + fontSize: 14, + bold: true, + alignment: 'right', + margin: [0,20,0,5] + }, + // Billing Details + invoiceBillingAddress: { + fontSize: 10, + lineHeight: 1.2 + }, + invoiceBillingAddressClient: { + fontSize: 10, + lineHeight: 1.2, + alignment: 'right', + margin: [0,0,0,30] + }, + // Invoice Dates + invoiceDateTitle: { + fontSize: 10, + alignment: 'left', + margin: [0,5,0,5] + }, + invoiceDateValue: { + fontSize: 10, + alignment: 'right', + margin: [0,5,0,5] + }, + // Items Header + itemsHeader: { + fontSize: 10, + margin: [0,5,0,5], + bold: true, + alignment: 'right' + }, + // Item Title + itemTitle: { + fontSize: 10, + bold: true, + margin: [0,5,0,3] + }, + itemDescription: { + italics: true, + fontSize: 9, + lineHeight: 1.1, + margin: [0,3,0,5] + }, + itemQty: { + fontSize: 10, + margin: [0,5,0,5], + alignment: 'center' + }, + itemNumber: { + fontSize: 10, + margin: [0,5,0,5], + alignment: 'right' + }, + itemTotal: { + fontSize: 10, + margin: [0,5,0,5], + bold: true, + alignment: 'right' + }, + // Items Footer (Subtotal, Total, Tax, etc) + itemsFooterSubTitle: { + fontSize: 10, + margin: [0,5,0,5], + alignment: 'right' + }, + itemsFooterSubValue: { + fontSize: 10, + margin: [0,5,0,5], + bold: false, + alignment: 'right' + }, + itemsFooterTotalTitle: { + fontSize: 10, + margin: [0,5,0,5], + bold: true, + alignment: 'right' + }, + itemsFooterTotalValue: { + fontSize: 10, + margin: [0,5,0,5], + bold: true, + alignment: 'right' + }, + notesTitle: { + fontSize: 10, + bold: true, + margin: [0,5,0,5] + }, + notesText: { + fontSize: 9, + margin: [0,5,50,5] + }, + left: { + alignment: 'left' + }, + center: { + alignment: 'center' + }, + }, + defaultStyle: { + columnGap: 20 } - + } + - $invoice_tally_total = $invoice_amount + $invoice_tally_total; + + $sql = mysqli_query($mysqli, "SELECT * FROM invoices WHERE invoice_client_id = $client_id AND invoice_due < CURDATE() AND(invoice_status = 'Sent' OR invoice_status = 'Viewed' OR invoice_status = 'Partial') ORDER BY invoice_date DESC"); - - - - 1) { - } - - ?> - - - -
Invoice #DateDue DateAmount
Payments
- - - -
-
-
- +
+
+ Previous Unpaid Invoices +
+
+ + + + + + + + + + + + + > + + + + + + + + + +
Invoice #DateDue DateAmount
( Days Late)
+
+
+ + + CURDATE() AND(invoice_status = 'Sent' OR invoice_status = 'Viewed' OR invoice_status = 'Partial') ORDER BY invoice_number DESC"); + + if (mysqli_num_rows($sql) > 1) { + + ?> + + +
+
+ Current Invoices +
+
+ + + + + + + + + + + + + > + + + + + + + + + +
Invoice #DateDueAmount
(Due in Days)
+
+
+ + + + 1) { + + ?> + + +
+
+ Previous Invoices Paid +
+
+ + + + + + + + + + + + + > + + + + + + + + + + + strtotime($invoice_due)) { + $payment_note = "Late"; + $difference = strtotime($payment_date) - strtotime($invoice_due); + $days = floor($difference / (60*60*24) ) . " Days"; + }else{ + $payment_note = ""; + $days = ""; + } + + + $invoice_tally_total = $invoice_amount + $invoice_tally_total; + + ?> + + + + + + + + + +
Invoice #DateDue DateAmount
Payments
- - - -
+
+
+ + + + diff --git a/invoice.php b/invoice.php index 9fdee922..5ad0aea5 100644 --- a/invoice.php +++ b/invoice.php @@ -1,499 +1,499 @@ -

Nothing to see here

"; - }else{ + if (mysqli_num_rows($sql) == 0) { + echo "

Nothing to see here

"; + } else { - $row = mysqli_fetch_array($sql); - $invoice_id = $row['invoice_id']; - $invoice_prefix = htmlentities($row['invoice_prefix']); - $invoice_number = htmlentities($row['invoice_number']); - $invoice_scope = htmlentities($row['invoice_scope']); - $invoice_status = htmlentities($row['invoice_status']); - $invoice_date = $row['invoice_date']; - $invoice_due = $row['invoice_due']; - $invoice_amount = floatval($row['invoice_amount']); - $invoice_currency_code = htmlentities($row['invoice_currency_code']); - $invoice_note = htmlentities($row['invoice_note']); - $invoice_url_key = htmlentities($row['invoice_url_key']); - $invoice_created_at = $row['invoice_created_at']; - $category_id = $row['invoice_category_id']; - $client_id = $row['client_id']; - $client_name = htmlentities($row['client_name']); - $location_address = htmlentities($row['location_address']); - $location_city = htmlentities($row['location_city']); - $location_state = htmlentities($row['location_state']); - $location_zip = htmlentities($row['location_zip']); - $contact_email = htmlentities($row['contact_email']); - $contact_phone = formatPhoneNumber($row['contact_phone']); - $contact_extension = htmlentities($row['contact_extension']); - $contact_mobile = formatPhoneNumber($row['contact_mobile']); - $client_website = htmlentities($row['client_website']); - $client_currency_code = htmlentities($row['client_currency_code']); - $client_net_terms = htmlentities($row['client_net_terms']); - if ($client_net_terms == 0) { - $client_net_terms = $config_default_net_terms; - } - $company_id = $row['company_id']; - $company_name = htmlentities($row['company_name']); - $company_country = htmlentities($row['company_country']); - $company_address = htmlentities($row['company_address']); - $company_city = htmlentities($row['company_city']); - $company_state = htmlentities($row['company_state']); - $company_zip = htmlentities($row['company_zip']); - $company_phone = formatPhoneNumber($row['company_phone']); - $company_email = htmlentities($row['company_email']); - $company_website = htmlentities($row['company_website']); - $company_logo = htmlentities($row['company_logo']); - if (!empty($company_logo)) { - $company_logo_base64 = base64_encode(file_get_contents("uploads/settings/$company_id/$company_logo")); - } - $sql_history = mysqli_query($mysqli,"SELECT * FROM history WHERE history_invoice_id = $invoice_id ORDER BY history_id DESC"); - - $sql_payments = mysqli_query($mysqli,"SELECT * FROM payments, accounts WHERE payment_account_id = account_id AND payment_invoice_id = $invoice_id ORDER BY payments.payment_id DESC"); + $row = mysqli_fetch_array($sql); + $invoice_id = $row['invoice_id']; + $invoice_prefix = htmlentities($row['invoice_prefix']); + $invoice_number = htmlentities($row['invoice_number']); + $invoice_scope = htmlentities($row['invoice_scope']); + $invoice_status = htmlentities($row['invoice_status']); + $invoice_date = $row['invoice_date']; + $invoice_due = $row['invoice_due']; + $invoice_amount = floatval($row['invoice_amount']); + $invoice_currency_code = htmlentities($row['invoice_currency_code']); + $invoice_note = htmlentities($row['invoice_note']); + $invoice_url_key = htmlentities($row['invoice_url_key']); + $invoice_created_at = $row['invoice_created_at']; + $category_id = $row['invoice_category_id']; + $client_id = $row['client_id']; + $client_name = htmlentities($row['client_name']); + $location_address = htmlentities($row['location_address']); + $location_city = htmlentities($row['location_city']); + $location_state = htmlentities($row['location_state']); + $location_zip = htmlentities($row['location_zip']); + $contact_email = htmlentities($row['contact_email']); + $contact_phone = formatPhoneNumber($row['contact_phone']); + $contact_extension = htmlentities($row['contact_extension']); + $contact_mobile = formatPhoneNumber($row['contact_mobile']); + $client_website = htmlentities($row['client_website']); + $client_currency_code = htmlentities($row['client_currency_code']); + $client_net_terms = htmlentities($row['client_net_terms']); + if ($client_net_terms == 0) { + $client_net_terms = $config_default_net_terms; + } + $company_id = $row['company_id']; + $company_name = htmlentities($row['company_name']); + $company_country = htmlentities($row['company_country']); + $company_address = htmlentities($row['company_address']); + $company_city = htmlentities($row['company_city']); + $company_state = htmlentities($row['company_state']); + $company_zip = htmlentities($row['company_zip']); + $company_phone = formatPhoneNumber($row['company_phone']); + $company_email = htmlentities($row['company_email']); + $company_website = htmlentities($row['company_website']); + $company_logo = htmlentities($row['company_logo']); + if (!empty($company_logo)) { + $company_logo_base64 = base64_encode(file_get_contents("uploads/settings/$company_id/$company_logo")); + } + $sql_history = mysqli_query($mysqli, "SELECT * FROM history WHERE history_invoice_id = $invoice_id ORDER BY history_id DESC"); - //Add up all the payments for the invoice and get the total amount paid to the invoice - $sql_amount_paid = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS amount_paid FROM payments WHERE payment_invoice_id = $invoice_id"); - $row = mysqli_fetch_array($sql_amount_paid); - $amount_paid = $row['amount_paid']; + $sql_payments = mysqli_query($mysqli, "SELECT * FROM payments, accounts WHERE payment_account_id = account_id AND payment_invoice_id = $invoice_id ORDER BY payments.payment_id DESC"); - $balance = $invoice_amount - $amount_paid; + //Add up all the payments for the invoice and get the total amount paid to the invoice + $sql_amount_paid = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS amount_paid FROM payments WHERE payment_invoice_id = $invoice_id"); + $row = mysqli_fetch_array($sql_amount_paid); + $amount_paid = $row['amount_paid']; - //check to see if overdue - if ($invoice_status !== "Paid" && $invoice_status !== "Draft" && $invoice_status !== "Cancelled") { - $unixtime_invoice_due = strtotime($invoice_due) + 86400; - if ($unixtime_invoice_due < time()) { - $invoice_overdue = "Overdue"; - } - } - - //Set Badge color based off of invoice status - if ($invoice_status == "Sent") { - $invoice_badge_color = "warning text-white"; - }elseif ($invoice_status == "Viewed") { - $invoice_badge_color = "info"; - }elseif ($invoice_status == "Partial") { - $invoice_badge_color = "primary"; - }elseif ($invoice_status == "Paid") { - $invoice_badge_color = "success"; - }elseif ($invoice_status == "Cancelled") { - $invoice_badge_color = "danger"; - }else{ - $invoice_badge_color = "secondary"; - } + $balance = $invoice_amount - $amount_paid; - //Product autocomplete - $products_sql = mysqli_query($mysqli,"SELECT product_name AS label, product_description AS description, product_price AS price FROM products WHERE company_id = $session_company_id"); - - if (mysqli_num_rows($products_sql) > 0) { - while ($row = mysqli_fetch_array($products_sql)) { - $products[] = $row; - } - $json_products = json_encode($products); - } - -?> - - - -
- -
- -
- -
- - - - - - - Add Payment - -
- -
- - - -
- -
- -
- -
- -
-
- "> -
-
-
-
- -
-
-

Invoice

-
- -
-
-
-
    -
  • -
  • -
  • -
  • -
  • -
  • -
-
-
-
    -
  • -
  • -
  • -
  • -
  • -
  • -
-
-
-
-
-
-
- - - - - - - - - -
Date
Due
-
-
- - - -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ItemDescriptionQtyPriceTaxTotal
- - -
- - - -
-
-
-
-
- -
-
-
-
- Notes -
- - - -
-
-
-
-
-
-
-
- - - - - - - 0) { ?> - - - - - - 0) { ?> - - - - - - - - - - -
Subtotal
Tax
Paid
Balance
-
-
- -
- -
-
-
- -
-
-
-
- History -
- - -
-
-
- - - - - - - - - - - - - - - - + } - -
DateStatusDescription
-
-
-
-
-
-
- Payments -
- - + //Set Badge color based off of invoice status + if ($invoice_status == "Sent") { + $invoice_badge_color = "warning text-white"; + } elseif ($invoice_status == "Viewed") { + $invoice_badge_color = "info"; + } elseif ($invoice_status == "Partial") { + $invoice_badge_color = "primary"; + } elseif ($invoice_status == "Paid") { + $invoice_badge_color = "success"; + } elseif ($invoice_status == "Cancelled") { + $invoice_badge_color = "danger"; + } else { + $invoice_badge_color = "secondary"; + } + + //Product autocomplete + $products_sql = mysqli_query($mysqli, "SELECT product_name AS label, product_description AS description, product_price AS price FROM products WHERE company_id = $session_company_id"); + + if (mysqli_num_rows($products_sql) > 0) { + while ($row = mysqli_fetch_array($products_sql)) { + $products[] = $row; + } + $json_products = json_encode($products); + } + + ?> + + + +
+ +
+ +
+ +
+ + + + + + + Add Payment + +
+ +
+ + + +
+ +
+ +
+ +
+ +
+
+ "> +
+
+
+
+ +
+
+

Invoice

+
+ +
+
+
+
    +
  • +
  • +
  • +
  • +
  • +
  • +
+
+
+
    +
  • +
  • +
  • +
  • +
  • +
  • +
+
+
+
+
+
+
+ + + + + + + + + +
Date
Due
+
+
+ + + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ItemDescriptionQtyPriceTaxTotal
+ + +
+ + + +
+
+
+
+
+ +
+
+
+
+ Notes +
+ + + +
+
+
+
+
+
+
+
+ + + + + + + 0) { ?> + + + + + + 0) { ?> + + + + + + + + + + +
Subtotal
Tax
Paid
Balance
+
+
+ +
+ +
+
-
-
-
- - - - - - - - - - - - - - - - - - - - - -
DateAmountReferenceAccountAction
+
+
+
+
+ History +
+ + +
+
+
+ + + + + + + + + + + + + + + + + + +
DateStatusDescription
+
+
+
+
+
+
+ Payments +
+ + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + +
DateAmountReferenceAccountAction
+
+
+
+
-
-
-
-
- @@ -501,440 +501,440 @@ include("footer.php"); diff --git a/portal/check_login.php b/portal/check_login.php index bcb5a523..6351286b 100644 --- a/portal/check_login.php +++ b/portal/check_login.php @@ -7,10 +7,10 @@ if (!isset($_SESSION)) { // HTTP Only cookies - ini_set("session.cookie_httponly", True); + ini_set("session.cookie_httponly", true); if ($config_https_only) { // Tell client to only send cookie(s) over HTTPS - ini_set("session.cookie_secure", True); + ini_set("session.cookie_secure", true); } session_start(); } @@ -36,10 +36,10 @@ $session_company_id = $_SESSION['company_id']; $contact_sql = mysqli_query($mysqli, "SELECT * FROM contacts WHERE contact_id = '$session_contact_id' AND contact_client_id = '$session_client_id'"); $contact = mysqli_fetch_array($contact_sql); -$session_contact_name = strip_tags(mysqli_real_escape_string($mysqli,$contact['contact_name'])); +$session_contact_name = strip_tags(mysqli_real_escape_string($mysqli, $contact['contact_name'])); $session_contact_initials = initials($session_contact_name); -$session_contact_title = strip_tags(mysqli_real_escape_string($mysqli,$contact['contact_title'])); -$session_contact_email = strip_tags(mysqli_real_escape_string($mysqli,$contact['contact_email'])); +$session_contact_title = strip_tags(mysqli_real_escape_string($mysqli, $contact['contact_title'])); +$session_contact_email = strip_tags(mysqli_real_escape_string($mysqli, $contact['contact_email'])); $session_contact_photo = $contact['contact_photo']; // Get client info @@ -47,4 +47,4 @@ $client_sql = mysqli_query($mysqli, "SELECT * FROM clients WHERE client_id = '$s $client = mysqli_fetch_array($client_sql); $session_client_name = $client['client_name']; -$session_client_primary_contact_id = $client['primary_contact']; \ No newline at end of file +$session_client_primary_contact_id = $client['primary_contact']; diff --git a/recurring_invoice.php b/recurring_invoice.php index ad1ad3e0..a6d7b465 100644 --- a/recurring_invoice.php +++ b/recurring_invoice.php @@ -1,360 +1,358 @@ - - - 0) { - while ($row = mysqli_fetch_array($products_sql)) { - $products[] = $row; + $row = mysqli_fetch_array($sql); + $recurring_id = $row['recurring_id']; + $recurring_prefix = htmlentities($row['recurring_prefix']); + $recurring_number = htmlentities($row['recurring_number']); + $recurring_scope = htmlentities($row['recurring_scope']); + $recurring_frequency = htmlentities($row['recurring_frequency']); + $recurring_status = htmlentities($row['recurring_status']); + $recurring_created_at = date('Y-m-d',strtotime($row['recurring_created_at'])); + $recurring_last_sent = $row['recurring_last_sent']; + if ($recurring_last_sent == 0) { + $recurring_last_sent = '-'; } - $json_products = json_encode($products); - } + $recurring_next_date = $row['recurring_next_date']; + $recurring_amount = floatval($row['recurring_amount']); + $recurring_currency_code = htmlentities($row['recurring_currency_code']); + $recurring_note = htmlentities($row['recurring_note']); + $category_id = $row['recurring_category_id']; + $client_id = $row['client_id']; + $client_name = htmlentities($row['client_name']); + $location_address = htmlentities($row['location_address']); + $location_city = htmlentities($row['location_city']); + $location_state = htmlentities($row['location_state']); + $location_zip = htmlentities($row['location_zip']); + $contact_email = htmlentities($row['contact_email']); + $contact_phone = formatPhoneNumber($row['contact_phone']); + $contact_extension = htmlentities($row['contact_extension']); + $contact_mobile = formatPhoneNumber($row['contact_mobile']); + $client_website = htmlentities($row['client_website']); + $client_currency_code = htmlentities($row['client_currency_code']); + $client_net_terms = htmlentities($row['client_net_terms']); -?> + if ($recurring_status == 1) { + $status = "Active"; + $status_badge_color = "success"; + } else { + $status = "Inactive"; + $status_badge_color = "secondary"; + } + $company_id = $row['company_id']; + $company_name = htmlentities($row['company_name']); + $company_country = htmlentities($row['company_country']); + $company_address = htmlentities($row['company_address']); + $company_city = htmlentities($row['company_city']); + $company_state = htmlentities($row['company_state']); + $company_zip = htmlentities($row['company_zip']); + $company_phone = formatPhoneNumber($row['company_phone']); + $company_email = htmlentities($row['company_email']); + $company_website = htmlentities($row['company_website']); + $company_logo = htmlentities($row['company_logo']); - + $sql_history = mysqli_query($mysqli, "SELECT * FROM history WHERE history_recurring_id = $recurring_id ORDER BY history_id DESC"); -
-
+ //Product autocomplete + $products_sql = mysqli_query($mysqli, "SELECT product_name AS label, product_description AS description, product_price AS price FROM products WHERE company_id = $session_company_id"); -
-
-
-
- -
- -
-
-
- "> -
-
-

Recurring Invoice
ly

-
-
-
-
-
    -
  • -
  • -
  • -
  • -
  • -
-
-
-
    -
  • -
  • -
  • -
  • -
  • -
  • -
-
-
-
-
-
-
- - - - - - - - - - - - - -
Created
Next Date
Last Sent
-
-
- - - -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
ItemDescriptionQtyPriceTaxTotal
- - -
- + + + + + + + + + + + + - - - - - - -
DateEvent
- -
- - - - -
-
-
-
- Notes -
- - - +
+
-
-
-
-
-
-
- - - - - - - 0) { ?> - - - - - - - - - - -
Subtotal
Tax
Total
-
-
-
-
-
-
-
- History -
- - -
-
-
- - - - - - - - - - - - - - + -
DateEvent
-
-
-
-
- - \ No newline at end of file + diff --git a/settings_update.php b/settings_update.php index a6e5a84d..fe366e9d 100644 --- a/settings_update.php +++ b/settings_update.php @@ -1,89 +1,86 @@ +include("config.php"); -%h%ar%s'"); ?> -
-
-

Update

+
+
+

Update

+
+
+
+ + + + + + + +
Update App
+ CURRENT_DATABASE_VERSION) { ?> + +
+
Update Database
+
+ Current DB Version: +
+ Latest DB Version: + +

Latest version!

+ Current DB Version: + + +
+ + + + + + + + + + + + + +
CommitWhenDescription
+ + +
-
-
- - - - - - - -
Update App
- CURRENT_DATABASE_VERSION) { ?> - -
-
Update Database
-
- Current DB Version: -
- Latest DB Version: - -

Latest version!

- Current DB Version: - - -
- - - - - - - - - - - - - -
CommitWhenDescription
- - -
-
- -

Nothing to see here

Go Back"; - include("footer.php"); + include_once("footer.php"); - }else{ + } else { $row = mysqli_fetch_array($sql); $client_id = $row['client_id']; @@ -47,20 +45,20 @@ if (isset($_GET['ticket_id'])) { if ($ticket_status == "Open") { $ticket_status_display = "$ticket_status"; - }elseif ($ticket_status == "Working") { + } elseif ($ticket_status == "Working") { $ticket_status_display = "$ticket_status"; - }else{ + } else { $ticket_status_display = "$ticket_status"; } //Set Ticket Bage Color based of priority if ($ticket_priority == "High") { $ticket_priority_display = "$ticket_priority"; - }elseif ($ticket_priority == "Medium") { + } elseif ($ticket_priority == "Medium") { $ticket_priority_display = "$ticket_priority"; - }elseif ($ticket_priority == "Low") { + } elseif ($ticket_priority == "Low") { $ticket_priority_display = "$ticket_priority"; - }else{ + } else { $ticket_priority_display = "-"; } @@ -92,7 +90,7 @@ if (isset($_GET['ticket_id'])) { $ticket_assigned_to = $row['ticket_assigned_to']; if (empty($ticket_assigned_to)) { $ticket_assigned_to_display = "Not Assigned"; - }else{ + } else { $ticket_assigned_to_display = htmlentities($row['user_name']); } @@ -105,7 +103,7 @@ if (isset($_GET['ticket_id'])) { //Ticket Assigned To if (empty($ticket_assigned_to)) { $ticket_assigned_to_display = "Not Assigned"; - }else{ + } else { $ticket_assigned_to_display = htmlentities($row['user_name']); } @@ -155,7 +153,7 @@ if (isset($_GET['ticket_id'])) { if ($dt_value <= $date) { $dt_value = "Expired on $asset_warranty_expire"; $warranty_status_color ='red'; - }else{ + } else { $warranty_status_color = 'green'; } @@ -309,7 +307,7 @@ if (isset($_GET['ticket_id'])) { ?> -
mb-3"> +
mb-3">

@@ -580,7 +578,7 @@ if (isset($_GET['ticket_id'])) { ?> - @@ -588,4 +586,4 @@ if ($ticket_status !== "Closed") { ?> - \ No newline at end of file + diff --git a/user_profile.php b/user_profile.php index 3c65be1e..b71ddd2f 100644 --- a/user_profile.php +++ b/user_profile.php @@ -1,233 +1,231 @@ - +
-
-
-
-

Your User Details

-
-
- -
- - - -
- - - - " class="img-fluid"> - -

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

Your User Details

-
+
-
- -
-
- -
- + + + + +
+ + + + User avatar" class="img-fluid"> + +

+
+ +
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+ +
+
+
+ +
+ + +
+ + 1) { ?> + +
+
+ > + +

Note: You must log out and back in again for these changes take effect.

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

You have set up 2FA. Your QR code is below.

+ + + +
+ ',TokenAuth6238::getBarCodeUrl($session_name,' ',$session_token,$_SERVER['SERVER_NAME'])); + + echo "

$session_token

"; + } + + ?> +
+ + + +
+ + +
+
+
+
+ +
+ +
+ +
+
+
+ +
+
-
- -
- -
-
- -
- -
- -
-
-
- -
- - -
- - 1) { ?> - -
-
- > - -

Note: You must log out and back in again for these changes take effect.

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

You have set up 2FA. Your QR code is below.

- - - -
- ',TokenAuth6238::getBarCodeUrl($session_name,' ',$session_token,$_SERVER['SERVER_NAME'])); - - echo "

$session_token

"; - } - - ?> -
- - - -
- - -
-
-
-
- -
- -
- -
-
-
- -
- -
+
-
-
-
-
-

Your Recent Sign ins

-
- - - +
+
+

Your Recent Sign ins

+
+
+ + + ?> - - - + + + - - - -
$log_user_os
$log_user_browser
$log_ip"; ?>
$log_user_os
$log_user_browser
$log_ip"; ?>
- + + + + + +
-
-
-
-
-

Your Recent Activity

-
+
+
+
+

Your Recent Activity

+
- - - + + + ?> - - - + + + - - - -
-
- -
+
+ +
- + + + + + +
-
From 5d77be3f413382b743d73134221eca7d5ae8573e Mon Sep 17 00:00:00 2001 From: Marcus Hill Date: Mon, 23 Jan 2023 21:19:11 +0000 Subject: [PATCH 4/7] Convert include to require_once --- blank.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blank.php b/blank.php index a966e579..fd2a1c16 100644 --- a/blank.php +++ b/blank.php @@ -1,4 +1,4 @@ - +
-
\ No newline at end of file +
diff --git a/base32static.php b/base32static.php index 7813986a..980a89c4 100644 --- a/base32static.php +++ b/base32static.php @@ -1,28 +1,28 @@ '0', 'B'=>'1', 'C'=>'2', 'D'=>'3', 'E'=>'4', 'F'=>'5', 'G'=>'6', 'H'=>'7', - 'I'=>'8', 'J'=>'9', 'K'=>'10', 'L'=>'11', 'M'=>'12', 'N'=>'13', 'O'=>'14', 'P'=>'15', - 'Q'=>'16', 'R'=>'17', 'S'=>'18', 'T'=>'19', 'U'=>'20', 'V'=>'21', 'W'=>'22', 'X'=>'23', - 'Y'=>'24', 'Z'=>'25', '2'=>'26', '3'=>'27', '4'=>'28', '5'=>'29', '6'=>'30', '7'=>'31' + + private static $flippedMap = array( + 'A'=>'0', 'B'=>'1', 'C'=>'2', 'D'=>'3', 'E'=>'4', 'F'=>'5', 'G'=>'6', 'H'=>'7', + 'I'=>'8', 'J'=>'9', 'K'=>'10', 'L'=>'11', 'M'=>'12', 'N'=>'13', 'O'=>'14', 'P'=>'15', + 'Q'=>'16', 'R'=>'17', 'S'=>'18', 'T'=>'19', 'U'=>'20', 'V'=>'21', 'W'=>'22', 'X'=>'23', + 'Y'=>'24', 'Z'=>'25', '2'=>'26', '3'=>'27', '4'=>'28', '5'=>'29', '6'=>'30', '7'=>'31' ); - + /** * Use padding false when encoding for urls * @@ -30,67 +30,67 @@ class Base32Static { * @author Bryan Ruiz **/ public static function encode($input, $padding = true) { - if(empty($input)) return ""; - - $input = str_split($input); - $binaryString = ""; - - for($i = 0; $i < count($input); $i++) { - $binaryString .= str_pad(base_convert(ord($input[$i]), 10, 2), 8, '0', STR_PAD_LEFT); - } - - $fiveBitBinaryArray = str_split($binaryString, 5); - $base32 = ""; - $i=0; - - while($i < count($fiveBitBinaryArray)) { - $base32 .= self::$map[base_convert(str_pad($fiveBitBinaryArray[$i], 5,'0'), 2, 10)]; - $i++; - } - - if($padding && ($x = strlen($binaryString) % 40) != 0) { - if($x == 8) $base32 .= str_repeat(self::$map[32], 6); - else if($x == 16) $base32 .= str_repeat(self::$map[32], 4); - else if($x == 24) $base32 .= str_repeat(self::$map[32], 3); - else if($x == 32) $base32 .= self::$map[32]; - } - - return $base32; + if (empty($input)) return ""; + + $input = str_split($input); + $binaryString = ""; + + for ($i = 0; $i < count($input); $i++) { + $binaryString .= str_pad(base_convert(ord($input[$i]), 10, 2), 8, '0', STR_PAD_LEFT); + } + + $fiveBitBinaryArray = str_split($binaryString, 5); + $base32 = ""; + $i=0; + + while($i < count($fiveBitBinaryArray)) { + $base32 .= self::$map[base_convert(str_pad($fiveBitBinaryArray[$i], 5,'0'), 2, 10)]; + $i++; + } + + if ($padding && ($x = strlen($binaryString) % 40) != 0) { + if ($x == 8) $base32 .= str_repeat(self::$map[32], 6); + else if ($x == 16) $base32 .= str_repeat(self::$map[32], 4); + else if ($x == 24) $base32 .= str_repeat(self::$map[32], 3); + else if ($x == 32) $base32 .= self::$map[32]; + } + + return $base32; } - + public static function decode($input) { - if(empty($input)) return; - - $paddingCharCount = substr_count($input, self::$map[32]); - $allowedValues = array(6,4,3,1,0); - - if(!in_array($paddingCharCount, $allowedValues)) return false; - - for($i=0; $i<4; $i++){ - if($paddingCharCount == $allowedValues[$i] && - substr($input, -($allowedValues[$i])) != str_repeat(self::$map[32], $allowedValues[$i])) return false; - } - - $input = str_replace('=','', $input); - $input = str_split($input); - $binaryString = ""; - - for($i=0; $i < count($input); $i = $i+8) { - $x = ""; - - if(!in_array($input[$i], self::$map)) return false; - - for($j=0; $j < 8; $j++) { - $x .= str_pad(base_convert(@self::$flippedMap[@$input[$i + $j]], 10, 2), 5, '0', STR_PAD_LEFT); + if (empty($input)) return; + + $paddingCharCount = substr_count($input, self::$map[32]); + $allowedValues = array(6,4,3,1,0); + + if (!in_array($paddingCharCount, $allowedValues)) return false; + + for ($i=0; $i<4; $i++){ + if ($paddingCharCount == $allowedValues[$i] && + substr($input, -($allowedValues[$i])) != str_repeat(self::$map[32], $allowedValues[$i])) return false; } - - $eightBits = str_split($x, 8); - - for($z = 0; $z < count($eightBits); $z++) { - $binaryString .= ( ($y = chr(base_convert($eightBits[$z], 2, 10))) || ord($y) == 48 ) ? $y:""; + + $input = str_replace('=','', $input); + $input = str_split($input); + $binaryString = ""; + + for ($i=0; $i < count($input); $i = $i+8) { + $x = ""; + + if (!in_array($input[$i], self::$map)) return false; + + for ($j=0; $j < 8; $j++) { + $x .= str_pad(base_convert(@self::$flippedMap[@$input[$i + $j]], 10, 2), 5, '0', STR_PAD_LEFT); + } + + $eightBits = str_split($x, 8); + + for ($z = 0; $z < count($eightBits); $z++) { + $binaryString .= ( ($y = chr(base_convert($eightBits[$z], 2, 10))) || ord($y) == 48 ) ? $y:""; + } } - } - - return $binaryString; + + return $binaryString; } -} \ No newline at end of file +} diff --git a/category_add_modal.php b/category_add_modal.php index 3c11aa54..fbb85f4b 100644 --- a/category_add_modal.php +++ b/category_add_modal.php @@ -11,7 +11,7 @@ -

\ No newline at end of file +
diff --git a/client_assets.php b/client_assets.php index 2cac0630..7ba2d85b 100644 --- a/client_assets.php +++ b/client_assets.php @@ -1,62 +1,60 @@ - - - $sb, 'o' => $o))); -$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM assets +$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS * FROM assets LEFT JOIN contacts ON asset_contact_id = contact_id LEFT JOIN locations ON asset_location_id = location_id LEFT JOIN logins ON login_asset_id = asset_id @@ -67,304 +65,304 @@ $sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM assets ORDER BY $sb $o LIMIT $record_from, $record_to" ); -$num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); +$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); ?> -
-
-

Assets

-
- -
-
-
-
- - -
- -
-
- s"> -
- +
+
+

Assets

+
+
-
-
-
-
- All Assets - 0) { ?> - Workstations - - 0) { ?> - Servers - - 0) { ?> - Virtual - - 0) { ?> - Network - - 0) { ?> - Other - -
-
- -
-
- Export - -
+
+ + + +
-
- -
-
- - "> - - - - - - - - - - - - - - - - - - - - - - - - - "; - } - $asset_mac = htmlentities($row['asset_mac']); - $asset_status = htmlentities($row['asset_status']); - $asset_purchase_date = $row['asset_purchase_date']; - $asset_warranty_expire = $row['asset_warranty_expire']; - $asset_install_date = $row['asset_install_date']; - if (empty($asset_install_date)) { - $asset_install_date_display = "-"; - }else{ - $asset_install_date_display = $asset_install_date; - } - $asset_notes = htmlentities($row['asset_notes']); - $asset_created_at = $row['asset_created_at']; - $asset_vendor_id = $row['asset_vendor_id']; - $asset_location_id = $row['asset_location_id']; - $asset_contact_id = $row['asset_contact_id']; - $asset_network_id = $row['asset_network_id']; - - if ($asset_type == 'Laptop') { - $device_icon = "laptop"; - }elseif ($asset_type == 'Desktop') { - $device_icon = "desktop"; - }elseif ($asset_type == 'Server') { - $device_icon = "server"; - }elseif ($asset_type == 'Printer') { - $device_icon = "print"; - }elseif ($asset_type == 'Camera') { - $device_icon = "video"; - }elseif ($asset_type == 'Switch' || $asset_type == 'Firewall/Router') { - $device_icon = "network-wired"; - }elseif ($asset_type == 'Access Point') { - $device_icon = "wifi"; - }elseif ($asset_type == 'Phone') { - $device_icon = "phone"; - }elseif ($asset_type == 'Mobile Phone') { - $device_icon = "mobile-alt"; - }elseif ($asset_type == 'Tablet') { - $device_icon = "tablet-alt"; - }elseif ($asset_type == 'TV') { - $device_icon = "tv"; - }elseif ($asset_type == 'Virtual Machine') { - $device_icon = "cloud"; - }else{ - $device_icon = "tag"; - } - - $contact_name = $row['contact_name']; - if (empty($contact_name)) { - $contact_name = "-"; - } - - $location_name = $row['location_name']; - if (empty($location_name)) { - $location_name = "-"; - } - - $login_id = $row['login_id']; - $login_username = htmlentities($row['login_username']); - $login_password = htmlentities(decryptLoginEntry($row['login_password'])); - - // Related tickets - $sql_tickets = mysqli_query($mysqli,"SELECT * FROM tickets WHERE ticket_asset_id = $asset_id ORDER BY ticket_number DESC"); - $ticket_count = mysqli_num_rows($sql_tickets); - - // Related Documents - $sql_related_documents = mysqli_query($mysqli,"SELECT * FROM documents, asset_documents WHERE documents.document_id = asset_documents.document_id AND document_archived_at IS NULL AND asset_documents.asset_id = $asset_id ORDER BY documents.document_name DESC"); - $document_count = mysqli_num_rows($sql_related_documents); - - - // Related File - $sql_related_files = mysqli_query($mysqli,"SELECT * FROM files, asset_files WHERE files.file_id = asset_files.file_id AND asset_files.asset_id = $asset_id ORDER BY files.file_name DESC"); - $file_count = mysqli_num_rows($sql_related_files); - - ?> - - - - - - - - - - - - - - - - - - - - - - - +
+
+ Export + +
+
- -
NameTypeMake/ModelSerial NumberOperating SystemInstall DateAssigned ToLocationStatusAction
- - - 0) { - ?> - - - - -
+
+ +
+
+ + "> + + + + + + + + + + + + + + + + + + + + + + + + + "; + } + $asset_mac = htmlentities($row['asset_mac']); + $asset_status = htmlentities($row['asset_status']); + $asset_purchase_date = $row['asset_purchase_date']; + $asset_warranty_expire = $row['asset_warranty_expire']; + $asset_install_date = $row['asset_install_date']; + if (empty($asset_install_date)) { + $asset_install_date_display = "-"; + }else{ + $asset_install_date_display = $asset_install_date; + } + $asset_notes = htmlentities($row['asset_notes']); + $asset_created_at = $row['asset_created_at']; + $asset_vendor_id = $row['asset_vendor_id']; + $asset_location_id = $row['asset_location_id']; + $asset_contact_id = $row['asset_contact_id']; + $asset_network_id = $row['asset_network_id']; + + if ($asset_type == 'Laptop') { + $device_icon = "laptop"; + }elseif ($asset_type == 'Desktop') { + $device_icon = "desktop"; + }elseif ($asset_type == 'Server') { + $device_icon = "server"; + }elseif ($asset_type == 'Printer') { + $device_icon = "print"; + }elseif ($asset_type == 'Camera') { + $device_icon = "video"; + }elseif ($asset_type == 'Switch' || $asset_type == 'Firewall/Router') { + $device_icon = "network-wired"; + }elseif ($asset_type == 'Access Point') { + $device_icon = "wifi"; + }elseif ($asset_type == 'Phone') { + $device_icon = "phone"; + }elseif ($asset_type == 'Mobile Phone') { + $device_icon = "mobile-alt"; + }elseif ($asset_type == 'Tablet') { + $device_icon = "tablet-alt"; + }elseif ($asset_type == 'TV') { + $device_icon = "tv"; + }elseif ($asset_type == 'Virtual Machine') { + $device_icon = "cloud"; + }else{ + $device_icon = "tag"; + } + + $contact_name = $row['contact_name']; + if (empty($contact_name)) { + $contact_name = "-"; + } + + $location_name = $row['location_name']; + if (empty($location_name)) { + $location_name = "-"; + } + + $login_id = $row['login_id']; + $login_username = htmlentities($row['login_username']); + $login_password = htmlentities(decryptLoginEntry($row['login_password'])); + + // Related tickets + $sql_tickets = mysqli_query($mysqli, "SELECT * FROM tickets WHERE ticket_asset_id = $asset_id ORDER BY ticket_number DESC"); + $ticket_count = mysqli_num_rows($sql_tickets); + + // Related Documents + $sql_related_documents = mysqli_query($mysqli, "SELECT * FROM documents, asset_documents WHERE documents.document_id = asset_documents.document_id AND document_archived_at IS NULL AND asset_documents.asset_id = $asset_id ORDER BY documents.document_name DESC"); + $document_count = mysqli_num_rows($sql_related_documents); + + + // Related File + $sql_related_files = mysqli_query($mysqli, "SELECT * FROM files, asset_files WHERE files.file_id = asset_files.file_id AND asset_files.asset_id = $asset_id ORDER BY files.file_name DESC"); + $file_count = mysqli_num_rows($sql_related_files); + + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeMake/ModelSerial NumberOperating SystemInstall DateAssigned ToLocationStatusAction
+ + + 0) { + ?> + + + + + + + + +
+
+ +
- -
-
- \ No newline at end of file + diff --git a/client_contact_details.php b/client_contact_details.php index 017e1fc4..4a6c3f48 100644 --- a/client_contact_details.php +++ b/client_contact_details.php @@ -1,370 +1,368 @@ - - -Primary Contact"; - }else{ - $primary_contact_display = FALSE; - } - $contact_location_id = $row['contact_location_id']; - $location_name = htmlentities($row['location_name']); - if (empty($location_name)) { - $location_name_display = "-"; - }else{ - $location_name_display = $location_name; - } - $auth_method = htmlentities($row['contact_auth_method']); + $row = mysqli_fetch_array($sql); + $contact_id = $row['contact_id']; + $contact_name = htmlentities($row['contact_name']); + $contact_title = htmlentities($row['contact_title']); + $contact_department =htmlentities($row['contact_department']); + $contact_phone = formatPhoneNumber($row['contact_phone']); + $contact_extension = htmlentities($row['contact_extension']); + $contact_mobile = formatPhoneNumber($row['contact_mobile']); + $contact_email = htmlentities($row['contact_email']); + $contact_photo = htmlentities($row['contact_photo']); + $contact_initials = initials($contact_name); + $contact_notes = htmlentities($row['contact_notes']); + $contact_important = intval($row['contact_important']); + $contact_created_at = $row['contact_created_at']; + if ($contact_id == $primary_contact) { + $primary_contact_display = "Primary Contact"; + } else { + $primary_contact_display = FALSE; + } + $contact_location_id = $row['contact_location_id']; + $location_name = htmlentities($row['location_name']); + if (empty($location_name)) { + $location_name_display = "-"; + } else { + $location_name_display = $location_name; + } + $auth_method = htmlentities($row['contact_auth_method']); - // Related Assets Query - $sql_related_assets = mysqli_query($mysqli,"SELECT * FROM assets WHERE asset_contact_id = $contact_id AND company_id = $session_company_id ORDER BY asset_name DESC"); + // Related Assets Query + $sql_related_assets = mysqli_query($mysqli,"SELECT * FROM assets WHERE asset_contact_id = $contact_id AND company_id = $session_company_id ORDER BY asset_name DESC"); - $asset_count = mysqli_num_rows($sql_related_assets); + $asset_count = mysqli_num_rows($sql_related_assets); - // Related Logins Query - $sql_related_logins = mysqli_query($mysqli,"SELECT * FROM logins WHERE login_contact_id = $contact_id AND company_id = $session_company_id ORDER BY login_name DESC"); - $login_count = mysqli_num_rows($sql_related_logins); + // Related Logins Query + $sql_related_logins = mysqli_query($mysqli,"SELECT * FROM logins WHERE login_contact_id = $contact_id AND company_id = $session_company_id ORDER BY login_name DESC"); + $login_count = mysqli_num_rows($sql_related_logins); - // Related Software Query - $sql_related_software = mysqli_query($mysqli,"SELECT * FROM software, software_contacts WHERE software.software_id = software_contacts.software_id AND software_contacts.contact_id = $contact_id AND software.company_id = $session_company_id ORDER BY software.software_id DESC"); - $software_count = mysqli_num_rows($sql_related_software); + // Related Software Query + $sql_related_software = mysqli_query($mysqli,"SELECT * FROM software, software_contacts WHERE software.software_id = software_contacts.software_id AND software_contacts.contact_id = $contact_id AND software.company_id = $session_company_id ORDER BY software.software_id DESC"); + $software_count = mysqli_num_rows($sql_related_software); - // Related Tickets Query - $sql_related_tickets = mysqli_query($mysqli,"SELECT * FROM tickets WHERE ticket_contact_id = $contact_id AND company_id = $session_company_id ORDER BY ticket_id DESC"); - $ticket_count = mysqli_num_rows($sql_related_tickets); + // Related Tickets Query + $sql_related_tickets = mysqli_query($mysqli,"SELECT * FROM tickets WHERE ticket_contact_id = $contact_id AND company_id = $session_company_id ORDER BY ticket_id DESC"); + $ticket_count = mysqli_num_rows($sql_related_tickets); -?> + ?> -
+
-
+
-
-
-
- - contact_photo"> - - +
+
+
+ + contact_photo"> + + - -
-
-

- -
- - -
- - -
- - -
- - -
- -
-
- - -
-
- -
- -
- - - - - -
"> -
-

Assets

-
-
-
- - - - - - - - - - - - - - - "; - } - $asset_mac = htmlentities($row['asset_mac']); - $asset_status = htmlentities($row['asset_status']); - $asset_purchase_date = $row['asset_purchase_date']; - $asset_warranty_expire = $row['asset_warranty_expire']; - $asset_install_date = $row['asset_install_date']; - if (empty($asset_install_date)) { - $asset_install_date_display = "-"; - }else{ - $asset_install_date_display = $asset_install_date; - } - $asset_notes = htmlentities($row['asset_notes']); - $asset_created_at = $row['asset_created_at']; - $asset_vendor_id = $row['asset_vendor_id']; - $asset_location_id = $row['asset_location_id']; - $asset_network_id = $row['asset_network_id']; - - if ($asset_type == 'Laptop') { - $device_icon = "laptop"; - }elseif ($asset_type == 'Desktop') { - $device_icon = "desktop"; - }elseif ($asset_type == 'Server') { - $device_icon = "server"; - }elseif ($asset_type == 'Printer') { - $device_icon = "print"; - }elseif ($asset_type == 'Camera') { - $device_icon = "video"; - }elseif ($asset_type == 'Switch' || $asset_type == 'Firewall/Router') { - $device_icon = "network-wired"; - }elseif ($asset_type == 'Access Point') { - $device_icon = "wifi"; - }elseif ($asset_type == 'Phone') { - $device_icon = "phone"; - }elseif ($asset_type == 'Mobile Phone') { - $device_icon = "mobile-alt"; - }elseif ($asset_type == 'Tablet') { - $device_icon = "tablet-alt"; - }elseif ($asset_type == 'TV') { - $device_icon = "tv"; - }elseif ($asset_type == 'Virtual Machine') { - $device_icon = "cloud"; - }else{ - $device_icon = "tag"; - } - - ?> - - - - - - - - - - - - - - -
NameTypeMake/ModelSerial NumberOperating SystemInstall DateStatusAction
- - - -
-
- -
-
- - - -
"> -
-

Passwords

-
-
-
- - - - - - - - - - - - - "; - } - $login_username = htmlentities($row['login_username']); - if (empty($login_username)) { - $login_username_display = "-"; - }else{ - $login_username_display = "$login_username"; - } - $login_password = htmlentities(decryptLoginEntry($row['login_password'])); - $login_otp_secret = htmlentities($row['login_otp_secret']); - $login_id_with_secret = '"' . $row['login_id'] . '","' . $row['login_otp_secret'] . '"'; - if (empty($login_otp_secret)) { - $otp_display = "-"; - }else{ - $otp_display = " Hover.."; - } - $login_note = htmlentities($row['login_note']); - $login_contact_id = $row['login_contact_id']; - $login_vendor_id = $row['login_vendor_id']; - $login_asset_id = $row['login_asset_id']; - $login_software_id = $row['login_software_id']; - - ?> - - - - - - - - + - - include("client_login_edit_modal.php"); - } +
- ?> -
-
NameUsernamePasswordOTPURIAction
- - - - - - - - -
-
- -
+ + + +
"> +
+

Assets

+
+
+
+ + + + + + + + + + + + + + + "; + } + $asset_mac = htmlentities($row['asset_mac']); + $asset_status = htmlentities($row['asset_status']); + $asset_purchase_date = $row['asset_purchase_date']; + $asset_warranty_expire = $row['asset_warranty_expire']; + $asset_install_date = $row['asset_install_date']; + if (empty($asset_install_date)) { + $asset_install_date_display = "-"; + } else { + $asset_install_date_display = $asset_install_date; + } + $asset_notes = htmlentities($row['asset_notes']); + $asset_created_at = $row['asset_created_at']; + $asset_vendor_id = $row['asset_vendor_id']; + $asset_location_id = $row['asset_location_id']; + $asset_network_id = $row['asset_network_id']; + + if ($asset_type == 'Laptop') { + $device_icon = "laptop"; + } elseif ($asset_type == 'Desktop') { + $device_icon = "desktop"; + } elseif ($asset_type == 'Server') { + $device_icon = "server"; + } elseif ($asset_type == 'Printer') { + $device_icon = "print"; + } elseif ($asset_type == 'Camera') { + $device_icon = "video"; + } elseif ($asset_type == 'Switch' || $asset_type == 'Firewall/Router') { + $device_icon = "network-wired"; + } elseif ($asset_type == 'Access Point') { + $device_icon = "wifi"; + } elseif ($asset_type == 'Phone') { + $device_icon = "phone"; + } elseif ($asset_type == 'Mobile Phone') { + $device_icon = "mobile-alt"; + } elseif ($asset_type == 'Tablet') { + $device_icon = "tablet-alt"; + } elseif ($asset_type == 'TV') { + $device_icon = "tv"; + } elseif ($asset_type == 'Virtual Machine') { + $device_icon = "cloud"; + } else { + $device_icon = "tag"; + } + + ?> + + + + + + + + + + + + + + +
NameTypeMake/ModelSerial NumberOperating SystemInstall DateStatusAction
+ + + +
+
+ +
+
+ + + +
"> +
+

Passwords

+
+
+
+ + + + + + + + + + + + + "; + } + $login_username = htmlentities($row['login_username']); + if (empty($login_username)) { + $login_username_display = "-"; + } else { + $login_username_display = "$login_username"; + } + $login_password = htmlentities(decryptLoginEntry($row['login_password'])); + $login_otp_secret = htmlentities($row['login_otp_secret']); + $login_id_with_secret = '"' . $row['login_id'] . '","' . $row['login_otp_secret'] . '"'; + if (empty($login_otp_secret)) { + $otp_display = "-"; + } else { + $otp_display = " Hover.."; + } + $login_note = htmlentities($row['login_note']); + $login_contact_id = $row['login_contact_id']; + $login_vendor_id = $row['login_vendor_id']; + $login_asset_id = $row['login_asset_id']; + $login_software_id = $row['login_software_id']; + + ?> + + + + + + + + + + + + +
NameUsernamePasswordOTPURIAction
+ + + + + + + + +
+
+ +
+
+ + +
+
+ + include("client_contact_edit_modal.php"); -
- - + ?> - \ No newline at end of file + diff --git a/client_document_add_modal.php b/client_document_add_modal.php index b0d27b8b..8d2bdf93 100644 --- a/client_document_add_modal.php +++ b/client_document_add_modal.php @@ -1,52 +1,52 @@
- - + +
@@ -101,7 +101,7 @@
- +
@@ -111,7 +111,7 @@
- +
@@ -131,7 +131,7 @@
- +
@@ -141,11 +141,11 @@
- +
- +
@@ -153,7 +153,7 @@
- +
- - + +
@@ -101,7 +101,7 @@
- +
@@ -111,7 +111,7 @@
- +
@@ -131,7 +131,7 @@
- +
@@ -141,11 +141,11 @@
- +
- +
@@ -153,7 +153,7 @@
- +
- +
@@ -44,4 +44,4 @@
- \ No newline at end of file +?> diff --git a/settings_backup.php b/settings_backup.php index 07f7b1aa..b889ea93 100644 --- a/settings_backup.php +++ b/settings_backup.php @@ -1,4 +1,4 @@ - +
@@ -30,4 +30,4 @@
- +
@@ -202,4 +202,4 @@
- +
@@ -36,4 +36,4 @@
- +
@@ -88,4 +88,4 @@
- +
@@ -165,4 +165,4 @@ - +
@@ -30,4 +30,4 @@
- +
Work in Progress @@ -48,4 +48,4 @@
- +
@@ -60,4 +60,4 @@
- + \ No newline at end of file +?> diff --git a/settings_taxes.php b/settings_taxes.php index b80bb0d7..fcb749b8 100644 --- a/settings_taxes.php +++ b/settings_taxes.php @@ -1,4 +1,4 @@ - \ No newline at end of file +?> diff --git a/settings_theme.php b/settings_theme.php index b3ffe09b..91d1136f 100644 --- a/settings_theme.php +++ b/settings_theme.php @@ -1,4 +1,4 @@ - +
@@ -39,4 +39,4 @@
- +
diff --git a/settings_update.php b/settings_update.php index fe366e9d..87b478b1 100644 --- a/settings_update.php +++ b/settings_update.php @@ -1,5 +1,5 @@ $sb, 'o' => $o))); +//Rebuild URL +$url_query_strings_sb = http_build_query(array_merge($_GET,array('sb' => $sb, 'o' => $o))); - $sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM users, user_settings +$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS * FROM users, user_settings WHERE users.user_id = user_settings.user_id AND (user_name LIKE '%$q%' OR user_email LIKE '%$q%') AND user_archived_at IS NULL ORDER BY $sb $o LIMIT $record_from, $record_to"); - $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); +$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); ?> -
-
-

Users

-
-
- - - -
-
- -
- -
- -
-
- -
-
- - "> - - - - - - - - - - - Invited"; - }elseif ($user_status == 1) { - $user_status_display = "Active"; - }else{ - $user_status_display = "Disabled"; - } - $user_avatar = htmlentities($row['user_avatar']); - $user_token = htmlentities($row['user_token']); - $user_default_company = $row['user_default_company']; - $user_role = $row['user_role']; - if ($user_role == 3) { - $user_role_display = "Administrator"; - }elseif ($user_role == 2) { - $user_role_display = "Technician"; - }else{ - $user_role_display = "Accountant"; - } - $user_company_access_sql = mysqli_query($mysqli,"SELECT company_id FROM user_companies WHERE user_id = $user_id"); - $user_company_access_array = array(); - while ($row = mysqli_fetch_array($user_company_access_sql)) { - $user_company_access_array[] = $row['company_id']; - } - $user_company_access = implode(',',$user_company_access_array); +
+
+
+ +
+ +
+
+ +
+
+
NameEmailRoleStatusLast LoginAction
+ "> + + + + + + + + + + + Invited"; + }elseif ($user_status == 1) { + $user_status_display = "Active"; + }else{ + $user_status_display = "Disabled"; + } + $user_avatar = htmlentities($row['user_avatar']); + $user_token = htmlentities($row['user_token']); + $user_default_company = $row['user_default_company']; + $user_role = $row['user_role']; + if ($user_role == 3) { + $user_role_display = "Administrator"; + }elseif ($user_role == 2) { + $user_role_display = "Technician"; + }else{ + $user_role_display = "Accountant"; + } + $user_company_access_sql = mysqli_query($mysqli, "SELECT company_id FROM user_companies WHERE user_id = $user_id"); + $user_company_access_array = array(); + while ($row = mysqli_fetch_array($user_company_access_sql)) { + $user_company_access_array[] = $row['company_id']; + } + $user_company_access = implode(',',$user_company_access_array); - $sql_last_login = mysqli_query($mysqli,"SELECT * FROM logs + $user_initials = htmlentities(initials($user_name)); + + $sql_last_login = mysqli_query($mysqli, "SELECT * FROM logs WHERE log_user_id = $user_id AND log_type = 'Login' ORDER BY log_id DESC LIMIT 1" - ); - $row = mysqli_fetch_array($sql_last_login); - $log_created_at = $row['log_created_at']; - $log_ip = htmlentities($row['log_ip']); - $log_user_agent = htmlentities($row['log_user_agent']); - $log_user_os = get_os($log_user_agent); - $log_user_browser = get_web_browser($log_user_agent); - $last_login = "$log_user_os
$log_user_browser
$log_ip"; - if (empty($last_login)) { - $last_login = "Never logged in"; - } - - ?> - - + - - - - - - +
+ + + + + + + + - + include("user_edit_modal.php"); + include("user_companies_modal.php"); + include("user_archive_modal.php"); - -
NameEmailRoleStatusLast LoginAction
- - - "> - - + ); + $row = mysqli_fetch_array($sql_last_login); + $log_created_at = $row['log_created_at']; + $log_ip = htmlentities($row['log_ip']); + $log_user_agent = htmlentities($row['log_user_agent']); + $log_user_os = get_os($log_user_agent); + $log_user_browser = get_web_browser($log_user_agent); + $last_login = "$log_user_os
$log_user_browser
$log_ip"; + if (empty($last_login)) { + $last_login = "Never logged in"; + } + + ?> +
+ + + "> + + -
- +
+ -
-
-
- -
- -
- -
+ +
+ +
+ +
+ } + + ?> + + + +
+ +
- -
-
- + \ No newline at end of file +include("user_add_modal.php"); +include("user_invite_modal.php"); + +include("footer.php"); + +?> From a340df0df9c43d8682f8cb6802434e33fd3adffa Mon Sep 17 00:00:00 2001 From: Marcus Hill Date: Mon, 23 Jan 2023 21:37:32 +0000 Subject: [PATCH 7/7] More general code cleanup/formatting --- logs.php | 302 ++++++++++++++++++++++---------------------- settings_backup.php | 50 ++++---- settings_quote.php | 112 ++++++++-------- settings_tags.php | 184 +++++++++++++-------------- settings_taxes.php | 118 ++++++++--------- settings_theme.php | 72 +++++------ 6 files changed, 418 insertions(+), 420 deletions(-) diff --git a/logs.php b/logs.php index 3f479f58..450e8e96 100644 --- a/logs.php +++ b/logs.php @@ -1,60 +1,60 @@ $sb, 'o' => $o))); -$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM logs +$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS * FROM logs LEFT JOIN users ON log_user_id = user_id LEFT JOIN clients ON log_client_id = client_id WHERE (log_type LIKE '%$q%' OR log_action LIKE '%$q%' OR log_description LIKE '%$q%' OR log_ip LIKE '%$q%' OR log_user_agent LIKE '%$q%' OR user_name LIKE '%$q%' OR client_name LIKE '%$q%') @@ -62,125 +62,125 @@ $sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM logs ORDER BY $sb $o LIMIT $record_from, $record_to" ); -$num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); +$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); ?> -
-
-

Audit Logs

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

Audit Logs

-
-
" id="advancedFilter"> -
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
- -
-
- - "> - - - - - - - - - - - - - $client_name"; - } - - ?> - - - - - - - - - - - +
+
+
+
+
+ +
+ + +
+
+
+
+
" id="advancedFilter"> +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+
TimestampUserClientTypeActionDescriptionIP AddressUser Agent
$log_user_browser"; ?>
+ "> + + + + + + + + + + + + + + while ($row = mysqli_fetch_array($sql)) { + $log_id = $row['log_id']; + $log_type = htmlentities($row['log_type']); + $log_action = htmlentities($row['log_action']); + $log_description = htmlentities($row['log_description']); + $log_ip = htmlentities($row['log_ip']); + $log_user_agent = htmlentities($row['log_user_agent']); + $log_user_os = get_os($log_user_agent); + $log_user_browser = get_web_browser($log_user_agent); + $log_created_at = $row['log_created_at']; + $user_id = $row['user_id']; + $user_name = htmlentities($row['user_name']); + if (empty($user_name)) { + $user_name_display = "-"; + }else{ + $user_name_display = $user_name; + } + $client_name = htmlentities($row['client_name']); + $client_id = $row['client_id']; + if (empty($client_name)) { + $client_name_display = "-"; + }else{ + $client_name_display = "$client_name"; + } - -
TimestampUserClientTypeActionDescriptionIP AddressUser Agent
+ ?> + + + + + + + + + + $log_user_browser"; ?> + + + + + + +
+ +
- -
-
-
-
-

Download Database

+
+
+

Download Database

+
+
+
+

Download
+
+
-
-
-

Download
-
-
-
-
-
-

Backup Master Encryption Key

-
-
-
-
- -
-
- +
+
+

Backup Master Encryption Key

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

Quote Settings

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

Quote Settings

-
+
+ -
- -
-
- -
- +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ + +
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ + + +
-
- -
- - -
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- - - - -
-
+
- - $sb, 'o' => $o))); -$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM tags +$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS * FROM tags WHERE tag_name LIKE '%$q%' AND company_id = $session_company_id ORDER BY $sb $o LIMIT $record_from, $record_to" ); -$num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); +$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); if ($num_row > 0) { //Colors Used -$sql_colors_used = mysqli_query($mysqli,"SELECT tag_color FROM tags - WHERE tag_archived_at IS NULL - AND company_id = $session_company_id" -); + $sql_colors_used = mysqli_query($mysqli, "SELECT tag_color FROM tags + WHERE tag_archived_at IS NULL + AND company_id = $session_company_id" + ); -while ($color_used_row = mysqli_fetch_array($sql_colors_used)) { - $colors_used_array[] = $color_used_row['tag_color']; -} -$colors_diff = array_diff($colors_array,$colors_used_array); + while ($color_used_row = mysqli_fetch_array($sql_colors_used)) { + $colors_used_array[] = $color_used_row['tag_color']; + } + $colors_diff = array_diff($colors_array, $colors_used_array); }else{ - $colors_diff = $colors_array; + $colors_diff = $colors_array; } ?>
-
-

Tags

-
- +
+

Tags

+
+ +
-
- -
-
-
-
-
- -
- + +
+
+
+ +
+ +
+ +
+
+
-
- -
-
-
+
+
+
+ +
+
+ + "> + + + + + + + + + + + + + + + + + + + +
NameTypeColorAction
"; ?> + +
+
+
- -
-
- - "> - - - - - - - - - - - - - - - - - - - -
NameTypeColorAction
"; ?> - -
-
- -
- diff --git a/settings_taxes.php b/settings_taxes.php index fcb749b8..33e71072 100644 --- a/settings_taxes.php +++ b/settings_taxes.php @@ -1,9 +1,9 @@ -
-
-

Taxes

-
- +
+

Taxes

+
+ +
-
-
-
- - "> - - - - - - - - - - - - - +
+
+
NamePercentAction
- -
+ "> + + + + + + + +

No Records Here

"; - } - - ?> + ?> + + + + + - -
NamePercentAction
+ +
+

No Records Here

"; + } + + ?> + + + + +
-
diff --git a/settings_theme.php b/settings_theme.php index 91d1136f..da2a44f1 100644 --- a/settings_theme.php +++ b/settings_theme.php @@ -1,42 +1,42 @@ -
-
-

Theme

-
-
-
- - -
- - - -
-
- > - -
-
- - - +
+
+

Theme

+
+ -
- - - - -
-
+ +
+ + + +
+
+ > + +
+
+ + + +
+ +
+ + + + +
+