diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index a0c935413f367..0a7770bcc3dc5 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -6,6 +6,7 @@ * Copyright (C) 2011-2017 Philippe Grand * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2017 Rui Strecht + * Copyright (C) 2023 Nick Fragoulis * * 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 @@ -233,6 +234,14 @@ dolibarr_set_const($db, "MAIN_INFO_LOCALTAX_CALC2", GETPOST("clt2", 'aZ09'), 'chaine', 0, '', $conf->entity); } + // Credentials for AADE webservices, applicable only for Greece + if ($mysoc->country_code == 'GR') { + dolibarr_set_const($db, "MYDATA_AADE_USER", GETPOST("MYDATA_AADE_USER", 'alpha'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MYDATA_AADE_KEY", GETPOST("MYDATA_AADE_KEY", 'alpha'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "AADE_WEBSERVICE_USER", GETPOST("AADE_WEBSERVICE_USER", 'alpha'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "AADE_WEBSERVICE_KEY", GETPOST("AADE_WEBSERVICE_KEY", 'alpha'), 'chaine', 0, '', $conf->entity); + } + // Remove constant MAIN_INFO_SOCIETE_SETUP_TODO_WARNING dolibarr_del_const($db, "MAIN_INFO_SOCIETE_SETUP_TODO_WARNING", $conf->entity); @@ -847,6 +856,41 @@ print ""; +// AADE webservices credentials, applicable only for Greece +if ($mysoc->country_code == 'GR') { + print load_fiche_titre($langs->trans("AADEWebserviceCredentials"), '', ''); + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + print ''; + + print ''; + + print ''; + + print ''; + + print '
'; + + print "
'.$langs->trans("AccountParameter").''.$langs->trans("Value").'
'; + print ''.$langs->trans("MYDATA_AADE_USER").''; + print '
'; + print ''.$langs->trans("MYDATA_AADE_KEY").''; + print '
'; + print ''.$langs->trans("AADE_WEBSERVICE_USER").''; + print '
'; + print ''.$langs->trans("AADE_WEBSERVICE_KEY").''; + print '
"; +} + print $form->buttonsSaveCancel("Save", ''); print ''; diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 702a22ccc4d70..2b1b6038807dd 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -510,3 +510,4 @@ ShowSocialNetworks=Show social networks HideSocialNetworks=Hide social networks ExternalSystemID=External system ID IDOfPaymentInAnExternalSystem=ID of the payment mode into an external system (like Stripe, Paypal, ...) +AADEWebserviceCredentials=AADE Webservice Credentials diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index b69448ff7fa8a..69960414e0b87 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -13,6 +13,8 @@ * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2018-2022 Frédéric France + * Copyright (C) 2022-2023 George Gkantinas + * Copyright (C) 2023 Nick Fragoulis * * 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 @@ -63,6 +65,12 @@ require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; } +if ($mysoc->country_code == 'GR') { + $u = getDolGlobalString('AADE_WEBSERVICE_USER'); + $p = getDolGlobalString('AADE_WEBSERVICE_KEY'); + $myafm = getDolGlobalString('MAIN_INFO_TVAINTRA'); +} + // Load translation files required by the page @@ -385,13 +393,13 @@ } if ($action == 'set_localtax1') { - //obtidre selected del combobox + //get selected from combobox $value = GETPOST('lt1'); $object->fetch($socid); $res = $object->setValueFrom('localtax1_value', $value, '', null, 'text', '', $user, 'COMPANY_MODIFY'); } if ($action == 'set_localtax2') { - //obtidre selected del combobox + //get selected from combobox $value = GETPOST('lt2'); $object->fetch($socid); $res = $object->setValueFrom('localtax2_value', $value, '', null, 'text', '', $user, 'COMPANY_MODIFY'); @@ -895,7 +903,7 @@ break; } } - // Gestion du logo de la société + // Company logo management // Update linked member @@ -1187,7 +1195,7 @@ $object->logo = (isset($_FILES['photo']) ?dol_sanitizeFileName($_FILES['photo']['name']) : ''); - // Gestion du logo de la société + // Company logo management $dir = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos"; $file_OK = (isset($_FILES['photo']) ?is_uploaded_file($_FILES['photo']['tmp_name']) : false); if ($file_OK) { @@ -1728,7 +1736,11 @@ function formatCustomerSelection (selection) { print "\n"; print ''; print "\n"; @@ -1957,7 +1969,7 @@ function formatCustomerSelection (selection) { } } $modCodeClient = new $module($db); - // We verified if the tag prefix is used + // We check if the prefix tag is used if ($modCodeClient->code_auto) { $prefixCustomerIsUsed = $modCodeClient->verif_prefixIsUsed(); } @@ -1973,7 +1985,7 @@ function formatCustomerSelection (selection) { } } $modCodeFournisseur = new $module($db); - // On verifie si la balise prefix est utilisee + // We check if the prefix tag is used if ($modCodeFournisseur->code_auto) { $prefixSupplierIsUsed = $modCodeFournisseur->verif_prefixIsUsed(); } @@ -2500,7 +2512,11 @@ function init_check_no_email(input) { print "\n"; print ''; print "\n"; @@ -2968,7 +2984,11 @@ function init_check_no_email(input) { print "\n"; print ''; print "\n"; @@ -3339,3 +3359,46 @@ function init_check_no_email(input) { // End of page llxFooter(); $db->close(); + +?> + + diff --git a/htdocs/societe/checkvat/checkVatGr.php b/htdocs/societe/checkvat/checkVatGr.php new file mode 100644 index 0000000000000..82684ac77815a --- /dev/null +++ b/htdocs/societe/checkvat/checkVatGr.php @@ -0,0 +1,64 @@ +. + */ + +/** + * \file htdocs/societe/checkvat/checkVatGr.php + * \ingroup societe + * \brief Request VAT details from the Greek Ministry of Finance GSIS SOAP web service + */ + +require "../../main.inc.php"; + +$username = getDolGlobalString('AADE_WEBSERVICE_USER'); // Get username from request +$password = getDolGlobalString('AADE_WEBSERVICE_KEY'); // Get password from request +$myafm = getDolGlobalString('MAIN_INFO_TVAINTRA'); // Get Vat from request +$afm = GETPOST('afm'); // Get client Vat from request + +// Make call to check VAT for Greek client +$result = checkVATGR($username, $password, $myafm, $afm); + +top_httphead('application/json'); +echo json_encode($result); // Encode the result as JSON and output + +/** +* Request VAT details +* @param string $username Company AADE username +* @param string $password Company AADE password +* @param string $AFMcalledfor Company vat number +* @param string $AFMcalledby Client vat number +* @return string +*/ +function checkVATGR($username, $password, $AFMcalledfor, $AFMcalledby = '') +{ + $client = new SoapClient("https://www1.gsis.gr/webtax2/wsgsis/RgWsPublic/RgWsPublicPort?WSDL", array('trace' => true)); + $authHeader = new stdClass(); + $authHeader->UsernameToken = new stdClass(); + $authHeader->UsernameToken->Username = "$username"; + $authHeader->UsernameToken->Password = "$password"; + $Headers[] = new SoapHeader('http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd', 'Security', $authHeader, true); + $client->__setSoapHeaders($Headers); + $result = $client->rgWsPublicAfmMethod( + array( + 'afmCalledBy' => "$AFMcalledby", + 'afmCalledFor' => "$AFMcalledfor", + ) + ); + + return $result; +}