dolibarr 24.0.0-beta
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 } else {
394 $infotoshow = $langs->trans("NotCertifiedVersionFR", $versionbadge);
395 }
396
397 $infotoshow .= ' - <a href="'.DOL_URL_ROOT.'/blockedlog/admin/filecheck.php">'.img_picto('', 'url', 'class="pictofixedwidth"').$langs->trans("FileCheck").'</a>';
398}
399
400// Show generic message (for countries that need registration) to explain we need registration to collect data and why
401if (in_array($mysoc->country_code, array('FR'))) {
402 $organization_for_ping = getDolGlobalString('MAIN_ORGANIZATION_FOR_PING', "Association Dolibarr");
403 $dataprivacy_url = getDolGlobalString('MAIN_ORGANIZATION_URL_PRIVACY', "https://www.dolibarr.org/legal-privacy-gdpr.php");
404
405 if (!isRegistrationDataSavedAndPushed() || $origin == 'initmodule') {
406 if ($infotoshow) {
407 print info_admin($infotoshow, 0, 0, 'info');
408 }
409
410 if ((!isRegistrationDataSavedAndPushed() || !isModEnabled('blockedlog')) && $mode != "forceregistration") {
411 print '<center><span class="error"><br>'.$langs->trans("RegistrationRequired").'<br><br></span></center>';
412 }
413
414 $htmltext = "";
415 $htmltext .= $langs->trans("UnalterableLogToolRegistrationFR").'<br>';
416 $htmltext .= $langs->trans("InformationWillBePublishedTo");
417 $htmltext .= '<br>'.$langs->trans("InformationWillBePublishedTo2", $organization_for_ping, $dataprivacy_url);
418 if (!isRegistrationDataSavedAndPushed() || !isModEnabled('blockedlog')) {
419 $htmltext .= '<br>'.$langs->trans("InformationWillBePublishedTo3");
420 $color = 'warning';
421 } else {
422 $color = 'info';
423 }
424
425 print info_admin($htmltext, 0, 0, $color);
426
427 $htmltext = '';
428 // @phpstan-ignore-next-line Country code is already FR because of in_array('FR') test above
429 if ($mysoc->country_code === 'FR') {
430 $htmltext .= $langs->trans("UnalterableLogTool1FR", $langs->transnoentitiesnoconv("Archives")).'<br>';
431 }
432
433 print info_admin($htmltext, 0, 0, 'warning');
434
435 if (isRegistrationDataSavedAndPushed() && isModEnabled('blockedlog') && $mode != "forceregistration") {
436 print '<center><span class="ok"><br>'.$langs->trans("ApplicationHasBeenRegistered").'<br><br></span></center>';
437 }
438 } else {
439 $htmltext = ($infotoshow ? $infotoshow.'<br>' : '');
440 $htmltext .= $langs->trans("ApplicationHasBeenRegistered");
441 $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>';
442 $htmltext .= '<br>';
443 $htmltext .= $langs->trans("LastRegistrationDate").' : ';
444 //$htmltext .= dol_print_date(getDolGlobalString('MAIN_FIRST_REGISTRATION_OK_DATE'), 'dayhour', 'tzuserrel');
445 $htmltext .= getDolGlobalString('MAIN_FIRST_REGISTRATION_OK_DATE');
446
447 print info_admin($htmltext, 0, 0, 'info');
448
449 // Show remind on good practices related to archives
450 $htmltext = $langs->trans("UnalterableLogTool1FR", $langs->transnoentitiesnoconv("Archives")).'<br>';
451 print info_admin($htmltext, 0, 0, 'warning');
452 }
453}
454
455
456print '<br>';
457
458
459if ($mode == "forceregistration") {
460 $company_state = $mysoc->state;
461 if (getDolGlobalString('BLOCKEDLOG_REGISTRATION_STATE')) {
462 $company_state = getState(getDolGlobalInt('BLOCKEDLOG_REGISTRATION_STATE'));
463 }
464 $arrayofdata = array(
465 'action' => 'dolibarrregistration',
466
467 'company_name' => getDolGlobalString('BLOCKEDLOG_REGISTRATION_NAME', $mysoc->name),
468 'company_email' => getDolGlobalString('BLOCKEDLOG_REGISTRATION_EMAIL', $mysoc->email),
469 'company_idprof1' => getDolGlobalString('MAIN_INFO_SIREN', $mysoc->idprof1),
470 'company_idprof2' => getDolGlobalString('MAIN_INFO_SIRET', $mysoc->idprof2),
471 'company_address' => getDolGlobalString('BLOCKEDLOG_REGISTRATION_ADDRESS', $mysoc->address),
472 'company_state' => $company_state,
473 'company_zip' => getDolGlobalString('BLOCKEDLOG_REGISTRATION_ZIP', $mysoc->zip),
474 'company_town' => getDolGlobalString('BLOCKEDLOG_REGISTRATION_TOWN', $mysoc->town),
475 'country_code' => $mysoc->country_code,
476
477 'provider_name' => getDolGlobalString('MAIN_INFO_ITPROVIDER_NAME'),
478 'provider_email' => getDolGlobalString('MAIN_INFO_ITPROVIDER_MAIL'),
479 'provider_phone' => getDolGlobalString('MAIN_INFO_ITPROVIDER_PHONE'),
480 'provider_address' => getDolGlobalString('MAIN_INFO_ITPROVIDER_ADDRESS'),
481 'provider_state' => getDolGlobalString('MAIN_INFO_ITPROVIDER_STATE'),
482 'provider_zip' => getDolGlobalString('MAIN_INFO_ITPROVIDER_ZIP'),
483 'provider_town' => getDolGlobalString('MAIN_INFO_ITPROVIDER_TOWN'),
484 'provider_country' => getDolGlobalString('MAIN_INFO_ITPROVIDER_COUNTRY'),
485 'provider_idprof1' => getDolGlobalString('MAIN_INFO_ITPROVIDER_IDPROF1'),
486 'provider_idprof2' => getDolGlobalString('MAIN_INFO_ITPROVIDER_IDPROF2')
487 );
488
489 // Output js code to register data.
490 // Note: You can force thereigstration message by calling page /index.php?foreceregistration=1
491 printCodeForPing("MAIN_LAST_REGISTRATION_KO_DATE", "MAIN_FIRST_REGISTRATION_OK_DATE", $arrayofdata, 1);
492
493 if (!isModEnabled("blockedlog")) {
494 $modblckedlog = new modBlockedLog($db);
495 $res = $modblckedlog->init('forceinit');
496 //$res = 1;
497
498 if ($res <= 0) {
499 setEventMessages($modblckedlog->error, $modblckedlog->errors, 'errors');
500
501 $mode = '';
502 }
503 }
504 if ($mode == "forceregistration") {
505 print '<div class="center">';
506 print img_picto('', 'tick', 'class="large"');
507 print '<br>'.$langs->trans("RegistrationDoneAndModuleEnabled", $langs->transnoentitiesnoconv("BlockedLog"));
508
509 // Go back to setup of module page
510 if (GETPOST('origin') == 'initmodule') {
511 print '<br><br>';
512 print '<br><br>';
513 print img_picto('', 'back').' ';
514 print '<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
515 }
516 print '</div>';
517 }
518}
519if (empty($mode)) {
520 if ($origin != 'initmodule') {
521 print '<br>';
522 print '<span class="opacitymedium">'.$langs->trans("UseThisFormToUpdate").'</span><br><br>';
523 }
524
525 $formSetup->newItem('Company')->setAsTitle();
526
527 //Company name
528 $item = $formSetup->newItem('BLOCKEDLOG_REGISTRATION_NAME');
529 $item->defaultFieldValue = getDolGlobalString('BLOCKEDLOG_REGISTRATION_NAME', $mysoc->name);
530 $item->fieldParams['isMandatory'] = 1;
531
532 //Company email
533 $item = $formSetup->newItem('BLOCKEDLOG_REGISTRATION_EMAIL');
534 $item->defaultFieldValue = (GETPOSTISSET('BLOCKEDLOG_REGISTRATION_EMAIL') ? GETPOST('BLOCKEDLOG_REGISTRATION_EMAIL') : getDolGlobalString('BLOCKEDLOG_REGISTRATION_EMAIL', $mysoc->email));
535 $item->setAsEmail();
536 $item->fieldParams['isMandatory'] = 1;
537 $item->cssClass = "minwidth300 maxwidth500 widthcentpercentminusx";
538
539 //Company IDPROF1
540 $item = $formSetup->newItem('BLOCKEDLOG_REGISTRATION_IDPROF1');
541 $item->defaultFieldValue = (GETPOSTISSET('MAIN_INFO_SIREN') ? GETPOST('MAIN_INFO_SIREN') : getDolGlobalString('MAIN_INFO_SIREN', $mysoc->idprof1));
542 $item->fieldValue = (GETPOSTISSET('MAIN_INFO_SIREN') ? GETPOST('MAIN_INFO_SIREN') : getDolGlobalString('MAIN_INFO_SIREN', $mysoc->idprof1));
543 $item->helpText = $langs->trans("Example").': 732 829 320';
544 $item->fieldParams['isMandatory'] = 1;
545 $item->nameText = $langs->transcountry("ProfId1", $mysoc->country_code);
546
547 //Company IDPROF2
548 $item = $formSetup->newItem('BLOCKEDLOG_REGISTRATION_IDPROF2');
549 $item->defaultFieldValue = (GETPOSTISSET('MAIN_INFO_SIRET') ? GETPOST('MAIN_INFO_SIRET') : getDolGlobalString('MAIN_INFO_SIRET', $mysoc->idprof2));
550 $item->fieldValue = (GETPOSTISSET('MAIN_INFO_SIRET') ? GETPOST('MAIN_INFO_SIRET') : getDolGlobalString('MAIN_INFO_SIRET', $mysoc->idprof2));
551 $item->helpText = $langs->trans("Example").': 732 829 320 00074';
552 $item->fieldParams['isMandatory'] = 1;
553 $item->nameText = $langs->transcountry("ProfId2", $mysoc->country_code);
554
555 //Company country code
556 $country_id = getDolGlobalString('BLOCKEDLOG_REGISTRATION_COUNTRY_ID', $mysoc->country_id);
557 $item = $formSetup->newItem('BLOCKEDLOG_REGISTRATION_COUNTRY_CODE');
558 $item->fieldInputOverride = $form->select_country($country_id, "BLOCKEDLOG_REGISTRATION_COUNTRY_ID", '', 0, 'minwidth300');
559 $item->fieldParams['isMandatory'] = 1;
560
561 //Company address
562 $item = $formSetup->newItem('BLOCKEDLOG_REGISTRATION_ADDRESS');
563 $item->defaultFieldValue = getDolGlobalString('BLOCKEDLOG_REGISTRATION_ADDRESS', $mysoc->address);
564 $item->setAsTextarea();
565
566 //Company state
567 $item = $formSetup->newItem('BLOCKEDLOG_REGISTRATION_STATE');
568 $state_id = 0;
569 if (getDolGlobalString('MAIN_INFO_SOCIETE_STATE')) {
570 $tmp = explode(':', getDolGlobalString('MAIN_INFO_SOCIETE_STATE'));
571 $state_id = $tmp[0];
572 }
573 $stateid = getDolGlobalInt('BLOCKEDLOG_REGISTRATION_STATE', (int) $state_id);
574 $item->fieldInputOverride = $formcompany->select_state($stateid, $mysoc->country_code, "BLOCKEDLOG_REGISTRATION_STATE");
575
576 //Company zip
577 $item = $formSetup->newItem('BLOCKEDLOG_REGISTRATION_ZIP');
578 $item->defaultFieldValue = getDolGlobalString('BLOCKEDLOG_REGISTRATION_ZIP', $mysoc->zip);
579 $item->cssClass = "width100";
580
581 //Company town
582 $item = $formSetup->newItem('BLOCKEDLOG_REGISTRATION_TOWN');
583 $item->defaultFieldValue = getDolGlobalString('BLOCKEDLOG_REGISTRATION_TOWN', $mysoc->town);
584
585 $formSetup->newItem('ITProvider')->setAsTitle();
586
587 //IT provider name
588 $item = $formSetup->newItem('MAIN_INFO_ITPROVIDER_NAME');
589 $item->defaultFieldValue = getDolGlobalString('MAIN_INFO_ITPROVIDER_NAME');
590
591 //IT provider email
592 $item = $formSetup->newItem('MAIN_INFO_ITPROVIDER_MAIL');
593 $item->defaultFieldValue = getDolGlobalString('MAIN_INFO_ITPROVIDER_MAIL');
594 $item->setAsEmail();
595 $item->cssClass = "minwidth300 maxwidth500 widthcentpercentminusx";
596
597 //IT provider IDPROF1
598 $item = $formSetup->newItem('MAIN_INFO_ITPROVIDER_IDPROF1');
599 $item->defaultFieldValue = getDolGlobalString('MAIN_INFO_ITPROVIDER_IDPROF1');
600
601 //IT provider IDPROF1
602 $item = $formSetup->newItem('MAIN_INFO_ITPROVIDER_IDPROF2');
603 $item->defaultFieldValue = getDolGlobalString('MAIN_INFO_ITPROVIDER_IDPROF2');
604
605 //IT provider country code
606 $item = $formSetup->newItem('MAIN_INFO_ITPROVIDER_COUNTRY');
607 $item->defaultFieldValue = getDolGlobalString('MAIN_INFO_ITPROVIDER_COUNTRY');
608 $item->fieldInputOverride = $form->select_country(getDolGlobalString('MAIN_INFO_ITPROVIDER_COUNTRY'), 'MAIN_INFO_ITPROVIDER_COUNTRY');
609
610 //IT provider address
611 $item = $formSetup->newItem('MAIN_INFO_ITPROVIDER_ADDRESS');
612 $item->defaultFieldValue = getDolGlobalString('MAIN_INFO_ITPROVIDER_ADDRESS');
613 $item->setAsTextarea();
614
615 //IT provider state
616 $item = $formSetup->newItem('MAIN_INFO_ITPROVIDER_STATE');
617 $item->fieldInputOverride = $formcompany->select_state(getDolGlobalInt('MAIN_INFO_ITPROVIDER_STATE'), getDolGlobalString('MAIN_INFO_ITPROVIDER_COUNTRY'), "MAIN_INFO_ITPROVIDER_STATE");
618
619 //IT provider zip
620 $item = $formSetup->newItem('MAIN_INFO_ITPROVIDER_ZIP');
621 $item->defaultFieldValue = getDolGlobalString('MAIN_INFO_ITPROVIDER_ZIP');
622 $item->cssClass = "width100";
623
624 //IT provider town
625 $item = $formSetup->newItem('MAIN_INFO_ITPROVIDER_TOWN');
626 $item->defaultFieldValue = getDolGlobalString('MAIN_INFO_ITPROVIDER_TOWN');
627
628 $formSetup->formHiddenInputs['origin'] = GETPOST('origin');
629 $formSetup->formHiddenInputs['withtab'] = $withtab;
630
631 if (isRegistrationDataSavedAndPushed() && $origin != 'initmodule') {
632 $formSetup->htmlButtonLabel = 'SaveUpdate';
633 } else {
634 $formSetup->htmlButtonLabel = 'SaveAndEnableModule';
635 }
636
637 print $formSetup->generateOutput(2, true, '', '');
638}
639
640if ($withtab) {
641 print dol_get_fiche_end();
642}
643
644print '<br>';
645
646
647// End of page
648llxFooter();
649$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)
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='')
Show information in HTML for admin users or standard users.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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)
Return value of a param into GET or POST supervariable.
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.
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.
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.