Skip to content

Commit

Permalink
Fixed timezone errors
Browse files Browse the repository at this point in the history
  • Loading branch information
o-psi committed Oct 14, 2023
1 parent 45acc58 commit ac76daa
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 7 deletions.
4 changes: 2 additions & 2 deletions check_login.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@
$session_company_country = $row['company_country'];
$session_company_locale = $row['company_locale'];
$session_company_currency = $row['company_currency'];
$session_timezone = $row['settings_timezone'];
$session_timezone = $row['company_timezone'];

// Set Timezone to the companies timezone
date_default_timezone_set('$session_timezone');
date_default_timezone_set($session_timezone);

//Set Currency Format
$currency_format = numfmt_create($session_company_locale, NumberFormatter::CURRENCY);
Expand Down
16 changes: 14 additions & 2 deletions database_updates.php
Original file line number Diff line number Diff line change
Expand Up @@ -1405,11 +1405,23 @@
// Please add this same comment block to the bottom of this file, and update the version number.
// Uncomment Below Lines, to add additional database updates
//
//if (CURRENT_DATABASE_VERSION == '0.8.8') {
if (CURRENT_DATABASE_VERSION == '0.8.8') {
// Insert queries here required to update to DB version 0.8.9
mysqli_query($mysqli, "ALTER TABLE `companies` ADD `company_timezone` VARCHAR(200) NULL DEFAULT NULL AFTER `company_phone`");
// Then, update the database to the next sequential version
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.8.9'");
}
//

// Be sure to change database_version.php to reflect the version you are updating to here
// Please add this same comment block to the bottom of this file, and update the version number.
// Uncomment Below Lines, to add additional database updates
//
//if (CURRENT_DATABASE_VERSION == '0.8.9') {
// Insert queries here required to update to DB version 0.8.10
//
// Then, update the database to the next sequential version
//mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.8.9'");
//mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.8.10'");
//}
//

Expand Down
1 change: 1 addition & 0 deletions db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ CREATE TABLE `companies` (
`company_zip` varchar(200) DEFAULT NULL,
`company_country` varchar(200) DEFAULT NULL,
`company_phone` varchar(200) DEFAULT NULL,
`company_timezone` varchar(200) DEFAULT NULL,
`company_email` varchar(200) DEFAULT NULL,
`company_website` varchar(200) DEFAULT NULL,
`company_logo` varchar(250) DEFAULT NULL,
Expand Down
12 changes: 11 additions & 1 deletion post/setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@
$sql = mysqli_query($mysqli,"SELECT company_logo FROM companies WHERE company_id = 1");
$row = mysqli_fetch_array($sql);
$existing_file_name = sanitizeInput($row['company_logo']);
$name = sanitizeInput($_POST['name']);
$address = sanitizeInput($_POST['address']);
$city = sanitizeInput($_POST['city']);
$state = sanitizeInput($_POST['state']);
$zip = sanitizeInput($_POST['zip']);
$country = sanitizeInput($_POST['country']);
$phone = sanitizeInput($_POST['phone']);
$email = sanitizeInput($_POST['email']);
$website = sanitizeInput($_POST['website']);
$timezone = sanitizeInput($_POST['timezone']);

// Check to see if a file is attached
if ($_FILES['file']['tmp_name'] != '') {
Expand All @@ -39,7 +49,7 @@
}
}

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' WHERE company_id = 1");
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_timezone = '$timezone' WHERE company_id = 1");

//Logging
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Company', log_action = 'Modify', log_description = '$session_name modified company $name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id");
Expand Down
25 changes: 24 additions & 1 deletion settings_company.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
$company_logo = nullable_htmlentities($row['company_logo']);
$company_locale = nullable_htmlentities($row['company_locale']);
$company_currency = nullable_htmlentities($row['company_currency']);

$company_timezone = nullable_htmlentities($row['company_timezone']);
$company_initials = nullable_htmlentities(initials($company_name));

$timezones = DateTimeZone::listIdentifiers();


?>

<div class="card card-dark">
Expand Down Expand Up @@ -104,6 +107,26 @@
</div>
</div>

<!--Timezone-->

<div class="form-group">
<label>Timezone</label>
<div class="input-group">
<div class="input-group-prepend">
<!--clock-->
<span class="input-group-text"><i class="fab fa-fw ffa-business-time"></i></span>
</div>
<select class="form-control select2" name="timezone">
<option value="">- Timezone -</option>
<?php foreach($timezones as $timezone_name) { ?>
<option <?php if ($company_timezone == $timezone_name) { echo "selected"; } ?>><?php echo $timezone_name; ?></option>
<?php } ?>
</select>
</div>
</div>



<div class="form-group">
<label>Phone</label>
<div class="input-group">
Expand Down
2 changes: 1 addition & 1 deletion setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@
$currency_code = sanitizeInput($_POST['currency_code']);
$timezone = sanitizeInput($_POST['timezone']);

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_locale = '$locale', company_currency = '$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_locale = '$locale', company_currency = '$currency_code', company_timezone = '$timezone'");

//Check to see if a file is attached
if ($_FILES['file']['tmp_name'] != '') {
Expand Down

0 comments on commit ac76daa

Please sign in to comment.