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
178//Activate Set accountancy code customer invoice mandatory
179if ($action == "setaccountancycodecustomerinvoicemandatory") {
180 $setaccountancycodecustomerinvoicemandatory = GETPOSTINT('value');
181 $res = dolibarr_set_const($db, "SOCIETE_ACCOUNTANCY_CODE_CUSTOMER_INVOICE_MANDATORY", $setaccountancycodecustomerinvoicemandatory, 'yesno', 0, '', $conf->entity);
182 if (!($res > 0)) {
183 $error++;
184 }
185 if (!$error) {
186 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
187 } else {
188 setEventMessages($langs->trans("Error"), null, 'errors');
189 }
190}
191
192//Activate Set ref in list
193if ($action == "setaddrefinlist") {
194 $setaddrefinlist = GETPOSTINT('value');
195 $res = dolibarr_set_const($db, "SOCIETE_ADD_REF_IN_LIST", $setaddrefinlist, 'yesno', 0, '', $conf->entity);
196 if (!($res > 0)) {
197 $error++;
198 }
199 if (!$error) {
200 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
201 } else {
202 setEventMessages($langs->trans("Error"), null, 'errors');
203 }
204}
205
206//Activate Set vat in list
207if ($action == "setvatinlist") {
208 $setvatinlist = GETPOSTINT('value');
209 $res = dolibarr_set_const($db, "SOCIETE_SHOW_VAT_IN_LIST", $setvatinlist, 'yesno', 0, '', $conf->entity);
210 if (!($res > 0)) {
211 $error++;
212 }
213 if (!$error) {
214 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
215 } else {
216 setEventMessages($langs->trans("Error"), null, 'errors');
217 }
218}
219
220//Activate Set address in list
221if ($action == "setaddadressinlist") {
222 $val = GETPOSTINT('value');
223 $res = dolibarr_set_const($db, "COMPANY_SHOW_ADDRESS_SELECTLIST", $val, 'yesno', 0, '', $conf->entity);
224 if (!($res > 0)) {
225 $error++;
226 }
227 if (!$error) {
228 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
229 } else {
230 setEventMessages($langs->trans("Error"), null, 'errors');
231 }
232}
233
234//Activate Set email phone town in contact list
235if ($action == "setaddemailphonetownincontactlist") {
236 $val = GETPOSTINT('value');
237 $res = dolibarr_set_const($db, "CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST", $val, 'yesno', 0, '', $conf->entity);
238 if (!($res > 0)) {
239 $error++;
240 }
241 if (!$error) {
242 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
243 } else {
244 setEventMessages($langs->trans("Error"), null, 'errors');
245 }
246}
247
248//Activate Ask For Preferred Shipping Method
249if ($action == "setaskforshippingmet") {
250 $setaskforshippingmet = GETPOSTINT('value');
251 $res = dolibarr_set_const($db, "SOCIETE_ASK_FOR_SHIPPING_METHOD", $setaskforshippingmet, 'yesno', 0, '', $conf->entity);
252 if (!($res > 0)) {
253 $error++;
254 }
255 if (!$error) {
256 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
257 } else {
258 setEventMessages($langs->trans("Error"), null, 'errors');
259 }
260}
261
262// Activate "Disable prospect/customer type"
263if ($action == "setdisableprospectcustomer") {
264 $setdisableprospectcustomer = GETPOSTINT('value');
265 $res = dolibarr_set_const($db, "SOCIETE_DISABLE_PROSPECTSCUSTOMERS", $setdisableprospectcustomer, 'yesno', 0, '', $conf->entity);
266 if (!($res > 0)) {
267 $error++;
268 }
269 if (!$error) {
270 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
271 } else {
272 setEventMessages($langs->trans("Error"), null, 'errors');
273 }
274}
275
276//Activate ProfId unique
277if ($action == 'setprofid') {
278 $status = GETPOST('status', 'alpha');
279
280 $idprof = "SOCIETE_".$value."_UNIQUE";
281 $result = dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity);
282 if ($result <= 0) {
283 dol_print_error($db);
284 }
285}
286
287//Activate ProfId mandatory
288if ($action == 'setprofidmandatory') {
289 $status = GETPOST('status', 'alpha');
290
291 $idprof = "SOCIETE_".$value."_MANDATORY";
292 $result = dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity);
293 if ($result <= 0) {
294 dol_print_error($db);
295 }
296}
297
298//Activate ProfId invoice mandatory
299if ($action == 'setprofidinvoicemandatory' || $action == 'setprofidinvoicemandatoryeeconly') {
300 $status = GETPOST('status', 'alpha');
301 if ($status == '1' && $action == 'setprofidinvoicemandatoryeeconly') {
302 $status = 'eeconly';
303 }
304 $idprof = "SOCIETE_".$value."_INVOICE_MANDATORY";
305 $result = dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity);
306 if ($result <= 0) {
307 dol_print_error($db);
308 }
309}
310
311//Set hide closed customer into combox or select
312if ($action == 'sethideinactivethirdparty') {
313 $status = GETPOST('status', 'alpha');
314
315 $result = dolibarr_set_const($db, "COMPANY_HIDE_INACTIVE_IN_COMBOBOX", $status, 'chaine', 0, '', $conf->entity);
316 if ($result <= 0) {
317 dol_print_error($db);
318 }
319}
320if ($action == 'setonsearchandlistgooncustomerorsuppliercard') {
321 $setonsearchandlistgooncustomerorsuppliercard = GETPOSTINT('value');
322 $res = dolibarr_set_const($db, "SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD", $setonsearchandlistgooncustomerorsuppliercard, 'yesno', 0, '', $conf->entity);
323 if (!($res > 0)) {
324 $error++;
325 }
326 if (!$error) {
327 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
328 } else {
329 setEventMessages($langs->trans("Error"), null, 'errors');
330 }
331}
332
333
334/*
335 * View
336 */
337
338clearstatcache();
339
340$form = new Form($db);
341
342$help_url = 'EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers|ES:Configuración_del_módulo_terceros';
343llxHeader('', $langs->trans("CompanySetup"), $help_url);
344
345$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>';
346
347print load_fiche_titre($langs->trans("CompanySetup"), $linkback, 'title_setup');
348
349
351
352print dol_get_fiche_head($head, 'general', $langs->trans("ThirdParties"), -1, 'company');
353
354$dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
355foreach ($conf->modules_parts['models'] as $mo) {
356 $dirsociete[] = $mo.'core/modules/societe/'; //Add more models
357}
358
359// Module to manage customer/supplier code
360
361print load_fiche_titre($langs->trans("CompanyCodeChecker"), '', '');
362
363print '<div class="div-table-responsive-no-min">';
364print '<table class="noborder centpercent">'."\n";
365print '<tr class="liste_titre">'."\n";
366print ' <td>'.$langs->trans("Name").'</td>';
367print ' <td>'.$langs->trans("Description").'</td>';
368print ' <td>'.$langs->trans("Example").'</td>';
369print ' <td class="center" width="80">'.$langs->trans("Status").'</td>';
370print ' <td class="center" width="60">'.$langs->trans("ShortInfo").'</td>';
371print "</tr>\n";
372
373$arrayofmodules = array();
374
375foreach ($dirsociete as $dirroot) {
376 $dir = dol_buildpath($dirroot, 0);
377
378 $handle = @opendir($dir);
379 if (is_resource($handle)) {
380 // Loop on each module find in opened directory
381 while (($file = readdir($handle)) !== false) {
382 if (dol_substr($file, 0, 15) == 'mod_codeclient_' && dol_substr($file, -3) == 'php') {
383 $file = dol_substr($file, 0, dol_strlen($file) - 4);
384
385 try {
386 dol_include_once($dirroot.$file.'.php');
387 } catch (Exception $e) {
388 dol_syslog($e->getMessage(), LOG_ERR);
389 }
390
392 $modCodeTiers = new $file($db);
393 '@phan-var-force ModeleThirdPartyCode $modCodeTiers';
394
395 // Show modules according to features level
396 if ($modCodeTiers->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
397 continue;
398 }
399 if ($modCodeTiers->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
400 continue;
401 }
402
403 $arrayofmodules[$file] = $modCodeTiers;
404 }
405 }
406 closedir($handle);
407 }
408}
409
410$arrayofmodules = dol_sort_array($arrayofmodules, 'position');
411// '@phan-var-force array<string,ModeleThirdPartyCode> $arrayofmodules'; // Repeat type because of dol_sort_array
412
413foreach ($arrayofmodules as $file => $modCodeTiers) {
414 print '<tr class="oddeven">'."\n";
415 print '<td width="140">'.$modCodeTiers->name.'</td>'."\n";
416 print '<td>'.$modCodeTiers->info($langs).'</td>'."\n";
417 print '<td class="nowrap">'.$modCodeTiers->getExample($langs).'</td>'."\n";
418
419 if (getDolGlobalString('SOCIETE_CODECLIENT_ADDON') == (string) $file) {
420 print '<td class="center">'."\n";
421 print img_picto($langs->trans("Activated"), 'switch_on');
422 print "</td>\n";
423 } else {
424 $disabled = (isModEnabled('multicompany') && isset($mc) && ((is_object($mc) && !empty($mc->sharings['referent'])) && ($mc->sharings['referent'] != $conf->entity)));
425 print '<td class="center">';
426 if (!$disabled) {
427 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setcodeclient&token='.newToken().'&value='.urlencode($file).'">';
428 }
429 print img_picto($langs->trans("Disabled"), 'switch_off');
430 if (!$disabled) {
431 print '</a>';
432 }
433 print '</td>';
434 }
435
436 print '<td class="center">';
437 $s = $modCodeTiers->getToolTip($langs, null, -1);
438 print $form->textwithpicto('', $s, 1);
439 print '</td>';
440
441 print '</tr>';
442}
443print '</table>';
444print '</div>';
445
446print "<br>";
447
448
449// Select accountancy code numbering module
450
451print load_fiche_titre($langs->trans("AccountCodeManager"), '', '');
452
453print '<div class="div-table-responsive-no-min">';
454print '<table class="noborder centpercent">';
455print '<tr class="liste_titre">';
456print '<td width="140">'.$langs->trans("Name").'</td>';
457print '<td>'.$langs->trans("Description").'</td>';
458print '<td>'.$langs->trans("Example").'</td>';
459print '<td class="center" width="80">'.$langs->trans("Status").'</td>';
460print '<td class="center" width="60">'.$langs->trans("ShortInfo").'</td>';
461print "</tr>\n";
462
463$arrayofmodules = array();
464
465foreach ($dirsociete as $dirroot) {
466 $dir = dol_buildpath($dirroot, 0);
467
468 $handle = @opendir($dir);
469 if (is_resource($handle)) {
470 while (($file = readdir($handle)) !== false) {
471 if (dol_substr($file, 0, 15) == 'mod_codecompta_' && dol_substr($file, -3) == 'php') {
472 $file = dol_substr($file, 0, dol_strlen($file) - 4);
473
474 try {
475 dol_include_once($dirroot.$file.'.php');
476 } catch (Exception $e) {
477 dol_syslog($e->getMessage(), LOG_ERR);
478 }
479
480 $modCodeCompta = new $file();
481 '@phan-var-force ModeleAccountancyCode $modCodeTiers';
482
483 $arrayofmodules[$file] = $modCodeCompta;
484 }
485 }
486 closedir($handle);
487 }
488}
489
490$arrayofmodules = dol_sort_array($arrayofmodules, 'position');
491'@phan-var-force array<string,ModeleAccountancyCode> $arrayofmodules';
492
493
494foreach ($arrayofmodules as $file => $modCodeCompta) {
495 print '<tr class="oddeven">';
496 print '<td>'.$modCodeCompta->name."</td><td>\n";
497 print $modCodeCompta->info($langs);
498 print '</td>';
499 print '<td class="nowrap">'.$modCodeCompta->getExample($langs)."</td>\n";
500
501 if (getDolGlobalString('SOCIETE_CODECOMPTA_ADDON') == "$file") {
502 print '<td class="center">';
503 print img_picto($langs->trans("Activated"), 'switch_on');
504 print '</td>';
505 } else {
506 print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setcodecompta&token='.newToken().'&value='.urlencode($file).'">';
507 print img_picto($langs->trans("Disabled"), 'switch_off');
508 print '</a></td>';
509 }
510 print '<td class="center">';
511 $s = $modCodeCompta->getToolTip($langs, null, -1);
512 print $form->textwithpicto('', $s, 1);
513 print '</td>';
514 print "</tr>\n";
515}
516print "</table>\n";
517print '</div>';
518
519
520/*
521 * Document templates generators
522 */
523
524print '<br>';
525printDocumentModelList('company', 'societe', 'COMPANY_ADDON_PDF', $langs->trans("ModelModules"), array(
526 'Logo' => 'option_logo',
527 'WatermarkOnDraft' => 'option_draft_watermark',
528), false, '', 0);
529
530print '<br>';
531
532
533// IDProf
534print load_fiche_titre($langs->trans("CompanyIdProfChecker"), '', '');
535
536print '<div class="div-table-responsive-no-min">';
537print '<table class="noborder centpercent">';
538print '<tr class="liste_titre">';
539print '<td>'.$langs->trans("Name").'</td>';
540print '<td>'.$langs->trans("Description").'</td>';
541print '<td class="center">'.$langs->trans("MustBeUnique").'</td>';
542print '<td class="center">'.$langs->trans("MustBeMandatory").'<br><span class="opacitymedium">'.$langs->trans("MustBeMandatory2").'</span></td>';
543print '<td class="center">'.$langs->trans("MustBeInvoiceMandatory").'</td>';
544print "</tr>\n";
545
546$profid = array('IDPROF1' => array(), 'IDPROF2' => array(), 'IDPROF3' => array(), 'IDPROF4' => array(), 'IDPROF5' => array(),'IDPROF6' => array(), 'EMAIL' => array(), 'EUID' => array());
547$profid['IDPROF1'][0] = $langs->trans("ProfId1");
548$profid['IDPROF1'][1] = $langs->transcountry('ProfId1', $mysoc->country_code);
549$profid['IDPROF2'][0] = $langs->trans("ProfId2");
550$profid['IDPROF2'][1] = $langs->transcountry('ProfId2', $mysoc->country_code);
551$profid['IDPROF3'][0] = $langs->trans("ProfId3");
552$profid['IDPROF3'][1] = $langs->transcountry('ProfId3', $mysoc->country_code);
553$profid['IDPROF4'][0] = $langs->trans("ProfId4");
554$profid['IDPROF4'][1] = $langs->transcountry('ProfId4', $mysoc->country_code);
555$profid['IDPROF5'][0] = $langs->trans("ProfId5");
556$profid['IDPROF5'][1] = $langs->transcountry('ProfId5', $mysoc->country_code);
557$profid['IDPROF6'][0] = $langs->trans("ProfId6");
558$profid['IDPROF6'][1] = $langs->transcountry('ProfId6', $mysoc->country_code);
559$profid['EMAIL'][0] = $langs->trans("EMail");
560$profid['EMAIL'][1] = $langs->trans('Email');
561$profid['EUID'][0] = $langs->trans("EUIDShort");
562$profid['EUID'][1] = $langs->trans('EUID');
563if (isModEnabled('accounting')) {
564 $profid['ACCOUNTANCY_CODE_CUSTOMER'] = array();
565 $profid['ACCOUNTANCY_CODE_CUSTOMER'][0] = $langs->trans("CustomerAccountancyCodeShort");
566 $profid['ACCOUNTANCY_CODE_CUSTOMER'][1] = $langs->trans('CustomerAccountancyCodeShort');
567 $profid['ACCOUNTANCY_CODE_SUPPLIER'] = array();
568 $profid['ACCOUNTANCY_CODE_SUPPLIER'][0] = $langs->trans("SupplierAccountancyCodeShort");
569 $profid['ACCOUNTANCY_CODE_SUPPLIER'][1] = $langs->trans('SupplierAccountancyCodeShort');
570}
571
572$nbofloop = count($profid);
573foreach ($profid as $key => $val) {
574 if ($profid[$key][1] != '-') {
575 print '<tr class="oddeven">';
576 print '<td>'.$profid[$key][0]."</td><td>\n";
577 print $profid[$key][1];
578 print '</td>';
579
580 $idprof_unique = 'SOCIETE_'.$key.'_UNIQUE';
581 $idprof_mandatory = 'SOCIETE_'.$key.'_MANDATORY';
582 $idprof_invoice_mandatory = 'SOCIETE_'.$key.'_INVOICE_MANDATORY';
583
584 $verif = !empty($conf->global->$idprof_unique);
585 $mandatory = !empty($conf->global->$idprof_mandatory);
586 $invoice_mandatory = !empty($conf->global->$idprof_invoice_mandatory);
587
588 if ($verif) {
589 print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofid&token='.newToken().'&value='.$key.'&status=0">';
590 print img_picto($langs->trans("Activated"), 'switch_on');
591 print '</a></td>';
592 } else {
593 print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofid&token='.newToken().'&value='.$key.'&status=1">';
594 print img_picto($langs->trans("Disabled"), 'switch_off');
595 print '</a></td>';
596 }
597
598 if ($mandatory) {
599 print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidmandatory&token='.newToken().'&value='.$key.'&status=0">';
600 print img_picto($langs->trans("Activated"), 'switch_on');
601 print '</a></td>';
602 } else {
603 print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidmandatory&token='.newToken().'&value='.$key.'&status=1">';
604 print img_picto($langs->trans("Disabled"), 'switch_off');
605 print '</a></td>';
606 }
607
608 if ($invoice_mandatory) {
609 print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidinvoicemandatory&token='.newToken().'&value='.$key.'&status=0">';
610 print img_picto($langs->trans("Activated"), 'switch_on');
611 print '</a></td>';
612 } else {
613 print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidinvoicemandatory&token='.newToken().'&value='.$key.'&status=1">';
614 print img_picto($langs->trans("Disabled"), 'switch_off');
615 print '</a></td>';
616 }
617
618 print "</tr>\n";
619 }
620}
621
622// VAT ID
623print '<tr class="oddeven">';
624print '<td colspan="2">'.$langs->trans('VATIntra')."</td>\n";
625$key = 'VAT_INTRA';
626if (getDolGlobalString('SOCIETE_VAT_INTRA_UNIQUE')) {
627 print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofid&token='.newToken().'&value='.$key.'&status=0">';
628 print img_picto($langs->trans("Activated"), 'switch_on', 'class="valignmiddle"');
629 print '</a></td>';
630} else {
631 print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofid&token='.newToken().'&value='.$key.'&status=1">';
632 print img_picto($langs->trans("Disabled"), 'switch_off', 'class="valignmiddle"');
633 print '</a></td>';
634}
635if (getDolGlobalString('SOCIETE_VAT_INTRA_MANDATORY')) {
636 print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidmandatory&token='.newToken().'&value='.$key.'&status=0">';
637 print img_picto($langs->trans("Activated"), 'switch_on', 'class="valignmiddle"');
638 print '</a></td>';
639} else {
640 print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidmandatory&token='.newToken().'&value='.$key.'&status=1">';
641 print img_picto($langs->trans("Disabled"), 'switch_off', 'class="valignmiddle"');
642 print '</a></td>';
643}
644print '<td class="center">';
645if (getDolGlobalString('SOCIETE_VAT_INTRA_INVOICE_MANDATORY') == 'eeconly') {
646 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidinvoicemandatoryeeconly&token='.newToken().'&value='.$key.'&status=0">';
647 print img_picto($langs->trans("Activated"), 'switch_on', 'class="valignmiddle paddingrightonly"');
648 print '</a>';
649 print $langs->trans("SaleEEC").'<br>';
650 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidinvoicemandatory&token='.newToken().'&value='.$key.'&status=1">';
651 print img_picto($langs->trans("Activated"), 'switch_off', 'class="valignmiddle paddingrightonly"');
652 print '</a>';
653 print $langs->trans("AnySale");
654} elseif (getDolGlobalString('SOCIETE_VAT_INTRA_INVOICE_MANDATORY')) {
655 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidinvoicemandatoryeeconly&token='.newToken().'&value='.$key.'&status=1">';
656 print img_picto($langs->trans("Activated"), 'switch_off', 'class="valignmiddle paddingrightonly"');
657 print '</a>';
658 print $langs->trans("SaleEEC").'<br>';
659 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidinvoicemandatory&token='.newToken().'&value='.$key.'&status=0">';
660 print img_picto($langs->trans("Activated"), 'switch_on', 'class="valignmiddle paddingrightonly"');
661 print '</a>';
662 print $langs->trans("AnySale");
663} else {
664 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidinvoicemandatoryeeconly&token='.newToken().'&value='.$key.'&status=1">';
665 print img_picto($langs->trans("Disabled"), 'switch_off', 'class="valignmiddle paddingrightonly"');
666 print '</a>';
667 print $langs->trans("SaleEEC").'<br>';
668 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidinvoicemandatory&token='.newToken().'&value='.$key.'&status=1">';
669 print img_picto($langs->trans("Disabled"), 'switch_off', 'class="valignmiddle paddingrightonly"');
670 print '</a>';
671 print $langs->trans("AnySale");
672}
673print '</td>';
674print "</tr>\n";
675
676print "</table>\n";
677print '</div>';
678
679print "<br>\n";
680
681print load_fiche_titre($langs->trans("Other"), '', '');
682
683// Autres options
684$form = new Form($db);
685
686print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
687print '<input type="hidden" name="token" value="'.newToken().'">';
688print '<input type="hidden" name="page_y" value="">';
689print '<input type="hidden" name="action" value="updateoptions">';
690
691print '<div class="div-table-responsive-no-min">';
692print '<table class="noborder centpercent">';
693print '<tr class="liste_titre">';
694print "<td>".$langs->trans("Parameters")."</td>\n";
695print '<td class="right" width="60"></td>'."\n";
696print '<td width="80">&nbsp;</td></tr>'."\n";
697
698// Use of Ajax form for thirdparty selection
699
700print '<tr class="oddeven">';
701print '<td width="80%">'.$form->textwithpicto($langs->trans("DelaiedFullListToSelectCompany"), $langs->trans('UseSearchToSelectCompanyTooltip'), 1).' </td>';
702if (!$conf->use_javascript_ajax) {
703 print '<td class="nowrap right" colspan="2">';
704 print $langs->trans("NotAvailableWhenAjaxDisabled");
705 print "</td>";
706} else {
707 print '<td width="60" class="right">';
708 $arrval = array(
709 0 => array('label' => $langs->trans("No")),
710 1 => array('label' => $langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 1).')', 'labelhtml' => $langs->trans("Yes").' <span class="opacitymedium small">('.$langs->trans("NumberOfKeyToSearch", 1).')</span>'),
711 2 => array('label' => $langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')', 'labelhtml' => $langs->trans("Yes").' <span class="opacitymedium small">('.$langs->trans("NumberOfKeyToSearch", 2).')</span>'),
712 3 => array('label' => $langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')', 'labelhtml' => $langs->trans("Yes").' <span class="opacitymedium small">('.$langs->trans("NumberOfKeyToSearch", 3).')</span>'),
713 );
714 print $form->selectarray("activate_COMPANY_USE_SEARCH_TO_SELECT", $arrval, getDolGlobalString('COMPANY_USE_SEARCH_TO_SELECT'), 0, 0, 0, '', 0, 0, 0, '', 'minwidth75imp maxwidth400');
715 print '</td><td class="right">';
716 print '<input type="submit" class="button small reposition" name="COMPANY_USE_SEARCH_TO_SELECT" value="'.$langs->trans("Modify").'">';
717 print "</td>";
718}
719print '</tr>';
720
721
722print '<tr class="oddeven">';
723print '<td width="80%">'.$form->textwithpicto($langs->trans("DelaiedFullListToSelectContact"), $langs->trans('UseSearchToSelectContactTooltip'), 1).'</td>';
724if (!$conf->use_javascript_ajax) {
725 print '<td class="nowrap right" colspan="2">';
726 print $langs->trans("NotAvailableWhenAjaxDisabled");
727 print "</td>";
728} else {
729 print '<td width="60" class="right">';
730 $arrval = array(
731 0 => array('label' => $langs->trans("No")),
732 1 => array('label' => $langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 1).')', 'labelhtml' => $langs->trans("Yes").' <span class="opacitymedium small">('.$langs->trans("NumberOfKeyToSearch", 1).')</span>'),
733 2 => array('label' => $langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')', 'labelhtml' => $langs->trans("Yes").' <span class="opacitymedium small">('.$langs->trans("NumberOfKeyToSearch", 2).')</span>'),
734 3 => array('label' => $langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')', 'labelhtml' => $langs->trans("Yes").' <span class="opacitymedium small">('.$langs->trans("NumberOfKeyToSearch", 3).')</span>'),
735 );
736 print $form->selectarray("activate_CONTACT_USE_SEARCH_TO_SELECT", $arrval, getDolGlobalString('CONTACT_USE_SEARCH_TO_SELECT'), 0, 0, 0, '', 0, 0, 0, '', 'minwidth75imp maxwidth400');
737 print '</td><td class="right">';
738 print '<input type="submit" class="button small reposition" name="CONTACT_USE_SEARCH_TO_SELECT" value="'.$langs->trans("Modify").'">';
739 print "</td>";
740}
741print '</tr>';
742
743
744print '<tr class="oddeven">';
745print '<td width="80%">'.$form->textwithpicto($langs->trans("AddRefInList"), $langs->trans("AddRefInListHelp")).'</td>';
746print '<td>&nbsp;</td>';
747print '<td class="center">';
748if (getDolGlobalString('SOCIETE_ADD_REF_IN_LIST')) {
749 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddrefinlist&token='.newToken().'&value=0">';
750 print img_picto($langs->trans("Activated"), 'switch_on');
751} else {
752 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddrefinlist&token='.newToken().'&value=1">';
753 print img_picto($langs->trans("Disabled"), 'switch_off');
754}
755print '</a></td>';
756print '</tr>';
757
758print '<tr class="oddeven">';
759print '<td width="80%">'.$langs->trans("AddVatInList").'</td>';
760print '<td>&nbsp;</td>';
761print '<td class="center">';
762if (getDolGlobalString('SOCIETE_SHOW_VAT_IN_LIST')) {
763 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setvatinlist&token='.newToken().'&value=0">';
764 print img_picto($langs->trans("Activated"), 'switch_on');
765} else {
766 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setvatinlist&token='.newToken().'&value=1">';
767 print img_picto($langs->trans("Disabled"), 'switch_off');
768}
769print '</a></td>';
770print '</tr>';
771
772print '<tr class="oddeven">';
773print '<td width="80%">'.$form->textwithpicto($langs->trans("AddAdressInList"), $langs->trans("AddAdressInListHelp")).'</td>';
774print '<td>&nbsp;</td>';
775print '<td class="center">';
776if (getDolGlobalString('COMPANY_SHOW_ADDRESS_SELECTLIST')) {
777 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddadressinlist&token='.newToken().'&value=0">';
778 print img_picto($langs->trans("Activated"), 'switch_on');
779} else {
780 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddadressinlist&token='.newToken().'&value=1">';
781 print img_picto($langs->trans("Disabled"), 'switch_off');
782}
783print '</a></td>';
784print '</tr>';
785
786print '<tr class="oddeven">';
787print '<td width="80%">'.$form->textwithpicto($langs->trans("AddEmailPhoneTownInContactList"), $langs->trans("AddEmailPhoneTownInContactListHelp")).'</td>';
788print '<td>&nbsp;</td>';
789print '<td class="center">';
790if (getDolGlobalString('CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST')) {
791 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddemailphonetownincontactlist&token='.newToken().'&value=0">';
792 print img_picto($langs->trans("Activated"), 'switch_on');
793} else {
794 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddemailphonetownincontactlist&token='.newToken().'&value=1">';
795 print img_picto($langs->trans("Disabled"), 'switch_off');
796}
797print '</a></td>';
798print '</tr>';
799
800if (isModEnabled("shipping")) {
801 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') > 0) { // Visible on experimental only because seems to not be implemented everywhere (only on proposal)
802 print '<tr class="oddeven">';
803 print '<td width="80%">'.$langs->trans("AskForPreferredShippingMethod").'</td>';
804 print '<td>&nbsp;</td>';
805 print '<td class="center">';
806 if (getDolGlobalString('SOCIETE_ASK_FOR_SHIPPING_METHOD')) {
807 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaskforshippingmet&token='.newToken().'&value=0">';
808 print img_picto($langs->trans("Activated"), 'switch_on');
809 } else {
810 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaskforshippingmet&token='.newToken().'&value=1">';
811 print img_picto($langs->trans("Disabled"), 'switch_off');
812 }
813 print '</a></td>';
814 print '</tr>';
815 }
816}
817
818// Disable Prospect/Customer thirdparty type
819print '<tr class="oddeven">';
820print '<td width="80%">'.$langs->trans("DisableProspectCustomerType").'</td>';
821print '<td>&nbsp;</td>';
822print '<td class="center">';
823if (getDolGlobalString('SOCIETE_DISABLE_PROSPECTSCUSTOMERS')) {
824 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setdisableprospectcustomer&token='.newToken().'&value=0">';
825 print img_picto($langs->trans("Activated"), 'switch_on');
826} else {
827 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setdisableprospectcustomer&token='.newToken().'&value=1">';
828 print img_picto($langs->trans("Disabled"), 'switch_off');
829}
830print '</a></td>';
831print '</tr>';
832
833if (!getDolGlobalString('SOCIETE_DISABLE_PROSPECTSCUSTOMERS')) {
834 // Default Prospect/Customer thirdparty type on customer creation
835 print '<tr class="oddeven">';
836 print '<td>'.$langs->trans("DefaultCustomerType", $langs->transnoentitiesnoconv("MenuNewThirdParty"), $langs->transnoentitiesnoconv("MenuNewCustomer")).'</td>';
837 print '<td>';
838 print $formcompany->selectProspectCustomerType(getDolGlobalInt('THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT'), 'defaultcustomertype', 'defaultcustomertype', 'admin');
839 print '</td>';
840 print '<td class="center">';
841 print '<input type="submit" class="button small reposition" name="THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT" value="'.$langs->trans("Modify").'">';
842 print '</td>';
843 print '</tr>';
844}
845
846if (getDolGlobalString('THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION')) {
847 print '<tr class="oddeven">';
848 print '<td width="80%">'.$langs->trans('ContactsDefaultRoles').'</td>';
849 if (!$conf->use_javascript_ajax) {
850 print '<td class="nowrap right" colspan="2">';
851 print $langs->trans("NotAvailableWhenAjaxDisabled");
852 print "</td>";
853 } else {
854 print '<td width="60" class="right">';
855 $contact = new Contact($db); // InfraS add
856 $contactType = $contact->listeTypeContacts('external', 0, 1);
857 $selected = explode(',', getDolGlobalString('CONTACTS_DEFAULT_ROLES'));
858 print $form->multiselectarray('activate_CONTACTS_DEFAULT_ROLES', $contactType, $selected, 0, 0, 'minwidth75imp');
859 print '</td><td class="right">';
860 print '<input type="submit" class="button small eposition" name="CONTACTS_DEFAULT_ROLES" value="'.$langs->trans("Modify").'">';
861 print "</td>";
862 }
863 print '</tr>';
864}
865
866print '</table>';
867print '</div>';
868
869print '</form>';
870
871
872print dol_get_fiche_end();
873
874// End of page
875llxFooter();
876$db->close();
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
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.
global $mysoc
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
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'.
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:540
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition html.lib.php:738
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.