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