25if (! defined(
'NOTOKENRENEWAL')) {
26 define(
'NOTOKENRENEWAL',
'1');
29require
"../../main.inc.php";
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
31require_once NUSOAP_PATH.
'/nusoap.php';
39$langs->load(
"companies");
42$WS_DOL_URL =
'https://ec.europa.eu/taxation_customs/vies/services/checkVatService';
44$WS_DOL_URL_WSDL =
'https://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl';
45$WS_METHOD =
'checkVat';
48$conf->dol_hide_topmenu = 1;
49$conf->dol_hide_leftmenu = 1;
51llxHeader(
'', $langs->trans(
"VATIntraCheckableOnEUSite"),
'',
'', 0, 0,
'',
'',
'',
'marginpopup');
53print
'<div class="vatcheckarea margintoponly marginbottomonly">';
55print
load_fiche_titre($langs->trans(
"VATIntraCheckableOnEUSite"),
'',
'title_setup');
57$vatNumber =
GETPOST(
"vatNumber",
'alpha');
61 print
'<span class="error">'.$langs->transnoentities(
"ErrorFieldRequired", $langs->trans(
"VATIntraShort")).
'</span><br>';
63 $vatNumber = preg_replace(
'/\^\w/',
'', $vatNumber);
64 $vatNumber = str_replace(array(
' ',
'.'),
'', $vatNumber);
65 $countryCode = substr($vatNumber, 0, 2);
66 $vatNumber = substr($vatNumber, 2);
68 print
'<b>'.$langs->trans(
"Country").
'</b>: '.$countryCode.
'<br>';
69 print
'<b>'.$langs->trans(
"VATIntraShort").
'</b>: '.$vatNumber.
'<br>';
74 "countryCode" => $countryCode,
75 "vatNumber" => $vatNumber,
79 dol_syslog(
"Create nusoap_client for URL=".$WS_DOL_URL.
" WSDL=".$WS_DOL_URL_WSDL);
80 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
84 $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']);
85 $soapclient->soap_defencoding =
'utf-8';
86 $soapclient->xml_encoding =
'utf-8';
87 $soapclient->decode_utf8 =
false;
90 $err = $soapclient->getError();
92 dol_syslog(
"Constructor error ".$WS_DOL_URL, LOG_ERR);
97 $result = $soapclient->call($WS_METHOD, $parameters);
100 print
'<b>'.$langs->trans(
"Response").
'</b>:<br>';
101 $faultstring = $result[
'faultstring'] ??
'';
103 if (!is_array($result) || preg_match(
'/SERVICE_UNAVAILABLE/i', $faultstring)) {
104 print
'<span class="error">'.$langs->trans(
"ErrorServiceUnavailableTryLater").
'</span><br>';
105 $messagetoshow = $soapclient->response;
106 } elseif (preg_match(
'/TIMEOUT/i', $faultstring)) {
107 print
'<span class="error">'.$langs->trans(
"ErrorServiceUnavailableTryLater").
'</span><br>';
108 $messagetoshow = $soapclient->response;
109 } elseif (preg_match(
'/SERVER_BUSY/i', $faultstring)) {
110 print
'<span class="error">'.$langs->trans(
"ErrorServiceUnavailableTryLater").
'</span><br>';
111 $messagetoshow = $soapclient->response;
112 } elseif ($faultstring) {
113 print
'<span class="error">'.$langs->trans(
"Error").
'</span><br>';
114 $messagetoshow = $faultstring;
115 } elseif (preg_match(
'/INVALID_INPUT/i', $faultstring)
116 || ($result[
'requestDate'] && !$result[
'valid'])) {
118 if ($result[
'requestDate']) {
119 print $langs->trans(
"Date").
': '.$result[
'requestDate'].
'<br>';
121 print $langs->trans(
"VATIntraSyntaxIsValid").
': <span class="error">'.$langs->trans(
"No").
'</span> (Might be a non europeen VAT)<br>';
122 print $langs->trans(
"ValueIsValid").
': <span class="error">'.$langs->trans(
"No").
'</span> (Might be a non europeen VAT)<br>';
126 if ($result[
'requestDate']) {
127 print $langs->trans(
"Date").
': '.$result[
'requestDate'].
'<br>';
129 print $langs->trans(
"VATIntraSyntaxIsValid").
': <span class="ok">'.$langs->trans(
"Yes").
'</span><br>';
130 print $langs->trans(
"ValueIsValid").
': ';
131 if (preg_match(
'/MS_UNAVAILABLE/i', $faultstring)) {
132 print
'<span class="error">'.$langs->trans(
"ErrorVATCheckMS_UNAVAILABLE", $countryCode).
'</span><br>';
134 if (!empty($result[
'valid']) && ($result[
'valid'] == 1 || $result[
'valid'] ==
'true')) {
135 print
'<span class="ok">'.$langs->trans(
"Yes").
'</span>';
137 print $langs->trans(
"Name").
': '.$result[
'name'].
'<br>';
138 print $langs->trans(
"Address").
': '.$result[
'address'].
'<br>';
140 print
'<span class="error">'.$langs->trans(
"No").
'</span>';
154print
'<span class="opacitymedium small">'.$langs->trans(
"VATIntraManualCheck", $langs->trans(
"VATIntraCheckURL"), $langs->transnoentitiesnoconv(
"VATIntraCheckURL")).
'</span><br>';
156print
'<div class="center"><input type="button" class="button small" value="'.$langs->trans(
"CloseWindow").
'" onclick="window.close()"></div>';
160 print
'<span class="opacitymedium small">Error returned:</small>'.
"\n";
161 print
'<textarea class="small centpercent">';
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
getSoapParams()
Return array to use for SoapClient constructor.
load_fiche_titre($title, $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_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...