From 0976a08730f5d8b6422e45f2b188ead4d9a2f92c Mon Sep 17 00:00:00 2001 From: johnnyq Date: Fri, 19 Nov 2021 20:45:57 -0500 Subject: [PATCH] Removed default currency and default country under settings added a company currency to the company table. Now currency default and country default uses company country and currency, updated the currency symbol to use companies currency under dashboard, expenses, profit loss reports --- add_account_modal.php | 2 +- add_client_modal.php | 4 ++-- add_revenue_modal.php | 2 +- check_login.php | 1 + companies.php | 3 ++- dashboard.php | 14 ++++++------ db.sql | 11 +++++----- edit_company_modal.php | 2 +- expenses.php | 2 +- get_settings.php | 2 -- post.php | 12 ++++------ report_profit_loss.php | 50 +++++++++++++++++++++--------------------- settings-defaults.php | 30 ------------------------- setup.php | 4 ++-- 14 files changed, 53 insertions(+), 86 deletions(-) diff --git a/add_account_modal.php b/add_account_modal.php index 1dd0e518..27fb4b2e 100644 --- a/add_account_modal.php +++ b/add_account_modal.php @@ -39,7 +39,7 @@ diff --git a/add_client_modal.php b/add_client_modal.php index 68a7f8d1..fbe4afae 100644 --- a/add_client_modal.php +++ b/add_client_modal.php @@ -130,7 +130,7 @@ @@ -234,7 +234,7 @@ diff --git a/add_revenue_modal.php b/add_revenue_modal.php index 2040bac7..ee4d6d6f 100644 --- a/add_revenue_modal.php +++ b/add_revenue_modal.php @@ -31,7 +31,7 @@ diff --git a/check_login.php b/check_login.php index 247bb1c5..351c1e18 100644 --- a/check_login.php +++ b/check_login.php @@ -45,6 +45,7 @@ $row = mysqli_fetch_array($sql); $session_company_name = $row['company_name']; + $session_company_country = $row['company_country']; $session_company_currency = $row['company_currency']; include("get_settings.php"); diff --git a/companies.php b/companies.php index 2f641e31..e445aa29 100644 --- a/companies.php +++ b/companies.php @@ -92,10 +92,11 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); $company_email = $row['company_email']; $company_website = $row['company_website']; $company_logo = $row['company_logo']; + $company_currency = $row['company_currency']; $company_initials = initials($company_name); - $company_currency_code = $row['config_default_currency']; + ?> diff --git a/dashboard.php b/dashboard.php index f855d546..959a6ff1 100644 --- a/dashboard.php +++ b/dashboard.php @@ -138,7 +138,7 @@ $vendors_added = $row['vendors_added'];
-

+

Expenses

@@ -152,7 +152,7 @@ $vendors_added = $row['vendors_added'];
-

+

Profit

@@ -166,7 +166,7 @@ $vendors_added = $row['vendors_added'];
-

+

Monthly Recurring

@@ -180,7 +180,7 @@ $vendors_added = $row['vendors_added'];
-

+

Yearly Recurring

