From 6f46f2ec879c839d8bf7878f4f1022096bfc2e60 Mon Sep 17 00:00:00 2001 From: "johnny@pittpc.com" Date: Sun, 14 Feb 2021 18:06:32 -0500 Subject: [PATCH] More Currency Code Updates, would like to do conversions and add currency icons at a later date also set default country so it doesnt have to be selected each time --- add_account_modal.php | 15 ++++++++ add_client_modal.php | 17 ++++++++- add_company_modal.php | 15 ++++++++ add_invoice_modal.php | 15 ++++++++ add_location_modal.php | 2 +- add_payment_modal.php | 1 + add_quote_modal.php | 15 ++++++++ add_recurring_modal.php | 20 +++++++++-- add_vendor_modal.php | 2 +- client.php | 1 + client_invoices.php | 1 + client_quotes.php | 1 + client_recurring.php | 1 + clients.php | 1 + companies.php | 7 ++-- cron.php | 3 +- db.sql | 22 +++++++----- edit_client_modal.php | 15 ++++++++ edit_company_modal.php | 15 ++++++++ edit_invoice_modal.php | 15 ++++++++ edit_quote_modal.php | 15 ++++++++ edit_recurring_modal.php | 15 ++++++++ get_settings.php | 9 +++++ guest_view_invoice.php | 1 + invoice.php | 2 ++ invoices.php | 2 ++ post.php | 74 +++++++++++++++++++++++++--------------- quote.php | 2 ++ quotes.php | 2 ++ recurring.php | 2 ++ recurring_invoice.php | 2 ++ settings-defaults.php | 46 ++++++++++++++++++++----- setup.php | 27 +++++++++++++-- 33 files changed, 328 insertions(+), 55 deletions(-) diff --git a/add_account_modal.php b/add_account_modal.php index 0c2836f9..1ec87d93 100644 --- a/add_account_modal.php +++ b/add_account_modal.php @@ -30,6 +30,21 @@ +
+ +
+
+ +
+ +
+
+
diff --git a/add_client_modal.php b/add_client_modal.php index 1a78eab6..09c3c831 100644 --- a/add_client_modal.php +++ b/add_client_modal.php @@ -77,6 +77,21 @@
+
+ +
+
+ +
+ +
+
+
@@ -149,7 +164,7 @@
diff --git a/add_company_modal.php b/add_company_modal.php index 8d40cdca..f4f66da3 100644 --- a/add_company_modal.php +++ b/add_company_modal.php @@ -110,6 +110,21 @@
+
+ +
+
+ +
+ +
+
+
diff --git a/add_invoice_modal.php b/add_invoice_modal.php index b1a9e2ed..76b5d980 100644 --- a/add_invoice_modal.php +++ b/add_invoice_modal.php @@ -77,6 +77,21 @@
+
+ +
+
+ +
+ +
+
+
diff --git a/add_location_modal.php b/add_location_modal.php index 98afbaa9..6b321f46 100644 --- a/add_location_modal.php +++ b/add_location_modal.php @@ -144,7 +144,7 @@
diff --git a/add_payment_modal.php b/add_payment_modal.php index caa2776d..aac9b472 100644 --- a/add_payment_modal.php +++ b/add_payment_modal.php @@ -10,6 +10,7 @@
+ +
+ +
+
+ +
+ +
+
+
diff --git a/add_recurring_modal.php b/add_recurring_modal.php index 3daf2eb3..e868439a 100644 --- a/add_recurring_modal.php +++ b/add_recurring_modal.php @@ -64,10 +64,9 @@
- - +
- +
@@ -93,6 +92,21 @@
+
+ +
+
+ +
+ +
+
+
diff --git a/add_vendor_modal.php b/add_vendor_modal.php index d66540e1..0de0fd35 100644 --- a/add_vendor_modal.php +++ b/add_vendor_modal.php @@ -122,7 +122,7 @@
diff --git a/client.php b/client.php index 6fd2e5ee..0b6353fb 100644 --- a/client.php +++ b/client.php @@ -34,6 +34,7 @@ if(isset($_GET['client_id'])){ } $client_website = $row['client_website']; $client_referral = $row['client_referral']; + $client_currency_code = $row['client_currency_code']; $client_net_terms = $row['client_net_terms']; if($client_net_terms == 0){ $client_net_terms = $config_default_net_terms; diff --git a/client_invoices.php b/client_invoices.php index f97da587..8b75b2ea 100644 --- a/client_invoices.php +++ b/client_invoices.php @@ -94,6 +94,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); $invoice_date = $row['invoice_date']; $invoice_due = $row['invoice_due']; $invoice_amount = $row['invoice_amount']; + $invoice_currency_code = $row['invoice_currency_code']; $invoice_created_at = $row['invoice_created_at']; $category_id = $row['category_id']; $category_name = $row['category_name']; diff --git a/client_quotes.php b/client_quotes.php index 445a55e6..ec72425d 100644 --- a/client_quotes.php +++ b/client_quotes.php @@ -92,6 +92,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); $quote_status = $row['quote_status']; $quote_date = $row['quote_date']; $quote_amount = $row['quote_amount']; + $quote_currency_code = $row['quote_currency_code']; $quote_created_at = $row['quote_created_at']; $category_id = $row['category_id']; $category_name = $row['category_name']; diff --git a/client_recurring.php b/client_recurring.php index 07d644c9..d9b70437 100644 --- a/client_recurring.php +++ b/client_recurring.php @@ -99,6 +99,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); } $recurring_next_date = $row['recurring_next_date']; $recurring_amount = $row['recurring_amount']; + $recurring_currency_code = $row['recurring_currency_code']; $recurring_created_at = $row['recurring_created_at']; $category_id = $row['category_id']; $category_name = $row['category_name']; diff --git a/clients.php b/clients.php index 7d8e88ff..aca65042 100644 --- a/clients.php +++ b/clients.php @@ -144,6 +144,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); } $client_email = $row['client_email']; $client_website = $row['client_website']; + $client_currency_code = $row['client_currency_code']; $client_net_terms = $row['client_net_terms']; $client_referral = $row['client_referral']; $client_notes = $row['client_notes']; diff --git a/companies.php b/companies.php index bc52d959..cf1f3596 100644 --- a/companies.php +++ b/companies.php @@ -39,8 +39,9 @@ if(isset($_GET['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 companies - WHERE company_name LIKE '%$q%' +$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM companies, settings + WHERE companies.company_id = settings.company_id + AND (company_name LIKE '%$q%') ORDER BY $sb $o LIMIT $record_from, $record_to"); $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); @@ -96,6 +97,8 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); $company_logo = $row['company_logo']; $company_initials = initials($company_name); + + $company_currency_code = $row['config_default_currency']; ?> diff --git a/cron.php b/cron.php index 0f729290..71167b2d 100644 --- a/cron.php +++ b/cron.php @@ -179,6 +179,7 @@ while($row = mysqli_fetch_array($sql_companies)){ $recurring_last_sent = $row['recurring_last_sent']; $recurring_next_date = $row['recurring_next_date']; $recurring_amount = $row['recurring_amount']; + $recurring_currency_code = $row['recurring_currency_code']; $recurring_note = mysqli_real_escape_string($mysqli,$row['recurring_note']); //Escape SQL $category_id = $row['category_id']; $client_id = $row['client_id']; @@ -197,7 +198,7 @@ while($row = mysqli_fetch_array($sql_companies)){ //Generate a unique URL key for clients to access $url_key = keygen(); - mysqli_query($mysqli,"INSERT INTO invoices SET invoice_prefix = '$config_invoice_prefix', invoice_number = $new_invoice_number, invoice_scope = '$recurring_scope', invoice_date = CURDATE(), invoice_due = DATE_ADD(CURDATE(), INTERVAL $client_net_terms day), invoice_amount = '$recurring_amount', invoice_note = '$recurring_note', category_id = $category_id, invoice_status = 'Sent', invoice_url_key = '$url_key', invoice_created_at = NOW(), client_id = $client_id, company_id = $company_id"); + mysqli_query($mysqli,"INSERT INTO invoices SET invoice_prefix = '$config_invoice_prefix', invoice_number = $new_invoice_number, invoice_scope = '$recurring_scope', invoice_date = CURDATE(), invoice_due = DATE_ADD(CURDATE(), INTERVAL $client_net_terms day), invoice_amount = '$recurring_amount', invoice_currency_code = 'recurring_currency_code', invoice_note = '$recurring_note', category_id = $category_id, invoice_status = 'Sent', invoice_url_key = '$url_key', invoice_created_at = NOW(), client_id = $client_id, company_id = $company_id"); $new_invoice_id = mysqli_insert_id($mysqli); diff --git a/db.sql b/db.sql index 0e9d697c..dc7b9482 100644 --- a/db.sql +++ b/db.sql @@ -26,6 +26,7 @@ CREATE TABLE `accounts` ( `account_id` int(11) NOT NULL AUTO_INCREMENT, `account_name` varchar(200) NOT NULL, `opening_balance` decimal(15,2) NOT NULL DEFAULT 0.00, + `account_curency_code` varchar(200) DEFAULT NULL, `account_notes` text DEFAULT NULL, `account_created_at` datetime NOT NULL, `account_updated_at` datetime DEFAULT NULL, @@ -69,7 +70,7 @@ CREATE TABLE `assets` ( `asset_serial` varchar(200) DEFAULT NULL, `asset_os` varchar(200) DEFAULT NULL, `asset_ip` varchar(20) DEFAULT NULL, - `asset_mac` varchar(200) DEFAULT NULL, + `asset_mac` varchar(17) DEFAULT NULL, `asset_purchase_date` date DEFAULT NULL, `asset_warranty_expire` date DEFAULT NULL, `asset_reciept` varchar(200) DEFAULT NULL, @@ -173,6 +174,7 @@ CREATE TABLE `clients` ( `client_email` varchar(200) DEFAULT NULL, `client_website` varchar(200) DEFAULT NULL, `client_referral` varchar(200) DEFAULT NULL, + `client_currency_code` varchar(200) DEFAULT NULL, `client_net_terms` int(10) NOT NULL, `client_notes` text DEFAULT NULL, `client_created_at` datetime NOT NULL, @@ -314,8 +316,8 @@ DROP TABLE IF EXISTS `expenses`; CREATE TABLE `expenses` ( `expense_id` int(11) NOT NULL AUTO_INCREMENT, `expense_description` text DEFAULT NULL, - `expense_currency` varchar(200) DEFAULT NULL, `expense_amount` decimal(15,2) NOT NULL, + `expense_currency_code` varchar(200) DEFAULT NULL, `expense_date` date NOT NULL, `expense_reference` varchar(200) DEFAULT NULL, `expense_payment_method` varchar(200) DEFAULT NULL, @@ -419,8 +421,8 @@ CREATE TABLE `invoices` ( `invoice_status` varchar(200) NOT NULL, `invoice_date` date NOT NULL, `invoice_due` date NOT NULL, - `invoice_currency` varchar(200) DEFAULT NULL, `invoice_amount` decimal(15,2) DEFAULT NULL, + `invoice_currency_code` varchar(200) DEFAULT NULL, `invoice_note` text DEFAULT NULL, `invoice_url_key` varchar(200) DEFAULT NULL, `invoice_created_at` datetime NOT NULL, @@ -549,8 +551,8 @@ DROP TABLE IF EXISTS `payments`; CREATE TABLE `payments` ( `payment_id` int(11) NOT NULL AUTO_INCREMENT, `payment_date` date NOT NULL, - `payment_currency` varchar(200) DEFAULT NULL, `payment_amount` decimal(15,2) NOT NULL, + `payment_currency_code` varchar(10) DEFAULT NULL, `payment_method` varchar(200) DEFAULT NULL, `payment_reference` varchar(200) DEFAULT NULL, `payment_created_at` datetime NOT NULL, @@ -593,8 +595,8 @@ CREATE TABLE `products` ( `product_id` int(11) NOT NULL AUTO_INCREMENT, `product_name` varchar(200) NOT NULL, `product_description` text DEFAULT NULL, - `product_currency` varchar(200) DEFAULT NULL, `product_cost` decimal(15,2) NOT NULL, + `product_currency_code` varchar(200) DEFAULT NULL, `product_created_at` datetime NOT NULL, `product_updated_at` datetime DEFAULT NULL, `product_archived_at` datetime DEFAULT NULL, @@ -619,8 +621,8 @@ CREATE TABLE `quotes` ( `quote_scope` varchar(255) DEFAULT NULL, `quote_status` varchar(200) NOT NULL, `quote_date` date NOT NULL, - `quote_currency` varchar(200) DEFAULT NULL, `quote_amount` decimal(15,2) DEFAULT NULL, + `quote_currency_code` varchar(200) DEFAULT NULL, `quote_note` text DEFAULT NULL, `quote_url_key` varchar(200) DEFAULT NULL, `quote_created_at` datetime NOT NULL, @@ -671,8 +673,8 @@ CREATE TABLE `recurring` ( `recurring_last_sent` date DEFAULT NULL, `recurring_next_date` date NOT NULL, `recurring_status` int(1) NOT NULL, - `recurring_currency` varchar(200) DEFAULT NULL, `recurring_amount` decimal(15,2) DEFAULT NULL, + `recurring_currency_code` varchar(200) DEFAULT NULL, `recurring_note` text DEFAULT NULL, `recurring_created_at` datetime NOT NULL, `recurring_updated_at` datetime DEFAULT NULL, @@ -694,8 +696,8 @@ DROP TABLE IF EXISTS `revenues`; CREATE TABLE `revenues` ( `revenue_id` int(11) NOT NULL AUTO_INCREMENT, `revenue_date` date NOT NULL, - `revenue_currency` varchar(200) NOT NULL, `revenue_amount` decimal(15,2) NOT NULL, + `revenue_currency_code` varchar(200) DEFAULT NULL, `revenue_payment_method` varchar(200) DEFAULT NULL, `revenue_reference` varchar(200) DEFAULT NULL, `revenue_description` varchar(200) DEFAULT NULL, @@ -728,6 +730,8 @@ CREATE TABLE `settings` ( `config_smtp_password` varchar(200) DEFAULT NULL, `config_mail_from_email` varchar(200) DEFAULT NULL, `config_mail_from_name` varchar(200) DEFAULT NULL, + `config_default_country` varchar(200) DEFAULT NULL, + `config_default_currency` varchar(200) NOT NULL, `config_default_transfer_from_account` int(11) DEFAULT NULL, `config_default_transfer_to_account` int(11) DEFAULT NULL, `config_default_payment_account` int(11) DEFAULT NULL, @@ -976,4 +980,4 @@ CREATE TABLE `vendors` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-02-11 1:03:59 +-- Dump completed on 2021-02-14 18:04:43 diff --git a/edit_client_modal.php b/edit_client_modal.php index b32a63c1..a57c5278 100644 --- a/edit_client_modal.php +++ b/edit_client_modal.php @@ -78,6 +78,21 @@
+
+ +
+
+ +
+ +
+
+
diff --git a/edit_company_modal.php b/edit_company_modal.php index c06bc239..4e4bb324 100644 --- a/edit_company_modal.php +++ b/edit_company_modal.php @@ -112,6 +112,21 @@
+
+ +
+
+ +
+ +
+
+
diff --git a/edit_invoice_modal.php b/edit_invoice_modal.php index c1091fa0..00986277 100644 --- a/edit_invoice_modal.php +++ b/edit_invoice_modal.php @@ -59,6 +59,21 @@
+
+ +
+
+ +
+ +
+
+
diff --git a/edit_quote_modal.php b/edit_quote_modal.php index a26cc9dc..ab2eb30c 100644 --- a/edit_quote_modal.php +++ b/edit_quote_modal.php @@ -59,6 +59,21 @@
+
+ +
+
+ +
+ +
+
+
diff --git a/edit_recurring_modal.php b/edit_recurring_modal.php index b4507508..be00c1fd 100644 --- a/edit_recurring_modal.php +++ b/edit_recurring_modal.php @@ -52,6 +52,21 @@
+ + +
+ +
+
+ +
+ +
diff --git a/get_settings.php b/get_settings.php index c9d4f818..a796949b 100644 --- a/get_settings.php +++ b/get_settings.php @@ -18,6 +18,8 @@ $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']; @@ -157,6 +159,13 @@ $timezones_array = array( 'US/Pacific' ); +$currencies_array = array( + 'USD'=>'US Dollars', + 'EUR'=>'Euro', + 'GBP'=>'British Pounds', + 'TRY'=>'Turkish Lira' +); + $category_types_array = array( 'Expense', 'Income', diff --git a/guest_view_invoice.php b/guest_view_invoice.php index e2f7b973..4e31007d 100644 --- a/guest_view_invoice.php +++ b/guest_view_invoice.php @@ -25,6 +25,7 @@ if(isset($_GET['invoice_id'], $_GET['url_key'])){ $invoice_date = $row['invoice_date']; $invoice_due = $row['invoice_due']; $invoice_amount = $row['invoice_amount']; + $invoice_currency_code = $row['invoice_currency_code']; $invoice_note = $row['invoice_note']; $invoice_category_id = $row['category_id']; $client_id = $row['client_id']; diff --git a/invoice.php b/invoice.php index 573d9eb1..601b3412 100644 --- a/invoice.php +++ b/invoice.php @@ -25,6 +25,7 @@ if(isset($_GET['invoice_id'])){ $invoice_date = $row['invoice_date']; $invoice_due = $row['invoice_due']; $invoice_amount = $row['invoice_amount']; + $invoice_currency_code = $row['invoice_currency_code']; $invoice_note = $row['invoice_note']; $invoice_url_key = $row['invoice_url_key']; $invoice_created_at = $row['invoice_created_at']; @@ -46,6 +47,7 @@ if(isset($_GET['invoice_id'])){ $client_mobile = substr($row['client_mobile'],0,3)."-".substr($row['client_mobile'],3,3)."-".substr($row['client_mobile'],6,4); } $client_website = $row['client_website']; + $client_currency_code = $row['client_currency_code']; $client_net_terms = $row['client_net_terms']; if($client_net_terms == 0){ $client_net_terms = $config_default_net_terms; diff --git a/invoices.php b/invoices.php index 63715ab9..0ab4a791 100644 --- a/invoices.php +++ b/invoices.php @@ -236,11 +236,13 @@ $invoice_date = $row['invoice_date']; $invoice_due = $row['invoice_due']; $invoice_amount = $row['invoice_amount']; + $invoice_currency_code = $row['invoice_currency_code']; $invoice_created_at = $row['invoice_created_at']; $client_id = $row['client_id']; $client_name = $row['client_name']; $category_id = $row['category_id']; $category_name = $row['category_name']; + $client_currency_code = $row['client_currency_code']; $client_net_terms = $row['client_net_terms']; if($client_net_terms == 0){ $client_net_terms = $config_default_net_terms; diff --git a/post.php b/post.php index 3417b95a..4a0722f8 100644 --- a/post.php +++ b/post.php @@ -225,6 +225,7 @@ if(isset($_POST['add_company'])){ $phone = preg_replace("/[^0-9]/", '',$_POST['phone']); $email = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['email']))); $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()"); @@ -247,7 +248,7 @@ if(isset($_POST['add_company'])){ } - 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'"); + 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'"); //logging mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Company', log_action = 'Create', log_description = '$name', log_created_at = NOW()"); @@ -269,6 +270,7 @@ if(isset($_POST['edit_company'])){ $phone = preg_replace("/[^0-9]/", '',$_POST['phone']); $email = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['email']))); $website = strip_tags(mysqli_real_escape_string($mysqli,$_POST['website'])); + $currency_code = strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code'])); $path = strip_tags(mysqli_real_escape_string($mysqli,$_POST['current_file_path'])); @@ -285,6 +287,8 @@ 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_logo = '$path', 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"); + //logging mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Company', log_action = 'Modified', log_description = '$name', log_created_at = NOW()"); @@ -472,16 +476,18 @@ if(isset($_POST['edit_ticket_settings'])){ if(isset($_POST['edit_default_settings'])){ - $config_default_expense_account = intval($_POST['config_default_expense_account']); - $config_default_payment_account = intval($_POST['config_default_payment_account']); - $config_default_payment_method = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_default_payment_method'])); - $config_default_expense_payment_method = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_default_expense_payment_method'])); - $config_default_transfer_from_account = intval($_POST['config_default_transfer_from_account']); - $config_default_transfer_to_account = intval($_POST['config_default_transfer_to_account']); - $config_default_calendar = intval($_POST['config_default_calendar']); - $config_default_net_terms = intval($_POST['config_default_net_terms']); + $country = strip_tags(mysqli_real_escape_string($mysqli,$_POST['country'])); + $currency_code = strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code'])); + $expense_account = intval($_POST['expense_account']); + $payment_account = intval($_POST['payment_account']); + $payment_method = strip_tags(mysqli_real_escape_string($mysqli,$_POST['payment_method'])); + $expense_payment_method = strip_tags(mysqli_real_escape_string($mysqli,$_POST['expense_payment_method'])); + $transfer_from_account = intval($_POST['transfer_from_account']); + $transfer_to_account = intval($_POST['transfer_to_account']); + $calendar = intval($_POST['calendar']); + $net_terms = intval($_POST['net_terms']); - mysqli_query($mysqli,"UPDATE settings SET config_default_expense_account = $config_default_expense_account, config_default_payment_account = $config_default_payment_account, config_default_payment_method = '$config_default_payment_method', config_default_expense_payment_method = '$config_default_expense_payment_method', config_default_transfer_from_account = $config_default_transfer_from_account, config_default_transfer_to_account = $config_default_transfer_to_account, config_default_calendar = $config_default_calendar, config_default_net_terms = $config_default_net_terms WHERE company_id = $session_company_id"); + 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"); //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, user_id = $session_user_id"); @@ -648,10 +654,11 @@ if(isset($_POST['add_client'])){ $email = strip_tags(mysqli_real_escape_string($mysqli,$_POST['email'])); $website = strip_tags(mysqli_real_escape_string($mysqli,$_POST['website'])); $referral = strip_tags(mysqli_real_escape_string($mysqli,$_POST['referral'])); + $currency_code = strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code'])); $net_terms = intval($_POST['net_terms']); $notes = strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes'])); - mysqli_query($mysqli,"INSERT INTO clients SET client_name = '$name', client_type = '$type', client_country = '$country', client_address = '$address', client_city = '$city', client_state = '$state', client_zip = '$zip', client_contact = '$contact', client_phone = '$phone', client_extension = '$extension', client_mobile = '$mobile', client_email = '$email', client_website = '$website', client_referral = '$referral', client_net_terms = $net_terms, client_notes = '$notes', client_created_at = NOW(), company_id = $session_company_id"); + mysqli_query($mysqli,"INSERT INTO clients SET client_name = '$name', client_type = '$type', client_country = '$country', client_address = '$address', client_city = '$city', client_state = '$state', client_zip = '$zip', client_contact = '$contact', client_phone = '$phone', client_extension = '$extension', client_mobile = '$mobile', client_email = '$email', client_website = '$website', client_referral = '$referral', client_currency_code = '$currency_code', client_net_terms = $net_terms, client_notes = '$notes', client_created_at = NOW(), company_id = $session_company_id"); $client_id = mysqli_insert_id($mysqli); @@ -685,10 +692,11 @@ if(isset($_POST['edit_client'])){ $email = strip_tags(mysqli_real_escape_string($mysqli,$_POST['email'])); $website = strip_tags(mysqli_real_escape_string($mysqli,$_POST['website'])); $referral = strip_tags(mysqli_real_escape_string($mysqli,$_POST['referral'])); + $currency_code = strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code'])); $net_terms = intval($_POST['net_terms']); $notes = strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes'])); - mysqli_query($mysqli,"UPDATE clients SET client_name = '$name', client_type = '$type', client_country = '$country', client_address = '$address', client_city = '$city', client_state = '$state', client_zip = '$zip', client_contact = '$contact', client_phone = '$phone', client_extension = '$extension', client_mobile = '$mobile', client_email = '$email', client_website = '$website', client_referral = '$referral', client_net_terms = $net_terms, client_notes = '$notes', client_updated_at = NOW() WHERE client_id = $client_id AND company_id = $session_company_id"); + mysqli_query($mysqli,"UPDATE clients SET client_name = '$name', client_type = '$type', client_country = '$country', client_address = '$address', client_city = '$city', client_state = '$state', client_zip = '$zip', client_contact = '$contact', client_phone = '$phone', client_extension = '$extension', client_mobile = '$mobile', client_email = '$email', client_website = '$website', client_referral = '$referral', client_currency_code = '$currency_code', client_net_terms = $net_terms, client_notes = '$notes', client_updated_at = NOW() WHERE client_id = $client_id AND company_id = $session_company_id"); //Logging mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Client', log_action = 'Modified', log_description = '$name', log_created_at = NOW(), client_id = $client_id, company_id = $session_company_id, user_id = $session_user_id"); @@ -1078,7 +1086,7 @@ if(isset($_POST['add_product'])){ $category = intval($_POST['category']); $tax = intval($_POST['tax']); - mysqli_query($mysqli,"INSERT INTO products SET product_name = '$name', product_description = '$description', product_cost = '$cost', product_created_at = NOW(), tax_id = $tax, category_id = $category, company_id = $session_company_id"); + mysqli_query($mysqli,"INSERT INTO products SET product_name = '$name', product_description = '$description', product_cost = '$cost', product_currency_code = '$config_default_currency', product_created_at = NOW(), tax_id = $tax, category_id = $category, company_id = $session_company_id"); //Logging mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Product', log_action = 'Created', log_description = '$name', log_created_at = NOW(), company_id = $session_company_id, user_id = $session_user_id"); @@ -1184,9 +1192,10 @@ if(isset($_POST['add_account'])){ $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); $opening_balance = floatval($_POST['opening_balance']); + $currency_code = strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code'])); $notes = strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes'])); - mysqli_query($mysqli,"INSERT INTO accounts SET account_name = '$name', opening_balance = '$opening_balance', account_notes = '$account_notes', account_created_at = NOW(), company_id = $session_company_id"); + mysqli_query($mysqli,"INSERT INTO accounts SET account_name = '$name', opening_balance = '$opening_balance', account_currency_code = '$currency_code', account_notes = '$account_notes', account_created_at = NOW(), company_id = $session_company_id"); //Logging mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Account', log_action = 'Created', log_description = '$name', log_created_at = NOW(), company_id = $session_company_id, user_id = $session_user_id"); @@ -1427,7 +1436,7 @@ if(isset($_POST['add_expense'])){ move_uploaded_file($_FILES['file']['tmp_name'], $path); } - mysqli_query($mysqli,"INSERT INTO expenses SET expense_date = '$date', expense_amount = '$amount', account_id = $account, vendor_id = $vendor, category_id = $category, expense_description = '$description', expense_reference = '$reference', expense_receipt = '$path', expense_created_at = NOW(), company_id = $session_company_id"); + mysqli_query($mysqli,"INSERT INTO expenses SET expense_date = '$date', expense_amount = '$amount', expense_currency_code = '$config_default_currency', account_id = $account, vendor_id = $vendor, category_id = $category, expense_description = '$description', expense_reference = '$reference', expense_receipt = '$path', expense_created_at = NOW(), company_id = $session_company_id"); //Logging mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Expense', log_action = 'Created', log_description = '$description', log_created_at = NOW(), company_id = $session_company_id, user_id = $session_user_id"); @@ -1569,6 +1578,7 @@ if(isset($_POST['add_invoice'])){ $client = intval($_POST['client']); $date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date'])); $category = intval($_POST['category']); + $currency_code = strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code'])); $scope = strip_tags(mysqli_real_escape_string($mysqli,$_POST['scope'])); //Get Net Terms @@ -1584,7 +1594,7 @@ if(isset($_POST['add_invoice'])){ //Generate a unique URL key for clients to access $url_key = keygen(); - mysqli_query($mysqli,"INSERT INTO invoices SET invoice_prefix = '$config_invoice_prefix', invoice_number = $invoice_number, invoice_scope = '$scope', invoice_date = '$date', invoice_due = DATE_ADD('$date', INTERVAL $client_net_terms day), category_id = $category, invoice_status = 'Draft', invoice_url_key = '$url_key', invoice_created_at = NOW(), client_id = $client, company_id = $session_company_id"); + mysqli_query($mysqli,"INSERT INTO invoices SET invoice_prefix = '$config_invoice_prefix', invoice_number = $invoice_number, invoice_scope = '$scope', invoice_date = '$date', invoice_due = DATE_ADD('$date', INTERVAL $client_net_terms day), invoice_currency_code = '$currency_code', category_id = $category, invoice_status = 'Draft', invoice_url_key = '$url_key', invoice_created_at = NOW(), client_id = $client, company_id = $session_company_id"); $invoice_id = mysqli_insert_id($mysqli); mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Draft', history_description = 'INVOICE added!', history_created_at = NOW(), invoice_id = $invoice_id, company_id = $session_company_id"); @@ -1603,9 +1613,10 @@ if(isset($_POST['edit_invoice'])){ $date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date'])); $due = strip_tags(mysqli_real_escape_string($mysqli,$_POST['due'])); $category = intval($_POST['category']); + $currency_code = strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code'])); $scope = strip_tags(mysqli_real_escape_string($mysqli,$_POST['scope'])); - mysqli_query($mysqli,"UPDATE invoices SET invoice_scope = '$scope', invoice_date = '$date', invoice_due = '$due', invoice_updated_at = NOW(), category_id = $category WHERE invoice_id = $invoice_id AND company_id = $session_company_id"); + mysqli_query($mysqli,"UPDATE invoices SET invoice_scope = '$scope', invoice_date = '$date', invoice_due = '$due', invoice_currency_code = '$currency_code', invoice_updated_at = NOW(), category_id = $category WHERE invoice_id = $invoice_id AND company_id = $session_company_id"); //Logging mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Invoice', log_action = 'Modified', log_description = '$invoice_id', log_created_at = NOW(), company_id = $session_company_id, user_id = $session_user_id"); @@ -1634,6 +1645,7 @@ if(isset($_POST['add_invoice_copy'])){ $row = mysqli_fetch_array($sql); $invoice_scope = $row['invoice_scope']; $invoice_amount = $row['invoice_amount']; + $invoice_currency_code = $row['invoice_currency_code']; $invoice_note = mysqli_real_escape_string($mysqli,$row['invoice_note']); $client_id = $row['client_id']; $category_id = $row['category_id']; @@ -1641,7 +1653,7 @@ if(isset($_POST['add_invoice_copy'])){ //Generate a unique URL key for clients to access $url_key = keygen(); - mysqli_query($mysqli,"INSERT INTO invoices SET invoice_prefix = '$config_invoice_prefix', invoice_number = $invoice_number, invoice_scope = '$invoice_scope', invoice_date = '$date', invoice_due = DATE_ADD('$date', INTERVAL $client_net_terms day), category_id = $category_id, invoice_status = 'Draft', invoice_amount = '$invoice_amount', invoice_note = '$invoice_note', invoice_url_key = '$url_key', invoice_created_at = NOW(), client_id = $client_id, company_id = $session_company_id") or die(mysql_error()); + mysqli_query($mysqli,"INSERT INTO invoices SET invoice_prefix = '$config_invoice_prefix', invoice_number = $invoice_number, invoice_scope = '$invoice_scope', invoice_date = '$date', invoice_due = DATE_ADD('$date', INTERVAL $client_net_terms day), category_id = $category_id, invoice_status = 'Draft', invoice_amount = '$invoice_amount', invoice_currency_code = '$invoice_currency_code', invoice_note = '$invoice_note', invoice_url_key = '$url_key', invoice_created_at = NOW(), client_id = $client_id, company_id = $session_company_id") or die(mysql_error()); $new_invoice_id = mysqli_insert_id($mysqli); @@ -1720,6 +1732,7 @@ if(isset($_POST['add_quote'])){ $client = intval($_POST['client']); $date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date'])); $category = intval($_POST['category']); + $currency_code = strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code'])); $scope = strip_tags(mysqli_real_escape_string($mysqli,$_POST['scope'])); //Get the last Quote Number and add 1 for the new Quote number @@ -1730,7 +1743,7 @@ if(isset($_POST['add_quote'])){ //Generate a unique URL key for clients to access $quote_url_key = keygen(); - mysqli_query($mysqli,"INSERT INTO quotes SET quote_prefix = '$config_quote_prefix', quote_number = $quote_number, quote_scope = '$scope', quote_date = '$date', category_id = $category, quote_status = 'Draft', quote_url_key = '$quote_url_key', quote_created_at = NOW(), client_id = $client, company_id = $session_company_id"); + mysqli_query($mysqli,"INSERT INTO quotes SET quote_prefix = '$config_quote_prefix', quote_number = $quote_number, quote_scope = '$scope', quote_date = '$date', quote_currency_code = '$currency_code', category_id = $category, quote_status = 'Draft', quote_url_key = '$quote_url_key', quote_created_at = NOW(), client_id = $client, company_id = $session_company_id"); $quote_id = mysqli_insert_id($mysqli); @@ -1758,12 +1771,13 @@ if(isset($_POST['add_quote_copy'])){ $sql = mysqli_query($mysqli,"SELECT * FROM quotes WHERE quote_id = $quote_id AND company_id = $session_company_id"); $row = mysqli_fetch_array($sql); $quote_amount = $row['quote_amount']; + $quote_currency_code = $row['quote_currency_code']; $quote_scope = mysqli_real_escape_string($mysqli,$row['quote_scope']); $quote_note = mysqli_real_escape_string($mysqli,$row['quote_note']); $client_id = $row['client_id']; $category_id = $row['category_id']; - mysqli_query($mysqli,"INSERT INTO quotes SET quote_prefix = '$config_quote_prefix', quote_number = $quote_number, quote_scope = '$quote_scope', quote_date = '$date', category_id = $category_id, quote_status = 'Draft', quote_amount = '$quote_amount', quote_note = '$quote_note', quote_created_at = NOW(), client_id = $client_id, company_id = $session_company_id"); + mysqli_query($mysqli,"INSERT INTO quotes SET quote_prefix = '$config_quote_prefix', quote_number = $quote_number, quote_scope = '$quote_scope', quote_date = '$date', category_id = $category_id, quote_status = 'Draft', quote_amount = '$quote_amount', quote_currency_code = '$quote_currency_code', quote_note = '$quote_note', quote_created_at = NOW(), client_id = $client_id, company_id = $session_company_id"); $new_quote_id = mysqli_insert_id($mysqli); @@ -1806,6 +1820,7 @@ if(isset($_POST['add_quote_to_invoice'])){ $sql = mysqli_query($mysqli,"SELECT * FROM quotes WHERE quote_id = $quote_id AND company_id = $session_company_id"); $row = mysqli_fetch_array($sql); $quote_amount = $row['quote_amount']; + $quote_currency_code = $row['quote_currency_code']; $quote_scope = mysqli_real_escape_string($mysqli,$row['quote_scope']); $quote_note = mysqli_real_escape_string($mysqli,$row['quote_note']); @@ -1815,7 +1830,7 @@ if(isset($_POST['add_quote_to_invoice'])){ //Generate a unique URL key for clients to access $url_key = keygen(); - mysqli_query($mysqli,"INSERT INTO invoices SET invoice_prefix = '$config_invoice_prefix', invoice_number = $invoice_number, invoice_scope = '$quote_scope', invoice_date = '$date', invoice_due = DATE_ADD(CURDATE(), INTERVAL $client_net_terms day), category_id = $category_id, invoice_status = 'Draft', invoice_amount = '$quote_amount', invoice_note = '$quote_note', invoice_url_key = '$url_key', invoice_created_at = NOW(), client_id = $client_id, company_id = $session_company_id"); + mysqli_query($mysqli,"INSERT INTO invoices SET invoice_prefix = '$config_invoice_prefix', invoice_number = $invoice_number, invoice_scope = '$quote_scope', invoice_date = '$date', invoice_due = DATE_ADD(CURDATE(), INTERVAL $client_net_terms day), category_id = $category_id, invoice_status = 'Draft', invoice_amount = '$quote_amount', invoice_currency_code = '$quote_currency_code', invoice_note = '$quote_note', invoice_url_key = '$url_key', invoice_created_at = NOW(), client_id = $client_id, company_id = $session_company_id"); $new_invoice_id = mysqli_insert_id($mysqli); @@ -1905,9 +1920,10 @@ if(isset($_POST['edit_quote'])){ $quote_id = intval($_POST['quote_id']); $date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date'])); $category = intval($_POST['category']); + $currency_code = strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code'])); $scope = strip_tags(mysqli_real_escape_string($mysqli,$_POST['scope'])); - mysqli_query($mysqli,"UPDATE quotes SET quote_scope = '$scope', quote_date = '$date', category_id = $category, quote_updated_at = NOW() WHERE quote_id = $quote_id AND company_id = $session_company_id"); + mysqli_query($mysqli,"UPDATE quotes SET quote_scope = '$scope', quote_date = '$date', quote_currency_code = '$currency_code', category_id = $category, quote_updated_at = NOW() WHERE quote_id = $quote_id AND company_id = $session_company_id"); //Logging mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Quote', log_action = 'Modified', log_description = '$quote_id', log_created_at = NOW(), company_id = $session_company_id, user_id = $session_user_id"); @@ -2551,6 +2567,7 @@ if(isset($_POST['add_recurring'])){ $frequency = strip_tags(mysqli_real_escape_string($mysqli,$_POST['frequency'])); $start_date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['start_date'])); $category = intval($_POST['category']); + $currency_code = intval($_POST['currency_code']); $scope = strip_tags(mysqli_real_escape_string($mysqli,$_POST['scope'])); //Get the last Recurring Number and add 1 for the new Recurring number @@ -2558,7 +2575,7 @@ if(isset($_POST['add_recurring'])){ $new_config_recurring_next_number = $config_recurring_next_number + 1; mysqli_query($mysqli,"UPDATE settings SET config_recurring_next_number = $new_config_recurring_next_number WHERE company_id = $session_company_id"); - mysqli_query($mysqli,"INSERT INTO recurring SET recurring_prefix = '$config_recurring_prefix', recurring_number = $recurring_number, recurring_scope = '$scope', recurring_frequency = '$frequency', recurring_next_date = '$start_date', category_id = $category, recurring_status = 1, recurring_created_at = NOW(), client_id = $client, company_id = $session_company_id"); + mysqli_query($mysqli,"INSERT INTO recurring SET recurring_prefix = '$config_recurring_prefix', recurring_number = $recurring_number, recurring_scope = '$scope', recurring_frequency = '$frequency', recurring_next_date = '$start_date', category_id = $category, recurring_status = 1, recurring_currency_code = '$currency_code', recurring_created_at = NOW(), client_id = $client, company_id = $session_company_id"); $recurring_id = mysqli_insert_id($mysqli); @@ -2578,10 +2595,11 @@ if(isset($_POST['edit_recurring'])){ $recurring_id = intval($_POST['recurring_id']); $frequency = strip_tags(mysqli_real_escape_string($mysqli,$_POST['frequency'])); $category = intval($_POST['category']); + $currency_code = strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code'])); $scope = strip_tags(mysqli_real_escape_string($mysqli,$_POST['scope'])); $status = intval($_POST['status']); - mysqli_query($mysqli,"UPDATE recurring SET recurring_scope = '$scope', recurring_frequency = '$frequency', category_id = $category, recurring_status = $status, recurring_updated_at = NOW() WHERE recurring_id = $recurring_id AND company_id = $session_company_id"); + mysqli_query($mysqli,"UPDATE recurring SET recurring_scope = '$scope', recurring_frequency = '$frequency', category_id = $category, recurring_status = $status, recurring_currency_code = '$currency_code', recurring_updated_at = NOW() WHERE recurring_id = $recurring_id AND company_id = $session_company_id"); mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_description = 'Recurring modified', history_created_at = NOW(), recurring_id = $recurring_id, company_id = $session_company_id"); @@ -2949,6 +2967,7 @@ if(isset($_POST['add_payment'])){ $date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date'])); $amount = floatval($_POST['amount']); $account = intval($_POST['account']); + $currency_code = strip_tags(mysqli_real_escape_string($mysqli,$_POST['currency_code'])); $payment_method = strip_tags(mysqli_real_escape_string($mysqli,$_POST['payment_method'])); $reference = strip_tags(mysqli_real_escape_string($mysqli,$_POST['reference'])); $email_receipt = intval($_POST['email_receipt']); @@ -2959,7 +2978,7 @@ if(isset($_POST['add_payment'])){ $_SESSION['alert_message'] = "Payment is more than the balance"; header("Location: " . $_SERVER["HTTP_REFERER"]); }else{ - mysqli_query($mysqli,"INSERT INTO payments SET payment_date = '$date', payment_amount = '$amount', account_id = $account, payment_method = '$payment_method', payment_reference = '$reference', payment_created_at = NOW(), invoice_id = $invoice_id, company_id = $session_company_id"); + mysqli_query($mysqli,"INSERT INTO payments SET payment_date = '$date', payment_amount = '$amount', payment_currency_code = '$currency_code', account_id = $account, payment_method = '$payment_method', payment_reference = '$reference', payment_created_at = NOW(), invoice_id = $invoice_id, company_id = $session_company_id"); //Add up all the payments for the invoice and get the total amount paid to the invoice $sql_total_payments_amount = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS payments_amount FROM payments WHERE invoice_id = $invoice_id AND company_id = $session_company_id"); @@ -3261,7 +3280,7 @@ if(isset($_POST['add_revenue'])){ $description = strip_tags(mysqli_real_escape_string($mysqli,$_POST['description'])); $reference = strip_tags(mysqli_real_escape_string($mysqli,$_POST['reference'])); - mysqli_query($mysqli,"INSERT INTO revenues SET revenue_date = '$date', revenue_amount = '$amount', revenue_payment_method = '$payment_method', revenue_reference = '$reference', revenue_description = '$description', revenue_created_at = NOW(), category_id = $category, account_id = $account, company_id = $session_company_id"); + mysqli_query($mysqli,"INSERT INTO revenues SET revenue_date = '$date', revenue_amount = '$amount', revenue_currency_code = '$config_default_currency_code', revenue_payment_method = '$payment_method', revenue_reference = '$reference', revenue_description = '$description', revenue_created_at = NOW(), category_id = $category, account_id = $account, company_id = $session_company_id"); //Logging mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Revenue', log_action = 'Created', log_description = '$date - $amount', log_created_at = NOW(), company_id = $session_company_id, user_id = $session_user_id"); @@ -4503,6 +4522,7 @@ if(isset($_GET['force_recurring'])){ $recurring_last_sent = $row['recurring_last_sent']; $recurring_next_date = $row['recurring_next_date']; $recurring_amount = $row['recurring_amount']; + $recurring_currency_code = $row['recurring_currency_code']; $recurring_note = mysqli_real_escape_string($mysqli,$row['recurring_note']); $category_id = $row['category_id']; $client_id = $row['client_id']; @@ -4516,7 +4536,7 @@ if(isset($_GET['force_recurring'])){ //Generate a unique URL key for clients to access $url_key = keygen(); - mysqli_query($mysqli,"INSERT INTO invoices SET invoice_prefix = '$config_invoice_prefix', invoice_number = '$new_invoice_number', invoice_scope = '$recurring_scope', invoice_date = CURDATE(), invoice_due = DATE_ADD(CURDATE(), INTERVAL $client_net_terms day), invoice_amount = '$recurring_amount', invoice_note = '$recurring_note', category_id = $category_id, invoice_status = 'Sent', invoice_url_key = '$url_key', invoice_created_at = NOW(), client_id = $client_id, company_id = $session_company_id"); + mysqli_query($mysqli,"INSERT INTO invoices SET invoice_prefix = '$config_invoice_prefix', invoice_number = '$new_invoice_number', invoice_scope = '$recurring_scope', invoice_date = CURDATE(), invoice_due = DATE_ADD(CURDATE(), INTERVAL $client_net_terms day), invoice_amount = '$recurring_amount', invoice_currency_code = '$recurring_currency_code', invoice_note = '$recurring_note', category_id = $category_id, invoice_status = 'Sent', invoice_url_key = '$url_key', invoice_created_at = NOW(), client_id = $client_id, company_id = $session_company_id"); $new_invoice_id = mysqli_insert_id($mysqli); diff --git a/quote.php b/quote.php index 1b692b7d..486af5eb 100644 --- a/quote.php +++ b/quote.php @@ -20,6 +20,7 @@ if(isset($_GET['quote_id'])){ $quote_status = $row['quote_status']; $quote_date = $row['quote_date']; $quote_amount = $row['quote_amount']; + $quote_currency_code = $row['quote_currency_code']; $quote_note = $row['quote_note']; $quote_url_key = $row['quote_url_key']; $quote_created_at = $row['quote_created_at']; @@ -41,6 +42,7 @@ if(isset($_GET['quote_id'])){ $client_mobile = substr($row['client_mobile'],0,3)."-".substr($row['client_mobile'],3,3)."-".substr($row['client_mobile'],6,4); } $client_website = $row['client_website']; + $client_currency_code = $row['client_currency_code']; $client_net_terms = $row['client_net_terms']; if($client_net_terms == 0){ $client_net_terms = $config_default_net_terms; diff --git a/quotes.php b/quotes.php index 93a074bb..f614c0df 100644 --- a/quotes.php +++ b/quotes.php @@ -126,9 +126,11 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); $quote_status = $row['quote_status']; $quote_date = $row['quote_date']; $quote_amount = $row['quote_amount']; + $quote_currency_code = $row['quote_currency_code']; $quote_created_at = $row['quote_created_at']; $client_id = $row['client_id']; $client_name = $row['client_name']; + $client_currency_code = $row['client_currency_code']; $category_id = $row['category_id']; $category_name = $row['category_name']; $client_net_terms = $row['client_net_terms']; diff --git a/recurring.php b/recurring.php index 46255355..bf1f7581 100644 --- a/recurring.php +++ b/recurring.php @@ -132,9 +132,11 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); } $recurring_next_date = $row['recurring_next_date']; $recurring_amount = $row['recurring_amount']; + $recurring_currency_code = $row['recurring_currency_code']; $recurring_created_at = $row['recurring_created_at']; $client_id = $row['client_id']; $client_name = $row['client_name']; + $client_currency_code = $row['client_currency_code']; $category_id = $row['category_id']; $category_name = $row['category_name']; if($recurring_status == 1){ diff --git a/recurring_invoice.php b/recurring_invoice.php index 9b6d6efc..21d0594b 100644 --- a/recurring_invoice.php +++ b/recurring_invoice.php @@ -26,6 +26,7 @@ if(isset($_GET['recurring_id'])){ } $recurring_next_date = $row['recurring_next_date']; $recurring_amount = $row['recurring_amount']; + $recurring_currency_code = $row['recurring_currency_code']; $recurring_note = $row['recurring_note']; $recurring_created_at = $row['recurring_created_at']; $category_id = $row['category_id']; @@ -46,6 +47,7 @@ if(isset($_GET['recurring_id'])){ $client_mobile = substr($row['client_mobile'],0,3)."-".substr($row['client_mobile'],3,3)."-".substr($row['client_mobile'],6,4); } $client_website = $row['client_website']; + $client_currency_code = $row['client_currency_code']; $client_net_terms = $row['client_net_terms']; if($recurring_status == 1){ diff --git a/settings-defaults.php b/settings-defaults.php index 896a2c94..ba711f06 100644 --- a/settings-defaults.php +++ b/settings-defaults.php @@ -9,13 +9,43 @@
+
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
-
-
-
-
- - - - $net_term_name) { ?> diff --git a/setup.php b/setup.php index 4fafe8e2..c01e17bd 100644 --- a/setup.php +++ b/setup.php @@ -16,6 +16,13 @@ $countries_array = array( 'Canada' ); +$currencies_array = array( + 'USD'=>'US Dollars', + 'EUR'=>'Euro', + 'GBP'=>'British Pounds', + 'TRY'=>'Turkish Lira' +); + $states_array = array( 'AL'=>'Alabama', 'AK'=>'Alaska', @@ -183,8 +190,9 @@ if(isset($_POST['add_company_settings'])){ $state = strip_tags(mysqli_real_escape_string($mysqli,$_POST['state'])); $zip = strip_tags(mysqli_real_escape_string($mysqli,$_POST['zip'])); $phone = preg_replace("/[^0-9]/", '',$_POST['phone']); - $website = strip_tags(mysqli_real_escape_string($mysqli,$_POST['website'])); $email = strip_tags(mysqli_real_escape_string($mysqli,$_POST['email'])); + $website = strip_tags(mysqli_real_escape_string($mysqli,$_POST['website'])); + $currency_code = 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()"); @@ -209,7 +217,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_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_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'"); //Create Some Data @@ -574,6 +582,21 @@ if(isset($_POST['add_company_settings'])){ +
+ +
+
+ +
+ +
+
+