* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /** * \file htdocs/societe/checkvat/checkVatPopup.php * \ingroup societe * \brief Popup screen to validate VAT * \version $Id$ */ require ("../../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/includes/nusoap/lib/nusoap.php"); $langs->load("companies"); $WS_DOL_URL='http://ec.europa.eu/taxation_customs/vies/api/checkVatPort'; $WS_METHOD ='checkVat'; top_htmlhead("", $langs->trans("VATIntraCheckableOnEUSite")); print ''; print '
'; print '
'; print_fiche_titre($langs->trans("VATIntraCheckableOnEUSite"),'','setup'); if (! $_REQUEST["vatNumber"]) { print '
'; print ''.$langs->transnoentities("ErrorFieldRequired",$langs->trans("VATIntraShort")).'
'; } else { $countryCode=substr($_REQUEST["vatNumber"],0,2); $vatNumber=substr($_REQUEST["vatNumber"],2); print ''.$langs->trans("Country").': '.$countryCode.'
'; print ''.$langs->trans("VATIntraShort").': '.$vatNumber.'
'; print '
'; // Set the parameters to send to the WebService $parameters = array("countryCode" => $countryCode, "vatNumber" => $vatNumber); // Set the WebService URL dol_syslog("Create nusoap_client for URL=".$WS_DOL_URL); $soapclient = new nusoap_client($WS_DOL_URL); // Call the WebService and store its result in $result. dol_syslog("Call method ".$WS_METHOD); $result = $soapclient->call($WS_METHOD,$parameters); // print "x".is_array($result)."i"; // print_r($result); // print $soapclient->request.'
'; // print $soapclient->response.'
'; $messagetoshow=''; print ''.$langs->trans("Response").':
'; // Service indisponible if (! is_array($result) || preg_match('/SERVICE_UNAVAILABLE/i',$result['faultstring'])) { print ''.$langs->trans("ErrorServiceUnavailableTryLater").'
'; $messagetoshow=$soapclient->response; } elseif (preg_match('/TIMEOUT/i',$result['faultstring'])) { print ''.$langs->trans("ErrorServiceUnavailableTryLater").'
'; $messagetoshow=$soapclient->response; } elseif (preg_match('/SERVER_BUSY/i',$result['faultstring'])) { print ''.$langs->trans("ErrorServiceUnavailableTryLater").'
'; $messagetoshow=$soapclient->response; } // Syntaxe ko elseif (preg_match('/INVALID_INPUT/i',$result['faultstring']) || ($result['requestDate'] && ! $result['valid'])) { if ($result['requestDate']) print $langs->trans("Date").': '.$result['requestDate'].'
'; print $langs->trans("VATIntraSyntaxIsValid").': '.$langs->trans("No").' (Might be a non europeen VAT)
'; print $langs->trans("VATIntraValueIsValid").': '.$langs->trans("No").' (Might be a non europeen VAT)
'; //$messagetoshow=$soapclient->response; } else { // Syntaxe ok if ($result['requestDate']) print $langs->trans("Date").': '.$result['requestDate'].'
'; print $langs->trans("VATIntraSyntaxIsValid").': '.$langs->trans("Yes").'
'; print $langs->trans("VATIntraValueIsValid").': '; if (preg_match('/MS_UNAVAILABLE/i',$result['faultstring'])) { print ''.$langs->trans("ErrorVATCheckMS_UNAVAILABLE",$countryCode).'
'; } else { if ($result['valid']) { print ''.$langs->trans("Yes").''; print '
'; print $langs->trans("Name").': '.$result['name'].'
'; print $langs->trans("Address").': '.$result['address'].'
'; } else { print ''.$langs->trans("No").''; print '
'; } } } } print '
'; print $langs->trans("VATIntraManualCheck",$langs->trans("VATIntraCheckURL"),$langs->trans("VATIntraCheckURL")).'
'; print '
'; print '
'; if ($messagetoshow) { print '

Error returned:
'; print nl2br($messagetoshow); } llxFooter('$Date$ - $Revision$',0); ?>