dolibarr 25.0.0-alpha
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
78if (!getDolGlobalString('MAIN_INFO_SOCIETE_NOM') || !getDolGlobalString('MAIN_INFO_SOCIETE_COUNTRY') || getDolGlobalString('MAIN_INFO_SOCIETE_SETUP_TODO_WARNING')) {
79 $setupcompanynotcomplete = 1;
80} else {
81 $setupcompanynotcomplete = 0;
82}
83
84
85/*
86 * Actions
87 */
88
89$parameters = array();
90$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
91if ($reshook < 0) {
92 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
93}
94
95if (($action == 'update' && !GETPOST("cancel", 'alpha'))
96|| ($action == 'updateedit')) {
97 $db->begin();
98
99 $tmparray = getCountry(GETPOSTINT('country_id'), 'all', $db, $langs, 0);
100 if (!empty($tmparray['id'])) {
101 // Check we can change country
102 include_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
103 if ($mysoc->country_code == 'FR' && $tmparray['code'] != $mysoc->country_code && isALNERunningVersion()) {
104 $langs->load("blockedlog");
105 setEventMessages($langs->trans("BlockedLogCountryChangeNotAllowedFR"), null, 'errors');
106 $error++;
107 } else {
108 if ($tmparray['code'] == 'FR' && $tmparray['id'] != $mysoc->country_id) {
109 // For FR, default value of option to show profid SIREN is on by default
110 $res = dolibarr_set_const($db, "MAIN_PROFID1_IN_ADDRESS", 1, 'chaine', 0, '', $conf->entity);
111 }
112
113 $mysoc->country_id = $tmparray['id'];
114 $mysoc->country_code = $tmparray['code'];
115 $mysoc->country_label = $tmparray['label'];
116
117 $s = $mysoc->country_id.':'.$mysoc->country_code.':'.$mysoc->country_label;
118 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_COUNTRY", $s, 'chaine', 0, '', $conf->entity);
119
120 activateModulesRequiredByCountry($mysoc->country_code);
121 }
122 }
123
124 $tmparray = getState(GETPOSTINT('state_id'), 'all', $db, 0, $langs, 0);
125 if (!empty($tmparray['id'])) {
126 $mysoc->state_id = $tmparray['id'];
127 $mysoc->state_code = $tmparray['code'];
128 $mysoc->state_label = $tmparray['label'];
129
130 $s = $mysoc->state_id.':'.$mysoc->state_code.':'.$mysoc->state_label;
131 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_STATE", $s, 'chaine', 0, '', $conf->entity);
132 } else {
133 dolibarr_del_const($db, "MAIN_INFO_SOCIETE_STATE", $conf->entity);
134 }
135
136 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", GETPOST("name", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
137 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ADDRESS", GETPOST("MAIN_INFO_SOCIETE_ADDRESS", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
138 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TOWN", GETPOST("MAIN_INFO_SOCIETE_TOWN", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
139 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ZIP", GETPOST("MAIN_INFO_SOCIETE_ZIP", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
140 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_REGION", GETPOST("region_code", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
141 dolibarr_set_const($db, "MAIN_MONNAIE", GETPOST("currency", 'aZ09'), 'chaine', 0, '', $conf->entity);
142 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TEL", GETPOST("phone", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
143 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MOBILE", GETPOST("phone_mobile", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
144 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FAX", GETPOST("fax", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
145 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MAIL", GETPOST("mail", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
146 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_WEB", GETPOST("web", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
147 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOTE", GETPOST("note", 'restricthtml'), 'chaine', 0, '', $conf->entity);
148 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_GENCOD", GETPOST("barcode", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
149
150 $dirforimage = $conf->mycompany->dir_output.'/logos/';
151
152 $arrayofimages = array('logo', 'logo_squarred');
153 //var_dump($_FILES); exit;
154 foreach ($arrayofimages as $varforimage) {
155 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.
156 $langs->load("errors");
157 $mesg = $langs->trans("ErrorBadImageFormat");
158 if (!function_exists("imagecreate")) {
159 $mesg .= ' - '.$langs->trans("ErrorPHPDoesNotSupport", "GD");
160 } else {
161 $supportedextensions = getListOfPossibleImageExt();
162 $supportedextensions = preg_replace('/\\\./', '', $supportedextensions); // Remove '\.'
163 $mesg .= ' - '.$langs->trans("ErrorSupportedFormatAre", implode(', ', explode('|', $supportedextensions)));
164 }
165 setEventMessages($mesg, null, 'errors');
166 break;
167 }
168
169 // Remove to check file size to large
170 /*if ($_FILES[$varforimage]["tmp_name"]) {*/
171 $reg = array();
172 if (preg_match('/([^\\/:]+)$/i', $_FILES[$varforimage]["name"], $reg)) {
173 $original_file = $reg[1];
174
175 $isimage = image_format_supported($original_file);
176 if ($isimage >= 0) {
177 dol_syslog("Move file ".$_FILES[$varforimage]["tmp_name"]." to ".$dirforimage.$original_file);
178 if (!is_dir($dirforimage)) {
179 dol_mkdir($dirforimage);
180 }
181 $result = dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage.$original_file, 1, 0, $_FILES[$varforimage]['error']);
182
183 if (is_numeric($result) && $result > 0) {
184 $constant = "MAIN_INFO_SOCIETE_LOGO";
185 if ($varforimage == 'logo_squarred') {
186 $constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED";
187 }
188
189 dolibarr_set_const($db, $constant, $original_file, 'chaine', 0, '', $conf->entity);
190
191 // Create thumbs of logo (Note that PDF use original file and not thumbs)
192 if ($isimage > 0) {
193 // Create thumbs
194 //$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...
195
196
197 // Create small thumb, Used on logon for example
198 $imgThumbSmall = vignette($dirforimage.$original_file, $maxwidthsmall, $maxheightsmall, '_small', $quality);
199 if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg)) {
200 $imgThumbSmall = $reg[1]; // Save only basename
201 dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity);
202 } else {
203 dol_syslog($imgThumbSmall);
204 }
205
206 // Create mini thumb, Used on menu or for setup page for example
207 $imgThumbMini = vignette($dirforimage.$original_file, $maxwidthmini, $maxheightmini, '_mini', $quality);
208 if (image_format_supported($imgThumbMini) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg)) {
209 $imgThumbMini = $reg[1]; // Save only basename
210 dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity);
211 } else {
212 dol_syslog($imgThumbMini);
213 }
214 } else {
215 dol_syslog("ErrorImageFormatNotSupported", LOG_WARNING);
216 }
217 } elseif (preg_match('/^ErrorFileIsInfectedWithAVirus/', $result)) {
218 $error++;
219 $langs->load("errors");
220 $tmparray = explode(':', $result);
221 setEventMessages($langs->trans('ErrorFileIsInfectedWithAVirus', $tmparray[1]), null, 'errors');
222 } elseif (preg_match('/^ErrorFileSizeTooLarge/', $result)) {
223 $error++;
224 setEventMessages($langs->trans("ErrorFileSizeTooLarge"), null, 'errors');
225 } else {
226 $error++;
227 setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors');
228 }
229 } else {
230 $error++;
231 $langs->load("errors");
232 setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors');
233 }
234 }
235 /*}*/
236 }
237
238 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MANAGERS", GETPOST("MAIN_INFO_SOCIETE_MANAGERS", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
239 dolibarr_set_const($db, "MAIN_INFO_GDPR", GETPOST("MAIN_INFO_GDPR", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
240 dolibarr_set_const($db, "MAIN_INFO_CAPITAL", GETPOST("capital", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
241 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FORME_JURIDIQUE", GETPOST("forme_juridique_code", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
242 dolibarr_set_const($db, "MAIN_INFO_SIREN", GETPOST("siren", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
243 dolibarr_set_const($db, "MAIN_INFO_SIRET", GETPOST("siret", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
244 dolibarr_set_const($db, "MAIN_INFO_APE", GETPOST("ape", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
245 dolibarr_set_const($db, "MAIN_INFO_RCS", GETPOST("rcs", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
246 dolibarr_set_const($db, "MAIN_INFO_PROFID5", GETPOST("MAIN_INFO_PROFID5", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
247 dolibarr_set_const($db, "MAIN_INFO_PROFID6", GETPOST("MAIN_INFO_PROFID6", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
248 dolibarr_set_const($db, "MAIN_INFO_PROFID7", GETPOST("MAIN_INFO_PROFID7", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
249 dolibarr_set_const($db, "MAIN_INFO_PROFID8", GETPOST("MAIN_INFO_PROFID8", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
250 dolibarr_set_const($db, "MAIN_INFO_PROFID9", GETPOST("MAIN_INFO_PROFID9", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
251 dolibarr_set_const($db, "MAIN_INFO_PROFID10", GETPOST("MAIN_INFO_PROFID10", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
252
253 dolibarr_set_const($db, "MAIN_INFO_TVAINTRA", GETPOST("tva", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
254 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_OBJECT", GETPOST("socialobject", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
255
256 dolibarr_set_const($db, "SOCIETE_FISCAL_MONTH_START", GETPOSTINT("SOCIETE_FISCAL_MONTH_START"), 'chaine', 0, '', $conf->entity);
257
258 // Sale tax options
259 $usevat = GETPOST("optiontva", 'aZ09');
260 $uselocaltax1 = GETPOST("optionlocaltax1", 'aZ09');
261 $uselocaltax2 = GETPOST("optionlocaltax2", 'aZ09');
262 if ($uselocaltax1 == 'localtax1on' && !$usevat) {
263 setEventMessages($langs->trans("IfYouUseASecondTaxYouMustSetYouUseTheMainTax"), null, 'errors');
264 $error++;
265 }
266 if ($uselocaltax2 == 'localtax2on' && !$usevat) {
267 setEventMessages($langs->trans("IfYouUseAThirdTaxYouMustSetYouUseTheMainTax"), null, 'errors');
268 $error++;
269 }
270
271 dolibarr_set_const($db, "FACTURE_TVAOPTION", $usevat, 'chaine', 0, '', $conf->entity);
272
273 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_VAT_EXEMPTION_CODE", GETPOST('MAIN_INFO_SOCIETE_VAT_EXEMPTION_CODE'), 'chaine', 0, '', $conf->entity);
274
275 dolibarr_set_const($db, "FACTURE_LOCAL_TAX1_OPTION", $uselocaltax1, 'chaine', 0, '', $conf->entity);
276 dolibarr_set_const($db, "FACTURE_LOCAL_TAX2_OPTION", $uselocaltax2, 'chaine', 0, '', $conf->entity);
277
278 if (GETPOST("optionlocaltax1") == "localtax1on") {
279 if (!GETPOSTISSET('lt1')) {
280 dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX1", 0, 'chaine', 0, '', $conf->entity);
281 } else {
282 dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX1", GETPOST('lt1', 'aZ09'), 'chaine', 0, '', $conf->entity);
283 }
284 dolibarr_set_const($db, "MAIN_INFO_LOCALTAX_CALC1", GETPOST("clt1", 'aZ09'), 'chaine', 0, '', $conf->entity);
285 }
286 if (GETPOST("optionlocaltax2") == "localtax2on") {
287 if (!GETPOSTISSET('lt2')) {
288 dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX2", 0, 'chaine', 0, '', $conf->entity);
289 } else {
290 dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX2", GETPOST('lt2', 'aZ09'), 'chaine', 0, '', $conf->entity);
291 }
292 dolibarr_set_const($db, "MAIN_INFO_LOCALTAX_CALC2", GETPOST("clt2", 'aZ09'), 'chaine', 0, '', $conf->entity);
293 }
294
295 // Credentials for AADE webservices, applicable only for Greece
296 if ($mysoc->country_code == 'GR') {
297 dolibarr_set_const($db, "MYDATA_AADE_USER", GETPOST("MYDATA_AADE_USER", 'alpha'), 'chaine', 0, '', $conf->entity);
298 dolibarr_set_const($db, "MYDATA_AADE_KEY", GETPOST("MYDATA_AADE_KEY", 'alpha'), 'chaine', 0, '', $conf->entity);
299 dolibarr_set_const($db, "AADE_WEBSERVICE_USER", GETPOST("AADE_WEBSERVICE_USER", 'alpha'), 'chaine', 0, '', $conf->entity);
300 dolibarr_set_const($db, "AADE_WEBSERVICE_KEY", GETPOST("AADE_WEBSERVICE_KEY", 'alpha'), 'chaine', 0, '', $conf->entity);
301 }
302
303 // Remove constant MAIN_INFO_SOCIETE_SETUP_TODO_WARNING
304 dolibarr_del_const($db, "MAIN_INFO_SOCIETE_SETUP_TODO_WARNING", $conf->entity);
305
306 if (!$error) {
307 if (GETPOST('save')) { // To avoid to show message when we juste switch the country that resubmit the form.
308 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
309 }
310 $db->commit();
311 } else {
312 $db->rollback();
313 }
314
315 if ($action != 'updateedit' && !$error) {
316 header("Location: ".$_SERVER["PHP_SELF"].($page_y ? '?page_y='.$page_y : ''));
317 exit;
318 }
319}
320
321if ($action == 'addthumb' || $action == 'addthumbsquarred') { // Regenerate thumbs
322 if (file_exists($conf->mycompany->dir_output.'/logos/'.GETPOST("file"))) {
323 $isimage = image_format_supported(GETPOST("file"));
324
325 // Create thumbs of logo
326 if ($isimage > 0) {
327 $constant = "MAIN_INFO_SOCIETE_LOGO";
328 if ($action == 'addthumbsquarred') {
329 $constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED";
330 }
331
332 $reg = array();
333
334 // Create thumbs
335 //$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...
336
337 // Create small thumb. Used on logon for example
338 $imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.GETPOST("file"), $maxwidthsmall, $maxheightsmall, '_small', $quality);
339 if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg)) {
340 $imgThumbSmall = $reg[1]; // Save only basename
341 dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity);
342 } else {
343 dol_syslog($imgThumbSmall);
344 }
345
346 // Create mini thumbs. Used on menu or for setup page for example
347 $imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.GETPOST("file"), $maxwidthmini, $maxheightmini, '_mini', $quality);
348 if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg)) {
349 $imgThumbMini = $reg[1]; // Save only basename
350 dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity);
351 } else {
352 dol_syslog($imgThumbMini);
353 }
354
355 header("Location: ".$_SERVER["PHP_SELF"]);
356 exit;
357 } else {
358 $error++;
359 $langs->load("errors");
360 setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors');
361 dol_syslog($langs->transnoentities("ErrorBadImageFormat"), LOG_INFO);
362 }
363 } else {
364 $error++;
365 $langs->load("errors");
366 setEventMessages($langs->trans("ErrorFileDoesNotExists", GETPOST("file")), null, 'errors');
367 dol_syslog($langs->transnoentities("ErrorFileDoesNotExists", GETPOST("file")), LOG_WARNING);
368 }
369}
370
371
372if ($action == 'removelogo' || $action == 'removelogo_squarred') {
373 $constant = "MAIN_INFO_SOCIETE_LOGO";
374 if ($action == 'removelogo_squarred') {
375 $constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED";
376 }
377
378 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
379
380 $logofilename = $mysoc->logo;
381 $logofilenamebis = $mysoc->logo_squarred;
382 if ($action == 'removelogo_squarred') {
383 $logofilename = $mysoc->logo_squarred;
384 $logofilenamebis = $mysoc->logo;
385 }
386
387 $logofile = $conf->mycompany->dir_output.'/logos/'.$logofilename;
388 if ($logofilename != '' && $logofilename != $logofilenamebis) {
389 dol_delete_file($logofile);
390 }
391 dolibarr_del_const($db, $constant, $conf->entity);
392 if ($action == 'removelogo_squarred') {
393 $mysoc->logo_squarred = '';
394 } else {
395 $mysoc->logo = '';
396 }
397
398 $logofilename = $mysoc->logo_small;
399 $logofilenamebis = $mysoc->logo_squarred_small;
400 if ($action == 'removelogo_squarred') {
401 $logofilename = $mysoc->logo_squarred_small;
402 $logofilenamebis = $mysoc->logo_small;
403 }
404
405 $logosmallfile = $conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename;
406 if ($logofilename != '' && $logofilename != $logofilenamebis) {
407 dol_delete_file($logosmallfile);
408 }
409 dolibarr_del_const($db, $constant."_SMALL", $conf->entity);
410 if ($action == 'removelogo_squarred') {
411 $mysoc->logo_squarred_small = '';
412 } else {
413 $mysoc->logo_small = '';
414 }
415
416 $logofilename = $mysoc->logo_mini;
417 $logofilenamebis = $mysoc->logo_squarred_mini;
418 if ($action == 'removelogo_squarred') {
419 $logofilename = $mysoc->logo_squarred_mini;
420 $logofilenamebis = $mysoc->logo_mini;
421 }
422
423 $logominifile = $conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename;
424 if ($logofilename != '' && $logofilename != $logofilenamebis) {
425 dol_delete_file($logominifile);
426 }
427 dolibarr_del_const($db, $constant."_MINI", $conf->entity);
428 if ($action == 'removelogo_squarred') {
429 $mysoc->logo_squarred_mini = '';
430 } else {
431 $mysoc->logo_mini = '';
432 }
433}
434
435
436/*
437 * View
438 */
439
440$wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
441llxHeader('', $langs->trans("Setup"), $wikihelp, '', 0, 0, '', '', '', 'mod-admin page-company');
442
443$form = new Form($db);
444$formother = new FormOther($db);
445$formcompany = new FormCompany($db);
446$formfile = new FormFile($db);
447
448$countrynotdefined = '<span class="error">'.$langs->trans("ErrorSetACountryFirst").' <a href="" onclick="window.scrollTo({top: 0, behavior: \'smooth\'}); return false;">('.$langs->trans("SeeAbove").')</a></span>';
449
450print load_fiche_titre($langs->trans("CompanyFoundation"), '', 'title_setup');
451
453
454print dol_get_fiche_head($head, 'company', '', -1, '');
455
456print '<div class="'.($setupcompanynotcomplete ? 'warning' : 'info').'">'.$langs->trans("CompanyFundationDesc", $langs->transnoentities("Save"))."</div>\n";
457print "<br>\n";
458
459
460// Edit parameters
461
462if (!empty($conf->use_javascript_ajax)) {
463 print "\n".'<script type="text/javascript">';
464 print '$(document).ready(function () {
465 $("#selectcountry_id").change(function() {
466 console.log("selectcountry_id change");
467 document.form_index.action.value="updateedit";
468 document.form_index.submit();
469 });
470
471 // Show/hide VAT exemption code field based on VAT option
472 $("input[name=\"optiontva\"]").change(function() {
473 if ($(this).val() == "0") {
474 $("#vat_exemption_code_div").show();
475 } else {
476 $("#vat_exemption_code_div").hide();
477 }
478 });
479 });';
480 print '</script>'."\n";
481}
482
483print '<form enctype="multipart/form-data" method="POST" action="'.$_SERVER["PHP_SELF"].'" name="form_index" spellcheck="false">';
484print '<input type="hidden" name="token" value="'.newToken().'">';
485print '<input type="hidden" name="action" value="update">';
486print '<input type="hidden" name="page_y" value="">';
487
488print '<table class="noborder centpercent editmode">';
489print '<tr class="liste_titre"><th class="wordbreak" colspan="2">'.$langs->trans("CompanyInfo").'</th></tr>'."\n";
490
491// Company name
492print '<tr class="oddeven"><td class="fieldrequired titlefieldcreate wordbreak"><label for="name">'.$langs->trans("CompanyName").'</label></td><td>';
493print '<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";
494
495// Main currency
496print '<tr class="oddeven"><td class="fieldrequired"><label for="currency">'.$langs->trans("CompanyCurrency").'</label></td><td>';
497print img_picto('', 'multicurrency', 'class="pictofixedwidth"');
498print $form->selectCurrency(getDolCurrency(), "currency", 2);
499print '</td></tr>'."\n";
500
501// Country
502print '<tr class="oddeven"><td class="fieldrequired"><label for="selectcountry_id">'.$langs->trans("Country").'</label></td><td>';
503print img_picto('', 'globe-americas', 'class="pictofixedwidth"');
504print $form->select_country((string) $mysoc->country_id, 'country_id', '', 0);
505print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
506print '</td></tr>'."\n";
507
508// Address
509print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_ADDRESS">'.$langs->trans("CompanyAddress").'</label></td><td>';
510print '<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";
511
512// Zip
513print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_ZIP">'.$langs->trans("CompanyZip").'</label></td><td>';
514print '<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";
515
516print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_TOWN">'.$langs->trans("CompanyTown").'</label></td><td>';
517print '<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";
518
519// State
520print '<tr class="oddeven"><td class="wordbreak"><label for="state_id">'.$langs->trans("State").'</label></td><td>';
521$state_id = 0;
522if (getDolGlobalString('MAIN_INFO_SOCIETE_STATE')) {
523 $tmp = explode(':', getDolGlobalString('MAIN_INFO_SOCIETE_STATE'));
524 $state_id = $tmp[0];
525}
526print img_picto('', 'state', 'class="pictofixedwidth"');
527print $formcompany->select_state($state_id, $mysoc->country_code, 'state_id', 'maxwidth200onsmartphone minwidth300');
528print '</td></tr>'."\n";
529
530// Phone
531print '<tr class="oddeven"><td><label for="phone">'.$langs->trans("Phone").'</label></td><td>';
532print img_picto('', 'object_phoning', '', 0, 0, 0, '', 'pictofixedwidth');
533print '<input class="maxwidth150 widthcentpercentminusx" name="phone" id="phone" value="'.dolPrintHTMLForAttribute((GETPOSTISSET('phone') ? GETPOST('phone', 'alphanohtml') : getDolGlobalString('MAIN_INFO_SOCIETE_TEL'))).'"></td></tr>';
534print '</td></tr>'."\n";
535
536// Phone mobile
537print '<tr class="oddeven"><td><label for="phone">'.$langs->trans("PhoneMobile").'</label></td><td>';
538print img_picto('', 'object_phoning_mobile', '', 0, 0, 0, '', 'pictofixedwidth');
539print '<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>';
540print '</td></tr>'."\n";
541
542// Fax
543print '<tr class="oddeven"><td><label for="fax">'.$langs->trans("Fax").'</label></td><td>';
544print img_picto('', 'object_phoning_fax', '', 0, 0, 0, '', 'pictofixedwidth');
545print '<input class="maxwidth150" name="fax" id="fax" value="'.dolPrintHTMLForAttribute((GETPOSTISSET('fax') ? GETPOST('fax', 'alphanohtml') : getDolGlobalString('MAIN_INFO_SOCIETE_FAX'))).'"></td></tr>';
546print '</td></tr>'."\n";
547
548// Email
549print '<tr class="oddeven"><td><label for="email">'.$langs->trans("EMail").'</label></td><td>';
550print img_picto('', 'object_email', '', 0, 0, 0, '', 'pictofixedwidth');
551print '<input class="minwidth300 maxwidth500 widthcentpercentminusx" name="mail" id="email" value="'.dolPrintHTMLForAttribute((GETPOSTISSET('mail') ? GETPOST('mail', 'alphanohtml') : getDolGlobalString('MAIN_INFO_SOCIETE_MAIL'))).'"></td></tr>';
552print '</td></tr>'."\n";
553
554// Web
555print '<tr class="oddeven"><td><label for="web">'.$langs->trans("Web").'</label></td><td>';
556print img_picto('', 'globe', '', 0, 0, 0, '', 'pictofixedwidth');
557print '<input class="maxwidth300 widthcentpercentminusx" name="web" id="web" value="'.dol_escape_htmltag((GETPOSTISSET('web') ? GETPOST('web', 'alphanohtml') : getDolGlobalString('MAIN_INFO_SOCIETE_WEB'))).'"></td></tr>';
558print '</td></tr>'."\n";
559
560// Barcode
561if (isModEnabled('barcode')) {
562 print '<tr class="oddeven"><td>';
563 print '<label for="barcode">'.$langs->trans("Gencod").'</label></td><td>';
564 print '<span class="fa fa-barcode pictofixedwidth"></span>';
565 print '<input name="barcode" id="barcode" class="minwidth150 widthcentpercentminusx maxwidth300" value="'.dolPrintHTMLForAttribute(GETPOSTISSET('barcode') ? GETPOST('barcode', 'alphanohtml') : getDolGlobalString('MAIN_INFO_SOCIETE_GENCOD')).'"></td></tr>';
566 print '</td></tr>';
567}
568
569// Tooltip for both Logo and LogSquarred
570$maxfilesizearray = getMaxFileSizeArray();
571$maxmin = $maxfilesizearray['maxmin'];
572$tooltiplogo = $langs->trans('AvailableFormats').' : png, jpg, jpeg';
573$tooltiplogo .= ($maxmin > 0) ? '<br>'.$langs->trans('MaxSize').' : '.$maxmin.' '.$langs->trans('Kb') : '';
574
575// Logo
576print '<tr class="oddeven"><td><label for="logo">'.$form->textwithpicto($langs->trans("Logo"), $tooltiplogo).'</label></td><td>';
577
578$modulepart = 'mycompany';
579$dirformainimage = $conf->mycompany->dir_output;
580$subdirformainimage = 'logos/';
581$fileformainimage = $mysoc->logo;
582
583print $formfile->showImageToEdit('logo', $modulepart, $dirformainimage, $subdirformainimage, $fileformainimage);
584
585print '</td></tr>';
586
587// Logo (squarred)
588print '<tr class="oddeven"><td><label for="logo_squarred">'.$form->textwithpicto($langs->trans("LogoSquarred"), $tooltiplogo).'</label></td><td>';
589
590$modulepart = 'mycompany';
591$dirformainimage = $conf->mycompany->dir_output;
592$subdirformainimage = 'logos/';
593$fileformainimage = $mysoc->logo_squarred;
594
595print $formfile->showImageToEdit('logo_squarred', $modulepart, $dirformainimage, $subdirformainimage, $fileformainimage);
596
597print '</td></tr>';
598
599// Note
600print '<tr class="oddeven"><td class="tdtop"><label for="note">'.$langs->trans("Note").'</label></td><td>';
601print '<textarea class="flat quatrevingtpercent" name="note" id="note" rows="'.ROWS_5.'">'.(GETPOSTISSET('note') ? GETPOST('note', 'restricthtml') : getDolGlobalString('MAIN_INFO_SOCIETE_NOTE')).'</textarea></td></tr>';
602print '</td></tr>';
603
604print '</table>';
605
606print $form->buttonsSaveCancel("Save", '', array(), false, 'reposition');
607
608print '<br><br>';
609
610
611// IDs of the company (country-specific)
612print '<div class="div-table-responsive-no-min">';
613print '<table class="noborder centpercent editmode">';
614print '<tr class="liste_titre"><td class="wordbreak" colspan="2">'.$langs->trans("CompanyIds").'</td></tr>';
615
616$langs->load("companies");
617
618// Managing Director(s)
619print '<tr class="oddeven"><td class="titlefieldcreate smallheight"><label for="director">'.$langs->trans("ManagingDirectors").'</label></td><td>';
620print '<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>';
621
622// GDPR contact
623print '<tr class="oddeven"><td class="smallheight">';
624print $form->textwithpicto($langs->trans("GDPRContact"), $langs->trans("GDPRContactDesc"));
625print '</td><td>';
626print '<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>';
627
628// Capital
629print '<tr class="oddeven"><td><label for="capital">'.$langs->trans("Capital").'</label></td><td>';
630print '<input name="capital" id="capital" class="maxwidth100" value="'.dolPrintHTMLForAttribute((GETPOSTISSET('capital') ? GETPOST('capital', 'alphanohtml') : getDolGlobalString('MAIN_INFO_CAPITAL'))).'"></td></tr>';
631
632// Object of the company
633print '<tr class="oddeven"><td><label for="socialobject">'.$langs->trans("CompanyObject").'</label></td><td>';
634print '<textarea class="flat quatrevingtpercent" name="socialobject" id="socialobject" rows="'.ROWS_3.'">'.getDolGlobalString('MAIN_INFO_SOCIETE_OBJECT').'</textarea></td></tr>';
635print '</td></tr>';
636
637// Tax ID Intra-community VAT number
638print '<tr class="oddeven"><td><label for="intra_vat">'.$langs->trans("VATIntra").'</label></td><td>';
639print '<input name="tva" id="intra_vat" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_TVAINTRA')).'">';
640print '</td></tr>';
641
642// Juridical Status
643print '<tr class="oddeven"><td><label for="forme_juridique_code">'.$langs->trans("JuridicalStatus").'</label></td><td>';
644if ($mysoc->country_code) {
645 print $formcompany->select_juridicalstatus(getDolGlobalInt('MAIN_INFO_SOCIETE_FORME_JURIDIQUE'), $mysoc->country_code, '', 'forme_juridique_code');
646} else {
647 print $countrynotdefined;
648}
649print '</td></tr>';
650
651// ProfId1
652if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-') {
653 print '<tr class="oddeven"><td><label for="profid1">'.$langs->transcountry("ProfId1", $mysoc->country_code).'</label></td><td>';
654 if (!empty($mysoc->country_code)) {
655 print '<input name="siren" id="profid1" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_SIREN')).'">';
656 } else {
657 print $countrynotdefined;
658 }
659 print '</td></tr>';
660}
661
662// ProfId2
663if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-') {
664 print '<tr class="oddeven"><td><label for="profid2">'.$langs->transcountry("ProfId2", $mysoc->country_code).'</label></td><td>';
665 if (!empty($mysoc->country_code)) {
666 print '<input name="siret" id="profid2" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_SIRET')).'">';
667 } else {
668 print $countrynotdefined;
669 }
670 print '</td></tr>';
671}
672
673// ProfId3
674if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-') {
675 print '<tr class="oddeven"><td><label for="profid3">'.$langs->transcountry("ProfId3", $mysoc->country_code).'</label></td><td>';
676 if (!empty($mysoc->country_code)) {
677 print '<input name="ape" id="profid3" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_APE')).'">';
678 } else {
679 print $countrynotdefined;
680 }
681 print '</td></tr>';
682}
683
684// ProfId4
685if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-') {
686 print '<tr class="oddeven"><td><label for="profid4">'.$langs->transcountry("ProfId4", $mysoc->country_code).'</label></td><td>';
687 if (!empty($mysoc->country_code)) {
688 print '<input name="rcs" id="profid4" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_RCS')).'">';
689 } else {
690 print $countrynotdefined;
691 }
692 print '</td></tr>';
693}
694
695// ProfId5
696if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-') {
697 print '<tr class="oddeven"><td><label for="profid5">'.$langs->transcountry("ProfId5", $mysoc->country_code).'</label></td><td>';
698 if (!empty($mysoc->country_code)) {
699 print '<input name="MAIN_INFO_PROFID5" id="profid5" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_PROFID5')).'">';
700 } else {
701 print $countrynotdefined;
702 }
703 print '</td></tr>';
704}
705
706// ProfId6
707if ($langs->transcountry("ProfId6", $mysoc->country_code) != '-') {
708 print '<tr class="oddeven"><td><label for="profid6">'.$langs->transcountry("ProfId6", $mysoc->country_code).'</label></td><td>';
709 if (!empty($mysoc->country_code)) {
710 print '<input name="MAIN_INFO_PROFID6" id="profid6" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_PROFID6')).'">';
711 } else {
712 print $countrynotdefined;
713 }
714 print '</td></tr>';
715}
716
717// ProfId7
718if ($langs->transcountry("ProfId7", $mysoc->country_code) != '-') {
719 print '<tr class="oddeven"><td><label for="profid7">'.$langs->transcountry("ProfId7", $mysoc->country_code).'</label></td><td>';
720 if (!empty($mysoc->country_code)) {
721 print '<input name="MAIN_INFO_PROFID7" id="profid7" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_PROFID7')).'">';
722 } else {
723 print $countrynotdefined;
724 }
725 print '</td></tr>';
726}
727
728// ProfId8
729if ($langs->transcountry("ProfId8", $mysoc->country_code) != '-') {
730 print '<tr class="oddeven"><td><label for="profid8">'.$langs->transcountry("ProfId8", $mysoc->country_code).'</label></td><td>';
731 if (!empty($mysoc->country_code)) {
732 print '<input name="MAIN_INFO_PROFID8" id="profid8" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_PROFID8')).'">';
733 } else {
734 print $countrynotdefined;
735 }
736 print '</td></tr>';
737}
738
739// ProfId9
740if ($langs->transcountry("ProfId9", $mysoc->country_code) != '-') {
741 print '<tr class="oddeven"><td><label for="profid9">'.$langs->transcountry("ProfId9", $mysoc->country_code).'</label></td><td>';
742 if (!empty($mysoc->country_code)) {
743 print '<input name="MAIN_INFO_PROFID9" id="profid9" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_PROFID9')).'">';
744 } else {
745 print $countrynotdefined;
746 }
747 print '</td></tr>';
748}
749
750// ProfId10
751if ($langs->transcountry("ProfId10", $mysoc->country_code) != '-') {
752 print '<tr class="oddeven"><td><label for="profid10">'.$langs->transcountry("ProfId10", $mysoc->country_code).'</label></td><td>';
753 if (!empty($mysoc->country_code)) {
754 print '<input name="MAIN_INFO_PROFID10" id="profid10" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_PROFID10')).'">';
755 } else {
756 print $countrynotdefined;
757 }
758 print '</td></tr>';
759}
760
761print '</table>';
762print '</div>';
763
764
765// Fiscal year start
766print '<br>';
767print '<table class="noborder centpercent editmode">';
768print '<tr class="liste_titre">';
769print '<td class="titlefieldcreate">'.$langs->trans("FiscalYearInformation").'</td><td></td>';
770print "</tr>\n";
771
772print '<tr class="oddeven"><td><label for="SOCIETE_FISCAL_MONTH_START">'.$langs->trans("FiscalMonthStart").'</label></td><td>';
773print $formother->select_month(getDolGlobalString('SOCIETE_FISCAL_MONTH_START'), 'SOCIETE_FISCAL_MONTH_START', 0, 1, 'maxwidth100').'</td></tr>';
774
775print "</table>";
776
777print $form->buttonsSaveCancel("Save", '', array(), false, 'reposition');
778
779print '<br>';
780
781
782// Sales taxes (VAT, IRPF, ...)
783print load_fiche_titre($langs->trans("TypeOfSaleTaxes"), '', 'object_payment');
784
785print '<table class="noborder centpercent editmode">';
786print '<tr class="liste_titre">';
787print '<td class="titlefieldcreate">'.$langs->trans("VATManagement").'</td><td></td>';
788print '<td class="right">&nbsp;</td>';
789print "</tr>\n";
790
791// Main tax
792print '<tr class="oddeven"><td><label><input type="radio" name="optiontva" id="use_vat" value="1"'.(!getDolGlobalString('FACTURE_TVAOPTION') ? "" : " checked")."> ".$langs->trans("VATIsUsed")."</label></td>";
793print '<td colspan="2">';
794$tooltiphelp = $langs->trans("VATIsUsedDesc");
795if ($mysoc->country_code == 'FR') {
796 $tooltiphelp .= '<br><br><i>'.$langs->trans("Example").': '.$langs->trans("VATIsUsedExampleFR")."</i>";
797}
798print '<label for="use_vat">'.$form->textwithpicto($langs->trans("VATIsUsedStandard"), $tooltiphelp)."</label>";
799print "</td></tr>\n";
800
801
802print '<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>";
803print '<td colspan="2">';
804$tooltiphelp = '';
805if ($mysoc->country_code == 'FR') {
806 $tooltiphelp = "<i>".$langs->trans("Example").': '.$langs->trans("VATIsNotUsedExampleFR")."</i>\n";
807}
808print '<label for="no_vat">'.$form->textwithpicto($langs->trans("VATIsNotUsedDesc"), $tooltiphelp)."</label>";
809
810print '<div class="shownifvatnotused" id="vat_exemption_code_div"'.(getDolGlobalString('FACTURE_TVAOPTION') ? ' style="display: none;"' : '').'>';
811$placeholder = (($mysoc->country_code == 'FR') ? 'VATEX-FR-FRANCHISE' : '');
812$tooltiptext = $langs->trans("VATExemptionCodeDesc").'<br>'.$langs->trans("VATExemptionCodeDesc2").'<br>'.$langs->trans("VATExemptionCodeDesc3");
813if (($mysoc->country_code == 'FR')) {
814 $tooltiptext .= '<br><br>'.$langs->trans("Example").':<br>';
815 $tooltiptext .= 'VATEX-FR-FRANCHISE, VATEX-FR-CGI261-4, VATEX-FR-J, VATEX-FR-I, VATEX-FR-D, ...';
816}
817print $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').'">';
818print '</div>';
819
820print "</td></tr>\n";
821
822print "</table>";
823
824// Second tax
825print '<br>';
826print '<table class="noborder centpercent editmode">';
827print '<tr class="liste_titre">';
828print '<td class="titlefieldcreate">'.$form->textwithpicto($langs->transcountry("LocalTax1Management", $mysoc->country_code), $langs->transcountry("LocalTax1IsUsedDesc", $mysoc->country_code)).'</td><td></td>';
829print '<td class="right">&nbsp;</td>';
830print "</tr>\n";
831
832if ($mysoc->useLocalTax(1)) {
833 // Note: When option is not set, it must not appears as set on on, because there is no default value for this option
834 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>";
835 print '<td colspan="2">';
836 print '<div class="nobordernopadding">';
837 $tooltiphelp = $langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code);
838 $tooltiphelp = ($tooltiphelp != "LocalTax1IsUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code)."</i>\n" : "");
839 print $form->textwithpicto($langs->transcountry("LocalTax1IsUsedDesc", $mysoc->country_code), $tooltiphelp);
840 if (!isOnlyOneLocalTax(1)) {
841 print '<br><label for="lt1">'.$langs->trans("LTRate").'</label>: ';
842 $formcompany->select_localtax(1, getDolGlobalFloat('MAIN_INFO_VALUE_LOCALTAX1'), "lt1");
843 }
844
845 $options = array($langs->trans("CalcLocaltax1").' '.$langs->trans("CalcLocaltax1Desc"), $langs->trans("CalcLocaltax2").' - '.$langs->trans("CalcLocaltax2Desc"), $langs->trans("CalcLocaltax3").' - '.$langs->trans("CalcLocaltax3Desc"));
846
847 print '<br><label for="clt1">'.$langs->trans("CalcLocaltax").'</label>: ';
848 print $form->selectarray("clt1", $options, getDolGlobalString('MAIN_INFO_LOCALTAX_CALC1'));
849 print "</div>";
850 print "</td></tr>\n";
851
852 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>";
853 print '<td colspan="2">';
854 $tooltiphelp = $langs->transcountry("LocalTax1IsNotUsedExample", $mysoc->country_code);
855 $tooltiphelp = ($tooltiphelp != "LocalTax1IsNotUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsNotUsedExample", $mysoc->country_code)."</i>\n" : "");
856 print $form->textwithpicto($langs->transcountry("LocalTax1IsNotUsedDesc", $mysoc->country_code), $tooltiphelp);
857 print "</td></tr>\n";
858} else {
859 if (empty($mysoc->country_code)) {
860 print '<tr class="oddeven nohover"><td class="" colspan="3">'.$countrynotdefined.'</td></tr>';
861 } else {
862 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>';
863 }
864}
865
866print "</table>";
867
868// Third tax system
869print '<br>';
870print '<table class="noborder centpercent editmode">';
871print '<tr class="liste_titre">';
872print '<td class="titlefieldcreate">'.$form->textwithpicto($langs->transcountry("LocalTax2Management", $mysoc->country_code), $langs->transcountry("LocalTax2IsUsedDesc", $mysoc->country_code)).'</td><td></td>';
873print '<td class="right">&nbsp;</td>';
874print "</tr>\n";
875
876if ($mysoc->useLocalTax(2)) {
877 // Note: When option is not set, it must not appears as set on on, because there is no default value for this option
878 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>";
879 print '<td colspan="2">';
880 print '<div class="nobordernopadding">';
881 print '<label for="lt2">'.$langs->transcountry("LocalTax2IsUsedDesc", $mysoc->country_code)."</label>";
882 $tooltiphelp = $langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code);
883 $tooltiphelp = ($tooltiphelp != "LocalTax2IsUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code)."</i>\n" : "");
884 if (!isOnlyOneLocalTax(2)) {
885 print '<br><label for="lt2">'.$langs->trans("LTRate").'</label>: ';
886 $formcompany->select_localtax(2, getDolGlobalFloat('MAIN_INFO_VALUE_LOCALTAX2'), "lt2");
887 }
888
889 $options = array($langs->trans("CalcLocaltax1").' '.$langs->trans("CalcLocaltax1Desc"), $langs->trans("CalcLocaltax2").' - '.$langs->trans("CalcLocaltax2Desc"), $langs->trans("CalcLocaltax3").' - '.$langs->trans("CalcLocaltax3Desc"));
890
891 print '<br><label for="clt2">'.$langs->trans("CalcLocaltax").'</label>: ';
892 print $form->selectarray("clt2", $options, getDolGlobalString('MAIN_INFO_LOCALTAX_CALC2'));
893 print "</div>";
894 print "</td></tr>\n";
895
896 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>";
897 print '<td colspan="2">';
898 print "<div>";
899 $tooltiphelp = $langs->transcountry("LocalTax2IsNotUsedExample", $mysoc->country_code);
900 $tooltiphelp = ($tooltiphelp != "LocalTax2IsNotUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsNotUsedExample", $mysoc->country_code)."</i>\n" : "");
901 print "<label for=\"nolt2\">".$form->textwithpicto($langs->transcountry("LocalTax2IsNotUsedDesc", $mysoc->country_code), $tooltiphelp)."</label>";
902 print "</div>";
903 print "</td></tr>\n";
904} else {
905 if (empty($mysoc->country_code)) {
906 print '<tr class="oddeven nohover"><td class="" colspan="3">'.$countrynotdefined.'</td></tr>';
907 } else {
908 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>';
909 }
910}
911
912print "</table>";
913
914
915// Tax stamp
916print '<br>';
917print '<table class="noborder centpercent editmode">';
918print '<tr class="liste_titre">';
919print '<td>'.$form->textwithpicto($langs->trans("RevenueStamp"), $langs->trans("RevenueStampDesc")).'</td><td></td>';
920print '<td class="right">&nbsp;</td>';
921print "</tr>\n";
922if ($mysoc->useRevenueStamp()) {
923 // Note: When option is not set, it must not appears as set on on, because there is no default value for this option
924 print '<tr class="oddeven"><td>';
925 print $langs->trans("UseRevenueStamp");
926 print "</td>";
927 print '<td colspan="2">';
928 print $langs->trans("UseRevenueStampExample", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryRevenueStamp"));
929 print "</td></tr>\n";
930} else {
931 if (empty($mysoc->country_code)) {
932 print '<tr class="oddeven nohover"><td class="" colspan="3">'.$countrynotdefined.'</td></tr>';
933 } else {
934 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>';
935 }
936}
937
938print "</table>";
939
940// AADE webservices credentials, applicable only for Greece
941if ($mysoc->country_code == 'GR') {
942 print load_fiche_titre($langs->trans("AADEWebserviceCredentials"), '', '');
943 print '<table class="noborder centpercent editmode">';
944 print '<tr class="liste_titre">';
945 print '<td>'.$langs->trans("AccountParameter").'</td>';
946 print '<td></td>';
947 print '<td></td>';
948 print "</tr>\n";
949
950 print '<tr class="oddeven"><td>';
951 print '<span class="titlefield fieldrequired">'.$langs->trans("MYDATA_AADE_USER").'</span></td><td>';
952 print '<input class="minwidth300" type="text" name="MYDATA_AADE_USER" value="'.getDolGlobalString('MYDATA_AADE_USER').'"';
953 print '</td><td></td></tr>';
954
955 print '<tr class="oddeven"><td>';
956 print '<span class="titlefield fieldrequired">'.$langs->trans("MYDATA_AADE_KEY").'</span></td><td>';
957 print '<input class="minwidth300" type="password" name="MYDATA_AADE_KEY" value="'.getDolGlobalString('MYDATA_AADE_KEY').'"';
958 print '</td><td></td></tr>';
959
960 print '<tr class="oddeven"><td>';
961 print '<span class="titlefield fieldrequired">'.$langs->trans("AADE_WEBSERVICE_USER").'</span></td><td>';
962 print '<input class="minwidth300" type="text" name="AADE_WEBSERVICE_USER" value="'.getDolGlobalString('AADE_WEBSERVICE_USER').'"';
963 print '</td><td></td></tr>';
964
965 print '<tr class="oddeven"><td>';
966 print '<span class="titlefield fieldrequired">'.$langs->trans("AADE_WEBSERVICE_KEY").'</span></td><td>';
967 print '<input class="minwidth300" type="password" name="AADE_WEBSERVICE_KEY" value="'.getDolGlobalString('AADE_WEBSERVICE_KEY').'"';
968 print '</td><td></td></tr>';
969
970 print '<br>';
971
972 print "</table>";
973}
974
975print $form->buttonsSaveCancel("Save", '', array(), false, 'reposition');
976
977print '</form>';
978
979
980// End of page
981llxFooter();
982$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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
getDolCurrency()
Return the main currency ('EUR', 'USD', ...)
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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)
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)
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:519
dolPrintHTMLForAttribute($s, $escapeonlyhtmltags=0, $allowothertags=array())
Return a string ready to be output into an HTML attribute (alt, title, data-html, ....
Definition html.lib.php:99
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='', $cssfordropdown='info_admin')
Show information in HTML for admin users or standard users.
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.