This commit is contained in:
Pinga 2024-01-12 13:51:42 +02:00
parent 66ae0e2d04
commit fd0909f3ec
8 changed files with 72 additions and 20 deletions

View file

@ -6,6 +6,7 @@ use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request; use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Container\ContainerInterface; use Psr\Container\ContainerInterface;
use Respect\Validation\Validator as v; use Respect\Validation\Validator as v;
use League\ISO3166\ISO3166;
class SystemController extends Controller class SystemController extends Controller
{ {
@ -143,7 +144,18 @@ class SystemController extends Controller
] ]
); );
$db->update(
'settings',
[
'value' => $data['currency']
],
[
'name' => "currency"
]
);
$db->commit(); $db->commit();
$_SESSION['_currency'] = $data['currency'];
} catch (Exception $e) { } catch (Exception $e) {
$db->rollBack(); $db->rollBack();
$this->container->get('flash')->addMessage('error', 'Database failure: ' . $e->getMessage()); $this->container->get('flash')->addMessage('error', 'Database failure: ' . $e->getMessage());
@ -155,6 +167,8 @@ class SystemController extends Controller
} }
$iso3166 = new ISO3166();
$countries = $iso3166->all();
$db = $this->container->get('db'); $db = $this->container->get('db');
$company_name = $db->selectValue("SELECT value FROM settings WHERE name = 'company_name'"); $company_name = $db->selectValue("SELECT value FROM settings WHERE name = 'company_name'");
$vat_number = $db->selectValue("SELECT value FROM settings WHERE name = 'vat_number'"); $vat_number = $db->selectValue("SELECT value FROM settings WHERE name = 'vat_number'");
@ -166,6 +180,17 @@ class SystemController extends Controller
$launch_phases = $db->selectValue("SELECT value FROM settings WHERE name = 'launch_phases'"); $launch_phases = $db->selectValue("SELECT value FROM settings WHERE name = 'launch_phases'");
$whois_server = $db->selectValue("SELECT value FROM settings WHERE name = 'whois_server'"); $whois_server = $db->selectValue("SELECT value FROM settings WHERE name = 'whois_server'");
$rdap_server = $db->selectValue("SELECT value FROM settings WHERE name = 'rdap_server'"); $rdap_server = $db->selectValue("SELECT value FROM settings WHERE name = 'rdap_server'");
$currency = $db->selectValue("SELECT value FROM settings WHERE name = 'currency'");
$uniqueCurrencies = [];
foreach ($countries as $country) {
// Assuming each country has a 'currency' field with an array of currencies
foreach ($country['currency'] as $currencyCode) {
if (!array_key_exists($currencyCode, $uniqueCurrencies)) {
$uniqueCurrencies[$currencyCode] = $currencyCode; // Or any other currency detail you have
}
}
}
return view($response,'admin/system/registry.twig', [ return view($response,'admin/system/registry.twig', [
'company_name' => $company_name, 'company_name' => $company_name,
@ -177,7 +202,9 @@ class SystemController extends Controller
'handle' => $handle, 'handle' => $handle,
'launch_phases' => $launch_phases, 'launch_phases' => $launch_phases,
'whois_server' => $whois_server, 'whois_server' => $whois_server,
'rdap_server' => $rdap_server 'rdap_server' => $rdap_server,
'uniqueCurrencies' => $uniqueCurrencies,
'currency' => $currency
]); ]);
} }

View file

