From dfb7364a8241aa2a3325545e54fd0e4e7417861b Mon Sep 17 00:00:00 2001 From: wrongecho <32306651+wrongecho@users.noreply.github.com> Date: Mon, 23 Jan 2023 19:34:49 +0000 Subject: [PATCH 01/31] Update README.md Adjust 1.0 release estimate to April/May in line with milestone --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9c68f846..2b6f273d 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ ### In Beta * This project is still in early beta and is considered a **work in progress**. Many changes are being performed and may cause breakage upon updates. * Currently, we strongly recommend against storing confidential information in ITFlow; ITFlow has not undergone a third-party security assessment. -* We are hoping to have a stable 1.0 release by Dec 2022. +* We are hoping to have a stable 1.0 release by April/May 2023. ### Built With From 95b9e2fe235a22b7a4dcd1cde1506b665ccaf3e2 Mon Sep 17 00:00:00 2001 From: Marcus Hill Date: Mon, 23 Jan 2023 20:55:25 +0000 Subject: [PATCH 02/31] 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 03/31] 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 04/31] 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 05/31] 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 08/31] 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

+
+ -
- - - - -
-
+ +
+ + + +
+
+ > + +
+
+ + + +
+ +
+ + + + +
+
Date: Mon, 23 Jan 2023 21:43:45 -0500 Subject: [PATCH 09/31] Updated DB Structure Defaults and dropped some unused fields --- database_updates.php | 300 ++++++++++++++++++++++++++++++++++++++++++- database_version.php | 2 +- db.sql | 169 ++++++++++++------------ 3 files changed, 381 insertions(+), 90 deletions(-) diff --git a/database_updates.php b/database_updates.php index 29b046f7..6c3c83f8 100644 --- a/database_updates.php +++ b/database_updates.php @@ -467,11 +467,305 @@ if(LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION){ } - //if(CURRENT_DATABASE_VERSION == '0.3.1'){ - // Insert queries here required to update to DB version 0.3.2 + if (CURRENT_DATABASE_VERSION == '0.3.1') { + + // Assets + + mysqli_query($mysqli, "UPDATE `assets` SET `asset_login_id` = 0 WHERE `asset_login_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `assets` CHANGE `asset_login_id` `asset_login_id` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "UPDATE `assets` SET `asset_vendor_id` = 0 WHERE `asset_vendor_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `assets` CHANGE `asset_vendor_id` `asset_vendor_id` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "UPDATE `assets` SET `asset_location_id` = 0 WHERE `asset_location_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `assets` CHANGE `asset_location_id` `asset_location_id` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "UPDATE `assets` SET `asset_network_id` = 0 WHERE `asset_network_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `assets` CHANGE `asset_network_id` `asset_network_id` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "UPDATE `assets` SET `asset_client_id` = 0 WHERE `asset_client_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `assets` CHANGE `asset_client_id` `asset_client_id` INT(11) NOT NULL DEFAULT 0"); + + // Certificates + + mysqli_query($mysqli, "UPDATE `certificates` SET `certificate_domain_id` = 0 WHERE `certificate_domain_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `certificates` CHANGE `certificate_domain_id` `certificate_domain_id` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "ALTER TABLE `certificates` CHANGE `certificate_client_id` `certificate_client_id` INT(11) NOT NULL DEFAULT 0"); + + // Clients + + mysqli_query($mysqli, "UPDATE `clients` SET `primary_location` = 0 WHERE `primary_location` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `clients` CHANGE `primary_location` `primary_location` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "UPDATE `clients` SET `primary_contact` = 0 WHERE `primary_contact` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `clients` CHANGE `primary_contact` `primary_contact` INT(11) NOT NULL DEFAULT 0"); + + // Contacts + + mysqli_query($mysqli, "UPDATE `contacts` SET `contact_location_id` = 0 WHERE `contact_location_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `contacts` CHANGE `contact_location_id` `contact_location_id` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "ALTER TABLE `contacts` CHANGE `contact_client_id` `contact_client_id` INT(11) NOT NULL DEFAULT 0"); + + // Documents + + mysqli_query($mysqli, "ALTER TABLE `documents` CHANGE `document_template` `document_template` TINYINT(1) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "UPDATE `documents` SET `document_folder_id` = 0 WHERE `document_folder_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `documents` CHANGE `document_folder_id` `document_folder_id` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "ALTER TABLE `documents` CHANGE `document_client_id` `document_client_id` INT(11) NOT NULL DEFAULT 0"); + + // Domains + + mysqli_query($mysqli, "UPDATE `domains` SET `domain_registrar` = 0 WHERE `domain_registrar` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `domains` CHANGE `domain_registrar` `domain_registrar` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "UPDATE `domains` SET `domain_webhost` = 0 WHERE `domain_webhost` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `domains` CHANGE `domain_webhost` `domain_webhost` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "ALTER TABLE `domains` CHANGE `domain_client_id` `domain_client_id` INT(11) NOT NULL DEFAULT 0"); + + // Events + + mysqli_query($mysqli, "UPDATE `events` SET `event_client_id` = 0 WHERE `event_client_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `events` CHANGE `event_client_id` `event_client_id` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "UPDATE `events` SET `event_location_id` = 0 WHERE `event_location_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `events` CHANGE `event_location_id` `event_location_id` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "ALTER TABLE `events` CHANGE `event_calendar_id` `event_calendar_id` INT(11) NOT NULL DEFAULT 0"); + + // Expenses + + mysqli_query($mysqli, "UPDATE `expenses` SET `expense_vendor_id` = 0 WHERE `expense_vendor_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `expenses` CHANGE `expense_vendor_id` `expense_vendor_id` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "UPDATE `expenses` SET `expense_client_id` = 0 WHERE `expense_client_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `expenses` CHANGE `expense_client_id` `expense_client_id` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "UPDATE `expenses` SET `expense_category_id` = 0 WHERE `expense_category_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `expenses` CHANGE `expense_category_id` `expense_category_id` INT(11) NOT NULL DEFAULT 0"); + + // Files + + mysqli_query($mysqli, "ALTER TABLE `files` CHANGE `file_client_id` `file_client_id` INT(11) NOT NULL DEFAULT 0"); + + // Folders + + mysqli_query($mysqli, "UPDATE `folders` SET `parent_folder` = 0 WHERE `parent_folder` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `folders` CHANGE `parent_folder` `parent_folder` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "ALTER TABLE `folders` CHANGE `folder_client_id` `folder_client_id` INT(11) NOT NULL DEFAULT 0"); + + // History + + mysqli_query($mysqli, "UPDATE `history` SET `history_invoice_id` = 0 WHERE `history_invoice_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `history` CHANGE `history_invoice_id` `history_invoice_id` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "UPDATE `history` SET `history_recurring_id` = 0 WHERE `history_recurring_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `history` CHANGE `history_recurring_id` `history_recurring_id` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "UPDATE `history` SET `history_quote_id` = 0 WHERE `history_quote_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `history` CHANGE `history_quote_id` `history_quote_id` INT(11) NOT NULL DEFAULT 0"); + + // Invoices + + mysqli_query($mysqli, "UPDATE `invoices` SET `invoice_amount` = 0.00 WHERE `invoice_amount` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `invoices` CHANGE `invoice_amount` `invoice_amount` DECIMAL(15,2) NOT NULL DEFAULT 0.00"); + + // Invoice Items + + mysqli_query($mysqli, "ALTER TABLE `invoice_items` CHANGE `item_quantity` `item_quantity` DECIMAL(15,2) NOT NULL DEFAULT 0.00"); + + mysqli_query($mysqli, "ALTER TABLE `invoice_items` CHANGE `item_price` `item_price` DECIMAL(15,2) NOT NULL DEFAULT 0.00"); + + mysqli_query($mysqli, "ALTER TABLE `invoice_items` CHANGE `item_subtotal` `item_subtotal` DECIMAL(15,2) NOT NULL DEFAULT 0.00"); + + mysqli_query($mysqli, "UPDATE `invoice_items` SET `item_tax` = 0.00 WHERE `item_tax` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `invoice_items` CHANGE `item_tax` `item_tax` DECIMAL(15,2) NOT NULL DEFAULT 0.00"); + + mysqli_query($mysqli, "ALTER TABLE `invoice_items` CHANGE `item_total` `item_total` DECIMAL(15,2) NOT NULL DEFAULT 0.00"); + + mysqli_query($mysqli, "UPDATE `invoice_items` SET `item_tax_id` = 0 WHERE `item_tax_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `invoice_items` CHANGE `item_tax_id` `item_tax_id` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "UPDATE `invoice_items` SET `item_quote_id` = 0 WHERE `item_quote_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `invoice_items` CHANGE `item_quote_id` `item_quote_id` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "UPDATE `invoice_items` SET `item_recurring_id` = 0 WHERE `item_recurring_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `invoice_items` CHANGE `item_recurring_id` `item_recurring_id` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "UPDATE `invoice_items` SET `item_invoice_id` = 0 WHERE `item_invoice_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `invoice_items` CHANGE `item_invoice_id` `item_invoice_id` INT(11) NOT NULL DEFAULT 0"); + + // Locations + + mysqli_query($mysqli, "UPDATE `locations` SET `location_contact_id` = 0 WHERE `location_contact_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `locations` CHANGE `location_contact_id` `location_contact_id` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "UPDATE `locations` SET `location_client_id` = 0 WHERE `location_client_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `locations` CHANGE `location_client_id` `location_client_id` INT(11) NOT NULL DEFAULT 0"); + + // Logins + + mysqli_query($mysqli, "UPDATE `logins` SET `login_vendor_id` = 0 WHERE `login_vendor_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `logins` CHANGE `login_vendor_id` `login_vendor_id` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "UPDATE `logins` SET `login_asset_id` = 0 WHERE `login_asset_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `logins` CHANGE `login_asset_id` `login_asset_id` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "UPDATE `logins` SET `login_software_id` = 0 WHERE `login_software_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `logins` CHANGE `login_software_id` `login_software_id` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "UPDATE `logins` SET `login_client_id` = 0 WHERE `login_client_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `logins` CHANGE `login_client_id` `login_client_id` INT(11) NOT NULL DEFAULT 0"); + + // Logs + + mysqli_query($mysqli, "UPDATE `logs` SET `log_client_id` = 0 WHERE `log_client_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `logs` CHANGE `log_client_id` `log_client_id` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "ALTER TABLE `logs` DROP `log_invoice_id`"); + mysqli_query($mysqli, "ALTER TABLE `logs` DROP `log_quote_id`"); + mysqli_query($mysqli, "ALTER TABLE `logs` DROP `log_recurring_id`"); + mysqli_query($mysqli, "ALTER TABLE `logs` DROP `log_entity_id`"); + + mysqli_query($mysqli, "UPDATE `logs` SET `log_user_id` = 0 WHERE `log_user_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `logs` CHANGE `log_user_id` `log_user_id` INT(11) NOT NULL DEFAULT 0"); + + // Networks + + mysqli_query($mysqli, "UPDATE `networks` SET `network_location_id` = 0 WHERE `network_location_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `networks` CHANGE `network_location_id` `network_location_id` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "ALTER TABLE `networks` CHANGE `network_client_id` `network_client_id` INT(11) NOT NULL DEFAULT 0"); + + // Notifications + + mysqli_query($mysqli, "UPDATE `notifications` SET `notification_client_id` = 0 WHERE `notification_client_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `notifications` CHANGE `notification_client_id` `notification_client_id` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "ALTER TABLE `notifications` CHANGE `notification_user_id` `notification_user_id` INT(11) NOT NULL DEFAULT 0"); + + // Payments + + mysqli_query($mysqli, "UPDATE `payments` SET `payment_invoice_id` = 0 WHERE `payment_invoice_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `payments` CHANGE `payment_invoice_id` `payment_invoice_id` INT(11) NOT NULL DEFAULT 0"); + + // Products + + mysqli_query($mysqli, "UPDATE `products` SET `product_tax_id` = 0 WHERE `product_tax_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `products` CHANGE `product_tax_id` `product_tax_id` INT(11) NOT NULL DEFAULT 0"); + + // Quotes + + mysqli_query($mysqli, "UPDATE `quotes` SET `quote_amount` = 0.00 WHERE `quote_amount` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `quotes` CHANGE `quote_amount` `quote_amount` DECIMAL(15,2) NOT NULL DEFAULT 0.00"); + + // Recurring + + mysqli_query($mysqli, "UPDATE `recurring` SET `recurring_amount` = 0.00 WHERE `recurring_amount` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `recurring` CHANGE `recurring_amount` `recurring_amount` DECIMAL(15,2) NOT NULL DEFAULT 0.00"); + + // Revenues + + mysqli_query($mysqli, "UPDATE `revenues` SET `revenue_amount` = 0.00 WHERE `revenue_amount` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `revenues` CHANGE `revenue_amount` `revenue_amount` DECIMAL(15,2) NOT NULL DEFAULT 0.00"); + + mysqli_query($mysqli, "UPDATE `revenues` SET `revenue_category_id` = 0 WHERE `revenue_category_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `revenues` CHANGE `revenue_category_id` `revenue_category_id` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "UPDATE `revenues` SET `revenue_client_id` = 0 WHERE `revenue_client_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `revenues` CHANGE `revenue_client_id` `revenue_client_id` INT(11) NOT NULL DEFAULT 0"); + + // Scheduled Tickets + + mysqli_query($mysqli, "ALTER TABLE `scheduled_tickets` CHANGE `scheduled_ticket_created_by` `scheduled_ticket_created_by` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "UPDATE `scheduled_tickets` SET `scheduled_ticket_client_id` = 0 WHERE `scheduled_ticket_client_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `scheduled_tickets` CHANGE `scheduled_ticket_client_id` `scheduled_ticket_client_id` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "UPDATE `scheduled_tickets` SET `scheduled_ticket_contact_id` = 0 WHERE `scheduled_ticket_contact_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `scheduled_tickets` CHANGE `scheduled_ticket_contact_id` `scheduled_ticket_contact_id` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "UPDATE `scheduled_tickets` SET `scheduled_ticket_asset_id` = 0 WHERE `scheduled_ticket_asset_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `scheduled_tickets` CHANGE `scheduled_ticket_asset_id` `scheduled_ticket_asset_id` INT(11) NOT NULL DEFAULT 0"); + + // Settings + + mysqli_query($mysqli, "ALTER TABLE `settings` CHANGE `config_ticket_email_parse` `config_ticket_email_parse` TINYINT(1) NOT NULL DEFAULT 0"); + mysqli_query($mysqli, "ALTER TABLE `settings` CHANGE `config_ticket_client_general_notifications` `config_ticket_client_general_notifications` TINYINT(1) NOT NULL DEFAULT 1"); + mysqli_query($mysqli, "ALTER TABLE `settings` CHANGE `config_enable_cron` `config_enable_cron` TINYINT(1) NOT NULL DEFAULT 0"); + mysqli_query($mysqli, "ALTER TABLE `settings` CHANGE `config_recurring_auto_send_invoice` `config_recurring_auto_send_invoice` TINYINT(1) NOT NULL DEFAULT 1"); + + mysqli_query($mysqli, "UPDATE `settings` SET `config_enable_alert_domain_expire` = 1 WHERE `config_enable_alert_domain_expire` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `settings` CHANGE `config_enable_alert_domain_expire` `config_enable_alert_domain_expire` TINYINT(1) NOT NULL DEFAULT 1"); + + mysqli_query($mysqli, "UPDATE `settings` SET `config_send_invoice_reminders` = 1 WHERE `config_send_invoice_reminders` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `settings` CHANGE `config_send_invoice_reminders` `config_send_invoice_reminders` TINYINT(1) NOT NULL DEFAULT 1"); + + mysqli_query($mysqli, "UPDATE `settings` SET `config_stripe_enable` = 0 WHERE `config_stripe_enable` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `settings` CHANGE `config_stripe_enable` `config_stripe_enable` TINYINT(1) NOT NULL DEFAULT 0"); + + // Software + + mysqli_query($mysqli, "UPDATE `software` SET `software_template` = 0 WHERE `software_template` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `software` CHANGE `software_template` `software_template` TINYINT(1) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "UPDATE `software` SET `software_login_id` = 0 WHERE `software_login_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `software` CHANGE `software_login_id` `software_login_id` INT(11) NOT NULL DEFAULT 0"); + + // Tags + + mysqli_query($mysqli, "ALTER TABLE `tags` ADD `tag_archived_at` DATETIME NULL DEFAULT NULL AFTER `tag_updated_at`"); + + // Tickets + + mysqli_query($mysqli, "UPDATE `tickets` SET `ticket_closed_by` = 0 WHERE `ticket_closed_by` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `tickets` CHANGE `ticket_closed_by` `ticket_closed_by` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "UPDATE `tickets` SET `ticket_vendor_id` = 0 WHERE `ticket_vendor_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `tickets` CHANGE `ticket_vendor_id` `ticket_vendor_id` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "UPDATE `tickets` SET `ticket_client_id` = 0 WHERE `ticket_client_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `tickets` CHANGE `ticket_client_id` `ticket_client_id` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "UPDATE `tickets` SET `ticket_contact_id` = 0 WHERE `ticket_contact_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `tickets` CHANGE `ticket_contact_id` `ticket_contact_id` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "UPDATE `tickets` SET `ticket_location_id` = 0 WHERE `ticket_location_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `tickets` CHANGE `ticket_location_id` `ticket_location_id` INT(11) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "UPDATE `tickets` SET `ticket_asset_id` = 0 WHERE `ticket_asset_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `tickets` CHANGE `ticket_asset_id` `ticket_asset_id` INT(11) NOT NULL DEFAULT 0"); + + //Trips + + mysqli_query($mysqli, "UPDATE `trips` SET `trip_client_id` = 0 WHERE `trip_client_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `trips` CHANGE `trip_client_id` `trip_client_id` INT(11) NOT NULL DEFAULT 0"); + + // Users + + mysqli_query($mysqli, "ALTER TABLE `users` CHANGE `user_status` `user_status` TINYINT(1) NOT NULL DEFAULT 1"); + + // Vendors + + mysqli_query($mysqli, "ALTER TABLE `vendors` CHANGE `vendor_template` `vendor_template` TINYINT(1) NOT NULL DEFAULT 0"); + + mysqli_query($mysqli, "UPDATE `vendors` SET `vendor_client_id` = 0 WHERE `vendor_client_id` IS NULL"); + mysqli_query($mysqli, "ALTER TABLE `vendors` CHANGE `vendor_client_id` `vendor_client_id` INT(11) NOT NULL DEFAULT 0"); + + // Then, update the database to the next sequential version + mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.3.2'"); + } + + //if(CURRENT_DATABASE_VERSION == '0.3.2'){ + // Insert queries here required to update to DB version 0.3.3 // Then, update the database to the next sequential version - // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.3.2'"); + // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.3.3'"); //} diff --git a/database_version.php b/database_version.php index d814941c..759dcc56 100644 --- a/database_version.php +++ b/database_version.php @@ -5,4 +5,4 @@ * It is used in conjunction with database_updates.php */ -DEFINE("LATEST_DATABASE_VERSION", "0.3.1"); \ No newline at end of file +DEFINE("LATEST_DATABASE_VERSION", "0.3.2"); \ No newline at end of file diff --git a/db.sql b/db.sql index 22bae51f..5a02b3b4 100644 --- a/db.sql +++ b/db.sql @@ -122,12 +122,12 @@ CREATE TABLE `assets` ( `asset_created_at` datetime NOT NULL DEFAULT current_timestamp(), `asset_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), `asset_archived_at` datetime DEFAULT NULL, - `asset_login_id` int(11) DEFAULT NULL, - `asset_vendor_id` int(11) DEFAULT NULL, - `asset_location_id` int(11) DEFAULT NULL, + `asset_login_id` int(11) NOT NULL DEFAULT 0, + `asset_vendor_id` int(11) NOT NULL DEFAULT 0, + `asset_location_id` int(11) NOT NULL DEFAULT 0, `asset_contact_id` int(11) NOT NULL DEFAULT 0, - `asset_network_id` int(11) DEFAULT NULL, - `asset_client_id` int(11) DEFAULT NULL, + `asset_network_id` int(11) NOT NULL DEFAULT 0, + `asset_client_id` int(11) NOT NULL DEFAULT 0, `company_id` int(11) NOT NULL, PRIMARY KEY (`asset_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; @@ -190,8 +190,8 @@ CREATE TABLE `certificates` ( `certificate_created_at` datetime NOT NULL DEFAULT current_timestamp(), `certificate_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), `certificate_archived_at` datetime DEFAULT NULL, - `certificate_domain_id` int(11) DEFAULT NULL, - `certificate_client_id` int(11) NOT NULL, + `certificate_domain_id` int(11) NOT NULL DEFAULT 0, + `certificate_client_id` int(11) NOT NULL DEFAULT 0, `company_id` int(11) NOT NULL, PRIMARY KEY (`certificate_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; @@ -231,8 +231,8 @@ CREATE TABLE `clients` ( `client_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), `client_archived_at` datetime DEFAULT NULL, `client_accessed_at` datetime DEFAULT NULL, - `primary_location` int(11) DEFAULT NULL, - `primary_contact` int(11) DEFAULT NULL, + `primary_location` int(11) NOT NULL DEFAULT 0, + `primary_contact` int(11) NOT NULL DEFAULT 0, `company_id` int(11) NOT NULL, PRIMARY KEY (`client_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; @@ -347,9 +347,9 @@ CREATE TABLE `contacts` ( `contact_created_at` datetime NOT NULL DEFAULT current_timestamp(), `contact_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), `contact_archived_at` datetime DEFAULT NULL, - `contact_location_id` int(11) DEFAULT NULL, + `contact_location_id` int(11) NOT NULL DEFAULT 0, `contact_department` varchar(200) DEFAULT NULL, - `contact_client_id` int(11) NOT NULL, + `contact_client_id` int(11) NOT NULL DEFAULT 0, `company_id` int(11) NOT NULL, PRIMARY KEY (`contact_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; @@ -370,9 +370,9 @@ CREATE TABLE `documents` ( `document_created_at` datetime NOT NULL DEFAULT current_timestamp(), `document_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), `document_archived_at` datetime DEFAULT NULL, - `document_template` tinyint(1) NOT NULL, - `document_folder_id` int(11) DEFAULT NULL, - `document_client_id` int(11) NOT NULL, + `document_template` tinyint(1) NOT NULL DEFAULT 0, + `document_folder_id` int(11) NOT NULL DEFAULT 0, + `document_client_id` int(11) NOT NULL DEFAULT 0, `company_id` int(11) NOT NULL, PRIMARY KEY (`document_id`), FULLTEXT KEY `document_content_raw` (`document_content_raw`) @@ -398,9 +398,9 @@ CREATE TABLE `domains` ( `domain_created_at` datetime NOT NULL DEFAULT current_timestamp(), `domain_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), `domain_archived_at` datetime DEFAULT NULL, - `domain_registrar` int(11) DEFAULT NULL, - `domain_webhost` int(11) DEFAULT NULL, - `domain_client_id` int(11) NOT NULL, + `domain_registrar` int(11) NOT NULL DEFAULT 0, + `domain_webhost` int(11) NOT NULL DEFAULT 0, + `domain_client_id` int(11) NOT NULL DEFAULT 0, `company_id` int(11) NOT NULL, PRIMARY KEY (`domain_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; @@ -423,9 +423,9 @@ CREATE TABLE `events` ( `event_created_at` datetime NOT NULL DEFAULT current_timestamp(), `event_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), `event_archived_at` datetime DEFAULT NULL, - `event_client_id` int(11) DEFAULT NULL, - `event_location_id` int(11) DEFAULT NULL, - `event_calendar_id` int(11) NOT NULL, + `event_client_id` int(11) NOT NULL DEFAULT 0, + `event_location_id` int(11) NOT NULL DEFAULT 0, + `event_calendar_id` int(11) NOT NULL DEFAULT 0, `company_id` int(11) NOT NULL, PRIMARY KEY (`event_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; @@ -450,9 +450,9 @@ CREATE TABLE `expenses` ( `expense_created_at` datetime NOT NULL DEFAULT current_timestamp(), `expense_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), `expense_archived_at` datetime DEFAULT NULL, - `expense_vendor_id` int(11) DEFAULT NULL, - `expense_client_id` int(11) DEFAULT NULL, - `expense_category_id` int(11) DEFAULT NULL, + `expense_vendor_id` int(11) NOT NULL DEFAULT 0, + `expense_client_id` int(11) NOT NULL DEFAULT 0, + `expense_category_id` int(11) NOT NULL DEFAULT 0, `expense_account_id` int(11) DEFAULT NULL, `company_id` int(11) NOT NULL, PRIMARY KEY (`expense_id`) @@ -474,7 +474,7 @@ CREATE TABLE `files` ( `file_created_at` datetime NOT NULL DEFAULT current_timestamp(), `file_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), `file_archived_at` datetime DEFAULT NULL, - `file_client_id` int(11) NOT NULL, + `file_client_id` int(11) NOT NULL DEFAULT 0, `company_id` int(11) NOT NULL, PRIMARY KEY (`file_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; @@ -490,8 +490,8 @@ DROP TABLE IF EXISTS `folders`; CREATE TABLE `folders` ( `folder_id` int(11) NOT NULL AUTO_INCREMENT, `folder_name` varchar(200) NOT NULL, - `parent_folder` int(11) DEFAULT NULL, - `folder_client_id` int(11) DEFAULT NULL, + `parent_folder` int(11) NOT NULL DEFAULT 0, + `folder_client_id` int(11) NOT NULL DEFAULT 0, `company_id` int(11) NOT NULL, PRIMARY KEY (`folder_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; @@ -509,9 +509,9 @@ CREATE TABLE `history` ( `history_status` varchar(200) NOT NULL, `history_description` varchar(200) NOT NULL, `history_created_at` datetime NOT NULL DEFAULT current_timestamp(), - `history_invoice_id` int(11) DEFAULT NULL, - `history_recurring_id` int(11) DEFAULT NULL, - `history_quote_id` int(11) DEFAULT NULL, + `history_invoice_id` int(11) NOT NULL DEFAULT 0, + `history_recurring_id` int(11) NOT NULL DEFAULT 0, + `history_quote_id` int(11) NOT NULL DEFAULT 0, `company_id` int(11) NOT NULL, PRIMARY KEY (`history_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; @@ -552,18 +552,18 @@ CREATE TABLE `invoice_items` ( `item_id` int(11) NOT NULL AUTO_INCREMENT, `item_name` varchar(200) NOT NULL, `item_description` text DEFAULT NULL, - `item_quantity` decimal(15,2) NOT NULL, - `item_price` decimal(15,2) NOT NULL, - `item_subtotal` decimal(15,2) NOT NULL, - `item_tax` decimal(15,2) DEFAULT NULL, - `item_total` decimal(15,2) NOT NULL, + `item_quantity` decimal(15,2) NOT NULL DEFAULT 0.00, + `item_price` decimal(15,2) NOT NULL DEFAULT 0.00, + `item_subtotal` decimal(15,2) NOT NULL DEFAULT 0.00, + `item_tax` decimal(15,2) NOT NULL DEFAULT 0.00, + `item_total` decimal(15,2) NOT NULL DEFAULT 0.00, `item_created_at` datetime NOT NULL DEFAULT current_timestamp(), `item_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), `item_archived_at` datetime DEFAULT NULL, - `item_tax_id` int(11) DEFAULT NULL, - `item_quote_id` int(11) DEFAULT NULL, - `item_recurring_id` int(11) DEFAULT NULL, - `item_invoice_id` int(11) DEFAULT NULL, + `item_tax_id` int(11) NOT NULL DEFAULT 0, + `item_quote_id` int(11) NOT NULL DEFAULT 0, + `item_recurring_id` int(11) NOT NULL DEFAULT 0, + `item_invoice_id` int(11) NOT NULL DEFAULT 0, `company_id` int(11) NOT NULL, PRIMARY KEY (`item_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; @@ -584,7 +584,7 @@ CREATE TABLE `invoices` ( `invoice_status` varchar(200) NOT NULL, `invoice_date` date NOT NULL, `invoice_due` date NOT NULL, - `invoice_amount` decimal(15,2) DEFAULT NULL, + `invoice_amount` decimal(15,2) NOT NULL DEFAULT 0.00, `invoice_currency_code` varchar(200) NOT NULL, `invoice_note` text DEFAULT NULL, `invoice_url_key` varchar(200) DEFAULT NULL, @@ -620,8 +620,8 @@ CREATE TABLE `locations` ( `location_created_at` datetime NOT NULL DEFAULT current_timestamp(), `location_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), `location_archived_at` datetime DEFAULT NULL, - `location_contact_id` int(11) DEFAULT NULL, - `location_client_id` int(11) DEFAULT NULL, + `location_contact_id` int(11) NOT NULL DEFAULT 0, + `location_client_id` int(11) NOT NULL DEFAULT 0, `company_id` int(11) NOT NULL, PRIMARY KEY (`location_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; @@ -647,10 +647,10 @@ CREATE TABLE `logins` ( `login_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), `login_archived_at` datetime DEFAULT NULL, `login_contact_id` int(11) NOT NULL DEFAULT 0, - `login_vendor_id` int(11) DEFAULT NULL, - `login_asset_id` int(11) DEFAULT NULL, - `login_software_id` int(11) DEFAULT NULL, - `login_client_id` int(11) DEFAULT NULL, + `login_vendor_id` int(11) NOT NULL DEFAULT 0, + `login_asset_id` int(11) NOT NULL DEFAULT 0, + `login_software_id` int(11) NOT NULL DEFAULT 0, + `login_client_id` int(11) NOT NULL DEFAULT 0, `company_id` int(11) NOT NULL, PRIMARY KEY (`login_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; @@ -671,12 +671,8 @@ CREATE TABLE `logs` ( `log_ip` varchar(200) DEFAULT NULL, `log_user_agent` varchar(250) DEFAULT NULL, `log_created_at` datetime NOT NULL DEFAULT current_timestamp(), - `log_client_id` int(11) DEFAULT NULL, - `log_invoice_id` int(11) DEFAULT NULL, - `log_quote_id` int(11) DEFAULT NULL, - `log_recurring_id` int(11) DEFAULT NULL, - `log_user_id` int(11) DEFAULT NULL, - `log_entity_id` int(11) NOT NULL DEFAULT 0, + `log_client_id` int(11) NOT NULL DEFAULT 0, + `log_user_id` int(11) NOT NULL DEFAULT 0, `company_id` int(11) DEFAULT NULL, PRIMARY KEY (`log_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; @@ -700,8 +696,8 @@ CREATE TABLE `networks` ( `network_created_at` datetime NOT NULL DEFAULT current_timestamp(), `network_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), `network_archived_at` datetime DEFAULT NULL, - `network_location_id` int(11) DEFAULT NULL, - `network_client_id` int(11) NOT NULL, + `network_location_id` int(11) NOT NULL DEFAULT 0, + `network_client_id` int(11) NOT NULL DEFAULT 0, `company_id` int(11) NOT NULL, PRIMARY KEY (`network_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; @@ -721,8 +717,8 @@ CREATE TABLE `notifications` ( `notification_timestamp` datetime NOT NULL DEFAULT current_timestamp(), `notification_dismissed_at` datetime DEFAULT NULL, `notification_dismissed_by` int(11) DEFAULT NULL, - `notification_client_id` int(11) DEFAULT NULL, - `notification_user_id` tinyint(1) DEFAULT 0, + `notification_client_id` int(11) NOT NULL DEFAULT 0, + `notification_user_id` int(11) NOT NULL DEFAULT 0, `company_id` int(11) NOT NULL, PRIMARY KEY (`notification_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; @@ -746,7 +742,7 @@ CREATE TABLE `payments` ( `payment_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), `payment_archived_at` datetime DEFAULT NULL, `payment_account_id` int(11) NOT NULL, - `payment_invoice_id` int(11) DEFAULT NULL, + `payment_invoice_id` int(11) NOT NULL DEFAULT 0, `company_id` int(11) NOT NULL, PRIMARY KEY (`payment_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; @@ -768,7 +764,7 @@ CREATE TABLE `products` ( `product_created_at` datetime NOT NULL DEFAULT current_timestamp(), `product_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), `product_archived_at` datetime DEFAULT NULL, - `product_tax_id` int(11) DEFAULT NULL, + `product_tax_id` int(11) NOT NULL DEFAULT 0, `product_category_id` int(11) NOT NULL, `company_id` int(11) NOT NULL, PRIMARY KEY (`product_id`) @@ -789,7 +785,7 @@ CREATE TABLE `quotes` ( `quote_scope` varchar(255) DEFAULT NULL, `quote_status` varchar(200) NOT NULL, `quote_date` date NOT NULL, - `quote_amount` decimal(15,2) DEFAULT NULL, + `quote_amount` decimal(15,2) NOT NULL DEFAULT 0.00, `quote_currency_code` varchar(200) NOT NULL, `quote_note` text DEFAULT NULL, `quote_url_key` varchar(200) DEFAULT NULL, @@ -841,7 +837,7 @@ CREATE TABLE `recurring` ( `recurring_last_sent` date DEFAULT NULL, `recurring_next_date` date NOT NULL, `recurring_status` int(1) NOT NULL, - `recurring_amount` decimal(15,2) DEFAULT NULL, + `recurring_amount` decimal(15,2) NOT NULL DEFAULT 0.00, `recurring_currency_code` varchar(200) NOT NULL, `recurring_note` text DEFAULT NULL, `recurring_created_at` datetime NOT NULL DEFAULT current_timestamp(), @@ -864,7 +860,7 @@ DROP TABLE IF EXISTS `revenues`; CREATE TABLE `revenues` ( `revenue_id` int(11) NOT NULL AUTO_INCREMENT, `revenue_date` date NOT NULL, - `revenue_amount` decimal(15,2) NOT NULL, + `revenue_amount` decimal(15,2) NOT NULL DEFAULT 0.00, `revenue_currency_code` varchar(200) NOT NULL, `revenue_payment_method` varchar(200) DEFAULT NULL, `revenue_reference` varchar(200) DEFAULT NULL, @@ -872,9 +868,9 @@ CREATE TABLE `revenues` ( `revenue_created_at` datetime NOT NULL DEFAULT current_timestamp(), `revenue_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), `revenue_archived_at` datetime DEFAULT NULL, - `revenue_category_id` int(11) NOT NULL, + `revenue_category_id` int(11) NOT NULL DEFAULT 0, `revenue_account_id` int(11) NOT NULL, - `revenue_client_id` int(11) DEFAULT NULL, + `revenue_client_id` int(11) NOT NULL DEFAULT 0, `company_id` int(11) NOT NULL, PRIMARY KEY (`revenue_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; @@ -898,10 +894,10 @@ CREATE TABLE `scheduled_tickets` ( `scheduled_ticket_next_run` date NOT NULL, `scheduled_ticket_created_at` datetime NOT NULL DEFAULT current_timestamp(), `scheduled_ticket_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), - `scheduled_ticket_created_by` int(11) NOT NULL, - `scheduled_ticket_client_id` int(11) DEFAULT NULL, - `scheduled_ticket_contact_id` int(11) DEFAULT NULL, - `scheduled_ticket_asset_id` int(11) DEFAULT NULL, + `scheduled_ticket_created_by` int(11) NOT NULL DEFAULT 0, + `scheduled_ticket_client_id` int(11) NOT NULL DEFAULT 0, + `scheduled_ticket_contact_id` int(11) NOT NULL DEFAULT 0, + `scheduled_ticket_asset_id` int(11) NOT NULL DEFAULT 0, `company_id` int(11) NOT NULL, PRIMARY KEY (`scheduled_ticket_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; @@ -1066,14 +1062,14 @@ CREATE TABLE `settings` ( `config_ticket_next_number` int(11) DEFAULT NULL, `config_ticket_from_name` varchar(200) DEFAULT NULL, `config_ticket_from_email` varchar(200) DEFAULT NULL, - `config_ticket_email_parse` int(1) NOT NULL DEFAULT 0, - `config_ticket_client_general_notifications` int(1) NOT NULL DEFAULT 1, - `config_enable_cron` tinyint(1) DEFAULT NULL, - `config_recurring_auto_send_invoice` tinyint(1) DEFAULT NULL, - `config_enable_alert_domain_expire` tinyint(1) DEFAULT NULL, - `config_send_invoice_reminders` tinyint(1) DEFAULT NULL, + `config_ticket_email_parse` tinyint(1) NOT NULL DEFAULT 0, + `config_ticket_client_general_notifications` tinyint(1) NOT NULL DEFAULT 1, + `config_enable_cron` tinyint(1) NOT NULL DEFAULT 0, + `config_recurring_auto_send_invoice` tinyint(1) NOT NULL DEFAULT 1, + `config_enable_alert_domain_expire` tinyint(1) NOT NULL DEFAULT 1, + `config_send_invoice_reminders` tinyint(1) NOT NULL DEFAULT 1, `config_invoice_overdue_reminders` varchar(200) DEFAULT NULL, - `config_stripe_enable` tinyint(1) DEFAULT NULL, + `config_stripe_enable` tinyint(1) NOT NULL DEFAULT 0, `config_stripe_publishable` varchar(255) DEFAULT NULL, `config_stripe_secret` varchar(255) DEFAULT NULL, `config_azure_client_id` varchar(200) DEFAULT NULL, @@ -1128,11 +1124,11 @@ CREATE TABLE `software` ( `software_purchase` date DEFAULT NULL, `software_expire` date DEFAULT NULL, `software_notes` text DEFAULT NULL, - `software_template` tinyint(1) DEFAULT 0, + `software_template` tinyint(1) NOT NULL DEFAULT 0, `software_created_at` datetime NOT NULL DEFAULT current_timestamp(), `software_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), `software_archived_at` datetime DEFAULT NULL, - `software_login_id` int(11) DEFAULT NULL, + `software_login_id` int(11) NOT NULL DEFAULT 0, `software_client_id` int(11) NOT NULL, `company_id` int(11) NOT NULL, PRIMARY KEY (`software_id`) @@ -1224,6 +1220,7 @@ CREATE TABLE `tags` ( `tag_icon` varchar(200) DEFAULT NULL, `tag_created_at` datetime NOT NULL DEFAULT current_timestamp(), `tag_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), + `tag_archived_at` datetime DEFAULT NULL, `company_id` int(11) NOT NULL, PRIMARY KEY (`tag_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; @@ -1309,12 +1306,12 @@ CREATE TABLE `tickets` ( `ticket_closed_at` datetime DEFAULT NULL, `ticket_created_by` int(11) NOT NULL, `ticket_assigned_to` int(11) NOT NULL DEFAULT 0, - `ticket_closed_by` int(11) DEFAULT NULL, - `ticket_vendor_id` int(11) DEFAULT NULL, - `ticket_client_id` int(11) DEFAULT NULL, - `ticket_contact_id` int(11) DEFAULT NULL, - `ticket_location_id` int(11) DEFAULT NULL, - `ticket_asset_id` int(11) DEFAULT NULL, + `ticket_closed_by` int(11) NOT NULL DEFAULT 0, + `ticket_vendor_id` int(11) NOT NULL DEFAULT 0, + `ticket_client_id` int(11) NOT NULL DEFAULT 0, + `ticket_contact_id` int(11) NOT NULL DEFAULT 0, + `ticket_location_id` int(11) NOT NULL DEFAULT 0, + `ticket_asset_id` int(11) NOT NULL DEFAULT 0, `company_id` int(11) NOT NULL, PRIMARY KEY (`ticket_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; @@ -1361,7 +1358,7 @@ CREATE TABLE `trips` ( `trip_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), `trip_archived_at` datetime DEFAULT NULL, `trip_user_id` int(11) NOT NULL DEFAULT 0, - `trip_client_id` int(11) DEFAULT NULL, + `trip_client_id` int(11) NOT NULL DEFAULT 0, `company_id` int(11) NOT NULL, PRIMARY KEY (`trip_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; @@ -1424,7 +1421,7 @@ CREATE TABLE `users` ( `user_name` varchar(200) NOT NULL, `user_email` varchar(200) NOT NULL, `user_password` varchar(200) NOT NULL, - `user_status` tinyint(1) DEFAULT 1, + `user_status` tinyint(1) NOT NULL DEFAULT 1, `user_token` varchar(200) DEFAULT NULL, `user_avatar` varchar(200) DEFAULT NULL, `user_specific_encryption_ciphertext` varchar(200) DEFAULT NULL, @@ -1500,11 +1497,11 @@ CREATE TABLE `vendors` ( `vendor_code` varchar(200) DEFAULT NULL, `vendor_account_number` varchar(200) DEFAULT NULL, `vendor_notes` text DEFAULT NULL, - `vendor_template` tinyint(1) DEFAULT 0, + `vendor_template` tinyint(1) NOT NULL DEFAULT 0, `vendor_created_at` datetime NOT NULL DEFAULT current_timestamp(), `vendor_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), `vendor_archived_at` datetime DEFAULT NULL, - `vendor_client_id` int(11) DEFAULT NULL, + `vendor_client_id` int(11) NOT NULL DEFAULT 0, `company_id` int(11) NOT NULL, PRIMARY KEY (`vendor_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; @@ -1519,4 +1516,4 @@ CREATE TABLE `vendors` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2023-01-22 20:00:27 +-- Dump completed on 2023-01-23 21:43:07 From da2c98a48aa685eaa6f6a14f8072f85a41d50abc Mon Sep 17 00:00:00 2001 From: johnnyq Date: Tue, 24 Jan 2023 12:59:51 -0500 Subject: [PATCH 10/31] Remove instances of unused db field log_entity was causing issues with adding and editing items including contacts --- post.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/post.php b/post.php index a06b094c..db830f35 100644 --- a/post.php +++ b/post.php @@ -4023,7 +4023,7 @@ if(isset($_POST['add_contact'])){ } //Logging - mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Contact', log_action = 'Create', log_description = '$session_name created contact $name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $contact_id, company_id = $session_company_id"); + mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Contact', log_action = 'Create', log_description = '$session_name created contact $name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, company_id = $session_company_id"); $_SESSION['alert_message'] .= "Contact added"; @@ -4138,7 +4138,7 @@ if(isset($_POST['edit_contact'])){ } //Logging - mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Contact', log_action = 'Modify', log_description = '$session_name modified contact $name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $contact_id, company_id = $session_company_id"); + mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Contact', log_action = 'Modify', log_description = '$session_name modified contact $name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, company_id = $session_company_id"); $_SESSION['alert_message'] .= "Contact updated"; @@ -4161,7 +4161,7 @@ if(isset($_GET['archive_contact'])){ mysqli_query($mysqli,"UPDATE contacts SET contact_archived_at = NOW() WHERE contact_id = $contact_id AND company_id = $session_company_id"); //logging - mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Contact', log_action = 'Archive', log_description = '$session_name archived contact $contact_name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $contact_id, company_id = $session_company_id"); + mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Contact', log_action = 'Archive', log_description = '$session_name archived contact $contact_name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, company_id = $session_company_id"); $_SESSION['alert_type'] = "error"; $_SESSION['alert_message'] = "Contact ".htmlentities($contact_name)." archived. Undo"; From bdd8f8823fb077af5c5b342b73a25ca9f33ce553 Mon Sep 17 00:00:00 2001 From: johnnyq Date: Tue, 24 Jan 2023 16:19:49 -0500 Subject: [PATCH 11/31] Added fields to contacts for billing and technical contacts --- database_updates.php | 13 ++++++++++--- database_version.php | 2 +- db.sql | 4 +++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/database_updates.php b/database_updates.php index 6c3c83f8..09ee055e 100644 --- a/database_updates.php +++ b/database_updates.php @@ -761,11 +761,18 @@ if(LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION){ mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.3.2'"); } - //if(CURRENT_DATABASE_VERSION == '0.3.2'){ - // Insert queries here required to update to DB version 0.3.3 + if(CURRENT_DATABASE_VERSION == '0.3.2'){ + mysqli_query($mysqli, "ALTER TABLE `contacts` ADD `contact_billing` TINYINT(1) DEFAULT 0 AFTER `contact_important`"); + mysqli_query($mysqli, "ALTER TABLE `contacts` ADD `contact_technical` TINYINT(1) DEFAULT 0 AFTER `contact_billing`"); + + mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.3.3'"); + } + + //if(CURRENT_DATABASE_VERSION == '0.3.3'){ + // Insert queries here required to update to DB version 0.3.4 // Then, update the database to the next sequential version - // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.3.3'"); + // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.3.4'"); //} diff --git a/database_version.php b/database_version.php index 759dcc56..e2f7de8c 100644 --- a/database_version.php +++ b/database_version.php @@ -5,4 +5,4 @@ * It is used in conjunction with database_updates.php */ -DEFINE("LATEST_DATABASE_VERSION", "0.3.2"); \ No newline at end of file +DEFINE("LATEST_DATABASE_VERSION", "0.3.3"); \ No newline at end of file diff --git a/db.sql b/db.sql index 5a02b3b4..4befe46d 100644 --- a/db.sql +++ b/db.sql @@ -344,6 +344,8 @@ CREATE TABLE `contacts` ( `contact_password_reset_token` varchar(200) DEFAULT NULL, `contact_token_expire` datetime DEFAULT NULL, `contact_important` tinyint(1) NOT NULL DEFAULT 0, + `contact_billing` tinyint(1) DEFAULT 0, + `contact_technical` tinyint(1) DEFAULT 0, `contact_created_at` datetime NOT NULL DEFAULT current_timestamp(), `contact_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), `contact_archived_at` datetime DEFAULT NULL, @@ -1516,4 +1518,4 @@ CREATE TABLE `vendors` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2023-01-23 21:43:07 +-- Dump completed on 2023-01-24 16:19:14 From a8379e331d02cfc7251ecc0ccbb8dc5bd1c0af66 Mon Sep 17 00:00:00 2001 From: johnnyq Date: Tue, 24 Jan 2023 16:35:16 -0500 Subject: [PATCH 12/31] Added Updated Date Time on Ticket Details --- ticket.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ticket.php b/ticket.php index d7eff92d..b2b8dc31 100644 --- a/ticket.php +++ b/ticket.php @@ -426,7 +426,8 @@ if (isset($_GET['ticket_id'])) {

