dolibarr 21.0.0-alpha
societe.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
4 * Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
7 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
8 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
30// Load Dolibarr environment
31require '../../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
34require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
35require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
36
37$langs->loadLangs(array("admin", "companies", "other"));
38
39$action = GETPOST('action', 'aZ09');
40$value = GETPOST('value', 'alpha');
41$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
42
43if (!$user->admin) {
45}
46
47$formcompany = new FormCompany($db);
48
49
50
51/*
52 * Actions
53 */
54
55include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
56
57if ($action == 'setcodeclient') {
58 $result = dolibarr_set_const($db, "SOCIETE_CODECLIENT_ADDON", $value, 'chaine', 0, '', $conf->entity);
59 if ($result <= 0) {
60 dol_print_error($db);
61 }
62}
63
64if ($action == 'setcodecompta') {
65 $result = dolibarr_set_const($db, "SOCIETE_CODECOMPTA_ADDON", $value, 'chaine', 0, '', $conf->entity);
66 if ($result <= 0) {
67 dol_print_error($db);
68 }
69}
70
71if ($action == 'updateoptions') {
72 if (GETPOSTISSET('COMPANY_USE_SEARCH_TO_SELECT')) {
73 $companysearch = GETPOST('activate_COMPANY_USE_SEARCH_TO_SELECT', 'alpha');
74 $res = dolibarr_set_const($db, "COMPANY_USE_SEARCH_TO_SELECT", $companysearch, 'chaine', 0, '', $conf->entity);
75 if (!($res > 0)) {
76 $error++;
77 }
78 if (!$error) {
79 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
80 } else {
81 setEventMessages($langs->trans("Error"), null, 'errors');
82 }
83 }
84
85 if (GETPOSTISSET('CONTACT_USE_SEARCH_TO_SELECT')) {
86 $contactsearch = GETPOST('activate_CONTACT_USE_SEARCH_TO_SELECT', 'alpha');
87 $res = dolibarr_set_const($db, "CONTACT_USE_SEARCH_TO_SELECT", $contactsearch, 'chaine', 0, '', $conf->entity);
88 if (!($res > 0)) {
89 $error++;
90 }
91 if (!$error) {
92 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
93 } else {
94 setEventMessages($langs->trans("Error"), null, 'errors');
95 }
96 }
97
98 if (GETPOSTISSET('THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT')) {
99 $customertypedefault = GETPOSTINT('defaultcustomertype');
100 $res = dolibarr_set_const($db, "THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT", $customertypedefault, 'chaine', 0, '', $conf->entity);
101 if (!($res > 0)) {
102 $error++;
103 }
104 if (!$error) {
105 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
106 } else {
107 setEventMessages($langs->trans("Error"), null, 'errors');
108 }
109 }
110
111 if (GETPOSTISARRAY('CONTACTS_DEFAULT_ROLES')) {
112 $rolessearch = GETPOST('activate_CONTACTS_DEFAULT_ROLES', 'array:aZ09');
113 $res = dolibarr_set_const($db, "CONTACTS_DEFAULT_ROLES", implode(',', $rolessearch), 'chaine', 0, '', $conf->entity);
114 if (!($res > 0)) {
115 $error++;
116 }
117 if (!$error) {
118 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
119 } else {
120 setEventMessages($langs->trans("Error"), null, 'errors');
121 }
122 }
123}
124
125// Activate a document generator module
126if ($action == 'set') {
127 $label = GETPOST('label', 'alpha');
128 $scandir = GETPOST('scan_dir', 'alpha');
129
130 $type = 'company';
131 $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
132 $sql .= " VALUES ('".$db->escape($value)."', '".$db->escape($type)."', ".((int) $conf->entity).", ";
133 $sql .= ($label ? "'".$db->escape($label)."'" : 'null').", ";
134 $sql .= (!empty($scandir) ? "'".$db->escape($scandir)."'" : "null");
135 $sql .= ")";
136
137 $resql = $db->query($sql);
138 if (!$resql) {
139 dol_print_error($db);
140 }
141}
142
143// Disable a document generator module
144if ($action == 'del') {
145 $type = 'company';
146 $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
147 $sql .= " WHERE nom='".$db->escape($value)."' AND type='".$db->escape($type)."' AND entity=".((int) $conf->entity);
148 $resql = $db->query($sql);
149 if (!$resql) {
150 dol_print_error($db);
151 }
152}
153
154// Define default generator
155if ($action == 'setdoc') {
156 $label = GETPOST('label', 'alpha');
157 $scandir = GETPOST('scan_dir', 'alpha');
158
159 $db->begin();
160
161 dolibarr_set_const($db, "COMPANY_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity);
162
163 // On active le modele
164 $type = 'company';
165 $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
166 $sql_del .= " WHERE nom = '".$db->escape(GETPOST('value', 'alpha'))."'";
167 $sql_del .= " AND type = '".$db->escape($type)."'";
168 $sql_del .= " AND entity = ".((int) $conf->entity);
169 dol_syslog("societe.php ".$sql);
170 $result1 = $db->query($sql_del);
171
172 $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
173 $sql .= " VALUES ('".$db->escape($value)."', '".$db->escape($type)."', ".((int) $conf->entity).", ";
174 $sql .= ($label ? "'".$db->escape($label)."'" : 'null').", ";
175 $sql .= (!empty($scandir) ? "'".$db->escape($scandir)."'" : "null");
176 $sql .= ")";
177 dol_syslog("societe.php", LOG_DEBUG);
178 $result2 = $db->query($sql);
179 if ($result1 && $result2) {
180 $db->commit();
181 } else {
182 $db->rollback();
183 }
184}
185
186//Activate Set accountancy code customer invoice mandatory
187if ($action == "setaccountancycodecustomerinvoicemandatory") {
188 $setaccountancycodecustomerinvoicemandatory = GETPOSTINT('value');
189 $res = dolibarr_set_const($db, "SOCIETE_ACCOUNTANCY_CODE_CUSTOMER_INVOICE_MANDATORY", $setaccountancycodecustomerinvoicemandatory, 'yesno', 0, '', $conf->entity);
190 if (!($res > 0)) {
191 $error++;
192 }
193 if (!$error) {
194 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
195 } else {
196 setEventMessages($langs->trans("Error"), null, 'errors');
197 }
198}
199
200//Activate Set vat id unique
201if ($action == "setvatintraunique") {
202 $setvatintraunique = GETPOSTINT('value');
203 $res = dolibarr_set_const($db, "SOCIETE_VAT_INTRA_UNIQUE", $setvatintraunique, 'yesno', 0, '', $conf->entity);
204 if (!($res > 0)) {
205 $error++;
206 }
207 if (!$error) {
208 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
209 } else {
210 setEventMessages($langs->trans("Error"), null, 'errors');
211 }
212}
213
214//Activate Set ref in list
215if ($action == "setaddrefinlist") {
216 $setaddrefinlist = GETPOSTINT('value');
217 $res = dolibarr_set_const($db, "SOCIETE_ADD_REF_IN_LIST", $setaddrefinlist, 'yesno', 0, '', $conf->entity);
218 if (!($res > 0)) {
219 $error++;
220 }
221 if (!$error) {
222 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
223 } else {
224 setEventMessages($langs->trans("Error"), null, 'errors');
225 }
226}
227
228//Activate Set vat in list
229if ($action == "setvatinlist") {
230 $setvatinlist = GETPOSTINT('value');
231 $res = dolibarr_set_const($db, "SOCIETE_SHOW_VAT_IN_LIST", $setvatinlist, 'yesno', 0, '', $conf->entity);
232 if (!($res > 0)) {
233 $error++;
234 }
235 if (!$error) {
236 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
237 } else {
238 setEventMessages($langs->trans("Error"), null, 'errors');
239 }
240}
241
242//Activate Set address in list
243if ($action == "setaddadressinlist") {
244 $val = GETPOSTINT('value');
245 $res = dolibarr_set_const($db, "COMPANY_SHOW_ADDRESS_SELECTLIST", $val, 'yesno', 0, '', $conf->entity);
246 if (!($res > 0)) {
247 $error++;
248 }
249 if (!$error) {
250 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
251 } else {
252 setEventMessages($langs->trans("Error"), null, 'errors');
253 }
254}
255
256//Activate Set email phone town in contact list
257if ($action == "setaddemailphonetownincontactlist") {
258 $val = GETPOSTINT('value');
259 $res = dolibarr_set_const($db, "CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST", $val, 'yesno', 0, '', $conf->entity);
260 if (!($res > 0)) {
261 $error++;
262 }
263 if (!$error) {
264 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
265 } else {
266 setEventMessages($langs->trans("Error"), null, 'errors');
267 }
268}
269
270//Activate Ask For Preferred Shipping Method
271if ($action == "setaskforshippingmet") {
272 $setaskforshippingmet = GETPOSTINT('value');
273 $res = dolibarr_set_const($db, "SOCIETE_ASK_FOR_SHIPPING_METHOD", $setaskforshippingmet, 'yesno', 0, '', $conf->entity);
274 if (!($res > 0)) {
275 $error++;
276 }
277 if (!$error) {
278 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
279 } else {
280 setEventMessages($langs->trans("Error"), null, 'errors');
281 }
282}
283
284// Activate "Disable prospect/customer type"
285if ($action == "setdisableprospectcustomer") {
286 $setdisableprospectcustomer = GETPOSTINT('value');
287 $res = dolibarr_set_const($db, "SOCIETE_DISABLE_PROSPECTSCUSTOMERS", $setdisableprospectcustomer, 'yesno', 0, '', $conf->entity);
288 if (!($res > 0)) {
289 $error++;
290 }
291 if (!$error) {
292 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
293 } else {
294 setEventMessages($langs->trans("Error"), null, 'errors');
295 }
296}
297
298//Activate ProfId unique
299if ($action == 'setprofid') {
300 $status = GETPOST('status', 'alpha');
301
302 $idprof = "SOCIETE_".$value."_UNIQUE";
303 $result = dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity);
304 if ($result <= 0) {
305 dol_print_error($db);
306 }
307}
308
309//Activate ProfId mandatory
310if ($action == 'setprofidmandatory') {
311 $status = GETPOST('status', 'alpha');
312
313 $idprof = "SOCIETE_".$value."_MANDATORY";
314 $result = dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity);
315 if ($result <= 0) {
316 dol_print_error($db);
317 }
318}
319
320//Activate ProfId invoice mandatory
321if ($action == 'setprofidinvoicemandatory') {
322 $status = GETPOST('status', 'alpha');
323
324 $idprof = "SOCIETE_".$value."_INVOICE_MANDATORY";
325 $result = dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity);
326 if ($result <= 0) {
327 dol_print_error($db);
328 }
329}
330
331//Set hide closed customer into combox or select
332if ($action == 'sethideinactivethirdparty') {
333 $status = GETPOST('status', 'alpha');
334
335 $result = dolibarr_set_const($db, "COMPANY_HIDE_INACTIVE_IN_COMBOBOX", $status, 'chaine', 0, '', $conf->entity);
336 if ($result <= 0) {
337 dol_print_error($db);
338 }
339}
340if ($action == 'setonsearchandlistgooncustomerorsuppliercard') {
341 $setonsearchandlistgooncustomerorsuppliercard = GETPOSTINT('value');
342 $res = dolibarr_set_const($db, "SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD", $setonsearchandlistgooncustomerorsuppliercard, 'yesno', 0, '', $conf->entity);
343 if (!($res > 0)) {
344 $error++;
345 }
346 if (!$error) {
347 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
348 } else {
349 setEventMessages($langs->trans("Error"), null, 'errors');
350 }
351}
352
353
354/*
355 * View
356 */
357
358clearstatcache();
359
360$form = new Form($db);
361
362$help_url = 'EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers|ES:Configuración_del_módulo_terceros';
363llxHeader('', $langs->trans("CompanySetup"), $help_url);
364
365$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
366print load_fiche_titre($langs->trans("CompanySetup"), $linkback, 'title_setup');
367
368
370
371print dol_get_fiche_head($head, 'general', $langs->trans("ThirdParties"), -1, 'company');
372
373$dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
374foreach ($conf->modules_parts['models'] as $mo) {
375 $dirsociete[] = $mo.'core/modules/societe/'; //Add more models
376}
377
378// Module to manage customer/supplier code
379
380print load_fiche_titre($langs->trans("CompanyCodeChecker"), '', '');
381
382print '<div class="div-table-responsive-no-min">';
383print '<table class="noborder centpercent">'."\n";
384print '<tr class="liste_titre">'."\n";
385print ' <td>'.$langs->trans("Name").'</td>';
386print ' <td>'.$langs->trans("Description").'</td>';
387print ' <td>'.$langs->trans("Example").'</td>';
388print ' <td class="center" width="80">'.$langs->trans("Status").'</td>';
389print ' <td class="center" width="60">'.$langs->trans("ShortInfo").'</td>';
390print "</tr>\n";
391
392$arrayofmodules = array();
393
394foreach ($dirsociete as $dirroot) {
395 $dir = dol_buildpath($dirroot, 0);
396
397 $handle = @opendir($dir);
398 if (is_resource($handle)) {
399 // Loop on each module find in opened directory
400 while (($file = readdir($handle)) !== false) {
401 if (substr($file, 0, 15) == 'mod_codeclient_' && substr($file, -3) == 'php') {
402 $file = substr($file, 0, dol_strlen($file) - 4);
403
404 try {
405 dol_include_once($dirroot.$file.'.php');
406 } catch (Exception $e) {
407 dol_syslog($e->getMessage(), LOG_ERR);
408 }
409
411 $modCodeTiers = new $file($db);
412 '@phan-var-force ModeleThirdPartyCode $modCodeTiers';
413
414 // Show modules according to features level
415 if ($modCodeTiers->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
416 continue;
417 }
418 if ($modCodeTiers->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
419 continue;
420 }
421
422 $arrayofmodules[$file] = $modCodeTiers;
423 }
424 }
425 closedir($handle);
426 }
427}
428
429$arrayofmodules = dol_sort_array($arrayofmodules, 'position');
430'@phan-var-force array<string,ModeleThirdPartyCode> $arrayofmodules'; // Repeat type because of dol_sort_array
431
432foreach ($arrayofmodules as $file => $modCodeTiers) {
433 print '<tr class="oddeven">'."\n";
434 print '<td width="140">'.$modCodeTiers->name.'</td>'."\n";
435 print '<td>'.$modCodeTiers->info($langs).'</td>'."\n";
436 print '<td class="nowrap">'.$modCodeTiers->getExample($langs).'</td>'."\n";
437
438 if ($conf->global->SOCIETE_CODECLIENT_ADDON == "$file") {
439 print '<td class="center">'."\n";
440 print img_picto($langs->trans("Activated"), 'switch_on');
441 print "</td>\n";
442 } else {
443 $disabled = (isModEnabled('multicompany') && ((is_object($mc) && !empty($mc->sharings['referent'])) && ($mc->sharings['referent'] != $conf->entity)));
444 print '<td class="center">';
445 if (!$disabled) {
446 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setcodeclient&token='.newToken().'&value='.urlencode($file).'">';
447 }
448 print img_picto($langs->trans("Disabled"), 'switch_off');
449 if (!$disabled) {
450 print '</a>';
451 }
452 print '</td>';
453 }
454
455 print '<td class="center">';
456 $s = $modCodeTiers->getToolTip($langs, null, -1);
457 print $form->textwithpicto('', $s, 1);
458 print '</td>';
459
460 print '</tr>';
461}
462print '</table>';
463print '</div>';
464
465print "<br>";
466
467
468// Select accountancy code numbering module
469
470print load_fiche_titre($langs->trans("AccountCodeManager"), '', '');
471
472print '<div class="div-table-responsive-no-min">';
473print '<table class="noborder centpercent">';
474print '<tr class="liste_titre">';
475print '<td width="140">'.$langs->trans("Name").'</td>';
476print '<td>'.$langs->trans("Description").'</td>';
477print '<td>'.$langs->trans("Example").'</td>';
478print '<td class="center" width="80">'.$langs->trans("Status").'</td>';
479print '<td class="center" width="60">'.$langs->trans("ShortInfo").'</td>';
480print "</tr>\n";
481
482$arrayofmodules = array();
483
484foreach ($dirsociete as $dirroot) {
485 $dir = dol_buildpath($dirroot, 0);
486
487 $handle = @opendir($dir);
488 if (is_resource($handle)) {
489 while (($file = readdir($handle)) !== false) {
490 if (substr($file, 0, 15) == 'mod_codecompta_' && substr($file, -3) == 'php') {
491 $file = substr($file, 0, dol_strlen($file) - 4);
492
493 try {
494 dol_include_once($dirroot.$file.'.php');
495 } catch (Exception $e) {
496 dol_syslog($e->getMessage(), LOG_ERR);
497 }
498
499 $modCodeCompta = new $file();
500 '@phan-var-force ModeleAccountancyCode $modCodeTiers';
501
502 $arrayofmodules[$file] = $modCodeCompta;
503 }
504 }
505 closedir($handle);
506 }
507}
508
509$arrayofmodules = dol_sort_array($arrayofmodules, 'position');
510'@phan-var-force array<string,ModeleAccountancyCode> $arrayofmodules';
511
512
513foreach ($arrayofmodules as $file => $modCodeCompta) {
514 print '<tr class="oddeven">';
515 print '<td>'.$modCodeCompta->name."</td><td>\n";
516 print $modCodeCompta->info($langs);
517 print '</td>';
518 print '<td class="nowrap">'.$modCodeCompta->getExample($langs)."</td>\n";
519
520 if ($conf->global->SOCIETE_CODECOMPTA_ADDON == "$file") {
521 print '<td class="center">';
522 print img_picto($langs->trans("Activated"), 'switch_on');
523 print '</td>';
524 } else {
525 print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setcodecompta&token='.newToken().'&value='.urlencode($file).'">';
526 print img_picto($langs->trans("Disabled"), 'switch_off');
527 print '</a></td>';
528 }
529 print '<td class="center">';
530 $s = $modCodeCompta->getToolTip($langs, null, -1);
531 print $form->textwithpicto('', $s, 1);
532 print '</td>';
533 print "</tr>\n";
534}
535print "</table>\n";
536print '</div>';
537
538
539/*
540 * Document templates generators
541 */
542print '<br>';
543print load_fiche_titre($langs->trans("ModelModules"), '', '');
544
545// Load array def with activated templates
546$def = array();
547$sql = "SELECT nom";
548$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
549$sql .= " WHERE type = 'company'";
550$sql .= " AND entity = ".$conf->entity;
551$resql = $db->query($sql);
552if ($resql) {
553 $i = 0;
554 $num_rows = $db->num_rows($resql);
555 while ($i < $num_rows) {
556 $array = $db->fetch_array($resql);
557 if (is_array($array)) {
558 array_push($def, $array[0]);
559 }
560 $i++;
561 }
562} else {
563 dol_print_error($db);
564}
565
566print '<div class="div-table-responsive-no-min">';
567print '<table class="noborder centpercent">';
568print '<tr class="liste_titre">';
569print '<td width="140">'.$langs->trans("Name").'</td>';
570print '<td>'.$langs->trans("Description").'</td>';
571print '<td class="center" width="80">'.$langs->trans("Status").'</td>';
572print '<td class="center" width="60">'.$langs->trans("ShortInfo").'</td>';
573print '<td class="center" width="60">'.$langs->trans("Preview").'</td>';
574print "</tr>\n";
575
576foreach ($dirsociete as $dirroot) {
577 $dir = dol_buildpath($dirroot.'doc/', 0);
578
579 $handle = @opendir($dir);
580 if (is_resource($handle)) {
581 while (($file = readdir($handle)) !== false) {
582 if (preg_match('/\.modules\.php$/i', $file)) {
583 $name = substr($file, 4, dol_strlen($file) - 16);
584 $classname = substr($file, 0, dol_strlen($file) - 12);
585
586 try {
587 dol_include_once($dirroot.'doc/'.$file);
588 } catch (Exception $e) {
589 dol_syslog($e->getMessage(), LOG_ERR);
590 }
591
592 $module = new $classname($db);
593 '@phan-var-force ModeleThirdPartyDoc $module';
594
595 $modulequalified = 1;
596 if (!empty($module->version)) {
597 if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
598 $modulequalified = 0;
599 } elseif ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
600 $modulequalified = 0;
601 }
602 }
603
604 if ($modulequalified) {
605 print '<tr class="oddeven"><td width="100">';
606 print dol_escape_htmltag($module->name);
607 print "</td><td>\n";
608 if (method_exists($module, 'info')) {
609 print $module->info($langs); // @phan-suppress-current-line PhanUndeclaredMethod
610 } else {
611 print $module->description;
612 }
613 print '</td>';
614
615 // Activate / Disable
616 if (in_array($name, $def)) {
617 print "<td class=\"center\">\n";
618 //if ($conf->global->COMPANY_ADDON_PDF != "$name")
619 //{
620 print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.urlencode($name).'&token='.newToken().'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">';
621 print img_picto($langs->trans("Enabled"), 'switch_on');
622 print '</a>';
623 //}
624 //else
625 //{
626 // print img_picto($langs->trans("Enabled"),'on');
627 //}
628 print "</td>";
629 } else {
630 if (versioncompare($module->phpmin, versionphparray()) > 0) {
631 print '<td class="center">'."\n";
632 print img_picto(dol_escape_htmltag($langs->trans("ErrorModuleRequirePHPVersion", implode('.', $module->phpmin))), 'switch_off');
633 print "</td>";
634 } else {
635 print '<td class="center">'."\n";
636 print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.urlencode($name).'&token='.newToken().'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
637 print "</td>";
638 }
639 }
640
641 // Info
642 $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
643 $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
644 if ($module->type == 'pdf') {
645 $htmltooltip .= '<br>'.$langs->trans("Height").'/'.$langs->trans("Width").': '.$module->page_hauteur.'/'.$module->page_largeur;
646 }
647 $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
648 $htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraft").': '.yn((isset($module->option_draft_watermark) ? $module->option_draft_watermark : ''), 1, 1);
649
650 print '<td class="center nowrap">';
651 print $form->textwithpicto('', $htmltooltip, 1, 0);
652 print '</td>';
653
654 // Preview
655 print '<td class="center nowrap">';
656 if ($module->type == 'pdf') {
657 $linkspec = '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=specimen&token='.newToken().'&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
658 } else {
659 $linkspec = img_object($langs->trans("PreviewNotAvailable"), 'generic');
660 }
661 print $linkspec;
662 print '</td>';
663
664 print "</tr>\n";
665 }
666 }
667 }
668 closedir($handle);
669 }
670}
671print '</table>';
672print '</div>';
673
674print '<br>';
675
676//IDProf
677print load_fiche_titre($langs->trans("CompanyIdProfChecker"), '', '');
678
679print '<div class="div-table-responsive-no-min">';
680print '<table class="noborder centpercent">';
681print '<tr class="liste_titre">';
682print '<td>'.$langs->trans("Name").'</td>';
683print '<td>'.$langs->trans("Description").'</td>';
684print '<td class="center">'.$langs->trans("MustBeUnique").'</td>';
685print '<td class="center">'.$langs->trans("MustBeMandatory").'</td>';
686print '<td class="center">'.$langs->trans("MustBeInvoiceMandatory").'</td>';
687print "</tr>\n";
688
689$profid = array('IDPROF1' => array(), 'IDPROF2' => array(), 'IDPROF3' => array(), 'IDPROF4' => array(), 'IDPROF5' => array(),'IDPROF6' => array(), 'EMAIL' => array());
690$profid['IDPROF1'][0] = $langs->trans("ProfId1");
691$profid['IDPROF1'][1] = $langs->transcountry('ProfId1', $mysoc->country_code);
692$profid['IDPROF2'][0] = $langs->trans("ProfId2");
693$profid['IDPROF2'][1] = $langs->transcountry('ProfId2', $mysoc->country_code);
694$profid['IDPROF3'][0] = $langs->trans("ProfId3");
695$profid['IDPROF3'][1] = $langs->transcountry('ProfId3', $mysoc->country_code);
696$profid['IDPROF4'][0] = $langs->trans("ProfId4");
697$profid['IDPROF4'][1] = $langs->transcountry('ProfId4', $mysoc->country_code);
698$profid['IDPROF5'][0] = $langs->trans("ProfId5");
699$profid['IDPROF5'][1] = $langs->transcountry('ProfId5', $mysoc->country_code);
700$profid['IDPROF6'][0] = $langs->trans("ProfId6");
701$profid['IDPROF6'][1] = $langs->transcountry('ProfId6', $mysoc->country_code);
702$profid['EMAIL'][0] = $langs->trans("EMail");
703$profid['EMAIL'][1] = $langs->trans('Email');
704if (isModEnabled('accounting')) {
705 $profid['ACCOUNTANCY_CODE_CUSTOMER'] = array();
706 $profid['ACCOUNTANCY_CODE_CUSTOMER'][0] = $langs->trans("CustomerAccountancyCodeShort");
707 $profid['ACCOUNTANCY_CODE_CUSTOMER'][1] = $langs->trans('CustomerAccountancyCodeShort');
708 $profid['ACCOUNTANCY_CODE_SUPPLIER'] = array();
709 $profid['ACCOUNTANCY_CODE_SUPPLIER'][0] = $langs->trans("SupplierAccountancyCodeShort");
710 $profid['ACCOUNTANCY_CODE_SUPPLIER'][1] = $langs->trans('SupplierAccountancyCodeShort');
711}
712
713$nbofloop = count($profid);
714foreach ($profid as $key => $val) {
715 if ($profid[$key][1] != '-') {
716 print '<tr class="oddeven">';
717 print '<td>'.$profid[$key][0]."</td><td>\n";
718 print $profid[$key][1];
719 print '</td>';
720
721 $idprof_unique = 'SOCIETE_'.$key.'_UNIQUE';
722 $idprof_mandatory = 'SOCIETE_'.$key.'_MANDATORY';
723 $idprof_invoice_mandatory = 'SOCIETE_'.$key.'_INVOICE_MANDATORY';
724
725 $verif = !empty($conf->global->$idprof_unique);
726 $mandatory = !empty($conf->global->$idprof_mandatory);
727 $invoice_mandatory = !empty($conf->global->$idprof_invoice_mandatory);
728
729 if ($verif) {
730 print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofid&token='.newToken().'&value='.$key.'&status=0">';
731 print img_picto($langs->trans("Activated"), 'switch_on');
732 print '</a></td>';
733 } else {
734 print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofid&token='.newToken().'&value='.$key.'&status=1">';
735 print img_picto($langs->trans("Disabled"), 'switch_off');
736 print '</a></td>';
737 }
738
739 if ($mandatory) {
740 print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidmandatory&token='.newToken().'&value='.$key.'&status=0">';
741 print img_picto($langs->trans("Activated"), 'switch_on');
742 print '</a></td>';
743 } else {
744 print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidmandatory&token='.newToken().'&value='.$key.'&status=1">';
745 print img_picto($langs->trans("Disabled"), 'switch_off');
746 print '</a></td>';
747 }
748
749 if ($invoice_mandatory) {
750 print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidinvoicemandatory&token='.newToken().'&value='.$key.'&status=0">';
751 print img_picto($langs->trans("Activated"), 'switch_on');
752 print '</a></td>';
753 } else {
754 print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidinvoicemandatory&token='.newToken().'&value='.$key.'&status=1">';
755 print img_picto($langs->trans("Disabled"), 'switch_off');
756 print '</a></td>';
757 }
758
759 print "</tr>\n";
760 }
761}
762
763// VAT ID
764print '<tr class="oddeven">';
765print '<td colspan="2">'.$langs->trans('VATIntra')."</td>\n";
766
767if (getDolGlobalString('SOCIETE_VAT_INTRA_UNIQUE')) {
768 print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setvatintraunique&token='.newToken().'&value=0">';
769 print img_picto($langs->trans("Activated"), 'switch_on');
770 print '</a></td>';
771} else {
772 print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setvatintraunique&token='.newToken().'&value=1">';
773 print img_picto($langs->trans("Disabled"), 'switch_off');
774 print '</a></td>';
775}
776print '<td colspan="2"></td>';
777print "</tr>\n";
778
779print "</table>\n";
780print '</div>';
781
782print "<br>\n";
783
784print load_fiche_titre($langs->trans("Other"), '', '');
785
786// Autres options
787$form = new Form($db);
788
789print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
790print '<input type="hidden" name="token" value="'.newToken().'">';
791print '<input type="hidden" name="page_y" value="">';
792print '<input type="hidden" name="action" value="updateoptions">';
793
794print '<div class="div-table-responsive-no-min">';
795print '<table class="noborder centpercent">';
796print '<tr class="liste_titre">';
797print "<td>".$langs->trans("Parameters")."</td>\n";
798print '<td class="right" width="60">'.$langs->trans("Value").'</td>'."\n";
799print '<td width="80">&nbsp;</td></tr>'."\n";
800
801// Utilisation formulaire Ajax sur choix societe
802
803print '<tr class="oddeven">';
804print '<td width="80%">'.$form->textwithpicto($langs->trans("DelaiedFullListToSelectCompany"), $langs->trans('UseSearchToSelectCompanyTooltip'), 1).' </td>';
805if (!$conf->use_javascript_ajax) {
806 print '<td class="nowrap right" colspan="2">';
807 print $langs->trans("NotAvailableWhenAjaxDisabled");
808 print "</td>";
809} else {
810 print '<td width="60" class="right">';
811 $arrval = array('0' => $langs->trans("No"),
812 '1' => $langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 1).')',
813 '2' => $langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')',
814 '3' => $langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')',
815 );
816 print $form->selectarray("activate_COMPANY_USE_SEARCH_TO_SELECT", $arrval, getDolGlobalString('COMPANY_USE_SEARCH_TO_SELECT'), 0, 0, 0, '', 0, 0, 0, '', 'minwidth75imp');
817 print '</td><td class="right">';
818 print '<input type="submit" class="button small reposition" name="COMPANY_USE_SEARCH_TO_SELECT" value="'.$langs->trans("Modify").'">';
819 print "</td>";
820}
821print '</tr>';
822
823
824print '<tr class="oddeven">';
825print '<td width="80%">'.$form->textwithpicto($langs->trans("DelaiedFullListToSelectContact"), $langs->trans('UseSearchToSelectContactTooltip'), 1).'</td>';
826if (!$conf->use_javascript_ajax) {
827 print '<td class="nowrap right" colspan="2">';
828 print $langs->trans("NotAvailableWhenAjaxDisabled");
829 print "</td>";
830} else {
831 print '<td width="60" class="right">';
832 $arrval = array('0' => $langs->trans("No"),
833 '1' => $langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 1).')',
834 '2' => $langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')',
835 '3' => $langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')',
836 );
837 print $form->selectarray("activate_CONTACT_USE_SEARCH_TO_SELECT", $arrval, getDolGlobalString('CONTACT_USE_SEARCH_TO_SELECT'), 0, 0, 0, '', 0, 0, 0, '', 'minwidth75imp');
838 print '</td><td class="right">';
839 print '<input type="submit" class="button small reposition" name="CONTACT_USE_SEARCH_TO_SELECT" value="'.$langs->trans("Modify").'">';
840 print "</td>";
841}
842print '</tr>';
843
844
845
846print '<tr class="oddeven">';
847print '<td width="80%">'.$langs->trans("AddRefInList").'</td>';
848print '<td>&nbsp;</td>';
849print '<td class="center">';
850if (getDolGlobalString('SOCIETE_ADD_REF_IN_LIST')) {
851 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddrefinlist&token='.newToken().'&value=0">';
852 print img_picto($langs->trans("Activated"), 'switch_on');
853} else {
854 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddrefinlist&token='.newToken().'&value=1">';
855 print img_picto($langs->trans("Disabled"), 'switch_off');
856}
857print '</a></td>';
858print '</tr>';
859
860print '<tr class="oddeven">';
861print '<td width="80%">'.$langs->trans("AddVatInList").'</td>';
862print '<td>&nbsp;</td>';
863print '<td class="center">';
864if (getDolGlobalString('SOCIETE_SHOW_VAT_IN_LIST')) {
865 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setvatinlist&token='.newToken().'&value=0">';
866 print img_picto($langs->trans("Activated"), 'switch_on');
867} else {
868 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setvatinlist&token='.newToken().'&value=1">';
869 print img_picto($langs->trans("Disabled"), 'switch_off');
870}
871print '</a></td>';
872print '</tr>';
873
874print '<tr class="oddeven">';
875print '<td width="80%">'.$langs->trans("AddAdressInList").'</td>';
876print '<td>&nbsp;</td>';
877print '<td class="center">';
878if (getDolGlobalString('COMPANY_SHOW_ADDRESS_SELECTLIST')) {
879 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddadressinlist&token='.newToken().'&value=0">';
880 print img_picto($langs->trans("Activated"), 'switch_on');
881} else {
882 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddadressinlist&token='.newToken().'&value=1">';
883 print img_picto($langs->trans("Disabled"), 'switch_off');
884}
885print '</a></td>';
886print '</tr>';
887
888print '<tr class="oddeven">';
889print '<td width="80%">'.$langs->trans("AddEmailPhoneTownInContactList").'</td>';
890print '<td>&nbsp;</td>';
891print '<td class="center">';
892if (getDolGlobalString('CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST')) {
893 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddemailphonetownincontactlist&token='.newToken().'&value=0">';
894 print img_picto($langs->trans("Activated"), 'switch_on');
895} else {
896 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddemailphonetownincontactlist&token='.newToken().'&value=1">';
897 print img_picto($langs->trans("Disabled"), 'switch_off');
898}
899print '</a></td>';
900print '</tr>';
901
902if (isModEnabled("shipping")) {
903 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') > 0) { // Visible on experimental only because seems to not be implemented everywhere (only on proposal)
904 print '<tr class="oddeven">';
905 print '<td width="80%">'.$langs->trans("AskForPreferredShippingMethod").'</td>';
906 print '<td>&nbsp;</td>';
907 print '<td class="center">';
908 if (getDolGlobalString('SOCIETE_ASK_FOR_SHIPPING_METHOD')) {
909 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaskforshippingmet&token='.newToken().'&value=0">';
910 print img_picto($langs->trans("Activated"), 'switch_on');
911 } else {
912 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaskforshippingmet&token='.newToken().'&value=1">';
913 print img_picto($langs->trans("Disabled"), 'switch_off');
914 }
915 print '</a></td>';
916 print '</tr>';
917 }
918}
919
920// Disable Prospect/Customer thirdparty type
921print '<tr class="oddeven">';
922print '<td width="80%">'.$langs->trans("DisableProspectCustomerType").'</td>';
923print '<td>&nbsp;</td>';
924print '<td class="center">';
925if (getDolGlobalString('SOCIETE_DISABLE_PROSPECTSCUSTOMERS')) {
926 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setdisableprospectcustomer&token='.newToken().'&value=0">';
927 print img_picto($langs->trans("Activated"), 'switch_on');
928} else {
929 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setdisableprospectcustomer&token='.newToken().'&value=1">';
930 print img_picto($langs->trans("Disabled"), 'switch_off');
931}
932print '</a></td>';
933print '</tr>';
934
935if (!getDolGlobalString('SOCIETE_DISABLE_PROSPECTSCUSTOMERS')) {
936 // Default Prospect/Customer thirdparty type on customer création
937 print '<tr class="oddeven">';
938 print '<td>'.$langs->trans("DefaultCustomerType").'</td>';
939 print '<td>';
940 print $formcompany->selectProspectCustomerType(getDolGlobalString('THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT'), 'defaultcustomertype', 'defaultcustomertype', 'admin');
941 print '</td>';
942 print '<td class="center">';
943 print '<input type="submit" class="button small reposition" name="THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT" value="'.$langs->trans("Modify").'">';
944 print '</td>';
945 print '</tr>';
946}
947
948if (getDolGlobalString('THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION')) {
949 print '<tr class="oddeven">';
950 print '<td width="80%">'.$langs->trans('ContactsDefaultRoles').'</td>';
951 if (!$conf->use_javascript_ajax) {
952 print '<td class="nowrap right" colspan="2">';
953 print $langs->trans("NotAvailableWhenAjaxDisabled");
954 print "</td>";
955 } else {
956 print '<td width="60" class="right">';
957 $contact = new Contact($db); // InfraS add
958 $contactType = $contact->listeTypeContacts('external', 0, 1);
959 $selected = explode(',', getDolGlobalString('CONTACTS_DEFAULT_ROLES'));
960 print $form->multiselectarray('activate_CONTACTS_DEFAULT_ROLES', $contactType, $selected, 0, 0, 'minwidth75imp');
961 print '</td><td class="right">';
962 print '<input type="submit" class="button small eposition" name="CONTACTS_DEFAULT_ROLES" value="'.$langs->trans("Modify").'">';
963 print "</td>";
964 }
965 print '</tr>';
966}
967
968print '</table>';
969print '</div>';
970
971print '</form>';
972
973
974print dol_get_fiche_end();
975
976// End of page
977llxFooter();
978$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).
versionphparray()
Return version PHP.
versioncompare($versionarray1, $versionarray2)
Compare 2 versions (stored into 2 arrays).
Definition admin.lib.php:69
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:70
Class to manage contact/addresses.
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.
societe_admin_prepare_head()
Return array head with list of tabs to view object information.
llxFooter()
Footer empty.
Definition document.php:107
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
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)
Show picto whatever it's its name (generic function)
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)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.