From ee09db0e55f2f472da11eb77e8df09f12df94a52 Mon Sep 17 00:00:00 2001 From: sonikf <93765174+sonikf@users.noreply.github.com> Date: Tue, 12 Sep 2023 00:44:22 +0300 Subject: [PATCH 01/17] Retrieve vat details from the Greek Ministry of Finance GSIS SOAP web service and autocomplete third party fields --- htdocs/societe/card.php | 83 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 73 insertions(+), 10 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index b69448ff7fa..6b827571d80 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 @@ if (isModEnabled('eventorganization')) { require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; } +if ($mysoc->country_code == 'GR') { + $u = $conf->global->AADE_WEBSERVICE_USER; + $p = $conf->global->AADE_WEBSERVICE_KEY; + $myafm = $mysoc->tva_intra; +} + // Load translation files required by the page @@ -385,13 +393,13 @@ if (empty($reshook)) { } 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 @@ if (empty($reshook)) { break; } } - // Gestion du logo de la société + // Company logo management // Update linked member @@ -1187,7 +1195,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $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,8 +1736,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print "\n"; print ''; print "\n"; $s .= ''.$langs->trans("VATIntraCheck").''; @@ -1957,7 +1968,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } } $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 +1984,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } } $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 +2511,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print "\n"; print ''; print "\n"; @@ -2968,7 +2983,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print "\n"; print ''; print "\n"; @@ -3339,3 +3358,47 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // End of page llxFooter(); $db->close(); + +?> + + From e3106915d379c40d389e21b1b9edd56016da0165 Mon Sep 17 00:00:00 2001 From: sonikf <93765174+sonikf@users.noreply.github.com> Date: Tue, 12 Sep 2023 00:47:28 +0300 Subject: [PATCH 02/17] Update companies.lang --- htdocs/langs/en_US/companies.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 871d9a72809..ebf390741c3 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 From ad323a6de8f5127baeee3df8006889e7cf189368 Mon Sep 17 00:00:00 2001 From: sonikf <93765174+sonikf@users.noreply.github.com> Date: Tue, 12 Sep 2023 01:02:35 +0300 Subject: [PATCH 03/17] Update company.php --- htdocs/admin/company.php | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index a0c935413f3..e0c3b470344 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 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) 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 @@ if ($mysoc->useRevenueStamp()) { print ""; +// AADE webservices credentials, applicable only for Greece +if ($mysoc->country_code == 'GR') { + print load_fiche_titre($langs->trans("AADEKeys"), '', ''); + 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 'global->MYDATA_AADE_KEY.'"'; + print '
'; + print ''.$langs->trans("AADE_WEBSERVICE_USER").''; + print '
'; + print ''.$langs->trans("AADE_WEBSERVICE_KEY").''; + print '
"; +} + print $form->buttonsSaveCancel("Save", ''); print ''; From b77e20b6bfb6cabd64d8a489da97595210f4c137 Mon Sep 17 00:00:00 2001 From: sonikf <93765174+sonikf@users.noreply.github.com> Date: Tue, 12 Sep 2023 01:05:49 +0300 Subject: [PATCH 04/17] Request VAT details from the Greek Ministry of Finance GSIS SOAP web service --- htdocs/societe/checkvat/checkVatGr.php | 54 ++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 htdocs/societe/checkvat/checkVatGr.php diff --git a/htdocs/societe/checkvat/checkVatGr.php b/htdocs/societe/checkvat/checkVatGr.php new file mode 100644 index 00000000000..9018081cf68 --- /dev/null +++ b/htdocs/societe/checkvat/checkVatGr.php @@ -0,0 +1,54 @@ +. + */ + +/** + * \file htdocs/societe/checkvat/checkVatGr.php + * \ingroup societe + * \brief Request VAT details from the Greek Ministry of Finance GSIS SOAP web service + */ + +$username = (isset($_REQUEST['u']) ? $_REQUEST['u'] : ''); // Get username from request +$password = (isset($_REQUEST['p']) ? $_REQUEST['p'] : ''); // Get password from request +$myafm = (isset($_REQUEST['myafm']) ? $_REQUEST['myafm'] : ''); // Get Vat from request +$afm = (isset($_REQUEST['afm']) ? $_REQUEST['afm'] : ''); // Get client Vat from request + +// Make call to check VAT for Greek client +$result = checkVATGR($username, $password, $myafm, $afm); + +echo json_encode($result); // Encode the result as JSON and output + +// Function to check VAT +function checkVATGR($username, $password, $AFMcalledby = '', $AFMcalledfor) +{ + $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; +} From 5cae3823fde9e234f1372fd58d2f3c86168909b9 Mon Sep 17 00:00:00 2001 From: sonikf <93765174+sonikf@users.noreply.github.com> Date: Tue, 12 Sep 2023 20:25:17 +0300 Subject: [PATCH 05/17] fix PHPCS --- htdocs/admin/company.php | 64 ++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index e0c3b470344..daba5b00427 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -234,14 +234,14 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) dolibarr_set_const($db, "MAIN_INFO_LOCALTAX_CALC2", GETPOST("clt2", 'aZ09'), 'chaine', 0, '', $conf->entity); } - // Credentials for AADE webservices, applicable only for Greece + // 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); + 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); @@ -856,39 +856,39 @@ if ($mysoc->useRevenueStamp()) { print ""; -// AADE webservices credentials, applicable only for Greece +// AADE webservices credentials, applicable only for Greece if ($mysoc->country_code == 'GR') { - print load_fiche_titre($langs->trans("AADEKeys"), '', ''); - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; + print load_fiche_titre($langs->trans("AADEKeys"), '', ''); + print '
'.$langs->trans("AccountParameter").''.$langs->trans("Value").'
'; + print ''; + print ''; + print ''; + print ''; + print "\n"; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print '
'; + print '
'; - print "
'.$langs->trans("AccountParameter").''.$langs->trans("Value").'
'; - print ''.$langs->trans("MYDATA_AADE_USER").''; - print '
'; + print ''.$langs->trans("MYDATA_AADE_USER").''; + print '
'; - print ''.$langs->trans("MYDATA_AADE_KEY").''; - print 'global->MYDATA_AADE_KEY.'"'; - print '
'; + print ''.$langs->trans("MYDATA_AADE_KEY").''; + print 'global->MYDATA_AADE_KEY.'"'; + print '
'; - print ''.$langs->trans("AADE_WEBSERVICE_USER").''; - print '
'; + print ''.$langs->trans("AADE_WEBSERVICE_USER").''; + print '
'; - print ''.$langs->trans("AADE_WEBSERVICE_KEY").''; - print '
'; + print ''.$langs->trans("AADE_WEBSERVICE_KEY").''; + print '
"; + print ""; } print $form->buttonsSaveCancel("Save", ''); From 3a44203ddf3ad75fa7073b6cb73e60f42ced14d9 Mon Sep 17 00:00:00 2001 From: sonikf <93765174+sonikf@users.noreply.github.com> Date: Tue, 12 Sep 2023 20:26:00 +0300 Subject: [PATCH 06/17] fix PHPCS --- htdocs/societe/checkvat/checkVatGr.php | 35 ++++++++++++++------------ 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/htdocs/societe/checkvat/checkVatGr.php b/htdocs/societe/checkvat/checkVatGr.php index 9018081cf68..40d1eaccb9c 100644 --- a/htdocs/societe/checkvat/checkVatGr.php +++ b/htdocs/societe/checkvat/checkVatGr.php @@ -33,22 +33,25 @@ $result = checkVATGR($username, $password, $myafm, $afm); echo json_encode($result); // Encode the result as JSON and output -// Function to check VAT -function checkVATGR($username, $password, $AFMcalledby = '', $AFMcalledfor) +/** +* Request VAT details +* +*/ +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", - ) - ); + $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; + return $result; } From e7d8f041875d441e236976309862ab92a1d478ec Mon Sep 17 00:00:00 2001 From: sonikf <93765174+sonikf@users.noreply.github.com> Date: Tue, 12 Sep 2023 21:04:32 +0300 Subject: [PATCH 07/17] fix ci errors --- htdocs/societe/card.php | 88 ++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 6b827571d80..ca92652ef09 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -66,9 +66,9 @@ if (isModEnabled('eventorganization')) { } if ($mysoc->country_code == 'GR') { - $u = $conf->global->AADE_WEBSERVICE_USER; - $p = $conf->global->AADE_WEBSERVICE_KEY; - $myafm = $mysoc->tva_intra; + $u = $conf->global->AADE_WEBSERVICE_USER; + $p = $conf->global->AADE_WEBSERVICE_KEY; + $myafm = $mysoc->tva_intra; } @@ -1737,10 +1737,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; print "\n"; $s .= ''.$langs->trans("VATIntraCheck").''; @@ -2512,9 +2513,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; @@ -2983,11 +2984,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print "\n"; print ''; print "\n"; @@ -3367,38 +3368,37 @@ function GRVAT(a, u, p, myafm) { var afm = a.replace(/\D/g, ""); // Remove non-digit characters from 'a' $.ajax({ - type: "GET", - url: "/societe/checkvat/checkVatGr.php", - data: { u: u, p: p, myafm: myafm, afm: afm }, // Set request parameters - success: function(data) { - var obj = JSON.parse(data); // Parse response data as JSON + type: "GET", + url: "/societe/checkvat/checkVatGr.php", + data: { u: u, p: p, myafm: myafm, afm: afm }, // Set request parameters + success: function(data) { + var obj = JSON.parse(data); // Parse response data as JSON - // Update form fields based on retrieved data - if (obj.RgWsPublicBasicRt_out.afm === null) { - alert(obj.pErrorRec_out.errorDescr); // Display error message if AFM is null - } else { - $("#name").val(obj.RgWsPublicBasicRt_out.onomasia); // Set 'name' field value - $("#address").val(obj.RgWsPublicBasicRt_out.postalAddress + " " + obj.RgWsPublicBasicRt_out.postalAddressNo); // Set 'address' field value - $("#zipcode").val(obj.RgWsPublicBasicRt_out.postalZipCode); // Set 'zipcode' field value - $("#town").val(obj.RgWsPublicBasicRt_out.postalAreaDescription); // Set 'town' field value - $("#idprof2").val(obj.RgWsPublicBasicRt_out.doyDescr); // Set 'idprof2' field value - $("#name_alias_input").val(obj.RgWsPublicBasicRt_out.commerTitle); // Set 'name_alias' field value + // Update form fields based on retrieved data + if (obj.RgWsPublicBasicRt_out.afm === null) { + alert(obj.pErrorRec_out.errorDescr); // Display error message if AFM is null + } else { + $("#name").val(obj.RgWsPublicBasicRt_out.onomasia); // Set 'name' field value + $("#zipcode").val(obj.RgWsPublicBasicRt_out.postalZipCode); // Set 'zipcode' field value + $("#town").val(obj.RgWsPublicBasicRt_out.postalAreaDescription); // Set 'town' field value + $("#idprof2").val(obj.RgWsPublicBasicRt_out.doyDescr); // Set 'idprof2' field value + $("#name_alias_input").val(obj.RgWsPublicBasicRt_out.commerTitle); // Set 'name_alias' field value - if (obj.arrayOfRgWsPublicFirmActRt_out.RgWsPublicFirmActRtUser) { - var firmActUser = obj.arrayOfRgWsPublicFirmActRt_out.RgWsPublicFirmActRtUser; - - if (Array.isArray(firmActUser)) { - var primaryFirmAct = firmActUser.find(item => item.firmActKindDescr === "ΚΥΡΙΑ"); // Find primary client activity - if (primaryFirmAct) { - $("#idprof1").val(primaryFirmAct.firmActDescr); // Set 'idprof1' field value - } - } else { - $("#idprof1").val(firmActUser.firmActDescr); // Set 'idprof1' field value - } - } + if (obj.arrayOfRgWsPublicFirmActRt_out.RgWsPublicFirmActRtUser) { + var firmActUser = obj.arrayOfRgWsPublicFirmActRt_out.RgWsPublicFirmActRtUser; + + if (Array.isArray(firmActUser)) { + var primaryFirmAct = firmActUser.find(item => item.firmActKindDescr === "ΚΥΡΙΑ"); // Find primary client activity + if (primaryFirmAct) { + $("#idprof1").val(primaryFirmAct.firmActDescr); // Set 'idprof1' field value + } + } else { + $("#idprof1").val(firmActUser.firmActDescr); // Set 'idprof1' field value + } } - } - }); + } + } + }); } From 4278b6629fb8e5eb38d90f1a364bef7604682422 Mon Sep 17 00:00:00 2001 From: sonikf <93765174+sonikf@users.noreply.github.com> Date: Tue, 12 Sep 2023 21:04:38 +0300 Subject: [PATCH 08/17] fix PHPCS --- htdocs/societe/checkvat/checkVatGr.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/checkvat/checkVatGr.php b/htdocs/societe/checkvat/checkVatGr.php index 40d1eaccb9c..5c038800791 100644 --- a/htdocs/societe/checkvat/checkVatGr.php +++ b/htdocs/societe/checkvat/checkVatGr.php @@ -33,9 +33,13 @@ $result = checkVATGR($username, $password, $myafm, $afm); 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 = '') { From fc2673102592ea0aaa79d9f40791ad3cb166354d Mon Sep 17 00:00:00 2001 From: sonikf <93765174+sonikf@users.noreply.github.com> Date: Tue, 12 Sep 2023 21:27:22 +0300 Subject: [PATCH 09/17] fix CI errors --- htdocs/societe/card.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index ca92652ef09..2c55b0e070d 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2514,9 +2514,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print "function CheckVAT(a) {\n"; if ($mysoc->country_code == 'GR' && $object->country_code == 'GR') { print "GRVAT(a,'{$u}','{$p}','{$myafm}');\n"; - } - else { print "newpopup('".DOL_URL_ROOT."/societe/checkvat/checkVatPopup.php?vatNumber='+a, '".dol_escape_js($langs->trans("VATIntraCheckableOnEUSite"))."', ".$widthpopup.", ".$heightpopup.");\n"; - } + } else { + print "newpopup('".DOL_URL_ROOT."/societe/checkvat/checkVatPopup.php?vatNumber='+a, '".dol_escape_js($langs->trans("VATIntraCheckableOnEUSite"))."', ".$widthpopup.", ".$heightpopup.");\n"; + } print "}\n"; print ''; print "\n"; @@ -2986,8 +2986,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print "function CheckVAT(a) {\n"; if ($mysoc->country_code == 'GR' && $object->country_code == 'GR') { print "GRVAT(a,'{$u}','{$p}','{$myafm}');\n"; - } - else { print "newpopup('".DOL_URL_ROOT."/societe/checkvat/checkVatPopup.php?vatNumber='+a, '".dol_escape_js($langs->trans("VATIntraCheckableOnEUSite"))."', ".$widthpopup.", ".$heightpopup.");\n"; + } else { + print "newpopup('".DOL_URL_ROOT."/societe/checkvat/checkVatPopup.php?vatNumber='+a, '".dol_escape_js($langs->trans("VATIntraCheckableOnEUSite"))."', ".$widthpopup.", ".$heightpopup.");\n"; } print "}\n"; print ''; From ceaefa5b09b7c03017052abba2778181f309a044 Mon Sep 17 00:00:00 2001 From: sonikf <93765174+sonikf@users.noreply.github.com> Date: Wed, 13 Sep 2023 12:29:22 +0300 Subject: [PATCH 10/17] FIX use getDolGlobalString() --- htdocs/societe/card.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 2c55b0e070d..969eda60f2b 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -66,9 +66,9 @@ if (isModEnabled('eventorganization')) { } if ($mysoc->country_code == 'GR') { - $u = $conf->global->AADE_WEBSERVICE_USER; - $p = $conf->global->AADE_WEBSERVICE_KEY; - $myafm = $mysoc->tva_intra; + $u = getDolGlobalString('AADE_WEBSERVICE_USER'); + $p = getDolGlobalString('AADE_WEBSERVICE_KEY'); + $myafm = getDolGlobalString('MAIN_INFO_TVAINTRA'); } @@ -3370,7 +3370,7 @@ function GRVAT(a, u, p, myafm) { $.ajax({ type: "GET", url: "/societe/checkvat/checkVatGr.php", - data: { u: u, p: p, myafm: myafm, afm: afm }, // Set request parameters + data: { u, p, myafm, afm }, // Set request parameters success: function(data) { var obj = JSON.parse(data); // Parse response data as JSON From 04dd93bb44d6e40dac5aeb92799e1f6cc81b5ae7 Mon Sep 17 00:00:00 2001 From: sonikf <93765174+sonikf@users.noreply.github.com> Date: Wed, 13 Sep 2023 12:29:28 +0300 Subject: [PATCH 11/17] FIX use getDolGlobalString() --- htdocs/admin/company.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index daba5b00427..0a7770bcc3d 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -858,7 +858,7 @@ print ""; // AADE webservices credentials, applicable only for Greece if ($mysoc->country_code == 'GR') { - print load_fiche_titre($langs->trans("AADEKeys"), '', ''); + print load_fiche_titre($langs->trans("AADEWebserviceCredentials"), '', ''); print ''; print ''; print ''; @@ -868,22 +868,22 @@ if ($mysoc->country_code == 'GR') { print ''; print ''; print ''; print ''; print '
'; From b1da68c048a52f6d7edcd9065eca49738f4f7d4c Mon Sep 17 00:00:00 2001 From: sonikf <93765174+sonikf@users.noreply.github.com> Date: Wed, 13 Sep 2023 12:29:39 +0300 Subject: [PATCH 12/17] FIX use getDolGlobalString() and include main.inc.php --- htdocs/societe/checkvat/checkVatGr.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/societe/checkvat/checkVatGr.php b/htdocs/societe/checkvat/checkVatGr.php index 5c038800791..c2be6305faa 100644 --- a/htdocs/societe/checkvat/checkVatGr.php +++ b/htdocs/societe/checkvat/checkVatGr.php @@ -23,9 +23,11 @@ * \brief Request VAT details from the Greek Ministry of Finance GSIS SOAP web service */ -$username = (isset($_REQUEST['u']) ? $_REQUEST['u'] : ''); // Get username from request -$password = (isset($_REQUEST['p']) ? $_REQUEST['p'] : ''); // Get password from request -$myafm = (isset($_REQUEST['myafm']) ? $_REQUEST['myafm'] : ''); // Get Vat from request +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 = (isset($_REQUEST['afm']) ? $_REQUEST['afm'] : ''); // Get client Vat from request // Make call to check VAT for Greek client From faee21b0d39d609ff1df9007980df12fb75e9ca7 Mon Sep 17 00:00:00 2001 From: sonikf <93765174+sonikf@users.noreply.github.com> Date: Fri, 22 Sep 2023 12:53:41 +0300 Subject: [PATCH 13/17] Use GETPOST instead of $_REQUEST --- htdocs/societe/checkvat/checkVatGr.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/checkvat/checkVatGr.php b/htdocs/societe/checkvat/checkVatGr.php index c2be6305faa..0b4cece0661 100644 --- a/htdocs/societe/checkvat/checkVatGr.php +++ b/htdocs/societe/checkvat/checkVatGr.php @@ -28,7 +28,7 @@ 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 = (isset($_REQUEST['afm']) ? $_REQUEST['afm'] : ''); // Get client 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); From 9199bce9da0b51c2427b2a3f256a84984c0f2fc7 Mon Sep 17 00:00:00 2001 From: sonikf <93765174+sonikf@users.noreply.github.com> Date: Fri, 22 Sep 2023 12:56:40 +0300 Subject: [PATCH 14/17] Add test on !empty($u) --- htdocs/societe/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 969eda60f2b..ad5e90f9614 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1736,7 +1736,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print "\n"; print '
'.$langs->trans("AccountParameter").'
'; print ''.$langs->trans("MYDATA_AADE_USER").''; - print '
'; print ''.$langs->trans("MYDATA_AADE_KEY").''; - print 'global->MYDATA_AADE_KEY.'"'; + print '
'; print ''.$langs->trans("AADE_WEBSERVICE_USER").''; - print '
'; print ''.$langs->trans("AADE_WEBSERVICE_KEY").''; - print '