diff --git a/cp/app/Controllers/SystemController.php b/cp/app/Controllers/SystemController.php
index 967301e..f0c6ca9 100644
--- a/cp/app/Controllers/SystemController.php
+++ b/cp/app/Controllers/SystemController.php
@@ -892,11 +892,11 @@ class SystemController extends Controller
[ $args ]);
if ($tld) {
- $createPrices = $db->selectRow('SELECT * FROM domain_price WHERE tldid = ? AND registrar_id = ? AND command = ?', [$tld['id'], NULL, 'create']);
- $renewPrices = $db->selectRow('SELECT * FROM domain_price WHERE tldid = ? AND registrar_id = ? AND command = ?', [$tld['id'], NULL, 'renew']);
- $transferPrices = $db->selectRow('SELECT * FROM domain_price WHERE tldid = ? AND registrar_id = ? AND command = ?', [$tld['id'], NULL, 'transfer']);
- $tld_restore = $db->selectRow('SELECT * FROM domain_restore_price WHERE tldid = ? AND registrar_id = ? ',
- [ $tld['id'], NULL ]);
+ $createPrices = $db->selectRow('SELECT * FROM domain_price WHERE tldid = ? AND registrar_id IS NULL AND command = ?', [$tld['id'], 'create']);
+ $renewPrices = $db->selectRow('SELECT * FROM domain_price WHERE tldid = ? AND registrar_id IS NULL AND command = ?', [$tld['id'], 'renew']);
+ $transferPrices = $db->selectRow('SELECT * FROM domain_price WHERE tldid = ? AND registrar_id IS NULL AND command = ?', [$tld['id'], 'transfer']);
+ $tld_restore = $db->selectRow('SELECT * FROM domain_restore_price WHERE tldid = ? AND registrar_id IS NULL ',
+ [ $tld['id'] ]);
$premium_pricing = $db->selectRow('SELECT * FROM premium_domain_pricing WHERE tld_id = ?',
[ $tld['id'] ]);
$premium_categories = $db->select('SELECT * FROM premium_domain_categories');
diff --git a/cp/resources/views/admin/domains/createDomain.twig b/cp/resources/views/admin/domains/createDomain.twig
index 8f06f79..6235f31 100644
--- a/cp/resources/views/admin/domains/createDomain.twig
+++ b/cp/resources/views/admin/domains/createDomain.twig
@@ -207,7 +207,7 @@
-
+
@@ -267,6 +267,7 @@ document.addEventListener("DOMContentLoaded", function() {
const removeNameserverBtn = document.getElementById('removeNameserver');
const nameserverFields = document.getElementById('nameserverFields');
const authInfoField = document.getElementById('authInfo');
+ const registrarDropdown = document.getElementById('registrarDropdown');
// Display year value from slider
yearSlider.addEventListener('input', function() {
@@ -371,7 +372,7 @@ document.addEventListener("DOMContentLoaded", function() {
}
}
- function getDomainPrice(domain, years) {
+ function getDomainPrice(domain, years, registrarId) {
const tld = extractTLD(domain);
if (!tld) {
return Promise.reject("Invalid TLD");
@@ -396,12 +397,22 @@ document.addEventListener("DOMContentLoaded", function() {
(!record.years_of_promotion || record.years_of_promotion >= years)
);
- // Find the regular price for the TLD
- const tldData = pricingData.records.find(record =>
+ // Find the regular price for the TLD with registrar ID
+ let tldData = pricingData.records.find(record =>
record.tldid && tldRegex.test(record.tldid.tld.toLowerCase()) &&
- record.command === 'create'
+ record.command === 'create' &&
+ record.registrar_id == registrarId
);
+ // If no registrar-specific price found, find the generic price
+ if (!tldData) {
+ tldData = pricingData.records.find(record =>
+ record.tldid && tldRegex.test(record.tldid.tld.toLowerCase()) &&
+ record.command === 'create' &&
+ record.registrar_id == null
+ );
+ }
+
if (tldData) {
const priceField = `m${years * 12}`;
let price = parseFloat(tldData[priceField]);
@@ -434,7 +445,8 @@ document.addEventListener("DOMContentLoaded", function() {
function updatePrice() {
if (domainInput.value) {
- getDomainPrice(domainInput.value, yearInput.value).then(price => {
+ const registrarId = registrarDropdown.value;
+ getDomainPrice(domainInput.value, yearInput.value, registrarId).then(price => {
priceValue.innerText = formatPrice(price);
priceDisplay.style.display = 'block';
});
@@ -445,6 +457,7 @@ document.addEventListener("DOMContentLoaded", function() {
domainInput.addEventListener('input', updatePrice);
yearInput.addEventListener('input', updatePrice);
+ registrarDropdown.addEventListener('change', updatePrice);
});
{% endblock %}
\ No newline at end of file
diff --git a/cp/resources/views/admin/domains/renewDomain.twig b/cp/resources/views/admin/domains/renewDomain.twig
index 8d71ecc..9fb09fe 100644
--- a/cp/resources/views/admin/domains/renewDomain.twig
+++ b/cp/resources/views/admin/domains/renewDomain.twig
@@ -83,7 +83,8 @@ document.addEventListener("DOMContentLoaded", function() {
yearSlider.addEventListener('input', function() {
yearValueDisplay.textContent = `${yearSlider.value} Year${yearSlider.value > 1 ? 's' : ''}`;
});
-
+
+ const registrarId = "{{ registrars.id }}"; // Embedded securely in JavaScript
const domainInput = document.getElementById('domainName');
const yearInput = document.getElementById('renewalYears');
const priceDisplay = document.getElementById('domainPriceDisplay');
@@ -102,7 +103,7 @@ document.addEventListener("DOMContentLoaded", function() {
}
}
- function getDomainPrice(domain, years) {
+ function getDomainPrice(domain, years, registrarId) {
const tld = extractTLD(domain);
if (!tld) {
return Promise.reject("Invalid TLD");
@@ -127,12 +128,22 @@ document.addEventListener("DOMContentLoaded", function() {
(!record.years_of_promotion || record.years_of_promotion >= years)
);
- // Find the regular price for the TLD
- const tldData = pricingData.records.find(record =>
+ // Find the regular price for the TLD with registrar ID
+ let tldData = pricingData.records.find(record =>
record.tldid && tldRegex.test(record.tldid.tld.toLowerCase()) &&
- record.command === 'renew'
+ record.command === 'renew' &&
+ record.registrar_id == registrarId
);
+ // If no registrar-specific price found, find the generic price
+ if (!tldData) {
+ tldData = pricingData.records.find(record =>
+ record.tldid && tldRegex.test(record.tldid.tld.toLowerCase()) &&
+ record.command === 'renew' &&
+ record.registrar_id == null
+ );
+ }
+
if (tldData) {
const priceField = `m${years * 12}`;
let price = parseFloat(tldData[priceField]);
@@ -164,8 +175,8 @@ document.addEventListener("DOMContentLoaded", function() {
}
function updatePrice() {
- if (domainInput.value) {
- getDomainPrice(domainInput.value, yearInput.value).then(price => {
+ if (domainInput.textContent) {
+ getDomainPrice(domainInput.textContent, yearInput.value, registrarId).then(price => {
priceValue.innerText = formatPrice(price);
priceDisplay.style.display = 'block';
}).catch(error => {
diff --git a/cp/resources/views/admin/domains/requestTransfer.twig b/cp/resources/views/admin/domains/requestTransfer.twig
index 1a8fb3f..454d84e 100644
--- a/cp/resources/views/admin/domains/requestTransfer.twig
+++ b/cp/resources/views/admin/domains/requestTransfer.twig
@@ -101,6 +101,7 @@ document.addEventListener("DOMContentLoaded", function() {
const yearInput = document.getElementById('transferYears');
const priceDisplay = document.getElementById('domainPriceDisplay');
const priceValue = document.getElementById('domainPrice');
+ const registrarDropdown = document.getElementById('registrarDropdown');
function extractTLD(domain) {
const parts = domain.split('.');
@@ -115,7 +116,7 @@ document.addEventListener("DOMContentLoaded", function() {
}
}
- function getDomainPrice(domain, years) {
+ function getDomainPrice(domain, years, registrarId) {
const tld = extractTLD(domain);
if (!tld) {
return Promise.reject("Invalid TLD");
@@ -140,12 +141,22 @@ document.addEventListener("DOMContentLoaded", function() {
(!record.years_of_promotion || record.years_of_promotion >= years)
);
- // Find the regular price for the TLD
- const tldData = pricingData.records.find(record =>
+ // Find the regular price for the TLD with registrar ID
+ let tldData = pricingData.records.find(record =>
record.tldid && tldRegex.test(record.tldid.tld.toLowerCase()) &&
- record.command === 'transfer'
+ record.command === 'transfer' &&
+ record.registrar_id == registrarId
);
+ // If no registrar-specific price found, find the generic price
+ if (!tldData) {
+ tldData = pricingData.records.find(record =>
+ record.tldid && tldRegex.test(record.tldid.tld.toLowerCase()) &&
+ record.command === 'transfer' &&
+ record.registrar_id == null
+ );
+ }
+
if (tldData) {
const priceField = `m${years * 12}`;
let price = parseFloat(tldData[priceField]);
@@ -178,7 +189,8 @@ document.addEventListener("DOMContentLoaded", function() {
function updatePrice() {
if (domainInput.value) {
- getDomainPrice(domainInput.value, yearInput.value).then(price => {
+ const registrarId = registrarDropdown.value;
+ getDomainPrice(domainInput.value, yearInput.value, registrarId).then(price => {
priceValue.innerText = formatPrice(price);
priceDisplay.style.display = 'block';
});
@@ -189,6 +201,7 @@ document.addEventListener("DOMContentLoaded", function() {
domainInput.addEventListener('input', updatePrice);
yearInput.addEventListener('input', updatePrice);
+ registrarDropdown.addEventListener('change', updatePrice);
});
{% endblock %}
\ No newline at end of file