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

This commit is contained in:
johnny@pittpc.com 2021-02-14 18:06:32 -05:00
parent e71b851dd7
commit 6f46f2ec87
33 changed files with 328 additions and 55 deletions

View File

@ -30,6 +30,21 @@
</div>
</div>
<div class="form-group">
<label>Currency <strong class="text-danger">*</strong></label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-money-bill"></i></span>
</div>
<select class="form-control select2" name="currency_code" required>
<option value="">- Currency -</option>
<?php foreach($currencies_array as $currency_code => $currency_name) { ?>
<option <?php if($config_default_currency == $currency_code){ echo "selected"; } ?> value="<?php echo $currency_code; ?>"><?php echo "$currency_code - $currency_name"; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group">
<label>Notes</label>
<textarea class="form-control" rows="5" name="notes"></textarea>

View File

@ -77,6 +77,21 @@
</div>
</div>
<div class="form-group">
<label>Currency <strong class="text-danger">*</strong></label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-money-bill"></i></span>
</div>
<select class="form-control select2" name="currency_code" required>
<option value="">- Currency -</option>
<?php foreach($currencies_array as $currency_code => $currency_name) { ?>
<option <?php if($config_default_currency == $currency_code){ echo "selected"; } ?> value="<?php echo $currency_code; ?>"><?php echo "$currency_code - $currency_name"; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group">
<label>Invoice Net Terms</label>
<div class="input-group">
@ -149,7 +164,7 @@
<select class="form-control select2" name="country">
<option value="">- Country -</option>
<?php foreach($countries_array as $country_name) { ?>
<option><?php echo $country_name; ?></option>
<option <?php if($config_default_country == $country_name){ echo "selected"; } ?> ><?php echo $country_name; ?></option>
<?php } ?>
</select>
</div>

View File

@ -110,6 +110,21 @@
</div>
</div>
<div class="form-group">
<label>Currency <strong class="text-danger">*</strong></label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-money-bill"></i></span>
</div>
<select class="form-control select2" name="currency_code" required>
<option value="">- Currency -</option>
<?php foreach($currencies_array as $currency_code => $currency_name) { ?>
<option value="<?php echo $currency_code; ?>"><?php echo "$currency_code - $currency_name"; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group mb-4">
<label>Logo</label>
<input type="file" class="form-control-file" name="file">

View File

@ -77,6 +77,21 @@
</div>
</div>
<div class="form-group">
<label>Currency <strong class="text-danger">*</strong></label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-money-bill"></i></span>
</div>
<select class="form-control select2" name="currency_code" required>
<option value="">- Currency -</option>
<?php foreach($currencies_array as $currency_code => $currency_name) { ?>
<option <?php if(isset($_GET['client_id']) AND $client_currency_code == $currency_code){ echo "selected"; }elseif($config_default_currency == $currency_code){ echo "selected"; } ?> value="<?php echo $currency_code; ?>"><?php echo "$currency_code - $currency_name"; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group">
<label>Scope</label>
<div class="input-group">

View File

@ -144,7 +144,7 @@
<select class="form-control select2" name="country">
<option value="">- Country -</option>
<?php foreach($countries_array as $country_name) { ?>
<option><?php echo $country_name; ?></option>
<option <?php if($country_name == $client_country){ echo "selected"; } ?> ><?php echo $country_name; ?></option>
<?php } ?>
</select>
</div>

View File

@ -10,6 +10,7 @@
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="invoice_id" value="<?php echo $invoice_id; ?>">
<input type="hidden" name="balance" value="<?php echo $balance; ?>">
<input type="hidden" name="currency_code" value="<?php echo $invoice_currency_code; ?>">
<div class="modal-body bg-white">
<div class="form-row">

View File

@ -78,6 +78,21 @@
</div>
</div>
<div class="form-group">
<label>Currency <strong class="text-danger">*</strong></label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-money-bill"></i></span>
</div>
<select class="form-control select2" name="currency_code" required>
<option value="">- Currency -</option>
<?php foreach($currencies_array as $currency_code => $currency_name) { ?>
<option <?php if(isset($_GET['client_id']) AND $client_currency_code == $currency_code){ echo "selected"; }elseif($config_default_currency == $currency_code){ echo "selected"; } ?> value="<?php echo $currency_code; ?>"><?php echo "$currency_code - $currency_name"; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group">
<label>Scope</label>
<div class="input-group">

View File

@ -64,10 +64,9 @@
</select>
</div>
</div>
<div class="form-group">
<label>Income Category <strong class="text-danger">*</strong></label>
<label>Category <strong class="text-danger">*</strong></label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-list"></i></span>
@ -93,6 +92,21 @@
</div>
</div>
<div class="form-group">
<label>Currency <strong class="text-danger">*</strong></label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-money-bill"></i></span>
</div>
<select class="form-control select2" name="currency_code" required>
<option value="">- Currency -</option>
<?php foreach($currencies_array as $currency_code => $currency_name) { ?>
<option <?php if(isset($_GET['client_id']) AND $client_currency_code == $currency_code){ echo "selected"; }elseif($config_default_currency == $currency_code){ echo "selected"; } ?> value="<?php echo $currency_code; ?>"><?php echo "$currency_code - $currency_name"; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group">
<label>Scope</label>
<div class="input-group">

View File

@ -122,7 +122,7 @@
<select class="form-control select2" name="country">
<option value="">- Country -</option>
<?php foreach($countries_array as $country_name) { ?>
<option><?php echo $country_name; ?></option>
<option <?php if($config_default_country == $country_name){ echo "selected"; } ?> ><?php echo $country_name; ?></option>
<?php } ?>
</select>
</div>

View File

@ -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;

View File

@ -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'];

View File

@ -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'];

View File

@ -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'];

View File

@ -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'];

View File

@ -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'];
?>
<tr>

View File

@ -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);

22
db.sql
View File

@ -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

View File

@ -78,6 +78,21 @@
</div>
</div>
<div class="form-group">
<label>Currency <strong class="text-danger">*</strong></label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-money-bill"></i></span>
</div>
<select class="form-control select2" name="currency_code" required>
<option value="">- Currency -</option>
<?php foreach($currencies_array as $currency_code => $currency_name) { ?>
<option <?php if($client_currency_code == $currency_code){ echo "selected"; } ?> value="<?php echo $currency_code; ?>"><?php echo "$currency_code - $currency_name"; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group">
<label>Invoice Net Terms</label>
<div class="input-group">

View File

@ -112,6 +112,21 @@
</div>
</div>
<div class="form-group">
<label>Currency <strong class="text-danger">*</strong></label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-money-bill"></i></span>
</div>
<select class="form-control select2" name="currency_code" required>
<option value="">- Currency -</option>
<?php foreach($currencies_array as $currency_code => $currency_name) { ?>
<option <?php if($company_currency_code == $currency_code){ echo "selected"; } ?> value="<?php echo $currency_code; ?>"><?php echo "$currency_code - $currency_name"; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group mb-4">
<label>Logo</label>
<input type="file" class="form-control-file" name="file">

View File

@ -59,6 +59,21 @@
</div>
</div>
<div class="form-group">
<label>Currency <strong class="text-danger">*</strong></label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-money-bill"></i></span>
</div>
<select class="form-control select2" name="currency_code" required>
<option value="">- Currency -</option>
<?php foreach($currencies_array as $currency_code => $currency_name) { ?>
<option <?php if($invoice_currency_code == $currency_code){ echo "selected"; } ?> value="<?php echo $currency_code; ?>"><?php echo "$currency_code - $currency_name"; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group">
<label>Scope</label>
<div class="input-group">

View File

@ -59,6 +59,21 @@
</div>
</div>
<div class="form-group">
<label>Currency <strong class="text-danger">*</strong></label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-money-bill"></i></span>
</div>
<select class="form-control select2" name="currency_code" required>
<option value="">- Currency -</option>
<?php foreach($currencies_array as $currency_code => $currency_name) { ?>
<option <?php if($quote_currency_code == $currency_code){ echo "selected"; } ?> value="<?php echo $currency_code; ?>"><?php echo "$currency_code - $currency_name"; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group">
<label>Scope</label>
<div class="input-group">

View File

@ -52,6 +52,21 @@
<button type="button" class="btn btn-secondary" data-toggle="modal" data-target="#addQuickCategoryIncomeModal"><i class="fas fa-fw fa-plus"></i></button>
</div>
</div>
</div>
<div class="form-group">
<label>Currency <strong class="text-danger">*</strong></label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-money-bill"></i></span>
</div>
<select class="form-control select2" name="currency_code" required>
<option value="">- Currency -</option>
<?php foreach($currencies_array as $currency_code => $currency_name) { ?>
<option <?php if($recurring_currency_code == $currency_code){ echo "selected"; } ?> value="<?php echo $currency_code; ?>"><?php echo "$currency_code - $currency_name"; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group">

View File

@ -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',

View File

@ -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'];

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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'];

View File

@ -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){

View File

@ -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){

View File

@ -9,13 +9,43 @@
<div class="card-body">
<form action="post.php" method="post" autocomplete="off">
<div class="form-group">
<label>Country</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-flag"></i></span>
</div>
<select class="form-control select2" name="country">
<option value="">- Country -</option>
<?php foreach($countries_array as $country) { ?>
<option <?php if($config_default_country == $country){ echo "selected"; } ?>><?php echo $country; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group">
<label>Currency</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-money-bill"></i></span>
</div>
<select class="form-control select2" name="currency_code" required>
<option value="">- Currency -</option>
<?php foreach($currencies_array as $currency_code => $currency_name) { ?>
<option <?php if($config_default_currency == $currency_code){ echo "selected"; } ?> value="<?php echo $currency_code; ?>"><?php echo "$currency_code - $currency_name"; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group">
<label>Transfer From Account</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-exchange-alt"></i></span>
</div>
<select class="form-control select2" name="config_default_transfer_from_account">
<select class="form-control select2" name="transfer_from_account">
<option value="0">- None -</option>
<?php
@ -40,7 +70,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-exchange-alt"></i></span>
</div>
<select class="form-control select2" name="config_default_transfer_to_account">
<select class="form-control select2" name="transfer_to_account">
<option value="0">- None -</option>
<?php
@ -65,7 +95,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-credit-card"></i></span>
</div>
<select class="form-control select2" name="config_default_payment_account">
<select class="form-control select2" name="payment_account">
<option value="0">- None -</option>
<?php
@ -90,7 +120,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-shopping-cart"></i></span>
</div>
<select class="form-control select2" name="config_default_expense_account">
<select class="form-control select2" name="expense_account">
<option value="0">- None -</option>
<?php
@ -115,7 +145,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-credit-card"></i></span>
</div>
<select class="form-control select2" name="config_default_payment_method">
<select class="form-control select2" name="payment_method">
<option value="">- None -</option>
<?php
@ -139,7 +169,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-credit-card"></i></span>
</div>
<select class="form-control select2" name="config_default_expense_payment_method">
<select class="form-control select2" name="expense_payment_method">
<option value="">- None -</option>
<?php
@ -163,7 +193,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
</div>
<select class="form-control select2" name="config_default_calendar">
<select class="form-control select2" name="calendar">
<option value="0">- None -</option>
<?php
@ -188,7 +218,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
</div>
<select class="form-control select2" name="config_default_net_terms">
<select class="form-control select2" name="net_terms">
<?php foreach($net_terms_array as $net_term_value => $net_term_name) { ?>
<option <?php if($config_default_net_terms == $net_term_value){ echo "selected"; } ?> value="<?php echo $net_term_value; ?>"><?php echo $net_term_name; ?></option>
<?php } ?>

View File

@ -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'])){
</div>
</div>
<div class="form-group">
<label>Currency</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-money-bill"></i></span>
</div>
<select class="form-control select2" name="currency_code" required>
<option value="">- Currency -</option>
<?php foreach($currencies_array as $currency_code => $currency_name) { ?>
<option><?php echo "$currency_code - $currency_name"; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group">
<label>Logo</label>
<input type="file" class="form-control-file" name="file">