dolibarr 24.0.1
registration.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017 ATM Consulting <contact@atm-consulting.fr>
3 * Copyright (C) 2017-2026 Laurent Destailleur <ldestailleur@dolicloud.com>
4 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2026 MDW <mdeweerd@users.noreply.github.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
28// Load Dolibarr environment
29require '../../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
39require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
40require_once DOL_DOCUMENT_ROOT.'/core/modules/modBlockedLog.class.php';
41require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
42require_once DOL_DOCUMENT_ROOT.'/core/lib/profid.lib.php';
43require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
44require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php';
45
46// Load translation files required by the page
47$langs->loadLangs(array('admin', 'blockedlog', 'other'));
48
49// Get Parameters
50$action = GETPOST('action', 'aZ09');
51$backtopage = GETPOST('backtopage', 'alpha');
52$cancel = GETPOST('cancel');
53
54$withtab = GETPOSTISSET('withtab') ? GETPOSTINT('withtab') : 1;
55$origin = GETPOST('origin');
56$mode = GETPOST('mode');
57
58// Access Control
59if (!$user->admin) {
61}
62
63
64/*
65 * Actions
66 */
67
68if (getDolGlobalString('BLOCKEDLOG_FOR_TAX_AUDITOR') && userIsTaxAuditor()) { // If we are in mode for tax auditor
69 header("Location: ".DOL_URL_ROOT.'/blockedlog/admin/blockedlog_archives.php');
70 exit;
71}
72
73if ($cancel && $origin == 'initmodule') {
74 header("Location: ".DOL_URL_ROOT."/admin/modules.php");
75 exit(0);
76}
77if ($cancel) {
78 $action = '';
79}
80
81if ($action == 'update') {
82 $error = 0;
83 $db->begin();
84
85 // The mandatory information must be the same than the one defined into isRegistrationDataSaved()
86 if (!GETPOST("BLOCKEDLOG_REGISTRATION_NAME")) {
87 setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("BLOCKEDLOG_REGISTRATION_NAME")), null, 'errors');
88 $error++;
89 }
90 if (!GETPOST("BLOCKEDLOG_REGISTRATION_EMAIL")) {
91 setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("BLOCKEDLOG_REGISTRATION_EMAIL")), null, 'errors');
92 $error++;
93 }
94 if (!GETPOST("BLOCKEDLOG_REGISTRATION_COUNTRY_ID")) {
95 setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("BLOCKEDLOG_REGISTRATION_COUNTRY_CODE")), null, 'errors');
96 $error++;
97 }
98 if (!GETPOST("BLOCKEDLOG_REGISTRATION_IDPROF1")) {
99 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transcountry("ProfId1", $mysoc->country_code)), null, 'errors');
100 $error++;
101 }
102 if (!GETPOST("BLOCKEDLOG_REGISTRATION_IDPROF2")) {
103 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transcountry("ProfId2", $mysoc->country_code)), null, 'errors');
104 $error++;
105 }
106
107 $tmpthirdparty = new Societe($db);
108
109 $tmparray = getCountry(GETPOSTINT('BLOCKEDLOG_REGISTRATION_COUNTRY_ID'), 'all', $db, $langs, 0);
110 if (!empty($tmparray['id'])) {
111 // Check we can change country
112 include_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
113 if ($mysoc->country_code == 'FR' && $tmparray['code'] != $mysoc->country_code && isALNERunningVersion()) {
114 // Trying to change the country. We refuse.
115 $langs->load("blockedlog");
116 setEventMessages($langs->trans("BlockedLogCountryChangeNotAllowedFR"), null, 'errors');
117 $error++;
118 } else {
119 $mysoc->country_id = $tmparray['id'];
120 $mysoc->country_code = $tmparray['code'];
121 $mysoc->country_label = $tmparray['label'];
122
123 $s = $mysoc->country_id.':'.$mysoc->country_code.':'.$mysoc->country_label;
124 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_COUNTRY", $s, 'chaine', 0, '', $conf->entity);
125
126 $tmpthirdparty->country_code = $mysoc->country_code;
127 $tmpthirdparty->country_id = $mysoc->country_id;
128 $tmpthirdparty->country_label = $mysoc->country_label;
129 $tmpthirdparty->idprof1 = GETPOST("BLOCKEDLOG_REGISTRATION_IDPROF1");
130 $tmpthirdparty->idprof2 = GETPOST("BLOCKEDLOG_REGISTRATION_IDPROF2");
131
132 activateModulesRequiredByCountry($mysoc->country_code);
133 }
134 }
135
136 // Check validity of email
137 if (!isValidEmail(GETPOST("BLOCKEDLOG_REGISTRATION_EMAIL"))) {
138 setEventMessages($langs->trans("ErrorBadEMail", GETPOST("BLOCKEDLOG_REGISTRATION_EMAIL")), null, 'errors');
139 $error++;
140 }
141
142 // Check validity of prof id if we try to save a new one
143 if ($tmpthirdparty->idprof1 && GETPOST('BLOCKEDLOG_REGISTRATION_IDPROF1') != $tmpthirdparty->idprof1 && isValidProfIds(1, $tmpthirdparty, 1) <= 0) {
144 $langs->loadLangs(array("errors", "companies"));
145 setEventMessages($langs->trans("ErrorBadValueForParameter", $tmpthirdparty->idprof1, $langs->transcountry("ProfId1Short", $tmpthirdparty->country_code)), null, 'errors');
146 $error++;
147 }
148 if ($tmpthirdparty->idprof2 && GETPOST('BLOCKEDLOG_REGISTRATION_IDPROF2') != $tmpthirdparty->idprof2 && isValidProfIds(2, $tmpthirdparty, 1) <= 0) {
149 $langs->loadLangs(array("errors", "companies"));
150 setEventMessages($langs->trans("ErrorBadValueForParameter", $tmpthirdparty->idprof2, $langs->transcountry("ProfId2Short", $tmpthirdparty->country_code)), null, 'errors');
151 $error++;
152 }
153
154 // Check that we don't change the SIREN. A new Dolibarr instance must be created to change SIREN.
155 if ($mysoc->country_code == 'FR' && $tmpthirdparty->idprof1 && $tmpthirdparty->idprof1 != $mysoc->idprof1 && isALNERunningVersion()) {
156 $langs->load("blockedlog");
157 setEventMessages($langs->trans("BlockedLogProfID1ChangeNotAllowedFR"), null, 'errors');
158 $error++;
159 }
160
161 $company_name = GETPOST("BLOCKEDLOG_REGISTRATION_NAME");
162 $company_email = GETPOST("BLOCKEDLOG_REGISTRATION_EMAIL");
163 $company_country_code = $tmparray['code'];
164 $company_idprof1 = GETPOST("BLOCKEDLOG_REGISTRATION_IDPROF1");
165 $company_idprof2 = GETPOST("BLOCKEDLOG_REGISTRATION_IDPROF2");
166 $company_address = GETPOST("BLOCKEDLOG_REGISTRATION_ADDRESS");
167 $company_state = GETPOST("BLOCKEDLOG_REGISTRATION_STATE");
168 $company_zip = GETPOST("BLOCKEDLOG_REGISTRATION_ZIP");
169 $company_town = GETPOST("BLOCKEDLOG_REGISTRATION_TOWN");
170
171 $provider_name = GETPOST("MAIN_INFO_ITPROVIDER_NAME");
172 $provider_email = GETPOST("MAIN_INFO_ITPROVIDER_MAIL");
173 $provider_country_id = GETPOST("MAIN_INFO_ITPROVIDER_COUNTRY");
174 $provider_idprof1 = GETPOST("MAIN_INFO_ITPROVIDER_IDPROF1");
175 $provider_idprof2 = GETPOST("MAIN_INFO_ITPROVIDER_IDPROF2");
176 $provider_address = GETPOST("MAIN_INFO_ITPROVIDER_ADDRESS");
177 $provider_state = GETPOST("MAIN_INFO_ITPROVIDER_STATE");
178 $provider_zip = GETPOST("MAIN_INFO_ITPROVIDER_ZIP");
179 $provider_town = GETPOST("MAIN_INFO_ITPROVIDER_TOWN");
180
181 if (!$error) {
182 //Company
183 $res = dolibarr_set_const($db, "BLOCKEDLOG_REGISTRATION_NAME", $company_name, 'chaine', 0, '', $conf->entity);
184 if ($res <= 0) {
185 $error++;
186 }
187 $res = dolibarr_set_const($db, "BLOCKEDLOG_REGISTRATION_EMAIL", $company_email, 'chaine', 0, '', $conf->entity);
188 if ($res <= 0) {
189 $error++;
190 }
191 $res = dolibarr_set_const($db, "MAIN_INFO_SIREN", $company_idprof1, 'chaine', 0, '', $conf->entity);
192 if ($res <= 0) {
193 $error++;
194 }
195 $res = dolibarr_set_const($db, "MAIN_INFO_SIRET", $company_idprof2, 'chaine', 0, '', $conf->entity);
196 if ($res <= 0) {
197 $error++;
198 }
199 $res = dolibarr_set_const($db, "BLOCKEDLOG_REGISTRATION_ADDRESS", $company_address, 'chaine', 0, '', $conf->entity);
200 if ($res <= 0) {
201 $error++;
202 }
203 $res = dolibarr_set_const($db, "BLOCKEDLOG_REGISTRATION_STATE", $company_state, 'chaine', 0, '', $conf->entity);
204 if ($res <= 0) {
205 $error++;
206 }
207 $res = dolibarr_set_const($db, "BLOCKEDLOG_REGISTRATION_ZIP", $company_zip, 'chaine', 0, '', $conf->entity);
208 if ($res <= 0) {
209 $error++;
210 }
211 $res = dolibarr_set_const($db, "BLOCKEDLOG_REGISTRATION_TOWN", $company_town, 'chaine', 0, '', $conf->entity);
212 if ($res <= 0) {
213 $error++;
214 }
215
216 //IT Provider
217 $res = dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_NAME", $provider_name, 'chaine', 0, '', $conf->entity);
218 if ($res <= 0) {
219 $error++;
220 }
221 $res = dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_MAIL", $provider_email, 'chaine', 0, '', $conf->entity);
222 if ($res <= 0) {
223 $error++;
224 }
225 $res = dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_COUNTRY", $provider_country_id, 'chaine', 0, '', $conf->entity);
226 if ($res <= 0) {
227 $error++;
228 }
229 $res = dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_IDPROF1", $provider_idprof1, 'chaine', 0, '', $conf->entity);
230 if ($res <= 0) {
231 $error++;
232 }
233 $res = dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_IDPROF2", $provider_idprof1, 'chaine', 0, '', $conf->entity);
234 if ($res <= 0) {
235 $error++;
236 }
237 $res = dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_ADDRESS", $provider_address, 'chaine', 0, '', $conf->entity);
238 if ($res <= 0) {
239 $error++;
240 }
241 $res = dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_STATE", $provider_state, 'chaine', 0, '', $conf->entity);
242 if ($res <= 0) {
243 $error++;
244 }
245 $res = dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_ZIP", $provider_zip, 'chaine', 0, '', $conf->entity);
246 if ($res <= 0) {
247 $error++;
248 }
249 $res = dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_TOWN", $provider_town, 'chaine', 0, '', $conf->entity);
250 if ($res <= 0) {
251 $error++;
252 }
253 }
254 if (!$error) {
255 // If HMAC key was not saved, we do it now
256
257 // Clear cache
258 unset($_SESSION['obfuscationkey_'.((int) $conf->entity)]);
259 unset($conf->cache['obfuscationkey_'.((int) $conf->entity)]);
260
261 require_once DOL_DOCUMENT_ROOT . '/blockedlog/class/blockedlog.class.php';
262 $b = new BlockedLog($db);
263
264 $hmac_encoded_secret_key = getDolGlobalString('BLOCKEDLOG_HMAC_KEY');
265
266 // This code is similar to the code into the init of module.
267 if (empty($hmac_encoded_secret_key)) {
268 // No HMAC key yet, we generate one.
269 $randomsecret = bin2hex(random_bytes(32)); // 64 char hex - 256 bits
270
271 $hmac_secret_key = 'BLOCKEDLOGHMAC'.$randomsecret; // Example: 'BLOCKEDLOGHMACY3Ewx37RXbSd8gL9JV8p7Wqw7qvq2K2A'
272 //$hmac_secret_key = 'BLOCKEDLOGHMACY3Ewx37RXbSd8gL9JV8p7Wqw7qvq2K2A';
273
274 $obfuscationkey = '';
275 if (isALNERunningVersion(1)) { // Note we are here if registration page requested, so for all french users, even if not assujeti.
276 try {
277 $obfuscationkey = $b->getObfuscationKey(); // Get the obfuscation key from memory or remote server. If not found, we retrieve it.
278 //$obfuscationkey = ''; // Uncomment this to test if obfuscation key can't be retrieved.
279 } catch (Exception $e) {
280 $error++;
281 setEventMessages($e->getMessage(), null, 'errors');
282 $obfuscationkey = '';
283 }
284 if (empty($obfuscationkey)) {
285 $error++;
286 $url_for_ping = getDolGlobalString('MAIN_URL_FOR_PING', "https://ping.dolibarr.org/");
287 setEventMessages($langs->trans('FailedToGetRemoteObfuscationKeyReTryLater', $url_for_ping), null, 'errors');
288 }
289
290 if (!$error) {
291 // Save HMAC key obfuscating it with remote $obfuscationkey
292 $result = $b->saveHMACSecretKey($hmac_secret_key, 'dolobfuscationv1-'.$mysoc->idprof1, $obfuscationkey); // gitleaks:allow
293 if ($result < 0) {
294 $error++;
295 setEventMessages($b->error, $b->errors, 'errors');
296 }
297 }
298 } else {
299 $result = $b->saveHMACSecretKey($hmac_secret_key, 'dolcrypt', $obfuscationkey); // gitleaks:allow
300 if ($result < 0) {
301 $error++;
302 setEventMessages($b->error, $b->errors, 'errors');
303 }
304 }
305 } else {
306 // If a HMAC key already exists, we don't need to create one.
307 // If it was store using the old method "dolcrypt", it will be converted into the new method "dolobfuscationv1-<siret>" at next recording by buildFinalSignatureHash().
308 }
309
310 if ($error) {
311 $db->rollback();
312 } else {
313 $db->commit();
314
315 //setEventMessages("SetupSaved", null, 'mesgs');
316 $urltouse = $_SERVER["PHP_SELF"]."?mode=forceregistration";
317 $urltouse .= (($withtab && GETPOST('origin')) ? '&withtab='.$withtab : '');
318 $urltouse .= (GETPOST('origin') ? '&origin='.GETPOST('origin') : '');
319
320 header("Location: ".$urltouse);
321 exit;
322 }
323 } else {
324 $db->rollback();
325 }
326}
327
328
329/*
330 * View
331 */
332
333$formSetup = new FormSetup($db);
334$form = new Form($db);
335$formcompany = new FormCompany($db);
336$block_static = new BlockedLog($db);
337$block_static->loadTrackedEvents();
338
339if ($withtab) {
340 $title = $langs->trans("ModuleSetup").' '.$langs->trans('BlockedLog');
341} else {
342 $title = $langs->trans("BrowseBlockedLog");
343}
344
345$help_url = "EN:Module_Unalterable_Archives_-_Logs|FR:Module_Archives_-_Logs_Inaltérable";
346
347llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-blockedlog page-admin_blockedlog');
348
349if ($withtab) {
350 $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>';
351} else {
352 $linkback = '';
353}
354
355$morehtmlcenter = '';
356$texttop = '';
357
358$registrationnumber = getHashUniqueIdOfRegistration();
359if (!userIsTaxAuditor()) {
360 $texttop = '<small class="opacitymedium">'.$langs->trans("RegistrationNumber").':</small> <small>'.dol_trunc($registrationnumber, 10).'</small>';
361 if ((!isRegistrationDataSavedAndPushed() || !isModEnabled('blockedlog')) && $mode != "forceregistration") {
362 $texttop = '';
363 }
364}
365
366print load_fiche_titre($title.'<br>'.$texttop, $linkback, 'blockedlog', 0, '', '', $morehtmlcenter);
367
368if ($withtab) {
369 $head = blockedlogadmin_prepare_head($withtab);
370 print dol_get_fiche_head($head, 'registration', '', -1);
371} else {
372 print '<br>';
373}
374
375print '<span class="opacitymedium">'.$langs->trans("BlockedLogDesc")."</span><br>\n";
376
377
378// Version
379$versionbadge = '<span class="badge-text badge-secondary">'.getBlockedLogVersionToShow().'</span>';
380
381
382// Special additional message for FR only
383$infotoshow = '';
384if ($mysoc->country_code == 'FR') {
385 $islne = isALNEQualifiedVersion(1, 1);
386 if ($islne) {
387 if (preg_match('/\-/', getBlockedLogVersionToShow())) {
388 // This is an alpha or beta version
389 $infotoshow = $langs->trans("LNECandidateVersionForCertificationFR", $versionbadge);
390 } else {
391 $infotoshow = $langs->trans("LNECertifiedVersionFR", $versionbadge);
392 }
393 $infotoshow .= ' - ';
394 } else {
395 $infotoshow = $langs->trans("NotCertifiedVersionFR", $versionbadge);
396 $infotoshow .= '<br>';
397 }
398
399 $infotoshow .= '<a href="'.DOL_URL_ROOT.'/blockedlog/admin/filecheck.php">'.img_picto('', 'url', 'class="pictofixedwidth"').$langs->trans("FileCheck").'</a>';
400}
401
402// Show generic message (for countries that need registration) to explain we need registration to collect data and why
403if (in_array($mysoc->country_code, array('FR'))) {
404 $organization_for_ping = getDolGlobalString('MAIN_ORGANIZATION_FOR_PING', "Association Dolibarr");
405 $dataprivacy_url = getDolGlobalString('MAIN_ORGANIZATION_URL_PRIVACY', "https://www.dolibarr.org/legal-privacy-gdpr.php");
406
407 if (!isRegistrationDataSavedAndPushed() || $origin == 'initmodule') {
408 if ($infotoshow) {
409 print info_admin($infotoshow, 0, 0, 'info');
410 }
411
412 if ((!isRegistrationDataSavedAndPushed() || !isModEnabled('blockedlog')) && $mode != "forceregistration") {
413 print '<center><span class="error"><br>'.$langs->trans("RegistrationRequired").'<br><br></span></center>';
414 }
415
416 $htmltext = "";
417 $htmltext .= $langs->trans("UnalterableLogToolRegistrationFR").'<br>';
418 $htmltext .= $langs->trans("InformationWillBePublishedTo");
419 $htmltext .= '<br>'.$langs->trans("InformationWillBePublishedTo2", $organization_for_ping, $dataprivacy_url);
420 if (!isRegistrationDataSavedAndPushed() || !isModEnabled('blockedlog')) {
421 $htmltext .= '<br>'.$langs->trans("InformationWillBePublishedTo3");
422 $color = 'warning';
423 } else {
424 $color = 'info';
425 }
426
427 print info_admin($htmltext, 0, 0, $color);
428
429 $htmltext = '';
430 // @phpstan-ignore-next-line Country code is already FR because of in_array('FR') test above
431 if ($mysoc->country_code === 'FR') {
432 $htmltext .= $langs->trans("UnalterableLogTool1FR", $langs->transnoentitiesnoconv("Archives")).'<br>';
433 }
434
435 print info_admin($htmltext, 0, 0, 'warning');
436
437 if (isRegistrationDataSavedAndPushed() && isModEnabled('blockedlog') && $mode != "forceregistration") {
438 print '<center><span class="ok"><br>'.$langs->trans("ApplicationHasBeenRegistered").'<br><br></span></center>';
439 }
440 } else {
441 $htmltext = ($infotoshow ? $infotoshow.'<br>' : '');
442 $htmltext .= $langs->trans("ApplicationHasBeenRegistered");
443 $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>';
444 $htmltext .= '<br>';
445 $htmltext .= $langs->trans("LastRegistrationDate").' : ';
446 //$htmltext .= dol_print_date(getDolGlobalString('MAIN_FIRST_REGISTRATION_OK_DATE'), 'dayhour', 'tzuserrel');
447 $htmltext .= getDolGlobalString('MAIN_FIRST_REGISTRATION_OK_DATE');
448
449 print info_admin($htmltext, 0, 0, 'info');
450
451 // Show remind on good practices related to archives
452 $htmltext = $langs->trans("UnalterableLogTool1FR", $langs->transnoentitiesnoconv("Archives")).'<br>';
453 print info_admin($htmltext, 0, 0, 'warning');
454 }
455}
456
457
458print '<br>';
459
460
461if ($mode == "forceregistration") {
462 $company_state = $mysoc->state;
463 if (getDolGlobalString('BLOCKEDLOG_REGISTRATION_STATE')) {
464 $company_state = getState(getDolGlobalInt('BLOCKEDLOG_REGISTRATION_STATE'));
465 }
466 $arrayofdata = array(
467 'action' => 'dolibarrregistration',
468
469 'company_name' => getDolGlobalString('BLOCKEDLOG_REGISTRATION_NAME', $mysoc->name),
470 'company_email' => getDolGlobalString('BLOCKEDLOG_REGISTRATION_EMAIL', $mysoc->email),
471 'company_idprof1' => getDolGlobalString('MAIN_INFO_SIREN', $mysoc->idprof1),
472 'company_idprof2' => getDolGlobalString('MAIN_INFO_SIRET', $mysoc->idprof2),
473 'company_address' => getDolGlobalString('BLOCKEDLOG_REGISTRATION_ADDRESS', $mysoc->address),
474 'company_state' => $company_state,
475 'company_zip' => getDolGlobalString('BLOCKEDLOG_REGISTRATION_ZIP', $mysoc->zip),
476 'company_town' => getDolGlobalString('BLOCKEDLOG_REGISTRATION_TOWN', $mysoc->town),
477 'country_code' => $mysoc->country_code,
478
479 'provider_name' => getDolGlobalString('MAIN_INFO_ITPROVIDER_NAME'),
480 'provider_email' => getDolGlobalString('MAIN_INFO_ITPROVIDER_MAIL'),
481 'provider_phone' => getDolGlobalString('MAIN_INFO_ITPROVIDER_PHONE'),
482 'provider_address' => getDolGlobalString('MAIN_INFO_ITPROVIDER_ADDRESS'),
483 'provider_state' => getDolGlobalString('MAIN_INFO_ITPROVIDER_STATE'),
484 'provider_zip' => getDolGlobalString('MAIN_INFO_ITPROVIDER_ZIP'),
485 'provider_town' => getDolGlobalString('MAIN_INFO_ITPROVIDER_TOWN'),
486 'provider_country' => getDolGlobalString('MAIN_INFO_ITPROVIDER_COUNTRY'),
487 'provider_idprof1' => getDolGlobalString('MAIN_INFO_ITPROVIDER_IDPROF1'),
488 'provider_idprof2' => getDolGlobalString('MAIN_INFO_ITPROVIDER_IDPROF2')
489 );
490
491 // Output js code to register data.
492 // Note: You can force the registration message by calling page /index.php?foreceregistration=1
493 printCodeForPing("MAIN_LAST_REGISTRATION_KO_DATE", "MAIN_FIRST_REGISTRATION_OK_DATE", $arrayofdata, 1);
494
495 if (!isModEnabled("blockedlog")) {
496 $modblckedlog = new modBlockedLog($db);
497 $res = $modblckedlog->init('forceinit');
498 //$res = 1;
499
500 if ($res <= 0) {
501 setEventMessages($modblckedlog->error, $modblckedlog->errors, 'errors');
502
503 $mode = '';
504 }
505 }
506 if ($mode == "forceregistration") {
507 print '<div class="center">';
508 print img_picto('', 'tick', 'class="large"');
509 print '<br>'.$langs->trans("RegistrationDoneAndModuleEnabled", $langs->transnoentitiesnoconv("BlockedLog"));
510
511 // Go back to setup of module page
512 if (GETPOST('origin') == 'initmodule') {
513 print '<br><br>';
514 print '<br><br>';
515 print img_picto('', 'back').' ';
516 print '<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
517 }
518 print '</div>';
519 }
520}
521if (empty($mode)) {
522 if ($origin != 'initmodule') {
523 print '<br>';
524 print '<span class="opacitymedium">'.$langs->trans("UseThisFormToUpdate").'</span><br><br>';
525 }
526
527 $formSetup->newItem('Company')->setAsTitle();
528
529 //Company name
530 $item = $formSetup->newItem('BLOCKEDLOG_REGISTRATION_NAME');
531 $item->defaultFieldValue = getDolGlobalString('BLOCKEDLOG_REGISTRATION_NAME', $mysoc->name);
532 $item->fieldParams['isMandatory'] = 1;
533
534 //Company email
535 $item = $formSetup->newItem('BLOCKEDLOG_REGISTRATION_EMAIL');
536 $item->defaultFieldValue = (GETPOSTISSET('BLOCKEDLOG_REGISTRATION_EMAIL') ? GETPOST('BLOCKEDLOG_REGISTRATION_EMAIL') : getDolGlobalString('BLOCKEDLOG_REGISTRATION_EMAIL', $mysoc->email));
537 $item->setAsEmail();
538 $item->fieldParams['isMandatory'] = 1;
539 $item->cssClass = "minwidth300 maxwidth500 widthcentpercentminusx";
540
541 //Company IDPROF1
542 $item = $formSetup->newItem('BLOCKEDLOG_REGISTRATION_IDPROF1');
543 $item->defaultFieldValue = (GETPOSTISSET('MAIN_INFO_SIREN') ? GETPOST('MAIN_INFO_SIREN') : getDolGlobalString('MAIN_INFO_SIREN', $mysoc->idprof1));
544 $item->fieldValue = (GETPOSTISSET('MAIN_INFO_SIREN') ? GETPOST('MAIN_INFO_SIREN') : getDolGlobalString('MAIN_INFO_SIREN', $mysoc->idprof1));
545 $item->helpText = $langs->trans("Example").': 732 829 320';
546 $item->fieldParams['isMandatory'] = 1;
547 $item->nameText = $langs->transcountry("ProfId1", $mysoc->country_code);
548
549 //Company IDPROF2
550 $item = $formSetup->newItem('BLOCKEDLOG_REGISTRATION_IDPROF2');
551 $item->defaultFieldValue = (GETPOSTISSET('MAIN_INFO_SIRET') ? GETPOST('MAIN_INFO_SIRET') : getDolGlobalString('MAIN_INFO_SIRET', $mysoc->idprof2));
552 $item->fieldValue = (GETPOSTISSET('MAIN_INFO_SIRET') ? GETPOST('MAIN_INFO_SIRET') : getDolGlobalString('MAIN_INFO_SIRET', $mysoc->idprof2));
553 $item->helpText = $langs->trans("Example").': 732 829 320 00074';
554 $item->fieldParams['isMandatory'] = 1;
555 $item->nameText = $langs->transcountry("ProfId2", $mysoc->country_code);
556
557 //Company country code
558 $country_id = getDolGlobalString('BLOCKEDLOG_REGISTRATION_COUNTRY_ID', $mysoc->country_id);
559 $item = $formSetup->newItem('BLOCKEDLOG_REGISTRATION_COUNTRY_CODE');
560 $item->fieldInputOverride = $form->select_country($country_id, "BLOCKEDLOG_REGISTRATION_COUNTRY_ID", '', 0, 'minwidth300');
561 $item->fieldParams['isMandatory'] = 1;
562
563 //Company address
564 $item = $formSetup->newItem('BLOCKEDLOG_REGISTRATION_ADDRESS');
565 $item->defaultFieldValue = getDolGlobalString('BLOCKEDLOG_REGISTRATION_ADDRESS', $mysoc->address);
566 $item->setAsTextarea();
567
568 //Company state
569 $item = $formSetup->newItem('BLOCKEDLOG_REGISTRATION_STATE');
570 $state_id = 0;
571 if (getDolGlobalString('MAIN_INFO_SOCIETE_STATE')) {
572 $tmp = explode(':', getDolGlobalString('MAIN_INFO_SOCIETE_STATE'));
573 $state_id = $tmp[0];
574 }
575 $stateid = getDolGlobalInt('BLOCKEDLOG_REGISTRATION_STATE', (int) $state_id);
576 $item->fieldInputOverride = $formcompany->select_state($stateid, $mysoc->country_code, "BLOCKEDLOG_REGISTRATION_STATE");
577
578 //Company zip
579 $item = $formSetup->newItem('BLOCKEDLOG_REGISTRATION_ZIP');
580 $item->defaultFieldValue = getDolGlobalString('BLOCKEDLOG_REGISTRATION_ZIP', $mysoc->zip);
581 $item->cssClass = "width100";
582
583 //Company town
584 $item = $formSetup->newItem('BLOCKEDLOG_REGISTRATION_TOWN');
585 $item->defaultFieldValue = getDolGlobalString('BLOCKEDLOG_REGISTRATION_TOWN', $mysoc->town);
586
587 $formSetup->newItem('ITProvider')->setAsTitle();
588
589 //IT provider name
590 $item = $formSetup->newItem('MAIN_INFO_ITPROVIDER_NAME');
591 $item->defaultFieldValue = getDolGlobalString('MAIN_INFO_ITPROVIDER_NAME');
592
593 //IT provider email
594 $item = $formSetup->newItem('MAIN_INFO_ITPROVIDER_MAIL');
595 $item->defaultFieldValue = getDolGlobalString('MAIN_INFO_ITPROVIDER_MAIL');
596 $item->setAsEmail();
597 $item->cssClass = "minwidth300 maxwidth500 widthcentpercentminusx";
598
599 //IT provider IDPROF1
600 $item = $formSetup->newItem('MAIN_INFO_ITPROVIDER_IDPROF1');
601 $item->defaultFieldValue = getDolGlobalString('MAIN_INFO_ITPROVIDER_IDPROF1');
602
603 //IT provider IDPROF1
604 $item = $formSetup->newItem('MAIN_INFO_ITPROVIDER_IDPROF2');
605 $item->defaultFieldValue = getDolGlobalString('MAIN_INFO_ITPROVIDER_IDPROF2');
606
607 //IT provider country code
608 $item = $formSetup->newItem('MAIN_INFO_ITPROVIDER_COUNTRY');
609 $item->defaultFieldValue = getDolGlobalString('MAIN_INFO_ITPROVIDER_COUNTRY');
610 $item->fieldInputOverride = $form->select_country(getDolGlobalString('MAIN_INFO_ITPROVIDER_COUNTRY'), 'MAIN_INFO_ITPROVIDER_COUNTRY');
611
612 //IT provider address
613 $item = $formSetup->newItem('MAIN_INFO_ITPROVIDER_ADDRESS');
614 $item->defaultFieldValue = getDolGlobalString('MAIN_INFO_ITPROVIDER_ADDRESS');
615 $item->setAsTextarea();
616
617 //IT provider state
618 $item = $formSetup->newItem('MAIN_INFO_ITPROVIDER_STATE');
619 $item->fieldInputOverride = $formcompany->select_state(getDolGlobalInt('MAIN_INFO_ITPROVIDER_STATE'), getDolGlobalString('MAIN_INFO_ITPROVIDER_COUNTRY'), "MAIN_INFO_ITPROVIDER_STATE");
620
621 //IT provider zip
622 $item = $formSetup->newItem('MAIN_INFO_ITPROVIDER_ZIP');
623 $item->defaultFieldValue = getDolGlobalString('MAIN_INFO_ITPROVIDER_ZIP');
624 $item->cssClass = "width100";
625
626 //IT provider town
627 $item = $formSetup->newItem('MAIN_INFO_ITPROVIDER_TOWN');
628 $item->defaultFieldValue = getDolGlobalString('MAIN_INFO_ITPROVIDER_TOWN');
629
630 $formSetup->formHiddenInputs['origin'] = GETPOST('origin');
631 $formSetup->formHiddenInputs['withtab'] = $withtab;
632
633 if (isRegistrationDataSavedAndPushed() && $origin != 'initmodule') {
634 $formSetup->htmlButtonLabel = 'SaveUpdate';
635 } else {
636 $formSetup->htmlButtonLabel = 'SaveAndEnableModule';
637 }
638
639 print $formSetup->generateOutput(2, true, '', '');
640}
641
642if ($withtab) {
643 print dol_get_fiche_end();
644}
645
646print '<br>';
647
648
649// End of page
650llxFooter();
651$db->close();
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
getBlockedLogVersionToShow()
Define head array for tabs of blockedlog tools setup pages.
isALNEQualifiedVersion($ignoredev=0, $ignoremodule=0)
Return if the version is a candidate version to get the LNE certification and if the prerequisites ar...
userIsTaxAuditor()
Call remote API service to push the last counter and signature.
blockedlogadmin_prepare_head($withtabsetup)
Define head array for tabs of blockedlog tools setup pages.
isRegistrationDataSavedAndPushed()
Return if the KYC mandatory parameters are set AND pushed/registered centralized server.
getHashUniqueIdOfRegistration($algo='sha256')
Return a hash unique identifier of the registration (used to identify the registration of instance wi...
isALNERunningVersion($blockedlogtestalreadydone=0, $blockedlogmodulealreadydone=0)
Return if the application is executed with the LNE requirements on.
Class to manage Blocked Log.
Class to build HTML component for third parties management Only common components are here.
Class to manage generation of HTML components Only common components must be here.
This class help you create setup render.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to describe a BlockedLog module.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
getState($id, $withcode='0', $dbtouse=null, $withregion=0, $outputlangs=null, $entconv=1)
Return state translated from an id.
global $mysoc
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as p label as s rowid as s nom as s email
Sender: Who sends the email ("Sender" has sent emails on behalf of "From").
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
printCodeForPing($constanttosavelastko, $constanttosavefirstok, $arrayofdata=array(), $forceping=0)
Function to output HTML to make an ajax call to make registration.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '...' if string larger than length.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='', $cssfordropdown='info_admin')
Show information in HTML for admin users or standard users.
isValidProfIds($idprof, $thirdparty, $lenghtonly=0)
Check the validity of a professional identifier according to the properties (country) of the company ...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.