24if (! defined(
'NOTOKENRENEWAL')) {
25 define(
'NOTOKENRENEWAL',
'1');
28require
"../../main.inc.php";
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
30require_once NUSOAP_PATH.
'/nusoap.php';
32$langs->load(
"companies");
35$WS_DOL_URL =
'https://ec.europa.eu/taxation_customs/vies/services/checkVatService';
37$WS_DOL_URL_WSDL =
'https://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl';
38$WS_METHOD =
'checkVat';
41$conf->dol_hide_topmenu = 1;
42$conf->dol_hide_leftmenu = 1;
44llxHeader(
'', $langs->trans(
"VATIntraCheckableOnEUSite"));
46print
'<div class="vatcheckarea margintoponly marginbottomonly">';
48print
load_fiche_titre($langs->trans(
"VATIntraCheckableOnEUSite"),
'',
'title_setup');
50$vatNumber =
GETPOST(
"vatNumber",
'alpha');
54 print
'<span class="error">'.$langs->transnoentities(
"ErrorFieldRequired", $langs->trans(
"VATIntraShort")).
'</span><br>';
56 $vatNumber = preg_replace(
'/\^\w/',
'', $vatNumber);
57 $vatNumber = str_replace(array(
' ',
'.'),
'', $vatNumber);
58 $countryCode = substr($vatNumber, 0, 2);
59 $vatNumber = substr($vatNumber, 2);
61 print
'<b>'.$langs->trans(
"Country").
'</b>: '.$countryCode.
'<br>';
62 print
'<b>'.$langs->trans(
"VATIntraShort").
'</b>: '.$vatNumber.
'<br>';
66 $parameters = array(
"countryCode" => $countryCode,
67 "vatNumber" => $vatNumber);
70 dol_syslog(
"Create nusoap_client for URL=".$WS_DOL_URL.
" WSDL=".$WS_DOL_URL_WSDL);
71 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
75 $soapclient =
new nusoap_client($WS_DOL_URL_WSDL,
true, $params[
'proxy_host'], $params[
'proxy_port'], $params[
'proxy_login'], $params[
'proxy_password'], $params[
'connection_timeout'], $params[
'response_timeout']);
76 $soapclient->soap_defencoding =
'utf-8';
77 $soapclient->xml_encoding =
'utf-8';
78 $soapclient->decode_utf8 =
false;
81 $err = $soapclient->getError();
83 dol_syslog(
"Constructor error ".$WS_DOL_URL, LOG_ERR);
88 $result = $soapclient->call($WS_METHOD, $parameters);
98 print
'<b>'.$langs->trans(
"Response").
'</b>:<br>';
101 if (!is_array($result) || preg_match(
'/SERVICE_UNAVAILABLE/i', $result[
'faultstring'])) {
102 print
'<span class="error">'.$langs->trans(
"ErrorServiceUnavailableTryLater").
'</span><br>';
103 $messagetoshow = $soapclient->response;
104 } elseif (preg_match(
'/TIMEOUT/i', $result[
'faultstring'])) {
105 print
'<span class="error">'.$langs->trans(
"ErrorServiceUnavailableTryLater").
'</span><br>';
106 $messagetoshow = $soapclient->response;
107 } elseif (preg_match(
'/SERVER_BUSY/i', $result[
'faultstring'])) {
108 print
'<span class="error">'.$langs->trans(
"ErrorServiceUnavailableTryLater").
'</span><br>';
109 $messagetoshow = $soapclient->response;
110 } elseif ($result[
'faultstring']) {
111 print
'<span class="error">'.$langs->trans(
"Error").
'</span><br>';
112 $messagetoshow = $result[
'faultstring'];
113 } elseif (preg_match(
'/INVALID_INPUT/i', $result[
'faultstring'])
114 || ($result[
'requestDate'] && !$result[
'valid'])) {
116 if ($result[
'requestDate']) {
117 print $langs->trans(
"Date").
': '.$result[
'requestDate'].
'<br>';
119 print $langs->trans(
"VATIntraSyntaxIsValid").
': <span class="error">'.$langs->trans(
"No").
'</span> (Might be a non europeen VAT)<br>';
120 print $langs->trans(
"ValueIsValid").
': <span class="error">'.$langs->trans(
"No").
'</span> (Might be a non europeen VAT)<br>';
124 if ($result[
'requestDate']) {
125 print $langs->trans(
"Date").
': '.$result[
'requestDate'].
'<br>';
127 print $langs->trans(
"VATIntraSyntaxIsValid").
': <span class="ok">'.$langs->trans(
"Yes").
'</span><br>';
128 print $langs->trans(
"ValueIsValid").
': ';
129 if (preg_match(
'/MS_UNAVAILABLE/i', $result[
'faultstring'])) {
130 print
'<span class="error">'.$langs->trans(
"ErrorVATCheckMS_UNAVAILABLE", $countryCode).
'</span><br>';
132 if (!empty($result[
'valid']) && ($result[
'valid'] == 1 || $result[
'valid'] ==
'true')) {
133 print
'<span class="ok">'.$langs->trans(
"Yes").
'</span>';
135 print $langs->trans(
"Name").
': '.$result[
'name'].
'<br>';
136 print $langs->trans(
"Address").
': '.$result[
'address'].
'<br>';
138 print
'<span class="error">'.$langs->trans(
"No").
'</span>';
152print $langs->trans(
"VATIntraManualCheck", $langs->trans(
"VATIntraCheckURL"), $langs->transnoentitiesnoconv(
"VATIntraCheckURL")).
'<br>';
154print
'<div class="center"><input type="button" class="button" value="'.$langs->trans(
"CloseWindow").
'" onclick="window.close()"></div>';
158 print
"\n".
'Error returned:<br>';
159 print nl2br($messagetoshow);
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
getSoapParams()
Return array to use for SoapClient constructor.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.