company.php 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852
  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("object", '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. if (!$error) {
  205. if (GETPOST('save')) { // To avoid to show message when we juste switch the country that resubmit the form.
  206. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  207. }
  208. $db->commit();
  209. } else {
  210. $db->rollback();
  211. }
  212. if ($action != 'updateedit' && !$error) {
  213. header("Location: ".$_SERVER["PHP_SELF"]);
  214. exit;
  215. }
  216. }
  217. if ($action == 'addthumb' || $action == 'addthumbsquarred') { // Regenerate thumbs
  218. if (file_exists($conf->mycompany->dir_output.'/logos/'.$_GET["file"])) {
  219. $isimage = image_format_supported($_GET["file"]);
  220. // Create thumbs of logo
  221. if ($isimage > 0) {
  222. $constant = "MAIN_INFO_SOCIETE_LOGO";
  223. if ($action == 'addthumbsquarred') {
  224. $constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED";
  225. }
  226. $reg = array();
  227. // Create thumbs
  228. //$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...
  229. // Create small thumb. Used on logon for example
  230. $imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthsmall, $maxheightsmall, '_small', $quality);
  231. if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg)) {
  232. $imgThumbSmall = $reg[1]; // Save only basename
  233. dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity);
  234. } else {
  235. dol_syslog($imgThumbSmall);
  236. }
  237. // Create mini thumbs. Used on menu or for setup page for example
  238. $imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthmini, $maxheightmini, '_mini', $quality);
  239. if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg)) {
  240. $imgThumbMini = $reg[1]; // Save only basename
  241. dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity);
  242. } else {
  243. dol_syslog($imgThumbMini);
  244. }
  245. header("Location: ".$_SERVER["PHP_SELF"]);
  246. exit;
  247. } else {
  248. $error++;
  249. $langs->load("errors");
  250. setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors');
  251. dol_syslog($langs->transnoentities("ErrorBadImageFormat"), LOG_INFO);
  252. }
  253. } else {
  254. $error++;
  255. $langs->load("errors");
  256. setEventMessages($langs->trans("ErrorFileDoesNotExists", GETPOST("file")), null, 'errors');
  257. dol_syslog($langs->transnoentities("ErrorFileDoesNotExists", GETPOST("file")), LOG_WARNING);
  258. }
  259. }
  260. if ($action == 'removelogo' || $action == 'removelogosquarred') {
  261. $constant = "MAIN_INFO_SOCIETE_LOGO";
  262. if ($action == 'removelogosquarred') {
  263. $constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED";
  264. }
  265. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  266. $logofilename = $mysoc->logo;
  267. $logofilenamebis = $mysoc->logo_squarred;
  268. if ($action == 'removelogosquarred') {
  269. $logofilename = $mysoc->logo_squarred;
  270. $logofilenamebis = $mysoc->logo;
  271. }
  272. $logofile = $conf->mycompany->dir_output.'/logos/'.$logofilename;
  273. if ($logofilename != '' && $logofilename != $logofilenamebis) {
  274. dol_delete_file($logofile);
  275. }
  276. dolibarr_del_const($db, $constant, $conf->entity);
  277. if ($action == 'removelogosquarred') {
  278. $mysoc->logo_squarred = '';
  279. } else {
  280. $mysoc->logo = '';
  281. }
  282. $logofilename = $mysoc->logo_small;
  283. $logofilenamebis = $mysoc->logo_squarred_small;
  284. if ($action == 'removelogosquarred') {
  285. $logofilename = $mysoc->logo_squarred_small;
  286. $logofilenamebis = $mysoc->logo_small;
  287. }
  288. $logosmallfile = $conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename;
  289. if ($logofilename != '' && $logofilename != $logofilenamebis) {
  290. dol_delete_file($logosmallfile);
  291. }
  292. dolibarr_del_const($db, $constant."_SMALL", $conf->entity);
  293. if ($action == 'removelogosquarred') {
  294. $mysoc->logo_squarred_small = '';
  295. } else {
  296. $mysoc->logo_small = '';
  297. }
  298. $logofilename = $mysoc->logo_mini;
  299. $logofilenamebis = $mysoc->logo_squarred_mini;
  300. if ($action == 'removelogosquarred') {
  301. $logofilename = $mysoc->logo_squarred_mini;
  302. $logofilenamebis = $mysoc->logo_mini;
  303. }
  304. $logominifile = $conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename;
  305. if ($logofilename != '' && $logofilename != $logofilenamebis) {
  306. dol_delete_file($logominifile);
  307. }
  308. dolibarr_del_const($db, $constant."_MINI", $conf->entity);
  309. if ($action == 'removelogosquarred') {
  310. $mysoc->logo_squarred_mini = '';
  311. } else {
  312. $mysoc->logo_mini = '';
  313. }
  314. }
  315. /*
  316. * View
  317. */
  318. $wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
  319. llxHeader('', $langs->trans("Setup"), $wikihelp);
  320. $form = new Form($db);
  321. $formother = new FormOther($db);
  322. $formcompany = new FormCompany($db);
  323. $countrynotdefined = '<span class="error">'.$langs->trans("ErrorSetACountryFirst").' <a href="#trzipbeforecountry">('.$langs->trans("SeeAbove").')</a></span>';
  324. print load_fiche_titre($langs->trans("CompanyFoundation"), '', 'title_setup');
  325. $head = company_admin_prepare_head();
  326. print dol_get_fiche_head($head, 'company', '', -1, '');
  327. print '<span class="opacitymedium">'.$langs->trans("CompanyFundationDesc", $langs->transnoentities("Save"))."</span><br>\n";
  328. print "<br><br>\n";
  329. // Edit parameters
  330. if (!empty($conf->use_javascript_ajax)) {
  331. print "\n".'<script type="text/javascript">';
  332. print '$(document).ready(function () {
  333. $("#selectcountry_id").change(function() {
  334. document.form_index.action.value="updateedit";
  335. document.form_index.submit();
  336. });
  337. });';
  338. print '</script>'."\n";
  339. }
  340. print '<form enctype="multipart/form-data" method="POST" action="'.$_SERVER["PHP_SELF"].'" name="form_index">';
  341. print '<input type="hidden" name="token" value="'.newToken().'">';
  342. print '<input type="hidden" name="action" value="update">';
  343. print '<table class="noborder centpercent editmode">';
  344. print '<tr class="liste_titre"><th class="titlefieldcreate wordbreak">'.$langs->trans("CompanyInfo").'</th><th>'.$langs->trans("Value").'</th></tr>'."\n";
  345. // Name
  346. print '<tr class="oddeven"><td class="fieldrequired wordbreak"><label for="name">'.$langs->trans("CompanyName").'</label></td><td>';
  347. 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";
  348. // Address
  349. print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_ADDRESS">'.$langs->trans("CompanyAddress").'</label></td><td>';
  350. 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";
  351. // Zip
  352. print '<tr class="oddeven" id="trzipbeforecountry"><td><label for="MAIN_INFO_SOCIETE_ZIP">'.$langs->trans("CompanyZip").'</label></td><td>';
  353. 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";
  354. print '<tr class="oddeven" id="trtownbeforecountry"><td><label for="MAIN_INFO_SOCIETE_TOWN">'.$langs->trans("CompanyTown").'</label></td><td>';
  355. 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";
  356. // Country
  357. print '<tr class="oddeven"><td class="fieldrequired"><label for="selectcountry_id">'.$langs->trans("Country").'</label></td><td>';
  358. print img_picto('', 'globe-americas', 'class="pictofixedwidth"');
  359. print $form->select_country($mysoc->country_id, 'country_id', '', 0);
  360. if ($user->admin) {
  361. print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
  362. }
  363. print '</td></tr>'."\n";
  364. print '<tr class="oddeven"><td class="wordbreak"><label for="state_id">'.$langs->trans("State").'</label></td><td>';
  365. $state_id = 0;
  366. if (!empty($conf->global->MAIN_INFO_SOCIETE_STATE)) {
  367. $tmp = explode(':', $conf->global->MAIN_INFO_SOCIETE_STATE);
  368. $state_id = $tmp[0];
  369. }
  370. print img_picto('', 'state', 'class="pictofixedwidth"');
  371. print $formcompany->select_state($state_id, $mysoc->country_code, 'state_id', 'maxwidth200onsmartphone minwidth300');
  372. print '</td></tr>'."\n";
  373. // Currency
  374. print '<tr class="oddeven"><td><label for="currency">'.$langs->trans("CompanyCurrency").'</label></td><td>';
  375. print img_picto('', 'multicurrency', 'class="pictofixedwidth"');
  376. print $form->selectCurrency($conf->currency, "currency");
  377. print '</td></tr>'."\n";
  378. // Phone
  379. print '<tr class="oddeven"><td><label for="phone">'.$langs->trans("Phone").'</label></td><td>';
  380. print img_picto('', 'object_phoning', '', false, 0, 0, '', 'pictofixedwidth');
  381. 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>';
  382. print '</td></tr>'."\n";
  383. // Fax
  384. print '<tr class="oddeven"><td><label for="fax">'.$langs->trans("Fax").'</label></td><td>';
  385. print img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'pictofixedwidth');
  386. 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>';
  387. print '</td></tr>'."\n";
  388. // Email
  389. print '<tr class="oddeven"><td><label for="email">'.$langs->trans("EMail").'</label></td><td>';
  390. print img_picto('', 'object_email', '', false, 0, 0, '', 'pictofixedwidth');
  391. 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>';
  392. print '</td></tr>'."\n";
  393. // Web
  394. print '<tr class="oddeven"><td><label for="web">'.$langs->trans("Web").'</label></td><td>';
  395. print img_picto('', 'globe', '', false, 0, 0, '', 'pictofixedwidth');
  396. 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>';
  397. print '</td></tr>'."\n";
  398. // Barcode
  399. if (isModEnabled('barcode')) {
  400. print '<tr class="oddeven"><td>';
  401. print '<label for="barcode">'.$langs->trans("Gencod").'</label></td><td>';
  402. print '<span class="fa fa-barcode pictofixedwidth"></span>';
  403. 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>';
  404. print '</td></tr>';
  405. }
  406. // Tooltip for both Logo and LogSquarred
  407. $tooltiplogo = $langs->trans('AvailableFormats').' : png, jpg, jpeg';
  408. $maxfilesizearray = getMaxFileSizeArray();
  409. $maxmin = $maxfilesizearray['maxmin'];
  410. $tooltiplogo .= ($maxmin > 0) ? '<br>'.$langs->trans('MaxSize').' : '.$maxmin.' '.$langs->trans('Kb') : '';
  411. // Logo
  412. print '<tr class="oddeven"><td><label for="logo">'.$form->textwithpicto($langs->trans("Logo"), $tooltiplogo).'</label></td><td>';
  413. print '<div class="centpercent nobordernopadding valignmiddle "><div class="inline-block marginrightonly">';
  414. if ($maxmin > 0) {
  415. print '<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).'">'; // MAX_FILE_SIZE must precede the field type=file
  416. }
  417. print '<input type="file" class="flat minwidth100 maxwidthinputfileonsmartphone" name="logo" id="logo" accept="image/*">';
  418. print '</div>';
  419. if (!empty($mysoc->logo_small)) {
  420. if (file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) {
  421. print '<div class="inline-block valignmiddle">';
  422. print '<img style="max-height: 80px; max-width: 200px;" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_small).'">';
  423. print '</div>';
  424. } elseif (!empty($mysoc->logo)) {
  425. if (!file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) {
  426. $imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$mysoc->logo, $maxwidthmini, $maxheightmini, '_mini', $quality);
  427. }
  428. $imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$mysoc->logo, $maxwidthmini, $maxheightmini, '_small', $quality);
  429. print '<div class="inline-block valignmiddle">';
  430. print '<img style="max-height: 80px; max-width: 200px;" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.basename($imgThumbSmall)).'">';
  431. print '</div>';
  432. }
  433. print '<div class="inline-block valignmiddle marginrightonly">';
  434. print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogo&token='.newToken().'">'.img_delete($langs->trans("Delete"), '', 'marginleftonly').'</a>';
  435. print '</div>';
  436. } elseif (!empty($mysoc->logo)) {
  437. if (file_exists($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) {
  438. print '<div class="inline-block valignmiddle">';
  439. print '<img style="max-height: 80px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/'.$mysoc->logo).'">';
  440. print '</div>';
  441. 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>';
  442. } else {
  443. print '<div class="inline-block valignmiddle">';
  444. print '<img height="80" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png">';
  445. print '</div>';
  446. }
  447. }
  448. print '</div>';
  449. print '</td></tr>';
  450. // Logo (squarred)
  451. print '<tr class="oddeven"><td><label for="logo_squarred">'.$form->textwithpicto($langs->trans("LogoSquarred"), $tooltiplogo).'</label></td><td>';
  452. print '<div class="centpercent nobordernopadding valignmiddle"><div class="inline-block marginrightonly">';
  453. $maxfilesizearray = getMaxFileSizeArray();
  454. $maxmin = $maxfilesizearray['maxmin'];
  455. if ($maxmin > 0) {
  456. print '<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).'">'; // MAX_FILE_SIZE must precede the field type=file
  457. }
  458. print '<input type="file" class="flat minwidth100 maxwidthinputfileonsmartphone" name="logo_squarred" id="logo_squarred" accept="image/*">';
  459. print '</div>';
  460. if (!empty($mysoc->logo_squarred_small)) {
  461. if (file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_squarred_small)) {
  462. print '<div class="inline-block valignmiddle marginrightonly">';
  463. print '<img style="max-height: 80px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_squarred_small).'">';
  464. print '</div>';
  465. } elseif (!empty($mysoc->logo_squarred)) {
  466. if (!file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_squarred_mini)) {
  467. $imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$mysoc->logo_squarred, $maxwidthmini, $maxheightmini, '_mini', $quality);
  468. }
  469. $imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$mysoc->logo_squarred, $maxwidthmini, $maxheightmini, '_small', $quality);
  470. print '<div class="inline-block valignmiddle">';
  471. print '<img style="max-height: 80px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/thumbs/'.basename($imgThumbSmall)).'">';
  472. print '</div>';
  473. }
  474. 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>';
  475. } elseif (!empty($mysoc->logo_squarred)) {
  476. if (file_exists($conf->mycompany->dir_output.'/logos/'.$mysoc->logo_squarred)) {
  477. print '<div class="inline-block valignmiddle">';
  478. print '<img style="max-height: 80px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/'.$mysoc->logo_squarred).'">';
  479. print '</div>';
  480. 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>';
  481. } else {
  482. print '<div class="inline-block valignmiddle">';
  483. print '<img height="80" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png">';
  484. print '</div>';
  485. }
  486. }
  487. print '</div>';
  488. print '</td></tr>';
  489. // Note
  490. print '<tr class="oddeven"><td class="tdtop"><label for="note">'.$langs->trans("Note").'</label></td><td>';
  491. 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>';
  492. print '</td></tr>';
  493. print '</table>';
  494. print '<br>';
  495. // IDs of the company (country-specific)
  496. print '<div class="div-table-responsive-no-min">';
  497. print '<table class="noborder centpercent editmode">';
  498. print '<tr class="liste_titre"><td class="titlefieldcreate wordbreak">'.$langs->trans("CompanyIds").'</td><td>'.$langs->trans("Value").'</td></tr>';
  499. $langs->load("companies");
  500. // Managing Director(s)
  501. print '<tr class="oddeven"><td><label for="director">'.$langs->trans("ManagingDirectors").'</label></td><td>';
  502. 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>';
  503. // GDPR contact
  504. print '<tr class="oddeven"><td>';
  505. print $form->textwithpicto($langs->trans("GDPRContact"), $langs->trans("GDPRContactDesc"));
  506. print '</td><td>';
  507. 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>';
  508. // Capital
  509. print '<tr class="oddeven"><td><label for="capital">'.$langs->trans("Capital").'</label></td><td>';
  510. 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>';
  511. // Juridical Status
  512. print '<tr class="oddeven"><td><label for="forme_juridique_code">'.$langs->trans("JuridicalStatus").'</label></td><td>';
  513. if ($mysoc->country_code) {
  514. print $formcompany->select_juridicalstatus($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE, $mysoc->country_code, '', 'forme_juridique_code');
  515. } else {
  516. print $countrynotdefined;
  517. }
  518. print '</td></tr>';
  519. // ProfId1
  520. if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-') {
  521. print '<tr class="oddeven"><td><label for="profid1">'.$langs->transcountry("ProfId1", $mysoc->country_code).'</label></td><td>';
  522. if (!empty($mysoc->country_code)) {
  523. print '<input name="siren" id="profid1" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_SIREN) ? $conf->global->MAIN_INFO_SIREN : '').'">';
  524. } else {
  525. print $countrynotdefined;
  526. }
  527. print '</td></tr>';
  528. }
  529. // ProfId2
  530. if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-') {
  531. print '<tr class="oddeven"><td><label for="profid2">'.$langs->transcountry("ProfId2", $mysoc->country_code).'</label></td><td>';
  532. if (!empty($mysoc->country_code)) {
  533. print '<input name="siret" id="profid2" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_SIRET) ? $conf->global->MAIN_INFO_SIRET : '').'">';
  534. } else {
  535. print $countrynotdefined;
  536. }
  537. print '</td></tr>';
  538. }
  539. // ProfId3
  540. if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-') {
  541. print '<tr class="oddeven"><td><label for="profid3">'.$langs->transcountry("ProfId3", $mysoc->country_code).'</label></td><td>';
  542. if (!empty($mysoc->country_code)) {
  543. print '<input name="ape" id="profid3" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_APE) ? $conf->global->MAIN_INFO_APE : '').'">';
  544. } else {
  545. print $countrynotdefined;
  546. }
  547. print '</td></tr>';
  548. }
  549. // ProfId4
  550. if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-') {
  551. print '<tr class="oddeven"><td><label for="profid4">'.$langs->transcountry("ProfId4", $mysoc->country_code).'</label></td><td>';
  552. if (!empty($mysoc->country_code)) {
  553. print '<input name="rcs" id="profid4" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_RCS) ? $conf->global->MAIN_INFO_RCS : '').'">';
  554. } else {
  555. print $countrynotdefined;
  556. }
  557. print '</td></tr>';
  558. }
  559. // ProfId5
  560. if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-') {
  561. print '<tr class="oddeven"><td><label for="profid5">'.$langs->transcountry("ProfId5", $mysoc->country_code).'</label></td><td>';
  562. if (!empty($mysoc->country_code)) {
  563. 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 : '').'">';
  564. } else {
  565. print $countrynotdefined;
  566. }
  567. print '</td></tr>';
  568. }
  569. // ProfId6
  570. if ($langs->transcountry("ProfId6", $mysoc->country_code) != '-') {
  571. print '<tr class="oddeven"><td><label for="profid6">'.$langs->transcountry("ProfId6", $mysoc->country_code).'</label></td><td>';
  572. if (!empty($mysoc->country_code)) {
  573. 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 : '').'">';
  574. } else {
  575. print $countrynotdefined;
  576. }
  577. print '</td></tr>';
  578. }
  579. // Intra-community VAT number
  580. print '<tr class="oddeven"><td><label for="intra_vat">'.$langs->trans("VATIntra").'</label></td><td>';
  581. print '<input name="tva" id="intra_vat" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_TVAINTRA) ? $conf->global->MAIN_INFO_TVAINTRA : '').'">';
  582. print '</td></tr>';
  583. // Object of the company
  584. print '<tr class="oddeven"><td><label for="object">'.$langs->trans("CompanyObject").'</label></td><td>';
  585. print '<textarea class="flat quatrevingtpercent" name="object" id="object" rows="'.ROWS_5.'">'.(!empty($conf->global->MAIN_INFO_SOCIETE_OBJECT) ? $conf->global->MAIN_INFO_SOCIETE_OBJECT : '').'</textarea></td></tr>';
  586. print '</td></tr>';
  587. print '</table>';
  588. print '</div>';
  589. // Fiscal year start
  590. print '<br>';
  591. print '<table class="noborder centpercent editmode">';
  592. print '<tr class="liste_titre">';
  593. print '<td class="titlefieldcreate">'.$langs->trans("FiscalYearInformation").'</td><td>'.$langs->trans("Value").'</td>';
  594. print "</tr>\n";
  595. print '<tr class="oddeven"><td><label for="SOCIETE_FISCAL_MONTH_START">'.$langs->trans("FiscalMonthStart").'</label></td><td>';
  596. 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>';
  597. print "</table>";
  598. print '<br>';
  599. // Sales taxes (VAT, IRPF, ...)
  600. print load_fiche_titre($langs->trans("TypeOfSaleTaxes"), '', 'object_payment');
  601. print '<table class="noborder centpercent editmode">';
  602. print '<tr class="liste_titre">';
  603. print '<td class="titlefieldcreate">'.$langs->trans("VATManagement").'</td><td>'.$langs->trans("Description").'</td>';
  604. print '<td class="right">&nbsp;</td>';
  605. print "</tr>\n";
  606. // Main tax
  607. 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>";
  608. print '<td colspan="2">';
  609. $tooltiphelp = '';
  610. if ($mysoc->country_code == 'FR') {
  611. $tooltiphelp = '<i>'.$langs->trans("Example").': '.$langs->trans("VATIsUsedExampleFR")."</i>";
  612. }
  613. print '<label for="use_vat">'.$form->textwithpicto($langs->trans("VATIsUsedDesc"), $tooltiphelp)."</label>";
  614. print "</td></tr>\n";
  615. 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>";
  616. print '<td colspan="2">';
  617. $tooltiphelp = '';
  618. if ($mysoc->country_code == 'FR') {
  619. $tooltiphelp = "<i>".$langs->trans("Example").': '.$langs->trans("VATIsNotUsedExampleFR")."</i>\n";
  620. }
  621. print '<label for="no_vat">'.$form->textwithpicto($langs->trans("VATIsNotUsedDesc"), $tooltiphelp)."</label>";
  622. print "</td></tr>\n";
  623. print "</table>";
  624. // Second tax
  625. print '<br>';
  626. print '<table class="noborder centpercent editmode">';
  627. print '<tr class="liste_titre">';
  628. print '<td class="titlefieldcreate">'.$form->textwithpicto($langs->transcountry("LocalTax1Management", $mysoc->country_code), $langs->transcountry("LocalTax1IsUsedDesc", $mysoc->country_code)).'</td><td>'.$langs->trans("Description").'</td>';
  629. print '<td class="right">&nbsp;</td>';
  630. print "</tr>\n";
  631. if ($mysoc->useLocalTax(1)) {
  632. // Note: When option is not set, it must not appears as set on on, because there is no default value for this option
  633. 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>";
  634. print '<td colspan="2">';
  635. print '<div class="nobordernopadding">';
  636. $tooltiphelp = $langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code);
  637. $tooltiphelp = ($tooltiphelp != "LocalTax1IsUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code)."</i>\n" : "");
  638. print $form->textwithpicto($langs->transcountry("LocalTax1IsUsedDesc", $mysoc->country_code), $tooltiphelp);
  639. if (!isOnlyOneLocalTax(1)) {
  640. print '<br><label for="lt1">'.$langs->trans("LTRate").'</label>: ';
  641. $formcompany->select_localtax(1, $conf->global->MAIN_INFO_VALUE_LOCALTAX1, "lt1");
  642. }
  643. $opcions = array($langs->trans("CalcLocaltax1").' '.$langs->trans("CalcLocaltax1Desc"), $langs->trans("CalcLocaltax2").' - '.$langs->trans("CalcLocaltax2Desc"), $langs->trans("CalcLocaltax3").' - '.$langs->trans("CalcLocaltax3Desc"));
  644. print '<br><label for="clt1">'.$langs->trans("CalcLocaltax").'</label>: ';
  645. print $form->selectarray("clt1", $opcions, $conf->global->MAIN_INFO_LOCALTAX_CALC1);
  646. print "</div>";
  647. print "</td></tr>\n";
  648. 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>";
  649. print '<td colspan="2">';
  650. $tooltiphelp = $langs->transcountry("LocalTax1IsNotUsedExample", $mysoc->country_code);
  651. $tooltiphelp = ($tooltiphelp != "LocalTax1IsNotUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsNotUsedExample", $mysoc->country_code)."</i>\n" : "");
  652. print $form->textwithpicto($langs->transcountry("LocalTax1IsNotUsedDesc", $mysoc->country_code), $tooltiphelp);
  653. print "</td></tr>\n";
  654. } else {
  655. if (empty($mysoc->country_code)) {
  656. print '<tr class="oddeven nohover"><td class="">'.$countrynotdefined.'</td><td></td><td></td></tr>';
  657. } else {
  658. 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>';
  659. }
  660. }
  661. print "</table>";
  662. // Third tax system
  663. print '<br>';
  664. print '<table class="noborder centpercent editmode">';
  665. print '<tr class="liste_titre">';
  666. print '<td class="titlefieldcreate">'.$form->textwithpicto($langs->transcountry("LocalTax2Management", $mysoc->country_code), $langs->transcountry("LocalTax2IsUsedDesc", $mysoc->country_code)).'</td><td>'.$langs->trans("Description").'</td>';
  667. print '<td class="right">&nbsp;</td>';
  668. print "</tr>\n";
  669. if ($mysoc->useLocalTax(2)) {
  670. // Note: When option is not set, it must not appears as set on on, because there is no default value for this option
  671. 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>";
  672. print '<td colspan="2">';
  673. print '<div class="nobordernopadding">';
  674. print '<label for="lt2">'.$langs->transcountry("LocalTax2IsUsedDesc", $mysoc->country_code)."</label>";
  675. $tooltiphelp = $langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code);
  676. $tooltiphelp = ($tooltiphelp != "LocalTax2IsUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code)."</i>\n" : "");
  677. if (!isOnlyOneLocalTax(2)) {
  678. print '<br><label for="lt2">'.$langs->trans("LTRate").'</label>: ';
  679. $formcompany->select_localtax(2, $conf->global->MAIN_INFO_VALUE_LOCALTAX2, "lt2");
  680. }
  681. print '<br><label for="clt2">'.$langs->trans("CalcLocaltax").'</label>: ';
  682. print $form->selectarray("clt2", $opcions, $conf->global->MAIN_INFO_LOCALTAX_CALC2);
  683. print "</div>";
  684. print "</td></tr>\n";
  685. 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>";
  686. print '<td colspan="2">';
  687. print "<div>";
  688. $tooltiphelp = $langs->transcountry("LocalTax2IsNotUsedExample", $mysoc->country_code);
  689. $tooltiphelp = ($tooltiphelp != "LocalTax2IsNotUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsNotUsedExample", $mysoc->country_code)."</i>\n" : "");
  690. print "<label for=\"nolt2\">".$form->textwithpicto($langs->transcountry("LocalTax2IsNotUsedDesc", $mysoc->country_code), $tooltiphelp)."</label>";
  691. print "</div>";
  692. print "</td></tr>\n";
  693. } else {
  694. if (empty($mysoc->country_code)) {
  695. print '<tr class="oddeven nohover"><td class="">'.$countrynotdefined.'</td><td></td><td></td></tr>';
  696. } else {
  697. 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>';
  698. }
  699. }
  700. print "</table>";
  701. // Tax stamp
  702. print '<br>';
  703. print '<table class="noborder centpercent editmode">';
  704. print '<tr class="liste_titre">';
  705. print '<td>'.$form->textwithpicto($langs->trans("RevenueStamp"), $langs->trans("RevenueStampDesc")).'</td><td>'.$langs->trans("Description").'</td>';
  706. print '<td class="right">&nbsp;</td>';
  707. print "</tr>\n";
  708. if ($mysoc->useRevenueStamp()) {
  709. // Note: When option is not set, it must not appears as set on on, because there is no default value for this option
  710. print '<tr class="oddeven"><td>';
  711. print $langs->trans("UseRevenueStamp");
  712. print "</td>";
  713. print '<td colspan="2">';
  714. print $langs->trans("UseRevenueStampExample", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryRevenueStamp"));
  715. print "</td></tr>\n";
  716. } else {
  717. if (empty($mysoc->country_code)) {
  718. print '<tr class="oddeven nohover"><td class="">'.$countrynotdefined.'</td><td></td><td></td></tr>';
  719. } else {
  720. 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>';
  721. }
  722. }
  723. print "</table>";
  724. print $form->buttonsSaveCancel("Save", '');
  725. print '</form>';
  726. // End of page
  727. llxFooter();
  728. $db->close();