Details

-
Created on:
+
Created:
+
Updated:
Created by:
Date: Tue, 24 Jan 2023 17:15:18 -0500 Subject: [PATCH 13/31] Updated Ticket Creation Modal to make room for upcoming multi selection of contacts, assets and involved vendors --- ticket_add_modal.php | 252 +++++++++++++++++++++++++------------------ 1 file changed, 147 insertions(+), 105 deletions(-) diff --git a/ticket_add_modal.php b/ticket_add_modal.php index 1b45ccdd..9f60c406 100644 --- a/ticket_add_modal.php +++ b/ticket_add_modal.php @@ -10,126 +10,168 @@
@@ -97,24 +96,24 @@
-
- -
- +
+ +
+
@@ -125,24 +124,24 @@
-
- -
- + + - + - - + +
@@ -153,24 +152,24 @@
-
- -
- + + + + + - - - - +
From a854baaf61f99c5559954e8d504166335930f632 Mon Sep 17 00:00:00 2001 From: johnnyq Date: Tue, 24 Jan 2023 19:27:58 -0500 Subject: [PATCH 17/31] Added Telemetry settings option --- client_contact_details.php | 12 +++++++----- database_updates.php | 12 +++++++++--- database_version.php | 2 +- db.sql | 3 ++- get_settings.php | 4 +++- post.php | 17 +++++++++++++++++ settings_side_nav.php | 8 ++++++++ settings_telemetry.php | 32 ++++++++++++++++++++++++++++++++ 8 files changed, 79 insertions(+), 11 deletions(-) create mode 100644 settings_telemetry.php diff --git a/client_contact_details.php b/client_contact_details.php index 4a6c3f48..6f8e1c00 100644 --- a/client_contact_details.php +++ b/client_contact_details.php @@ -67,9 +67,9 @@ if (isset($_GET['contact_id'])) { contact_photo"> - - - + + +

@@ -181,7 +181,7 @@ if (isset($_GET['contact_id'])) { $asset_vendor_id = $row['asset_vendor_id']; $asset_location_id = $row['asset_location_id']; $asset_network_id = $row['asset_network_id']; - + $asset_contact_id = $row['asset_contact_id']; if ($asset_type == 'Laptop') { $device_icon = "laptop"; } elseif ($asset_type == 'Desktop') { @@ -213,7 +213,8 @@ if (isset($_GET['contact_id'])) { ?> - + + @@ -360,6 +361,7 @@ if (isset($_GET['contact_id'])) { diff --git a/database_updates.php b/database_updates.php index 09ee055e..29ff09b3 100644 --- a/database_updates.php +++ b/database_updates.php @@ -768,11 +768,17 @@ if(LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION){ mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.3.3'"); } - //if(CURRENT_DATABASE_VERSION == '0.3.3'){ - // Insert queries here required to update to DB version 0.3.4 + if(CURRENT_DATABASE_VERSION == '0.3.3'){ + mysqli_query($mysqli, "ALTER TABLE `settings` ADD `config_telemetry` TINYINT(1) DEFAULT 0 AFTER `config_theme`"); + + mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.3.4'"); + } + + //if(CURRENT_DATABASE_VERSION == '0.3.4'){ + // Insert queries here required to update to DB version 0.3.5 // Then, update the database to the next sequential version - // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.3.4'"); + // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.3.5'"); //} diff --git a/database_version.php b/database_version.php index e2f7de8c..8f7c311e 100644 --- a/database_version.php +++ b/database_version.php @@ -5,4 +5,4 @@ * It is used in conjunction with database_updates.php */ -DEFINE("LATEST_DATABASE_VERSION", "0.3.3"); \ No newline at end of file +DEFINE("LATEST_DATABASE_VERSION", "0.3.4"); \ No newline at end of file diff --git a/db.sql b/db.sql index 4befe46d..9a3bae00 100644 --- a/db.sql +++ b/db.sql @@ -1080,6 +1080,7 @@ CREATE TABLE `settings` ( `config_module_enable_accounting` tinyint(1) NOT NULL DEFAULT 1, `config_module_enable_ticketing` tinyint(1) NOT NULL DEFAULT 1, `config_theme` varchar(200) DEFAULT 'blue', + `config_telemetry` tinyint(1) DEFAULT 0, PRIMARY KEY (`company_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -1518,4 +1519,4 @@ CREATE TABLE `vendors` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2023-01-24 16:19:14 +-- Dump completed on 2023-01-24 19:27:29 diff --git a/get_settings.php b/get_settings.php index 6efad592..01f2e736 100644 --- a/get_settings.php +++ b/get_settings.php @@ -79,13 +79,15 @@ $config_module_enable_ticketing = $row['config_module_enable_ticketing']; $config_module_enable_accounting = $row['config_module_enable_accounting']; // Currency - $config_currency_format = "US_en"; // Theme $config_theme = $row['config_theme']; $config_theme_mode = "dark_mode"; +// Telemetry +$config_telemetry = intval($row['config_telemetry']); + $colors_array = array( 'blue', 'green', diff --git a/post.php b/post.php index db830f35..d748353e 100644 --- a/post.php +++ b/post.php @@ -1108,6 +1108,23 @@ if(isset($_POST['edit_module_settings'])){ } +if(isset($_POST['edit_telemetry_settings'])){ + + validateAdminRole(); + + $config_telemetry = intval($_POST['config_telemetry']); + + mysqli_query($mysqli,"UPDATE settings SET config_telemetry = $config_telemetry WHERE company_id = $session_company_id"); + + // Logging + mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Settings', log_action = 'Modify', log_description = '$session_name modified telemetry settings', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id, company_id = $session_company_id"); + + $_SESSION['alert_message'] = "Telemetry settings updated"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} + if(isset($_POST['enable_2fa'])){ // CSRF Check diff --git a/settings_side_nav.php b/settings_side_nav.php index f81125ee..4f08ac35 100644 --- a/settings_side_nav.php +++ b/settings_side_nav.php @@ -152,6 +152,14 @@ + +

- + 0) { ?> + + +
From f670efa16a2299291fb6676df99b73734cf0c4d1 Mon Sep 17 00:00:00 2001 From: johnnyq Date: Tue, 24 Jan 2023 20:24:15 -0500 Subject: [PATCH 19/31] Added comments and version to Telemetry --- post.php | 4 ++++ settings_telemetry.php | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/post.php b/post.php index 03958eb0..1090ffc8 100644 --- a/post.php +++ b/post.php @@ -1130,6 +1130,7 @@ if(isset($_POST['send_telemetry_data'])){ validateAdminRole(); $config_telemetry = intval($_POST['config_telemetry']); + $comments = $_POST['comments']; mysqli_query($mysqli,"UPDATE settings SET config_telemetry = $config_telemetry WHERE company_id = $session_company_id"); @@ -1141,6 +1142,7 @@ if(isset($_POST['send_telemetry_data'])){ $state = $row['company_state']; $country = $row['company_country']; $currency = $row['company_currency']; + $current_version = exec("git rev-parse HEAD"); // Basic Telemetry if($config_telemetry == 1){ @@ -1173,11 +1175,13 @@ if(isset($_POST['send_telemetry_data'])){ $postdata = http_build_query( array( + 'version' => "$current_version", 'company_name' => "$company_name", 'city' => "$city", 'state' => "$state", 'country' => "$country", 'currency' => "$currency", + 'comments' => "$comments", 'user_count' => $user_count, 'client_count' => $client_count, 'invoice_count' => $invoice_count, diff --git a/settings_telemetry.php b/settings_telemetry.php index daa56e4b..a08b43bf 100644 --- a/settings_telemetry.php +++ b/settings_telemetry.php @@ -21,6 +21,11 @@
+
+ + +
+
0) { ?> From 1e1933798d1043caa9e65309a4055b1a21891d00 Mon Sep 17 00:00:00 2001 From: johnnyq Date: Tue, 24 Jan 2023 21:15:57 -0500 Subject: [PATCH 20/31] Added more telemetry data including if certain options are on or off to get an idea what businesses are using --- post.php | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/post.php b/post.php index 1090ffc8..d71ce67e 100644 --- a/post.php +++ b/post.php @@ -1147,6 +1147,10 @@ if(isset($_POST['send_telemetry_data'])){ // Basic Telemetry if($config_telemetry == 1){ + // Company Count + $row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('company_id') AS num FROM companies")); + $company_count = $row['num']; + // User Count $row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('user_id') AS num FROM users")); $user_count = $row['num']; @@ -1167,10 +1171,46 @@ if(isset($_POST['send_telemetry_data'])){ $row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('recurring_id') AS num FROM recurring")); $recurring_count = $row['num']; - // Tickets + // Account Count + $row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('account_id') AS num FROM accounts")); + $account_count = $row['num']; + + // Tax Count + $row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('tax_id') AS num FROM taxes")); + $tax_count = $row['num']; + + // Product Count + $row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('product_id') AS num FROM products")); + $product_count = $row['num']; + + // Ticket Count $row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('recurring_id') AS num FROM tickets")); $ticket_count = $row['num']; + // Contact Count + $row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('contact_id') AS num FROM contacts")); + $contact_count = $row['num']; + + // Company Vendor Count + $row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('vendor_id') AS num FROM vendors WHERE vendor_template = 0 AND vendor_client_id = 0")); + $company_vendor_count = $row['num']; + + // Client Vendor Count + $row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('vendor_id') AS num FROM vendors WHERE vendor_template = 0 AND vendor_client_id > 0")); + $client_vendor_count = $row['num']; + + // Vendor Template Count + $row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('vendor_id') AS num FROM vendors WHERE vendor_template = 1")); + $vendor_template_count = $row['num']; + + // Asset Count + $row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('asset_id') AS num FROM assets")); + $asset_count = $row['num']; + + // Log Count + $row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('log_id') AS num FROM logs")); + $log_count = $row['num']; + } $postdata = http_build_query( @@ -1182,12 +1222,28 @@ if(isset($_POST['send_telemetry_data'])){ 'country' => "$country", 'currency' => "$currency", 'comments' => "$comments", + 'company_count' => $company_count, 'user_count' => $user_count, 'client_count' => $client_count, 'invoice_count' => $invoice_count, 'quote_count' => $quote_count, 'recurring_count' => $recurring_count, - 'ticket_count' => $ticket_count + 'account_count' => $account_count, + 'tax_count' => $tax_count, + 'product_count' => $product_count, + 'ticket_count' => $ticket_count, + 'contact_count' => $contact_count, + 'company_vendor_count' => $company_vendor_count, + 'client_vendor_count' => $client_vendor_count, + 'vendor_template_count' => $vendor_template_count, + 'asset_count' => $asset_count, + 'log_count' => $log_count, + 'config_theme' => "$config_theme", + 'config_enable_cron' => $config_enable_cron, + 'config_ticket_email_parse' => $config_ticket_email_parse, + 'config_module_enable_itdoc' => $config_module_enable_itdoc, + 'config_module_enable_ticketing' => $config_module_enable_ticketing, + 'config_module_enable_accounting' => $config_module_enable_accounting ) ); From 27d1d2a592066ae04fbea51f1ab790459119e3f7 Mon Sep 17 00:00:00 2001 From: johnnyq Date: Wed, 25 Jan 2023 11:16:36 -0500 Subject: [PATCH 21/31] Added Software Licenses, Tickets and notes under contact details as well as fix the contact edit by moving the modal just below the edit button so it does not conflict with other tables that have the contact_id var --- ajax.php | 12 ++ client_contact_details.php | 245 ++++++++++++++++++++++++++++++++++++- client_tickets.php | 2 +- 3 files changed, 256 insertions(+), 3 deletions(-) diff --git a/ajax.php b/ajax.php index 39a88a6b..a9247a13 100644 --- a/ajax.php +++ b/ajax.php @@ -163,6 +163,18 @@ if (isset($_POST['client_set_notes'])) { } +if (isset($_POST['contact_set_notes'])) { + $contact_id = intval($_POST['contact_id']); + $notes = trim(strip_tags(mysqli_real_escape_string($mysqli, $_POST['notes']))); + + // Update notes + mysqli_query($mysqli, "UPDATE contacts SET contact_notes = '$notes' WHERE contact_id = contact_id"); + + // Logging + mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Contact', log_action = 'Modify', log_description = '$session_name modified contact notes', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id, company_id = $session_company_id"); + +} + /* * Collision Detection/Avoidance * Called upon loading a ticket, and every 2 mins thereafter diff --git a/client_contact_details.php b/client_contact_details.php index 6f8e1c00..0ff9194c 100644 --- a/client_contact_details.php +++ b/client_contact_details.php @@ -95,6 +95,17 @@ if (isset($_GET['contact_id'])) { Edit + + +
+
+ +
+
+
Notes
+
+
+
@@ -119,7 +130,6 @@ if (isset($_GET['contact_id'])) { -
">

Assets

@@ -354,17 +364,248 @@ if (isset($_GET['contact_id'])) {
+
"> +
+

Licenses

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
SoftwareTypeLicense TypeSeatsAction
$software_version"; ?> + +
+
+
+
+ + + + +
"> +
+

Tickets

+
+
+
+ + + + + + + + + + + + + + + Never

"; + } else { + $ticket_updated_at_display = "

Never

"; + } + } else { + $ticket_updated_at_display = $ticket_updated_at; + } + $ticket_closed_at = $row['ticket_closed_at']; + + if ($ticket_status == "Open") { + $ticket_status_display = "$ticket_status"; + } elseif ($ticket_status == "Working") { + $ticket_status_display = "$ticket_status"; + } else { + $ticket_status_display = "$ticket_status"; + } + + if ($ticket_priority == "High") { + $ticket_priority_display = "$ticket_priority"; + } elseif ($ticket_priority == "Medium") { + $ticket_priority_display = "$ticket_priority"; + } elseif ($ticket_priority == "Low") { + $ticket_priority_display = "$ticket_priority"; + } else { + $ticket_priority_display = "-"; + } + $ticket_assigned_to = $row['ticket_assigned_to']; + if (empty($ticket_assigned_to)) { + if ($ticket_status == "Closed") { + $ticket_assigned_to_display = "

Not Assigned

"; + } else { + $ticket_assigned_to_display = "

Not Assigned

"; + } + } else { + $ticket_assigned_to_display = htmlentities($row['user_name']); + } + $contact_id = $row['contact_id']; + $contact_name = htmlentities($row['contact_name']); + if (empty($contact_name)) { + $contact_display = "-"; + } else { + $contact_display = "$contact_name
$contact_email"; + } + $contact_title = htmlentities($row['contact_title']); + $contact_email = htmlentities($row['contact_email']); + $contact_phone = formatPhoneNumber($row['contact_phone']); + $contact_extension = htmlentities($row['contact_extension']); + $contact_mobile = formatPhoneNumber($row['contact_mobile']); + + ?> + + + + + + + + + + + + + + + + +
NumberSubjectPriorityStatusAssignedLast ResponseCreatedAction
+ + + +
+
+
+
+
+ + diff --git a/client_tickets.php b/client_tickets.php index 6b8fef45..5ef30065 100644 --- a/client_tickets.php +++ b/client_tickets.php @@ -78,7 +78,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); Subject Contact Priority - Status + Status Assigned Last Response Created From da810349f4f1a124753aeffb9c7a939b977b3191 Mon Sep 17 00:00:00 2001 From: johnnyq Date: Wed, 25 Jan 2023 12:40:25 -0500 Subject: [PATCH 22/31] Moved the toastr response from the top right to the top center --- client_contact_details.php | 26 ++++++++++---------------- clients.php | 4 ++-- inc_alert_feedback.php | 34 ++++++++++++++++++++++++++++------ inc_client_top_head.php | 2 +- 4 files changed, 41 insertions(+), 25 deletions(-) diff --git a/client_contact_details.php b/client_contact_details.php index 0ff9194c..98eb0449 100644 --- a/client_contact_details.php +++ b/client_contact_details.php @@ -4,9 +4,9 @@ if (isset($_GET['contact_id'])) { $contact_id = intval($_GET['contact_id']); $sql = mysqli_query($mysqli,"SELECT * FROM contacts - LEFT JOIN locations ON location_id = contact_location_id - WHERE contact_id = $contact_id - "); + LEFT JOIN locations ON location_id = contact_location_id + WHERE contact_id = $contact_id + "); $row = mysqli_fetch_array($sql); $contact_id = $row['contact_id']; @@ -53,7 +53,6 @@ if (isset($_GET['contact_id'])) { $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); - ?>
@@ -62,7 +61,12 @@ if (isset($_GET['contact_id'])) {
-
+

+ +
+ + +
contact_photo"> @@ -73,11 +77,7 @@ if (isset($_GET['contact_id'])) {

-

- -
- - +
@@ -267,8 +267,6 @@ if (isset($_GET['contact_id'])) {
- -
">

Passwords

@@ -363,7 +361,6 @@ if (isset($_GET['contact_id'])) {
-
">

Licenses

@@ -450,9 +447,6 @@ if (isset($_GET['contact_id'])) {
- - -
">

Tickets

diff --git a/clients.php b/clients.php index 85679ca3..7278c7eb 100644 --- a/clients.php +++ b/clients.php @@ -166,8 +166,8 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); "> Name - Address - Contact + Primary Address + Primary Contact Billing Action diff --git a/inc_alert_feedback.php b/inc_alert_feedback.php index b3a3d0b0..4b118909 100644 --- a/inc_alert_feedback.php +++ b/inc_alert_feedback.php @@ -5,20 +5,42 @@ if (!empty($_SESSION['alert_message'])) { if (!isset($_SESSION['alert_type'])) { $_SESSION['alert_type'] = "success"; } - ?> +?> - + + + \ No newline at end of file diff --git a/inc_client_top_head.php b/inc_client_top_head.php index 8f2a23bb..3f762280 100644 --- a/inc_client_top_head.php +++ b/inc_client_top_head.php @@ -42,7 +42,7 @@ $location_phone = formatPhoneNumber($location_phone); ?>
-

Contact

+

Primary Contact

From 6c5e92dd3cca3eb3104fb75c6c5fd2c165cb577b Mon Sep 17 00:00:00 2001 From: johnnyq Date: Wed, 25 Jan 2023 12:59:26 -0500 Subject: [PATCH 23/31] Only show notifications belonging to the logged in user and system notifications where notification_user_id = 0 --- check_login.php | 2 +- notifications.php | 2 +- notifications_dismissed.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/check_login.php b/check_login.php index 557ca399..4e1486a0 100644 --- a/check_login.php +++ b/check_login.php @@ -84,7 +84,7 @@ if ($iPod || $iPhone || $iPad) { } //Get Notification Count for the badge on the top nav -$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('notification_id') AS num FROM notifications WHERE notification_dismissed_at IS NULL AND company_id = $session_company_id")); +$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('notification_id') AS num FROM notifications WHERE (notification_user_id = $session_user_id OR notification_user_id = 0) AND notification_dismissed_at IS NULL AND company_id = $session_company_id")); $num_notifications = $row['num']; //Set Currency Format diff --git a/notifications.php b/notifications.php index 50ce7168..e2582827 100644 --- a/notifications.php +++ b/notifications.php @@ -2,7 +2,7 @@ diff --git a/notifications_dismissed.php b/notifications_dismissed.php index e1597d8b..c90a13e3 100644 --- a/notifications_dismissed.php +++ b/notifications_dismissed.php @@ -29,7 +29,7 @@ $url_query_strings_sb = http_build_query(array_merge($_GET,array('sb' => $sb, 'o $sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM notifications LEFT JOIN users ON notification_dismissed_by = user_id LEFT JOIN clients ON notification_client_id = client_id - WHERE (notification_type LIKE '%$q%' OR notification LIKE '%$q%' OR user_name LIKE '%$q%' OR client_name LIKE '%$q%') AND DATE(notification_timestamp) BETWEEN '$dtf' AND '$dtt' AND notifications.company_id = $session_company_id AND notification_dismissed_at IS NOT NULL ORDER BY $sb $o LIMIT $record_from, $record_to"); + WHERE (notification_type LIKE '%$q%' OR notification LIKE '%$q%' OR user_name LIKE '%$q%' OR client_name LIKE '%$q%') AND DATE(notification_timestamp) BETWEEN '$dtf' AND '$dtt' AND (notification_user_id = $session_user_id OR notification_user_id = 0) AND notifications.company_id = $session_company_id AND notification_dismissed_at IS NOT NULL ORDER BY $sb $o LIMIT $record_from, $record_to"); $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); From 037e42fb20551addb12d5cdc73a6442dfde2308c Mon Sep 17 00:00:00 2001 From: johnnyq Date: Wed, 25 Jan 2023 13:02:25 -0500 Subject: [PATCH 24/31] Cleaned up notification SQL format --- notifications_dismissed.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/notifications_dismissed.php b/notifications_dismissed.php index c90a13e3..2ceed34d 100644 --- a/notifications_dismissed.php +++ b/notifications_dismissed.php @@ -29,7 +29,14 @@ $url_query_strings_sb = http_build_query(array_merge($_GET,array('sb' => $sb, 'o $sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM notifications LEFT JOIN users ON notification_dismissed_by = user_id LEFT JOIN clients ON notification_client_id = client_id - WHERE (notification_type LIKE '%$q%' OR notification LIKE '%$q%' OR user_name LIKE '%$q%' OR client_name LIKE '%$q%') AND DATE(notification_timestamp) BETWEEN '$dtf' AND '$dtt' AND (notification_user_id = $session_user_id OR notification_user_id = 0) AND notifications.company_id = $session_company_id AND notification_dismissed_at IS NOT NULL ORDER BY $sb $o LIMIT $record_from, $record_to"); + WHERE (notification_type LIKE '%$q%' OR notification LIKE '%$q%' OR user_name LIKE '%$q%' OR client_name LIKE '%$q%') + AND DATE(notification_timestamp) BETWEEN '$dtf' AND '$dtt' + AND (notification_user_id = $session_user_id OR notification_user_id = 0) + AND notifications.company_id = $session_company_id + AND notification_dismissed_at IS NOT NULL + ORDER BY $sb $o + LIMIT $record_from, $record_to +"); $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); From 9a15f0e0b345299da080f2acc9dbf75310738c39 Mon Sep 17 00:00:00 2001 From: johnnyq Date: Wed, 25 Jan 2023 13:33:29 -0500 Subject: [PATCH 25/31] Do not always show expiring card if no items are expiring under client overview --- client_overview.php | 262 +++++++++++++++++++++++--------------------- 1 file changed, 137 insertions(+), 125 deletions(-) diff --git a/client_overview.php b/client_overview.php index a73b4ee3..ac3109f0 100644 --- a/client_overview.php +++ b/client_overview.php @@ -44,148 +44,155 @@ $sql_domains_expiring = mysqli_query($mysqli, "SELECT * FROM domains 0) { ?> -
+
-
-
-
Important Contacts
-
-
- - +
+
Important Contacts
+
+
+
+ - - + + - - - +
+ + + + -
- + ?> +
+ +
+ +
+ + $contact_phone $contact_extension"; ?> + +
- -
- - $contact_phone $contact_extension"; ?> - - -
-
- -
-
+
+
0 || mysqli_num_rows($sql_vendors) > 0) { ?> -
+
-
-
-
Recently Updated
-
-
+
+
+
Recently Updated
+
+
- -

- - -

- - +

+ + +

- 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
-
-
+
+
+
Recently Viewed
+
+
- -

- - -

- - +

+ + +

- 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_asset_warranties_expiring) > 0 + || mysqli_num_rows($sql_asset_retire) > 0 + ) { ?> +
@@ -252,42 +259,47 @@ $sql_domains_expiring = mysqli_query($mysqli, "SELECT * FROM domains
+ + 0) { ?> - + -
+
-
-
-
Stale Tickets (14d)
- - - +
+
Stale Tickets (14d)
+
+
+ +
+ + - - - - - - - + + + + + - -
-
+ + + +
+
From 16d3d4420a71db6a8167499e4bfcf2306e60e37d Mon Sep 17 00:00:00 2001 From: johnnyq Date: Wed, 25 Jan 2023 16:43:34 -0500 Subject: [PATCH 26/31] Feature: Contact Important Billing and Technical were addded Started migrating checkboxes and radio buttons to custom css to match the selected theme --- calendar_event_add_modal.php | 8 +++++--- client_add_modal.php | 10 +++++++--- client_contact_add_modal.php | 36 +++++++++++++++++++++++++++++------ client_contact_edit_modal.php | 29 ++++++++++++++++++++++++++++ client_contacts.php | 2 ++ client_edit_modal.php | 12 ++++++++---- expense_add_modal.php | 2 -- post.php | 8 ++++++-- settings_alerts.php | 24 ++++++++++++++--------- settings_modules.php | 24 ++++++++++++++--------- settings_online_payment.php | 8 +++++--- settings_theme.php | 16 +++++++++------- settings_ticket.php | 17 ++++++++++------- user_add_modal.php | 10 +++++++--- 14 files changed, 148 insertions(+), 58 deletions(-) diff --git a/calendar_event_add_modal.php b/calendar_event_add_modal.php index 47d3d9e3..eff6307a 100644 --- a/calendar_event_add_modal.php +++ b/calendar_event_add_modal.php @@ -139,9 +139,11 @@ -
- - +
+
+ + +
diff --git a/client_add_modal.php b/client_add_modal.php index fb2dcfd3..3316f81f 100644 --- a/client_add_modal.php +++ b/client_add_modal.php @@ -285,9 +285,13 @@ ?>
  • -
    - - +
    + +
  • diff --git a/client_contact_add_modal.php b/client_contact_add_modal.php index f87bedc5..b3f08d35 100644 --- a/client_contact_add_modal.php +++ b/client_contact_add_modal.php @@ -48,17 +48,12 @@
    - +
    -
    -
    - -
    -
    @@ -133,6 +128,35 @@
    +
    + +
    +
    +
    + + +
    +
    +
    +
    +
    +
    + + +
    +
    +
    +
    +
    +
    + + +
    +
    +
    + +
    +
    diff --git a/client_contact_edit_modal.php b/client_contact_edit_modal.php index bbfd7423..809df8c4 100644 --- a/client_contact_edit_modal.php +++ b/client_contact_edit_modal.php @@ -135,6 +135,35 @@
    +
    + +
    +
    +
    + > + +
    +
    +
    +
    +
    +
    + > + +
    +
    +
    +
    +
    +
    + > + +
    +
    +
    + +
    +
    diff --git a/client_contacts.php b/client_contacts.php index 68373c15..295969b4 100644 --- a/client_contacts.php +++ b/client_contacts.php @@ -127,6 +127,8 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); $contact_initials = initials($contact_name); $contact_notes = htmlentities($row['contact_notes']); $contact_important = intval($row['contact_important']); + $contact_billing = intval($row['contact_billing']); + $contact_technical = intval($row['contact_technical']); $contact_created_at = $row['contact_created_at']; if ($contact_id == $primary_contact) { $primary_contact_display = "Primary Contact"; diff --git a/client_edit_modal.php b/client_edit_modal.php index 7c09f8a7..496d8663 100644 --- a/client_edit_modal.php +++ b/client_edit_modal.php @@ -148,11 +148,15 @@ ?>
  • -
    - > - +
    + " name="tags[]" value="" > +
    -
  • + Receipt
    - -