dolibarr 20.0.0
checkVatGr.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2016 Spiros Ioannou
3 * Copyright (C) 2017 Marios Kaintatzis
4 * Copyright (C) 2023 Nick Fragoulis
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26require "../../main.inc.php";
27
28$username = getDolGlobalString('AADE_WEBSERVICE_USER'); // Get username from request
29$password = getDolGlobalString('AADE_WEBSERVICE_KEY'); // Get password from request
30$myafm = preg_replace('/\D/', '', getDolGlobalString('MAIN_INFO_TVAINTRA')); // Get Vat from request after removing non-digit characters
31$afm = GETPOST('afm'); // Get client Vat from request
32
33// Make call to check VAT for Greek client
34$result = checkVATGR($username, $password, $myafm, $afm);
35
36top_httphead('application/json');
37echo json_encode($result); // Encode the result as JSON and output
38
47function checkVATGR($username, $password, $AFMcalledby, $AFMcalledfor)
48{
49 /*
50 $WS_DOL_URL_WSDL = "https://www1.gsis.gr/webtax2/wsgsis/RgWsPublic/RgWsPublicPort?WSDL";
51
52 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
53 $params = getSoapParams();
54 //ini_set('default_socket_timeout', $params['response_timeout']);
55 $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']);
56
57 $soapclient->soap_defencoding = 'utf-8';
58 $soapclient->xml_encoding = 'utf-8';
59 $soapclient->decode_utf8 = false;
60
61 // Check for an error
62 $err = $soapclient->getError();
63 if ($err) {
64 dol_syslog("Constructor error ".$WS_DOL_URL, LOG_ERR);
65 }
66
67 ...
68
69
70 */
71
72 // TODO Replace this with code using nusoap_client(), see previous commented code, and remove phpstan tag
73 // @phpstan-ignore-next-line
74 $client = new SoapClient("https://www1.gsis.gr/webtax2/wsgsis/RgWsPublic/RgWsPublicPort?WSDL", array('trace' => true));
75 $authHeader = new stdClass();
76 $authHeader->UsernameToken = new stdClass();
77 $authHeader->UsernameToken->Username = "$username";
78 $authHeader->UsernameToken->Password = "$password";
79 $Headers = array();
80 $Headers[] = new SoapHeader('https://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd', 'Security', $authHeader, true);
81 $client->__setSoapHeaders($Headers);
82 $result = $client->rgWsPublicAfmMethod(
83 array(
84 'afmCalledBy' => "$AFMcalledby",
85 'afmCalledFor' => "$AFMcalledfor",
86 )
87 );
88
89 return $result;
90}
checkVATGR($username, $password, $AFMcalledby, $AFMcalledfor)
Request VAT details.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.