2026-01-27 00:13:22 +00:00
< ? php
2026-05-26 04:36:12 +00:00
/* Copyright ( C ) 2017 ATM Consulting < contact @ atm - consulting . fr >
* Copyright ( C ) 2017 - 2026 Laurent Destailleur < ldestailleur @ dolicloud . com >
* Copyright ( C ) 2024 - 2026 Frédéric France < frederic . france @ free . fr >
2026-02-24 16:35:35 +00:00
* Copyright ( C ) 2026 MDW < mdeweerd @ users . noreply . github . com >
2026-01-27 00:13:22 +00:00
*
* 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 3 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 , see < https :// www . gnu . org / licenses />.
*/
/**
* \file htdocs / blockedlog / admin / registration . php
* \ingroup blockedlog
* \brief Page setup for blockedlog module ( user registration )
*/
// Load Dolibarr environment
require '../../main.inc.php' ;
/**
* @ var Conf $conf
* @ var DoliDB $db
* @ var HookManager $hookmanager
* @ var Societe $mysoc
* @ var Translate $langs
* @ var User $user
*/
require_once DOL_DOCUMENT_ROOT . '/blockedlog/lib/blockedlog.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/blockedlog/class/blockedlog.class.php' ;
2026-02-08 22:14:07 +00:00
require_once DOL_DOCUMENT_ROOT . '/core/modules/modBlockedLog.class.php' ;
2026-01-27 00:13:22 +00:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php' ;
2026-05-27 21:25:28 +00:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/profid.lib.php' ;
2026-02-08 22:14:07 +00:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php' ;
2026-02-09 06:11:20 +00:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formsetup.class.php' ;
2026-01-27 00:13:22 +00:00
// Load translation files required by the page
$langs -> loadLangs ( array ( 'admin' , 'blockedlog' , 'other' ));
// Get Parameters
$action = GETPOST ( 'action' , 'aZ09' );
$backtopage = GETPOST ( 'backtopage' , 'alpha' );
2026-02-15 23:08:14 +00:00
$cancel = GETPOST ( 'cancel' );
2026-02-09 06:11:20 +00:00
2026-02-09 17:28:53 +00:00
$withtab = GETPOSTISSET ( 'withtab' ) ? GETPOSTINT ( 'withtab' ) : 1 ;
2026-02-09 17:04:59 +00:00
$origin = GETPOST ( 'origin' );
2026-02-09 06:11:20 +00:00
$mode = GETPOST ( 'mode' );
2026-01-27 00:13:22 +00:00
// Access Control
if ( ! $user -> admin ) {
accessforbidden ();
}
/*
* Actions
*/
2026-06-16 21:49:32 +00:00
if ( getDolGlobalString ( 'BLOCKEDLOG_FOR_TAX_AUDITOR' ) && userIsTaxAuditor ()) { // If we are in mode for tax auditor
2026-04-11 15:30:15 +00:00
header ( " Location: " . DOL_URL_ROOT . '/blockedlog/admin/blockedlog_archives.php' );
exit ;
}
2026-02-15 23:08:14 +00:00
if ( $cancel && $origin == 'initmodule' ) {
header ( " Location: " . DOL_URL_ROOT . " /admin/modules.php " );
exit ( 0 );
}
2026-02-17 14:01:38 +00:00
if ( $cancel ) {
$action = '' ;
}
2026-02-15 23:08:14 +00:00
2026-02-08 22:14:07 +00:00
if ( $action == 'update' ) {
$error = 0 ;
$db -> begin ();
2026-02-13 00:22:06 +00:00
// The mandatory information must be the same than the one defined into isRegistrationDataSaved()
2026-02-08 22:14:07 +00:00
if ( ! GETPOST ( " BLOCKEDLOG_REGISTRATION_NAME " )) {
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> trans ( " BLOCKEDLOG_REGISTRATION_NAME " )), null , 'errors' );
$error ++ ;
}
if ( ! GETPOST ( " BLOCKEDLOG_REGISTRATION_EMAIL " )) {
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> trans ( " BLOCKEDLOG_REGISTRATION_EMAIL " )), null , 'errors' );
$error ++ ;
}
2026-06-15 16:51:49 +00:00
if ( ! GETPOST ( " BLOCKEDLOG_REGISTRATION_COUNTRY_ID " )) {
2026-02-08 22:14:07 +00:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> trans ( " BLOCKEDLOG_REGISTRATION_COUNTRY_CODE " )), null , 'errors' );
$error ++ ;
}
2026-06-15 21:00:35 +00:00
if ( ! GETPOST ( " BLOCKEDLOG_REGISTRATION_IDPROF1 " )) {
2026-06-03 20:12:06 +00:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transcountry ( " ProfId1 " , $mysoc -> country_code )), null , 'errors' );
$error ++ ;
}
2026-06-15 21:00:35 +00:00
if ( ! GETPOST ( " BLOCKEDLOG_REGISTRATION_IDPROF2 " )) {
2026-06-03 20:12:06 +00:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transcountry ( " ProfId2 " , $mysoc -> country_code )), null , 'errors' );
2026-02-08 22:14:07 +00:00
$error ++ ;
}
2026-05-26 04:36:12 +00:00
$tmpthirdparty = new Societe ( $db );
2026-06-15 16:51:49 +00:00
$tmparray = getCountry ( GETPOSTINT ( 'BLOCKEDLOG_REGISTRATION_COUNTRY_ID' ), 'all' , $db , $langs , 0 );
if ( ! empty ( $tmparray [ 'id' ])) {
// Check we can change country
include_once DOL_DOCUMENT_ROOT . '/blockedlog/lib/blockedlog.lib.php' ;
if ( $mysoc -> country_code == 'FR' && $tmparray [ 'code' ] != $mysoc -> country_code && isALNERunningVersion ()) {
2026-06-15 21:00:35 +00:00
// Trying to change the country. We refuse.
2026-06-15 16:51:49 +00:00
$langs -> load ( " blockedlog " );
setEventMessages ( $langs -> trans ( " BlockedLogCountryChangeNotAllowedFR " ), null , 'errors' );
$error ++ ;
} else {
$mysoc -> country_id = $tmparray [ 'id' ];
$mysoc -> country_code = $tmparray [ 'code' ];
$mysoc -> country_label = $tmparray [ 'label' ];
$s = $mysoc -> country_id . ':' . $mysoc -> country_code . ':' . $mysoc -> country_label ;
dolibarr_set_const ( $db , " MAIN_INFO_SOCIETE_COUNTRY " , $s , 'chaine' , 0 , '' , $conf -> entity );
$tmpthirdparty -> country_code = $mysoc -> country_code ;
$tmpthirdparty -> country_id = $mysoc -> country_id ;
$tmpthirdparty -> country_label = $mysoc -> country_label ;
2026-06-15 21:00:35 +00:00
$tmpthirdparty -> idprof1 = GETPOST ( " BLOCKEDLOG_REGISTRATION_IDPROF1 " );
$tmpthirdparty -> idprof2 = GETPOST ( " BLOCKEDLOG_REGISTRATION_IDPROF2 " );
2026-06-15 16:51:49 +00:00
activateModulesRequiredByCountry ( $mysoc -> country_code );
}
}
2026-05-26 04:36:12 +00:00
// Check validity of email
2026-05-26 08:13:34 +00:00
if ( ! isValidEmail ( GETPOST ( " BLOCKEDLOG_REGISTRATION_EMAIL " ))) {
2026-05-26 04:36:12 +00:00
setEventMessages ( $langs -> trans ( " ErrorBadEMail " , GETPOST ( " BLOCKEDLOG_REGISTRATION_EMAIL " )), null , 'errors' );
$error ++ ;
}
2026-06-18 14:13:36 +00:00
// Check validity of prof id if we try to save a new one
if ( $tmpthirdparty -> idprof1 && GETPOST ( 'BLOCKEDLOG_REGISTRATION_IDPROF1' ) != $tmpthirdparty -> idprof1 && isValidProfIds ( 1 , $tmpthirdparty , 1 ) <= 0 ) {
2026-05-26 04:36:12 +00:00
$langs -> loadLangs ( array ( " errors " , " companies " ));
setEventMessages ( $langs -> trans ( " ErrorBadValueForParameter " , $tmpthirdparty -> idprof1 , $langs -> transcountry ( " ProfId1Short " , $tmpthirdparty -> country_code )), null , 'errors' );
$error ++ ;
}
2026-06-18 14:13:36 +00:00
if ( $tmpthirdparty -> idprof2 && GETPOST ( 'BLOCKEDLOG_REGISTRATION_IDPROF2' ) != $tmpthirdparty -> idprof2 && isValidProfIds ( 2 , $tmpthirdparty , 1 ) <= 0 ) {
2026-06-10 10:06:34 +00:00
$langs -> loadLangs ( array ( " errors " , " companies " ));
setEventMessages ( $langs -> trans ( " ErrorBadValueForParameter " , $tmpthirdparty -> idprof2 , $langs -> transcountry ( " ProfId2Short " , $tmpthirdparty -> country_code )), null , 'errors' );
$error ++ ;
}
2026-05-26 04:36:12 +00:00
2026-06-15 16:51:49 +00:00
// Check that we don't change the SIREN. A new Dolibarr instance must be created to change SIREN.
if ( $mysoc -> country_code == 'FR' && $tmpthirdparty -> idprof1 && $tmpthirdparty -> idprof1 != $mysoc -> idprof1 && isALNERunningVersion ()) {
$langs -> load ( " blockedlog " );
setEventMessages ( $langs -> trans ( " BlockedLogProfID1ChangeNotAllowedFR " ), null , 'errors' );
$error ++ ;
}
2026-02-08 22:14:07 +00:00
$company_name = GETPOST ( " BLOCKEDLOG_REGISTRATION_NAME " );
$company_email = GETPOST ( " BLOCKEDLOG_REGISTRATION_EMAIL " );
2026-06-15 16:51:49 +00:00
$company_country_code = $tmparray [ 'code' ];
2026-06-15 21:00:35 +00:00
$company_idprof1 = GETPOST ( " BLOCKEDLOG_REGISTRATION_IDPROF1 " );
$company_idprof2 = GETPOST ( " BLOCKEDLOG_REGISTRATION_IDPROF2 " );
2026-02-08 22:14:07 +00:00
$company_address = GETPOST ( " BLOCKEDLOG_REGISTRATION_ADDRESS " );
$company_state = GETPOST ( " BLOCKEDLOG_REGISTRATION_STATE " );
$company_zip = GETPOST ( " BLOCKEDLOG_REGISTRATION_ZIP " );
$company_town = GETPOST ( " BLOCKEDLOG_REGISTRATION_TOWN " );
$provider_name = GETPOST ( " MAIN_INFO_ITPROVIDER_NAME " );
$provider_email = GETPOST ( " MAIN_INFO_ITPROVIDER_MAIL " );
$provider_country_id = GETPOST ( " MAIN_INFO_ITPROVIDER_COUNTRY " );
$provider_idprof1 = GETPOST ( " MAIN_INFO_ITPROVIDER_IDPROF1 " );
2026-06-10 10:06:34 +00:00
$provider_idprof2 = GETPOST ( " MAIN_INFO_ITPROVIDER_IDPROF2 " );
2026-02-08 22:14:07 +00:00
$provider_address = GETPOST ( " MAIN_INFO_ITPROVIDER_ADDRESS " );
$provider_state = GETPOST ( " MAIN_INFO_ITPROVIDER_STATE " );
$provider_zip = GETPOST ( " MAIN_INFO_ITPROVIDER_ZIP " );
$provider_town = GETPOST ( " MAIN_INFO_ITPROVIDER_TOWN " );
if ( ! $error ) {
//Company
$res = dolibarr_set_const ( $db , " BLOCKEDLOG_REGISTRATION_NAME " , $company_name , 'chaine' , 0 , '' , $conf -> entity );
if ( $res <= 0 ) {
2026-02-24 16:35:35 +00:00
$error ++ ;
2026-02-08 22:14:07 +00:00
}
$res = dolibarr_set_const ( $db , " BLOCKEDLOG_REGISTRATION_EMAIL " , $company_email , 'chaine' , 0 , '' , $conf -> entity );
if ( $res <= 0 ) {
2026-02-24 16:35:35 +00:00
$error ++ ;
2026-02-08 22:14:07 +00:00
}
2026-06-15 14:07:30 +00:00
$res = dolibarr_set_const ( $db , " MAIN_INFO_SIREN " , $company_idprof1 , 'chaine' , 0 , '' , $conf -> entity );
2026-02-08 22:14:07 +00:00
if ( $res <= 0 ) {
2026-02-24 16:35:35 +00:00
$error ++ ;
2026-02-08 22:14:07 +00:00
}
2026-06-15 14:07:30 +00:00
$res = dolibarr_set_const ( $db , " MAIN_INFO_SIRET " , $company_idprof2 , 'chaine' , 0 , '' , $conf -> entity );
2026-06-03 20:12:06 +00:00
if ( $res <= 0 ) {
$error ++ ;
}
2026-02-08 22:14:07 +00:00
$res = dolibarr_set_const ( $db , " BLOCKEDLOG_REGISTRATION_ADDRESS " , $company_address , 'chaine' , 0 , '' , $conf -> entity );
if ( $res <= 0 ) {
2026-02-24 16:35:35 +00:00
$error ++ ;
2026-02-08 22:14:07 +00:00
}
$res = dolibarr_set_const ( $db , " BLOCKEDLOG_REGISTRATION_STATE " , $company_state , 'chaine' , 0 , '' , $conf -> entity );
if ( $res <= 0 ) {
2026-02-24 16:35:35 +00:00
$error ++ ;
2026-02-08 22:14:07 +00:00
}
$res = dolibarr_set_const ( $db , " BLOCKEDLOG_REGISTRATION_ZIP " , $company_zip , 'chaine' , 0 , '' , $conf -> entity );
if ( $res <= 0 ) {
2026-02-24 16:35:35 +00:00
$error ++ ;
2026-02-08 22:14:07 +00:00
}
$res = dolibarr_set_const ( $db , " BLOCKEDLOG_REGISTRATION_TOWN " , $company_town , 'chaine' , 0 , '' , $conf -> entity );
if ( $res <= 0 ) {
2026-02-24 16:35:35 +00:00
$error ++ ;
2026-02-08 22:14:07 +00:00
}
//IT Provider
$res = dolibarr_set_const ( $db , " MAIN_INFO_ITPROVIDER_NAME " , $provider_name , 'chaine' , 0 , '' , $conf -> entity );
if ( $res <= 0 ) {
2026-02-24 16:35:35 +00:00
$error ++ ;
2026-02-08 22:14:07 +00:00
}
$res = dolibarr_set_const ( $db , " MAIN_INFO_ITPROVIDER_MAIL " , $provider_email , 'chaine' , 0 , '' , $conf -> entity );
if ( $res <= 0 ) {
2026-02-24 16:35:35 +00:00
$error ++ ;
2026-02-08 22:14:07 +00:00
}
$res = dolibarr_set_const ( $db , " MAIN_INFO_ITPROVIDER_COUNTRY " , $provider_country_id , 'chaine' , 0 , '' , $conf -> entity );
if ( $res <= 0 ) {
2026-02-24 16:35:35 +00:00
$error ++ ;
2026-02-08 22:14:07 +00:00
}
$res = dolibarr_set_const ( $db , " MAIN_INFO_ITPROVIDER_IDPROF1 " , $provider_idprof1 , 'chaine' , 0 , '' , $conf -> entity );
if ( $res <= 0 ) {
2026-02-24 16:35:35 +00:00
$error ++ ;
2026-02-08 22:14:07 +00:00
}
2026-06-10 10:06:34 +00:00
$res = dolibarr_set_const ( $db , " MAIN_INFO_ITPROVIDER_IDPROF2 " , $provider_idprof1 , 'chaine' , 0 , '' , $conf -> entity );
if ( $res <= 0 ) {
$error ++ ;
}
2026-02-08 22:14:07 +00:00
$res = dolibarr_set_const ( $db , " MAIN_INFO_ITPROVIDER_ADDRESS " , $provider_address , 'chaine' , 0 , '' , $conf -> entity );
if ( $res <= 0 ) {
2026-02-24 16:35:35 +00:00
$error ++ ;
2026-02-08 22:14:07 +00:00
}
$res = dolibarr_set_const ( $db , " MAIN_INFO_ITPROVIDER_STATE " , $provider_state , 'chaine' , 0 , '' , $conf -> entity );
if ( $res <= 0 ) {
2026-02-24 16:35:35 +00:00
$error ++ ;
2026-02-08 22:14:07 +00:00
}
$res = dolibarr_set_const ( $db , " MAIN_INFO_ITPROVIDER_ZIP " , $provider_zip , 'chaine' , 0 , '' , $conf -> entity );
if ( $res <= 0 ) {
2026-02-24 16:35:35 +00:00
$error ++ ;
2026-02-08 22:14:07 +00:00
}
$res = dolibarr_set_const ( $db , " MAIN_INFO_ITPROVIDER_TOWN " , $provider_town , 'chaine' , 0 , '' , $conf -> entity );
if ( $res <= 0 ) {
2026-02-24 16:35:35 +00:00
$error ++ ;
2026-02-08 22:14:07 +00:00
}
}
if ( ! $error ) {
2026-06-15 21:00:35 +00:00
// If HMAC key was not saved, we do it now
2026-06-16 15:06:46 +00:00
// Clear cache
unset ( $_SESSION [ 'obfuscationkey_' . (( int ) $conf -> entity )]);
unset ( $conf -> cache [ 'obfuscationkey_' . (( int ) $conf -> entity )]);
2026-06-15 21:00:35 +00:00
require_once DOL_DOCUMENT_ROOT . '/blockedlog/class/blockedlog.class.php' ;
$b = new BlockedLog ( $db );
$hmac_encoded_secret_key = getDolGlobalString ( 'BLOCKEDLOG_HMAC_KEY' );
2026-06-16 15:06:46 +00:00
// This code is similar to the code into the init of module.
2026-06-15 21:00:35 +00:00
if ( empty ( $hmac_encoded_secret_key )) {
2026-06-16 15:06:46 +00:00
// No HMAC key yet, we generate one.
2026-06-15 21:00:35 +00:00
$randomsecret = bin2hex ( random_bytes ( 32 )); // 64 char hex - 256 bits
$hmac_secret_key = 'BLOCKEDLOGHMAC' . $randomsecret ; // Example: 'BLOCKEDLOGHMACY3Ewx37RXbSd8gL9JV8p7Wqw7qvq2K2A'
2026-06-16 15:06:46 +00:00
//$hmac_secret_key = 'BLOCKEDLOGHMACY3Ewx37RXbSd8gL9JV8p7Wqw7qvq2K2A';
$obfuscationkey = '' ;
if ( isALNERunningVersion ( 1 )) { // Note we are here if registration page requested, so for all french users, even if not assujeti.
try {
$obfuscationkey = $b -> getObfuscationKey (); // Get the obfuscation key from memory or remote server. If not found, we retrieve it.
//$obfuscationkey = ''; // Uncomment this to test if obfuscation key can't be retrieved.
} catch ( Exception $e ) {
$error ++ ;
setEventMessages ( $e -> getMessage (), null , 'errors' );
$obfuscationkey = '' ;
}
if ( empty ( $obfuscationkey )) {
$error ++ ;
2026-06-17 15:39:31 +00:00
$url_for_ping = getDolGlobalString ( 'MAIN_URL_FOR_PING' , " https://ping.dolibarr.org/ " );
setEventMessages ( $langs -> trans ( 'FailedToGetRemoteObfuscationKeyReTryLater' , $url_for_ping ), null , 'errors' );
2026-06-16 15:06:46 +00:00
}
if ( ! $error ) {
// Save HMAC key obfuscating it with remote $obfuscationkey
$result = $b -> saveHMACSecretKey ( $hmac_secret_key , 'dolobfuscationv1-' . $mysoc -> idprof1 , $obfuscationkey ); // gitleaks:allow
if ( $result < 0 ) {
$error ++ ;
setEventMessages ( $b -> error , $b -> errors , 'errors' );
}
}
} else {
$result = $b -> saveHMACSecretKey ( $hmac_secret_key , 'dolcrypt' , $obfuscationkey ); // gitleaks:allow
if ( $result < 0 ) {
$error ++ ;
setEventMessages ( $b -> error , $b -> errors , 'errors' );
}
}
} else {
// If a HMAC key already exists, we don't need to create one.
// If it was store using the old method "dolcrypt", it will be converted into the new method "dolobfuscationv1-<siret>" at next recording by buildFinalSignatureHash().
2026-06-15 21:00:35 +00:00
}
2026-06-16 15:06:46 +00:00
if ( $error ) {
$db -> rollback ();
} else {
$db -> commit ();
2026-06-15 21:00:35 +00:00
2026-06-16 15:06:46 +00:00
//setEventMessages("SetupSaved", null, 'mesgs');
$urltouse = $_SERVER [ " PHP_SELF " ] . " ?mode=forceregistration " ;
$urltouse .= (( $withtab && GETPOST ( 'origin' )) ? '&withtab=' . $withtab : '' );
$urltouse .= ( GETPOST ( 'origin' ) ? '&origin=' . GETPOST ( 'origin' ) : '' );
2026-02-09 06:11:20 +00:00
2026-06-16 15:06:46 +00:00
header ( " Location: " . $urltouse );
exit ;
}
2026-02-08 22:14:07 +00:00
} else {
$db -> rollback ();
}
}
2026-01-27 00:13:22 +00:00
/*
* View
*/
2026-02-08 22:14:07 +00:00
$formSetup = new FormSetup ( $db );
2026-01-27 00:13:22 +00:00
$form = new Form ( $db );
2026-02-08 22:14:07 +00:00
$formcompany = new FormCompany ( $db );
2026-01-27 00:13:22 +00:00
$block_static = new BlockedLog ( $db );
$block_static -> loadTrackedEvents ();
2026-04-12 09:59:56 +00:00
if ( $withtab ) {
2026-02-09 17:28:53 +00:00
$title = $langs -> trans ( " ModuleSetup " ) . ' ' . $langs -> trans ( 'BlockedLog' );
} else {
$title = $langs -> trans ( " BrowseBlockedLog " );
}
2026-02-24 16:35:35 +00:00
$help_url = " EN:Module_Unalterable_Archives_-_Logs|FR:Module_Archives_-_Logs_Inaltérable " ;
2026-01-27 00:13:22 +00:00
llxHeader ( '' , $title , $help_url , '' , 0 , 0 , '' , '' , '' , 'mod-blockedlog page-admin_blockedlog' );
2026-04-12 09:59:56 +00:00
if ( $withtab ) {
2026-02-09 17:28:53 +00:00
$linkback = '<a href="' . dolBuildUrl ( $backtopage ? $backtopage : DOL_URL_ROOT . '/admin/modules.php' , [ 'restore_lastsearch_values' => 1 ]) . '">' . img_picto ( $langs -> trans ( " BackToModuleList " ), 'back' , 'class="pictofixedwidth"' ) . '<span class="hideonsmartphone">' . $langs -> trans ( " BackToModuleList " ) . '</span></a>' ;
} else {
2026-02-24 16:35:35 +00:00
$linkback = '' ;
2026-02-09 17:28:53 +00:00
}
2026-01-27 00:13:22 +00:00
$morehtmlcenter = '' ;
2026-03-11 23:00:34 +00:00
$texttop = '' ;
2026-01-27 00:13:22 +00:00
$registrationnumber = getHashUniqueIdOfRegistration ();
2026-03-08 21:27:57 +00:00
if ( ! userIsTaxAuditor ()) {
2026-03-08 20:19:21 +00:00
$texttop = '<small class="opacitymedium">' . $langs -> trans ( " RegistrationNumber " ) . ':</small> <small>' . dol_trunc ( $registrationnumber , 10 ) . '</small>' ;
if (( ! isRegistrationDataSavedAndPushed () || ! isModEnabled ( 'blockedlog' )) && $mode != " forceregistration " ) {
$texttop = '' ;
}
2026-01-27 00:13:22 +00:00
}
print load_fiche_titre ( $title . '<br>' . $texttop , $linkback , 'blockedlog' , 0 , '' , '' , $morehtmlcenter );
if ( $withtab ) {
2026-04-12 09:59:56 +00:00
$head = blockedlogadmin_prepare_head ( $withtab );
2026-02-09 17:04:59 +00:00
print dol_get_fiche_head ( $head , 'registration' , '' , - 1 );
2026-02-09 17:28:53 +00:00
} else {
print '<br>' ;
2026-01-27 00:13:22 +00:00
}
2026-02-09 17:04:59 +00:00
print '<span class="opacitymedium">' . $langs -> trans ( " BlockedLogDesc " ) . " </span><br> \n " ;
2026-02-09 21:43:56 +00:00
2026-02-16 04:48:39 +00:00
// Version
2026-02-19 21:29:20 +00:00
$versionbadge = '<span class="badge-text badge-secondary">' . getBlockedLogVersionToShow () . '</span>' ;
2026-02-16 04:48:39 +00:00
2026-02-09 17:04:59 +00:00
// Special additional message for FR only
$infotoshow = '' ;
2026-02-09 06:11:20 +00:00
if ( $mysoc -> country_code == 'FR' ) {
$islne = isALNEQualifiedVersion ( 1 , 1 );
if ( $islne ) {
2026-03-19 14:58:41 +00:00
if ( preg_match ( '/\-/' , getBlockedLogVersionToShow ())) {
2026-02-12 20:43:54 +00:00
// This is an alpha or beta version
2026-02-16 04:41:19 +00:00
$infotoshow = $langs -> trans ( " LNECandidateVersionForCertificationFR " , $versionbadge );
2026-02-12 20:43:54 +00:00
} else {
2026-02-16 04:41:19 +00:00
$infotoshow = $langs -> trans ( " LNECertifiedVersionFR " , $versionbadge );
2026-02-12 20:43:54 +00:00
}
2026-02-09 06:11:20 +00:00
} else {
2026-02-16 04:41:19 +00:00
$infotoshow = $langs -> trans ( " NotCertifiedVersionFR " , $versionbadge );
2026-02-09 06:11:20 +00:00
}
2026-03-19 14:58:41 +00:00
$infotoshow .= ' - <a href="' . DOL_URL_ROOT . '/blockedlog/admin/filecheck.php">' . img_picto ( '' , 'url' , 'class="pictofixedwidth"' ) . $langs -> trans ( " FileCheck " ) . '</a>' ;
2026-02-09 06:11:20 +00:00
}
2026-02-09 17:04:59 +00:00
// Show generic message (for countries that need registration) to explain we need registration to collect data and why
2026-01-27 00:13:22 +00:00
if ( in_array ( $mysoc -> country_code , array ( 'FR' ))) {
2026-02-09 06:11:20 +00:00
$organization_for_ping = getDolGlobalString ( 'MAIN_ORGANIZATION_FOR_PING' , " Association Dolibarr " );
$dataprivacy_url = getDolGlobalString ( 'MAIN_ORGANIZATION_URL_PRIVACY' , " https://www.dolibarr.org/legal-privacy-gdpr.php " );
2026-02-09 17:04:59 +00:00
if ( ! isRegistrationDataSavedAndPushed () || $origin == 'initmodule' ) {
if ( $infotoshow ) {
print info_admin ( $infotoshow , 0 , 0 , 'info' );
}
2026-02-15 23:08:14 +00:00
if (( ! isRegistrationDataSavedAndPushed () || ! isModEnabled ( 'blockedlog' )) && $mode != " forceregistration " ) {
2026-02-16 04:41:19 +00:00
print '<center><span class="error"><br>' . $langs -> trans ( " RegistrationRequired " ) . '<br><br></span></center>' ;
2026-02-15 22:13:45 +00:00
}
$htmltext = " " ;
$htmltext .= $langs -> trans ( " UnalterableLogToolRegistrationFR " ) . '<br>' ;
2026-02-09 17:04:59 +00:00
$htmltext .= $langs -> trans ( " InformationWillBePublishedTo " );
$htmltext .= '<br>' . $langs -> trans ( " InformationWillBePublishedTo2 " , $organization_for_ping , $dataprivacy_url );
2026-02-15 23:08:14 +00:00
if ( ! isRegistrationDataSavedAndPushed () || ! isModEnabled ( 'blockedlog' )) {
$htmltext .= '<br>' . $langs -> trans ( " InformationWillBePublishedTo3 " );
$color = 'warning' ;
} else {
$color = 'info' ;
}
2026-02-09 17:04:59 +00:00
2026-02-15 23:08:14 +00:00
print info_admin ( $htmltext , 0 , 0 , $color );
2026-02-19 23:27:56 +00:00
$htmltext = '' ;
2026-02-24 16:35:35 +00:00
// @phpstan-ignore-next-line Country code is already FR because of in_array('FR') test above
if ( $mysoc -> country_code === 'FR' ) {
2026-06-07 11:55:52 +00:00
$htmltext .= $langs -> trans ( " UnalterableLogTool1FR " , $langs -> transnoentitiesnoconv ( " Archives " )) . '<br>' ;
2026-02-19 23:27:56 +00:00
}
print info_admin ( $htmltext , 0 , 0 , 'warning' );
2026-02-15 23:08:14 +00:00
if ( isRegistrationDataSavedAndPushed () && isModEnabled ( 'blockedlog' ) && $mode != " forceregistration " ) {
print '<center><span class="ok"><br>' . $langs -> trans ( " ApplicationHasBeenRegistered " ) . '<br><br></span></center>' ;
}
2026-02-09 06:11:20 +00:00
} else {
2026-02-09 17:04:59 +00:00
$htmltext = ( $infotoshow ? $infotoshow . '<br>' : '' );
2026-02-17 20:21:48 +00:00
$htmltext .= $langs -> trans ( " ApplicationHasBeenRegistered " );
2026-04-02 14:38:21 +00:00
$htmltext .= ' ' . $langs -> trans ( " RegistrationNumber " ) . ': <span class="badge-text badge-secondary" title="Flag stored into MAIN_FIRST_REGISTRATION_OK_DATE. Registered data saved into BLOCKEDLOG_REGISTRATION_...">' . dol_trunc ( $registrationnumber , 10 ) . '</span>' ;
2026-02-17 20:21:48 +00:00
$htmltext .= '<br>' ;
2026-02-09 06:11:20 +00:00
$htmltext .= $langs -> trans ( " LastRegistrationDate " ) . ' : ' ;
//$htmltext .= dol_print_date(getDolGlobalString('MAIN_FIRST_REGISTRATION_OK_DATE'), 'dayhour', 'tzuserrel');
$htmltext .= getDolGlobalString ( 'MAIN_FIRST_REGISTRATION_OK_DATE' );
print info_admin ( $htmltext , 0 , 0 , 'info' );
2026-02-09 17:04:59 +00:00
// Show remind on good practices related to archives
2026-06-07 11:55:52 +00:00
$htmltext = $langs -> trans ( " UnalterableLogTool1FR " , $langs -> transnoentitiesnoconv ( " Archives " )) . '<br>' ;
2026-02-09 17:04:59 +00:00
print info_admin ( $htmltext , 0 , 0 , 'warning' );
2026-02-09 06:11:20 +00:00
}
2026-01-27 00:13:22 +00:00
}
2026-02-09 17:04:59 +00:00
2026-01-27 00:13:22 +00:00
print '<br>' ;
2026-02-09 17:04:59 +00:00
if ( $mode == " forceregistration " ) {
2026-02-08 22:14:07 +00:00
$company_state = $mysoc -> state ;
if ( getDolGlobalString ( 'BLOCKEDLOG_REGISTRATION_STATE' )) {
$company_state = getState ( getDolGlobalInt ( 'BLOCKEDLOG_REGISTRATION_STATE' ));
}
$arrayofdata = array (
'action' => 'dolibarrregistration' ,
'company_name' => getDolGlobalString ( 'BLOCKEDLOG_REGISTRATION_NAME' , $mysoc -> name ),
'company_email' => getDolGlobalString ( 'BLOCKEDLOG_REGISTRATION_EMAIL' , $mysoc -> email ),
2026-06-15 14:07:30 +00:00
'company_idprof1' => getDolGlobalString ( 'MAIN_INFO_SIREN' , $mysoc -> idprof1 ),
'company_idprof2' => getDolGlobalString ( 'MAIN_INFO_SIRET' , $mysoc -> idprof2 ),
2026-02-08 22:14:07 +00:00
'company_address' => getDolGlobalString ( 'BLOCKEDLOG_REGISTRATION_ADDRESS' , $mysoc -> address ),
'company_state' => $company_state ,
'company_zip' => getDolGlobalString ( 'BLOCKEDLOG_REGISTRATION_ZIP' , $mysoc -> zip ),
'company_town' => getDolGlobalString ( 'BLOCKEDLOG_REGISTRATION_TOWN' , $mysoc -> town ),
2026-06-15 16:51:49 +00:00
'country_code' => $mysoc -> country_code ,
2026-02-08 22:14:07 +00:00
'provider_name' => getDolGlobalString ( 'MAIN_INFO_ITPROVIDER_NAME' ),
'provider_email' => getDolGlobalString ( 'MAIN_INFO_ITPROVIDER_MAIL' ),
'provider_phone' => getDolGlobalString ( 'MAIN_INFO_ITPROVIDER_PHONE' ),
'provider_address' => getDolGlobalString ( 'MAIN_INFO_ITPROVIDER_ADDRESS' ),
'provider_state' => getDolGlobalString ( 'MAIN_INFO_ITPROVIDER_STATE' ),
'provider_zip' => getDolGlobalString ( 'MAIN_INFO_ITPROVIDER_ZIP' ),
'provider_town' => getDolGlobalString ( 'MAIN_INFO_ITPROVIDER_TOWN' ),
'provider_country' => getDolGlobalString ( 'MAIN_INFO_ITPROVIDER_COUNTRY' ),
2026-06-10 10:06:34 +00:00
'provider_idprof1' => getDolGlobalString ( 'MAIN_INFO_ITPROVIDER_IDPROF1' ),
'provider_idprof2' => getDolGlobalString ( 'MAIN_INFO_ITPROVIDER_IDPROF2' )
2026-02-08 22:14:07 +00:00
);
2026-02-09 06:11:20 +00:00
// Output js code to register data.
2026-08-12 23:06:24 +00:00
// Note: You can force the registration message by calling page /index.php?foreceregistration=1
2026-02-08 22:14:07 +00:00
printCodeForPing ( " MAIN_LAST_REGISTRATION_KO_DATE " , " MAIN_FIRST_REGISTRATION_OK_DATE " , $arrayofdata , 1 );
if ( ! isModEnabled ( " blockedlog " )) {
$modblckedlog = new modBlockedLog ( $db );
$res = $modblckedlog -> init ( 'forceinit' );
2026-02-09 06:11:20 +00:00
//$res = 1;
2026-02-08 22:14:07 +00:00
if ( $res <= 0 ) {
setEventMessages ( $modblckedlog -> error , $modblckedlog -> errors , 'errors' );
2026-02-09 06:11:20 +00:00
$mode = '' ;
2026-02-08 22:14:07 +00:00
}
}
2026-02-09 17:04:59 +00:00
if ( $mode == " forceregistration " ) {
print '<div class="center">' ;
print img_picto ( '' , 'tick' , 'class="large"' );
print '<br>' . $langs -> trans ( " RegistrationDoneAndModuleEnabled " , $langs -> transnoentitiesnoconv ( " BlockedLog " ));
2026-02-09 17:28:53 +00:00
2026-02-09 17:04:59 +00:00
// Go back to setup of module page
if ( GETPOST ( 'origin' ) == 'initmodule' ) {
print '<br><br>' ;
print '<br><br>' ;
2026-02-09 17:28:53 +00:00
print img_picto ( '' , 'back' ) . ' ' ;
2026-02-09 17:04:59 +00:00
print '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs -> trans ( " BackToModuleList " ) . '</a>' ;
}
print '</div>' ;
}
2026-02-09 06:11:20 +00:00
}
if ( empty ( $mode )) {
2026-02-09 17:04:59 +00:00
if ( $origin != 'initmodule' ) {
print '<br>' ;
print '<span class="opacitymedium">' . $langs -> trans ( " UseThisFormToUpdate " ) . '</span><br><br>' ;
}
2026-02-08 22:14:07 +00:00
$formSetup -> newItem ( 'Company' ) -> setAsTitle ();
//Company name
$item = $formSetup -> newItem ( 'BLOCKEDLOG_REGISTRATION_NAME' );
$item -> defaultFieldValue = getDolGlobalString ( 'BLOCKEDLOG_REGISTRATION_NAME' , $mysoc -> name );
$item -> fieldParams [ 'isMandatory' ] = 1 ;
//Company email
$item = $formSetup -> newItem ( 'BLOCKEDLOG_REGISTRATION_EMAIL' );
2026-05-26 04:36:25 +00:00
$item -> defaultFieldValue = ( GETPOSTISSET ( 'BLOCKEDLOG_REGISTRATION_EMAIL' ) ? GETPOST ( 'BLOCKEDLOG_REGISTRATION_EMAIL' ) : getDolGlobalString ( 'BLOCKEDLOG_REGISTRATION_EMAIL' , $mysoc -> email ));
2026-02-08 22:14:07 +00:00
$item -> setAsEmail ();
$item -> fieldParams [ 'isMandatory' ] = 1 ;
$item -> cssClass = " minwidth300 maxwidth500 widthcentpercentminusx " ;
//Company IDPROF1
2026-06-15 16:51:49 +00:00
$item = $formSetup -> newItem ( 'BLOCKEDLOG_REGISTRATION_IDPROF1' );
2026-06-15 14:07:30 +00:00
$item -> defaultFieldValue = ( GETPOSTISSET ( 'MAIN_INFO_SIREN' ) ? GETPOST ( 'MAIN_INFO_SIREN' ) : getDolGlobalString ( 'MAIN_INFO_SIREN' , $mysoc -> idprof1 ));
$item -> fieldValue = ( GETPOSTISSET ( 'MAIN_INFO_SIREN' ) ? GETPOST ( 'MAIN_INFO_SIREN' ) : getDolGlobalString ( 'MAIN_INFO_SIREN' , $mysoc -> idprof1 ));
2026-05-26 07:33:43 +00:00
$item -> helpText = $langs -> trans ( " Example " ) . ': 732 829 320' ;
2026-02-08 22:14:07 +00:00
$item -> fieldParams [ 'isMandatory' ] = 1 ;
2026-06-03 20:12:06 +00:00
$item -> nameText = $langs -> transcountry ( " ProfId1 " , $mysoc -> country_code );
//Company IDPROF2
2026-06-15 16:51:49 +00:00
$item = $formSetup -> newItem ( 'BLOCKEDLOG_REGISTRATION_IDPROF2' );
2026-06-15 14:07:30 +00:00
$item -> defaultFieldValue = ( GETPOSTISSET ( 'MAIN_INFO_SIRET' ) ? GETPOST ( 'MAIN_INFO_SIRET' ) : getDolGlobalString ( 'MAIN_INFO_SIRET' , $mysoc -> idprof2 ));
$item -> fieldValue = ( GETPOSTISSET ( 'MAIN_INFO_SIRET' ) ? GETPOST ( 'MAIN_INFO_SIRET' ) : getDolGlobalString ( 'MAIN_INFO_SIRET' , $mysoc -> idprof2 ));
$item -> helpText = $langs -> trans ( " Example " ) . ': 732 829 320 00074' ;
2026-06-03 20:12:06 +00:00
$item -> fieldParams [ 'isMandatory' ] = 1 ;
$item -> nameText = $langs -> transcountry ( " ProfId2 " , $mysoc -> country_code );
2026-01-27 00:13:22 +00:00
2026-02-08 22:14:07 +00:00
//Company country code
2026-06-15 16:51:49 +00:00
$country_id = getDolGlobalString ( 'BLOCKEDLOG_REGISTRATION_COUNTRY_ID' , $mysoc -> country_id );
2026-02-08 22:14:07 +00:00
$item = $formSetup -> newItem ( 'BLOCKEDLOG_REGISTRATION_COUNTRY_CODE' );
2026-06-15 16:51:49 +00:00
$item -> fieldInputOverride = $form -> select_country ( $country_id , " BLOCKEDLOG_REGISTRATION_COUNTRY_ID " , '' , 0 , 'minwidth300' );
2026-02-08 22:14:07 +00:00
$item -> fieldParams [ 'isMandatory' ] = 1 ;
//Company address
$item = $formSetup -> newItem ( 'BLOCKEDLOG_REGISTRATION_ADDRESS' );
$item -> defaultFieldValue = getDolGlobalString ( 'BLOCKEDLOG_REGISTRATION_ADDRESS' , $mysoc -> address );
$item -> setAsTextarea ();
//Company state
$item = $formSetup -> newItem ( 'BLOCKEDLOG_REGISTRATION_STATE' );
$state_id = 0 ;
if ( getDolGlobalString ( 'MAIN_INFO_SOCIETE_STATE' )) {
$tmp = explode ( ':' , getDolGlobalString ( 'MAIN_INFO_SOCIETE_STATE' ));
$state_id = $tmp [ 0 ];
}
$stateid = getDolGlobalInt ( 'BLOCKEDLOG_REGISTRATION_STATE' , ( int ) $state_id );
2026-06-16 01:48:29 +00:00
$item -> fieldInputOverride = $formcompany -> select_state ( $stateid , $mysoc -> country_code , " BLOCKEDLOG_REGISTRATION_STATE " );
2026-02-08 22:14:07 +00:00
//Company zip
$item = $formSetup -> newItem ( 'BLOCKEDLOG_REGISTRATION_ZIP' );
$item -> defaultFieldValue = getDolGlobalString ( 'BLOCKEDLOG_REGISTRATION_ZIP' , $mysoc -> zip );
$item -> cssClass = " width100 " ;
//Company town
$item = $formSetup -> newItem ( 'BLOCKEDLOG_REGISTRATION_TOWN' );
$item -> defaultFieldValue = getDolGlobalString ( 'BLOCKEDLOG_REGISTRATION_TOWN' , $mysoc -> town );
$formSetup -> newItem ( 'ITProvider' ) -> setAsTitle ();
//IT provider name
$item = $formSetup -> newItem ( 'MAIN_INFO_ITPROVIDER_NAME' );
$item -> defaultFieldValue = getDolGlobalString ( 'MAIN_INFO_ITPROVIDER_NAME' );
//IT provider email
$item = $formSetup -> newItem ( 'MAIN_INFO_ITPROVIDER_MAIL' );
$item -> defaultFieldValue = getDolGlobalString ( 'MAIN_INFO_ITPROVIDER_MAIL' );
$item -> setAsEmail ();
$item -> cssClass = " minwidth300 maxwidth500 widthcentpercentminusx " ;
//IT provider IDPROF1
$item = $formSetup -> newItem ( 'MAIN_INFO_ITPROVIDER_IDPROF1' );
$item -> defaultFieldValue = getDolGlobalString ( 'MAIN_INFO_ITPROVIDER_IDPROF1' );
2026-06-10 10:06:34 +00:00
//IT provider IDPROF1
$item = $formSetup -> newItem ( 'MAIN_INFO_ITPROVIDER_IDPROF2' );
$item -> defaultFieldValue = getDolGlobalString ( 'MAIN_INFO_ITPROVIDER_IDPROF2' );
2026-02-08 22:14:07 +00:00
//IT provider country code
$item = $formSetup -> newItem ( 'MAIN_INFO_ITPROVIDER_COUNTRY' );
$item -> defaultFieldValue = getDolGlobalString ( 'MAIN_INFO_ITPROVIDER_COUNTRY' );
$item -> fieldInputOverride = $form -> select_country ( getDolGlobalString ( 'MAIN_INFO_ITPROVIDER_COUNTRY' ), 'MAIN_INFO_ITPROVIDER_COUNTRY' );
//IT provider address
$item = $formSetup -> newItem ( 'MAIN_INFO_ITPROVIDER_ADDRESS' );
$item -> defaultFieldValue = getDolGlobalString ( 'MAIN_INFO_ITPROVIDER_ADDRESS' );
$item -> setAsTextarea ();
//IT provider state
$item = $formSetup -> newItem ( 'MAIN_INFO_ITPROVIDER_STATE' );
$item -> fieldInputOverride = $formcompany -> select_state ( getDolGlobalInt ( 'MAIN_INFO_ITPROVIDER_STATE' ), getDolGlobalString ( 'MAIN_INFO_ITPROVIDER_COUNTRY' ), " MAIN_INFO_ITPROVIDER_STATE " );
//IT provider zip
$item = $formSetup -> newItem ( 'MAIN_INFO_ITPROVIDER_ZIP' );
$item -> defaultFieldValue = getDolGlobalString ( 'MAIN_INFO_ITPROVIDER_ZIP' );
$item -> cssClass = " width100 " ;
//IT provider town
$item = $formSetup -> newItem ( 'MAIN_INFO_ITPROVIDER_TOWN' );
$item -> defaultFieldValue = getDolGlobalString ( 'MAIN_INFO_ITPROVIDER_TOWN' );
2026-02-09 06:11:20 +00:00
$formSetup -> formHiddenInputs [ 'origin' ] = GETPOST ( 'origin' );
2026-02-09 17:04:59 +00:00
$formSetup -> formHiddenInputs [ 'withtab' ] = $withtab ;
2026-02-09 06:11:20 +00:00
2026-02-09 17:04:59 +00:00
if ( isRegistrationDataSavedAndPushed () && $origin != 'initmodule' ) {
$formSetup -> htmlButtonLabel = 'SaveUpdate' ;
} else {
$formSetup -> htmlButtonLabel = 'SaveAndEnableModule' ;
}
2026-02-09 06:11:20 +00:00
2026-02-15 23:08:14 +00:00
print $formSetup -> generateOutput ( 2 , true , '' , '' );
2026-02-08 22:14:07 +00:00
}
2026-01-27 00:13:22 +00:00
if ( $withtab ) {
print dol_get_fiche_end ();
}
2026-02-09 17:04:59 +00:00
print '<br>' ;
2026-01-27 00:13:22 +00:00
// End of page
llxFooter ();
$db -> close ();