@@ -359,7 +359,7 @@ $vendors_added = $row['vendors_added']; $balance = '0.00'; } ?> - + - + - + $currency_name) { ?> - +
diff --git a/expenses.php b/expenses.php index e7107961..5e45c396 100644 --- a/expenses.php +++ b/expenses.php @@ -181,7 +181,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
- + diff --git a/get_settings.php b/get_settings.php index 4d06eccf..99dcd81f 100644 --- a/get_settings.php +++ b/get_settings.php @@ -18,8 +18,6 @@ $config_mail_from_email = $row['config_mail_from_email']; $config_mail_from_name = $row['config_mail_from_name']; //Defaults -$config_default_country = $row['config_default_country']; -$config_default_currency = $row['config_default_currency']; $config_default_transfer_from_account = $row['config_default_transfer_from_account']; $config_default_transfer_to_account = $row['config_default_transfer_to_account']; $config_default_payment_account = $row['config_default_payment_account']; diff --git a/post.php b/post.php index fb7a67c1..77917081 100644 --- a/post.php +++ b/post.php @@ -333,7 +333,7 @@ if(isset($_POST['add_company'])){ $website = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['website']))); $currency_code = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code']))); - mysqli_query($mysqli,"INSERT INTO companies SET company_name = '$name', company_address = '$address', company_city = '$city', company_state = '$state', company_zip = '$zip', company_country = '$country', company_phone = '$phone', company_email = '$email', company_website = '$website', company_created_at = NOW()"); + mysqli_query($mysqli,"INSERT INTO companies SET company_name = '$name', company_address = '$address', company_city = '$city', company_state = '$state', company_zip = '$zip', company_country = '$country', company_phone = '$phone', company_email = '$email', company_website = '$website', company_currency = '$currency_code', company_created_at = NOW()"); $config_api_key = keygen(); $config_base_url = $_SERVER['HTTP_HOST'] . dirname($_SERVER['REQUEST_URI']); @@ -386,7 +386,7 @@ if(isset($_POST['add_company'])){ } } - mysqli_query($mysqli,"INSERT INTO settings SET company_id = $company_id, config_default_country = '$country', config_default_currency = '$currency_code', config_invoice_prefix = 'INV-', config_invoice_next_number = 1, config_recurring_prefix = 'REC-', config_recurring_next_number = 1, config_invoice_overdue_reminders = '1,3,7', config_quote_prefix = 'QUO-', config_quote_next_number = 1, config_api_key = '$config_api_key', config_recurring_auto_send_invoice = 1, config_default_net_terms = 7, config_send_invoice_reminders = 0, config_enable_cron = 0, config_ticket_next_number = 1, config_base_url = '$config_base_url'"); + mysqli_query($mysqli,"INSERT INTO settings SET company_id = $company_id, config_invoice_prefix = 'INV-', config_invoice_next_number = 1, config_recurring_prefix = 'REC-', config_recurring_next_number = 1, config_invoice_overdue_reminders = '1,3,7', config_quote_prefix = 'QUO-', config_quote_next_number = 1, config_api_key = '$config_api_key', config_recurring_auto_send_invoice = 1, config_default_net_terms = 7, config_send_invoice_reminders = 0, config_enable_cron = 0, config_ticket_next_number = 1, config_base_url = '$config_base_url'"); //logging mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Company', log_action = 'Create', log_description = '$name', log_created_at = NOW()"); @@ -461,9 +461,7 @@ if(isset($_POST['edit_company'])){ } } - mysqli_query($mysqli,"UPDATE companies SET company_name = '$name', company_address = '$address', company_city = '$city', company_state = '$state', company_zip = '$zip', company_country = '$country', company_phone = '$phone', company_email = '$email', company_website = '$website', company_updated_at = NOW() WHERE company_id = $company_id"); - - mysqli_query($mysqli,"UPDATE settings SET config_default_currency = '$currency_code', config_default_country = '$country' WHERE company_id = $company_id"); + mysqli_query($mysqli,"UPDATE companies SET company_name = '$name', company_address = '$address', company_city = '$city', company_state = '$state', company_zip = '$zip', company_country = '$country', company_phone = '$phone', company_email = '$email', company_website = '$website', company_currency = '$currency_code', company_updated_at = NOW() WHERE company_id = $company_id"); //logging mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Company', log_action = 'Modified', log_description = '$name', log_created_at = NOW()"); @@ -688,8 +686,6 @@ if(isset($_POST['edit_ticket_settings'])){ if(isset($_POST['edit_default_settings'])){ - $country = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['country']))); - $currency_code = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code']))); $expense_account = intval($_POST['expense_account']); $payment_account = intval($_POST['payment_account']); $payment_method = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['payment_method']))); @@ -699,7 +695,7 @@ if(isset($_POST['edit_default_settings'])){ $calendar = intval($_POST['calendar']); $net_terms = intval($_POST['net_terms']); - mysqli_query($mysqli,"UPDATE settings SET config_default_country = '$country', config_default_currency = '$currency_code', config_default_expense_account = $expense_account, config_default_payment_account = $payment_account, config_default_payment_method = '$payment_method', config_default_expense_payment_method = '$expense_payment_method', config_default_transfer_from_account = $transfer_from_account, config_default_transfer_to_account = $transfer_to_account, config_default_calendar = $calendar, config_default_net_terms = $net_terms WHERE company_id = $session_company_id"); + mysqli_query($mysqli,"UPDATE settings SET config_default_expense_account = $expense_account, config_default_payment_account = $payment_account, config_default_payment_method = '$payment_method', config_default_expense_payment_method = '$expense_payment_method', config_default_transfer_from_account = $transfer_from_account, config_default_transfer_to_account = $transfer_to_account, config_default_calendar = $calendar, config_default_net_terms = $net_terms WHERE company_id = $session_company_id"); //Logging mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Settings', log_action = 'Modified', log_description = 'Defaults', log_created_at = NOW(), company_id = $session_company_id, log_user_id = $session_user_id"); diff --git a/report_profit_loss.php b/report_profit_loss.php index 8dac2311..e0eea3fc 100644 --- a/report_profit_loss.php +++ b/report_profit_loss.php @@ -87,7 +87,7 @@ $sql_categories_expense = mysqli_query($mysqli,"SELECT * FROM categories WHERE c ?> - $ + - $ + - $ + - $ + - $ + - $ + - $ + - $ + - $ + - $ + @@ -286,7 +286,7 @@ $sql_categories_expense = mysqli_query($mysqli,"SELECT * FROM categories WHERE c ?> - $ + - $ + - $ + - $ + - $ + - $ + - $ + - $ + - $ + - $ + Net Profit - $ - $ - $ - $ - $ + + + + + diff --git a/settings-defaults.php b/settings-defaults.php index ba711f06..fb400dd4 100644 --- a/settings-defaults.php +++ b/settings-defaults.php @@ -8,36 +8,6 @@
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
diff --git a/setup.php b/setup.php index f03b4bc6..5f58d9fc 100644 --- a/setup.php +++ b/setup.php @@ -465,7 +465,7 @@ if(isset($_POST['add_company_settings'])){ $website = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['website']))); $currency_code = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code']))); - mysqli_query($mysqli,"INSERT INTO companies SET company_name = '$name', company_address = '$address', company_city = '$city', company_state = '$state', company_zip = '$zip', company_country = '$country', company_phone = '$phone', company_email = '$email', company_website = '$website', company_logo = '$path', company_created_at = NOW()"); + mysqli_query($mysqli,"INSERT INTO companies SET company_name = '$name', company_address = '$address', company_city = '$city', company_state = '$state', company_zip = '$zip', company_country = '$country', company_phone = '$phone', company_email = '$email', company_website = '$website', company_logo = '$path', company_currency = '$currency_code', company_created_at = NOW()"); $company_id = mysqli_insert_id($mysqli); $config_api_key = keygen(); @@ -521,7 +521,7 @@ if(isset($_POST['add_company_settings'])){ //Create Permissions mysqli_query($mysqli,"INSERT INTO permissions SET permission_level = 5, permission_default_company = $company_id, permission_companies = $company_id, user_id = $user_id"); - mysqli_query($mysqli,"INSERT INTO settings SET company_id = $company_id, config_default_country = '$country', config_default_currency = '$currency_code', config_invoice_prefix = 'INV-', config_invoice_next_number = 1, config_recurring_prefix = 'REC-', config_recurring_next_number = 1, config_invoice_overdue_reminders = '1,3,7', config_quote_prefix = 'QUO-', config_quote_next_number = 1, config_api_key = '$config_api_key', config_recurring_auto_send_invoice = 1, config_default_net_terms = 7, config_send_invoice_reminders = 0, config_enable_cron = 0, config_ticket_next_number = 1, config_base_url = '$config_base_url'"); + mysqli_query($mysqli,"INSERT INTO settings SET company_id = $company_id, config_invoice_prefix = 'INV-', config_invoice_next_number = 1, config_recurring_prefix = 'REC-', config_recurring_next_number = 1, config_invoice_overdue_reminders = '1,3,7', config_quote_prefix = 'QUO-', config_quote_next_number = 1, config_api_key = '$config_api_key', config_recurring_auto_send_invoice = 1, config_default_net_terms = 7, config_send_invoice_reminders = 0, config_enable_cron = 0, config_ticket_next_number = 1, config_base_url = '$config_base_url'"); //Create Some Data