Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lang/overrides/english.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@
$_LANG['fiIdentificationPassport'] = 'Passport/ID number for Individuals';
$_LANG['fiIdentificationSocialSecurityNumber'] = 'Social Security Number for Individuals';
$_LANG['fiIdentificationBirthDate'] = 'Birthday for Foreign Private Individuals (YYYY-MM-DD)';

$_LANG['itIdentificationCORI'] = 'Company or Individual Codice Fiscale';
Comment thread
YumeChaan marked this conversation as resolved.
Outdated
$_LANG['seIdentificationCORI'] = 'Company or Individual ID';
$_LANG['fiIdentificationCORI'] = 'Company or Individual ID';
Comment thread
YumeChaan marked this conversation as resolved.
Outdated
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,29 @@
use OpenProvider\WhmcsRegistrar\enums\DatabaseTable;
use OpenProvider\WhmcsRegistrar\src\Configuration;
use OpenProvider\WhmcsRegistrar\helpers\DB;
use OpenProvider\WhmcsRegistrar\helpers\DomainFullNameToDomainObject;
use WHMCS\Database\Capsule;

class ClientAreaFooterController
{
private const ID_NUMBER_REQUIRED_TLDS = [
'es',
'pt',
'se',
'com.es',
'nom.es',
'edu.es',
'org.es',
'it',
'fi',
];

private const ES_SECOND_LEVEL_TLDS = [
'com.es',
'nom.es',
'edu.es',
'org.es',
];

public function output($vars)
{
GLOBAL $_LANG;
Expand All @@ -18,10 +36,11 @@ public function output($vars)

if ($idnumbermod) {

$template = $vars['templatefile'];
$template = $vars['templatefile'] ?? '';
$js = '';
$check_tempaltes = array('account-contacts-manage', 'account-contacts-new');
unset($_SESSION['msg']);
if (in_array($template, $check_tempaltes)) {
if (in_array($template, $check_tempaltes, true)) {
$contactid = $vars['contactid'];

if ($_SESSION['Contact_Pending_Update']) {
Expand Down Expand Up @@ -61,11 +80,31 @@ public function output($vars)
}
}

if ($template == 'clientareadomaincontactinfo') {
$domain = DomainFullNameToDomainObject::convert($vars['domain']);
$idNumberName = $_LANG[sprintf('%s%s', $domain->extension ?? 'es', 'IdentificationCORI')];
$js = '$("#frmDomainContactModification").submit(function(e){ e.preventDefault(); setSessionContact(); $(this).unbind("submit").submit(); }); $("input[name=\"contactdetails[Owner][Company or Individual Id]\"]").attr("required" , true); $("input[name=\"contactdetails[Admin][Company or Individual Id]\"]").attr("required" , true); $("input[name=\"contactdetails[Tech][Company or Individual Id]\"]").attr("required" , true); $("input[name=\"contactdetails[Billing][Company or Individual Id]\"]").attr("required" , true); $("label:contains(\"Company or Individual Id\")").html("' . $idNumberName . '");';
$js .= '$("#frmDomainContactModification").submit(function(e){ e.preventDefault(); setSessionContact(); $(this).unbind("submit").submit(); }); $("input[name=\"contactdetails[Owner][Vat or Tax ID]\"]").attr("required" , true); $("input[name=\"contactdetails[Admin][Vat or Tax ID]\"]").attr("required" , true); $("input[name=\"contactdetails[Tech][Vat or Tax ID]\"]").attr("required" , true); $("input[name=\"contactdetails[Billing][Vat or Tax ID]\"]").attr("required" , true); $("label:contains(\"Vat or Tax ID\")").html("' . $idNumberName . '");';
if ($template === 'clientareadomaincontactinfo') {
$domainName = $vars['domain'] ?? '';
$tld = $this->getFullTld($domainName);

if (!$this->isIdNumberRequiredTld($tld)) {
$js = '$("input[name^=\"contactdetails\"][name$=\"[Company or Individual Id]\"]").closest(".form-group").remove();';
$js .= '$("input[name^=\"contactdetails\"][name$=\"[Vat or Tax ID]\"]").closest(".form-group").remove();';
} else {
$langKey = $this->getIdNumberLangKey($tld);

$idNumberName = $_LANG[$langKey] ?? 'Company or Individual ID';
$idNumberNameJs = json_encode($idNumberName);
Comment thread
Copilot marked this conversation as resolved.
Outdated

$js = '$("#frmDomainContactModification").submit(function(e){
e.preventDefault();
setSessionContact();
$(this).unbind("submit").submit();
});';
Comment thread
YumeChaan marked this conversation as resolved.

$js .= '$("input[name^=\"contactdetails\"][name$=\"[Company or Individual Id]\"]").attr("required", true);';
$js .= '$("input[name^=\"contactdetails\"][name$=\"[Vat or Tax ID]\"]").attr("required", true);';

$js .= '$("label:contains(\"Company or Individual Id\")").html(' . $idNumberNameJs . ');';
$js .= '$("label:contains(\"Vat or Tax ID\")").html(' . $idNumberNameJs . ');';
Comment thread
Copilot marked this conversation as resolved.
Outdated
Comment thread
YumeChaan marked this conversation as resolved.
Outdated
}
}

$systemurl = $vars['systemurl'];
Expand Down Expand Up @@ -123,4 +162,34 @@ function setSessionContact(){
HTML;
}
}


private function isIdNumberRequiredTld(string $tld): bool
{
return in_array(strtolower($tld), self::ID_NUMBER_REQUIRED_TLDS, true);
}

private function getFullTld(string $domainName): string
{
$domainName = strtolower($domainName);

foreach (self::ES_SECOND_LEVEL_TLDS as $multiTld) {
if (str_ends_with($domainName, '.' . $multiTld)) {
return $multiTld;
}
}
Comment thread
YumeChaan marked this conversation as resolved.

$labels = array_values(array_filter(explode('.', $domainName)));

return !empty($labels) ? end($labels) : '';
}
Comment thread
YumeChaan marked this conversation as resolved.
Outdated

private function getIdNumberLangKey(string $tld): string
{
if (in_array($tld, self::ES_SECOND_LEVEL_TLDS, true)) {
return 'esIdentificationCORI';
}

return $tld . 'IdentificationCORI';
}
}