From 1cfed6e5cfca0cb0daa97364f1b7f7dc9df6b08e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 3 Jun 2026 22:12:06 +0200 Subject: [PATCH] NEW Can add profid2 in addition with profid1 --- htdocs/blockedlog/admin/registration.php | 21 ++++++++++++++++++++- htdocs/blockedlog/ajax/block-add.php | 7 ++++++- htdocs/blockedlog/lib/blockedlog.lib.php | 3 ++- htdocs/langs/en_US/blockedlog.lang | 1 + htdocs/main.inc.php | 1 + htdocs/takepos/receipt.php | 5 ++++- 6 files changed, 34 insertions(+), 4 deletions(-) diff --git a/htdocs/blockedlog/admin/registration.php b/htdocs/blockedlog/admin/registration.php index 3d9ffb701d4..a8dd1034dd5 100644 --- a/htdocs/blockedlog/admin/registration.php +++ b/htdocs/blockedlog/admin/registration.php @@ -96,7 +96,11 @@ if ($action == 'update') { $error++; } if (!GETPOST("BLOCKEDLOG_REGISTRATION_IDPROF1")) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("BLOCKEDLOG_REGISTRATION_IDPROF1")), null, 'errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transcountry("ProfId1", $mysoc->country_code)), null, 'errors'); + $error++; + } + if (!GETPOST("BLOCKEDLOG_REGISTRATION_IDPROF2")) { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transcountry("ProfId2", $mysoc->country_code)), null, 'errors'); $error++; } @@ -105,6 +109,7 @@ if ($action == 'update') { $tmpthirdparty->country_code = $country_code; $tmpthirdparty->country_id = getCountry($country_code, '3', $db, $langs, 0); $tmpthirdparty->idprof1 = GETPOST("BLOCKEDLOG_REGISTRATION_IDPROF1"); + $tmpthirdparty->idprof2 = GETPOST("BLOCKEDLOG_REGISTRATION_IDPROF2"); // Check validity of email if (!isValidEmail(GETPOST("BLOCKEDLOG_REGISTRATION_EMAIL"))) { @@ -123,6 +128,7 @@ if ($action == 'update') { $company_email = GETPOST("BLOCKEDLOG_REGISTRATION_EMAIL"); $company_country_code = GETPOST("BLOCKEDLOG_REGISTRATION_COUNTRY_CODE"); $company_idprof1 = GETPOST("BLOCKEDLOG_REGISTRATION_IDPROF1"); + $company_idprof2 = GETPOST("BLOCKEDLOG_REGISTRATION_IDPROF2"); $company_address = GETPOST("BLOCKEDLOG_REGISTRATION_ADDRESS"); $company_state = GETPOST("BLOCKEDLOG_REGISTRATION_STATE"); $company_zip = GETPOST("BLOCKEDLOG_REGISTRATION_ZIP"); @@ -155,6 +161,10 @@ if ($action == 'update') { if ($res <= 0) { $error++; } + $res = dolibarr_set_const($db, "BLOCKEDLOG_REGISTRATION_IDPROF2", $company_idprof2, 'chaine', 0, '', $conf->entity); + if ($res <= 0) { + $error++; + } $res = dolibarr_set_const($db, "BLOCKEDLOG_REGISTRATION_ADDRESS", $company_address, 'chaine', 0, '', $conf->entity); if ($res <= 0) { $error++; @@ -363,6 +373,7 @@ if ($mode == "forceregistration") { 'company_name' => getDolGlobalString('BLOCKEDLOG_REGISTRATION_NAME', $mysoc->name), 'company_email' => getDolGlobalString('BLOCKEDLOG_REGISTRATION_EMAIL', $mysoc->email), 'company_idprof1' => getDolGlobalString('BLOCKEDLOG_REGISTRATION_IDPROF1', $mysoc->idprof1), + 'company_idprof2' => getDolGlobalString('BLOCKEDLOG_REGISTRATION_IDPROF2', $mysoc->idprof2), 'company_address' => getDolGlobalString('BLOCKEDLOG_REGISTRATION_ADDRESS', $mysoc->address), 'company_state' => $company_state, 'company_zip' => getDolGlobalString('BLOCKEDLOG_REGISTRATION_ZIP', $mysoc->zip), @@ -435,6 +446,14 @@ if (empty($mode)) { $item->defaultFieldValue = (GETPOSTISSET('BLOCKEDLOG_REGISTRATION_IDPROF1') ? GETPOST('BLOCKEDLOG_REGISTRATION_IDPROF1') : getDolGlobalString('BLOCKEDLOG_REGISTRATION_IDPROF1', $mysoc->idprof1)); $item->helpText = $langs->trans("Example").': 732 829 320'; $item->fieldParams['isMandatory'] = 1; + $item->nameText = $langs->transcountry("ProfId1", $mysoc->country_code); + + //Company IDPROF2 + $item = $formSetup->newItem('BLOCKEDLOG_REGISTRATION_IDPROF2'); + $item->defaultFieldValue = (GETPOSTISSET('BLOCKEDLOG_REGISTRATION_IDPROF2') ? GETPOST('BLOCKEDLOG_REGISTRATION_IDPROF2') : getDolGlobalString('BLOCKEDLOG_REGISTRATION_IDPROF2', $mysoc->idprof2)); + $item->helpText = $langs->trans("Example").': 732 829 320 00010'; + $item->fieldParams['isMandatory'] = 1; + $item->nameText = $langs->transcountry("ProfId2", $mysoc->country_code); //Company country code $country_code = getDolGlobalString('BLOCKEDLOG_REGISTRATION_COUNTRY_CODE', $mysoc->country_code); diff --git a/htdocs/blockedlog/ajax/block-add.php b/htdocs/blockedlog/ajax/block-add.php index 10554337f63..bbdcb9aa22d 100644 --- a/htdocs/blockedlog/ajax/block-add.php +++ b/htdocs/blockedlog/ajax/block-add.php @@ -90,5 +90,10 @@ if ($element === 'facture') { // Test on permission done in top of page $facture->call_trigger($action, $user); } - print 'Object '.$element.' logged with action code = '.$action." pos_print_counter is now ".$facture->pos_print_counter; + if ($facture->errors) { + http_response_code(500); + print implode("\n", $facture->errors); + } else { + print 'Object '.$element.' logged with action code = '.$action." pos_print_counter is now ".$facture->pos_print_counter; + } } diff --git a/htdocs/blockedlog/lib/blockedlog.lib.php b/htdocs/blockedlog/lib/blockedlog.lib.php index 1018b4e8e46..a2825a57626 100644 --- a/htdocs/blockedlog/lib/blockedlog.lib.php +++ b/htdocs/blockedlog/lib/blockedlog.lib.php @@ -142,9 +142,10 @@ function isRegistrationDataSaved() $companyemail = getDolGlobalString('BLOCKEDLOG_REGISTRATION_EMAIL', $mysoc->email); $companycountrycode = getDolGlobalString('BLOCKEDLOG_REGISTRATION_COUNTRY_CODE', $mysoc->country_code); $companyidprof1 = getDolGlobalString('BLOCKEDLOG_REGISTRATION_IDPROF1', $mysoc->idprof1); + $companyidprof2 = getDolGlobalString('BLOCKEDLOG_REGISTRATION_IDPROF2', $mysoc->idprof2); //$companytel = getDolGlobalString('BLOCKEDLOG_REGISTRATION_TEL', $mysoc->phone); - if (empty($companyname) || empty($companycountrycode) || empty($companyidprof1) || empty($companyemail)) { + if (empty($companyname) || empty($companycountrycode) || empty($companyidprof1) || empty($companyidprof2) || empty($companyemail)) { return false; } diff --git a/htdocs/langs/en_US/blockedlog.lang b/htdocs/langs/en_US/blockedlog.lang index 5a01e514556..16f80779aff 100644 --- a/htdocs/langs/en_US/blockedlog.lang +++ b/htdocs/langs/en_US/blockedlog.lang @@ -80,6 +80,7 @@ BLOCKEDLOG_REGISTRATION_NAME=Company name BLOCKEDLOG_REGISTRATION_EMAIL=Company email BLOCKEDLOG_REGISTRATION_COUNTRY_CODE=Company country BLOCKEDLOG_REGISTRATION_IDPROF1=Company Prof Id 1 (SIREN) +BLOCKEDLOG_REGISTRATION_IDPROF2=Company Prof Id 2 (SIRET) BLOCKEDLOG_REGISTRATION_ADDRESS=Company address BLOCKEDLOG_REGISTRATION_STATE=Company state/province BLOCKEDLOG_REGISTRATION_ZIP=Company zip diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index d606c882a64..a79ccce9031 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -3960,6 +3960,7 @@ if (!function_exists("llxFooter")) { 'company_name' => getDolGlobalString('BLOCKEDLOG_REGISTRATION_NAME', $mysoc->name), 'company_email' => getDolGlobalString('BLOCKEDLOG_REGISTRATION_EMAIL', $mysoc->email), 'company_idprof1' => getDolGlobalString('BLOCKEDLOG_REGISTRATION_IDPROF1', $mysoc->idprof1), + 'company_idprof2' => getDolGlobalString('BLOCKEDLOG_REGISTRATION_IDPROF2', $mysoc->idprof2), 'company_address' => getDolGlobalString('BLOCKEDLOG_REGISTRATION_ADDRESS', $mysoc->address), 'company_state' => getDolGlobalString('BLOCKEDLOG_REGISTRATION_STATE', $mysoc->state), 'company_zip' => getDolGlobalString('BLOCKEDLOG_REGISTRATION_ZIP', $mysoc->zip), diff --git a/htdocs/takepos/receipt.php b/htdocs/takepos/receipt.php index 2f281716f89..5205f2547af 100644 --- a/htdocs/takepos/receipt.php +++ b/htdocs/takepos/receipt.php @@ -130,7 +130,10 @@ if (!GETPOST('specimen') && empty($nojs)) { lang: '".dol_escape_js($langs->defaultlang)."', token: '".currentToken()."' } - ); + ).fail(function(jqXHR, textStatus, errorThrown) { + console.error('Error AJAX :', textStatus, errorThrown); + console.error('Answer server :', jqXHR.responseText); + }); "; }