company.php 44 KB

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