company.php 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971
  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 Alexandre Spangaro <aspangaro@open-dsi.fr>
  8. * Copyright (C) 2017 Rui Strecht <rui.strecht@aliartalentos.com>
  9. * Copyright (C) 2023 Nick Fragoulis
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 3 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  23. */
  24. /**
  25. * \file htdocs/admin/company.php
  26. * \ingroup company
  27. * \brief Setup page to configure company/foundation
  28. */
  29. // Load Dolibarr environment
  30. require '../main.inc.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  34. require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
  35. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  36. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  37. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  38. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  39. $action = GETPOST('action', 'aZ09');
  40. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'admincompany'; // To manage different context of search
  41. $page_y = GETPOSTINT('page_y');
  42. // Load translation files required by the page
  43. $langs->loadLangs(array('admin', 'companies', 'bills'));
  44. if (!$user->admin) {
  45. accessforbidden();
  46. }
  47. $error = 0;
  48. $tmparraysize = getDefaultImageSizes();
  49. $maxwidthsmall = $tmparraysize['maxwidthsmall'];
  50. $maxheightsmall = $tmparraysize['maxheightsmall'];
  51. $maxwidthmini = $tmparraysize['maxwidthmini'];
  52. $maxheightmini = $tmparraysize['maxheightmini'];
  53. $quality = $tmparraysize['quality'];
  54. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  55. $hookmanager->initHooks(array('admincompany', 'globaladmin'));
  56. /*
  57. * Actions
  58. */
  59. $parameters = array();
  60. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  61. if ($reshook < 0) {
  62. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  63. }
  64. if (($action == 'update' && !GETPOST("cancel", 'alpha'))
  65. || ($action == 'updateedit')) {
  66. $tmparray = getCountry(GETPOSTINT('country_id'), 'all', $db, $langs, 0);
  67. if (!empty($tmparray['id'])) {
  68. if ($tmparray['code'] == 'FR' && $tmparray['id'] != $mysoc->country_id) {
  69. // For FR, default value of option to show profid SIREN is on by default
  70. $res = dolibarr_set_const($db, "MAIN_PROFID1_IN_ADDRESS", 1, 'chaine', 0, '', $conf->entity);
  71. }
  72. $mysoc->country_id = $tmparray['id'];
  73. $mysoc->country_code = $tmparray['code'];
  74. $mysoc->country_label = $tmparray['label'];
  75. $s = $mysoc->country_id.':'.$mysoc->country_code.':'.$mysoc->country_label;
  76. dolibarr_set_const($db, "MAIN_INFO_SOCIETE_COUNTRY", $s, 'chaine', 0, '', $conf->entity);
  77. activateModulesRequiredByCountry($mysoc->country_code);
  78. }
  79. $tmparray = getState(GETPOST('state_id', 'int'), 'all', $db, $langs, 0);
  80. if (!empty($tmparray['id'])) {
  81. $mysoc->state_id = $tmparray['id'];
  82. $mysoc->state_code = $tmparray['code'];
  83. $mysoc->state_label = $tmparray['label'];
  84. $s = $mysoc->state_id.':'.$mysoc->state_code.':'.$mysoc->state_label;
  85. dolibarr_set_const($db, "MAIN_INFO_SOCIETE_STATE", $s, 'chaine', 0, '', $conf->entity);
  86. } else {
  87. dolibarr_del_const($db, "MAIN_INFO_SOCIETE_STATE", $conf->entity);
  88. }
  89. $db->begin();
  90. dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", GETPOST("nom", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  91. dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ADDRESS", GETPOST("MAIN_INFO_SOCIETE_ADDRESS", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  92. dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TOWN", GETPOST("MAIN_INFO_SOCIETE_TOWN", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  93. dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ZIP", GETPOST("MAIN_INFO_SOCIETE_ZIP", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  94. dolibarr_set_const($db, "MAIN_INFO_SOCIETE_REGION", GETPOST("region_code", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  95. dolibarr_set_const($db, "MAIN_MONNAIE", GETPOST("currency", 'aZ09'), 'chaine', 0, '', $conf->entity);
  96. dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TEL", GETPOST("tel", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  97. dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FAX", GETPOST("fax", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  98. dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MAIL", GETPOST("mail", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  99. dolibarr_set_const($db, "MAIN_INFO_SOCIETE_WEB", GETPOST("web", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  100. dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOTE", GETPOST("note", 'restricthtml'), 'chaine', 0, '', $conf->entity);
  101. dolibarr_set_const($db, "MAIN_INFO_SOCIETE_GENCOD", GETPOST("barcode", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  102. $dirforimage = $conf->mycompany->dir_output.'/logos/';
  103. $arrayofimages = array('logo', 'logo_squarred');
  104. //var_dump($_FILES); exit;
  105. foreach ($arrayofimages as $varforimage) {
  106. if ($_FILES[$varforimage]["name"] && !preg_match('/(\.jpeg|\.jpg|\.png)$/i', $_FILES[$varforimage]["name"])) { // Logo can be used on a lot of different places. Only jpg and png can be supported.
  107. $langs->load("errors");
  108. setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors');
  109. break;
  110. }
  111. // Remove to check file size to large
  112. /*if ($_FILES[$varforimage]["tmp_name"]) {*/
  113. $reg = array();
  114. if (preg_match('/([^\\/:]+)$/i', $_FILES[$varforimage]["name"], $reg)) {
  115. $original_file = $reg[1];
  116. $isimage = image_format_supported($original_file);
  117. if ($isimage >= 0) {
  118. dol_syslog("Move file ".$_FILES[$varforimage]["tmp_name"]." to ".$dirforimage.$original_file);
  119. if (!is_dir($dirforimage)) {
  120. dol_mkdir($dirforimage);
  121. }
  122. $result = dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage.$original_file, 1, 0, $_FILES[$varforimage]['error']);
  123. if (is_numeric($result) && $result > 0) {
  124. $constant = "MAIN_INFO_SOCIETE_LOGO";
  125. if ($varforimage == 'logo_squarred') {
  126. $constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED";
  127. }
  128. dolibarr_set_const($db, $constant, $original_file, 'chaine', 0, '', $conf->entity);
  129. // Create thumbs of logo (Note that PDF use original file and not thumbs)
  130. if ($isimage > 0) {
  131. // Create thumbs
  132. //$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...
  133. // Create small thumb, Used on logon for example
  134. $imgThumbSmall = vignette($dirforimage.$original_file, $maxwidthsmall, $maxheightsmall, '_small', $quality);
  135. if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg)) {
  136. $imgThumbSmall = $reg[1]; // Save only basename
  137. dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity);
  138. } else {
  139. dol_syslog($imgThumbSmall);
  140. }
  141. // Create mini thumb, Used on menu or for setup page for example
  142. $imgThumbMini = vignette($dirforimage.$original_file, $maxwidthmini, $maxheightmini, '_mini', $quality);
  143. if (image_format_supported($imgThumbMini) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg)) {
  144. $imgThumbMini = $reg[1]; // Save only basename
  145. dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity);
  146. } else {
  147. dol_syslog($imgThumbMini);
  148. }
  149. } else {
  150. dol_syslog("ErrorImageFormatNotSupported", LOG_WARNING);
  151. }
  152. } elseif (preg_match('/^ErrorFileIsInfectedWithAVirus/', $result)) {
  153. $error++;
  154. $langs->load("errors");
  155. $tmparray = explode(':', $result);
  156. setEventMessages($langs->trans('ErrorFileIsInfectedWithAVirus', $tmparray[1]), null, 'errors');
  157. } elseif (preg_match('/^ErrorFileSizeTooLarge/', $result)) {
  158. $error++;
  159. setEventMessages($langs->trans("ErrorFileSizeTooLarge"), null, 'errors');
  160. } else {
  161. $error++;
  162. setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors');
  163. }
  164. } else {
  165. $error++;
  166. $langs->load("errors");
  167. setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors');
  168. }
  169. }
  170. /*}*/
  171. }
  172. dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MANAGERS", GETPOST("MAIN_INFO_SOCIETE_MANAGERS", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  173. dolibarr_set_const($db, "MAIN_INFO_GDPR", GETPOST("MAIN_INFO_GDPR", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  174. dolibarr_set_const($db, "MAIN_INFO_CAPITAL", GETPOST("capital", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  175. dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FORME_JURIDIQUE", GETPOST("forme_juridique_code", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  176. dolibarr_set_const($db, "MAIN_INFO_SIREN", GETPOST("siren", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  177. dolibarr_set_const($db, "MAIN_INFO_SIRET", GETPOST("siret", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  178. dolibarr_set_const($db, "MAIN_INFO_APE", GETPOST("ape", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  179. dolibarr_set_const($db, "MAIN_INFO_RCS", GETPOST("rcs", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  180. dolibarr_set_const($db, "MAIN_INFO_PROFID5", GETPOST("MAIN_INFO_PROFID5", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  181. dolibarr_set_const($db, "MAIN_INFO_PROFID6", GETPOST("MAIN_INFO_PROFID6", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  182. dolibarr_set_const($db, "MAIN_INFO_PROFID7", GETPOST("MAIN_INFO_PROFID7", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  183. dolibarr_set_const($db, "MAIN_INFO_PROFID8", GETPOST("MAIN_INFO_PROFID8", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  184. dolibarr_set_const($db, "MAIN_INFO_PROFID9", GETPOST("MAIN_INFO_PROFID9", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  185. dolibarr_set_const($db, "MAIN_INFO_PROFID10", GETPOST("MAIN_INFO_PROFID10", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  186. dolibarr_set_const($db, "MAIN_INFO_TVAINTRA", GETPOST("tva", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  187. dolibarr_set_const($db, "MAIN_INFO_SOCIETE_OBJECT", GETPOST("socialobject", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  188. dolibarr_set_const($db, "SOCIETE_FISCAL_MONTH_START", GETPOST("SOCIETE_FISCAL_MONTH_START", 'int'), 'chaine', 0, '', $conf->entity);
  189. // Sale tax options
  190. $usevat = GETPOST("optiontva", 'aZ09');
  191. $uselocaltax1 = GETPOST("optionlocaltax1", 'aZ09');
  192. $uselocaltax2 = GETPOST("optionlocaltax2", 'aZ09');
  193. if ($uselocaltax1 == 'localtax1on' && !$usevat) {
  194. setEventMessages($langs->trans("IfYouUseASecondTaxYouMustSetYouUseTheMainTax"), null, 'errors');
  195. $error++;
  196. }
  197. if ($uselocaltax2 == 'localtax2on' && !$usevat) {
  198. setEventMessages($langs->trans("IfYouUseAThirdTaxYouMustSetYouUseTheMainTax"), null, 'errors');
  199. $error++;
  200. }
  201. dolibarr_set_const($db, "FACTURE_TVAOPTION", $usevat, 'chaine', 0, '', $conf->entity);
  202. dolibarr_set_const($db, "FACTURE_LOCAL_TAX1_OPTION", $uselocaltax1, 'chaine', 0, '', $conf->entity);
  203. dolibarr_set_const($db, "FACTURE_LOCAL_TAX2_OPTION", $uselocaltax2, 'chaine', 0, '', $conf->entity);
  204. if (GETPOST("optionlocaltax1") == "localtax1on") {
  205. if (!GETPOSTISSET('lt1')) {
  206. dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX1", 0, 'chaine', 0, '', $conf->entity);
  207. } else {
  208. dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX1", GETPOST('lt1', 'aZ09'), 'chaine', 0, '', $conf->entity);
  209. }
  210. dolibarr_set_const($db, "MAIN_INFO_LOCALTAX_CALC1", GETPOST("clt1", 'aZ09'), 'chaine', 0, '', $conf->entity);
  211. }
  212. if (GETPOST("optionlocaltax2") == "localtax2on") {
  213. if (!GETPOSTISSET('lt2')) {
  214. dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX2", 0, 'chaine', 0, '', $conf->entity);
  215. } else {
  216. dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX2", GETPOST('lt2', 'aZ09'), 'chaine', 0, '', $conf->entity);
  217. }
  218. dolibarr_set_const($db, "MAIN_INFO_LOCALTAX_CALC2", GETPOST("clt2", 'aZ09'), 'chaine', 0, '', $conf->entity);
  219. }
  220. // Credentials for AADE webservices, applicable only for Greece
  221. if ($mysoc->country_code == 'GR') {
  222. dolibarr_set_const($db, "MYDATA_AADE_USER", GETPOST("MYDATA_AADE_USER", 'alpha'), 'chaine', 0, '', $conf->entity);
  223. dolibarr_set_const($db, "MYDATA_AADE_KEY", GETPOST("MYDATA_AADE_KEY", 'alpha'), 'chaine', 0, '', $conf->entity);
  224. dolibarr_set_const($db, "AADE_WEBSERVICE_USER", GETPOST("AADE_WEBSERVICE_USER", 'alpha'), 'chaine', 0, '', $conf->entity);
  225. dolibarr_set_const($db, "AADE_WEBSERVICE_KEY", GETPOST("AADE_WEBSERVICE_KEY", 'alpha'), 'chaine', 0, '', $conf->entity);
  226. }
  227. // Remove constant MAIN_INFO_SOCIETE_SETUP_TODO_WARNING
  228. dolibarr_del_const($db, "MAIN_INFO_SOCIETE_SETUP_TODO_WARNING", $conf->entity);
  229. if (!$error) {
  230. if (GETPOST('save')) { // To avoid to show message when we juste switch the country that resubmit the form.
  231. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  232. }
  233. $db->commit();
  234. } else {
  235. $db->rollback();
  236. }
  237. if ($action != 'updateedit' && !$error) {
  238. header("Location: ".$_SERVER["PHP_SELF"].($page_y ? '?page_y='.$page_y : ''));
  239. exit;
  240. }
  241. }
  242. if ($action == 'addthumb' || $action == 'addthumbsquarred') { // Regenerate thumbs
  243. if (file_exists($conf->mycompany->dir_output.'/logos/'.$_GET["file"])) {
  244. $isimage = image_format_supported($_GET["file"]);
  245. // Create thumbs of logo
  246. if ($isimage > 0) {
  247. $constant = "MAIN_INFO_SOCIETE_LOGO";
  248. if ($action == 'addthumbsquarred') {
  249. $constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED";
  250. }
  251. $reg = array();
  252. // Create thumbs
  253. //$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...
  254. // Create small thumb. Used on logon for example
  255. $imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthsmall, $maxheightsmall, '_small', $quality);
  256. if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg)) {
  257. $imgThumbSmall = $reg[1]; // Save only basename
  258. dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity);
  259. } else {
  260. dol_syslog($imgThumbSmall);
  261. }
  262. // Create mini thumbs. Used on menu or for setup page for example
  263. $imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthmini, $maxheightmini, '_mini', $quality);
  264. if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg)) {
  265. $imgThumbMini = $reg[1]; // Save only basename
  266. dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity);
  267. } else {
  268. dol_syslog($imgThumbMini);
  269. }
  270. header("Location: ".$_SERVER["PHP_SELF"]);
  271. exit;
  272. } else {
  273. $error++;
  274. $langs->load("errors");
  275. setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors');
  276. dol_syslog($langs->transnoentities("ErrorBadImageFormat"), LOG_INFO);
  277. }
  278. } else {
  279. $error++;
  280. $langs->load("errors");
  281. setEventMessages($langs->trans("ErrorFileDoesNotExists", GETPOST("file")), null, 'errors');
  282. dol_syslog($langs->transnoentities("ErrorFileDoesNotExists", GETPOST("file")), LOG_WARNING);
  283. }
  284. }
  285. if ($action == 'removelogo' || $action == 'removelogosquarred') {
  286. $constant = "MAIN_INFO_SOCIETE_LOGO";
  287. if ($action == 'removelogosquarred') {
  288. $constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED";
  289. }
  290. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  291. $logofilename = $mysoc->logo;
  292. $logofilenamebis = $mysoc->logo_squarred;
  293. if ($action == 'removelogosquarred') {
  294. $logofilename = $mysoc->logo_squarred;
  295. $logofilenamebis = $mysoc->logo;
  296. }
  297. $logofile = $conf->mycompany->dir_output.'/logos/'.$logofilename;
  298. if ($logofilename != '' && $logofilename != $logofilenamebis) {
  299. dol_delete_file($logofile);
  300. }
  301. dolibarr_del_const($db, $constant, $conf->entity);
  302. if ($action == 'removelogosquarred') {
  303. $mysoc->logo_squarred = '';
  304. } else {
  305. $mysoc->logo = '';
  306. }
  307. $logofilename = $mysoc->logo_small;
  308. $logofilenamebis = $mysoc->logo_squarred_small;
  309. if ($action == 'removelogosquarred') {
  310. $logofilename = $mysoc->logo_squarred_small;
  311. $logofilenamebis = $mysoc->logo_small;
  312. }
  313. $logosmallfile = $conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename;
  314. if ($logofilename != '' && $logofilename != $logofilenamebis) {
  315. dol_delete_file($logosmallfile);
  316. }
  317. dolibarr_del_const($db, $constant."_SMALL", $conf->entity);
  318. if ($action == 'removelogosquarred') {
  319. $mysoc->logo_squarred_small = '';
  320. } else {
  321. $mysoc->logo_small = '';
  322. }
  323. $logofilename = $mysoc->logo_mini;
  324. $logofilenamebis = $mysoc->logo_squarred_mini;
  325. if ($action == 'removelogosquarred') {
  326. $logofilename = $mysoc->logo_squarred_mini;
  327. $logofilenamebis = $mysoc->logo_mini;
  328. }
  329. $logominifile = $conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename;
  330. if ($logofilename != '' && $logofilename != $logofilenamebis) {
  331. dol_delete_file($logominifile);
  332. }
  333. dolibarr_del_const($db, $constant."_MINI", $conf->entity);
  334. if ($action == 'removelogosquarred') {
  335. $mysoc->logo_squarred_mini = '';
  336. } else {
  337. $mysoc->logo_mini = '';
  338. }
  339. }
  340. /*
  341. * View
  342. */
  343. $wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
  344. llxHeader('', $langs->trans("Setup"), $wikihelp);
  345. $form = new Form($db);
  346. $formother = new FormOther($db);
  347. $formcompany = new FormCompany($db);
  348. $countrynotdefined = '<span class="error">'.$langs->trans("ErrorSetACountryFirst").' <a href="#trzipbeforecountry">('.$langs->trans("SeeAbove").')</a></span>';
  349. print load_fiche_titre($langs->trans("CompanyFoundation"), '', 'title_setup');
  350. $head = company_admin_prepare_head();
  351. print dol_get_fiche_head($head, 'company', '', -1, '');
  352. print '<span class="opacitymedium">'.$langs->trans("CompanyFundationDesc", $langs->transnoentities("Save"))."</span><br>\n";
  353. print "<br><br>\n";
  354. // Edit parameters
  355. if (!empty($conf->use_javascript_ajax)) {
  356. print "\n".'<script type="text/javascript">';
  357. print '$(document).ready(function () {
  358. $("#selectcountry_id").change(function() {
  359. document.form_index.action.value="updateedit";
  360. document.form_index.submit();
  361. });
  362. });';
  363. print '</script>'."\n";
  364. }
  365. print '<form enctype="multipart/form-data" method="POST" action="'.$_SERVER["PHP_SELF"].'" name="form_index">';
  366. print '<input type="hidden" name="token" value="'.newToken().'">';
  367. print '<input type="hidden" name="action" value="update">';
  368. print '<input type="hidden" name="page_y" value="">';
  369. print '<table class="noborder centpercent editmode">';
  370. print '<tr class="liste_titre"><th class="titlefieldcreate wordbreak">'.$langs->trans("CompanyInfo").'</th><th></th></tr>'."\n";
  371. // Name
  372. print '<tr class="oddeven"><td class="fieldrequired wordbreak"><label for="name">'.$langs->trans("CompanyName").'</label></td><td>';
  373. print '<input name="nom" id="name" class="minwidth200" value="'.dol_escape_htmltag((GETPOSTISSET('nom') ? GETPOST('nom', 'alphanohtml') : (getDolGlobalString('MAIN_INFO_SOCIETE_NOM') ? $conf->global->MAIN_INFO_SOCIETE_NOM : ''))).'"'.(!getDolGlobalString('MAIN_INFO_SOCIETE_NOM') ? ' autofocus="autofocus"' : '').'></td></tr>'."\n";
  374. // Address
  375. print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_ADDRESS">'.$langs->trans("CompanyAddress").'</label></td><td>';
  376. print '<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') ? $conf->global->MAIN_INFO_SOCIETE_ADDRESS : '')).'</textarea></td></tr>'."\n";
  377. // Zip
  378. print '<tr class="oddeven" id="trzipbeforecountry"><td><label for="MAIN_INFO_SOCIETE_ZIP">'.$langs->trans("CompanyZip").'</label></td><td>';
  379. print '<input class="width100" name="MAIN_INFO_SOCIETE_ZIP" id="MAIN_INFO_SOCIETE_ZIP" value="'.dol_escape_htmltag((GETPOSTISSET('MAIN_INFO_SOCIETE_ZIP') ? GETPOST('MAIN_INFO_SOCIETE_ZIP', 'alphanohtml') : (getDolGlobalString('MAIN_INFO_SOCIETE_ZIP') ? $conf->global->MAIN_INFO_SOCIETE_ZIP : ''))).'"></td></tr>'."\n";
  380. print '<tr class="oddeven" id="trtownbeforecountry"><td><label for="MAIN_INFO_SOCIETE_TOWN">'.$langs->trans("CompanyTown").'</label></td><td>';
  381. print '<input name="MAIN_INFO_SOCIETE_TOWN" class="minwidth200" id="MAIN_INFO_SOCIETE_TOWN" value="'.dol_escape_htmltag((GETPOSTISSET('MAIN_INFO_SOCIETE_TOWN') ? GETPOST('MAIN_INFO_SOCIETE_TOWN', 'alphanohtml') : (getDolGlobalString('MAIN_INFO_SOCIETE_TOWN') ? $conf->global->MAIN_INFO_SOCIETE_TOWN : ''))).'"></td></tr>'."\n";
  382. // Country
  383. print '<tr class="oddeven"><td class="fieldrequired"><label for="selectcountry_id">'.$langs->trans("Country").'</label></td><td>';
  384. print img_picto('', 'globe-americas', 'class="pictofixedwidth"');
  385. print $form->select_country($mysoc->country_id, 'country_id', '', 0);
  386. if ($user->admin) {
  387. print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
  388. }
  389. print '</td></tr>'."\n";
  390. print '<tr class="oddeven"><td class="wordbreak"><label for="state_id">'.$langs->trans("State").'</label></td><td>';
  391. $state_id = 0;
  392. if (getDolGlobalString('MAIN_INFO_SOCIETE_STATE')) {
  393. $tmp = explode(':', getDolGlobalString('MAIN_INFO_SOCIETE_STATE'));
  394. $state_id = $tmp[0];
  395. }
  396. print img_picto('', 'state', 'class="pictofixedwidth"');
  397. print $formcompany->select_state($state_id, $mysoc->country_code, 'state_id', 'maxwidth200onsmartphone minwidth300');
  398. print '</td></tr>'."\n";
  399. // Currency
  400. print '<tr class="oddeven"><td><label for="currency">'.$langs->trans("CompanyCurrency").'</label></td><td>';
  401. print img_picto('', 'multicurrency', 'class="pictofixedwidth"');
  402. print $form->selectCurrency($conf->currency, "currency");
  403. print '</td></tr>'."\n";
  404. // Phone
  405. print '<tr class="oddeven"><td><label for="phone">'.$langs->trans("Phone").'</label></td><td>';
  406. print img_picto('', 'object_phoning', '', false, 0, 0, '', 'pictofixedwidth');
  407. print '<input class="maxwidth150 widthcentpercentminusx" name="tel" id="phone" value="'.dol_escape_htmltag((GETPOSTISSET('tel') ? GETPOST('tel', 'alphanohtml') : (getDolGlobalString('MAIN_INFO_SOCIETE_TEL') ? $conf->global->MAIN_INFO_SOCIETE_TEL : ''))).'"></td></tr>';
  408. print '</td></tr>'."\n";
  409. // Fax
  410. print '<tr class="oddeven"><td><label for="fax">'.$langs->trans("Fax").'</label></td><td>';
  411. print img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'pictofixedwidth');
  412. print '<input class="maxwidth150" name="fax" id="fax" value="'.dol_escape_htmltag((GETPOSTISSET('fax') ? GETPOST('fax', 'alphanohtml') : (getDolGlobalString('MAIN_INFO_SOCIETE_FAX') ? $conf->global->MAIN_INFO_SOCIETE_FAX : ''))).'"></td></tr>';
  413. print '</td></tr>'."\n";
  414. // Email
  415. print '<tr class="oddeven"><td><label for="email">'.$langs->trans("EMail").'</label></td><td>';
  416. print img_picto('', 'object_email', '', false, 0, 0, '', 'pictofixedwidth');
  417. print '<input class="minwidth300 maxwidth500 widthcentpercentminusx" name="mail" id="email" value="'.dol_escape_htmltag((GETPOSTISSET('mail') ? GETPOST('mail', 'alphanohtml') : (getDolGlobalString('MAIN_INFO_SOCIETE_MAIL') ? $conf->global->MAIN_INFO_SOCIETE_MAIL : ''))).'"></td></tr>';
  418. print '</td></tr>'."\n";
  419. // Web
  420. print '<tr class="oddeven"><td><label for="web">'.$langs->trans("Web").'</label></td><td>';
  421. print img_picto('', 'globe', '', false, 0, 0, '', 'pictofixedwidth');
  422. print '<input class="maxwidth300 widthcentpercentminusx" name="web" id="web" value="'.dol_escape_htmltag((GETPOSTISSET('web') ? GETPOST('web', 'alphanohtml') : (getDolGlobalString('MAIN_INFO_SOCIETE_WEB') ? $conf->global->MAIN_INFO_SOCIETE_WEB : ''))).'"></td></tr>';
  423. print '</td></tr>'."\n";
  424. // Barcode
  425. if (isModEnabled('barcode')) {
  426. print '<tr class="oddeven"><td>';
  427. print '<label for="barcode">'.$langs->trans("Gencod").'</label></td><td>';
  428. print '<span class="fa fa-barcode pictofixedwidth"></span>';
  429. print '<input name="barcode" id="barcode" class="minwidth150 widthcentpercentminusx maxwidth300" value="'.dol_escape_htmltag(GETPOSTISSET('barcode') ? GETPOST('barcode', 'alphanohtml') : getDolGlobalString('MAIN_INFO_SOCIETE_GENCOD', '')).'"></td></tr>';
  430. print '</td></tr>';
  431. }
  432. // Tooltip for both Logo and LogSquarred
  433. $tooltiplogo = $langs->trans('AvailableFormats').' : png, jpg, jpeg';
  434. $maxfilesizearray = getMaxFileSizeArray();
  435. $maxmin = $maxfilesizearray['maxmin'];
  436. $tooltiplogo .= ($maxmin > 0) ? '<br>'.$langs->trans('MaxSize').' : '.$maxmin.' '.$langs->trans('Kb') : '';
  437. // Logo
  438. print '<tr class="oddeven"><td><label for="logo">'.$form->textwithpicto($langs->trans("Logo"), $tooltiplogo).'</label></td><td>';
  439. print '<div class="centpercent nobordernopadding valignmiddle "><div class="inline-block marginrightonly">';
  440. if ($maxmin > 0) {
  441. print '<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).'">'; // MAX_FILE_SIZE must precede the field type=file
  442. }
  443. print '<input type="file" class="flat minwidth100 maxwidthinputfileonsmartphone" name="logo" id="logo" accept="image/*">';
  444. print '</div>';
  445. if (!empty($mysoc->logo_small)) {
  446. print '<div class="inline-block valignmiddle marginrightonly">';
  447. print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogo&token='.newToken().'">'.img_delete($langs->trans("Delete"), '', 'marginleftonly').'</a>';
  448. print '</div>';
  449. if (file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) {
  450. print '<div class="inline-block valignmiddle">';
  451. print '<img style="max-height: 80px; max-width: 200px;" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_small).'">';
  452. print '</div>';
  453. } elseif (!empty($mysoc->logo)) {
  454. if (!file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) {
  455. $imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$mysoc->logo, $maxwidthmini, $maxheightmini, '_mini', $quality);
  456. }
  457. $imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$mysoc->logo, $maxwidthmini, $maxheightmini, '_small', $quality);
  458. print '<div class="inline-block valignmiddle">';
  459. print '<img style="max-height: 80px; max-width: 200px;" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.basename($imgThumbSmall)).'">';
  460. print '</div>';
  461. }
  462. } elseif (!empty($mysoc->logo)) {
  463. if (file_exists($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) {
  464. print '<div class="inline-block valignmiddle">';
  465. print '<img style="max-height: 80px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/'.$mysoc->logo).'">';
  466. print '</div>';
  467. print '<div class="inline-block valignmiddle marginrightonly"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogo&token='.newToken().'">'.img_delete($langs->trans("Delete"), '', 'marginleftonly').'</a></div>';
  468. } else {
  469. print '<div class="inline-block valignmiddle">';
  470. print '<img height="80" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png" title="File has been removed from disk">';
  471. print '</div>';
  472. }
  473. }
  474. print '</div>';
  475. print '</td></tr>';
  476. // Logo (squarred)
  477. print '<tr class="oddeven"><td><label for="logo_squarred">'.$form->textwithpicto($langs->trans("LogoSquarred"), $tooltiplogo).'</label></td><td>';
  478. print '<div class="centpercent nobordernopadding valignmiddle"><div class="inline-block marginrightonly">';
  479. $maxfilesizearray = getMaxFileSizeArray();
  480. $maxmin = $maxfilesizearray['maxmin'];
  481. if ($maxmin > 0) {
  482. print '<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).'">'; // MAX_FILE_SIZE must precede the field type=file
  483. }
  484. print '<input type="file" class="flat minwidth100 maxwidthinputfileonsmartphone" name="logo_squarred" id="logo_squarred" accept="image/*">';
  485. print '</div>';
  486. if (!empty($mysoc->logo_squarred_small)) {
  487. print '<div class="inline-block valignmiddle marginrightonly">';
  488. print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogosquarred&token='.newToken().'">'.img_delete($langs->trans("Delete"), '', 'marginleftonly').'</a>';
  489. print '</div>';
  490. if (file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_squarred_small)) {
  491. print '<div class="inline-block valignmiddle marginrightonly">';
  492. print '<img style="max-height: 80px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_squarred_small).'">';
  493. print '</div>';
  494. } elseif (!empty($mysoc->logo_squarred)) {
  495. if (!file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_squarred_mini)) {
  496. $imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$mysoc->logo_squarred, $maxwidthmini, $maxheightmini, '_mini', $quality);
  497. }
  498. $imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$mysoc->logo_squarred, $maxwidthmini, $maxheightmini, '_small', $quality);
  499. print '<div class="inline-block valignmiddle">';
  500. print '<img style="max-height: 80px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/thumbs/'.basename($imgThumbSmall)).'">';
  501. print '</div>';
  502. }
  503. } elseif (!empty($mysoc->logo_squarred)) {
  504. if (file_exists($conf->mycompany->dir_output.'/logos/'.$mysoc->logo_squarred)) {
  505. print '<div class="inline-block valignmiddle">';
  506. print '<img style="max-height: 80px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/'.$mysoc->logo_squarred).'">';
  507. print '</div>';
  508. print '<div class="inline-block valignmiddle marginrightonly"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogosquarred&token='.newToken().'">'.img_delete($langs->trans("Delete"), '', 'marginleftonly').'</a></div>';
  509. } else {
  510. print '<div class="inline-block valignmiddle">';
  511. print '<img height="80" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png" title="File has been removed from disk">';
  512. print '</div>';
  513. }
  514. }
  515. print '</div>';
  516. print '</td></tr>';
  517. // Note
  518. print '<tr class="oddeven"><td class="tdtop"><label for="note">'.$langs->trans("Note").'</label></td><td>';
  519. print '<textarea class="flat quatrevingtpercent" name="note" id="note" rows="'.ROWS_5.'">'.(GETPOSTISSET('note') ? GETPOST('note', 'restricthtml') : (getDolGlobalString('MAIN_INFO_SOCIETE_NOTE') ? $conf->global->MAIN_INFO_SOCIETE_NOTE : '')).'</textarea></td></tr>';
  520. print '</td></tr>';
  521. print '</table>';
  522. print $form->buttonsSaveCancel("Save", '', array(), false, 'reposition');
  523. print '<br><br>';
  524. // IDs of the company (country-specific)
  525. print '<div class="div-table-responsive-no-min">';
  526. print '<table class="noborder centpercent editmode">';
  527. print '<tr class="liste_titre"><td class="titlefieldcreate wordbreak">'.$langs->trans("CompanyIds").'</td><td></td></tr>';
  528. $langs->load("companies");
  529. // Managing Director(s)
  530. print '<tr class="oddeven"><td><label for="director">'.$langs->trans("ManagingDirectors").'</label></td><td>';
  531. print '<input name="MAIN_INFO_SOCIETE_MANAGERS" id="directors" class="minwidth300" value="'.dol_escape_htmltag((GETPOSTISSET('MAIN_INFO_SOCIETE_MANAGERS') ? GETPOST('MAIN_INFO_SOCIETE_MANAGERS', 'alphanohtml') : (getDolGlobalString('MAIN_INFO_SOCIETE_MANAGERS') ? $conf->global->MAIN_INFO_SOCIETE_MANAGERS : ''))).'"></td></tr>';
  532. // GDPR contact
  533. print '<tr class="oddeven"><td>';
  534. print $form->textwithpicto($langs->trans("GDPRContact"), $langs->trans("GDPRContactDesc"));
  535. print '</td><td>';
  536. print '<input name="MAIN_INFO_GDPR" id="infodirector" class="minwidth300" value="'.dol_escape_htmltag((GETPOSTISSET("MAIN_INFO_GDPR") ? GETPOST("MAIN_INFO_GDPR", 'alphanohtml') : (getDolGlobalString('MAIN_INFO_GDPR') ? $conf->global->MAIN_INFO_GDPR : ''))).'"></td></tr>';
  537. // Capital
  538. print '<tr class="oddeven"><td><label for="capital">'.$langs->trans("Capital").'</label></td><td>';
  539. print '<input name="capital" id="capital" class="maxwidth100" value="'.dol_escape_htmltag((GETPOSTISSET('capital') ? GETPOST('capital', 'alphanohtml') : (getDolGlobalString('MAIN_INFO_CAPITAL') ? $conf->global->MAIN_INFO_CAPITAL : ''))).'"></td></tr>';
  540. // Juridical Status
  541. print '<tr class="oddeven"><td><label for="forme_juridique_code">'.$langs->trans("JuridicalStatus").'</label></td><td>';
  542. if ($mysoc->country_code) {
  543. print $formcompany->select_juridicalstatus($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE, $mysoc->country_code, '', 'forme_juridique_code');
  544. } else {
  545. print $countrynotdefined;
  546. }
  547. print '</td></tr>';
  548. // ProfId1
  549. if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-') {
  550. print '<tr class="oddeven"><td><label for="profid1">'.$langs->transcountry("ProfId1", $mysoc->country_code).'</label></td><td>';
  551. if (!empty($mysoc->country_code)) {
  552. print '<input name="siren" id="profid1" class="minwidth200" value="'.dol_escape_htmltag(getDolGlobalString('MAIN_INFO_SIREN') ? $conf->global->MAIN_INFO_SIREN : '').'">';
  553. } else {
  554. print $countrynotdefined;
  555. }
  556. print '</td></tr>';
  557. }
  558. // ProfId2
  559. if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-') {
  560. print '<tr class="oddeven"><td><label for="profid2">'.$langs->transcountry("ProfId2", $mysoc->country_code).'</label></td><td>';
  561. if (!empty($mysoc->country_code)) {
  562. print '<input name="siret" id="profid2" class="minwidth200" value="'.dol_escape_htmltag(getDolGlobalString('MAIN_INFO_SIRET') ? $conf->global->MAIN_INFO_SIRET : '').'">';
  563. } else {
  564. print $countrynotdefined;
  565. }
  566. print '</td></tr>';
  567. }
  568. // ProfId3
  569. if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-') {
  570. print '<tr class="oddeven"><td><label for="profid3">'.$langs->transcountry("ProfId3", $mysoc->country_code).'</label></td><td>';
  571. if (!empty($mysoc->country_code)) {
  572. print '<input name="ape" id="profid3" class="minwidth200" value="'.dol_escape_htmltag(getDolGlobalString('MAIN_INFO_APE') ? $conf->global->MAIN_INFO_APE : '').'">';
  573. } else {
  574. print $countrynotdefined;
  575. }
  576. print '</td></tr>';
  577. }
  578. // ProfId4
  579. if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-') {
  580. print '<tr class="oddeven"><td><label for="profid4">'.$langs->transcountry("ProfId4", $mysoc->country_code).'</label></td><td>';
  581. if (!empty($mysoc->country_code)) {
  582. print '<input name="rcs" id="profid4" class="minwidth200" value="'.dol_escape_htmltag(getDolGlobalString('MAIN_INFO_RCS') ? $conf->global->MAIN_INFO_RCS : '').'">';
  583. } else {
  584. print $countrynotdefined;
  585. }
  586. print '</td></tr>';
  587. }
  588. // ProfId5
  589. if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-') {
  590. print '<tr class="oddeven"><td><label for="profid5">'.$langs->transcountry("ProfId5", $mysoc->country_code).'</label></td><td>';
  591. if (!empty($mysoc->country_code)) {
  592. print '<input name="MAIN_INFO_PROFID5" id="profid5" class="minwidth200" value="'.dol_escape_htmltag(getDolGlobalString('MAIN_INFO_PROFID5') ? $conf->global->MAIN_INFO_PROFID5 : '').'">';
  593. } else {
  594. print $countrynotdefined;
  595. }
  596. print '</td></tr>';
  597. }
  598. // ProfId6
  599. if ($langs->transcountry("ProfId6", $mysoc->country_code) != '-') {
  600. print '<tr class="oddeven"><td><label for="profid6">'.$langs->transcountry("ProfId6", $mysoc->country_code).'</label></td><td>';
  601. if (!empty($mysoc->country_code)) {
  602. print '<input name="MAIN_INFO_PROFID6" id="profid6" class="minwidth200" value="'.dol_escape_htmltag(getDolGlobalString('MAIN_INFO_PROFID6') ? $conf->global->MAIN_INFO_PROFID6 : '').'">';
  603. } else {
  604. print $countrynotdefined;
  605. }
  606. print '</td></tr>';
  607. }
  608. // ProfId7
  609. if ($langs->transcountry("ProfId7", $mysoc->country_code) != '-') {
  610. print '<tr class="oddeven"><td><label for="profid7">'.$langs->transcountry("profid7", $mysoc->country_code).'</label></td><td>';
  611. if (!empty($mysoc->country_code)) {
  612. print '<input name="MAIN_INFO_PROFID7" id="profid7" class="minwidth200" value="'.dol_escape_htmltag(getDolGlobalString('MAIN_INFO_PROFID7') ? $conf->global->MAIN_INFO_PROFID7 : '').'">';
  613. } else {
  614. print $countrynotdefined;
  615. }
  616. print '</td></tr>';
  617. }
  618. // ProfId8
  619. if ($langs->transcountry("ProfId8", $mysoc->country_code) != '-') {
  620. print '<tr class="oddeven"><td><label for="profid8">'.$langs->transcountry("profid8", $mysoc->country_code).'</label></td><td>';
  621. if (!empty($mysoc->country_code)) {
  622. print '<input name="MAIN_INFO_PROFID8" id="profid8" class="minwidth200" value="'.dol_escape_htmltag(getDolGlobalString('MAIN_INFO_PROFID8') ? $conf->global->MAIN_INFO_PROFID8 : '').'">';
  623. } else {
  624. print $countrynotdefined;
  625. }
  626. print '</td></tr>';
  627. }
  628. // ProfId9
  629. if ($langs->transcountry("ProfId9", $mysoc->country_code) != '-') {
  630. print '<tr class="oddeven"><td><label for="profid9">'.$langs->transcountry("profid9", $mysoc->country_code).'</label></td><td>';
  631. if (!empty($mysoc->country_code)) {
  632. print '<input name="MAIN_INFO_PROFID9" id="profid9" class="minwidth200" value="'.dol_escape_htmltag(getDolGlobalString('MAIN_INFO_PROFID9') ? $conf->global->MAIN_INFO_PROFID9 : '').'">';
  633. } else {
  634. print $countrynotdefined;
  635. }
  636. print '</td></tr>';
  637. }
  638. // ProfId10
  639. if ($langs->transcountry("ProfId10", $mysoc->country_code) != '-') {
  640. print '<tr class="oddeven"><td><label for="profid10">'.$langs->transcountry("profid10", $mysoc->country_code).'</label></td><td>';
  641. if (!empty($mysoc->country_code)) {
  642. print '<input name="MAIN_INFO_PROFID10" id="profid10" class="minwidth200" value="'.dol_escape_htmltag(getDolGlobalString('MAIN_INFO_PROFID10') ? $conf->global->MAIN_INFO_PROFID10 : '').'">';
  643. } else {
  644. print $countrynotdefined;
  645. }
  646. print '</td></tr>';
  647. }
  648. // Intra-community VAT number
  649. print '<tr class="oddeven"><td><label for="intra_vat">'.$langs->trans("VATIntra").'</label></td><td>';
  650. print '<input name="tva" id="intra_vat" class="minwidth200" value="'.dol_escape_htmltag(getDolGlobalString('MAIN_INFO_TVAINTRA') ? $conf->global->MAIN_INFO_TVAINTRA : '').'">';
  651. print '</td></tr>';
  652. // Object of the company
  653. print '<tr class="oddeven"><td><label for="socialobject">'.$langs->trans("CompanyObject").'</label></td><td>';
  654. print '<textarea class="flat quatrevingtpercent" name="socialobject" id="socialobject" rows="'.ROWS_5.'">'.(getDolGlobalString('MAIN_INFO_SOCIETE_OBJECT') ? $conf->global->MAIN_INFO_SOCIETE_OBJECT : '').'</textarea></td></tr>';
  655. print '</td></tr>';
  656. print '</table>';
  657. print '</div>';
  658. // Fiscal year start
  659. print '<br>';
  660. print '<table class="noborder centpercent editmode">';
  661. print '<tr class="liste_titre">';
  662. print '<td class="titlefieldcreate">'.$langs->trans("FiscalYearInformation").'</td><td></td>';
  663. print "</tr>\n";
  664. print '<tr class="oddeven"><td><label for="SOCIETE_FISCAL_MONTH_START">'.$langs->trans("FiscalMonthStart").'</label></td><td>';
  665. print $formother->select_month(getDolGlobalInt('SOCIETE_FISCAL_MONTH_START') ? $conf->global->SOCIETE_FISCAL_MONTH_START : '', 'SOCIETE_FISCAL_MONTH_START', 0, 1, 'maxwidth100').'</td></tr>';
  666. print "</table>";
  667. print $form->buttonsSaveCancel("Save", '', array(), false, 'reposition');
  668. print '<br>';
  669. // Sales taxes (VAT, IRPF, ...)
  670. print load_fiche_titre($langs->trans("TypeOfSaleTaxes"), '', 'object_payment');
  671. print '<table class="noborder centpercent editmode">';
  672. print '<tr class="liste_titre">';
  673. print '<td class="titlefieldcreate">'.$langs->trans("VATManagement").'</td><td></td>';
  674. print '<td class="right">&nbsp;</td>';
  675. print "</tr>\n";
  676. // Main tax
  677. print '<tr class="oddeven"><td><label><input type="radio" name="optiontva" id="use_vat" value="1"'.(!getDolGlobalString('FACTURE_TVAOPTION') ? "" : " checked")."> ".$langs->trans("VATIsUsed")."</label></td>";
  678. print '<td colspan="2">';
  679. $tooltiphelp = '';
  680. if ($mysoc->country_code == 'FR') {
  681. $tooltiphelp = '<i>'.$langs->trans("Example").': '.$langs->trans("VATIsUsedExampleFR")."</i>";
  682. }
  683. print '<label for="use_vat">'.$form->textwithpicto($langs->trans("VATIsUsedDesc"), $tooltiphelp)."</label>";
  684. print "</td></tr>\n";
  685. print '<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>";
  686. print '<td colspan="2">';
  687. $tooltiphelp = '';
  688. if ($mysoc->country_code == 'FR') {
  689. $tooltiphelp = "<i>".$langs->trans("Example").': '.$langs->trans("VATIsNotUsedExampleFR")."</i>\n";
  690. }
  691. print '<label for="no_vat">'.$form->textwithpicto($langs->trans("VATIsNotUsedDesc"), $tooltiphelp)."</label>";
  692. print "</td></tr>\n";
  693. print "</table>";
  694. // Second tax
  695. print '<br>';
  696. print '<table class="noborder centpercent editmode">';
  697. print '<tr class="liste_titre">';
  698. print '<td class="titlefieldcreate">'.$form->textwithpicto($langs->transcountry("LocalTax1Management", $mysoc->country_code), $langs->transcountry("LocalTax1IsUsedDesc", $mysoc->country_code)).'</td><td></td>';
  699. print '<td class="right">&nbsp;</td>';
  700. print "</tr>\n";
  701. if ($mysoc->useLocalTax(1)) {
  702. // Note: When option is not set, it must not appears as set on on, because there is no default value for this option
  703. 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>";
  704. print '<td colspan="2">';
  705. print '<div class="nobordernopadding">';
  706. $tooltiphelp = $langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code);
  707. $tooltiphelp = ($tooltiphelp != "LocalTax1IsUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code)."</i>\n" : "");
  708. print $form->textwithpicto($langs->transcountry("LocalTax1IsUsedDesc", $mysoc->country_code), $tooltiphelp);
  709. if (!isOnlyOneLocalTax(1)) {
  710. print '<br><label for="lt1">'.$langs->trans("LTRate").'</label>: ';
  711. $formcompany->select_localtax(1, $conf->global->MAIN_INFO_VALUE_LOCALTAX1, "lt1");
  712. }
  713. $opcions = array($langs->trans("CalcLocaltax1").' '.$langs->trans("CalcLocaltax1Desc"), $langs->trans("CalcLocaltax2").' - '.$langs->trans("CalcLocaltax2Desc"), $langs->trans("CalcLocaltax3").' - '.$langs->trans("CalcLocaltax3Desc"));
  714. print '<br><label for="clt1">'.$langs->trans("CalcLocaltax").'</label>: ';
  715. print $form->selectarray("clt1", $opcions, getDolGlobalString('MAIN_INFO_LOCALTAX_CALC1'));
  716. print "</div>";
  717. print "</td></tr>\n";
  718. 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>";
  719. print '<td colspan="2">';
  720. $tooltiphelp = $langs->transcountry("LocalTax1IsNotUsedExample", $mysoc->country_code);
  721. $tooltiphelp = ($tooltiphelp != "LocalTax1IsNotUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsNotUsedExample", $mysoc->country_code)."</i>\n" : "");
  722. print $form->textwithpicto($langs->transcountry("LocalTax1IsNotUsedDesc", $mysoc->country_code), $tooltiphelp);
  723. print "</td></tr>\n";
  724. } else {
  725. if (empty($mysoc->country_code)) {
  726. print '<tr class="oddeven nohover"><td class="">'.$countrynotdefined.'</td><td></td><td></td></tr>';
  727. } else {
  728. 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>';
  729. }
  730. }
  731. print "</table>";
  732. // Third tax system
  733. print '<br>';
  734. print '<table class="noborder centpercent editmode">';
  735. print '<tr class="liste_titre">';
  736. print '<td class="titlefieldcreate">'.$form->textwithpicto($langs->transcountry("LocalTax2Management", $mysoc->country_code), $langs->transcountry("LocalTax2IsUsedDesc", $mysoc->country_code)).'</td><td></td>';
  737. print '<td class="right">&nbsp;</td>';
  738. print "</tr>\n";
  739. if ($mysoc->useLocalTax(2)) {
  740. // Note: When option is not set, it must not appears as set on on, because there is no default value for this option
  741. 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>";
  742. print '<td colspan="2">';
  743. print '<div class="nobordernopadding">';
  744. print '<label for="lt2">'.$langs->transcountry("LocalTax2IsUsedDesc", $mysoc->country_code)."</label>";
  745. $tooltiphelp = $langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code);
  746. $tooltiphelp = ($tooltiphelp != "LocalTax2IsUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code)."</i>\n" : "");
  747. if (!isOnlyOneLocalTax(2)) {
  748. print '<br><label for="lt2">'.$langs->trans("LTRate").'</label>: ';
  749. $formcompany->select_localtax(2, $conf->global->MAIN_INFO_VALUE_LOCALTAX2, "lt2");
  750. }
  751. print '<br><label for="clt2">'.$langs->trans("CalcLocaltax").'</label>: ';
  752. print $form->selectarray("clt2", $opcions, getDolGlobalString('MAIN_INFO_LOCALTAX_CALC2'));
  753. print "</div>";
  754. print "</td></tr>\n";
  755. 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>";
  756. print '<td colspan="2">';
  757. print "<div>";
  758. $tooltiphelp = $langs->transcountry("LocalTax2IsNotUsedExample", $mysoc->country_code);
  759. $tooltiphelp = ($tooltiphelp != "LocalTax2IsNotUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsNotUsedExample", $mysoc->country_code)."</i>\n" : "");
  760. print "<label for=\"nolt2\">".$form->textwithpicto($langs->transcountry("LocalTax2IsNotUsedDesc", $mysoc->country_code), $tooltiphelp)."</label>";
  761. print "</div>";
  762. print "</td></tr>\n";
  763. } else {
  764. if (empty($mysoc->country_code)) {
  765. print '<tr class="oddeven nohover"><td class="">'.$countrynotdefined.'</td><td></td><td></td></tr>';
  766. } else {
  767. 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>';
  768. }
  769. }
  770. print "</table>";
  771. // Tax stamp
  772. print '<br>';
  773. print '<table class="noborder centpercent editmode">';
  774. print '<tr class="liste_titre">';
  775. print '<td>'.$form->textwithpicto($langs->trans("RevenueStamp"), $langs->trans("RevenueStampDesc")).'</td><td></td>';
  776. print '<td class="right">&nbsp;</td>';
  777. print "</tr>\n";
  778. if ($mysoc->useRevenueStamp()) {
  779. // Note: When option is not set, it must not appears as set on on, because there is no default value for this option
  780. print '<tr class="oddeven"><td>';
  781. print $langs->trans("UseRevenueStamp");
  782. print "</td>";
  783. print '<td colspan="2">';
  784. print $langs->trans("UseRevenueStampExample", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryRevenueStamp"));
  785. print "</td></tr>\n";
  786. } else {
  787. if (empty($mysoc->country_code)) {
  788. print '<tr class="oddeven nohover"><td class="">'.$countrynotdefined.'</td><td></td><td></td></tr>';
  789. } else {
  790. 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>';
  791. }
  792. }
  793. print "</table>";
  794. // AADE webservices credentials, applicable only for Greece
  795. if ($mysoc->country_code == 'GR') {
  796. print load_fiche_titre($langs->trans("AADEWebserviceCredentials"), '', '');
  797. print '<table class="noborder centpercent editmode">';
  798. print '<tr class="liste_titre">';
  799. print '<td>'.$langs->trans("AccountParameter").'</td>';
  800. print '<td>'.$langs->trans("Value").'</td>';
  801. print '<td></td>';
  802. print "</tr>\n";
  803. print '<tr class="oddeven"><td>';
  804. print '<span class="titlefield fieldrequired">'.$langs->trans("MYDATA_AADE_USER").'</span></td><td>';
  805. print '<input class="minwidth300" type="text" name="MYDATA_AADE_USER" value="'.getDolGlobalString('MYDATA_AADE_USER').'"';
  806. print '</td><td></td></tr>';
  807. print '<tr class="oddeven"><td>';
  808. print '<span class="titlefield fieldrequired">'.$langs->trans("MYDATA_AADE_KEY").'</span></td><td>';
  809. print '<input class="minwidth300" type="text" name="MYDATA_AADE_KEY" value="'.getDolGlobalString('MYDATA_AADE_KEY').'"';
  810. print '</td><td></td></tr>';
  811. print '<tr class="oddeven"><td>';
  812. print '<span class="titlefield fieldrequired">'.$langs->trans("AADE_WEBSERVICE_USER").'</span></td><td>';
  813. print '<input class="minwidth300" type="text" name="AADE_WEBSERVICE_USER" value="'.getDolGlobalString('AADE_WEBSERVICE_USER').'"';
  814. print '</td><td></td></tr>';
  815. print '<tr class="oddeven"><td>';
  816. print '<span class="titlefield fieldrequired">'.$langs->trans("AADE_WEBSERVICE_KEY").'</span></td><td>';
  817. print '<input class="minwidth300" type="text" name="AADE_WEBSERVICE_KEY" value="'.getDolGlobalString('AADE_WEBSERVICE_KEY').'"';
  818. print '</td><td></td></tr>';
  819. print '<br>';
  820. print "</table>";
  821. }
  822. print $form->buttonsSaveCancel("Save", '', array(), false, 'reposition');
  823. print '</form>';
  824. // End of page
  825. llxFooter();
  826. $db->close();