dolibarr 24.0.0-beta
company.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
6 * Copyright (C) 2011-2017 Philippe Grand <philippe.grand@atoo-net.com>
7 * Copyright (C) 2015-2025 Alexandre Spangaro <alexandre@inovea-conseil.com>
8 * Copyright (C) 2017 Rui Strecht <rui.strecht@aliartalentos.com>
9 * Copyright (C) 2023 Nick Fragoulis
10 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
11 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <https://www.gnu.org/licenses/>.
25 */
26
33// Load Dolibarr environment
34require '../main.inc.php';
43require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
44require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
45require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
46require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
47require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
48require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
49require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
50require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
51require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
52
53$action = GETPOST('action', 'aZ09');
54$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'admincompany'; // To manage different context of search
55$page_y = GETPOSTINT('page_y');
56
57// Load translation files required by the page
58$langs->loadLangs(array('admin', 'companies', 'bills'));
59
60if (!$user->admin) {
62}
63
64$error = 0;
65
66$tmparraysize = getDefaultImageSizes();
67$maxwidthsmall = $tmparraysize['maxwidthsmall'];
68$maxheightsmall = $tmparraysize['maxheightsmall'];
69$maxwidthmini = $tmparraysize['maxwidthmini'];
70$maxheightmini = $tmparraysize['maxheightmini'];
71$quality = $tmparraysize['quality'];
72
73// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
74$hookmanager->initHooks(array('admincompany', 'globaladmin'));
75
76$object = new Societe($db);
77
78
79/*
80 * Actions
81 */
82
83$parameters = array();
84$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
85if ($reshook < 0) {
86 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
87}
88
89if (($action == 'update' && !GETPOST("cancel", 'alpha'))
90|| ($action == 'updateedit')) {
91 $db->begin();
92
93 $tmparray = getCountry(GETPOSTINT('country_id'), 'all', $db, $langs, 0);
94 if (!empty($tmparray['id'])) {
95 // Check we can change country
96 include_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
97 if ($mysoc->country_code == 'FR' && $tmparray['code'] != $mysoc->country_code && isALNERunningVersion()) {
98 $langs->load("blockedlog");
99 setEventMessages($langs->trans("BlockedLogCountryChangeNotAllowedFR"), null, 'errors');
100 $error++;
101 } else {
102 if ($tmparray['code'] == 'FR' && $tmparray['id'] != $mysoc->country_id) {
103 // For FR, default value of option to show profid SIREN is on by default
104 $res = dolibarr_set_const($db, "MAIN_PROFID1_IN_ADDRESS", 1, 'chaine', 0, '', $conf->entity);
105 }
106
107 $mysoc->country_id = $tmparray['id'];
108 $mysoc->country_code = $tmparray['code'];
109 $mysoc->country_label = $tmparray['label'];
110
111 $s = $mysoc->country_id.':'.$mysoc->country_code.':'.$mysoc->country_label;
112 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_COUNTRY", $s, 'chaine', 0, '', $conf->entity);
113
114 activateModulesRequiredByCountry($mysoc->country_code);
115 }
116 }
117
118 $tmparray = getState(GETPOSTINT('state_id'), 'all', $db, 0, $langs, 0);
119 if (!empty($tmparray['id'])) {
120 $mysoc->state_id = $tmparray['id'];
121 $mysoc->state_code = $tmparray['code'];
122 $mysoc->state_label = $tmparray['label'];
123
124 $s = $mysoc->state_id.':'.$mysoc->state_code.':'.$mysoc->state_label;
125 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_STATE", $s, 'chaine', 0, '', $conf->entity);
126 } else {
127 dolibarr_del_const($db, "MAIN_INFO_SOCIETE_STATE", $conf->entity);
128 }
129
130 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", GETPOST("name", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
131 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ADDRESS", GETPOST("MAIN_INFO_SOCIETE_ADDRESS", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
132 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TOWN", GETPOST("MAIN_INFO_SOCIETE_TOWN", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
133 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ZIP", GETPOST("MAIN_INFO_SOCIETE_ZIP", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
134 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_REGION", GETPOST("region_code", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
135 dolibarr_set_const($db, "MAIN_MONNAIE", GETPOST("currency", 'aZ09'), 'chaine', 0, '', $conf->entity);
136 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TEL", GETPOST("phone", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
137 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MOBILE", GETPOST("phone_mobile", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
138 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FAX", GETPOST("fax", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
139 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MAIL", GETPOST("mail", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
140 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_WEB", GETPOST("web", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
141 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOTE", GETPOST("note", 'restricthtml'), 'chaine', 0, '', $conf->entity);
142 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_GENCOD", GETPOST("barcode", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
143
144 $dirforimage = $conf->mycompany->dir_output.'/logos/';
145
146 $arrayofimages = array('logo', 'logo_squarred');
147 //var_dump($_FILES); exit;
148 foreach ($arrayofimages as $varforimage) {
149 if ($_FILES[$varforimage]["name"] && !image_format_supported($_FILES[$varforimage]["name"], 0)) { // Logo can be used on a lot of different places. Recommend using jpg and png for better compatibility.
150 $langs->load("errors");
151 $mesg = $langs->trans("ErrorBadImageFormat");
152 if (!function_exists("imagecreate")) {
153 $mesg .= ' - '.$langs->trans("ErrorPHPDoesNotSupport", "GD");
154 } else {
155 $supportedextensions = getListOfPossibleImageExt();
156 $supportedextensions = preg_replace('/\\\./', '', $supportedextensions); // Remove '\.'
157 $mesg .= ' - '.$langs->trans("ErrorSupportedFormatAre", implode(', ', explode('|', $supportedextensions)));
158 }
159 setEventMessages($mesg, null, 'errors');
160 break;
161 }
162
163 // Remove to check file size to large
164 /*if ($_FILES[$varforimage]["tmp_name"]) {*/
165 $reg = array();
166 if (preg_match('/([^\\/:]+)$/i', $_FILES[$varforimage]["name"], $reg)) {
167 $original_file = $reg[1];
168
169 $isimage = image_format_supported($original_file);
170 if ($isimage >= 0) {
171 dol_syslog("Move file ".$_FILES[$varforimage]["tmp_name"]." to ".$dirforimage.$original_file);
172 if (!is_dir($dirforimage)) {
173 dol_mkdir($dirforimage);
174 }
175 $result = dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage.$original_file, 1, 0, $_FILES[$varforimage]['error']);
176
177 if (is_numeric($result) && $result > 0) {
178 $constant = "MAIN_INFO_SOCIETE_LOGO";
179 if ($varforimage == 'logo_squarred') {
180 $constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED";
181 }
182
183 dolibarr_set_const($db, $constant, $original_file, 'chaine', 0, '', $conf->entity);
184
185 // Create thumbs of logo (Note that PDF use original file and not thumbs)
186 if ($isimage > 0) {
187 // Create thumbs
188 //$object->addThumbs($newfile); // We can't use addThumbs here yet because we need name of generated thumbs to add them into constants. TODO Check if need such constants. We should be able to retrieve value with get...
189
190
191 // Create small thumb, Used on logon for example
192 $imgThumbSmall = vignette($dirforimage.$original_file, $maxwidthsmall, $maxheightsmall, '_small', $quality);
193 if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg)) {
194 $imgThumbSmall = $reg[1]; // Save only basename
195 dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity);
196 } else {
197 dol_syslog($imgThumbSmall);
198 }
199
200 // Create mini thumb, Used on menu or for setup page for example
201 $imgThumbMini = vignette($dirforimage.$original_file, $maxwidthmini, $maxheightmini, '_mini', $quality);
202 if (image_format_supported($imgThumbMini) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg)) {
203 $imgThumbMini = $reg[1]; // Save only basename
204 dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity);
205 } else {
206 dol_syslog($imgThumbMini);
207 }
208 } else {
209 dol_syslog("ErrorImageFormatNotSupported", LOG_WARNING);
210 }
211 } elseif (preg_match('/^ErrorFileIsInfectedWithAVirus/', $result)) {
212 $error++;
213 $langs->load("errors");
214 $tmparray = explode(':', $result);
215 setEventMessages($langs->trans('ErrorFileIsInfectedWithAVirus', $tmparray[1]), null, 'errors');
216 } elseif (preg_match('/^ErrorFileSizeTooLarge/', $result)) {
217 $error++;
218 setEventMessages($langs->trans("ErrorFileSizeTooLarge"), null, 'errors');
219 } else {
220 $error++;
221 setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors');
222 }
223 } else {
224 $error++;
225 $langs->load("errors");
226 setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors');
227 }
228 }
229 /*}*/
230 }
231
232 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MANAGERS", GETPOST("MAIN_INFO_SOCIETE_MANAGERS", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
233 dolibarr_set_const($db, "MAIN_INFO_GDPR", GETPOST("MAIN_INFO_GDPR", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
234 dolibarr_set_const($db, "MAIN_INFO_CAPITAL", GETPOST("capital", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
235 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FORME_JURIDIQUE", GETPOST("forme_juridique_code", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
236 dolibarr_set_const($db, "MAIN_INFO_SIREN", GETPOST("siren", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
237 dolibarr_set_const($db, "MAIN_INFO_SIRET", GETPOST("siret", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
238 dolibarr_set_const($db, "MAIN_INFO_APE", GETPOST("ape", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
239 dolibarr_set_const($db, "MAIN_INFO_RCS", GETPOST("rcs", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
240 dolibarr_set_const($db, "MAIN_INFO_PROFID5", GETPOST("MAIN_INFO_PROFID5", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
241 dolibarr_set_const($db, "MAIN_INFO_PROFID6", GETPOST("MAIN_INFO_PROFID6", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
242 dolibarr_set_const($db, "MAIN_INFO_PROFID7", GETPOST("MAIN_INFO_PROFID7", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
243 dolibarr_set_const($db, "MAIN_INFO_PROFID8", GETPOST("MAIN_INFO_PROFID8", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
244 dolibarr_set_const($db, "MAIN_INFO_PROFID9", GETPOST("MAIN_INFO_PROFID9", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
245 dolibarr_set_const($db, "MAIN_INFO_PROFID10", GETPOST("MAIN_INFO_PROFID10", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
246
247 dolibarr_set_const($db, "MAIN_INFO_TVAINTRA", GETPOST("tva", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
248 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_OBJECT", GETPOST("socialobject", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
249
250 dolibarr_set_const($db, "SOCIETE_FISCAL_MONTH_START", GETPOSTINT("SOCIETE_FISCAL_MONTH_START"), 'chaine', 0, '', $conf->entity);
251
252 // Sale tax options
253 $usevat = GETPOST("optiontva", 'aZ09');
254 $uselocaltax1 = GETPOST("optionlocaltax1", 'aZ09');
255 $uselocaltax2 = GETPOST("optionlocaltax2", 'aZ09');
256 if ($uselocaltax1 == 'localtax1on' && !$usevat) {
257 setEventMessages($langs->trans("IfYouUseASecondTaxYouMustSetYouUseTheMainTax"), null, 'errors');
258 $error++;
259 }
260 if ($uselocaltax2 == 'localtax2on' && !$usevat) {
261 setEventMessages($langs->trans("IfYouUseAThirdTaxYouMustSetYouUseTheMainTax"), null, 'errors');
262 $error++;
263 }
264
265 dolibarr_set_const($db, "FACTURE_TVAOPTION", $usevat, 'chaine', 0, '', $conf->entity);
266 dolibarr_set_const($db, "FACTURE_LOCAL_TAX1_OPTION", $uselocaltax1, 'chaine', 0, '', $conf->entity);
267 dolibarr_set_const($db, "FACTURE_LOCAL_TAX2_OPTION", $uselocaltax2, 'chaine', 0, '', $conf->entity);
268
269 if (GETPOST("optionlocaltax1") == "localtax1on") {
270 if (!GETPOSTISSET('lt1')) {
271 dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX1", 0, 'chaine', 0, '', $conf->entity);
272 } else {
273 dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX1", GETPOST('lt1', 'aZ09'), 'chaine', 0, '', $conf->entity);
274 }
275 dolibarr_set_const($db, "MAIN_INFO_LOCALTAX_CALC1", GETPOST("clt1", 'aZ09'), 'chaine', 0, '', $conf->entity);
276 }
277 if (GETPOST("optionlocaltax2") == "localtax2on") {
278 if (!GETPOSTISSET('lt2')) {
279 dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX2", 0, 'chaine', 0, '', $conf->entity);
280 } else {
281 dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX2", GETPOST('lt2', 'aZ09'), 'chaine', 0, '', $conf->entity);
282 }
283 dolibarr_set_const($db, "MAIN_INFO_LOCALTAX_CALC2", GETPOST("clt2", 'aZ09'), 'chaine', 0, '', $conf->entity);
284 }
285
286 // Credentials for AADE webservices, applicable only for Greece
287 if ($mysoc->country_code == 'GR') {
288 dolibarr_set_const($db, "MYDATA_AADE_USER", GETPOST("MYDATA_AADE_USER", 'alpha'), 'chaine', 0, '', $conf->entity);
289 dolibarr_set_const($db, "MYDATA_AADE_KEY", GETPOST("MYDATA_AADE_KEY", 'alpha'), 'chaine', 0, '', $conf->entity);
290 dolibarr_set_const($db, "AADE_WEBSERVICE_USER", GETPOST("AADE_WEBSERVICE_USER", 'alpha'), 'chaine', 0, '', $conf->entity);
291 dolibarr_set_const($db, "AADE_WEBSERVICE_KEY", GETPOST("AADE_WEBSERVICE_KEY", 'alpha'), 'chaine', 0, '', $conf->entity);
292 }
293
294 // Remove constant MAIN_INFO_SOCIETE_SETUP_TODO_WARNING
295 dolibarr_del_const($db, "MAIN_INFO_SOCIETE_SETUP_TODO_WARNING", $conf->entity);
296
297 if (!$error) {
298 if (GETPOST('save')) { // To avoid to show message when we juste switch the country that resubmit the form.
299 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
300 }
301 $db->commit();
302 } else {
303 $db->rollback();
304 }
305
306 if ($action != 'updateedit' && !$error) {
307 header("Location: ".$_SERVER["PHP_SELF"].($page_y ? '?page_y='.$page_y : ''));
308 exit;
309 }
310}
311
312if ($action == 'addthumb' || $action == 'addthumbsquarred') { // Regenerate thumbs
313 if (file_exists($conf->mycompany->dir_output.'/logos/'.GETPOST("file"))) {
314 $isimage = image_format_supported(GETPOST("file"));
315
316 // Create thumbs of logo
317 if ($isimage > 0) {
318 $constant = "MAIN_INFO_SOCIETE_LOGO";
319 if ($action == 'addthumbsquarred') {
320 $constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED";
321 }
322
323 $reg = array();
324
325 // Create thumbs
326 //$object->addThumbs($newfile); // We can't use addThumbs here yet because we need name of generated thumbs to add them into constants. TODO Check if need such constants. We should be able to retrieve value with get...
327
328 // Create small thumb. Used on logon for example
329 $imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.GETPOST("file"), $maxwidthsmall, $maxheightsmall, '_small', $quality);
330 if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg)) {
331 $imgThumbSmall = $reg[1]; // Save only basename
332 dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity);
333 } else {
334 dol_syslog($imgThumbSmall);
335 }
336
337 // Create mini thumbs. Used on menu or for setup page for example
338 $imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.GETPOST("file"), $maxwidthmini, $maxheightmini, '_mini', $quality);
339 if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg)) {
340 $imgThumbMini = $reg[1]; // Save only basename
341 dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity);
342 } else {
343 dol_syslog($imgThumbMini);
344 }
345
346 header("Location: ".$_SERVER["PHP_SELF"]);
347 exit;
348 } else {
349 $error++;
350 $langs->load("errors");
351 setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors');
352 dol_syslog($langs->transnoentities("ErrorBadImageFormat"), LOG_INFO);
353 }
354 } else {
355 $error++;
356 $langs->load("errors");
357 setEventMessages($langs->trans("ErrorFileDoesNotExists", GETPOST("file")), null, 'errors');
358 dol_syslog($langs->transnoentities("ErrorFileDoesNotExists", GETPOST("file")), LOG_WARNING);
359 }
360}
361
362
363if ($action == 'removelogo' || $action == 'removelogo_squarred') {
364 $constant = "MAIN_INFO_SOCIETE_LOGO";
365 if ($action == 'removelogo_squarred') {
366 $constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED";
367 }
368
369 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
370
371 $logofilename = $mysoc->logo;
372 $logofilenamebis = $mysoc->logo_squarred;
373 if ($action == 'removelogo_squarred') {
374 $logofilename = $mysoc->logo_squarred;
375 $logofilenamebis = $mysoc->logo;
376 }
377
378 $logofile = $conf->mycompany->dir_output.'/logos/'.$logofilename;
379 if ($logofilename != '' && $logofilename != $logofilenamebis) {
380 dol_delete_file($logofile);
381 }
382 dolibarr_del_const($db, $constant, $conf->entity);
383 if ($action == 'removelogo_squarred') {
384 $mysoc->logo_squarred = '';
385 } else {
386 $mysoc->logo = '';
387 }
388
389 $logofilename = $mysoc->logo_small;
390 $logofilenamebis = $mysoc->logo_squarred_small;
391 if ($action == 'removelogo_squarred') {
392 $logofilename = $mysoc->logo_squarred_small;
393 $logofilenamebis = $mysoc->logo_small;
394 }
395
396 $logosmallfile = $conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename;
397 if ($logofilename != '' && $logofilename != $logofilenamebis) {
398 dol_delete_file($logosmallfile);
399 }
400 dolibarr_del_const($db, $constant."_SMALL", $conf->entity);
401 if ($action == 'removelogo_squarred') {
402 $mysoc->logo_squarred_small = '';
403 } else {
404 $mysoc->logo_small = '';
405 }
406
407 $logofilename = $mysoc->logo_mini;
408 $logofilenamebis = $mysoc->logo_squarred_mini;
409 if ($action == 'removelogo_squarred') {
410 $logofilename = $mysoc->logo_squarred_mini;
411 $logofilenamebis = $mysoc->logo_mini;
412 }
413
414 $logominifile = $conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename;
415 if ($logofilename != '' && $logofilename != $logofilenamebis) {
416 dol_delete_file($logominifile);
417 }
418 dolibarr_del_const($db, $constant."_MINI", $conf->entity);
419 if ($action == 'removelogo_squarred') {
420 $mysoc->logo_squarred_mini = '';
421 } else {
422 $mysoc->logo_mini = '';
423 }
424}
425
426
427/*
428 * View
429 */
430
431$wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
432llxHeader('', $langs->trans("Setup"), $wikihelp, '', 0, 0, '', '', '', 'mod-admin page-company');
433
434$form = new Form($db);
435$formother = new FormOther($db);
436$formcompany = new FormCompany($db);
437$formfile = new FormFile($db);
438
439$countrynotdefined = '<span class="error">'.$langs->trans("ErrorSetACountryFirst").' <a href="" onclick="window.scrollTo({top: 0, behavior: \'smooth\'}); return false;">('.$langs->trans("SeeAbove").')</a></span>';
440
441print load_fiche_titre($langs->trans("CompanyFoundation"), '', 'title_setup');
442
444
445print dol_get_fiche_head($head, 'company', '', -1, '');
446
447print '<span class="opacitymedium">'.$langs->trans("CompanyFundationDesc", $langs->transnoentities("Save"))."</span><br>\n";
448print "<br><br>\n";
449
450
451// Edit parameters
452
453if (!empty($conf->use_javascript_ajax)) {
454 print "\n".'<script type="text/javascript">';
455 print '$(document).ready(function () {
456 $("#selectcountry_id").change(function() {
457 console.log("selectcountry_id change");
458 document.form_index.action.value="updateedit";
459 document.form_index.submit();
460 });
461
462 // Show/hide VAT exemption code field based on VAT option
463 $("input[name=\"optiontva\"]").change(function() {
464 if ($(this).val() == "0") {
465 $("#vat_exemption_code_div").show();
466 } else {
467 $("#vat_exemption_code_div").hide();
468 }
469 });
470 });';
471 print '</script>'."\n";
472}
473
474print '<form enctype="multipart/form-data" method="POST" action="'.$_SERVER["PHP_SELF"].'" name="form_index" spellcheck="false">';
475print '<input type="hidden" name="token" value="'.newToken().'">';
476print '<input type="hidden" name="action" value="update">';
477print '<input type="hidden" name="page_y" value="">';
478
479print '<table class="noborder centpercent editmode">';
480print '<tr class="liste_titre"><th class="wordbreak" colspan="2">'.$langs->trans("CompanyInfo").'</th></tr>'."\n";
481
482// Company name
483print '<tr class="oddeven"><td class="fieldrequired titlefieldcreate wordbreak"><label for="name">'.$langs->trans("CompanyName").'</label></td><td>';
484print '<input name="name" id="name" maxlength="'.$mysoc->fields['nom']['length'].'" class="minwidth250" value="'.dolPrintHTMLForAttribute((GETPOSTISSET('name') ? GETPOST('name', 'alphanohtml') : getDolGlobalString('MAIN_INFO_SOCIETE_NOM'))).'"'.(getDolGlobalString('MAIN_INFO_SOCIETE_NOM') ? '' : ' autofocus="autofocus"').'></td></tr>'."\n";
485
486// Main currency
487print '<tr class="oddeven"><td class="fieldrequired"><label for="currency">'.$langs->trans("CompanyCurrency").'</label></td><td>';
488print img_picto('', 'multicurrency', 'class="pictofixedwidth"');
489print $form->selectCurrency(getDolCurrency(), "currency", 2);
490print '</td></tr>'."\n";
491
492// Country
493print '<tr class="oddeven"><td class="fieldrequired"><label for="selectcountry_id">'.$langs->trans("Country").'</label></td><td>';
494print img_picto('', 'globe-americas', 'class="pictofixedwidth"');
495print $form->select_country((string) $mysoc->country_id, 'country_id', '', 0);
496print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
497print '</td></tr>'."\n";
498
499// Address
500print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_ADDRESS">'.$langs->trans("CompanyAddress").'</label></td><td>';
501print '<textarea name="MAIN_INFO_SOCIETE_ADDRESS" id="MAIN_INFO_SOCIETE_ADDRESS" class="quatrevingtpercent" rows="'.ROWS_3.'">'.(GETPOSTISSET('MAIN_INFO_SOCIETE_ADDRESS') ? GETPOST('MAIN_INFO_SOCIETE_ADDRESS', 'alphanohtml') : getDolGlobalString('MAIN_INFO_SOCIETE_ADDRESS')).'</textarea></td></tr>'."\n";
502
503// Zip
504print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_ZIP">'.$langs->trans("CompanyZip").'</label></td><td>';
505print '<input class="width100" name="MAIN_INFO_SOCIETE_ZIP" id="MAIN_INFO_SOCIETE_ZIP" value="'.dolPrintHTMLForAttribute((GETPOSTISSET('MAIN_INFO_SOCIETE_ZIP') ? GETPOST('MAIN_INFO_SOCIETE_ZIP', 'alphanohtml') : getDolGlobalString('MAIN_INFO_SOCIETE_ZIP'))).'"></td></tr>'."\n";
506
507print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_TOWN">'.$langs->trans("CompanyTown").'</label></td><td>';
508print '<input name="MAIN_INFO_SOCIETE_TOWN" class="minwidth200" id="MAIN_INFO_SOCIETE_TOWN" value="'.dolPrintHTMLForAttribute((GETPOSTISSET('MAIN_INFO_SOCIETE_TOWN') ? GETPOST('MAIN_INFO_SOCIETE_TOWN', 'alphanohtml') : getDolGlobalString('MAIN_INFO_SOCIETE_TOWN'))).'"></td></tr>'."\n";
509
510// State
511print '<tr class="oddeven"><td class="wordbreak"><label for="state_id">'.$langs->trans("State").'</label></td><td>';
512$state_id = 0;
513if (getDolGlobalString('MAIN_INFO_SOCIETE_STATE')) {
514 $tmp = explode(':', getDolGlobalString('MAIN_INFO_SOCIETE_STATE'));
515 $state_id = $tmp[0];
516}
517print img_picto('', 'state', 'class="pictofixedwidth"');
518print $formcompany->select_state($state_id, $mysoc->country_code, 'state_id', 'maxwidth200onsmartphone minwidth300');
519print '</td></tr>'."\n";
520
521// Phone
522print '<tr class="oddeven"><td><label for="phone">'.$langs->trans("Phone").'</label></td><td>';
523print img_picto('', 'object_phoning', '', 0, 0, 0, '', 'pictofixedwidth');
524print '<input class="maxwidth150 widthcentpercentminusx" name="phone" id="phone" value="'.dolPrintHTMLForAttribute((GETPOSTISSET('phone') ? GETPOST('phone', 'alphanohtml') : getDolGlobalString('MAIN_INFO_SOCIETE_TEL'))).'"></td></tr>';
525print '</td></tr>'."\n";
526
527// Phone mobile
528print '<tr class="oddeven"><td><label for="phone">'.$langs->trans("PhoneMobile").'</label></td><td>';
529print img_picto('', 'object_phoning_mobile', '', 0, 0, 0, '', 'pictofixedwidth');
530print '<input class="maxwidth150 widthcentpercentminusx" name="phone_mobile" id="phone_mobile" value="'.dolPrintHTMLForAttribute((GETPOSTISSET('phone_mobile') ? GETPOST('phone_mobile', 'alphanohtml') : getDolGlobalString('MAIN_INFO_SOCIETE_MOBILE'))).'"></td></tr>';
531print '</td></tr>'."\n";
532
533// Fax
534print '<tr class="oddeven"><td><label for="fax">'.$langs->trans("Fax").'</label></td><td>';
535print img_picto('', 'object_phoning_fax', '', 0, 0, 0, '', 'pictofixedwidth');
536print '<input class="maxwidth150" name="fax" id="fax" value="'.dolPrintHTMLForAttribute((GETPOSTISSET('fax') ? GETPOST('fax', 'alphanohtml') : getDolGlobalString('MAIN_INFO_SOCIETE_FAX'))).'"></td></tr>';
537print '</td></tr>'."\n";
538
539// Email
540print '<tr class="oddeven"><td><label for="email">'.$langs->trans("EMail").'</label></td><td>';
541print img_picto('', 'object_email', '', 0, 0, 0, '', 'pictofixedwidth');
542print '<input class="minwidth300 maxwidth500 widthcentpercentminusx" name="mail" id="email" value="'.dolPrintHTMLForAttribute((GETPOSTISSET('mail') ? GETPOST('mail', 'alphanohtml') : getDolGlobalString('MAIN_INFO_SOCIETE_MAIL'))).'"></td></tr>';
543print '</td></tr>'."\n";
544
545// Web
546print '<tr class="oddeven"><td><label for="web">'.$langs->trans("Web").'</label></td><td>';
547print img_picto('', 'globe', '', 0, 0, 0, '', 'pictofixedwidth');
548print '<input class="maxwidth300 widthcentpercentminusx" name="web" id="web" value="'.dol_escape_htmltag((GETPOSTISSET('web') ? GETPOST('web', 'alphanohtml') : getDolGlobalString('MAIN_INFO_SOCIETE_WEB'))).'"></td></tr>';
549print '</td></tr>'."\n";
550
551// Barcode
552if (isModEnabled('barcode')) {
553 print '<tr class="oddeven"><td>';
554 print '<label for="barcode">'.$langs->trans("Gencod").'</label></td><td>';
555 print '<span class="fa fa-barcode pictofixedwidth"></span>';
556 print '<input name="barcode" id="barcode" class="minwidth150 widthcentpercentminusx maxwidth300" value="'.dolPrintHTMLForAttribute(GETPOSTISSET('barcode') ? GETPOST('barcode', 'alphanohtml') : getDolGlobalString('MAIN_INFO_SOCIETE_GENCOD')).'"></td></tr>';
557 print '</td></tr>';
558}
559
560// Tooltip for both Logo and LogSquarred
561$maxfilesizearray = getMaxFileSizeArray();
562$maxmin = $maxfilesizearray['maxmin'];
563$tooltiplogo = $langs->trans('AvailableFormats').' : png, jpg, jpeg';
564$tooltiplogo .= ($maxmin > 0) ? '<br>'.$langs->trans('MaxSize').' : '.$maxmin.' '.$langs->trans('Kb') : '';
565
566// Logo
567print '<tr class="oddeven"><td><label for="logo">'.$form->textwithpicto($langs->trans("Logo"), $tooltiplogo).'</label></td><td>';
568
569$modulepart = 'mycompany';
570$dirformainimage = $conf->mycompany->dir_output;
571$subdirformainimage = 'logos/';
572$fileformainimage = $mysoc->logo;
573
574print $formfile->showImageToEdit('logo', $modulepart, $dirformainimage, $subdirformainimage, $fileformainimage);
575
576print '</td></tr>';
577
578// Logo (squarred)
579print '<tr class="oddeven"><td><label for="logo_squarred">'.$form->textwithpicto($langs->trans("LogoSquarred"), $tooltiplogo).'</label></td><td>';
580
581$modulepart = 'mycompany';
582$dirformainimage = $conf->mycompany->dir_output;
583$subdirformainimage = 'logos/';
584$fileformainimage = $mysoc->logo_squarred;
585
586print $formfile->showImageToEdit('logo_squarred', $modulepart, $dirformainimage, $subdirformainimage, $fileformainimage);
587
588print '</td></tr>';
589
590// Note
591print '<tr class="oddeven"><td class="tdtop"><label for="note">'.$langs->trans("Note").'</label></td><td>';
592print '<textarea class="flat quatrevingtpercent" name="note" id="note" rows="'.ROWS_5.'">'.(GETPOSTISSET('note') ? GETPOST('note', 'restricthtml') : getDolGlobalString('MAIN_INFO_SOCIETE_NOTE')).'</textarea></td></tr>';
593print '</td></tr>';
594
595print '</table>';
596
597print $form->buttonsSaveCancel("Save", '', array(), false, 'reposition');
598
599print '<br><br>';
600
601
602// IDs of the company (country-specific)
603print '<div class="div-table-responsive-no-min">';
604print '<table class="noborder centpercent editmode">';
605print '<tr class="liste_titre"><td class="wordbreak" colspan="2">'.$langs->trans("CompanyIds").'</td></tr>';
606
607$langs->load("companies");
608
609// Managing Director(s)
610print '<tr class="oddeven"><td class="titlefieldcreate smallheight"><label for="director">'.$langs->trans("ManagingDirectors").'</label></td><td>';
611print '<input name="MAIN_INFO_SOCIETE_MANAGERS" id="directors" class="minwidth300" value="'.dolPrintHTMLForAttribute((GETPOSTISSET('MAIN_INFO_SOCIETE_MANAGERS') ? GETPOST('MAIN_INFO_SOCIETE_MANAGERS', 'alphanohtml') : getDolGlobalString('MAIN_INFO_SOCIETE_MANAGERS'))).'"></td></tr>';
612
613// GDPR contact
614print '<tr class="oddeven"><td class="smallheight">';
615print $form->textwithpicto($langs->trans("GDPRContact"), $langs->trans("GDPRContactDesc"));
616print '</td><td>';
617print '<input name="MAIN_INFO_GDPR" id="infodirector" class="minwidth300" value="'.dolPrintHTMLForAttribute((GETPOSTISSET("MAIN_INFO_GDPR") ? GETPOST("MAIN_INFO_GDPR", 'alphanohtml') : getDolGlobalString('MAIN_INFO_GDPR'))).'"></td></tr>';
618
619// Capital
620print '<tr class="oddeven"><td><label for="capital">'.$langs->trans("Capital").'</label></td><td>';
621print '<input name="capital" id="capital" class="maxwidth100" value="'.dolPrintHTMLForAttribute((GETPOSTISSET('capital') ? GETPOST('capital', 'alphanohtml') : getDolGlobalString('MAIN_INFO_CAPITAL'))).'"></td></tr>';
622
623// Object of the company
624print '<tr class="oddeven"><td><label for="socialobject">'.$langs->trans("CompanyObject").'</label></td><td>';
625print '<textarea class="flat quatrevingtpercent" name="socialobject" id="socialobject" rows="'.ROWS_3.'">'.getDolGlobalString('MAIN_INFO_SOCIETE_OBJECT').'</textarea></td></tr>';
626print '</td></tr>';
627
628// Tax ID Intra-community VAT number
629print '<tr class="oddeven"><td><label for="intra_vat">'.$langs->trans("VATIntra").'</label></td><td>';
630print '<input name="tva" id="intra_vat" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_TVAINTRA')).'">';
631print '</td></tr>';
632
633// Juridical Status
634print '<tr class="oddeven"><td><label for="forme_juridique_code">'.$langs->trans("JuridicalStatus").'</label></td><td>';
635if ($mysoc->country_code) {
636 print $formcompany->select_juridicalstatus(getDolGlobalInt('MAIN_INFO_SOCIETE_FORME_JURIDIQUE'), $mysoc->country_code, '', 'forme_juridique_code');
637} else {
638 print $countrynotdefined;
639}
640print '</td></tr>';
641
642// ProfId1
643if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-') {
644 print '<tr class="oddeven"><td><label for="profid1">'.$langs->transcountry("ProfId1", $mysoc->country_code).'</label></td><td>';
645 if (!empty($mysoc->country_code)) {
646 print '<input name="siren" id="profid1" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_SIREN')).'">';
647 } else {
648 print $countrynotdefined;
649 }
650 print '</td></tr>';
651}
652
653// ProfId2
654if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-') {
655 print '<tr class="oddeven"><td><label for="profid2">'.$langs->transcountry("ProfId2", $mysoc->country_code).'</label></td><td>';
656 if (!empty($mysoc->country_code)) {
657 print '<input name="siret" id="profid2" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_SIRET')).'">';
658 } else {
659 print $countrynotdefined;
660 }
661 print '</td></tr>';
662}
663
664// ProfId3
665if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-') {
666 print '<tr class="oddeven"><td><label for="profid3">'.$langs->transcountry("ProfId3", $mysoc->country_code).'</label></td><td>';
667 if (!empty($mysoc->country_code)) {
668 print '<input name="ape" id="profid3" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_APE')).'">';
669 } else {
670 print $countrynotdefined;
671 }
672 print '</td></tr>';
673}
674
675// ProfId4
676if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-') {
677 print '<tr class="oddeven"><td><label for="profid4">'.$langs->transcountry("ProfId4", $mysoc->country_code).'</label></td><td>';
678 if (!empty($mysoc->country_code)) {
679 print '<input name="rcs" id="profid4" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_RCS')).'">';
680 } else {
681 print $countrynotdefined;
682 }
683 print '</td></tr>';
684}
685
686// ProfId5
687if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-') {
688 print '<tr class="oddeven"><td><label for="profid5">'.$langs->transcountry("ProfId5", $mysoc->country_code).'</label></td><td>';
689 if (!empty($mysoc->country_code)) {
690 print '<input name="MAIN_INFO_PROFID5" id="profid5" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_PROFID5')).'">';
691 } else {
692 print $countrynotdefined;
693 }
694 print '</td></tr>';
695}
696
697// ProfId6
698if ($langs->transcountry("ProfId6", $mysoc->country_code) != '-') {
699 print '<tr class="oddeven"><td><label for="profid6">'.$langs->transcountry("ProfId6", $mysoc->country_code).'</label></td><td>';
700 if (!empty($mysoc->country_code)) {
701 print '<input name="MAIN_INFO_PROFID6" id="profid6" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_PROFID6')).'">';
702 } else {
703 print $countrynotdefined;
704 }
705 print '</td></tr>';
706}
707
708// ProfId7
709if ($langs->transcountry("ProfId7", $mysoc->country_code) != '-') {
710 print '<tr class="oddeven"><td><label for="profid7">'.$langs->transcountry("ProfId7", $mysoc->country_code).'</label></td><td>';
711 if (!empty($mysoc->country_code)) {
712 print '<input name="MAIN_INFO_PROFID7" id="profid7" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_PROFID7')).'">';
713 } else {
714 print $countrynotdefined;
715 }
716 print '</td></tr>';
717}
718
719// ProfId8
720if ($langs->transcountry("ProfId8", $mysoc->country_code) != '-') {
721 print '<tr class="oddeven"><td><label for="profid8">'.$langs->transcountry("ProfId8", $mysoc->country_code).'</label></td><td>';
722 if (!empty($mysoc->country_code)) {
723 print '<input name="MAIN_INFO_PROFID8" id="profid8" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_PROFID8')).'">';
724 } else {
725 print $countrynotdefined;
726 }
727 print '</td></tr>';
728}
729
730// ProfId9
731if ($langs->transcountry("ProfId9", $mysoc->country_code) != '-') {
732 print '<tr class="oddeven"><td><label for="profid9">'.$langs->transcountry("ProfId9", $mysoc->country_code).'</label></td><td>';
733 if (!empty($mysoc->country_code)) {
734 print '<input name="MAIN_INFO_PROFID9" id="profid9" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_PROFID9')).'">';
735 } else {
736 print $countrynotdefined;
737 }
738 print '</td></tr>';
739}
740
741// ProfId10
742if ($langs->transcountry("ProfId10", $mysoc->country_code) != '-') {
743 print '<tr class="oddeven"><td><label for="profid10">'.$langs->transcountry("ProfId10", $mysoc->country_code).'</label></td><td>';
744 if (!empty($mysoc->country_code)) {
745 print '<input name="MAIN_INFO_PROFID10" id="profid10" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_PROFID10')).'">';
746 } else {
747 print $countrynotdefined;
748 }
749 print '</td></tr>';
750}
751
752print '</table>';
753print '</div>';
754
755
756// Fiscal year start
757print '<br>';
758print '<table class="noborder centpercent editmode">';
759print '<tr class="liste_titre">';
760print '<td class="titlefieldcreate">'.$langs->trans("FiscalYearInformation").'</td><td></td>';
761print "</tr>\n";
762
763print '<tr class="oddeven"><td><label for="SOCIETE_FISCAL_MONTH_START">'.$langs->trans("FiscalMonthStart").'</label></td><td>';
764print $formother->select_month(getDolGlobalString('SOCIETE_FISCAL_MONTH_START'), 'SOCIETE_FISCAL_MONTH_START', 0, 1, 'maxwidth100').'</td></tr>';
765
766print "</table>";
767
768print $form->buttonsSaveCancel("Save", '', array(), false, 'reposition');
769
770print '<br>';
771
772
773// Sales taxes (VAT, IRPF, ...)
774print load_fiche_titre($langs->trans("TypeOfSaleTaxes"), '', 'object_payment');
775
776print '<table class="noborder centpercent editmode">';
777print '<tr class="liste_titre">';
778print '<td class="titlefieldcreate">'.$langs->trans("VATManagement").'</td><td></td>';
779print '<td class="right">&nbsp;</td>';
780print "</tr>\n";
781
782// Main tax
783print '<tr class="oddeven"><td><label><input type="radio" name="optiontva" id="use_vat" value="1"'.(!getDolGlobalString('FACTURE_TVAOPTION') ? "" : " checked")."> ".$langs->trans("VATIsUsed")."</label></td>";
784print '<td colspan="2">';
785$tooltiphelp = $langs->trans("VATIsUsedDesc");
786if ($mysoc->country_code == 'FR') {
787 $tooltiphelp .= '<br><br><i>'.$langs->trans("Example").': '.$langs->trans("VATIsUsedExampleFR")."</i>";
788}
789print '<label for="use_vat">'.$form->textwithpicto($langs->trans("VATIsUsedStandard"), $tooltiphelp)."</label>";
790print "</td></tr>\n";
791
792
793print '<tr class="oddeven"><td width="140"><label><input type="radio" name="optiontva" id="no_vat" value="0"'.(!getDolGlobalString('FACTURE_TVAOPTION') ? " checked" : "")."> ".$langs->trans("VATIsNotUsed")."</label></td>";
794print '<td colspan="2">';
795$tooltiphelp = '';
796if ($mysoc->country_code == 'FR') {
797 $tooltiphelp = "<i>".$langs->trans("Example").': '.$langs->trans("VATIsNotUsedExampleFR")."</i>\n";
798}
799print '<label for="no_vat">'.$form->textwithpicto($langs->trans("VATIsNotUsedDesc"), $tooltiphelp)."</label>";
800
801print '<div class="shownifvatnotused" id="vat_exemption_code_div"'.(getDolGlobalString('FACTURE_TVAOPTION') ? ' style="display: none;"' : '').'>';
802$placeholder = (($mysoc->country_code == 'FR') ? 'VATEX-FR-FRANCHISE' : '');
803$tooltiptext = $langs->trans("VATExemptionCodeDesc").'<br>'.$langs->trans("VATExemptionCodeDesc2").'<br>'.$langs->trans("VATExemptionCodeDesc3");
804if (($mysoc->country_code == 'FR')) {
805 $tooltiptext .= '<br><br>'.$langs->trans("Example").':<br>';
806 $tooltiptext .= 'VATEX-FR-FRANCHISE, VATEX-FR-CGI261-4, VATEX-FR-J, VATEX-FR-I, VATEX-FR-D, ...';
807}
808print $form->textwithpicto($langs->trans("VATExemptionCode"), $tooltiptext, 1, 'help', 'valignmiddle', 0, 3, 'exemptioncode').' <input type="text" name="MAIN_INFO_SOCIETE_VAT_EXEMPTION_CODE" placeholder="'.$placeholder.'" value="'.getDolGlobalString('MAIN_INFO_SOCIETE_VAT_EXEMPTION_CODE').'">';
809print '</div>';
810
811print "</td></tr>\n";
812
813print "</table>";
814
815// Second tax
816print '<br>';
817print '<table class="noborder centpercent editmode">';
818print '<tr class="liste_titre">';
819print '<td class="titlefieldcreate">'.$form->textwithpicto($langs->transcountry("LocalTax1Management", $mysoc->country_code), $langs->transcountry("LocalTax1IsUsedDesc", $mysoc->country_code)).'</td><td></td>';
820print '<td class="right">&nbsp;</td>';
821print "</tr>\n";
822
823if ($mysoc->useLocalTax(1)) {
824 // Note: When option is not set, it must not appears as set on on, because there is no default value for this option
825 print '<tr class="oddeven"><td><input type="radio" name="optionlocaltax1" id="lt1" value="localtax1on"'.((getDolGlobalString('FACTURE_LOCAL_TAX1_OPTION') == '1' || getDolGlobalString('FACTURE_LOCAL_TAX1_OPTION') == "localtax1on") ? " checked" : "").'> <label for="lt1">'.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code)."</label></td>";
826 print '<td colspan="2">';
827 print '<div class="nobordernopadding">';
828 $tooltiphelp = $langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code);
829 $tooltiphelp = ($tooltiphelp != "LocalTax1IsUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code)."</i>\n" : "");
830 print $form->textwithpicto($langs->transcountry("LocalTax1IsUsedDesc", $mysoc->country_code), $tooltiphelp);
831 if (!isOnlyOneLocalTax(1)) {
832 print '<br><label for="lt1">'.$langs->trans("LTRate").'</label>: ';
833 $formcompany->select_localtax(1, getDolGlobalFloat('MAIN_INFO_VALUE_LOCALTAX1'), "lt1");
834 }
835
836 $options = array($langs->trans("CalcLocaltax1").' '.$langs->trans("CalcLocaltax1Desc"), $langs->trans("CalcLocaltax2").' - '.$langs->trans("CalcLocaltax2Desc"), $langs->trans("CalcLocaltax3").' - '.$langs->trans("CalcLocaltax3Desc"));
837
838 print '<br><label for="clt1">'.$langs->trans("CalcLocaltax").'</label>: ';
839 print $form->selectarray("clt1", $options, getDolGlobalString('MAIN_INFO_LOCALTAX_CALC1'));
840 print "</div>";
841 print "</td></tr>\n";
842
843 print '<tr class="oddeven"><td><input type="radio" name="optionlocaltax1" id="nolt1" value="localtax1off"'.((!getDolGlobalString('FACTURE_LOCAL_TAX1_OPTION') || getDolGlobalString('FACTURE_LOCAL_TAX1_OPTION') == "localtax1off") ? " checked" : "").'> <label for="nolt1">'.$langs->transcountry("LocalTax1IsNotUsed", $mysoc->country_code)."</label></td>";
844 print '<td colspan="2">';
845 $tooltiphelp = $langs->transcountry("LocalTax1IsNotUsedExample", $mysoc->country_code);
846 $tooltiphelp = ($tooltiphelp != "LocalTax1IsNotUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsNotUsedExample", $mysoc->country_code)."</i>\n" : "");
847 print $form->textwithpicto($langs->transcountry("LocalTax1IsNotUsedDesc", $mysoc->country_code), $tooltiphelp);
848 print "</td></tr>\n";
849} else {
850 if (empty($mysoc->country_code)) {
851 print '<tr class="oddeven nohover"><td class="" colspan="3">'.$countrynotdefined.'</td></tr>';
852 } else {
853 print '<tr class="oddeven nohover"><td class="" colspan="3"><span class="opacitymedium">'.$langs->trans("NoLocalTaxXForThisCountry", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryVAT"), $langs->transnoentitiesnoconv("LocalTax1Management")).'</span></td></tr>';
854 }
855}
856
857print "</table>";
858
859// Third tax system
860print '<br>';
861print '<table class="noborder centpercent editmode">';
862print '<tr class="liste_titre">';
863print '<td class="titlefieldcreate">'.$form->textwithpicto($langs->transcountry("LocalTax2Management", $mysoc->country_code), $langs->transcountry("LocalTax2IsUsedDesc", $mysoc->country_code)).'</td><td></td>';
864print '<td class="right">&nbsp;</td>';
865print "</tr>\n";
866
867if ($mysoc->useLocalTax(2)) {
868 // Note: When option is not set, it must not appears as set on on, because there is no default value for this option
869 print '<tr class="oddeven"><td><input type="radio" name="optionlocaltax2" id="lt2" value="localtax2on"'.((getDolGlobalString('FACTURE_LOCAL_TAX2_OPTION') == '1' || getDolGlobalString('FACTURE_LOCAL_TAX2_OPTION') == "localtax2on") ? " checked" : "").'> <label for="lt2">'.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code)."</label></td>";
870 print '<td colspan="2">';
871 print '<div class="nobordernopadding">';
872 print '<label for="lt2">'.$langs->transcountry("LocalTax2IsUsedDesc", $mysoc->country_code)."</label>";
873 $tooltiphelp = $langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code);
874 $tooltiphelp = ($tooltiphelp != "LocalTax2IsUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code)."</i>\n" : "");
875 if (!isOnlyOneLocalTax(2)) {
876 print '<br><label for="lt2">'.$langs->trans("LTRate").'</label>: ';
877 $formcompany->select_localtax(2, getDolGlobalFloat('MAIN_INFO_VALUE_LOCALTAX2'), "lt2");
878 }
879
880 $options = array($langs->trans("CalcLocaltax1").' '.$langs->trans("CalcLocaltax1Desc"), $langs->trans("CalcLocaltax2").' - '.$langs->trans("CalcLocaltax2Desc"), $langs->trans("CalcLocaltax3").' - '.$langs->trans("CalcLocaltax3Desc"));
881
882 print '<br><label for="clt2">'.$langs->trans("CalcLocaltax").'</label>: ';
883 print $form->selectarray("clt2", $options, getDolGlobalString('MAIN_INFO_LOCALTAX_CALC2'));
884 print "</div>";
885 print "</td></tr>\n";
886
887 print '<tr class="oddeven"><td><input type="radio" name="optionlocaltax2" id="nolt2" value="localtax2off"'.((!getDolGlobalString('FACTURE_LOCAL_TAX2_OPTION') || getDolGlobalString('FACTURE_LOCAL_TAX2_OPTION') == "localtax2off") ? " checked" : "").'> <label for="nolt2">'.$langs->transcountry("LocalTax2IsNotUsed", $mysoc->country_code)."</label></td>";
888 print '<td colspan="2">';
889 print "<div>";
890 $tooltiphelp = $langs->transcountry("LocalTax2IsNotUsedExample", $mysoc->country_code);
891 $tooltiphelp = ($tooltiphelp != "LocalTax2IsNotUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsNotUsedExample", $mysoc->country_code)."</i>\n" : "");
892 print "<label for=\"nolt2\">".$form->textwithpicto($langs->transcountry("LocalTax2IsNotUsedDesc", $mysoc->country_code), $tooltiphelp)."</label>";
893 print "</div>";
894 print "</td></tr>\n";
895} else {
896 if (empty($mysoc->country_code)) {
897 print '<tr class="oddeven nohover"><td class="" colspan="3">'.$countrynotdefined.'</td></tr>';
898 } else {
899 print '<tr class="oddeven nohover"><td class="" colspan="3"><span class="opacitymedium">'.$langs->trans("NoLocalTaxXForThisCountry", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryVAT"), $langs->transnoentitiesnoconv("LocalTax2Management")).'</span></td></tr>';
900 }
901}
902
903print "</table>";
904
905
906// Tax stamp
907print '<br>';
908print '<table class="noborder centpercent editmode">';
909print '<tr class="liste_titre">';
910print '<td>'.$form->textwithpicto($langs->trans("RevenueStamp"), $langs->trans("RevenueStampDesc")).'</td><td></td>';
911print '<td class="right">&nbsp;</td>';
912print "</tr>\n";
913if ($mysoc->useRevenueStamp()) {
914 // Note: When option is not set, it must not appears as set on on, because there is no default value for this option
915 print '<tr class="oddeven"><td>';
916 print $langs->trans("UseRevenueStamp");
917 print "</td>";
918 print '<td colspan="2">';
919 print $langs->trans("UseRevenueStampExample", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryRevenueStamp"));
920 print "</td></tr>\n";
921} else {
922 if (empty($mysoc->country_code)) {
923 print '<tr class="oddeven nohover"><td class="" colspan="3">'.$countrynotdefined.'</td></tr>';
924 } else {
925 print '<tr class="oddeven nohover"><td class="" colspan="3"><span class="opacitymedium">'.$langs->trans("NoLocalTaxXForThisCountry", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryRevenueStamp"), $langs->transnoentitiesnoconv("RevenueStamp")).'</span></td></tr>';
926 }
927}
928
929print "</table>";
930
931// AADE webservices credentials, applicable only for Greece
932if ($mysoc->country_code == 'GR') {
933 print load_fiche_titre($langs->trans("AADEWebserviceCredentials"), '', '');
934 print '<table class="noborder centpercent editmode">';
935 print '<tr class="liste_titre">';
936 print '<td>'.$langs->trans("AccountParameter").'</td>';
937 print '<td></td>';
938 print '<td></td>';
939 print "</tr>\n";
940
941 print '<tr class="oddeven"><td>';
942 print '<span class="titlefield fieldrequired">'.$langs->trans("MYDATA_AADE_USER").'</span></td><td>';
943 print '<input class="minwidth300" type="text" name="MYDATA_AADE_USER" value="'.getDolGlobalString('MYDATA_AADE_USER').'"';
944 print '</td><td></td></tr>';
945
946 print '<tr class="oddeven"><td>';
947 print '<span class="titlefield fieldrequired">'.$langs->trans("MYDATA_AADE_KEY").'</span></td><td>';
948 print '<input class="minwidth300" type="password" name="MYDATA_AADE_KEY" value="'.getDolGlobalString('MYDATA_AADE_KEY').'"';
949 print '</td><td></td></tr>';
950
951 print '<tr class="oddeven"><td>';
952 print '<span class="titlefield fieldrequired">'.$langs->trans("AADE_WEBSERVICE_USER").'</span></td><td>';
953 print '<input class="minwidth300" type="text" name="AADE_WEBSERVICE_USER" value="'.getDolGlobalString('AADE_WEBSERVICE_USER').'"';
954 print '</td><td></td></tr>';
955
956 print '<tr class="oddeven"><td>';
957 print '<span class="titlefield fieldrequired">'.$langs->trans("AADE_WEBSERVICE_KEY").'</span></td><td>';
958 print '<input class="minwidth300" type="password" name="AADE_WEBSERVICE_KEY" value="'.getDolGlobalString('AADE_WEBSERVICE_KEY').'"';
959 print '</td><td></td></tr>';
960
961 print '<br>';
962
963 print "</table>";
964}
965
966print $form->buttonsSaveCancel("Save", '', array(), false, 'reposition');
967
968print '</form>';
969
970
971// End of page
972llxFooter();
973$db->close();
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
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).
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
company_admin_prepare_head()
Return array head with list of tabs to view object information.
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
isALNERunningVersion($blockedlogtestalreadydone=0, $blockedlogmodulealreadydone=0)
Return if the application is executed with the LNE requirements on.
Class to build HTML component for third parties management Only common components are here.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class to help generate other html components Only common components are here.
Class to manage third parties objects (customers, suppliers, prospects...)
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
getState($id, $withcode='0', $dbtouse=null, $withregion=0, $outputlangs=null, $entconv=1)
Return state translated from an id.
global $mysoc
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $nohook=0, $keyforsourcefile='addedfile', $upload_dir='', $mode=0)
Check validity of a file upload from an GUI page, and move it to its final destination.
getDolGlobalFloat($key, $default=0)
Return a Dolibarr global constant float value.
isOnlyOneLocalTax($local)
Return true if LocalTax (1 or 2) is unique.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='')
Show information in HTML for admin users or standard users.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dolPrintHTMLForAttribute($s, $escapeonlyhtmltags=0, $allowothertags=array())
Return a string ready to be output into an HTML attribute (alt, title, data-html, ....
getDolCurrency()
Return the main currency ('EUR', 'USD', ...)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
vignette($file, $maxWidth=160, $maxHeight=120, $extName='_small', $quality=50, $outdir='thumbs', $targetformat=0)
Create a thumbnail from an image file (Supported extensions are gif, jpg, png and bmp).
getListOfPossibleImageExt($acceptsvg=0)
Return if a filename is file name of a supported image format.
if(!defined( 'IMAGETYPE_WEBP')) getDefaultImageSizes()
Return default values for image sizes.
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
getMaxFileSizeArray()
Return the max allowed for file upload.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.