Jump to content
Sign in to follow this  
doigro

Configurare CNP/TVA

Recommended Posts

Am instalat ultima versiune 1.3.1. si la inregistrarea unui client nou apare un camp CNP care nu este obligatoriu.

Ma intereseaza sa recunoasca formatul romanesc de CNP si respectiv de TVA si sa il fac obligatoriu.
Cum se poate proceda?

Share this post


Link to post
Share on other sites

Pentru dezactivarea verificarii corectitudinii am gasit o metoda poate neeleganta dar eficienta. Orice varianta de text introdusa este validata.

Linia 750 - 823

/**
* Check for Dni validity
*
* @param string $dni to validate
* @return int
*/
static public function isDni($dni)
{
/*
Return code:
1 : It's Ok
0 : Bad format for DNI
-1 : DNI duplicate
-2 : NIF error
-3 : CIF error
-4 : NIE error
*/

if (!$dni)
return 1;

$dni = strtoupper($dni);
if (!preg_match('/((^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$)/', $dni))
return 1;

$result = Db::getInstance()->getValue('
SELECT COUNT(`id_customer`) AS total
FROM `'._DB_PREFIX_.'customer`
WHERE `dni` = \''.pSQL($dni).'\'
');
if($result)
return -1;

for ($i=0;$i<9;$i++)
$char[$i] = substr($dni, $i, 1);
// 12345678T
if (preg_match('/(^[0-9]{8}[A-Z]{1}$)/', $dni))
if ($char[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($dni, 0, 8) % 23, 1))
return 1;
else
return 1;

$sum = $char[2] + $char[4] + $char[6];
for ($i = 1; $i < 8; $i += 2)
$sum += substr((2 * $char[$i]),0,1) + substr((2 * $char[$i]),1,1);

$n = 10 - substr($sum, strlen($sum) - 1, 1);

if (preg_match('/^[KLM]{1}/', $dni))
if ($char[8] == chr(64 + $n))
return 1;
else
return 1;

if (preg_match('/^[ABCDEFGHJNPQRSUVW]{1}/', $dni))
if ($char[8] == chr(64 + $n) || $char[8] == substr($n, strlen($n) - 1, 1))
return 1;
else
return 1;

if (preg_match('/^[T]{1}/', $dni))
if ($char[8] == preg_match('/^[T]{1}[A-Z0-9]{8}$/', $dni))
return 1;
else
return 1;

if (preg_match('/^[XYZ]{1}/', $dni))
if ($char[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr(str_replace(array('X','Y','Z'), array('0','1','2'), $dni), 0, 8) % 23, 1))
return 1;
else
return 1;

return 0;
}

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More