company.php 44 KB

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