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-2026 Nick Fragoulis
10 * Copyright (C) 2024-2026 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 (!is_numeric($result)) { // $result is a translation key
218 $error++;
219 $langs->load("errors");
220 setEventMessages($langs->trans($result), null, 'errors');
221 } else {
222 $error++;
223 setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors');
224 }
225 } else {
226 $error++;
227 $langs->load("errors");
228 setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors');
229 }
230 }
231 /*}*/
232 }
233
234 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MANAGERS", GETPOST("MAIN_INFO_SOCIETE_MANAGERS", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
235 dolibarr_set_const($db, "MAIN_INFO_GDPR", GETPOST("MAIN_INFO_GDPR", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
236 dolibarr_set_const($db, "MAIN_INFO_CAPITAL", GETPOST("capital", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
237 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FORME_JURIDIQUE", GETPOST("forme_juridique_code", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
238 dolibarr_set_const($db, "MAIN_INFO_SIREN", GETPOST("siren", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
239 dolibarr_set_const($db, "MAIN_INFO_SIRET", GETPOST("siret", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
240 dolibarr_set_const($db, "MAIN_INFO_APE", GETPOST("ape", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
241 dolibarr_set_const($db, "MAIN_INFO_RCS", GETPOST("rcs", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
242 dolibarr_set_const($db, "MAIN_INFO_PROFID5", GETPOST("MAIN_INFO_PROFID5", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
243 dolibarr_set_const($db, "MAIN_INFO_PROFID6", GETPOST("MAIN_INFO_PROFID6", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
244 dolibarr_set_const($db, "MAIN_INFO_PROFID7", GETPOST("MAIN_INFO_PROFID7", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
245 dolibarr_set_const($db, "MAIN_INFO_PROFID8", GETPOST("MAIN_INFO_PROFID8", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
246 dolibarr_set_const($db, "MAIN_INFO_PROFID9", GETPOST("MAIN_INFO_PROFID9", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
247 dolibarr_set_const($db, "MAIN_INFO_PROFID10", GETPOST("MAIN_INFO_PROFID10", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
248
249 dolibarr_set_const($db, "MAIN_INFO_TVAINTRA", GETPOST("tva", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
250 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_OBJECT", GETPOST("socialobject", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
251
252 // Payment identifier used when the reference mode is one reference for the company.
253 // It is printed on every invoice, so a greek reference that checks one fixed amount
254 // is refused, the bank would reject most payments.
255 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions_gr.lib.php';
256 $companypaymentid = GETPOST("MAIN_INFO_SOCIETE_PAYMENT_ID", 'alphanohtml');
257 if ($mysoc->country_code == 'GR' && dolGRIsAmountCheckedReference($companypaymentid)) {
258 setEventMessages($langs->trans("ErrorDIASReferenceAmountChecked"), null, 'errors');
259 } else {
260 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_PAYMENT_ID", $companypaymentid, 'chaine', 0, '', $conf->entity);
261 }
262
263 // DIAS merchant code, greek companies only. It is assigned by the bank and a wrong
264 // value would route payments to another creditor, so refuse anything but 9nnnn.
265 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions_gr.lib.php';
266 $diascode = preg_replace('/[^0-9]/', '', GETPOST("MAIN_INFO_SOCIETE_DIAS_CODE", 'alphanohtml'));
267 if ($diascode == '' || dolGRIsValidDiasCode($diascode)) {
268 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_DIAS_CODE", $diascode, 'chaine', 0, '', $conf->entity);
269 } else {
270 setEventMessages($langs->trans("ErrorDIASCodeMustBe5Digits"), null, 'errors');
271 }
272
273 // DIAS code usage digit, position 10 of a greek reference
274 if (GETPOSTISSET("MAIN_INFO_SOCIETE_DIAS_CODE_USAGE")) {
275 $diasusage = GETPOST("MAIN_INFO_SOCIETE_DIAS_CODE_USAGE", 'aZ09');
276 if (!in_array($diasusage, array('8', '9'), true)) {
277 $diasusage = '8';
278 }
279 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_DIAS_CODE_USAGE", $diasusage, 'chaine', 0, '', $conf->entity);
280 }
281
282 dolibarr_set_const($db, "SOCIETE_FISCAL_MONTH_START", GETPOSTINT("SOCIETE_FISCAL_MONTH_START"), 'chaine', 0, '', $conf->entity);
283
284 // Sale tax options
285 $usevat = GETPOST("optiontva", 'aZ09');
286 $uselocaltax1 = GETPOST("optionlocaltax1", 'aZ09');
287 $uselocaltax2 = GETPOST("optionlocaltax2", 'aZ09');
288 if ($uselocaltax1 == 'localtax1on' && !$usevat) {
289 setEventMessages($langs->trans("IfYouUseASecondTaxYouMustSetYouUseTheMainTax"), null, 'errors');
290 $error++;
291 }
292 if ($uselocaltax2 == 'localtax2on' && !$usevat) {
293 setEventMessages($langs->trans("IfYouUseAThirdTaxYouMustSetYouUseTheMainTax"), null, 'errors');
294 $error++;
295 }
296
297 dolibarr_set_const($db, "FACTURE_TVAOPTION", $usevat, 'chaine', 0, '', $conf->entity);
298
299 dolibarr_set_const($db, "MAIN_INFO_SOCIETE_VAT_EXEMPTION_CODE", GETPOST('MAIN_INFO_SOCIETE_VAT_EXEMPTION_CODE'), 'chaine', 0, '', $conf->entity);
300
301 dolibarr_set_const($db, "FACTURE_LOCAL_TAX1_OPTION", $uselocaltax1, 'chaine', 0, '', $conf->entity);
302 dolibarr_set_const($db, "FACTURE_LOCAL_TAX2_OPTION", $uselocaltax2, 'chaine', 0, '', $conf->entity);
303
304 if (GETPOST("optionlocaltax1") == "localtax1on") {
305 if (!GETPOSTISSET('lt1')) {
306 dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX1", 0, 'chaine', 0, '', $conf->entity);
307 } else {
308 dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX1", GETPOST('lt1', 'aZ09'), 'chaine', 0, '', $conf->entity);
309 }
310 dolibarr_set_const($db, "MAIN_INFO_LOCALTAX_CALC1", GETPOST("clt1", 'aZ09'), 'chaine', 0, '', $conf->entity);
311 }
312 if (GETPOST("optionlocaltax2") == "localtax2on") {
313 if (!GETPOSTISSET('lt2')) {
314 dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX2", 0, 'chaine', 0, '', $conf->entity);
315 } else {
316 dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX2", GETPOST('lt2', 'aZ09'), 'chaine', 0, '', $conf->entity);
317 }
318 dolibarr_set_const($db, "MAIN_INFO_LOCALTAX_CALC2", GETPOST("clt2", 'aZ09'), 'chaine', 0, '', $conf->entity);
319 }
320
321 // Credentials for AADE webservices, applicable only for Greece
322 if ($mysoc->country_code == 'GR') {
323 dolibarr_set_const($db, "MYDATA_AADE_USER", GETPOST("MYDATA_AADE_USER", 'alpha'), 'chaine', 0, '', $conf->entity);
324 dolibarr_set_const($db, "MYDATA_AADE_KEY", GETPOST("MYDATA_AADE_KEY", 'alpha'), 'chaine', 0, '', $conf->entity);
325 dolibarr_set_const($db, "AADE_WEBSERVICE_USER", GETPOST("AADE_WEBSERVICE_USER", 'alpha'), 'chaine', 0, '', $conf->entity);
326 dolibarr_set_const($db, "AADE_WEBSERVICE_KEY", GETPOST("AADE_WEBSERVICE_KEY", 'alpha'), 'chaine', 0, '', $conf->entity);
327 }
328
329 // Remove constant MAIN_INFO_SOCIETE_SETUP_TODO_WARNING
330 dolibarr_del_const($db, "MAIN_INFO_SOCIETE_SETUP_TODO_WARNING", $conf->entity);
331
332 if (!$error) {
333 if (GETPOST('save')) { // To avoid to show message when we juste switch the country that resubmit the form.
334 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
335 }
336 $db->commit();
337 } else {
338 $db->rollback();
339 }
340
341 if ($action != 'updateedit' && !$error) {
342 header("Location: ".$_SERVER["PHP_SELF"].($page_y ? '?page_y='.$page_y : ''));
343 exit;
344 }
345}
346
347if ($action == 'addthumb' || $action == 'addthumbsquarred') { // Regenerate thumbs
348 if (file_exists($conf->mycompany->dir_output.'/logos/'.GETPOST("file"))) {
349 $isimage = image_format_supported(GETPOST("file"));
350
351 // Create thumbs of logo
352 if ($isimage > 0) {
353 $constant = "MAIN_INFO_SOCIETE_LOGO";
354 if ($action == 'addthumbsquarred') {
355 $constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED";
356 }
357
358 $reg = array();
359
360 // Create thumbs
361 //$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...
362
363 // Create small thumb. Used on logon for example
364 $imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.GETPOST("file"), $maxwidthsmall, $maxheightsmall, '_small', $quality);
365 if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg)) {
366 $imgThumbSmall = $reg[1]; // Save only basename
367 dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity);
368 } else {
369 dol_syslog($imgThumbSmall);
370 }
371
372 // Create mini thumbs. Used on menu or for setup page for example
373 $imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.GETPOST("file"), $maxwidthmini, $maxheightmini, '_mini', $quality);
374 if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg)) {
375 $imgThumbMini = $reg[1]; // Save only basename
376 dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity);
377 } else {
378 dol_syslog($imgThumbMini);
379 }
380
381 header("Location: ".$_SERVER["PHP_SELF"]);
382 exit;
383 } else {
384 $error++;
385 $langs->load("errors");
386 setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors');
387 dol_syslog($langs->transnoentities("ErrorBadImageFormat"), LOG_INFO);
388 }
389 } else {
390 $error++;
391 $langs->load("errors");
392 setEventMessages($langs->trans("ErrorFileDoesNotExists", GETPOST("file")), null, 'errors');
393 dol_syslog($langs->transnoentities("ErrorFileDoesNotExists", GETPOST("file")), LOG_WARNING);
394 }
395}
396
397
398if ($action == 'removelogo' || $action == 'removelogo_squarred') {
399 $constant = "MAIN_INFO_SOCIETE_LOGO";
400 if ($action == 'removelogo_squarred') {
401 $constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED";
402 }
403
404 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
405
406 $logofilename = $mysoc->logo;
407 $logofilenamebis = $mysoc->logo_squarred;
408 if ($action == 'removelogo_squarred') {
409 $logofilename = $mysoc->logo_squarred;
410 $logofilenamebis = $mysoc->logo;
411 }
412
413 $logofile = $conf->mycompany->dir_output.'/logos/'.$logofilename;
414 if ($logofilename != '' && $logofilename != $logofilenamebis) {
415 dol_delete_file($logofile);
416 }
417 dolibarr_del_const($db, $constant, $conf->entity);
418 if ($action == 'removelogo_squarred') {
419 $mysoc->logo_squarred = '';
420 } else {
421 $mysoc->logo = '';
422 }
423
424 $logofilename = $mysoc->logo_small;
425 $logofilenamebis = $mysoc->logo_squarred_small;
426 if ($action == 'removelogo_squarred') {
427 $logofilename = $mysoc->logo_squarred_small;
428 $logofilenamebis = $mysoc->logo_small;
429 }
430
431 $logosmallfile = $conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename;
432 if ($logofilename != '' && $logofilename != $logofilenamebis) {
433 dol_delete_file($logosmallfile);
434 }
435 dolibarr_del_const($db, $constant."_SMALL", $conf->entity);
436 if ($action == 'removelogo_squarred') {
437 $mysoc->logo_squarred_small = '';
438 } else {
439 $mysoc->logo_small = '';
440 }
441
442 $logofilename = $mysoc->logo_mini;
443 $logofilenamebis = $mysoc->logo_squarred_mini;
444 if ($action == 'removelogo_squarred') {
445 $logofilename = $mysoc->logo_squarred_mini;
446 $logofilenamebis = $mysoc->logo_mini;
447 }
448
449 $logominifile = $conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename;
450 if ($logofilename != '' && $logofilename != $logofilenamebis) {
451 dol_delete_file($logominifile);
452 }
453 dolibarr_del_const($db, $constant."_MINI", $conf->entity);
454 if ($action == 'removelogo_squarred') {
455 $mysoc->logo_squarred_mini = '';
456 } else {
457 $mysoc->logo_mini = '';
458 }
459}
460
461
462/*
463 * View
464 */
465
466$wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
467llxHeader('', $langs->trans("Setup"), $wikihelp, '', 0, 0, '', '', '', 'mod-admin page-company');
468
469$form = new Form($db);
470$formother = new FormOther($db);
471$formcompany = new FormCompany($db);
472$formfile = new FormFile($db);
473
474$countrynotdefined = '<span class="error">'.$langs->trans("ErrorSetACountryFirst").' <a href="" onclick="window.scrollTo({top: 0, behavior: \'smooth\'}); return false;">('.$langs->trans("SeeAbove").')</a></span>';
475
476print load_fiche_titre($langs->trans("CompanyFoundation"), '', 'title_setup');
477
479
480print dol_get_fiche_head($head, 'company', '', -1, '');
481
482print '<div class="'.($setupcompanynotcomplete ? 'warning' : 'info').'">'.$langs->trans("CompanyFundationDesc", $langs->transnoentities("Save"))."</div>\n";
483print "<br>\n";
484
485
486// Edit parameters
487
488if (!empty($conf->use_javascript_ajax)) {
489 print "\n".'<script type="text/javascript">';
490 print '$(document).ready(function () {
491 $("#selectcountry_id").change(function() {
492 console.log("selectcountry_id change");
493 document.form_index.action.value="updateedit";
494 document.form_index.submit();
495 });
496
497 // Show/hide VAT exemption code field based on VAT option
498 $("input[name=\"optiontva\"]").change(function() {
499 if ($(this).val() == "0") {
500 $("#vat_exemption_code_div").show();
501 } else {
502 $("#vat_exemption_code_div").hide();
503 }
504 });
505 });';
506 print '</script>'."\n";
507}
508
509print '<form enctype="multipart/form-data" method="POST" action="'.$_SERVER["PHP_SELF"].'" name="form_index" spellcheck="false">';
510print '<input type="hidden" name="token" value="'.newToken().'">';
511print '<input type="hidden" name="action" value="update">';
512print '<input type="hidden" name="page_y" value="">';
513
514print '<table class="noborder centpercent editmode">';
515print '<tr class="liste_titre"><th class="wordbreak" colspan="2">'.$langs->trans("CompanyInfo").'</th></tr>'."\n";
516
517// Company name
518print '<tr class="oddeven"><td class="fieldrequired titlefieldcreate wordbreak"><label for="name">'.$langs->trans("CompanyName").'</label></td><td>';
519print '<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";
520
521// Main currency
522print '<tr class="oddeven"><td class="fieldrequired"><label for="currency">'.$langs->trans("CompanyCurrency").'</label></td><td>';
523print img_picto('', 'multicurrency', 'class="pictofixedwidth"');
524print $form->selectCurrency(getDolCurrency(), "currency", 2);
525print '</td></tr>'."\n";
526
527// Country
528print '<tr class="oddeven"><td class="fieldrequired"><label for="selectcountry_id">'.$langs->trans("Country").'</label></td><td>';
529print img_picto('', 'globe-americas', 'class="pictofixedwidth"');
530print $form->select_country((string) $mysoc->country_id, 'country_id', '', 0);
531print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
532print '</td></tr>'."\n";
533
534// Address
535print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_ADDRESS">'.$langs->trans("CompanyAddress").'</label></td><td>';
536print '<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";
537
538// Zip
539print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_ZIP">'.$langs->trans("CompanyZip").'</label></td><td>';
540print '<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";
541
542print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_TOWN">'.$langs->trans("CompanyTown").'</label></td><td>';
543print '<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";
544
545// State
546print '<tr class="oddeven"><td class="wordbreak"><label for="state_id">'.$langs->trans("State").'</label></td><td>';
547$state_id = 0;
548if (getDolGlobalString('MAIN_INFO_SOCIETE_STATE')) {
549 $tmp = explode(':', getDolGlobalString('MAIN_INFO_SOCIETE_STATE'));
550 $state_id = $tmp[0];
551}
552print img_picto('', 'state', 'class="pictofixedwidth"');
553print $formcompany->select_state($state_id, $mysoc->country_code, 'state_id', 'maxwidth200onsmartphone minwidth300');
554print '</td></tr>'."\n";
555
556// Phone
557print '<tr class="oddeven"><td><label for="phone">'.$langs->trans("Phone").'</label></td><td>';
558print $form->showPhoneInput(getDolGlobalString('MAIN_INFO_SOCIETE_TEL'), 'phone', $mysoc->country_id, 'object_phoning', 'maxwidth150 widthcentpercentminusx');
559print '</td></tr>';
560print '</td></tr>'."\n";
561
562// Phone mobile
563print '<tr class="oddeven"><td><label for="phone">'.$langs->trans("PhoneMobile").'</label></td><td>';
564print $form->showPhoneInput(getDolGlobalString('MAIN_INFO_SOCIETE_MOBILE'), 'phone_mobile', $mysoc->country_id, 'object_phoning_mobile', 'maxwidth150 widthcentpercentminusx');
565print '</td></tr>';
566print '</td></tr>'."\n";
567
568// Fax
569print '<tr class="oddeven"><td><label for="fax">'.$langs->trans("Fax").'</label></td><td>';
570print $form->showPhoneInput(getDolGlobalString('MAIN_INFO_SOCIETE_FAX'), 'fax', $mysoc->country_id, 'object_phoning_fax', 'maxwidth150 widthcentpercentminusx');
571print '</td></tr>';
572print '</td></tr>'."\n";
573
574// Email
575print '<tr class="oddeven"><td><label for="email">'.$langs->trans("EMail").'</label></td><td>';
576print img_picto('', 'object_email', '', 0, 0, 0, '', 'pictofixedwidth');
577print '<input class="minwidth300 maxwidth500 widthcentpercentminusx" name="mail" id="email" value="'.dolPrintHTMLForAttribute((GETPOSTISSET('mail') ? GETPOST('mail', 'alphanohtml') : getDolGlobalString('MAIN_INFO_SOCIETE_MAIL'))).'"></td></tr>';
578print '</td></tr>'."\n";
579
580// Web
581print '<tr class="oddeven"><td><label for="web">'.$langs->trans("Web").'</label></td><td>';
582print img_picto('', 'globe', '', 0, 0, 0, '', 'pictofixedwidth');
583print '<input class="maxwidth300 widthcentpercentminusx" name="web" id="web" value="'.dol_escape_htmltag((GETPOSTISSET('web') ? GETPOST('web', 'alphanohtml') : getDolGlobalString('MAIN_INFO_SOCIETE_WEB'))).'"></td></tr>';
584print '</td></tr>'."\n";
585
586// Barcode
587if (isModEnabled('barcode')) {
588 print '<tr class="oddeven"><td>';
589 print '<label for="barcode">'.$langs->trans("Gencod").'</label></td><td>';
590 print '<span class="fa fa-barcode pictofixedwidth"></span>';
591 print '<input name="barcode" id="barcode" class="minwidth150 widthcentpercentminusx maxwidth300" value="'.dolPrintHTMLForAttribute(GETPOSTISSET('barcode') ? GETPOST('barcode', 'alphanohtml') : getDolGlobalString('MAIN_INFO_SOCIETE_GENCOD')).'"></td></tr>';
592 print '</td></tr>';
593}
594
595// Tooltip for both Logo and LogSquarred
596$maxfilesizearray = getMaxFileSizeArray();
597$maxmin = $maxfilesizearray['maxmin'];
598$tooltiplogo = $langs->trans('AvailableFormats').' : png, jpg, jpeg';
599$tooltiplogo .= ($maxmin > 0) ? '<br>'.$langs->trans('MaxSize').' : '.$maxmin.' '.$langs->trans('Kb') : '';
600
601// Logo
602print '<tr class="oddeven"><td><label for="logo">'.$form->textwithpicto($langs->trans("Logo"), $tooltiplogo).'</label></td><td>';
603
604$modulepart = 'mycompany';
605$dirformainimage = $conf->mycompany->dir_output;
606$subdirformainimage = 'logos/';
607$fileformainimage = $mysoc->logo;
608
609print $formfile->showImageToEdit('logo', $modulepart, $dirformainimage, $subdirformainimage, $fileformainimage);
610
611print '</td></tr>';
612
613// Logo (squarred)
614print '<tr class="oddeven"><td><label for="logo_squarred">'.$form->textwithpicto($langs->trans("LogoSquarred"), $tooltiplogo).'</label></td><td>';
615
616$modulepart = 'mycompany';
617$dirformainimage = $conf->mycompany->dir_output;
618$subdirformainimage = 'logos/';
619$fileformainimage = $mysoc->logo_squarred;
620
621print $formfile->showImageToEdit('logo_squarred', $modulepart, $dirformainimage, $subdirformainimage, $fileformainimage);
622
623print '</td></tr>';
624
625// Note
626print '<tr class="oddeven"><td class="tdtop"><label for="note">'.$langs->trans("Note").'</label></td><td>';
627print '<textarea class="flat quatrevingtpercent" name="note" id="note" rows="'.ROWS_5.'">'.(GETPOSTISSET('note') ? GETPOST('note', 'restricthtml') : getDolGlobalString('MAIN_INFO_SOCIETE_NOTE')).'</textarea></td></tr>';
628print '</td></tr>';
629
630print '</table>';
631
632print $form->buttonsSaveCancel("Save", '', array(), false, 'reposition');
633
634print '<br><br>';
635
636
637// IDs of the company (country-specific)
638print '<div class="div-table-responsive-no-min">';
639print '<table class="noborder centpercent editmode">';
640print '<tr class="liste_titre"><td class="wordbreak" colspan="2">'.$langs->trans("CompanyIds").'</td></tr>';
641
642$langs->load("companies");
643
644// Managing Director(s)
645print '<tr class="oddeven"><td class="titlefieldcreate smallheight"><label for="director">'.$langs->trans("ManagingDirectors").'</label></td><td>';
646print '<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>';
647
648// GDPR contact
649print '<tr class="oddeven"><td class="smallheight">';
650print $form->textwithpicto($langs->trans("GDPRContact"), $langs->trans("GDPRContactDesc"));
651print '</td><td>';
652print '<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>';
653
654// Capital
655print '<tr class="oddeven"><td><label for="capital">'.$langs->trans("Capital").'</label></td><td>';
656print '<input name="capital" id="capital" class="maxwidth100" value="'.dolPrintHTMLForAttribute((GETPOSTISSET('capital') ? GETPOST('capital', 'alphanohtml') : getDolGlobalString('MAIN_INFO_CAPITAL'))).'"></td></tr>';
657
658// Object of the company
659print '<tr class="oddeven"><td><label for="socialobject">'.$langs->trans("CompanyObject").'</label></td><td>';
660print '<textarea class="flat quatrevingtpercent" name="socialobject" id="socialobject" rows="'.ROWS_3.'">'.getDolGlobalString('MAIN_INFO_SOCIETE_OBJECT').'</textarea></td></tr>';
661
662// Payment identifier used to build the company wide payment reference
663print '<tr class="oddeven"><td>'.$form->textwithpicto($langs->trans("PaymentRefCompanyPaymentId"), $langs->trans("PaymentRefCompanyPaymentIdHelp")).'</td><td>';
664print '<input name="MAIN_INFO_SOCIETE_PAYMENT_ID" id="payment_id" class="minwidth250" maxlength="25" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_SOCIETE_PAYMENT_ID')).'">';
665print '</td></tr>';
666
667// DIAS merchant code, greek companies only
668if ($mysoc->country_code == 'GR') {
669 print '<tr class="oddeven"><td>'.$form->textwithpicto($langs->trans("DIASCode"), $langs->trans("DIASCodeHelp")).'</td><td>';
670 print '<input name="MAIN_INFO_SOCIETE_DIAS_CODE" id="dias_code" class="minwidth100" maxlength="5" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_SOCIETE_DIAS_CODE')).'">';
671 print ' <span class="opacitymedium">'.$langs->trans("DIASCodeExample").'</span>';
672 print '</td></tr>';
673
674 print '<tr class="oddeven"><td>'.$form->textwithpicto($langs->trans("DIASCodeUsage"), $langs->trans("DIASCodeUsageHelp")).'</td><td>';
675 $arraydiasusage = array(
676 '8' => $langs->trans("DIASCodeUsage8"),
677 '9' => $langs->trans("DIASCodeUsage9"),
678 );
679 print $form->selectarray("MAIN_INFO_SOCIETE_DIAS_CODE_USAGE", $arraydiasusage, getDolGlobalString('MAIN_INFO_SOCIETE_DIAS_CODE_USAGE', '8'), 0, 0, 0, '', 0, 0, 0, '', 'minwidth200');
680 print '</td></tr>';
681}
682print '</td></tr>';
683
684// Tax ID Intra-community VAT number
685print '<tr class="oddeven"><td><label for="intra_vat">'.$langs->trans("VATIntra").'</label></td><td>';
686print '<input name="tva" id="intra_vat" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_TVAINTRA')).'">';
687print '</td></tr>';
688
689// Juridical Status
690print '<tr class="oddeven"><td><label for="forme_juridique_code">'.$langs->trans("JuridicalStatus").'</label></td><td>';
691if ($mysoc->country_code) {
692 print $formcompany->select_juridicalstatus(getDolGlobalInt('MAIN_INFO_SOCIETE_FORME_JURIDIQUE'), $mysoc->country_code, '', 'forme_juridique_code');
693} else {
694 print $countrynotdefined;
695}
696print '</td></tr>';
697
698// ProfId1
699if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-') {
700 print '<tr class="oddeven"><td><label for="profid1">'.$langs->transcountry("ProfId1", $mysoc->country_code).'</label></td><td>';
701 if (!empty($mysoc->country_code)) {
702 print '<input name="siren" id="profid1" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_SIREN')).'">';
703 } else {
704 print $countrynotdefined;
705 }
706 print '</td></tr>';
707}
708
709// ProfId2
710if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-') {
711 print '<tr class="oddeven"><td><label for="profid2">'.$langs->transcountry("ProfId2", $mysoc->country_code).'</label></td><td>';
712 if (!empty($mysoc->country_code)) {
713 print '<input name="siret" id="profid2" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_SIRET')).'">';
714 } else {
715 print $countrynotdefined;
716 }
717 print '</td></tr>';
718}
719
720// ProfId3
721if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-') {
722 print '<tr class="oddeven"><td><label for="profid3">'.$langs->transcountry("ProfId3", $mysoc->country_code).'</label></td><td>';
723 if (!empty($mysoc->country_code)) {
724 print '<input name="ape" id="profid3" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_APE')).'">';
725 } else {
726 print $countrynotdefined;
727 }
728 print '</td></tr>';
729}
730
731// ProfId4
732if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-') {
733 print '<tr class="oddeven"><td><label for="profid4">'.$langs->transcountry("ProfId4", $mysoc->country_code).'</label></td><td>';
734 if (!empty($mysoc->country_code)) {
735 print '<input name="rcs" id="profid4" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_RCS')).'">';
736 } else {
737 print $countrynotdefined;
738 }
739 print '</td></tr>';
740}
741
742// ProfId5
743if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-') {
744 print '<tr class="oddeven"><td><label for="profid5">'.$langs->transcountry("ProfId5", $mysoc->country_code).'</label></td><td>';
745 if (!empty($mysoc->country_code)) {
746 print '<input name="MAIN_INFO_PROFID5" id="profid5" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_PROFID5')).'">';
747 } else {
748 print $countrynotdefined;
749 }
750 print '</td></tr>';
751}
752
753// ProfId6
754if ($langs->transcountry("ProfId6", $mysoc->country_code) != '-') {
755 print '<tr class="oddeven"><td><label for="profid6">'.$langs->transcountry("ProfId6", $mysoc->country_code).'</label></td><td>';
756 if (!empty($mysoc->country_code)) {
757 print '<input name="MAIN_INFO_PROFID6" id="profid6" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_PROFID6')).'">';
758 } else {
759 print $countrynotdefined;
760 }
761 print '</td></tr>';
762}
763
764// ProfId7
765if ($langs->transcountry("ProfId7", $mysoc->country_code) != '-') {
766 print '<tr class="oddeven"><td><label for="profid7">'.$langs->transcountry("ProfId7", $mysoc->country_code).'</label></td><td>';
767 if (!empty($mysoc->country_code)) {
768 print '<input name="MAIN_INFO_PROFID7" id="profid7" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_PROFID7')).'">';
769 } else {
770 print $countrynotdefined;
771 }
772 print '</td></tr>';
773}
774
775// ProfId8
776if ($langs->transcountry("ProfId8", $mysoc->country_code) != '-') {
777 print '<tr class="oddeven"><td><label for="profid8">'.$langs->transcountry("ProfId8", $mysoc->country_code).'</label></td><td>';
778 if (!empty($mysoc->country_code)) {
779 print '<input name="MAIN_INFO_PROFID8" id="profid8" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_PROFID8')).'">';
780 } else {
781 print $countrynotdefined;
782 }
783 print '</td></tr>';
784}
785
786// ProfId9
787if ($langs->transcountry("ProfId9", $mysoc->country_code) != '-') {
788 print '<tr class="oddeven"><td><label for="profid9">'.$langs->transcountry("ProfId9", $mysoc->country_code).'</label></td><td>';
789 if (!empty($mysoc->country_code)) {
790 print '<input name="MAIN_INFO_PROFID9" id="profid9" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_PROFID9')).'">';
791 } else {
792 print $countrynotdefined;
793 }
794 print '</td></tr>';
795}
796
797// ProfId10
798if ($langs->transcountry("ProfId10", $mysoc->country_code) != '-') {
799 print '<tr class="oddeven"><td><label for="profid10">'.$langs->transcountry("ProfId10", $mysoc->country_code).'</label></td><td>';
800 if (!empty($mysoc->country_code)) {
801 print '<input name="MAIN_INFO_PROFID10" id="profid10" class="minwidth200" value="'.dolPrintHTMLForAttribute(getDolGlobalString('MAIN_INFO_PROFID10')).'">';
802 } else {
803 print $countrynotdefined;
804 }
805 print '</td></tr>';
806}
807
808print '</table>';
809print '</div>';
810
811
812// Fiscal year start
813print '<br>';
814print '<table class="noborder centpercent editmode">';
815print '<tr class="liste_titre">';
816print '<td class="titlefieldcreate">'.$langs->trans("FiscalYearInformation").'</td><td></td>';
817print "</tr>\n";
818
819print '<tr class="oddeven"><td><label for="SOCIETE_FISCAL_MONTH_START">'.$langs->trans("FiscalMonthStart").'</label></td><td>';
820print $formother->select_month(getDolGlobalString('SOCIETE_FISCAL_MONTH_START'), 'SOCIETE_FISCAL_MONTH_START', 0, 1, 'maxwidth100').'</td></tr>';
821
822print "</table>";
823
824print $form->buttonsSaveCancel("Save", '', array(), false, 'reposition');
825
826print '<br>';
827
828
829// Sales taxes (VAT, IRPF, ...)
830print load_fiche_titre($langs->trans("TypeOfSaleTaxes"), '', 'object_payment');
831
832print '<table class="noborder centpercent editmode">';
833print '<tr class="liste_titre">';
834print '<td class="titlefieldcreate">'.$langs->trans("VATManagement").'</td><td></td>';
835print '<td class="right">&nbsp;</td>';
836print "</tr>\n";
837
838// Main tax
839print '<tr class="oddeven"><td><label><input type="radio" name="optiontva" id="use_vat" value="1"'.(!getDolGlobalString('FACTURE_TVAOPTION') ? "" : " checked")."> ".$langs->trans("VATIsUsed")."</label></td>";
840print '<td colspan="2">';
841$tooltiphelp = $langs->trans("VATIsUsedDesc");
842if ($mysoc->country_code == 'FR') {
843 $tooltiphelp .= '<br><br><i>'.$langs->trans("Example").': '.$langs->trans("VATIsUsedExampleFR")."</i>";
844}
845print '<label for="use_vat">'.$form->textwithpicto($langs->trans("VATIsUsedStandard"), $tooltiphelp)."</label>";
846print "</td></tr>\n";
847
848
849print '<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>";
850print '<td colspan="2">';
851$tooltiphelp = '';
852if ($mysoc->country_code == 'FR') {
853 $tooltiphelp = "<i>".$langs->trans("Example").': '.$langs->trans("VATIsNotUsedExampleFR")."</i>\n";
854}
855print '<label for="no_vat">'.$form->textwithpicto($langs->trans("VATIsNotUsedDesc"), $tooltiphelp)."</label>";
856
857print '<div class="shownifvatnotused" id="vat_exemption_code_div"'.(getDolGlobalString('FACTURE_TVAOPTION') ? ' style="display: none;"' : '').'>';
858$placeholder = (($mysoc->country_code == 'FR') ? 'VATEX-FR-FRANCHISE' : '');
859$tooltiptext = $langs->trans("VATExemptionCodeDesc").'<br>'.$langs->trans("VATExemptionCodeDesc2").'<br>'.$langs->trans("VATExemptionCodeDesc3");
860if (($mysoc->country_code == 'FR')) {
861 $tooltiptext .= '<br><br>'.$langs->trans("Example").':<br>';
862 $tooltiptext .= 'VATEX-FR-FRANCHISE, VATEX-FR-CGI261-4, VATEX-FR-J, VATEX-FR-I, VATEX-FR-D, ...';
863}
864print $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').'">';
865print '</div>';
866
867print "</td></tr>\n";
868
869print "</table>";
870
871// Second tax
872print '<br>';
873print '<table class="noborder centpercent editmode">';
874print '<tr class="liste_titre">';
875print '<td class="titlefieldcreate">'.$form->textwithpicto($langs->transcountry("LocalTax1Management", $mysoc->country_code), $langs->transcountry("LocalTax1IsUsedDesc", $mysoc->country_code)).'</td><td></td>';
876print '<td class="right">&nbsp;</td>';
877print "</tr>\n";
878
879if ($mysoc->useLocalTax(1)) {
880 // Note: When option is not set, it must not appears as set on on, because there is no default value for this option
881 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>";
882 print '<td colspan="2">';
883 print '<div class="nobordernopadding">';
884 $tooltiphelp = $langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code);
885 $tooltiphelp = ($tooltiphelp != "LocalTax1IsUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code)."</i>\n" : "");
886 print $form->textwithpicto($langs->transcountry("LocalTax1IsUsedDesc", $mysoc->country_code), $tooltiphelp);
887 if (!isOnlyOneLocalTax(1)) {
888 print '<br><label for="lt1">'.$langs->trans("LTRate").'</label>: ';
889 $formcompany->select_localtax(1, getDolGlobalFloat('MAIN_INFO_VALUE_LOCALTAX1'), "lt1");
890 }
891
892 $options = array($langs->trans("CalcLocaltax1").' '.$langs->trans("CalcLocaltax1Desc"), $langs->trans("CalcLocaltax2").' - '.$langs->trans("CalcLocaltax2Desc"), $langs->trans("CalcLocaltax3").' - '.$langs->trans("CalcLocaltax3Desc"));
893
894 print '<br><label for="clt1">'.$langs->trans("CalcLocaltax").'</label>: ';
895 print $form->selectarray("clt1", $options, getDolGlobalString('MAIN_INFO_LOCALTAX_CALC1'));
896 print "</div>";
897 print "</td></tr>\n";
898
899 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>";
900 print '<td colspan="2">';
901 $tooltiphelp = $langs->transcountry("LocalTax1IsNotUsedExample", $mysoc->country_code);
902 $tooltiphelp = ($tooltiphelp != "LocalTax1IsNotUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsNotUsedExample", $mysoc->country_code)."</i>\n" : "");
903 print $form->textwithpicto($langs->transcountry("LocalTax1IsNotUsedDesc", $mysoc->country_code), $tooltiphelp);
904 print "</td></tr>\n";
905} else {
906 if (empty($mysoc->country_code)) {
907 print '<tr class="oddeven nohover"><td class="" colspan="3">'.$countrynotdefined.'</td></tr>';
908 } else {
909 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>';
910 }
911}
912
913print "</table>";
914
915// Third tax system
916print '<br>';
917print '<table class="noborder centpercent editmode">';
918print '<tr class="liste_titre">';
919print '<td class="titlefieldcreate">'.$form->textwithpicto($langs->transcountry("LocalTax2Management", $mysoc->country_code), $langs->transcountry("LocalTax2IsUsedDesc", $mysoc->country_code)).'</td><td></td>';
920print '<td class="right">&nbsp;</td>';
921print "</tr>\n";
922
923if ($mysoc->useLocalTax(2)) {
924 // Note: When option is not set, it must not appears as set on on, because there is no default value for this option
925 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>";
926 print '<td colspan="2">';
927 print '<div class="nobordernopadding">';
928 print '<label for="lt2">'.$langs->transcountry("LocalTax2IsUsedDesc", $mysoc->country_code)."</label>";
929 $tooltiphelp = $langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code);
930 $tooltiphelp = ($tooltiphelp != "LocalTax2IsUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code)."</i>\n" : "");
931 if (!isOnlyOneLocalTax(2)) {
932 print '<br><label for="lt2">'.$langs->trans("LTRate").'</label>: ';
933 $formcompany->select_localtax(2, getDolGlobalFloat('MAIN_INFO_VALUE_LOCALTAX2'), "lt2");
934 }
935
936 $options = array($langs->trans("CalcLocaltax1").' '.$langs->trans("CalcLocaltax1Desc"), $langs->trans("CalcLocaltax2").' - '.$langs->trans("CalcLocaltax2Desc"), $langs->trans("CalcLocaltax3").' - '.$langs->trans("CalcLocaltax3Desc"));
937
938 print '<br><label for="clt2">'.$langs->trans("CalcLocaltax").'</label>: ';
939 print $form->selectarray("clt2", $options, getDolGlobalString('MAIN_INFO_LOCALTAX_CALC2'));
940 print "</div>";
941 print "</td></tr>\n";
942
943 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>";
944 print '<td colspan="2">';
945 print "<div>";
946 $tooltiphelp = $langs->transcountry("LocalTax2IsNotUsedExample", $mysoc->country_code);
947 $tooltiphelp = ($tooltiphelp != "LocalTax2IsNotUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsNotUsedExample", $mysoc->country_code)."</i>\n" : "");
948 print "<label for=\"nolt2\">".$form->textwithpicto($langs->transcountry("LocalTax2IsNotUsedDesc", $mysoc->country_code), $tooltiphelp)."</label>";
949 print "</div>";
950 print "</td></tr>\n";
951} else {
952 if (empty($mysoc->country_code)) {
953 print '<tr class="oddeven nohover"><td class="" colspan="3">'.$countrynotdefined.'</td></tr>';
954 } else {
955 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>';
956 }
957}
958
959print "</table>";
960
961
962// Tax stamp
963print '<br>';
964print '<table class="noborder centpercent editmode">';
965print '<tr class="liste_titre">';
966print '<td>'.$form->textwithpicto($langs->trans("RevenueStamp"), $langs->trans("RevenueStampDesc")).'</td><td></td>';
967print '<td class="right">&nbsp;</td>';
968print "</tr>\n";
969if ($mysoc->useRevenueStamp()) {
970 // Note: When option is not set, it must not appears as set on on, because there is no default value for this option
971 print '<tr class="oddeven"><td>';
972 print $langs->trans("UseRevenueStamp");
973 print "</td>";
974 print '<td colspan="2">';
975 print $langs->trans("UseRevenueStampExample", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryRevenueStamp"));
976 print "</td></tr>\n";
977} else {
978 if (empty($mysoc->country_code)) {
979 print '<tr class="oddeven nohover"><td class="" colspan="3">'.$countrynotdefined.'</td></tr>';
980 } else {
981 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>';
982 }
983}
984
985print "</table>";
986
987// AADE webservices credentials, applicable only for Greece
988if ($mysoc->country_code == 'GR') {
989 print load_fiche_titre($langs->trans("AADEWebserviceCredentials"), '', '');
990 print '<table class="noborder centpercent editmode">';
991 print '<tr class="liste_titre">';
992 print '<td>'.$langs->trans("AccountParameter").'</td>';
993 print '<td></td>';
994 print '<td></td>';
995 print "</tr>\n";
996
997 print '<tr class="oddeven"><td>';
998 print '<span class="titlefield fieldrequired">'.$langs->trans("MYDATA_AADE_USER").'</span></td><td>';
999 print '<input class="minwidth300" type="text" name="MYDATA_AADE_USER" value="'.getDolGlobalString('MYDATA_AADE_USER').'"';
1000 print '</td><td></td></tr>';
1001
1002 print '<tr class="oddeven"><td>';
1003 print '<span class="titlefield fieldrequired">'.$langs->trans("MYDATA_AADE_KEY").'</span></td><td>';
1004 print '<input class="minwidth300" type="password" name="MYDATA_AADE_KEY" value="'.getDolGlobalString('MYDATA_AADE_KEY').'"';
1005 print '</td><td></td></tr>';
1006
1007 print '<tr class="oddeven"><td>';
1008 print '<span class="titlefield fieldrequired">'.$langs->trans("AADE_WEBSERVICE_USER").'</span></td><td>';
1009 print '<input class="minwidth300" type="text" name="AADE_WEBSERVICE_USER" value="'.getDolGlobalString('AADE_WEBSERVICE_USER').'"';
1010 print '</td><td></td></tr>';
1011
1012 print '<tr class="oddeven"><td>';
1013 print '<span class="titlefield fieldrequired">'.$langs->trans("AADE_WEBSERVICE_KEY").'</span></td><td>';
1014 print '<input class="minwidth300" type="password" name="AADE_WEBSERVICE_KEY" value="'.getDolGlobalString('AADE_WEBSERVICE_KEY').'"';
1015 print '</td><td></td></tr>';
1016
1017 print '<br>';
1018
1019 print "</table>";
1020}
1021
1022print $form->buttonsSaveCancel("Save", '', array(), false, 'reposition');
1023
1024print '</form>';
1025
1026
1027// End of page
1028llxFooter();
1029$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($blockedlogusagealreadychecked=0, $blockedlogmoduleonalreadychecked=0)
Return if the application is executed with the LNE requirements on.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to 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
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
dolGRIsValidDiasCode($dias_code)
Check a DIAS creditor code.
dolGRIsAmountCheckedReference($ref)
Tell if a greek DIAS reference asks the paying bank for an amount check.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
Definition html.lib.php:542
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.