company.php 45 KB

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