@ -131,22 +131,20 @@ $container->set('view', function ($container) {
} }
$db = $container->get('db'); $db = $container->get('db');
$query = 'SELECT r.currency, ru.registrar_id $user_data = 'SELECT ru.registrar_id
FROM registrar_users ru FROM registrar_users ru
JOIN registrar r ON ru.registrar_id = r.id JOIN registrar r ON ru.registrar_id = r.id
WHERE ru.user_id = ?'; WHERE ru.user_id = ?';
$currency_data = "SELECT value FROM settings WHERE name = 'currency'";
if (isset($_SESSION['auth_user_id'])) { if (isset($_SESSION['auth_user_id'])) {
$result = $db->select($query, [$_SESSION['auth_user_id']]); $result = $db->select($user_data, [$_SESSION['auth_user_id']]);
$db_currency = $db->select($currency_data);
// Default values $_SESSION['_currency'] = $db_currency[0]['value'];
$_SESSION['_currency'] = 'USD';
$_SESSION['auth_registrar_id'] = null; // Default registrar_id $_SESSION['auth_registrar_id'] = null; // Default registrar_id
if ($result !== null && count($result) > 0) { if ($result !== null && count($result) > 0) {
if (isset($result[0]['currency'])) {
$_SESSION['_currency'] = $result[0]['currency'];
}
if (isset($result[0]['registrar_id'])) { if (isset($result[0]['registrar_id'])) {
$_SESSION['auth_registrar_id'] = $result[0]['registrar_id']; $_SESSION['auth_registrar_id'] = $result[0]['registrar_id'];
} }

View file

@ -1339,3 +1339,8 @@ msgstr "TLDs"
msgid "Support" msgid "Support"
msgstr "Support" msgstr "Support"
msgid "Registry Currency"
msgstr "Registry Currency"
msgid "Choose the currency for all transactions. This impacts billing and financial reports. Inform stakeholders of changes."
msgstr "Choose the currency for all transactions. This impacts billing and financial reports. Inform stakeholders of changes."

View file

@ -1339,3 +1339,8 @@ msgstr ""
msgid "Support" msgid "Support"
msgstr "" msgstr ""
msgid "Registry Currency"
msgstr ""
msgid "Choose the currency for all transactions. This impacts billing and financial reports. Inform stakeholders of changes."
msgstr ""

View file

@ -1339,3 +1339,8 @@ msgstr "TLDs"
msgid "Support" msgid "Support"
msgstr "Підтримка" msgstr "Підтримка"
msgid "Registry Currency"
msgstr "Валюта реєстру"
msgid "Choose the currency for all transactions. This impacts billing and financial reports. Inform stakeholders of changes."
msgstr "Виберіть валюту для всіх операцій. Це впливає на рахунки та фінансові звіти. Інформувати зацікавлених сторін про зміни."

View file

@ -40,9 +40,9 @@
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label for="registryHandle" class="form-label required">{{ __('Registry Handle') }}</label> <label for="rdapServer" class="form-label required">{{ __('RDAP Server') }}</label>
<input type="text" class="form-control" id="registryHandle" name="registryHandle" placeholder="{{ __('Enter registry handle') }}" value="{{ handle }}" required> <input type="text" class="form-control" id="rdapServer" name="rdapServer" placeholder="{{ __('Enter registry RDAP server') }}" value="{{ rdap_server }}" required>
<small class="form-hint">{{ __('A unique identifier for the registry which will be appended to each object handle.') }}</small> <small class="form-hint">{{ __('Enter the URL of the registry\'s RDAP server. Example:') }} https://rdap.example.com</small>
</div> </div>
<div class="mb-3"> <div class="mb-3">
@ -52,9 +52,19 @@
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label for="rdapServer" class="form-label required">{{ __('RDAP Server') }}</label> <label for="registryHandle" class="form-label required">{{ __('Registry Handle') }}</label>
<input type="text" class="form-control" id="rdapServer" name="rdapServer" placeholder="{{ __('Enter registry RDAP server') }}" value="{{ rdap_server }}" required> <input type="text" class="form-control" id="registryHandle" name="registryHandle" placeholder="{{ __('Enter registry handle') }}" value="{{ handle }}" required>
<small class="form-hint">{{ __('Enter the URL of the registry\'s RDAP server. Example:') }} https://rdap.example.com</small> <small class="form-hint">{{ __('A unique identifier for the registry which will be appended to each object handle.') }}</small>
</div>
<div class="mb-3">
<label for="registryCurrency" class="form-label required">{{ __('Registry Currency') }}</label>
<select class="form-select" id="registryCurrency" name="currency" required="required">
{% for currencyCode, currencyName in uniqueCurrencies %}
<option value="{{ currencyCode }}" {% if currency == currencyCode %}selected{% endif %}>{{ currencyName }}</option>
{% endfor %}
</select>
<small class="form-hint">{{ __('Choose the currency for all transactions. This impacts billing and financial reports. Inform stakeholders of changes.') }}</small>
</div> </div>
<div class="mb-3"> <div class="mb-3">

View file

@ -880,7 +880,8 @@ INSERT INTO `registry`.`settings` (`name`, `value`) VALUES
('email', 'contact@example.com'), ('email', 'contact@example.com'),
('launch_phases', 'on'), ('launch_phases', 'on'),
('whois_server', 'whois.example.com'), ('whois_server', 'whois.example.com'),
('rdap_server', 'https://rdap.example.com'); ('rdap_server', 'https://rdap.example.com'),
('currency', 'USD');
CREATE DATABASE IF NOT EXISTS `registryTransaction`; CREATE DATABASE IF NOT EXISTS `registryTransaction`;

View file

@ -802,7 +802,8 @@ INSERT INTO settings (name, value) VALUES
('email', 'contact@example.com'), ('email', 'contact@example.com'),
('launch_phases', 'on'), ('launch_phases', 'on'),
('whois_server', 'whois.example.com'), ('whois_server', 'whois.example.com'),
('rdap_server', 'https://rdap.example.com'); ('rdap_server', 'https://rdap.example.com'),
('currency', 'USD');
ALTER TABLE domain_tld ADD FOREIGN KEY (launch_phase_id) REFERENCES launch_phases(id); ALTER TABLE domain_tld ADD FOREIGN KEY (launch_phase_id) REFERENCES launch_phases(id);
ALTER TABLE launch_phases ADD FOREIGN KEY (tld_id) REFERENCES domain_tld(id); ALTER TABLE launch_phases ADD FOREIGN KEY (tld_id) REFERENCES domain_tld(id);